etiquetas.js 1.0.0-alpha.4 → 1.0.0-alpha.6
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/etiquetas.es.js +1 -1
- package/dist/etiquetas.umd.js +2 -2
- package/dist/etiquetas.umd.js.map +1 -1
- package/dist/{index-BUpKxNQ0.js → index-hPMt3Mo7.js} +199 -199
- package/dist/{index-BUpKxNQ0.js.map → index-hPMt3Mo7.js.map} +1 -1
- package/dist/{index.es-CCAzIpY-.js → index.es-CKhxQJQK.js} +2 -2
- package/dist/{index.es-CCAzIpY-.js.map → index.es-CKhxQJQK.js.map} +1 -1
- package/package.json +1 -1
package/dist/etiquetas.umd.js
CHANGED
|
@@ -337,7 +337,7 @@ function(t){t.__bidiEngine__=t.prototype.__bidiEngine__=function(t){var n,r,i,A,
|
|
|
337
337
|
*
|
|
338
338
|
* This source code is licensed under the MIT license found in the
|
|
339
339
|
* LICENSE file in the root directory of this source tree.
|
|
340
|
-
*/var xL="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},EL=CL.useSyncExternalStore,SL=_L.useRef,FL=_L.useEffect,LL=_L.useMemo,UL=_L.useDebugValue;uL.useSyncExternalStoreWithSelector=function(t,e,n,r,i){var A=SL(null);if(null===A.current){var s={hasValue:!1,value:null};A.current=s}else s=A.current;A=LL(function(){function t(t){if(!o){if(o=!0,A=t,t=r(t),void 0!==i&&s.hasValue){var e=s.value;if(i(e,t))return a=e}return a=t}if(e=a,xL(A,t))return e;var n=r(t);return void 0!==i&&i(e,n)?(A=t,e):(A=t,a=n)}var A,a,o=!1,l=void 0===n?null:n;return[function(){return t(e())},null===l?void 0:function(){return t(l())}]},[e,n,r,i]);var a=EL(t,A[0],A[1]);return FL(function(){s.hasValue=!0,s.value=a},[a]),UL(a),a},hL.exports=uL;const IL=Zc(hL.exports),QL={},{useDebugValue:kL}=cL,{useSyncExternalStoreWithSelector:ML}=IL;let OL=!1;const PL=t=>t;const NL=t=>{"production"!==(QL?"production":void 0)&&"function"!=typeof t&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e="function"==typeof t?(t=>t?FF(t):FF)(t):t,n=(t,n)=>function(t,e=PL,n){"production"!==(QL?"production":void 0)&&n&&!OL&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),OL=!0);const r=ML(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return kL(r),r}(e,t,n);return Object.assign(n,e),n},TL=t=>t?NL(t):NL,DL=TL((t,e)=>({pdfInstance:null,cacheKey:null,labelType:null,isGenerating:!1,progress:0,error:null,currentData:null,currentConfig:null,setPDFInstance:(e,n,r)=>t({pdfInstance:e,cacheKey:n,labelType:r}),setGenerating:e=>t({isGenerating:e}),setProgress:e=>t({progress:e}),setError:e=>t({error:e}),setCurrentData:e=>t({currentData:e}),setCurrentConfig:e=>t({currentConfig:e}),resetPDFInstance:()=>t({pdfInstance:null,cacheKey:null,labelType:null,progress:0,error:null}),reset:()=>t({pdfInstance:null,cacheKey:null,labelType:null,isGenerating:!1,progress:0,error:null,currentData:null,currentConfig:null})})),RL={type:"parts",index:0,specific:!1,dataIndex:null,source:null,otherData:null,category:[]};const HL=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),jL=[.001,0,0,.001,0,0],WL=1.35,VL=1,KL=2,GL=4,zL=16,qL=32,XL=64,YL=128,$L=256,JL={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},ZL="pdfjs_internal_editor_",tU={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101,COMMENT:102},eU={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},nU=0,rU=1,iU=2,AU=3,sU=3,aU=4,oU={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},lU={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},cU=1,hU=2,uU=3,dU=4,fU=5,pU={ERRORS:0,WARNINGS:1,INFOS:5},gU={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},mU=0,wU=1,vU=2,yU=3;let bU=pU.WARNINGS;function BU(){return bU}function _U(t){bU>=pU.INFOS&&console.log(`Info: ${t}`)}function CU(t){bU>=pU.WARNINGS&&console.log(`Warning: ${t}`)}function xU(t){throw new Error(t)}function EU(t,e){t||xU(e)}function SU(t,e=null,n=null){if(!t)return null;if(n&&"string"==typeof t){if(n.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);(null==e?void 0:e.length)>=2&&(t=`http://${t}`)}if(n.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch(hw){}}const r=e?URL.parse(t,e):URL.parse(t);return function(t){switch(null==t?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r)?r:null}function FU(t,e,n=!1){const r=URL.parse(t);return r?(r.hash=e,r.href):n&&SU(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function LU(t,e,n,r=!1){return Object.defineProperty(t,e,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}const UU=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class IU extends UU{constructor(t,e){super(t,"PasswordException"),this.code=e}}class QU extends UU{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class kU extends UU{constructor(t){super(t,"InvalidPDFException")}}class MU extends UU{constructor(t,e,n){super(t,"ResponseException"),this.status=e,this.missing=n}}class OU extends UU{constructor(t){super(t,"FormatError")}}class PU extends UU{constructor(t){super(t,"AbortException")}}function NU(t){"object"==typeof t&&void 0!==(null==t?void 0:t.length)||xU("Invalid argument for bytesToString");const e=t.length,n=8192;if(e<n)return String.fromCharCode.apply(null,t);const r=[];for(let i=0;i<e;i+=n){const A=Math.min(i+n,e),s=t.subarray(i,A);r.push(String.fromCharCode.apply(null,s))}return r.join("")}function TU(t){"string"!=typeof t&&xU("Invalid argument for stringToBytes");const e=t.length,n=new Uint8Array(e);for(let r=0;r<e;++r)n[r]=255&t.charCodeAt(r);return n}class DU{static get isLittleEndian(){return LU(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return LU(this,"isEvalSupported",function(){try{return new Function(""),!0}catch(hw){return!1}}())}static get isOffscreenCanvasSupported(){return LU(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return LU(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){const{platform:t,userAgent:e}=navigator;return LU(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){var t,e;return LU(this,"isCSSRoundSupported",null==(e=null==(t=globalThis.CSS)?void 0:t.supports)?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const RU=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class HU{static makeHexColor(t,e,n){return`#${RU[t]}${RU[e]}${RU[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,n=0){const r=t[n],i=t[n+1];t[n]=r*e[0]+i*e[2]+e[4],t[n+1]=r*e[1]+i*e[3]+e[5]}static applyTransformToBezier(t,e,n=0){const r=e[0],i=e[1],A=e[2],s=e[3],a=e[4],o=e[5];for(let l=0;l<6;l+=2){const e=t[n+l],c=t[n+l+1];t[n+l]=e*r+c*A+a,t[n+l+1]=e*i+c*s+o}}static applyInverseTransform(t,e){const n=t[0],r=t[1],i=e[0]*e[3]-e[1]*e[2];t[0]=(n*e[3]-r*e[2]+e[2]*e[5]-e[4]*e[3])/i,t[1]=(-n*e[1]+r*e[0]+e[4]*e[1]-e[5]*e[0])/i}static axialAlignedBoundingBox(t,e,n){const r=e[0],i=e[1],A=e[2],s=e[3],a=e[4],o=e[5],l=t[0],c=t[1],h=t[2],u=t[3];let d=r*l+a,f=d,p=r*h+a,g=p,m=s*c+o,w=m,v=s*u+o,y=v;if(0!==i||0!==A){const t=i*l,e=i*h,n=A*c,r=A*u;d+=n,g+=n,p+=r,f+=r,m+=t,y+=t,v+=e,w+=e}n[0]=Math.min(n[0],d,p,f,g),n[1]=Math.min(n[1],m,v,w,y),n[2]=Math.max(n[2],d,p,f,g),n[3]=Math.max(n[3],m,v,w,y)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const n=t[0],r=t[1],i=t[2],A=t[3],s=Uc(n,2)+Uc(r,2),a=n*i+r*A,o=Uc(i,2)+Uc(A,2),l=(s+o)/2,c=Math.sqrt(Uc(l,2)-(s*o-Uc(a,2)));e[0]=Math.sqrt(l+c||1),e[1]=Math.sqrt(l-c||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const 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;const i=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),A=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return i>A?null:[n,i,r,A]}static pointBoundingBox(t,e,n){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}static rectBoundingBox(t,e,n,r,i){i[0]=Math.min(i[0],t,n),i[1]=Math.min(i[1],e,r),i[2]=Math.max(i[2],t,n),i[3]=Math.max(i[3],e,r)}static bezierBoundingBox(t,e,r,A,s,a,o,l,c){c[0]=Math.min(c[0],t,o),c[1]=Math.min(c[1],e,l),c[2]=Math.max(c[2],t,o),c[3]=Math.max(c[3],e,l),Rc(this,n,i).call(this,t,r,s,o,e,A,a,l,3*(3*(r-s)-t+o),6*(t-2*r+s),3*(r-t),c),Rc(this,n,i).call(this,t,r,s,o,e,A,a,l,3*(3*(A-a)-e+l),6*(e-2*A+a),3*(A-e),c)}}n=new WeakSet,r=function(t,e,n,r,i,A,s,a,o,l){if(o<=0||o>=1)return;const c=1-o,h=o*o,u=h*o,d=c*(c*(c*t+3*o*e)+3*h*n)+u*r,f=c*(c*(c*i+3*o*A)+3*h*s)+u*a;l[0]=Math.min(l[0],d),l[1]=Math.min(l[1],f),l[2]=Math.max(l[2],d),l[3]=Math.max(l[3],f)},i=function(t,e,i,A,s,a,o,l,c,h,u,d){if(Math.abs(c)<1e-12)return void(Math.abs(h)>=1e-12&&Rc(this,n,r).call(this,t,e,i,A,s,a,o,l,-u/h,d));const f=Uc(h,2)-4*u*c;if(f<0)return;const p=Math.sqrt(f),g=2*c;Rc(this,n,r).call(this,t,e,i,A,s,a,o,l,(-h+p)/g,d),Rc(this,n,r).call(this,t,e,i,A,s,a,o,l,(-h-p)/g,d)},Tc(HU,n);let jU=null,WU=null;function VU(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),NU(t)}const KU="pdfjs_internal_id_";function GU(t,e,n){return Math.min(Math.max(t,e),n)}function zU(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(NU(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(n=>{n(t(...e))})}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});const qU="http://www.w3.org/2000/svg",XU=class{};Oc(XU,"CSS",96),Oc(XU,"PDF",72),Oc(XU,"PDF_TO_CSS_UNITS",XU.CSS/XU.PDF);let YU=XU;function $U(t,e="text"){return Wc(this,null,function*(){if(rI(t,document.baseURI)){const n=yield fetch(t);if(!n.ok)throw new Error(n.statusText);switch(e){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise((n,r)=>{const i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(200!==i.status&&0!==i.status)r(new Error(i.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void n(i.response)}n(i.responseText)}},i.send(null)})})}class JU{constructor({viewBox:t,userUnit:e,scale:n,rotation:r,offsetX:i=0,offsetY:A=0,dontFlip:s=!1}){this.viewBox=t,this.userUnit=e,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=A,n*=e;const a=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let l,c,h,u,d,f,p,g;switch((r%=360)<0&&(r+=360),r){case 180:l=-1,c=0,h=0,u=1;break;case 90:l=0,c=1,h=1,u=0;break;case 270:l=0,c=-1,h=-1,u=0;break;case 0:l=1,c=0,h=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}s&&(h=-h,u=-u),0===l?(d=Math.abs(o-t[1])*n+i,f=Math.abs(a-t[0])*n+A,p=(t[3]-t[1])*n,g=(t[2]-t[0])*n):(d=Math.abs(a-t[0])*n+i,f=Math.abs(o-t[1])*n+A,p=(t[2]-t[0])*n,g=(t[3]-t[1])*n),this.transform=[l*n,c*n,h*n,u*n,d-l*n*a-h*n*o,f-c*n*a-u*n*o],this.width=p,this.height=g}get rawDims(){const t=this.viewBox;return LU(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:n=this.offsetX,offsetY:r=this.offsetY,dontFlip:i=!1}={}){return new JU({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:r,dontFlip:i})}convertToViewportPoint(t,e){const n=[t,e];return HU.applyTransform(n,this.transform),n}convertToViewportRectangle(t){const e=[t[0],t[1]];HU.applyTransform(e,this.transform);const n=[t[2],t[3]];return HU.applyTransform(n,this.transform),[e[0],e[1],n[0],n[1]]}convertToPdfPoint(t,e){const n=[t,e];return HU.applyInverseTransform(n,this.transform),n}}class ZU extends UU{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function tI(t){const e=t.length;let n=0;for(;n<e&&""===t[n].trim();)n++;return"data:"===t.substring(n,n+5).toLowerCase()}function eI(t){return"string"==typeof t&&/\.pdf$/i.test(t)}class nI{constructor(){Oc(this,"started",Object.create(null)),Oc(this,"times",[])}time(t){t in this.started&&CU(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||CU(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:n}of this.times)e=Math.max(n.length,e);for(const{name:n,start:r,end:i}of this.times)t.push(`${n.padEnd(e)} ${i-r}ms\n`);return t.join("")}}function rI(t,e){const n=e?URL.parse(t,e):URL.parse(t);return"http:"===(null==n?void 0:n.protocol)||"https:"===(null==n?void 0:n.protocol)}function iI(t){t.preventDefault()}function AI(t){t.preventDefault(),t.stopPropagation()}class sI{static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;Nc(this,A)||Dc(this,A,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=Nc(this,A).exec(t);if(!e)return null;const n=parseInt(e[1],10);let r=parseInt(e[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(e[3],10);i=i>=1&&i<=31?i:1;let s=parseInt(e[4],10);s=s>=0&&s<=23?s:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let h=parseInt(e[9],10)||0;return h=h>=0&&h<=59?h:0,"-"===l?(s+=c,a+=h):"+"===l&&(s-=c,a-=h),new Date(Date.UTC(n,r,i,s,a,o))}}function aI(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(CU(`Not a valid color format: "${t}"`),[0,0,0])}function oI(t){const{a:e,b:n,c:r,d:i,e:A,f:s}=t.getTransform();return[e,n,r,i,A,s]}function lI(t){const{a:e,b:n,c:r,d:i,e:A,f:s}=t.getTransform().invertSelf();return[e,n,r,i,A,s]}function cI(t,e,n=!1,r=!0){if(e instanceof JU){const{pageWidth:r,pageHeight:i}=e.rawDims,{style:A}=t,s=DU.isCSSRoundSupported,a=`var(--total-scale-factor) * ${r}px`,o=`var(--total-scale-factor) * ${i}px`,l=s?`round(down, ${a}, var(--scale-round-x))`:`calc(${a})`,c=s?`round(down, ${o}, var(--scale-round-y))`:`calc(${o})`;n&&e.rotation%180!=0?(A.width=c,A.height=l):(A.width=l,A.height=c)}r&&t.setAttribute("data-main-rotation",e.rotation)}A=new WeakMap,Tc(sI,A);class hI{constructor(){const{pixelRatio:t}=hI;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,n,r,i=-1){let A=1/0,s=1/0,a=1/0;(n=hI.capPixels(n,i))>0&&(A=Math.sqrt(n/(t*e))),-1!==r&&(s=r/t,a=r/e);const o=Math.min(A,s,a);return(this.sx>o||this.sy>o)&&(this.sx=o,this.sy=o,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const n=Math.ceil(window.screen.availWidth*window.screen.availHeight*Uc(this.pixelRatio,2)*(1+e/100));return t>0?Math.min(t,n):n}return t}}const uI=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"],dI=class t{constructor(e){Tc(this,g),Tc(this,s,null),Tc(this,a,null),Tc(this,o),Tc(this,l,null),Tc(this,c,null),Tc(this,h,null),Tc(this,u,null),Dc(this,o,e),Nc(t,d)||Dc(t,d,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=Dc(this,s,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const n=Nc(this,o)._uiManager._signal;e.addEventListener("contextmenu",iI,{signal:n}),e.addEventListener("pointerdown",Rc(t,f,p),{signal:n});const r=Dc(this,l,document.createElement("div"));r.className="buttons",e.append(r);const i=Nc(this,o).toolbarPosition;if(i){const{style:t}=e,n="ltr"===Nc(this,o)._uiManager.direction?1-i[0]:i[0];t.insetInlineEnd=100*n+"%",t.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return Nc(this,s)}hide(){var t;Nc(this,s).classList.add("hidden"),null==(t=Nc(this,a))||t.hideDropdown()}show(){var t,e;Nc(this,s).classList.remove("hidden"),null==(t=Nc(this,c))||t.shown(),null==(e=Nc(this,h))||e.shown()}addDeleteButton(){const{editorType:e,_uiManager:n}=Nc(this,o),r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",Nc(t,d)[e]),Rc(this,g,v).call(this,r),r.addEventListener("click",t=>{n.delete()},{signal:n._signal}),Nc(this,l).append(r)}addAltText(t){return Wc(this,null,function*(){const e=yield t.render();Rc(this,g,v).call(this,e),Nc(this,l).append(e,Nc(this,g,y)),Dc(this,c,t)})}addComment(t){if(Nc(this,h))return;const e=t.render();e&&(Rc(this,g,v).call(this,e),Nc(this,l).prepend(e,Nc(this,g,y)),Dc(this,h,t),t.toolbar=this)}addColorPicker(t){if(Nc(this,a))return;Dc(this,a,t);const e=t.renderButton();Rc(this,g,v).call(this,e),Nc(this,l).append(e,Nc(this,g,y))}addEditSignatureButton(t){return Wc(this,null,function*(){const e=Dc(this,u,yield t.renderEditButton(Nc(this,o)));Rc(this,g,v).call(this,e),Nc(this,l).append(e,Nc(this,g,y))})}addButton(t,e){return Wc(this,null,function*(){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":yield this.addAltText(e);break;case"editSignature":yield this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e)}})}updateEditSignatureButton(t){Nc(this,u)&&(Nc(this,u).title=t)}remove(){var t;Nc(this,s).remove(),null==(t=Nc(this,a))||t.destroy(),Dc(this,a,null)}};s=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakSet,p=function(t){t.stopPropagation()},g=new WeakSet,m=function(t){Nc(this,o)._focusEventsAllowed=!1,AI(t)},w=function(t){Nc(this,o)._focusEventsAllowed=!0,AI(t)},v=function(t){const e=Nc(this,o)._uiManager._signal;t.addEventListener("focusin",Rc(this,g,m).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",Rc(this,g,w).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",iI,{signal:e})},y=function(){const t=document.createElement("div");return t.className="divider",t},Tc(dI,f),Tc(dI,d,null);let fI=dI;class pI{constructor(t){Tc(this,C),Tc(this,b,null),Tc(this,B,null),Tc(this,_),Dc(this,_,t)}show(t,e,n){const[r,i]=Rc(this,C,E).call(this,e,n),{style:A}=Nc(this,B)||Dc(this,B,Rc(this,C,x).call(this));t.append(Nc(this,B)),A.insetInlineEnd=100*r+"%",A.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){Nc(this,B).remove()}}function gI(t,e,n){for(const r of n)e.addEventListener(r,t[r].bind(t))}b=new WeakMap,B=new WeakMap,_=new WeakMap,C=new WeakSet,x=function(){const t=Dc(this,B,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",iI,{signal:Nc(this,_)._signal});const e=Dc(this,b,document.createElement("div"));return e.className="buttons",t.append(e),Rc(this,C,S).call(this),t},E=function(t,e){let n=0,r=0;for(const i of t){const t=i.y+i.height;if(t<n)continue;const A=i.x+(e?i.width:0);t>n?(r=A,n=t):e?A>r&&(r=A):A<r&&(r=A)}return[e?1-r:r,n]},S=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=Nc(this,_)._signal;t.addEventListener("contextmenu",iI,{signal:n}),t.addEventListener("click",()=>{Nc(this,_).highlightSelection("floating_button")},{signal:n}),Nc(this,b).append(t)};class mI{constructor(){Tc(this,F,0)}get id(){return`${ZL}${Hc(this,F)._++}`}}F=new WeakMap;const wI=class{constructor(){Tc(this,Q),Tc(this,L,VU()),Tc(this,U,0),Tc(this,I,null)}static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return LU(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}getFromFile(t){return Wc(this,null,function*(){const{lastModified:e,name:n,size:r,type:i}=t;return Rc(this,Q,k).call(this,`${e}_${n}_${r}_${i}`,t)})}getFromUrl(t){return Wc(this,null,function*(){return Rc(this,Q,k).call(this,t,t)})}getFromBlob(t,e){return Wc(this,null,function*(){const n=yield e;return Rc(this,Q,k).call(this,t,n)})}getFromId(t){return Wc(this,null,function*(){Nc(this,I)||Dc(this,I,new Map);const e=Nc(this,I).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)})}getFromCanvas(t,e){Nc(this,I)||Dc(this,I,new Map);let n=Nc(this,I).get(t);if(null==n?void 0:n.bitmap)return n.refCounter+=1,n;const r=new OffscreenCanvas(e.width,e.height);return r.getContext("2d").drawImage(e,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${Nc(this,L)}_${Hc(this,U)._++}`,refCounter:1,isSvg:!1},Nc(this,I).set(t,n),Nc(this,I).set(n.id,n),n}getSvgUrl(t){const e=Nc(this,I).get(t);return(null==e?void 0:e.isSvg)?e.svgUrl:null}deleteId(t){var e;Nc(this,I)||Dc(this,I,new Map);const n=Nc(this,I).get(t);if(!n)return;if(n.refCounter-=1,0!==n.refCounter)return;const{bitmap:r}=n;if(!n.url&&!n.file){const t=new OffscreenCanvas(r.width,r.height);t.getContext("bitmaprenderer").transferFromImageBitmap(r),n.blobPromise=t.convertToBlob()}null==(e=r.close)||e.call(r),n.bitmap=null}isValidId(t){return t.startsWith(`image_${Nc(this,L)}_`)}};L=new WeakMap,U=new WeakMap,I=new WeakMap,Q=new WeakSet,k=function(t,e){return Wc(this,null,function*(){Nc(this,I)||Dc(this,I,new Map);let n=Nc(this,I).get(t);if(null===n)return null;if(null==n?void 0:n.bitmap)return n.refCounter+=1,n;try{let t;if(n||(n={bitmap:null,id:`image_${Nc(this,L)}_${Hc(this,U)._++}`,refCounter:0,isSvg:!1}),"string"==typeof e?(n.url=e,t=yield $U(e,"blob")):e instanceof File?t=n.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=wI._isSVGFittingCanvas,r=new FileReader,i=new Image,A=new Promise((t,A)=>{i.onload=()=>{n.bitmap=i,n.isSvg=!0,t()},r.onload=()=>Wc(this,null,function*(){const t=n.svgUrl=r.result;i.src=(yield e)?`${t}#svgView(preserveAspectRatio(none))`:t}),i.onerror=r.onerror=A});r.readAsDataURL(t),yield A}else n.bitmap=yield createImageBitmap(t);n.refCounter=1}catch(hw){CU(hw),n=null}return Nc(this,I).set(t,n),n&&Nc(this,I).set(n.id,n),n})};let vI=wI;class yI{constructor(t=128){Tc(this,M,[]),Tc(this,O,!1),Tc(this,P),Tc(this,N,-1),Dc(this,P,t)}add({cmd:t,undo:e,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:A=!1,keepUndo:s=!1}){if(r&&t(),Nc(this,O))return;const a={cmd:t,undo:e,post:n,type:i};if(-1===Nc(this,N))return Nc(this,M).length>0&&(Nc(this,M).length=0),Dc(this,N,0),void Nc(this,M).push(a);if(A&&Nc(this,M)[Nc(this,N)].type===i)return s&&(a.undo=Nc(this,M)[Nc(this,N)].undo),void(Nc(this,M)[Nc(this,N)]=a);const o=Nc(this,N)+1;o===Nc(this,P)?Nc(this,M).splice(0,1):(Dc(this,N,o),o<Nc(this,M).length&&Nc(this,M).splice(o)),Nc(this,M).push(a)}undo(){if(-1===Nc(this,N))return;Dc(this,O,!0);const{undo:t,post:e}=Nc(this,M)[Nc(this,N)];t(),null==e||e(),Dc(this,O,!1),Dc(this,N,Nc(this,N)-1)}redo(){if(Nc(this,N)<Nc(this,M).length-1){Dc(this,N,Nc(this,N)+1),Dc(this,O,!0);const{cmd:t,post:e}=Nc(this,M)[Nc(this,N)];t(),null==e||e(),Dc(this,O,!1)}}hasSomethingToUndo(){return-1!==Nc(this,N)}hasSomethingToRedo(){return Nc(this,N)<Nc(this,M).length-1}cleanType(t){if(-1!==Nc(this,N)){for(let e=Nc(this,N);e>=0;e--)if(Nc(this,M)[e].type!==t)return Nc(this,M).splice(e+1,Nc(this,N)-e),void Dc(this,N,e);Nc(this,M).length=0,Dc(this,N,-1)}}destroy(){Dc(this,M,null)}}M=new WeakMap,O=new WeakMap,P=new WeakMap,N=new WeakMap;class bI{constructor(t){Tc(this,T),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=DU.platform;for(const[n,r,i={}]of t)for(const t of n){const n=t.startsWith("mac+");e&&n?(this.callbacks.set(t.slice(4),{callback:r,options:i}),this.allKeys.add(t.split("+").at(-1))):e||n||(this.callbacks.set(t,{callback:r,options:i}),this.allKeys.add(t.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const n=this.callbacks.get(Rc(this,T,D).call(this,e));if(!n)return;const{callback:r,options:{bubbles:i=!1,args:A=[],checker:s=null}}=n;s&&!s(t,e)||(r.bind(t,...A,e)(),i||AI(e))}}T=new WeakSet,D=function(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e};const BI=class t{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const n of t.keys()){e.style.color=n;const r=window.getComputedStyle(e).color;t.set(n,aI(r))}e.remove()}(t),LU(this,"_colors",t)}convert(e){const n=aI(e);if(!window.matchMedia("(forced-colors: active)").matches)return n;for(const[r,i]of this._colors)if(i.every((t,e)=>t===n[e]))return t._colorsMapping.get(r);return n}getHexCode(t){const e=this._colors.get(t);return e?HU.makeHexColor(...e):t}};Oc(BI,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let _I=BI;const CI=class t{constructor(t,e,n,r,i,A,s,a,o,l,c,h,u,d,f,p){Tc(this,Qt),Tc(this,R,new AbortController),Tc(this,H,null),Tc(this,j,new Map),Tc(this,W,new Map),Tc(this,V,null),Tc(this,K,null),Tc(this,G,null),Tc(this,z,new yI),Tc(this,q,null),Tc(this,X,null),Tc(this,Y,null),Tc(this,$,0),Tc(this,J,new Set),Tc(this,Z,null),Tc(this,tt,null),Tc(this,et,new Set),Oc(this,"_editorUndoBar",null),Tc(this,nt,!1),Tc(this,rt,!1),Tc(this,it,!1),Tc(this,At,null),Tc(this,st,null),Tc(this,at,null),Tc(this,ot,null),Tc(this,lt,!1),Tc(this,ct,null),Tc(this,ht,new mI),Tc(this,ut,!1),Tc(this,dt,!1),Tc(this,ft,null),Tc(this,pt,null),Tc(this,gt,null),Tc(this,mt,null),Tc(this,wt,null),Tc(this,vt,tU.NONE),Tc(this,yt,new Set),Tc(this,bt,null),Tc(this,Bt,null),Tc(this,_t,null),Tc(this,Ct,null),Tc(this,xt,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),Tc(this,Et,[0,0]),Tc(this,St,null),Tc(this,Ft,null),Tc(this,Lt,null),Tc(this,Ut,null),Tc(this,It,null);const g=this._signal=Nc(this,R).signal;Dc(this,Ft,t),Dc(this,Lt,e),Dc(this,Ut,n),Dc(this,V,r),Dc(this,q,i),Dc(this,Bt,A),this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:g}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:g}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:g}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:g}),s._on("setpreference",this.onSetPreference.bind(this),{signal:g}),s._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:g}),Rc(this,Qt,Tt).call(this),Rc(this,Qt,Kt).call(this),Rc(this,Qt,Ht).call(this),Dc(this,K,a.annotationStorage),Dc(this,At,a.filterFactory),Dc(this,_t,o),Dc(this,ot,l||null),Dc(this,nt,c),Dc(this,rt,h),Dc(this,it,u),Dc(this,wt,d||null),this.viewParameters={realScale:YU.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=f||null,this._supportsPinchToZoom=!1!==p}static get _keyboardManager(){const e=t.prototype,n=t=>Nc(t,Ft).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),r=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},i=this.TRANSLATE_SMALL,A=this.TRANSLATE_BIG;return LU(this,"_keyboardManager",new bI([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],e.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:r}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Nc(t,Ft).contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Nc(t,Ft).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-A,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[A,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-A],checker:n}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,A],checker:n}]]))}destroy(){var t,e,n,r,i,A,s,a,o;null==(t=Nc(this,It))||t.resolve(),Dc(this,It,null),null==(e=Nc(this,R))||e.abort(),Dc(this,R,null),this._signal=null;for(const l of Nc(this,W).values())l.destroy();Nc(this,W).clear(),Nc(this,j).clear(),Nc(this,et).clear(),null==(n=Nc(this,mt))||n.clear(),Dc(this,H,null),Nc(this,yt).clear(),Nc(this,z).destroy(),null==(r=Nc(this,V))||r.destroy(),null==(i=Nc(this,q))||i.destroy(),null==(A=Nc(this,Bt))||A.destroy(),null==(s=Nc(this,ct))||s.hide(),Dc(this,ct,null),null==(a=Nc(this,gt))||a.destroy(),Dc(this,gt,null),Nc(this,st)&&(clearTimeout(Nc(this,st)),Dc(this,st,null)),Nc(this,St)&&(clearTimeout(Nc(this,St)),Dc(this,St,null)),null==(o=this._editorUndoBar)||o.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return Nc(this,wt)}get useNewAltTextFlow(){return Nc(this,rt)}get useNewAltTextWhenAddingImage(){return Nc(this,it)}get hcmFilter(){return LU(this,"hcmFilter",Nc(this,_t)?Nc(this,At).addHCMFilter(Nc(this,_t).foreground,Nc(this,_t).background):"none")}get direction(){return LU(this,"direction",getComputedStyle(Nc(this,Ft)).direction)}get _highlightColors(){return LU(this,"_highlightColors",Nc(this,ot)?new Map(Nc(this,ot).split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return LU(this,"highlightColors",null);const e=new Map,n=!!Nc(this,_t);for(const[r,i]of t){const t=r.endsWith("_HCM");n&&t?e.set(r.replace("_HCM",""),i):n||t||e.set(r,i)}return LU(this,"highlightColors",e)}get highlightColorNames(){return LU(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),Dc(this,Y,t)}setMainHighlightColorPicker(t){Dc(this,gt,t)}editAltText(t,e=!1){var n;null==(n=Nc(this,V))||n.editAltText(this,t,e)}hasCommentManager(){return!!Nc(this,q)}editComment(t,e){var n;null==(n=Nc(this,q))||n.open(this,t,e)}getSignature(t){var e;null==(e=Nc(this,Bt))||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return Nc(this,Bt)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)Dc(this,it,e)}onPageChanging({pageNumber:t}){Dc(this,$,t-1)}focusMainContainer(){Nc(this,Ft).focus()}findParent(t,e){for(const n of Nc(this,W).values()){const{x:r,y:i,width:A,height:s}=n.div.getBoundingClientRect();if(t>=r&&t<=r+A&&e>=i&&e<=i+s)return n}return null}disableUserSelect(t=!1){Nc(this,Lt).classList.toggle("noUserSelect",t)}addShouldRescale(t){Nc(this,et).add(t)}removeShouldRescale(t){Nc(this,et).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*YU.PDF_TO_CSS_UNITS;for(const n of Nc(this,et))n.onScaleChanging();null==(e=Nc(this,Y))||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:A}=e,s=e.toString(),a=Rc(this,Qt,kt).call(this,e).closest(".textLayer"),o=this.getSelectionBoxes(a);if(!o)return;e.empty();const l=Rc(this,Qt,Mt).call(this,a),c=Nc(this,vt)===tU.NONE,h=()=>{null==l||l.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:o,anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:A,text:s}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(tU.HIGHLIGHT,h):h()}addToAnnotationStorage(t){t.isEmpty()||!Nc(this,K)||Nc(this,K).has(t.id)||Nc(this,K).setValue(t.id,t)}a11yAlert(t,e=null){const n=Nc(this,Ut);n&&(n.setAttribute("data-l10n-id",t),e?n.setAttribute("data-l10n-args",JSON.stringify(e)):n.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,Nc(this,lt)&&(Dc(this,lt,!1),Rc(this,Qt,Nt).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of Nc(this,yt))if(e.div.contains(t)){Dc(this,pt,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!Nc(this,pt))return;const[t,e]=Nc(this,pt);Dc(this,pt,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){Rc(this,Qt,Ht).call(this),Rc(this,Qt,Wt).call(this)}removeEditListeners(){Rc(this,Qt,jt).call(this),Rc(this,Qt,Vt).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const n of Nc(this,tt))if(n.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const n of Nc(this,tt))if(n.isHandlingMimeForPasting(e.type))return n.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null==(e=Nc(this,H))||e.commitOrRemove(),!this.hasSelection)return;const n=[];for(const r of Nc(this,yt)){const t=r.serialize(!0);t&&n.push(t)}0!==n.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(n))}cut(t){this.copy(t),this.delete()}paste(t){return Wc(this,null,function*(){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of Nc(this,tt))if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let n=e.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(i){return void CU(`paste: "${i.message}".`)}if(!Array.isArray(n))return;this.unselectAll();const r=this.currentLayer;try{const t=[];for(const A of n){const e=yield r.deserialize(A);if(!e)return;t.push(e)}const e=()=>{for(const e of t)Rc(this,Qt,Yt).call(this,e);Rc(this,Qt,Zt).call(this,t)},i=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:i,mustExec:!0})}catch(i){CU(`paste: "${i.message}".`)}})}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),Nc(this,vt)===tU.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,Nc(this,lt)&&(Dc(this,lt,!1),Rc(this,Qt,Nt).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(t){t?(Rc(this,Qt,Dt).call(this),Rc(this,Qt,Wt).call(this),Rc(this,Qt,Gt).call(this,{isEditing:Nc(this,vt)!==tU.NONE,isEmpty:Rc(this,Qt,Jt).call(this),hasSomethingToUndo:Nc(this,z).hasSomethingToUndo(),hasSomethingToRedo:Nc(this,z).hasSomethingToRedo(),hasSelectedEditor:!1})):(Rc(this,Qt,Rt).call(this),Rc(this,Qt,Vt).call(this),Rc(this,Qt,Gt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!Nc(this,tt)){Dc(this,tt,t);for(const t of Nc(this,tt))Rc(this,Qt,zt).call(this,t.defaultPropertiesToUpdate)}}getId(){return Nc(this,ht).id}get currentLayer(){return Nc(this,W).get(Nc(this,$))}getLayer(t){return Nc(this,W).get(t)}get currentPageIndex(){return Nc(this,$)}addLayer(t){Nc(this,W).set(t.pageIndex,t),Nc(this,ut)?t.enable():t.disable()}removeLayer(t){Nc(this,W).delete(t.pageIndex)}updateMode(t,e=null,n=!1,r=!1,i=!1){return Wc(this,null,function*(){var A,s,a;if(Nc(this,vt)!==t&&(!Nc(this,It)||(yield Nc(this,It).promise,Nc(this,It)))){if(Dc(this,It,Promise.withResolvers()),null==(A=Nc(this,Y))||A.commitOrRemove(),Dc(this,vt,t),t===tU.NONE)return this.setEditingState(!1),Rc(this,Qt,Xt).call(this),null==(s=this._editorUndoBar)||s.hide(),void Nc(this,It).resolve();t===tU.SIGNATURE&&(yield null==(a=Nc(this,Bt))?void 0:a.loadSignatures()),this.setEditingState(!0),yield Rc(this,Qt,qt).call(this),this.unselectAll();for(const e of Nc(this,W).values())e.updateMode(t);if(!e)return n&&this.addNewEditorFromKeyboard(),void Nc(this,It).resolve();for(const t of Nc(this,j).values())t.annotationElementId===e||t.id===e?(this.setSelected(t),i?t.editComment():r&&t.enterInEditMode()):t.unselect();Nc(this,It).resolve()}})}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==Nc(this,vt)&&this._eventBus.dispatch("switchannotationeditormode",Qc({source:this},t))}updateParams(t,e){if(Nc(this,tt)){switch(t){case eU.CREATE:return void this.currentLayer.addNewEditor(e);case eU.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(Nc(this,Ct)||Dc(this,Ct,new Map)).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const n of Nc(this,yt))n.updateParams(t,e);else for(const n of Nc(this,tt))n.updateDefaultParams(t,e)}}showAllEditors(t,e,n=!1){var r,i;for(const A of Nc(this,j).values())A.editorType===t&&A.show(e);(null==(i=null==(r=Nc(this,Ct))?void 0:r.get(eU.HIGHLIGHT_SHOW_ALL))||i)!==e&&Rc(this,Qt,zt).call(this,[[eU.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(Nc(this,dt)!==t){Dc(this,dt,t);for(const e of Nc(this,W).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const n of Nc(this,j).values())n.pageIndex===t&&e.push(n);return e}getEditor(t){return Nc(this,j).get(t)}addEditor(t){Nc(this,j).set(t.id,t)}removeEditor(t){var e,n;t.div.contains(document.activeElement)&&(Nc(this,st)&&clearTimeout(Nc(this,st)),Dc(this,st,setTimeout(()=>{this.focusMainContainer(),Dc(this,st,null)},0))),Nc(this,j).delete(t.id),t.annotationElementId&&(null==(e=Nc(this,mt))||e.delete(t.annotationElementId)),this.unselect(t),t.annotationElementId&&Nc(this,J).has(t.annotationElementId)||null==(n=Nc(this,K))||n.remove(t.id)}addDeletedAnnotationElement(t){Nc(this,J).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return Nc(this,J).has(t)}removeDeletedAnnotationElement(t){Nc(this,J).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){Nc(this,H)!==t&&(Dc(this,H,t),t&&Rc(this,Qt,zt).call(this,t.propertiesToUpdate))}updateUI(t){Nc(this,Qt,$t)===t&&Rc(this,Qt,zt).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){Rc(this,Qt,zt).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(Nc(this,yt).has(t))return Nc(this,yt).delete(t),t.unselect(),void Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection});Nc(this,yt).add(t),t.select(),Rc(this,Qt,zt).call(this,t.propertiesToUpdate),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.id}),null==(e=Nc(this,Y))||e.commitOrRemove();for(const n of Nc(this,yt))n!==t&&n.unselect();Nc(this,yt).clear(),Nc(this,yt).add(t),t.select(),Rc(this,Qt,zt).call(this,t.propertiesToUpdate),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:!0})}isSelected(t){return Nc(this,yt).has(t)}get firstSelectedEditor(){return Nc(this,yt).values().next().value}unselect(t){t.unselect(),Nc(this,yt).delete(t),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==Nc(this,yt).size}get isEnterHandled(){return 1===Nc(this,yt).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;Nc(this,z).undo(),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:Nc(this,z).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:Rc(this,Qt,Jt).call(this)}),null==(t=this._editorUndoBar)||t.hide()}redo(){Nc(this,z).redo(),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:Nc(this,z).hasSomethingToRedo(),isEmpty:Rc(this,Qt,Jt).call(this)})}addCommands(t){Nc(this,z).add(t),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:Rc(this,Qt,Jt).call(this)})}cleanUndoStack(t){Nc(this,z).cleanType(t)}delete(){var t;this.commitOrRemove();const e=null==(t=this.currentLayer)?void 0:t.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const n=e?[e]:[...Nc(this,yt)],r=()=>{for(const t of n)Rc(this,Qt,Yt).call(this,t)};this.addCommands({cmd:()=>{var t;null==(t=this._editorUndoBar)||t.show(r,1===n.length?n[0].editorType:n.length);for(const e of n)e.remove()},undo:r,mustExec:!0})}commitOrRemove(){var t;null==(t=Nc(this,H))||t.commitOrRemove()}hasSomethingToControl(){return Nc(this,H)||this.hasSelection}selectAll(){for(const t of Nc(this,yt))t.commit();Rc(this,Qt,Zt).call(this,Nc(this,j).values())}unselectAll(){var t;if((!Nc(this,H)||(Nc(this,H).commitOrRemove(),Nc(this,vt)===tU.NONE))&&!(null==(t=Nc(this,Y))?void 0:t.commitOrRemove())&&this.hasSelection){for(const t of Nc(this,yt))t.unselect();Nc(this,yt).clear(),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;Nc(this,Et)[0]+=t,Nc(this,Et)[1]+=e;const[r,i]=Nc(this,Et),A=[...Nc(this,yt)];Nc(this,St)&&clearTimeout(Nc(this,St)),Dc(this,St,setTimeout(()=>{Dc(this,St,null),Nc(this,Et)[0]=Nc(this,Et)[1]=0,this.addCommands({cmd:()=>{for(const t of A)Nc(this,j).has(t.id)&&(t.translateInPage(r,i),t.translationDone())},undo:()=>{for(const t of A)Nc(this,j).has(t.id)&&(t.translateInPage(-r,-i),t.translationDone())},mustExec:!1})},1e3));for(const s of A)s.translateInPage(t,e),s.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),Dc(this,Z,new Map);for(const t of Nc(this,yt))Nc(this,Z).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!Nc(this,Z))return!1;this.disableUserSelect(!1);const t=Nc(this,Z);Dc(this,Z,null);let e=!1;for(const[{x:r,y:i,pageIndex:A},s]of t)s.newX=r,s.newY=i,s.newPageIndex=A,e||(e=r!==s.savedX||i!==s.savedY||A!==s.savedPageIndex);if(!e)return!1;const n=(t,e,n,r)=>{if(Nc(this,j).has(t.id)){const i=Nc(this,W).get(r);i?t._setParentAndPosition(i,e,n):(t.pageIndex=r,t.x=e,t.y=n)}};return this.addCommands({cmd:()=>{for(const[e,{newX:r,newY:i,newPageIndex:A}]of t)n(e,r,i,A)},undo:()=>{for(const[e,{savedX:r,savedY:i,savedPageIndex:A}]of t)n(e,r,i,A)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(Nc(this,Z))for(const n of Nc(this,Z).keys())n.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return(null==(t=this.getActive())?void 0:t.shouldGetKeyboardEvents())||1===Nc(this,yt).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return Nc(this,H)===t}getActive(){return Nc(this,H)}getMode(){return Nc(this,vt)}get imageManager(){return LU(this,"imageManager",new vI)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let o=0,l=e.rangeCount;o<l;o++)if(!t.contains(e.getRangeAt(o).commonAncestorContainer))return null;const{x:n,y:r,width:i,height:A}=t.getBoundingClientRect();let s;switch(t.getAttribute("data-main-rotation")){case"90":s=(t,e,s,a)=>({x:(e-r)/A,y:1-(t+s-n)/i,width:a/A,height:s/i});break;case"180":s=(t,e,s,a)=>({x:1-(t+s-n)/i,y:1-(e+a-r)/A,width:s/i,height:a/A});break;case"270":s=(t,e,s,a)=>({x:1-(e+a-r)/A,y:(t-n)/i,width:a/A,height:s/i});break;default:s=(t,e,s,a)=>({x:(t-n)/i,y:(e-r)/A,width:s/i,height:a/A})}const a=[];for(let o=0,l=e.rangeCount;o<l;o++){const t=e.getRangeAt(o);if(!t.collapsed)for(const{x:e,y:n,width:r,height:i}of t.getClientRects())0!==r&&0!==i&&a.push(s(e,n,r,i))}return 0===a.length?null:a}addChangedExistingAnnotation({annotationElementId:t,id:e}){(Nc(this,G)||Dc(this,G,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;null==(e=Nc(this,G))||e.delete(t)}renderAnnotationElement(t){var e;const n=null==(e=Nc(this,G))?void 0:e.get(t.data.id);if(!n)return;const r=Nc(this,K).getRawValue(n);r&&(Nc(this,vt)!==tU.NONE||r.hasBeenModified)&&r.renderAnnotationElement(t)}setMissingCanvas(t,e,n){var r;const i=null==(r=Nc(this,mt))?void 0:r.get(t);i&&(i.setCanvas(e,n),Nc(this,mt).delete(t))}addMissingCanvas(t,e){(Nc(this,mt)||Dc(this,mt,new Map)).set(t,e)}};R=new WeakMap,H=new WeakMap,j=new WeakMap,W=new WeakMap,V=new WeakMap,K=new WeakMap,G=new WeakMap,z=new WeakMap,q=new WeakMap,X=new WeakMap,Y=new WeakMap,$=new WeakMap,J=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,nt=new WeakMap,rt=new WeakMap,it=new WeakMap,At=new WeakMap,st=new WeakMap,at=new WeakMap,ot=new WeakMap,lt=new WeakMap,ct=new WeakMap,ht=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,wt=new WeakMap,vt=new WeakMap,yt=new WeakMap,bt=new WeakMap,Bt=new WeakMap,_t=new WeakMap,Ct=new WeakMap,xt=new WeakMap,Et=new WeakMap,St=new WeakMap,Ft=new WeakMap,Lt=new WeakMap,Ut=new WeakMap,It=new WeakMap,Qt=new WeakSet,kt=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Mt=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const n of Nc(this,W).values())if(n.hasTextLayer(t))return n;return null},Ot=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=Rc(this,Qt,kt).call(this,t).closest(".textLayer"),n=this.getSelectionBoxes(e);n&&(Nc(this,ct)||Dc(this,ct,new pI(this)),Nc(this,ct).show(e,n,"ltr"===this.direction))},Pt=function(){var t,e,n;const r=document.getSelection();if(!r||r.isCollapsed)return void(Nc(this,bt)&&(null==(t=Nc(this,ct))||t.hide(),Dc(this,bt,null),Rc(this,Qt,Gt).call(this,{hasSelectedText:!1})));const{anchorNode:i}=r;if(i===Nc(this,bt))return;const A=Rc(this,Qt,kt).call(this,r).closest(".textLayer");if(A){if(null==(n=Nc(this,ct))||n.hide(),Dc(this,bt,i),Rc(this,Qt,Gt).call(this,{hasSelectedText:!0}),(Nc(this,vt)===tU.HIGHLIGHT||Nc(this,vt)===tU.NONE)&&(Nc(this,vt)===tU.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),Dc(this,lt,this.isShiftKeyDown),!this.isShiftKeyDown)){const t=Nc(this,vt)===tU.HIGHLIGHT?Rc(this,Qt,Mt).call(this,A):null;null==t||t.toggleDrawing();const e=new AbortController,n=this.combinedSignal(e),r=n=>{"pointerup"===n.type&&0!==n.button||(e.abort(),null==t||t.toggleDrawing(!0),"pointerup"===n.type&&Rc(this,Qt,Nt).call(this,"main_toolbar"))};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}}else Nc(this,bt)&&(null==(e=Nc(this,ct))||e.hide(),Dc(this,bt,null),Rc(this,Qt,Gt).call(this,{hasSelectedText:!1}))},Nt=function(t=""){Nc(this,vt)===tU.HIGHLIGHT?this.highlightSelection(t):Nc(this,nt)&&Rc(this,Qt,Ot).call(this)},Tt=function(){document.addEventListener("selectionchange",Rc(this,Qt,Pt).bind(this),{signal:this._signal})},Dt=function(){if(Nc(this,at))return;Dc(this,at,new AbortController);const t=this.combinedSignal(Nc(this,at));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Rt=function(){var t;null==(t=Nc(this,at))||t.abort(),Dc(this,at,null)},Ht=function(){if(Nc(this,ft))return;Dc(this,ft,new AbortController);const t=this.combinedSignal(Nc(this,ft));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},jt=function(){var t;null==(t=Nc(this,ft))||t.abort(),Dc(this,ft,null)},Wt=function(){if(Nc(this,X))return;Dc(this,X,new AbortController);const t=this.combinedSignal(Nc(this,X));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})},Vt=function(){var t;null==(t=Nc(this,X))||t.abort(),Dc(this,X,null)},Kt=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Gt=function(t){Object.entries(t).some(([t,e])=>Nc(this,xt)[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(Nc(this,xt),t)}),Nc(this,vt)===tU.HIGHLIGHT&&!1===t.hasSelectedEditor&&Rc(this,Qt,zt).call(this,[[eU.HIGHLIGHT_FREE,!0]]))},zt=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},qt=function(){return Wc(this,null,function*(){if(!Nc(this,ut)){Dc(this,ut,!0);const t=[];for(const e of Nc(this,W).values())t.push(e.enable());yield Promise.all(t);for(const e of Nc(this,j).values())e.enable()}})},Xt=function(){if(this.unselectAll(),Nc(this,ut)){Dc(this,ut,!1);for(const t of Nc(this,W).values())t.disable();for(const t of Nc(this,j).values())t.disable()}},Yt=function(t){const e=Nc(this,W).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},$t=function(){let t=null;for(t of Nc(this,yt));return t},Jt=function(){if(0===Nc(this,j).size)return!0;if(1===Nc(this,j).size)for(const t of Nc(this,j).values())return t.isEmpty();return!1},Zt=function(t){for(const e of Nc(this,yt))e.unselect();Nc(this,yt).clear();for(const e of t)e.isEmpty()||(Nc(this,yt).add(e),e.select());Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection})},Oc(CI,"TRANSLATE_SMALL",1),Oc(CI,"TRANSLATE_BIG",10);let xI=CI;const EI=class t{constructor(e){Tc(this,de),Tc(this,te,null),Tc(this,ee,!1),Tc(this,ne,null),Tc(this,re,null),Tc(this,ie,null),Tc(this,Ae,null),Tc(this,se,!1),Tc(this,ae,null),Tc(this,oe,null),Tc(this,le,null),Tc(this,ce,null),Tc(this,he,!1),Dc(this,oe,e),Dc(this,he,e._uiManager.useNewAltTextFlow),Nc(t,ue)||Dc(t,ue,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){null!=t._l10n||(t._l10n=e)}render(){return Wc(this,null,function*(){const e=Dc(this,ne,document.createElement("button"));e.className="altText",e.tabIndex="0";const n=Dc(this,re,document.createElement("span"));e.append(n),Nc(this,he)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Nc(t,ue).missing),n.setAttribute("data-l10n-id",Nc(t,ue)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const r=Nc(this,oe)._uiManager._signal;e.addEventListener("contextmenu",iI,{signal:r}),e.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:r});const i=t=>{t.preventDefault(),Nc(this,oe)._uiManager.editAltText(Nc(this,oe)),Nc(this,he)&&Nc(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:Nc(this,de,fe)}})};return e.addEventListener("click",i,{capture:!0,signal:r}),e.addEventListener("keydown",t=>{t.target===e&&"Enter"===t.key&&(Dc(this,se,!0),i(t))},{signal:r}),yield Rc(this,de,pe).call(this),e})}finish(){Nc(this,ne)&&(Nc(this,ne).focus({focusVisible:Nc(this,se)}),Dc(this,se,!1))}isEmpty(){return Nc(this,he)?null===Nc(this,te):!Nc(this,te)&&!Nc(this,ee)}hasData(){return Nc(this,he)?null!==Nc(this,te)||!!Nc(this,le):this.isEmpty()}get guessedText(){return Nc(this,le)}setGuessedText(e){return Wc(this,null,function*(){null===Nc(this,te)&&(Dc(this,le,e),Dc(this,ce,yield t._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),Rc(this,de,pe).call(this))})}toggleAltTextBadge(t=!1){var e;if(!Nc(this,he)||Nc(this,te))return null==(e=Nc(this,ae))||e.remove(),void Dc(this,ae,null);if(!Nc(this,ae)){const t=Dc(this,ae,document.createElement("div"));t.className="noAltTextBadge",Nc(this,oe).div.append(t)}Nc(this,ae).classList.toggle("hidden",!t)}serialize(t){let e=Nc(this,te);return t||Nc(this,le)!==e||(e=Nc(this,ce)),{altText:e,decorative:Nc(this,ee),guessedText:Nc(this,le),textWithDisclaimer:Nc(this,ce)}}get data(){return{altText:Nc(this,te),decorative:Nc(this,ee)}}set data({altText:t,decorative:e,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(Dc(this,le,n),Dc(this,ce,r)),Nc(this,te)===t&&Nc(this,ee)===e||(i||(Dc(this,te,t),Dc(this,ee,e)),Rc(this,de,pe).call(this))}toggle(t=!1){Nc(this,ne)&&(!t&&Nc(this,Ae)&&(clearTimeout(Nc(this,Ae)),Dc(this,Ae,null)),Nc(this,ne).disabled=!t)}shown(){Nc(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:Nc(this,de,fe)}})}destroy(){var t,e;null==(t=Nc(this,ne))||t.remove(),Dc(this,ne,null),Dc(this,re,null),Dc(this,ie,null),null==(e=Nc(this,ae))||e.remove(),Dc(this,ae,null)}};te=new WeakMap,ee=new WeakMap,ne=new WeakMap,re=new WeakMap,ie=new WeakMap,Ae=new WeakMap,se=new WeakMap,ae=new WeakMap,oe=new WeakMap,le=new WeakMap,ce=new WeakMap,he=new WeakMap,ue=new WeakMap,de=new WeakSet,fe=function(){return(Nc(this,te)?"added":null===Nc(this,te)&&this.guessedText&&"review")||"missing"},pe=function(){return Wc(this,null,function*(){var t,e,n;const r=Nc(this,ne);if(!r)return;if(Nc(this,he)){if(r.classList.toggle("done",!!Nc(this,te)),r.setAttribute("data-l10n-id",Nc(EI,ue)[Nc(this,de,fe)]),null==(t=Nc(this,re))||t.setAttribute("data-l10n-id",Nc(EI,ue)[`${Nc(this,de,fe)}-label`]),!Nc(this,te))return void(null==(e=Nc(this,ie))||e.remove())}else{if(!Nc(this,te)&&!Nc(this,ee))return r.classList.remove("done"),void(null==(n=Nc(this,ie))||n.remove());r.classList.add("done"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let i=Nc(this,ie);if(!i){Dc(this,ie,i=document.createElement("span")),i.className="tooltip",i.setAttribute("role","tooltip"),i.id=`alt-text-tooltip-${Nc(this,oe).id}`;const t=100,e=Nc(this,oe)._uiManager._signal;e.addEventListener("abort",()=>{clearTimeout(Nc(this,Ae)),Dc(this,Ae,null)},{once:!0}),r.addEventListener("mouseenter",()=>{Dc(this,Ae,setTimeout(()=>{Dc(this,Ae,null),Nc(this,ie).classList.add("show"),Nc(this,oe)._reportTelemetry({action:"alt_text_tooltip"})},t))},{signal:e}),r.addEventListener("mouseleave",()=>{var t;Nc(this,Ae)&&(clearTimeout(Nc(this,Ae)),Dc(this,Ae,null)),null==(t=Nc(this,ie))||t.classList.remove("show")},{signal:e})}Nc(this,ee)?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=Nc(this,te)),i.parentNode||r.append(i);const A=Nc(this,oe).getElementForAltText();null==A||A.setAttribute("aria-describedby",i.id)})},Tc(EI,ue,null),Oc(EI,"_l10n",null);let SI=EI;class FI{constructor(t){Tc(this,ge,null),Tc(this,me,!1),Tc(this,we,null),Tc(this,ve,null),Tc(this,ye,null),Tc(this,be,null),Tc(this,Be,!1),Dc(this,we,t),this.toolbar=null}render(){if(!Nc(this,we)._uiManager.hasCommentManager())return null;const t=Dc(this,ge,document.createElement("button"));t.className="comment",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button");const e=Nc(this,we)._uiManager._signal;t.addEventListener("contextmenu",iI,{signal:e}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:e});const n=t=>{t.preventDefault(),this.edit()};return t.addEventListener("click",n,{capture:!0,signal:e}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(Dc(this,me,!0),n(e))},{signal:e}),t}edit(){const{bottom:t,left:e,right:n}=Nc(this,we).getClientDimensions(),r={top:t};"ltr"===Nc(this,we)._uiManager.direction?r.right=n:r.left=e,Nc(this,we)._uiManager.editComment(Nc(this,we),r)}finish(){Nc(this,ge)&&(Nc(this,ge).focus({focusVisible:Nc(this,me)}),Dc(this,me,!1))}isDeleted(){return Nc(this,Be)||""===Nc(this,ye)}hasBeenEdited(){return this.isDeleted()||Nc(this,ye)!==Nc(this,ve)}serialize(){return this.data}get data(){return{text:Nc(this,ye),date:Nc(this,be),deleted:Nc(this,Be)}}set data(t){if(null===t)return Dc(this,ye,""),void Dc(this,Be,!0);Dc(this,ye,t),Dc(this,be,new Date),Dc(this,Be,!1)}setInitialText(t){Dc(this,ve,t),this.data=t}toggle(t=!1){Nc(this,ge)&&(Nc(this,ge).disabled=!t)}shown(){}destroy(){var t;null==(t=Nc(this,ge))||t.remove(),Dc(this,ge,null),Dc(this,ye,""),Dc(this,be,null),Dc(this,we,null),Dc(this,me,!1),Dc(this,Be,!1)}}ge=new WeakMap,me=new WeakMap,we=new WeakMap,ve=new WeakMap,ye=new WeakMap,be=new WeakMap,Be=new WeakMap;const LI=class{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:A=null,signal:s}){Tc(this,Oe),Tc(this,_e),Tc(this,Ce,!1),Tc(this,xe,null),Tc(this,Ee),Tc(this,Se),Tc(this,Fe),Tc(this,Le),Tc(this,Ue,null),Tc(this,Ie),Tc(this,Qe,null),Tc(this,ke),Tc(this,Me,null),Dc(this,_e,t),Dc(this,xe,n),Dc(this,Ee,e),Dc(this,Se,r),Dc(this,Fe,i),Dc(this,Le,A),Dc(this,ke,new AbortController),Dc(this,Ie,AbortSignal.any([s,Nc(this,ke).signal])),t.addEventListener("touchstart",Rc(this,Oe,Pe).bind(this),{passive:!1,signal:Nc(this,Ie)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/hI.pixelRatio}destroy(){var t,e;null==(t=Nc(this,ke))||t.abort(),Dc(this,ke,null),null==(e=Nc(this,Ue))||e.abort(),Dc(this,Ue,null)}};_e=new WeakMap,Ce=new WeakMap,xe=new WeakMap,Ee=new WeakMap,Se=new WeakMap,Fe=new WeakMap,Le=new WeakMap,Ue=new WeakMap,Ie=new WeakMap,Qe=new WeakMap,ke=new WeakMap,Me=new WeakMap,Oe=new WeakSet,Pe=function(t){var e,n,r;if(null==(e=Nc(this,Ee))?void 0:e.call(this))return;if(1===t.touches.length){if(Nc(this,Ue))return;const t=Dc(this,Ue,new AbortController),e=AbortSignal.any([Nc(this,Ie),t.signal]),n=Nc(this,_e),r={capture:!0,signal:e,passive:!1},i=t=>{var e;"touch"===t.pointerType&&(null==(e=Nc(this,Ue))||e.abort(),Dc(this,Ue,null))};return n.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(AI(t),i(t))},r),n.addEventListener("pointerup",i,r),void n.addEventListener("pointercancel",i,r)}if(!Nc(this,Me)){Dc(this,Me,new AbortController);const t=AbortSignal.any([Nc(this,Ie),Nc(this,Me).signal]),e=Nc(this,_e),r={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",Rc(this,Oe,Ne).bind(this),r);const i=Rc(this,Oe,Te).bind(this);e.addEventListener("touchend",i,r),e.addEventListener("touchcancel",i,r),r.capture=!0,e.addEventListener("pointerdown",AI,r),e.addEventListener("pointermove",AI,r),e.addEventListener("pointercancel",AI,r),e.addEventListener("pointerup",AI,r),null==(n=Nc(this,Se))||n.call(this)}if(AI(t),2!==t.touches.length||(null==(r=Nc(this,xe))?void 0:r.call(this)))return void Dc(this,Qe,null);let[i,A]=t.touches;i.identifier>A.identifier&&([i,A]=[A,i]),Dc(this,Qe,{touch0X:i.screenX,touch0Y:i.screenY,touch1X:A.screenX,touch1Y:A.screenY})},Ne=function(t){var e;if(!Nc(this,Qe)||2!==t.touches.length)return;AI(t);let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]);const{screenX:i,screenY:A}=n,{screenX:s,screenY:a}=r,o=Nc(this,Qe),{touch0X:l,touch0Y:c,touch1X:h,touch1Y:u}=o,d=h-l,f=u-c,p=s-i,g=a-A,m=Math.hypot(p,g)||1,w=Math.hypot(d,f)||1;if(!Nc(this,Ce)&&Math.abs(w-m)<=LI.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=i,o.touch0Y=A,o.touch1X=s,o.touch1Y=a,!Nc(this,Ce))return void Dc(this,Ce,!0);const v=[(i+s)/2,(A+a)/2];null==(e=Nc(this,Fe))||e.call(this,v,w,m)},Te=function(t){var e;t.touches.length>=2||(Nc(this,Me)&&(Nc(this,Me).abort(),Dc(this,Me,null),null==(e=Nc(this,Le))||e.call(this)),Nc(this,Qe)&&(AI(t),Dc(this,Qe,null),Dc(this,Ce,!1)))};let UI=LI;const II=class t{constructor(e){Tc(this,hn),Tc(this,De,null),Tc(this,Re,null),Tc(this,He,null),Tc(this,je,null),Tc(this,We,!1),Tc(this,Ve,null),Tc(this,Ke,""),Tc(this,Ge,!1),Tc(this,ze,null),Tc(this,qe,null),Tc(this,Xe,null),Tc(this,Ye,null),Tc(this,$e,""),Tc(this,Je,!1),Tc(this,Ze,null),Tc(this,tn,!1),Tc(this,en,!1),Tc(this,nn,!1),Tc(this,rn,null),Tc(this,An,0),Tc(this,sn,0),Tc(this,an,null),Tc(this,on,null),Oc(this,"isSelected",!1),Oc(this,"_isCopy",!1),Oc(this,"_editToolbar",null),Oc(this,"_initialOptions",Object.create(null)),Oc(this,"_initialData",null),Oc(this,"_isVisible",!0),Oc(this,"_uiManager",null),Oc(this,"_focusEventsAllowed",!0),Tc(this,ln,!1),Tc(this,cn,t._zIndex++),this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null;const{rotation:n,rawDims:{pageWidth:r,pageHeight:i,pageX:A,pageY:s}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,i],this.pageTranslation=[A,s];const[a,o]=this.parentDimensions;this.x=e.x/a,this.y=e.y/o,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=t.prototype._resizeWithKeyboard,n=xI.TRANSLATE_SMALL,r=xI.TRANSLATE_BIG;return LU(this,"_resizerKeyboardManager",new bI([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-n,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[n,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-n]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,n]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,r]}],[["Escape","mac+Escape"],t.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return LU(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new kI({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(e,n){if(null!=t._l10n||(t._l10n=e),t._l10nResizer||(t._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),-1!==t._borderLineWidth)return;const r=getComputedStyle(document.documentElement);t._borderLineWidth=parseFloat(r.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){xU("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return Nc(this,ln)}set _isDraggable(t){var e;Dc(this,ln,t),null==(e=this.div)||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=Nc(this,cn)}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):Rc(this,hn,In).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(Nc(this,Je)?Dc(this,Je,!1):this.parent.setSelected(this))}focusout(t){var e;if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const n=t.relatedTarget;(null==n?void 0:n.closest(`#${this.id}`))||(t.preventDefault(),(null==(e=this.parent)?void 0:e.isMultipleSelection)||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,n,r){const[i,A]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(t+n)/i,this.y=(e+r)/A,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[n,r]=this.parentDimensions;this.setAt(t*n,e*r,this.width*n,this.height*r),this._onTranslated()}translate(t,e){Rc(this,hn,un).call(this,this.parentDimensions,t,e)}translateInPage(t,e){Nc(this,Ze)||Dc(this,Ze,[this.x,this.y,this.width,this.height]),Rc(this,hn,un).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){Nc(this,Ze)||Dc(this,Ze,[this.x,this.y,this.width,this.height]);const{div:n,parentDimensions:[r,i]}=this;if(this.x+=t/r,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:A,y:s}=this;const[a,o]=this.getBaseTranslation();A+=a,s+=o;const{style:l}=n;l.left=`${(100*A).toFixed(2)}%`,l.top=`${(100*s).toFixed(2)}%`,this._onTranslating(A,s),n.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!Nc(this,Ze)&&(Nc(this,Ze)[0]!==this.x||Nc(this,Ze)[1]!==this.y)}get _hasBeenResized(){return!!Nc(this,Ze)&&(Nc(this,Ze)[2]!==this.width||Nc(this,Ze)[3]!==this.height)}getBaseTranslation(){const[e,n]=this.parentDimensions,{_borderLineWidth:r}=t,i=r/e,A=r/n;switch(this.rotation){case 90:return[-i,A];case 180:return[i,A];case 270:return[i,-A];default:return[-i,-A]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[n,r]}=this;let{x:i,y:A,width:s,height:a}=this;if(s*=n,a*=r,i*=n,A*=r,this._mustFixPosition)switch(t){case 0:i=GU(i,0,n-s),A=GU(A,0,r-a);break;case 90:i=GU(i,0,n-a),A=GU(A,s,r);break;case 180:i=GU(i,s,n),A=GU(A,a,r);break;case 270:i=GU(i,a,n),A=GU(A,0,r-s)}this.x=i/=n,this.y=A/=r;const[o,l]=this.getBaseTranslation();i+=o,A+=l,e.left=`${(100*i).toFixed(2)}%`,e.top=`${(100*A).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,n){var r;return Rc(r=t,dn,fn).call(r,e,n,this.parentRotation)}pageTranslationToScreen(e,n){var r;return Rc(r=t,dn,fn).call(r,e,n,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,n]}=this;return[e*t,n*t]}setDims(t,e){const[n,r]=this.parentDimensions,{style:i}=this.div;i.width=`${(100*t/n).toFixed(2)}%`,Nc(this,Ge)||(i.height=`${(100*e/r).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:n}=t,r=n.endsWith("%"),i=!Nc(this,Ge)&&e.endsWith("%");if(r&&i)return;const[A,s]=this.parentDimensions;r||(t.width=`${(100*parseFloat(n)/A).toFixed(2)}%`),Nc(this,Ge)||i||(t.height=`${(100*parseFloat(e)/s).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){var t;null==(t=Nc(this,He))||t.finish()}get toolbarButtons(){return null}addEditToolbar(){return Wc(this,null,function*(){if(this._editToolbar||Nc(this,en))return this._editToolbar;this._editToolbar=new fI(this),this.div.append(this._editToolbar.render()),this._editToolbar.addButton("comment",this.addCommentButton());const{toolbarButtons:t}=this;if(t)for(const[e,n]of t)yield this._editToolbar.addButton(e,n);return this._editToolbar.addButton("delete"),this._editToolbar})}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,null==(t=Nc(this,He))||t.destroy())}addContainer(t){var e;const n=null==(e=this._editToolbar)?void 0:e.div;n?n.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return Nc(this,He)||(SI.initialize(t._l10n),Dc(this,He,new SI(this)),Nc(this,De)&&(Nc(this,He).data=Nc(this,De),Dc(this,De,null))),Nc(this,He)}get altTextData(){var t;return null==(t=Nc(this,He))?void 0:t.data}set altTextData(t){Nc(this,He)&&(Nc(this,He).data=t)}get guessedAltText(){var t;return null==(t=Nc(this,He))?void 0:t.guessedText}setGuessedAltText(t){return Wc(this,null,function*(){var e;yield null==(e=Nc(this,He))?void 0:e.setGuessedText(t)})}serializeAltText(t){var e;return null==(e=Nc(this,He))?void 0:e.serialize(t)}hasAltText(){return!!Nc(this,He)&&!Nc(this,He).isEmpty()}hasAltTextData(){var t,e;return null!=(e=null==(t=Nc(this,He))?void 0:t.hasData())&&e}addCommentButton(){return Nc(this,je)?Nc(this,je):Dc(this,je,new FI(this))}get commentColor(){return null}get comment(){const t=Nc(this,je);return{text:t.data.text,date:t.data.date,deleted:t.isDeleted(),color:this.commentColor}}set comment(t){Nc(this,je)||Dc(this,je,new FI(this)),Nc(this,je).data=t}setCommentData(t){Nc(this,je)||Dc(this,je,new FI(this)),Nc(this,je).setInitialText(t)}get hasEditedComment(){var t;return null==(t=Nc(this,je))?void 0:t.hasBeenEdited()}editComment(){return Wc(this,null,function*(){Nc(this,je)||Dc(this,je,new FI(this)),Nc(this,je).edit()})}addComment(t){this.hasEditedComment&&(t.popup={contents:this.comment.text,deleted:this.comment.deleted})}render(){var t;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=Nc(this,We)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),Rc(this,hn,En).call(this);const[n,r]=this.parentDimensions;this.parentRotation%180!=0&&(e.style.maxWidth=`${(100*r/n).toFixed(2)}%`,e.style.maxHeight=`${(100*n/r).toFixed(2)}%`);const[i,A]=this.getInitialTranslation();return this.translate(i,A),gI(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(Nc(this,on)||Dc(this,on,new UI({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:Rc(this,hn,bn).bind(this),onPinching:Rc(this,hn,Bn).bind(this),onPinchEnd:Rc(this,hn,_n).bind(this),signal:this._uiManager._signal}))),null==(t=this._uiManager._editorUndoBar)||t.hide(),e}pointerdown(t){const{isMac:e}=DU.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(Dc(this,Je,!0),this._isDraggable?Rc(this,hn,xn).call(this,t):Rc(this,hn,Cn).call(this,t))}_onStartDragging(){}_onStopDragging(){}moveInDOM(){Nc(this,rn)&&clearTimeout(Nc(this,rn)),Dc(this,rn,setTimeout(()=>{var t;Dc(this,rn,null),null==(t=this.parent)||t.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){const r=this.parentScale,[i,A]=this.pageDimensions,[s,a]=this.pageTranslation,o=t/r,l=e/r,c=this.x*i,h=this.y*A,u=this.width*i,d=this.height*A;switch(n){case 0:return[c+o+s,A-h-l-d+a,c+o+u+s,A-h-l+a];case 90:return[c+l+s,A-h+o+a,c+l+d+s,A-h+o+u+a];case 180:return[c-o-u+s,A-h+l+a,c-o+s,A-h+l+d+a];case 270:return[c-l-d+s,A-h-o-u+a,c-l+s,A-h-o+a];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[n,r,i,A]=t,s=i-n,a=A-r;switch(this.rotation){case 0:return[n,e-A,s,a];case 90:return[n,e-r,a,s];case 180:return[i,e-r,s,a];case 270:return[i,e-A,a,s];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),Dc(this,en,!0),!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),Dc(this,en,!1),!0)}isInEditMode(){return Nc(this,en)}shouldGetKeyboardEvents(){return Nc(this,nn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:A}=window;return e<A&&r>0&&t<i&&n>0}rebuild(){Rc(this,hn,En).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:(null==(t=this._initialData)?void 0:t.popupRef)||""}}serialize(t=!1,e=null){xU("An editor must be serializable")}static deserialize(t,e,n){return Wc(this,null,function*(){const r=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:n,annotationElementId:t.annotationElementId});r.rotation=t.rotation,Dc(r,De,t.accessibilityData),r._isCopy=t.isCopy||!1;const[i,A]=r.pageDimensions,[s,a,o,l]=r.getRectInCurrentCoords(t.rect,A);return r.x=s/i,r.y=a/A,r.width=o/i,r.height=l/A,r})}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t,e;if(null==(t=Nc(this,Ye))||t.abort(),Dc(this,Ye,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),Nc(this,rn)&&(clearTimeout(Nc(this,rn)),Dc(this,rn,null)),Rc(this,hn,In).call(this),this.removeEditToolbar(),Nc(this,an)){for(const t of Nc(this,an).values())clearTimeout(t);Dc(this,an,null)}this.parent=null,null==(e=Nc(this,on))||e.destroy(),Dc(this,on,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(Rc(this,hn,gn).call(this),Nc(this,ze).classList.remove("hidden"))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),Dc(this,Xe,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const n=Nc(this,ze).children;if(!Nc(this,Re)){Dc(this,Re,Array.from(n));const e=Rc(this,hn,Sn).bind(this),r=Rc(this,hn,Fn).bind(this),i=this._uiManager._signal;for(const n of Nc(this,Re)){const A=n.getAttribute("data-resizer-name");n.setAttribute("role","spinbutton"),n.addEventListener("keydown",e,{signal:i}),n.addEventListener("blur",r,{signal:i}),n.addEventListener("focus",Rc(this,hn,Ln).bind(this,A),{signal:i}),n.setAttribute("data-l10n-id",t._l10nResizer[A])}}const r=Nc(this,Re)[0];let i=0;for(const t of n){if(t===r)break;i++}const A=(360-this.rotation+this.parentRotation)%360/90*(Nc(this,Re).length/4);if(A!==i){if(A<i)for(let t=0;t<i-A;t++)Nc(this,ze).append(Nc(this,ze).firstChild);else if(A>i)for(let t=0;t<A-i;t++)Nc(this,ze).firstChild.before(Nc(this,ze).lastChild);let e=0;for(const r of n){const n=Nc(this,Re)[e++].getAttribute("data-resizer-name");r.setAttribute("data-l10n-id",t._l10nResizer[n])}}Rc(this,hn,Un).call(this,0),Dc(this,nn,!0),Nc(this,ze).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(t,e){Nc(this,nn)&&Rc(this,hn,yn).call(this,Nc(this,$e),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){Rc(this,hn,In).call(this),this.div.focus()}select(){var t,e,n;this.isSelected&&this._editToolbar||(this.isSelected=!0,this.makeResizable(),null==(t=this.div)||t.classList.add("selectedEditor"),this._editToolbar?(null==(e=this._editToolbar)||e.show(),null==(n=Nc(this,He))||n.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{var t,e;(null==(t=this.div)?void 0:t.classList.contains("selectedEditor"))&&(null==(e=this._editToolbar)||e.show())}))}unselect(){var t,e,n,r,i;this.isSelected&&(this.isSelected=!1,null==(t=Nc(this,ze))||t.classList.add("hidden"),null==(e=this.div)||e.classList.remove("selectedEditor"),(null==(n=this.div)?void 0:n.contains(document.activeElement))&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null==(r=this._editToolbar)||r.hide(),null==(i=Nc(this,He))||i.toggleAltTextBadge(!0))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return Nc(this,tn)}set isEditing(t){Dc(this,tn,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){Dc(this,Ge,!0);const 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(e,n=!1){if(n){Nc(this,an)||Dc(this,an,new Map);const{action:n}=e;let r=Nc(this,an).get(n);return r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(e),Nc(this,an).delete(n),0===Nc(this,an).size&&Dc(this,an,null)},t._telemetryTimeout),void Nc(this,an).set(n,r)}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),Dc(this,We,!1)}disable(){this.div&&(this.div.tabIndex=-1),Dc(this,We,!0)}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===(null==e?void 0:e.nodeName)&&e.classList.contains("annotationContent")&&e.remove()}};De=new WeakMap,Re=new WeakMap,He=new WeakMap,je=new WeakMap,We=new WeakMap,Ve=new WeakMap,Ke=new WeakMap,Ge=new WeakMap,ze=new WeakMap,qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,$e=new WeakMap,Je=new WeakMap,Ze=new WeakMap,tn=new WeakMap,en=new WeakMap,nn=new WeakMap,rn=new WeakMap,An=new WeakMap,sn=new WeakMap,an=new WeakMap,on=new WeakMap,ln=new WeakMap,cn=new WeakMap,hn=new WeakSet,un=function([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()},dn=new WeakSet,fn=function(t,e,n){switch(n){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},pn=function(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}},gn=function(){if(Nc(this,ze))return;Dc(this,ze,document.createElement("div")),Nc(this,ze).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const n of t){const t=document.createElement("div");Nc(this,ze).append(t),t.classList.add("resizer",n),t.setAttribute("data-resizer-name",n),t.addEventListener("pointerdown",Rc(this,hn,mn).bind(this,n),{signal:e}),t.addEventListener("contextmenu",iI,{signal:e}),t.tabIndex=-1}this.div.prepend(Nc(this,ze))},mn=function(t,e){var n;e.preventDefault();const{isMac:r}=DU.platform;if(0!==e.button||e.ctrlKey&&r)return;null==(n=Nc(this,He))||n.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,Dc(this,qe,[e.screenX,e.screenY]);const A=new AbortController,s=this._uiManager.combinedSignal(A);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",Rc(this,hn,yn).bind(this,t),{passive:!0,capture:!0,signal:s}),window.addEventListener("touchmove",AI,{passive:!1,signal:s}),window.addEventListener("contextmenu",iI,{signal:s}),Dc(this,Xe,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{var t;A.abort(),this.parent.togglePointerEvents(!0),null==(t=Nc(this,He))||t.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,Rc(this,hn,vn).call(this)};window.addEventListener("pointerup",l,{signal:s}),window.addEventListener("blur",l,{signal:s})},wn=function(t,e,n,r){this.width=n,this.height=r,this.x=t,this.y=e;const[i,A]=this.parentDimensions;this.setDims(i*n,A*r),this.fixAndSetPosition(),this._onResized()},vn=function(){if(!Nc(this,Xe))return;const{savedX:t,savedY:e,savedWidth:n,savedHeight:r}=Nc(this,Xe);Dc(this,Xe,null);const i=this.x,A=this.y,s=this.width,a=this.height;i===t&&A===e&&s===n&&a===r||this.addCommands({cmd:Rc(this,hn,wn).bind(this,i,A,s,a),undo:Rc(this,hn,wn).bind(this,t,e,n,r),mustExec:!0})},yn=function(t,e){const[n,r]=this.parentDimensions,i=this.x,A=this.y,s=this.width,a=this.height,o=II.MIN_SIZE/n,l=II.MIN_SIZE/r,c=Rc(this,hn,pn).call(this,this.rotation),h=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],u=Rc(this,hn,pn).call(this,360-this.rotation);let d,f,p=!1,g=!1;switch(t){case"topLeft":p=!0,d=(t,e)=>[0,0],f=(t,e)=>[t,e];break;case"topMiddle":d=(t,e)=>[t/2,0],f=(t,e)=>[t/2,e];break;case"topRight":p=!0,d=(t,e)=>[t,0],f=(t,e)=>[0,e];break;case"middleRight":g=!0,d=(t,e)=>[t,e/2],f=(t,e)=>[0,e/2];break;case"bottomRight":p=!0,d=(t,e)=>[t,e],f=(t,e)=>[0,0];break;case"bottomMiddle":d=(t,e)=>[t/2,e],f=(t,e)=>[t/2,0];break;case"bottomLeft":p=!0,d=(t,e)=>[0,e],f=(t,e)=>[t,0];break;case"middleLeft":g=!0,d=(t,e)=>[0,e/2],f=(t,e)=>[t,e/2]}const m=d(s,a),w=f(s,a);let v=h(...w);const y=II._round(i+v[0]),b=II._round(A+v[1]);let B,_,C=1,x=1;if(e.fromKeyboard)({deltaX:B,deltaY:_}=e);else{const{screenX:t,screenY:n}=e,[r,i]=Nc(this,qe);[B,_]=this.screenToPageTranslation(t-r,n-i),Nc(this,qe)[0]=t,Nc(this,qe)[1]=n}var E,S;if([B,_]=(E=B/n,S=_/r,[u[0]*E+u[2]*S,u[1]*E+u[3]*S]),p){const t=Math.hypot(s,a);C=x=Math.max(Math.min(Math.hypot(w[0]-m[0]-B,w[1]-m[1]-_)/t,1/s,1/a),o/s,l/a)}else g?C=GU(Math.abs(w[0]-m[0]-B),o,1)/s:x=GU(Math.abs(w[1]-m[1]-_),l,1)/a;const F=II._round(s*C),L=II._round(a*x);v=h(...f(F,L));const U=y-v[0],I=b-v[1];Nc(this,Ze)||Dc(this,Ze,[this.x,this.y,this.width,this.height]),this.width=F,this.height=L,this.x=U,this.y=I,this.setDims(n*F,r*L),this.fixAndSetPosition(),this._onResizing()},bn=function(){var t;Dc(this,Xe,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),null==(t=Nc(this,He))||t.toggle(!1),this.parent.togglePointerEvents(!1)},Bn=function(t,e,n){let r=n/e*.7+1-.7;if(1===r)return;const i=Rc(this,hn,pn).call(this,this.rotation),A=(t,e)=>[i[0]*t+i[2]*e,i[1]*t+i[3]*e],[s,a]=this.parentDimensions,o=this.x,l=this.y,c=this.width,h=this.height,u=II.MIN_SIZE/s,d=II.MIN_SIZE/a;r=Math.max(Math.min(r,1/c,1/h),u/c,d/h);const f=II._round(c*r),p=II._round(h*r);if(f===c&&p===h)return;Nc(this,Ze)||Dc(this,Ze,[o,l,c,h]);const g=A(c/2,h/2),m=II._round(o+g[0]),w=II._round(l+g[1]),v=A(f/2,p/2);this.x=m-v[0],this.y=w-v[1],this.width=f,this.height=p,this.setDims(s*f,a*p),this.fixAndSetPosition(),this._onResizing()},_n=function(){var t;null==(t=Nc(this,He))||t.toggle(!0),this.parent.togglePointerEvents(!0),Rc(this,hn,vn).call(this)},Cn=function(t){const{isMac:e}=DU.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},xn=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let n=!1;const r=new AbortController,i=this._uiManager.combinedSignal(r),A={capture:!0,passive:!1,signal:i},s=t=>{r.abort(),Dc(this,Ve,null),Dc(this,Je,!1),this._uiManager.endDragSession()||Rc(this,hn,Cn).call(this,t),n&&this._onStopDragging()};e&&(Dc(this,An,t.clientX),Dc(this,sn,t.clientY),Dc(this,Ve,t.pointerId),Dc(this,Ke,t.pointerType),window.addEventListener("pointermove",t=>{n||(n=!0,this._onStartDragging());const{clientX:e,clientY:r,pointerId:i}=t;if(i!==Nc(this,Ve))return void AI(t);const[A,s]=this.screenToPageTranslation(e-Nc(this,An),r-Nc(this,sn));Dc(this,An,e),Dc(this,sn,r),this._uiManager.dragSelectedEditors(A,s)},A),window.addEventListener("touchmove",AI,A),window.addEventListener("pointerdown",t=>{t.pointerType===Nc(this,Ke)&&(Nc(this,on)||t.isPrimary)&&s(t),AI(t)},A));const a=t=>{Nc(this,Ve)&&Nc(this,Ve)!==t.pointerId?AI(t):s(t)};window.addEventListener("pointerup",a,{signal:i}),window.addEventListener("blur",a,{signal:i})},En=function(){if(Nc(this,Ye)||!this.div)return;Dc(this,Ye,new AbortController);const t=this._uiManager.combinedSignal(Nc(this,Ye));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Sn=function(t){II._resizerKeyboardManager.exec(this,t)},Fn=function(t){var e;Nc(this,nn)&&(null==(e=t.relatedTarget)?void 0:e.parentNode)!==Nc(this,ze)&&Rc(this,hn,In).call(this)},Ln=function(t){Dc(this,$e,Nc(this,nn)?t:"")},Un=function(t){if(Nc(this,Re))for(const e of Nc(this,Re))e.tabIndex=t},In=function(){Dc(this,nn,!1),Rc(this,hn,Un).call(this,-1),Rc(this,hn,vn).call(this)},Tc(II,dn),Oc(II,"_l10n",null),Oc(II,"_l10nResizer",null),Oc(II,"_borderLineWidth",-1),Oc(II,"_colorManager",new _I),Oc(II,"_zIndex",1),Oc(II,"_telemetryTimeout",1e3);let QI=II;class kI extends QI{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const MI=3285377520,OI=4294901760,PI=65535;class NI{constructor(t){this.h1=t?4294967295&t:MI,this.h2=t?4294967295&t:MI}update(t){let e,n;if("string"==typeof t){e=new Uint8Array(2*t.length),n=0;for(let r=0,i=t.length;r<i;r++){const i=t.charCodeAt(r);i<=255?e[n++]=i:(e[n++]=i>>>8,e[n++]=255&i)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),n=e.byteLength}const r=n>>2,i=n-4*r,A=new Uint32Array(e.buffer,0,r);let s=0,a=0,o=this.h1,l=this.h2;const c=3432918353,h=461845907,u=11601,d=13715;for(let f=0;f<r;f++)1&f?(s=A[f],s=s*c&OI|s*u&PI,s=s<<15|s>>>17,s=s*h&OI|s*d&PI,o^=s,o=o<<13|o>>>19,o=5*o+3864292196):(a=A[f],a=a*c&OI|a*u&PI,a=a<<15|a>>>17,a=a*h&OI|a*d&PI,l^=a,l=l<<13|l>>>19,l=5*l+3864292196);switch(s=0,i){case 3:s^=e[4*r+2]<<16;case 2:s^=e[4*r+1]<<8;case 1:s^=e[4*r],s=s*c&OI|s*u&PI,s=s<<15|s>>>17,s=s*h&OI|s*d&PI,1&r?o^=s:l^=s}this.h1=o,this.h2=l}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&OI|36045*t&PI,e=4283543511*e&OI|(2950163797*(e<<16|t>>>16)&OI)>>>16,t^=e>>>1,t=444984403*t&OI|60499*t&PI,e=3301882366*e&OI|(3120437893*(e<<16|t>>>16)&OI)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const TI=Object.freeze({map:null,hash:"",transfer:void 0});class DI{constructor(){Tc(this,On),Tc(this,Qn,!1),Tc(this,kn,null),Tc(this,Mn,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const n=Nc(this,Mn).get(t);return void 0===n?e:Object.assign(e,n)}getRawValue(t){return Nc(this,Mn).get(t)}remove(t){if(Nc(this,Mn).delete(t),0===Nc(this,Mn).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of Nc(this,Mn).values())if(t instanceof QI)return;this.onAnnotationEditor(null)}}setValue(t,e){const n=Nc(this,Mn).get(t);let r=!1;if(void 0!==n)for(const[i,A]of Object.entries(e))n[i]!==A&&(r=!0,n[i]=A);else r=!0,Nc(this,Mn).set(t,e);r&&Rc(this,On,Pn).call(this),e instanceof QI&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return Nc(this,Mn).has(t)}get size(){return Nc(this,Mn).size}resetModified(){Nc(this,Qn)&&(Dc(this,Qn,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new RI(this)}get serializable(){if(0===Nc(this,Mn).size)return TI;const t=new Map,e=new NI,n=[],r=Object.create(null);let i=!1;for(const[A,s]of Nc(this,Mn)){const n=s instanceof QI?s.serialize(!1,r):s;n&&(t.set(A,n),e.update(`${A}:${JSON.stringify(n)}`),i||(i=!!n.bitmap))}if(i)for(const A of t.values())A.bitmap&&n.push(A.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:n}:TI}get editorStats(){var t;let e=null;const n=new Map;for(const r of Nc(this,Mn).values()){if(!(r instanceof QI))continue;const i=r.telemetryFinalData;if(!i)continue;const{type:A}=i;n.has(A)||n.set(A,Object.getPrototypeOf(r).constructor),e||(e=Object.create(null));const s=e[A]||(e[A]=new Map);for(const[e,n]of Object.entries(i)){if("type"===e)continue;let r=s.get(e);r||(r=new Map,s.set(e,r));const i=null!=(t=r.get(n))?t:0;r.set(n,i+1)}}for(const[r,i]of n)e[r]=i.computeTelemetryFinalData(e[r]);return e}resetModifiedIds(){Dc(this,kn,null)}get modifiedIds(){if(Nc(this,kn))return Nc(this,kn);const t=[];for(const e of Nc(this,Mn).values())e instanceof QI&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return Dc(this,kn,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return Nc(this,Mn).entries()}}Qn=new WeakMap,kn=new WeakMap,Mn=new WeakMap,On=new WeakSet,Pn=function(){Nc(this,Qn)||(Dc(this,Qn,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class RI extends DI{constructor(t){super(),Tc(this,Nn);const{map:e,hash:n,transfer:r}=t.serializable,i=structuredClone(e,r?{transfer:r}:null);Dc(this,Nn,{map:i,hash:n,transfer:r})}get print(){xU("Should not call PrintAnnotationStorage.print")}get serializable(){return Nc(this,Nn)}get modifiedIds(){return LU(this,"modifiedIds",{ids:new Set,hash:""})}}Nn=new WeakMap;class HI{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){Tc(this,Tn,new Set),this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),Nc(this,Tn).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(t){return Wc(this,arguments,function*({systemFontInfo:t,disableFontFace:e,_inspectFont:n}){if(t&&!Nc(this,Tn).has(t.loadedName)){if(EU(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:r,style:i}=t,A=new FontFace(e,r,i);this.addNativeFontFace(A);try{yield A.load(),Nc(this,Tn).add(e),null==n||n(t)}catch(hw){CU(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(A)}return}xU("Not implemented: loadSystemFont without the Font Loading API.")}})}bind(t){return Wc(this,null,function*(){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void(yield this.loadSystemFont(t));if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{yield e.loaded}catch(n){throw CU(`Failed to load font '${e.family}': '${n}'.`),t.disableFontFace=!0,n}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;yield new Promise(e=>{const n=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,n)})}})}get isFontLoadingAPISupported(){var t;return LU(this,"isFontLoadingAPISupported",!!(null==(t=this._document)?void 0:t.fonts))}get isSyncFontLoadingSupported(){return LU(this,"isSyncFontLoadingSupported",HL||DU.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,n={done:!1,complete:function(){for(EU(!n.done,"completeRequest() cannot be called twice."),n.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(n),n}get _loadTestFont(){return LU(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function n(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function r(t,e,n,r){return t.substring(0,e)+r+t.substring(e+n)}let i,A;const s=this._document.createElement("canvas");s.width=1,s.height=1;const a=s.getContext("2d");let o=0;const l=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=r(c,976,l.length,l);const h=1482184792;let u=n(c,16);for(i=0,A=l.length-3;i<A;i+=4)u=u-h+n(l,i)|0;var d;i<l.length&&(u=u-h+n(l+"XXX",i)|0),c=r(c,16,4,(d=u,String.fromCharCode(d>>24&255,d>>16&255,d>>8&255,255&d)));const f=`@font-face {font-family:"${l}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(f);const p=this._document.createElement("div");p.style.visibility="hidden",p.style.width=p.style.height="10px",p.style.position="absolute",p.style.top=p.style.left="0px";for(const g of[t.loadedName,l]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=g,p.append(t)}this._document.body.append(p),function t(e,n){if(++o>30)return CU("Load test font never loaded."),void n();a.font="30px "+e,a.fillText(".",0,20),a.getImageData(0,0,1,1).data[3]>0?n():setTimeout(t.bind(null,e,n))}(l,()=>{p.remove(),e.complete()})}}Tn=new WeakMap;class jI{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const n in t)this[n]=t[n];this._inspectFont=e}createNativeFontFace(){var t;if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return null==(t=this._inspectFont)||t.call(this,this),e}createFontFaceRule(){var t;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${zU(this.data)});`;let n;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return null==(t=this._inspectFont)||t.call(this,this,e),n}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const n=this.loadedName+"_path_"+e;let r;try{r=t.get(n)}catch(A){CU(`getPathGenerator - ignoring character: "${A}".`)}const i=new Path2D(r||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=i}}function WI(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const VI=t=>"object"==typeof t&&Number.isInteger(null==t?void 0:t.num)&&t.num>=0&&Number.isInteger(null==t?void 0:t.gen)&&t.gen>=0,KI=function(t,e,n){if(!Array.isArray(n)||n.length<2)return!1;const[r,i,...A]=n;if(!t(r)&&!Number.isInteger(r))return!1;if(!e(i))return!1;const s=A.length;let a=!0;switch(i.name){case"XYZ":if(s<2||s>3)return!1;break;case"Fit":case"FitB":return 0===s;case"FitH":case"FitBH":case"FitV":case"FitBV":if(s>1)return!1;break;case"FitR":if(4!==s)return!1;a=!1;break;default:return!1}for(const o of A)if(!("number"==typeof o||a&&null===o))return!1;return!0}.bind(null,VI,t=>"object"==typeof t&&"string"==typeof(null==t?void 0:t.name));class GI{constructor(){Tc(this,Dn,new Map),Tc(this,Rn,Promise.resolve())}postMessage(t,e){const n={data:structuredClone(t,e?{transfer:e}:null)};Nc(this,Rn).then(()=>{for(const[t]of Nc(this,Dn))t.call(this,n)})}addEventListener(t,e,n=null){let r=null;if((null==n?void 0:n.signal)instanceof AbortSignal){const{signal:i}=n;if(i.aborted)return void CU("LoopbackPort - cannot use an `aborted` signal.");const A=()=>this.removeEventListener(t,e);r=()=>i.removeEventListener("abort",A),i.addEventListener("abort",A)}Nc(this,Dn).set(e,r)}removeEventListener(t,e){const n=Nc(this,Dn).get(e);null==n||n(),Nc(this,Dn).delete(e)}terminate(){for(const[,t]of Nc(this,Dn))null==t||t();Nc(this,Dn).clear()}}Dn=new WeakMap,Rn=new WeakMap;const zI=1,qI=2,XI=1,YI=2,$I=3,JI=4,ZI=5,tQ=6,eQ=7,nQ=8;function rQ(){}function iQ(t){if(t instanceof PU||t instanceof kU||t instanceof IU||t instanceof MU||t instanceof QU)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||xU('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new PU(t.message);case"InvalidPDFException":return new kU(t.message);case"PasswordException":return new IU(t.message,t.code);case"ResponseException":return new MU(t.message,t.status,t.missing);case"UnknownErrorException":return new QU(t.message,t.details)}return new QU(t.message,t.toString())}class AQ{constructor(t,e,n){Tc(this,jn),Tc(this,Hn,new AbortController),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",Rc(this,jn,Wn).bind(this),{signal:Nc(this,Hn).signal})}on(t,e){const 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){const r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:r,data:e},n)}catch(A){i.reject(A)}return i.promise}sendWithStream(t,e,n,r){const i=this.streamId++,A=this.sourceName,s=this.targetName,a=this.comObj;return new ReadableStream({start:n=>{const o=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:o,pullCall:null,cancelCall:null,isClosed:!1},a.postMessage({sourceName:A,targetName:s,action:t,streamId:i,data:e,desiredSize:n.desiredSize},r),o.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[i].pullCall=e,a.postMessage({sourceName:A,targetName:s,stream:tQ,streamId:i,desiredSize:t.desiredSize}),e.promise},cancel:t=>{EU(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[i].cancelCall=e,this.streamControllers[i].isClosed=!0,a.postMessage({sourceName:A,targetName:s,stream:XI,streamId:i,reason:iQ(t)}),e.promise}},n)}destroy(){var t;null==(t=Nc(this,Hn))||t.abort(),Dc(this,Hn,null)}}Hn=new WeakMap,jn=new WeakSet,Wn=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void Rc(this,jn,Kn).call(this,t);if(t.callback){const e=t.callbackId,n=this.callbackCapabilities[e];if(!n)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===zI)n.resolve(t.data);else{if(t.callback!==qI)throw new Error("Unexpected callback case");n.reject(iQ(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const n=this.sourceName,r=t.sourceName,i=this.comObj;return void Promise.try(e,t.data).then(function(e){i.postMessage({sourceName:n,targetName:r,callback:zI,callbackId:t.callbackId,data:e})},function(e){i.postMessage({sourceName:n,targetName:r,callback:qI,callbackId:t.callbackId,reason:iQ(e)})})}t.streamId?Rc(this,jn,Vn).call(this,t):e(t.data)},Vn=function(t){const e=t.streamId,n=this.sourceName,r=t.sourceName,i=this.comObj,A=this,s=this.actionHandler[t.action],a={enqueue(t,A=1,s){if(this.isCancelled)return;const a=this.desiredSize;this.desiredSize-=A,a>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:JI,streamId:e,chunk:t},s)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:$I,streamId:e}),delete A.streamSinks[e])},error(t){EU(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:ZI,streamId:e,reason:iQ(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};a.sinkCapability.resolve(),a.ready=a.sinkCapability.promise,this.streamSinks[e]=a,Promise.try(s,t.data,a).then(function(){i.postMessage({sourceName:n,targetName:r,stream:nQ,streamId:e,success:!0})},function(t){i.postMessage({sourceName:n,targetName:r,stream:nQ,streamId:e,reason:iQ(t)})})},Kn=function(t){const e=t.streamId,n=this.sourceName,r=t.sourceName,i=this.comObj,A=this.streamControllers[e],s=this.streamSinks[e];switch(t.stream){case nQ:t.success?A.startCall.resolve():A.startCall.reject(iQ(t.reason));break;case eQ:t.success?A.pullCall.resolve():A.pullCall.reject(iQ(t.reason));break;case tQ:if(!s){i.postMessage({sourceName:n,targetName:r,stream:eQ,streamId:e,success:!0});break}s.desiredSize<=0&&t.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=t.desiredSize,Promise.try(s.onPull||rQ).then(function(){i.postMessage({sourceName:n,targetName:r,stream:eQ,streamId:e,success:!0})},function(t){i.postMessage({sourceName:n,targetName:r,stream:eQ,streamId:e,reason:iQ(t)})});break;case JI:if(EU(A,"enqueue should have stream controller"),A.isClosed)break;A.controller.enqueue(t.chunk);break;case $I:if(EU(A,"close should have stream controller"),A.isClosed)break;A.isClosed=!0,A.controller.close(),Rc(this,jn,Gn).call(this,A,e);break;case ZI:EU(A,"error should have stream controller"),A.controller.error(iQ(t.reason)),Rc(this,jn,Gn).call(this,A,e);break;case YI:t.success?A.cancelCall.resolve():A.cancelCall.reject(iQ(t.reason)),Rc(this,jn,Gn).call(this,A,e);break;case XI:if(!s)break;const a=iQ(t.reason);Promise.try(s.onCancel||rQ,a).then(function(){i.postMessage({sourceName:n,targetName:r,stream:YI,streamId:e,success:!0})},function(t){i.postMessage({sourceName:n,targetName:r,stream:YI,streamId:e,reason:iQ(t)})}),s.sinkCapability.reject(a),s.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Gn=function(t,e){return Wc(this,null,function*(){var n,r,i;yield Promise.allSettled([null==(n=t.startCall)?void 0:n.promise,null==(r=t.pullCall)?void 0:r.promise,null==(i=t.cancelCall)?void 0:i.promise]),delete this.streamControllers[e]})};class sQ{constructor({enableHWA:t=!1}){Tc(this,zn,!1),Dc(this,zn,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(t,e);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!Nc(this,zn)})}}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){xU("Abstract method `_createCanvas` called.")}}zn=new WeakMap;class aQ extends sQ{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const n=this._document.createElement("canvas");return n.width=t,n.height=e,n}}class oQ{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}fetch(t){return Wc(this,arguments,function*({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})})}_fetch(t){return Wc(this,null,function*(){xU("Abstract method `_fetch` called.")})}}class lQ extends oQ{_fetch(t){return Wc(this,null,function*(){const e=yield $U(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):TU(e)})}}class cQ{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,n,r,i){return"none"}destroy(t=!1){}}class hQ extends cQ{constructor({docId:t,ownerDocument:e=globalThis.document}){super(),Tc(this,er),Tc(this,qn),Tc(this,Xn),Tc(this,Yn),Tc(this,$n),Tc(this,Jn),Tc(this,Zn),Tc(this,tr,0),Dc(this,$n,t),Dc(this,Jn,e)}addFilter(t){if(!t)return"none";let e=Nc(this,er,nr).get(t);if(e)return e;const[n,r,i]=Rc(this,er,Ar).call(this,t),A=1===t.length?n:`${n}${r}${i}`;if(e=Nc(this,er,nr).get(A),e)return Nc(this,er,nr).set(t,e),e;const s=`g_${Nc(this,$n)}_transfer_map_${Hc(this,tr)._++}`,a=Rc(this,er,sr).call(this,s);Nc(this,er,nr).set(t,a),Nc(this,er,nr).set(A,a);const o=Rc(this,er,lr).call(this,s);return Rc(this,er,hr).call(this,n,r,i,o),a}addHCMFilter(t,e){var n;const r=`${t}-${e}`,i="base";let A=Nc(this,er,rr).get(i);if((null==A?void 0:A.key)===r)return A.url;if(A?(null==(n=A.filter)||n.remove(),A.key=r,A.url="none",A.filter=null):(A={key:r,url:"none",filter:null},Nc(this,er,rr).set(i,A)),!t||!e)return A.url;const s=Rc(this,er,dr).call(this,t);t=HU.makeHexColor(...s);const a=Rc(this,er,dr).call(this,e);if(e=HU.makeHexColor(...a),Nc(this,er,ir).style.color="","#000000"===t&&"#ffffff"===e||t===e)return A.url;const o=new Array(256);for(let d=0;d<=255;d++){const t=d/255;o[d]=t<=.03928?t/12.92:Uc((t+.055)/1.055,2.4)}const l=o.join(","),c=`g_${Nc(this,$n)}_hcm_filter`,h=A.filter=Rc(this,er,lr).call(this,c);Rc(this,er,hr).call(this,l,l,l,h),Rc(this,er,or).call(this,h);const u=(t,e)=>{const n=s[t]/255,r=a[t]/255,i=new Array(e+1);for(let A=0;A<=e;A++)i[A]=n+A/e*(r-n);return i.join(",")};return Rc(this,er,hr).call(this,u(0,5),u(1,5),u(2,5),h),A.url=Rc(this,er,sr).call(this,c),A.url}addAlphaFilter(t){let e=Nc(this,er,nr).get(t);if(e)return e;const[n]=Rc(this,er,Ar).call(this,[t]),r=`alpha_${n}`;if(e=Nc(this,er,nr).get(r),e)return Nc(this,er,nr).set(t,e),e;const i=`g_${Nc(this,$n)}_alpha_map_${Hc(this,tr)._++}`,A=Rc(this,er,sr).call(this,i);Nc(this,er,nr).set(t,A),Nc(this,er,nr).set(r,A);const s=Rc(this,er,lr).call(this,i);return Rc(this,er,ur).call(this,n,s),A}addLuminosityFilter(t){let e,n,r=Nc(this,er,nr).get(t||"luminosity");if(r)return r;if(t?([e]=Rc(this,er,Ar).call(this,[t]),n=`luminosity_${e}`):n="luminosity",r=Nc(this,er,nr).get(n),r)return Nc(this,er,nr).set(t,r),r;const i=`g_${Nc(this,$n)}_luminosity_map_${Hc(this,tr)._++}`,A=Rc(this,er,sr).call(this,i);Nc(this,er,nr).set(t,A),Nc(this,er,nr).set(n,A);const s=Rc(this,er,lr).call(this,i);return Rc(this,er,ar).call(this,s),t&&Rc(this,er,ur).call(this,e,s),A}addHighlightHCMFilter(t,e,n,r,i){var A;const s=`${e}-${n}-${r}-${i}`;let a=Nc(this,er,rr).get(t);if((null==a?void 0:a.key)===s)return a.url;if(a?(null==(A=a.filter)||A.remove(),a.key=s,a.url="none",a.filter=null):(a={key:s,url:"none",filter:null},Nc(this,er,rr).set(t,a)),!e||!n)return a.url;const[o,l]=[e,n].map(Rc(this,er,dr).bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),h=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[u,d]=[r,i].map(Rc(this,er,dr).bind(this));h<c&&([c,h,u,d]=[h,c,d,u]),Nc(this,er,ir).style.color="";const f=(t,e,n)=>{const r=new Array(256),i=(h-c)/n,A=t/255,s=(e-t)/(255*n);let a=0;for(let o=0;o<=n;o++){const t=Math.round(c+o*i),e=A+o*s;for(let n=a;n<=t;n++)r[n]=e;a=t+1}for(let o=a;o<256;o++)r[o]=r[a-1];return r.join(",")},p=`g_${Nc(this,$n)}_hcm_${t}_filter`,g=a.filter=Rc(this,er,lr).call(this,p);return Rc(this,er,or).call(this,g),Rc(this,er,hr).call(this,f(u[0],d[0],5),f(u[1],d[1],5),f(u[2],d[2],5),g),a.url=Rc(this,er,sr).call(this,p),a.url}destroy(t=!1){var e,n,r,i;t&&(null==(e=Nc(this,Zn))?void 0:e.size)||(null==(n=Nc(this,Yn))||n.parentNode.parentNode.remove(),Dc(this,Yn,null),null==(r=Nc(this,Xn))||r.clear(),Dc(this,Xn,null),null==(i=Nc(this,Zn))||i.clear(),Dc(this,Zn,null),Dc(this,tr,0))}}qn=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,$n=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,tr=new WeakMap,er=new WeakSet,nr=function(){return Nc(this,Xn)||Dc(this,Xn,new Map)},rr=function(){return Nc(this,Zn)||Dc(this,Zn,new Map)},ir=function(){if(!Nc(this,Yn)){const t=Nc(this,Jn).createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const n=Nc(this,Jn).createElementNS(qU,"svg");n.setAttribute("width",0),n.setAttribute("height",0),Dc(this,Yn,Nc(this,Jn).createElementNS(qU,"defs")),t.append(n),n.append(Nc(this,Yn)),Nc(this,Jn).body.append(t)}return Nc(this,Yn)},Ar=function(t){if(1===t.length){const e=t[0],n=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255;const r=n.join(",");return[r,r,r]}const[e,n,r]=t,i=new Array(256),A=new Array(256),s=new Array(256);for(let a=0;a<256;a++)i[a]=e[a]/255,A[a]=n[a]/255,s[a]=r[a]/255;return[i.join(","),A.join(","),s.join(",")]},sr=function(t){if(void 0===Nc(this,qn)){Dc(this,qn,"");const t=Nc(this,Jn).URL;t!==Nc(this,Jn).baseURI&&(tI(t)?CU('#createUrl: ignore "data:"-URL for performance reasons.'):Dc(this,qn,FU(t,"")))}return`url(${Nc(this,qn)}#${t})`},ar=function(t){const e=Nc(this,Jn).createElementNS(qU,"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)},or=function(t){const e=Nc(this,Jn).createElementNS(qU,"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)},lr=function(t){const e=Nc(this,Jn).createElementNS(qU,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),Nc(this,er,ir).append(e),e},cr=function(t,e,n){const r=Nc(this,Jn).createElementNS(qU,e);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),t.append(r)},hr=function(t,e,n,r){const i=Nc(this,Jn).createElementNS(qU,"feComponentTransfer");r.append(i),Rc(this,er,cr).call(this,i,"feFuncR",t),Rc(this,er,cr).call(this,i,"feFuncG",e),Rc(this,er,cr).call(this,i,"feFuncB",n)},ur=function(t,e){const n=Nc(this,Jn).createElementNS(qU,"feComponentTransfer");e.append(n),Rc(this,er,cr).call(this,n,"feFuncA",t)},dr=function(t){return Nc(this,er,ir).style.color=t,aI(getComputedStyle(Nc(this,er,ir)).getPropertyValue("color"))};class uQ{constructor({baseUrl:t=null}){this.baseUrl=t}fetch(t){return Wc(this,arguments,function*({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load font data at: ${e}`)})})}_fetch(t){return Wc(this,null,function*(){xU("Abstract method `_fetch` called.")})}}class dQ extends uQ{_fetch(t){return Wc(this,null,function*(){const e=yield $U(t,"arraybuffer");return new Uint8Array(e)})}}class fQ{constructor({baseUrl:t=null}){this.baseUrl=t}fetch(t){return Wc(this,arguments,function*({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load wasm data at: ${e}`)})})}_fetch(t){return Wc(this,null,function*(){xU("Abstract method `_fetch` called.")})}}class pQ extends fQ{_fetch(t){return Wc(this,null,function*(){const e=yield $U(t,"arraybuffer");return new Uint8Array(e)})}}function gQ(t){return Wc(this,null,function*(){const e=process.getBuiltinModule("fs"),n=yield e.promises.readFile(t);return new Uint8Array(n)})}HL&&CU("Please use the `legacy` build in Node.js environments.");class mQ extends cQ{}class wQ extends sQ{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:Kc&&"SCRIPT"===Kc.tagName.toUpperCase()&&Kc.src||new URL("etiquetas.umd.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class vQ extends oQ{_fetch(t){return Wc(this,null,function*(){return gQ(t)})}}class yQ extends uQ{_fetch(t){return Wc(this,null,function*(){return gQ(t)})}}class bQ extends fQ{_fetch(t){return Wc(this,null,function*(){return gQ(t)})}}const BQ="Fill",_Q="Stroke",CQ="Shading";function xQ(t,e){if(!e)return;const n=e[2]-e[0],r=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],n,r),t.clip(i)}class EQ{isModifyingCurrentTransform(){return!1}getPattern(){xU("Abstract method `getPattern` called.")}}class SQ extends EQ{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const n of this._colorStops)e.addColorStop(n[0],n[1]);return e}getPattern(t,e,n,r){let i;if(r===_Q||r===BQ){const A=e.current.getClippedPathBoundingBox(r,oI(t))||[0,0,0,0],s=Math.ceil(A[2]-A[0])||1,a=Math.ceil(A[3]-A[1])||1,o=e.cachedCanvases.getCanvas("pattern",s,a),l=o.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-A[0],-A[1]),n=HU.transform(n,[1,0,0,1,A[0],A[1]]),l.transform(...e.baseTransform),this.matrix&&l.transform(...this.matrix),xQ(l,this._bbox),l.fillStyle=this._createGradient(l),l.fill(),i=t.createPattern(o.canvas,"no-repeat");const c=new DOMMatrix(n);i.setTransform(c)}else xQ(t,this._bbox),i=this._createGradient(t);return i}}function FQ(t,e,n,r,i,A,s,a){const o=e.coords,l=e.colors,c=t.data,h=4*t.width;let u;o[n+1]>o[r+1]&&(u=n,n=r,r=u,u=A,A=s,s=u),o[r+1]>o[i+1]&&(u=r,r=i,i=u,u=s,s=a,a=u),o[n+1]>o[r+1]&&(u=n,n=r,r=u,u=A,A=s,s=u);const d=(o[n]+e.offsetX)*e.scaleX,f=(o[n+1]+e.offsetY)*e.scaleY,p=(o[r]+e.offsetX)*e.scaleX,g=(o[r+1]+e.offsetY)*e.scaleY,m=(o[i]+e.offsetX)*e.scaleX,w=(o[i+1]+e.offsetY)*e.scaleY;if(f>=w)return;const v=l[A],y=l[A+1],b=l[A+2],B=l[s],_=l[s+1],C=l[s+2],x=l[a],E=l[a+1],S=l[a+2],F=Math.round(f),L=Math.round(w);let U,I,Q,k,M,O,P,N;for(let T=F;T<=L;T++){if(T<g){const t=T<f?0:(f-T)/(f-g);U=d-(d-p)*t,I=v-(v-B)*t,Q=y-(y-_)*t,k=b-(b-C)*t}else{let t;t=T>w?1:g===w?0:(g-T)/(g-w),U=p-(p-m)*t,I=B-(B-x)*t,Q=_-(_-E)*t,k=C-(C-S)*t}let t;t=T<f?0:T>w?1:(f-T)/(f-w),M=d-(d-m)*t,O=v-(v-x)*t,P=y-(y-E)*t,N=b-(b-S)*t;const e=Math.round(Math.min(U,M)),n=Math.round(Math.max(U,M));let r=h*T+4*e;for(let i=e;i<=n;i++)t=(U-i)/(U-M),t<0?t=0:t>1&&(t=1),c[r++]=I-(I-O)*t|0,c[r++]=Q-(Q-P)*t|0,c[r++]=k-(k-N)*t|0,c[r++]=255}}function LQ(t,e,n){const r=e.coords,i=e.colors;let A,s;switch(e.type){case"lattice":const a=e.verticesPerRow,o=Math.floor(r.length/a)-1,l=a-1;for(A=0;A<o;A++){let e=A*a;for(let A=0;A<l;A++,e++)FQ(t,n,r[e],r[e+1],r[e+a],i[e],i[e+1],i[e+a]),FQ(t,n,r[e+a+1],r[e+1],r[e+a],i[e+a+1],i[e+1],i[e+a])}break;case"triangles":for(A=0,s=r.length;A<s;A+=3)FQ(t,n,r[A],r[A+1],r[A+2],i[A],i[A+1],i[A+2]);break;default:throw new Error("illegal figure")}}class UQ extends EQ{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,n){const r=Math.floor(this._bounds[0]),i=Math.floor(this._bounds[1]),A=Math.ceil(this._bounds[2])-r,s=Math.ceil(this._bounds[3])-i,a=Math.min(Math.ceil(Math.abs(A*t[0]*1.1)),3e3),o=Math.min(Math.ceil(Math.abs(s*t[1]*1.1)),3e3),l=A/a,c=s/o,h={coords:this._coords,colors:this._colors,offsetX:-r,offsetY:-i,scaleX:1/l,scaleY:1/c},u=a+4,d=o+4,f=n.getCanvas("mesh",u,d),p=f.context,g=p.createImageData(a,o);if(e){const t=g.data;for(let n=0,r=t.length;n<r;n+=4)t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=255}for(const m of this._figures)LQ(g,m,h);p.putImageData(g,2,2);return{canvas:f.canvas,offsetX:r-2*l,offsetY:i-2*c,scaleX:l,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(t,e,n,r){xQ(t,this._bbox);const i=new Float32Array(2);if(r===CQ)HU.singularValueDecompose2dScale(oI(t),i);else if(this.matrix){HU.singularValueDecompose2dScale(this.matrix,i);const[t,n]=i;HU.singularValueDecompose2dScale(e.baseTransform,i),i[0]*=t,i[1]*=n}else HU.singularValueDecompose2dScale(e.baseTransform,i);const A=this._createMeshCanvas(i,r===CQ?null:this._background,e.cachedCanvases);return r!==CQ&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(A.offsetX,A.offsetY),t.scale(A.scaleX,A.scaleY),t.createPattern(A.canvas,"no-repeat")}}class IQ extends EQ{getPattern(){return"hotpink"}}const QQ=1,kQ=2,MQ=class t{constructor(t,e,n,r){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=n,this.baseTransform=r}createPatternCanvas(t){const{bbox:e,operatorList:n,paintType:r,tilingType:i,color:A,canvasGraphicsFactory:s}=this;let{xstep:a,ystep:o}=this;a=Math.abs(a),o=Math.abs(o),_U("TilingType: "+i);const l=e[0],c=e[1],h=e[2],u=e[3],d=h-l,f=u-c,p=new Float32Array(2);HU.singularValueDecompose2dScale(this.matrix,p);const[g,m]=p;HU.singularValueDecompose2dScale(this.baseTransform,p);const w=g*p[0],v=m*p[1];let y=d,b=f,B=!1,_=!1;const C=Math.ceil(a*w),x=Math.ceil(o*v);C>=Math.ceil(d*w)?y=a:B=!0,x>=Math.ceil(f*v)?b=o:_=!0;const E=this.getSizeAndScale(y,this.ctx.canvas.width,w),S=this.getSizeAndScale(b,this.ctx.canvas.height,v),F=t.cachedCanvases.getCanvas("pattern",E.size,S.size),L=F.context,U=s.createCanvasGraphics(L);if(U.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(U,r,A),L.translate(-E.scale*l,-S.scale*c),U.transform(E.scale,0,0,S.scale,0,0),L.save(),this.clipBbox(U,l,c,h,u),U.baseTransform=oI(U.ctx),U.executeOperatorList(n),U.endDrawing(),L.restore(),B||_){const e=F.canvas;B&&(y=a),_&&(b=o);const n=this.getSizeAndScale(y,this.ctx.canvas.width,w),r=this.getSizeAndScale(b,this.ctx.canvas.height,v),i=n.size,A=r.size,s=t.cachedCanvases.getCanvas("pattern-workaround",i,A),h=s.context,u=B?Math.floor(d/a):0,p=_?Math.floor(f/o):0;for(let t=0;t<=u;t++)for(let n=0;n<=p;n++)h.drawImage(e,i*t,A*n,i,A,0,0,i,A);return{canvas:s.canvas,scaleX:n.scale,scaleY:r.scale,offsetX:l,offsetY:c}}return{canvas:F.canvas,scaleX:E.scale,scaleY:S.scale,offsetX:l,offsetY:c}}getSizeAndScale(e,n,r){const i=Math.max(t.MAX_PATTERN_SIZE,n);let A=Math.ceil(e*r);return A>=i?A=i:r=A/e,{scale:r,size:A}}clipBbox(t,e,n,r,i){const A=r-e,s=i-n;t.ctx.rect(e,n,A,s),HU.axialAlignedBoundingBox([e,n,r,i],oI(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,n){const r=t.ctx,i=t.current;switch(e){case QQ:const{fillStyle:t,strokeStyle:A}=this.ctx;r.fillStyle=i.fillColor=t,r.strokeStyle=i.strokeColor=A;break;case kQ:r.fillStyle=r.strokeStyle=n,i.fillColor=i.strokeColor=n;break;default:throw new OU(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,n,r){let i=n;r!==CQ&&(i=HU.transform(i,e.baseTransform),this.matrix&&(i=HU.transform(i,this.matrix)));const A=this.createPatternCanvas(e);let s=new DOMMatrix(i);s=s.translate(A.offsetX,A.offsetY),s=s.scale(1/A.scaleX,1/A.scaleY);const a=t.createPattern(A.canvas,"repeat");return a.setTransform(s),a}};Oc(MQ,"MAX_PATTERN_SIZE",3e3);let OQ=MQ;function PQ({src:t,srcPos:e=0,dest:n,width:r,height:i,nonBlackColor:A=4294967295,inverseDecode:s=!1}){const a=DU.isLittleEndian?4278190080:255,[o,l]=s?[A,a]:[a,A],c=r>>3,h=7&r,u=t.length;n=new Uint32Array(n.buffer);let d=0;for(let f=0;f<i;f++){for(const i=e+c;e<i;e++){const r=e<u?t[e]:255;n[d++]=128&r?l:o,n[d++]=64&r?l:o,n[d++]=32&r?l:o,n[d++]=16&r?l:o,n[d++]=8&r?l:o,n[d++]=4&r?l:o,n[d++]=2&r?l:o,n[d++]=1&r?l:o}if(0===h)continue;const r=e<u?t[e++]:255;for(let t=0;t<h;t++)n[d++]=r&1<<7-t?l:o}return{srcPos:e,destPos:d}}const NQ=16,TQ=new DOMMatrix,DQ=new Float32Array(2),RQ=new Float32Array([1/0,1/0,-1/0,-1/0]);class HQ{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,n){let r;return void 0!==this.cache[t]?(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(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function jQ(t,e,n,r,i,A,s,a,o,l){const[c,h,u,d,f,p]=oI(t);if(0===h&&0===u){const g=s*c+f,m=Math.round(g),w=a*d+p,v=Math.round(w),y=(s+o)*c+f,b=Math.abs(Math.round(y)-m)||1,B=(a+l)*d+p,_=Math.abs(Math.round(B)-v)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(d),m,v),t.drawImage(e,n,r,i,A,0,0,b,_),t.setTransform(c,h,u,d,f,p),[b,_]}if(0===c&&0===d){const g=a*u+f,m=Math.round(g),w=s*h+p,v=Math.round(w),y=(a+l)*u+f,b=Math.abs(Math.round(y)-m)||1,B=(s+o)*h+p,_=Math.abs(Math.round(B)-v)||1;return t.setTransform(0,Math.sign(h),Math.sign(u),0,m,v),t.drawImage(e,n,r,i,A,0,0,_,b),t.setTransform(c,h,u,d,f,p),[_,b]}t.drawImage(e,n,r,i,A,s,a,o,l);return[Math.hypot(c,h)*o,Math.hypot(u,d)*l]}class WQ{constructor(t,e){Oc(this,"alphaIsShape",!1),Oc(this,"fontSize",0),Oc(this,"fontSizeScale",1),Oc(this,"textMatrix",null),Oc(this,"textMatrixScale",1),Oc(this,"fontMatrix",jL),Oc(this,"leading",0),Oc(this,"x",0),Oc(this,"y",0),Oc(this,"lineX",0),Oc(this,"lineY",0),Oc(this,"charSpacing",0),Oc(this,"wordSpacing",0),Oc(this,"textHScale",1),Oc(this,"textRenderingMode",nU),Oc(this,"textRise",0),Oc(this,"fillColor","#000000"),Oc(this,"strokeColor","#000000"),Oc(this,"patternFill",!1),Oc(this,"patternStroke",!1),Oc(this,"fillAlpha",1),Oc(this,"strokeAlpha",1),Oc(this,"lineWidth",1),Oc(this,"activeSMask",null),Oc(this,"transferMaps","none"),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=RQ.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=BQ,e=null){const n=this.minMax.slice();if(t===_Q){e||xU("Stroke bounding box must include transform."),HU.singularValueDecompose2dScale(e,DQ);const t=DQ[0]*this.lineWidth/2,r=DQ[1]*this.lineWidth/2;n[0]-=t,n[1]-=r,n[2]+=t,n[3]+=r}return n}updateClipFromPath(){const t=HU.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(RQ,0)}getClippedPathBoundingBox(t=BQ,e=null){return HU.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function VQ(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const n=e.height,r=e.width,i=n%NQ,A=(n-i)/NQ,s=0===i?A:A+1,a=t.createImageData(r,NQ);let o,l=0;const c=e.data,h=a.data;let u,d,f,p;if(e.kind===oU.GRAYSCALE_1BPP){const e=c.byteLength,n=new Uint32Array(h.buffer,0,h.byteLength>>2),p=n.length,g=r+7>>3,m=4294967295,w=DU.isLittleEndian?4278190080:255;for(u=0;u<s;u++){for(f=u<A?NQ:i,o=0,d=0;d<f;d++){const t=e-l;let i=0;const A=t>g?r:8*t-7,s=-8&A;let a=0,h=0;for(;i<s;i+=8)h=c[l++],n[o++]=128&h?m:w,n[o++]=64&h?m:w,n[o++]=32&h?m:w,n[o++]=16&h?m:w,n[o++]=8&h?m:w,n[o++]=4&h?m:w,n[o++]=2&h?m:w,n[o++]=1&h?m:w;for(;i<A;i++)0===a&&(h=c[l++],a=128),n[o++]=h&a?m:w,a>>=1}for(;o<p;)n[o++]=0;t.putImageData(a,0,u*NQ)}}else if(e.kind===oU.RGBA_32BPP){for(d=0,p=r*NQ*4,u=0;u<A;u++)h.set(c.subarray(l,l+p)),l+=p,t.putImageData(a,0,d),d+=NQ;u<s&&(p=r*i*4,h.set(c.subarray(l,l+p)),t.putImageData(a,0,d))}else{if(e.kind!==oU.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(f=NQ,p=r*f,u=0;u<s;u++){for(u>=A&&(f=i,p=r*f),o=0,d=p;d--;)h[o++]=c[l++],h[o++]=c[l++],h[o++]=c[l++],h[o++]=255;t.putImageData(a,0,u*NQ)}}}function KQ(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const n=e.height,r=e.width,i=n%NQ,A=(n-i)/NQ,s=0===i?A:A+1,a=t.createImageData(r,NQ);let o=0;const l=e.data,c=a.data;for(let h=0;h<s;h++){const e=h<A?NQ:i;({srcPos:o}=PQ({src:l,srcPos:o,dest:c,width:r,height:e,nonBlackColor:0})),t.putImageData(a,0,h*NQ)}}function GQ(t,e){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const r of n)void 0!==t[r]&&(e[r]=t[r]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function zQ(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function qQ(t,e){if(e)return!0;HU.singularValueDecompose2dScale(t,DQ);const n=Math.fround(hI.pixelRatio*YU.PDF_TO_CSS_UNITS);return DQ[0]<=n&&DQ[1]<=n}const XQ=["butt","round","square"],YQ=["miter","round","bevel"],$Q={},JQ={};fr=new WeakSet,pr=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},gr=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},mr=function(t,e,n){const r=new Path2D;return r.addPath(t,new DOMMatrix(n).invertSelf().multiplySelf(e)),r};let ZQ=class t{constructor(t,e,n,r,i,{optionalContentConfig:A,markedContentStack:s=null},a,o){Tc(this,fr),this.ctx=t,this.current=new WQ(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=i,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=s||[],this.optionalContentConfig=A,this.cachedCanvases=new HQ(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=a,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=o,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:n=!1,background:r=null}){const i=this.ctx.canvas.width,A=this.ctx.canvas.height,s=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,i,A),this.ctx.fillStyle=s,n){const t=this.cachedCanvases.getCanvas("transparent",i,A);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...oI(this.compositeCtx))}this.ctx.save(),zQ(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=oI(this.ctx)}executeOperatorList(t,e,n,r){const i=t.argsArray,A=t.fnArray;let s=e||0;const a=i.length;if(a===s)return s;const o=a-s>10&&"function"==typeof n,l=o?Date.now()+15:0;let c=0;const h=this.commonObjs,u=this.objs;let d;for(;;){if(void 0!==r&&s===r.nextBreakPoint)return r.breakIt(s,n),s;if(d=A[s],d!==gU.dependency)this[d].apply(this,i[s]);else for(const t of i[s]){const e=t.startsWith("g_")?h:u;if(!e.has(t))return e.get(t,n),s}if(s++,s===a)return s;if(o&&++c>10){if(Date.now()>l)return n(),s;c=0}}}endDrawing(){Rc(this,fr,pr).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),Rc(this,fr,gr).call(this)}_scaleImage(t,e){var n,r;const i=null!=(n=t.width)?n:t.displayWidth,A=null!=(r=t.height)?r:t.displayHeight;let s,a,o=Math.max(Math.hypot(e[0],e[1]),1),l=Math.max(Math.hypot(e[2],e[3]),1),c=i,h=A,u="prescale1";for(;o>2&&c>1||l>2&&h>1;){let e=c,n=h;o>2&&c>1&&(e=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c/2),o/=c/e),l>2&&h>1&&(n=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,l/=h/n),s=this.cachedCanvases.getCanvas(u,e,n),a=s.context,a.clearRect(0,0,e,n),a.drawImage(t,0,0,c,h,0,0,e,n),t=s.canvas,c=e,h=n,u="prescale1"===u?"prescale2":"prescale1"}return{img:t,paintWidth:c,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:n,height:r}=t,i=this.current.fillColor,A=this.current.patternFill,s=oI(e);let a,o,l,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;o=JSON.stringify(A?s:[s.slice(0,4),i]),a=this._cachedBitmapsMap.get(e),a||(a=new Map,this._cachedBitmapsMap.set(e,a));const n=a.get(o);if(n&&!A){return{canvas:n,offsetX:Math.round(Math.min(s[0],s[2])+s[4]),offsetY:Math.round(Math.min(s[1],s[3])+s[5])}}l=n}l||(c=this.cachedCanvases.getCanvas("maskCanvas",n,r),KQ(c.context,t));let h=HU.transform(s,[1/n,0,0,-1/r,0,0]);h=HU.transform(h,[1,0,0,1,0,-r]);const u=RQ.slice();HU.axialAlignedBoundingBox([0,0,n,r],h,u);const[d,f,p,g]=u,m=Math.round(p-d)||1,w=Math.round(g-f)||1,v=this.cachedCanvases.getCanvas("fillCanvas",m,w),y=v.context,b=d,B=f;y.translate(-b,-B),y.transform(...h),l||(l=this._scaleImage(c.canvas,lI(y)),l=l.img,a&&A&&a.set(o,l)),y.imageSmoothingEnabled=qQ(oI(y),t.interpolate),jQ(y,l,0,0,l.width,l.height,0,0,n,r),y.globalCompositeOperation="source-in";const _=HU.transform(lI(y),[1,0,0,1,-b,-B]);return y.fillStyle=A?i.getPattern(e,this,_,BQ):i,y.fillRect(0,0,n,r),a&&!A&&(this.cachedCanvases.delete("fillCanvas"),a.set(o,v.canvas)),{canvas:v.canvas,offsetX:Math.round(b),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=XQ[t]}setLineJoin(t){this.ctx.lineJoin=YQ[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(t),n.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[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.ctx.globalAlpha=this.current.fillAlpha=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)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(n,t,e);this.suspendedCtx=this.ctx;const i=this.ctx=r.context;i.setTransform(this.suspendedCtx.getTransform()),GQ(this.suspendedCtx,i),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,n){e.translate(t,n),this.__originalTranslate(t,n)},t.scale=function(t,n){e.scale(t,n),this.__originalScale(t,n)},t.transform=function(t,n,r,i,A,s){e.transform(t,n,r,i,A,s),this.__originalTransform(t,n,r,i,A,s)},t.setTransform=function(t,n,r,i,A,s){e.setTransform(t,n,r,i,A,s),this.__originalSetTransform(t,n,r,i,A,s)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,n){e.moveTo(t,n),this.__originalMoveTo(t,n)},t.lineTo=function(t,n){e.lineTo(t,n),this.__originalLineTo(t,n)},t.bezierCurveTo=function(t,n,r,i,A,s){e.bezierCurveTo(t,n,r,i,A,s),this.__originalBezierCurveTo(t,n,r,i,A,s)},t.rect=function(t,n,r,i){e.rect(t,n,r,i),this.__originalRect(t,n,r,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(i,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),GQ(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,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){const i=r[0],A=r[1],s=r[2]-i,a=r[3]-A;0!==s&&0!==a&&(this.genericComposeSMask(e.context,n,s,a,e.subtype,e.backdrop,e.transferMap,i,A,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,i,A,s,a,o,l,c){let h=t.canvas,u=a-l,d=o-c;if(A)if(u<0||d<0||u+n>h.width||d+r>h.height){const t=this.cachedCanvases.getCanvas("maskExtension",n,r),e=t.context;e.drawImage(h,-u,-d),e.globalCompositeOperation="destination-atop",e.fillStyle=A,e.fillRect(0,0,n,r),e.globalCompositeOperation="source-over",h=t.canvas,u=d=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,d,n,r),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=A,t.fillRect(u,d,n,r),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===i&&s?e.filter=this.filterFactory.addAlphaFilter(s):"Luminosity"===i&&(e.filter=this.filterFactory.addLuminosityFilter(s));const f=new Path2D;f.rect(a,o,n,r),e.clip(f),e.globalCompositeOperation="destination-in",e.drawImage(h,u,d,n,r,a,o,n,r),e.restore()}save(){this.inSMaskMode&&GQ(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&GQ(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,n,r,i,A){this.ctx.transform(t,e,n,r,i,A),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,n){let[r]=e;if(!n)return r||(r=e[0]=new Path2D),void this[t](r);if(!(r instanceof Path2D)){const t=e[0]=new Path2D;for(let e=0,n=r.length;e<n;)switch(r[e++]){case mU:t.moveTo(r[e++],r[e++]);break;case wU:t.lineTo(r[e++],r[e++]);break;case vU:t.bezierCurveTo(r[e++],r[e++],r[e++],r[e++],r[e++],r[e++]);break;case yU:t.closePath();break;default:CU(`Unrecognized drawing path operator: ${r[e-1]}`)}r=t}HU.axialAlignedBoundingBox(n,oI(this.ctx),this.current.minMax),this[t](r)}closePath(){this.ctx.closePath()}stroke(t,e=!0){const n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof r&&(null==r?void 0:r.getPattern)){const e=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,lI(n),_Q),e){const r=new Path2D;r.addPath(t,n.getTransform().invertSelf().multiplySelf(e)),t=r}this.rescaleAndStroke(t,!1),n.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(_Q,oI(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,e=!0){const n=this.ctx,r=this.current.fillColor;let i=!1;if(this.current.patternFill){const e=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.fillStyle=r.getPattern(n,this,lI(n),BQ),e){const r=new Path2D;r.addPath(t,n.getTransform().invertSelf().multiplySelf(e)),t=r}i=!0}const A=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==A&&(this.pendingEOFill?(n.fill(t,"evenodd"),this.pendingEOFill=!1):n.fill(t)),i&&n.restore(),e&&this.consumePath(t,A)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=$Q}eoClip(){this.pendingClip=JQ}beginText(){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return;const n=new Path2D,r=e.getTransform().invertSelf();for(const{transform:i,x:A,y:s,fontSize:a,path:o}of t)o&&n.addPath(o,new DOMMatrix(i).preMultiplySelf(r).translate(A,s).scale(a,-a));e.clip(n),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){var n;const r=this.commonObjs.get(t),i=this.current;if(!r)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=r.fontMatrix||jL,0!==i.fontMatrix[0]&&0!==i.fontMatrix[3]||CU("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=r,this.current.fontSize=e,r.isType3Font)return;const A=r.loadedName||"sans-serif",s=(null==(n=r.systemFontInfo)?void 0:n.css)||`"${A}", ${r.fallbackName}`;let a="normal";r.black?a="900":r.bold&&(a="bold");const o=r.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${s}`}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){const{current:e}=this;e.textMatrix=t,e.textMatrixScale=Math.hypot(t[0],t[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,n,r,i){const A=this.ctx,s=this.current,a=s.font,o=s.textRenderingMode,l=s.fontSize/s.fontSizeScale,c=o&sU,h=!!(o&aU),u=s.patternFill&&!a.missingFile,d=s.patternStroke&&!a.missingFile;let f;if((a.disableFontFace||h||u||d)&&!a.missingFile&&(f=a.getPathGenerator(this.commonObjs,t)),f&&(a.disableFontFace||u||d)){let t;if(A.save(),A.translate(e,n),A.scale(l,-l),c!==nU&&c!==iU||(r?(t=A.getTransform(),A.setTransform(...r),A.fill(Rc(this,fr,mr).call(this,f,t,r))):A.fill(f)),c===rU||c===iU)if(i){t||(t=A.getTransform()),A.setTransform(...i);const{a:e,b:n,c:r,d:s}=t,a=HU.inverseTransform(i),o=HU.transform([e,n,r,s,0,0],a);HU.singularValueDecompose2dScale(o,DQ),A.lineWidth*=Math.max(DQ[0],DQ[1])/l,A.stroke(Rc(this,fr,mr).call(this,f,t,i))}else A.lineWidth/=l,A.stroke(f);A.restore()}else c!==nU&&c!==iU||A.fillText(t,e,n),c!==rU&&c!==iU||A.strokeText(t,e,n);if(h){(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:oI(A),x:e,y:n,fontSize:l,path:f})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let n=!1;for(let r=3;r<e.length;r+=4)if(e[r]>0&&e[r]<255){n=!0;break}return LU(this,"isFontSubpixelAAEnabled",n)}showText(t){const e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);const r=e.fontSize;if(0===r)return;const i=this.ctx,A=e.fontSizeScale,s=e.charSpacing,a=e.wordSpacing,o=e.fontDirection,l=e.textHScale*o,c=t.length,h=n.vertical,u=h?1:-1,d=n.defaultVMetrics,f=r*e.fontMatrix[0],p=e.textRenderingMode===nU&&!n.disableFontFace&&!e.patternFill;let g,m;if(i.save(),e.textMatrix&&i.transform(...e.textMatrix),i.translate(e.x,e.y+e.textRise),o>0?i.scale(l,-1):i.scale(l,1),e.patternFill){i.save();const t=e.fillColor.getPattern(i,this,lI(i),BQ);g=oI(i),i.restore(),i.fillStyle=t}if(e.patternStroke){i.save();const t=e.strokeColor.getPattern(i,this,lI(i),_Q);m=oI(i),i.restore(),i.strokeStyle=t}let w=e.lineWidth;const v=e.textMatrixScale;if(0===v||0===w){const t=e.textRenderingMode&sU;t!==rU&&t!==iU||(w=this.getSinglePixelWidth())}else w/=v;if(1!==A&&(i.scale(A,A),w/=A),i.lineWidth=w,n.isInvalidPDFjsFont){const n=[];let r=0;for(const e of t)n.push(e.unicode),r+=e.width;return i.fillText(n.join(""),0,0),e.x+=r*f*l,i.restore(),void this.compose()}let y,b=0;for(y=0;y<c;++y){const e=t[y];if("number"==typeof e){b+=u*e*r/1e3;continue}let l=!1;const c=(e.isSpace?a:0)+s,w=e.fontChar,v=e.accent;let B,_,C=e.width;if(h){const t=e.vmetric||d,n=-(e.vmetric?t[1]:.5*C)*f,r=t[2]*f;C=t?-t[0]:C,B=n/A,_=(b+r)/A}else B=b/A,_=0;if(n.remeasure&&C>0){const t=1e3*i.measureText(w).width/r*A;if(C<t&&this.isFontSubpixelAAEnabled){const e=C/t;l=!0,i.save(),i.scale(e,1),B/=e}else C!==t&&(B+=(C-t)/2e3*r/A)}if(this.contentVisible&&(e.isInFont||n.missingFile))if(p&&!v)i.fillText(w,B,_);else if(this.paintChar(w,B,_,g,m),v){const t=B+r*v.offset.x/A,e=_-r*v.offset.y/A;this.paintChar(v.fontChar,t,e,g,m)}b+=h?C*f-c*o:C*f+c*o,l&&i.restore()}h?e.y-=b:e.x+=b*l,i.restore(),this.compose()}showType3Text(t){const e=this.ctx,n=this.current,r=n.font,i=n.fontSize,A=n.fontDirection,s=r.vertical?1:-1,a=n.charSpacing,o=n.wordSpacing,l=n.textHScale*A,c=n.fontMatrix||jL,h=t.length;let u,d,f,p;if(!(n.textRenderingMode===AU)&&0!==i){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),n.textMatrix&&e.transform(...n.textMatrix),e.translate(n.x,n.y+n.textRise),e.scale(l,A),u=0;u<h;++u){if(d=t[u],"number"==typeof d){p=s*d*i/1e3,this.ctx.translate(p,0),n.x+=p*l;continue}const A=(d.isSpace?o:0)+a,h=r.charProcOperatorList[d.operatorListId];h?this.contentVisible&&(this.save(),e.scale(i,i),e.transform(...c),this.executeOperatorList(h),this.restore()):CU(`Type3 character "${d.operatorListId}" is not available.`);const g=[d.width,0];HU.applyTransform(g,c),f=g[0]*i+A,e.translate(f,0),n.x+=f*l}e.restore()}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,n,r,i,A){const s=new Path2D;s.rect(n,r,i-n,A-r),this.ctx.clip(s),this.endPath()}getColorN_Pattern(e){let n;if("TilingPattern"===e[0]){const r=this.baseTransform||oI(this.ctx),i={createCanvasGraphics:e=>new t(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};n=new OQ(e,this.ctx,i,r)}else n=this._getPattern(e[1],e[2]);return n}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){this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t){this.ctx.fillStyle=this.current.fillColor=t,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=function(t){switch(t[0]){case"RadialAxial":return new SQ(t);case"Mesh":return new UQ(t);case"Dummy":return new IQ}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,n)),e&&(n.matrix=e),n}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const n=this._getPattern(t);e.fillStyle=n.getPattern(e,this,lI(e),CQ);const r=lI(e);if(r){const{width:t,height:n}=e.canvas,i=RQ.slice();HU.axialAlignedBoundingBox([0,0,t,n],r,i);const[A,s,a,o]=i;this.ctx.fillRect(A,s,a-A,o-s)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){xU("Should not call beginInlineImage")}beginImageData(){xU("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=oI(this.ctx),e)){HU.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[t,n,r,i]=e,A=new Path2D;A.rect(t,n,r-t,i-n),this.ctx.clip(A),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||_U("TODO: Support non-isolated groups."),t.knockout&&CU("Knockout groups not supported.");const n=oI(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let r=RQ.slice();HU.axialAlignedBoundingBox(t.bbox,oI(e),r);const i=[0,0,e.canvas.width,e.canvas.height];r=HU.intersect(r,i)||[0,0,0,0];const A=Math.floor(r[0]),s=Math.floor(r[1]),a=Math.max(Math.ceil(r[2])-A,1),o=Math.max(Math.ceil(r[3])-s,1);this.current.startNewPathAndClipBox([0,0,a,o]);let l="groupAt"+this.groupLevel;t.smask&&(l+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(l,a,o),h=c.context;h.translate(-A,-s),h.transform(...n);let u=new Path2D;const[d,f,p,g]=t.bbox;if(u.rect(d,f,p-d,g-f),t.matrix){const e=new Path2D;e.addPath(u,new DOMMatrix(t.matrix)),u=e}h.clip(u),t.smask?this.smaskStack.push({canvas:c.canvas,context:h,offsetX:A,offsetY:s,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(A,s),e.save()),GQ(e,h),this.ctx=h,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,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();const t=oI(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const n=RQ.slice();HU.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t,n),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,n,r,i){if(Rc(this,fr,pr).call(this),zQ(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],A=e[3]-e[1];if(i&&this.annotationCanvasMap){(n=n.slice())[4]-=e[0],n[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=r,e[3]=A,HU.singularValueDecompose2dScale(oI(this.ctx),DQ);const{viewportScale:i}=this,s=Math.ceil(r*this.outputScaleX*i),a=Math.ceil(A*this.outputScaleY*i);this.annotationCanvas=this.canvasFactory.create(s,a);const{canvas:o,context:l}=this.annotationCanvas;this.annotationCanvasMap.set(t,o),this.annotationCanvas.savedCtx=this.ctx,this.ctx=l,this.ctx.save(),this.ctx.setTransform(DQ[0],0,0,-DQ[1],0,A*DQ[1]),zQ(this.ctx)}else{zQ(this.ctx),this.endPath();const t=new Path2D;t.rect(e[0],e[1],r,A),this.ctx.clip(t)}}this.current=new WQ(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),Rc(this,fr,gr).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const n=this.ctx,r=this._createMaskCanvas(t),i=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(i,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,n=0,r=0,i,A){if(!this.contentVisible)return;t=this.getObject(t.data,t);const s=this.ctx;s.save();const a=oI(s);s.transform(e,n,r,i,0,0);const o=this._createMaskCanvas(t);s.setTransform(1,0,0,1,o.offsetX-a[4],o.offsetY-a[5]);for(let l=0,c=A.length;l<c;l+=2){const t=HU.transform(a,[e,n,r,i,A[l],A[l+1]]);s.drawImage(o.canvas,t[4],t[5])}s.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,n=this.current.fillColor,r=this.current.patternFill;for(const i of t){const{data:t,width:A,height:s,transform:a}=i,o=this.cachedCanvases.getCanvas("maskCanvas",A,s),l=o.context;l.save();KQ(l,this.getObject(t,i)),l.globalCompositeOperation="source-in",l.fillStyle=r?n.getPattern(l,this,lI(e),BQ):n,l.fillRect(0,0,A,s),l.restore(),e.save(),e.transform(...a),e.scale(1,-1),jQ(e,o.canvas,0,0,A,s,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):CU("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,n,r){if(!this.contentVisible)return;const i=this.getObject(t);if(!i)return void CU("Dependent image isn't ready yet");const A=i.width,s=i.height,a=[];for(let o=0,l=r.length;o<l;o+=2)a.push({transform:[e,0,0,n,r[o],r[o+1]],x:0,y:0,w:A,h:s});this.paintInlineImageXObjectGroup(i,a)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:n,height:r}=t,i=this.cachedCanvases.getCanvas("inlineImage",n,r),A=i.context;return A.filter=this.current.transferMaps,A.drawImage(e,0,0),A.filter="none",i.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,n=t.height,r=this.ctx;this.save();const{filter:i}=r;let A;if("none"!==i&&""!==i&&(r.filter="none"),r.scale(1/e,-1/n),t.bitmap)A=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)A=t;else{const r=this.cachedCanvases.getCanvas("inlineImage",e,n).context;VQ(r,t),A=this.applyTransferMapsToCanvas(r)}const s=this._scaleImage(A,lI(r));r.imageSmoothingEnabled=qQ(oI(r),t.interpolate),jQ(r,s.img,0,0,s.paintWidth,s.paintHeight,0,-n,e,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const n=this.ctx;let r;if(t.bitmap)r=t.bitmap;else{const e=t.width,n=t.height,i=this.cachedCanvases.getCanvas("inlineImage",e,n).context;VQ(i,t),r=this.applyTransferMapsToCanvas(i)}for(const i of e)n.save(),n.transform(...i.transform),n.scale(1,-1),jQ(n,r,i.x,i.y,i.w,i.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){"OC"===t?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,e){const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const r=this.ctx;this.pendingClip&&(n||(this.pendingClip===JQ?r.clip(t,"evenodd"):r.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=oI(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),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(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:n,c:r,d:i}=this.ctx.getTransform();let A,s;if(0===n&&0===r){const n=Math.abs(e),r=Math.abs(i);if(n===r)if(0===t)A=s=1/n;else{const e=n*t;A=s=e<1?1/e:1}else if(0===t)A=1/n,s=1/r;else{const e=n*t,i=r*t;A=e<1?1/e:1,s=i<1?1/i:1}}else{const a=Math.abs(e*i-n*r),o=Math.hypot(e,n),l=Math.hypot(r,i);if(0===t)A=l/a,s=o/a;else{const e=t*a;A=l>e?l/e:1,s=o>e?o/e:1}}this._cachedScaleForStroking[0]=A,this._cachedScaleForStroking[1]=s}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:n,current:{lineWidth:r}}=this,[i,A]=this.getScaleForStroking();if(i===A)return n.lineWidth=(r||1)*i,void n.stroke(t);const s=n.getLineDash();e&&n.save(),n.scale(i,A),TQ.a=1/i,TQ.d=1/A;const a=new Path2D;if(a.addPath(t,TQ),s.length>0){const t=Math.max(i,A);n.setLineDash(s.map(e=>e/t)),n.lineDashOffset/=t}n.lineWidth=r||1,n.stroke(a),e&&n.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};for(const c3 in gU)void 0!==ZQ.prototype[c3]&&(ZQ.prototype[gU[c3]]=ZQ.prototype[c3]);class tk{static get workerPort(){return Nc(this,wr)}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");Dc(this,wr,t)}static get workerSrc(){return Nc(this,vr)}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");Dc(this,vr,t)}}wr=new WeakMap,vr=new WeakMap,Tc(tk,wr,null),Tc(tk,vr,"");class ek{constructor({parsedData:t,rawData:e}){Tc(this,yr),Tc(this,br),Dc(this,yr,t),Dc(this,br,e)}getRaw(){return Nc(this,br)}get(t){var e;return null!=(e=Nc(this,yr).get(t))?e:null}[Symbol.iterator](){return Nc(this,yr).entries()}}yr=new WeakMap,br=new WeakMap;const nk=Symbol("INTERNAL");class rk{constructor(t,{name:e,intent:n,usage:r,rbGroups:i}){Tc(this,Br,!1),Tc(this,_r,!1),Tc(this,Cr,!1),Tc(this,xr,!0),Dc(this,Br,!!(t&KL)),Dc(this,_r,!!(t&GL)),this.name=e,this.intent=n,this.usage=r,this.rbGroups=i}get visible(){if(Nc(this,Cr))return Nc(this,xr);if(!Nc(this,xr))return!1;const{print:t,view:e}=this.usage;return Nc(this,Br)?"OFF"!==(null==e?void 0:e.viewState):!Nc(this,_r)||"OFF"!==(null==t?void 0:t.printState)}_setVisible(t,e,n=!1){t!==nk&&xU("Internal method `_setVisible` called."),Dc(this,Cr,n),Dc(this,xr,e)}}Br=new WeakMap,_r=new WeakMap,Cr=new WeakMap,xr=new WeakMap;class ik{constructor(t,e=KL){if(Tc(this,Ur),Tc(this,Er,null),Tc(this,Sr,new Map),Tc(this,Fr,null),Tc(this,Lr,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,Dc(this,Lr,t.order);for(const n of t.groups)Nc(this,Sr).set(n.id,new rk(e,n));if("OFF"===t.baseState)for(const t of Nc(this,Sr).values())t._setVisible(nk,!1);for(const e of t.on)Nc(this,Sr).get(e)._setVisible(nk,!0);for(const e of t.off)Nc(this,Sr).get(e)._setVisible(nk,!1);Dc(this,Fr,this.getHash())}}isVisible(t){if(0===Nc(this,Sr).size)return!0;if(!t)return _U("Optional content group not defined."),!0;if("OCG"===t.type)return Nc(this,Sr).has(t.id)?Nc(this,Sr).get(t.id).visible:(CU(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return Rc(this,Ur,Ir).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(Nc(this,Sr).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(!Nc(this,Sr).get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(!Nc(this,Sr).get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(Nc(this,Sr).get(e).visible)return!1}return!0}return CU(`Unknown optional content policy ${t.policy}.`),!0}return CU(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,n=!0){var r;const i=Nc(this,Sr).get(t);if(i){if(n&&e&&i.rbGroups.length)for(const e of i.rbGroups)for(const n of e)n!==t&&(null==(r=Nc(this,Sr).get(n))||r._setVisible(nk,!1,!0));i._setVisible(nk,!!e,!0),Dc(this,Er,null)}else CU(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let n;for(const r of t){switch(r){case"ON":case"OFF":case"Toggle":n=r;continue}const t=Nc(this,Sr).get(r);if(t)switch(n){case"ON":this.setVisibility(r,!0,e);break;case"OFF":this.setVisibility(r,!1,e);break;case"Toggle":this.setVisibility(r,!t.visible,e)}}Dc(this,Er,null)}get hasInitialVisibility(){return null===Nc(this,Fr)||this.getHash()===Nc(this,Fr)}getOrder(){return Nc(this,Sr).size?Nc(this,Lr)?Nc(this,Lr).slice():[...Nc(this,Sr).keys()]:null}getGroup(t){return Nc(this,Sr).get(t)||null}getHash(){if(null!==Nc(this,Er))return Nc(this,Er);const t=new NI;for(const[e,n]of Nc(this,Sr))t.update(`${e}:${n.visible}`);return Dc(this,Er,t.hexdigest())}[Symbol.iterator](){return Nc(this,Sr).entries()}}Er=new WeakMap,Sr=new WeakMap,Fr=new WeakMap,Lr=new WeakMap,Ur=new WeakSet,Ir=function(t){const e=t.length;if(e<2)return!0;const n=t[0];for(let r=1;r<e;r++){const e=t[r];let i;if(Array.isArray(e))i=Rc(this,Ur,Ir).call(this,e);else{if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;i=Nc(this,Sr).get(e).visible}switch(n){case"And":if(!i)return!1;break;case"Or":if(i)return!0;break;case"Not":return!i;default:return!0}}return"And"===n};class Ak{constructor(t,{disableRange:e=!1,disableStream:n=!1}){EU(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:r,initialData:i,progressiveDone:A,contentDispositionFilename:s}=t;if(this._queuedChunks=[],this._progressiveDone=A,this._contentDispositionFilename=s,(null==i?void 0:i.length)>0){const t=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!e,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const n=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{EU(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(n),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t,e;return null!=(e=null==(t=this._fullRequestReader)?void 0:t._loaded)?e:0}_onProgress(t){var e,n,r,i;void 0===t.total?null==(n=null==(e=this._rangeReaders[0])?void 0:e.onProgress)||n.call(e,{loaded:t.loaded}):null==(i=null==(r=this._fullRequestReader)?void 0:r.onProgress)||i.call(r,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;null==(t=this._fullRequestReader)||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){EU(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new sk(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new ak(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(n),n}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const n of this._rangeReaders.slice(0))n.cancel(t);this._pdfDataRangeTransport.abort()}}class sk{constructor(t,e,n=!1,r=null){this._stream=t,this._done=n||!1,this._filename=eI(r)?r:null,this._queuedChunks=e||[],this._loaded=0;for(const i of this._queuedChunks)this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){return Wc(this,null,function*(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise})}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class ak{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(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){return Wc(this,null,function*(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise})}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ok(t,e){const n=new Headers;if(!t||!e||"object"!=typeof e)return n;for(const r in e){const t=e[r];void 0!==t&&n.append(r,t)}return n}function lk(t){var e,n;return null!=(n=null==(e=URL.parse(t))?void 0:e.origin)?n:null}function ck({responseHeaders:t,isHttp:e,rangeChunkSize:n,disableRange:r}){const i={allowRangeRequests:!1,suggestedLength:void 0},A=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(A))return i;if(i.suggestedLength=A,A<=2*n)return i;if(r||!e)return i;if("bytes"!==t.get("Accept-Ranges"))return i;return"identity"!==(t.get("Content-Encoding")||"identity")||(i.allowRangeRequests=!0),i}function hk(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,n=r("filename\\*","i").exec(t);if(n){n=n[1];let t=s(n);return t=unescape(t),t=a(t),t=o(t),A(t)}if(n=function(t){const e=[];let n;const i=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(n=i.exec(t));){let[,t,r,i]=n;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[r,i]}const A=[];for(let r=0;r<e.length&&r in e;++r){let[t,n]=e[r];n=s(n),t&&(n=unescape(n),0===r&&(n=a(n))),A.push(n)}return A.join("")}(t),n)return A(o(n));if(n=r("filename","i").exec(t),n){n=n[1];let t=s(n);return t=o(t),A(t)}function r(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function i(t,n){if(t){if(!/^[\x00-\xFF]+$/.test(n))return n;try{const r=new TextDecoder(t,{fatal:!0}),i=TU(n);n=r.decode(i),e=!1}catch(hw){}}return n}function A(t){return e&&/[\x80-\xff]/.test(t)&&(t=i("utf-8",t),e&&(t=i("iso-8859-1",t))),t}function s(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const n=e[t].indexOf('"');-1!==n&&(e[t]=e[t].slice(0,n),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function a(t){const e=t.indexOf("'");return-1===e?t:i(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function o(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,n,r){if("q"===n||"Q"===n)return i(e,r=(r=r.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{r=atob(r)}catch(hw){}return i(e,r)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch(hw){}if(eI(t))return t}return null}function uk(t,e){return new MU(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function dk(t){return 200===t||206===t}function fk(t,e,n){return{method:"GET",headers:t,signal:n.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function pk(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(CU(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class gk{constructor(t){Oc(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=ok(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!=(e=null==(t=this._fullRequestReader)?void 0:t._loaded)?e:0}getFullReader(){return EU(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new mk(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new wk(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class mk{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const n=new Headers(t.headers),r=e.url;fetch(r,fk(n,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=lk(e.url),!dk(e.status))throw uk(e.status,r);this._reader=e.body.getReader(),this._headersCapability.resolve();const n=e.headers,{allowRangeRequests:i,suggestedLength:A}=ck({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=A||this._contentLength,this._filename=hk(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new PU("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}read(){return Wc(this,null,function*(){var t;yield this._headersCapability.promise;const{value:e,done:n}=yield this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength}),{value:pk(e),done:!1})})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class wk{constructor(t,e,n){this._stream=t,this._reader=null,this._loaded=0;const r=t.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;const i=new Headers(t.headers);i.append("Range",`bytes=${e}-${n-1}`);const A=r.url;fetch(A,fk(i,this._withCredentials,this._abortController)).then(e=>{const n=lk(e.url);if(n!==t._responseOrigin)throw new Error(`Expected range response-origin "${n}" to match "${t._responseOrigin}".`);if(!dk(e.status))throw uk(e.status,A);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){return Wc(this,null,function*(){var t;yield this._readCapability.promise;const{value:e,done:n}=yield this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded}),{value:pk(e),done:!1})})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class vk{constructor({url:t,httpHeaders:e,withCredentials:n}){Oc(this,"_responseOrigin",null),this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=ok(this.isHttp,e),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,n=this.currXhrId++,r=this.pendingRequests[n]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[i,A]of this.headers)e.setRequestHeader(i,A);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),r.expectedStatus=206):r.expectedStatus=200,e.responseType="arraybuffer",EU(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){var n;const r=this.pendingRequests[t];r&&(null==(n=r.onProgress)||n.call(r,e))}onStateChange(t,e){const n=this.pendingRequests[t];if(!n)return;const r=n.xhr;if(r.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),4!==r.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===r.status&&this.isHttp)return void n.onError(r.status);const i=r.status||200;if(!(200===i&&206===n.expectedStatus)&&i!==n.expectedStatus)return void n.onError(r.status);const A=function(t){const e=t.response;return"string"!=typeof e?e:TU(e).buffer}(r);if(206===i){const t=r.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?n.onDone({begin:parseInt(e[1],10),chunk:A}):(CU('Missing or invalid "Content-Range" header.'),n.onError(0))}else A?n.onDone({begin:0,chunk:A}):n.onError(r.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class yk{constructor(t){this._source=t,this._manager=new vk(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return EU(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new bk(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const n=new Bk(this._manager,t,e);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class bk{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=lk(e.responseURL);const n=e.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{const[e,...n]=t.split(": ");return[e,n.join(": ")]}):[]),{allowRangeRequests:i,suggestedLength:A}=ck({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=A||this._contentLength,this._filename=hk(r),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=uk(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;null==(e=this.onProgress)||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}read(){return Wc(this,null,function*(){if(yield this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise})}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Bk{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(){var t;const e=lk(null==(t=this._manager.getRequestXhr(this._requestId))?void 0:t.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;null==(t=this.onClosed)||t.call(this,this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){null!=this._storedError||(this._storedError=uk(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||null==(e=this.onProgress)||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}read(){return Wc(this,null,function*(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise})}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const _k=/^[a-z][a-z0-9\-+.]+:/i;class Ck{constructor(t){this.source=t,this.url=function(t){if(_k.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),EU("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!=(e=null==(t=this._fullRequestReader)?void 0:t._loaded)?e:0}getFullReader(){return EU(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new xk(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new Ek(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class xk{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const n=process.getBuiltinModule("fs");n.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=uk(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return Wc(this,null,function*(){var t;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(e).buffer,done:!1}})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new PU("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Ek{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();const r=t.source;this._isStreamingSupported=!r.disableStream;const i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){return Wc(this,null,function*(){var t;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded});return{value:new Uint8Array(e).buffer,done:!1}})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Sk=Symbol("INITIAL_DATA");class Fk{constructor(){Tc(this,kr),Tc(this,Qr,Object.create(null))}get(t,e=null){if(e){const n=Rc(this,kr,Mr).call(this,t);return n.promise.then(()=>e(n.data)),null}const n=Nc(this,Qr)[t];if(!n||n.data===Sk)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return n.data}has(t){const e=Nc(this,Qr)[t];return!!e&&e.data!==Sk}delete(t){const e=Nc(this,Qr)[t];return!(!e||e.data===Sk)&&(delete Nc(this,Qr)[t],!0)}resolve(t,e=null){const n=Rc(this,kr,Mr).call(this,t);n.data=e,n.resolve()}clear(){var t;for(const e in Nc(this,Qr)){const{data:n}=Nc(this,Qr)[e];null==(t=null==n?void 0:n.bitmap)||t.close()}Dc(this,Qr,Object.create(null))}*[Symbol.iterator](){for(const t in Nc(this,Qr)){const{data:e}=Nc(this,Qr)[t];e!==Sk&&(yield[t,e])}}}Qr=new WeakMap,kr=new WeakSet,Mr=function(t){var e;return(e=Nc(this,Qr))[t]||(e[t]=kc(Qc({},Promise.withResolvers()),{data:Sk}))};const Lk=class t{constructor({textContentSource:e,container:n,viewport:r}){var i;if(Tc(this,Ai),Tc(this,Pr,Promise.withResolvers()),Tc(this,Nr,null),Tc(this,Tr,!1),Tc(this,Dr,!!(null==(Or=globalThis.FontInspector)?void 0:Or.enabled)),Tc(this,Rr,null),Tc(this,Hr,null),Tc(this,jr,0),Tc(this,Wr,0),Tc(this,Vr,null),Tc(this,Kr,null),Tc(this,Gr,0),Tc(this,zr,0),Tc(this,qr,Object.create(null)),Tc(this,Xr,[]),Tc(this,Yr,null),Tc(this,$r,[]),Tc(this,Jr,new WeakMap),Tc(this,Zr,null),e instanceof ReadableStream)Dc(this,Yr,e);else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');Dc(this,Yr,new ReadableStream({start(t){t.enqueue(e),t.close()}}))}Dc(this,Nr,Dc(this,Kr,n)),Dc(this,zr,r.scale*hI.pixelRatio),Dc(this,Gr,r.rotation),Dc(this,Hr,{div:null,properties:null,ctx:null});const{pageWidth:A,pageHeight:s,pageX:a,pageY:o}=r.rawDims;Dc(this,Zr,[1,0,0,-1,-a,o+s]),Dc(this,Wr,A),Dc(this,jr,s),Rc(i=t,li,ui).call(i),cI(n,r),Nc(this,Pr).promise.finally(()=>{Nc(t,ii).delete(this),Dc(this,Hr,null),Dc(this,qr,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=DU.platform;return LU(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{Nc(this,Vr).read().then(({value:t,done:n})=>{n?Nc(this,Pr).resolve():(null!=Nc(this,Rr)||Dc(this,Rr,t.lang),Object.assign(Nc(this,qr),t.styles),Rc(this,Ai,si).call(this,t.items),e())},Nc(this,Pr).reject)};return Dc(this,Vr,Nc(this,Yr).getReader()),Nc(t,ii).add(this),e(),Nc(this,Pr).promise}update({viewport:e,onBefore:n=null}){var r;const i=e.scale*hI.pixelRatio,A=e.rotation;if(A!==Nc(this,Gr)&&(null==n||n(),Dc(this,Gr,A),cI(Nc(this,Kr),{rotation:A})),i!==Nc(this,zr)){null==n||n(),Dc(this,zr,i);const e={div:null,properties:null,ctx:Rc(r=t,li,ci).call(r,Nc(this,Rr))};for(const t of Nc(this,$r))e.properties=Nc(this,Jr).get(t),e.div=t,Rc(this,Ai,oi).call(this,e)}}cancel(){var t;const e=new PU("TextLayer task cancelled.");null==(t=Nc(this,Vr))||t.cancel(e).catch(()=>{}),Dc(this,Vr,null),Nc(this,Pr).reject(e)}get textDivs(){return Nc(this,$r)}get textContentItemsStr(){return Nc(this,Xr)}static cleanup(){if(!(Nc(this,ii).size>0)){Nc(this,ti).clear();for(const{canvas:t}of Nc(this,ei).values())t.remove();Nc(this,ei).clear()}}};Pr=new WeakMap,Nr=new WeakMap,Tr=new WeakMap,Dr=new WeakMap,Rr=new WeakMap,Hr=new WeakMap,jr=new WeakMap,Wr=new WeakMap,Vr=new WeakMap,Kr=new WeakMap,Gr=new WeakMap,zr=new WeakMap,qr=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,$r=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,ti=new WeakMap,ei=new WeakMap,ni=new WeakMap,ri=new WeakMap,ii=new WeakMap,Ai=new WeakSet,si=function(t){var e,n;if(Nc(this,Tr))return;null!=(n=Nc(this,Hr)).ctx||(n.ctx=Rc(e=Lk,li,ci).call(e,Nc(this,Rr)));const r=Nc(this,$r),i=Nc(this,Xr);for(const A of t){if(r.length>1e5)return CU("Ignoring additional textDivs for performance reasons."),void Dc(this,Tr,!0);if(void 0!==A.str)i.push(A.str),Rc(this,Ai,ai).call(this,A);else if("beginMarkedContentProps"===A.type||"beginMarkedContent"===A.type){const t=Nc(this,Nr);Dc(this,Nr,document.createElement("span")),Nc(this,Nr).classList.add("markedContent"),A.id&&Nc(this,Nr).setAttribute("id",`${A.id}`),t.append(Nc(this,Nr))}else"endMarkedContent"===A.type&&Dc(this,Nr,Nc(this,Nr).parentNode)}},ai=function(t){var e;const n=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};Nc(this,$r).push(n);const i=HU.transform(Nc(this,Zr),t.transform);let A=Math.atan2(i[1],i[0]);const s=Nc(this,qr)[t.fontName];s.vertical&&(A+=Math.PI/2);let a=Nc(this,Dr)&&s.fontSubstitution||s.fontFamily;a=Lk.fontFamilyMap.get(a)||a;const o=Math.hypot(i[2],i[3]),l=o*Rc(e=Lk,li,di).call(e,a,s,Nc(this,Rr));let c,h;0===A?(c=i[4],h=i[5]-l):(c=i[4]+l*Math.sin(A),h=i[5]-l*Math.cos(A));const u="calc(var(--total-scale-factor) *",d=n.style;Nc(this,Nr)===Nc(this,Kr)?(d.left=`${(100*c/Nc(this,Wr)).toFixed(2)}%`,d.top=`${(100*h/Nc(this,jr)).toFixed(2)}%`):(d.left=`${u}${c.toFixed(2)}px)`,d.top=`${u}${h.toFixed(2)}px)`),d.fontSize=`${u}${(Nc(Lk,ri)*o).toFixed(2)}px)`,d.fontFamily=a,r.fontSize=o,n.setAttribute("role","presentation"),n.textContent=t.str,n.dir=t.dir,Nc(this,Dr)&&(n.dataset.fontName=s.fontSubstitutionLoadedName||t.fontName),0!==A&&(r.angle=A*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(f=!0)}if(f&&(r.canvasWidth=s.vertical?t.height:t.width),Nc(this,Jr).set(n,r),Nc(this,Hr).div=n,Nc(this,Hr).properties=r,Rc(this,Ai,oi).call(this,Nc(this,Hr)),r.hasText&&Nc(this,Nr).append(n),r.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),Nc(this,Nr).append(t)}},oi=function(t){var e;const{div:n,properties:r,ctx:i}=t,{style:A}=n;let s="";if(Nc(Lk,ri)>1&&(s=`scale(${1/Nc(Lk,ri)})`),0!==r.canvasWidth&&r.hasText){const{fontFamily:t}=A,{canvasWidth:a,fontSize:o}=r;Rc(e=Lk,li,hi).call(e,i,o*Nc(this,zr),t);const{width:l}=i.measureText(n.textContent);l>0&&(s=`scaleX(${a*Nc(this,zr)/l}) ${s}`)}0!==r.angle&&(s=`rotate(${r.angle}deg) ${s}`),s.length>0&&(A.transform=s)},li=new WeakSet,ci=function(t=null){let e=Nc(this,ei).get(t||(t=""));if(!e){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=t,document.body.append(n),e=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),Nc(this,ei).set(t,e),Nc(this,ni).set(e,{size:0,family:""})}return e},hi=function(t,e,n){const r=Nc(this,ni).get(t);e===r.size&&n===r.family||(t.font=`${e}px ${n}`,r.size=e,r.family=n)},ui=function(){if(null!==Nc(this,ri))return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),Dc(this,ri,t.getBoundingClientRect().height),t.remove()},di=function(t,e,n){const r=Nc(this,ti).get(t);if(r)return r;const i=Rc(this,li,ci).call(this,n);i.canvas.width=i.canvas.height=30,Rc(this,li,hi).call(this,i,30,t);const A=i.measureText(""),s=A.fontBoundingBoxAscent,a=Math.abs(A.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let o=.8;return s?o=s/(s+a):(DU.platform.isFirefox&&CU("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?o=e.ascent:e.descent&&(o=1+e.descent)),Nc(this,ti).set(t,o),o},Tc(Lk,li),Tc(Lk,ti,new Map),Tc(Lk,ei,new Map),Tc(Lk,ni,new WeakMap),Tc(Lk,ri,null),Tc(Lk,ii,new Set);let Uk=Lk;class Ik{static textContent(t){const e=[],n={items:e,styles:Object.create(null)};return function t(n){var r;if(!n)return;let i=null;const A=n.name;if("#text"===A)i=n.value;else{if(!Ik.shouldBuildText(A))return;(null==(r=null==n?void 0:n.attributes)?void 0:r.textContent)?i=n.attributes.textContent:n.value&&(i=n.value)}if(null!==i&&e.push({str:i}),n.children)for(const e of n.children)t(e)}(t),n}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}function Qk(t={}){var e,n;"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const r=new Mk,{docId:i}=r,A=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(HL)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,s=t.data?function(t){if(HL&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return TU(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(null==t?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,a=t.httpHeaders||null,o=!0===t.withCredentials,l=null!=(e=t.password)?e:null,c=t.range instanceof Ok?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:Uc(2,16);let u=t.worker instanceof Dk?t.worker:null;const d=t.verbosity,f="string"!=typeof t.docBaseUrl||tI(t.docBaseUrl)?null:t.docBaseUrl,p=WI(t.cMapUrl),g=!1!==t.cMapPacked,m=t.CMapReaderFactory||(HL?vQ:lQ),w=WI(t.iccUrl),v=WI(t.standardFontDataUrl),y=t.StandardFontDataFactory||(HL?yQ:dQ),b=WI(t.wasmUrl),B=t.WasmFactory||(HL?bQ:pQ),_=!0!==t.stopAtErrors,C=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,x=!1!==t.isEvalSupported,E="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!HL,S="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!HL&&(DU.platform.isFirefox||!globalThis.chrome),F=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,L="boolean"==typeof t.disableFontFace?t.disableFontFace:HL,U=!0===t.fontExtraProperties,I=!0===t.enableXfa,Q=t.ownerDocument||globalThis.document,k=!0===t.disableRange,M=!0===t.disableStream,O=!0===t.disableAutoFetch,P=!0===t.pdfBug,N=t.CanvasFactory||(HL?wQ:aQ),T=t.FilterFactory||(HL?mQ:hQ),D=!0===t.enableHWA,R=!1!==t.useWasm,H=c?c.length:null!=(n=t.length)?n:NaN,j="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!HL&&!L,W="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(m===lQ&&y===dQ&&B===pQ&&p&&v&&b&&rI(p,document.baseURI)&&rI(v,document.baseURI)&&rI(b,document.baseURI));var V;V=d,Number.isInteger(V)&&(bU=V);const K={canvasFactory:new N({ownerDocument:Q,enableHWA:D}),filterFactory:new T({docId:i,ownerDocument:Q}),cMapReaderFactory:W?null:new m({baseUrl:p,isCompressed:g}),standardFontDataFactory:W?null:new y({baseUrl:v}),wasmFactory:W?null:new B({baseUrl:b})};u||(u=Dk.create({verbosity:d,port:tk.workerPort}),r._worker=u);const G={docId:i,apiVersion:"5.4.54",data:s,password:l,disableAutoFetch:O,rangeChunkSize:h,length:H,docBaseUrl:f,enableXfa:I,evaluatorOptions:{maxImageSize:C,disableFontFace:L,ignoreErrors:_,isEvalSupported:x,isOffscreenCanvasSupported:E,isImageDecoderSupported:S,canvasMaxAreaInBytes:F,fontExtraProperties:U,useSystemFonts:j,useWasm:R,useWorkerFetch:W,cMapUrl:p,iccUrl:w,standardFontDataUrl:v,wasmUrl:b}},z={ownerDocument:Q,pdfBug:P,styleElement:null,loadingParams:{disableAutoFetch:O,enableXfa:I}};return u.promise.then(function(){if(r.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const t=u.messageHandler.sendWithPromise("GetDocRequest",G,s?[s.buffer]:null);let e;if(c)e=new Ak(c,{disableRange:k,disableStream:M});else if(!s){if(!A)throw new Error("getDocument - no `url` parameter provided.");const t=rI(A)?gk:HL?Ck:yk;e=new t({url:A,length:H,httpHeaders:a,withCredentials:o,rangeChunkSize:h,disableRange:k,disableStream:M})}return t.then(t=>{if(r.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const n=new AQ(i,t,u.port),A=new Rk(n,r,e,z,K,D);r._transport=A,n.send("Ready",null)})}).catch(r._capability.reject),r}const kk=class t{constructor(){Oc(this,"_capability",Promise.withResolvers()),Oc(this,"_transport",null),Oc(this,"_worker",null),Oc(this,"docId","d"+Hc(t,fi)._++),Oc(this,"destroyed",!1),Oc(this,"onPassword",null),Oc(this,"onProgress",null)}get promise(){return this._capability.promise}destroy(){return Wc(this,null,function*(){var t,e,n,r;this.destroyed=!0;try{(null==(t=this._worker)?void 0:t.port)&&(this._worker._pendingDestroy=!0),yield null==(e=this._transport)?void 0:e.destroy()}catch(i){throw(null==(n=this._worker)?void 0:n.port)&&delete this._worker._pendingDestroy,i}this._transport=null,null==(r=this._worker)||r.destroy(),this._worker=null})}getData(){return Wc(this,null,function*(){return this._transport.getData()})}};fi=new WeakMap,Tc(kk,fi,0);let Mk=kk;class Ok{constructor(t,e,n=!1,r=null){Tc(this,pi,Promise.withResolvers()),Tc(this,gi,[]),Tc(this,mi,[]),Tc(this,wi,[]),Tc(this,vi,[]),this.length=t,this.initialData=e,this.progressiveDone=n,this.contentDispositionFilename=r}addRangeListener(t){Nc(this,vi).push(t)}addProgressListener(t){Nc(this,wi).push(t)}addProgressiveReadListener(t){Nc(this,mi).push(t)}addProgressiveDoneListener(t){Nc(this,gi).push(t)}onDataRange(t,e){for(const n of Nc(this,vi))n(t,e)}onDataProgress(t,e){Nc(this,pi).promise.then(()=>{for(const n of Nc(this,wi))n(t,e)})}onDataProgressiveRead(t){Nc(this,pi).promise.then(()=>{for(const e of Nc(this,mi))e(t)})}onDataProgressiveDone(){Nc(this,pi).promise.then(()=>{for(const t of Nc(this,gi))t()})}transportReady(){Nc(this,pi).resolve()}requestDataRange(t,e){xU("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}pi=new WeakMap,gi=new WeakMap,mi=new WeakMap,wi=new WeakMap,vi=new WeakMap;class Pk{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 LU(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Nk{constructor(t,e,n,r=!1){Tc(this,bi),Tc(this,yi,!1),this._pageIndex=t,this._pageInfo=e,this._transport=n,this._stats=r?new nI:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new Fk,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:i=!1}={}){return new JU({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:r,dontFlip:i})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return LU(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){return Wc(this,null,function*(){var t;return(null==(t=this._transport._htmlForXfa)?void 0:t.children[this._pageIndex])||null})}render({canvasContext:t,canvas:e=t.canvas,viewport:n,intent:r="display",annotationMode:i=JL.ENABLE,transform:A=null,background:s=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:c=null,isEditing:h=!1}){var u,d;null==(u=this._stats)||u.time("Overall");const f=this._transport.getRenderingIntent(r,i,c,h),{renderingIntent:p,cacheKey:g}=f;Dc(this,yi,!1),a||(a=this._transport.getOptionalContentConfig(p));let m=this._intentStates.get(g);m||(m=Object.create(null),this._intentStates.set(g,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);const w=!!(p&GL);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(d=this._stats)||d.time("Page Request"),this._pumpOperatorList(f));const v=t=>{var e;m.renderTasks.delete(y),w&&Dc(this,yi,!0),Rc(this,bi,Bi).call(this),t?(y.capability.reject(t),this._abortOperatorList({intentState:m,reason:t instanceof Error?t:new Error(t)})):y.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(null==(e=globalThis.Stats)?void 0:e.enabled)&&globalThis.Stats.add(this.pageNumber,this._stats))},y=new Wk({callback:v,params:{canvas:e,canvasContext:t,viewport:n,transform:A,background:s},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:l,enableHWA:this._transport.enableHWA});(m.renderTasks||(m.renderTasks=new Set)).add(y);const b=y.task;return Promise.all([m.displayReadyCapability.promise,a]).then(([t,e])=>{var n;if(this.destroyed)v();else{if(null==(n=this._stats)||n.time("Rendering"),!(e.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");y.initializeGraphics({transparency:t,optionalContentConfig:e}),y.operatorListChanged()}}).catch(v),b}getOperatorList({intent:t="display",annotationMode:e=JL.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){var i;const A=this._transport.getRenderingIntent(t,e,n,r,!0);let s,a=this._intentStates.get(A.cacheKey);return a||(a=Object.create(null),this._intentStates.set(A.cacheKey,a)),a.opListReadCapability||(s=Object.create(null),s.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(s))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||(a.renderTasks=new Set)).add(s),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(i=this._stats)||i.time("Page Request"),this._pumpOperatorList(A)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>Ik.textContent(t));const e=this.streamTextContent(t);return new Promise(function(t,n){const r=e.getReader(),i={items:[],styles:Object.create(null),lang:null};!function e(){r.read().then(function({value:n,done:r}){r?t(i):(null!=i.lang||(i.lang=n.lang),Object.assign(i.styles,n.styles),i.items.push(...n.items),e())},n)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const n of e.renderTasks)t.push(n.completed),n.cancel();return this.objs.clear(),Dc(this,yi,!1),Promise.all(t)}cleanup(t=!1){Dc(this,yi,!0);const e=Rc(this,bi,Bi).call(this);return t&&e&&this._stats&&(this._stats=new nI),e}_startRenderPage(t,e){var n,r;const i=this._intentStates.get(e);i&&(null==(n=this._stats)||n.timeEnd("Page Request"),null==(r=i.displayReadyCapability)||r.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(const n of e.renderTasks)n.operatorListChanged();t.lastChunk&&Rc(this,bi,Bi).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:n,modifiedIds:r}){const{map:i,transfer:A}=n,s=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i,modifiedIds:r},A).getReader(),a=this._intentStates.get(e);a.streamReader=s;const o=()=>{s.read().then(({value:t,done:e})=>{e?a.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,a),o())},t=>{if(a.streamReader=null,!this._transport.destroyed){if(a.operatorList){a.operatorList.lastChunk=!0;for(const t of a.renderTasks)t.operatorListChanged();Rc(this,bi,Bi).call(this)}if(a.displayReadyCapability)a.displayReadyCapability.reject(t);else{if(!a.opListReadCapability)throw t;a.opListReadCapability.reject(t)}}})};o()}_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 ZU){let n=100;return e.extraDelay>0&&e.extraDelay<1e3&&(n+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},n))}}if(t.streamReader.cancel(new PU(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[e,n]of this._intentStates)if(n===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}yi=new WeakMap,bi=new WeakSet,Bi=function(){if(!Nc(this,yi)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Dc(this,yi,!1),!0};const Tk=class t{constructor({name:e=null,port:n=null,verbosity:r=BU()}={}){if(Tc(this,Ui),Tc(this,_i,Promise.withResolvers()),Tc(this,Ci,null),Tc(this,xi,null),Tc(this,Ei,null),this.name=e,this.destroyed=!1,this.verbosity=r,n){if(Nc(t,Li).has(n))throw new Error("Cannot use more than one PDFWorker per port.");Nc(t,Li).set(n,this),Rc(this,Ui,Qi).call(this,n)}else Rc(this,Ui,ki).call(this)}get promise(){return Nc(this,_i).promise}get port(){return Nc(this,xi)}get messageHandler(){return Nc(this,Ci)}destroy(){var e,n;this.destroyed=!0,null==(e=Nc(this,Ei))||e.terminate(),Dc(this,Ei,null),Nc(t,Li).delete(Nc(this,xi)),Dc(this,xi,null),null==(n=Nc(this,Ci))||n.destroy(),Dc(this,Ci,null)}static create(e){const n=Nc(this,Li).get(null==e?void 0:e.port);if(n){if(n._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new t(e)}static get workerSrc(){if(tk.workerSrc)return tk.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return LU(this,"_setupFakeWorkerGlobal",(()=>Wc(this,null,function*(){if(Nc(this,Oi,Pi))return Nc(this,Oi,Pi);return(yield import(this.workerSrc)).WorkerMessageHandler}))())}};_i=new WeakMap,Ci=new WeakMap,xi=new WeakMap,Ei=new WeakMap,Si=new WeakMap,Fi=new WeakMap,Li=new WeakMap,Ui=new WeakSet,Ii=function(){Nc(this,_i).resolve(),Nc(this,Ci).send("configure",{verbosity:this.verbosity})},Qi=function(t){Dc(this,xi,t),Dc(this,Ci,new AQ("main","worker",t)),Nc(this,Ci).on("ready",()=>{}),Rc(this,Ui,Ii).call(this)},ki=function(){if(Nc(Tk,Fi)||Nc(Tk,Oi,Pi))return void Rc(this,Ui,Mi).call(this);let{workerSrc:t}=Tk;try{Tk._isSameOrigin(window.location,t)||(t=Tk._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),n=new AQ("main","worker",e),r=()=>{i.abort(),n.destroy(),e.terminate(),this.destroyed?Nc(this,_i).reject(new Error("Worker was destroyed")):Rc(this,Ui,Mi).call(this)},i=new AbortController;e.addEventListener("error",()=>{Nc(this,Ei)||r()},{signal:i.signal}),n.on("test",t=>{i.abort(),!this.destroyed&&t?(Dc(this,Ci,n),Dc(this,xi,e),Dc(this,Ei,e),Rc(this,Ui,Ii).call(this)):r()}),n.on("ready",t=>{if(i.abort(),this.destroyed)r();else try{A()}catch(hw){Rc(this,Ui,Mi).call(this)}});const A=()=>{const t=new Uint8Array;n.send("test",t,[t.buffer])};return void A()}catch(hw){_U("The worker has been disabled.")}Rc(this,Ui,Mi).call(this)},Mi=function(){Nc(Tk,Fi)||(CU("Setting up fake worker."),Dc(Tk,Fi,!0)),Tk._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void Nc(this,_i).reject(new Error("Worker was destroyed"));const e=new GI;Dc(this,xi,e);const n="fake"+Hc(Tk,Si)._++,r=new AQ(n+"_worker",n,e);t.setup(r,e),Dc(this,Ci,new AQ(n,n+"_worker",e)),Rc(this,Ui,Ii).call(this)}).catch(t=>{Nc(this,_i).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Oi=new WeakSet,Pi=function(){var t;try{return(null==(t=globalThis.pdfjsWorker)?void 0:t.WorkerMessageHandler)||null}catch(hw){return null}},Tc(Tk,Oi),Tc(Tk,Si,0),Tc(Tk,Fi,!1),Tc(Tk,Li,new WeakMap),HL&&(Dc(Tk,Fi,!0),tk.workerSrc||(tk.workerSrc="./pdf.worker.mjs")),Tk._isSameOrigin=(t,e)=>{const n=URL.parse(t);if(!(null==n?void 0:n.origin)||"null"===n.origin)return!1;const r=new URL(e,n);return n.origin===r.origin},Tk._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Tk.fromPort=t=>{var e;if(e="`PDFWorker.fromPort` - please use `PDFWorker.create` instead.",console.log("Deprecated API usage: "+e),!(null==t?void 0:t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return Tk.create(t)};let Dk=Tk;class Rk{constructor(t,e,n,r,i,A){Tc(this,ji),Tc(this,Ni,new Map),Tc(this,Ti,new Map),Tc(this,Di,new Map),Tc(this,Ri,new Map),Tc(this,Hi,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Fk,this.fontLoader=new HI({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.wasmFactory=i.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=A,this.setupMessageHandler()}get annotationStorage(){return LU(this,"annotationStorage",new DI)}getRenderingIntent(t,e=JL.ENABLE,n=null,r=!1,i=!1){let A=KL,s=TI;switch(t){case"any":A=VL;break;case"display":break;case"print":A=GL;break;default:CU(`getRenderingIntent - invalid intent: ${t}`)}const a=A&GL&&n instanceof RI?n:this.annotationStorage;switch(e){case JL.DISABLE:A+=XL;break;case JL.ENABLE:break;case JL.ENABLE_FORMS:A+=zL;break;case JL.ENABLE_STORAGE:A+=qL,s=a.serializable;break;default:CU(`getRenderingIntent - invalid annotationMode: ${e}`)}r&&(A+=YL),i&&(A+=$L);const{ids:o,hash:l}=a.modifiedIds;return{renderingIntent:A,cacheKey:[A,s.hash,l].join("_"),annotationStorageSerializable:s,modifiedIds:o}}destroy(){var t;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null==(t=Nc(this,Hi))||t.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const r of Nc(this,Ti).values())e.push(r._destroy());Nc(this,Ti).clear(),Nc(this,Di).clear(),Nc(this,Ri).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then(()=>{var t,e;this.commonObjs.clear(),this.fontLoader.clear(),Nc(this,Ni).clear(),this.filterFactory.destroy(),Uk.cleanup(),null==(t=this._networkStream)||t.cancelAllRequests(new PU("Worker was terminated.")),null==(e=this.messageHandler)||e.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{EU(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:n}){n?e.close():(EU(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",t=>Wc(this,null,function*(){var t;yield this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:i}=this._fullReader;return n&&r||(this._lastProgress&&(null==(t=e.onProgress)||t.call(e,this._lastProgress)),this._fullReader.onProgress=t=>{var n;null==(n=e.onProgress)||n.call(e,{loaded:t.loaded,total:t.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:i}})),t.on("GetRangeReader",(t,e)=>{EU(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(t.begin,t.end);n?(e.onPull=()=>{n.read().then(function({value:t,done:n}){n?e.close():(EU(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{n.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Pk(t,this))}),t.on("DocException",t=>{e._capability.reject(iQ(t))}),t.on("PasswordRequest",t=>{Dc(this,Hi,Promise.withResolvers());try{if(!e.onPassword)throw iQ(t);const n=t=>{t instanceof Error?Nc(this,Hi).reject(t):Nc(this,Hi).resolve({password:t})};e.onPassword(n,t.code)}catch(n){Nc(this,Hi).reject(n)}return Nc(this,Hi).promise}),t.on("DataLoaded",t=>{var n;null==(n=e.onProgress)||n.call(e,{loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{if(this.destroyed)return;Nc(this,Ti).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,n,r])=>{var i;if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(n){case"Font":if("error"in r){const t=r.error;CU(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const A=this._params.pdfBug&&(null==(i=globalThis.FontInspector)?void 0:i.enabled)?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,s=new jI(r,A);this.fontLoader.bind(s).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!s.fontExtraProperties&&s.data&&(s.data=null),this.commonObjs.resolve(e,s)});break;case"CopyLocalImage":const{imageRef:a}=r;EU(a,"The imageRef must be defined.");for(const t of Nc(this,Ti).values())for(const[,n]of t.objs)if((null==n?void 0:n.ref)===a)return n.dataLen?(this.commonObjs.resolve(e,structuredClone(n)),n.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,r);break;default:throw new Error(`Got unknown common object type ${n}`)}return null}),t.on("obj",([t,e,n,r])=>{var i;if(this.destroyed)return;const A=Nc(this,Ti).get(e);if(!A.objs.has(t))if(0!==A._intentStates.size)switch(n){case"Image":case"Pattern":A.objs.resolve(t,r);break;default:throw new Error(`Got unknown object type ${n}`)}else null==(i=null==r?void 0:r.bitmap)||i.close()}),t.on("DocProgress",t=>{var n;this.destroyed||null==(n=e.onProgress)||n.call(e,{loaded:t.loaded,total:t.total})}),t.on("FetchBinaryData",t=>Wc(this,null,function*(){if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var t,e;this.annotationStorage.size<=0&&CU("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:n,transfer:r}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:n,filename:null!=(e=null==(t=this._fullReader)?void 0:t.filename)?e:null},r).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,n=Nc(this,Di).get(e);if(n)return n;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&Nc(this,Ri).set(n.refStr,t);const r=new Nk(e,n,this,this._params.pdfBug);return Nc(this,Ti).set(e,r),r});return Nc(this,Di).set(e,r),r}getPageIndex(t){return VI(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 Rc(this,ji,Wi).call(this,"GetFieldObjects")}hasJSActions(){return Rc(this,ji,Wi).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return Rc(this,ji,Wi).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return Rc(this,ji,Wi).call(this,"GetOptionalContentConfig").then(e=>new ik(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=Nc(this,Ni).get(t);if(e)return e;const n=this.messageHandler.sendWithPromise(t,null).then(t=>{var e,n,r,i;return{info:t[0],metadata:t[1]?new ek(t[1]):null,contentDispositionFilename:null!=(n=null==(e=this._fullReader)?void 0:e.filename)?n:null,contentLength:null!=(i=null==(r=this._fullReader)?void 0:r.contentLength)?i:null}});return Nc(this,Ni).set(t,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(t=!1){return Wc(this,null,function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(const t of Nc(this,Ti).values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),Nc(this,Ni).clear(),this.filterFactory.destroy(!0),Uk.cleanup()}})}cachedPageNumber(t){var e;if(!VI(t))return null;const n=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return null!=(e=Nc(this,Ri).get(n))?e:null}}Ni=new WeakMap,Ti=new WeakMap,Di=new WeakMap,Ri=new WeakMap,Hi=new WeakMap,ji=new WeakSet,Wi=function(t,e=null){const n=Nc(this,Ni).get(t);if(n)return n;const r=this.messageHandler.sendWithPromise(t,e);return Nc(this,Ni).set(t,r),r};class Hk{constructor(t){Tc(this,Vi,null),Oc(this,"onContinue",null),Oc(this,"onError",null),Dc(this,Vi,t)}get promise(){return Nc(this,Vi).capability.promise}cancel(t=0){Nc(this,Vi).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=Nc(this,Vi).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=Nc(this,Vi);return t.form||t.canvas&&(null==e?void 0:e.size)>0}}Vi=new WeakMap;const jk=class t{constructor({callback:t,params:e,objs:n,commonObjs:r,annotationCanvasMap:i,operatorList:A,pageIndex:s,canvasFactory:a,filterFactory:o,useRequestAnimationFrame:l=!1,pdfBug:c=!1,pageColors:h=null,enableHWA:u=!1}){Tc(this,Ki,null),this.callback=t,this.params=e,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=A,this._pageIndex=s,this.canvasFactory=a,this.filterFactory=o,this._pdfBug=c,this.pageColors=h,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===l&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Hk(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:n}){var r,i;if(this.cancelled)return;if(this._canvas){if(Nc(t,Gi).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.");Nc(t,Gi).add(this._canvas)}this._pdfBug&&(null==(r=globalThis.StepperManager)?void 0:r.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:A,transform:s,background:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new ZQ(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:s,viewport:A,transparency:e,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,null==(i=this.graphicsReadyCallback)||i.call(this)}cancel(e=null,n=0){var r,i,A;this.running=!1,this.cancelled=!0,null==(r=this.gfx)||r.endDrawing(),Nc(this,Ki)&&(window.cancelAnimationFrame(Nc(this,Ki)),Dc(this,Ki,null)),Nc(t,Gi).delete(this._canvas),e||(e=new ZU(`Rendering cancelled, page ${this._pageIndex+1}`,n)),this.callback(e),null==(A=(i=this.task).onError)||A.call(i,e)}operatorListChanged(){var t;this.graphicsReady?(null==(t=this.stepper)||t.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?Dc(this,Ki,window.requestAnimationFrame(()=>{Dc(this,Ki,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){return Wc(this,null,function*(){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(),Nc(t,Gi).delete(this._canvas),this.callback())))})}};Ki=new WeakMap,Gi=new WeakMap,Tc(jk,Gi,new WeakSet);let Wk=jk;const Vk=class t{constructor({editor:e=null,uiManager:n=null}){var r,i;Tc(this,iA),Tc(this,zi,null),Tc(this,qi,null),Tc(this,Xi),Tc(this,Yi,null),Tc(this,$i,!1),Tc(this,Ji,!1),Tc(this,Zi,null),Tc(this,tA),Tc(this,eA,null),Tc(this,nA,null),e?(Dc(this,Ji,!1),Dc(this,Zi,e)):Dc(this,Ji,!0),Dc(this,nA,(null==e?void 0:e._uiManager)||n),Dc(this,tA,Nc(this,nA)._eventBus),Dc(this,Xi,(null==(r=null==e?void 0:e.color)?void 0:r.toUpperCase())||(null==(i=Nc(this,nA))?void 0:i.highlightColors.values().next().value)||"#FFFF98"),Nc(t,rA)||Dc(t,rA,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return LU(this,"_keyboardManager",new bI([[["Escape","mac+Escape"],t.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],t.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],t.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],t.prototype._moveToPrevious],[["Home","mac+Home"],t.prototype._moveToBeginning],[["End","mac+End"],t.prototype._moveToEnd]]))}renderButton(){const t=Dc(this,zi,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",Nc(this,Zi)&&(t.ariaControls=`${Nc(this,Zi).id}_colorpicker_dropdown`);const e=Nc(this,nA)._signal;t.addEventListener("click",Rc(this,iA,oA).bind(this),{signal:e}),t.addEventListener("keydown",Rc(this,iA,aA).bind(this),{signal:e});const n=Dc(this,qi,document.createElement("span"));return n.className="swatch",n.ariaHidden="true",n.style.backgroundColor=Nc(this,Xi),t.append(n),t}renderMainDropdown(){const t=Dc(this,Yi,Rc(this,iA,AA).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===Nc(this,zi))return void Rc(this,iA,oA).call(this,t);const e=t.target.getAttribute("data-color");e&&Rc(this,iA,sA).call(this,e,t)}_moveToNext(t){var e,n;Nc(this,iA,cA)?t.target!==Nc(this,zi)?null==(n=t.target.nextSibling)||n.focus():null==(e=Nc(this,Yi).firstChild)||e.focus():Rc(this,iA,oA).call(this,t)}_moveToPrevious(t){var e,n;t.target!==(null==(e=Nc(this,Yi))?void 0:e.firstChild)&&t.target!==Nc(this,zi)?(Nc(this,iA,cA)||Rc(this,iA,oA).call(this,t),null==(n=t.target.previousSibling)||n.focus()):Nc(this,iA,cA)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;Nc(this,iA,cA)?null==(e=Nc(this,Yi).firstChild)||e.focus():Rc(this,iA,oA).call(this,t)}_moveToEnd(t){var e;Nc(this,iA,cA)?null==(e=Nc(this,Yi).lastChild)||e.focus():Rc(this,iA,oA).call(this,t)}hideDropdown(){var t,e;null==(t=Nc(this,Yi))||t.classList.add("hidden"),Nc(this,zi).ariaExpanded="false",null==(e=Nc(this,eA))||e.abort(),Dc(this,eA,null)}_hideDropdownFromKeyboard(){var t;Nc(this,Ji)||(Nc(this,iA,cA)?(this.hideDropdown(),Nc(this,zi).focus({preventScroll:!0,focusVisible:Nc(this,$i)})):null==(t=Nc(this,Zi))||t.unselect())}updateColor(t){if(Nc(this,qi)&&(Nc(this,qi).style.backgroundColor=t),!Nc(this,Yi))return;const e=Nc(this,nA).highlightColors.values();for(const n of Nc(this,Yi).children)n.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;null==(t=Nc(this,zi))||t.remove(),Dc(this,zi,null),Dc(this,qi,null),null==(e=Nc(this,Yi))||e.remove(),Dc(this,Yi,null)}};zi=new WeakMap,qi=new WeakMap,Xi=new WeakMap,Yi=new WeakMap,$i=new WeakMap,Ji=new WeakMap,Zi=new WeakMap,tA=new WeakMap,eA=new WeakMap,nA=new WeakMap,rA=new WeakMap,iA=new WeakSet,AA=function(){const t=document.createElement("div"),e=Nc(this,nA)._signal;t.addEventListener("contextmenu",iI,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),Nc(this,Zi)&&(t.id=`${Nc(this,Zi).id}_colorpicker_dropdown`);for(const[n,r]of Nc(this,nA).highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",r),i.title=n,i.setAttribute("data-l10n-id",Nc(Vk,rA)[n]);const A=document.createElement("span");i.append(A),A.className="swatch",A.style.backgroundColor=r,i.ariaSelected=r===Nc(this,Xi),i.addEventListener("click",Rc(this,iA,sA).bind(this,r),{signal:e}),t.append(i)}return t.addEventListener("keydown",Rc(this,iA,aA).bind(this),{signal:e}),t},sA=function(t,e){e.stopPropagation(),Nc(this,tA).dispatch("switchannotationeditorparams",{source:this,type:eU.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},aA=function(t){Vk._keyboardManager.exec(this,t)},oA=function(t){if(Nc(this,iA,cA))return void this.hideDropdown();if(Dc(this,$i,0===t.detail),Nc(this,eA)||(Dc(this,eA,new AbortController),window.addEventListener("pointerdown",Rc(this,iA,lA).bind(this),{signal:Nc(this,nA).combinedSignal(Nc(this,eA))})),Nc(this,zi).ariaExpanded="true",Nc(this,Yi))return void Nc(this,Yi).classList.remove("hidden");const e=Dc(this,Yi,Rc(this,iA,AA).call(this));Nc(this,zi).append(e)},lA=function(t){var e;(null==(e=Nc(this,Yi))?void 0:e.contains(t.target))||this.hideDropdown()},cA=function(){return Nc(this,Yi)&&!Nc(this,Yi).classList.contains("hidden")},Tc(Vk,rA,null);let Kk=Vk;const Gk=class t{constructor(e){Tc(this,hA,null),Tc(this,uA,null),Tc(this,dA,null),Dc(this,uA,e),Dc(this,dA,e._uiManager),Nc(t,fA)||Dc(t,fA,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(Nc(this,hA))return Nc(this,hA);const{editorType:e,colorType:n,colorValue:r}=Nc(this,uA),i=Dc(this,hA,document.createElement("input"));return i.type="color",i.value=r||"#000000",i.className="basicColorPicker",i.tabIndex=0,i.setAttribute("data-l10n-id",Nc(t,fA)[e]),i.addEventListener("input",()=>{Nc(this,dA).updateParams(n,i.value)},{signal:Nc(this,dA)._signal}),i}update(t){Nc(this,hA)&&(Nc(this,hA).value=t)}destroy(){var t;null==(t=Nc(this,hA))||t.remove(),Dc(this,hA,null)}hideDropdown(){}};hA=new WeakMap,uA=new WeakMap,dA=new WeakMap,fA=new WeakMap,Tc(Gk,fA,null);let zk=Gk;function qk(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Xk(t){return Math.max(0,Math.min(255,255*t))}class Yk{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=Xk(t),t,t]}static G_HTML([t]){const e=qk(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(Xk)}static RGB_HTML(t){return`#${t.map(qk).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[Xk(1-Math.min(1,t+r)),Xk(1-Math.min(1,n+r)),Xk(1-Math.min(1,e+r))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,n]){const r=1-t,i=1-e,A=1-n;return["CMYK",r,i,A,Math.min(r,i,A)]}}class $k{create(t,e,n=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const 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("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){xU("Abstract method `_createSVG` called.")}}class Jk extends $k{_createSVG(t){return document.createElementNS(qU,t)}}class Zk{static setupStorage(t,e,n,r,i){const A=r.getValue(e,{value:null});switch(n.name){case"textarea":if(null!==A.value&&(t.textContent=A.value),"print"===i)break;t.addEventListener("input",t=>{r.setValue(e,{value:t.target.value})});break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(A.value===n.attributes.xfaOn?t.setAttribute("checked",!0):A.value===n.attributes.xfaOff&&t.removeAttribute("checked"),"print"===i)break;t.addEventListener("change",t=>{r.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==A.value&&t.setAttribute("value",A.value),"print"===i)break;t.addEventListener("input",t=>{r.setValue(e,{value:t.target.value})})}break;case"select":if(null!==A.value){t.setAttribute("value",A.value);for(const t of n.children)t.attributes.value===A.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",t=>{const n=t.target.options,i=-1===n.selectedIndex?"":n[n.selectedIndex].value;r.setValue(e,{value:i})})}}static setAttributes({html:t,element:e,storage:n=null,intent:r,linkService:i}){const{attributes:A}=e,s=t instanceof HTMLAnchorElement;"radio"===A.type&&(A.name=`${A.name}-${r}`);for(const[a,o]of Object.entries(A))if(null!=o)switch(a){case"class":o.length&&t.setAttribute(a,o.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",o);break;case"style":Object.assign(t.style,o);break;case"textContent":t.textContent=o;break;default:(!s||"href"!==a&&"newWindow"!==a)&&t.setAttribute(a,o)}s&&i.addLinkAttributes(t,A.href,A.newWindow),n&&A.dataId&&this.setupStorage(t,A.dataId,e,n)}static render(t){var e,n;const r=t.annotationStorage,i=t.linkService,A=t.xfaHtml,s=t.intent||"display",a=document.createElement(A.name);A.attributes&&this.setAttributes({html:a,element:A,intent:s,linkService:i});const o="richText"!==s,l=t.div;if(l.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=e}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(0===A.children.length){if(A.value){const t=document.createTextNode(A.value);a.append(t),o&&Ik.shouldBuildText(A.name)&&c.push(t)}return{textDivs:c}}const h=[[A,-1,a]];for(;h.length>0;){const[t,A,a]=h.at(-1);if(A+1===t.children.length){h.pop();continue}const l=t.children[++h.at(-1)[1]];if(null===l)continue;const{name:u}=l;if("#text"===u){const t=document.createTextNode(l.value);c.push(t),a.append(t);continue}const d=(null==(e=null==l?void 0:l.attributes)?void 0:e.xmlns)?document.createElementNS(l.attributes.xmlns,u):document.createElement(u);if(a.append(d),l.attributes&&this.setAttributes({html:d,element:l,storage:r,intent:s,linkService:i}),(null==(n=l.children)?void 0:n.length)>0)h.push([l,-1,d]);else if(l.value){const t=document.createTextNode(l.value);o&&Ik.shouldBuildText(u)&&c.push(t),d.append(t)}}for(const u of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))u.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const tM=new WeakSet,eM=60*(new Date).getTimezoneOffset()*1e3;class nM{static create(t){switch(t.data.annotationType){case lU.LINK:return new iM(t);case lU.TEXT:return new AM(t);case lU.WIDGET:switch(t.data.fieldType){case"Tx":return new aM(t);case"Btn":return t.data.radioButton?new cM(t):t.data.checkBox?new lM(t):new hM(t);case"Ch":return new uM(t);case"Sig":return new oM(t)}return new sM(t);case lU.POPUP:return new dM(t);case lU.FREETEXT:return new pM(t);case lU.LINE:return new gM(t);case lU.SQUARE:return new mM(t);case lU.CIRCLE:return new wM(t);case lU.POLYLINE:return new vM(t);case lU.CARET:return new bM(t);case lU.INK:return new BM(t);case lU.POLYGON:return new yM(t);case lU.HIGHLIGHT:return new _M(t);case lU.UNDERLINE:return new CM(t);case lU.SQUIGGLY:return new xM(t);case lU.STRIKEOUT:return new EM(t);case lU.STAMP:return new SM(t);case lU.FILEATTACHMENT:return new FM(t);default:return new rM(t)}}}pA=new WeakMap,gA=new WeakMap,mA=new WeakMap,wA=new WeakSet,vA=function(t){const{container:{style:e},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:A,pageX:s,pageY:a}}}}=this;null==n||n.splice(0,4,...t),e.left=100*(t[0]-s)/i+"%",e.top=100*(A-t[3]+a)/A+"%",0===r?(e.width=100*(t[2]-t[0])/i+"%",e.height=100*(t[3]-t[1])/A+"%"):this.setRotation(r)};let rM=class t{constructor(t,{isRenderable:e=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){Tc(this,wA),Tc(this,pA,null),Tc(this,gA,!1),Tc(this,mA,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!(!(null==t?void 0:t.str)&&!(null==e?void 0:e.str))}get _isEditable(){return this.data.isEditable}get hasPopupData(){return t._hasPopupData(this.data)}updateEdited(t){var e;if(!this.container)return;t.rect&&(Nc(this,pA)||Dc(this,pA,{rect:this.data.rect.slice(0)}));const{rect:n,popup:r}=t;n&&Rc(this,wA,vA).call(this,n);let i=(null==(e=Nc(this,mA))?void 0:e.popup)||this.popup;!i&&(null==r?void 0:r.text)&&(this._createPopup(r),i=Nc(this,mA).popup),i&&(i.updateEdited(t),(null==r?void 0:r.deleted)&&(i.remove(),Dc(this,mA,null),this.popup=null))}resetEdited(){var t;Nc(this,pA)&&(Rc(this,wA,vA).call(this,Nc(this,pA).rect),null==(t=Nc(this,mA))||t.popup.resetEdited(),Dc(this,pA,null))}_createContainer(t){const{data:e,parent:{page:n,viewport:r}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",e.id),this instanceof sM||this instanceof iM||(i.tabIndex=0);const{style:A}=i;if(A.zIndex=this.parent.zIndex++,e.alternativeText&&(i.title=e.alternativeText),e.noRotate&&i.classList.add("norotate"),!e.rect||this instanceof dM){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,i),i}const{width:s,height:a}=this;if(!t&&e.borderStyle.width>0){A.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,n=e.borderStyle.verticalCornerRadius;if(t>0||n>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${n}px * var(--total-scale-factor))`;A.borderRadius=e}else if(this instanceof cM){const t=`calc(${s}px * var(--total-scale-factor)) / calc(${a}px * var(--total-scale-factor))`;A.borderRadius=t}switch(e.borderStyle.style){case cU:A.borderStyle="solid";break;case hU:A.borderStyle="dashed";break;case uU:CU("Unimplemented border style: beveled");break;case dU:CU("Unimplemented border style: inset");break;case fU:A.borderBottomStyle="solid"}const r=e.borderColor||null;r?(Dc(this,gA,!0),A.borderColor=HU.makeHexColor(0|r[0],0|r[1],0|r[2])):A.borderWidth=0}const o=HU.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:l,pageHeight:c,pageX:h,pageY:u}=r.rawDims;A.left=100*(o[0]-h)/l+"%",A.top=100*(o[1]-u)/c+"%";const{rotation:d}=e;return e.hasOwnCanvas||0===d?(A.width=100*s/l+"%",A.height=100*a/c+"%"):this.setRotation(d,i),i}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims;let{width:i,height:A}=this;t%180!=0&&([i,A]=[A,i]),e.style.width=100*i/n+"%",e.style.height=100*A/r+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,n)=>{const r=n.detail[t],i=r[0],A=r.slice(1);n.target.style[e]=Yk[`${i}_HTML`](A),this.annotationStorage.setValue(this.data.id,{[e]:Yk[`${i}_rgb`](A)})};return LU(this,"_commonActions",{display:t=>{const{display:e}=t.detail,n=e%2==1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const n=this._commonActions;for(const r of Object.keys(e.detail)){const i=t[r]||n[r];null==i||i(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const n=this._commonActions;for(const[r,i]of Object.entries(e)){const A=n[r];if(A){A({detail:{[r]:i},target:t}),delete e[r]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,n,r,i]=this.data.rect.map(t=>Math.fround(t));if(8===t.length){const[A,s,a,o]=t.subarray(2,6);if(r===A&&i===s&&e===a&&n===o)return}const{style:A}=this.container;let s;if(Nc(this,gA)){const{borderColor:t,borderWidth:e}=A;A.borderWidth=0,s=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const a=r-e,o=i-n,{svgFactory:l}=this,c=l.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0),c.role="none";const h=l.createElement("defs");c.append(h);const u=l.createElement("clipPath"),d=`clippath_${this.data.id}`;u.setAttribute("id",d),u.setAttribute("clipPathUnits","objectBoundingBox"),h.append(u);for(let f=2,p=t.length;f<p;f+=8){const n=t[f],r=t[f+1],A=t[f+2],c=t[f+3],h=l.createElement("rect"),d=(A-e)/a,p=(i-r)/o,g=(n-A)/a,m=(r-c)/o;h.setAttribute("x",d),h.setAttribute("y",p),h.setAttribute("width",g),h.setAttribute("height",m),u.append(h),null==s||s.push(`<rect vector-effect="non-scaling-stroke" x="${d}" y="${p}" width="${g}" height="${m}"/>`)}Nc(this,gA)&&(s.push("</g></svg>')"),A.backgroundImage=s.join("")),this.container.append(c),this.container.style.clipPath=`url(#${d})`}_createPopup(t=null){const{data:e}=this;let n,r;t?(n={str:t.text},r=t.date):(n=e.contentsObj,r=e.modificationDate);const i=Dc(this,mA,new dM({data:{color:e.color,titleObj:e.titleObj,modificationDate:r,contentsObj:n,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent.div.append(i.render())}get hasPopupElement(){return!!(Nc(this,mA)||this.popup||this.data.popupRef)}render(){xU("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const n=[];if(this._fieldObjects){const r=this._fieldObjects[t];if(r)for(const{page:t,id:i,exportValues:A}of r){if(-1===t)continue;if(i===e)continue;const r="string"==typeof A?A:null,s=document.querySelector(`[data-element-id="${i}"]`);!s||tM.has(s)?n.push({id:i,exportValue:r,domElement:s}):CU(`_getElementsByName - element not allowed: ${i}`)}return n}for(const r of document.getElementsByName(t)){const{exportValue:t}=r,i=r.getAttribute("data-element-id");i!==e&&(tM.has(r)&&n.push({id:i,exportValue:t,domElement:r}))}return n}show(){var t;this.container&&(this.container.hidden=!1),null==(t=this.popup)||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null==(t=this.popup)||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var n;null==(n=this.linkService.eventBus)||n.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};class iM extends rM{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!(null==e?void 0:e.ignoreBorder),createQuadrilaterals:!0}),Tc(this,yA),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{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,t.overlaidText),r=!0):t.attachment?(Rc(this,yA,BA).call(this,n,t.attachment,t.overlaidText,t.attachmentDest),r=!0):t.setOCGState?(Rc(this,yA,_A).call(this,n,t.setOCGState,t.overlaidText),r=!0):t.dest?(this._bindLink(n,t.dest,t.overlaidText),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}_bindLink(t,e,n=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&Rc(this,yA,bA).call(this),n&&(t.title=n)}_bindNamedAction(t,e,n=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),n&&(t.title=n),Rc(this,yA,bA).call(this)}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(e.actions)){const i=n.get(r);i&&(t[i]=()=>{var t;return null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:r}}),!1})}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),Rc(this,yA,bA).call(this)}_bindResetFormAction(t,e){const n=t.onclick;if(n||(t.href=this.linkService.getAnchorUrl("")),Rc(this,yA,bA).call(this),!this._fieldObjects)return CU('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(t.onclick=()=>!1));t.onclick=()=>{var t;null==n||n();const{fields:r,refs:i,include:A}=e,s=[];if(0!==r.length||0!==i.length){const t=new Set(i);for(const e of r){const n=this._fieldObjects[e]||[];for(const{id:e}of n)t.add(e)}for(const e of Object.values(this._fieldObjects))for(const n of e)t.has(n.id)===A&&s.push(n)}else for(const e of Object.values(this._fieldObjects))s.push(...e);const a=this.annotationStorage,o=[];for(const e of s){const{id:t}=e;switch(o.push(t),e.type){case"text":{const n=e.defaultValue||"";a.setValue(t,{value:n});break}case"checkbox":case"radiobutton":{const n=e.defaultValue===e.exportValues;a.setValue(t,{value:n});break}case"combobox":case"listbox":{const n=e.defaultValue||"";a.setValue(t,{value:n});break}default:continue}const n=document.querySelector(`[data-element-id="${t}"]`);n&&(tM.has(n)?n.dispatchEvent(new Event("resetform")):CU(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&(null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}})),!1}}}yA=new WeakSet,bA=function(){this.container.setAttribute("data-internal-link","")},BA=function(t,e,n="",r=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:n&&(t.title=n),t.onclick=()=>{var t;return null==(t=this.downloadManager)||t.openOrDownloadData(e.content,e.filename,r),!1},Rc(this,yA,bA).call(this)},_A=function(t,e,n=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),n&&(t.title=n),Rc(this,yA,bA).call(this)};class AM extends rM{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class sM extends rM{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null==(e=t.previousSibling)?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return DU.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,n,r,i){n.includes("mouse")?t.addEventListener(n,t=>{var e;null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:i(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(n,t=>{var A;if("blur"===n){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===n){if(e.focused)return;e.focused=!0}i&&(null==(A=this.linkService.eventBus)||A.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:i(t)}}))})}_setEventListeners(t,e,n,r){var i,A,s;for(const[a,o]of n)("Action"===o||(null==(i=this.data.actions)?void 0:i[o]))&&("Focus"!==o&&"Blur"!==o||e||(e={focused:!1}),this._setEventListener(t,e,a,o,r),"Focus"!==o||(null==(A=this.data.actions)?void 0:A.Blur)?"Blur"!==o||(null==(s=this.data.actions)?void 0:s.Focus)||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":HU.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||9,i=t.style;let A;const s=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(WL*r))||1);A=Math.min(r,s(e/WL))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);A=Math.min(r,s(t/WL))}i.fontSize=`calc(${A}px * var(--total-scale-factor))`,i.color=HU.makeHexColor(n[0],n[1],n[2]),null!==this.data.textAlignment&&(i.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class aM extends sM{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,n,r){const i=this.annotationStorage;for(const A of this._getElementsByName(t.name,t.id))A.domElement&&(A.domElement[e]=n),i.setValue(A.id,{[r]:n})}render(){var t,e;const n=this.annotationStorage,r=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const A=n.getValue(r,{value:this.data.fieldValue});let s=A.value||"";const a=n.getValue(r,{charLimit:this.data.maxLen}).charLimit;a&&s.length>a&&(s=s.slice(0,a));let o=A.formattedValue||(null==(t=this.data.textContent)?void 0:t.join("\n"))||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));const l={userValue:s,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=null!=o?o:s,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",null!=o?o:s),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),tM.add(i),i.setAttribute("data-element-id",r),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;const{datetimeFormat:c,datetimeType:h,timeStep:u}=this.data,d=!!h&&this.enableScripting;c&&(i.title=c),this._setRequired(i,this.data.required),a&&(i.maxLength=a),i.addEventListener("input",t=>{n.setValue(r,{value:t.target.value}),this.setPropertyOnSiblings(i,"value",t.target.value,"value"),l.formattedValue=null}),i.addEventListener("resetform",t=>{var e;const n=null!=(e=this.data.defaultFieldValue)?e:"";i.value=l.userValue=n,l.formattedValue=null});let f=t=>{const{formattedValue:e}=l;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{var e;if(l.focused)return;const{target:n}=t;if(d&&(n.type=h,u&&(n.step=u)),l.userValue){const t=l.userValue;if(d)if("time"===h){const e=new Date(t),r=[e.getHours(),e.getMinutes(),e.getSeconds()];n.value=r.map(t=>t.toString().padStart(2,"0")).join(":")}else n.value=new Date(t-eM).toISOString().split("date"===h?"T":".",1)[0];else n.value=t}l.lastCommittedValue=n.value,l.commitKey=1,(null==(e=this.data.actions)?void 0:e.Focus)||(l.focused=!0)}),i.addEventListener("updatefromsandbox",t=>{this.showElementAndHideCanvas(t.target);const e={value(t){var e;l.userValue=null!=(e=t.detail.value)?e:"",d||n.setValue(r,{value:l.userValue.toString()}),t.target.value=l.userValue},formattedValue(t){const{formattedValue:e}=t.detail;l.formattedValue=e,null!=e&&t.target!==document.activeElement&&(t.target.value=e);const i={formattedValue:e};d&&(i.value=e),n.setValue(r,i)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:t=>{var e;const{charLimit:i}=t.detail,{target:A}=t;if(0===i)return void A.removeAttribute("maxLength");A.setAttribute("maxLength",i);let s=l.userValue;!s||s.length<=i||(s=s.slice(0,i),A.value=l.userValue=s,n.setValue(r,{value:s}),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:A.selectionStart,selEnd:A.selectionEnd}}))}};this._dispatchEventFromSandbox(e,t)}),i.addEventListener("keydown",t=>{var e;l.commitKey=1;let n=-1;if("Escape"===t.key?n=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(l.commitKey=3):n=2,-1===n)return;const{value:i}=t.target;l.lastCommittedValue!==i&&(l.lastCommittedValue=i,l.userValue=i,null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:i,willCommit:!0,commitKey:n,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});const t=f;f=null,i.addEventListener("blur",e=>{var n,i;if(!l.focused||!e.relatedTarget)return;(null==(n=this.data.actions)?void 0:n.Blur)||(l.focused=!1);const{target:A}=e;let{value:s}=A;if(d){if(s&&"time"===h){const t=s.split(":").map(t=>parseInt(t,10));s=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),A.step=""}else s=new Date(s).valueOf();A.type="text"}l.userValue=s,l.lastCommittedValue!==s&&(null==(i=this.linkService.eventBus)||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:s,willCommit:!0,commitKey:l.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})),t(e)}),(null==(e=this.data.actions)?void 0:e.Keystroke)&&i.addEventListener("beforeinput",t=>{var e;l.lastCommittedValue=null;const{data:n,target:i}=t,{value:A,selectionStart:s,selectionEnd:a}=i;let o=s,c=a;switch(t.inputType){case"deleteWordBackward":{const t=A.substring(0,s).match(/\w*[^\w]*$/);t&&(o-=t[0].length);break}case"deleteWordForward":{const t=A.substring(s).match(/^[^\w]*\w*/);t&&(c+=t[0].length);break}case"deleteContentBackward":s===a&&(o-=1);break;case"deleteContentForward":s===a&&(c+=1)}t.preventDefault(),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:A,change:n||"",willCommit:!1,selStart:o,selEnd:c}})}),this._setEventListeners(i,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(f&&i.addEventListener("blur",f),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/a;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class oM extends sM{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class lM extends sM{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,n=e.id;let r=t.getValue(n,{value:e.exportValue===e.fieldValue}).value;"string"==typeof r&&(r="Off"!==r,t.setValue(n,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const i=document.createElement("input");return tM.add(i),i.setAttribute("data-element-id",n),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=e.fieldName,r&&i.setAttribute("checked",!0),i.setAttribute("exportValue",e.exportValue),i.tabIndex=0,i.addEventListener("change",r=>{const{name:i,checked:A}=r.target;for(const s of this._getElementsByName(i,n)){const n=A&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=n),t.setValue(s.id,{value:n})}t.setValue(n,{value:A})}),i.addEventListener("resetform",t=>{const n=e.defaultFieldValue||"Off";t.target.checked=n===e.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",e=>{const r={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(n,{value:e.target.checked})}};this._dispatchEventFromSandbox(r,e)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class cM extends sM{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,n=e.id;let r=t.getValue(n,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof r&&(r=r!==e.buttonValue,t.setValue(n,{value:r})),r)for(const A of this._getElementsByName(e.fieldName,n))t.setValue(A.id,{value:!1});const i=document.createElement("input");if(tM.add(i),i.setAttribute("data-element-id",n),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="radio",i.name=e.fieldName,r&&i.setAttribute("checked",!0),i.tabIndex=0,i.addEventListener("change",e=>{const{name:r,checked:i}=e.target;for(const A of this._getElementsByName(r,n))t.setValue(A.id,{value:!1});t.setValue(n,{value:i})}),i.addEventListener("resetform",t=>{const n=e.defaultFieldValue;t.target.checked=null!=n&&n===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;i.addEventListener("updatefromsandbox",e=>{const i={value:e=>{const i=r===e.detail.value;for(const r of this._getElementsByName(e.target.name)){const e=i&&r.id===n;r.domElement&&(r.domElement.checked=e),t.setValue(r.id,{value:e})}}};this._dispatchEventFromSandbox(i,e)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class hM extends iM{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class uM extends sM{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,n=t.getValue(e,{value:this.data.fieldValue}),r=document.createElement("select");tM.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=0;let i=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",t=>{const e=this.data.defaultFieldValue;for(const n of r.options)n.selected=n.value===e});for(const l of this.data.options){const t=document.createElement("option");t.textContent=l.displayValue,t.value=l.exportValue,n.value.includes(l.exportValue)&&(t.setAttribute("selected",!0),i=!1),r.append(t)}let A=null;if(i){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),r.prepend(t),A=()=>{t.remove(),r.removeEventListener("input",A),A=null},r.addEventListener("input",A)}const s=t=>{const e=t?"value":"textContent",{options:n,multiple:i}=r;return i?Array.prototype.filter.call(n,t=>t.selected).map(t=>t[e]):-1===n.selectedIndex?null:n[n.selectedIndex][e]};let a=s(!1);const o=t=>{const e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",n=>{const i={value(n){null==A||A();const i=n.detail.value,o=new Set(Array.isArray(i)?i:[i]);for(const t of r.options)t.selected=o.has(t.value);t.setValue(e,{value:s(!0)}),a=s(!1)},multipleSelection(t){r.multiple=!0},remove(n){const i=r.options,A=n.detail.remove;if(i[A].selected=!1,r.remove(A),i.length>0){-1===Array.prototype.findIndex.call(i,t=>t.selected)&&(i[0].selected=!0)}t.setValue(e,{value:s(!0),items:o(n)}),a=s(!1)},clear(n){for(;0!==r.length;)r.remove(0);t.setValue(e,{value:null,items:[]}),a=s(!1)},insert(n){const{index:i,displayValue:A,exportValue:l}=n.detail.insert,c=r.children[i],h=document.createElement("option");h.textContent=A,h.value=l,c?c.before(h):r.append(h),t.setValue(e,{value:s(!0),items:o(n)}),a=s(!1)},items(n){const{items:i}=n.detail;for(;0!==r.length;)r.remove(0);for(const t of i){const{displayValue:e,exportValue:n}=t,i=document.createElement("option");i.textContent=e,i.value=n,r.append(i)}r.options.length>0&&(r.options[0].selected=!0),t.setValue(e,{value:s(!0),items:o(n)}),a=s(!1)},indices(n){const r=new Set(n.detail.indices);for(const t of n.target.options)t.selected=r.has(t.index);t.setValue(e,{value:s(!0)}),a=s(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(i,n)}),r.addEventListener("input",n=>{var r;const i=s(!0),A=s(!1);t.setValue(e,{value:i}),n.preventDefault(),null==(r=this.linkService.eventBus)||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,change:A,changeEx:i,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"]],t=>t.target.value)):r.addEventListener("input",function(n){t.setValue(e,{value:s(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class dM extends rM{constructor(t){const{data:e,elements:n}=t;super(t,{isRenderable:rM._hasPopupData(e)}),this.elements=n,this.popup=null}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=new fM({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),n=[];for(const r of this.elements)r.popup=e,r.container.ariaHasPopup="dialog",n.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",n.map(t=>`${KU}${t}`).join(",")),this.container}}class fM{constructor({container:t,color:e,elements:n,titleObj:r,modificationDate:i,contentsObj:A,richText:s,parent:a,rect:o,parentRect:l,open:c}){Tc(this,VA),Tc(this,CA,Rc(this,VA,YA).bind(this)),Tc(this,xA,Rc(this,VA,ts).bind(this)),Tc(this,EA,Rc(this,VA,ZA).bind(this)),Tc(this,SA,Rc(this,VA,JA).bind(this)),Tc(this,FA,null),Tc(this,LA,null),Tc(this,UA,null),Tc(this,IA,null),Tc(this,QA,null),Tc(this,kA,null),Tc(this,MA,null),Tc(this,OA,!1),Tc(this,PA,null),Tc(this,NA,null),Tc(this,TA,null),Tc(this,DA,null),Tc(this,RA,null),Tc(this,HA,null),Tc(this,jA,null),Tc(this,WA,!1),Dc(this,LA,t),Dc(this,HA,r),Dc(this,UA,A),Dc(this,RA,s),Dc(this,kA,a),Dc(this,FA,e),Dc(this,DA,o),Dc(this,MA,l),Dc(this,QA,n),Dc(this,IA,sI.toDateObject(i)),this.trigger=n.flatMap(t=>t.getElementsToTriggerPopup()),Rc(this,VA,KA).call(this),Nc(this,LA).hidden=!0,c&&Rc(this,VA,JA).call(this)}render(){var t;if(Nc(this,PA))return;const e=Dc(this,PA,document.createElement("div"));if(e.className="popup",Nc(this,FA)){const t=e.style.outlineColor=HU.makeHexColor(...Nc(this,FA));e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const n=document.createElement("span");if(n.className="header",null==(t=Nc(this,HA))?void 0:t.str){const t=document.createElement("span");t.className="title",n.append(t),({dir:t.dir,str:t.textContent}=Nc(this,HA))}if(e.append(n),Nc(this,IA)){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:Nc(this,IA).valueOf()})),t.dateTime=Nc(this,IA).toISOString(),n.append(t)}const r=Nc(this,VA,GA);if(r)Zk.render({xfaHtml:r,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const t=this._formatContents(Nc(this,UA));e.append(t)}Nc(this,LA).append(e)}_formatContents({str:t,dir:e}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=e;const r=t.split(/(?:\r\n?|\n)/);for(let i=0,A=r.length;i<A;++i){const t=r[i];n.append(document.createTextNode(t)),i<A-1&&n.append(document.createElement("br"))}return n}updateEdited({rect:t,popup:e,deleted:n}){var r;n||(null==e?void 0:e.deleted)?this.remove():(Rc(this,VA,KA).call(this),Nc(this,jA)||Dc(this,jA,{contentsObj:Nc(this,UA),richText:Nc(this,RA)}),t&&Dc(this,TA,null),e&&(Dc(this,RA,Rc(this,VA,XA).call(this,e.text)),Dc(this,IA,sI.toDateObject(e.date)),Dc(this,UA,null)),null==(r=Nc(this,PA))||r.remove(),Dc(this,PA,null))}resetEdited(){var t;Nc(this,jA)&&(({contentsObj:Hc(this,UA)._,richText:Hc(this,RA)._}=Nc(this,jA)),Dc(this,jA,null),null==(t=Nc(this,PA))||t.remove(),Dc(this,PA,null),Dc(this,TA,null))}remove(){var t,e;null==(t=Nc(this,NA))||t.abort(),Dc(this,NA,null),null==(e=Nc(this,PA))||e.remove(),Dc(this,PA,null),Dc(this,WA,!1),Dc(this,OA,!1);for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){Dc(this,WA,this.isVisible),Nc(this,WA)&&(Nc(this,LA).hidden=!0)}maybeShow(){Rc(this,VA,KA).call(this),Nc(this,WA)&&(Nc(this,PA)||Rc(this,VA,ZA).call(this),Dc(this,WA,!1),Nc(this,LA).hidden=!1)}get isVisible(){return!1===Nc(this,LA).hidden}}CA=new WeakMap,xA=new WeakMap,EA=new WeakMap,SA=new WeakMap,FA=new WeakMap,LA=new WeakMap,UA=new WeakMap,IA=new WeakMap,QA=new WeakMap,kA=new WeakMap,MA=new WeakMap,OA=new WeakMap,PA=new WeakMap,NA=new WeakMap,TA=new WeakMap,DA=new WeakMap,RA=new WeakMap,HA=new WeakMap,jA=new WeakMap,WA=new WeakMap,VA=new WeakSet,KA=function(){var t;if(Nc(this,NA))return;Dc(this,NA,new AbortController);const{signal:e}=Nc(this,NA);for(const n of this.trigger)n.addEventListener("click",Nc(this,SA),{signal:e}),n.addEventListener("mouseenter",Nc(this,EA),{signal:e}),n.addEventListener("mouseleave",Nc(this,xA),{signal:e}),n.classList.add("popupTriggerArea");for(const n of Nc(this,QA))null==(t=n.container)||t.addEventListener("keydown",Nc(this,CA),{signal:e})},GA=function(){const t=Nc(this,RA),e=Nc(this,UA);return!(null==t?void 0:t.str)||(null==e?void 0:e.str)&&e.str!==t.str?null:Nc(this,RA).html||null},zA=function(){var t,e,n;return(null==(n=null==(e=null==(t=Nc(this,VA,GA))?void 0:t.attributes)?void 0:e.style)?void 0:n.fontSize)||0},qA=function(){var t,e,n;return(null==(n=null==(e=null==(t=Nc(this,VA,GA))?void 0:t.attributes)?void 0:e.style)?void 0:n.color)||null},XA=function(t){const e=[],n={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},r={style:{color:Nc(this,VA,qA),fontSize:Nc(this,VA,zA)?`calc(${Nc(this,VA,zA)}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:r});return n},YA=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&Nc(this,OA))&&Rc(this,VA,JA).call(this)},$A=function(){if(null!==Nc(this,TA))return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:n,pageX:r,pageY:i}}}=Nc(this,kA);let A=!!Nc(this,MA),s=Nc(this,A?MA:DA);for(const u of Nc(this,QA))if(!s||null!==HU.intersect(u.data.rect,s)){s=u.data.rect,A=!0;break}const a=HU.normalizeRect([s[0],t[3]-s[1]+t[1],s[2],t[3]-s[3]+t[1]]),o=A?s[2]-s[0]+5:0,l=a[0]+o,c=a[1];Dc(this,TA,[100*(l-r)/e,100*(c-i)/n]);const{style:h}=Nc(this,LA);h.left=`${Nc(this,TA)[0]}%`,h.top=`${Nc(this,TA)[1]}%`},JA=function(){Dc(this,OA,!Nc(this,OA)),Nc(this,OA)?(Rc(this,VA,ZA).call(this),Nc(this,LA).addEventListener("click",Nc(this,SA)),Nc(this,LA).addEventListener("keydown",Nc(this,CA))):(Rc(this,VA,ts).call(this),Nc(this,LA).removeEventListener("click",Nc(this,SA)),Nc(this,LA).removeEventListener("keydown",Nc(this,CA)))},ZA=function(){Nc(this,PA)||this.render(),this.isVisible?Nc(this,OA)&&Nc(this,LA).classList.add("focused"):(Rc(this,VA,$A).call(this),Nc(this,LA).hidden=!1,Nc(this,LA).style.zIndex=parseInt(Nc(this,LA).style.zIndex)+1e3)},ts=function(){Nc(this,LA).classList.remove("focused"),!Nc(this,OA)&&this.isVisible&&(Nc(this,LA).hidden=!0,Nc(this,LA).style.zIndex=parseInt(Nc(this,LA).style.zIndex)-1e3)};class pM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=tU.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const 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}}class gM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,es,null)}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:n}=this,r=this.svgFactory.create(e,n,!0),i=Dc(this,es,this.svgFactory.createElement("svg:line"));return i.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),i.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),i.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),i.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),i.setAttribute("stroke-width",t.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),r.append(i),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Nc(this,es)}addHighlightArea(){this.container.classList.add("highlightArea")}}es=new WeakMap;class mM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,ns,null)}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:n}=this,r=this.svgFactory.create(e,n,!0),i=t.borderStyle.width,A=Dc(this,ns,this.svgFactory.createElement("svg:rect"));return A.setAttribute("x",i/2),A.setAttribute("y",i/2),A.setAttribute("width",e-i),A.setAttribute("height",n-i),A.setAttribute("stroke-width",i||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 Nc(this,ns)}addHighlightArea(){this.container.classList.add("highlightArea")}}ns=new WeakMap;class wM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,rs,null)}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:n}=this,r=this.svgFactory.create(e,n,!0),i=t.borderStyle.width,A=Dc(this,rs,this.svgFactory.createElement("svg:ellipse"));return A.setAttribute("cx",e/2),A.setAttribute("cy",n/2),A.setAttribute("rx",e/2-i/2),A.setAttribute("ry",n/2-i/2),A.setAttribute("stroke-width",i||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 Nc(this,rs)}addHighlightArea(){this.container.classList.add("highlightArea")}}rs=new WeakMap;class vM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,is,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:n,popupRef:r},width:i,height:A}=this;if(!e)return this.container;const s=this.svgFactory.create(i,A,!0);let a=[];for(let l=0,c=e.length;l<c;l+=2){const n=e[l]-t[0],r=t[3]-e[l+1];a.push(`${n},${r}`)}a=a.join(" ");const o=Dc(this,is,this.svgFactory.createElement(this.svgElementName));return o.setAttribute("points",a),o.setAttribute("stroke-width",n.width||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),s.append(o),this.container.append(s),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Nc(this,is)}addHighlightArea(){this.container.classList.add("highlightArea")}}is=new WeakMap;class yM extends vM{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class bM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class BM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,as),Tc(this,As,null),Tc(this,ss,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?tU.HIGHLIGHT:tU.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:n,borderStyle:r,popupRef:i}}=this,{transform:A,width:s,height:a}=Rc(this,as,os).call(this,e,t),o=this.svgFactory.create(s,a,!0),l=Dc(this,As,this.svgFactory.createElement("svg:g"));o.append(l),l.setAttribute("stroke-width",r.width||1),l.setAttribute("stroke-linecap","round"),l.setAttribute("stroke-linejoin","round"),l.setAttribute("stroke-miterlimit",10),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),l.setAttribute("transform",A);for(let c=0,h=n.length;c<h;c++){const t=this.svgFactory.createElement(this.svgElementName);Nc(this,ss).push(t),t.setAttribute("points",n[c].join(",")),l.append(t)}return!i&&this.hasPopupData&&this._createPopup(),this.container.append(o),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:n,rect:r}=t,i=Nc(this,As);if(e>=0&&i.setAttribute("stroke-width",e||1),n)for(let A=0,s=Nc(this,ss).length;A<s;A++)Nc(this,ss)[A].setAttribute("points",n[A].join(","));if(r){const{transform:t,width:e,height:n}=Rc(this,as,os).call(this,this.data.rotation,r);i.parentElement.setAttribute("viewBox",`0 0 ${e} ${n}`),i.setAttribute("transform",t)}}getElementsToTriggerPopup(){return Nc(this,ss)}addHighlightArea(){this.container.classList.add("highlightArea")}}As=new WeakMap,ss=new WeakMap,as=new WeakSet,os=function(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}};class _M extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=tU.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class CM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class xM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class EM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class SM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=tU.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class FM extends rM{constructor(t){var e;super(t,{isRenderable:!0}),Tc(this,cs),Tc(this,ls,null);const{file:n}=this.data;this.filename=n.filename,this.content=n.content,null==(e=this.linkService.eventBus)||e.dispatch("fileattachmentannotation",Qc({source:this},n))}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let n;e.hasAppearance||0===e.fillAlpha?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(100*e.fillAlpha)}%);`)),n.addEventListener("dblclick",Rc(this,cs,hs).bind(this)),Dc(this,ls,n);const{isMac:r}=DU.platform;return t.addEventListener("keydown",t=>{"Enter"===t.key&&(r?t.metaKey:t.ctrlKey)&&Rc(this,cs,hs).call(this)}),!e.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),t.append(n),t}getElementsToTriggerPopup(){return Nc(this,ls)}addHighlightArea(){this.container.classList.add("highlightArea")}}ls=new WeakMap,cs=new WeakSet,hs=function(){var t;null==(t=this.downloadManager)||t.openOrDownloadData(this.content,this.filename)};us=new WeakMap,ds=new WeakMap,fs=new WeakMap,ps=new WeakMap,gs=new WeakSet,ms=function(t,e,n){return Wc(this,null,function*(){var r,i;const A=t.firstChild||t,s=A.id=`${KU}${e}`,a=yield null==(r=Nc(this,ps))?void 0:r.getAriaAttributes(s);if(a)for(const[t,e]of a)A.setAttribute(t,e);n?n.at(-1).container.after(t):(this.div.append(t),null==(i=Nc(this,us))||i.moveElementInDOM(this.div,t,A,!1))})},ws=function(){var t;if(!Nc(this,ds))return;const e=this.div;for(const[n,r]of Nc(this,ds)){const i=e.querySelector(`[data-annotation-id="${n}"]`);if(!i)continue;r.className="annotationContent";const{firstChild:A}=i;A?"CANVAS"===A.nodeName?A.replaceWith(r):A.classList.contains("annotationContent")?A.after(r):A.before(r):i.append(r);const s=Nc(this,fs).get(n);s&&(s._hasNoCanvas?(null==(t=this._annotationEditorUIManager)||t.setMissingCanvas(n,i.id,r),s._hasNoCanvas=!1):s.canvas=r)}Nc(this,ds).clear()};let LM=class t{constructor({div:t,accessibilityManager:e,annotationCanvasMap:n,annotationEditorUIManager:r,page:i,viewport:A,structTreeLayer:s}){Tc(this,gs),Tc(this,us,null),Tc(this,ds,null),Tc(this,fs,new Map),Tc(this,ps,null),this.div=t,Dc(this,us,e),Dc(this,ds,n),Dc(this,ps,s||null),this.page=i,this.viewport=A,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return Nc(this,fs).size>0}render(t){return Wc(this,null,function*(){var e;const{annotations:n}=t,r=this.div;cI(r,this.viewport);const i=new Map,A={data:null,layer:r,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Jk,annotationStorage:t.annotationStorage||new DI,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of n){if(t.noHTML)continue;const n=t.annotationType===lU.POPUP;if(n){const e=i.get(t.id);if(!e)continue;A.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;A.data=t;const r=nM.create(A);if(!r.isRenderable)continue;if(!n&&t.popupRef){const e=i.get(t.popupRef);e?e.push(r):i.set(t.popupRef,[r])}const s=r.render();t.hidden&&(s.style.visibility="hidden"),yield Rc(this,gs,ms).call(this,s,t.id,A.elements),r._isEditable&&(Nc(this,fs).set(r.data.id,r),null==(e=this._annotationEditorUIManager)||e.renderAnnotationElement(r))}Rc(this,gs,ws).call(this)})}addLinkAnnotations(e,n){return Wc(this,null,function*(){const r={data:null,layer:this.div,linkService:n,svgFactory:new Jk,parent:this};for(const n of e){n.borderStyle||(n.borderStyle=t._defaultBorderStyle),r.data=n;const e=nM.create(r);if(!e.isRenderable)continue;const i=e.render();yield Rc(this,gs,ms).call(this,i,n.id,null)}})}update({viewport:t}){const e=this.div;this.viewport=t,cI(e,{rotation:t.rotation}),Rc(this,gs,ws).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(Nc(this,fs).values())}getEditableAnnotation(t){return Nc(this,fs).get(t)}static get _defaultBorderStyle(){return LU(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:cU,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};const UM=/\r\n?|\n/g,IM=class t extends QI{constructor(e){super(kc(Qc({},e),{name:"freeTextEditor"})),Tc(this,Cs),Tc(this,vs),Tc(this,ys,""),Tc(this,bs,`${this.id}-editor`),Tc(this,Bs,null),Tc(this,_s),Oc(this,"_colorPicker",null),Dc(this,vs,e.color||t._defaultColor||QI._defaultLineColor),Dc(this,_s,e.fontSize||t._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const e=t.prototype,n=t=>t.isEmpty(),r=xI.TRANSLATE_SMALL,i=xI.TRANSLATE_BIG;return LU(this,"_keyboardManager",new bI([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[r,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[i,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:n}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,r],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,i],checker:n}]]))}static initialize(t,e){QI.initialize(t,e);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,n){switch(e){case eU.FREETEXT_SIZE:t._defaultFontSize=n;break;case eU.FREETEXT_COLOR:t._defaultColor=n}}updateParams(t,e){switch(t){case eU.FREETEXT_SIZE:Rc(this,Cs,xs).call(this,e);break;case eU.FREETEXT_COLOR:Rc(this,Cs,Es).call(this,e)}}static get defaultPropertiesToUpdate(){return[[eU.FREETEXT_SIZE,t._defaultFontSize],[eU.FREETEXT_COLOR,t._defaultColor||QI._defaultLineColor]]}get propertiesToUpdate(){return[[eU.FREETEXT_SIZE,Nc(this,_s)],[eU.FREETEXT_COLOR,Nc(this,vs)]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new zk(this)),[["colorPicker",this._colorPicker]]}get colorType(){return eU.FREETEXT_COLOR}get colorValue(){return Nc(this,vs)}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const e=this.parentScale;return[-t._internalPadding*e,-(t._internalPadding+Nc(this,_s))*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),Dc(this,Bs,new AbortController);const t=this._uiManager.combinedSignal(Nc(this,Bs));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){var t;return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",Nc(this,bs)),this._isDraggable=!0,null==(t=Nc(this,Bs))||t.abort(),Dc(this,Bs,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var e;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),(null==(e=this._initialOptions)?void 0:e.isCentered)&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=Nc(this,ys),e=Dc(this,ys,Rc(this,Cs,Ss).call(this).trimEnd());if(t===e)return;const n=t=>{Dc(this,ys,t),t?(Rc(this,Cs,Is).call(this),this._uiManager.rebuild(this),Rc(this,Cs,Fs).call(this)):this.remove()};this.addCommands({cmd:()=>{n(e)},undo:()=>{n(t)},mustExec:!1}),Rc(this,Cs,Fs).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(e){t._keyboardManager.exec(this,e)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",Nc(this,bs)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:n}=this.editorDiv;if(n.fontSize=`calc(${Nc(this,_s)}px * var(--total-scale-factor))`,n.color=Nc(this,vs),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[n,r]=this.parentDimensions;if(this.annotationElementId){const{position:i}=this._initialData;let[A,s]=this.getInitialTranslation();[A,s]=this.pageTranslationToScreen(A,s);const[a,o]=this.pageDimensions,[l,c]=this.pageTranslation;let h,u;switch(this.rotation){case 0:h=t+(i[0]-l)/a,u=e+this.height-(i[1]-c)/o;break;case 90:h=t+(i[0]-l)/a,u=e-(i[1]-c)/o,[A,s]=[s,-A];break;case 180:h=t-this.width+(i[0]-l)/a,u=e-(i[1]-c)/o,[A,s]=[-A,-s];break;case 270:h=t+(i[0]-l-this.height*o)/a,u=e+(i[1]-c-this.width*a)/o,[A,s]=[-s,A]}this.setAt(h*n,u*r,A,s)}else this._moveAfterPaste(t,e);Rc(this,Cs,Is).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var n,r,i;const A=e.clipboardData||window.clipboardData,{types:s}=A;if(1===s.length&&"text/plain"===s[0])return;e.preventDefault();const a=Rc(n=t,Ls,ks).call(n,A.getData("text")||"").replaceAll(UM,"\n");if(!a)return;const o=window.getSelection();if(!o.rangeCount)return;this.editorDiv.normalize(),o.deleteFromDocument();const l=o.getRangeAt(0);if(!a.includes("\n"))return l.insertNode(document.createTextNode(a)),this.editorDiv.normalize(),void o.collapseToStart();const{startContainer:c,startOffset:h}=l,u=[],d=[];if(c.nodeType===Node.TEXT_NODE){const e=c.parentElement;if(d.push(c.nodeValue.slice(h).replaceAll(UM,"")),e!==this.editorDiv){let n=u;for(const i of this.editorDiv.childNodes)i!==e?n.push(Rc(r=t,Ls,Us).call(r,i)):n=d}u.push(c.nodeValue.slice(0,h).replaceAll(UM,""))}else if(c===this.editorDiv){let e=u,n=0;for(const r of this.editorDiv.childNodes)n++===h&&(e=d),e.push(Rc(i=t,Ls,Us).call(i,r))}Dc(this,ys,`${u.join("\n")}${a}${d.join("\n")}`),Rc(this,Cs,Is).call(this);const f=new Range;let p=Math.sumPrecise(u.map(t=>t.length));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(p<=e){f.setStart(t,p),f.setEnd(t,p);break}p-=e}o.removeAllRanges(),o.addRange(f)}get contentDiv(){return this.editorDiv}static deserialize(e,n,r){return Wc(this,null,function*(){var i;let A=null;if(e instanceof pM){const{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:r,rotation:i,id:s,popupRef:a,contentsObj:o},textContent:l,textPosition:c,parent:{page:{pageNumber:h}}}=e;if(!l||0===l.length)return null;A=e={annotationType:tU.FREETEXT,color:Array.from(n),fontSize:t,value:l.join("\n"),position:c,pageIndex:h-1,rect:r.slice(0),rotation:i,annotationElementId:s,id:s,deleted:!1,popupRef:a,comment:(null==o?void 0:o.str)||null}}const s=yield jc(t,this,"deserialize").call(this,e,n,r);return Dc(s,_s,e.fontSize),Dc(s,vs,HU.makeHexColor(...e.color)),Dc(s,ys,Rc(i=t,Ls,ks).call(i,e.value)),s._initialData=A,e.comment&&s.setCommentData(e.comment),s})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n=t._internalPadding*this.parentScale,r=this.getRect(n,n),i=QI._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:Nc(this,vs)),A={annotationType:tU.FREETEXT,color:i,fontSize:Nc(this,_s),value:Rc(this,Cs,Qs).call(this),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(A),e?(A.isCopy=!0,A):this.annotationElementId&&!Rc(this,Cs,Ms).call(this,A)?null:(A.id=this.annotationElementId,A)}renderAnnotationElement(e){const n=super.renderAnnotationElement(e),{style:r}=n;r.fontSize=`calc(${Nc(this,_s)}px * var(--total-scale-factor))`,r.color=Nc(this,vs),n.replaceChildren();for(const t of Nc(this,ys).split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),n.append(e)}const i=t._internalPadding*this.parentScale,A={rect:this.getRect(i,i)};return A.popup=this.hasEditedComment?this.comment:{text:Nc(this,ys)},e.updateEdited(A),n}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};vs=new WeakMap,ys=new WeakMap,bs=new WeakMap,Bs=new WeakMap,_s=new WeakMap,Cs=new WeakSet,xs=function(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-Nc(this,_s))*this.parentScale),Dc(this,_s,t),Rc(this,Cs,Fs).call(this)},n=Nc(this,_s);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:eU.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Es=function(t){const e=t=>{var e;Dc(this,vs,this.editorDiv.style.color=t),null==(e=this._colorPicker)||e.update(t)},n=Nc(this,vs);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:eU.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Ss=function(){var t;const e=[];this.editorDiv.normalize();let n=null;for(const r of this.editorDiv.childNodes)(null==n?void 0:n.nodeType)===Node.TEXT_NODE&&"BR"===r.nodeName||(e.push(Rc(t=IM,Ls,Us).call(t,r)),n=r);return e.join("\n")},Fs=function(){const[t,e]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,r=e.style.display,i=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),n=e.getBoundingClientRect(),e.remove(),e.style.display=r,e.classList.toggle("hidden",i)}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()},Ls=new WeakSet,Us=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(UM,"")},Is=function(){if(this.editorDiv.replaceChildren(),Nc(this,ys))for(const t of Nc(this,ys).split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}},Qs=function(){return Nc(this,ys).replaceAll(" "," ")},ks=function(t){return t.replaceAll(" "," ")},Ms=function(t){const{value:e,fontSize:n,color:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==n||t.color.some((t,e)=>t!==r[e])||t.pageIndex!==i},Tc(IM,Ls),Oc(IM,"_freeTextDefaultContent",""),Oc(IM,"_internalPadding",0),Oc(IM,"_defaultColor",null),Oc(IM,"_defaultFontSize",10),Oc(IM,"_type","freetext"),Oc(IM,"_editorType",tU.FREETEXT);let QM=IM;class kM{toSVGPath(){xU("Abstract method `toSVGPath` must be implemented.")}get box(){xU("Abstract getter `box` must be implemented.")}serialize(t,e){xU("Abstract method `serialize` must be implemented.")}static _rescale(t,e,n,r,i,A){A||(A=new Float32Array(t.length));for(let s=0,a=t.length;s<a;s+=2)A[s]=e+t[s]*r,A[s+1]=n+t[s+1]*i;return A}static _rescaleAndSwap(t,e,n,r,i,A){A||(A=new Float32Array(t.length));for(let s=0,a=t.length;s<a;s+=2)A[s]=e+t[s+1]*r,A[s+1]=n+t[s]*i;return A}static _translate(t,e,n,r){r||(r=new Float32Array(t.length));for(let i=0,A=t.length;i<A;i+=2)r[i]=e+t[i],r[i+1]=n+t[i+1];return r}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,n,r,i){switch(i){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,i,A){return[(t+5*n)/6,(e+5*r)/6,(5*n+i)/6,(5*r+A)/6,(n+i)/2,(r+A)/2]}}Oc(kM,"PRECISION",1e-4);const MM=class t{constructor({x:e,y:n},r,i,A,s,a=0){Tc(this,$s),Tc(this,Os),Tc(this,Ps,[]),Tc(this,Ns),Tc(this,Ts),Tc(this,Ds,[]),Tc(this,Rs,new Float32Array(18)),Tc(this,Hs),Tc(this,js),Tc(this,Ws),Tc(this,Vs),Tc(this,Ks),Tc(this,Gs),Tc(this,zs,[]),Dc(this,Os,r),Dc(this,Gs,A*i),Dc(this,Ts,s),Nc(this,Rs).set([NaN,NaN,NaN,NaN,e,n],6),Dc(this,Ns,a),Dc(this,Vs,Nc(t,qs)*i),Dc(this,Ws,Nc(t,Ys)*i),Dc(this,Ks,i),Nc(this,zs).push(e,n)}isEmpty(){return isNaN(Nc(this,Rs)[8])}add({x:t,y:e}){var n;Dc(this,Hs,t),Dc(this,js,e);const[r,i,A,s]=Nc(this,Os);let[a,o,l,c]=Nc(this,Rs).subarray(8,12);const h=t-l,u=e-c,d=Math.hypot(h,u);if(d<Nc(this,Ws))return!1;const f=d-Nc(this,Vs),p=f/d,g=p*h,m=p*u;let w=a,v=o;a=l,o=c,l+=g,c+=m,null==(n=Nc(this,zs))||n.push(t,e);const y=g/f,b=-m/f*Nc(this,Gs),B=y*Nc(this,Gs);if(Nc(this,Rs).set(Nc(this,Rs).subarray(2,8),0),Nc(this,Rs).set([l+b,c+B],4),Nc(this,Rs).set(Nc(this,Rs).subarray(14,18),12),Nc(this,Rs).set([l-b,c-B],16),isNaN(Nc(this,Rs)[6]))return 0===Nc(this,Ds).length&&(Nc(this,Rs).set([a+b,o+B],2),Nc(this,Ds).push(NaN,NaN,NaN,NaN,(a+b-r)/A,(o+B-i)/s),Nc(this,Rs).set([a-b,o-B],14),Nc(this,Ps).push(NaN,NaN,NaN,NaN,(a-b-r)/A,(o-B-i)/s)),Nc(this,Rs).set([w,v,a,o,l,c],6),!this.isEmpty();Nc(this,Rs).set([w,v,a,o,l,c],6);return Math.abs(Math.atan2(v-o,w-a)-Math.atan2(m,g))<Math.PI/2?([a,o,l,c]=Nc(this,Rs).subarray(2,6),Nc(this,Ds).push(NaN,NaN,NaN,NaN,((a+l)/2-r)/A,((o+c)/2-i)/s),[a,o,w,v]=Nc(this,Rs).subarray(14,18),Nc(this,Ps).push(NaN,NaN,NaN,NaN,((w+a)/2-r)/A,((v+o)/2-i)/s),!0):([w,v,a,o,l,c]=Nc(this,Rs).subarray(0,6),Nc(this,Ds).push(((w+5*a)/6-r)/A,((v+5*o)/6-i)/s,((5*a+l)/6-r)/A,((5*o+c)/6-i)/s,((a+l)/2-r)/A,((o+c)/2-i)/s),[l,c,a,o,w,v]=Nc(this,Rs).subarray(12,18),Nc(this,Ps).push(((w+5*a)/6-r)/A,((v+5*o)/6-i)/s,((5*a+l)/6-r)/A,((5*o+c)/6-i)/s,((a+l)/2-r)/A,((o+c)/2-i)/s),!0)}toSVGPath(){if(this.isEmpty())return"";const t=Nc(this,Ds),e=Nc(this,Ps);if(isNaN(Nc(this,Rs)[6])&&!this.isEmpty())return Rc(this,$s,Zs).call(this);const 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]}`);Rc(this,$s,ea).call(this,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 Rc(this,$s,ta).call(this,n),n.join(" ")}newFreeDrawOutline(t,e,n,r,i,A){return new PM(t,e,n,r,i,A)}getOutlines(){var t,e;const n=Nc(this,Ds),r=Nc(this,Ps),i=Nc(this,Rs),[A,s,a,o]=Nc(this,Os),l=new Float32Array((null!=(e=null==(t=Nc(this,zs))?void 0:t.length)?e:0)+2);for(let u=0,d=l.length-2;u<d;u+=2)l[u]=(Nc(this,zs)[u]-A)/a,l[u+1]=(Nc(this,zs)[u+1]-s)/o;if(l[l.length-2]=(Nc(this,Hs)-A)/a,l[l.length-1]=(Nc(this,js)-s)/o,isNaN(i[6])&&!this.isEmpty())return Rc(this,$s,na).call(this,l);const c=new Float32Array(Nc(this,Ds).length+24+Nc(this,Ps).length);let h=n.length;for(let u=0;u<h;u+=2)isNaN(n[u])?c[u]=c[u+1]=NaN:(c[u]=n[u],c[u+1]=n[u+1]);h=Rc(this,$s,ia).call(this,c,h);for(let u=r.length-6;u>=6;u-=6)for(let t=0;t<6;t+=2)isNaN(r[u+t])?(c[h]=c[h+1]=NaN,h+=2):(c[h]=r[u+t],c[h+1]=r[u+t+1],h+=2);return Rc(this,$s,ra).call(this,c,h),this.newFreeDrawOutline(c,l,Nc(this,Os),Nc(this,Ks),Nc(this,Ns),Nc(this,Ts))}};Os=new WeakMap,Ps=new WeakMap,Ns=new WeakMap,Ts=new WeakMap,Ds=new WeakMap,Rs=new WeakMap,Hs=new WeakMap,js=new WeakMap,Ws=new WeakMap,Vs=new WeakMap,Ks=new WeakMap,Gs=new WeakMap,zs=new WeakMap,qs=new WeakMap,Xs=new WeakMap,Ys=new WeakMap,$s=new WeakSet,Js=function(){const t=Nc(this,Rs).subarray(4,6),e=Nc(this,Rs).subarray(16,18),[n,r,i,A]=Nc(this,Os);return[(Nc(this,Hs)+(t[0]-e[0])/2-n)/i,(Nc(this,js)+(t[1]-e[1])/2-r)/A,(Nc(this,Hs)+(e[0]-t[0])/2-n)/i,(Nc(this,js)+(e[1]-t[1])/2-r)/A]},Zs=function(){const[t,e,n,r]=Nc(this,Os),[i,A,s,a]=Rc(this,$s,Js).call(this);return`M${(Nc(this,Rs)[2]-t)/n} ${(Nc(this,Rs)[3]-e)/r} L${(Nc(this,Rs)[4]-t)/n} ${(Nc(this,Rs)[5]-e)/r} L${i} ${A} L${s} ${a} L${(Nc(this,Rs)[16]-t)/n} ${(Nc(this,Rs)[17]-e)/r} L${(Nc(this,Rs)[14]-t)/n} ${(Nc(this,Rs)[15]-e)/r} Z`},ta=function(t){const e=Nc(this,Ps);t.push(`L${e[4]} ${e[5]} Z`)},ea=function(t){const[e,n,r,i]=Nc(this,Os),A=Nc(this,Rs).subarray(4,6),s=Nc(this,Rs).subarray(16,18),[a,o,l,c]=Rc(this,$s,Js).call(this);t.push(`L${(A[0]-e)/r} ${(A[1]-n)/i} L${a} ${o} L${l} ${c} L${(s[0]-e)/r} ${(s[1]-n)/i}`)},na=function(t){const e=Nc(this,Rs),[n,r,i,A]=Nc(this,Os),[s,a,o,l]=Rc(this,$s,Js).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-n)/i,(e[3]-r)/A,NaN,NaN,NaN,NaN,(e[4]-n)/i,(e[5]-r)/A,NaN,NaN,NaN,NaN,s,a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,(e[16]-n)/i,(e[17]-r)/A,NaN,NaN,NaN,NaN,(e[14]-n)/i,(e[15]-r)/A],0),this.newFreeDrawOutline(c,t,Nc(this,Os),Nc(this,Ks),Nc(this,Ns),Nc(this,Ts))},ra=function(t,e){const n=Nc(this,Ps);return t.set([NaN,NaN,NaN,NaN,n[4],n[5]],e),e+6},ia=function(t,e){const n=Nc(this,Rs).subarray(4,6),r=Nc(this,Rs).subarray(16,18),[i,A,s,a]=Nc(this,Os),[o,l,c,h]=Rc(this,$s,Js).call(this);return t.set([NaN,NaN,NaN,NaN,(n[0]-i)/s,(n[1]-A)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(r[0]-i)/s,(r[1]-A)/a],e),e+24},Tc(MM,qs,8),Tc(MM,Xs,2),Tc(MM,Ys,Nc(MM,qs)+Nc(MM,Xs));let OM=MM;class PM extends kM{constructor(t,e,n,r,i,A){super(),Tc(this,ua),Tc(this,Aa),Tc(this,sa,new Float32Array(4)),Tc(this,aa),Tc(this,oa),Tc(this,la),Tc(this,ca),Tc(this,ha),Dc(this,ha,t),Dc(this,la,e),Dc(this,Aa,n),Dc(this,ca,r),Dc(this,aa,i),Dc(this,oa,A),this.lastPoint=[NaN,NaN],Rc(this,ua,da).call(this,A);const[s,a,o,l]=Nc(this,sa);for(let c=0,h=t.length;c<h;c+=2)t[c]=(t[c]-s)/o,t[c+1]=(t[c+1]-a)/l;for(let c=0,h=e.length;c<h;c+=2)e[c]=(e[c]-s)/o,e[c+1]=(e[c+1]-a)/l}toSVGPath(){const t=[`M${Nc(this,ha)[4]} ${Nc(this,ha)[5]}`];for(let e=6,n=Nc(this,ha).length;e<n;e+=6)isNaN(Nc(this,ha)[e])?t.push(`L${Nc(this,ha)[e+4]} ${Nc(this,ha)[e+5]}`):t.push(`C${Nc(this,ha)[e]} ${Nc(this,ha)[e+1]} ${Nc(this,ha)[e+2]} ${Nc(this,ha)[e+3]} ${Nc(this,ha)[e+4]} ${Nc(this,ha)[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,n,r],i){const A=n-t,s=r-e;let a,o;switch(i){case 0:a=kM._rescale(Nc(this,ha),t,r,A,-s),o=kM._rescale(Nc(this,la),t,r,A,-s);break;case 90:a=kM._rescaleAndSwap(Nc(this,ha),t,e,A,s),o=kM._rescaleAndSwap(Nc(this,la),t,e,A,s);break;case 180:a=kM._rescale(Nc(this,ha),n,e,-A,s),o=kM._rescale(Nc(this,la),n,e,-A,s);break;case 270:a=kM._rescaleAndSwap(Nc(this,ha),n,r,-A,-s),o=kM._rescaleAndSwap(Nc(this,la),n,r,-A,-s)}return{outline:Array.from(a),points:[Array.from(o)]}}get box(){return Nc(this,sa)}newOutliner(t,e,n,r,i,A=0){return new OM(t,e,n,r,i,A)}getNewOutline(t,e){const[n,r,i,A]=Nc(this,sa),[s,a,o,l]=Nc(this,Aa),c=i*o,h=A*l,u=n*o+s,d=r*l+a,f=this.newOutliner({x:Nc(this,la)[0]*c+u,y:Nc(this,la)[1]*h+d},Nc(this,Aa),Nc(this,ca),t,Nc(this,oa),null!=e?e:Nc(this,aa));for(let p=2;p<Nc(this,la).length;p+=2)f.add({x:Nc(this,la)[p]*c+u,y:Nc(this,la)[p+1]*h+d});return f.getOutlines()}}Aa=new WeakMap,sa=new WeakMap,aa=new WeakMap,oa=new WeakMap,la=new WeakMap,ca=new WeakMap,ha=new WeakMap,ua=new WeakSet,da=function(t){const e=Nc(this,ha);let n=e[4],r=e[5];const i=[n,r,n,r];let A=n,s=r;const a=t?Math.max:Math.min;for(let l=6,c=e.length;l<c;l+=6){const t=e[l+4],o=e[l+5];if(isNaN(e[l]))HU.pointBoundingBox(t,o,i),s<o?(A=t,s=o):s===o&&(A=a(A,t));else{const t=[1/0,1/0,-1/0,-1/0];HU.bezierBoundingBox(n,r,...e.slice(l,l+6),t),HU.rectBoundingBox(...t,i),s<t[3]?(A=t[2],s=t[3]):s===t[3]&&(A=a(A,t[2]))}n=t,r=o}const o=Nc(this,sa);o[0]=i[0]-Nc(this,aa),o[1]=i[1]-Nc(this,aa),o[2]=i[2]-i[0]+2*Nc(this,aa),o[3]=i[3]-i[1]+2*Nc(this,aa),this.lastPoint=[A,s]};class NM{constructor(t,e=0,n=0,r=!0){Tc(this,wa),Tc(this,fa),Tc(this,pa),Tc(this,ga,[]),Tc(this,ma,[]);const i=[1/0,1/0,-1/0,-1/0],A=Uc(10,-4);for(const{x:u,y:d,width:f,height:p}of t){const t=Math.floor((u-e)/A)*A,n=Math.ceil((u+f+e)/A)*A,r=Math.floor((d-e)/A)*A,s=Math.ceil((d+p+e)/A)*A,a=[t,r,s,!0],o=[n,r,s,!1];Nc(this,ga).push(a,o),HU.rectBoundingBox(t,r,n,s,i)}const s=i[2]-i[0]+2*n,a=i[3]-i[1]+2*n,o=i[0]-n,l=i[1]-n,c=Nc(this,ga).at(r?-1:-2),h=[c[0],c[2]];for(const u of Nc(this,ga)){const[t,e,n]=u;u[0]=(t-o)/s,u[1]=(e-l)/a,u[2]=(n-l)/a}Dc(this,fa,new Float32Array([o,l,s,a])),Dc(this,pa,h)}getOutlines(){Nc(this,ga).sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of Nc(this,ga))e[3]?(t.push(...Rc(this,wa,_a).call(this,e)),Rc(this,wa,ba).call(this,e)):(Rc(this,wa,Ba).call(this,e),t.push(...Rc(this,wa,_a).call(this,e)));return Rc(this,wa,va).call(this,t)}}fa=new WeakMap,pa=new WeakMap,ga=new WeakMap,ma=new WeakMap,wa=new WeakSet,va=function(t){const e=[],n=new Set;for(const A of t){const[t,n,r]=A;e.push([t,n,A],[t,r,A])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let A=0,s=e.length;A<s;A+=2){const t=e[A][2],r=e[A+1][2];t.push(r),r.push(t),n.add(t),n.add(r)}const r=[];let i;for(;n.size>0;){const t=n.values().next().value;let[e,A,s,a,o]=t;n.delete(t);let l=e,c=A;for(i=[e,s],r.push(i);;){let t;if(n.has(a))t=a;else{if(!n.has(o))break;t=o}n.delete(t),[e,A,s,a,o]=t,l!==e&&(i.push(l,c,e,c===A?A:s),l=e),c=c===A?s:A}i.push(l,c)}return new TM(r,Nc(this,fa),Nc(this,pa))},ya=function(t){const e=Nc(this,ma);let n=0,r=e.length-1;for(;n<=r;){const i=n+r>>1,A=e[i][0];if(A===t)return i;A<t?n=i+1:r=i-1}return r+1},ba=function([,t,e]){const n=Rc(this,wa,ya).call(this,t);Nc(this,ma).splice(n,0,[t,e])},Ba=function([,t,e]){const n=Rc(this,wa,ya).call(this,t);for(let r=n;r<Nc(this,ma).length;r++){const[n,i]=Nc(this,ma)[r];if(n!==t)break;if(n===t&&i===e)return void Nc(this,ma).splice(r,1)}for(let r=n-1;r>=0;r--){const[n,i]=Nc(this,ma)[r];if(n!==t)break;if(n===t&&i===e)return void Nc(this,ma).splice(r,1)}},_a=function(t){const[e,n,r]=t,i=[[e,n,r]],A=Rc(this,wa,ya).call(this,r);for(let s=0;s<A;s++){const[t,n]=Nc(this,ma)[s];for(let r=0,A=i.length;r<A;r++){const[,s,a]=i[r];if(!(n<=s||a<=t))if(s>=t)if(a>n)i[r][1]=n;else{if(1===A)return[];i.splice(r,1),r--,A--}else i[r][2]=t,a>n&&i.push([e,n,a])}}return i};class TM extends kM{constructor(t,e,n){super(),Tc(this,Ca),Tc(this,xa),Dc(this,xa,t),Dc(this,Ca,e),this.lastPoint=n}toSVGPath(){const t=[];for(const e of Nc(this,xa)){let[n,r]=e;t.push(`M${n} ${r}`);for(let i=2;i<e.length;i+=2){const A=e[i],s=e[i+1];A===n?(t.push(`V${s}`),r=s):s===r&&(t.push(`H${A}`),n=A)}t.push("Z")}return t.join(" ")}serialize([t,e,n,r],i){const A=[],s=n-t,a=r-e;for(const o of Nc(this,xa)){const e=new Array(o.length);for(let n=0;n<o.length;n+=2)e[n]=t+o[n]*s,e[n+1]=r-o[n+1]*a;A.push(e)}return A}get box(){return Nc(this,Ca)}get classNamesForOutlining(){return["highlightOutline"]}}Ca=new WeakMap,xa=new WeakMap;class DM extends OM{newFreeDrawOutline(t,e,n,r,i,A){return new RM(t,e,n,r,i,A)}}class RM extends PM{newOutliner(t,e,n,r,i,A=0){return new DM(t,e,n,r,i,A)}}const HM=class t extends QI{constructor(e){super(kc(Qc({},e),{name:"highlightEditor"})),Tc(this,Va),Tc(this,Ea,null),Tc(this,Sa,0),Tc(this,Fa),Tc(this,La,null),Tc(this,Ua,null),Tc(this,Ia,null),Tc(this,Qa,null),Tc(this,ka,0),Tc(this,Ma,null),Tc(this,Oa,null),Tc(this,Pa,null),Tc(this,Na,!1),Tc(this,Ta,null),Tc(this,Da),Tc(this,Ra,null),Tc(this,Ha,""),Tc(this,ja),Tc(this,Wa,""),this.color=e.color||t._defaultColor,Dc(this,ja,e.thickness||t._defaultThickness),Dc(this,Da,e.opacity||t._defaultOpacity),Dc(this,Fa,e.boxes||null),Dc(this,Wa,e.methodOfCreation||""),Dc(this,Ha,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(Dc(this,Na,!0),Rc(this,Va,Ga).call(this,e),Rc(this,Va,$a).call(this)):Nc(this,Fa)&&(Dc(this,Ea,e.anchorNode),Dc(this,Sa,e.anchorOffset),Dc(this,Qa,e.focusNode),Dc(this,ka,e.focusOffset),Rc(this,Va,Ka).call(this),Rc(this,Va,$a).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=t.prototype;return LU(this,"_keyboardManager",new bI([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:Nc(this,Na)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:Nc(this,ja),methodOfCreation:Nc(this,Wa)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}get commentColor(){return this.color}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(e,n){var r;QI.initialize(e,n),t._defaultColor||(t._defaultColor=(null==(r=n.highlightColors)?void 0:r.values().next().value)||"#fff066")}static updateDefaultParams(e,n){switch(e){case eU.HIGHLIGHT_COLOR:t._defaultColor=n;break;case eU.HIGHLIGHT_THICKNESS:t._defaultThickness=n}}translateInPage(t,e){}get toolbarPosition(){return Nc(this,Ta)}updateParams(t,e){switch(t){case eU.HIGHLIGHT_COLOR:Rc(this,Va,za).call(this,e);break;case eU.HIGHLIGHT_THICKNESS:Rc(this,Va,qa).call(this,e)}}static get defaultPropertiesToUpdate(){return[[eU.HIGHLIGHT_COLOR,t._defaultColor],[eU.HIGHLIGHT_THICKNESS,t._defaultThickness]]}get propertiesToUpdate(){return[[eU.HIGHLIGHT_COLOR,this.color||t._defaultColor],[eU.HIGHLIGHT_THICKNESS,Nc(this,ja)||t._defaultThickness],[eU.HIGHLIGHT_FREE,Nc(this,Na)]]}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",Dc(this,Ua,new Kk({editor:this}))]]}return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(Rc(this,Va,no).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,Rc(this,Va,no).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){Rc(this,Va,Ya).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(Rc(this,Va,$a).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let n=!1;this.parent&&!t?Rc(this,Va,Ya).call(this):t&&(Rc(this,Va,$a).call(this,t),n=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),n&&this.select()}rotate(e){var n,r,i;const{drawLayer:A}=this.parent;let s;Nc(this,Na)?(e=(e-this.rotation+360)%360,s=Rc(n=t,Ja,Za).call(n,Nc(this,Oa).box,e)):s=Rc(r=t,Ja,Za).call(r,[this.x,this.y,this.width,this.height],e),A.updateProperties(Nc(this,Pa),{bbox:s,root:{"data-main-rotation":e}}),A.updateProperties(Nc(this,Ra),{bbox:Rc(i=t,Ja,Za).call(i,Nc(this,Ia).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const t=super.render();Nc(this,Ha)&&(t.setAttribute("aria-label",Nc(this,Ha)),t.setAttribute("role","mark")),Nc(this,Na)?t.classList.add("free"):this.div.addEventListener("keydown",Rc(this,Va,to).bind(this),{signal:this._uiManager._signal});const e=Dc(this,Ma,document.createElement("div"));t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=Nc(this,La);const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),gI(this,Nc(this,Ma),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:Rc(this,Va,eo).call(this,!0);break;case 1:case 3:Rc(this,Va,eo).call(this,!1)}}select(){var t;super.select(),Nc(this,Ra)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),Nc(this,Ra)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{selected:!1}}),Nc(this,Na)||Rc(this,Va,eo).call(this,!1))}get _mustFixPosition(){return!Nc(this,Na)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(Nc(this,Pa),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,{target:n,x:r,y:i}){const{x:A,y:s,width:a,height:o}=n.getBoundingClientRect(),l=new AbortController,c=t.combinedSignal(l),h=e=>{l.abort(),Rc(this,Ja,so).call(this,t,e)};window.addEventListener("blur",h,{signal:c}),window.addEventListener("pointerup",h,{signal:c}),window.addEventListener("pointerdown",AI,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",iI,{signal:c}),n.addEventListener("pointermove",Rc(this,Ja,Ao).bind(this,t),{signal:c}),this._freeHighlight=new DM({x:r,y:i},[A,s,a,o],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 deserialize(e,n,r){return Wc(this,null,function*(){var i,A,s,a;let o=null;if(e instanceof _M){const{data:{quadPoints:t,rect:n,rotation:r,id:i,color:A,opacity:s,popupRef:a,contentsObj:l},parent:{page:{pageNumber:c}}}=e;o=e={annotationType:tU.HIGHLIGHT,color:Array.from(A),opacity:s,quadPoints:t,boxes:null,pageIndex:c-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:a,comment:(null==l?void 0:l.str)||null}}else if(e instanceof BM){const{data:{inkLists:t,rect:n,rotation:r,id:i,color:A,borderStyle:{rawWidth:s},popupRef:a,contentsObj:l},parent:{page:{pageNumber:c}}}=e;o=e={annotationType:tU.HIGHLIGHT,color:Array.from(A),thickness:s,inkLists:t,boxes:null,pageIndex:c-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:a,comment:(null==l?void 0:l.str)||null}}const{color:l,quadPoints:c,inkLists:h,opacity:u}=e,d=yield jc(t,this,"deserialize").call(this,e,n,r);d.color=HU.makeHexColor(...l),Dc(d,Da,u||1),h&&Dc(d,ja,e.thickness),d._initialData=o,e.comment&&d.setCommentData(e.comment);const[f,p]=d.pageDimensions,[g,m]=d.pageTranslation;if(c){const t=Dc(d,Fa,[]);for(let e=0;e<c.length;e+=8)t.push({x:(c[e]-g)/f,y:1-(c[e+1]-m)/p,width:(c[e+2]-c[e])/f,height:(c[e+1]-c[e+5])/p});Rc(i=d,Va,Ka).call(i),Rc(A=d,Va,$a).call(A),d.rotate(d.rotation)}else if(h){Dc(d,Na,!0);const t=h[0],e={x:t[0]-g,y:p-(t[1]-m)},r=new DM(e,[0,0,f,p],1,Nc(d,ja)/2,!0,.001);for(let n=0,s=t.length;n<s;n+=2)e.x=t[n]-g,e.y=p-(t[n+1]-m),r.add(e);const{id:i,clipPathId:A}=n.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);Rc(s=d,Va,Ga).call(s,{highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:A}),Rc(a=d,Va,$a).call(a),d.rotate(d.parentRotation)}return d})}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),n=QI._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),r={annotationType:tU.HIGHLIGHT,color:n,opacity:Nc(this,Da),thickness:Nc(this,ja),quadPoints:Rc(this,Va,ro).call(this),outlines:Rc(this,Va,io).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:Rc(this,Va,no).call(this),structTreeParentId:this._structTreeParentId};return this.addComment(r),this.annotationElementId&&!Rc(this,Va,ao).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(t){const e={rect:this.getRect(0,0)};return this.hasEditedComment&&(e.popup=this.comment),t.updateEdited(e),null}static canCreateNewEmptyEditor(){return!1}};Ea=new WeakMap,Sa=new WeakMap,Fa=new WeakMap,La=new WeakMap,Ua=new WeakMap,Ia=new WeakMap,Qa=new WeakMap,ka=new WeakMap,Ma=new WeakMap,Oa=new WeakMap,Pa=new WeakMap,Na=new WeakMap,Ta=new WeakMap,Da=new WeakMap,Ra=new WeakMap,Ha=new WeakMap,ja=new WeakMap,Wa=new WeakMap,Va=new WeakSet,Ka=function(){const t=new NM(Nc(this,Fa),.001);Dc(this,Oa,t.getOutlines()),[this.x,this.y,this.width,this.height]=Nc(this,Oa).box;const e=new NM(Nc(this,Fa),.0025,.001,"ltr"===this._uiManager.direction);Dc(this,Ia,e.getOutlines());const{lastPoint:n}=Nc(this,Ia);Dc(this,Ta,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height])},Ga=function({highlightOutlines:t,highlightId:e,clipPathId:n}){var r,i;Dc(this,Oa,t);if(Dc(this,Ia,t.getNewOutline(Nc(this,ja)/2+1.5,.0025)),e>=0)Dc(this,Pa,e),Dc(this,La,n),this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),Dc(this,Ra,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:Nc(this,Ia).box,path:{d:Nc(this,Ia).toSVGPath()}},!0));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(Nc(this,Pa),{bbox:Rc(r=HM,Ja,Za).call(r,Nc(this,Oa).box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(Nc(this,Ra),{bbox:Rc(i=HM,Ja,Za).call(i,Nc(this,Ia).box,e),path:{d:Nc(this,Ia).toSVGPath()}})}const[A,s,a,o]=t.box;switch(this.rotation){case 0:this.x=A,this.y=s,this.width=a,this.height=o;break;case 90:{const[t,e]=this.parentDimensions;this.x=s,this.y=1-A,this.width=a*e/t,this.height=o*t/e;break}case 180:this.x=1-A,this.y=1-s,this.width=a,this.height=o;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-s,this.y=A,this.width=a*e/t,this.height=o*t/e;break}}const{lastPoint:l}=Nc(this,Ia);Dc(this,Ta,[(l[0]-A)/a,(l[1]-s)/o])},za=function(t){const e=(t,e)=>{var n,r;this.color=t,Dc(this,Da,e),null==(n=this.parent)||n.drawLayer.updateProperties(Nc(this,Pa),{root:{fill:t,"fill-opacity":e}}),null==(r=Nc(this,Ua))||r.updateColor(t)},n=this.color,r=Nc(this,Da);this.addCommands({cmd:e.bind(this,t,HM._defaultOpacity),undo:e.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:eU.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)},qa=function(t){const e=Nc(this,ja),n=t=>{Dc(this,ja,t),Rc(this,Va,Xa).call(this,t)};this.addCommands({cmd:n.bind(this,t),undo:n.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:eU.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},Xa=function(t){if(!Nc(this,Na))return;Rc(this,Va,Ga).call(this,{highlightOutlines:Nc(this,Oa).getNewOutline(t/2)}),this.fixAndSetPosition();const[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)},Ya=function(){null!==Nc(this,Pa)&&this.parent&&(this.parent.drawLayer.remove(Nc(this,Pa)),Dc(this,Pa,null),this.parent.drawLayer.remove(Nc(this,Ra)),Dc(this,Ra,null))},$a=function(t=this.parent){null===Nc(this,Pa)&&(({id:Hc(this,Pa)._,clipPathId:Hc(this,La)._}=t.drawLayer.draw({bbox:Nc(this,Oa).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":Nc(this,Da)},rootClass:{highlight:!0,free:Nc(this,Na)},path:{d:Nc(this,Oa).toSVGPath()}},!1,!0)),Dc(this,Ra,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:Nc(this,Na)},bbox:Nc(this,Ia).box,path:{d:Nc(this,Ia).toSVGPath()}},Nc(this,Na))),Nc(this,Ma)&&(Nc(this,Ma).style.clipPath=Nc(this,La)))},Ja=new WeakSet,Za=function([t,e,n,r],i){switch(i){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]},to=function(t){HM._keyboardManager.exec(this,t)},eo=function(t){if(!Nc(this,Ea))return;const e=window.getSelection();t?e.setPosition(Nc(this,Ea),Nc(this,Sa)):e.setPosition(Nc(this,Qa),Nc(this,ka))},no=function(){return Nc(this,Na)?this.rotation:0},ro=function(){if(Nc(this,Na))return null;const[t,e]=this.pageDimensions,[n,r]=this.pageTranslation,i=Nc(this,Fa),A=new Float32Array(8*i.length);let s=0;for(const{x:a,y:o,width:l,height:c}of i){const i=a*t+n,h=(1-o)*e+r;A[s]=A[s+4]=i,A[s+1]=A[s+3]=h,A[s+2]=A[s+6]=i+l*t,A[s+5]=A[s+7]=h-c*e,s+=8}return A},io=function(t){return Nc(this,Oa).serialize(t,Rc(this,Va,no).call(this))},Ao=function(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},so=function(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},ao=function(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,n)=>t!==e[n])},Tc(HM,Ja),Oc(HM,"_defaultColor",null),Oc(HM,"_defaultOpacity",1),Oc(HM,"_defaultThickness",12),Oc(HM,"_type","highlight"),Oc(HM,"_editorType",tU.HIGHLIGHT),Oc(HM,"_freeHighlightId",-1),Oc(HM,"_freeHighlight",null),Oc(HM,"_freeHighlightClipId","");let jM=HM;class WM{constructor(){Tc(this,oo,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,n]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,n)}updateSVGProperty(t,e){Nc(this,oo)[t]=e}toSVGProperties(){const t=Nc(this,oo);return Dc(this,oo,Object.create(null)),{root:t}}reset(){Dc(this,oo,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){xU("Not implemented")}}oo=new WeakMap;const VM=class t extends QI{constructor(t){super(t),Tc(this,vo),Tc(this,lo,null),Tc(this,co),Oc(this,"_colorPicker",null),Oc(this,"_drawId",null),Dc(this,co,t.mustBeCommitted||!1),this._addOutlines(t)}_addOutlines(t){t.drawOutlines&&(Rc(this,vo,yo).call(this,t),Rc(this,vo,_o).call(this))}static _mergeSVGProperties(t,e){const n=new Set(Object.keys(t));for(const[r,i]of Object.entries(e))n.has(r)?Object.assign(t[r],i):t[r]=i;return t}static getDefaultDrawingOptions(t){xU("Not implemented")}static get typesMap(){xU("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,n){const r=this.typesMap.get(e);r&&this._defaultDrawingOptions.updateProperty(r,n),this._currentParent&&(Nc(t,ho).updateProperty(r,n),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const n=this.constructor.typesMap.get(t);n&&this._updateProperty(t,n,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[n,r]of this.typesMap)t.push([n,e[r]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[n,r]of this.constructor.typesMap)t.push([n,e[r]]);return t}_updateProperty(t,e,n){const r=this._drawingOptions,i=r[e],A=n=>{var i,A;r.updateProperty(e,n);const s=Nc(this,lo).updateProperty(e,n);s&&Rc(this,vo,Eo).call(this,s),null==(i=this.parent)||i.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),t===this.colorType&&(null==(A=this._colorPicker)||A.update(n))};this.addCommands({cmd:A.bind(this,n),undo:A.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Nc(this,lo).getPathResizingSVGProperties(Rc(this,vo,xo).call(this)),{bbox:Rc(this,vo,So).call(this)}))}_onResized(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Nc(this,lo).getPathResizedSVGProperties(Rc(this,vo,xo).call(this)),{bbox:Rc(this,vo,So).call(this)}))}_onTranslating(t,e){var n;null==(n=this.parent)||n.drawLayer.updateProperties(this._drawId,{bbox:Rc(this,vo,So).call(this)})}_onTranslated(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Nc(this,lo).getPathTranslatedSVGProperties(Rc(this,vo,xo).call(this),this.parentDimensions),{bbox:Rc(this,vo,So).call(this)}))}_onStartDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,Nc(this,co)&&(Dc(this,co,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){Rc(this,vo,Bo).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(Rc(this,vo,_o).call(this),Rc(this,vo,Eo).call(this,Nc(this,lo).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let n=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),Rc(this,vo,Bo).call(this)):t&&(this._uiManager.addShouldRescale(this),Rc(this,vo,_o).call(this,t),n=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),n&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties({bbox:Rc(this,vo,So).call(this)},Nc(this,lo).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&Rc(this,vo,Eo).call(this,Nc(this,lo).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const n=super.render();n.classList.add("draw");const r=document.createElement("div");n.append(r),r.setAttribute("aria-hidden","true"),r.className="internal";const[i,A]=this.parentDimensions;return this.setDims(this.width*i,this.height*A),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),n}static createDrawerInstance(t,e,n,r,i){xU("Not implemented")}static startDrawing(e,n,r,i){var A;const{target:s,offsetX:a,offsetY:o,pointerId:l,pointerType:c}=i;if(Nc(t,go)&&Nc(t,go)!==c)return;const{viewport:{rotation:h}}=e,{width:u,height:d}=s.getBoundingClientRect(),f=Dc(t,uo,new AbortController),p=e.combinedSignal(f);Nc(t,po)||Dc(t,po,l),null!=Nc(t,go)||Dc(t,go,c),window.addEventListener("pointerup",e=>{var n;Nc(t,po)===e.pointerId?this._endDraw(e):null==(n=Nc(t,mo))||n.delete(e.pointerId)},{signal:p}),window.addEventListener("pointercancel",e=>{var n;Nc(t,po)===e.pointerId?this._currentParent.endDrawingSession():null==(n=Nc(t,mo))||n.delete(e.pointerId)},{signal:p}),window.addEventListener("pointerdown",e=>{Nc(t,go)===e.pointerType&&((Nc(t,mo)||Dc(t,mo,new Set)).add(e.pointerId),Nc(t,ho).isCancellable()&&(Nc(t,ho).removeLastElement(),Nc(t,ho).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",iI,{signal:p}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),s.addEventListener("touchmove",e=>{e.timeStamp===Nc(t,wo)&&AI(e)},{signal:p}),e.toggleDrawing(),null==(A=n._editorUndoBar)||A.hide(),Nc(t,ho)?e.drawLayer.updateProperties(this._currentDrawId,Nc(t,ho).startNew(a,o,u,d,h)):(n.updateUIForDefaultProperties(this),Dc(t,ho,this.createDrawerInstance(a,o,u,d,h)),Dc(t,fo,this.getDefaultDrawingOptions()),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(Nc(t,fo).toSVGProperties(),Nc(t,ho).defaultSVGProperties),!0,!1)))}static _drawMove(e){var n;if(Dc(t,wo,-1),!Nc(t,ho))return;const{offsetX:r,offsetY:i,pointerId:A}=e;Nc(t,po)===A&&((null==(n=Nc(t,mo))?void 0:n.size)>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Nc(t,ho).add(r,i)),Dc(t,wo,e.timeStamp),AI(e)))}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,Dc(t,ho,null),Dc(t,fo,null),Dc(t,go,null),Dc(t,wo,NaN)),Nc(t,uo)&&(Nc(t,uo).abort(),Dc(t,uo,null),Dc(t,po,NaN),Dc(t,mo,null))}static _endDraw(e){const n=this._currentParent;if(n){if(n.toggleDrawing(!0),this._cleanup(!1),(null==e?void 0:e.target)===n.div&&n.drawLayer.updateProperties(this._currentDrawId,Nc(t,ho).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=Nc(t,ho),r=this._currentDrawId,i=e.getLastElement();return void n.addCommands({cmd:()=>{n.drawLayer.updateProperties(r,e.setLastElement(i))},undo:()=>{n.drawLayer.updateProperties(r,e.removeLastElement())},mustExec:!1,type:eU.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(e){const n=this._currentParent;if(!n)return null;if(n.toggleDrawing(!0),n.cleanUndoStack(eU.DRAW_STEP),!Nc(t,ho).isEmpty()){const{pageDimensions:[r,i],scale:A}=n,s=n.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Nc(t,ho).getOutlines(r*A,i*A,A,this._INNER_MARGIN),drawingOptions:Nc(t,fo),mustBeCommitted:!e});return this._cleanup(!0),s}return n.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,n,r,i,A){xU("Not implemented")}static deserialize(e,n,r){return Wc(this,null,function*(){var i,A;const{rawDims:{pageWidth:s,pageHeight:a,pageX:o,pageY:l}}=n.viewport,c=this.deserializeDraw(o,l,s,a,this._INNER_MARGIN,e),h=yield jc(t,this,"deserialize").call(this,e,n,r);return h.createDrawingOptions(e),Rc(i=h,vo,yo).call(i,{drawOutlines:c}),Rc(A=h,vo,_o).call(A),h.onScaleChanging(),h.rotate(),h})}serializeDraw(t){const[e,n]=this.pageTranslation,[r,i]=this.pageDimensions;return Nc(this,lo).serialize([e,n,r,i],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};lo=new WeakMap,co=new WeakMap,ho=new WeakMap,uo=new WeakMap,fo=new WeakMap,po=new WeakMap,go=new WeakMap,mo=new WeakMap,wo=new WeakMap,vo=new WeakSet,yo=function({drawOutlines:t,drawId:e,drawingOptions:n}){Dc(this,lo,t),this._drawingOptions||(this._drawingOptions=n),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=Rc(this,vo,bo).call(this,t,this.parent),Rc(this,vo,Eo).call(this,t.box)},bo=function(t,e){const{id:n}=e.drawLayer.draw(VM._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return n},Bo=function(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},_o=function(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=Rc(this,vo,bo).call(this,Nc(this,lo),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))},Co=function([t,e,n,r]){const{parentDimensions:[i,A],rotation:s}=this;switch(s){case 90:return[e,1-t,n*(A/i),r*(i/A)];case 180:return[1-t,1-e,n,r];case 270:return[1-e,t,n*(A/i),r*(i/A)];default:return[t,e,n,r]}},xo=function(){const{x:t,y:e,width:n,height:r,parentDimensions:[i,A],rotation:s}=this;switch(s){case 90:return[1-e,t,n*(i/A),r*(A/i)];case 180:return[1-t,1-e,n,r];case 270:return[e,1-t,n*(i/A),r*(A/i)];default:return[t,e,n,r]}},Eo=function(t){if([this.x,this.y,this.width,this.height]=Rc(this,vo,Co).call(this,t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()},So=function(){const{x:t,y:e,width:n,height:r,rotation:i,parentRotation:A,parentDimensions:[s,a]}=this;switch((4*i+A)/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*(s/a),r*(a/s),n*(s/a)];case 5:return[1-e,t,n*(s/a),r*(a/s)];case 6:return[1-t-r*(a/s),1-e,r*(a/s),n*(s/a)];case 7:return[e-n*(s/a),1-t-r*(a/s),n*(s/a),r*(a/s)];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*(a/s),e,r*(a/s),n*(s/a)];case 13:return[1-e-n*(s/a),t-r*(a/s),n*(s/a),r*(a/s)];case 14:return[1-t,1-e-n*(s/a),r*(a/s),n*(s/a)];case 15:return[e,1-t,n*(s/a),r*(a/s)];default:return[t,e,n,r]}},Oc(VM,"_currentDrawId",-1),Oc(VM,"_currentParent",null),Tc(VM,ho,null),Tc(VM,uo,null),Tc(VM,fo,null),Tc(VM,po,NaN),Tc(VM,go,null),Tc(VM,mo,null),Tc(VM,wo,NaN),Oc(VM,"_INNER_MARGIN",3);let KM=VM;class GM{constructor(t,e,n,r,i,A){Tc(this,Do),Tc(this,Fo,new Float64Array(6)),Tc(this,Lo),Tc(this,Uo),Tc(this,Io),Tc(this,Qo),Tc(this,ko),Tc(this,Mo,""),Tc(this,Oo,0),Tc(this,Po,new zM),Tc(this,No),Tc(this,To),Dc(this,No,n),Dc(this,To,r),Dc(this,Io,i),Dc(this,Qo,A),[t,e]=Rc(this,Do,Ro).call(this,t,e);const s=Dc(this,Lo,[NaN,NaN,NaN,NaN,t,e]);Dc(this,ko,[t,e]),Dc(this,Uo,[{line:s,points:Nc(this,ko)}]),Nc(this,Fo).set(s,0)}updateProperty(t,e){"stroke-width"===t&&Dc(this,Qo,e)}isEmpty(){return!Nc(this,Uo)||0===Nc(this,Uo).length}isCancellable(){return Nc(this,ko).length<=10}add(t,e){[t,e]=Rc(this,Do,Ro).call(this,t,e);const[n,r,i,A]=Nc(this,Fo).subarray(2,6),s=t-i,a=e-A;return Math.hypot(Nc(this,No)*s,Nc(this,To)*a)<=2?null:(Nc(this,ko).push(t,e),isNaN(n)?(Nc(this,Fo).set([i,A,t,e],2),Nc(this,Lo).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(Nc(this,Fo)[0])&&Nc(this,Lo).splice(6,6),Nc(this,Fo).set([n,r,i,A,t,e],0),Nc(this,Lo).push(...kM.createBezierPoints(n,r,i,A,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const n=this.add(t,e);return n||(2===Nc(this,ko).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,n,r,i){Dc(this,No,n),Dc(this,To,r),Dc(this,Io,i),[t,e]=Rc(this,Do,Ro).call(this,t,e);const A=Dc(this,Lo,[NaN,NaN,NaN,NaN,t,e]);Dc(this,ko,[t,e]);const s=Nc(this,Uo).at(-1);return s&&(s.line=new Float32Array(s.line),s.points=new Float32Array(s.points)),Nc(this,Uo).push({line:A,points:Nc(this,ko)}),Nc(this,Fo).set(A,0),Dc(this,Oo,0),this.toSVGPath(),null}getLastElement(){return Nc(this,Uo).at(-1)}setLastElement(t){return Nc(this,Uo)?(Nc(this,Uo).push(t),Dc(this,Lo,t.line),Dc(this,ko,t.points),Dc(this,Oo,0),{path:{d:this.toSVGPath()}}):Nc(this,Po).setLastElement(t)}removeLastElement(){if(!Nc(this,Uo))return Nc(this,Po).removeLastElement();Nc(this,Uo).pop(),Dc(this,Mo,"");for(let t=0,e=Nc(this,Uo).length;t<e;t++){const{line:e,points:n}=Nc(this,Uo)[t];Dc(this,Lo,e),Dc(this,ko,n),Dc(this,Oo,0),this.toSVGPath()}return{path:{d:Nc(this,Mo)}}}toSVGPath(){const t=kM.svgRound(Nc(this,Lo)[4]),e=kM.svgRound(Nc(this,Lo)[5]);if(2===Nc(this,ko).length)return Dc(this,Mo,`${Nc(this,Mo)} M ${t} ${e} Z`),Nc(this,Mo);if(Nc(this,ko).length<=6){const n=Nc(this,Mo).lastIndexOf("M");Dc(this,Mo,`${Nc(this,Mo).slice(0,n)} M ${t} ${e}`),Dc(this,Oo,6)}if(4===Nc(this,ko).length){const t=kM.svgRound(Nc(this,Lo)[10]),e=kM.svgRound(Nc(this,Lo)[11]);return Dc(this,Mo,`${Nc(this,Mo)} L ${t} ${e}`),Dc(this,Oo,12),Nc(this,Mo)}const n=[];0===Nc(this,Oo)&&(n.push(`M ${t} ${e}`),Dc(this,Oo,6));for(let r=Nc(this,Oo),i=Nc(this,Lo).length;r<i;r+=6){const[t,e,i,A,s,a]=Nc(this,Lo).slice(r,r+6).map(kM.svgRound);n.push(`C${t} ${e} ${i} ${A} ${s} ${a}`)}return Dc(this,Mo,Nc(this,Mo)+n.join(" ")),Dc(this,Oo,Nc(this,Lo).length),Nc(this,Mo)}getOutlines(t,e,n,r){const i=Nc(this,Uo).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),Nc(this,Po).build(Nc(this,Uo),t,e,n,Nc(this,Io),Nc(this,Qo),r),Dc(this,Fo,null),Dc(this,Lo,null),Dc(this,Uo,null),Dc(this,Mo,null),Nc(this,Po)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Fo=new WeakMap,Lo=new WeakMap,Uo=new WeakMap,Io=new WeakMap,Qo=new WeakMap,ko=new WeakMap,Mo=new WeakMap,Oo=new WeakMap,Po=new WeakMap,No=new WeakMap,To=new WeakMap,Do=new WeakSet,Ro=function(t,e){return kM._normalizePoint(t,e,Nc(this,No),Nc(this,To),Nc(this,Io))};class zM extends kM{constructor(){super(...arguments),Tc(this,Yo),Tc(this,Ho),Tc(this,jo,0),Tc(this,Wo),Tc(this,Vo),Tc(this,Ko),Tc(this,Go),Tc(this,zo),Tc(this,qo),Tc(this,Xo)}build(t,e,n,r,i,A,s){Dc(this,Ko,e),Dc(this,Go,n),Dc(this,zo,r),Dc(this,qo,i),Dc(this,Xo,A),Dc(this,Wo,null!=s?s:0),Dc(this,Vo,t),Rc(this,Yo,Zo).call(this)}get thickness(){return Nc(this,Xo)}setLastElement(t){return Nc(this,Vo).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return Nc(this,Vo).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of Nc(this,Vo))if(t.push(`M${kM.svgRound(e[4])} ${kM.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${kM.svgRound(e[10])} ${kM.svgRound(e[11])}`);else for(let n=6,r=e.length;n<r;n+=6){const[r,i,A,s,a,o]=e.subarray(n,n+6).map(kM.svgRound);t.push(`C${r} ${i} ${A} ${s} ${a} ${o}`)}else t.push("Z");return t.join("")}serialize([t,e,n,r],i){const A=[],s=[],[a,o,l,c]=Rc(this,Yo,Jo).call(this);let h,u,d,f,p,g,m,w,v;switch(Nc(this,qo)){case 0:v=kM._rescale,h=t,u=e+r,d=n,f=-r,p=t+a*n,g=e+(1-o-c)*r,m=t+(a+l)*n,w=e+(1-o)*r;break;case 90:v=kM._rescaleAndSwap,h=t,u=e,d=n,f=r,p=t+o*n,g=e+a*r,m=t+(o+c)*n,w=e+(a+l)*r;break;case 180:v=kM._rescale,h=t+n,u=e,d=-n,f=r,p=t+(1-a-l)*n,g=e+o*r,m=t+(1-a)*n,w=e+(o+c)*r;break;case 270:v=kM._rescaleAndSwap,h=t+n,u=e+r,d=-n,f=-r,p=t+(1-o-c)*n,g=e+(1-a-l)*r,m=t+(1-o)*n,w=e+(1-a)*r}for(const{line:y,points:b}of Nc(this,Vo))A.push(v(y,h,u,d,f,i?new Array(y.length):null)),s.push(v(b,h,u,d,f,i?new Array(b.length):null));return{lines:A,points:s,rect:[p,g,m,w]}}static deserialize(t,e,n,r,i,{paths:{lines:A,points:s},rotation:a,thickness:o}){const l=[];let c,h,u,d,f;switch(a){case 0:f=kM._rescale,c=-t/n,h=e/r+1,u=1/n,d=-1/r;break;case 90:f=kM._rescaleAndSwap,c=-e/r,h=-t/n,u=1/r,d=1/n;break;case 180:f=kM._rescale,c=t/n+1,h=-e/r,u=-1/n,d=1/r;break;case 270:f=kM._rescaleAndSwap,c=e/r+1,h=t/n+1,u=-1/r,d=-1/n}if(!A){A=[];for(const t of s){const e=t.length;if(2===e){A.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){A.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const n=new Float32Array(3*(e-2));A.push(n);let[r,i,s,a]=t.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let A=4;A<e;A+=2){const e=t[A],o=t[A+1];n.set(kM.createBezierPoints(r,i,s,a,e,o),3*(A-2)),[r,i,s,a]=[s,a,e,o]}}}for(let g=0,m=A.length;g<m;g++)l.push({line:f(A[g].map(t=>null!=t?t:NaN),c,h,u,d),points:f(s[g].map(t=>null!=t?t:NaN),c,h,u,d)});const p=new this.prototype.constructor;return p.build(l,n,r,1,a,o,i),p}get box(){return Nc(this,Ho)}updateProperty(t,e){return"stroke-width"===t?Rc(this,Yo,tl).call(this,e):null}updateParentDimensions([t,e],n){const[r,i]=Rc(this,Yo,$o).call(this);Dc(this,Ko,t),Dc(this,Go,e),Dc(this,zo,n);const[A,s]=Rc(this,Yo,$o).call(this),a=A-r,o=s-i,l=Nc(this,Ho);return l[0]-=a,l[1]-=o,l[2]+=2*a,l[3]+=2*o,l}updateRotation(t){return Dc(this,jo,t),{path:{transform:this.rotationTransform}}}get viewBox(){return Nc(this,Ho).map(kM.svgRound).join(" ")}get defaultProperties(){const[t,e]=Nc(this,Ho);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=Nc(this,Ho);let n=0,r=0,i=0,A=0,s=0,a=0;switch(Nc(this,jo)){case 90:r=e/t,i=-t/e,s=t;break;case 180:n=-1,A=-1,s=t,a=e;break;case 270:r=-e/t,i=t/e,a=e;break;default:return""}return`matrix(${n} ${r} ${i} ${A} ${kM.svgRound(s)} ${kM.svgRound(a)})`}getPathResizingSVGProperties([t,e,n,r]){const[i,A]=Rc(this,Yo,$o).call(this),[s,a,o,l]=Nc(this,Ho);if(Math.abs(o-i)<=kM.PRECISION||Math.abs(l-A)<=kM.PRECISION){const i=t+n/2-(s+o/2),A=e+r/2-(a+l/2);return{path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`,transform:`${this.rotationTransform} translate(${i} ${A})`}}}const c=(n-2*i)/(o-2*i),h=(r-2*A)/(l-2*A),u=o/n,d=l/r;return{path:{"transform-origin":`${kM.svgRound(s)} ${kM.svgRound(a)}`,transform:`${this.rotationTransform} scale(${u} ${d}) translate(${kM.svgRound(i)} ${kM.svgRound(A)}) scale(${c} ${h}) translate(${kM.svgRound(-i)} ${kM.svgRound(-A)})`}}}getPathResizedSVGProperties([t,e,n,r]){const[i,A]=Rc(this,Yo,$o).call(this),s=Nc(this,Ho),[a,o,l,c]=s;if(s[0]=t,s[1]=e,s[2]=n,s[3]=r,Math.abs(l-i)<=kM.PRECISION||Math.abs(c-A)<=kM.PRECISION){const i=t+n/2-(a+l/2),A=e+r/2-(o+c/2);for(const{line:t,points:e}of Nc(this,Vo))kM._translate(t,i,A,t),kM._translate(e,i,A,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const h=(n-2*i)/(l-2*i),u=(r-2*A)/(c-2*A),d=-h*(a+i)+t+i,f=-u*(o+A)+e+A;if(1!==h||1!==u||0!==d||0!==f)for(const{line:p,points:g}of Nc(this,Vo))kM._rescale(p,d,f,h,u,p),kM._rescale(g,d,f,h,u,g);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],n){const[r,i]=n,A=Nc(this,Ho),s=t-A[0],a=e-A[1];if(Nc(this,Ko)===r&&Nc(this,Go)===i)for(const{line:o,points:l}of Nc(this,Vo))kM._translate(o,s,a,o),kM._translate(l,s,a,l);else{const t=Nc(this,Ko)/r,e=Nc(this,Go)/i;Dc(this,Ko,r),Dc(this,Go,i);for(const{line:n,points:r}of Nc(this,Vo))kM._rescale(n,s,a,t,e,n),kM._rescale(r,s,a,t,e,r);A[2]*=t,A[3]*=e}return A[0]=t,A[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`}}}get defaultSVGProperties(){const t=Nc(this,Ho);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${kM.svgRound(t[0])} ${kM.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}Ho=new WeakMap,jo=new WeakMap,Wo=new WeakMap,Vo=new WeakMap,Ko=new WeakMap,Go=new WeakMap,zo=new WeakMap,qo=new WeakMap,Xo=new WeakMap,Yo=new WeakSet,$o=function(t=Nc(this,Xo)){const e=Nc(this,Wo)+t/2*Nc(this,zo);return Nc(this,qo)%180==0?[e/Nc(this,Ko),e/Nc(this,Go)]:[e/Nc(this,Go),e/Nc(this,Ko)]},Jo=function(){const[t,e,n,r]=Nc(this,Ho),[i,A]=Rc(this,Yo,$o).call(this,0);return[t+i,e+A,n-2*i,r-2*A]},Zo=function(){const t=Dc(this,Ho,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:r}of Nc(this,Vo)){if(r.length<=12){for(let e=4,n=r.length;e<n;e+=6)HU.pointBoundingBox(r[e],r[e+1],t);continue}let e=r[4],n=r[5];for(let i=6,A=r.length;i<A;i+=6){const[A,s,a,o,l,c]=r.subarray(i,i+6);HU.bezierBoundingBox(e,n,A,s,a,o,l,c,t),e=l,n=c}}const[e,n]=Rc(this,Yo,$o).call(this);t[0]=GU(t[0]-e,0,1),t[1]=GU(t[1]-n,0,1),t[2]=GU(t[2]+e,0,1),t[3]=GU(t[3]+n,0,1),t[2]-=t[0],t[3]-=t[1]},tl=function(t){const[e,n]=Rc(this,Yo,$o).call(this);Dc(this,Xo,t);const[r,i]=Rc(this,Yo,$o).call(this),[A,s]=[r-e,i-n],a=Nc(this,Ho);return a[0]-=A,a[1]-=s,a[2]+=2*A,a[3]+=2*s,a};class qM extends WM{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:QI._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(null!=e||(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new qM(this._viewParameters);return t.updateAll(this),t}}const XM=class t extends KM{constructor(t){super(kc(Qc({},t),{name:"inkEditor"})),Tc(this,el),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){QI.initialize(t,e),this._defaultDrawingOptions=new qM(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return LU(this,"typesMap",new Map([[eU.INK_THICKNESS,"stroke-width"],[eU.INK_COLOR,"stroke"],[eU.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,n,r,i){return new GM(t,e,n,r,i,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,n,r,i,A){return zM.deserialize(t,e,n,r,i,A)}static deserialize(e,n,r){return Wc(this,null,function*(){let i=null;if(e instanceof BM){const{data:{inkLists:t,rect:n,rotation:r,id:A,color:s,opacity:a,borderStyle:{rawWidth:o},popupRef:l,contentsObj:c},parent:{page:{pageNumber:h}}}=e;i=e={annotationType:tU.INK,color:Array.from(s),thickness:o,opacity:a,paths:{points:t},boxes:null,pageIndex:h-1,rect:n.slice(0),rotation:r,annotationElementId:A,id:A,deleted:!1,popupRef:l,comment:(null==c?void 0:c.str)||null}}const A=yield jc(t,this,"deserialize").call(this,e,n,r);return A._initialData=i,e.comment&&A.setCommentData(e.comment),A})}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new zk(this)),[["colorPicker",this._colorPicker]]}get colorType(){return eU.INK_COLOR}get colorValue(){return this._drawingOptions.stroke}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:n}=this;e.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:n,opacity:r}){this._drawingOptions=t.getDefaultDrawingOptions({stroke:HU.makeHexColor(...e),"stroke-width":n,"stroke-opacity":r})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:n,rect:r}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":A,"stroke-width":s}}=this,a={annotationType:tU.INK,color:QI._colorManager.convert(i),opacity:A,thickness:s,paths:{lines:e,points:n},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!Rc(this,el,nl).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(t){const{points:e,rect:n}=this.serializeDraw(!1),r={rect:n,thickness:this._drawingOptions["stroke-width"],points:e};return this.hasEditedComment&&(r.popup=this.comment),t.updateEdited(r),null}};el=new WeakSet,nl=function(t){const{color:e,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,n)=>t!==e[n])||t.thickness!==n||t.opacity!==r||t.pageIndex!==i},Oc(XM,"_type","ink"),Oc(XM,"_editorType",tU.INK),Oc(XM,"_defaultDrawingOptions",null);let YM=XM;class $M extends zM{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class JM{static extractContoursFromText(t,{fontFamily:e,fontStyle:n,fontWeight:r},i,A,s,a){let o=new OffscreenCanvas(1,1),l=o.getContext("2d",{alpha:!1});const c=l.font=`${n} ${r} 200px ${e}`,{actualBoundingBoxLeft:h,actualBoundingBoxRight:u,actualBoundingBoxAscent:d,actualBoundingBoxDescent:f,fontBoundingBoxAscent:p,fontBoundingBoxDescent:g,width:m}=l.measureText(t),w=1.5,v=Math.ceil(Math.max(Math.abs(h)+Math.abs(u)||0,m)*w),y=Math.ceil(Math.max(Math.abs(d)+Math.abs(f)||200,Math.abs(p)+Math.abs(g)||200)*w);o=new OffscreenCanvas(v,y),l=o.getContext("2d",{alpha:!0,willReadFrequently:!0}),l.font=c,l.filter="grayscale(1)",l.fillStyle="white",l.fillRect(0,0,v,y),l.fillStyle="black",l.fillText(t,.5*v/2,1.5*y/2);const b=Rc(this,il,fl).call(this,l.getImageData(0,0,v,y).data),B=Rc(this,il,dl).call(this,b),_=Rc(this,il,pl).call(this,B),C=Rc(this,il,ll).call(this,b,v,y,_);return this.processDrawnLines({lines:{curves:C,width:v,height:y},pageWidth:i,pageHeight:A,rotation:s,innerMargin:a,mustSmooth:!0,areContours:!0})}static process(t,e,n,r,i){const[A,s,a]=Rc(this,il,gl).call(this,t),[o,l]=Rc(this,il,ul).call(this,A,s,a,Math.hypot(s,a)*Nc(this,rl).sigmaSFactor,Nc(this,rl).sigmaR,Nc(this,rl).kernelSize),c=Rc(this,il,pl).call(this,l),h=Rc(this,il,ll).call(this,o,s,a,c);return this.processDrawnLines({lines:{curves:h,width:s,height:a},pageWidth:e,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:A,areContours:s}){var a;r%180!=0&&([e,n]=[n,e]);const{curves:o,width:l,height:c}=t,h=null!=(a=t.thickness)?a:0,u=[],d=Math.min(e/l,n/c),f=d/e,p=d/n,g=[];for(const{points:w}of o){const t=A?Rc(this,il,hl).call(this,w):w;if(!t)continue;g.push(t);const e=t.length,n=new Float32Array(e),r=new Float32Array(3*(2===e?2:e-2));if(u.push({line:r,points:n}),2===e){n[0]=t[0]*f,n[1]=t[1]*p,r.set([NaN,NaN,NaN,NaN,n[0],n[1]],0);continue}let[i,s,a,o]=t;i*=f,s*=p,a*=f,o*=p,n.set([i,s,a,o],0),r.set([NaN,NaN,NaN,NaN,i,s],0);for(let A=4;A<e;A+=2){const e=n[A]=t[A]*f,l=n[A+1]=t[A+1]*p;r.set(kM.createBezierPoints(i,s,a,o,e,l),3*(A-2)),[i,s,a,o]=[a,o,e,l]}}if(0===u.length)return null;const m=s?new $M:new zM;return m.build(u,e,n,1,r,s?0:h,i),{outline:m,newCurves:g,areContours:s,thickness:h,width:l,height:c}}static compressSignature(t){return Wc(this,arguments,function*({outlines:t,areContours:e,thickness:n,width:r,height:i}){let A,s=1/0,a=-1/0,o=0;for(const m of t){o+=m.length;for(let t=2,e=m.length;t<e;t++){const e=m[t]-m[t-2];s=Math.min(s,e),a=Math.max(a,e)}}A=s>=-128&&a<=127?Int8Array:s>=-32768&&a<=32767?Int16Array:Int32Array;const l=t.length,c=8+3*l,h=new Uint32Array(c);let u=0;h[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(o-2*l)*A.BYTES_PER_ELEMENT,h[u++]=0,h[u++]=r,h[u++]=i,h[u++]=e?0:1,h[u++]=Math.max(0,Math.floor(null!=n?n:0)),h[u++]=l,h[u++]=A.BYTES_PER_ELEMENT;for(const m of t)h[u++]=m.length-2,h[u++]=m[0],h[u++]=m[1];const d=new CompressionStream("deflate-raw"),f=d.writable.getWriter();yield f.ready,f.write(h);const p=A.prototype.constructor;for(const m of t){const t=new p(m.length-2);for(let e=2,n=m.length;e<n;e++)t[e-2]=m[e]-m[e-2];f.write(t)}f.close();const g=yield new Response(d.readable).arrayBuffer();return zU(new Uint8Array(g))})}static decompressSignature(t){return Wc(this,null,function*(){try{const s=(A=t,Uint8Array.fromBase64?Uint8Array.fromBase64(A):TU(atob(A))),{readable:a,writable:o}=new DecompressionStream("deflate-raw"),l=o.getWriter();yield l.ready,l.write(s).then(()=>Wc(this,null,function*(){yield l.ready,yield l.close()})).catch(()=>{});let c=null,h=0;try{for(var e,n,r,i=((t,e,n)=>(e=t[Fc("asyncIterator")])?e.call(t):(t=t[Fc("iterator")](),e={},(n=(n,r)=>(r=t[n])&&(e[n]=e=>new Promise((n,i,A)=>(e=r.call(t,e),A=e.done,Promise.resolve(e.value).then(t=>n({value:t,done:A}),i)))))("next"),n("return"),e))(a);e=!(n=yield i.next()).done;e=!1){const t=n.value;c||(c=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])),c.set(t,h),h+=t.length}}catch(n){r=[n]}finally{try{e&&(n=i.return)&&(yield n.call(i))}finally{if(r)throw r[0]}}const u=new Uint32Array(c.buffer,0,c.length>>2),d=u[1];if(0!==d)throw new Error(`Invalid version: ${d}`);const f=u[2],p=u[3],g=0===u[4],m=u[5],w=u[6],v=u[7],y=[],b=(8+3*w)*Uint32Array.BYTES_PER_ELEMENT;let B;switch(v){case Int8Array.BYTES_PER_ELEMENT:B=new Int8Array(c.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:B=new Int16Array(c.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:B=new Int32Array(c.buffer,b)}h=0;for(let t=0;t<w;t++){const e=u[3*t+8],n=new Float32Array(e+2);y.push(n);for(let r=0;r<2;r++)n[r]=u[3*t+8+r+1];for(let t=0;t<e;t++)n[t+2]=n[t]+B[h++]}return{areContours:g,thickness:m,outlines:y,width:f,height:p}}catch(hw){return CU(`decompressSignature: ${hw}`),null}var A})}}rl=new WeakMap,il=new WeakSet,Al=function(t,e,n,r){return r-=e,0===(n-=t)?r>0?0:4:1===n?r+6:2-r},sl=new WeakMap,al=function(t,e,n,r,i,A,s){const a=Rc(this,il,Al).call(this,n,r,i,A);for(let o=0;o<8;o++){const i=(-o+a-s+16)%8;if(0!==t[(n+Nc(this,sl)[2*i])*e+(r+Nc(this,sl)[2*i+1])])return i}return-1},ol=function(t,e,n,r,i,A,s){const a=Rc(this,il,Al).call(this,n,r,i,A);for(let o=0;o<8;o++){const i=(o+a+s+16)%8;if(0!==t[(n+Nc(this,sl)[2*i])*e+(r+Nc(this,sl)[2*i+1])])return i}return-1},ll=function(t,e,n,r){const i=t.length,A=new Int32Array(i);for(let l=0;l<i;l++)A[l]=t[l]<=r?1:0;for(let l=1;l<n-1;l++)A[l*e]=A[l*e+e-1]=0;for(let l=0;l<e;l++)A[l]=A[e*n-1-l]=0;let s,a=1;const o=[];for(let l=1;l<n-1;l++){s=1;for(let t=1;t<e-1;t++){const n=l*e+t,r=A[n];if(0===r)continue;let i=l,c=t;if(1===r&&0===A[n-1])a+=1,c-=1;else{if(!(r>=1&&0===A[n+1])){1!==r&&(s=Math.abs(r));continue}a+=1,c+=1,r>1&&(s=r)}const h=[t,l],u=c===t+1,d={isHole:u,points:h,id:a,parent:0};let f;o.push(d);for(const t of o)if(t.id===s){f=t;break}f?f.isHole?d.parent=u?f.parent:s:d.parent=u?s:f.parent:d.parent=u?s:0;const p=Rc(this,il,al).call(this,A,e,l,t,i,c,0);if(-1===p){A[n]=-a,1!==A[n]&&(s=Math.abs(A[n]));continue}let g=Nc(this,sl)[2*p],m=Nc(this,sl)[2*p+1];const w=l+g,v=t+m;i=w,c=v;let y=l,b=t;for(;;){const r=Rc(this,il,ol).call(this,A,e,y,b,i,c,1);g=Nc(this,sl)[2*r],m=Nc(this,sl)[2*r+1];const o=y+g,u=b+m;h.push(u,o);const d=y*e+b;if(0===A[d+1]?A[d]=-a:1===A[d]&&(A[d]=a),o===l&&u===t&&y===w&&b===v){1!==A[n]&&(s=Math.abs(A[n]));break}i=y,c=b,y=o,b=u}}}return o},cl=function(t,e,n,r){if(n-e<=4){for(let i=e;i<n-2;i+=2)r.push(t[i],t[i+1]);return}const i=t[e],A=t[e+1],s=t[n-4]-i,a=t[n-3]-A,o=Math.hypot(s,a),l=s/o,c=a/o,h=l*A-c*i,u=a/s,d=1/o,f=Math.atan(u),p=Math.cos(f),g=Math.sin(f),m=d*(Math.abs(p)+Math.abs(g)),w=d*(1-m+Uc(m,2)),v=Math.max(Math.atan(Math.abs(g+p)*w),Math.atan(Math.abs(g-p)*w));let y=0,b=e;for(let B=e+2;B<n-2;B+=2){const e=Math.abs(h-l*t[B+1]+c*t[B]);e>y&&(b=B,y=e)}y>Uc(o*v,2)?(Rc(this,il,cl).call(this,t,e,b+2,r),Rc(this,il,cl).call(this,t,b,n,r)):r.push(i,A)},hl=function(t){const e=[],n=t.length;return Rc(this,il,cl).call(this,t,0,n,e),e.push(t[n-2],t[n-1]),e.length<=4?null:e},ul=function(t,e,n,r,i,A){const s=new Float32Array(Uc(A,2)),a=-2*Uc(r,2),o=A>>1;for(let f=0;f<A;f++){const t=Uc(f-o,2);for(let e=0;e<A;e++)s[f*A+e]=Math.exp((t+Uc(e-o,2))/a)}const l=new Float32Array(256),c=-2*Uc(i,2);for(let f=0;f<256;f++)l[f]=Math.exp(Uc(f,2)/c);const h=t.length,u=new Uint8Array(h),d=new Uint32Array(256);for(let f=0;f<n;f++)for(let r=0;r<e;r++){const i=f*e+r,a=t[i];let c=0,h=0;for(let u=0;u<A;u++){const i=f+u-o;if(!(i<0||i>=n))for(let n=0;n<A;n++){const d=r+n-o;if(d<0||d>=e)continue;const f=t[i*e+d],p=s[u*A+n]*l[Math.abs(f-a)];c+=f*p,h+=p}}d[u[i]=Math.round(c/h)]++}return[u,d]},dl=function(t){const e=new Uint32Array(256);for(const n of t)e[n]++;return e},fl=function(t){const e=t.length,n=new Uint8ClampedArray(e>>2);let r=-1/0,i=1/0;for(let s=0,a=n.length;s<a;s++){const e=n[s]=t[s<<2];r=Math.max(r,e),i=Math.min(i,e)}const A=255/(r-i);for(let s=0,a=n.length;s<a;s++)n[s]=(n[s]-i)*A;return n},pl=function(t){let e,n=-1/0,r=-1/0;const i=t.findIndex(t=>0!==t);let A=i,s=i;for(e=i;e<256;e++){const i=t[e];i>n&&(e-A>r&&(r=e-A,s=e-1),n=i,A=e)}for(e=s-1;e>=0&&!(t[e]>t[e+1]);e--);return e},gl=function(t){const e=t,{width:n,height:r}=t,{maxDim:i}=Nc(this,rl);let A=n,s=r;if(n>i||r>i){let a=n,o=r,l=Math.log2(Math.max(n,r)/i);const c=Math.floor(l);l=l===c?c-1:c;for(let n=0;n<l;n++){A=Math.ceil(a/2),s=Math.ceil(o/2);const n=new OffscreenCanvas(A,s);n.getContext("2d").drawImage(t,0,0,a,o,0,0,A,s),a=A,o=s,t!==e&&t.close(),t=n.transferToImageBitmap()}const h=Math.min(i/A,i/s);A=Math.round(A*h),s=Math.round(s*h)}const a=new OffscreenCanvas(A,s).getContext("2d",{willReadFrequently:!0});a.fillStyle="white",a.fillRect(0,0,A,s),a.filter="grayscale(1)",a.drawImage(t,0,0,t.width,t.height,0,0,A,s);const o=a.getImageData(0,0,A,s).data;return[Rc(this,il,fl).call(this,o),A,s]},Tc(JM,il),Tc(JM,rl,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),Tc(JM,sl,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class ZM extends WM{constructor(){super(),super.updateProperties({fill:QI._defaultLineColor,"stroke-width":0})}clone(){const t=new ZM;return t.updateAll(this),t}}class tO extends qM{constructor(t){super(t),super.updateProperties({stroke:QI._defaultLineColor,"stroke-width":1})}clone(){const t=new tO(this._viewParameters);return t.updateAll(this),t}}const eO=class t extends KM{constructor(t){super(kc(Qc({},t),{mustBeCommitted:!0,name:"signatureEditor"})),Tc(this,ml,!1),Tc(this,wl,null),Tc(this,vl,null),Tc(this,yl,null),this._willKeepAspectRatio=!0,Dc(this,vl,t.signatureData||null),Dc(this,wl,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){QI.initialize(t,e),this._defaultDrawingOptions=new ZM,this._defaultDrawnSignatureOptions=new tO(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return LU(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!Nc(this,wl)}}static computeTelemetryFinalData(t){var e,n;const r=t.get("hasDescription");return{hasAltText:null!=(e=r.get(!0))?e:0,hasNoAltText:null!=(n=r.get(!1))?n:0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,n;const{_isCopy:r}=this;if(r&&(this._isCopy=!1,e=this.x,n=this.y),super.render(),null===this._drawId)if(Nc(this,vl)){const{lines:e,mustSmooth:n,areContours:r,description:i,uuid:A,heightInPage:s}=Nc(this,vl),{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,c=JM.processDrawnLines({lines:e,pageWidth:a,pageHeight:o,rotation:l,innerMargin:t._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(c,s,i,A)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:Nc(this,wl)||""}));return r&&(this._isCopy=!0,this._moveAfterPaste(e,n)),this.div}setUuid(t){Dc(this,yl,t),this.addEditToolbar()}getUuid(){return Nc(this,yl)}get description(){return Nc(this,wl)}set description(t){Dc(this,wl,t),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{null==e||e.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:n,width:r,height:i}=Nc(this,vl),A=Math.max(r,i);return{areContours:e,outline:JM.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:n,width:r,height:i},pageWidth:A,pageHeight:A,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,n,r,i){const{x:A,y:s}=this,{outline:a}=Dc(this,vl,e);let o;Dc(this,ml,a instanceof $M),this.description=r,Nc(this,ml)?o=t.getDefaultDrawingOptions():(o=t._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[l,c]=this.parentDimensions,[,h]=this.pageDimensions;let u=n/h;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(l*this.width,c*this.height),this.x=A,this.y=s,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!r}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return JM.process(e,n,r,i,t._INNER_MARGIN)}getFromText(e,n){const{rawDims:{pageWidth:r,pageHeight:i},rotation:A}=this.parent.viewport;return JM.extractContoursFromText(e,n,r,i,A,t._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return JM.processDrawnLines({lines:e,pageWidth:n,pageHeight:r,rotation:i,innerMargin:t._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:n}){e?this._drawingOptions=t.getDefaultDrawingOptions():(this._drawingOptions=t._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":n}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:n,rect:r}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,A={annotationType:tU.SIGNATURE,isSignature:!0,areContours:Nc(this,ml),color:[0,0,0],thickness:Nc(this,ml)?0:i,pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(A),t?(A.paths={lines:e,points:n},A.uuid=Nc(this,yl),A.isCopy=!0):A.lines=e,Nc(this,wl)&&(A.accessibilityData={type:"Figure",alt:Nc(this,wl)}),A}static deserializeDraw(t,e,n,r,i,A){return A.areContours?$M.deserialize(t,e,n,r,i,A):zM.deserialize(t,e,n,r,i,A)}static deserialize(e,n,r){return Wc(this,null,function*(){var i;const A=yield jc(t,this,"deserialize").call(this,e,n,r);return Dc(A,ml,e.areContours),A.description=(null==(i=e.accessibilityData)?void 0:i.alt)||"",Dc(A,yl,e.uuid),A})}};ml=new WeakMap,wl=new WeakMap,vl=new WeakMap,yl=new WeakMap,Oc(eO,"_type","signature"),Oc(eO,"_editorType",tU.SIGNATURE),Oc(eO,"_defaultDrawingOptions",null);let nO=eO;const rO=class t extends QI{constructor(t){super(kc(Qc({},t),{name:"stampEditor"})),Tc(this,Ql),Tc(this,bl,null),Tc(this,Bl,null),Tc(this,_l,null),Tc(this,Cl,null),Tc(this,xl,null),Tc(this,El,""),Tc(this,Sl,null),Tc(this,Fl,!1),Tc(this,Ll,null),Tc(this,Ul,!1),Tc(this,Il,!1),Dc(this,Cl,t.bitmapUrl),Dc(this,xl,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){QI.initialize(t,e)}static isHandlingMimeForPasting(t){return uI.includes(t)}static paste(t,e){e.pasteEditor({mode:tU.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!(null==(t=this.altTextData)?void 0:t.altText)}}static computeTelemetryFinalData(t){var e,n;const r=t.get("hasAltText");return{hasAltText:null!=(e=r.get(!0))?e:0,hasNoAltText:null!=(n=r.get(!1))?n:0}}mlGuessAltText(t=null,e=!0){return Wc(this,null,function*(){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!(yield n.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");const{data:r,width:i,height:A}=t||this.copyCanvas(null,null,!0).imageData,s=yield n.guess({name:"altText",request:{data:r,width:i,height:A,channels:r.length/(i*A)}});if(!s)throw new Error("No response from the AI service.");if(s.error)throw new Error("Error from the AI service.");if(s.cancel)return null;if(!s.output)throw new Error("No valid response from the AI service.");const a=s.output;return yield this.setGuessedAltText(a),e&&!this.hasAltTextData()&&(this.altTextData={alt:a,decorative:!1}),a})}remove(){var t;Nc(this,Bl)&&(Dc(this,bl,null),this._uiManager.imageManager.deleteId(Nc(this,Bl)),null==(t=Nc(this,Sl))||t.remove(),Dc(this,Sl,null),Nc(this,Ll)&&(clearTimeout(Nc(this,Ll)),Dc(this,Ll,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(Nc(this,Bl)&&null===Nc(this,Sl)&&Rc(this,Ql,Ol).call(this),this.isAttachedToDOM||this.parent.add(this))):Nc(this,Bl)&&Rc(this,Ql,Ol).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(Nc(this,_l)||Nc(this,bl)||Nc(this,Cl)||Nc(this,xl)||Nc(this,Bl)||Nc(this,Fl))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),Nc(this,Fl)||(Nc(this,bl)?Rc(this,Ql,Pl).call(this):Rc(this,Ql,Ol).call(this)),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),n&&this._uiManager.imageManager.isValidId(n)&&(Dc(this,Bl,n),r&&Dc(this,bl,r),Dc(this,Fl,!1),Rc(this,Ql,Pl).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==Nc(this,Ll)&&clearTimeout(Nc(this,Ll));Dc(this,Ll,setTimeout(()=>{Dc(this,Ll,null),Rc(this,Ql,Tl).call(this)},200))}copyCanvas(t,e,n=!1){var r;t||(t=224);const{width:i,height:A}=Nc(this,bl),s=new hI;let a=Nc(this,bl),o=i,l=A,c=null;if(e){if(i>e||A>e){const t=Math.min(e/i,e/A);o=Math.floor(i*t),l=Math.floor(A*t)}c=document.createElement("canvas");const t=c.width=Math.ceil(o*s.sx),n=c.height=Math.ceil(l*s.sy);Nc(this,Ul)||(a=Rc(this,Ql,Nl).call(this,t,n));const h=c.getContext("2d");h.filter=this._uiManager.hcmFilter;let u="white",d="#cfcfd8";"none"!==this._uiManager.hcmFilter?d="black":(null==(r=window.matchMedia)?void 0:r.call(window,"(prefers-color-scheme: dark)").matches)&&(u="#8f8f9d",d="#42414d");const f=15,p=f*s.sx,g=f*s.sy,m=new OffscreenCanvas(2*p,2*g),w=m.getContext("2d");w.fillStyle=u,w.fillRect(0,0,2*p,2*g),w.fillStyle=d,w.fillRect(0,0,p,g),w.fillRect(p,g,p,g),h.fillStyle=h.createPattern(m,"repeat"),h.fillRect(0,0,t,n),h.drawImage(a,0,0,a.width,a.height,0,0,t,n)}let h=null;if(n){let e,n;if(s.symmetric&&a.width<t&&a.height<t)e=a.width,n=a.height;else if(a=Nc(this,bl),i>t||A>t){const r=Math.min(t/i,t/A);e=Math.floor(i*r),n=Math.floor(A*r),Nc(this,Ul)||(a=Rc(this,Ql,Nl).call(this,e,n))}const r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});r.drawImage(a,0,0,a.width,a.height,0,0,e,n),h={width:e,height:n,data:r.getImageData(0,0,e,n).data}}return{canvas:c,width:o,height:l,imageData:h}}static deserialize(e,n,r){return Wc(this,null,function*(){var i;let A=null,s=!1;if(e instanceof SM){const{data:{rect:t,rotation:a,id:o,structParent:l,popupRef:c,contentsObj:h},container:u,parent:{page:{pageNumber:d}},canvas:f}=e;let p,g;f?(delete e.canvas,({id:p,bitmap:g}=r.imageManager.getFromCanvas(u.id,f)),f.remove()):(s=!0,e._hasNoCanvas=!0);const m=(null==(i=yield n._structTree.getAriaAttributes(`${KU}${o}`))?void 0:i.get("aria-label"))||"";A=e={annotationType:tU.STAMP,bitmapId:p,bitmap:g,pageIndex:d-1,rect:t.slice(0),rotation:a,annotationElementId:o,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:m},isSvg:!1,structParent:l,popupRef:c,comment:(null==h?void 0:h.str)||null}}const a=yield jc(t,this,"deserialize").call(this,e,n,r),{rect:o,bitmap:l,bitmapUrl:c,bitmapId:h,isSvg:u,accessibilityData:d}=e;s?(r.addMissingCanvas(e.id,a),Dc(a,Fl,!0)):h&&r.imageManager.isValidId(h)?(Dc(a,Bl,h),l&&Dc(a,bl,l)):Dc(a,Cl,c),Dc(a,Ul,u);const[f,p]=a.pageDimensions;return a.width=(o[2]-o[0])/f,a.height=(o[3]-o[1])/p,d&&(a.altTextData=d),a._initialData=A,e.comment&&a.setCommentData(e.comment),Dc(a,Il,!!A),a})}serialize(t=!1,e=null){var n;if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const r={annotationType:tU.STAMP,bitmapId:Nc(this,Bl),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:Nc(this,Ul),structTreeParentId:this._structTreeParentId};if(this.addComment(r),t)return r.bitmapUrl=Rc(this,Ql,Dl).call(this,!0),r.accessibilityData=this.serializeAltText(!0),r.isCopy=!0,r;const{decorative:i,altText:A}=this.serializeAltText(!1);if(!i&&A&&(r.accessibilityData={type:"Figure",alt:A}),this.annotationElementId){const t=Rc(this,Ql,Rl).call(this,r);if(t.isSame)return null;t.isSameAltText?delete r.accessibilityData:r.accessibilityData.structParent=null!=(n=this._initialData.structParent)?n:-1}if(r.id=this.annotationElementId,null===e)return r;e.stamps||(e.stamps=new Map);const s=Nc(this,Ul)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(e.stamps.has(Nc(this,Bl))){if(Nc(this,Ul)){const t=e.stamps.get(Nc(this,Bl));s>t.area&&(t.area=s,t.serialized.bitmap.close(),t.serialized.bitmap=Rc(this,Ql,Dl).call(this,!1))}}else e.stamps.set(Nc(this,Bl),{area:s,serialized:r}),r.bitmap=Rc(this,Ql,Dl).call(this,!1);return r}renderAnnotationElement(t){const e={rect:this.getRect(0,0)};return this.hasEditedComment&&(e.popup=this.comment),t.updateEdited(e),null}};bl=new WeakMap,Bl=new WeakMap,_l=new WeakMap,Cl=new WeakMap,xl=new WeakMap,El=new WeakMap,Sl=new WeakMap,Fl=new WeakMap,Ll=new WeakMap,Ul=new WeakMap,Il=new WeakMap,Ql=new WeakSet,kl=function(t,e=!1){t?(Dc(this,bl,t.bitmap),e||(Dc(this,Bl,t.id),Dc(this,Ul,t.isSvg)),t.file&&Dc(this,El,t.file.name),Rc(this,Ql,Pl).call(this)):this.remove()},Ml=function(){if(Dc(this,_l,null),this._uiManager.enableWaiting(!1),Nc(this,Sl))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Nc(this,bl))this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Nc(this,bl)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch(hw){}}this.div.focus()}},Ol=function(){if(Nc(this,Bl))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(Nc(this,Bl)).then(t=>Rc(this,Ql,kl).call(this,t,!0)).finally(()=>Rc(this,Ql,Ml).call(this));if(Nc(this,Cl)){const t=Nc(this,Cl);return Dc(this,Cl,null),this._uiManager.enableWaiting(!0),void Dc(this,_l,this._uiManager.imageManager.getFromUrl(t).then(t=>Rc(this,Ql,kl).call(this,t)).finally(()=>Rc(this,Ql,Ml).call(this)))}if(Nc(this,xl)){const t=Nc(this,xl);return Dc(this,xl,null),this._uiManager.enableWaiting(!0),void Dc(this,_l,this._uiManager.imageManager.getFromFile(t).then(t=>Rc(this,Ql,kl).call(this,t)).finally(()=>Rc(this,Ql,Ml).call(this)))}const t=document.createElement("input");t.type="file",t.accept=uI.join(",");const e=this._uiManager._signal;Dc(this,_l,new Promise(n=>{t.addEventListener("change",()=>Wc(this,null,function*(){if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=yield this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),Rc(this,Ql,kl).call(this,e)}else this.remove();n()}),{signal:e}),t.addEventListener("cancel",()=>{this.remove(),n()},{signal:e})}).finally(()=>Rc(this,Ql,Ml).call(this))),t.click()},Pl=function(){var t;const{div:e}=this;let{width:n,height:r}=Nc(this,bl);const[i,A]=this.pageDimensions,s=.75;if(this.width)n=this.width*i,r=this.height*A;else if(n>s*i||r>s*A){const t=Math.min(s*i/n,s*A/r);n*=t,r*=t}const[a,o]=this.parentDimensions;this.setDims(n*a/i,r*o/A),this._uiManager.enableWaiting(!1);const l=Dc(this,Sl,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=n/i,this.height=r/A,(null==(t=this._initialOptions)?void 0:t.isCentered)?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),Rc(this,Ql,Tl).call(this),Nc(this,Il)||(this.parent.addUndoableEditor(this),Dc(this,Il,!0)),this._reportTelemetry({action:"inserted_image"}),Nc(this,El)&&this.div.setAttribute("aria-description",Nc(this,El)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},Nl=function(t,e){const{width:n,height:r}=Nc(this,bl);let i=n,A=r,s=Nc(this,bl);for(;i>2*t||A>2*e;){const n=i,r=A;i>2*t&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2)),A>2*e&&(A=A>=16384?Math.floor(A/2)-1:Math.ceil(A/2));const a=new OffscreenCanvas(i,A);a.getContext("2d").drawImage(s,0,0,n,r,0,0,i,A),s=a.transferToImageBitmap()}return s},Tl=function(){const[t,e]=this.parentDimensions,{width:n,height:r}=this,i=new hI,A=Math.ceil(n*t*i.sx),s=Math.ceil(r*e*i.sy),a=Nc(this,Sl);if(!a||a.width===A&&a.height===s)return;a.width=A,a.height=s;const o=Nc(this,Ul)?Nc(this,bl):Rc(this,Ql,Nl).call(this,A,s),l=a.getContext("2d");l.filter=this._uiManager.hcmFilter,l.drawImage(o,0,0,o.width,o.height,0,0,A,s)},Dl=function(t){if(t){if(Nc(this,Ul)){const t=this._uiManager.imageManager.getSvgUrl(Nc(this,Bl));if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=Nc(this,bl));return t.getContext("2d").drawImage(Nc(this,bl),0,0),t.toDataURL()}if(Nc(this,Ul)){const[t,e]=this.pageDimensions,n=Math.round(this.width*t*YU.PDF_TO_CSS_UNITS),r=Math.round(this.height*e*YU.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);return i.getContext("2d").drawImage(Nc(this,bl),0,0,Nc(this,bl).width,Nc(this,bl).height,0,0,n,r),i.transferToImageBitmap()}return structuredClone(Nc(this,bl))},Rl=function(t){var e;const{pageIndex:n,accessibilityData:{altText:r}}=this._initialData,i=t.pageIndex===n,A=((null==(e=t.accessibilityData)?void 0:e.alt)||"")===r;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&A,isSameAltText:A}},Oc(rO,"_type","stamp"),Oc(rO,"_editorType",tU.STAMP);let iO=rO;const AO=class t{constructor({uiManager:e,pageIndex:n,div:r,structTreeLayer:i,accessibilityManager:A,annotationLayer:s,drawLayer:a,textLayer:o,viewport:l,l10n:c}){Tc(this,ic),Tc(this,Hl),Tc(this,jl,!1),Tc(this,Wl,null),Tc(this,Vl,null),Tc(this,Kl,null),Tc(this,Gl,new Map),Tc(this,zl,!1),Tc(this,ql,!1),Tc(this,Xl,!1),Tc(this,Yl,null),Tc(this,$l,null),Tc(this,Jl,null),Tc(this,Zl,null),Tc(this,tc,null),Tc(this,ec,-1),Tc(this,nc);const h=[...Nc(t,rc).values()];if(!t._initialized){t._initialized=!0;for(const t of h)t.initialize(c,e)}e.registerEditorTypes(h),Dc(this,nc,e),this.pageIndex=n,this.div=r,Dc(this,Hl,A),Dc(this,Wl,s),this.viewport=l,Dc(this,Jl,o),this.drawLayer=a,this._structTree=i,Nc(this,nc).addLayer(this)}get isEmpty(){return 0===Nc(this,Gl).size}get isInvisible(){return this.isEmpty&&Nc(this,nc).getMode()===tU.NONE}updateToolbar(t){Nc(this,nc).updateToolbar(t)}updateMode(e=Nc(this,nc).getMode()){switch(Rc(this,ic,lc).call(this),e){case tU.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case tU.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case tU.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:n}=this.div;for(const r of Nc(t,rc).values())n.toggle(`${r._type}Editing`,e===r._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null==(e=Nc(this,Jl))?void 0:e.div)}setEditingState(t){Nc(this,nc).setEditingState(t)}addCommands(t){Nc(this,nc).addCommands(t)}cleanUndoStack(t){Nc(this,nc).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;null==(e=Nc(this,Wl))||e.div.classList.toggle("disabled",!t)}enable(){return Wc(this,null,function*(){var t;Dc(this,Xl,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),null==(t=Nc(this,tc))||t.abort(),Dc(this,tc,null);const e=new Set;for(const r of Nc(this,Gl).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(Nc(this,nc).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(!Nc(this,Wl))return void Dc(this,Xl,!1);const n=Nc(this,Wl).getEditableAnnotations();for(const r of n){if(r.hide(),Nc(this,nc).isDeletedAnnotationElement(r.data.id))continue;if(e.has(r.data.id))continue;const t=yield this.deserialize(r);t&&(this.addOrRebuild(t),t.enableEditing())}Dc(this,Xl,!1)})}disable(){var e;if(Dc(this,ql,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),Nc(this,Jl)&&!Nc(this,tc)){Dc(this,tc,new AbortController);const t=Nc(this,nc).combinedSignal(Nc(this,tc));Nc(this,Jl).div.addEventListener("pointerdown",t=>{const{clientX:e,clientY:n,timeStamp:r}=t;if(r-Nc(this,ec)>500)return void Dc(this,ec,r);Dc(this,ec,-1);const{classList:i}=this.div;i.toggle("getElements",!0);const A=document.elementsFromPoint(e,n);if(i.toggle("getElements",!1),!this.div.contains(A[0]))return;let s;const a=new RegExp(`^${ZL}[0-9]+$`);for(const l of A)if(a.test(l.id)){s=l.id;break}if(!s)return;const o=Nc(this,Gl).get(s);null===(null==o?void 0:o.annotationElementId)&&(t.stopPropagation(),t.preventDefault(),o.dblclick())},{signal:t,capture:!0})}const n=new Map,r=new Map;for(const t of Nc(this,Gl).values())t.disableEditing(),t.annotationElementId&&(null===t.serialize()?(r.set(t.annotationElementId,t),null==(e=this.getEditableAnnotation(t.annotationElementId))||e.show(),t.remove()):n.set(t.annotationElementId,t));if(Nc(this,Wl)){const t=Nc(this,Wl).getEditableAnnotations();for(const e of t){const{id:t}=e.data;if(Nc(this,nc).isDeletedAnnotationElement(t)){e.updateEdited({deleted:!0});continue}let i=r.get(t);i?(i.resetAnnotationElement(e),i.show(!1),e.show()):(i=n.get(t),i&&(Nc(this,nc).addChangedExistingAnnotation(i),i.renderAnnotationElement(e)&&i.show(!1)),e.show())}}Rc(this,ic,lc).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const A of Nc(t,rc).values())i.remove(`${A._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),Dc(this,ql,!1)}getEditableAnnotation(t){var e;return(null==(e=Nc(this,Wl))?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){Nc(this,nc).getActive()!==t&&Nc(this,nc).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(null==(t=Nc(this,Jl))?void 0:t.div)&&!Nc(this,Zl)){Dc(this,Zl,new AbortController);const t=Nc(this,nc).combinedSignal(Nc(this,Zl));Nc(this,Jl).div.addEventListener("pointerdown",Rc(this,ic,Ac).bind(this),{signal:t}),Nc(this,Jl).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(null==(t=Nc(this,Jl))?void 0:t.div)&&Nc(this,Zl)&&(Nc(this,Zl).abort(),Dc(this,Zl,null),Nc(this,Jl).div.classList.remove("highlighting"))}enableClick(){if(Nc(this,Vl))return;Dc(this,Vl,new AbortController);const t=Nc(this,nc).combinedSignal(Nc(this,Vl));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;null==(t=Nc(this,Vl))||t.abort(),Dc(this,Vl,null)}attach(t){Nc(this,Gl).set(t.id,t);const{annotationElementId:e}=t;e&&Nc(this,nc).isDeletedAnnotationElement(e)&&Nc(this,nc).removeDeletedAnnotationElement(t)}detach(t){var e;Nc(this,Gl).delete(t.id),null==(e=Nc(this,Hl))||e.removePointerInTextLayer(t.contentDiv),!Nc(this,ql)&&t.annotationElementId&&Nc(this,nc).addDeletedAnnotationElement(t)}remove(t){this.detach(t),Nc(this,nc).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(Nc(this,nc).addDeletedAnnotationElement(t.annotationElementId),QI.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null==(e=t.parent)||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),Nc(this,nc).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!Nc(this,Xl)),Nc(this,nc).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:n}=document;t.div.contains(n)&&!Nc(this,Kl)&&(t._focusEventsAllowed=!1,Dc(this,Kl,setTimeout(()=>{Dc(this,Kl,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:Nc(this,nc)._signal}),n.focus())},0))),t._structTreeParentId=null==(e=Nc(this,Hl))?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return Nc(this,nc).getId()}combinedSignal(t){return Nc(this,nc).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null==(t=Nc(this,ic,sc))?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){return Wc(this,null,function*(){this.updateToolbar(t),yield Nc(this,nc).updateMode(t.mode);const{offsetX:n,offsetY:r}=Rc(this,ic,oc).call(this),i=this.getNextId(),A=Rc(this,ic,ac).call(this,Qc({parent:this,id:i,x:n,y:r,uiManager:Nc(this,nc),isCentered:!0},e));A&&this.add(A)})}deserialize(e){return Wc(this,null,function*(){var n,r;return(yield null==(r=Nc(t,rc).get(null!=(n=e.annotationType)?n:e.annotationEditorType))?void 0:r.deserialize(e,this,Nc(this,nc)))||null})}createAndAddNewEditor(t,e,n={}){const r=this.getNextId(),i=Rc(this,ic,ac).call(this,Qc({parent:this,id:r,x:t.offsetX,y:t.offsetY,uiManager:Nc(this,nc),isCentered:e},n));return i&&this.add(i),i}addNewEditor(t={}){this.createAndAddNewEditor(Rc(this,ic,oc).call(this),!0,t)}setSelected(t){Nc(this,nc).setSelected(t)}toggleSelected(t){Nc(this,nc).toggleSelected(t)}unselect(t){Nc(this,nc).unselect(t)}pointerup(t){var e;const{isMac:n}=DU.platform;if(0!==t.button||t.ctrlKey&&n)return;if(t.target!==this.div)return;if(!Nc(this,zl))return;if(Dc(this,zl,!1),(null==(e=Nc(this,ic,sc))?void 0:e.isDrawer)&&Nc(this,ic,sc).supportMultipleDrawings)return;if(!Nc(this,jl))return void Dc(this,jl,!0);const r=Nc(this,nc).getMode();r!==tU.STAMP&&r!==tU.SIGNATURE?this.createAndAddNewEditor(t,!1):Nc(this,nc).unselectAll()}pointerdown(t){var e;if(Nc(this,nc).getMode()===tU.HIGHLIGHT&&this.enableTextSelection(),Nc(this,zl))return void Dc(this,zl,!1);const{isMac:n}=DU.platform;if(0!==t.button||t.ctrlKey&&n)return;if(t.target!==this.div)return;if(Dc(this,zl,!0),null==(e=Nc(this,ic,sc))?void 0:e.isDrawer)return void this.startDrawingSession(t);const r=Nc(this,nc).getActive();Dc(this,jl,!r||r.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),Nc(this,Yl))return void Nc(this,ic,sc).startDrawing(this,Nc(this,nc),!1,t);Nc(this,nc).setCurrentDrawingSession(this),Dc(this,Yl,new AbortController);const e=Nc(this,nc).combinedSignal(Nc(this,Yl));this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(Dc(this,$l,null),this.commitOrRemove())},{signal:e}),Nc(this,ic,sc).startDrawing(this,Nc(this,nc),!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&Dc(this,$l,t))}Nc(this,$l)&&setTimeout(()=>{var t;null==(t=Nc(this,$l))||t.focus(),Dc(this,$l,null)},0)}endDrawingSession(t=!1){return Nc(this,Yl)?(Nc(this,nc).setCurrentDrawingSession(null),Nc(this,Yl).abort(),Dc(this,Yl,null),Dc(this,$l,null),Nc(this,ic,sc).endDrawing(t)):null}findNewParent(t,e,n){const r=Nc(this,nc).findParent(e,n);return null!==r&&r!==this&&(r.changeParent(t),!0)}commitOrRemove(){return!!Nc(this,Yl)&&(this.endDrawingSession(),!0)}onScaleChanging(){Nc(this,Yl)&&Nc(this,ic,sc).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),(null==(t=Nc(this,nc).getActive())?void 0:t.parent)===this&&(Nc(this,nc).commitOrRemove(),Nc(this,nc).setActiveEditor(null)),Nc(this,Kl)&&(clearTimeout(Nc(this,Kl)),Dc(this,Kl,null));for(const n of Nc(this,Gl).values())null==(e=Nc(this,Hl))||e.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,Nc(this,Gl).clear(),Nc(this,nc).removeLayer(this)}render({viewport:t}){this.viewport=t,cI(this.div,t);for(const e of Nc(this,nc).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){Nc(this,nc).commitOrRemove(),Rc(this,ic,lc).call(this);const e=this.viewport.rotation,n=t.rotation;if(this.viewport=t,cI(this.div,{rotation:n}),e!==n)for(const r of Nc(this,Gl).values())r.rotate(n)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return Nc(this,nc).viewParameters.realScale}};Hl=new WeakMap,jl=new WeakMap,Wl=new WeakMap,Vl=new WeakMap,Kl=new WeakMap,Gl=new WeakMap,zl=new WeakMap,ql=new WeakMap,Xl=new WeakMap,Yl=new WeakMap,$l=new WeakMap,Jl=new WeakMap,Zl=new WeakMap,tc=new WeakMap,ec=new WeakMap,nc=new WeakMap,rc=new WeakMap,ic=new WeakSet,Ac=function(t){Nc(this,nc).unselectAll();const{target:e}=t;if(e===Nc(this,Jl).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&Nc(this,Jl).div.contains(e)){const{isMac:e}=DU.platform;if(0!==t.button||t.ctrlKey&&e)return;Nc(this,nc).showAllEditors("highlight",!0,!0),Nc(this,Jl).div.classList.add("free"),this.toggleDrawing(),jM.startHighlighting(this,"ltr"===Nc(this,nc).direction,{target:Nc(this,Jl).div,x:t.x,y:t.y}),Nc(this,Jl).div.addEventListener("pointerup",()=>{Nc(this,Jl).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:Nc(this,nc)._signal}),t.preventDefault()}},sc=function(){return Nc(AO,rc).get(Nc(this,nc).getMode())},ac=function(t){const e=Nc(this,ic,sc);return e?new e.prototype.constructor(t):null},oc=function(){const{x:t,y:e,width:n,height:r}=this.div.getBoundingClientRect(),i=Math.max(0,t),A=Math.max(0,e),s=(i+Math.min(window.innerWidth,t+n))/2-t,a=(A+Math.min(window.innerHeight,e+r))/2-e,[o,l]=this.viewport.rotation%180==0?[s,a]:[a,s];return{offsetX:o,offsetY:l}},lc=function(){for(const t of Nc(this,Gl).values())t.isEmpty()&&t.remove()},Oc(AO,"_initialized",!1),Tc(AO,rc,new Map([QM,YM,iO,jM,nO].map(t=>[t._editorType,t])));let sO=AO;const aO=class t{constructor({pageIndex:t}){Tc(this,gc),Tc(this,cc,null),Tc(this,hc,new Map),Tc(this,uc,new Map),this.pageIndex=t}setParent(t){if(Nc(this,cc)){if(Nc(this,cc)!==t){if(Nc(this,hc).size>0)for(const e of Nc(this,hc).values())e.remove(),t.append(e);Dc(this,cc,t)}}else Dc(this,cc,t)}static get _svgFactory(){return LU(this,"_svgFactory",new Jk)}draw(e,n=!1,r=!1){const i=Hc(t,dc)._++,A=Rc(this,gc,mc).call(this),s=t._svgFactory.createElement("defs");A.append(s);const a=t._svgFactory.createElement("path");s.append(a);const o=`path_p${this.pageIndex}_${i}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),n&&Nc(this,uc).set(i,a);const l=r?Rc(this,gc,wc).call(this,s,o):null,c=t._svgFactory.createElement("use");return A.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(A,e),Nc(this,hc).set(i,A),{id:i,clipPathId:`url(#${l})`}}drawOutline(e,n){const r=Hc(t,dc)._++,i=Rc(this,gc,mc).call(this),A=t._svgFactory.createElement("defs");i.append(A);const s=t._svgFactory.createElement("path");A.append(s);const a=`path_p${this.pageIndex}_${r}`;let o;if(s.setAttribute("id",a),s.setAttribute("vector-effect","non-scaling-stroke"),n){const e=t._svgFactory.createElement("mask");A.append(e),o=`mask_p${this.pageIndex}_${r}`,e.setAttribute("id",o),e.setAttribute("maskUnits","objectBoundingBox");const n=t._svgFactory.createElement("rect");e.append(n),n.setAttribute("width","1"),n.setAttribute("height","1"),n.setAttribute("fill","white");const i=t._svgFactory.createElement("use");e.append(i),i.setAttribute("href",`#${a}`),i.setAttribute("stroke","none"),i.setAttribute("fill","black"),i.setAttribute("fill-rule","nonzero"),i.classList.add("mask")}const l=t._svgFactory.createElement("use");i.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const c=l.cloneNode();return i.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,e),Nc(this,hc).set(r,i),r}finalizeDraw(t,e){Nc(this,uc).delete(t),this.updateProperties(t,e)}updateProperties(e,n){var r;if(!n)return;const{root:i,bbox:A,rootClass:s,path:a}=n,o="number"==typeof e?Nc(this,hc).get(e):e;if(o){if(i&&Rc(this,gc,vc).call(this,o,i),A&&Rc(r=t,fc,pc).call(r,o,A),s){const{classList:t}=o;for(const[e,n]of Object.entries(s))t.toggle(e,n)}if(a){const t=o.firstChild.firstChild;Rc(this,gc,vc).call(this,t,a)}}}updateParent(t,e){if(e===this)return;const n=Nc(this,hc).get(t);n&&(Nc(e,cc).append(n),Nc(this,hc).delete(t),Nc(e,hc).set(t,n))}remove(t){Nc(this,uc).delete(t),null!==Nc(this,cc)&&(Nc(this,hc).get(t).remove(),Nc(this,hc).delete(t))}destroy(){Dc(this,cc,null);for(const t of Nc(this,hc).values())t.remove();Nc(this,hc).clear(),Nc(this,uc).clear()}};cc=new WeakMap,hc=new WeakMap,uc=new WeakMap,dc=new WeakMap,fc=new WeakSet,pc=function(t,[e,n,r,i]){const{style:A}=t;A.top=100*n+"%",A.left=100*e+"%",A.width=100*r+"%",A.height=100*i+"%"},gc=new WeakSet,mc=function(){const t=aO._svgFactory.create(1,1,!0);return Nc(this,cc).append(t),t.setAttribute("aria-hidden",!0),t},wc=function(t,e){const n=aO._svgFactory.createElement("clipPath");t.append(n);const r=`clip_${e}`;n.setAttribute("id",r),n.setAttribute("clipPathUnits","objectBoundingBox");const i=aO._svgFactory.createElement("use");return n.append(i),i.setAttribute("href",`#${e}`),i.classList.add("clip"),r},vc=function(t,e){for(const[n,r]of Object.entries(e))null===r?t.removeAttribute(n):t.setAttribute(n,r)},Tc(aO,fc),Tc(aO,dc,0);let oO=aO;globalThis._pdfjsTestingUtils={HighlightOutliner:NM},globalThis.pdfjsLib={AbortException:PU,AnnotationEditorLayer:sO,AnnotationEditorParamsType:eU,AnnotationEditorType:tU,AnnotationEditorUIManager:xI,AnnotationLayer:LM,AnnotationMode:JL,AnnotationType:lU,build:"295fb3ec4",ColorPicker:Kk,createValidAbsoluteUrl:SU,DOMSVGFactory:Jk,DrawLayer:oO,FeatureTest:DU,fetchData:$U,getDocument:Qk,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)},getPdfFilenameFromUrl:function(t,e="document.pdf"){if("string"!=typeof t)return e;if(tI(t))return CU('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const n=(t=>{try{return new URL(t)}catch(hw){try{return new URL(decodeURIComponent(t))}catch(e){try{return new URL(t,"https://foo.bar")}catch(n){try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch(r){return null}}}}})(t);if(!n)return e;const r=t=>{try{let e=decodeURIComponent(t);return e.includes("/")?(e=e.split("/").at(-1),e.test(/^\.pdf$/i)?e:t):e}catch(hw){return t}},i=/\.pdf$/i,A=n.pathname.split("/").at(-1);if(i.test(A))return r(A);if(n.searchParams.size>0){const t=Array.from(n.searchParams.values()).reverse();for(const n of t)if(i.test(n))return r(n);const e=Array.from(n.searchParams.keys()).reverse();for(const n of e)if(i.test(n))return r(n)}if(n.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(n.hash);if(t)return r(t[0])}return e},getRGB:aI,getUuid:VU,getXfaPageViewport:function(t,{scale:e=1,rotation:n=0}){const{width:r,height:i}=t.attributes.style,A=[0,0,parseInt(r),parseInt(i)];return new JU({viewBox:A,userUnit:1,scale:e,rotation:n})},GlobalWorkerOptions:tk,ImageKind:oU,InvalidPDFException:kU,isDataScheme:tI,isPdfFile:eI,isValidExplicitDest:KI,MathClamp:GU,noContextMenu:iI,normalizeUnicode:function(t){return jU||(jU=/([\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,WU=new Map([["ſt","ſt"]])),t.replaceAll(jU,(t,e,n)=>e?e.normalize("NFKC"):WU.get(n))},OPS:gU,OutputScale:hI,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:Ok,PDFDateString:sI,PDFWorker:Dk,PermissionFlag:{PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},PixelsPerInch:YU,RenderingCancelledException:ZU,ResponseException:MU,setLayerDimensions:cI,shadow:LU,SignatureExtractor:JM,stopEvent:AI,SupportedImageMimeTypes:uI,TextLayer:Uk,TouchManager:UI,updateUrlHash:FU,Util:HU,VerbosityLevel:pU,version:"5.4.54",XfaLayer:Zk};function lO(t){let e=t.length;for(;--e>=0;)t[e]=0}const cO=256,hO=286,uO=30,dO=15,fO=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),pO=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),gO=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),mO=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wO=new Array(576);lO(wO);const vO=new Array(60);lO(vO);const yO=new Array(512);lO(yO);const bO=new Array(256);lO(bO);const BO=new Array(29);lO(BO);const _O=new Array(uO);function CO(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}let xO,EO,SO;function FO(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}lO(_O);const LO=t=>t<256?yO[t]:yO[256+(t>>>7)],UO=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},IO=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,UO(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},QO=(t,e,n)=>{IO(t,n[2*e],n[2*e+1])},kO=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},MO=(t,e,n)=>{const r=new Array(16);let i,A,s=0;for(i=1;i<=dO;i++)s=s+n[i-1]<<1,r[i]=s;for(A=0;A<=e;A++){let e=t[2*A+1];0!==e&&(t[2*A]=kO(r[e]++,e))}},OO=t=>{let e;for(e=0;e<hO;e++)t.dyn_ltree[2*e]=0;for(e=0;e<uO;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},PO=t=>{t.bi_valid>8?UO(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},NO=(t,e,n,r)=>{const i=2*e,A=2*n;return t[i]<t[A]||t[i]===t[A]&&r[e]<=r[n]},TO=(t,e,n)=>{const r=t.heap[n];let i=n<<1;for(;i<=t.heap_len&&(i<t.heap_len&&NO(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!NO(e,r,t.heap[i],t.depth));)t.heap[n]=t.heap[i],n=i,i<<=1;t.heap[n]=r},DO=(t,e,n)=>{let r,i,A,s,a=0;if(0!==t.sym_next)do{r=255&t.pending_buf[t.sym_buf+a++],r+=(255&t.pending_buf[t.sym_buf+a++])<<8,i=t.pending_buf[t.sym_buf+a++],0===r?QO(t,i,e):(A=bO[i],QO(t,A+cO+1,e),s=fO[A],0!==s&&(i-=BO[A],IO(t,i,s)),r--,A=LO(r),QO(t,A,n),s=pO[A],0!==s&&(r-=_O[A],IO(t,r,s)))}while(a<t.sym_next);QO(t,256,e)},RO=(t,e)=>{const n=e.dyn_tree,r=e.stat_desc.static_tree,i=e.stat_desc.has_stree,A=e.stat_desc.elems;let s,a,o,l=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<A;s++)0!==n[2*s]?(t.heap[++t.heap_len]=l=s,t.depth[s]=0):n[2*s+1]=0;for(;t.heap_len<2;)o=t.heap[++t.heap_len]=l<2?++l:0,n[2*o]=1,t.depth[o]=0,t.opt_len--,i&&(t.static_len-=r[2*o+1]);for(e.max_code=l,s=t.heap_len>>1;s>=1;s--)TO(t,n,s);o=A;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],TO(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,n[2*o]=n[2*s]+n[2*a],t.depth[o]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,n[2*s+1]=n[2*a+1]=o,t.heap[1]=o++,TO(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,r=e.max_code,i=e.stat_desc.static_tree,A=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,o=e.stat_desc.max_length;let l,c,h,u,d,f,p=0;for(u=0;u<=dO;u++)t.bl_count[u]=0;for(n[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)c=t.heap[l],u=n[2*n[2*c+1]+1]+1,u>o&&(u=o,p++),n[2*c+1]=u,c>r||(t.bl_count[u]++,d=0,c>=a&&(d=s[c-a]),f=n[2*c],t.opt_len+=f*(u+d),A&&(t.static_len+=f*(i[2*c+1]+d)));if(0!==p){do{for(u=o-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[o]--,p-=2}while(p>0);for(u=o;0!==u;u--)for(c=t.bl_count[u];0!==c;)h=t.heap[--l],h>r||(n[2*h+1]!==u&&(t.opt_len+=(u-n[2*h+1])*n[2*h],n[2*h+1]=u),c--)}})(t,e),MO(n,l,t.bl_count)},HO=(t,e,n)=>{let r,i,A=-1,s=e[1],a=0,o=7,l=4;for(0===s&&(o=138,l=3),e[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=e[2*(r+1)+1],++a<o&&i===s||(a<l?t.bl_tree[2*i]+=a:0!==i?(i!==A&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,A=i,0===s?(o=138,l=3):i===s?(o=6,l=3):(o=7,l=4))},jO=(t,e,n)=>{let r,i,A=-1,s=e[1],a=0,o=7,l=4;for(0===s&&(o=138,l=3),r=0;r<=n;r++)if(i=s,s=e[2*(r+1)+1],!(++a<o&&i===s)){if(a<l)do{QO(t,i,t.bl_tree)}while(0!==--a);else 0!==i?(i!==A&&(QO(t,i,t.bl_tree),a--),QO(t,16,t.bl_tree),IO(t,a-3,2)):a<=10?(QO(t,17,t.bl_tree),IO(t,a-3,3)):(QO(t,18,t.bl_tree),IO(t,a-11,7));a=0,A=i,0===s?(o=138,l=3):i===s?(o=6,l=3):(o=7,l=4)}};let WO=!1;const VO=(t,e,n,r)=>{IO(t,0+(r?1:0),3),PO(t),UO(t,n),UO(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n};var KO={_tr_init:t=>{WO||((()=>{let t,e,n,r,i;const A=new Array(16);for(n=0,r=0;r<28;r++)for(BO[r]=n,t=0;t<1<<fO[r];t++)bO[n++]=r;for(bO[n-1]=r,i=0,r=0;r<16;r++)for(_O[r]=i,t=0;t<1<<pO[r];t++)yO[i++]=r;for(i>>=7;r<uO;r++)for(_O[r]=i<<7,t=0;t<1<<pO[r]-7;t++)yO[256+i++]=r;for(e=0;e<=dO;e++)A[e]=0;for(t=0;t<=143;)wO[2*t+1]=8,t++,A[8]++;for(;t<=255;)wO[2*t+1]=9,t++,A[9]++;for(;t<=279;)wO[2*t+1]=7,t++,A[7]++;for(;t<=287;)wO[2*t+1]=8,t++,A[8]++;for(MO(wO,287,A),t=0;t<uO;t++)vO[2*t+1]=5,vO[2*t]=kO(t,5);xO=new CO(wO,fO,257,hO,dO),EO=new CO(vO,pO,0,uO,dO),SO=new CO(new Array(0),gO,0,19,7)})(),WO=!0),t.l_desc=new FO(t.dyn_ltree,xO),t.d_desc=new FO(t.dyn_dtree,EO),t.bl_desc=new FO(t.bl_tree,SO),t.bi_buf=0,t.bi_valid=0,OO(t)},_tr_stored_block:VO,_tr_flush_block:(t,e,n,r)=>{let i,A,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<cO;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),RO(t,t.l_desc),RO(t,t.d_desc),s=(t=>{let e;for(HO(t,t.dyn_ltree,t.l_desc.max_code),HO(t,t.dyn_dtree,t.d_desc.max_code),RO(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*mO[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,A=t.static_len+3+7>>>3,A<=i&&(i=A)):i=A=n+5,n+4<=i&&-1!==e?VO(t,e,n,r):4===t.strategy||A===i?(IO(t,2+(r?1:0),3),DO(t,wO,vO)):(IO(t,4+(r?1:0),3),((t,e,n,r)=>{let i;for(IO(t,e-257,5),IO(t,n-1,5),IO(t,r-4,4),i=0;i<r;i++)IO(t,t.bl_tree[2*mO[i]+1],3);jO(t,t.dyn_ltree,e-1),jO(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),DO(t,t.dyn_ltree,t.dyn_dtree)),OO(t),r&&PO(t)},_tr_tally:(t,e,n)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=n,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(bO[n]+cO+1)]++,t.dyn_dtree[2*LO(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{IO(t,2,3),QO(t,256,wO),(t=>{16===t.bi_valid?(UO(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var GO=(t,e,n,r)=>{let i=65535&t,A=t>>>16&65535,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+e[r++]|0,A=A+i|0}while(--s);i%=65521,A%=65521}return i|A<<16};const zO=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());var qO=(t,e,n,r)=>{const i=zO,A=r+n;t^=-1;for(let s=r;s<A;s++)t=t>>>8^i[255&(t^e[s])];return-1^t},XO={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},YO={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:$O,_tr_stored_block:JO,_tr_flush_block:ZO,_tr_tally:tP,_tr_align:eP}=KO,{Z_NO_FLUSH:nP,Z_PARTIAL_FLUSH:rP,Z_FULL_FLUSH:iP,Z_FINISH:AP,Z_BLOCK:sP,Z_OK:aP,Z_STREAM_END:oP,Z_STREAM_ERROR:lP,Z_DATA_ERROR:cP,Z_BUF_ERROR:hP,Z_DEFAULT_COMPRESSION:uP,Z_FILTERED:dP,Z_HUFFMAN_ONLY:fP,Z_RLE:pP,Z_FIXED:gP,Z_DEFAULT_STRATEGY:mP,Z_UNKNOWN:wP,Z_DEFLATED:vP}=YO,yP=258,bP=262,BP=42,_P=113,CP=666,xP=(t,e)=>(t.msg=XO[e],e),EP=t=>2*t-(t>4?9:0),SP=t=>{let e=t.length;for(;--e>=0;)t[e]=0},FP=t=>{let e,n,r,i=t.w_size;e=t.hash_size,r=e;do{n=t.head[--r],t.head[r]=n>=i?n-i:0}while(--e);e=i,r=e;do{n=t.prev[--r],t.prev[r]=n>=i?n-i:0}while(--e)};let LP=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const UP=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},IP=(t,e)=>{ZO(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,UP(t.strm)},QP=(t,e)=>{t.pending_buf[t.pending++]=e},kP=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},MP=(t,e,n,r)=>{let i=t.avail_in;return i>r&&(i=r),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),n),1===t.state.wrap?t.adler=GO(t.adler,e,i,n):2===t.state.wrap&&(t.adler=qO(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)},OP=(t,e)=>{let n,r,i=t.max_chain_length,A=t.strstart,s=t.prev_length,a=t.nice_match;const o=t.strstart>t.w_size-bP?t.strstart-(t.w_size-bP):0,l=t.window,c=t.w_mask,h=t.prev,u=t.strstart+yP;let d=l[A+s-1],f=l[A+s];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(n=e,l[n+s]===f&&l[n+s-1]===d&&l[n]===l[A]&&l[++n]===l[A+1]){A+=2,n++;do{}while(l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&A<u);if(r=yP-(u-A),A=u-yP,r>s){if(t.match_start=e,s=r,r>=a)break;d=l[A+s-1],f=l[A+s]}}}while((e=h[e&c])>o&&0!==--i);return s<=t.lookahead?s:t.lookahead},PP=t=>{const e=t.w_size;let n,r,i;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-bP)&&(t.window.set(t.window.subarray(e,e+e-r),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),FP(t),r+=e),0===t.strm.avail_in)break;if(n=MP(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=n,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=LP(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=LP(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<bP&&0!==t.strm.avail_in)},NP=(t,e)=>{let n,r,i,A=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,s=0,a=t.strm.avail_in;do{if(n=65535,i=t.bi_valid+42>>3,t.strm.avail_out<i)break;if(i=t.strm.avail_out-i,r=t.strstart-t.block_start,n>r+t.strm.avail_in&&(n=r+t.strm.avail_in),n>i&&(n=i),n<A&&(0===n&&e!==AP||e===nP||n!==r+t.strm.avail_in))break;s=e===AP&&n===r+t.strm.avail_in?1:0,JO(t,0,0,s),t.pending_buf[t.pending-4]=n,t.pending_buf[t.pending-3]=n>>8,t.pending_buf[t.pending-2]=~n,t.pending_buf[t.pending-1]=~n>>8,UP(t.strm),r&&(r>n&&(r=n),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+r),t.strm.next_out),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r,t.block_start+=r,n-=r),n&&(MP(t.strm,t.strm.output,t.strm.next_out,n),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n)}while(0===s);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),s?4:e!==nP&&e!==AP&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(i=t.window_size-t.strstart,t.strm.avail_in>i&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&(MP(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water<t.strstart&&(t.high_water=t.strstart),i=t.bi_valid+42>>3,i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i,A=i>t.w_size?t.w_size:i,r=t.strstart-t.block_start,(r>=A||(r||e===AP)&&e!==nP&&0===t.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=e===AP&&0===t.strm.avail_in&&n===r?1:0,JO(t,t.block_start,n,s),t.block_start+=n,UP(t.strm)),s?3:1)},TP=(t,e)=>{let n,r;for(;;){if(t.lookahead<bP){if(PP(t),t.lookahead<bP&&e===nP)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=LP(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-bP&&(t.match_length=OP(t,n)),t.match_length>=3)if(r=tP(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=LP(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=LP(t,t.ins_h,t.window[t.strstart+1]);else r=tP(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(IP(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===AP?(IP(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IP(t,!1),0===t.strm.avail_out)?1:2},DP=(t,e)=>{let n,r,i;for(;;){if(t.lookahead<bP){if(PP(t),t.lookahead<bP&&e===nP)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=LP(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-bP&&(t.match_length=OP(t,n),t.match_length<=5&&(t.strategy===dP||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,r=tP(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=LP(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,r&&(IP(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(r=tP(t,0,t.window[t.strstart-1]),r&&IP(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=tP(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===AP?(IP(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IP(t,!1),0===t.strm.avail_out)?1:2};function RP(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}const HP=[new RP(0,0,0,0,NP),new RP(4,4,8,4,TP),new RP(4,5,16,8,TP),new RP(4,6,32,32,TP),new RP(4,4,16,16,DP),new RP(8,16,32,32,DP),new RP(8,16,128,128,DP),new RP(8,32,128,256,DP),new RP(32,128,258,1024,DP),new RP(32,258,258,4096,DP)];function jP(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=vP,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),SP(this.dyn_ltree),SP(this.dyn_dtree),SP(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),SP(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),SP(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const WP=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==BP&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==_P&&e.status!==CP?1:0},VP=t=>{if(WP(t))return xP(t,lP);t.total_in=t.total_out=0,t.data_type=wP;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?BP:_P,t.adler=2===e.wrap?0:1,e.last_flush=-2,$O(e),aP},KP=t=>{const e=VP(t);var n;return e===aP&&((n=t.state).window_size=2*n.w_size,SP(n.head),n.max_lazy_match=HP[n.level].max_lazy,n.good_match=HP[n.level].good_length,n.nice_match=HP[n.level].nice_length,n.max_chain_length=HP[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),e},GP=(t,e,n,r,i,A)=>{if(!t)return lP;let s=1;if(e===uP&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==vP||r<8||r>15||e<0||e>9||A<0||A>gP||8===r&&1!==s)return xP(t,lP);8===r&&(r=9);const a=new jP;return t.state=a,a.strm=t,a.status=BP,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=A,a.method=n,KP(t)};var zP={deflateInit:(t,e)=>GP(t,e,vP,15,8,mP),deflateInit2:GP,deflateReset:KP,deflateResetKeep:VP,deflateSetHeader:(t,e)=>WP(t)||2!==t.state.wrap?lP:(t.state.gzhead=e,aP),deflate:(t,e)=>{if(WP(t)||e>sP||e<0)return t?xP(t,lP):lP;const n=t.state;if(!t.output||0!==t.avail_in&&!t.input||n.status===CP&&e!==AP)return xP(t,0===t.avail_out?hP:lP);const r=n.last_flush;if(n.last_flush=e,0!==n.pending){if(UP(t),0===t.avail_out)return n.last_flush=-1,aP}else if(0===t.avail_in&&EP(e)<=EP(r)&&e!==AP)return xP(t,hP);if(n.status===CP&&0!==t.avail_in)return xP(t,hP);if(n.status===BP&&0===n.wrap&&(n.status=_P),n.status===BP){let e=vP+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=fP||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=r<<6,0!==n.strstart&&(e|=32),e+=31-e%31,kP(n,e),0!==n.strstart&&(kP(n,t.adler>>>16),kP(n,65535&t.adler)),t.adler=1,n.status=_P,UP(t),0!==n.pending)return n.last_flush=-1,aP}if(57===n.status)if(t.adler=0,QP(n,31),QP(n,139),QP(n,8),n.gzhead)QP(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),QP(n,255&n.gzhead.time),QP(n,n.gzhead.time>>8&255),QP(n,n.gzhead.time>>16&255),QP(n,n.gzhead.time>>24&255),QP(n,9===n.level?2:n.strategy>=fP||n.level<2?4:0),QP(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(QP(n,255&n.gzhead.extra.length),QP(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=qO(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(QP(n,0),QP(n,0),QP(n,0),QP(n,0),QP(n,0),QP(n,9===n.level?2:n.strategy>=fP||n.level<2?4:0),QP(n,3),n.status=_P,UP(t),0!==n.pending)return n.last_flush=-1,aP;if(69===n.status){if(n.gzhead.extra){let e=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>e&&(t.adler=qO(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex+=i,UP(t),0!==n.pending)return n.last_flush=-1,aP;e=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>e&&(t.adler=qO(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let e,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(t.adler=qO(t.adler,n.pending_buf,n.pending-r,r)),UP(t),0!==n.pending)return n.last_flush=-1,aP;r=0}e=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,QP(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>r&&(t.adler=qO(t.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let e,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(t.adler=qO(t.adler,n.pending_buf,n.pending-r,r)),UP(t),0!==n.pending)return n.last_flush=-1,aP;r=0}e=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,QP(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>r&&(t.adler=qO(t.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(UP(t),0!==n.pending))return n.last_flush=-1,aP;QP(n,255&t.adler),QP(n,t.adler>>8&255),t.adler=0}if(n.status=_P,UP(t),0!==n.pending)return n.last_flush=-1,aP}if(0!==t.avail_in||0!==n.lookahead||e!==nP&&n.status!==CP){let r=0===n.level?NP(n,e):n.strategy===fP?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(PP(t),0===t.lookahead)){if(e===nP)return 1;break}if(t.match_length=0,n=tP(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(IP(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===AP?(IP(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IP(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===pP?((t,e)=>{let n,r,i,A;const s=t.window;for(;;){if(t.lookahead<=yP){if(PP(t),t.lookahead<=yP&&e===nP)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){A=t.strstart+yP;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&i<A);t.match_length=yP-(A-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=tP(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=tP(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(IP(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===AP?(IP(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IP(t,!1),0===t.strm.avail_out)?1:2})(n,e):HP[n.level].func(n,e);if(3!==r&&4!==r||(n.status=CP),1===r||3===r)return 0===t.avail_out&&(n.last_flush=-1),aP;if(2===r&&(e===rP?eP(n):e!==sP&&(JO(n,0,0,!1),e===iP&&(SP(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),UP(t),0===t.avail_out))return n.last_flush=-1,aP}return e!==AP?aP:n.wrap<=0?oP:(2===n.wrap?(QP(n,255&t.adler),QP(n,t.adler>>8&255),QP(n,t.adler>>16&255),QP(n,t.adler>>24&255),QP(n,255&t.total_in),QP(n,t.total_in>>8&255),QP(n,t.total_in>>16&255),QP(n,t.total_in>>24&255)):(kP(n,t.adler>>>16),kP(n,65535&t.adler)),UP(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?aP:oP)},deflateEnd:t=>{if(WP(t))return lP;const e=t.state.status;return t.state=null,e===_P?xP(t,cP):aP},deflateSetDictionary:(t,e)=>{let n=e.length;if(WP(t))return lP;const r=t.state,i=r.wrap;if(2===i||1===i&&r.status!==BP||r.lookahead)return lP;if(1===i&&(t.adler=GO(t.adler,e,n,0)),r.wrap=0,n>=r.w_size){0===i&&(SP(r.head),r.strstart=0,r.block_start=0,r.insert=0);let t=new Uint8Array(r.w_size);t.set(e.subarray(n-r.w_size,n),0),e=t,n=r.w_size}const A=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,PP(r);r.lookahead>=3;){let t=r.strstart,e=r.lookahead-2;do{r.ins_h=LP(r,r.ins_h,r.window[t+3-1]),r.prev[t&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=t,t++}while(--e);r.strstart=t,r.lookahead=2,PP(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=s,t.input=a,t.avail_in=A,r.wrap=i,aP},deflateInfo:"pako deflate (from Nodeca project)"};const qP=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var XP=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)qP(n,e)&&(t[e]=n[e])}}return t},YP=t=>{let e=0;for(let r=0,i=t.length;r<i;r++)e+=t[r].length;const n=new Uint8Array(e);for(let r=0,i=0,A=t.length;r<A;r++){let e=t[r];n.set(e,i),i+=e.length}return n};let $P=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(l3){$P=!1}const JP=new Uint8Array(256);for(let c3=0;c3<256;c3++)JP[c3]=c3>=252?6:c3>=248?5:c3>=240?4:c3>=224?3:c3>=192?2:1;JP[254]=JP[254]=1;var ZP=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,r,i,A,s=t.length,a=0;for(i=0;i<s;i++)n=t.charCodeAt(i),55296==(64512&n)&&i+1<s&&(r=t.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(a),A=0,i=0;A<a;i++)n=t.charCodeAt(i),55296==(64512&n)&&i+1<s&&(r=t.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?e[A++]=n:n<2048?(e[A++]=192|n>>>6,e[A++]=128|63&n):n<65536?(e[A++]=224|n>>>12,e[A++]=128|n>>>6&63,e[A++]=128|63&n):(e[A++]=240|n>>>18,e[A++]=128|n>>>12&63,e[A++]=128|n>>>6&63,e[A++]=128|63&n);return e},tN=(t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let r,i;const A=new Array(2*n);for(i=0,r=0;r<n;){let e=t[r++];if(e<128){A[i++]=e;continue}let s=JP[e];if(s>4)A[i++]=65533,r+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&r<n;)e=e<<6|63&t[r++],s--;s>1?A[i++]=65533:e<65536?A[i++]=e:(e-=65536,A[i++]=55296|e>>10&1023,A[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&$P)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let r=0;r<e;r++)n+=String.fromCharCode(t[r]);return n})(A,i)},eN=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+JP[t[n]]>e?n:e};var nN=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const rN=Object.prototype.toString,{Z_NO_FLUSH:iN,Z_SYNC_FLUSH:AN,Z_FULL_FLUSH:sN,Z_FINISH:aN,Z_OK:oN,Z_STREAM_END:lN,Z_DEFAULT_COMPRESSION:cN,Z_DEFAULT_STRATEGY:hN,Z_DEFLATED:uN}=YO;function dN(t){this.options=XP({level:cN,method:uN,chunkSize:16384,windowBits:15,memLevel:8,strategy:hN},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new nN,this.strm.avail_out=0;let n=zP.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==oN)throw new Error(XO[n]);if(e.header&&zP.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?ZP(e.dictionary):"[object ArrayBuffer]"===rN.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=zP.deflateSetDictionary(this.strm,t),n!==oN)throw new Error(XO[n]);this._dict_set=!0}}function fN(t,e){const n=new dN(e);if(n.push(t,!0),n.err)throw n.msg||XO[n.err];return n.result}dN.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize;let i,A;if(this.ended)return!1;for(A=e===~~e?e:!0===e?aN:iN,"string"==typeof t?n.input=ZP(t):"[object ArrayBuffer]"===rN.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(A===AN||A===sN)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=zP.deflate(n,A),i===lN)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=zP.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===oN;if(0!==n.avail_out){if(A>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},dN.prototype.onData=function(t){this.chunks.push(t)},dN.prototype.onEnd=function(t){t===oN&&(this.result=YP(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var pN={Deflate:dN,deflate:fN,deflateRaw:function(t,e){return(e=e||{}).raw=!0,fN(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,fN(t,e)}};const gN=16209;var mN=function(t,e){let n,r,i,A,s,a,o,l,c,h,u,d,f,p,g,m,w,v,y,b,B,_,C,x;const E=t.state;n=t.next_in,C=t.input,r=n+(t.avail_in-5),i=t.next_out,x=t.output,A=i-(e-t.avail_out),s=i+(t.avail_out-257),a=E.dmax,o=E.wsize,l=E.whave,c=E.wnext,h=E.window,u=E.hold,d=E.bits,f=E.lencode,p=E.distcode,g=(1<<E.lenbits)-1,m=(1<<E.distbits)-1;t:do{d<15&&(u+=C[n++]<<d,d+=8,u+=C[n++]<<d,d+=8),w=f[u&g];e:for(;;){if(v=w>>>24,u>>>=v,d-=v,v=w>>>16&255,0===v)x[i++]=65535&w;else{if(!(16&v)){if(64&v){if(32&v){E.mode=16191;break t}t.msg="invalid literal/length code",E.mode=gN;break t}w=f[(65535&w)+(u&(1<<v)-1)];continue e}for(y=65535&w,v&=15,v&&(d<v&&(u+=C[n++]<<d,d+=8),y+=u&(1<<v)-1,u>>>=v,d-=v),d<15&&(u+=C[n++]<<d,d+=8,u+=C[n++]<<d,d+=8),w=p[u&m];;){if(v=w>>>24,u>>>=v,d-=v,v=w>>>16&255,16&v){if(b=65535&w,v&=15,d<v&&(u+=C[n++]<<d,d+=8,d<v&&(u+=C[n++]<<d,d+=8)),b+=u&(1<<v)-1,b>a){t.msg="invalid distance too far back",E.mode=gN;break t}if(u>>>=v,d-=v,v=i-A,b>v){if(v=b-v,v>l&&E.sane){t.msg="invalid distance too far back",E.mode=gN;break t}if(B=0,_=h,0===c){if(B+=o-v,v<y){y-=v;do{x[i++]=h[B++]}while(--v);B=i-b,_=x}}else if(c<v){if(B+=o+c-v,v-=c,v<y){y-=v;do{x[i++]=h[B++]}while(--v);if(B=0,c<y){v=c,y-=v;do{x[i++]=h[B++]}while(--v);B=i-b,_=x}}}else if(B+=c-v,v<y){y-=v;do{x[i++]=h[B++]}while(--v);B=i-b,_=x}for(;y>2;)x[i++]=_[B++],x[i++]=_[B++],x[i++]=_[B++],y-=3;y&&(x[i++]=_[B++],y>1&&(x[i++]=_[B++]))}else{B=i-b;do{x[i++]=x[B++],x[i++]=x[B++],x[i++]=x[B++],y-=3}while(y>2);y&&(x[i++]=x[B++],y>1&&(x[i++]=x[B++]))}break}if(64&v){t.msg="invalid distance code",E.mode=gN;break t}w=p[(65535&w)+(u&(1<<v)-1)]}}break}}while(n<r&&i<s);y=d>>3,n-=y,d-=y<<3,u&=(1<<d)-1,t.next_in=n,t.next_out=i,t.avail_in=n<r?r-n+5:5-(n-r),t.avail_out=i<s?s-i+257:257-(i-s),E.hold=u,E.bits=d};const wN=15,vN=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),yN=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),bN=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),BN=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var _N=(t,e,n,r,i,A,s,a)=>{const o=a.bits;let l,c,h,u,d,f,p=0,g=0,m=0,w=0,v=0,y=0,b=0,B=0,_=0,C=0,x=null;const E=new Uint16Array(16),S=new Uint16Array(16);let F,L,U,I=null;for(p=0;p<=wN;p++)E[p]=0;for(g=0;g<r;g++)E[e[n+g]]++;for(v=o,w=wN;w>=1&&0===E[w];w--);if(v>w&&(v=w),0===w)return i[A++]=20971520,i[A++]=20971520,a.bits=1,0;for(m=1;m<w&&0===E[m];m++);for(v<m&&(v=m),B=1,p=1;p<=wN;p++)if(B<<=1,B-=E[p],B<0)return-1;if(B>0&&(0===t||1!==w))return-1;for(S[1]=0,p=1;p<wN;p++)S[p+1]=S[p]+E[p];for(g=0;g<r;g++)0!==e[n+g]&&(s[S[e[n+g]]++]=g);if(0===t?(x=I=s,f=20):1===t?(x=vN,I=yN,f=257):(x=bN,I=BN,f=0),C=0,g=0,p=m,d=A,y=v,b=0,h=-1,_=1<<v,u=_-1,1===t&&_>852||2===t&&_>592)return 1;for(;;){F=p-b,s[g]+1<f?(L=0,U=s[g]):s[g]>=f?(L=I[s[g]-f],U=x[s[g]-f]):(L=96,U=0),l=1<<p-b,c=1<<y,m=c;do{c-=l,i[d+(C>>b)+c]=F<<24|L<<16|U}while(0!==c);for(l=1<<p-1;C&l;)l>>=1;if(0!==l?(C&=l-1,C+=l):C=0,g++,0===--E[p]){if(p===w)break;p=e[n+s[g]]}if(p>v&&(C&u)!==h){for(0===b&&(b=v),d+=m,y=p-b,B=1<<y;y+b<w&&(B-=E[y+b],!(B<=0));)y++,B<<=1;if(_+=1<<y,1===t&&_>852||2===t&&_>592)return 1;h=C&u,i[h]=v<<24|y<<16|d-A}}return 0!==C&&(i[d+C]=p-b<<24|64<<16),a.bits=v,0};const{Z_FINISH:CN,Z_BLOCK:xN,Z_TREES:EN,Z_OK:SN,Z_STREAM_END:FN,Z_NEED_DICT:LN,Z_STREAM_ERROR:UN,Z_DATA_ERROR:IN,Z_MEM_ERROR:QN,Z_BUF_ERROR:kN,Z_DEFLATED:MN}=YO,ON=16180,PN=16190,NN=16191,TN=16192,DN=16194,RN=16199,HN=16200,jN=16206,WN=16209,VN=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function KN(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const GN=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<ON||e.mode>16211?1:0},zN=t=>{if(GN(t))return UN;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=ON,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,SN},qN=t=>{if(GN(t))return UN;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,zN(t)},XN=(t,e)=>{let n;if(GN(t))return UN;const r=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?UN:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,qN(t))},YN=(t,e)=>{if(!t)return UN;const n=new KN;t.state=n,n.strm=t,n.window=null,n.mode=ON;const r=XN(t,e);return r!==SN&&(t.state=null),r};let $N,JN,ZN=!0;const tT=t=>{if(ZN){$N=new Int32Array(512),JN=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(_N(1,t.lens,0,288,$N,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;_N(2,t.lens,0,32,JN,0,t.work,{bits:5}),ZN=!1}t.lencode=$N,t.lenbits=9,t.distcode=JN,t.distbits=5},eT=(t,e,n,r)=>{let i;const A=t.state;return null===A.window&&(A.wsize=1<<A.wbits,A.wnext=0,A.whave=0,A.window=new Uint8Array(A.wsize)),r>=A.wsize?(A.window.set(e.subarray(n-A.wsize,n),0),A.wnext=0,A.whave=A.wsize):(i=A.wsize-A.wnext,i>r&&(i=r),A.window.set(e.subarray(n-r,n-r+i),A.wnext),(r-=i)?(A.window.set(e.subarray(n-r,n),0),A.wnext=r,A.whave=A.wsize):(A.wnext+=i,A.wnext===A.wsize&&(A.wnext=0),A.whave<A.wsize&&(A.whave+=i))),0};var nT={inflateReset:qN,inflateReset2:XN,inflateResetKeep:zN,inflateInit:t=>YN(t,15),inflateInit2:YN,inflate:(t,e)=>{let n,r,i,A,s,a,o,l,c,h,u,d,f,p,g,m,w,v,y,b,B,_,C=0;const x=new Uint8Array(4);let E,S;const F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(GN(t)||!t.output||!t.input&&0!==t.avail_in)return UN;n=t.state,n.mode===NN&&(n.mode=TN),s=t.next_out,i=t.output,o=t.avail_out,A=t.next_in,r=t.input,a=t.avail_in,l=n.hold,c=n.bits,h=a,u=o,_=SN;t:for(;;)switch(n.mode){case ON:if(0===n.wrap){n.mode=TN;break}for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(2&n.wrap&&35615===l){0===n.wbits&&(n.wbits=15),n.check=0,x[0]=255&l,x[1]=l>>>8&255,n.check=qO(n.check,x,2,0),l=0,c=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",n.mode=WN;break}if((15&l)!==MN){t.msg="unknown compression method",n.mode=WN;break}if(l>>>=4,c-=4,B=8+(15&l),0===n.wbits&&(n.wbits=B),B>15||B>n.wbits){t.msg="invalid window size",n.mode=WN;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&l?16189:NN,l=0,c=0;break;case 16181:for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(n.flags=l,(255&n.flags)!==MN){t.msg="unknown compression method",n.mode=WN;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=WN;break}n.head&&(n.head.text=l>>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&l,x[1]=l>>>8&255,n.check=qO(n.check,x,2,0)),l=0,c=0,n.mode=16182;case 16182:for(;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.head&&(n.head.time=l),512&n.flags&&4&n.wrap&&(x[0]=255&l,x[1]=l>>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,n.check=qO(n.check,x,4,0)),l=0,c=0,n.mode=16183;case 16183:for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.head&&(n.head.xflags=255&l,n.head.os=l>>8),512&n.flags&&4&n.wrap&&(x[0]=255&l,x[1]=l>>>8&255,n.check=qO(n.check,x,2,0)),l=0,c=0,n.mode=16184;case 16184:if(1024&n.flags){for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.length=l,n.head&&(n.head.extra_len=l),512&n.flags&&4&n.wrap&&(x[0]=255&l,x[1]=l>>>8&255,n.check=qO(n.check,x,2,0)),l=0,c=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(d=n.length,d>a&&(d=a),d&&(n.head&&(B=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(A,A+d),B)),512&n.flags&&4&n.wrap&&(n.check=qO(n.check,r,d,A)),a-=d,A+=d,n.length-=d),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break t;d=0;do{B=r[A+d++],n.head&&B&&n.length<65536&&(n.head.name+=String.fromCharCode(B))}while(B&&d<a);if(512&n.flags&&4&n.wrap&&(n.check=qO(n.check,r,d,A)),a-=d,A+=d,B)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===a)break t;d=0;do{B=r[A+d++],n.head&&B&&n.length<65536&&(n.head.comment+=String.fromCharCode(B))}while(B&&d<a);if(512&n.flags&&4&n.wrap&&(n.check=qO(n.check,r,d,A)),a-=d,A+=d,B)break t}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(4&n.wrap&&l!==(65535&n.check)){t.msg="header crc mismatch",n.mode=WN;break}l=0,c=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=NN;break;case 16189:for(;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}t.adler=n.check=VN(l),l=0,c=0,n.mode=PN;case PN:if(0===n.havedict)return t.next_out=s,t.avail_out=o,t.next_in=A,t.avail_in=a,n.hold=l,n.bits=c,LN;t.adler=n.check=1,n.mode=NN;case NN:if(e===xN||e===EN)break t;case TN:if(n.last){l>>>=7&c,c-=7&c,n.mode=jN;break}for(;c<3;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}switch(n.last=1&l,l>>>=1,c-=1,3&l){case 0:n.mode=16193;break;case 1:if(tT(n),n.mode=RN,e===EN){l>>>=2,c-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=WN}l>>>=2,c-=2;break;case 16193:for(l>>>=7&c,c-=7&c;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",n.mode=WN;break}if(n.length=65535&l,l=0,c=0,n.mode=DN,e===EN)break t;case DN:n.mode=16195;case 16195:if(d=n.length,d){if(d>a&&(d=a),d>o&&(d=o),0===d)break t;i.set(r.subarray(A,A+d),s),a-=d,A+=d,o-=d,s+=d,n.length-=d;break}n.mode=NN;break;case 16196:for(;c<14;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(n.nlen=257+(31&l),l>>>=5,c-=5,n.ndist=1+(31&l),l>>>=5,c-=5,n.ncode=4+(15&l),l>>>=4,c-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=WN;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;c<3;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.lens[F[n.have++]]=7&l,l>>>=3,c-=3}for(;n.have<19;)n.lens[F[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},_=_N(0,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid code lengths set",n.mode=WN;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;C=n.lencode[l&(1<<n.lenbits)-1],g=C>>>24,m=C>>>16&255,w=65535&C,!(g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(w<16)l>>>=g,c-=g,n.lens[n.have++]=w;else{if(16===w){for(S=g+2;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(l>>>=g,c-=g,0===n.have){t.msg="invalid bit length repeat",n.mode=WN;break}B=n.lens[n.have-1],d=3+(3&l),l>>>=2,c-=2}else if(17===w){for(S=g+3;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}l>>>=g,c-=g,B=0,d=3+(7&l),l>>>=3,c-=3}else{for(S=g+7;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}l>>>=g,c-=g,B=0,d=11+(127&l),l>>>=7,c-=7}if(n.have+d>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=WN;break}for(;d--;)n.lens[n.have++]=B}}if(n.mode===WN)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=WN;break}if(n.lenbits=9,E={bits:n.lenbits},_=_N(1,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid literal/lengths set",n.mode=WN;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},_=_N(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,_){t.msg="invalid distances set",n.mode=WN;break}if(n.mode=RN,e===EN)break t;case RN:n.mode=HN;case HN:if(a>=6&&o>=258){t.next_out=s,t.avail_out=o,t.next_in=A,t.avail_in=a,n.hold=l,n.bits=c,mN(t,u),s=t.next_out,i=t.output,o=t.avail_out,A=t.next_in,r=t.input,a=t.avail_in,l=n.hold,c=n.bits,n.mode===NN&&(n.back=-1);break}for(n.back=0;C=n.lencode[l&(1<<n.lenbits)-1],g=C>>>24,m=C>>>16&255,w=65535&C,!(g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(m&&!(240&m)){for(v=g,y=m,b=w;C=n.lencode[b+((l&(1<<v+y)-1)>>v)],g=C>>>24,m=C>>>16&255,w=65535&C,!(v+g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}l>>>=v,c-=v,n.back+=v}if(l>>>=g,c-=g,n.back+=g,n.length=w,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=NN;break}if(64&m){t.msg="invalid literal/length code",n.mode=WN;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,c-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;C=n.distcode[l&(1<<n.distbits)-1],g=C>>>24,m=C>>>16&255,w=65535&C,!(g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(!(240&m)){for(v=g,y=m,b=w;C=n.distcode[b+((l&(1<<v+y)-1)>>v)],g=C>>>24,m=C>>>16&255,w=65535&C,!(v+g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}l>>>=v,c-=v,n.back+=v}if(l>>>=g,c-=g,n.back+=g,64&m){t.msg="invalid distance code",n.mode=WN;break}n.offset=w,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,c-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=WN;break}n.mode=16204;case 16204:if(0===o)break t;if(d=u-o,n.offset>d){if(d=n.offset-d,d>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=WN;break}d>n.wnext?(d-=n.wnext,f=n.wsize-d):f=n.wnext-d,d>n.length&&(d=n.length),p=n.window}else p=i,f=s-n.offset,d=n.length;d>o&&(d=o),o-=d,n.length-=d;do{i[s++]=p[f++]}while(--d);0===n.length&&(n.mode=HN);break;case 16205:if(0===o)break t;i[s++]=n.length,o--,n.mode=HN;break;case jN:if(n.wrap){for(;c<32;){if(0===a)break t;a--,l|=r[A++]<<c,c+=8}if(u-=o,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?qO(n.check,i,u,s-u):GO(n.check,i,u,s-u)),u=o,4&n.wrap&&(n.flags?l:VN(l))!==n.check){t.msg="incorrect data check",n.mode=WN;break}l=0,c=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(4&n.wrap&&l!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=WN;break}l=0,c=0}n.mode=16208;case 16208:_=FN;break t;case WN:_=IN;break t;case 16210:return QN;default:return UN}return t.next_out=s,t.avail_out=o,t.next_in=A,t.avail_in=a,n.hold=l,n.bits=c,(n.wsize||u!==t.avail_out&&n.mode<WN&&(n.mode<jN||e!==CN))&&eT(t,t.output,t.next_out,u-t.avail_out),h-=t.avail_in,u-=t.avail_out,t.total_in+=h,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?qO(n.check,i,u,t.next_out-u):GO(n.check,i,u,t.next_out-u)),t.data_type=n.bits+(n.last?64:0)+(n.mode===NN?128:0)+(n.mode===RN||n.mode===DN?256:0),(0===h&&0===u||e===CN)&&_===SN&&(_=kN),_},inflateEnd:t=>{if(GN(t))return UN;let e=t.state;return e.window&&(e.window=null),t.state=null,SN},inflateGetHeader:(t,e)=>{if(GN(t))return UN;const n=t.state;return 2&n.wrap?(n.head=e,e.done=!1,SN):UN},inflateSetDictionary:(t,e)=>{const n=e.length;let r,i,A;return GN(t)?UN:(r=t.state,0!==r.wrap&&r.mode!==PN?UN:r.mode===PN&&(i=1,i=GO(i,e,n,0),i!==r.check)?IN:(A=eT(t,e,n,n),A?(r.mode=16210,QN):(r.havedict=1,SN)))},inflateInfo:"pako inflate (from Nodeca project)"};var rT=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const iT=Object.prototype.toString,{Z_NO_FLUSH:AT,Z_FINISH:sT,Z_OK:aT,Z_STREAM_END:oT,Z_NEED_DICT:lT,Z_STREAM_ERROR:cT,Z_DATA_ERROR:hT,Z_MEM_ERROR:uT}=YO;function dT(t){this.options=XP({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new nN,this.strm.avail_out=0;let n=nT.inflateInit2(this.strm,e.windowBits);if(n!==aT)throw new Error(XO[n]);if(this.header=new rT,nT.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=ZP(e.dictionary):"[object ArrayBuffer]"===iT.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=nT.inflateSetDictionary(this.strm,e.dictionary),n!==aT)))throw new Error(XO[n])}function fT(t,e){const n=new dT(e);if(n.push(t),n.err)throw n.msg||XO[n.err];return n.result}dT.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let A,s,a;if(this.ended)return!1;for(s=e===~~e?e:!0===e?sT:AT,"[object ArrayBuffer]"===iT.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),A=nT.inflate(n,s),A===lT&&i&&(A=nT.inflateSetDictionary(n,i),A===aT?A=nT.inflate(n,s):A===hT&&(A=lT));n.avail_in>0&&A===oT&&n.state.wrap>0&&0!==t[n.next_in];)nT.inflateReset(n),A=nT.inflate(n,s);switch(A){case cT:case hT:case lT:case uT:return this.onEnd(A),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||A===oT))if("string"===this.options.to){let t=eN(n.output,n.next_out),e=n.next_out-t,i=tN(n.output,t);n.next_out=e,n.avail_out=r-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(A!==aT||0!==a){if(A===oT)return A=nT.inflateEnd(this.strm),this.onEnd(A),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},dT.prototype.onData=function(t){this.chunks.push(t)},dT.prototype.onEnd=function(t){t===aT&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=YP(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var pT={Inflate:dT,inflate:fT,inflateRaw:function(t,e){return(e=e||{}).raw=!0,fT(t,e)},ungzip:fT};const{Deflate:gT,deflate:mT,deflateRaw:wT,gzip:vT}=pN,{Inflate:yT,inflate:bT,inflateRaw:BT,ungzip:_T}=pT;var CT={Deflate:gT,deflate:mT,deflateRaw:wT,gzip:vT,Inflate:yT,inflate:bT,inflateRaw:BT,ungzip:_T,constants:YO};tk.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/5.4.54/pdf.worker.min.mjs";const xT=(t,...e)=>Wc(this,[t,...e],function*(t,e={}){const{scale:n=1.5,format:r="image/png"}=e;try{let e;if(t instanceof ArrayBuffer)e=t;else{if(!Buffer.isBuffer(t))throw new Error("Formato de PDF inválido");e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const i=Qk(e),A=yield i.promise,s=A.numPages,a=[];console.log(`🔄 Convertendo PDF para imagens: ${s} páginas`);for(let t=1;t<=s;t++){const e=yield A.getPage(t),i=e.getViewport({scale:n}),o=document.createElement("canvas"),l=o.getContext("2d");o.height=i.height,o.width=i.width,yield e.render({canvasContext:l,viewport:i}).promise,a.push(o.toDataURL(r)),console.log(`✅ Página ${t}/${s} convertida`)}return a}catch(o3){throw console.error("❌ Erro ao converter PDF para imagens:",o3),o3}}),ET=()=>Wc(this,null,function*(){try{return 200===(yield e.get("http://localhost:9999/health",{timeout:3e3})).status}catch(o3){return console.log("🖨️ Impressora não detectada:",o3.message),!1}}),ST=(t,...n)=>Wc(this,[t,...n],function*(t,n={}){try{const r={images:t,metadata:Qc({timestamp:(new Date).toISOString()},n)},i=JSON.stringify(r),A=CT.gzip(i);console.log(`🖨️ Enviando ${t.length} imagens para impressão...`);const s=yield e.post("http://localhost:9999/print/multiple/png-to-zpl",A,{headers:{"Content-Type":"application/gzip","Content-Encoding":"gzip"},timeout:3e4});return console.log("✅ Etiquetas enviadas para impressão com sucesso"),{success:!0,printed:!0,response:s.data,message:"Etiquetas enviadas para impressão com sucesso"}}catch(o3){throw console.error("❌ Erro ao enviar para impressão:",o3),o3}}),FT=(t,e="etiqueta.pdf")=>Wc(this,null,function*(){try{return yield Yc(t,e),console.log("📥 PDF baixado automaticamente:",e),{success:!0,downloaded:!0,fileName:e,message:"PDF baixado automaticamente - nenhuma impressora detectada"}}catch(o3){throw console.error("❌ Erro ao baixar PDF:",o3),o3}}),LT=(t,...e)=>Wc(this,[t,...e],function*(t,e={}){try{const{filename:r="etiqueta.pdf",metadata:i={},scale:A=1.5,autoDownloadOnError:s=!0}=e;console.log("🖨️ Iniciando processo de impressão...");if(!(yield ET()))return console.log("🖨️ Nenhuma impressora detectada. Baixando PDF automaticamente..."),yield FT(t,r);try{const e=yield xT(t,{scale:A});return yield ST(e,i)}catch(n){if(console.error("❌ Erro na conversão ou impressão:",n),s)return console.log("📥 Fazendo download do PDF como alternativa..."),kc(Qc({},yield FT(t,r)),{error:n.message,message:"Falha na impressão - PDF baixado como alternativa"});throw n}}catch(o3){return console.error("❌ Erro geral no processo de impressão:",o3),{success:!1,error:o3.message,message:"Falha no processo de impressão"}}});let UT,IT,QT;const kT=()=>{if(!Gc)throw new Error("Este módulo funciona apenas no browser");const t=Xc();UT=t.window,IT=t.document,UT.Image,QT=UT.btoa,UT.XMLSerializer;let e=IT.getElementById("label-container");e||(e=IT.createElement("div"),e.id="label-container",e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",IT.body.appendChild(e))};Gc&&kT();const MT={NO_MATERIAL:"black",MATERIAL_NOT_MATCHED:"#FF0000",MATERIAL_MATCHED:"#0f45d8"};function OT(t,e){for(var n in t=IT.createElementNS("http://www.w3.org/2000/svg",t),e)t.setAttributeNS(null,n.replace(/[A-Z]/g,function(t,e,n,r){return"-"+t.toLowerCase()}),e[n]);return t}const PT=(t,e)=>{const n={w:e.width/t.width,h:e.height/t.height};return{get ratio(){return n.w<n.h?n.w:n.h}}},NT=(t,e,n,r,i,A,s,a,o)=>{t.setLineWidth(.5),TT(t,e,n,e,i+n,A),TT(t,e+r,n,e+r,i+n,s),TT(t,e,n,e+r,n,o),TT(t,e,n+i,e+r,n+i,a)},TT=(t,e,n,r,i,A)=>{A&&(t.setDrawColor(A),t.line(e,n,r,i))},DT=(t,e)=>t&&"0"!==t?t===e?MT.MATERIAL_MATCHED:MT.MATERIAL_NOT_MATCHED:MT.NO_MATERIAL,RT=e.create({baseURL:"https://db33.dev.dinabox.net/api",timeout:1e4,headers:{"Content-Type":"application/json",Accept:"application/json"}}),HT={PART:"part",SCRAP:"scrap",THICKENED:"thickened",INPUT:"input",VOLUME:"volume"};RT.interceptors.response.use(t=>t,t=>{var e;return console.error("Erro na API:",(null==(e=t.response)?void 0:e.data)||t.message),Promise.reject(t)});const jT=t=>Wc(this,null,function*(){return console.warn("LabelsAPI não carregado - usando placeholder"),null});const WT=TL((t,e)=>Qc(Qc({},(t=>({printerStatus:{name:"Aguardando...",connected:!1,status:"disconnected",hasDefaultPrinter:!1,message:"Conectando ao servidor...",printer:null},setPrinterStatus:e=>t(()=>({printerStatus:e})),updatePrinterStatus:e=>t(t=>({printerStatus:Qc(Qc({},t.printerStatus),e)}))}))(t)),((t,e)=>({sseConnected:!1,eventSource:null,setSseConnected:e=>t(()=>({sseConnected:e})),setEventSource:e=>t(()=>({eventSource:e})),connectToSSE:()=>{const{eventSource:t,setSseConnected:n,updatePrinterStatus:r,setEventSource:i}=e();if("undefined"==typeof EventSource)return console.log("EventSource não disponível em ambiente Node.js"),n(!1),void r({connected:!1,status:"disconnected"});t&&t.close();try{const t=new EventSource("http://localhost:9999/printer/status/stream");i(t),t.onopen=()=>{console.log("Conexão SSE estabelecida com a impressora"),n(!0),r({status:"connecting"})},t.addEventListener("printer-status",t=>{var e;try{const n=JSON.parse(t.data);console.log("message =>>>>>>>>>",n);let i="disconnected",A="Nenhuma impressora";n.hasDefaultPrinter?n.isConnected&&n.printer?(i="connected",A=n.printer.name||"Impressora"):(i="disconnected",A=(null==(e=n.printer)?void 0:e.name)||"Impressora"):(i="no-printer",A="Sem impressora configurada"),r({name:A,connected:n.isConnected||!1,status:i,hasDefaultPrinter:n.hasDefaultPrinter||!1,message:n.message||"",printer:n.printer||null})}catch(o3){console.error("Erro ao processar dados da impressora:",o3)}}),t.onerror=A=>{console.error("Erro na conexão SSE:",A),n(!1),r({connected:!1,status:"disconnected"}),t.close(),i(null),setTimeout(()=>{e().connectToSSE()},5e3)}}catch(o3){console.error("Erro ao conectar SSE:",o3),n(!1),r({connected:!1,status:"disconnected"})}},disconnectSSE:()=>{const{eventSource:t,setSseConnected:n,setEventSource:r}=e();t&&(t.close(),r(null)),n(!1)}}))(t,e))),VT=(t,e)=>{if(!t||"object"!=typeof t)return t;const n=Qc({},t);for(const[r,i]of Object.entries(e)){switch(typeof i){case"string":void 0!==t[i]&&(n[r]=t[i]);break;case"object":if(Array.isArray(i)){const e=t[r.toLowerCase()];"number"==typeof e&&e>=0&&e<i.length&&(n[r]=i[e])}break;case"function":const e=i(t);void 0!==e&&(n[r]=e)}}return n},KT=t=>{if(!t||"object"!=typeof t)return!1;for(const[e,n]of Object.entries(t)){const t=typeof n;if("string"!==t&&"function"!==t&&!Array.isArray(n))return console.warn(`⚠️ FieldMap inválido: campo '${e}' deve ser string, array ou function`),!1}return!0},GT={PROJETO_ID:"project_id",PROJETO_NOME:"project_description",PROJETO_OBS:"project_note",CLIENTE_ID:"project_customer_id",CLIENTE_NOME:"project_customer_name",PECA_ID:"id",PECA_CODIGO:"pid",PECA_REF:["pref","ref"],MODULO_REF:"mref",MODULO_QTD:["mqt","module_quantity"],PECA_INDICE:"index",PECA_INDICE2:"number",PECA_NOME:"name",PECA_OBS:"note",LARGURA:"width",ALTURA:"height",ESPESSURA:"thickness",MN:["materialName","material","material_name"],MA:"material_height",ML:"material_width",FURO_A:"code_a",FURO_B:"code_b",FE:"edge_left",FD:"edge_right",FS:"edge_top",FI:"edge_bottom",PECA_TIPO:"type",MODULO_NOME:"mname",MODULO_OBS:"mnote",LOTE_ID:["group_id","groupId"],DATA_CRIACAO:["date","created_at"],LADO_USINAGEM:"machining_side",INSUMO_QTD:"qt",INSUMO_PESO:"weight",INSUMO_DIMENSOES:"dimensions",INSUMO_MARCA:"manufacturer",VOLUME_ID:"volume_id",VOLUME_NOME:"volume_name",SCRAP_ID:"scrapId",FURO_A2:"code_a2",FURO_B2:"code_b2",MATERIAL_NOME:["materialName","material","material_name"],TAMPONAMENTO_ID:"id",TAMPONAMENTO_REF:["pref","ref"],TAMPONAMENTO_QT:"qt",TAMPONAMENTO_PESO:"weight",TAMPONAMENTO_NOME:"name",INSUMO_NOME:"name",INSUMO_ID:"id",INSUMO_REF:["pref","ref"],INSUMO_CATEGORIA:"category",INSUMO_FABRICANTE:"manufacturer",RETALHO_ID:"scrapId",RETALHO_INDICE:"index",RETALHO_NOME:"name",RETALHO_QT:"qt",RETALHO_PESO:"weight",RETALHO_DIMENSOES:"dimensions",RETALHO_MATERIAL:["materialName","material","material_name"],RETALHO_ORIGEM:"origin",CODIGO_A:"code_a",CODIGO_B:"code_b",FURO_A_SD:"hole_a_sd",FURO_B_SD:"hole_b_sd",FURO_TOPO:"hole_top",VOLUME_PESO:"weight",VOLUME_DATA:["date","created_at"],VOLUME_DESCRICAO:"description",VOLUME_PECAS:"itemList",VOLUME_DIMENSOES:"dimensions",FURO_A_SD:t=>t.code_a?"0"+t.code_a.slice(1):null,FURO_B_SD:t=>t.code_b?"0"+t.code_b.slice(1):null};new JE;let zT={printerName:null,paperSize:"A4",orientation:"portrait",defaultTemplate:"template-padrao",autoDownloadOnPrinterError:!0,defaultTransformer:{fieldMap:"legacy",fieldMapSource:null}};function qT(t){return Array.isArray(t)?t.map(t=>t&&(t.variableProps||t.specialProps)?Qc(Qc({},t.variableProps||{}),t.specialProps||{}):t||{}):t&&(t.variableProps||t.specialProps)?[Qc(Qc({},t.variableProps),t.specialProps)]:[t]}const XT=(t={})=>{if(t.defaultTransformer){const{fieldMap:e,fieldMapSource:n}=t.defaultTransformer;if(!["legacy","custom","none"].includes(e))throw new Error(`defaultTransformer.fieldMap inválido: "${e}". Use "legacy", "custom" ou "none"`);if("custom"===e&&!n)throw new Error('defaultTransformer.fieldMapSource é obrigatório quando fieldMap="custom"');if("custom"===e&&!KT(n))throw new Error("defaultTransformer.fieldMapSource inválido")}const e=Qc({autoConnectPrinter:!0},t);if(zT=Qc(Qc({},zT),e),e.token&&console.warn("updateApiToken não carregado - usando placeholder"),e.autoConnectPrinter)try{$T(),console.log("🖨️ Auto-conectando ao SSE da impressora...")}catch(o3){console.warn("⚠️ Falha na auto-conexão do SSE da impressora:",o3.message)}return console.log("🏷️ Etiquetas.js initialized successfully"),console.log("🔄 Default transformer:",zT.defaultTransformer.fieldMap),console.log("🖨️ Auto-connect printer:",e.autoConnectPrinter),zT},YT=()=>Wc(this,null,function*(){try{const t=WT.getState(),{printerStatus:e,sseConnected:n}=t;return{connected:e.connected,printerName:e.name,status:e.status,hasDefaultPrinter:e.hasDefaultPrinter,message:e.message,printer:e.printer,sseConnected:n,paperSize:zT.paperSize,orientation:zT.orientation,globalPrinterName:zT.printerName}}catch(o3){return{connected:!1,error:o3.message,status:"error",printerName:"Erro ao obter status",hasDefaultPrinter:!1,message:`Erro: ${o3.message}`,printer:null,sseConnected:!1,paperSize:zT.paperSize,orientation:zT.orientation}}}),$T=()=>{try{WT.getState().connectToSSE(),console.log("🔌 Conectando ao SSE da impressora...")}catch(o3){console.error("❌ Erro ao conectar SSE da impressora:",o3)}};function JT(t,e){const n=[];return e||n.push("Conecte ao servidor de impressão (SSE)"),t.hasDefaultPrinter||n.push("Configure uma impressora padrão no sistema"),!t.connected&&t.hasDefaultPrinter&&n.push("Verifique se a impressora está ligada e conectada"),"no-printer"===t.status&&n.push("Instale e configure uma impressora no sistema"),n}const ZT=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF();let i,A=t,s=!1;if(n.transformer?i=n.transformer:n.useLegacyTransformer?(console.warn("⚠️ useLegacyTransformer está deprecated. Use options.transformer ao invés."),i={fieldMap:"legacy",fieldMapSource:n.customFieldMap}):i=zT.defaultTransformer,i&&"none"!==i.fieldMap){const{fieldMap:e,fieldMapSource:r}=i;let a;switch(e){case"legacy":a=GT,console.log("🔄 Using legacy transformer");break;case"custom":if(!r)throw new Error('fieldMapSource é obrigatório quando fieldMap="custom"');if(!KT(r))throw new Error("fieldMapSource inválido");a=r,console.log("🔄 Using custom transformer");break;default:throw new Error(`fieldMap inválido: "${e}". Use "legacy", "custom" ou "none"`)}A=((t,e,n={})=>{const{validateMap:r=!0,throwOnError:i=!1,logErrors:A=!0}=n;try{if(r&&!KT(e)){const e=new Error("FieldMap inválido");if(i)throw e;return A&&console.error("❌",e.message),t}return Array.isArray(t)?t.map(t=>VT(t,e)):VT(t,e)}catch(o3){if(A&&console.error("❌ Erro ao aplicar transformações:",o3.message),i)throw o3;return t}})(t,a,{validateMap:!0,throwOnError:!0,logErrors:!0}),s=!0,n.transformer?console.log("✅ Transformer applied from options"):n.useLegacyTransformer?console.log("🔄 Legacy transformer applied (deprecated API)"):console.log("✅ Default transformer applied from init config")}else console.log("🚫 Transformer disabled");const a=Qc({dataSource:A,labels:yield oD(e),userPrefs:zT,cacheKey:`label-${Date.now()}`},n),o=yield r.generateLabels(a);if(console.log("✅ Label generated successfully"),Array.isArray(o)){const[t,e,n]=o;return n&&n.output?n.output("arraybuffer"):t}return o}catch(o3){throw console.error("❌ Error generating label:",o3),o3}}),tD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{let r=!1,i=null;if(n.transformer)r=!0,i=n.transformer.fieldMap;else if(n.useLegacyTransformer)r=!0,i="legacy (deprecated)";else{const t=zT.defaultTransformer;t&&"none"!==t.fieldMap?(r=!0,i=`${t.fieldMap} (default from init)`):(r=!1,i="none (disabled in init)")}const A=yield ZT(t,e,n),s=n.fileName||`label-${Date.now()}.pdf`;console.log("📄 PDF gerado:",A);const a=yield aD(A,Qc({filename:s,metadata:{type:"unified",labelId:e,timestamp:(new Date).toISOString(),usedTransformer:r,transformerType:i}},n));return a&&"object"==typeof a&&(a.usedTransformer=r,a.transformerType=i),a}catch(o3){throw console.error("❌ Error in smart label sending:",o3),o3}}),eD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>{return kc(Qc({},e=t),{type:e.type||"cabinet",PROJETO_ID:e.project_id,PROJETO_NOME:e.project_description,CLIENTE_NOME:e.project_customer_name,PECA_ID:e.id,PECA_CODIGO:e.ref||e.pref,PECA_NOME:e.name,PECA_INDICE:e.index||e.number,PECA_NOTA:e.note,LARGURA:e.width,ALTURA:e.height,ESPESSURA:e.thickness,MN:e.material_name,FE:e.edge_left,FD:e.edge_right,FS:e.edge_top,FI:e.edge_bottom,MODULO_REF:e.mref,MODULO_NOME:e.mname,MODULO_NOTA:e.mnote,CODIGO_A:e.code_a,CODIGO_B:e.code_b,material_name:e.material_name,material_width:e.material_width,material_height:e.material_height,edge_left:e.edge_left,edge_right:e.edge_right,edge_top:e.edge_top,edge_bottom:e.edge_bottom,code_a:e.code_a,code_b:e.code_b,code_a2:e.code_a2,code_b2:e.code_b2,machining_side:e.machining_side,project_id:e.project_id,project_description:e.project_description,project_customer_name:e.project_customer_name,project_customer_id:e.project_customer_id,project_note:e.project_note,rotated:e.rotated||!1,holes:e.holes||[]});var e}),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`part-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Part label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating part label:",o3),o3}}),nD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>{return e=t,console.log("=>>",e),Qc({},e);var e}),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`thickening-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Thickening label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating thickening label:",o3),o3}}),rD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>{return kc(Qc({},e=t),{type:"input",INSUMO_ID:e.id,INSUMO_NOME:e.name,INSUMO_DIMENSOES:e.dimensions,INSUMO_QT:e.qt||e.quantity||1,INSUMO_PESO:e.weight||"0.00",INSUMO_REF:e.ref,INSUMO_FABRICANTE:e.manufacturer,INSUMO_CATEGORIA:e.category_name,INSUMO_MATERIAL:e.material,INSUMO_DESCRICAO:e.description,PROJETO_ID:e.project_id,PROJETO_NOME:e.project_description,CLIENTE_NOME:e.project_customer_name,MODULO_REF:e.mref,MODULO_NOME:e.mname,MODULO_NOTA:e.mnote,mref:e.mref,mname:e.mname,mnote:e.mnote,project_customer_id:e.project_customer_id,project_note:e.project_note});var e}),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`input-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Input label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating input label:",o3),o3}}),iD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>{return kc(Qc({},e=t),{type:"scrap",RETALHO_ID:e.scrapId||e.id,RETALHO_NOME:e.name,RETALHO_REF:e.ref,RETALHO_QT:e.qt||e.quantity||1,RETALHO_PESO:e.weight||"0.00",RETALHO_DIMENSOES:e.dimensions||`${e.width||0}x${e.height||0}`,RETALHO_MATERIAL:e.material,RETALHO_ORIGEM:e.origin,PROJETO_ID:e.project_id,PROJETO_NOME:e.project_description,CLIENTE_NOME:e.project_customer_name,MODULO_REF:e.mref,MODULO_NOME:e.mname,MODULO_NOTA:e.mnote,mref:e.mref,mname:e.mname,mnote:e.mnote,project_customer_id:e.project_customer_id,project_note:e.project_note});var e}),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`scrap-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Scrap label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating scrap label:",o3),o3}}),AD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>(t=>{const e=t.parts&&Array.isArray(t.parts);return kc(Qc({},t),{type:"volume",VOLUME_ID:t.volume_id||t.id,VOLUME_NOME:t.volume_name||t.name,VOLUME_PESO:t.volume_weight||t.weight||"0.00",VOLUME_DATA:t.volume_date||t.date||(new Date).toLocaleDateString("pt-BR"),VOLUME_DESCRICAO:t.volume_description||t.note||"",VOLUME_PECAS:t.volume_parts_count||(e?t.parts.length:0)||(t.itemList?t.itemList.length:0),VOLUME_DIMENSOES:t.volume_dimensions||"",PROJETO_ID:t.project_id,PROJETO_NOME:t.project_description,CLIENTE_NOME:t.project_customer_name,VOLUME_NAME:t.volume_name||t.name,PROJECT_NAME:t.project_description,CUSTOMER_NAME:t.project_customer_name,volume_id:t.volume_id||t.id,volume_name:t.volume_name||t.name,project_customer_id:t.project_customer_id,project_note:t.project_note,parts:t.parts||[],itemList:t.itemList||[],inputs:t.inputs||[]})})(t)),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`volume-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Volume label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating volume label:",o3),o3}}),sD=(t,e="etiqueta.pdf")=>Wc(this,null,function*(){try{if("undefined"==typeof window)return console.log("📁 PDF generated for download:",e),t;{const n=new Blob([t],{type:"application/pdf"}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}console.log("📥 Download completed:",e)}catch(o3){throw console.error("❌ Download error:",o3),o3}}),aD=(t,...e)=>Wc(this,[t,...e],function*(t,e={}){try{const n=WT.getState(),{printerStatus:r}=n,i={filename:e.filename||"etiqueta.pdf",metadata:Qc({printerName:r.name,printerConnected:r.connected,printerStatus:r.status,hasDefaultPrinter:r.hasDefaultPrinter,globalPrinterName:zT.printerName,paperSize:zT.paperSize,orientation:zT.orientation},e.metadata),scale:e.scale||1.5,autoDownloadOnError:!1!==zT.autoDownloadOnPrinterError};console.log("🖨️ Enviando PDF para impressão via printer worker..."),console.log("📊 Status da impressora:",{name:r.name,connected:r.connected,status:r.status,hasDefaultPrinter:r.hasDefaultPrinter});const A=yield LT(t,i);return A.success&&A.printed&&(A.printerName=r.name,A.printerConnected=r.connected,A.printerStatus=r.status,A.timestamp=(new Date).toISOString()),A}catch(o3){if(console.error("❌ Print error:",o3),zT.autoDownloadOnPrinterError)try{return console.log("📥 Tentando download como alternativa..."),yield sD(t,e.filename||"etiqueta.pdf"),{success:!0,downloaded:!0,fileName:e.filename||"etiqueta.pdf",message:"Falha na impressão - PDF baixado como alternativa",error:o3.message,printerError:!0}}catch(n){console.error("❌ Erro também no download:",n)}throw o3}}),oD=t=>Wc(this,null,function*(){try{const e=yield function(t){return Wc(this,null,function*(){try{const e=yield jT(t);if(!e)throw new Error(`Template/etiqueta não encontrado com ID: ${t}`);return console.log("templateContent:",e),JSON.parse(e.label_content)}catch(o3){throw console.error(`Erro ao buscar template: ${o3.message}`),o3}})}(t);return e||(console.warn(`Template ${t} not found, using default template`),[{pageWidth:800,pageHeight:50,pageHorizontalSpace:0,pageVerticalSpace:0,pageMarginLeft:0,pageMarginTop:0,pageLines:1,pageColumns:1,pageShowBorder:!1,left:0,top:0,width:100,height:50}])}catch(o3){return console.error("❌ Error loading template:",o3),[{pageWidth:210,pageHeight:297,pageHorizontalSpace:0,pageVerticalSpace:0,pageMarginLeft:10,pageMarginTop:10,pageLines:1,pageColumns:1,pageShowBorder:!1,left:0,top:0,width:190,height:277}]}}),lD=(t,e)=>{if(!t||"object"!=typeof t)return console.error("❌ Invalid data: must be an object"),!1;switch(e){case"parts":return t.partId&&t.partName;case"thickening":return t.tamponamentoId&&t.material;case"inputs":return t.insumoId&&t.description;case"scraps":return t.scrapId&&t.material;case"volumes":return t.volume_id&&t.parts;default:return console.error(`❌ Unsupported label type: ${e}`),!1}},cD={init:XT,getPrinterStatus:YT,isPrinterReady:()=>Wc(this,null,function*(){try{const t=WT.getState(),{printerStatus:e,sseConnected:n}=t,r=e.connected&&e.hasDefaultPrinter&&"connected"===e.status;return{ready:r,connected:e.connected,hasDefaultPrinter:e.hasDefaultPrinter,status:e.status,printerName:e.name,sseConnected:n,message:r?"Impressora pronta para uso":e.message||"Impressora não está pronta",recommendations:r?[]:JT(e,n)}}catch(o3){return{ready:!1,error:o3.message,message:"Erro ao verificar status da impressora",recommendations:["Verifique a conexão com o servidor de impressão"]}}}),makeLabel:ZT,sendLabel:tD,makePartLabel:eD,makeThickeningLabel:nD,makeInputLabel:rD,makeScrapLabel:iD,makeVolumeLabel:AD,downloadPDF:sD,sendToPrinter:aD,sendPartLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield eD(t,e,n),i=`part-${t.codigo||t.id}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"part",partId:t.id,partName:t.nome||t.name}},n))}catch(o3){throw console.error("❌ Error in smart part sending:",o3),o3}}),sendTamponamentoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield nD(t,e,n),i=`thickening-${t.id}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"thickening",tamponamentoId:t.id,material:t.material}},n))}catch(o3){throw console.error("❌ Error in smart thickening sending:",o3),o3}}),sendInsumoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield rD(t,e,n),i=`input-${t.id}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"input",insumoId:t.id,description:t.description}},n))}catch(o3){throw console.error("❌ Error in smart input sending:",o3),o3}}),sendRetalhoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield iD(t,e,n),i=`scrap-${t.scrapId}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"scrap",scrapId:t.scrapId,material:t.material}},n))}catch(o3){throw console.error("❌ Error in smart scrap sending:",o3),o3}}),sendVolumeLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield AD(t,e,n),i=`volume-${t.volume_id}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"volume",volumeId:t.volume_id,volumeName:t.volume_nome||t.name,partsCount:t.parts?t.parts.length:0}},n))}catch(o3){throw console.error("❌ Error in smart volume sending:",o3),o3}}),makeBatchLabels:(t,e,n="parts")=>Wc(this,null,function*(){const r=[];for(const i of t)try{let t;switch(n){case"parts":t=yield eD(i,e);break;case"thickening":t=yield nD(i,e);break;case"inputs":t=yield rD(i,e);break;case"scraps":t=yield iD(i,e);break;case"volumes":t=yield AD(i,e);break;default:throw new Error(`Unsupported label type: ${n}`)}r.push(t)}catch(o3){console.error(`❌ Error generating label for item ${i.id}:`,o3),r.push(null)}return r}),validateLabelData:lD,legacyFieldMap:GT,transformField:(t,e,n)=>{const r=n[e];if(!r)return t[e];switch(typeof r){case"string":default:return t[e];case"object":if(Array.isArray(r)){const n=t[e];return"number"==typeof n&&n>=0&&n<r.length?r[n]:null}return t[e];case"function":return r(t)}},applyTransformations:VT,legacyTransformer:t=>VT(t,GT)},hD=kc(Qc({},cD),{environment:{isBrowser:Gc,isNodeJS:!Gc,version:"1.0.0-alpha.1",bundler:"vite"}});
|
|
340
|
+
*/var xL="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},EL=CL.useSyncExternalStore,SL=_L.useRef,FL=_L.useEffect,LL=_L.useMemo,UL=_L.useDebugValue;uL.useSyncExternalStoreWithSelector=function(t,e,n,r,i){var A=SL(null);if(null===A.current){var s={hasValue:!1,value:null};A.current=s}else s=A.current;A=LL(function(){function t(t){if(!o){if(o=!0,A=t,t=r(t),void 0!==i&&s.hasValue){var e=s.value;if(i(e,t))return a=e}return a=t}if(e=a,xL(A,t))return e;var n=r(t);return void 0!==i&&i(e,n)?(A=t,e):(A=t,a=n)}var A,a,o=!1,l=void 0===n?null:n;return[function(){return t(e())},null===l?void 0:function(){return t(l())}]},[e,n,r,i]);var a=EL(t,A[0],A[1]);return FL(function(){s.hasValue=!0,s.value=a},[a]),UL(a),a},hL.exports=uL;const IL=Zc(hL.exports),QL={},{useDebugValue:kL}=cL,{useSyncExternalStoreWithSelector:ML}=IL;let OL=!1;const PL=t=>t;const NL=t=>{"production"!==(QL?"production":void 0)&&"function"!=typeof t&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const e="function"==typeof t?(t=>t?FF(t):FF)(t):t,n=(t,n)=>function(t,e=PL,n){"production"!==(QL?"production":void 0)&&n&&!OL&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),OL=!0);const r=ML(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return kL(r),r}(e,t,n);return Object.assign(n,e),n},TL=t=>t?NL(t):NL,DL=TL((t,e)=>({pdfInstance:null,cacheKey:null,labelType:null,isGenerating:!1,progress:0,error:null,currentData:null,currentConfig:null,setPDFInstance:(e,n,r)=>t({pdfInstance:e,cacheKey:n,labelType:r}),setGenerating:e=>t({isGenerating:e}),setProgress:e=>t({progress:e}),setError:e=>t({error:e}),setCurrentData:e=>t({currentData:e}),setCurrentConfig:e=>t({currentConfig:e}),resetPDFInstance:()=>t({pdfInstance:null,cacheKey:null,labelType:null,progress:0,error:null}),reset:()=>t({pdfInstance:null,cacheKey:null,labelType:null,isGenerating:!1,progress:0,error:null,currentData:null,currentConfig:null})})),RL={type:"parts",index:0,specific:!1,dataIndex:null,source:null,otherData:null,category:[]};const HL=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),jL=[.001,0,0,.001,0,0],WL=1.35,VL=1,KL=2,GL=4,zL=16,qL=32,XL=64,YL=128,$L=256,JL={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},ZL="pdfjs_internal_editor_",tU={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101,COMMENT:102},eU={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},nU=0,rU=1,iU=2,AU=3,sU=3,aU=4,oU={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},lU={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},cU=1,hU=2,uU=3,dU=4,fU=5,pU={ERRORS:0,WARNINGS:1,INFOS:5},gU={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},mU=0,wU=1,vU=2,yU=3;let bU=pU.WARNINGS;function BU(){return bU}function _U(t){bU>=pU.INFOS&&console.log(`Info: ${t}`)}function CU(t){bU>=pU.WARNINGS&&console.log(`Warning: ${t}`)}function xU(t){throw new Error(t)}function EU(t,e){t||xU(e)}function SU(t,e=null,n=null){if(!t)return null;if(n&&"string"==typeof t){if(n.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);(null==e?void 0:e.length)>=2&&(t=`http://${t}`)}if(n.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch(hw){}}const r=e?URL.parse(t,e):URL.parse(t);return function(t){switch(null==t?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r)?r:null}function FU(t,e,n=!1){const r=URL.parse(t);return r?(r.hash=e,r.href):n&&SU(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function LU(t,e,n,r=!1){return Object.defineProperty(t,e,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}const UU=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class IU extends UU{constructor(t,e){super(t,"PasswordException"),this.code=e}}class QU extends UU{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class kU extends UU{constructor(t){super(t,"InvalidPDFException")}}class MU extends UU{constructor(t,e,n){super(t,"ResponseException"),this.status=e,this.missing=n}}class OU extends UU{constructor(t){super(t,"FormatError")}}class PU extends UU{constructor(t){super(t,"AbortException")}}function NU(t){"object"==typeof t&&void 0!==(null==t?void 0:t.length)||xU("Invalid argument for bytesToString");const e=t.length,n=8192;if(e<n)return String.fromCharCode.apply(null,t);const r=[];for(let i=0;i<e;i+=n){const A=Math.min(i+n,e),s=t.subarray(i,A);r.push(String.fromCharCode.apply(null,s))}return r.join("")}function TU(t){"string"!=typeof t&&xU("Invalid argument for stringToBytes");const e=t.length,n=new Uint8Array(e);for(let r=0;r<e;++r)n[r]=255&t.charCodeAt(r);return n}class DU{static get isLittleEndian(){return LU(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return LU(this,"isEvalSupported",function(){try{return new Function(""),!0}catch(hw){return!1}}())}static get isOffscreenCanvasSupported(){return LU(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return LU(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){const{platform:t,userAgent:e}=navigator;return LU(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){var t,e;return LU(this,"isCSSRoundSupported",null==(e=null==(t=globalThis.CSS)?void 0:t.supports)?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const RU=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class HU{static makeHexColor(t,e,n){return`#${RU[t]}${RU[e]}${RU[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,n=0){const r=t[n],i=t[n+1];t[n]=r*e[0]+i*e[2]+e[4],t[n+1]=r*e[1]+i*e[3]+e[5]}static applyTransformToBezier(t,e,n=0){const r=e[0],i=e[1],A=e[2],s=e[3],a=e[4],o=e[5];for(let l=0;l<6;l+=2){const e=t[n+l],c=t[n+l+1];t[n+l]=e*r+c*A+a,t[n+l+1]=e*i+c*s+o}}static applyInverseTransform(t,e){const n=t[0],r=t[1],i=e[0]*e[3]-e[1]*e[2];t[0]=(n*e[3]-r*e[2]+e[2]*e[5]-e[4]*e[3])/i,t[1]=(-n*e[1]+r*e[0]+e[4]*e[1]-e[5]*e[0])/i}static axialAlignedBoundingBox(t,e,n){const r=e[0],i=e[1],A=e[2],s=e[3],a=e[4],o=e[5],l=t[0],c=t[1],h=t[2],u=t[3];let d=r*l+a,f=d,p=r*h+a,g=p,m=s*c+o,w=m,v=s*u+o,y=v;if(0!==i||0!==A){const t=i*l,e=i*h,n=A*c,r=A*u;d+=n,g+=n,p+=r,f+=r,m+=t,y+=t,v+=e,w+=e}n[0]=Math.min(n[0],d,p,f,g),n[1]=Math.min(n[1],m,v,w,y),n[2]=Math.max(n[2],d,p,f,g),n[3]=Math.max(n[3],m,v,w,y)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const n=t[0],r=t[1],i=t[2],A=t[3],s=Uc(n,2)+Uc(r,2),a=n*i+r*A,o=Uc(i,2)+Uc(A,2),l=(s+o)/2,c=Math.sqrt(Uc(l,2)-(s*o-Uc(a,2)));e[0]=Math.sqrt(l+c||1),e[1]=Math.sqrt(l-c||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const 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;const i=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),A=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return i>A?null:[n,i,r,A]}static pointBoundingBox(t,e,n){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}static rectBoundingBox(t,e,n,r,i){i[0]=Math.min(i[0],t,n),i[1]=Math.min(i[1],e,r),i[2]=Math.max(i[2],t,n),i[3]=Math.max(i[3],e,r)}static bezierBoundingBox(t,e,r,A,s,a,o,l,c){c[0]=Math.min(c[0],t,o),c[1]=Math.min(c[1],e,l),c[2]=Math.max(c[2],t,o),c[3]=Math.max(c[3],e,l),Rc(this,n,i).call(this,t,r,s,o,e,A,a,l,3*(3*(r-s)-t+o),6*(t-2*r+s),3*(r-t),c),Rc(this,n,i).call(this,t,r,s,o,e,A,a,l,3*(3*(A-a)-e+l),6*(e-2*A+a),3*(A-e),c)}}n=new WeakSet,r=function(t,e,n,r,i,A,s,a,o,l){if(o<=0||o>=1)return;const c=1-o,h=o*o,u=h*o,d=c*(c*(c*t+3*o*e)+3*h*n)+u*r,f=c*(c*(c*i+3*o*A)+3*h*s)+u*a;l[0]=Math.min(l[0],d),l[1]=Math.min(l[1],f),l[2]=Math.max(l[2],d),l[3]=Math.max(l[3],f)},i=function(t,e,i,A,s,a,o,l,c,h,u,d){if(Math.abs(c)<1e-12)return void(Math.abs(h)>=1e-12&&Rc(this,n,r).call(this,t,e,i,A,s,a,o,l,-u/h,d));const f=Uc(h,2)-4*u*c;if(f<0)return;const p=Math.sqrt(f),g=2*c;Rc(this,n,r).call(this,t,e,i,A,s,a,o,l,(-h+p)/g,d),Rc(this,n,r).call(this,t,e,i,A,s,a,o,l,(-h-p)/g,d)},Tc(HU,n);let jU=null,WU=null;function VU(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),NU(t)}const KU="pdfjs_internal_id_";function GU(t,e,n){return Math.min(Math.max(t,e),n)}function zU(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(NU(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(n=>{n(t(...e))})}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});const qU="http://www.w3.org/2000/svg",XU=class{};Oc(XU,"CSS",96),Oc(XU,"PDF",72),Oc(XU,"PDF_TO_CSS_UNITS",XU.CSS/XU.PDF);let YU=XU;function $U(t,e="text"){return Wc(this,null,function*(){if(rI(t,document.baseURI)){const n=yield fetch(t);if(!n.ok)throw new Error(n.statusText);switch(e){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise((n,r)=>{const i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(200!==i.status&&0!==i.status)r(new Error(i.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void n(i.response)}n(i.responseText)}},i.send(null)})})}class JU{constructor({viewBox:t,userUnit:e,scale:n,rotation:r,offsetX:i=0,offsetY:A=0,dontFlip:s=!1}){this.viewBox=t,this.userUnit=e,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=A,n*=e;const a=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let l,c,h,u,d,f,p,g;switch((r%=360)<0&&(r+=360),r){case 180:l=-1,c=0,h=0,u=1;break;case 90:l=0,c=1,h=1,u=0;break;case 270:l=0,c=-1,h=-1,u=0;break;case 0:l=1,c=0,h=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}s&&(h=-h,u=-u),0===l?(d=Math.abs(o-t[1])*n+i,f=Math.abs(a-t[0])*n+A,p=(t[3]-t[1])*n,g=(t[2]-t[0])*n):(d=Math.abs(a-t[0])*n+i,f=Math.abs(o-t[1])*n+A,p=(t[2]-t[0])*n,g=(t[3]-t[1])*n),this.transform=[l*n,c*n,h*n,u*n,d-l*n*a-h*n*o,f-c*n*a-u*n*o],this.width=p,this.height=g}get rawDims(){const t=this.viewBox;return LU(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:n=this.offsetX,offsetY:r=this.offsetY,dontFlip:i=!1}={}){return new JU({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:r,dontFlip:i})}convertToViewportPoint(t,e){const n=[t,e];return HU.applyTransform(n,this.transform),n}convertToViewportRectangle(t){const e=[t[0],t[1]];HU.applyTransform(e,this.transform);const n=[t[2],t[3]];return HU.applyTransform(n,this.transform),[e[0],e[1],n[0],n[1]]}convertToPdfPoint(t,e){const n=[t,e];return HU.applyInverseTransform(n,this.transform),n}}class ZU extends UU{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function tI(t){const e=t.length;let n=0;for(;n<e&&""===t[n].trim();)n++;return"data:"===t.substring(n,n+5).toLowerCase()}function eI(t){return"string"==typeof t&&/\.pdf$/i.test(t)}class nI{constructor(){Oc(this,"started",Object.create(null)),Oc(this,"times",[])}time(t){t in this.started&&CU(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||CU(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:n}of this.times)e=Math.max(n.length,e);for(const{name:n,start:r,end:i}of this.times)t.push(`${n.padEnd(e)} ${i-r}ms\n`);return t.join("")}}function rI(t,e){const n=e?URL.parse(t,e):URL.parse(t);return"http:"===(null==n?void 0:n.protocol)||"https:"===(null==n?void 0:n.protocol)}function iI(t){t.preventDefault()}function AI(t){t.preventDefault(),t.stopPropagation()}class sI{static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;Nc(this,A)||Dc(this,A,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=Nc(this,A).exec(t);if(!e)return null;const n=parseInt(e[1],10);let r=parseInt(e[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(e[3],10);i=i>=1&&i<=31?i:1;let s=parseInt(e[4],10);s=s>=0&&s<=23?s:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let h=parseInt(e[9],10)||0;return h=h>=0&&h<=59?h:0,"-"===l?(s+=c,a+=h):"+"===l&&(s-=c,a-=h),new Date(Date.UTC(n,r,i,s,a,o))}}function aI(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(CU(`Not a valid color format: "${t}"`),[0,0,0])}function oI(t){const{a:e,b:n,c:r,d:i,e:A,f:s}=t.getTransform();return[e,n,r,i,A,s]}function lI(t){const{a:e,b:n,c:r,d:i,e:A,f:s}=t.getTransform().invertSelf();return[e,n,r,i,A,s]}function cI(t,e,n=!1,r=!0){if(e instanceof JU){const{pageWidth:r,pageHeight:i}=e.rawDims,{style:A}=t,s=DU.isCSSRoundSupported,a=`var(--total-scale-factor) * ${r}px`,o=`var(--total-scale-factor) * ${i}px`,l=s?`round(down, ${a}, var(--scale-round-x))`:`calc(${a})`,c=s?`round(down, ${o}, var(--scale-round-y))`:`calc(${o})`;n&&e.rotation%180!=0?(A.width=c,A.height=l):(A.width=l,A.height=c)}r&&t.setAttribute("data-main-rotation",e.rotation)}A=new WeakMap,Tc(sI,A);class hI{constructor(){const{pixelRatio:t}=hI;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,n,r,i=-1){let A=1/0,s=1/0,a=1/0;(n=hI.capPixels(n,i))>0&&(A=Math.sqrt(n/(t*e))),-1!==r&&(s=r/t,a=r/e);const o=Math.min(A,s,a);return(this.sx>o||this.sy>o)&&(this.sx=o,this.sy=o,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const n=Math.ceil(window.screen.availWidth*window.screen.availHeight*Uc(this.pixelRatio,2)*(1+e/100));return t>0?Math.min(t,n):n}return t}}const uI=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"],dI=class t{constructor(e){Tc(this,g),Tc(this,s,null),Tc(this,a,null),Tc(this,o),Tc(this,l,null),Tc(this,c,null),Tc(this,h,null),Tc(this,u,null),Dc(this,o,e),Nc(t,d)||Dc(t,d,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=Dc(this,s,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const n=Nc(this,o)._uiManager._signal;e.addEventListener("contextmenu",iI,{signal:n}),e.addEventListener("pointerdown",Rc(t,f,p),{signal:n});const r=Dc(this,l,document.createElement("div"));r.className="buttons",e.append(r);const i=Nc(this,o).toolbarPosition;if(i){const{style:t}=e,n="ltr"===Nc(this,o)._uiManager.direction?1-i[0]:i[0];t.insetInlineEnd=100*n+"%",t.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return Nc(this,s)}hide(){var t;Nc(this,s).classList.add("hidden"),null==(t=Nc(this,a))||t.hideDropdown()}show(){var t,e;Nc(this,s).classList.remove("hidden"),null==(t=Nc(this,c))||t.shown(),null==(e=Nc(this,h))||e.shown()}addDeleteButton(){const{editorType:e,_uiManager:n}=Nc(this,o),r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",Nc(t,d)[e]),Rc(this,g,v).call(this,r),r.addEventListener("click",t=>{n.delete()},{signal:n._signal}),Nc(this,l).append(r)}addAltText(t){return Wc(this,null,function*(){const e=yield t.render();Rc(this,g,v).call(this,e),Nc(this,l).append(e,Nc(this,g,y)),Dc(this,c,t)})}addComment(t){if(Nc(this,h))return;const e=t.render();e&&(Rc(this,g,v).call(this,e),Nc(this,l).prepend(e,Nc(this,g,y)),Dc(this,h,t),t.toolbar=this)}addColorPicker(t){if(Nc(this,a))return;Dc(this,a,t);const e=t.renderButton();Rc(this,g,v).call(this,e),Nc(this,l).append(e,Nc(this,g,y))}addEditSignatureButton(t){return Wc(this,null,function*(){const e=Dc(this,u,yield t.renderEditButton(Nc(this,o)));Rc(this,g,v).call(this,e),Nc(this,l).append(e,Nc(this,g,y))})}addButton(t,e){return Wc(this,null,function*(){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":yield this.addAltText(e);break;case"editSignature":yield this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e)}})}updateEditSignatureButton(t){Nc(this,u)&&(Nc(this,u).title=t)}remove(){var t;Nc(this,s).remove(),null==(t=Nc(this,a))||t.destroy(),Dc(this,a,null)}};s=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakMap,d=new WeakMap,f=new WeakSet,p=function(t){t.stopPropagation()},g=new WeakSet,m=function(t){Nc(this,o)._focusEventsAllowed=!1,AI(t)},w=function(t){Nc(this,o)._focusEventsAllowed=!0,AI(t)},v=function(t){const e=Nc(this,o)._uiManager._signal;t.addEventListener("focusin",Rc(this,g,m).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",Rc(this,g,w).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",iI,{signal:e})},y=function(){const t=document.createElement("div");return t.className="divider",t},Tc(dI,f),Tc(dI,d,null);let fI=dI;class pI{constructor(t){Tc(this,C),Tc(this,b,null),Tc(this,B,null),Tc(this,_),Dc(this,_,t)}show(t,e,n){const[r,i]=Rc(this,C,E).call(this,e,n),{style:A}=Nc(this,B)||Dc(this,B,Rc(this,C,x).call(this));t.append(Nc(this,B)),A.insetInlineEnd=100*r+"%",A.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){Nc(this,B).remove()}}function gI(t,e,n){for(const r of n)e.addEventListener(r,t[r].bind(t))}b=new WeakMap,B=new WeakMap,_=new WeakMap,C=new WeakSet,x=function(){const t=Dc(this,B,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",iI,{signal:Nc(this,_)._signal});const e=Dc(this,b,document.createElement("div"));return e.className="buttons",t.append(e),Rc(this,C,S).call(this),t},E=function(t,e){let n=0,r=0;for(const i of t){const t=i.y+i.height;if(t<n)continue;const A=i.x+(e?i.width:0);t>n?(r=A,n=t):e?A>r&&(r=A):A<r&&(r=A)}return[e?1-r:r,n]},S=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=Nc(this,_)._signal;t.addEventListener("contextmenu",iI,{signal:n}),t.addEventListener("click",()=>{Nc(this,_).highlightSelection("floating_button")},{signal:n}),Nc(this,b).append(t)};class mI{constructor(){Tc(this,F,0)}get id(){return`${ZL}${Hc(this,F)._++}`}}F=new WeakMap;const wI=class{constructor(){Tc(this,Q),Tc(this,L,VU()),Tc(this,U,0),Tc(this,I,null)}static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return LU(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}getFromFile(t){return Wc(this,null,function*(){const{lastModified:e,name:n,size:r,type:i}=t;return Rc(this,Q,k).call(this,`${e}_${n}_${r}_${i}`,t)})}getFromUrl(t){return Wc(this,null,function*(){return Rc(this,Q,k).call(this,t,t)})}getFromBlob(t,e){return Wc(this,null,function*(){const n=yield e;return Rc(this,Q,k).call(this,t,n)})}getFromId(t){return Wc(this,null,function*(){Nc(this,I)||Dc(this,I,new Map);const e=Nc(this,I).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)})}getFromCanvas(t,e){Nc(this,I)||Dc(this,I,new Map);let n=Nc(this,I).get(t);if(null==n?void 0:n.bitmap)return n.refCounter+=1,n;const r=new OffscreenCanvas(e.width,e.height);return r.getContext("2d").drawImage(e,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${Nc(this,L)}_${Hc(this,U)._++}`,refCounter:1,isSvg:!1},Nc(this,I).set(t,n),Nc(this,I).set(n.id,n),n}getSvgUrl(t){const e=Nc(this,I).get(t);return(null==e?void 0:e.isSvg)?e.svgUrl:null}deleteId(t){var e;Nc(this,I)||Dc(this,I,new Map);const n=Nc(this,I).get(t);if(!n)return;if(n.refCounter-=1,0!==n.refCounter)return;const{bitmap:r}=n;if(!n.url&&!n.file){const t=new OffscreenCanvas(r.width,r.height);t.getContext("bitmaprenderer").transferFromImageBitmap(r),n.blobPromise=t.convertToBlob()}null==(e=r.close)||e.call(r),n.bitmap=null}isValidId(t){return t.startsWith(`image_${Nc(this,L)}_`)}};L=new WeakMap,U=new WeakMap,I=new WeakMap,Q=new WeakSet,k=function(t,e){return Wc(this,null,function*(){Nc(this,I)||Dc(this,I,new Map);let n=Nc(this,I).get(t);if(null===n)return null;if(null==n?void 0:n.bitmap)return n.refCounter+=1,n;try{let t;if(n||(n={bitmap:null,id:`image_${Nc(this,L)}_${Hc(this,U)._++}`,refCounter:0,isSvg:!1}),"string"==typeof e?(n.url=e,t=yield $U(e,"blob")):e instanceof File?t=n.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=wI._isSVGFittingCanvas,r=new FileReader,i=new Image,A=new Promise((t,A)=>{i.onload=()=>{n.bitmap=i,n.isSvg=!0,t()},r.onload=()=>Wc(this,null,function*(){const t=n.svgUrl=r.result;i.src=(yield e)?`${t}#svgView(preserveAspectRatio(none))`:t}),i.onerror=r.onerror=A});r.readAsDataURL(t),yield A}else n.bitmap=yield createImageBitmap(t);n.refCounter=1}catch(hw){CU(hw),n=null}return Nc(this,I).set(t,n),n&&Nc(this,I).set(n.id,n),n})};let vI=wI;class yI{constructor(t=128){Tc(this,M,[]),Tc(this,O,!1),Tc(this,P),Tc(this,N,-1),Dc(this,P,t)}add({cmd:t,undo:e,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:A=!1,keepUndo:s=!1}){if(r&&t(),Nc(this,O))return;const a={cmd:t,undo:e,post:n,type:i};if(-1===Nc(this,N))return Nc(this,M).length>0&&(Nc(this,M).length=0),Dc(this,N,0),void Nc(this,M).push(a);if(A&&Nc(this,M)[Nc(this,N)].type===i)return s&&(a.undo=Nc(this,M)[Nc(this,N)].undo),void(Nc(this,M)[Nc(this,N)]=a);const o=Nc(this,N)+1;o===Nc(this,P)?Nc(this,M).splice(0,1):(Dc(this,N,o),o<Nc(this,M).length&&Nc(this,M).splice(o)),Nc(this,M).push(a)}undo(){if(-1===Nc(this,N))return;Dc(this,O,!0);const{undo:t,post:e}=Nc(this,M)[Nc(this,N)];t(),null==e||e(),Dc(this,O,!1),Dc(this,N,Nc(this,N)-1)}redo(){if(Nc(this,N)<Nc(this,M).length-1){Dc(this,N,Nc(this,N)+1),Dc(this,O,!0);const{cmd:t,post:e}=Nc(this,M)[Nc(this,N)];t(),null==e||e(),Dc(this,O,!1)}}hasSomethingToUndo(){return-1!==Nc(this,N)}hasSomethingToRedo(){return Nc(this,N)<Nc(this,M).length-1}cleanType(t){if(-1!==Nc(this,N)){for(let e=Nc(this,N);e>=0;e--)if(Nc(this,M)[e].type!==t)return Nc(this,M).splice(e+1,Nc(this,N)-e),void Dc(this,N,e);Nc(this,M).length=0,Dc(this,N,-1)}}destroy(){Dc(this,M,null)}}M=new WeakMap,O=new WeakMap,P=new WeakMap,N=new WeakMap;class bI{constructor(t){Tc(this,T),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=DU.platform;for(const[n,r,i={}]of t)for(const t of n){const n=t.startsWith("mac+");e&&n?(this.callbacks.set(t.slice(4),{callback:r,options:i}),this.allKeys.add(t.split("+").at(-1))):e||n||(this.callbacks.set(t,{callback:r,options:i}),this.allKeys.add(t.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const n=this.callbacks.get(Rc(this,T,D).call(this,e));if(!n)return;const{callback:r,options:{bubbles:i=!1,args:A=[],checker:s=null}}=n;s&&!s(t,e)||(r.bind(t,...A,e)(),i||AI(e))}}T=new WeakSet,D=function(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e};const BI=class t{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const n of t.keys()){e.style.color=n;const r=window.getComputedStyle(e).color;t.set(n,aI(r))}e.remove()}(t),LU(this,"_colors",t)}convert(e){const n=aI(e);if(!window.matchMedia("(forced-colors: active)").matches)return n;for(const[r,i]of this._colors)if(i.every((t,e)=>t===n[e]))return t._colorsMapping.get(r);return n}getHexCode(t){const e=this._colors.get(t);return e?HU.makeHexColor(...e):t}};Oc(BI,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let _I=BI;const CI=class t{constructor(t,e,n,r,i,A,s,a,o,l,c,h,u,d,f,p){Tc(this,Qt),Tc(this,R,new AbortController),Tc(this,H,null),Tc(this,j,new Map),Tc(this,W,new Map),Tc(this,V,null),Tc(this,K,null),Tc(this,G,null),Tc(this,z,new yI),Tc(this,q,null),Tc(this,X,null),Tc(this,Y,null),Tc(this,$,0),Tc(this,J,new Set),Tc(this,Z,null),Tc(this,tt,null),Tc(this,et,new Set),Oc(this,"_editorUndoBar",null),Tc(this,nt,!1),Tc(this,rt,!1),Tc(this,it,!1),Tc(this,At,null),Tc(this,st,null),Tc(this,at,null),Tc(this,ot,null),Tc(this,lt,!1),Tc(this,ct,null),Tc(this,ht,new mI),Tc(this,ut,!1),Tc(this,dt,!1),Tc(this,ft,null),Tc(this,pt,null),Tc(this,gt,null),Tc(this,mt,null),Tc(this,wt,null),Tc(this,vt,tU.NONE),Tc(this,yt,new Set),Tc(this,bt,null),Tc(this,Bt,null),Tc(this,_t,null),Tc(this,Ct,null),Tc(this,xt,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),Tc(this,Et,[0,0]),Tc(this,St,null),Tc(this,Ft,null),Tc(this,Lt,null),Tc(this,Ut,null),Tc(this,It,null);const g=this._signal=Nc(this,R).signal;Dc(this,Ft,t),Dc(this,Lt,e),Dc(this,Ut,n),Dc(this,V,r),Dc(this,q,i),Dc(this,Bt,A),this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:g}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:g}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:g}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:g}),s._on("setpreference",this.onSetPreference.bind(this),{signal:g}),s._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:g}),Rc(this,Qt,Tt).call(this),Rc(this,Qt,Kt).call(this),Rc(this,Qt,Ht).call(this),Dc(this,K,a.annotationStorage),Dc(this,At,a.filterFactory),Dc(this,_t,o),Dc(this,ot,l||null),Dc(this,nt,c),Dc(this,rt,h),Dc(this,it,u),Dc(this,wt,d||null),this.viewParameters={realScale:YU.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=f||null,this._supportsPinchToZoom=!1!==p}static get _keyboardManager(){const e=t.prototype,n=t=>Nc(t,Ft).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),r=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},i=this.TRANSLATE_SMALL,A=this.TRANSLATE_BIG;return LU(this,"_keyboardManager",new bI([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],e.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:r}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Nc(t,Ft).contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Nc(t,Ft).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-A,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[A,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-A],checker:n}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,A],checker:n}]]))}destroy(){var t,e,n,r,i,A,s,a,o;null==(t=Nc(this,It))||t.resolve(),Dc(this,It,null),null==(e=Nc(this,R))||e.abort(),Dc(this,R,null),this._signal=null;for(const l of Nc(this,W).values())l.destroy();Nc(this,W).clear(),Nc(this,j).clear(),Nc(this,et).clear(),null==(n=Nc(this,mt))||n.clear(),Dc(this,H,null),Nc(this,yt).clear(),Nc(this,z).destroy(),null==(r=Nc(this,V))||r.destroy(),null==(i=Nc(this,q))||i.destroy(),null==(A=Nc(this,Bt))||A.destroy(),null==(s=Nc(this,ct))||s.hide(),Dc(this,ct,null),null==(a=Nc(this,gt))||a.destroy(),Dc(this,gt,null),Nc(this,st)&&(clearTimeout(Nc(this,st)),Dc(this,st,null)),Nc(this,St)&&(clearTimeout(Nc(this,St)),Dc(this,St,null)),null==(o=this._editorUndoBar)||o.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return Nc(this,wt)}get useNewAltTextFlow(){return Nc(this,rt)}get useNewAltTextWhenAddingImage(){return Nc(this,it)}get hcmFilter(){return LU(this,"hcmFilter",Nc(this,_t)?Nc(this,At).addHCMFilter(Nc(this,_t).foreground,Nc(this,_t).background):"none")}get direction(){return LU(this,"direction",getComputedStyle(Nc(this,Ft)).direction)}get _highlightColors(){return LU(this,"_highlightColors",Nc(this,ot)?new Map(Nc(this,ot).split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return LU(this,"highlightColors",null);const e=new Map,n=!!Nc(this,_t);for(const[r,i]of t){const t=r.endsWith("_HCM");n&&t?e.set(r.replace("_HCM",""),i):n||t||e.set(r,i)}return LU(this,"highlightColors",e)}get highlightColorNames(){return LU(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),Dc(this,Y,t)}setMainHighlightColorPicker(t){Dc(this,gt,t)}editAltText(t,e=!1){var n;null==(n=Nc(this,V))||n.editAltText(this,t,e)}hasCommentManager(){return!!Nc(this,q)}editComment(t,e){var n;null==(n=Nc(this,q))||n.open(this,t,e)}getSignature(t){var e;null==(e=Nc(this,Bt))||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return Nc(this,Bt)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)Dc(this,it,e)}onPageChanging({pageNumber:t}){Dc(this,$,t-1)}focusMainContainer(){Nc(this,Ft).focus()}findParent(t,e){for(const n of Nc(this,W).values()){const{x:r,y:i,width:A,height:s}=n.div.getBoundingClientRect();if(t>=r&&t<=r+A&&e>=i&&e<=i+s)return n}return null}disableUserSelect(t=!1){Nc(this,Lt).classList.toggle("noUserSelect",t)}addShouldRescale(t){Nc(this,et).add(t)}removeShouldRescale(t){Nc(this,et).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*YU.PDF_TO_CSS_UNITS;for(const n of Nc(this,et))n.onScaleChanging();null==(e=Nc(this,Y))||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:A}=e,s=e.toString(),a=Rc(this,Qt,kt).call(this,e).closest(".textLayer"),o=this.getSelectionBoxes(a);if(!o)return;e.empty();const l=Rc(this,Qt,Mt).call(this,a),c=Nc(this,vt)===tU.NONE,h=()=>{null==l||l.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:o,anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:A,text:s}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(tU.HIGHLIGHT,h):h()}addToAnnotationStorage(t){t.isEmpty()||!Nc(this,K)||Nc(this,K).has(t.id)||Nc(this,K).setValue(t.id,t)}a11yAlert(t,e=null){const n=Nc(this,Ut);n&&(n.setAttribute("data-l10n-id",t),e?n.setAttribute("data-l10n-args",JSON.stringify(e)):n.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,Nc(this,lt)&&(Dc(this,lt,!1),Rc(this,Qt,Nt).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of Nc(this,yt))if(e.div.contains(t)){Dc(this,pt,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!Nc(this,pt))return;const[t,e]=Nc(this,pt);Dc(this,pt,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){Rc(this,Qt,Ht).call(this),Rc(this,Qt,Wt).call(this)}removeEditListeners(){Rc(this,Qt,jt).call(this),Rc(this,Qt,Vt).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const n of Nc(this,tt))if(n.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const n of Nc(this,tt))if(n.isHandlingMimeForPasting(e.type))return n.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null==(e=Nc(this,H))||e.commitOrRemove(),!this.hasSelection)return;const n=[];for(const r of Nc(this,yt)){const t=r.serialize(!0);t&&n.push(t)}0!==n.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(n))}cut(t){this.copy(t),this.delete()}paste(t){return Wc(this,null,function*(){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of Nc(this,tt))if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let n=e.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(i){return void CU(`paste: "${i.message}".`)}if(!Array.isArray(n))return;this.unselectAll();const r=this.currentLayer;try{const t=[];for(const A of n){const e=yield r.deserialize(A);if(!e)return;t.push(e)}const e=()=>{for(const e of t)Rc(this,Qt,Yt).call(this,e);Rc(this,Qt,Zt).call(this,t)},i=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:i,mustExec:!0})}catch(i){CU(`paste: "${i.message}".`)}})}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),Nc(this,vt)===tU.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,Nc(this,lt)&&(Dc(this,lt,!1),Rc(this,Qt,Nt).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(t){t?(Rc(this,Qt,Dt).call(this),Rc(this,Qt,Wt).call(this),Rc(this,Qt,Gt).call(this,{isEditing:Nc(this,vt)!==tU.NONE,isEmpty:Rc(this,Qt,Jt).call(this),hasSomethingToUndo:Nc(this,z).hasSomethingToUndo(),hasSomethingToRedo:Nc(this,z).hasSomethingToRedo(),hasSelectedEditor:!1})):(Rc(this,Qt,Rt).call(this),Rc(this,Qt,Vt).call(this),Rc(this,Qt,Gt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!Nc(this,tt)){Dc(this,tt,t);for(const t of Nc(this,tt))Rc(this,Qt,zt).call(this,t.defaultPropertiesToUpdate)}}getId(){return Nc(this,ht).id}get currentLayer(){return Nc(this,W).get(Nc(this,$))}getLayer(t){return Nc(this,W).get(t)}get currentPageIndex(){return Nc(this,$)}addLayer(t){Nc(this,W).set(t.pageIndex,t),Nc(this,ut)?t.enable():t.disable()}removeLayer(t){Nc(this,W).delete(t.pageIndex)}updateMode(t,e=null,n=!1,r=!1,i=!1){return Wc(this,null,function*(){var A,s,a;if(Nc(this,vt)!==t&&(!Nc(this,It)||(yield Nc(this,It).promise,Nc(this,It)))){if(Dc(this,It,Promise.withResolvers()),null==(A=Nc(this,Y))||A.commitOrRemove(),Dc(this,vt,t),t===tU.NONE)return this.setEditingState(!1),Rc(this,Qt,Xt).call(this),null==(s=this._editorUndoBar)||s.hide(),void Nc(this,It).resolve();t===tU.SIGNATURE&&(yield null==(a=Nc(this,Bt))?void 0:a.loadSignatures()),this.setEditingState(!0),yield Rc(this,Qt,qt).call(this),this.unselectAll();for(const e of Nc(this,W).values())e.updateMode(t);if(!e)return n&&this.addNewEditorFromKeyboard(),void Nc(this,It).resolve();for(const t of Nc(this,j).values())t.annotationElementId===e||t.id===e?(this.setSelected(t),i?t.editComment():r&&t.enterInEditMode()):t.unselect();Nc(this,It).resolve()}})}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==Nc(this,vt)&&this._eventBus.dispatch("switchannotationeditormode",Qc({source:this},t))}updateParams(t,e){if(Nc(this,tt)){switch(t){case eU.CREATE:return void this.currentLayer.addNewEditor(e);case eU.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(Nc(this,Ct)||Dc(this,Ct,new Map)).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const n of Nc(this,yt))n.updateParams(t,e);else for(const n of Nc(this,tt))n.updateDefaultParams(t,e)}}showAllEditors(t,e,n=!1){var r,i;for(const A of Nc(this,j).values())A.editorType===t&&A.show(e);(null==(i=null==(r=Nc(this,Ct))?void 0:r.get(eU.HIGHLIGHT_SHOW_ALL))||i)!==e&&Rc(this,Qt,zt).call(this,[[eU.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(Nc(this,dt)!==t){Dc(this,dt,t);for(const e of Nc(this,W).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const n of Nc(this,j).values())n.pageIndex===t&&e.push(n);return e}getEditor(t){return Nc(this,j).get(t)}addEditor(t){Nc(this,j).set(t.id,t)}removeEditor(t){var e,n;t.div.contains(document.activeElement)&&(Nc(this,st)&&clearTimeout(Nc(this,st)),Dc(this,st,setTimeout(()=>{this.focusMainContainer(),Dc(this,st,null)},0))),Nc(this,j).delete(t.id),t.annotationElementId&&(null==(e=Nc(this,mt))||e.delete(t.annotationElementId)),this.unselect(t),t.annotationElementId&&Nc(this,J).has(t.annotationElementId)||null==(n=Nc(this,K))||n.remove(t.id)}addDeletedAnnotationElement(t){Nc(this,J).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return Nc(this,J).has(t)}removeDeletedAnnotationElement(t){Nc(this,J).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){Nc(this,H)!==t&&(Dc(this,H,t),t&&Rc(this,Qt,zt).call(this,t.propertiesToUpdate))}updateUI(t){Nc(this,Qt,$t)===t&&Rc(this,Qt,zt).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){Rc(this,Qt,zt).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(Nc(this,yt).has(t))return Nc(this,yt).delete(t),t.unselect(),void Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection});Nc(this,yt).add(t),t.select(),Rc(this,Qt,zt).call(this,t.propertiesToUpdate),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.id}),null==(e=Nc(this,Y))||e.commitOrRemove();for(const n of Nc(this,yt))n!==t&&n.unselect();Nc(this,yt).clear(),Nc(this,yt).add(t),t.select(),Rc(this,Qt,zt).call(this,t.propertiesToUpdate),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:!0})}isSelected(t){return Nc(this,yt).has(t)}get firstSelectedEditor(){return Nc(this,yt).values().next().value}unselect(t){t.unselect(),Nc(this,yt).delete(t),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==Nc(this,yt).size}get isEnterHandled(){return 1===Nc(this,yt).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;Nc(this,z).undo(),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:Nc(this,z).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:Rc(this,Qt,Jt).call(this)}),null==(t=this._editorUndoBar)||t.hide()}redo(){Nc(this,z).redo(),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:Nc(this,z).hasSomethingToRedo(),isEmpty:Rc(this,Qt,Jt).call(this)})}addCommands(t){Nc(this,z).add(t),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:Rc(this,Qt,Jt).call(this)})}cleanUndoStack(t){Nc(this,z).cleanType(t)}delete(){var t;this.commitOrRemove();const e=null==(t=this.currentLayer)?void 0:t.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const n=e?[e]:[...Nc(this,yt)],r=()=>{for(const t of n)Rc(this,Qt,Yt).call(this,t)};this.addCommands({cmd:()=>{var t;null==(t=this._editorUndoBar)||t.show(r,1===n.length?n[0].editorType:n.length);for(const e of n)e.remove()},undo:r,mustExec:!0})}commitOrRemove(){var t;null==(t=Nc(this,H))||t.commitOrRemove()}hasSomethingToControl(){return Nc(this,H)||this.hasSelection}selectAll(){for(const t of Nc(this,yt))t.commit();Rc(this,Qt,Zt).call(this,Nc(this,j).values())}unselectAll(){var t;if((!Nc(this,H)||(Nc(this,H).commitOrRemove(),Nc(this,vt)===tU.NONE))&&!(null==(t=Nc(this,Y))?void 0:t.commitOrRemove())&&this.hasSelection){for(const t of Nc(this,yt))t.unselect();Nc(this,yt).clear(),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;Nc(this,Et)[0]+=t,Nc(this,Et)[1]+=e;const[r,i]=Nc(this,Et),A=[...Nc(this,yt)];Nc(this,St)&&clearTimeout(Nc(this,St)),Dc(this,St,setTimeout(()=>{Dc(this,St,null),Nc(this,Et)[0]=Nc(this,Et)[1]=0,this.addCommands({cmd:()=>{for(const t of A)Nc(this,j).has(t.id)&&(t.translateInPage(r,i),t.translationDone())},undo:()=>{for(const t of A)Nc(this,j).has(t.id)&&(t.translateInPage(-r,-i),t.translationDone())},mustExec:!1})},1e3));for(const s of A)s.translateInPage(t,e),s.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),Dc(this,Z,new Map);for(const t of Nc(this,yt))Nc(this,Z).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!Nc(this,Z))return!1;this.disableUserSelect(!1);const t=Nc(this,Z);Dc(this,Z,null);let e=!1;for(const[{x:r,y:i,pageIndex:A},s]of t)s.newX=r,s.newY=i,s.newPageIndex=A,e||(e=r!==s.savedX||i!==s.savedY||A!==s.savedPageIndex);if(!e)return!1;const n=(t,e,n,r)=>{if(Nc(this,j).has(t.id)){const i=Nc(this,W).get(r);i?t._setParentAndPosition(i,e,n):(t.pageIndex=r,t.x=e,t.y=n)}};return this.addCommands({cmd:()=>{for(const[e,{newX:r,newY:i,newPageIndex:A}]of t)n(e,r,i,A)},undo:()=>{for(const[e,{savedX:r,savedY:i,savedPageIndex:A}]of t)n(e,r,i,A)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(Nc(this,Z))for(const n of Nc(this,Z).keys())n.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return(null==(t=this.getActive())?void 0:t.shouldGetKeyboardEvents())||1===Nc(this,yt).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return Nc(this,H)===t}getActive(){return Nc(this,H)}getMode(){return Nc(this,vt)}get imageManager(){return LU(this,"imageManager",new vI)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let o=0,l=e.rangeCount;o<l;o++)if(!t.contains(e.getRangeAt(o).commonAncestorContainer))return null;const{x:n,y:r,width:i,height:A}=t.getBoundingClientRect();let s;switch(t.getAttribute("data-main-rotation")){case"90":s=(t,e,s,a)=>({x:(e-r)/A,y:1-(t+s-n)/i,width:a/A,height:s/i});break;case"180":s=(t,e,s,a)=>({x:1-(t+s-n)/i,y:1-(e+a-r)/A,width:s/i,height:a/A});break;case"270":s=(t,e,s,a)=>({x:1-(e+a-r)/A,y:(t-n)/i,width:a/A,height:s/i});break;default:s=(t,e,s,a)=>({x:(t-n)/i,y:(e-r)/A,width:s/i,height:a/A})}const a=[];for(let o=0,l=e.rangeCount;o<l;o++){const t=e.getRangeAt(o);if(!t.collapsed)for(const{x:e,y:n,width:r,height:i}of t.getClientRects())0!==r&&0!==i&&a.push(s(e,n,r,i))}return 0===a.length?null:a}addChangedExistingAnnotation({annotationElementId:t,id:e}){(Nc(this,G)||Dc(this,G,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;null==(e=Nc(this,G))||e.delete(t)}renderAnnotationElement(t){var e;const n=null==(e=Nc(this,G))?void 0:e.get(t.data.id);if(!n)return;const r=Nc(this,K).getRawValue(n);r&&(Nc(this,vt)!==tU.NONE||r.hasBeenModified)&&r.renderAnnotationElement(t)}setMissingCanvas(t,e,n){var r;const i=null==(r=Nc(this,mt))?void 0:r.get(t);i&&(i.setCanvas(e,n),Nc(this,mt).delete(t))}addMissingCanvas(t,e){(Nc(this,mt)||Dc(this,mt,new Map)).set(t,e)}};R=new WeakMap,H=new WeakMap,j=new WeakMap,W=new WeakMap,V=new WeakMap,K=new WeakMap,G=new WeakMap,z=new WeakMap,q=new WeakMap,X=new WeakMap,Y=new WeakMap,$=new WeakMap,J=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,nt=new WeakMap,rt=new WeakMap,it=new WeakMap,At=new WeakMap,st=new WeakMap,at=new WeakMap,ot=new WeakMap,lt=new WeakMap,ct=new WeakMap,ht=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,wt=new WeakMap,vt=new WeakMap,yt=new WeakMap,bt=new WeakMap,Bt=new WeakMap,_t=new WeakMap,Ct=new WeakMap,xt=new WeakMap,Et=new WeakMap,St=new WeakMap,Ft=new WeakMap,Lt=new WeakMap,Ut=new WeakMap,It=new WeakMap,Qt=new WeakSet,kt=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Mt=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const n of Nc(this,W).values())if(n.hasTextLayer(t))return n;return null},Ot=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=Rc(this,Qt,kt).call(this,t).closest(".textLayer"),n=this.getSelectionBoxes(e);n&&(Nc(this,ct)||Dc(this,ct,new pI(this)),Nc(this,ct).show(e,n,"ltr"===this.direction))},Pt=function(){var t,e,n;const r=document.getSelection();if(!r||r.isCollapsed)return void(Nc(this,bt)&&(null==(t=Nc(this,ct))||t.hide(),Dc(this,bt,null),Rc(this,Qt,Gt).call(this,{hasSelectedText:!1})));const{anchorNode:i}=r;if(i===Nc(this,bt))return;const A=Rc(this,Qt,kt).call(this,r).closest(".textLayer");if(A){if(null==(n=Nc(this,ct))||n.hide(),Dc(this,bt,i),Rc(this,Qt,Gt).call(this,{hasSelectedText:!0}),(Nc(this,vt)===tU.HIGHLIGHT||Nc(this,vt)===tU.NONE)&&(Nc(this,vt)===tU.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),Dc(this,lt,this.isShiftKeyDown),!this.isShiftKeyDown)){const t=Nc(this,vt)===tU.HIGHLIGHT?Rc(this,Qt,Mt).call(this,A):null;null==t||t.toggleDrawing();const e=new AbortController,n=this.combinedSignal(e),r=n=>{"pointerup"===n.type&&0!==n.button||(e.abort(),null==t||t.toggleDrawing(!0),"pointerup"===n.type&&Rc(this,Qt,Nt).call(this,"main_toolbar"))};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}}else Nc(this,bt)&&(null==(e=Nc(this,ct))||e.hide(),Dc(this,bt,null),Rc(this,Qt,Gt).call(this,{hasSelectedText:!1}))},Nt=function(t=""){Nc(this,vt)===tU.HIGHLIGHT?this.highlightSelection(t):Nc(this,nt)&&Rc(this,Qt,Ot).call(this)},Tt=function(){document.addEventListener("selectionchange",Rc(this,Qt,Pt).bind(this),{signal:this._signal})},Dt=function(){if(Nc(this,at))return;Dc(this,at,new AbortController);const t=this.combinedSignal(Nc(this,at));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Rt=function(){var t;null==(t=Nc(this,at))||t.abort(),Dc(this,at,null)},Ht=function(){if(Nc(this,ft))return;Dc(this,ft,new AbortController);const t=this.combinedSignal(Nc(this,ft));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},jt=function(){var t;null==(t=Nc(this,ft))||t.abort(),Dc(this,ft,null)},Wt=function(){if(Nc(this,X))return;Dc(this,X,new AbortController);const t=this.combinedSignal(Nc(this,X));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})},Vt=function(){var t;null==(t=Nc(this,X))||t.abort(),Dc(this,X,null)},Kt=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Gt=function(t){Object.entries(t).some(([t,e])=>Nc(this,xt)[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(Nc(this,xt),t)}),Nc(this,vt)===tU.HIGHLIGHT&&!1===t.hasSelectedEditor&&Rc(this,Qt,zt).call(this,[[eU.HIGHLIGHT_FREE,!0]]))},zt=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},qt=function(){return Wc(this,null,function*(){if(!Nc(this,ut)){Dc(this,ut,!0);const t=[];for(const e of Nc(this,W).values())t.push(e.enable());yield Promise.all(t);for(const e of Nc(this,j).values())e.enable()}})},Xt=function(){if(this.unselectAll(),Nc(this,ut)){Dc(this,ut,!1);for(const t of Nc(this,W).values())t.disable();for(const t of Nc(this,j).values())t.disable()}},Yt=function(t){const e=Nc(this,W).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},$t=function(){let t=null;for(t of Nc(this,yt));return t},Jt=function(){if(0===Nc(this,j).size)return!0;if(1===Nc(this,j).size)for(const t of Nc(this,j).values())return t.isEmpty();return!1},Zt=function(t){for(const e of Nc(this,yt))e.unselect();Nc(this,yt).clear();for(const e of t)e.isEmpty()||(Nc(this,yt).add(e),e.select());Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection})},Oc(CI,"TRANSLATE_SMALL",1),Oc(CI,"TRANSLATE_BIG",10);let xI=CI;const EI=class t{constructor(e){Tc(this,de),Tc(this,te,null),Tc(this,ee,!1),Tc(this,ne,null),Tc(this,re,null),Tc(this,ie,null),Tc(this,Ae,null),Tc(this,se,!1),Tc(this,ae,null),Tc(this,oe,null),Tc(this,le,null),Tc(this,ce,null),Tc(this,he,!1),Dc(this,oe,e),Dc(this,he,e._uiManager.useNewAltTextFlow),Nc(t,ue)||Dc(t,ue,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){null!=t._l10n||(t._l10n=e)}render(){return Wc(this,null,function*(){const e=Dc(this,ne,document.createElement("button"));e.className="altText",e.tabIndex="0";const n=Dc(this,re,document.createElement("span"));e.append(n),Nc(this,he)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Nc(t,ue).missing),n.setAttribute("data-l10n-id",Nc(t,ue)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const r=Nc(this,oe)._uiManager._signal;e.addEventListener("contextmenu",iI,{signal:r}),e.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:r});const i=t=>{t.preventDefault(),Nc(this,oe)._uiManager.editAltText(Nc(this,oe)),Nc(this,he)&&Nc(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:Nc(this,de,fe)}})};return e.addEventListener("click",i,{capture:!0,signal:r}),e.addEventListener("keydown",t=>{t.target===e&&"Enter"===t.key&&(Dc(this,se,!0),i(t))},{signal:r}),yield Rc(this,de,pe).call(this),e})}finish(){Nc(this,ne)&&(Nc(this,ne).focus({focusVisible:Nc(this,se)}),Dc(this,se,!1))}isEmpty(){return Nc(this,he)?null===Nc(this,te):!Nc(this,te)&&!Nc(this,ee)}hasData(){return Nc(this,he)?null!==Nc(this,te)||!!Nc(this,le):this.isEmpty()}get guessedText(){return Nc(this,le)}setGuessedText(e){return Wc(this,null,function*(){null===Nc(this,te)&&(Dc(this,le,e),Dc(this,ce,yield t._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),Rc(this,de,pe).call(this))})}toggleAltTextBadge(t=!1){var e;if(!Nc(this,he)||Nc(this,te))return null==(e=Nc(this,ae))||e.remove(),void Dc(this,ae,null);if(!Nc(this,ae)){const t=Dc(this,ae,document.createElement("div"));t.className="noAltTextBadge",Nc(this,oe).div.append(t)}Nc(this,ae).classList.toggle("hidden",!t)}serialize(t){let e=Nc(this,te);return t||Nc(this,le)!==e||(e=Nc(this,ce)),{altText:e,decorative:Nc(this,ee),guessedText:Nc(this,le),textWithDisclaimer:Nc(this,ce)}}get data(){return{altText:Nc(this,te),decorative:Nc(this,ee)}}set data({altText:t,decorative:e,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(Dc(this,le,n),Dc(this,ce,r)),Nc(this,te)===t&&Nc(this,ee)===e||(i||(Dc(this,te,t),Dc(this,ee,e)),Rc(this,de,pe).call(this))}toggle(t=!1){Nc(this,ne)&&(!t&&Nc(this,Ae)&&(clearTimeout(Nc(this,Ae)),Dc(this,Ae,null)),Nc(this,ne).disabled=!t)}shown(){Nc(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:Nc(this,de,fe)}})}destroy(){var t,e;null==(t=Nc(this,ne))||t.remove(),Dc(this,ne,null),Dc(this,re,null),Dc(this,ie,null),null==(e=Nc(this,ae))||e.remove(),Dc(this,ae,null)}};te=new WeakMap,ee=new WeakMap,ne=new WeakMap,re=new WeakMap,ie=new WeakMap,Ae=new WeakMap,se=new WeakMap,ae=new WeakMap,oe=new WeakMap,le=new WeakMap,ce=new WeakMap,he=new WeakMap,ue=new WeakMap,de=new WeakSet,fe=function(){return(Nc(this,te)?"added":null===Nc(this,te)&&this.guessedText&&"review")||"missing"},pe=function(){return Wc(this,null,function*(){var t,e,n;const r=Nc(this,ne);if(!r)return;if(Nc(this,he)){if(r.classList.toggle("done",!!Nc(this,te)),r.setAttribute("data-l10n-id",Nc(EI,ue)[Nc(this,de,fe)]),null==(t=Nc(this,re))||t.setAttribute("data-l10n-id",Nc(EI,ue)[`${Nc(this,de,fe)}-label`]),!Nc(this,te))return void(null==(e=Nc(this,ie))||e.remove())}else{if(!Nc(this,te)&&!Nc(this,ee))return r.classList.remove("done"),void(null==(n=Nc(this,ie))||n.remove());r.classList.add("done"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let i=Nc(this,ie);if(!i){Dc(this,ie,i=document.createElement("span")),i.className="tooltip",i.setAttribute("role","tooltip"),i.id=`alt-text-tooltip-${Nc(this,oe).id}`;const t=100,e=Nc(this,oe)._uiManager._signal;e.addEventListener("abort",()=>{clearTimeout(Nc(this,Ae)),Dc(this,Ae,null)},{once:!0}),r.addEventListener("mouseenter",()=>{Dc(this,Ae,setTimeout(()=>{Dc(this,Ae,null),Nc(this,ie).classList.add("show"),Nc(this,oe)._reportTelemetry({action:"alt_text_tooltip"})},t))},{signal:e}),r.addEventListener("mouseleave",()=>{var t;Nc(this,Ae)&&(clearTimeout(Nc(this,Ae)),Dc(this,Ae,null)),null==(t=Nc(this,ie))||t.classList.remove("show")},{signal:e})}Nc(this,ee)?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=Nc(this,te)),i.parentNode||r.append(i);const A=Nc(this,oe).getElementForAltText();null==A||A.setAttribute("aria-describedby",i.id)})},Tc(EI,ue,null),Oc(EI,"_l10n",null);let SI=EI;class FI{constructor(t){Tc(this,ge,null),Tc(this,me,!1),Tc(this,we,null),Tc(this,ve,null),Tc(this,ye,null),Tc(this,be,null),Tc(this,Be,!1),Dc(this,we,t),this.toolbar=null}render(){if(!Nc(this,we)._uiManager.hasCommentManager())return null;const t=Dc(this,ge,document.createElement("button"));t.className="comment",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button");const e=Nc(this,we)._uiManager._signal;t.addEventListener("contextmenu",iI,{signal:e}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:e});const n=t=>{t.preventDefault(),this.edit()};return t.addEventListener("click",n,{capture:!0,signal:e}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(Dc(this,me,!0),n(e))},{signal:e}),t}edit(){const{bottom:t,left:e,right:n}=Nc(this,we).getClientDimensions(),r={top:t};"ltr"===Nc(this,we)._uiManager.direction?r.right=n:r.left=e,Nc(this,we)._uiManager.editComment(Nc(this,we),r)}finish(){Nc(this,ge)&&(Nc(this,ge).focus({focusVisible:Nc(this,me)}),Dc(this,me,!1))}isDeleted(){return Nc(this,Be)||""===Nc(this,ye)}hasBeenEdited(){return this.isDeleted()||Nc(this,ye)!==Nc(this,ve)}serialize(){return this.data}get data(){return{text:Nc(this,ye),date:Nc(this,be),deleted:Nc(this,Be)}}set data(t){if(null===t)return Dc(this,ye,""),void Dc(this,Be,!0);Dc(this,ye,t),Dc(this,be,new Date),Dc(this,Be,!1)}setInitialText(t){Dc(this,ve,t),this.data=t}toggle(t=!1){Nc(this,ge)&&(Nc(this,ge).disabled=!t)}shown(){}destroy(){var t;null==(t=Nc(this,ge))||t.remove(),Dc(this,ge,null),Dc(this,ye,""),Dc(this,be,null),Dc(this,we,null),Dc(this,me,!1),Dc(this,Be,!1)}}ge=new WeakMap,me=new WeakMap,we=new WeakMap,ve=new WeakMap,ye=new WeakMap,be=new WeakMap,Be=new WeakMap;const LI=class{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:A=null,signal:s}){Tc(this,Oe),Tc(this,_e),Tc(this,Ce,!1),Tc(this,xe,null),Tc(this,Ee),Tc(this,Se),Tc(this,Fe),Tc(this,Le),Tc(this,Ue,null),Tc(this,Ie),Tc(this,Qe,null),Tc(this,ke),Tc(this,Me,null),Dc(this,_e,t),Dc(this,xe,n),Dc(this,Ee,e),Dc(this,Se,r),Dc(this,Fe,i),Dc(this,Le,A),Dc(this,ke,new AbortController),Dc(this,Ie,AbortSignal.any([s,Nc(this,ke).signal])),t.addEventListener("touchstart",Rc(this,Oe,Pe).bind(this),{passive:!1,signal:Nc(this,Ie)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/hI.pixelRatio}destroy(){var t,e;null==(t=Nc(this,ke))||t.abort(),Dc(this,ke,null),null==(e=Nc(this,Ue))||e.abort(),Dc(this,Ue,null)}};_e=new WeakMap,Ce=new WeakMap,xe=new WeakMap,Ee=new WeakMap,Se=new WeakMap,Fe=new WeakMap,Le=new WeakMap,Ue=new WeakMap,Ie=new WeakMap,Qe=new WeakMap,ke=new WeakMap,Me=new WeakMap,Oe=new WeakSet,Pe=function(t){var e,n,r;if(null==(e=Nc(this,Ee))?void 0:e.call(this))return;if(1===t.touches.length){if(Nc(this,Ue))return;const t=Dc(this,Ue,new AbortController),e=AbortSignal.any([Nc(this,Ie),t.signal]),n=Nc(this,_e),r={capture:!0,signal:e,passive:!1},i=t=>{var e;"touch"===t.pointerType&&(null==(e=Nc(this,Ue))||e.abort(),Dc(this,Ue,null))};return n.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(AI(t),i(t))},r),n.addEventListener("pointerup",i,r),void n.addEventListener("pointercancel",i,r)}if(!Nc(this,Me)){Dc(this,Me,new AbortController);const t=AbortSignal.any([Nc(this,Ie),Nc(this,Me).signal]),e=Nc(this,_e),r={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",Rc(this,Oe,Ne).bind(this),r);const i=Rc(this,Oe,Te).bind(this);e.addEventListener("touchend",i,r),e.addEventListener("touchcancel",i,r),r.capture=!0,e.addEventListener("pointerdown",AI,r),e.addEventListener("pointermove",AI,r),e.addEventListener("pointercancel",AI,r),e.addEventListener("pointerup",AI,r),null==(n=Nc(this,Se))||n.call(this)}if(AI(t),2!==t.touches.length||(null==(r=Nc(this,xe))?void 0:r.call(this)))return void Dc(this,Qe,null);let[i,A]=t.touches;i.identifier>A.identifier&&([i,A]=[A,i]),Dc(this,Qe,{touch0X:i.screenX,touch0Y:i.screenY,touch1X:A.screenX,touch1Y:A.screenY})},Ne=function(t){var e;if(!Nc(this,Qe)||2!==t.touches.length)return;AI(t);let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]);const{screenX:i,screenY:A}=n,{screenX:s,screenY:a}=r,o=Nc(this,Qe),{touch0X:l,touch0Y:c,touch1X:h,touch1Y:u}=o,d=h-l,f=u-c,p=s-i,g=a-A,m=Math.hypot(p,g)||1,w=Math.hypot(d,f)||1;if(!Nc(this,Ce)&&Math.abs(w-m)<=LI.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=i,o.touch0Y=A,o.touch1X=s,o.touch1Y=a,!Nc(this,Ce))return void Dc(this,Ce,!0);const v=[(i+s)/2,(A+a)/2];null==(e=Nc(this,Fe))||e.call(this,v,w,m)},Te=function(t){var e;t.touches.length>=2||(Nc(this,Me)&&(Nc(this,Me).abort(),Dc(this,Me,null),null==(e=Nc(this,Le))||e.call(this)),Nc(this,Qe)&&(AI(t),Dc(this,Qe,null),Dc(this,Ce,!1)))};let UI=LI;const II=class t{constructor(e){Tc(this,hn),Tc(this,De,null),Tc(this,Re,null),Tc(this,He,null),Tc(this,je,null),Tc(this,We,!1),Tc(this,Ve,null),Tc(this,Ke,""),Tc(this,Ge,!1),Tc(this,ze,null),Tc(this,qe,null),Tc(this,Xe,null),Tc(this,Ye,null),Tc(this,$e,""),Tc(this,Je,!1),Tc(this,Ze,null),Tc(this,tn,!1),Tc(this,en,!1),Tc(this,nn,!1),Tc(this,rn,null),Tc(this,An,0),Tc(this,sn,0),Tc(this,an,null),Tc(this,on,null),Oc(this,"isSelected",!1),Oc(this,"_isCopy",!1),Oc(this,"_editToolbar",null),Oc(this,"_initialOptions",Object.create(null)),Oc(this,"_initialData",null),Oc(this,"_isVisible",!0),Oc(this,"_uiManager",null),Oc(this,"_focusEventsAllowed",!0),Tc(this,ln,!1),Tc(this,cn,t._zIndex++),this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null;const{rotation:n,rawDims:{pageWidth:r,pageHeight:i,pageX:A,pageY:s}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,i],this.pageTranslation=[A,s];const[a,o]=this.parentDimensions;this.x=e.x/a,this.y=e.y/o,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=t.prototype._resizeWithKeyboard,n=xI.TRANSLATE_SMALL,r=xI.TRANSLATE_BIG;return LU(this,"_resizerKeyboardManager",new bI([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-n,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[n,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-n]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,n]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,r]}],[["Escape","mac+Escape"],t.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return LU(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new kI({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(e,n){if(null!=t._l10n||(t._l10n=e),t._l10nResizer||(t._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),-1!==t._borderLineWidth)return;const r=getComputedStyle(document.documentElement);t._borderLineWidth=parseFloat(r.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){xU("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return Nc(this,ln)}set _isDraggable(t){var e;Dc(this,ln,t),null==(e=this.div)||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=Nc(this,cn)}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):Rc(this,hn,In).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(Nc(this,Je)?Dc(this,Je,!1):this.parent.setSelected(this))}focusout(t){var e;if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const n=t.relatedTarget;(null==n?void 0:n.closest(`#${this.id}`))||(t.preventDefault(),(null==(e=this.parent)?void 0:e.isMultipleSelection)||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,n,r){const[i,A]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(t+n)/i,this.y=(e+r)/A,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[n,r]=this.parentDimensions;this.setAt(t*n,e*r,this.width*n,this.height*r),this._onTranslated()}translate(t,e){Rc(this,hn,un).call(this,this.parentDimensions,t,e)}translateInPage(t,e){Nc(this,Ze)||Dc(this,Ze,[this.x,this.y,this.width,this.height]),Rc(this,hn,un).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){Nc(this,Ze)||Dc(this,Ze,[this.x,this.y,this.width,this.height]);const{div:n,parentDimensions:[r,i]}=this;if(this.x+=t/r,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:A,y:s}=this;const[a,o]=this.getBaseTranslation();A+=a,s+=o;const{style:l}=n;l.left=`${(100*A).toFixed(2)}%`,l.top=`${(100*s).toFixed(2)}%`,this._onTranslating(A,s),n.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!Nc(this,Ze)&&(Nc(this,Ze)[0]!==this.x||Nc(this,Ze)[1]!==this.y)}get _hasBeenResized(){return!!Nc(this,Ze)&&(Nc(this,Ze)[2]!==this.width||Nc(this,Ze)[3]!==this.height)}getBaseTranslation(){const[e,n]=this.parentDimensions,{_borderLineWidth:r}=t,i=r/e,A=r/n;switch(this.rotation){case 90:return[-i,A];case 180:return[i,A];case 270:return[i,-A];default:return[-i,-A]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[n,r]}=this;let{x:i,y:A,width:s,height:a}=this;if(s*=n,a*=r,i*=n,A*=r,this._mustFixPosition)switch(t){case 0:i=GU(i,0,n-s),A=GU(A,0,r-a);break;case 90:i=GU(i,0,n-a),A=GU(A,s,r);break;case 180:i=GU(i,s,n),A=GU(A,a,r);break;case 270:i=GU(i,a,n),A=GU(A,0,r-s)}this.x=i/=n,this.y=A/=r;const[o,l]=this.getBaseTranslation();i+=o,A+=l,e.left=`${(100*i).toFixed(2)}%`,e.top=`${(100*A).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,n){var r;return Rc(r=t,dn,fn).call(r,e,n,this.parentRotation)}pageTranslationToScreen(e,n){var r;return Rc(r=t,dn,fn).call(r,e,n,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,n]}=this;return[e*t,n*t]}setDims(t,e){const[n,r]=this.parentDimensions,{style:i}=this.div;i.width=`${(100*t/n).toFixed(2)}%`,Nc(this,Ge)||(i.height=`${(100*e/r).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:n}=t,r=n.endsWith("%"),i=!Nc(this,Ge)&&e.endsWith("%");if(r&&i)return;const[A,s]=this.parentDimensions;r||(t.width=`${(100*parseFloat(n)/A).toFixed(2)}%`),Nc(this,Ge)||i||(t.height=`${(100*parseFloat(e)/s).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){var t;null==(t=Nc(this,He))||t.finish()}get toolbarButtons(){return null}addEditToolbar(){return Wc(this,null,function*(){if(this._editToolbar||Nc(this,en))return this._editToolbar;this._editToolbar=new fI(this),this.div.append(this._editToolbar.render()),this._editToolbar.addButton("comment",this.addCommentButton());const{toolbarButtons:t}=this;if(t)for(const[e,n]of t)yield this._editToolbar.addButton(e,n);return this._editToolbar.addButton("delete"),this._editToolbar})}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,null==(t=Nc(this,He))||t.destroy())}addContainer(t){var e;const n=null==(e=this._editToolbar)?void 0:e.div;n?n.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return Nc(this,He)||(SI.initialize(t._l10n),Dc(this,He,new SI(this)),Nc(this,De)&&(Nc(this,He).data=Nc(this,De),Dc(this,De,null))),Nc(this,He)}get altTextData(){var t;return null==(t=Nc(this,He))?void 0:t.data}set altTextData(t){Nc(this,He)&&(Nc(this,He).data=t)}get guessedAltText(){var t;return null==(t=Nc(this,He))?void 0:t.guessedText}setGuessedAltText(t){return Wc(this,null,function*(){var e;yield null==(e=Nc(this,He))?void 0:e.setGuessedText(t)})}serializeAltText(t){var e;return null==(e=Nc(this,He))?void 0:e.serialize(t)}hasAltText(){return!!Nc(this,He)&&!Nc(this,He).isEmpty()}hasAltTextData(){var t,e;return null!=(e=null==(t=Nc(this,He))?void 0:t.hasData())&&e}addCommentButton(){return Nc(this,je)?Nc(this,je):Dc(this,je,new FI(this))}get commentColor(){return null}get comment(){const t=Nc(this,je);return{text:t.data.text,date:t.data.date,deleted:t.isDeleted(),color:this.commentColor}}set comment(t){Nc(this,je)||Dc(this,je,new FI(this)),Nc(this,je).data=t}setCommentData(t){Nc(this,je)||Dc(this,je,new FI(this)),Nc(this,je).setInitialText(t)}get hasEditedComment(){var t;return null==(t=Nc(this,je))?void 0:t.hasBeenEdited()}editComment(){return Wc(this,null,function*(){Nc(this,je)||Dc(this,je,new FI(this)),Nc(this,je).edit()})}addComment(t){this.hasEditedComment&&(t.popup={contents:this.comment.text,deleted:this.comment.deleted})}render(){var t;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=Nc(this,We)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),Rc(this,hn,En).call(this);const[n,r]=this.parentDimensions;this.parentRotation%180!=0&&(e.style.maxWidth=`${(100*r/n).toFixed(2)}%`,e.style.maxHeight=`${(100*n/r).toFixed(2)}%`);const[i,A]=this.getInitialTranslation();return this.translate(i,A),gI(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(Nc(this,on)||Dc(this,on,new UI({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:Rc(this,hn,bn).bind(this),onPinching:Rc(this,hn,Bn).bind(this),onPinchEnd:Rc(this,hn,_n).bind(this),signal:this._uiManager._signal}))),null==(t=this._uiManager._editorUndoBar)||t.hide(),e}pointerdown(t){const{isMac:e}=DU.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(Dc(this,Je,!0),this._isDraggable?Rc(this,hn,xn).call(this,t):Rc(this,hn,Cn).call(this,t))}_onStartDragging(){}_onStopDragging(){}moveInDOM(){Nc(this,rn)&&clearTimeout(Nc(this,rn)),Dc(this,rn,setTimeout(()=>{var t;Dc(this,rn,null),null==(t=this.parent)||t.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){const r=this.parentScale,[i,A]=this.pageDimensions,[s,a]=this.pageTranslation,o=t/r,l=e/r,c=this.x*i,h=this.y*A,u=this.width*i,d=this.height*A;switch(n){case 0:return[c+o+s,A-h-l-d+a,c+o+u+s,A-h-l+a];case 90:return[c+l+s,A-h+o+a,c+l+d+s,A-h+o+u+a];case 180:return[c-o-u+s,A-h+l+a,c-o+s,A-h+l+d+a];case 270:return[c-l-d+s,A-h-o-u+a,c-l+s,A-h-o+a];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[n,r,i,A]=t,s=i-n,a=A-r;switch(this.rotation){case 0:return[n,e-A,s,a];case 90:return[n,e-r,a,s];case 180:return[i,e-r,s,a];case 270:return[i,e-A,a,s];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),Dc(this,en,!0),!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),Dc(this,en,!1),!0)}isInEditMode(){return Nc(this,en)}shouldGetKeyboardEvents(){return Nc(this,nn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:A}=window;return e<A&&r>0&&t<i&&n>0}rebuild(){Rc(this,hn,En).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:(null==(t=this._initialData)?void 0:t.popupRef)||""}}serialize(t=!1,e=null){xU("An editor must be serializable")}static deserialize(t,e,n){return Wc(this,null,function*(){const r=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:n,annotationElementId:t.annotationElementId});r.rotation=t.rotation,Dc(r,De,t.accessibilityData),r._isCopy=t.isCopy||!1;const[i,A]=r.pageDimensions,[s,a,o,l]=r.getRectInCurrentCoords(t.rect,A);return r.x=s/i,r.y=a/A,r.width=o/i,r.height=l/A,r})}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t,e;if(null==(t=Nc(this,Ye))||t.abort(),Dc(this,Ye,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),Nc(this,rn)&&(clearTimeout(Nc(this,rn)),Dc(this,rn,null)),Rc(this,hn,In).call(this),this.removeEditToolbar(),Nc(this,an)){for(const t of Nc(this,an).values())clearTimeout(t);Dc(this,an,null)}this.parent=null,null==(e=Nc(this,on))||e.destroy(),Dc(this,on,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(Rc(this,hn,gn).call(this),Nc(this,ze).classList.remove("hidden"))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),Dc(this,Xe,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const n=Nc(this,ze).children;if(!Nc(this,Re)){Dc(this,Re,Array.from(n));const e=Rc(this,hn,Sn).bind(this),r=Rc(this,hn,Fn).bind(this),i=this._uiManager._signal;for(const n of Nc(this,Re)){const A=n.getAttribute("data-resizer-name");n.setAttribute("role","spinbutton"),n.addEventListener("keydown",e,{signal:i}),n.addEventListener("blur",r,{signal:i}),n.addEventListener("focus",Rc(this,hn,Ln).bind(this,A),{signal:i}),n.setAttribute("data-l10n-id",t._l10nResizer[A])}}const r=Nc(this,Re)[0];let i=0;for(const t of n){if(t===r)break;i++}const A=(360-this.rotation+this.parentRotation)%360/90*(Nc(this,Re).length/4);if(A!==i){if(A<i)for(let t=0;t<i-A;t++)Nc(this,ze).append(Nc(this,ze).firstChild);else if(A>i)for(let t=0;t<A-i;t++)Nc(this,ze).firstChild.before(Nc(this,ze).lastChild);let e=0;for(const r of n){const n=Nc(this,Re)[e++].getAttribute("data-resizer-name");r.setAttribute("data-l10n-id",t._l10nResizer[n])}}Rc(this,hn,Un).call(this,0),Dc(this,nn,!0),Nc(this,ze).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(t,e){Nc(this,nn)&&Rc(this,hn,yn).call(this,Nc(this,$e),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){Rc(this,hn,In).call(this),this.div.focus()}select(){var t,e,n;this.isSelected&&this._editToolbar||(this.isSelected=!0,this.makeResizable(),null==(t=this.div)||t.classList.add("selectedEditor"),this._editToolbar?(null==(e=this._editToolbar)||e.show(),null==(n=Nc(this,He))||n.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{var t,e;(null==(t=this.div)?void 0:t.classList.contains("selectedEditor"))&&(null==(e=this._editToolbar)||e.show())}))}unselect(){var t,e,n,r,i;this.isSelected&&(this.isSelected=!1,null==(t=Nc(this,ze))||t.classList.add("hidden"),null==(e=this.div)||e.classList.remove("selectedEditor"),(null==(n=this.div)?void 0:n.contains(document.activeElement))&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null==(r=this._editToolbar)||r.hide(),null==(i=Nc(this,He))||i.toggleAltTextBadge(!0))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return Nc(this,tn)}set isEditing(t){Dc(this,tn,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){Dc(this,Ge,!0);const 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(e,n=!1){if(n){Nc(this,an)||Dc(this,an,new Map);const{action:n}=e;let r=Nc(this,an).get(n);return r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(e),Nc(this,an).delete(n),0===Nc(this,an).size&&Dc(this,an,null)},t._telemetryTimeout),void Nc(this,an).set(n,r)}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),Dc(this,We,!1)}disable(){this.div&&(this.div.tabIndex=-1),Dc(this,We,!0)}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===(null==e?void 0:e.nodeName)&&e.classList.contains("annotationContent")&&e.remove()}};De=new WeakMap,Re=new WeakMap,He=new WeakMap,je=new WeakMap,We=new WeakMap,Ve=new WeakMap,Ke=new WeakMap,Ge=new WeakMap,ze=new WeakMap,qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,$e=new WeakMap,Je=new WeakMap,Ze=new WeakMap,tn=new WeakMap,en=new WeakMap,nn=new WeakMap,rn=new WeakMap,An=new WeakMap,sn=new WeakMap,an=new WeakMap,on=new WeakMap,ln=new WeakMap,cn=new WeakMap,hn=new WeakSet,un=function([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()},dn=new WeakSet,fn=function(t,e,n){switch(n){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},pn=function(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}},gn=function(){if(Nc(this,ze))return;Dc(this,ze,document.createElement("div")),Nc(this,ze).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const n of t){const t=document.createElement("div");Nc(this,ze).append(t),t.classList.add("resizer",n),t.setAttribute("data-resizer-name",n),t.addEventListener("pointerdown",Rc(this,hn,mn).bind(this,n),{signal:e}),t.addEventListener("contextmenu",iI,{signal:e}),t.tabIndex=-1}this.div.prepend(Nc(this,ze))},mn=function(t,e){var n;e.preventDefault();const{isMac:r}=DU.platform;if(0!==e.button||e.ctrlKey&&r)return;null==(n=Nc(this,He))||n.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,Dc(this,qe,[e.screenX,e.screenY]);const A=new AbortController,s=this._uiManager.combinedSignal(A);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",Rc(this,hn,yn).bind(this,t),{passive:!0,capture:!0,signal:s}),window.addEventListener("touchmove",AI,{passive:!1,signal:s}),window.addEventListener("contextmenu",iI,{signal:s}),Dc(this,Xe,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{var t;A.abort(),this.parent.togglePointerEvents(!0),null==(t=Nc(this,He))||t.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,Rc(this,hn,vn).call(this)};window.addEventListener("pointerup",l,{signal:s}),window.addEventListener("blur",l,{signal:s})},wn=function(t,e,n,r){this.width=n,this.height=r,this.x=t,this.y=e;const[i,A]=this.parentDimensions;this.setDims(i*n,A*r),this.fixAndSetPosition(),this._onResized()},vn=function(){if(!Nc(this,Xe))return;const{savedX:t,savedY:e,savedWidth:n,savedHeight:r}=Nc(this,Xe);Dc(this,Xe,null);const i=this.x,A=this.y,s=this.width,a=this.height;i===t&&A===e&&s===n&&a===r||this.addCommands({cmd:Rc(this,hn,wn).bind(this,i,A,s,a),undo:Rc(this,hn,wn).bind(this,t,e,n,r),mustExec:!0})},yn=function(t,e){const[n,r]=this.parentDimensions,i=this.x,A=this.y,s=this.width,a=this.height,o=II.MIN_SIZE/n,l=II.MIN_SIZE/r,c=Rc(this,hn,pn).call(this,this.rotation),h=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],u=Rc(this,hn,pn).call(this,360-this.rotation);let d,f,p=!1,g=!1;switch(t){case"topLeft":p=!0,d=(t,e)=>[0,0],f=(t,e)=>[t,e];break;case"topMiddle":d=(t,e)=>[t/2,0],f=(t,e)=>[t/2,e];break;case"topRight":p=!0,d=(t,e)=>[t,0],f=(t,e)=>[0,e];break;case"middleRight":g=!0,d=(t,e)=>[t,e/2],f=(t,e)=>[0,e/2];break;case"bottomRight":p=!0,d=(t,e)=>[t,e],f=(t,e)=>[0,0];break;case"bottomMiddle":d=(t,e)=>[t/2,e],f=(t,e)=>[t/2,0];break;case"bottomLeft":p=!0,d=(t,e)=>[0,e],f=(t,e)=>[t,0];break;case"middleLeft":g=!0,d=(t,e)=>[0,e/2],f=(t,e)=>[t,e/2]}const m=d(s,a),w=f(s,a);let v=h(...w);const y=II._round(i+v[0]),b=II._round(A+v[1]);let B,_,C=1,x=1;if(e.fromKeyboard)({deltaX:B,deltaY:_}=e);else{const{screenX:t,screenY:n}=e,[r,i]=Nc(this,qe);[B,_]=this.screenToPageTranslation(t-r,n-i),Nc(this,qe)[0]=t,Nc(this,qe)[1]=n}var E,S;if([B,_]=(E=B/n,S=_/r,[u[0]*E+u[2]*S,u[1]*E+u[3]*S]),p){const t=Math.hypot(s,a);C=x=Math.max(Math.min(Math.hypot(w[0]-m[0]-B,w[1]-m[1]-_)/t,1/s,1/a),o/s,l/a)}else g?C=GU(Math.abs(w[0]-m[0]-B),o,1)/s:x=GU(Math.abs(w[1]-m[1]-_),l,1)/a;const F=II._round(s*C),L=II._round(a*x);v=h(...f(F,L));const U=y-v[0],I=b-v[1];Nc(this,Ze)||Dc(this,Ze,[this.x,this.y,this.width,this.height]),this.width=F,this.height=L,this.x=U,this.y=I,this.setDims(n*F,r*L),this.fixAndSetPosition(),this._onResizing()},bn=function(){var t;Dc(this,Xe,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),null==(t=Nc(this,He))||t.toggle(!1),this.parent.togglePointerEvents(!1)},Bn=function(t,e,n){let r=n/e*.7+1-.7;if(1===r)return;const i=Rc(this,hn,pn).call(this,this.rotation),A=(t,e)=>[i[0]*t+i[2]*e,i[1]*t+i[3]*e],[s,a]=this.parentDimensions,o=this.x,l=this.y,c=this.width,h=this.height,u=II.MIN_SIZE/s,d=II.MIN_SIZE/a;r=Math.max(Math.min(r,1/c,1/h),u/c,d/h);const f=II._round(c*r),p=II._round(h*r);if(f===c&&p===h)return;Nc(this,Ze)||Dc(this,Ze,[o,l,c,h]);const g=A(c/2,h/2),m=II._round(o+g[0]),w=II._round(l+g[1]),v=A(f/2,p/2);this.x=m-v[0],this.y=w-v[1],this.width=f,this.height=p,this.setDims(s*f,a*p),this.fixAndSetPosition(),this._onResizing()},_n=function(){var t;null==(t=Nc(this,He))||t.toggle(!0),this.parent.togglePointerEvents(!0),Rc(this,hn,vn).call(this)},Cn=function(t){const{isMac:e}=DU.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},xn=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let n=!1;const r=new AbortController,i=this._uiManager.combinedSignal(r),A={capture:!0,passive:!1,signal:i},s=t=>{r.abort(),Dc(this,Ve,null),Dc(this,Je,!1),this._uiManager.endDragSession()||Rc(this,hn,Cn).call(this,t),n&&this._onStopDragging()};e&&(Dc(this,An,t.clientX),Dc(this,sn,t.clientY),Dc(this,Ve,t.pointerId),Dc(this,Ke,t.pointerType),window.addEventListener("pointermove",t=>{n||(n=!0,this._onStartDragging());const{clientX:e,clientY:r,pointerId:i}=t;if(i!==Nc(this,Ve))return void AI(t);const[A,s]=this.screenToPageTranslation(e-Nc(this,An),r-Nc(this,sn));Dc(this,An,e),Dc(this,sn,r),this._uiManager.dragSelectedEditors(A,s)},A),window.addEventListener("touchmove",AI,A),window.addEventListener("pointerdown",t=>{t.pointerType===Nc(this,Ke)&&(Nc(this,on)||t.isPrimary)&&s(t),AI(t)},A));const a=t=>{Nc(this,Ve)&&Nc(this,Ve)!==t.pointerId?AI(t):s(t)};window.addEventListener("pointerup",a,{signal:i}),window.addEventListener("blur",a,{signal:i})},En=function(){if(Nc(this,Ye)||!this.div)return;Dc(this,Ye,new AbortController);const t=this._uiManager.combinedSignal(Nc(this,Ye));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Sn=function(t){II._resizerKeyboardManager.exec(this,t)},Fn=function(t){var e;Nc(this,nn)&&(null==(e=t.relatedTarget)?void 0:e.parentNode)!==Nc(this,ze)&&Rc(this,hn,In).call(this)},Ln=function(t){Dc(this,$e,Nc(this,nn)?t:"")},Un=function(t){if(Nc(this,Re))for(const e of Nc(this,Re))e.tabIndex=t},In=function(){Dc(this,nn,!1),Rc(this,hn,Un).call(this,-1),Rc(this,hn,vn).call(this)},Tc(II,dn),Oc(II,"_l10n",null),Oc(II,"_l10nResizer",null),Oc(II,"_borderLineWidth",-1),Oc(II,"_colorManager",new _I),Oc(II,"_zIndex",1),Oc(II,"_telemetryTimeout",1e3);let QI=II;class kI extends QI{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const MI=3285377520,OI=4294901760,PI=65535;class NI{constructor(t){this.h1=t?4294967295&t:MI,this.h2=t?4294967295&t:MI}update(t){let e,n;if("string"==typeof t){e=new Uint8Array(2*t.length),n=0;for(let r=0,i=t.length;r<i;r++){const i=t.charCodeAt(r);i<=255?e[n++]=i:(e[n++]=i>>>8,e[n++]=255&i)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),n=e.byteLength}const r=n>>2,i=n-4*r,A=new Uint32Array(e.buffer,0,r);let s=0,a=0,o=this.h1,l=this.h2;const c=3432918353,h=461845907,u=11601,d=13715;for(let f=0;f<r;f++)1&f?(s=A[f],s=s*c&OI|s*u&PI,s=s<<15|s>>>17,s=s*h&OI|s*d&PI,o^=s,o=o<<13|o>>>19,o=5*o+3864292196):(a=A[f],a=a*c&OI|a*u&PI,a=a<<15|a>>>17,a=a*h&OI|a*d&PI,l^=a,l=l<<13|l>>>19,l=5*l+3864292196);switch(s=0,i){case 3:s^=e[4*r+2]<<16;case 2:s^=e[4*r+1]<<8;case 1:s^=e[4*r],s=s*c&OI|s*u&PI,s=s<<15|s>>>17,s=s*h&OI|s*d&PI,1&r?o^=s:l^=s}this.h1=o,this.h2=l}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&OI|36045*t&PI,e=4283543511*e&OI|(2950163797*(e<<16|t>>>16)&OI)>>>16,t^=e>>>1,t=444984403*t&OI|60499*t&PI,e=3301882366*e&OI|(3120437893*(e<<16|t>>>16)&OI)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const TI=Object.freeze({map:null,hash:"",transfer:void 0});class DI{constructor(){Tc(this,On),Tc(this,Qn,!1),Tc(this,kn,null),Tc(this,Mn,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const n=Nc(this,Mn).get(t);return void 0===n?e:Object.assign(e,n)}getRawValue(t){return Nc(this,Mn).get(t)}remove(t){if(Nc(this,Mn).delete(t),0===Nc(this,Mn).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of Nc(this,Mn).values())if(t instanceof QI)return;this.onAnnotationEditor(null)}}setValue(t,e){const n=Nc(this,Mn).get(t);let r=!1;if(void 0!==n)for(const[i,A]of Object.entries(e))n[i]!==A&&(r=!0,n[i]=A);else r=!0,Nc(this,Mn).set(t,e);r&&Rc(this,On,Pn).call(this),e instanceof QI&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return Nc(this,Mn).has(t)}get size(){return Nc(this,Mn).size}resetModified(){Nc(this,Qn)&&(Dc(this,Qn,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new RI(this)}get serializable(){if(0===Nc(this,Mn).size)return TI;const t=new Map,e=new NI,n=[],r=Object.create(null);let i=!1;for(const[A,s]of Nc(this,Mn)){const n=s instanceof QI?s.serialize(!1,r):s;n&&(t.set(A,n),e.update(`${A}:${JSON.stringify(n)}`),i||(i=!!n.bitmap))}if(i)for(const A of t.values())A.bitmap&&n.push(A.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:n}:TI}get editorStats(){var t;let e=null;const n=new Map;for(const r of Nc(this,Mn).values()){if(!(r instanceof QI))continue;const i=r.telemetryFinalData;if(!i)continue;const{type:A}=i;n.has(A)||n.set(A,Object.getPrototypeOf(r).constructor),e||(e=Object.create(null));const s=e[A]||(e[A]=new Map);for(const[e,n]of Object.entries(i)){if("type"===e)continue;let r=s.get(e);r||(r=new Map,s.set(e,r));const i=null!=(t=r.get(n))?t:0;r.set(n,i+1)}}for(const[r,i]of n)e[r]=i.computeTelemetryFinalData(e[r]);return e}resetModifiedIds(){Dc(this,kn,null)}get modifiedIds(){if(Nc(this,kn))return Nc(this,kn);const t=[];for(const e of Nc(this,Mn).values())e instanceof QI&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return Dc(this,kn,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return Nc(this,Mn).entries()}}Qn=new WeakMap,kn=new WeakMap,Mn=new WeakMap,On=new WeakSet,Pn=function(){Nc(this,Qn)||(Dc(this,Qn,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class RI extends DI{constructor(t){super(),Tc(this,Nn);const{map:e,hash:n,transfer:r}=t.serializable,i=structuredClone(e,r?{transfer:r}:null);Dc(this,Nn,{map:i,hash:n,transfer:r})}get print(){xU("Should not call PrintAnnotationStorage.print")}get serializable(){return Nc(this,Nn)}get modifiedIds(){return LU(this,"modifiedIds",{ids:new Set,hash:""})}}Nn=new WeakMap;class HI{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){Tc(this,Tn,new Set),this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),Nc(this,Tn).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(t){return Wc(this,arguments,function*({systemFontInfo:t,disableFontFace:e,_inspectFont:n}){if(t&&!Nc(this,Tn).has(t.loadedName)){if(EU(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:r,style:i}=t,A=new FontFace(e,r,i);this.addNativeFontFace(A);try{yield A.load(),Nc(this,Tn).add(e),null==n||n(t)}catch(hw){CU(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(A)}return}xU("Not implemented: loadSystemFont without the Font Loading API.")}})}bind(t){return Wc(this,null,function*(){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void(yield this.loadSystemFont(t));if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{yield e.loaded}catch(n){throw CU(`Failed to load font '${e.family}': '${n}'.`),t.disableFontFace=!0,n}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;yield new Promise(e=>{const n=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,n)})}})}get isFontLoadingAPISupported(){var t;return LU(this,"isFontLoadingAPISupported",!!(null==(t=this._document)?void 0:t.fonts))}get isSyncFontLoadingSupported(){return LU(this,"isSyncFontLoadingSupported",HL||DU.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,n={done:!1,complete:function(){for(EU(!n.done,"completeRequest() cannot be called twice."),n.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(n),n}get _loadTestFont(){return LU(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function n(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function r(t,e,n,r){return t.substring(0,e)+r+t.substring(e+n)}let i,A;const s=this._document.createElement("canvas");s.width=1,s.height=1;const a=s.getContext("2d");let o=0;const l=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=r(c,976,l.length,l);const h=1482184792;let u=n(c,16);for(i=0,A=l.length-3;i<A;i+=4)u=u-h+n(l,i)|0;var d;i<l.length&&(u=u-h+n(l+"XXX",i)|0),c=r(c,16,4,(d=u,String.fromCharCode(d>>24&255,d>>16&255,d>>8&255,255&d)));const f=`@font-face {font-family:"${l}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(f);const p=this._document.createElement("div");p.style.visibility="hidden",p.style.width=p.style.height="10px",p.style.position="absolute",p.style.top=p.style.left="0px";for(const g of[t.loadedName,l]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=g,p.append(t)}this._document.body.append(p),function t(e,n){if(++o>30)return CU("Load test font never loaded."),void n();a.font="30px "+e,a.fillText(".",0,20),a.getImageData(0,0,1,1).data[3]>0?n():setTimeout(t.bind(null,e,n))}(l,()=>{p.remove(),e.complete()})}}Tn=new WeakMap;class jI{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const n in t)this[n]=t[n];this._inspectFont=e}createNativeFontFace(){var t;if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return null==(t=this._inspectFont)||t.call(this,this),e}createFontFaceRule(){var t;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${zU(this.data)});`;let n;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return null==(t=this._inspectFont)||t.call(this,this,e),n}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const n=this.loadedName+"_path_"+e;let r;try{r=t.get(n)}catch(A){CU(`getPathGenerator - ignoring character: "${A}".`)}const i=new Path2D(r||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=i}}function WI(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const VI=t=>"object"==typeof t&&Number.isInteger(null==t?void 0:t.num)&&t.num>=0&&Number.isInteger(null==t?void 0:t.gen)&&t.gen>=0,KI=function(t,e,n){if(!Array.isArray(n)||n.length<2)return!1;const[r,i,...A]=n;if(!t(r)&&!Number.isInteger(r))return!1;if(!e(i))return!1;const s=A.length;let a=!0;switch(i.name){case"XYZ":if(s<2||s>3)return!1;break;case"Fit":case"FitB":return 0===s;case"FitH":case"FitBH":case"FitV":case"FitBV":if(s>1)return!1;break;case"FitR":if(4!==s)return!1;a=!1;break;default:return!1}for(const o of A)if(!("number"==typeof o||a&&null===o))return!1;return!0}.bind(null,VI,t=>"object"==typeof t&&"string"==typeof(null==t?void 0:t.name));class GI{constructor(){Tc(this,Dn,new Map),Tc(this,Rn,Promise.resolve())}postMessage(t,e){const n={data:structuredClone(t,e?{transfer:e}:null)};Nc(this,Rn).then(()=>{for(const[t]of Nc(this,Dn))t.call(this,n)})}addEventListener(t,e,n=null){let r=null;if((null==n?void 0:n.signal)instanceof AbortSignal){const{signal:i}=n;if(i.aborted)return void CU("LoopbackPort - cannot use an `aborted` signal.");const A=()=>this.removeEventListener(t,e);r=()=>i.removeEventListener("abort",A),i.addEventListener("abort",A)}Nc(this,Dn).set(e,r)}removeEventListener(t,e){const n=Nc(this,Dn).get(e);null==n||n(),Nc(this,Dn).delete(e)}terminate(){for(const[,t]of Nc(this,Dn))null==t||t();Nc(this,Dn).clear()}}Dn=new WeakMap,Rn=new WeakMap;const zI=1,qI=2,XI=1,YI=2,$I=3,JI=4,ZI=5,tQ=6,eQ=7,nQ=8;function rQ(){}function iQ(t){if(t instanceof PU||t instanceof kU||t instanceof IU||t instanceof MU||t instanceof QU)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||xU('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new PU(t.message);case"InvalidPDFException":return new kU(t.message);case"PasswordException":return new IU(t.message,t.code);case"ResponseException":return new MU(t.message,t.status,t.missing);case"UnknownErrorException":return new QU(t.message,t.details)}return new QU(t.message,t.toString())}class AQ{constructor(t,e,n){Tc(this,jn),Tc(this,Hn,new AbortController),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",Rc(this,jn,Wn).bind(this),{signal:Nc(this,Hn).signal})}on(t,e){const 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){const r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:r,data:e},n)}catch(A){i.reject(A)}return i.promise}sendWithStream(t,e,n,r){const i=this.streamId++,A=this.sourceName,s=this.targetName,a=this.comObj;return new ReadableStream({start:n=>{const o=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:o,pullCall:null,cancelCall:null,isClosed:!1},a.postMessage({sourceName:A,targetName:s,action:t,streamId:i,data:e,desiredSize:n.desiredSize},r),o.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[i].pullCall=e,a.postMessage({sourceName:A,targetName:s,stream:tQ,streamId:i,desiredSize:t.desiredSize}),e.promise},cancel:t=>{EU(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[i].cancelCall=e,this.streamControllers[i].isClosed=!0,a.postMessage({sourceName:A,targetName:s,stream:XI,streamId:i,reason:iQ(t)}),e.promise}},n)}destroy(){var t;null==(t=Nc(this,Hn))||t.abort(),Dc(this,Hn,null)}}Hn=new WeakMap,jn=new WeakSet,Wn=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void Rc(this,jn,Kn).call(this,t);if(t.callback){const e=t.callbackId,n=this.callbackCapabilities[e];if(!n)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===zI)n.resolve(t.data);else{if(t.callback!==qI)throw new Error("Unexpected callback case");n.reject(iQ(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const n=this.sourceName,r=t.sourceName,i=this.comObj;return void Promise.try(e,t.data).then(function(e){i.postMessage({sourceName:n,targetName:r,callback:zI,callbackId:t.callbackId,data:e})},function(e){i.postMessage({sourceName:n,targetName:r,callback:qI,callbackId:t.callbackId,reason:iQ(e)})})}t.streamId?Rc(this,jn,Vn).call(this,t):e(t.data)},Vn=function(t){const e=t.streamId,n=this.sourceName,r=t.sourceName,i=this.comObj,A=this,s=this.actionHandler[t.action],a={enqueue(t,A=1,s){if(this.isCancelled)return;const a=this.desiredSize;this.desiredSize-=A,a>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:JI,streamId:e,chunk:t},s)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:$I,streamId:e}),delete A.streamSinks[e])},error(t){EU(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:ZI,streamId:e,reason:iQ(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};a.sinkCapability.resolve(),a.ready=a.sinkCapability.promise,this.streamSinks[e]=a,Promise.try(s,t.data,a).then(function(){i.postMessage({sourceName:n,targetName:r,stream:nQ,streamId:e,success:!0})},function(t){i.postMessage({sourceName:n,targetName:r,stream:nQ,streamId:e,reason:iQ(t)})})},Kn=function(t){const e=t.streamId,n=this.sourceName,r=t.sourceName,i=this.comObj,A=this.streamControllers[e],s=this.streamSinks[e];switch(t.stream){case nQ:t.success?A.startCall.resolve():A.startCall.reject(iQ(t.reason));break;case eQ:t.success?A.pullCall.resolve():A.pullCall.reject(iQ(t.reason));break;case tQ:if(!s){i.postMessage({sourceName:n,targetName:r,stream:eQ,streamId:e,success:!0});break}s.desiredSize<=0&&t.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=t.desiredSize,Promise.try(s.onPull||rQ).then(function(){i.postMessage({sourceName:n,targetName:r,stream:eQ,streamId:e,success:!0})},function(t){i.postMessage({sourceName:n,targetName:r,stream:eQ,streamId:e,reason:iQ(t)})});break;case JI:if(EU(A,"enqueue should have stream controller"),A.isClosed)break;A.controller.enqueue(t.chunk);break;case $I:if(EU(A,"close should have stream controller"),A.isClosed)break;A.isClosed=!0,A.controller.close(),Rc(this,jn,Gn).call(this,A,e);break;case ZI:EU(A,"error should have stream controller"),A.controller.error(iQ(t.reason)),Rc(this,jn,Gn).call(this,A,e);break;case YI:t.success?A.cancelCall.resolve():A.cancelCall.reject(iQ(t.reason)),Rc(this,jn,Gn).call(this,A,e);break;case XI:if(!s)break;const a=iQ(t.reason);Promise.try(s.onCancel||rQ,a).then(function(){i.postMessage({sourceName:n,targetName:r,stream:YI,streamId:e,success:!0})},function(t){i.postMessage({sourceName:n,targetName:r,stream:YI,streamId:e,reason:iQ(t)})}),s.sinkCapability.reject(a),s.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Gn=function(t,e){return Wc(this,null,function*(){var n,r,i;yield Promise.allSettled([null==(n=t.startCall)?void 0:n.promise,null==(r=t.pullCall)?void 0:r.promise,null==(i=t.cancelCall)?void 0:i.promise]),delete this.streamControllers[e]})};class sQ{constructor({enableHWA:t=!1}){Tc(this,zn,!1),Dc(this,zn,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(t,e);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!Nc(this,zn)})}}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){xU("Abstract method `_createCanvas` called.")}}zn=new WeakMap;class aQ extends sQ{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const n=this._document.createElement("canvas");return n.width=t,n.height=e,n}}class oQ{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}fetch(t){return Wc(this,arguments,function*({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})})}_fetch(t){return Wc(this,null,function*(){xU("Abstract method `_fetch` called.")})}}class lQ extends oQ{_fetch(t){return Wc(this,null,function*(){const e=yield $U(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):TU(e)})}}class cQ{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,n,r,i){return"none"}destroy(t=!1){}}class hQ extends cQ{constructor({docId:t,ownerDocument:e=globalThis.document}){super(),Tc(this,er),Tc(this,qn),Tc(this,Xn),Tc(this,Yn),Tc(this,$n),Tc(this,Jn),Tc(this,Zn),Tc(this,tr,0),Dc(this,$n,t),Dc(this,Jn,e)}addFilter(t){if(!t)return"none";let e=Nc(this,er,nr).get(t);if(e)return e;const[n,r,i]=Rc(this,er,Ar).call(this,t),A=1===t.length?n:`${n}${r}${i}`;if(e=Nc(this,er,nr).get(A),e)return Nc(this,er,nr).set(t,e),e;const s=`g_${Nc(this,$n)}_transfer_map_${Hc(this,tr)._++}`,a=Rc(this,er,sr).call(this,s);Nc(this,er,nr).set(t,a),Nc(this,er,nr).set(A,a);const o=Rc(this,er,lr).call(this,s);return Rc(this,er,hr).call(this,n,r,i,o),a}addHCMFilter(t,e){var n;const r=`${t}-${e}`,i="base";let A=Nc(this,er,rr).get(i);if((null==A?void 0:A.key)===r)return A.url;if(A?(null==(n=A.filter)||n.remove(),A.key=r,A.url="none",A.filter=null):(A={key:r,url:"none",filter:null},Nc(this,er,rr).set(i,A)),!t||!e)return A.url;const s=Rc(this,er,dr).call(this,t);t=HU.makeHexColor(...s);const a=Rc(this,er,dr).call(this,e);if(e=HU.makeHexColor(...a),Nc(this,er,ir).style.color="","#000000"===t&&"#ffffff"===e||t===e)return A.url;const o=new Array(256);for(let d=0;d<=255;d++){const t=d/255;o[d]=t<=.03928?t/12.92:Uc((t+.055)/1.055,2.4)}const l=o.join(","),c=`g_${Nc(this,$n)}_hcm_filter`,h=A.filter=Rc(this,er,lr).call(this,c);Rc(this,er,hr).call(this,l,l,l,h),Rc(this,er,or).call(this,h);const u=(t,e)=>{const n=s[t]/255,r=a[t]/255,i=new Array(e+1);for(let A=0;A<=e;A++)i[A]=n+A/e*(r-n);return i.join(",")};return Rc(this,er,hr).call(this,u(0,5),u(1,5),u(2,5),h),A.url=Rc(this,er,sr).call(this,c),A.url}addAlphaFilter(t){let e=Nc(this,er,nr).get(t);if(e)return e;const[n]=Rc(this,er,Ar).call(this,[t]),r=`alpha_${n}`;if(e=Nc(this,er,nr).get(r),e)return Nc(this,er,nr).set(t,e),e;const i=`g_${Nc(this,$n)}_alpha_map_${Hc(this,tr)._++}`,A=Rc(this,er,sr).call(this,i);Nc(this,er,nr).set(t,A),Nc(this,er,nr).set(r,A);const s=Rc(this,er,lr).call(this,i);return Rc(this,er,ur).call(this,n,s),A}addLuminosityFilter(t){let e,n,r=Nc(this,er,nr).get(t||"luminosity");if(r)return r;if(t?([e]=Rc(this,er,Ar).call(this,[t]),n=`luminosity_${e}`):n="luminosity",r=Nc(this,er,nr).get(n),r)return Nc(this,er,nr).set(t,r),r;const i=`g_${Nc(this,$n)}_luminosity_map_${Hc(this,tr)._++}`,A=Rc(this,er,sr).call(this,i);Nc(this,er,nr).set(t,A),Nc(this,er,nr).set(n,A);const s=Rc(this,er,lr).call(this,i);return Rc(this,er,ar).call(this,s),t&&Rc(this,er,ur).call(this,e,s),A}addHighlightHCMFilter(t,e,n,r,i){var A;const s=`${e}-${n}-${r}-${i}`;let a=Nc(this,er,rr).get(t);if((null==a?void 0:a.key)===s)return a.url;if(a?(null==(A=a.filter)||A.remove(),a.key=s,a.url="none",a.filter=null):(a={key:s,url:"none",filter:null},Nc(this,er,rr).set(t,a)),!e||!n)return a.url;const[o,l]=[e,n].map(Rc(this,er,dr).bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),h=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[u,d]=[r,i].map(Rc(this,er,dr).bind(this));h<c&&([c,h,u,d]=[h,c,d,u]),Nc(this,er,ir).style.color="";const f=(t,e,n)=>{const r=new Array(256),i=(h-c)/n,A=t/255,s=(e-t)/(255*n);let a=0;for(let o=0;o<=n;o++){const t=Math.round(c+o*i),e=A+o*s;for(let n=a;n<=t;n++)r[n]=e;a=t+1}for(let o=a;o<256;o++)r[o]=r[a-1];return r.join(",")},p=`g_${Nc(this,$n)}_hcm_${t}_filter`,g=a.filter=Rc(this,er,lr).call(this,p);return Rc(this,er,or).call(this,g),Rc(this,er,hr).call(this,f(u[0],d[0],5),f(u[1],d[1],5),f(u[2],d[2],5),g),a.url=Rc(this,er,sr).call(this,p),a.url}destroy(t=!1){var e,n,r,i;t&&(null==(e=Nc(this,Zn))?void 0:e.size)||(null==(n=Nc(this,Yn))||n.parentNode.parentNode.remove(),Dc(this,Yn,null),null==(r=Nc(this,Xn))||r.clear(),Dc(this,Xn,null),null==(i=Nc(this,Zn))||i.clear(),Dc(this,Zn,null),Dc(this,tr,0))}}qn=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,$n=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,tr=new WeakMap,er=new WeakSet,nr=function(){return Nc(this,Xn)||Dc(this,Xn,new Map)},rr=function(){return Nc(this,Zn)||Dc(this,Zn,new Map)},ir=function(){if(!Nc(this,Yn)){const t=Nc(this,Jn).createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const n=Nc(this,Jn).createElementNS(qU,"svg");n.setAttribute("width",0),n.setAttribute("height",0),Dc(this,Yn,Nc(this,Jn).createElementNS(qU,"defs")),t.append(n),n.append(Nc(this,Yn)),Nc(this,Jn).body.append(t)}return Nc(this,Yn)},Ar=function(t){if(1===t.length){const e=t[0],n=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255;const r=n.join(",");return[r,r,r]}const[e,n,r]=t,i=new Array(256),A=new Array(256),s=new Array(256);for(let a=0;a<256;a++)i[a]=e[a]/255,A[a]=n[a]/255,s[a]=r[a]/255;return[i.join(","),A.join(","),s.join(",")]},sr=function(t){if(void 0===Nc(this,qn)){Dc(this,qn,"");const t=Nc(this,Jn).URL;t!==Nc(this,Jn).baseURI&&(tI(t)?CU('#createUrl: ignore "data:"-URL for performance reasons.'):Dc(this,qn,FU(t,"")))}return`url(${Nc(this,qn)}#${t})`},ar=function(t){const e=Nc(this,Jn).createElementNS(qU,"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)},or=function(t){const e=Nc(this,Jn).createElementNS(qU,"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)},lr=function(t){const e=Nc(this,Jn).createElementNS(qU,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),Nc(this,er,ir).append(e),e},cr=function(t,e,n){const r=Nc(this,Jn).createElementNS(qU,e);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),t.append(r)},hr=function(t,e,n,r){const i=Nc(this,Jn).createElementNS(qU,"feComponentTransfer");r.append(i),Rc(this,er,cr).call(this,i,"feFuncR",t),Rc(this,er,cr).call(this,i,"feFuncG",e),Rc(this,er,cr).call(this,i,"feFuncB",n)},ur=function(t,e){const n=Nc(this,Jn).createElementNS(qU,"feComponentTransfer");e.append(n),Rc(this,er,cr).call(this,n,"feFuncA",t)},dr=function(t){return Nc(this,er,ir).style.color=t,aI(getComputedStyle(Nc(this,er,ir)).getPropertyValue("color"))};class uQ{constructor({baseUrl:t=null}){this.baseUrl=t}fetch(t){return Wc(this,arguments,function*({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load font data at: ${e}`)})})}_fetch(t){return Wc(this,null,function*(){xU("Abstract method `_fetch` called.")})}}class dQ extends uQ{_fetch(t){return Wc(this,null,function*(){const e=yield $U(t,"arraybuffer");return new Uint8Array(e)})}}class fQ{constructor({baseUrl:t=null}){this.baseUrl=t}fetch(t){return Wc(this,arguments,function*({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load wasm data at: ${e}`)})})}_fetch(t){return Wc(this,null,function*(){xU("Abstract method `_fetch` called.")})}}class pQ extends fQ{_fetch(t){return Wc(this,null,function*(){const e=yield $U(t,"arraybuffer");return new Uint8Array(e)})}}function gQ(t){return Wc(this,null,function*(){const e=process.getBuiltinModule("fs"),n=yield e.promises.readFile(t);return new Uint8Array(n)})}HL&&CU("Please use the `legacy` build in Node.js environments.");class mQ extends cQ{}class wQ extends sQ{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:Kc&&"SCRIPT"===Kc.tagName.toUpperCase()&&Kc.src||new URL("etiquetas.umd.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class vQ extends oQ{_fetch(t){return Wc(this,null,function*(){return gQ(t)})}}class yQ extends uQ{_fetch(t){return Wc(this,null,function*(){return gQ(t)})}}class bQ extends fQ{_fetch(t){return Wc(this,null,function*(){return gQ(t)})}}const BQ="Fill",_Q="Stroke",CQ="Shading";function xQ(t,e){if(!e)return;const n=e[2]-e[0],r=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],n,r),t.clip(i)}class EQ{isModifyingCurrentTransform(){return!1}getPattern(){xU("Abstract method `getPattern` called.")}}class SQ extends EQ{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const n of this._colorStops)e.addColorStop(n[0],n[1]);return e}getPattern(t,e,n,r){let i;if(r===_Q||r===BQ){const A=e.current.getClippedPathBoundingBox(r,oI(t))||[0,0,0,0],s=Math.ceil(A[2]-A[0])||1,a=Math.ceil(A[3]-A[1])||1,o=e.cachedCanvases.getCanvas("pattern",s,a),l=o.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-A[0],-A[1]),n=HU.transform(n,[1,0,0,1,A[0],A[1]]),l.transform(...e.baseTransform),this.matrix&&l.transform(...this.matrix),xQ(l,this._bbox),l.fillStyle=this._createGradient(l),l.fill(),i=t.createPattern(o.canvas,"no-repeat");const c=new DOMMatrix(n);i.setTransform(c)}else xQ(t,this._bbox),i=this._createGradient(t);return i}}function FQ(t,e,n,r,i,A,s,a){const o=e.coords,l=e.colors,c=t.data,h=4*t.width;let u;o[n+1]>o[r+1]&&(u=n,n=r,r=u,u=A,A=s,s=u),o[r+1]>o[i+1]&&(u=r,r=i,i=u,u=s,s=a,a=u),o[n+1]>o[r+1]&&(u=n,n=r,r=u,u=A,A=s,s=u);const d=(o[n]+e.offsetX)*e.scaleX,f=(o[n+1]+e.offsetY)*e.scaleY,p=(o[r]+e.offsetX)*e.scaleX,g=(o[r+1]+e.offsetY)*e.scaleY,m=(o[i]+e.offsetX)*e.scaleX,w=(o[i+1]+e.offsetY)*e.scaleY;if(f>=w)return;const v=l[A],y=l[A+1],b=l[A+2],B=l[s],_=l[s+1],C=l[s+2],x=l[a],E=l[a+1],S=l[a+2],F=Math.round(f),L=Math.round(w);let U,I,Q,k,M,O,P,N;for(let T=F;T<=L;T++){if(T<g){const t=T<f?0:(f-T)/(f-g);U=d-(d-p)*t,I=v-(v-B)*t,Q=y-(y-_)*t,k=b-(b-C)*t}else{let t;t=T>w?1:g===w?0:(g-T)/(g-w),U=p-(p-m)*t,I=B-(B-x)*t,Q=_-(_-E)*t,k=C-(C-S)*t}let t;t=T<f?0:T>w?1:(f-T)/(f-w),M=d-(d-m)*t,O=v-(v-x)*t,P=y-(y-E)*t,N=b-(b-S)*t;const e=Math.round(Math.min(U,M)),n=Math.round(Math.max(U,M));let r=h*T+4*e;for(let i=e;i<=n;i++)t=(U-i)/(U-M),t<0?t=0:t>1&&(t=1),c[r++]=I-(I-O)*t|0,c[r++]=Q-(Q-P)*t|0,c[r++]=k-(k-N)*t|0,c[r++]=255}}function LQ(t,e,n){const r=e.coords,i=e.colors;let A,s;switch(e.type){case"lattice":const a=e.verticesPerRow,o=Math.floor(r.length/a)-1,l=a-1;for(A=0;A<o;A++){let e=A*a;for(let A=0;A<l;A++,e++)FQ(t,n,r[e],r[e+1],r[e+a],i[e],i[e+1],i[e+a]),FQ(t,n,r[e+a+1],r[e+1],r[e+a],i[e+a+1],i[e+1],i[e+a])}break;case"triangles":for(A=0,s=r.length;A<s;A+=3)FQ(t,n,r[A],r[A+1],r[A+2],i[A],i[A+1],i[A+2]);break;default:throw new Error("illegal figure")}}class UQ extends EQ{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,n){const r=Math.floor(this._bounds[0]),i=Math.floor(this._bounds[1]),A=Math.ceil(this._bounds[2])-r,s=Math.ceil(this._bounds[3])-i,a=Math.min(Math.ceil(Math.abs(A*t[0]*1.1)),3e3),o=Math.min(Math.ceil(Math.abs(s*t[1]*1.1)),3e3),l=A/a,c=s/o,h={coords:this._coords,colors:this._colors,offsetX:-r,offsetY:-i,scaleX:1/l,scaleY:1/c},u=a+4,d=o+4,f=n.getCanvas("mesh",u,d),p=f.context,g=p.createImageData(a,o);if(e){const t=g.data;for(let n=0,r=t.length;n<r;n+=4)t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=255}for(const m of this._figures)LQ(g,m,h);p.putImageData(g,2,2);return{canvas:f.canvas,offsetX:r-2*l,offsetY:i-2*c,scaleX:l,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(t,e,n,r){xQ(t,this._bbox);const i=new Float32Array(2);if(r===CQ)HU.singularValueDecompose2dScale(oI(t),i);else if(this.matrix){HU.singularValueDecompose2dScale(this.matrix,i);const[t,n]=i;HU.singularValueDecompose2dScale(e.baseTransform,i),i[0]*=t,i[1]*=n}else HU.singularValueDecompose2dScale(e.baseTransform,i);const A=this._createMeshCanvas(i,r===CQ?null:this._background,e.cachedCanvases);return r!==CQ&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(A.offsetX,A.offsetY),t.scale(A.scaleX,A.scaleY),t.createPattern(A.canvas,"no-repeat")}}class IQ extends EQ{getPattern(){return"hotpink"}}const QQ=1,kQ=2,MQ=class t{constructor(t,e,n,r){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=n,this.baseTransform=r}createPatternCanvas(t){const{bbox:e,operatorList:n,paintType:r,tilingType:i,color:A,canvasGraphicsFactory:s}=this;let{xstep:a,ystep:o}=this;a=Math.abs(a),o=Math.abs(o),_U("TilingType: "+i);const l=e[0],c=e[1],h=e[2],u=e[3],d=h-l,f=u-c,p=new Float32Array(2);HU.singularValueDecompose2dScale(this.matrix,p);const[g,m]=p;HU.singularValueDecompose2dScale(this.baseTransform,p);const w=g*p[0],v=m*p[1];let y=d,b=f,B=!1,_=!1;const C=Math.ceil(a*w),x=Math.ceil(o*v);C>=Math.ceil(d*w)?y=a:B=!0,x>=Math.ceil(f*v)?b=o:_=!0;const E=this.getSizeAndScale(y,this.ctx.canvas.width,w),S=this.getSizeAndScale(b,this.ctx.canvas.height,v),F=t.cachedCanvases.getCanvas("pattern",E.size,S.size),L=F.context,U=s.createCanvasGraphics(L);if(U.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(U,r,A),L.translate(-E.scale*l,-S.scale*c),U.transform(E.scale,0,0,S.scale,0,0),L.save(),this.clipBbox(U,l,c,h,u),U.baseTransform=oI(U.ctx),U.executeOperatorList(n),U.endDrawing(),L.restore(),B||_){const e=F.canvas;B&&(y=a),_&&(b=o);const n=this.getSizeAndScale(y,this.ctx.canvas.width,w),r=this.getSizeAndScale(b,this.ctx.canvas.height,v),i=n.size,A=r.size,s=t.cachedCanvases.getCanvas("pattern-workaround",i,A),h=s.context,u=B?Math.floor(d/a):0,p=_?Math.floor(f/o):0;for(let t=0;t<=u;t++)for(let n=0;n<=p;n++)h.drawImage(e,i*t,A*n,i,A,0,0,i,A);return{canvas:s.canvas,scaleX:n.scale,scaleY:r.scale,offsetX:l,offsetY:c}}return{canvas:F.canvas,scaleX:E.scale,scaleY:S.scale,offsetX:l,offsetY:c}}getSizeAndScale(e,n,r){const i=Math.max(t.MAX_PATTERN_SIZE,n);let A=Math.ceil(e*r);return A>=i?A=i:r=A/e,{scale:r,size:A}}clipBbox(t,e,n,r,i){const A=r-e,s=i-n;t.ctx.rect(e,n,A,s),HU.axialAlignedBoundingBox([e,n,r,i],oI(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,n){const r=t.ctx,i=t.current;switch(e){case QQ:const{fillStyle:t,strokeStyle:A}=this.ctx;r.fillStyle=i.fillColor=t,r.strokeStyle=i.strokeColor=A;break;case kQ:r.fillStyle=r.strokeStyle=n,i.fillColor=i.strokeColor=n;break;default:throw new OU(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,n,r){let i=n;r!==CQ&&(i=HU.transform(i,e.baseTransform),this.matrix&&(i=HU.transform(i,this.matrix)));const A=this.createPatternCanvas(e);let s=new DOMMatrix(i);s=s.translate(A.offsetX,A.offsetY),s=s.scale(1/A.scaleX,1/A.scaleY);const a=t.createPattern(A.canvas,"repeat");return a.setTransform(s),a}};Oc(MQ,"MAX_PATTERN_SIZE",3e3);let OQ=MQ;function PQ({src:t,srcPos:e=0,dest:n,width:r,height:i,nonBlackColor:A=4294967295,inverseDecode:s=!1}){const a=DU.isLittleEndian?4278190080:255,[o,l]=s?[A,a]:[a,A],c=r>>3,h=7&r,u=t.length;n=new Uint32Array(n.buffer);let d=0;for(let f=0;f<i;f++){for(const i=e+c;e<i;e++){const r=e<u?t[e]:255;n[d++]=128&r?l:o,n[d++]=64&r?l:o,n[d++]=32&r?l:o,n[d++]=16&r?l:o,n[d++]=8&r?l:o,n[d++]=4&r?l:o,n[d++]=2&r?l:o,n[d++]=1&r?l:o}if(0===h)continue;const r=e<u?t[e++]:255;for(let t=0;t<h;t++)n[d++]=r&1<<7-t?l:o}return{srcPos:e,destPos:d}}const NQ=16,TQ=new DOMMatrix,DQ=new Float32Array(2),RQ=new Float32Array([1/0,1/0,-1/0,-1/0]);class HQ{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,n){let r;return void 0!==this.cache[t]?(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(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function jQ(t,e,n,r,i,A,s,a,o,l){const[c,h,u,d,f,p]=oI(t);if(0===h&&0===u){const g=s*c+f,m=Math.round(g),w=a*d+p,v=Math.round(w),y=(s+o)*c+f,b=Math.abs(Math.round(y)-m)||1,B=(a+l)*d+p,_=Math.abs(Math.round(B)-v)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(d),m,v),t.drawImage(e,n,r,i,A,0,0,b,_),t.setTransform(c,h,u,d,f,p),[b,_]}if(0===c&&0===d){const g=a*u+f,m=Math.round(g),w=s*h+p,v=Math.round(w),y=(a+l)*u+f,b=Math.abs(Math.round(y)-m)||1,B=(s+o)*h+p,_=Math.abs(Math.round(B)-v)||1;return t.setTransform(0,Math.sign(h),Math.sign(u),0,m,v),t.drawImage(e,n,r,i,A,0,0,_,b),t.setTransform(c,h,u,d,f,p),[_,b]}t.drawImage(e,n,r,i,A,s,a,o,l);return[Math.hypot(c,h)*o,Math.hypot(u,d)*l]}class WQ{constructor(t,e){Oc(this,"alphaIsShape",!1),Oc(this,"fontSize",0),Oc(this,"fontSizeScale",1),Oc(this,"textMatrix",null),Oc(this,"textMatrixScale",1),Oc(this,"fontMatrix",jL),Oc(this,"leading",0),Oc(this,"x",0),Oc(this,"y",0),Oc(this,"lineX",0),Oc(this,"lineY",0),Oc(this,"charSpacing",0),Oc(this,"wordSpacing",0),Oc(this,"textHScale",1),Oc(this,"textRenderingMode",nU),Oc(this,"textRise",0),Oc(this,"fillColor","#000000"),Oc(this,"strokeColor","#000000"),Oc(this,"patternFill",!1),Oc(this,"patternStroke",!1),Oc(this,"fillAlpha",1),Oc(this,"strokeAlpha",1),Oc(this,"lineWidth",1),Oc(this,"activeSMask",null),Oc(this,"transferMaps","none"),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=RQ.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=BQ,e=null){const n=this.minMax.slice();if(t===_Q){e||xU("Stroke bounding box must include transform."),HU.singularValueDecompose2dScale(e,DQ);const t=DQ[0]*this.lineWidth/2,r=DQ[1]*this.lineWidth/2;n[0]-=t,n[1]-=r,n[2]+=t,n[3]+=r}return n}updateClipFromPath(){const t=HU.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(RQ,0)}getClippedPathBoundingBox(t=BQ,e=null){return HU.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function VQ(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const n=e.height,r=e.width,i=n%NQ,A=(n-i)/NQ,s=0===i?A:A+1,a=t.createImageData(r,NQ);let o,l=0;const c=e.data,h=a.data;let u,d,f,p;if(e.kind===oU.GRAYSCALE_1BPP){const e=c.byteLength,n=new Uint32Array(h.buffer,0,h.byteLength>>2),p=n.length,g=r+7>>3,m=4294967295,w=DU.isLittleEndian?4278190080:255;for(u=0;u<s;u++){for(f=u<A?NQ:i,o=0,d=0;d<f;d++){const t=e-l;let i=0;const A=t>g?r:8*t-7,s=-8&A;let a=0,h=0;for(;i<s;i+=8)h=c[l++],n[o++]=128&h?m:w,n[o++]=64&h?m:w,n[o++]=32&h?m:w,n[o++]=16&h?m:w,n[o++]=8&h?m:w,n[o++]=4&h?m:w,n[o++]=2&h?m:w,n[o++]=1&h?m:w;for(;i<A;i++)0===a&&(h=c[l++],a=128),n[o++]=h&a?m:w,a>>=1}for(;o<p;)n[o++]=0;t.putImageData(a,0,u*NQ)}}else if(e.kind===oU.RGBA_32BPP){for(d=0,p=r*NQ*4,u=0;u<A;u++)h.set(c.subarray(l,l+p)),l+=p,t.putImageData(a,0,d),d+=NQ;u<s&&(p=r*i*4,h.set(c.subarray(l,l+p)),t.putImageData(a,0,d))}else{if(e.kind!==oU.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(f=NQ,p=r*f,u=0;u<s;u++){for(u>=A&&(f=i,p=r*f),o=0,d=p;d--;)h[o++]=c[l++],h[o++]=c[l++],h[o++]=c[l++],h[o++]=255;t.putImageData(a,0,u*NQ)}}}function KQ(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const n=e.height,r=e.width,i=n%NQ,A=(n-i)/NQ,s=0===i?A:A+1,a=t.createImageData(r,NQ);let o=0;const l=e.data,c=a.data;for(let h=0;h<s;h++){const e=h<A?NQ:i;({srcPos:o}=PQ({src:l,srcPos:o,dest:c,width:r,height:e,nonBlackColor:0})),t.putImageData(a,0,h*NQ)}}function GQ(t,e){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const r of n)void 0!==t[r]&&(e[r]=t[r]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function zQ(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function qQ(t,e){if(e)return!0;HU.singularValueDecompose2dScale(t,DQ);const n=Math.fround(hI.pixelRatio*YU.PDF_TO_CSS_UNITS);return DQ[0]<=n&&DQ[1]<=n}const XQ=["butt","round","square"],YQ=["miter","round","bevel"],$Q={},JQ={};fr=new WeakSet,pr=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},gr=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},mr=function(t,e,n){const r=new Path2D;return r.addPath(t,new DOMMatrix(n).invertSelf().multiplySelf(e)),r};let ZQ=class t{constructor(t,e,n,r,i,{optionalContentConfig:A,markedContentStack:s=null},a,o){Tc(this,fr),this.ctx=t,this.current=new WQ(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=i,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=s||[],this.optionalContentConfig=A,this.cachedCanvases=new HQ(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=a,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=o,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:n=!1,background:r=null}){const i=this.ctx.canvas.width,A=this.ctx.canvas.height,s=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,i,A),this.ctx.fillStyle=s,n){const t=this.cachedCanvases.getCanvas("transparent",i,A);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...oI(this.compositeCtx))}this.ctx.save(),zQ(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=oI(this.ctx)}executeOperatorList(t,e,n,r){const i=t.argsArray,A=t.fnArray;let s=e||0;const a=i.length;if(a===s)return s;const o=a-s>10&&"function"==typeof n,l=o?Date.now()+15:0;let c=0;const h=this.commonObjs,u=this.objs;let d;for(;;){if(void 0!==r&&s===r.nextBreakPoint)return r.breakIt(s,n),s;if(d=A[s],d!==gU.dependency)this[d].apply(this,i[s]);else for(const t of i[s]){const e=t.startsWith("g_")?h:u;if(!e.has(t))return e.get(t,n),s}if(s++,s===a)return s;if(o&&++c>10){if(Date.now()>l)return n(),s;c=0}}}endDrawing(){Rc(this,fr,pr).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),Rc(this,fr,gr).call(this)}_scaleImage(t,e){var n,r;const i=null!=(n=t.width)?n:t.displayWidth,A=null!=(r=t.height)?r:t.displayHeight;let s,a,o=Math.max(Math.hypot(e[0],e[1]),1),l=Math.max(Math.hypot(e[2],e[3]),1),c=i,h=A,u="prescale1";for(;o>2&&c>1||l>2&&h>1;){let e=c,n=h;o>2&&c>1&&(e=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c/2),o/=c/e),l>2&&h>1&&(n=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,l/=h/n),s=this.cachedCanvases.getCanvas(u,e,n),a=s.context,a.clearRect(0,0,e,n),a.drawImage(t,0,0,c,h,0,0,e,n),t=s.canvas,c=e,h=n,u="prescale1"===u?"prescale2":"prescale1"}return{img:t,paintWidth:c,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:n,height:r}=t,i=this.current.fillColor,A=this.current.patternFill,s=oI(e);let a,o,l,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;o=JSON.stringify(A?s:[s.slice(0,4),i]),a=this._cachedBitmapsMap.get(e),a||(a=new Map,this._cachedBitmapsMap.set(e,a));const n=a.get(o);if(n&&!A){return{canvas:n,offsetX:Math.round(Math.min(s[0],s[2])+s[4]),offsetY:Math.round(Math.min(s[1],s[3])+s[5])}}l=n}l||(c=this.cachedCanvases.getCanvas("maskCanvas",n,r),KQ(c.context,t));let h=HU.transform(s,[1/n,0,0,-1/r,0,0]);h=HU.transform(h,[1,0,0,1,0,-r]);const u=RQ.slice();HU.axialAlignedBoundingBox([0,0,n,r],h,u);const[d,f,p,g]=u,m=Math.round(p-d)||1,w=Math.round(g-f)||1,v=this.cachedCanvases.getCanvas("fillCanvas",m,w),y=v.context,b=d,B=f;y.translate(-b,-B),y.transform(...h),l||(l=this._scaleImage(c.canvas,lI(y)),l=l.img,a&&A&&a.set(o,l)),y.imageSmoothingEnabled=qQ(oI(y),t.interpolate),jQ(y,l,0,0,l.width,l.height,0,0,n,r),y.globalCompositeOperation="source-in";const _=HU.transform(lI(y),[1,0,0,1,-b,-B]);return y.fillStyle=A?i.getPattern(e,this,_,BQ):i,y.fillRect(0,0,n,r),a&&!A&&(this.cachedCanvases.delete("fillCanvas"),a.set(o,v.canvas)),{canvas:v.canvas,offsetX:Math.round(b),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=XQ[t]}setLineJoin(t){this.ctx.lineJoin=YQ[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(t),n.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[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.ctx.globalAlpha=this.current.fillAlpha=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)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(n,t,e);this.suspendedCtx=this.ctx;const i=this.ctx=r.context;i.setTransform(this.suspendedCtx.getTransform()),GQ(this.suspendedCtx,i),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,n){e.translate(t,n),this.__originalTranslate(t,n)},t.scale=function(t,n){e.scale(t,n),this.__originalScale(t,n)},t.transform=function(t,n,r,i,A,s){e.transform(t,n,r,i,A,s),this.__originalTransform(t,n,r,i,A,s)},t.setTransform=function(t,n,r,i,A,s){e.setTransform(t,n,r,i,A,s),this.__originalSetTransform(t,n,r,i,A,s)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,n){e.moveTo(t,n),this.__originalMoveTo(t,n)},t.lineTo=function(t,n){e.lineTo(t,n),this.__originalLineTo(t,n)},t.bezierCurveTo=function(t,n,r,i,A,s){e.bezierCurveTo(t,n,r,i,A,s),this.__originalBezierCurveTo(t,n,r,i,A,s)},t.rect=function(t,n,r,i){e.rect(t,n,r,i),this.__originalRect(t,n,r,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(i,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),GQ(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,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){const i=r[0],A=r[1],s=r[2]-i,a=r[3]-A;0!==s&&0!==a&&(this.genericComposeSMask(e.context,n,s,a,e.subtype,e.backdrop,e.transferMap,i,A,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,i,A,s,a,o,l,c){let h=t.canvas,u=a-l,d=o-c;if(A)if(u<0||d<0||u+n>h.width||d+r>h.height){const t=this.cachedCanvases.getCanvas("maskExtension",n,r),e=t.context;e.drawImage(h,-u,-d),e.globalCompositeOperation="destination-atop",e.fillStyle=A,e.fillRect(0,0,n,r),e.globalCompositeOperation="source-over",h=t.canvas,u=d=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,d,n,r),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=A,t.fillRect(u,d,n,r),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===i&&s?e.filter=this.filterFactory.addAlphaFilter(s):"Luminosity"===i&&(e.filter=this.filterFactory.addLuminosityFilter(s));const f=new Path2D;f.rect(a,o,n,r),e.clip(f),e.globalCompositeOperation="destination-in",e.drawImage(h,u,d,n,r,a,o,n,r),e.restore()}save(){this.inSMaskMode&&GQ(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&GQ(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,n,r,i,A){this.ctx.transform(t,e,n,r,i,A),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,n){let[r]=e;if(!n)return r||(r=e[0]=new Path2D),void this[t](r);if(!(r instanceof Path2D)){const t=e[0]=new Path2D;for(let e=0,n=r.length;e<n;)switch(r[e++]){case mU:t.moveTo(r[e++],r[e++]);break;case wU:t.lineTo(r[e++],r[e++]);break;case vU:t.bezierCurveTo(r[e++],r[e++],r[e++],r[e++],r[e++],r[e++]);break;case yU:t.closePath();break;default:CU(`Unrecognized drawing path operator: ${r[e-1]}`)}r=t}HU.axialAlignedBoundingBox(n,oI(this.ctx),this.current.minMax),this[t](r)}closePath(){this.ctx.closePath()}stroke(t,e=!0){const n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof r&&(null==r?void 0:r.getPattern)){const e=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,lI(n),_Q),e){const r=new Path2D;r.addPath(t,n.getTransform().invertSelf().multiplySelf(e)),t=r}this.rescaleAndStroke(t,!1),n.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(_Q,oI(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,e=!0){const n=this.ctx,r=this.current.fillColor;let i=!1;if(this.current.patternFill){const e=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.fillStyle=r.getPattern(n,this,lI(n),BQ),e){const r=new Path2D;r.addPath(t,n.getTransform().invertSelf().multiplySelf(e)),t=r}i=!0}const A=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==A&&(this.pendingEOFill?(n.fill(t,"evenodd"),this.pendingEOFill=!1):n.fill(t)),i&&n.restore(),e&&this.consumePath(t,A)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=$Q}eoClip(){this.pendingClip=JQ}beginText(){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return;const n=new Path2D,r=e.getTransform().invertSelf();for(const{transform:i,x:A,y:s,fontSize:a,path:o}of t)o&&n.addPath(o,new DOMMatrix(i).preMultiplySelf(r).translate(A,s).scale(a,-a));e.clip(n),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){var n;const r=this.commonObjs.get(t),i=this.current;if(!r)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=r.fontMatrix||jL,0!==i.fontMatrix[0]&&0!==i.fontMatrix[3]||CU("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=r,this.current.fontSize=e,r.isType3Font)return;const A=r.loadedName||"sans-serif",s=(null==(n=r.systemFontInfo)?void 0:n.css)||`"${A}", ${r.fallbackName}`;let a="normal";r.black?a="900":r.bold&&(a="bold");const o=r.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${s}`}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){const{current:e}=this;e.textMatrix=t,e.textMatrixScale=Math.hypot(t[0],t[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,n,r,i){const A=this.ctx,s=this.current,a=s.font,o=s.textRenderingMode,l=s.fontSize/s.fontSizeScale,c=o&sU,h=!!(o&aU),u=s.patternFill&&!a.missingFile,d=s.patternStroke&&!a.missingFile;let f;if((a.disableFontFace||h||u||d)&&!a.missingFile&&(f=a.getPathGenerator(this.commonObjs,t)),f&&(a.disableFontFace||u||d)){let t;if(A.save(),A.translate(e,n),A.scale(l,-l),c!==nU&&c!==iU||(r?(t=A.getTransform(),A.setTransform(...r),A.fill(Rc(this,fr,mr).call(this,f,t,r))):A.fill(f)),c===rU||c===iU)if(i){t||(t=A.getTransform()),A.setTransform(...i);const{a:e,b:n,c:r,d:s}=t,a=HU.inverseTransform(i),o=HU.transform([e,n,r,s,0,0],a);HU.singularValueDecompose2dScale(o,DQ),A.lineWidth*=Math.max(DQ[0],DQ[1])/l,A.stroke(Rc(this,fr,mr).call(this,f,t,i))}else A.lineWidth/=l,A.stroke(f);A.restore()}else c!==nU&&c!==iU||A.fillText(t,e,n),c!==rU&&c!==iU||A.strokeText(t,e,n);if(h){(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:oI(A),x:e,y:n,fontSize:l,path:f})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let n=!1;for(let r=3;r<e.length;r+=4)if(e[r]>0&&e[r]<255){n=!0;break}return LU(this,"isFontSubpixelAAEnabled",n)}showText(t){const e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);const r=e.fontSize;if(0===r)return;const i=this.ctx,A=e.fontSizeScale,s=e.charSpacing,a=e.wordSpacing,o=e.fontDirection,l=e.textHScale*o,c=t.length,h=n.vertical,u=h?1:-1,d=n.defaultVMetrics,f=r*e.fontMatrix[0],p=e.textRenderingMode===nU&&!n.disableFontFace&&!e.patternFill;let g,m;if(i.save(),e.textMatrix&&i.transform(...e.textMatrix),i.translate(e.x,e.y+e.textRise),o>0?i.scale(l,-1):i.scale(l,1),e.patternFill){i.save();const t=e.fillColor.getPattern(i,this,lI(i),BQ);g=oI(i),i.restore(),i.fillStyle=t}if(e.patternStroke){i.save();const t=e.strokeColor.getPattern(i,this,lI(i),_Q);m=oI(i),i.restore(),i.strokeStyle=t}let w=e.lineWidth;const v=e.textMatrixScale;if(0===v||0===w){const t=e.textRenderingMode&sU;t!==rU&&t!==iU||(w=this.getSinglePixelWidth())}else w/=v;if(1!==A&&(i.scale(A,A),w/=A),i.lineWidth=w,n.isInvalidPDFjsFont){const n=[];let r=0;for(const e of t)n.push(e.unicode),r+=e.width;return i.fillText(n.join(""),0,0),e.x+=r*f*l,i.restore(),void this.compose()}let y,b=0;for(y=0;y<c;++y){const e=t[y];if("number"==typeof e){b+=u*e*r/1e3;continue}let l=!1;const c=(e.isSpace?a:0)+s,w=e.fontChar,v=e.accent;let B,_,C=e.width;if(h){const t=e.vmetric||d,n=-(e.vmetric?t[1]:.5*C)*f,r=t[2]*f;C=t?-t[0]:C,B=n/A,_=(b+r)/A}else B=b/A,_=0;if(n.remeasure&&C>0){const t=1e3*i.measureText(w).width/r*A;if(C<t&&this.isFontSubpixelAAEnabled){const e=C/t;l=!0,i.save(),i.scale(e,1),B/=e}else C!==t&&(B+=(C-t)/2e3*r/A)}if(this.contentVisible&&(e.isInFont||n.missingFile))if(p&&!v)i.fillText(w,B,_);else if(this.paintChar(w,B,_,g,m),v){const t=B+r*v.offset.x/A,e=_-r*v.offset.y/A;this.paintChar(v.fontChar,t,e,g,m)}b+=h?C*f-c*o:C*f+c*o,l&&i.restore()}h?e.y-=b:e.x+=b*l,i.restore(),this.compose()}showType3Text(t){const e=this.ctx,n=this.current,r=n.font,i=n.fontSize,A=n.fontDirection,s=r.vertical?1:-1,a=n.charSpacing,o=n.wordSpacing,l=n.textHScale*A,c=n.fontMatrix||jL,h=t.length;let u,d,f,p;if(!(n.textRenderingMode===AU)&&0!==i){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),n.textMatrix&&e.transform(...n.textMatrix),e.translate(n.x,n.y+n.textRise),e.scale(l,A),u=0;u<h;++u){if(d=t[u],"number"==typeof d){p=s*d*i/1e3,this.ctx.translate(p,0),n.x+=p*l;continue}const A=(d.isSpace?o:0)+a,h=r.charProcOperatorList[d.operatorListId];h?this.contentVisible&&(this.save(),e.scale(i,i),e.transform(...c),this.executeOperatorList(h),this.restore()):CU(`Type3 character "${d.operatorListId}" is not available.`);const g=[d.width,0];HU.applyTransform(g,c),f=g[0]*i+A,e.translate(f,0),n.x+=f*l}e.restore()}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,n,r,i,A){const s=new Path2D;s.rect(n,r,i-n,A-r),this.ctx.clip(s),this.endPath()}getColorN_Pattern(e){let n;if("TilingPattern"===e[0]){const r=this.baseTransform||oI(this.ctx),i={createCanvasGraphics:e=>new t(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};n=new OQ(e,this.ctx,i,r)}else n=this._getPattern(e[1],e[2]);return n}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){this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t){this.ctx.fillStyle=this.current.fillColor=t,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=function(t){switch(t[0]){case"RadialAxial":return new SQ(t);case"Mesh":return new UQ(t);case"Dummy":return new IQ}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,n)),e&&(n.matrix=e),n}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const n=this._getPattern(t);e.fillStyle=n.getPattern(e,this,lI(e),CQ);const r=lI(e);if(r){const{width:t,height:n}=e.canvas,i=RQ.slice();HU.axialAlignedBoundingBox([0,0,t,n],r,i);const[A,s,a,o]=i;this.ctx.fillRect(A,s,a-A,o-s)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){xU("Should not call beginInlineImage")}beginImageData(){xU("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=oI(this.ctx),e)){HU.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[t,n,r,i]=e,A=new Path2D;A.rect(t,n,r-t,i-n),this.ctx.clip(A),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||_U("TODO: Support non-isolated groups."),t.knockout&&CU("Knockout groups not supported.");const n=oI(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let r=RQ.slice();HU.axialAlignedBoundingBox(t.bbox,oI(e),r);const i=[0,0,e.canvas.width,e.canvas.height];r=HU.intersect(r,i)||[0,0,0,0];const A=Math.floor(r[0]),s=Math.floor(r[1]),a=Math.max(Math.ceil(r[2])-A,1),o=Math.max(Math.ceil(r[3])-s,1);this.current.startNewPathAndClipBox([0,0,a,o]);let l="groupAt"+this.groupLevel;t.smask&&(l+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(l,a,o),h=c.context;h.translate(-A,-s),h.transform(...n);let u=new Path2D;const[d,f,p,g]=t.bbox;if(u.rect(d,f,p-d,g-f),t.matrix){const e=new Path2D;e.addPath(u,new DOMMatrix(t.matrix)),u=e}h.clip(u),t.smask?this.smaskStack.push({canvas:c.canvas,context:h,offsetX:A,offsetY:s,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(A,s),e.save()),GQ(e,h),this.ctx=h,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,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();const t=oI(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const n=RQ.slice();HU.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t,n),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,n,r,i){if(Rc(this,fr,pr).call(this),zQ(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],A=e[3]-e[1];if(i&&this.annotationCanvasMap){(n=n.slice())[4]-=e[0],n[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=r,e[3]=A,HU.singularValueDecompose2dScale(oI(this.ctx),DQ);const{viewportScale:i}=this,s=Math.ceil(r*this.outputScaleX*i),a=Math.ceil(A*this.outputScaleY*i);this.annotationCanvas=this.canvasFactory.create(s,a);const{canvas:o,context:l}=this.annotationCanvas;this.annotationCanvasMap.set(t,o),this.annotationCanvas.savedCtx=this.ctx,this.ctx=l,this.ctx.save(),this.ctx.setTransform(DQ[0],0,0,-DQ[1],0,A*DQ[1]),zQ(this.ctx)}else{zQ(this.ctx),this.endPath();const t=new Path2D;t.rect(e[0],e[1],r,A),this.ctx.clip(t)}}this.current=new WQ(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),Rc(this,fr,gr).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const n=this.ctx,r=this._createMaskCanvas(t),i=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(i,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,n=0,r=0,i,A){if(!this.contentVisible)return;t=this.getObject(t.data,t);const s=this.ctx;s.save();const a=oI(s);s.transform(e,n,r,i,0,0);const o=this._createMaskCanvas(t);s.setTransform(1,0,0,1,o.offsetX-a[4],o.offsetY-a[5]);for(let l=0,c=A.length;l<c;l+=2){const t=HU.transform(a,[e,n,r,i,A[l],A[l+1]]);s.drawImage(o.canvas,t[4],t[5])}s.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,n=this.current.fillColor,r=this.current.patternFill;for(const i of t){const{data:t,width:A,height:s,transform:a}=i,o=this.cachedCanvases.getCanvas("maskCanvas",A,s),l=o.context;l.save();KQ(l,this.getObject(t,i)),l.globalCompositeOperation="source-in",l.fillStyle=r?n.getPattern(l,this,lI(e),BQ):n,l.fillRect(0,0,A,s),l.restore(),e.save(),e.transform(...a),e.scale(1,-1),jQ(e,o.canvas,0,0,A,s,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):CU("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,n,r){if(!this.contentVisible)return;const i=this.getObject(t);if(!i)return void CU("Dependent image isn't ready yet");const A=i.width,s=i.height,a=[];for(let o=0,l=r.length;o<l;o+=2)a.push({transform:[e,0,0,n,r[o],r[o+1]],x:0,y:0,w:A,h:s});this.paintInlineImageXObjectGroup(i,a)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:n,height:r}=t,i=this.cachedCanvases.getCanvas("inlineImage",n,r),A=i.context;return A.filter=this.current.transferMaps,A.drawImage(e,0,0),A.filter="none",i.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,n=t.height,r=this.ctx;this.save();const{filter:i}=r;let A;if("none"!==i&&""!==i&&(r.filter="none"),r.scale(1/e,-1/n),t.bitmap)A=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)A=t;else{const r=this.cachedCanvases.getCanvas("inlineImage",e,n).context;VQ(r,t),A=this.applyTransferMapsToCanvas(r)}const s=this._scaleImage(A,lI(r));r.imageSmoothingEnabled=qQ(oI(r),t.interpolate),jQ(r,s.img,0,0,s.paintWidth,s.paintHeight,0,-n,e,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const n=this.ctx;let r;if(t.bitmap)r=t.bitmap;else{const e=t.width,n=t.height,i=this.cachedCanvases.getCanvas("inlineImage",e,n).context;VQ(i,t),r=this.applyTransferMapsToCanvas(i)}for(const i of e)n.save(),n.transform(...i.transform),n.scale(1,-1),jQ(n,r,i.x,i.y,i.w,i.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){"OC"===t?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,e){const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const r=this.ctx;this.pendingClip&&(n||(this.pendingClip===JQ?r.clip(t,"evenodd"):r.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=oI(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),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(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:n,c:r,d:i}=this.ctx.getTransform();let A,s;if(0===n&&0===r){const n=Math.abs(e),r=Math.abs(i);if(n===r)if(0===t)A=s=1/n;else{const e=n*t;A=s=e<1?1/e:1}else if(0===t)A=1/n,s=1/r;else{const e=n*t,i=r*t;A=e<1?1/e:1,s=i<1?1/i:1}}else{const a=Math.abs(e*i-n*r),o=Math.hypot(e,n),l=Math.hypot(r,i);if(0===t)A=l/a,s=o/a;else{const e=t*a;A=l>e?l/e:1,s=o>e?o/e:1}}this._cachedScaleForStroking[0]=A,this._cachedScaleForStroking[1]=s}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:n,current:{lineWidth:r}}=this,[i,A]=this.getScaleForStroking();if(i===A)return n.lineWidth=(r||1)*i,void n.stroke(t);const s=n.getLineDash();e&&n.save(),n.scale(i,A),TQ.a=1/i,TQ.d=1/A;const a=new Path2D;if(a.addPath(t,TQ),s.length>0){const t=Math.max(i,A);n.setLineDash(s.map(e=>e/t)),n.lineDashOffset/=t}n.lineWidth=r||1,n.stroke(a),e&&n.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};for(const c3 in gU)void 0!==ZQ.prototype[c3]&&(ZQ.prototype[gU[c3]]=ZQ.prototype[c3]);class tk{static get workerPort(){return Nc(this,wr)}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");Dc(this,wr,t)}static get workerSrc(){return Nc(this,vr)}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");Dc(this,vr,t)}}wr=new WeakMap,vr=new WeakMap,Tc(tk,wr,null),Tc(tk,vr,"");class ek{constructor({parsedData:t,rawData:e}){Tc(this,yr),Tc(this,br),Dc(this,yr,t),Dc(this,br,e)}getRaw(){return Nc(this,br)}get(t){var e;return null!=(e=Nc(this,yr).get(t))?e:null}[Symbol.iterator](){return Nc(this,yr).entries()}}yr=new WeakMap,br=new WeakMap;const nk=Symbol("INTERNAL");class rk{constructor(t,{name:e,intent:n,usage:r,rbGroups:i}){Tc(this,Br,!1),Tc(this,_r,!1),Tc(this,Cr,!1),Tc(this,xr,!0),Dc(this,Br,!!(t&KL)),Dc(this,_r,!!(t&GL)),this.name=e,this.intent=n,this.usage=r,this.rbGroups=i}get visible(){if(Nc(this,Cr))return Nc(this,xr);if(!Nc(this,xr))return!1;const{print:t,view:e}=this.usage;return Nc(this,Br)?"OFF"!==(null==e?void 0:e.viewState):!Nc(this,_r)||"OFF"!==(null==t?void 0:t.printState)}_setVisible(t,e,n=!1){t!==nk&&xU("Internal method `_setVisible` called."),Dc(this,Cr,n),Dc(this,xr,e)}}Br=new WeakMap,_r=new WeakMap,Cr=new WeakMap,xr=new WeakMap;class ik{constructor(t,e=KL){if(Tc(this,Ur),Tc(this,Er,null),Tc(this,Sr,new Map),Tc(this,Fr,null),Tc(this,Lr,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,Dc(this,Lr,t.order);for(const n of t.groups)Nc(this,Sr).set(n.id,new rk(e,n));if("OFF"===t.baseState)for(const t of Nc(this,Sr).values())t._setVisible(nk,!1);for(const e of t.on)Nc(this,Sr).get(e)._setVisible(nk,!0);for(const e of t.off)Nc(this,Sr).get(e)._setVisible(nk,!1);Dc(this,Fr,this.getHash())}}isVisible(t){if(0===Nc(this,Sr).size)return!0;if(!t)return _U("Optional content group not defined."),!0;if("OCG"===t.type)return Nc(this,Sr).has(t.id)?Nc(this,Sr).get(t.id).visible:(CU(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return Rc(this,Ur,Ir).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(Nc(this,Sr).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(!Nc(this,Sr).get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(!Nc(this,Sr).get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(Nc(this,Sr).get(e).visible)return!1}return!0}return CU(`Unknown optional content policy ${t.policy}.`),!0}return CU(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,n=!0){var r;const i=Nc(this,Sr).get(t);if(i){if(n&&e&&i.rbGroups.length)for(const e of i.rbGroups)for(const n of e)n!==t&&(null==(r=Nc(this,Sr).get(n))||r._setVisible(nk,!1,!0));i._setVisible(nk,!!e,!0),Dc(this,Er,null)}else CU(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let n;for(const r of t){switch(r){case"ON":case"OFF":case"Toggle":n=r;continue}const t=Nc(this,Sr).get(r);if(t)switch(n){case"ON":this.setVisibility(r,!0,e);break;case"OFF":this.setVisibility(r,!1,e);break;case"Toggle":this.setVisibility(r,!t.visible,e)}}Dc(this,Er,null)}get hasInitialVisibility(){return null===Nc(this,Fr)||this.getHash()===Nc(this,Fr)}getOrder(){return Nc(this,Sr).size?Nc(this,Lr)?Nc(this,Lr).slice():[...Nc(this,Sr).keys()]:null}getGroup(t){return Nc(this,Sr).get(t)||null}getHash(){if(null!==Nc(this,Er))return Nc(this,Er);const t=new NI;for(const[e,n]of Nc(this,Sr))t.update(`${e}:${n.visible}`);return Dc(this,Er,t.hexdigest())}[Symbol.iterator](){return Nc(this,Sr).entries()}}Er=new WeakMap,Sr=new WeakMap,Fr=new WeakMap,Lr=new WeakMap,Ur=new WeakSet,Ir=function(t){const e=t.length;if(e<2)return!0;const n=t[0];for(let r=1;r<e;r++){const e=t[r];let i;if(Array.isArray(e))i=Rc(this,Ur,Ir).call(this,e);else{if(!Nc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;i=Nc(this,Sr).get(e).visible}switch(n){case"And":if(!i)return!1;break;case"Or":if(i)return!0;break;case"Not":return!i;default:return!0}}return"And"===n};class Ak{constructor(t,{disableRange:e=!1,disableStream:n=!1}){EU(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:r,initialData:i,progressiveDone:A,contentDispositionFilename:s}=t;if(this._queuedChunks=[],this._progressiveDone=A,this._contentDispositionFilename=s,(null==i?void 0:i.length)>0){const t=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!e,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const n=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{EU(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(n),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t,e;return null!=(e=null==(t=this._fullRequestReader)?void 0:t._loaded)?e:0}_onProgress(t){var e,n,r,i;void 0===t.total?null==(n=null==(e=this._rangeReaders[0])?void 0:e.onProgress)||n.call(e,{loaded:t.loaded}):null==(i=null==(r=this._fullRequestReader)?void 0:r.onProgress)||i.call(r,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;null==(t=this._fullRequestReader)||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){EU(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new sk(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new ak(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(n),n}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const n of this._rangeReaders.slice(0))n.cancel(t);this._pdfDataRangeTransport.abort()}}class sk{constructor(t,e,n=!1,r=null){this._stream=t,this._done=n||!1,this._filename=eI(r)?r:null,this._queuedChunks=e||[],this._loaded=0;for(const i of this._queuedChunks)this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){return Wc(this,null,function*(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise})}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class ak{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(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){return Wc(this,null,function*(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise})}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ok(t,e){const n=new Headers;if(!t||!e||"object"!=typeof e)return n;for(const r in e){const t=e[r];void 0!==t&&n.append(r,t)}return n}function lk(t){var e,n;return null!=(n=null==(e=URL.parse(t))?void 0:e.origin)?n:null}function ck({responseHeaders:t,isHttp:e,rangeChunkSize:n,disableRange:r}){const i={allowRangeRequests:!1,suggestedLength:void 0},A=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(A))return i;if(i.suggestedLength=A,A<=2*n)return i;if(r||!e)return i;if("bytes"!==t.get("Accept-Ranges"))return i;return"identity"!==(t.get("Content-Encoding")||"identity")||(i.allowRangeRequests=!0),i}function hk(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,n=r("filename\\*","i").exec(t);if(n){n=n[1];let t=s(n);return t=unescape(t),t=a(t),t=o(t),A(t)}if(n=function(t){const e=[];let n;const i=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(n=i.exec(t));){let[,t,r,i]=n;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[r,i]}const A=[];for(let r=0;r<e.length&&r in e;++r){let[t,n]=e[r];n=s(n),t&&(n=unescape(n),0===r&&(n=a(n))),A.push(n)}return A.join("")}(t),n)return A(o(n));if(n=r("filename","i").exec(t),n){n=n[1];let t=s(n);return t=o(t),A(t)}function r(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function i(t,n){if(t){if(!/^[\x00-\xFF]+$/.test(n))return n;try{const r=new TextDecoder(t,{fatal:!0}),i=TU(n);n=r.decode(i),e=!1}catch(hw){}}return n}function A(t){return e&&/[\x80-\xff]/.test(t)&&(t=i("utf-8",t),e&&(t=i("iso-8859-1",t))),t}function s(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const n=e[t].indexOf('"');-1!==n&&(e[t]=e[t].slice(0,n),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function a(t){const e=t.indexOf("'");return-1===e?t:i(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function o(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,n,r){if("q"===n||"Q"===n)return i(e,r=(r=r.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{r=atob(r)}catch(hw){}return i(e,r)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch(hw){}if(eI(t))return t}return null}function uk(t,e){return new MU(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function dk(t){return 200===t||206===t}function fk(t,e,n){return{method:"GET",headers:t,signal:n.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function pk(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(CU(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class gk{constructor(t){Oc(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=ok(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!=(e=null==(t=this._fullRequestReader)?void 0:t._loaded)?e:0}getFullReader(){return EU(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new mk(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new wk(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class mk{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const n=new Headers(t.headers),r=e.url;fetch(r,fk(n,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=lk(e.url),!dk(e.status))throw uk(e.status,r);this._reader=e.body.getReader(),this._headersCapability.resolve();const n=e.headers,{allowRangeRequests:i,suggestedLength:A}=ck({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=A||this._contentLength,this._filename=hk(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new PU("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}read(){return Wc(this,null,function*(){var t;yield this._headersCapability.promise;const{value:e,done:n}=yield this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength}),{value:pk(e),done:!1})})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class wk{constructor(t,e,n){this._stream=t,this._reader=null,this._loaded=0;const r=t.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;const i=new Headers(t.headers);i.append("Range",`bytes=${e}-${n-1}`);const A=r.url;fetch(A,fk(i,this._withCredentials,this._abortController)).then(e=>{const n=lk(e.url);if(n!==t._responseOrigin)throw new Error(`Expected range response-origin "${n}" to match "${t._responseOrigin}".`);if(!dk(e.status))throw uk(e.status,A);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){return Wc(this,null,function*(){var t;yield this._readCapability.promise;const{value:e,done:n}=yield this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded}),{value:pk(e),done:!1})})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class vk{constructor({url:t,httpHeaders:e,withCredentials:n}){Oc(this,"_responseOrigin",null),this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=ok(this.isHttp,e),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,n=this.currXhrId++,r=this.pendingRequests[n]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[i,A]of this.headers)e.setRequestHeader(i,A);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),r.expectedStatus=206):r.expectedStatus=200,e.responseType="arraybuffer",EU(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){var n;const r=this.pendingRequests[t];r&&(null==(n=r.onProgress)||n.call(r,e))}onStateChange(t,e){const n=this.pendingRequests[t];if(!n)return;const r=n.xhr;if(r.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),4!==r.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===r.status&&this.isHttp)return void n.onError(r.status);const i=r.status||200;if(!(200===i&&206===n.expectedStatus)&&i!==n.expectedStatus)return void n.onError(r.status);const A=function(t){const e=t.response;return"string"!=typeof e?e:TU(e).buffer}(r);if(206===i){const t=r.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?n.onDone({begin:parseInt(e[1],10),chunk:A}):(CU('Missing or invalid "Content-Range" header.'),n.onError(0))}else A?n.onDone({begin:0,chunk:A}):n.onError(r.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class yk{constructor(t){this._source=t,this._manager=new vk(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return EU(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new bk(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const n=new Bk(this._manager,t,e);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class bk{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=lk(e.responseURL);const n=e.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{const[e,...n]=t.split(": ");return[e,n.join(": ")]}):[]),{allowRangeRequests:i,suggestedLength:A}=ck({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=A||this._contentLength,this._filename=hk(r),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=uk(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;null==(e=this.onProgress)||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}read(){return Wc(this,null,function*(){if(yield this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise})}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Bk{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(){var t;const e=lk(null==(t=this._manager.getRequestXhr(this._requestId))?void 0:t.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;null==(t=this.onClosed)||t.call(this,this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){null!=this._storedError||(this._storedError=uk(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||null==(e=this.onProgress)||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}read(){return Wc(this,null,function*(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise})}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const _k=/^[a-z][a-z0-9\-+.]+:/i;class Ck{constructor(t){this.source=t,this.url=function(t){if(_k.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),EU("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!=(e=null==(t=this._fullRequestReader)?void 0:t._loaded)?e:0}getFullReader(){return EU(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new xk(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new Ek(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class xk{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const n=process.getBuiltinModule("fs");n.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=uk(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return Wc(this,null,function*(){var t;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(e).buffer,done:!1}})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new PU("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Ek{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();const r=t.source;this._isStreamingSupported=!r.disableStream;const i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){return Wc(this,null,function*(){var t;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded});return{value:new Uint8Array(e).buffer,done:!1}})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Sk=Symbol("INITIAL_DATA");class Fk{constructor(){Tc(this,kr),Tc(this,Qr,Object.create(null))}get(t,e=null){if(e){const n=Rc(this,kr,Mr).call(this,t);return n.promise.then(()=>e(n.data)),null}const n=Nc(this,Qr)[t];if(!n||n.data===Sk)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return n.data}has(t){const e=Nc(this,Qr)[t];return!!e&&e.data!==Sk}delete(t){const e=Nc(this,Qr)[t];return!(!e||e.data===Sk)&&(delete Nc(this,Qr)[t],!0)}resolve(t,e=null){const n=Rc(this,kr,Mr).call(this,t);n.data=e,n.resolve()}clear(){var t;for(const e in Nc(this,Qr)){const{data:n}=Nc(this,Qr)[e];null==(t=null==n?void 0:n.bitmap)||t.close()}Dc(this,Qr,Object.create(null))}*[Symbol.iterator](){for(const t in Nc(this,Qr)){const{data:e}=Nc(this,Qr)[t];e!==Sk&&(yield[t,e])}}}Qr=new WeakMap,kr=new WeakSet,Mr=function(t){var e;return(e=Nc(this,Qr))[t]||(e[t]=kc(Qc({},Promise.withResolvers()),{data:Sk}))};const Lk=class t{constructor({textContentSource:e,container:n,viewport:r}){var i;if(Tc(this,Ai),Tc(this,Pr,Promise.withResolvers()),Tc(this,Nr,null),Tc(this,Tr,!1),Tc(this,Dr,!!(null==(Or=globalThis.FontInspector)?void 0:Or.enabled)),Tc(this,Rr,null),Tc(this,Hr,null),Tc(this,jr,0),Tc(this,Wr,0),Tc(this,Vr,null),Tc(this,Kr,null),Tc(this,Gr,0),Tc(this,zr,0),Tc(this,qr,Object.create(null)),Tc(this,Xr,[]),Tc(this,Yr,null),Tc(this,$r,[]),Tc(this,Jr,new WeakMap),Tc(this,Zr,null),e instanceof ReadableStream)Dc(this,Yr,e);else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');Dc(this,Yr,new ReadableStream({start(t){t.enqueue(e),t.close()}}))}Dc(this,Nr,Dc(this,Kr,n)),Dc(this,zr,r.scale*hI.pixelRatio),Dc(this,Gr,r.rotation),Dc(this,Hr,{div:null,properties:null,ctx:null});const{pageWidth:A,pageHeight:s,pageX:a,pageY:o}=r.rawDims;Dc(this,Zr,[1,0,0,-1,-a,o+s]),Dc(this,Wr,A),Dc(this,jr,s),Rc(i=t,li,ui).call(i),cI(n,r),Nc(this,Pr).promise.finally(()=>{Nc(t,ii).delete(this),Dc(this,Hr,null),Dc(this,qr,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=DU.platform;return LU(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{Nc(this,Vr).read().then(({value:t,done:n})=>{n?Nc(this,Pr).resolve():(null!=Nc(this,Rr)||Dc(this,Rr,t.lang),Object.assign(Nc(this,qr),t.styles),Rc(this,Ai,si).call(this,t.items),e())},Nc(this,Pr).reject)};return Dc(this,Vr,Nc(this,Yr).getReader()),Nc(t,ii).add(this),e(),Nc(this,Pr).promise}update({viewport:e,onBefore:n=null}){var r;const i=e.scale*hI.pixelRatio,A=e.rotation;if(A!==Nc(this,Gr)&&(null==n||n(),Dc(this,Gr,A),cI(Nc(this,Kr),{rotation:A})),i!==Nc(this,zr)){null==n||n(),Dc(this,zr,i);const e={div:null,properties:null,ctx:Rc(r=t,li,ci).call(r,Nc(this,Rr))};for(const t of Nc(this,$r))e.properties=Nc(this,Jr).get(t),e.div=t,Rc(this,Ai,oi).call(this,e)}}cancel(){var t;const e=new PU("TextLayer task cancelled.");null==(t=Nc(this,Vr))||t.cancel(e).catch(()=>{}),Dc(this,Vr,null),Nc(this,Pr).reject(e)}get textDivs(){return Nc(this,$r)}get textContentItemsStr(){return Nc(this,Xr)}static cleanup(){if(!(Nc(this,ii).size>0)){Nc(this,ti).clear();for(const{canvas:t}of Nc(this,ei).values())t.remove();Nc(this,ei).clear()}}};Pr=new WeakMap,Nr=new WeakMap,Tr=new WeakMap,Dr=new WeakMap,Rr=new WeakMap,Hr=new WeakMap,jr=new WeakMap,Wr=new WeakMap,Vr=new WeakMap,Kr=new WeakMap,Gr=new WeakMap,zr=new WeakMap,qr=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,$r=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,ti=new WeakMap,ei=new WeakMap,ni=new WeakMap,ri=new WeakMap,ii=new WeakMap,Ai=new WeakSet,si=function(t){var e,n;if(Nc(this,Tr))return;null!=(n=Nc(this,Hr)).ctx||(n.ctx=Rc(e=Lk,li,ci).call(e,Nc(this,Rr)));const r=Nc(this,$r),i=Nc(this,Xr);for(const A of t){if(r.length>1e5)return CU("Ignoring additional textDivs for performance reasons."),void Dc(this,Tr,!0);if(void 0!==A.str)i.push(A.str),Rc(this,Ai,ai).call(this,A);else if("beginMarkedContentProps"===A.type||"beginMarkedContent"===A.type){const t=Nc(this,Nr);Dc(this,Nr,document.createElement("span")),Nc(this,Nr).classList.add("markedContent"),A.id&&Nc(this,Nr).setAttribute("id",`${A.id}`),t.append(Nc(this,Nr))}else"endMarkedContent"===A.type&&Dc(this,Nr,Nc(this,Nr).parentNode)}},ai=function(t){var e;const n=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};Nc(this,$r).push(n);const i=HU.transform(Nc(this,Zr),t.transform);let A=Math.atan2(i[1],i[0]);const s=Nc(this,qr)[t.fontName];s.vertical&&(A+=Math.PI/2);let a=Nc(this,Dr)&&s.fontSubstitution||s.fontFamily;a=Lk.fontFamilyMap.get(a)||a;const o=Math.hypot(i[2],i[3]),l=o*Rc(e=Lk,li,di).call(e,a,s,Nc(this,Rr));let c,h;0===A?(c=i[4],h=i[5]-l):(c=i[4]+l*Math.sin(A),h=i[5]-l*Math.cos(A));const u="calc(var(--total-scale-factor) *",d=n.style;Nc(this,Nr)===Nc(this,Kr)?(d.left=`${(100*c/Nc(this,Wr)).toFixed(2)}%`,d.top=`${(100*h/Nc(this,jr)).toFixed(2)}%`):(d.left=`${u}${c.toFixed(2)}px)`,d.top=`${u}${h.toFixed(2)}px)`),d.fontSize=`${u}${(Nc(Lk,ri)*o).toFixed(2)}px)`,d.fontFamily=a,r.fontSize=o,n.setAttribute("role","presentation"),n.textContent=t.str,n.dir=t.dir,Nc(this,Dr)&&(n.dataset.fontName=s.fontSubstitutionLoadedName||t.fontName),0!==A&&(r.angle=A*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(f=!0)}if(f&&(r.canvasWidth=s.vertical?t.height:t.width),Nc(this,Jr).set(n,r),Nc(this,Hr).div=n,Nc(this,Hr).properties=r,Rc(this,Ai,oi).call(this,Nc(this,Hr)),r.hasText&&Nc(this,Nr).append(n),r.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),Nc(this,Nr).append(t)}},oi=function(t){var e;const{div:n,properties:r,ctx:i}=t,{style:A}=n;let s="";if(Nc(Lk,ri)>1&&(s=`scale(${1/Nc(Lk,ri)})`),0!==r.canvasWidth&&r.hasText){const{fontFamily:t}=A,{canvasWidth:a,fontSize:o}=r;Rc(e=Lk,li,hi).call(e,i,o*Nc(this,zr),t);const{width:l}=i.measureText(n.textContent);l>0&&(s=`scaleX(${a*Nc(this,zr)/l}) ${s}`)}0!==r.angle&&(s=`rotate(${r.angle}deg) ${s}`),s.length>0&&(A.transform=s)},li=new WeakSet,ci=function(t=null){let e=Nc(this,ei).get(t||(t=""));if(!e){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=t,document.body.append(n),e=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),Nc(this,ei).set(t,e),Nc(this,ni).set(e,{size:0,family:""})}return e},hi=function(t,e,n){const r=Nc(this,ni).get(t);e===r.size&&n===r.family||(t.font=`${e}px ${n}`,r.size=e,r.family=n)},ui=function(){if(null!==Nc(this,ri))return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),Dc(this,ri,t.getBoundingClientRect().height),t.remove()},di=function(t,e,n){const r=Nc(this,ti).get(t);if(r)return r;const i=Rc(this,li,ci).call(this,n);i.canvas.width=i.canvas.height=30,Rc(this,li,hi).call(this,i,30,t);const A=i.measureText(""),s=A.fontBoundingBoxAscent,a=Math.abs(A.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let o=.8;return s?o=s/(s+a):(DU.platform.isFirefox&&CU("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?o=e.ascent:e.descent&&(o=1+e.descent)),Nc(this,ti).set(t,o),o},Tc(Lk,li),Tc(Lk,ti,new Map),Tc(Lk,ei,new Map),Tc(Lk,ni,new WeakMap),Tc(Lk,ri,null),Tc(Lk,ii,new Set);let Uk=Lk;class Ik{static textContent(t){const e=[],n={items:e,styles:Object.create(null)};return function t(n){var r;if(!n)return;let i=null;const A=n.name;if("#text"===A)i=n.value;else{if(!Ik.shouldBuildText(A))return;(null==(r=null==n?void 0:n.attributes)?void 0:r.textContent)?i=n.attributes.textContent:n.value&&(i=n.value)}if(null!==i&&e.push({str:i}),n.children)for(const e of n.children)t(e)}(t),n}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}function Qk(t={}){var e,n;"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const r=new Mk,{docId:i}=r,A=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(HL)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,s=t.data?function(t){if(HL&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return TU(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(null==t?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,a=t.httpHeaders||null,o=!0===t.withCredentials,l=null!=(e=t.password)?e:null,c=t.range instanceof Ok?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:Uc(2,16);let u=t.worker instanceof Dk?t.worker:null;const d=t.verbosity,f="string"!=typeof t.docBaseUrl||tI(t.docBaseUrl)?null:t.docBaseUrl,p=WI(t.cMapUrl),g=!1!==t.cMapPacked,m=t.CMapReaderFactory||(HL?vQ:lQ),w=WI(t.iccUrl),v=WI(t.standardFontDataUrl),y=t.StandardFontDataFactory||(HL?yQ:dQ),b=WI(t.wasmUrl),B=t.WasmFactory||(HL?bQ:pQ),_=!0!==t.stopAtErrors,C=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,x=!1!==t.isEvalSupported,E="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!HL,S="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!HL&&(DU.platform.isFirefox||!globalThis.chrome),F=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,L="boolean"==typeof t.disableFontFace?t.disableFontFace:HL,U=!0===t.fontExtraProperties,I=!0===t.enableXfa,Q=t.ownerDocument||globalThis.document,k=!0===t.disableRange,M=!0===t.disableStream,O=!0===t.disableAutoFetch,P=!0===t.pdfBug,N=t.CanvasFactory||(HL?wQ:aQ),T=t.FilterFactory||(HL?mQ:hQ),D=!0===t.enableHWA,R=!1!==t.useWasm,H=c?c.length:null!=(n=t.length)?n:NaN,j="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!HL&&!L,W="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(m===lQ&&y===dQ&&B===pQ&&p&&v&&b&&rI(p,document.baseURI)&&rI(v,document.baseURI)&&rI(b,document.baseURI));var V;V=d,Number.isInteger(V)&&(bU=V);const K={canvasFactory:new N({ownerDocument:Q,enableHWA:D}),filterFactory:new T({docId:i,ownerDocument:Q}),cMapReaderFactory:W?null:new m({baseUrl:p,isCompressed:g}),standardFontDataFactory:W?null:new y({baseUrl:v}),wasmFactory:W?null:new B({baseUrl:b})};u||(u=Dk.create({verbosity:d,port:tk.workerPort}),r._worker=u);const G={docId:i,apiVersion:"5.4.54",data:s,password:l,disableAutoFetch:O,rangeChunkSize:h,length:H,docBaseUrl:f,enableXfa:I,evaluatorOptions:{maxImageSize:C,disableFontFace:L,ignoreErrors:_,isEvalSupported:x,isOffscreenCanvasSupported:E,isImageDecoderSupported:S,canvasMaxAreaInBytes:F,fontExtraProperties:U,useSystemFonts:j,useWasm:R,useWorkerFetch:W,cMapUrl:p,iccUrl:w,standardFontDataUrl:v,wasmUrl:b}},z={ownerDocument:Q,pdfBug:P,styleElement:null,loadingParams:{disableAutoFetch:O,enableXfa:I}};return u.promise.then(function(){if(r.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const t=u.messageHandler.sendWithPromise("GetDocRequest",G,s?[s.buffer]:null);let e;if(c)e=new Ak(c,{disableRange:k,disableStream:M});else if(!s){if(!A)throw new Error("getDocument - no `url` parameter provided.");const t=rI(A)?gk:HL?Ck:yk;e=new t({url:A,length:H,httpHeaders:a,withCredentials:o,rangeChunkSize:h,disableRange:k,disableStream:M})}return t.then(t=>{if(r.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const n=new AQ(i,t,u.port),A=new Rk(n,r,e,z,K,D);r._transport=A,n.send("Ready",null)})}).catch(r._capability.reject),r}const kk=class t{constructor(){Oc(this,"_capability",Promise.withResolvers()),Oc(this,"_transport",null),Oc(this,"_worker",null),Oc(this,"docId","d"+Hc(t,fi)._++),Oc(this,"destroyed",!1),Oc(this,"onPassword",null),Oc(this,"onProgress",null)}get promise(){return this._capability.promise}destroy(){return Wc(this,null,function*(){var t,e,n,r;this.destroyed=!0;try{(null==(t=this._worker)?void 0:t.port)&&(this._worker._pendingDestroy=!0),yield null==(e=this._transport)?void 0:e.destroy()}catch(i){throw(null==(n=this._worker)?void 0:n.port)&&delete this._worker._pendingDestroy,i}this._transport=null,null==(r=this._worker)||r.destroy(),this._worker=null})}getData(){return Wc(this,null,function*(){return this._transport.getData()})}};fi=new WeakMap,Tc(kk,fi,0);let Mk=kk;class Ok{constructor(t,e,n=!1,r=null){Tc(this,pi,Promise.withResolvers()),Tc(this,gi,[]),Tc(this,mi,[]),Tc(this,wi,[]),Tc(this,vi,[]),this.length=t,this.initialData=e,this.progressiveDone=n,this.contentDispositionFilename=r}addRangeListener(t){Nc(this,vi).push(t)}addProgressListener(t){Nc(this,wi).push(t)}addProgressiveReadListener(t){Nc(this,mi).push(t)}addProgressiveDoneListener(t){Nc(this,gi).push(t)}onDataRange(t,e){for(const n of Nc(this,vi))n(t,e)}onDataProgress(t,e){Nc(this,pi).promise.then(()=>{for(const n of Nc(this,wi))n(t,e)})}onDataProgressiveRead(t){Nc(this,pi).promise.then(()=>{for(const e of Nc(this,mi))e(t)})}onDataProgressiveDone(){Nc(this,pi).promise.then(()=>{for(const t of Nc(this,gi))t()})}transportReady(){Nc(this,pi).resolve()}requestDataRange(t,e){xU("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}pi=new WeakMap,gi=new WeakMap,mi=new WeakMap,wi=new WeakMap,vi=new WeakMap;class Pk{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 LU(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Nk{constructor(t,e,n,r=!1){Tc(this,bi),Tc(this,yi,!1),this._pageIndex=t,this._pageInfo=e,this._transport=n,this._stats=r?new nI:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new Fk,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:i=!1}={}){return new JU({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:r,dontFlip:i})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return LU(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){return Wc(this,null,function*(){var t;return(null==(t=this._transport._htmlForXfa)?void 0:t.children[this._pageIndex])||null})}render({canvasContext:t,canvas:e=t.canvas,viewport:n,intent:r="display",annotationMode:i=JL.ENABLE,transform:A=null,background:s=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:c=null,isEditing:h=!1}){var u,d;null==(u=this._stats)||u.time("Overall");const f=this._transport.getRenderingIntent(r,i,c,h),{renderingIntent:p,cacheKey:g}=f;Dc(this,yi,!1),a||(a=this._transport.getOptionalContentConfig(p));let m=this._intentStates.get(g);m||(m=Object.create(null),this._intentStates.set(g,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);const w=!!(p&GL);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(d=this._stats)||d.time("Page Request"),this._pumpOperatorList(f));const v=t=>{var e;m.renderTasks.delete(y),w&&Dc(this,yi,!0),Rc(this,bi,Bi).call(this),t?(y.capability.reject(t),this._abortOperatorList({intentState:m,reason:t instanceof Error?t:new Error(t)})):y.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(null==(e=globalThis.Stats)?void 0:e.enabled)&&globalThis.Stats.add(this.pageNumber,this._stats))},y=new Wk({callback:v,params:{canvas:e,canvasContext:t,viewport:n,transform:A,background:s},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:l,enableHWA:this._transport.enableHWA});(m.renderTasks||(m.renderTasks=new Set)).add(y);const b=y.task;return Promise.all([m.displayReadyCapability.promise,a]).then(([t,e])=>{var n;if(this.destroyed)v();else{if(null==(n=this._stats)||n.time("Rendering"),!(e.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");y.initializeGraphics({transparency:t,optionalContentConfig:e}),y.operatorListChanged()}}).catch(v),b}getOperatorList({intent:t="display",annotationMode:e=JL.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){var i;const A=this._transport.getRenderingIntent(t,e,n,r,!0);let s,a=this._intentStates.get(A.cacheKey);return a||(a=Object.create(null),this._intentStates.set(A.cacheKey,a)),a.opListReadCapability||(s=Object.create(null),s.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(s))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||(a.renderTasks=new Set)).add(s),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(i=this._stats)||i.time("Page Request"),this._pumpOperatorList(A)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>Ik.textContent(t));const e=this.streamTextContent(t);return new Promise(function(t,n){const r=e.getReader(),i={items:[],styles:Object.create(null),lang:null};!function e(){r.read().then(function({value:n,done:r}){r?t(i):(null!=i.lang||(i.lang=n.lang),Object.assign(i.styles,n.styles),i.items.push(...n.items),e())},n)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const n of e.renderTasks)t.push(n.completed),n.cancel();return this.objs.clear(),Dc(this,yi,!1),Promise.all(t)}cleanup(t=!1){Dc(this,yi,!0);const e=Rc(this,bi,Bi).call(this);return t&&e&&this._stats&&(this._stats=new nI),e}_startRenderPage(t,e){var n,r;const i=this._intentStates.get(e);i&&(null==(n=this._stats)||n.timeEnd("Page Request"),null==(r=i.displayReadyCapability)||r.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(const n of e.renderTasks)n.operatorListChanged();t.lastChunk&&Rc(this,bi,Bi).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:n,modifiedIds:r}){const{map:i,transfer:A}=n,s=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i,modifiedIds:r},A).getReader(),a=this._intentStates.get(e);a.streamReader=s;const o=()=>{s.read().then(({value:t,done:e})=>{e?a.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,a),o())},t=>{if(a.streamReader=null,!this._transport.destroyed){if(a.operatorList){a.operatorList.lastChunk=!0;for(const t of a.renderTasks)t.operatorListChanged();Rc(this,bi,Bi).call(this)}if(a.displayReadyCapability)a.displayReadyCapability.reject(t);else{if(!a.opListReadCapability)throw t;a.opListReadCapability.reject(t)}}})};o()}_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 ZU){let n=100;return e.extraDelay>0&&e.extraDelay<1e3&&(n+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},n))}}if(t.streamReader.cancel(new PU(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[e,n]of this._intentStates)if(n===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}yi=new WeakMap,bi=new WeakSet,Bi=function(){if(!Nc(this,yi)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Dc(this,yi,!1),!0};const Tk=class t{constructor({name:e=null,port:n=null,verbosity:r=BU()}={}){if(Tc(this,Ui),Tc(this,_i,Promise.withResolvers()),Tc(this,Ci,null),Tc(this,xi,null),Tc(this,Ei,null),this.name=e,this.destroyed=!1,this.verbosity=r,n){if(Nc(t,Li).has(n))throw new Error("Cannot use more than one PDFWorker per port.");Nc(t,Li).set(n,this),Rc(this,Ui,Qi).call(this,n)}else Rc(this,Ui,ki).call(this)}get promise(){return Nc(this,_i).promise}get port(){return Nc(this,xi)}get messageHandler(){return Nc(this,Ci)}destroy(){var e,n;this.destroyed=!0,null==(e=Nc(this,Ei))||e.terminate(),Dc(this,Ei,null),Nc(t,Li).delete(Nc(this,xi)),Dc(this,xi,null),null==(n=Nc(this,Ci))||n.destroy(),Dc(this,Ci,null)}static create(e){const n=Nc(this,Li).get(null==e?void 0:e.port);if(n){if(n._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new t(e)}static get workerSrc(){if(tk.workerSrc)return tk.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return LU(this,"_setupFakeWorkerGlobal",(()=>Wc(this,null,function*(){if(Nc(this,Oi,Pi))return Nc(this,Oi,Pi);return(yield import(this.workerSrc)).WorkerMessageHandler}))())}};_i=new WeakMap,Ci=new WeakMap,xi=new WeakMap,Ei=new WeakMap,Si=new WeakMap,Fi=new WeakMap,Li=new WeakMap,Ui=new WeakSet,Ii=function(){Nc(this,_i).resolve(),Nc(this,Ci).send("configure",{verbosity:this.verbosity})},Qi=function(t){Dc(this,xi,t),Dc(this,Ci,new AQ("main","worker",t)),Nc(this,Ci).on("ready",()=>{}),Rc(this,Ui,Ii).call(this)},ki=function(){if(Nc(Tk,Fi)||Nc(Tk,Oi,Pi))return void Rc(this,Ui,Mi).call(this);let{workerSrc:t}=Tk;try{Tk._isSameOrigin(window.location,t)||(t=Tk._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),n=new AQ("main","worker",e),r=()=>{i.abort(),n.destroy(),e.terminate(),this.destroyed?Nc(this,_i).reject(new Error("Worker was destroyed")):Rc(this,Ui,Mi).call(this)},i=new AbortController;e.addEventListener("error",()=>{Nc(this,Ei)||r()},{signal:i.signal}),n.on("test",t=>{i.abort(),!this.destroyed&&t?(Dc(this,Ci,n),Dc(this,xi,e),Dc(this,Ei,e),Rc(this,Ui,Ii).call(this)):r()}),n.on("ready",t=>{if(i.abort(),this.destroyed)r();else try{A()}catch(hw){Rc(this,Ui,Mi).call(this)}});const A=()=>{const t=new Uint8Array;n.send("test",t,[t.buffer])};return void A()}catch(hw){_U("The worker has been disabled.")}Rc(this,Ui,Mi).call(this)},Mi=function(){Nc(Tk,Fi)||(CU("Setting up fake worker."),Dc(Tk,Fi,!0)),Tk._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void Nc(this,_i).reject(new Error("Worker was destroyed"));const e=new GI;Dc(this,xi,e);const n="fake"+Hc(Tk,Si)._++,r=new AQ(n+"_worker",n,e);t.setup(r,e),Dc(this,Ci,new AQ(n,n+"_worker",e)),Rc(this,Ui,Ii).call(this)}).catch(t=>{Nc(this,_i).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Oi=new WeakSet,Pi=function(){var t;try{return(null==(t=globalThis.pdfjsWorker)?void 0:t.WorkerMessageHandler)||null}catch(hw){return null}},Tc(Tk,Oi),Tc(Tk,Si,0),Tc(Tk,Fi,!1),Tc(Tk,Li,new WeakMap),HL&&(Dc(Tk,Fi,!0),tk.workerSrc||(tk.workerSrc="./pdf.worker.mjs")),Tk._isSameOrigin=(t,e)=>{const n=URL.parse(t);if(!(null==n?void 0:n.origin)||"null"===n.origin)return!1;const r=new URL(e,n);return n.origin===r.origin},Tk._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Tk.fromPort=t=>{var e;if(e="`PDFWorker.fromPort` - please use `PDFWorker.create` instead.",console.log("Deprecated API usage: "+e),!(null==t?void 0:t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return Tk.create(t)};let Dk=Tk;class Rk{constructor(t,e,n,r,i,A){Tc(this,ji),Tc(this,Ni,new Map),Tc(this,Ti,new Map),Tc(this,Di,new Map),Tc(this,Ri,new Map),Tc(this,Hi,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Fk,this.fontLoader=new HI({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.wasmFactory=i.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=A,this.setupMessageHandler()}get annotationStorage(){return LU(this,"annotationStorage",new DI)}getRenderingIntent(t,e=JL.ENABLE,n=null,r=!1,i=!1){let A=KL,s=TI;switch(t){case"any":A=VL;break;case"display":break;case"print":A=GL;break;default:CU(`getRenderingIntent - invalid intent: ${t}`)}const a=A&GL&&n instanceof RI?n:this.annotationStorage;switch(e){case JL.DISABLE:A+=XL;break;case JL.ENABLE:break;case JL.ENABLE_FORMS:A+=zL;break;case JL.ENABLE_STORAGE:A+=qL,s=a.serializable;break;default:CU(`getRenderingIntent - invalid annotationMode: ${e}`)}r&&(A+=YL),i&&(A+=$L);const{ids:o,hash:l}=a.modifiedIds;return{renderingIntent:A,cacheKey:[A,s.hash,l].join("_"),annotationStorageSerializable:s,modifiedIds:o}}destroy(){var t;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null==(t=Nc(this,Hi))||t.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const r of Nc(this,Ti).values())e.push(r._destroy());Nc(this,Ti).clear(),Nc(this,Di).clear(),Nc(this,Ri).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then(()=>{var t,e;this.commonObjs.clear(),this.fontLoader.clear(),Nc(this,Ni).clear(),this.filterFactory.destroy(),Uk.cleanup(),null==(t=this._networkStream)||t.cancelAllRequests(new PU("Worker was terminated.")),null==(e=this.messageHandler)||e.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{EU(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:n}){n?e.close():(EU(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",t=>Wc(this,null,function*(){var t;yield this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:i}=this._fullReader;return n&&r||(this._lastProgress&&(null==(t=e.onProgress)||t.call(e,this._lastProgress)),this._fullReader.onProgress=t=>{var n;null==(n=e.onProgress)||n.call(e,{loaded:t.loaded,total:t.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:i}})),t.on("GetRangeReader",(t,e)=>{EU(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(t.begin,t.end);n?(e.onPull=()=>{n.read().then(function({value:t,done:n}){n?e.close():(EU(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{n.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Pk(t,this))}),t.on("DocException",t=>{e._capability.reject(iQ(t))}),t.on("PasswordRequest",t=>{Dc(this,Hi,Promise.withResolvers());try{if(!e.onPassword)throw iQ(t);const n=t=>{t instanceof Error?Nc(this,Hi).reject(t):Nc(this,Hi).resolve({password:t})};e.onPassword(n,t.code)}catch(n){Nc(this,Hi).reject(n)}return Nc(this,Hi).promise}),t.on("DataLoaded",t=>{var n;null==(n=e.onProgress)||n.call(e,{loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{if(this.destroyed)return;Nc(this,Ti).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,n,r])=>{var i;if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(n){case"Font":if("error"in r){const t=r.error;CU(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const A=this._params.pdfBug&&(null==(i=globalThis.FontInspector)?void 0:i.enabled)?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,s=new jI(r,A);this.fontLoader.bind(s).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!s.fontExtraProperties&&s.data&&(s.data=null),this.commonObjs.resolve(e,s)});break;case"CopyLocalImage":const{imageRef:a}=r;EU(a,"The imageRef must be defined.");for(const t of Nc(this,Ti).values())for(const[,n]of t.objs)if((null==n?void 0:n.ref)===a)return n.dataLen?(this.commonObjs.resolve(e,structuredClone(n)),n.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,r);break;default:throw new Error(`Got unknown common object type ${n}`)}return null}),t.on("obj",([t,e,n,r])=>{var i;if(this.destroyed)return;const A=Nc(this,Ti).get(e);if(!A.objs.has(t))if(0!==A._intentStates.size)switch(n){case"Image":case"Pattern":A.objs.resolve(t,r);break;default:throw new Error(`Got unknown object type ${n}`)}else null==(i=null==r?void 0:r.bitmap)||i.close()}),t.on("DocProgress",t=>{var n;this.destroyed||null==(n=e.onProgress)||n.call(e,{loaded:t.loaded,total:t.total})}),t.on("FetchBinaryData",t=>Wc(this,null,function*(){if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var t,e;this.annotationStorage.size<=0&&CU("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:n,transfer:r}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:n,filename:null!=(e=null==(t=this._fullReader)?void 0:t.filename)?e:null},r).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,n=Nc(this,Di).get(e);if(n)return n;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&Nc(this,Ri).set(n.refStr,t);const r=new Nk(e,n,this,this._params.pdfBug);return Nc(this,Ti).set(e,r),r});return Nc(this,Di).set(e,r),r}getPageIndex(t){return VI(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 Rc(this,ji,Wi).call(this,"GetFieldObjects")}hasJSActions(){return Rc(this,ji,Wi).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return Rc(this,ji,Wi).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return Rc(this,ji,Wi).call(this,"GetOptionalContentConfig").then(e=>new ik(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=Nc(this,Ni).get(t);if(e)return e;const n=this.messageHandler.sendWithPromise(t,null).then(t=>{var e,n,r,i;return{info:t[0],metadata:t[1]?new ek(t[1]):null,contentDispositionFilename:null!=(n=null==(e=this._fullReader)?void 0:e.filename)?n:null,contentLength:null!=(i=null==(r=this._fullReader)?void 0:r.contentLength)?i:null}});return Nc(this,Ni).set(t,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(t=!1){return Wc(this,null,function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(const t of Nc(this,Ti).values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),Nc(this,Ni).clear(),this.filterFactory.destroy(!0),Uk.cleanup()}})}cachedPageNumber(t){var e;if(!VI(t))return null;const n=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return null!=(e=Nc(this,Ri).get(n))?e:null}}Ni=new WeakMap,Ti=new WeakMap,Di=new WeakMap,Ri=new WeakMap,Hi=new WeakMap,ji=new WeakSet,Wi=function(t,e=null){const n=Nc(this,Ni).get(t);if(n)return n;const r=this.messageHandler.sendWithPromise(t,e);return Nc(this,Ni).set(t,r),r};class Hk{constructor(t){Tc(this,Vi,null),Oc(this,"onContinue",null),Oc(this,"onError",null),Dc(this,Vi,t)}get promise(){return Nc(this,Vi).capability.promise}cancel(t=0){Nc(this,Vi).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=Nc(this,Vi).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=Nc(this,Vi);return t.form||t.canvas&&(null==e?void 0:e.size)>0}}Vi=new WeakMap;const jk=class t{constructor({callback:t,params:e,objs:n,commonObjs:r,annotationCanvasMap:i,operatorList:A,pageIndex:s,canvasFactory:a,filterFactory:o,useRequestAnimationFrame:l=!1,pdfBug:c=!1,pageColors:h=null,enableHWA:u=!1}){Tc(this,Ki,null),this.callback=t,this.params=e,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=A,this._pageIndex=s,this.canvasFactory=a,this.filterFactory=o,this._pdfBug=c,this.pageColors=h,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===l&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Hk(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:n}){var r,i;if(this.cancelled)return;if(this._canvas){if(Nc(t,Gi).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.");Nc(t,Gi).add(this._canvas)}this._pdfBug&&(null==(r=globalThis.StepperManager)?void 0:r.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:A,transform:s,background:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new ZQ(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:s,viewport:A,transparency:e,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,null==(i=this.graphicsReadyCallback)||i.call(this)}cancel(e=null,n=0){var r,i,A;this.running=!1,this.cancelled=!0,null==(r=this.gfx)||r.endDrawing(),Nc(this,Ki)&&(window.cancelAnimationFrame(Nc(this,Ki)),Dc(this,Ki,null)),Nc(t,Gi).delete(this._canvas),e||(e=new ZU(`Rendering cancelled, page ${this._pageIndex+1}`,n)),this.callback(e),null==(A=(i=this.task).onError)||A.call(i,e)}operatorListChanged(){var t;this.graphicsReady?(null==(t=this.stepper)||t.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?Dc(this,Ki,window.requestAnimationFrame(()=>{Dc(this,Ki,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){return Wc(this,null,function*(){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(),Nc(t,Gi).delete(this._canvas),this.callback())))})}};Ki=new WeakMap,Gi=new WeakMap,Tc(jk,Gi,new WeakSet);let Wk=jk;const Vk=class t{constructor({editor:e=null,uiManager:n=null}){var r,i;Tc(this,iA),Tc(this,zi,null),Tc(this,qi,null),Tc(this,Xi),Tc(this,Yi,null),Tc(this,$i,!1),Tc(this,Ji,!1),Tc(this,Zi,null),Tc(this,tA),Tc(this,eA,null),Tc(this,nA,null),e?(Dc(this,Ji,!1),Dc(this,Zi,e)):Dc(this,Ji,!0),Dc(this,nA,(null==e?void 0:e._uiManager)||n),Dc(this,tA,Nc(this,nA)._eventBus),Dc(this,Xi,(null==(r=null==e?void 0:e.color)?void 0:r.toUpperCase())||(null==(i=Nc(this,nA))?void 0:i.highlightColors.values().next().value)||"#FFFF98"),Nc(t,rA)||Dc(t,rA,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return LU(this,"_keyboardManager",new bI([[["Escape","mac+Escape"],t.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],t.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],t.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],t.prototype._moveToPrevious],[["Home","mac+Home"],t.prototype._moveToBeginning],[["End","mac+End"],t.prototype._moveToEnd]]))}renderButton(){const t=Dc(this,zi,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",Nc(this,Zi)&&(t.ariaControls=`${Nc(this,Zi).id}_colorpicker_dropdown`);const e=Nc(this,nA)._signal;t.addEventListener("click",Rc(this,iA,oA).bind(this),{signal:e}),t.addEventListener("keydown",Rc(this,iA,aA).bind(this),{signal:e});const n=Dc(this,qi,document.createElement("span"));return n.className="swatch",n.ariaHidden="true",n.style.backgroundColor=Nc(this,Xi),t.append(n),t}renderMainDropdown(){const t=Dc(this,Yi,Rc(this,iA,AA).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===Nc(this,zi))return void Rc(this,iA,oA).call(this,t);const e=t.target.getAttribute("data-color");e&&Rc(this,iA,sA).call(this,e,t)}_moveToNext(t){var e,n;Nc(this,iA,cA)?t.target!==Nc(this,zi)?null==(n=t.target.nextSibling)||n.focus():null==(e=Nc(this,Yi).firstChild)||e.focus():Rc(this,iA,oA).call(this,t)}_moveToPrevious(t){var e,n;t.target!==(null==(e=Nc(this,Yi))?void 0:e.firstChild)&&t.target!==Nc(this,zi)?(Nc(this,iA,cA)||Rc(this,iA,oA).call(this,t),null==(n=t.target.previousSibling)||n.focus()):Nc(this,iA,cA)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;Nc(this,iA,cA)?null==(e=Nc(this,Yi).firstChild)||e.focus():Rc(this,iA,oA).call(this,t)}_moveToEnd(t){var e;Nc(this,iA,cA)?null==(e=Nc(this,Yi).lastChild)||e.focus():Rc(this,iA,oA).call(this,t)}hideDropdown(){var t,e;null==(t=Nc(this,Yi))||t.classList.add("hidden"),Nc(this,zi).ariaExpanded="false",null==(e=Nc(this,eA))||e.abort(),Dc(this,eA,null)}_hideDropdownFromKeyboard(){var t;Nc(this,Ji)||(Nc(this,iA,cA)?(this.hideDropdown(),Nc(this,zi).focus({preventScroll:!0,focusVisible:Nc(this,$i)})):null==(t=Nc(this,Zi))||t.unselect())}updateColor(t){if(Nc(this,qi)&&(Nc(this,qi).style.backgroundColor=t),!Nc(this,Yi))return;const e=Nc(this,nA).highlightColors.values();for(const n of Nc(this,Yi).children)n.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;null==(t=Nc(this,zi))||t.remove(),Dc(this,zi,null),Dc(this,qi,null),null==(e=Nc(this,Yi))||e.remove(),Dc(this,Yi,null)}};zi=new WeakMap,qi=new WeakMap,Xi=new WeakMap,Yi=new WeakMap,$i=new WeakMap,Ji=new WeakMap,Zi=new WeakMap,tA=new WeakMap,eA=new WeakMap,nA=new WeakMap,rA=new WeakMap,iA=new WeakSet,AA=function(){const t=document.createElement("div"),e=Nc(this,nA)._signal;t.addEventListener("contextmenu",iI,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),Nc(this,Zi)&&(t.id=`${Nc(this,Zi).id}_colorpicker_dropdown`);for(const[n,r]of Nc(this,nA).highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",r),i.title=n,i.setAttribute("data-l10n-id",Nc(Vk,rA)[n]);const A=document.createElement("span");i.append(A),A.className="swatch",A.style.backgroundColor=r,i.ariaSelected=r===Nc(this,Xi),i.addEventListener("click",Rc(this,iA,sA).bind(this,r),{signal:e}),t.append(i)}return t.addEventListener("keydown",Rc(this,iA,aA).bind(this),{signal:e}),t},sA=function(t,e){e.stopPropagation(),Nc(this,tA).dispatch("switchannotationeditorparams",{source:this,type:eU.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},aA=function(t){Vk._keyboardManager.exec(this,t)},oA=function(t){if(Nc(this,iA,cA))return void this.hideDropdown();if(Dc(this,$i,0===t.detail),Nc(this,eA)||(Dc(this,eA,new AbortController),window.addEventListener("pointerdown",Rc(this,iA,lA).bind(this),{signal:Nc(this,nA).combinedSignal(Nc(this,eA))})),Nc(this,zi).ariaExpanded="true",Nc(this,Yi))return void Nc(this,Yi).classList.remove("hidden");const e=Dc(this,Yi,Rc(this,iA,AA).call(this));Nc(this,zi).append(e)},lA=function(t){var e;(null==(e=Nc(this,Yi))?void 0:e.contains(t.target))||this.hideDropdown()},cA=function(){return Nc(this,Yi)&&!Nc(this,Yi).classList.contains("hidden")},Tc(Vk,rA,null);let Kk=Vk;const Gk=class t{constructor(e){Tc(this,hA,null),Tc(this,uA,null),Tc(this,dA,null),Dc(this,uA,e),Dc(this,dA,e._uiManager),Nc(t,fA)||Dc(t,fA,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(Nc(this,hA))return Nc(this,hA);const{editorType:e,colorType:n,colorValue:r}=Nc(this,uA),i=Dc(this,hA,document.createElement("input"));return i.type="color",i.value=r||"#000000",i.className="basicColorPicker",i.tabIndex=0,i.setAttribute("data-l10n-id",Nc(t,fA)[e]),i.addEventListener("input",()=>{Nc(this,dA).updateParams(n,i.value)},{signal:Nc(this,dA)._signal}),i}update(t){Nc(this,hA)&&(Nc(this,hA).value=t)}destroy(){var t;null==(t=Nc(this,hA))||t.remove(),Dc(this,hA,null)}hideDropdown(){}};hA=new WeakMap,uA=new WeakMap,dA=new WeakMap,fA=new WeakMap,Tc(Gk,fA,null);let zk=Gk;function qk(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Xk(t){return Math.max(0,Math.min(255,255*t))}class Yk{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=Xk(t),t,t]}static G_HTML([t]){const e=qk(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(Xk)}static RGB_HTML(t){return`#${t.map(qk).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[Xk(1-Math.min(1,t+r)),Xk(1-Math.min(1,n+r)),Xk(1-Math.min(1,e+r))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,n]){const r=1-t,i=1-e,A=1-n;return["CMYK",r,i,A,Math.min(r,i,A)]}}class $k{create(t,e,n=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const 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("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){xU("Abstract method `_createSVG` called.")}}class Jk extends $k{_createSVG(t){return document.createElementNS(qU,t)}}class Zk{static setupStorage(t,e,n,r,i){const A=r.getValue(e,{value:null});switch(n.name){case"textarea":if(null!==A.value&&(t.textContent=A.value),"print"===i)break;t.addEventListener("input",t=>{r.setValue(e,{value:t.target.value})});break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(A.value===n.attributes.xfaOn?t.setAttribute("checked",!0):A.value===n.attributes.xfaOff&&t.removeAttribute("checked"),"print"===i)break;t.addEventListener("change",t=>{r.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==A.value&&t.setAttribute("value",A.value),"print"===i)break;t.addEventListener("input",t=>{r.setValue(e,{value:t.target.value})})}break;case"select":if(null!==A.value){t.setAttribute("value",A.value);for(const t of n.children)t.attributes.value===A.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",t=>{const n=t.target.options,i=-1===n.selectedIndex?"":n[n.selectedIndex].value;r.setValue(e,{value:i})})}}static setAttributes({html:t,element:e,storage:n=null,intent:r,linkService:i}){const{attributes:A}=e,s=t instanceof HTMLAnchorElement;"radio"===A.type&&(A.name=`${A.name}-${r}`);for(const[a,o]of Object.entries(A))if(null!=o)switch(a){case"class":o.length&&t.setAttribute(a,o.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",o);break;case"style":Object.assign(t.style,o);break;case"textContent":t.textContent=o;break;default:(!s||"href"!==a&&"newWindow"!==a)&&t.setAttribute(a,o)}s&&i.addLinkAttributes(t,A.href,A.newWindow),n&&A.dataId&&this.setupStorage(t,A.dataId,e,n)}static render(t){var e,n;const r=t.annotationStorage,i=t.linkService,A=t.xfaHtml,s=t.intent||"display",a=document.createElement(A.name);A.attributes&&this.setAttributes({html:a,element:A,intent:s,linkService:i});const o="richText"!==s,l=t.div;if(l.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=e}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(0===A.children.length){if(A.value){const t=document.createTextNode(A.value);a.append(t),o&&Ik.shouldBuildText(A.name)&&c.push(t)}return{textDivs:c}}const h=[[A,-1,a]];for(;h.length>0;){const[t,A,a]=h.at(-1);if(A+1===t.children.length){h.pop();continue}const l=t.children[++h.at(-1)[1]];if(null===l)continue;const{name:u}=l;if("#text"===u){const t=document.createTextNode(l.value);c.push(t),a.append(t);continue}const d=(null==(e=null==l?void 0:l.attributes)?void 0:e.xmlns)?document.createElementNS(l.attributes.xmlns,u):document.createElement(u);if(a.append(d),l.attributes&&this.setAttributes({html:d,element:l,storage:r,intent:s,linkService:i}),(null==(n=l.children)?void 0:n.length)>0)h.push([l,-1,d]);else if(l.value){const t=document.createTextNode(l.value);o&&Ik.shouldBuildText(u)&&c.push(t),d.append(t)}}for(const u of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))u.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const tM=new WeakSet,eM=60*(new Date).getTimezoneOffset()*1e3;class nM{static create(t){switch(t.data.annotationType){case lU.LINK:return new iM(t);case lU.TEXT:return new AM(t);case lU.WIDGET:switch(t.data.fieldType){case"Tx":return new aM(t);case"Btn":return t.data.radioButton?new cM(t):t.data.checkBox?new lM(t):new hM(t);case"Ch":return new uM(t);case"Sig":return new oM(t)}return new sM(t);case lU.POPUP:return new dM(t);case lU.FREETEXT:return new pM(t);case lU.LINE:return new gM(t);case lU.SQUARE:return new mM(t);case lU.CIRCLE:return new wM(t);case lU.POLYLINE:return new vM(t);case lU.CARET:return new bM(t);case lU.INK:return new BM(t);case lU.POLYGON:return new yM(t);case lU.HIGHLIGHT:return new _M(t);case lU.UNDERLINE:return new CM(t);case lU.SQUIGGLY:return new xM(t);case lU.STRIKEOUT:return new EM(t);case lU.STAMP:return new SM(t);case lU.FILEATTACHMENT:return new FM(t);default:return new rM(t)}}}pA=new WeakMap,gA=new WeakMap,mA=new WeakMap,wA=new WeakSet,vA=function(t){const{container:{style:e},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:A,pageX:s,pageY:a}}}}=this;null==n||n.splice(0,4,...t),e.left=100*(t[0]-s)/i+"%",e.top=100*(A-t[3]+a)/A+"%",0===r?(e.width=100*(t[2]-t[0])/i+"%",e.height=100*(t[3]-t[1])/A+"%"):this.setRotation(r)};let rM=class t{constructor(t,{isRenderable:e=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){Tc(this,wA),Tc(this,pA,null),Tc(this,gA,!1),Tc(this,mA,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!(!(null==t?void 0:t.str)&&!(null==e?void 0:e.str))}get _isEditable(){return this.data.isEditable}get hasPopupData(){return t._hasPopupData(this.data)}updateEdited(t){var e;if(!this.container)return;t.rect&&(Nc(this,pA)||Dc(this,pA,{rect:this.data.rect.slice(0)}));const{rect:n,popup:r}=t;n&&Rc(this,wA,vA).call(this,n);let i=(null==(e=Nc(this,mA))?void 0:e.popup)||this.popup;!i&&(null==r?void 0:r.text)&&(this._createPopup(r),i=Nc(this,mA).popup),i&&(i.updateEdited(t),(null==r?void 0:r.deleted)&&(i.remove(),Dc(this,mA,null),this.popup=null))}resetEdited(){var t;Nc(this,pA)&&(Rc(this,wA,vA).call(this,Nc(this,pA).rect),null==(t=Nc(this,mA))||t.popup.resetEdited(),Dc(this,pA,null))}_createContainer(t){const{data:e,parent:{page:n,viewport:r}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",e.id),this instanceof sM||this instanceof iM||(i.tabIndex=0);const{style:A}=i;if(A.zIndex=this.parent.zIndex++,e.alternativeText&&(i.title=e.alternativeText),e.noRotate&&i.classList.add("norotate"),!e.rect||this instanceof dM){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,i),i}const{width:s,height:a}=this;if(!t&&e.borderStyle.width>0){A.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,n=e.borderStyle.verticalCornerRadius;if(t>0||n>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${n}px * var(--total-scale-factor))`;A.borderRadius=e}else if(this instanceof cM){const t=`calc(${s}px * var(--total-scale-factor)) / calc(${a}px * var(--total-scale-factor))`;A.borderRadius=t}switch(e.borderStyle.style){case cU:A.borderStyle="solid";break;case hU:A.borderStyle="dashed";break;case uU:CU("Unimplemented border style: beveled");break;case dU:CU("Unimplemented border style: inset");break;case fU:A.borderBottomStyle="solid"}const r=e.borderColor||null;r?(Dc(this,gA,!0),A.borderColor=HU.makeHexColor(0|r[0],0|r[1],0|r[2])):A.borderWidth=0}const o=HU.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:l,pageHeight:c,pageX:h,pageY:u}=r.rawDims;A.left=100*(o[0]-h)/l+"%",A.top=100*(o[1]-u)/c+"%";const{rotation:d}=e;return e.hasOwnCanvas||0===d?(A.width=100*s/l+"%",A.height=100*a/c+"%"):this.setRotation(d,i),i}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims;let{width:i,height:A}=this;t%180!=0&&([i,A]=[A,i]),e.style.width=100*i/n+"%",e.style.height=100*A/r+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,n)=>{const r=n.detail[t],i=r[0],A=r.slice(1);n.target.style[e]=Yk[`${i}_HTML`](A),this.annotationStorage.setValue(this.data.id,{[e]:Yk[`${i}_rgb`](A)})};return LU(this,"_commonActions",{display:t=>{const{display:e}=t.detail,n=e%2==1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const n=this._commonActions;for(const r of Object.keys(e.detail)){const i=t[r]||n[r];null==i||i(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const n=this._commonActions;for(const[r,i]of Object.entries(e)){const A=n[r];if(A){A({detail:{[r]:i},target:t}),delete e[r]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,n,r,i]=this.data.rect.map(t=>Math.fround(t));if(8===t.length){const[A,s,a,o]=t.subarray(2,6);if(r===A&&i===s&&e===a&&n===o)return}const{style:A}=this.container;let s;if(Nc(this,gA)){const{borderColor:t,borderWidth:e}=A;A.borderWidth=0,s=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const a=r-e,o=i-n,{svgFactory:l}=this,c=l.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0),c.role="none";const h=l.createElement("defs");c.append(h);const u=l.createElement("clipPath"),d=`clippath_${this.data.id}`;u.setAttribute("id",d),u.setAttribute("clipPathUnits","objectBoundingBox"),h.append(u);for(let f=2,p=t.length;f<p;f+=8){const n=t[f],r=t[f+1],A=t[f+2],c=t[f+3],h=l.createElement("rect"),d=(A-e)/a,p=(i-r)/o,g=(n-A)/a,m=(r-c)/o;h.setAttribute("x",d),h.setAttribute("y",p),h.setAttribute("width",g),h.setAttribute("height",m),u.append(h),null==s||s.push(`<rect vector-effect="non-scaling-stroke" x="${d}" y="${p}" width="${g}" height="${m}"/>`)}Nc(this,gA)&&(s.push("</g></svg>')"),A.backgroundImage=s.join("")),this.container.append(c),this.container.style.clipPath=`url(#${d})`}_createPopup(t=null){const{data:e}=this;let n,r;t?(n={str:t.text},r=t.date):(n=e.contentsObj,r=e.modificationDate);const i=Dc(this,mA,new dM({data:{color:e.color,titleObj:e.titleObj,modificationDate:r,contentsObj:n,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent.div.append(i.render())}get hasPopupElement(){return!!(Nc(this,mA)||this.popup||this.data.popupRef)}render(){xU("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const n=[];if(this._fieldObjects){const r=this._fieldObjects[t];if(r)for(const{page:t,id:i,exportValues:A}of r){if(-1===t)continue;if(i===e)continue;const r="string"==typeof A?A:null,s=document.querySelector(`[data-element-id="${i}"]`);!s||tM.has(s)?n.push({id:i,exportValue:r,domElement:s}):CU(`_getElementsByName - element not allowed: ${i}`)}return n}for(const r of document.getElementsByName(t)){const{exportValue:t}=r,i=r.getAttribute("data-element-id");i!==e&&(tM.has(r)&&n.push({id:i,exportValue:t,domElement:r}))}return n}show(){var t;this.container&&(this.container.hidden=!1),null==(t=this.popup)||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null==(t=this.popup)||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var n;null==(n=this.linkService.eventBus)||n.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};class iM extends rM{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!(null==e?void 0:e.ignoreBorder),createQuadrilaterals:!0}),Tc(this,yA),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{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,t.overlaidText),r=!0):t.attachment?(Rc(this,yA,BA).call(this,n,t.attachment,t.overlaidText,t.attachmentDest),r=!0):t.setOCGState?(Rc(this,yA,_A).call(this,n,t.setOCGState,t.overlaidText),r=!0):t.dest?(this._bindLink(n,t.dest,t.overlaidText),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}_bindLink(t,e,n=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&Rc(this,yA,bA).call(this),n&&(t.title=n)}_bindNamedAction(t,e,n=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),n&&(t.title=n),Rc(this,yA,bA).call(this)}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(e.actions)){const i=n.get(r);i&&(t[i]=()=>{var t;return null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:r}}),!1})}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),Rc(this,yA,bA).call(this)}_bindResetFormAction(t,e){const n=t.onclick;if(n||(t.href=this.linkService.getAnchorUrl("")),Rc(this,yA,bA).call(this),!this._fieldObjects)return CU('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(t.onclick=()=>!1));t.onclick=()=>{var t;null==n||n();const{fields:r,refs:i,include:A}=e,s=[];if(0!==r.length||0!==i.length){const t=new Set(i);for(const e of r){const n=this._fieldObjects[e]||[];for(const{id:e}of n)t.add(e)}for(const e of Object.values(this._fieldObjects))for(const n of e)t.has(n.id)===A&&s.push(n)}else for(const e of Object.values(this._fieldObjects))s.push(...e);const a=this.annotationStorage,o=[];for(const e of s){const{id:t}=e;switch(o.push(t),e.type){case"text":{const n=e.defaultValue||"";a.setValue(t,{value:n});break}case"checkbox":case"radiobutton":{const n=e.defaultValue===e.exportValues;a.setValue(t,{value:n});break}case"combobox":case"listbox":{const n=e.defaultValue||"";a.setValue(t,{value:n});break}default:continue}const n=document.querySelector(`[data-element-id="${t}"]`);n&&(tM.has(n)?n.dispatchEvent(new Event("resetform")):CU(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&(null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}})),!1}}}yA=new WeakSet,bA=function(){this.container.setAttribute("data-internal-link","")},BA=function(t,e,n="",r=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:n&&(t.title=n),t.onclick=()=>{var t;return null==(t=this.downloadManager)||t.openOrDownloadData(e.content,e.filename,r),!1},Rc(this,yA,bA).call(this)},_A=function(t,e,n=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),n&&(t.title=n),Rc(this,yA,bA).call(this)};class AM extends rM{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class sM extends rM{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null==(e=t.previousSibling)?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return DU.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,n,r,i){n.includes("mouse")?t.addEventListener(n,t=>{var e;null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:i(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(n,t=>{var A;if("blur"===n){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===n){if(e.focused)return;e.focused=!0}i&&(null==(A=this.linkService.eventBus)||A.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:i(t)}}))})}_setEventListeners(t,e,n,r){var i,A,s;for(const[a,o]of n)("Action"===o||(null==(i=this.data.actions)?void 0:i[o]))&&("Focus"!==o&&"Blur"!==o||e||(e={focused:!1}),this._setEventListener(t,e,a,o,r),"Focus"!==o||(null==(A=this.data.actions)?void 0:A.Blur)?"Blur"!==o||(null==(s=this.data.actions)?void 0:s.Focus)||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":HU.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||9,i=t.style;let A;const s=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(WL*r))||1);A=Math.min(r,s(e/WL))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);A=Math.min(r,s(t/WL))}i.fontSize=`calc(${A}px * var(--total-scale-factor))`,i.color=HU.makeHexColor(n[0],n[1],n[2]),null!==this.data.textAlignment&&(i.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class aM extends sM{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,n,r){const i=this.annotationStorage;for(const A of this._getElementsByName(t.name,t.id))A.domElement&&(A.domElement[e]=n),i.setValue(A.id,{[r]:n})}render(){var t,e;const n=this.annotationStorage,r=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const A=n.getValue(r,{value:this.data.fieldValue});let s=A.value||"";const a=n.getValue(r,{charLimit:this.data.maxLen}).charLimit;a&&s.length>a&&(s=s.slice(0,a));let o=A.formattedValue||(null==(t=this.data.textContent)?void 0:t.join("\n"))||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));const l={userValue:s,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=null!=o?o:s,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",null!=o?o:s),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),tM.add(i),i.setAttribute("data-element-id",r),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;const{datetimeFormat:c,datetimeType:h,timeStep:u}=this.data,d=!!h&&this.enableScripting;c&&(i.title=c),this._setRequired(i,this.data.required),a&&(i.maxLength=a),i.addEventListener("input",t=>{n.setValue(r,{value:t.target.value}),this.setPropertyOnSiblings(i,"value",t.target.value,"value"),l.formattedValue=null}),i.addEventListener("resetform",t=>{var e;const n=null!=(e=this.data.defaultFieldValue)?e:"";i.value=l.userValue=n,l.formattedValue=null});let f=t=>{const{formattedValue:e}=l;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{var e;if(l.focused)return;const{target:n}=t;if(d&&(n.type=h,u&&(n.step=u)),l.userValue){const t=l.userValue;if(d)if("time"===h){const e=new Date(t),r=[e.getHours(),e.getMinutes(),e.getSeconds()];n.value=r.map(t=>t.toString().padStart(2,"0")).join(":")}else n.value=new Date(t-eM).toISOString().split("date"===h?"T":".",1)[0];else n.value=t}l.lastCommittedValue=n.value,l.commitKey=1,(null==(e=this.data.actions)?void 0:e.Focus)||(l.focused=!0)}),i.addEventListener("updatefromsandbox",t=>{this.showElementAndHideCanvas(t.target);const e={value(t){var e;l.userValue=null!=(e=t.detail.value)?e:"",d||n.setValue(r,{value:l.userValue.toString()}),t.target.value=l.userValue},formattedValue(t){const{formattedValue:e}=t.detail;l.formattedValue=e,null!=e&&t.target!==document.activeElement&&(t.target.value=e);const i={formattedValue:e};d&&(i.value=e),n.setValue(r,i)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:t=>{var e;const{charLimit:i}=t.detail,{target:A}=t;if(0===i)return void A.removeAttribute("maxLength");A.setAttribute("maxLength",i);let s=l.userValue;!s||s.length<=i||(s=s.slice(0,i),A.value=l.userValue=s,n.setValue(r,{value:s}),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:A.selectionStart,selEnd:A.selectionEnd}}))}};this._dispatchEventFromSandbox(e,t)}),i.addEventListener("keydown",t=>{var e;l.commitKey=1;let n=-1;if("Escape"===t.key?n=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(l.commitKey=3):n=2,-1===n)return;const{value:i}=t.target;l.lastCommittedValue!==i&&(l.lastCommittedValue=i,l.userValue=i,null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:i,willCommit:!0,commitKey:n,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});const t=f;f=null,i.addEventListener("blur",e=>{var n,i;if(!l.focused||!e.relatedTarget)return;(null==(n=this.data.actions)?void 0:n.Blur)||(l.focused=!1);const{target:A}=e;let{value:s}=A;if(d){if(s&&"time"===h){const t=s.split(":").map(t=>parseInt(t,10));s=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),A.step=""}else s=new Date(s).valueOf();A.type="text"}l.userValue=s,l.lastCommittedValue!==s&&(null==(i=this.linkService.eventBus)||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:s,willCommit:!0,commitKey:l.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})),t(e)}),(null==(e=this.data.actions)?void 0:e.Keystroke)&&i.addEventListener("beforeinput",t=>{var e;l.lastCommittedValue=null;const{data:n,target:i}=t,{value:A,selectionStart:s,selectionEnd:a}=i;let o=s,c=a;switch(t.inputType){case"deleteWordBackward":{const t=A.substring(0,s).match(/\w*[^\w]*$/);t&&(o-=t[0].length);break}case"deleteWordForward":{const t=A.substring(s).match(/^[^\w]*\w*/);t&&(c+=t[0].length);break}case"deleteContentBackward":s===a&&(o-=1);break;case"deleteContentForward":s===a&&(c+=1)}t.preventDefault(),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:A,change:n||"",willCommit:!1,selStart:o,selEnd:c}})}),this._setEventListeners(i,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(f&&i.addEventListener("blur",f),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/a;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class oM extends sM{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class lM extends sM{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,n=e.id;let r=t.getValue(n,{value:e.exportValue===e.fieldValue}).value;"string"==typeof r&&(r="Off"!==r,t.setValue(n,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const i=document.createElement("input");return tM.add(i),i.setAttribute("data-element-id",n),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=e.fieldName,r&&i.setAttribute("checked",!0),i.setAttribute("exportValue",e.exportValue),i.tabIndex=0,i.addEventListener("change",r=>{const{name:i,checked:A}=r.target;for(const s of this._getElementsByName(i,n)){const n=A&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=n),t.setValue(s.id,{value:n})}t.setValue(n,{value:A})}),i.addEventListener("resetform",t=>{const n=e.defaultFieldValue||"Off";t.target.checked=n===e.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",e=>{const r={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(n,{value:e.target.checked})}};this._dispatchEventFromSandbox(r,e)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class cM extends sM{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,n=e.id;let r=t.getValue(n,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof r&&(r=r!==e.buttonValue,t.setValue(n,{value:r})),r)for(const A of this._getElementsByName(e.fieldName,n))t.setValue(A.id,{value:!1});const i=document.createElement("input");if(tM.add(i),i.setAttribute("data-element-id",n),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="radio",i.name=e.fieldName,r&&i.setAttribute("checked",!0),i.tabIndex=0,i.addEventListener("change",e=>{const{name:r,checked:i}=e.target;for(const A of this._getElementsByName(r,n))t.setValue(A.id,{value:!1});t.setValue(n,{value:i})}),i.addEventListener("resetform",t=>{const n=e.defaultFieldValue;t.target.checked=null!=n&&n===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;i.addEventListener("updatefromsandbox",e=>{const i={value:e=>{const i=r===e.detail.value;for(const r of this._getElementsByName(e.target.name)){const e=i&&r.id===n;r.domElement&&(r.domElement.checked=e),t.setValue(r.id,{value:e})}}};this._dispatchEventFromSandbox(i,e)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class hM extends iM{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class uM extends sM{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,n=t.getValue(e,{value:this.data.fieldValue}),r=document.createElement("select");tM.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=0;let i=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",t=>{const e=this.data.defaultFieldValue;for(const n of r.options)n.selected=n.value===e});for(const l of this.data.options){const t=document.createElement("option");t.textContent=l.displayValue,t.value=l.exportValue,n.value.includes(l.exportValue)&&(t.setAttribute("selected",!0),i=!1),r.append(t)}let A=null;if(i){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),r.prepend(t),A=()=>{t.remove(),r.removeEventListener("input",A),A=null},r.addEventListener("input",A)}const s=t=>{const e=t?"value":"textContent",{options:n,multiple:i}=r;return i?Array.prototype.filter.call(n,t=>t.selected).map(t=>t[e]):-1===n.selectedIndex?null:n[n.selectedIndex][e]};let a=s(!1);const o=t=>{const e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",n=>{const i={value(n){null==A||A();const i=n.detail.value,o=new Set(Array.isArray(i)?i:[i]);for(const t of r.options)t.selected=o.has(t.value);t.setValue(e,{value:s(!0)}),a=s(!1)},multipleSelection(t){r.multiple=!0},remove(n){const i=r.options,A=n.detail.remove;if(i[A].selected=!1,r.remove(A),i.length>0){-1===Array.prototype.findIndex.call(i,t=>t.selected)&&(i[0].selected=!0)}t.setValue(e,{value:s(!0),items:o(n)}),a=s(!1)},clear(n){for(;0!==r.length;)r.remove(0);t.setValue(e,{value:null,items:[]}),a=s(!1)},insert(n){const{index:i,displayValue:A,exportValue:l}=n.detail.insert,c=r.children[i],h=document.createElement("option");h.textContent=A,h.value=l,c?c.before(h):r.append(h),t.setValue(e,{value:s(!0),items:o(n)}),a=s(!1)},items(n){const{items:i}=n.detail;for(;0!==r.length;)r.remove(0);for(const t of i){const{displayValue:e,exportValue:n}=t,i=document.createElement("option");i.textContent=e,i.value=n,r.append(i)}r.options.length>0&&(r.options[0].selected=!0),t.setValue(e,{value:s(!0),items:o(n)}),a=s(!1)},indices(n){const r=new Set(n.detail.indices);for(const t of n.target.options)t.selected=r.has(t.index);t.setValue(e,{value:s(!0)}),a=s(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(i,n)}),r.addEventListener("input",n=>{var r;const i=s(!0),A=s(!1);t.setValue(e,{value:i}),n.preventDefault(),null==(r=this.linkService.eventBus)||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,change:A,changeEx:i,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"]],t=>t.target.value)):r.addEventListener("input",function(n){t.setValue(e,{value:s(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class dM extends rM{constructor(t){const{data:e,elements:n}=t;super(t,{isRenderable:rM._hasPopupData(e)}),this.elements=n,this.popup=null}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=new fM({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),n=[];for(const r of this.elements)r.popup=e,r.container.ariaHasPopup="dialog",n.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",n.map(t=>`${KU}${t}`).join(",")),this.container}}class fM{constructor({container:t,color:e,elements:n,titleObj:r,modificationDate:i,contentsObj:A,richText:s,parent:a,rect:o,parentRect:l,open:c}){Tc(this,VA),Tc(this,CA,Rc(this,VA,YA).bind(this)),Tc(this,xA,Rc(this,VA,ts).bind(this)),Tc(this,EA,Rc(this,VA,ZA).bind(this)),Tc(this,SA,Rc(this,VA,JA).bind(this)),Tc(this,FA,null),Tc(this,LA,null),Tc(this,UA,null),Tc(this,IA,null),Tc(this,QA,null),Tc(this,kA,null),Tc(this,MA,null),Tc(this,OA,!1),Tc(this,PA,null),Tc(this,NA,null),Tc(this,TA,null),Tc(this,DA,null),Tc(this,RA,null),Tc(this,HA,null),Tc(this,jA,null),Tc(this,WA,!1),Dc(this,LA,t),Dc(this,HA,r),Dc(this,UA,A),Dc(this,RA,s),Dc(this,kA,a),Dc(this,FA,e),Dc(this,DA,o),Dc(this,MA,l),Dc(this,QA,n),Dc(this,IA,sI.toDateObject(i)),this.trigger=n.flatMap(t=>t.getElementsToTriggerPopup()),Rc(this,VA,KA).call(this),Nc(this,LA).hidden=!0,c&&Rc(this,VA,JA).call(this)}render(){var t;if(Nc(this,PA))return;const e=Dc(this,PA,document.createElement("div"));if(e.className="popup",Nc(this,FA)){const t=e.style.outlineColor=HU.makeHexColor(...Nc(this,FA));e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const n=document.createElement("span");if(n.className="header",null==(t=Nc(this,HA))?void 0:t.str){const t=document.createElement("span");t.className="title",n.append(t),({dir:t.dir,str:t.textContent}=Nc(this,HA))}if(e.append(n),Nc(this,IA)){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:Nc(this,IA).valueOf()})),t.dateTime=Nc(this,IA).toISOString(),n.append(t)}const r=Nc(this,VA,GA);if(r)Zk.render({xfaHtml:r,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const t=this._formatContents(Nc(this,UA));e.append(t)}Nc(this,LA).append(e)}_formatContents({str:t,dir:e}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=e;const r=t.split(/(?:\r\n?|\n)/);for(let i=0,A=r.length;i<A;++i){const t=r[i];n.append(document.createTextNode(t)),i<A-1&&n.append(document.createElement("br"))}return n}updateEdited({rect:t,popup:e,deleted:n}){var r;n||(null==e?void 0:e.deleted)?this.remove():(Rc(this,VA,KA).call(this),Nc(this,jA)||Dc(this,jA,{contentsObj:Nc(this,UA),richText:Nc(this,RA)}),t&&Dc(this,TA,null),e&&(Dc(this,RA,Rc(this,VA,XA).call(this,e.text)),Dc(this,IA,sI.toDateObject(e.date)),Dc(this,UA,null)),null==(r=Nc(this,PA))||r.remove(),Dc(this,PA,null))}resetEdited(){var t;Nc(this,jA)&&(({contentsObj:Hc(this,UA)._,richText:Hc(this,RA)._}=Nc(this,jA)),Dc(this,jA,null),null==(t=Nc(this,PA))||t.remove(),Dc(this,PA,null),Dc(this,TA,null))}remove(){var t,e;null==(t=Nc(this,NA))||t.abort(),Dc(this,NA,null),null==(e=Nc(this,PA))||e.remove(),Dc(this,PA,null),Dc(this,WA,!1),Dc(this,OA,!1);for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){Dc(this,WA,this.isVisible),Nc(this,WA)&&(Nc(this,LA).hidden=!0)}maybeShow(){Rc(this,VA,KA).call(this),Nc(this,WA)&&(Nc(this,PA)||Rc(this,VA,ZA).call(this),Dc(this,WA,!1),Nc(this,LA).hidden=!1)}get isVisible(){return!1===Nc(this,LA).hidden}}CA=new WeakMap,xA=new WeakMap,EA=new WeakMap,SA=new WeakMap,FA=new WeakMap,LA=new WeakMap,UA=new WeakMap,IA=new WeakMap,QA=new WeakMap,kA=new WeakMap,MA=new WeakMap,OA=new WeakMap,PA=new WeakMap,NA=new WeakMap,TA=new WeakMap,DA=new WeakMap,RA=new WeakMap,HA=new WeakMap,jA=new WeakMap,WA=new WeakMap,VA=new WeakSet,KA=function(){var t;if(Nc(this,NA))return;Dc(this,NA,new AbortController);const{signal:e}=Nc(this,NA);for(const n of this.trigger)n.addEventListener("click",Nc(this,SA),{signal:e}),n.addEventListener("mouseenter",Nc(this,EA),{signal:e}),n.addEventListener("mouseleave",Nc(this,xA),{signal:e}),n.classList.add("popupTriggerArea");for(const n of Nc(this,QA))null==(t=n.container)||t.addEventListener("keydown",Nc(this,CA),{signal:e})},GA=function(){const t=Nc(this,RA),e=Nc(this,UA);return!(null==t?void 0:t.str)||(null==e?void 0:e.str)&&e.str!==t.str?null:Nc(this,RA).html||null},zA=function(){var t,e,n;return(null==(n=null==(e=null==(t=Nc(this,VA,GA))?void 0:t.attributes)?void 0:e.style)?void 0:n.fontSize)||0},qA=function(){var t,e,n;return(null==(n=null==(e=null==(t=Nc(this,VA,GA))?void 0:t.attributes)?void 0:e.style)?void 0:n.color)||null},XA=function(t){const e=[],n={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},r={style:{color:Nc(this,VA,qA),fontSize:Nc(this,VA,zA)?`calc(${Nc(this,VA,zA)}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:r});return n},YA=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&Nc(this,OA))&&Rc(this,VA,JA).call(this)},$A=function(){if(null!==Nc(this,TA))return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:n,pageX:r,pageY:i}}}=Nc(this,kA);let A=!!Nc(this,MA),s=Nc(this,A?MA:DA);for(const u of Nc(this,QA))if(!s||null!==HU.intersect(u.data.rect,s)){s=u.data.rect,A=!0;break}const a=HU.normalizeRect([s[0],t[3]-s[1]+t[1],s[2],t[3]-s[3]+t[1]]),o=A?s[2]-s[0]+5:0,l=a[0]+o,c=a[1];Dc(this,TA,[100*(l-r)/e,100*(c-i)/n]);const{style:h}=Nc(this,LA);h.left=`${Nc(this,TA)[0]}%`,h.top=`${Nc(this,TA)[1]}%`},JA=function(){Dc(this,OA,!Nc(this,OA)),Nc(this,OA)?(Rc(this,VA,ZA).call(this),Nc(this,LA).addEventListener("click",Nc(this,SA)),Nc(this,LA).addEventListener("keydown",Nc(this,CA))):(Rc(this,VA,ts).call(this),Nc(this,LA).removeEventListener("click",Nc(this,SA)),Nc(this,LA).removeEventListener("keydown",Nc(this,CA)))},ZA=function(){Nc(this,PA)||this.render(),this.isVisible?Nc(this,OA)&&Nc(this,LA).classList.add("focused"):(Rc(this,VA,$A).call(this),Nc(this,LA).hidden=!1,Nc(this,LA).style.zIndex=parseInt(Nc(this,LA).style.zIndex)+1e3)},ts=function(){Nc(this,LA).classList.remove("focused"),!Nc(this,OA)&&this.isVisible&&(Nc(this,LA).hidden=!0,Nc(this,LA).style.zIndex=parseInt(Nc(this,LA).style.zIndex)-1e3)};class pM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=tU.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const 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}}class gM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,es,null)}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:n}=this,r=this.svgFactory.create(e,n,!0),i=Dc(this,es,this.svgFactory.createElement("svg:line"));return i.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),i.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),i.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),i.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),i.setAttribute("stroke-width",t.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),r.append(i),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Nc(this,es)}addHighlightArea(){this.container.classList.add("highlightArea")}}es=new WeakMap;class mM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,ns,null)}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:n}=this,r=this.svgFactory.create(e,n,!0),i=t.borderStyle.width,A=Dc(this,ns,this.svgFactory.createElement("svg:rect"));return A.setAttribute("x",i/2),A.setAttribute("y",i/2),A.setAttribute("width",e-i),A.setAttribute("height",n-i),A.setAttribute("stroke-width",i||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 Nc(this,ns)}addHighlightArea(){this.container.classList.add("highlightArea")}}ns=new WeakMap;class wM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,rs,null)}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:n}=this,r=this.svgFactory.create(e,n,!0),i=t.borderStyle.width,A=Dc(this,rs,this.svgFactory.createElement("svg:ellipse"));return A.setAttribute("cx",e/2),A.setAttribute("cy",n/2),A.setAttribute("rx",e/2-i/2),A.setAttribute("ry",n/2-i/2),A.setAttribute("stroke-width",i||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 Nc(this,rs)}addHighlightArea(){this.container.classList.add("highlightArea")}}rs=new WeakMap;class vM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,is,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:n,popupRef:r},width:i,height:A}=this;if(!e)return this.container;const s=this.svgFactory.create(i,A,!0);let a=[];for(let l=0,c=e.length;l<c;l+=2){const n=e[l]-t[0],r=t[3]-e[l+1];a.push(`${n},${r}`)}a=a.join(" ");const o=Dc(this,is,this.svgFactory.createElement(this.svgElementName));return o.setAttribute("points",a),o.setAttribute("stroke-width",n.width||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),s.append(o),this.container.append(s),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return Nc(this,is)}addHighlightArea(){this.container.classList.add("highlightArea")}}is=new WeakMap;class yM extends vM{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class bM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class BM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),Tc(this,as),Tc(this,As,null),Tc(this,ss,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?tU.HIGHLIGHT:tU.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:n,borderStyle:r,popupRef:i}}=this,{transform:A,width:s,height:a}=Rc(this,as,os).call(this,e,t),o=this.svgFactory.create(s,a,!0),l=Dc(this,As,this.svgFactory.createElement("svg:g"));o.append(l),l.setAttribute("stroke-width",r.width||1),l.setAttribute("stroke-linecap","round"),l.setAttribute("stroke-linejoin","round"),l.setAttribute("stroke-miterlimit",10),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),l.setAttribute("transform",A);for(let c=0,h=n.length;c<h;c++){const t=this.svgFactory.createElement(this.svgElementName);Nc(this,ss).push(t),t.setAttribute("points",n[c].join(",")),l.append(t)}return!i&&this.hasPopupData&&this._createPopup(),this.container.append(o),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:n,rect:r}=t,i=Nc(this,As);if(e>=0&&i.setAttribute("stroke-width",e||1),n)for(let A=0,s=Nc(this,ss).length;A<s;A++)Nc(this,ss)[A].setAttribute("points",n[A].join(","));if(r){const{transform:t,width:e,height:n}=Rc(this,as,os).call(this,this.data.rotation,r);i.parentElement.setAttribute("viewBox",`0 0 ${e} ${n}`),i.setAttribute("transform",t)}}getElementsToTriggerPopup(){return Nc(this,ss)}addHighlightArea(){this.container.classList.add("highlightArea")}}As=new WeakMap,ss=new WeakMap,as=new WeakSet,os=function(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}};class _M extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=tU.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class CM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class xM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class EM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class SM extends rM{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=tU.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class FM extends rM{constructor(t){var e;super(t,{isRenderable:!0}),Tc(this,cs),Tc(this,ls,null);const{file:n}=this.data;this.filename=n.filename,this.content=n.content,null==(e=this.linkService.eventBus)||e.dispatch("fileattachmentannotation",Qc({source:this},n))}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let n;e.hasAppearance||0===e.fillAlpha?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(100*e.fillAlpha)}%);`)),n.addEventListener("dblclick",Rc(this,cs,hs).bind(this)),Dc(this,ls,n);const{isMac:r}=DU.platform;return t.addEventListener("keydown",t=>{"Enter"===t.key&&(r?t.metaKey:t.ctrlKey)&&Rc(this,cs,hs).call(this)}),!e.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),t.append(n),t}getElementsToTriggerPopup(){return Nc(this,ls)}addHighlightArea(){this.container.classList.add("highlightArea")}}ls=new WeakMap,cs=new WeakSet,hs=function(){var t;null==(t=this.downloadManager)||t.openOrDownloadData(this.content,this.filename)};us=new WeakMap,ds=new WeakMap,fs=new WeakMap,ps=new WeakMap,gs=new WeakSet,ms=function(t,e,n){return Wc(this,null,function*(){var r,i;const A=t.firstChild||t,s=A.id=`${KU}${e}`,a=yield null==(r=Nc(this,ps))?void 0:r.getAriaAttributes(s);if(a)for(const[t,e]of a)A.setAttribute(t,e);n?n.at(-1).container.after(t):(this.div.append(t),null==(i=Nc(this,us))||i.moveElementInDOM(this.div,t,A,!1))})},ws=function(){var t;if(!Nc(this,ds))return;const e=this.div;for(const[n,r]of Nc(this,ds)){const i=e.querySelector(`[data-annotation-id="${n}"]`);if(!i)continue;r.className="annotationContent";const{firstChild:A}=i;A?"CANVAS"===A.nodeName?A.replaceWith(r):A.classList.contains("annotationContent")?A.after(r):A.before(r):i.append(r);const s=Nc(this,fs).get(n);s&&(s._hasNoCanvas?(null==(t=this._annotationEditorUIManager)||t.setMissingCanvas(n,i.id,r),s._hasNoCanvas=!1):s.canvas=r)}Nc(this,ds).clear()};let LM=class t{constructor({div:t,accessibilityManager:e,annotationCanvasMap:n,annotationEditorUIManager:r,page:i,viewport:A,structTreeLayer:s}){Tc(this,gs),Tc(this,us,null),Tc(this,ds,null),Tc(this,fs,new Map),Tc(this,ps,null),this.div=t,Dc(this,us,e),Dc(this,ds,n),Dc(this,ps,s||null),this.page=i,this.viewport=A,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return Nc(this,fs).size>0}render(t){return Wc(this,null,function*(){var e;const{annotations:n}=t,r=this.div;cI(r,this.viewport);const i=new Map,A={data:null,layer:r,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Jk,annotationStorage:t.annotationStorage||new DI,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of n){if(t.noHTML)continue;const n=t.annotationType===lU.POPUP;if(n){const e=i.get(t.id);if(!e)continue;A.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;A.data=t;const r=nM.create(A);if(!r.isRenderable)continue;if(!n&&t.popupRef){const e=i.get(t.popupRef);e?e.push(r):i.set(t.popupRef,[r])}const s=r.render();t.hidden&&(s.style.visibility="hidden"),yield Rc(this,gs,ms).call(this,s,t.id,A.elements),r._isEditable&&(Nc(this,fs).set(r.data.id,r),null==(e=this._annotationEditorUIManager)||e.renderAnnotationElement(r))}Rc(this,gs,ws).call(this)})}addLinkAnnotations(e,n){return Wc(this,null,function*(){const r={data:null,layer:this.div,linkService:n,svgFactory:new Jk,parent:this};for(const n of e){n.borderStyle||(n.borderStyle=t._defaultBorderStyle),r.data=n;const e=nM.create(r);if(!e.isRenderable)continue;const i=e.render();yield Rc(this,gs,ms).call(this,i,n.id,null)}})}update({viewport:t}){const e=this.div;this.viewport=t,cI(e,{rotation:t.rotation}),Rc(this,gs,ws).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(Nc(this,fs).values())}getEditableAnnotation(t){return Nc(this,fs).get(t)}static get _defaultBorderStyle(){return LU(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:cU,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};const UM=/\r\n?|\n/g,IM=class t extends QI{constructor(e){super(kc(Qc({},e),{name:"freeTextEditor"})),Tc(this,Cs),Tc(this,vs),Tc(this,ys,""),Tc(this,bs,`${this.id}-editor`),Tc(this,Bs,null),Tc(this,_s),Oc(this,"_colorPicker",null),Dc(this,vs,e.color||t._defaultColor||QI._defaultLineColor),Dc(this,_s,e.fontSize||t._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const e=t.prototype,n=t=>t.isEmpty(),r=xI.TRANSLATE_SMALL,i=xI.TRANSLATE_BIG;return LU(this,"_keyboardManager",new bI([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[r,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[i,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:n}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,r],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,i],checker:n}]]))}static initialize(t,e){QI.initialize(t,e);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,n){switch(e){case eU.FREETEXT_SIZE:t._defaultFontSize=n;break;case eU.FREETEXT_COLOR:t._defaultColor=n}}updateParams(t,e){switch(t){case eU.FREETEXT_SIZE:Rc(this,Cs,xs).call(this,e);break;case eU.FREETEXT_COLOR:Rc(this,Cs,Es).call(this,e)}}static get defaultPropertiesToUpdate(){return[[eU.FREETEXT_SIZE,t._defaultFontSize],[eU.FREETEXT_COLOR,t._defaultColor||QI._defaultLineColor]]}get propertiesToUpdate(){return[[eU.FREETEXT_SIZE,Nc(this,_s)],[eU.FREETEXT_COLOR,Nc(this,vs)]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new zk(this)),[["colorPicker",this._colorPicker]]}get colorType(){return eU.FREETEXT_COLOR}get colorValue(){return Nc(this,vs)}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const e=this.parentScale;return[-t._internalPadding*e,-(t._internalPadding+Nc(this,_s))*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),Dc(this,Bs,new AbortController);const t=this._uiManager.combinedSignal(Nc(this,Bs));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){var t;return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",Nc(this,bs)),this._isDraggable=!0,null==(t=Nc(this,Bs))||t.abort(),Dc(this,Bs,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var e;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),(null==(e=this._initialOptions)?void 0:e.isCentered)&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=Nc(this,ys),e=Dc(this,ys,Rc(this,Cs,Ss).call(this).trimEnd());if(t===e)return;const n=t=>{Dc(this,ys,t),t?(Rc(this,Cs,Is).call(this),this._uiManager.rebuild(this),Rc(this,Cs,Fs).call(this)):this.remove()};this.addCommands({cmd:()=>{n(e)},undo:()=>{n(t)},mustExec:!1}),Rc(this,Cs,Fs).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(e){t._keyboardManager.exec(this,e)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",Nc(this,bs)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:n}=this.editorDiv;if(n.fontSize=`calc(${Nc(this,_s)}px * var(--total-scale-factor))`,n.color=Nc(this,vs),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[n,r]=this.parentDimensions;if(this.annotationElementId){const{position:i}=this._initialData;let[A,s]=this.getInitialTranslation();[A,s]=this.pageTranslationToScreen(A,s);const[a,o]=this.pageDimensions,[l,c]=this.pageTranslation;let h,u;switch(this.rotation){case 0:h=t+(i[0]-l)/a,u=e+this.height-(i[1]-c)/o;break;case 90:h=t+(i[0]-l)/a,u=e-(i[1]-c)/o,[A,s]=[s,-A];break;case 180:h=t-this.width+(i[0]-l)/a,u=e-(i[1]-c)/o,[A,s]=[-A,-s];break;case 270:h=t+(i[0]-l-this.height*o)/a,u=e+(i[1]-c-this.width*a)/o,[A,s]=[-s,A]}this.setAt(h*n,u*r,A,s)}else this._moveAfterPaste(t,e);Rc(this,Cs,Is).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var n,r,i;const A=e.clipboardData||window.clipboardData,{types:s}=A;if(1===s.length&&"text/plain"===s[0])return;e.preventDefault();const a=Rc(n=t,Ls,ks).call(n,A.getData("text")||"").replaceAll(UM,"\n");if(!a)return;const o=window.getSelection();if(!o.rangeCount)return;this.editorDiv.normalize(),o.deleteFromDocument();const l=o.getRangeAt(0);if(!a.includes("\n"))return l.insertNode(document.createTextNode(a)),this.editorDiv.normalize(),void o.collapseToStart();const{startContainer:c,startOffset:h}=l,u=[],d=[];if(c.nodeType===Node.TEXT_NODE){const e=c.parentElement;if(d.push(c.nodeValue.slice(h).replaceAll(UM,"")),e!==this.editorDiv){let n=u;for(const i of this.editorDiv.childNodes)i!==e?n.push(Rc(r=t,Ls,Us).call(r,i)):n=d}u.push(c.nodeValue.slice(0,h).replaceAll(UM,""))}else if(c===this.editorDiv){let e=u,n=0;for(const r of this.editorDiv.childNodes)n++===h&&(e=d),e.push(Rc(i=t,Ls,Us).call(i,r))}Dc(this,ys,`${u.join("\n")}${a}${d.join("\n")}`),Rc(this,Cs,Is).call(this);const f=new Range;let p=Math.sumPrecise(u.map(t=>t.length));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(p<=e){f.setStart(t,p),f.setEnd(t,p);break}p-=e}o.removeAllRanges(),o.addRange(f)}get contentDiv(){return this.editorDiv}static deserialize(e,n,r){return Wc(this,null,function*(){var i;let A=null;if(e instanceof pM){const{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:r,rotation:i,id:s,popupRef:a,contentsObj:o},textContent:l,textPosition:c,parent:{page:{pageNumber:h}}}=e;if(!l||0===l.length)return null;A=e={annotationType:tU.FREETEXT,color:Array.from(n),fontSize:t,value:l.join("\n"),position:c,pageIndex:h-1,rect:r.slice(0),rotation:i,annotationElementId:s,id:s,deleted:!1,popupRef:a,comment:(null==o?void 0:o.str)||null}}const s=yield jc(t,this,"deserialize").call(this,e,n,r);return Dc(s,_s,e.fontSize),Dc(s,vs,HU.makeHexColor(...e.color)),Dc(s,ys,Rc(i=t,Ls,ks).call(i,e.value)),s._initialData=A,e.comment&&s.setCommentData(e.comment),s})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n=t._internalPadding*this.parentScale,r=this.getRect(n,n),i=QI._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:Nc(this,vs)),A={annotationType:tU.FREETEXT,color:i,fontSize:Nc(this,_s),value:Rc(this,Cs,Qs).call(this),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(A),e?(A.isCopy=!0,A):this.annotationElementId&&!Rc(this,Cs,Ms).call(this,A)?null:(A.id=this.annotationElementId,A)}renderAnnotationElement(e){const n=super.renderAnnotationElement(e),{style:r}=n;r.fontSize=`calc(${Nc(this,_s)}px * var(--total-scale-factor))`,r.color=Nc(this,vs),n.replaceChildren();for(const t of Nc(this,ys).split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),n.append(e)}const i=t._internalPadding*this.parentScale,A={rect:this.getRect(i,i)};return A.popup=this.hasEditedComment?this.comment:{text:Nc(this,ys)},e.updateEdited(A),n}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};vs=new WeakMap,ys=new WeakMap,bs=new WeakMap,Bs=new WeakMap,_s=new WeakMap,Cs=new WeakSet,xs=function(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-Nc(this,_s))*this.parentScale),Dc(this,_s,t),Rc(this,Cs,Fs).call(this)},n=Nc(this,_s);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:eU.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Es=function(t){const e=t=>{var e;Dc(this,vs,this.editorDiv.style.color=t),null==(e=this._colorPicker)||e.update(t)},n=Nc(this,vs);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:eU.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Ss=function(){var t;const e=[];this.editorDiv.normalize();let n=null;for(const r of this.editorDiv.childNodes)(null==n?void 0:n.nodeType)===Node.TEXT_NODE&&"BR"===r.nodeName||(e.push(Rc(t=IM,Ls,Us).call(t,r)),n=r);return e.join("\n")},Fs=function(){const[t,e]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,r=e.style.display,i=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),n=e.getBoundingClientRect(),e.remove(),e.style.display=r,e.classList.toggle("hidden",i)}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()},Ls=new WeakSet,Us=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(UM,"")},Is=function(){if(this.editorDiv.replaceChildren(),Nc(this,ys))for(const t of Nc(this,ys).split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}},Qs=function(){return Nc(this,ys).replaceAll(" "," ")},ks=function(t){return t.replaceAll(" "," ")},Ms=function(t){const{value:e,fontSize:n,color:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==n||t.color.some((t,e)=>t!==r[e])||t.pageIndex!==i},Tc(IM,Ls),Oc(IM,"_freeTextDefaultContent",""),Oc(IM,"_internalPadding",0),Oc(IM,"_defaultColor",null),Oc(IM,"_defaultFontSize",10),Oc(IM,"_type","freetext"),Oc(IM,"_editorType",tU.FREETEXT);let QM=IM;class kM{toSVGPath(){xU("Abstract method `toSVGPath` must be implemented.")}get box(){xU("Abstract getter `box` must be implemented.")}serialize(t,e){xU("Abstract method `serialize` must be implemented.")}static _rescale(t,e,n,r,i,A){A||(A=new Float32Array(t.length));for(let s=0,a=t.length;s<a;s+=2)A[s]=e+t[s]*r,A[s+1]=n+t[s+1]*i;return A}static _rescaleAndSwap(t,e,n,r,i,A){A||(A=new Float32Array(t.length));for(let s=0,a=t.length;s<a;s+=2)A[s]=e+t[s+1]*r,A[s+1]=n+t[s]*i;return A}static _translate(t,e,n,r){r||(r=new Float32Array(t.length));for(let i=0,A=t.length;i<A;i+=2)r[i]=e+t[i],r[i+1]=n+t[i+1];return r}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,n,r,i){switch(i){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,i,A){return[(t+5*n)/6,(e+5*r)/6,(5*n+i)/6,(5*r+A)/6,(n+i)/2,(r+A)/2]}}Oc(kM,"PRECISION",1e-4);const MM=class t{constructor({x:e,y:n},r,i,A,s,a=0){Tc(this,$s),Tc(this,Os),Tc(this,Ps,[]),Tc(this,Ns),Tc(this,Ts),Tc(this,Ds,[]),Tc(this,Rs,new Float32Array(18)),Tc(this,Hs),Tc(this,js),Tc(this,Ws),Tc(this,Vs),Tc(this,Ks),Tc(this,Gs),Tc(this,zs,[]),Dc(this,Os,r),Dc(this,Gs,A*i),Dc(this,Ts,s),Nc(this,Rs).set([NaN,NaN,NaN,NaN,e,n],6),Dc(this,Ns,a),Dc(this,Vs,Nc(t,qs)*i),Dc(this,Ws,Nc(t,Ys)*i),Dc(this,Ks,i),Nc(this,zs).push(e,n)}isEmpty(){return isNaN(Nc(this,Rs)[8])}add({x:t,y:e}){var n;Dc(this,Hs,t),Dc(this,js,e);const[r,i,A,s]=Nc(this,Os);let[a,o,l,c]=Nc(this,Rs).subarray(8,12);const h=t-l,u=e-c,d=Math.hypot(h,u);if(d<Nc(this,Ws))return!1;const f=d-Nc(this,Vs),p=f/d,g=p*h,m=p*u;let w=a,v=o;a=l,o=c,l+=g,c+=m,null==(n=Nc(this,zs))||n.push(t,e);const y=g/f,b=-m/f*Nc(this,Gs),B=y*Nc(this,Gs);if(Nc(this,Rs).set(Nc(this,Rs).subarray(2,8),0),Nc(this,Rs).set([l+b,c+B],4),Nc(this,Rs).set(Nc(this,Rs).subarray(14,18),12),Nc(this,Rs).set([l-b,c-B],16),isNaN(Nc(this,Rs)[6]))return 0===Nc(this,Ds).length&&(Nc(this,Rs).set([a+b,o+B],2),Nc(this,Ds).push(NaN,NaN,NaN,NaN,(a+b-r)/A,(o+B-i)/s),Nc(this,Rs).set([a-b,o-B],14),Nc(this,Ps).push(NaN,NaN,NaN,NaN,(a-b-r)/A,(o-B-i)/s)),Nc(this,Rs).set([w,v,a,o,l,c],6),!this.isEmpty();Nc(this,Rs).set([w,v,a,o,l,c],6);return Math.abs(Math.atan2(v-o,w-a)-Math.atan2(m,g))<Math.PI/2?([a,o,l,c]=Nc(this,Rs).subarray(2,6),Nc(this,Ds).push(NaN,NaN,NaN,NaN,((a+l)/2-r)/A,((o+c)/2-i)/s),[a,o,w,v]=Nc(this,Rs).subarray(14,18),Nc(this,Ps).push(NaN,NaN,NaN,NaN,((w+a)/2-r)/A,((v+o)/2-i)/s),!0):([w,v,a,o,l,c]=Nc(this,Rs).subarray(0,6),Nc(this,Ds).push(((w+5*a)/6-r)/A,((v+5*o)/6-i)/s,((5*a+l)/6-r)/A,((5*o+c)/6-i)/s,((a+l)/2-r)/A,((o+c)/2-i)/s),[l,c,a,o,w,v]=Nc(this,Rs).subarray(12,18),Nc(this,Ps).push(((w+5*a)/6-r)/A,((v+5*o)/6-i)/s,((5*a+l)/6-r)/A,((5*o+c)/6-i)/s,((a+l)/2-r)/A,((o+c)/2-i)/s),!0)}toSVGPath(){if(this.isEmpty())return"";const t=Nc(this,Ds),e=Nc(this,Ps);if(isNaN(Nc(this,Rs)[6])&&!this.isEmpty())return Rc(this,$s,Zs).call(this);const 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]}`);Rc(this,$s,ea).call(this,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 Rc(this,$s,ta).call(this,n),n.join(" ")}newFreeDrawOutline(t,e,n,r,i,A){return new PM(t,e,n,r,i,A)}getOutlines(){var t,e;const n=Nc(this,Ds),r=Nc(this,Ps),i=Nc(this,Rs),[A,s,a,o]=Nc(this,Os),l=new Float32Array((null!=(e=null==(t=Nc(this,zs))?void 0:t.length)?e:0)+2);for(let u=0,d=l.length-2;u<d;u+=2)l[u]=(Nc(this,zs)[u]-A)/a,l[u+1]=(Nc(this,zs)[u+1]-s)/o;if(l[l.length-2]=(Nc(this,Hs)-A)/a,l[l.length-1]=(Nc(this,js)-s)/o,isNaN(i[6])&&!this.isEmpty())return Rc(this,$s,na).call(this,l);const c=new Float32Array(Nc(this,Ds).length+24+Nc(this,Ps).length);let h=n.length;for(let u=0;u<h;u+=2)isNaN(n[u])?c[u]=c[u+1]=NaN:(c[u]=n[u],c[u+1]=n[u+1]);h=Rc(this,$s,ia).call(this,c,h);for(let u=r.length-6;u>=6;u-=6)for(let t=0;t<6;t+=2)isNaN(r[u+t])?(c[h]=c[h+1]=NaN,h+=2):(c[h]=r[u+t],c[h+1]=r[u+t+1],h+=2);return Rc(this,$s,ra).call(this,c,h),this.newFreeDrawOutline(c,l,Nc(this,Os),Nc(this,Ks),Nc(this,Ns),Nc(this,Ts))}};Os=new WeakMap,Ps=new WeakMap,Ns=new WeakMap,Ts=new WeakMap,Ds=new WeakMap,Rs=new WeakMap,Hs=new WeakMap,js=new WeakMap,Ws=new WeakMap,Vs=new WeakMap,Ks=new WeakMap,Gs=new WeakMap,zs=new WeakMap,qs=new WeakMap,Xs=new WeakMap,Ys=new WeakMap,$s=new WeakSet,Js=function(){const t=Nc(this,Rs).subarray(4,6),e=Nc(this,Rs).subarray(16,18),[n,r,i,A]=Nc(this,Os);return[(Nc(this,Hs)+(t[0]-e[0])/2-n)/i,(Nc(this,js)+(t[1]-e[1])/2-r)/A,(Nc(this,Hs)+(e[0]-t[0])/2-n)/i,(Nc(this,js)+(e[1]-t[1])/2-r)/A]},Zs=function(){const[t,e,n,r]=Nc(this,Os),[i,A,s,a]=Rc(this,$s,Js).call(this);return`M${(Nc(this,Rs)[2]-t)/n} ${(Nc(this,Rs)[3]-e)/r} L${(Nc(this,Rs)[4]-t)/n} ${(Nc(this,Rs)[5]-e)/r} L${i} ${A} L${s} ${a} L${(Nc(this,Rs)[16]-t)/n} ${(Nc(this,Rs)[17]-e)/r} L${(Nc(this,Rs)[14]-t)/n} ${(Nc(this,Rs)[15]-e)/r} Z`},ta=function(t){const e=Nc(this,Ps);t.push(`L${e[4]} ${e[5]} Z`)},ea=function(t){const[e,n,r,i]=Nc(this,Os),A=Nc(this,Rs).subarray(4,6),s=Nc(this,Rs).subarray(16,18),[a,o,l,c]=Rc(this,$s,Js).call(this);t.push(`L${(A[0]-e)/r} ${(A[1]-n)/i} L${a} ${o} L${l} ${c} L${(s[0]-e)/r} ${(s[1]-n)/i}`)},na=function(t){const e=Nc(this,Rs),[n,r,i,A]=Nc(this,Os),[s,a,o,l]=Rc(this,$s,Js).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-n)/i,(e[3]-r)/A,NaN,NaN,NaN,NaN,(e[4]-n)/i,(e[5]-r)/A,NaN,NaN,NaN,NaN,s,a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,(e[16]-n)/i,(e[17]-r)/A,NaN,NaN,NaN,NaN,(e[14]-n)/i,(e[15]-r)/A],0),this.newFreeDrawOutline(c,t,Nc(this,Os),Nc(this,Ks),Nc(this,Ns),Nc(this,Ts))},ra=function(t,e){const n=Nc(this,Ps);return t.set([NaN,NaN,NaN,NaN,n[4],n[5]],e),e+6},ia=function(t,e){const n=Nc(this,Rs).subarray(4,6),r=Nc(this,Rs).subarray(16,18),[i,A,s,a]=Nc(this,Os),[o,l,c,h]=Rc(this,$s,Js).call(this);return t.set([NaN,NaN,NaN,NaN,(n[0]-i)/s,(n[1]-A)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(r[0]-i)/s,(r[1]-A)/a],e),e+24},Tc(MM,qs,8),Tc(MM,Xs,2),Tc(MM,Ys,Nc(MM,qs)+Nc(MM,Xs));let OM=MM;class PM extends kM{constructor(t,e,n,r,i,A){super(),Tc(this,ua),Tc(this,Aa),Tc(this,sa,new Float32Array(4)),Tc(this,aa),Tc(this,oa),Tc(this,la),Tc(this,ca),Tc(this,ha),Dc(this,ha,t),Dc(this,la,e),Dc(this,Aa,n),Dc(this,ca,r),Dc(this,aa,i),Dc(this,oa,A),this.lastPoint=[NaN,NaN],Rc(this,ua,da).call(this,A);const[s,a,o,l]=Nc(this,sa);for(let c=0,h=t.length;c<h;c+=2)t[c]=(t[c]-s)/o,t[c+1]=(t[c+1]-a)/l;for(let c=0,h=e.length;c<h;c+=2)e[c]=(e[c]-s)/o,e[c+1]=(e[c+1]-a)/l}toSVGPath(){const t=[`M${Nc(this,ha)[4]} ${Nc(this,ha)[5]}`];for(let e=6,n=Nc(this,ha).length;e<n;e+=6)isNaN(Nc(this,ha)[e])?t.push(`L${Nc(this,ha)[e+4]} ${Nc(this,ha)[e+5]}`):t.push(`C${Nc(this,ha)[e]} ${Nc(this,ha)[e+1]} ${Nc(this,ha)[e+2]} ${Nc(this,ha)[e+3]} ${Nc(this,ha)[e+4]} ${Nc(this,ha)[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,n,r],i){const A=n-t,s=r-e;let a,o;switch(i){case 0:a=kM._rescale(Nc(this,ha),t,r,A,-s),o=kM._rescale(Nc(this,la),t,r,A,-s);break;case 90:a=kM._rescaleAndSwap(Nc(this,ha),t,e,A,s),o=kM._rescaleAndSwap(Nc(this,la),t,e,A,s);break;case 180:a=kM._rescale(Nc(this,ha),n,e,-A,s),o=kM._rescale(Nc(this,la),n,e,-A,s);break;case 270:a=kM._rescaleAndSwap(Nc(this,ha),n,r,-A,-s),o=kM._rescaleAndSwap(Nc(this,la),n,r,-A,-s)}return{outline:Array.from(a),points:[Array.from(o)]}}get box(){return Nc(this,sa)}newOutliner(t,e,n,r,i,A=0){return new OM(t,e,n,r,i,A)}getNewOutline(t,e){const[n,r,i,A]=Nc(this,sa),[s,a,o,l]=Nc(this,Aa),c=i*o,h=A*l,u=n*o+s,d=r*l+a,f=this.newOutliner({x:Nc(this,la)[0]*c+u,y:Nc(this,la)[1]*h+d},Nc(this,Aa),Nc(this,ca),t,Nc(this,oa),null!=e?e:Nc(this,aa));for(let p=2;p<Nc(this,la).length;p+=2)f.add({x:Nc(this,la)[p]*c+u,y:Nc(this,la)[p+1]*h+d});return f.getOutlines()}}Aa=new WeakMap,sa=new WeakMap,aa=new WeakMap,oa=new WeakMap,la=new WeakMap,ca=new WeakMap,ha=new WeakMap,ua=new WeakSet,da=function(t){const e=Nc(this,ha);let n=e[4],r=e[5];const i=[n,r,n,r];let A=n,s=r;const a=t?Math.max:Math.min;for(let l=6,c=e.length;l<c;l+=6){const t=e[l+4],o=e[l+5];if(isNaN(e[l]))HU.pointBoundingBox(t,o,i),s<o?(A=t,s=o):s===o&&(A=a(A,t));else{const t=[1/0,1/0,-1/0,-1/0];HU.bezierBoundingBox(n,r,...e.slice(l,l+6),t),HU.rectBoundingBox(...t,i),s<t[3]?(A=t[2],s=t[3]):s===t[3]&&(A=a(A,t[2]))}n=t,r=o}const o=Nc(this,sa);o[0]=i[0]-Nc(this,aa),o[1]=i[1]-Nc(this,aa),o[2]=i[2]-i[0]+2*Nc(this,aa),o[3]=i[3]-i[1]+2*Nc(this,aa),this.lastPoint=[A,s]};class NM{constructor(t,e=0,n=0,r=!0){Tc(this,wa),Tc(this,fa),Tc(this,pa),Tc(this,ga,[]),Tc(this,ma,[]);const i=[1/0,1/0,-1/0,-1/0],A=Uc(10,-4);for(const{x:u,y:d,width:f,height:p}of t){const t=Math.floor((u-e)/A)*A,n=Math.ceil((u+f+e)/A)*A,r=Math.floor((d-e)/A)*A,s=Math.ceil((d+p+e)/A)*A,a=[t,r,s,!0],o=[n,r,s,!1];Nc(this,ga).push(a,o),HU.rectBoundingBox(t,r,n,s,i)}const s=i[2]-i[0]+2*n,a=i[3]-i[1]+2*n,o=i[0]-n,l=i[1]-n,c=Nc(this,ga).at(r?-1:-2),h=[c[0],c[2]];for(const u of Nc(this,ga)){const[t,e,n]=u;u[0]=(t-o)/s,u[1]=(e-l)/a,u[2]=(n-l)/a}Dc(this,fa,new Float32Array([o,l,s,a])),Dc(this,pa,h)}getOutlines(){Nc(this,ga).sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of Nc(this,ga))e[3]?(t.push(...Rc(this,wa,_a).call(this,e)),Rc(this,wa,ba).call(this,e)):(Rc(this,wa,Ba).call(this,e),t.push(...Rc(this,wa,_a).call(this,e)));return Rc(this,wa,va).call(this,t)}}fa=new WeakMap,pa=new WeakMap,ga=new WeakMap,ma=new WeakMap,wa=new WeakSet,va=function(t){const e=[],n=new Set;for(const A of t){const[t,n,r]=A;e.push([t,n,A],[t,r,A])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let A=0,s=e.length;A<s;A+=2){const t=e[A][2],r=e[A+1][2];t.push(r),r.push(t),n.add(t),n.add(r)}const r=[];let i;for(;n.size>0;){const t=n.values().next().value;let[e,A,s,a,o]=t;n.delete(t);let l=e,c=A;for(i=[e,s],r.push(i);;){let t;if(n.has(a))t=a;else{if(!n.has(o))break;t=o}n.delete(t),[e,A,s,a,o]=t,l!==e&&(i.push(l,c,e,c===A?A:s),l=e),c=c===A?s:A}i.push(l,c)}return new TM(r,Nc(this,fa),Nc(this,pa))},ya=function(t){const e=Nc(this,ma);let n=0,r=e.length-1;for(;n<=r;){const i=n+r>>1,A=e[i][0];if(A===t)return i;A<t?n=i+1:r=i-1}return r+1},ba=function([,t,e]){const n=Rc(this,wa,ya).call(this,t);Nc(this,ma).splice(n,0,[t,e])},Ba=function([,t,e]){const n=Rc(this,wa,ya).call(this,t);for(let r=n;r<Nc(this,ma).length;r++){const[n,i]=Nc(this,ma)[r];if(n!==t)break;if(n===t&&i===e)return void Nc(this,ma).splice(r,1)}for(let r=n-1;r>=0;r--){const[n,i]=Nc(this,ma)[r];if(n!==t)break;if(n===t&&i===e)return void Nc(this,ma).splice(r,1)}},_a=function(t){const[e,n,r]=t,i=[[e,n,r]],A=Rc(this,wa,ya).call(this,r);for(let s=0;s<A;s++){const[t,n]=Nc(this,ma)[s];for(let r=0,A=i.length;r<A;r++){const[,s,a]=i[r];if(!(n<=s||a<=t))if(s>=t)if(a>n)i[r][1]=n;else{if(1===A)return[];i.splice(r,1),r--,A--}else i[r][2]=t,a>n&&i.push([e,n,a])}}return i};class TM extends kM{constructor(t,e,n){super(),Tc(this,Ca),Tc(this,xa),Dc(this,xa,t),Dc(this,Ca,e),this.lastPoint=n}toSVGPath(){const t=[];for(const e of Nc(this,xa)){let[n,r]=e;t.push(`M${n} ${r}`);for(let i=2;i<e.length;i+=2){const A=e[i],s=e[i+1];A===n?(t.push(`V${s}`),r=s):s===r&&(t.push(`H${A}`),n=A)}t.push("Z")}return t.join(" ")}serialize([t,e,n,r],i){const A=[],s=n-t,a=r-e;for(const o of Nc(this,xa)){const e=new Array(o.length);for(let n=0;n<o.length;n+=2)e[n]=t+o[n]*s,e[n+1]=r-o[n+1]*a;A.push(e)}return A}get box(){return Nc(this,Ca)}get classNamesForOutlining(){return["highlightOutline"]}}Ca=new WeakMap,xa=new WeakMap;class DM extends OM{newFreeDrawOutline(t,e,n,r,i,A){return new RM(t,e,n,r,i,A)}}class RM extends PM{newOutliner(t,e,n,r,i,A=0){return new DM(t,e,n,r,i,A)}}const HM=class t extends QI{constructor(e){super(kc(Qc({},e),{name:"highlightEditor"})),Tc(this,Va),Tc(this,Ea,null),Tc(this,Sa,0),Tc(this,Fa),Tc(this,La,null),Tc(this,Ua,null),Tc(this,Ia,null),Tc(this,Qa,null),Tc(this,ka,0),Tc(this,Ma,null),Tc(this,Oa,null),Tc(this,Pa,null),Tc(this,Na,!1),Tc(this,Ta,null),Tc(this,Da),Tc(this,Ra,null),Tc(this,Ha,""),Tc(this,ja),Tc(this,Wa,""),this.color=e.color||t._defaultColor,Dc(this,ja,e.thickness||t._defaultThickness),Dc(this,Da,e.opacity||t._defaultOpacity),Dc(this,Fa,e.boxes||null),Dc(this,Wa,e.methodOfCreation||""),Dc(this,Ha,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(Dc(this,Na,!0),Rc(this,Va,Ga).call(this,e),Rc(this,Va,$a).call(this)):Nc(this,Fa)&&(Dc(this,Ea,e.anchorNode),Dc(this,Sa,e.anchorOffset),Dc(this,Qa,e.focusNode),Dc(this,ka,e.focusOffset),Rc(this,Va,Ka).call(this),Rc(this,Va,$a).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=t.prototype;return LU(this,"_keyboardManager",new bI([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:Nc(this,Na)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:Nc(this,ja),methodOfCreation:Nc(this,Wa)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}get commentColor(){return this.color}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(e,n){var r;QI.initialize(e,n),t._defaultColor||(t._defaultColor=(null==(r=n.highlightColors)?void 0:r.values().next().value)||"#fff066")}static updateDefaultParams(e,n){switch(e){case eU.HIGHLIGHT_COLOR:t._defaultColor=n;break;case eU.HIGHLIGHT_THICKNESS:t._defaultThickness=n}}translateInPage(t,e){}get toolbarPosition(){return Nc(this,Ta)}updateParams(t,e){switch(t){case eU.HIGHLIGHT_COLOR:Rc(this,Va,za).call(this,e);break;case eU.HIGHLIGHT_THICKNESS:Rc(this,Va,qa).call(this,e)}}static get defaultPropertiesToUpdate(){return[[eU.HIGHLIGHT_COLOR,t._defaultColor],[eU.HIGHLIGHT_THICKNESS,t._defaultThickness]]}get propertiesToUpdate(){return[[eU.HIGHLIGHT_COLOR,this.color||t._defaultColor],[eU.HIGHLIGHT_THICKNESS,Nc(this,ja)||t._defaultThickness],[eU.HIGHLIGHT_FREE,Nc(this,Na)]]}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",Dc(this,Ua,new Kk({editor:this}))]]}return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(Rc(this,Va,no).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,Rc(this,Va,no).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){Rc(this,Va,Ya).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(Rc(this,Va,$a).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let n=!1;this.parent&&!t?Rc(this,Va,Ya).call(this):t&&(Rc(this,Va,$a).call(this,t),n=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),n&&this.select()}rotate(e){var n,r,i;const{drawLayer:A}=this.parent;let s;Nc(this,Na)?(e=(e-this.rotation+360)%360,s=Rc(n=t,Ja,Za).call(n,Nc(this,Oa).box,e)):s=Rc(r=t,Ja,Za).call(r,[this.x,this.y,this.width,this.height],e),A.updateProperties(Nc(this,Pa),{bbox:s,root:{"data-main-rotation":e}}),A.updateProperties(Nc(this,Ra),{bbox:Rc(i=t,Ja,Za).call(i,Nc(this,Ia).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const t=super.render();Nc(this,Ha)&&(t.setAttribute("aria-label",Nc(this,Ha)),t.setAttribute("role","mark")),Nc(this,Na)?t.classList.add("free"):this.div.addEventListener("keydown",Rc(this,Va,to).bind(this),{signal:this._uiManager._signal});const e=Dc(this,Ma,document.createElement("div"));t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=Nc(this,La);const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),gI(this,Nc(this,Ma),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:Rc(this,Va,eo).call(this,!0);break;case 1:case 3:Rc(this,Va,eo).call(this,!1)}}select(){var t;super.select(),Nc(this,Ra)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),Nc(this,Ra)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{selected:!1}}),Nc(this,Na)||Rc(this,Va,eo).call(this,!1))}get _mustFixPosition(){return!Nc(this,Na)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(Nc(this,Pa),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(Nc(this,Ra),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,{target:n,x:r,y:i}){const{x:A,y:s,width:a,height:o}=n.getBoundingClientRect(),l=new AbortController,c=t.combinedSignal(l),h=e=>{l.abort(),Rc(this,Ja,so).call(this,t,e)};window.addEventListener("blur",h,{signal:c}),window.addEventListener("pointerup",h,{signal:c}),window.addEventListener("pointerdown",AI,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",iI,{signal:c}),n.addEventListener("pointermove",Rc(this,Ja,Ao).bind(this,t),{signal:c}),this._freeHighlight=new DM({x:r,y:i},[A,s,a,o],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 deserialize(e,n,r){return Wc(this,null,function*(){var i,A,s,a;let o=null;if(e instanceof _M){const{data:{quadPoints:t,rect:n,rotation:r,id:i,color:A,opacity:s,popupRef:a,contentsObj:l},parent:{page:{pageNumber:c}}}=e;o=e={annotationType:tU.HIGHLIGHT,color:Array.from(A),opacity:s,quadPoints:t,boxes:null,pageIndex:c-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:a,comment:(null==l?void 0:l.str)||null}}else if(e instanceof BM){const{data:{inkLists:t,rect:n,rotation:r,id:i,color:A,borderStyle:{rawWidth:s},popupRef:a,contentsObj:l},parent:{page:{pageNumber:c}}}=e;o=e={annotationType:tU.HIGHLIGHT,color:Array.from(A),thickness:s,inkLists:t,boxes:null,pageIndex:c-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:a,comment:(null==l?void 0:l.str)||null}}const{color:l,quadPoints:c,inkLists:h,opacity:u}=e,d=yield jc(t,this,"deserialize").call(this,e,n,r);d.color=HU.makeHexColor(...l),Dc(d,Da,u||1),h&&Dc(d,ja,e.thickness),d._initialData=o,e.comment&&d.setCommentData(e.comment);const[f,p]=d.pageDimensions,[g,m]=d.pageTranslation;if(c){const t=Dc(d,Fa,[]);for(let e=0;e<c.length;e+=8)t.push({x:(c[e]-g)/f,y:1-(c[e+1]-m)/p,width:(c[e+2]-c[e])/f,height:(c[e+1]-c[e+5])/p});Rc(i=d,Va,Ka).call(i),Rc(A=d,Va,$a).call(A),d.rotate(d.rotation)}else if(h){Dc(d,Na,!0);const t=h[0],e={x:t[0]-g,y:p-(t[1]-m)},r=new DM(e,[0,0,f,p],1,Nc(d,ja)/2,!0,.001);for(let n=0,s=t.length;n<s;n+=2)e.x=t[n]-g,e.y=p-(t[n+1]-m),r.add(e);const{id:i,clipPathId:A}=n.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);Rc(s=d,Va,Ga).call(s,{highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:A}),Rc(a=d,Va,$a).call(a),d.rotate(d.parentRotation)}return d})}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),n=QI._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),r={annotationType:tU.HIGHLIGHT,color:n,opacity:Nc(this,Da),thickness:Nc(this,ja),quadPoints:Rc(this,Va,ro).call(this),outlines:Rc(this,Va,io).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:Rc(this,Va,no).call(this),structTreeParentId:this._structTreeParentId};return this.addComment(r),this.annotationElementId&&!Rc(this,Va,ao).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(t){const e={rect:this.getRect(0,0)};return this.hasEditedComment&&(e.popup=this.comment),t.updateEdited(e),null}static canCreateNewEmptyEditor(){return!1}};Ea=new WeakMap,Sa=new WeakMap,Fa=new WeakMap,La=new WeakMap,Ua=new WeakMap,Ia=new WeakMap,Qa=new WeakMap,ka=new WeakMap,Ma=new WeakMap,Oa=new WeakMap,Pa=new WeakMap,Na=new WeakMap,Ta=new WeakMap,Da=new WeakMap,Ra=new WeakMap,Ha=new WeakMap,ja=new WeakMap,Wa=new WeakMap,Va=new WeakSet,Ka=function(){const t=new NM(Nc(this,Fa),.001);Dc(this,Oa,t.getOutlines()),[this.x,this.y,this.width,this.height]=Nc(this,Oa).box;const e=new NM(Nc(this,Fa),.0025,.001,"ltr"===this._uiManager.direction);Dc(this,Ia,e.getOutlines());const{lastPoint:n}=Nc(this,Ia);Dc(this,Ta,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height])},Ga=function({highlightOutlines:t,highlightId:e,clipPathId:n}){var r,i;Dc(this,Oa,t);if(Dc(this,Ia,t.getNewOutline(Nc(this,ja)/2+1.5,.0025)),e>=0)Dc(this,Pa,e),Dc(this,La,n),this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),Dc(this,Ra,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:Nc(this,Ia).box,path:{d:Nc(this,Ia).toSVGPath()}},!0));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(Nc(this,Pa),{bbox:Rc(r=HM,Ja,Za).call(r,Nc(this,Oa).box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(Nc(this,Ra),{bbox:Rc(i=HM,Ja,Za).call(i,Nc(this,Ia).box,e),path:{d:Nc(this,Ia).toSVGPath()}})}const[A,s,a,o]=t.box;switch(this.rotation){case 0:this.x=A,this.y=s,this.width=a,this.height=o;break;case 90:{const[t,e]=this.parentDimensions;this.x=s,this.y=1-A,this.width=a*e/t,this.height=o*t/e;break}case 180:this.x=1-A,this.y=1-s,this.width=a,this.height=o;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-s,this.y=A,this.width=a*e/t,this.height=o*t/e;break}}const{lastPoint:l}=Nc(this,Ia);Dc(this,Ta,[(l[0]-A)/a,(l[1]-s)/o])},za=function(t){const e=(t,e)=>{var n,r;this.color=t,Dc(this,Da,e),null==(n=this.parent)||n.drawLayer.updateProperties(Nc(this,Pa),{root:{fill:t,"fill-opacity":e}}),null==(r=Nc(this,Ua))||r.updateColor(t)},n=this.color,r=Nc(this,Da);this.addCommands({cmd:e.bind(this,t,HM._defaultOpacity),undo:e.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:eU.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)},qa=function(t){const e=Nc(this,ja),n=t=>{Dc(this,ja,t),Rc(this,Va,Xa).call(this,t)};this.addCommands({cmd:n.bind(this,t),undo:n.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:eU.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},Xa=function(t){if(!Nc(this,Na))return;Rc(this,Va,Ga).call(this,{highlightOutlines:Nc(this,Oa).getNewOutline(t/2)}),this.fixAndSetPosition();const[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)},Ya=function(){null!==Nc(this,Pa)&&this.parent&&(this.parent.drawLayer.remove(Nc(this,Pa)),Dc(this,Pa,null),this.parent.drawLayer.remove(Nc(this,Ra)),Dc(this,Ra,null))},$a=function(t=this.parent){null===Nc(this,Pa)&&(({id:Hc(this,Pa)._,clipPathId:Hc(this,La)._}=t.drawLayer.draw({bbox:Nc(this,Oa).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":Nc(this,Da)},rootClass:{highlight:!0,free:Nc(this,Na)},path:{d:Nc(this,Oa).toSVGPath()}},!1,!0)),Dc(this,Ra,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:Nc(this,Na)},bbox:Nc(this,Ia).box,path:{d:Nc(this,Ia).toSVGPath()}},Nc(this,Na))),Nc(this,Ma)&&(Nc(this,Ma).style.clipPath=Nc(this,La)))},Ja=new WeakSet,Za=function([t,e,n,r],i){switch(i){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]},to=function(t){HM._keyboardManager.exec(this,t)},eo=function(t){if(!Nc(this,Ea))return;const e=window.getSelection();t?e.setPosition(Nc(this,Ea),Nc(this,Sa)):e.setPosition(Nc(this,Qa),Nc(this,ka))},no=function(){return Nc(this,Na)?this.rotation:0},ro=function(){if(Nc(this,Na))return null;const[t,e]=this.pageDimensions,[n,r]=this.pageTranslation,i=Nc(this,Fa),A=new Float32Array(8*i.length);let s=0;for(const{x:a,y:o,width:l,height:c}of i){const i=a*t+n,h=(1-o)*e+r;A[s]=A[s+4]=i,A[s+1]=A[s+3]=h,A[s+2]=A[s+6]=i+l*t,A[s+5]=A[s+7]=h-c*e,s+=8}return A},io=function(t){return Nc(this,Oa).serialize(t,Rc(this,Va,no).call(this))},Ao=function(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},so=function(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},ao=function(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,n)=>t!==e[n])},Tc(HM,Ja),Oc(HM,"_defaultColor",null),Oc(HM,"_defaultOpacity",1),Oc(HM,"_defaultThickness",12),Oc(HM,"_type","highlight"),Oc(HM,"_editorType",tU.HIGHLIGHT),Oc(HM,"_freeHighlightId",-1),Oc(HM,"_freeHighlight",null),Oc(HM,"_freeHighlightClipId","");let jM=HM;class WM{constructor(){Tc(this,oo,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,n]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,n)}updateSVGProperty(t,e){Nc(this,oo)[t]=e}toSVGProperties(){const t=Nc(this,oo);return Dc(this,oo,Object.create(null)),{root:t}}reset(){Dc(this,oo,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){xU("Not implemented")}}oo=new WeakMap;const VM=class t extends QI{constructor(t){super(t),Tc(this,vo),Tc(this,lo,null),Tc(this,co),Oc(this,"_colorPicker",null),Oc(this,"_drawId",null),Dc(this,co,t.mustBeCommitted||!1),this._addOutlines(t)}_addOutlines(t){t.drawOutlines&&(Rc(this,vo,yo).call(this,t),Rc(this,vo,_o).call(this))}static _mergeSVGProperties(t,e){const n=new Set(Object.keys(t));for(const[r,i]of Object.entries(e))n.has(r)?Object.assign(t[r],i):t[r]=i;return t}static getDefaultDrawingOptions(t){xU("Not implemented")}static get typesMap(){xU("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,n){const r=this.typesMap.get(e);r&&this._defaultDrawingOptions.updateProperty(r,n),this._currentParent&&(Nc(t,ho).updateProperty(r,n),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const n=this.constructor.typesMap.get(t);n&&this._updateProperty(t,n,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[n,r]of this.typesMap)t.push([n,e[r]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[n,r]of this.constructor.typesMap)t.push([n,e[r]]);return t}_updateProperty(t,e,n){const r=this._drawingOptions,i=r[e],A=n=>{var i,A;r.updateProperty(e,n);const s=Nc(this,lo).updateProperty(e,n);s&&Rc(this,vo,Eo).call(this,s),null==(i=this.parent)||i.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),t===this.colorType&&(null==(A=this._colorPicker)||A.update(n))};this.addCommands({cmd:A.bind(this,n),undo:A.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Nc(this,lo).getPathResizingSVGProperties(Rc(this,vo,xo).call(this)),{bbox:Rc(this,vo,So).call(this)}))}_onResized(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Nc(this,lo).getPathResizedSVGProperties(Rc(this,vo,xo).call(this)),{bbox:Rc(this,vo,So).call(this)}))}_onTranslating(t,e){var n;null==(n=this.parent)||n.drawLayer.updateProperties(this._drawId,{bbox:Rc(this,vo,So).call(this)})}_onTranslated(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(Nc(this,lo).getPathTranslatedSVGProperties(Rc(this,vo,xo).call(this),this.parentDimensions),{bbox:Rc(this,vo,So).call(this)}))}_onStartDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,Nc(this,co)&&(Dc(this,co,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){Rc(this,vo,Bo).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(Rc(this,vo,_o).call(this),Rc(this,vo,Eo).call(this,Nc(this,lo).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let n=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),Rc(this,vo,Bo).call(this)):t&&(this._uiManager.addShouldRescale(this),Rc(this,vo,_o).call(this,t),n=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),n&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties({bbox:Rc(this,vo,So).call(this)},Nc(this,lo).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&Rc(this,vo,Eo).call(this,Nc(this,lo).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const n=super.render();n.classList.add("draw");const r=document.createElement("div");n.append(r),r.setAttribute("aria-hidden","true"),r.className="internal";const[i,A]=this.parentDimensions;return this.setDims(this.width*i,this.height*A),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),n}static createDrawerInstance(t,e,n,r,i){xU("Not implemented")}static startDrawing(e,n,r,i){var A;const{target:s,offsetX:a,offsetY:o,pointerId:l,pointerType:c}=i;if(Nc(t,go)&&Nc(t,go)!==c)return;const{viewport:{rotation:h}}=e,{width:u,height:d}=s.getBoundingClientRect(),f=Dc(t,uo,new AbortController),p=e.combinedSignal(f);Nc(t,po)||Dc(t,po,l),null!=Nc(t,go)||Dc(t,go,c),window.addEventListener("pointerup",e=>{var n;Nc(t,po)===e.pointerId?this._endDraw(e):null==(n=Nc(t,mo))||n.delete(e.pointerId)},{signal:p}),window.addEventListener("pointercancel",e=>{var n;Nc(t,po)===e.pointerId?this._currentParent.endDrawingSession():null==(n=Nc(t,mo))||n.delete(e.pointerId)},{signal:p}),window.addEventListener("pointerdown",e=>{Nc(t,go)===e.pointerType&&((Nc(t,mo)||Dc(t,mo,new Set)).add(e.pointerId),Nc(t,ho).isCancellable()&&(Nc(t,ho).removeLastElement(),Nc(t,ho).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",iI,{signal:p}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),s.addEventListener("touchmove",e=>{e.timeStamp===Nc(t,wo)&&AI(e)},{signal:p}),e.toggleDrawing(),null==(A=n._editorUndoBar)||A.hide(),Nc(t,ho)?e.drawLayer.updateProperties(this._currentDrawId,Nc(t,ho).startNew(a,o,u,d,h)):(n.updateUIForDefaultProperties(this),Dc(t,ho,this.createDrawerInstance(a,o,u,d,h)),Dc(t,fo,this.getDefaultDrawingOptions()),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(Nc(t,fo).toSVGProperties(),Nc(t,ho).defaultSVGProperties),!0,!1)))}static _drawMove(e){var n;if(Dc(t,wo,-1),!Nc(t,ho))return;const{offsetX:r,offsetY:i,pointerId:A}=e;Nc(t,po)===A&&((null==(n=Nc(t,mo))?void 0:n.size)>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Nc(t,ho).add(r,i)),Dc(t,wo,e.timeStamp),AI(e)))}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,Dc(t,ho,null),Dc(t,fo,null),Dc(t,go,null),Dc(t,wo,NaN)),Nc(t,uo)&&(Nc(t,uo).abort(),Dc(t,uo,null),Dc(t,po,NaN),Dc(t,mo,null))}static _endDraw(e){const n=this._currentParent;if(n){if(n.toggleDrawing(!0),this._cleanup(!1),(null==e?void 0:e.target)===n.div&&n.drawLayer.updateProperties(this._currentDrawId,Nc(t,ho).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=Nc(t,ho),r=this._currentDrawId,i=e.getLastElement();return void n.addCommands({cmd:()=>{n.drawLayer.updateProperties(r,e.setLastElement(i))},undo:()=>{n.drawLayer.updateProperties(r,e.removeLastElement())},mustExec:!1,type:eU.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(e){const n=this._currentParent;if(!n)return null;if(n.toggleDrawing(!0),n.cleanUndoStack(eU.DRAW_STEP),!Nc(t,ho).isEmpty()){const{pageDimensions:[r,i],scale:A}=n,s=n.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Nc(t,ho).getOutlines(r*A,i*A,A,this._INNER_MARGIN),drawingOptions:Nc(t,fo),mustBeCommitted:!e});return this._cleanup(!0),s}return n.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,n,r,i,A){xU("Not implemented")}static deserialize(e,n,r){return Wc(this,null,function*(){var i,A;const{rawDims:{pageWidth:s,pageHeight:a,pageX:o,pageY:l}}=n.viewport,c=this.deserializeDraw(o,l,s,a,this._INNER_MARGIN,e),h=yield jc(t,this,"deserialize").call(this,e,n,r);return h.createDrawingOptions(e),Rc(i=h,vo,yo).call(i,{drawOutlines:c}),Rc(A=h,vo,_o).call(A),h.onScaleChanging(),h.rotate(),h})}serializeDraw(t){const[e,n]=this.pageTranslation,[r,i]=this.pageDimensions;return Nc(this,lo).serialize([e,n,r,i],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};lo=new WeakMap,co=new WeakMap,ho=new WeakMap,uo=new WeakMap,fo=new WeakMap,po=new WeakMap,go=new WeakMap,mo=new WeakMap,wo=new WeakMap,vo=new WeakSet,yo=function({drawOutlines:t,drawId:e,drawingOptions:n}){Dc(this,lo,t),this._drawingOptions||(this._drawingOptions=n),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=Rc(this,vo,bo).call(this,t,this.parent),Rc(this,vo,Eo).call(this,t.box)},bo=function(t,e){const{id:n}=e.drawLayer.draw(VM._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return n},Bo=function(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},_o=function(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=Rc(this,vo,bo).call(this,Nc(this,lo),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))},Co=function([t,e,n,r]){const{parentDimensions:[i,A],rotation:s}=this;switch(s){case 90:return[e,1-t,n*(A/i),r*(i/A)];case 180:return[1-t,1-e,n,r];case 270:return[1-e,t,n*(A/i),r*(i/A)];default:return[t,e,n,r]}},xo=function(){const{x:t,y:e,width:n,height:r,parentDimensions:[i,A],rotation:s}=this;switch(s){case 90:return[1-e,t,n*(i/A),r*(A/i)];case 180:return[1-t,1-e,n,r];case 270:return[e,1-t,n*(i/A),r*(A/i)];default:return[t,e,n,r]}},Eo=function(t){if([this.x,this.y,this.width,this.height]=Rc(this,vo,Co).call(this,t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()},So=function(){const{x:t,y:e,width:n,height:r,rotation:i,parentRotation:A,parentDimensions:[s,a]}=this;switch((4*i+A)/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*(s/a),r*(a/s),n*(s/a)];case 5:return[1-e,t,n*(s/a),r*(a/s)];case 6:return[1-t-r*(a/s),1-e,r*(a/s),n*(s/a)];case 7:return[e-n*(s/a),1-t-r*(a/s),n*(s/a),r*(a/s)];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*(a/s),e,r*(a/s),n*(s/a)];case 13:return[1-e-n*(s/a),t-r*(a/s),n*(s/a),r*(a/s)];case 14:return[1-t,1-e-n*(s/a),r*(a/s),n*(s/a)];case 15:return[e,1-t,n*(s/a),r*(a/s)];default:return[t,e,n,r]}},Oc(VM,"_currentDrawId",-1),Oc(VM,"_currentParent",null),Tc(VM,ho,null),Tc(VM,uo,null),Tc(VM,fo,null),Tc(VM,po,NaN),Tc(VM,go,null),Tc(VM,mo,null),Tc(VM,wo,NaN),Oc(VM,"_INNER_MARGIN",3);let KM=VM;class GM{constructor(t,e,n,r,i,A){Tc(this,Do),Tc(this,Fo,new Float64Array(6)),Tc(this,Lo),Tc(this,Uo),Tc(this,Io),Tc(this,Qo),Tc(this,ko),Tc(this,Mo,""),Tc(this,Oo,0),Tc(this,Po,new zM),Tc(this,No),Tc(this,To),Dc(this,No,n),Dc(this,To,r),Dc(this,Io,i),Dc(this,Qo,A),[t,e]=Rc(this,Do,Ro).call(this,t,e);const s=Dc(this,Lo,[NaN,NaN,NaN,NaN,t,e]);Dc(this,ko,[t,e]),Dc(this,Uo,[{line:s,points:Nc(this,ko)}]),Nc(this,Fo).set(s,0)}updateProperty(t,e){"stroke-width"===t&&Dc(this,Qo,e)}isEmpty(){return!Nc(this,Uo)||0===Nc(this,Uo).length}isCancellable(){return Nc(this,ko).length<=10}add(t,e){[t,e]=Rc(this,Do,Ro).call(this,t,e);const[n,r,i,A]=Nc(this,Fo).subarray(2,6),s=t-i,a=e-A;return Math.hypot(Nc(this,No)*s,Nc(this,To)*a)<=2?null:(Nc(this,ko).push(t,e),isNaN(n)?(Nc(this,Fo).set([i,A,t,e],2),Nc(this,Lo).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(Nc(this,Fo)[0])&&Nc(this,Lo).splice(6,6),Nc(this,Fo).set([n,r,i,A,t,e],0),Nc(this,Lo).push(...kM.createBezierPoints(n,r,i,A,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const n=this.add(t,e);return n||(2===Nc(this,ko).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,n,r,i){Dc(this,No,n),Dc(this,To,r),Dc(this,Io,i),[t,e]=Rc(this,Do,Ro).call(this,t,e);const A=Dc(this,Lo,[NaN,NaN,NaN,NaN,t,e]);Dc(this,ko,[t,e]);const s=Nc(this,Uo).at(-1);return s&&(s.line=new Float32Array(s.line),s.points=new Float32Array(s.points)),Nc(this,Uo).push({line:A,points:Nc(this,ko)}),Nc(this,Fo).set(A,0),Dc(this,Oo,0),this.toSVGPath(),null}getLastElement(){return Nc(this,Uo).at(-1)}setLastElement(t){return Nc(this,Uo)?(Nc(this,Uo).push(t),Dc(this,Lo,t.line),Dc(this,ko,t.points),Dc(this,Oo,0),{path:{d:this.toSVGPath()}}):Nc(this,Po).setLastElement(t)}removeLastElement(){if(!Nc(this,Uo))return Nc(this,Po).removeLastElement();Nc(this,Uo).pop(),Dc(this,Mo,"");for(let t=0,e=Nc(this,Uo).length;t<e;t++){const{line:e,points:n}=Nc(this,Uo)[t];Dc(this,Lo,e),Dc(this,ko,n),Dc(this,Oo,0),this.toSVGPath()}return{path:{d:Nc(this,Mo)}}}toSVGPath(){const t=kM.svgRound(Nc(this,Lo)[4]),e=kM.svgRound(Nc(this,Lo)[5]);if(2===Nc(this,ko).length)return Dc(this,Mo,`${Nc(this,Mo)} M ${t} ${e} Z`),Nc(this,Mo);if(Nc(this,ko).length<=6){const n=Nc(this,Mo).lastIndexOf("M");Dc(this,Mo,`${Nc(this,Mo).slice(0,n)} M ${t} ${e}`),Dc(this,Oo,6)}if(4===Nc(this,ko).length){const t=kM.svgRound(Nc(this,Lo)[10]),e=kM.svgRound(Nc(this,Lo)[11]);return Dc(this,Mo,`${Nc(this,Mo)} L ${t} ${e}`),Dc(this,Oo,12),Nc(this,Mo)}const n=[];0===Nc(this,Oo)&&(n.push(`M ${t} ${e}`),Dc(this,Oo,6));for(let r=Nc(this,Oo),i=Nc(this,Lo).length;r<i;r+=6){const[t,e,i,A,s,a]=Nc(this,Lo).slice(r,r+6).map(kM.svgRound);n.push(`C${t} ${e} ${i} ${A} ${s} ${a}`)}return Dc(this,Mo,Nc(this,Mo)+n.join(" ")),Dc(this,Oo,Nc(this,Lo).length),Nc(this,Mo)}getOutlines(t,e,n,r){const i=Nc(this,Uo).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),Nc(this,Po).build(Nc(this,Uo),t,e,n,Nc(this,Io),Nc(this,Qo),r),Dc(this,Fo,null),Dc(this,Lo,null),Dc(this,Uo,null),Dc(this,Mo,null),Nc(this,Po)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Fo=new WeakMap,Lo=new WeakMap,Uo=new WeakMap,Io=new WeakMap,Qo=new WeakMap,ko=new WeakMap,Mo=new WeakMap,Oo=new WeakMap,Po=new WeakMap,No=new WeakMap,To=new WeakMap,Do=new WeakSet,Ro=function(t,e){return kM._normalizePoint(t,e,Nc(this,No),Nc(this,To),Nc(this,Io))};class zM extends kM{constructor(){super(...arguments),Tc(this,Yo),Tc(this,Ho),Tc(this,jo,0),Tc(this,Wo),Tc(this,Vo),Tc(this,Ko),Tc(this,Go),Tc(this,zo),Tc(this,qo),Tc(this,Xo)}build(t,e,n,r,i,A,s){Dc(this,Ko,e),Dc(this,Go,n),Dc(this,zo,r),Dc(this,qo,i),Dc(this,Xo,A),Dc(this,Wo,null!=s?s:0),Dc(this,Vo,t),Rc(this,Yo,Zo).call(this)}get thickness(){return Nc(this,Xo)}setLastElement(t){return Nc(this,Vo).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return Nc(this,Vo).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of Nc(this,Vo))if(t.push(`M${kM.svgRound(e[4])} ${kM.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${kM.svgRound(e[10])} ${kM.svgRound(e[11])}`);else for(let n=6,r=e.length;n<r;n+=6){const[r,i,A,s,a,o]=e.subarray(n,n+6).map(kM.svgRound);t.push(`C${r} ${i} ${A} ${s} ${a} ${o}`)}else t.push("Z");return t.join("")}serialize([t,e,n,r],i){const A=[],s=[],[a,o,l,c]=Rc(this,Yo,Jo).call(this);let h,u,d,f,p,g,m,w,v;switch(Nc(this,qo)){case 0:v=kM._rescale,h=t,u=e+r,d=n,f=-r,p=t+a*n,g=e+(1-o-c)*r,m=t+(a+l)*n,w=e+(1-o)*r;break;case 90:v=kM._rescaleAndSwap,h=t,u=e,d=n,f=r,p=t+o*n,g=e+a*r,m=t+(o+c)*n,w=e+(a+l)*r;break;case 180:v=kM._rescale,h=t+n,u=e,d=-n,f=r,p=t+(1-a-l)*n,g=e+o*r,m=t+(1-a)*n,w=e+(o+c)*r;break;case 270:v=kM._rescaleAndSwap,h=t+n,u=e+r,d=-n,f=-r,p=t+(1-o-c)*n,g=e+(1-a-l)*r,m=t+(1-o)*n,w=e+(1-a)*r}for(const{line:y,points:b}of Nc(this,Vo))A.push(v(y,h,u,d,f,i?new Array(y.length):null)),s.push(v(b,h,u,d,f,i?new Array(b.length):null));return{lines:A,points:s,rect:[p,g,m,w]}}static deserialize(t,e,n,r,i,{paths:{lines:A,points:s},rotation:a,thickness:o}){const l=[];let c,h,u,d,f;switch(a){case 0:f=kM._rescale,c=-t/n,h=e/r+1,u=1/n,d=-1/r;break;case 90:f=kM._rescaleAndSwap,c=-e/r,h=-t/n,u=1/r,d=1/n;break;case 180:f=kM._rescale,c=t/n+1,h=-e/r,u=-1/n,d=1/r;break;case 270:f=kM._rescaleAndSwap,c=e/r+1,h=t/n+1,u=-1/r,d=-1/n}if(!A){A=[];for(const t of s){const e=t.length;if(2===e){A.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){A.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const n=new Float32Array(3*(e-2));A.push(n);let[r,i,s,a]=t.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let A=4;A<e;A+=2){const e=t[A],o=t[A+1];n.set(kM.createBezierPoints(r,i,s,a,e,o),3*(A-2)),[r,i,s,a]=[s,a,e,o]}}}for(let g=0,m=A.length;g<m;g++)l.push({line:f(A[g].map(t=>null!=t?t:NaN),c,h,u,d),points:f(s[g].map(t=>null!=t?t:NaN),c,h,u,d)});const p=new this.prototype.constructor;return p.build(l,n,r,1,a,o,i),p}get box(){return Nc(this,Ho)}updateProperty(t,e){return"stroke-width"===t?Rc(this,Yo,tl).call(this,e):null}updateParentDimensions([t,e],n){const[r,i]=Rc(this,Yo,$o).call(this);Dc(this,Ko,t),Dc(this,Go,e),Dc(this,zo,n);const[A,s]=Rc(this,Yo,$o).call(this),a=A-r,o=s-i,l=Nc(this,Ho);return l[0]-=a,l[1]-=o,l[2]+=2*a,l[3]+=2*o,l}updateRotation(t){return Dc(this,jo,t),{path:{transform:this.rotationTransform}}}get viewBox(){return Nc(this,Ho).map(kM.svgRound).join(" ")}get defaultProperties(){const[t,e]=Nc(this,Ho);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=Nc(this,Ho);let n=0,r=0,i=0,A=0,s=0,a=0;switch(Nc(this,jo)){case 90:r=e/t,i=-t/e,s=t;break;case 180:n=-1,A=-1,s=t,a=e;break;case 270:r=-e/t,i=t/e,a=e;break;default:return""}return`matrix(${n} ${r} ${i} ${A} ${kM.svgRound(s)} ${kM.svgRound(a)})`}getPathResizingSVGProperties([t,e,n,r]){const[i,A]=Rc(this,Yo,$o).call(this),[s,a,o,l]=Nc(this,Ho);if(Math.abs(o-i)<=kM.PRECISION||Math.abs(l-A)<=kM.PRECISION){const i=t+n/2-(s+o/2),A=e+r/2-(a+l/2);return{path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`,transform:`${this.rotationTransform} translate(${i} ${A})`}}}const c=(n-2*i)/(o-2*i),h=(r-2*A)/(l-2*A),u=o/n,d=l/r;return{path:{"transform-origin":`${kM.svgRound(s)} ${kM.svgRound(a)}`,transform:`${this.rotationTransform} scale(${u} ${d}) translate(${kM.svgRound(i)} ${kM.svgRound(A)}) scale(${c} ${h}) translate(${kM.svgRound(-i)} ${kM.svgRound(-A)})`}}}getPathResizedSVGProperties([t,e,n,r]){const[i,A]=Rc(this,Yo,$o).call(this),s=Nc(this,Ho),[a,o,l,c]=s;if(s[0]=t,s[1]=e,s[2]=n,s[3]=r,Math.abs(l-i)<=kM.PRECISION||Math.abs(c-A)<=kM.PRECISION){const i=t+n/2-(a+l/2),A=e+r/2-(o+c/2);for(const{line:t,points:e}of Nc(this,Vo))kM._translate(t,i,A,t),kM._translate(e,i,A,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const h=(n-2*i)/(l-2*i),u=(r-2*A)/(c-2*A),d=-h*(a+i)+t+i,f=-u*(o+A)+e+A;if(1!==h||1!==u||0!==d||0!==f)for(const{line:p,points:g}of Nc(this,Vo))kM._rescale(p,d,f,h,u,p),kM._rescale(g,d,f,h,u,g);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],n){const[r,i]=n,A=Nc(this,Ho),s=t-A[0],a=e-A[1];if(Nc(this,Ko)===r&&Nc(this,Go)===i)for(const{line:o,points:l}of Nc(this,Vo))kM._translate(o,s,a,o),kM._translate(l,s,a,l);else{const t=Nc(this,Ko)/r,e=Nc(this,Go)/i;Dc(this,Ko,r),Dc(this,Go,i);for(const{line:n,points:r}of Nc(this,Vo))kM._rescale(n,s,a,t,e,n),kM._rescale(r,s,a,t,e,r);A[2]*=t,A[3]*=e}return A[0]=t,A[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`}}}get defaultSVGProperties(){const t=Nc(this,Ho);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${kM.svgRound(t[0])} ${kM.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}Ho=new WeakMap,jo=new WeakMap,Wo=new WeakMap,Vo=new WeakMap,Ko=new WeakMap,Go=new WeakMap,zo=new WeakMap,qo=new WeakMap,Xo=new WeakMap,Yo=new WeakSet,$o=function(t=Nc(this,Xo)){const e=Nc(this,Wo)+t/2*Nc(this,zo);return Nc(this,qo)%180==0?[e/Nc(this,Ko),e/Nc(this,Go)]:[e/Nc(this,Go),e/Nc(this,Ko)]},Jo=function(){const[t,e,n,r]=Nc(this,Ho),[i,A]=Rc(this,Yo,$o).call(this,0);return[t+i,e+A,n-2*i,r-2*A]},Zo=function(){const t=Dc(this,Ho,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:r}of Nc(this,Vo)){if(r.length<=12){for(let e=4,n=r.length;e<n;e+=6)HU.pointBoundingBox(r[e],r[e+1],t);continue}let e=r[4],n=r[5];for(let i=6,A=r.length;i<A;i+=6){const[A,s,a,o,l,c]=r.subarray(i,i+6);HU.bezierBoundingBox(e,n,A,s,a,o,l,c,t),e=l,n=c}}const[e,n]=Rc(this,Yo,$o).call(this);t[0]=GU(t[0]-e,0,1),t[1]=GU(t[1]-n,0,1),t[2]=GU(t[2]+e,0,1),t[3]=GU(t[3]+n,0,1),t[2]-=t[0],t[3]-=t[1]},tl=function(t){const[e,n]=Rc(this,Yo,$o).call(this);Dc(this,Xo,t);const[r,i]=Rc(this,Yo,$o).call(this),[A,s]=[r-e,i-n],a=Nc(this,Ho);return a[0]-=A,a[1]-=s,a[2]+=2*A,a[3]+=2*s,a};class qM extends WM{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:QI._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(null!=e||(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new qM(this._viewParameters);return t.updateAll(this),t}}const XM=class t extends KM{constructor(t){super(kc(Qc({},t),{name:"inkEditor"})),Tc(this,el),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){QI.initialize(t,e),this._defaultDrawingOptions=new qM(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return LU(this,"typesMap",new Map([[eU.INK_THICKNESS,"stroke-width"],[eU.INK_COLOR,"stroke"],[eU.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,n,r,i){return new GM(t,e,n,r,i,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,n,r,i,A){return zM.deserialize(t,e,n,r,i,A)}static deserialize(e,n,r){return Wc(this,null,function*(){let i=null;if(e instanceof BM){const{data:{inkLists:t,rect:n,rotation:r,id:A,color:s,opacity:a,borderStyle:{rawWidth:o},popupRef:l,contentsObj:c},parent:{page:{pageNumber:h}}}=e;i=e={annotationType:tU.INK,color:Array.from(s),thickness:o,opacity:a,paths:{points:t},boxes:null,pageIndex:h-1,rect:n.slice(0),rotation:r,annotationElementId:A,id:A,deleted:!1,popupRef:l,comment:(null==c?void 0:c.str)||null}}const A=yield jc(t,this,"deserialize").call(this,e,n,r);return A._initialData=i,e.comment&&A.setCommentData(e.comment),A})}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new zk(this)),[["colorPicker",this._colorPicker]]}get colorType(){return eU.INK_COLOR}get colorValue(){return this._drawingOptions.stroke}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:n}=this;e.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:n,opacity:r}){this._drawingOptions=t.getDefaultDrawingOptions({stroke:HU.makeHexColor(...e),"stroke-width":n,"stroke-opacity":r})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:n,rect:r}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":A,"stroke-width":s}}=this,a={annotationType:tU.INK,color:QI._colorManager.convert(i),opacity:A,thickness:s,paths:{lines:e,points:n},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!Rc(this,el,nl).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(t){const{points:e,rect:n}=this.serializeDraw(!1),r={rect:n,thickness:this._drawingOptions["stroke-width"],points:e};return this.hasEditedComment&&(r.popup=this.comment),t.updateEdited(r),null}};el=new WeakSet,nl=function(t){const{color:e,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,n)=>t!==e[n])||t.thickness!==n||t.opacity!==r||t.pageIndex!==i},Oc(XM,"_type","ink"),Oc(XM,"_editorType",tU.INK),Oc(XM,"_defaultDrawingOptions",null);let YM=XM;class $M extends zM{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class JM{static extractContoursFromText(t,{fontFamily:e,fontStyle:n,fontWeight:r},i,A,s,a){let o=new OffscreenCanvas(1,1),l=o.getContext("2d",{alpha:!1});const c=l.font=`${n} ${r} 200px ${e}`,{actualBoundingBoxLeft:h,actualBoundingBoxRight:u,actualBoundingBoxAscent:d,actualBoundingBoxDescent:f,fontBoundingBoxAscent:p,fontBoundingBoxDescent:g,width:m}=l.measureText(t),w=1.5,v=Math.ceil(Math.max(Math.abs(h)+Math.abs(u)||0,m)*w),y=Math.ceil(Math.max(Math.abs(d)+Math.abs(f)||200,Math.abs(p)+Math.abs(g)||200)*w);o=new OffscreenCanvas(v,y),l=o.getContext("2d",{alpha:!0,willReadFrequently:!0}),l.font=c,l.filter="grayscale(1)",l.fillStyle="white",l.fillRect(0,0,v,y),l.fillStyle="black",l.fillText(t,.5*v/2,1.5*y/2);const b=Rc(this,il,fl).call(this,l.getImageData(0,0,v,y).data),B=Rc(this,il,dl).call(this,b),_=Rc(this,il,pl).call(this,B),C=Rc(this,il,ll).call(this,b,v,y,_);return this.processDrawnLines({lines:{curves:C,width:v,height:y},pageWidth:i,pageHeight:A,rotation:s,innerMargin:a,mustSmooth:!0,areContours:!0})}static process(t,e,n,r,i){const[A,s,a]=Rc(this,il,gl).call(this,t),[o,l]=Rc(this,il,ul).call(this,A,s,a,Math.hypot(s,a)*Nc(this,rl).sigmaSFactor,Nc(this,rl).sigmaR,Nc(this,rl).kernelSize),c=Rc(this,il,pl).call(this,l),h=Rc(this,il,ll).call(this,o,s,a,c);return this.processDrawnLines({lines:{curves:h,width:s,height:a},pageWidth:e,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:A,areContours:s}){var a;r%180!=0&&([e,n]=[n,e]);const{curves:o,width:l,height:c}=t,h=null!=(a=t.thickness)?a:0,u=[],d=Math.min(e/l,n/c),f=d/e,p=d/n,g=[];for(const{points:w}of o){const t=A?Rc(this,il,hl).call(this,w):w;if(!t)continue;g.push(t);const e=t.length,n=new Float32Array(e),r=new Float32Array(3*(2===e?2:e-2));if(u.push({line:r,points:n}),2===e){n[0]=t[0]*f,n[1]=t[1]*p,r.set([NaN,NaN,NaN,NaN,n[0],n[1]],0);continue}let[i,s,a,o]=t;i*=f,s*=p,a*=f,o*=p,n.set([i,s,a,o],0),r.set([NaN,NaN,NaN,NaN,i,s],0);for(let A=4;A<e;A+=2){const e=n[A]=t[A]*f,l=n[A+1]=t[A+1]*p;r.set(kM.createBezierPoints(i,s,a,o,e,l),3*(A-2)),[i,s,a,o]=[a,o,e,l]}}if(0===u.length)return null;const m=s?new $M:new zM;return m.build(u,e,n,1,r,s?0:h,i),{outline:m,newCurves:g,areContours:s,thickness:h,width:l,height:c}}static compressSignature(t){return Wc(this,arguments,function*({outlines:t,areContours:e,thickness:n,width:r,height:i}){let A,s=1/0,a=-1/0,o=0;for(const m of t){o+=m.length;for(let t=2,e=m.length;t<e;t++){const e=m[t]-m[t-2];s=Math.min(s,e),a=Math.max(a,e)}}A=s>=-128&&a<=127?Int8Array:s>=-32768&&a<=32767?Int16Array:Int32Array;const l=t.length,c=8+3*l,h=new Uint32Array(c);let u=0;h[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(o-2*l)*A.BYTES_PER_ELEMENT,h[u++]=0,h[u++]=r,h[u++]=i,h[u++]=e?0:1,h[u++]=Math.max(0,Math.floor(null!=n?n:0)),h[u++]=l,h[u++]=A.BYTES_PER_ELEMENT;for(const m of t)h[u++]=m.length-2,h[u++]=m[0],h[u++]=m[1];const d=new CompressionStream("deflate-raw"),f=d.writable.getWriter();yield f.ready,f.write(h);const p=A.prototype.constructor;for(const m of t){const t=new p(m.length-2);for(let e=2,n=m.length;e<n;e++)t[e-2]=m[e]-m[e-2];f.write(t)}f.close();const g=yield new Response(d.readable).arrayBuffer();return zU(new Uint8Array(g))})}static decompressSignature(t){return Wc(this,null,function*(){try{const s=(A=t,Uint8Array.fromBase64?Uint8Array.fromBase64(A):TU(atob(A))),{readable:a,writable:o}=new DecompressionStream("deflate-raw"),l=o.getWriter();yield l.ready,l.write(s).then(()=>Wc(this,null,function*(){yield l.ready,yield l.close()})).catch(()=>{});let c=null,h=0;try{for(var e,n,r,i=((t,e,n)=>(e=t[Fc("asyncIterator")])?e.call(t):(t=t[Fc("iterator")](),e={},(n=(n,r)=>(r=t[n])&&(e[n]=e=>new Promise((n,i,A)=>(e=r.call(t,e),A=e.done,Promise.resolve(e.value).then(t=>n({value:t,done:A}),i)))))("next"),n("return"),e))(a);e=!(n=yield i.next()).done;e=!1){const t=n.value;c||(c=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])),c.set(t,h),h+=t.length}}catch(n){r=[n]}finally{try{e&&(n=i.return)&&(yield n.call(i))}finally{if(r)throw r[0]}}const u=new Uint32Array(c.buffer,0,c.length>>2),d=u[1];if(0!==d)throw new Error(`Invalid version: ${d}`);const f=u[2],p=u[3],g=0===u[4],m=u[5],w=u[6],v=u[7],y=[],b=(8+3*w)*Uint32Array.BYTES_PER_ELEMENT;let B;switch(v){case Int8Array.BYTES_PER_ELEMENT:B=new Int8Array(c.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:B=new Int16Array(c.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:B=new Int32Array(c.buffer,b)}h=0;for(let t=0;t<w;t++){const e=u[3*t+8],n=new Float32Array(e+2);y.push(n);for(let r=0;r<2;r++)n[r]=u[3*t+8+r+1];for(let t=0;t<e;t++)n[t+2]=n[t]+B[h++]}return{areContours:g,thickness:m,outlines:y,width:f,height:p}}catch(hw){return CU(`decompressSignature: ${hw}`),null}var A})}}rl=new WeakMap,il=new WeakSet,Al=function(t,e,n,r){return r-=e,0===(n-=t)?r>0?0:4:1===n?r+6:2-r},sl=new WeakMap,al=function(t,e,n,r,i,A,s){const a=Rc(this,il,Al).call(this,n,r,i,A);for(let o=0;o<8;o++){const i=(-o+a-s+16)%8;if(0!==t[(n+Nc(this,sl)[2*i])*e+(r+Nc(this,sl)[2*i+1])])return i}return-1},ol=function(t,e,n,r,i,A,s){const a=Rc(this,il,Al).call(this,n,r,i,A);for(let o=0;o<8;o++){const i=(o+a+s+16)%8;if(0!==t[(n+Nc(this,sl)[2*i])*e+(r+Nc(this,sl)[2*i+1])])return i}return-1},ll=function(t,e,n,r){const i=t.length,A=new Int32Array(i);for(let l=0;l<i;l++)A[l]=t[l]<=r?1:0;for(let l=1;l<n-1;l++)A[l*e]=A[l*e+e-1]=0;for(let l=0;l<e;l++)A[l]=A[e*n-1-l]=0;let s,a=1;const o=[];for(let l=1;l<n-1;l++){s=1;for(let t=1;t<e-1;t++){const n=l*e+t,r=A[n];if(0===r)continue;let i=l,c=t;if(1===r&&0===A[n-1])a+=1,c-=1;else{if(!(r>=1&&0===A[n+1])){1!==r&&(s=Math.abs(r));continue}a+=1,c+=1,r>1&&(s=r)}const h=[t,l],u=c===t+1,d={isHole:u,points:h,id:a,parent:0};let f;o.push(d);for(const t of o)if(t.id===s){f=t;break}f?f.isHole?d.parent=u?f.parent:s:d.parent=u?s:f.parent:d.parent=u?s:0;const p=Rc(this,il,al).call(this,A,e,l,t,i,c,0);if(-1===p){A[n]=-a,1!==A[n]&&(s=Math.abs(A[n]));continue}let g=Nc(this,sl)[2*p],m=Nc(this,sl)[2*p+1];const w=l+g,v=t+m;i=w,c=v;let y=l,b=t;for(;;){const r=Rc(this,il,ol).call(this,A,e,y,b,i,c,1);g=Nc(this,sl)[2*r],m=Nc(this,sl)[2*r+1];const o=y+g,u=b+m;h.push(u,o);const d=y*e+b;if(0===A[d+1]?A[d]=-a:1===A[d]&&(A[d]=a),o===l&&u===t&&y===w&&b===v){1!==A[n]&&(s=Math.abs(A[n]));break}i=y,c=b,y=o,b=u}}}return o},cl=function(t,e,n,r){if(n-e<=4){for(let i=e;i<n-2;i+=2)r.push(t[i],t[i+1]);return}const i=t[e],A=t[e+1],s=t[n-4]-i,a=t[n-3]-A,o=Math.hypot(s,a),l=s/o,c=a/o,h=l*A-c*i,u=a/s,d=1/o,f=Math.atan(u),p=Math.cos(f),g=Math.sin(f),m=d*(Math.abs(p)+Math.abs(g)),w=d*(1-m+Uc(m,2)),v=Math.max(Math.atan(Math.abs(g+p)*w),Math.atan(Math.abs(g-p)*w));let y=0,b=e;for(let B=e+2;B<n-2;B+=2){const e=Math.abs(h-l*t[B+1]+c*t[B]);e>y&&(b=B,y=e)}y>Uc(o*v,2)?(Rc(this,il,cl).call(this,t,e,b+2,r),Rc(this,il,cl).call(this,t,b,n,r)):r.push(i,A)},hl=function(t){const e=[],n=t.length;return Rc(this,il,cl).call(this,t,0,n,e),e.push(t[n-2],t[n-1]),e.length<=4?null:e},ul=function(t,e,n,r,i,A){const s=new Float32Array(Uc(A,2)),a=-2*Uc(r,2),o=A>>1;for(let f=0;f<A;f++){const t=Uc(f-o,2);for(let e=0;e<A;e++)s[f*A+e]=Math.exp((t+Uc(e-o,2))/a)}const l=new Float32Array(256),c=-2*Uc(i,2);for(let f=0;f<256;f++)l[f]=Math.exp(Uc(f,2)/c);const h=t.length,u=new Uint8Array(h),d=new Uint32Array(256);for(let f=0;f<n;f++)for(let r=0;r<e;r++){const i=f*e+r,a=t[i];let c=0,h=0;for(let u=0;u<A;u++){const i=f+u-o;if(!(i<0||i>=n))for(let n=0;n<A;n++){const d=r+n-o;if(d<0||d>=e)continue;const f=t[i*e+d],p=s[u*A+n]*l[Math.abs(f-a)];c+=f*p,h+=p}}d[u[i]=Math.round(c/h)]++}return[u,d]},dl=function(t){const e=new Uint32Array(256);for(const n of t)e[n]++;return e},fl=function(t){const e=t.length,n=new Uint8ClampedArray(e>>2);let r=-1/0,i=1/0;for(let s=0,a=n.length;s<a;s++){const e=n[s]=t[s<<2];r=Math.max(r,e),i=Math.min(i,e)}const A=255/(r-i);for(let s=0,a=n.length;s<a;s++)n[s]=(n[s]-i)*A;return n},pl=function(t){let e,n=-1/0,r=-1/0;const i=t.findIndex(t=>0!==t);let A=i,s=i;for(e=i;e<256;e++){const i=t[e];i>n&&(e-A>r&&(r=e-A,s=e-1),n=i,A=e)}for(e=s-1;e>=0&&!(t[e]>t[e+1]);e--);return e},gl=function(t){const e=t,{width:n,height:r}=t,{maxDim:i}=Nc(this,rl);let A=n,s=r;if(n>i||r>i){let a=n,o=r,l=Math.log2(Math.max(n,r)/i);const c=Math.floor(l);l=l===c?c-1:c;for(let n=0;n<l;n++){A=Math.ceil(a/2),s=Math.ceil(o/2);const n=new OffscreenCanvas(A,s);n.getContext("2d").drawImage(t,0,0,a,o,0,0,A,s),a=A,o=s,t!==e&&t.close(),t=n.transferToImageBitmap()}const h=Math.min(i/A,i/s);A=Math.round(A*h),s=Math.round(s*h)}const a=new OffscreenCanvas(A,s).getContext("2d",{willReadFrequently:!0});a.fillStyle="white",a.fillRect(0,0,A,s),a.filter="grayscale(1)",a.drawImage(t,0,0,t.width,t.height,0,0,A,s);const o=a.getImageData(0,0,A,s).data;return[Rc(this,il,fl).call(this,o),A,s]},Tc(JM,il),Tc(JM,rl,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),Tc(JM,sl,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class ZM extends WM{constructor(){super(),super.updateProperties({fill:QI._defaultLineColor,"stroke-width":0})}clone(){const t=new ZM;return t.updateAll(this),t}}class tO extends qM{constructor(t){super(t),super.updateProperties({stroke:QI._defaultLineColor,"stroke-width":1})}clone(){const t=new tO(this._viewParameters);return t.updateAll(this),t}}const eO=class t extends KM{constructor(t){super(kc(Qc({},t),{mustBeCommitted:!0,name:"signatureEditor"})),Tc(this,ml,!1),Tc(this,wl,null),Tc(this,vl,null),Tc(this,yl,null),this._willKeepAspectRatio=!0,Dc(this,vl,t.signatureData||null),Dc(this,wl,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){QI.initialize(t,e),this._defaultDrawingOptions=new ZM,this._defaultDrawnSignatureOptions=new tO(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return LU(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!Nc(this,wl)}}static computeTelemetryFinalData(t){var e,n;const r=t.get("hasDescription");return{hasAltText:null!=(e=r.get(!0))?e:0,hasNoAltText:null!=(n=r.get(!1))?n:0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,n;const{_isCopy:r}=this;if(r&&(this._isCopy=!1,e=this.x,n=this.y),super.render(),null===this._drawId)if(Nc(this,vl)){const{lines:e,mustSmooth:n,areContours:r,description:i,uuid:A,heightInPage:s}=Nc(this,vl),{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,c=JM.processDrawnLines({lines:e,pageWidth:a,pageHeight:o,rotation:l,innerMargin:t._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(c,s,i,A)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:Nc(this,wl)||""}));return r&&(this._isCopy=!0,this._moveAfterPaste(e,n)),this.div}setUuid(t){Dc(this,yl,t),this.addEditToolbar()}getUuid(){return Nc(this,yl)}get description(){return Nc(this,wl)}set description(t){Dc(this,wl,t),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{null==e||e.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:n,width:r,height:i}=Nc(this,vl),A=Math.max(r,i);return{areContours:e,outline:JM.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:n,width:r,height:i},pageWidth:A,pageHeight:A,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,n,r,i){const{x:A,y:s}=this,{outline:a}=Dc(this,vl,e);let o;Dc(this,ml,a instanceof $M),this.description=r,Nc(this,ml)?o=t.getDefaultDrawingOptions():(o=t._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[l,c]=this.parentDimensions,[,h]=this.pageDimensions;let u=n/h;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(l*this.width,c*this.height),this.x=A,this.y=s,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!r}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return JM.process(e,n,r,i,t._INNER_MARGIN)}getFromText(e,n){const{rawDims:{pageWidth:r,pageHeight:i},rotation:A}=this.parent.viewport;return JM.extractContoursFromText(e,n,r,i,A,t._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return JM.processDrawnLines({lines:e,pageWidth:n,pageHeight:r,rotation:i,innerMargin:t._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:n}){e?this._drawingOptions=t.getDefaultDrawingOptions():(this._drawingOptions=t._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":n}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:n,rect:r}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,A={annotationType:tU.SIGNATURE,isSignature:!0,areContours:Nc(this,ml),color:[0,0,0],thickness:Nc(this,ml)?0:i,pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(A),t?(A.paths={lines:e,points:n},A.uuid=Nc(this,yl),A.isCopy=!0):A.lines=e,Nc(this,wl)&&(A.accessibilityData={type:"Figure",alt:Nc(this,wl)}),A}static deserializeDraw(t,e,n,r,i,A){return A.areContours?$M.deserialize(t,e,n,r,i,A):zM.deserialize(t,e,n,r,i,A)}static deserialize(e,n,r){return Wc(this,null,function*(){var i;const A=yield jc(t,this,"deserialize").call(this,e,n,r);return Dc(A,ml,e.areContours),A.description=(null==(i=e.accessibilityData)?void 0:i.alt)||"",Dc(A,yl,e.uuid),A})}};ml=new WeakMap,wl=new WeakMap,vl=new WeakMap,yl=new WeakMap,Oc(eO,"_type","signature"),Oc(eO,"_editorType",tU.SIGNATURE),Oc(eO,"_defaultDrawingOptions",null);let nO=eO;const rO=class t extends QI{constructor(t){super(kc(Qc({},t),{name:"stampEditor"})),Tc(this,Ql),Tc(this,bl,null),Tc(this,Bl,null),Tc(this,_l,null),Tc(this,Cl,null),Tc(this,xl,null),Tc(this,El,""),Tc(this,Sl,null),Tc(this,Fl,!1),Tc(this,Ll,null),Tc(this,Ul,!1),Tc(this,Il,!1),Dc(this,Cl,t.bitmapUrl),Dc(this,xl,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){QI.initialize(t,e)}static isHandlingMimeForPasting(t){return uI.includes(t)}static paste(t,e){e.pasteEditor({mode:tU.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!(null==(t=this.altTextData)?void 0:t.altText)}}static computeTelemetryFinalData(t){var e,n;const r=t.get("hasAltText");return{hasAltText:null!=(e=r.get(!0))?e:0,hasNoAltText:null!=(n=r.get(!1))?n:0}}mlGuessAltText(t=null,e=!0){return Wc(this,null,function*(){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!(yield n.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");const{data:r,width:i,height:A}=t||this.copyCanvas(null,null,!0).imageData,s=yield n.guess({name:"altText",request:{data:r,width:i,height:A,channels:r.length/(i*A)}});if(!s)throw new Error("No response from the AI service.");if(s.error)throw new Error("Error from the AI service.");if(s.cancel)return null;if(!s.output)throw new Error("No valid response from the AI service.");const a=s.output;return yield this.setGuessedAltText(a),e&&!this.hasAltTextData()&&(this.altTextData={alt:a,decorative:!1}),a})}remove(){var t;Nc(this,Bl)&&(Dc(this,bl,null),this._uiManager.imageManager.deleteId(Nc(this,Bl)),null==(t=Nc(this,Sl))||t.remove(),Dc(this,Sl,null),Nc(this,Ll)&&(clearTimeout(Nc(this,Ll)),Dc(this,Ll,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(Nc(this,Bl)&&null===Nc(this,Sl)&&Rc(this,Ql,Ol).call(this),this.isAttachedToDOM||this.parent.add(this))):Nc(this,Bl)&&Rc(this,Ql,Ol).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(Nc(this,_l)||Nc(this,bl)||Nc(this,Cl)||Nc(this,xl)||Nc(this,Bl)||Nc(this,Fl))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),Nc(this,Fl)||(Nc(this,bl)?Rc(this,Ql,Pl).call(this):Rc(this,Ql,Ol).call(this)),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),n&&this._uiManager.imageManager.isValidId(n)&&(Dc(this,Bl,n),r&&Dc(this,bl,r),Dc(this,Fl,!1),Rc(this,Ql,Pl).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==Nc(this,Ll)&&clearTimeout(Nc(this,Ll));Dc(this,Ll,setTimeout(()=>{Dc(this,Ll,null),Rc(this,Ql,Tl).call(this)},200))}copyCanvas(t,e,n=!1){var r;t||(t=224);const{width:i,height:A}=Nc(this,bl),s=new hI;let a=Nc(this,bl),o=i,l=A,c=null;if(e){if(i>e||A>e){const t=Math.min(e/i,e/A);o=Math.floor(i*t),l=Math.floor(A*t)}c=document.createElement("canvas");const t=c.width=Math.ceil(o*s.sx),n=c.height=Math.ceil(l*s.sy);Nc(this,Ul)||(a=Rc(this,Ql,Nl).call(this,t,n));const h=c.getContext("2d");h.filter=this._uiManager.hcmFilter;let u="white",d="#cfcfd8";"none"!==this._uiManager.hcmFilter?d="black":(null==(r=window.matchMedia)?void 0:r.call(window,"(prefers-color-scheme: dark)").matches)&&(u="#8f8f9d",d="#42414d");const f=15,p=f*s.sx,g=f*s.sy,m=new OffscreenCanvas(2*p,2*g),w=m.getContext("2d");w.fillStyle=u,w.fillRect(0,0,2*p,2*g),w.fillStyle=d,w.fillRect(0,0,p,g),w.fillRect(p,g,p,g),h.fillStyle=h.createPattern(m,"repeat"),h.fillRect(0,0,t,n),h.drawImage(a,0,0,a.width,a.height,0,0,t,n)}let h=null;if(n){let e,n;if(s.symmetric&&a.width<t&&a.height<t)e=a.width,n=a.height;else if(a=Nc(this,bl),i>t||A>t){const r=Math.min(t/i,t/A);e=Math.floor(i*r),n=Math.floor(A*r),Nc(this,Ul)||(a=Rc(this,Ql,Nl).call(this,e,n))}const r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});r.drawImage(a,0,0,a.width,a.height,0,0,e,n),h={width:e,height:n,data:r.getImageData(0,0,e,n).data}}return{canvas:c,width:o,height:l,imageData:h}}static deserialize(e,n,r){return Wc(this,null,function*(){var i;let A=null,s=!1;if(e instanceof SM){const{data:{rect:t,rotation:a,id:o,structParent:l,popupRef:c,contentsObj:h},container:u,parent:{page:{pageNumber:d}},canvas:f}=e;let p,g;f?(delete e.canvas,({id:p,bitmap:g}=r.imageManager.getFromCanvas(u.id,f)),f.remove()):(s=!0,e._hasNoCanvas=!0);const m=(null==(i=yield n._structTree.getAriaAttributes(`${KU}${o}`))?void 0:i.get("aria-label"))||"";A=e={annotationType:tU.STAMP,bitmapId:p,bitmap:g,pageIndex:d-1,rect:t.slice(0),rotation:a,annotationElementId:o,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:m},isSvg:!1,structParent:l,popupRef:c,comment:(null==h?void 0:h.str)||null}}const a=yield jc(t,this,"deserialize").call(this,e,n,r),{rect:o,bitmap:l,bitmapUrl:c,bitmapId:h,isSvg:u,accessibilityData:d}=e;s?(r.addMissingCanvas(e.id,a),Dc(a,Fl,!0)):h&&r.imageManager.isValidId(h)?(Dc(a,Bl,h),l&&Dc(a,bl,l)):Dc(a,Cl,c),Dc(a,Ul,u);const[f,p]=a.pageDimensions;return a.width=(o[2]-o[0])/f,a.height=(o[3]-o[1])/p,d&&(a.altTextData=d),a._initialData=A,e.comment&&a.setCommentData(e.comment),Dc(a,Il,!!A),a})}serialize(t=!1,e=null){var n;if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const r={annotationType:tU.STAMP,bitmapId:Nc(this,Bl),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:Nc(this,Ul),structTreeParentId:this._structTreeParentId};if(this.addComment(r),t)return r.bitmapUrl=Rc(this,Ql,Dl).call(this,!0),r.accessibilityData=this.serializeAltText(!0),r.isCopy=!0,r;const{decorative:i,altText:A}=this.serializeAltText(!1);if(!i&&A&&(r.accessibilityData={type:"Figure",alt:A}),this.annotationElementId){const t=Rc(this,Ql,Rl).call(this,r);if(t.isSame)return null;t.isSameAltText?delete r.accessibilityData:r.accessibilityData.structParent=null!=(n=this._initialData.structParent)?n:-1}if(r.id=this.annotationElementId,null===e)return r;e.stamps||(e.stamps=new Map);const s=Nc(this,Ul)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(e.stamps.has(Nc(this,Bl))){if(Nc(this,Ul)){const t=e.stamps.get(Nc(this,Bl));s>t.area&&(t.area=s,t.serialized.bitmap.close(),t.serialized.bitmap=Rc(this,Ql,Dl).call(this,!1))}}else e.stamps.set(Nc(this,Bl),{area:s,serialized:r}),r.bitmap=Rc(this,Ql,Dl).call(this,!1);return r}renderAnnotationElement(t){const e={rect:this.getRect(0,0)};return this.hasEditedComment&&(e.popup=this.comment),t.updateEdited(e),null}};bl=new WeakMap,Bl=new WeakMap,_l=new WeakMap,Cl=new WeakMap,xl=new WeakMap,El=new WeakMap,Sl=new WeakMap,Fl=new WeakMap,Ll=new WeakMap,Ul=new WeakMap,Il=new WeakMap,Ql=new WeakSet,kl=function(t,e=!1){t?(Dc(this,bl,t.bitmap),e||(Dc(this,Bl,t.id),Dc(this,Ul,t.isSvg)),t.file&&Dc(this,El,t.file.name),Rc(this,Ql,Pl).call(this)):this.remove()},Ml=function(){if(Dc(this,_l,null),this._uiManager.enableWaiting(!1),Nc(this,Sl))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Nc(this,bl))this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Nc(this,bl)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch(hw){}}this.div.focus()}},Ol=function(){if(Nc(this,Bl))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(Nc(this,Bl)).then(t=>Rc(this,Ql,kl).call(this,t,!0)).finally(()=>Rc(this,Ql,Ml).call(this));if(Nc(this,Cl)){const t=Nc(this,Cl);return Dc(this,Cl,null),this._uiManager.enableWaiting(!0),void Dc(this,_l,this._uiManager.imageManager.getFromUrl(t).then(t=>Rc(this,Ql,kl).call(this,t)).finally(()=>Rc(this,Ql,Ml).call(this)))}if(Nc(this,xl)){const t=Nc(this,xl);return Dc(this,xl,null),this._uiManager.enableWaiting(!0),void Dc(this,_l,this._uiManager.imageManager.getFromFile(t).then(t=>Rc(this,Ql,kl).call(this,t)).finally(()=>Rc(this,Ql,Ml).call(this)))}const t=document.createElement("input");t.type="file",t.accept=uI.join(",");const e=this._uiManager._signal;Dc(this,_l,new Promise(n=>{t.addEventListener("change",()=>Wc(this,null,function*(){if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=yield this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),Rc(this,Ql,kl).call(this,e)}else this.remove();n()}),{signal:e}),t.addEventListener("cancel",()=>{this.remove(),n()},{signal:e})}).finally(()=>Rc(this,Ql,Ml).call(this))),t.click()},Pl=function(){var t;const{div:e}=this;let{width:n,height:r}=Nc(this,bl);const[i,A]=this.pageDimensions,s=.75;if(this.width)n=this.width*i,r=this.height*A;else if(n>s*i||r>s*A){const t=Math.min(s*i/n,s*A/r);n*=t,r*=t}const[a,o]=this.parentDimensions;this.setDims(n*a/i,r*o/A),this._uiManager.enableWaiting(!1);const l=Dc(this,Sl,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=n/i,this.height=r/A,(null==(t=this._initialOptions)?void 0:t.isCentered)?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),Rc(this,Ql,Tl).call(this),Nc(this,Il)||(this.parent.addUndoableEditor(this),Dc(this,Il,!0)),this._reportTelemetry({action:"inserted_image"}),Nc(this,El)&&this.div.setAttribute("aria-description",Nc(this,El)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},Nl=function(t,e){const{width:n,height:r}=Nc(this,bl);let i=n,A=r,s=Nc(this,bl);for(;i>2*t||A>2*e;){const n=i,r=A;i>2*t&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2)),A>2*e&&(A=A>=16384?Math.floor(A/2)-1:Math.ceil(A/2));const a=new OffscreenCanvas(i,A);a.getContext("2d").drawImage(s,0,0,n,r,0,0,i,A),s=a.transferToImageBitmap()}return s},Tl=function(){const[t,e]=this.parentDimensions,{width:n,height:r}=this,i=new hI,A=Math.ceil(n*t*i.sx),s=Math.ceil(r*e*i.sy),a=Nc(this,Sl);if(!a||a.width===A&&a.height===s)return;a.width=A,a.height=s;const o=Nc(this,Ul)?Nc(this,bl):Rc(this,Ql,Nl).call(this,A,s),l=a.getContext("2d");l.filter=this._uiManager.hcmFilter,l.drawImage(o,0,0,o.width,o.height,0,0,A,s)},Dl=function(t){if(t){if(Nc(this,Ul)){const t=this._uiManager.imageManager.getSvgUrl(Nc(this,Bl));if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=Nc(this,bl));return t.getContext("2d").drawImage(Nc(this,bl),0,0),t.toDataURL()}if(Nc(this,Ul)){const[t,e]=this.pageDimensions,n=Math.round(this.width*t*YU.PDF_TO_CSS_UNITS),r=Math.round(this.height*e*YU.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);return i.getContext("2d").drawImage(Nc(this,bl),0,0,Nc(this,bl).width,Nc(this,bl).height,0,0,n,r),i.transferToImageBitmap()}return structuredClone(Nc(this,bl))},Rl=function(t){var e;const{pageIndex:n,accessibilityData:{altText:r}}=this._initialData,i=t.pageIndex===n,A=((null==(e=t.accessibilityData)?void 0:e.alt)||"")===r;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&A,isSameAltText:A}},Oc(rO,"_type","stamp"),Oc(rO,"_editorType",tU.STAMP);let iO=rO;const AO=class t{constructor({uiManager:e,pageIndex:n,div:r,structTreeLayer:i,accessibilityManager:A,annotationLayer:s,drawLayer:a,textLayer:o,viewport:l,l10n:c}){Tc(this,ic),Tc(this,Hl),Tc(this,jl,!1),Tc(this,Wl,null),Tc(this,Vl,null),Tc(this,Kl,null),Tc(this,Gl,new Map),Tc(this,zl,!1),Tc(this,ql,!1),Tc(this,Xl,!1),Tc(this,Yl,null),Tc(this,$l,null),Tc(this,Jl,null),Tc(this,Zl,null),Tc(this,tc,null),Tc(this,ec,-1),Tc(this,nc);const h=[...Nc(t,rc).values()];if(!t._initialized){t._initialized=!0;for(const t of h)t.initialize(c,e)}e.registerEditorTypes(h),Dc(this,nc,e),this.pageIndex=n,this.div=r,Dc(this,Hl,A),Dc(this,Wl,s),this.viewport=l,Dc(this,Jl,o),this.drawLayer=a,this._structTree=i,Nc(this,nc).addLayer(this)}get isEmpty(){return 0===Nc(this,Gl).size}get isInvisible(){return this.isEmpty&&Nc(this,nc).getMode()===tU.NONE}updateToolbar(t){Nc(this,nc).updateToolbar(t)}updateMode(e=Nc(this,nc).getMode()){switch(Rc(this,ic,lc).call(this),e){case tU.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case tU.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case tU.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:n}=this.div;for(const r of Nc(t,rc).values())n.toggle(`${r._type}Editing`,e===r._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null==(e=Nc(this,Jl))?void 0:e.div)}setEditingState(t){Nc(this,nc).setEditingState(t)}addCommands(t){Nc(this,nc).addCommands(t)}cleanUndoStack(t){Nc(this,nc).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;null==(e=Nc(this,Wl))||e.div.classList.toggle("disabled",!t)}enable(){return Wc(this,null,function*(){var t;Dc(this,Xl,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),null==(t=Nc(this,tc))||t.abort(),Dc(this,tc,null);const e=new Set;for(const r of Nc(this,Gl).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(Nc(this,nc).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(!Nc(this,Wl))return void Dc(this,Xl,!1);const n=Nc(this,Wl).getEditableAnnotations();for(const r of n){if(r.hide(),Nc(this,nc).isDeletedAnnotationElement(r.data.id))continue;if(e.has(r.data.id))continue;const t=yield this.deserialize(r);t&&(this.addOrRebuild(t),t.enableEditing())}Dc(this,Xl,!1)})}disable(){var e;if(Dc(this,ql,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),Nc(this,Jl)&&!Nc(this,tc)){Dc(this,tc,new AbortController);const t=Nc(this,nc).combinedSignal(Nc(this,tc));Nc(this,Jl).div.addEventListener("pointerdown",t=>{const{clientX:e,clientY:n,timeStamp:r}=t;if(r-Nc(this,ec)>500)return void Dc(this,ec,r);Dc(this,ec,-1);const{classList:i}=this.div;i.toggle("getElements",!0);const A=document.elementsFromPoint(e,n);if(i.toggle("getElements",!1),!this.div.contains(A[0]))return;let s;const a=new RegExp(`^${ZL}[0-9]+$`);for(const l of A)if(a.test(l.id)){s=l.id;break}if(!s)return;const o=Nc(this,Gl).get(s);null===(null==o?void 0:o.annotationElementId)&&(t.stopPropagation(),t.preventDefault(),o.dblclick())},{signal:t,capture:!0})}const n=new Map,r=new Map;for(const t of Nc(this,Gl).values())t.disableEditing(),t.annotationElementId&&(null===t.serialize()?(r.set(t.annotationElementId,t),null==(e=this.getEditableAnnotation(t.annotationElementId))||e.show(),t.remove()):n.set(t.annotationElementId,t));if(Nc(this,Wl)){const t=Nc(this,Wl).getEditableAnnotations();for(const e of t){const{id:t}=e.data;if(Nc(this,nc).isDeletedAnnotationElement(t)){e.updateEdited({deleted:!0});continue}let i=r.get(t);i?(i.resetAnnotationElement(e),i.show(!1),e.show()):(i=n.get(t),i&&(Nc(this,nc).addChangedExistingAnnotation(i),i.renderAnnotationElement(e)&&i.show(!1)),e.show())}}Rc(this,ic,lc).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const A of Nc(t,rc).values())i.remove(`${A._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),Dc(this,ql,!1)}getEditableAnnotation(t){var e;return(null==(e=Nc(this,Wl))?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){Nc(this,nc).getActive()!==t&&Nc(this,nc).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(null==(t=Nc(this,Jl))?void 0:t.div)&&!Nc(this,Zl)){Dc(this,Zl,new AbortController);const t=Nc(this,nc).combinedSignal(Nc(this,Zl));Nc(this,Jl).div.addEventListener("pointerdown",Rc(this,ic,Ac).bind(this),{signal:t}),Nc(this,Jl).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(null==(t=Nc(this,Jl))?void 0:t.div)&&Nc(this,Zl)&&(Nc(this,Zl).abort(),Dc(this,Zl,null),Nc(this,Jl).div.classList.remove("highlighting"))}enableClick(){if(Nc(this,Vl))return;Dc(this,Vl,new AbortController);const t=Nc(this,nc).combinedSignal(Nc(this,Vl));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;null==(t=Nc(this,Vl))||t.abort(),Dc(this,Vl,null)}attach(t){Nc(this,Gl).set(t.id,t);const{annotationElementId:e}=t;e&&Nc(this,nc).isDeletedAnnotationElement(e)&&Nc(this,nc).removeDeletedAnnotationElement(t)}detach(t){var e;Nc(this,Gl).delete(t.id),null==(e=Nc(this,Hl))||e.removePointerInTextLayer(t.contentDiv),!Nc(this,ql)&&t.annotationElementId&&Nc(this,nc).addDeletedAnnotationElement(t)}remove(t){this.detach(t),Nc(this,nc).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(Nc(this,nc).addDeletedAnnotationElement(t.annotationElementId),QI.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null==(e=t.parent)||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),Nc(this,nc).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!Nc(this,Xl)),Nc(this,nc).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:n}=document;t.div.contains(n)&&!Nc(this,Kl)&&(t._focusEventsAllowed=!1,Dc(this,Kl,setTimeout(()=>{Dc(this,Kl,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:Nc(this,nc)._signal}),n.focus())},0))),t._structTreeParentId=null==(e=Nc(this,Hl))?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return Nc(this,nc).getId()}combinedSignal(t){return Nc(this,nc).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null==(t=Nc(this,ic,sc))?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){return Wc(this,null,function*(){this.updateToolbar(t),yield Nc(this,nc).updateMode(t.mode);const{offsetX:n,offsetY:r}=Rc(this,ic,oc).call(this),i=this.getNextId(),A=Rc(this,ic,ac).call(this,Qc({parent:this,id:i,x:n,y:r,uiManager:Nc(this,nc),isCentered:!0},e));A&&this.add(A)})}deserialize(e){return Wc(this,null,function*(){var n,r;return(yield null==(r=Nc(t,rc).get(null!=(n=e.annotationType)?n:e.annotationEditorType))?void 0:r.deserialize(e,this,Nc(this,nc)))||null})}createAndAddNewEditor(t,e,n={}){const r=this.getNextId(),i=Rc(this,ic,ac).call(this,Qc({parent:this,id:r,x:t.offsetX,y:t.offsetY,uiManager:Nc(this,nc),isCentered:e},n));return i&&this.add(i),i}addNewEditor(t={}){this.createAndAddNewEditor(Rc(this,ic,oc).call(this),!0,t)}setSelected(t){Nc(this,nc).setSelected(t)}toggleSelected(t){Nc(this,nc).toggleSelected(t)}unselect(t){Nc(this,nc).unselect(t)}pointerup(t){var e;const{isMac:n}=DU.platform;if(0!==t.button||t.ctrlKey&&n)return;if(t.target!==this.div)return;if(!Nc(this,zl))return;if(Dc(this,zl,!1),(null==(e=Nc(this,ic,sc))?void 0:e.isDrawer)&&Nc(this,ic,sc).supportMultipleDrawings)return;if(!Nc(this,jl))return void Dc(this,jl,!0);const r=Nc(this,nc).getMode();r!==tU.STAMP&&r!==tU.SIGNATURE?this.createAndAddNewEditor(t,!1):Nc(this,nc).unselectAll()}pointerdown(t){var e;if(Nc(this,nc).getMode()===tU.HIGHLIGHT&&this.enableTextSelection(),Nc(this,zl))return void Dc(this,zl,!1);const{isMac:n}=DU.platform;if(0!==t.button||t.ctrlKey&&n)return;if(t.target!==this.div)return;if(Dc(this,zl,!0),null==(e=Nc(this,ic,sc))?void 0:e.isDrawer)return void this.startDrawingSession(t);const r=Nc(this,nc).getActive();Dc(this,jl,!r||r.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),Nc(this,Yl))return void Nc(this,ic,sc).startDrawing(this,Nc(this,nc),!1,t);Nc(this,nc).setCurrentDrawingSession(this),Dc(this,Yl,new AbortController);const e=Nc(this,nc).combinedSignal(Nc(this,Yl));this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(Dc(this,$l,null),this.commitOrRemove())},{signal:e}),Nc(this,ic,sc).startDrawing(this,Nc(this,nc),!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&Dc(this,$l,t))}Nc(this,$l)&&setTimeout(()=>{var t;null==(t=Nc(this,$l))||t.focus(),Dc(this,$l,null)},0)}endDrawingSession(t=!1){return Nc(this,Yl)?(Nc(this,nc).setCurrentDrawingSession(null),Nc(this,Yl).abort(),Dc(this,Yl,null),Dc(this,$l,null),Nc(this,ic,sc).endDrawing(t)):null}findNewParent(t,e,n){const r=Nc(this,nc).findParent(e,n);return null!==r&&r!==this&&(r.changeParent(t),!0)}commitOrRemove(){return!!Nc(this,Yl)&&(this.endDrawingSession(),!0)}onScaleChanging(){Nc(this,Yl)&&Nc(this,ic,sc).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),(null==(t=Nc(this,nc).getActive())?void 0:t.parent)===this&&(Nc(this,nc).commitOrRemove(),Nc(this,nc).setActiveEditor(null)),Nc(this,Kl)&&(clearTimeout(Nc(this,Kl)),Dc(this,Kl,null));for(const n of Nc(this,Gl).values())null==(e=Nc(this,Hl))||e.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,Nc(this,Gl).clear(),Nc(this,nc).removeLayer(this)}render({viewport:t}){this.viewport=t,cI(this.div,t);for(const e of Nc(this,nc).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){Nc(this,nc).commitOrRemove(),Rc(this,ic,lc).call(this);const e=this.viewport.rotation,n=t.rotation;if(this.viewport=t,cI(this.div,{rotation:n}),e!==n)for(const r of Nc(this,Gl).values())r.rotate(n)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return Nc(this,nc).viewParameters.realScale}};Hl=new WeakMap,jl=new WeakMap,Wl=new WeakMap,Vl=new WeakMap,Kl=new WeakMap,Gl=new WeakMap,zl=new WeakMap,ql=new WeakMap,Xl=new WeakMap,Yl=new WeakMap,$l=new WeakMap,Jl=new WeakMap,Zl=new WeakMap,tc=new WeakMap,ec=new WeakMap,nc=new WeakMap,rc=new WeakMap,ic=new WeakSet,Ac=function(t){Nc(this,nc).unselectAll();const{target:e}=t;if(e===Nc(this,Jl).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&Nc(this,Jl).div.contains(e)){const{isMac:e}=DU.platform;if(0!==t.button||t.ctrlKey&&e)return;Nc(this,nc).showAllEditors("highlight",!0,!0),Nc(this,Jl).div.classList.add("free"),this.toggleDrawing(),jM.startHighlighting(this,"ltr"===Nc(this,nc).direction,{target:Nc(this,Jl).div,x:t.x,y:t.y}),Nc(this,Jl).div.addEventListener("pointerup",()=>{Nc(this,Jl).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:Nc(this,nc)._signal}),t.preventDefault()}},sc=function(){return Nc(AO,rc).get(Nc(this,nc).getMode())},ac=function(t){const e=Nc(this,ic,sc);return e?new e.prototype.constructor(t):null},oc=function(){const{x:t,y:e,width:n,height:r}=this.div.getBoundingClientRect(),i=Math.max(0,t),A=Math.max(0,e),s=(i+Math.min(window.innerWidth,t+n))/2-t,a=(A+Math.min(window.innerHeight,e+r))/2-e,[o,l]=this.viewport.rotation%180==0?[s,a]:[a,s];return{offsetX:o,offsetY:l}},lc=function(){for(const t of Nc(this,Gl).values())t.isEmpty()&&t.remove()},Oc(AO,"_initialized",!1),Tc(AO,rc,new Map([QM,YM,iO,jM,nO].map(t=>[t._editorType,t])));let sO=AO;const aO=class t{constructor({pageIndex:t}){Tc(this,gc),Tc(this,cc,null),Tc(this,hc,new Map),Tc(this,uc,new Map),this.pageIndex=t}setParent(t){if(Nc(this,cc)){if(Nc(this,cc)!==t){if(Nc(this,hc).size>0)for(const e of Nc(this,hc).values())e.remove(),t.append(e);Dc(this,cc,t)}}else Dc(this,cc,t)}static get _svgFactory(){return LU(this,"_svgFactory",new Jk)}draw(e,n=!1,r=!1){const i=Hc(t,dc)._++,A=Rc(this,gc,mc).call(this),s=t._svgFactory.createElement("defs");A.append(s);const a=t._svgFactory.createElement("path");s.append(a);const o=`path_p${this.pageIndex}_${i}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),n&&Nc(this,uc).set(i,a);const l=r?Rc(this,gc,wc).call(this,s,o):null,c=t._svgFactory.createElement("use");return A.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(A,e),Nc(this,hc).set(i,A),{id:i,clipPathId:`url(#${l})`}}drawOutline(e,n){const r=Hc(t,dc)._++,i=Rc(this,gc,mc).call(this),A=t._svgFactory.createElement("defs");i.append(A);const s=t._svgFactory.createElement("path");A.append(s);const a=`path_p${this.pageIndex}_${r}`;let o;if(s.setAttribute("id",a),s.setAttribute("vector-effect","non-scaling-stroke"),n){const e=t._svgFactory.createElement("mask");A.append(e),o=`mask_p${this.pageIndex}_${r}`,e.setAttribute("id",o),e.setAttribute("maskUnits","objectBoundingBox");const n=t._svgFactory.createElement("rect");e.append(n),n.setAttribute("width","1"),n.setAttribute("height","1"),n.setAttribute("fill","white");const i=t._svgFactory.createElement("use");e.append(i),i.setAttribute("href",`#${a}`),i.setAttribute("stroke","none"),i.setAttribute("fill","black"),i.setAttribute("fill-rule","nonzero"),i.classList.add("mask")}const l=t._svgFactory.createElement("use");i.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const c=l.cloneNode();return i.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,e),Nc(this,hc).set(r,i),r}finalizeDraw(t,e){Nc(this,uc).delete(t),this.updateProperties(t,e)}updateProperties(e,n){var r;if(!n)return;const{root:i,bbox:A,rootClass:s,path:a}=n,o="number"==typeof e?Nc(this,hc).get(e):e;if(o){if(i&&Rc(this,gc,vc).call(this,o,i),A&&Rc(r=t,fc,pc).call(r,o,A),s){const{classList:t}=o;for(const[e,n]of Object.entries(s))t.toggle(e,n)}if(a){const t=o.firstChild.firstChild;Rc(this,gc,vc).call(this,t,a)}}}updateParent(t,e){if(e===this)return;const n=Nc(this,hc).get(t);n&&(Nc(e,cc).append(n),Nc(this,hc).delete(t),Nc(e,hc).set(t,n))}remove(t){Nc(this,uc).delete(t),null!==Nc(this,cc)&&(Nc(this,hc).get(t).remove(),Nc(this,hc).delete(t))}destroy(){Dc(this,cc,null);for(const t of Nc(this,hc).values())t.remove();Nc(this,hc).clear(),Nc(this,uc).clear()}};cc=new WeakMap,hc=new WeakMap,uc=new WeakMap,dc=new WeakMap,fc=new WeakSet,pc=function(t,[e,n,r,i]){const{style:A}=t;A.top=100*n+"%",A.left=100*e+"%",A.width=100*r+"%",A.height=100*i+"%"},gc=new WeakSet,mc=function(){const t=aO._svgFactory.create(1,1,!0);return Nc(this,cc).append(t),t.setAttribute("aria-hidden",!0),t},wc=function(t,e){const n=aO._svgFactory.createElement("clipPath");t.append(n);const r=`clip_${e}`;n.setAttribute("id",r),n.setAttribute("clipPathUnits","objectBoundingBox");const i=aO._svgFactory.createElement("use");return n.append(i),i.setAttribute("href",`#${e}`),i.classList.add("clip"),r},vc=function(t,e){for(const[n,r]of Object.entries(e))null===r?t.removeAttribute(n):t.setAttribute(n,r)},Tc(aO,fc),Tc(aO,dc,0);let oO=aO;globalThis._pdfjsTestingUtils={HighlightOutliner:NM},globalThis.pdfjsLib={AbortException:PU,AnnotationEditorLayer:sO,AnnotationEditorParamsType:eU,AnnotationEditorType:tU,AnnotationEditorUIManager:xI,AnnotationLayer:LM,AnnotationMode:JL,AnnotationType:lU,build:"295fb3ec4",ColorPicker:Kk,createValidAbsoluteUrl:SU,DOMSVGFactory:Jk,DrawLayer:oO,FeatureTest:DU,fetchData:$U,getDocument:Qk,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)},getPdfFilenameFromUrl:function(t,e="document.pdf"){if("string"!=typeof t)return e;if(tI(t))return CU('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const n=(t=>{try{return new URL(t)}catch(hw){try{return new URL(decodeURIComponent(t))}catch(e){try{return new URL(t,"https://foo.bar")}catch(n){try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch(r){return null}}}}})(t);if(!n)return e;const r=t=>{try{let e=decodeURIComponent(t);return e.includes("/")?(e=e.split("/").at(-1),e.test(/^\.pdf$/i)?e:t):e}catch(hw){return t}},i=/\.pdf$/i,A=n.pathname.split("/").at(-1);if(i.test(A))return r(A);if(n.searchParams.size>0){const t=Array.from(n.searchParams.values()).reverse();for(const n of t)if(i.test(n))return r(n);const e=Array.from(n.searchParams.keys()).reverse();for(const n of e)if(i.test(n))return r(n)}if(n.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(n.hash);if(t)return r(t[0])}return e},getRGB:aI,getUuid:VU,getXfaPageViewport:function(t,{scale:e=1,rotation:n=0}){const{width:r,height:i}=t.attributes.style,A=[0,0,parseInt(r),parseInt(i)];return new JU({viewBox:A,userUnit:1,scale:e,rotation:n})},GlobalWorkerOptions:tk,ImageKind:oU,InvalidPDFException:kU,isDataScheme:tI,isPdfFile:eI,isValidExplicitDest:KI,MathClamp:GU,noContextMenu:iI,normalizeUnicode:function(t){return jU||(jU=/([\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,WU=new Map([["ſt","ſt"]])),t.replaceAll(jU,(t,e,n)=>e?e.normalize("NFKC"):WU.get(n))},OPS:gU,OutputScale:hI,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:Ok,PDFDateString:sI,PDFWorker:Dk,PermissionFlag:{PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},PixelsPerInch:YU,RenderingCancelledException:ZU,ResponseException:MU,setLayerDimensions:cI,shadow:LU,SignatureExtractor:JM,stopEvent:AI,SupportedImageMimeTypes:uI,TextLayer:Uk,TouchManager:UI,updateUrlHash:FU,Util:HU,VerbosityLevel:pU,version:"5.4.54",XfaLayer:Zk};function lO(t){let e=t.length;for(;--e>=0;)t[e]=0}const cO=256,hO=286,uO=30,dO=15,fO=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),pO=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),gO=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),mO=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wO=new Array(576);lO(wO);const vO=new Array(60);lO(vO);const yO=new Array(512);lO(yO);const bO=new Array(256);lO(bO);const BO=new Array(29);lO(BO);const _O=new Array(uO);function CO(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}let xO,EO,SO;function FO(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}lO(_O);const LO=t=>t<256?yO[t]:yO[256+(t>>>7)],UO=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},IO=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,UO(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},QO=(t,e,n)=>{IO(t,n[2*e],n[2*e+1])},kO=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},MO=(t,e,n)=>{const r=new Array(16);let i,A,s=0;for(i=1;i<=dO;i++)s=s+n[i-1]<<1,r[i]=s;for(A=0;A<=e;A++){let e=t[2*A+1];0!==e&&(t[2*A]=kO(r[e]++,e))}},OO=t=>{let e;for(e=0;e<hO;e++)t.dyn_ltree[2*e]=0;for(e=0;e<uO;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},PO=t=>{t.bi_valid>8?UO(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},NO=(t,e,n,r)=>{const i=2*e,A=2*n;return t[i]<t[A]||t[i]===t[A]&&r[e]<=r[n]},TO=(t,e,n)=>{const r=t.heap[n];let i=n<<1;for(;i<=t.heap_len&&(i<t.heap_len&&NO(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!NO(e,r,t.heap[i],t.depth));)t.heap[n]=t.heap[i],n=i,i<<=1;t.heap[n]=r},DO=(t,e,n)=>{let r,i,A,s,a=0;if(0!==t.sym_next)do{r=255&t.pending_buf[t.sym_buf+a++],r+=(255&t.pending_buf[t.sym_buf+a++])<<8,i=t.pending_buf[t.sym_buf+a++],0===r?QO(t,i,e):(A=bO[i],QO(t,A+cO+1,e),s=fO[A],0!==s&&(i-=BO[A],IO(t,i,s)),r--,A=LO(r),QO(t,A,n),s=pO[A],0!==s&&(r-=_O[A],IO(t,r,s)))}while(a<t.sym_next);QO(t,256,e)},RO=(t,e)=>{const n=e.dyn_tree,r=e.stat_desc.static_tree,i=e.stat_desc.has_stree,A=e.stat_desc.elems;let s,a,o,l=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<A;s++)0!==n[2*s]?(t.heap[++t.heap_len]=l=s,t.depth[s]=0):n[2*s+1]=0;for(;t.heap_len<2;)o=t.heap[++t.heap_len]=l<2?++l:0,n[2*o]=1,t.depth[o]=0,t.opt_len--,i&&(t.static_len-=r[2*o+1]);for(e.max_code=l,s=t.heap_len>>1;s>=1;s--)TO(t,n,s);o=A;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],TO(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,n[2*o]=n[2*s]+n[2*a],t.depth[o]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,n[2*s+1]=n[2*a+1]=o,t.heap[1]=o++,TO(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,r=e.max_code,i=e.stat_desc.static_tree,A=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,o=e.stat_desc.max_length;let l,c,h,u,d,f,p=0;for(u=0;u<=dO;u++)t.bl_count[u]=0;for(n[2*t.heap[t.heap_max]+1]=0,l=t.heap_max+1;l<573;l++)c=t.heap[l],u=n[2*n[2*c+1]+1]+1,u>o&&(u=o,p++),n[2*c+1]=u,c>r||(t.bl_count[u]++,d=0,c>=a&&(d=s[c-a]),f=n[2*c],t.opt_len+=f*(u+d),A&&(t.static_len+=f*(i[2*c+1]+d)));if(0!==p){do{for(u=o-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[o]--,p-=2}while(p>0);for(u=o;0!==u;u--)for(c=t.bl_count[u];0!==c;)h=t.heap[--l],h>r||(n[2*h+1]!==u&&(t.opt_len+=(u-n[2*h+1])*n[2*h],n[2*h+1]=u),c--)}})(t,e),MO(n,l,t.bl_count)},HO=(t,e,n)=>{let r,i,A=-1,s=e[1],a=0,o=7,l=4;for(0===s&&(o=138,l=3),e[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=e[2*(r+1)+1],++a<o&&i===s||(a<l?t.bl_tree[2*i]+=a:0!==i?(i!==A&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,A=i,0===s?(o=138,l=3):i===s?(o=6,l=3):(o=7,l=4))},jO=(t,e,n)=>{let r,i,A=-1,s=e[1],a=0,o=7,l=4;for(0===s&&(o=138,l=3),r=0;r<=n;r++)if(i=s,s=e[2*(r+1)+1],!(++a<o&&i===s)){if(a<l)do{QO(t,i,t.bl_tree)}while(0!==--a);else 0!==i?(i!==A&&(QO(t,i,t.bl_tree),a--),QO(t,16,t.bl_tree),IO(t,a-3,2)):a<=10?(QO(t,17,t.bl_tree),IO(t,a-3,3)):(QO(t,18,t.bl_tree),IO(t,a-11,7));a=0,A=i,0===s?(o=138,l=3):i===s?(o=6,l=3):(o=7,l=4)}};let WO=!1;const VO=(t,e,n,r)=>{IO(t,0+(r?1:0),3),PO(t),UO(t,n),UO(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n};var KO={_tr_init:t=>{WO||((()=>{let t,e,n,r,i;const A=new Array(16);for(n=0,r=0;r<28;r++)for(BO[r]=n,t=0;t<1<<fO[r];t++)bO[n++]=r;for(bO[n-1]=r,i=0,r=0;r<16;r++)for(_O[r]=i,t=0;t<1<<pO[r];t++)yO[i++]=r;for(i>>=7;r<uO;r++)for(_O[r]=i<<7,t=0;t<1<<pO[r]-7;t++)yO[256+i++]=r;for(e=0;e<=dO;e++)A[e]=0;for(t=0;t<=143;)wO[2*t+1]=8,t++,A[8]++;for(;t<=255;)wO[2*t+1]=9,t++,A[9]++;for(;t<=279;)wO[2*t+1]=7,t++,A[7]++;for(;t<=287;)wO[2*t+1]=8,t++,A[8]++;for(MO(wO,287,A),t=0;t<uO;t++)vO[2*t+1]=5,vO[2*t]=kO(t,5);xO=new CO(wO,fO,257,hO,dO),EO=new CO(vO,pO,0,uO,dO),SO=new CO(new Array(0),gO,0,19,7)})(),WO=!0),t.l_desc=new FO(t.dyn_ltree,xO),t.d_desc=new FO(t.dyn_dtree,EO),t.bl_desc=new FO(t.bl_tree,SO),t.bi_buf=0,t.bi_valid=0,OO(t)},_tr_stored_block:VO,_tr_flush_block:(t,e,n,r)=>{let i,A,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<cO;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),RO(t,t.l_desc),RO(t,t.d_desc),s=(t=>{let e;for(HO(t,t.dyn_ltree,t.l_desc.max_code),HO(t,t.dyn_dtree,t.d_desc.max_code),RO(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*mO[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,A=t.static_len+3+7>>>3,A<=i&&(i=A)):i=A=n+5,n+4<=i&&-1!==e?VO(t,e,n,r):4===t.strategy||A===i?(IO(t,2+(r?1:0),3),DO(t,wO,vO)):(IO(t,4+(r?1:0),3),((t,e,n,r)=>{let i;for(IO(t,e-257,5),IO(t,n-1,5),IO(t,r-4,4),i=0;i<r;i++)IO(t,t.bl_tree[2*mO[i]+1],3);jO(t,t.dyn_ltree,e-1),jO(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),DO(t,t.dyn_ltree,t.dyn_dtree)),OO(t),r&&PO(t)},_tr_tally:(t,e,n)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=n,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(bO[n]+cO+1)]++,t.dyn_dtree[2*LO(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{IO(t,2,3),QO(t,256,wO),(t=>{16===t.bi_valid?(UO(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var GO=(t,e,n,r)=>{let i=65535&t,A=t>>>16&65535,s=0;for(;0!==n;){s=n>2e3?2e3:n,n-=s;do{i=i+e[r++]|0,A=A+i|0}while(--s);i%=65521,A%=65521}return i|A<<16};const zO=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());var qO=(t,e,n,r)=>{const i=zO,A=r+n;t^=-1;for(let s=r;s<A;s++)t=t>>>8^i[255&(t^e[s])];return-1^t},XO={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},YO={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:$O,_tr_stored_block:JO,_tr_flush_block:ZO,_tr_tally:tP,_tr_align:eP}=KO,{Z_NO_FLUSH:nP,Z_PARTIAL_FLUSH:rP,Z_FULL_FLUSH:iP,Z_FINISH:AP,Z_BLOCK:sP,Z_OK:aP,Z_STREAM_END:oP,Z_STREAM_ERROR:lP,Z_DATA_ERROR:cP,Z_BUF_ERROR:hP,Z_DEFAULT_COMPRESSION:uP,Z_FILTERED:dP,Z_HUFFMAN_ONLY:fP,Z_RLE:pP,Z_FIXED:gP,Z_DEFAULT_STRATEGY:mP,Z_UNKNOWN:wP,Z_DEFLATED:vP}=YO,yP=258,bP=262,BP=42,_P=113,CP=666,xP=(t,e)=>(t.msg=XO[e],e),EP=t=>2*t-(t>4?9:0),SP=t=>{let e=t.length;for(;--e>=0;)t[e]=0},FP=t=>{let e,n,r,i=t.w_size;e=t.hash_size,r=e;do{n=t.head[--r],t.head[r]=n>=i?n-i:0}while(--e);e=i,r=e;do{n=t.prev[--r],t.prev[r]=n>=i?n-i:0}while(--e)};let LP=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const UP=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},IP=(t,e)=>{ZO(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,UP(t.strm)},QP=(t,e)=>{t.pending_buf[t.pending++]=e},kP=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},MP=(t,e,n,r)=>{let i=t.avail_in;return i>r&&(i=r),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),n),1===t.state.wrap?t.adler=GO(t.adler,e,i,n):2===t.state.wrap&&(t.adler=qO(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)},OP=(t,e)=>{let n,r,i=t.max_chain_length,A=t.strstart,s=t.prev_length,a=t.nice_match;const o=t.strstart>t.w_size-bP?t.strstart-(t.w_size-bP):0,l=t.window,c=t.w_mask,h=t.prev,u=t.strstart+yP;let d=l[A+s-1],f=l[A+s];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(n=e,l[n+s]===f&&l[n+s-1]===d&&l[n]===l[A]&&l[++n]===l[A+1]){A+=2,n++;do{}while(l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&l[++A]===l[++n]&&A<u);if(r=yP-(u-A),A=u-yP,r>s){if(t.match_start=e,s=r,r>=a)break;d=l[A+s-1],f=l[A+s]}}}while((e=h[e&c])>o&&0!==--i);return s<=t.lookahead?s:t.lookahead},PP=t=>{const e=t.w_size;let n,r,i;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-bP)&&(t.window.set(t.window.subarray(e,e+e-r),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),FP(t),r+=e),0===t.strm.avail_in)break;if(n=MP(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=n,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=LP(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=LP(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<bP&&0!==t.strm.avail_in)},NP=(t,e)=>{let n,r,i,A=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,s=0,a=t.strm.avail_in;do{if(n=65535,i=t.bi_valid+42>>3,t.strm.avail_out<i)break;if(i=t.strm.avail_out-i,r=t.strstart-t.block_start,n>r+t.strm.avail_in&&(n=r+t.strm.avail_in),n>i&&(n=i),n<A&&(0===n&&e!==AP||e===nP||n!==r+t.strm.avail_in))break;s=e===AP&&n===r+t.strm.avail_in?1:0,JO(t,0,0,s),t.pending_buf[t.pending-4]=n,t.pending_buf[t.pending-3]=n>>8,t.pending_buf[t.pending-2]=~n,t.pending_buf[t.pending-1]=~n>>8,UP(t.strm),r&&(r>n&&(r=n),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+r),t.strm.next_out),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r,t.block_start+=r,n-=r),n&&(MP(t.strm,t.strm.output,t.strm.next_out,n),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n)}while(0===s);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),s?4:e!==nP&&e!==AP&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(i=t.window_size-t.strstart,t.strm.avail_in>i&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&(MP(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water<t.strstart&&(t.high_water=t.strstart),i=t.bi_valid+42>>3,i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i,A=i>t.w_size?t.w_size:i,r=t.strstart-t.block_start,(r>=A||(r||e===AP)&&e!==nP&&0===t.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=e===AP&&0===t.strm.avail_in&&n===r?1:0,JO(t,t.block_start,n,s),t.block_start+=n,UP(t.strm)),s?3:1)},TP=(t,e)=>{let n,r;for(;;){if(t.lookahead<bP){if(PP(t),t.lookahead<bP&&e===nP)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=LP(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-bP&&(t.match_length=OP(t,n)),t.match_length>=3)if(r=tP(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=LP(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=LP(t,t.ins_h,t.window[t.strstart+1]);else r=tP(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(IP(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===AP?(IP(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IP(t,!1),0===t.strm.avail_out)?1:2},DP=(t,e)=>{let n,r,i;for(;;){if(t.lookahead<bP){if(PP(t),t.lookahead<bP&&e===nP)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=LP(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-bP&&(t.match_length=OP(t,n),t.match_length<=5&&(t.strategy===dP||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,r=tP(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=LP(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,r&&(IP(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(r=tP(t,0,t.window[t.strstart-1]),r&&IP(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(r=tP(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===AP?(IP(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IP(t,!1),0===t.strm.avail_out)?1:2};function RP(t,e,n,r,i){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=r,this.func=i}const HP=[new RP(0,0,0,0,NP),new RP(4,4,8,4,TP),new RP(4,5,16,8,TP),new RP(4,6,32,32,TP),new RP(4,4,16,16,DP),new RP(8,16,32,32,DP),new RP(8,16,128,128,DP),new RP(8,32,128,256,DP),new RP(32,128,258,1024,DP),new RP(32,258,258,4096,DP)];function jP(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=vP,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),SP(this.dyn_ltree),SP(this.dyn_dtree),SP(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),SP(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),SP(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const WP=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==BP&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==_P&&e.status!==CP?1:0},VP=t=>{if(WP(t))return xP(t,lP);t.total_in=t.total_out=0,t.data_type=wP;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?BP:_P,t.adler=2===e.wrap?0:1,e.last_flush=-2,$O(e),aP},KP=t=>{const e=VP(t);var n;return e===aP&&((n=t.state).window_size=2*n.w_size,SP(n.head),n.max_lazy_match=HP[n.level].max_lazy,n.good_match=HP[n.level].good_length,n.nice_match=HP[n.level].nice_length,n.max_chain_length=HP[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),e},GP=(t,e,n,r,i,A)=>{if(!t)return lP;let s=1;if(e===uP&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==vP||r<8||r>15||e<0||e>9||A<0||A>gP||8===r&&1!==s)return xP(t,lP);8===r&&(r=9);const a=new jP;return t.state=a,a.strm=t,a.status=BP,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=A,a.method=n,KP(t)};var zP={deflateInit:(t,e)=>GP(t,e,vP,15,8,mP),deflateInit2:GP,deflateReset:KP,deflateResetKeep:VP,deflateSetHeader:(t,e)=>WP(t)||2!==t.state.wrap?lP:(t.state.gzhead=e,aP),deflate:(t,e)=>{if(WP(t)||e>sP||e<0)return t?xP(t,lP):lP;const n=t.state;if(!t.output||0!==t.avail_in&&!t.input||n.status===CP&&e!==AP)return xP(t,0===t.avail_out?hP:lP);const r=n.last_flush;if(n.last_flush=e,0!==n.pending){if(UP(t),0===t.avail_out)return n.last_flush=-1,aP}else if(0===t.avail_in&&EP(e)<=EP(r)&&e!==AP)return xP(t,hP);if(n.status===CP&&0!==t.avail_in)return xP(t,hP);if(n.status===BP&&0===n.wrap&&(n.status=_P),n.status===BP){let e=vP+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=fP||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=r<<6,0!==n.strstart&&(e|=32),e+=31-e%31,kP(n,e),0!==n.strstart&&(kP(n,t.adler>>>16),kP(n,65535&t.adler)),t.adler=1,n.status=_P,UP(t),0!==n.pending)return n.last_flush=-1,aP}if(57===n.status)if(t.adler=0,QP(n,31),QP(n,139),QP(n,8),n.gzhead)QP(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),QP(n,255&n.gzhead.time),QP(n,n.gzhead.time>>8&255),QP(n,n.gzhead.time>>16&255),QP(n,n.gzhead.time>>24&255),QP(n,9===n.level?2:n.strategy>=fP||n.level<2?4:0),QP(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(QP(n,255&n.gzhead.extra.length),QP(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=qO(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(QP(n,0),QP(n,0),QP(n,0),QP(n,0),QP(n,0),QP(n,9===n.level?2:n.strategy>=fP||n.level<2?4:0),QP(n,3),n.status=_P,UP(t),0!==n.pending)return n.last_flush=-1,aP;if(69===n.status){if(n.gzhead.extra){let e=n.pending,r=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>e&&(t.adler=qO(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex+=i,UP(t),0!==n.pending)return n.last_flush=-1,aP;e=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>e&&(t.adler=qO(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let e,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(t.adler=qO(t.adler,n.pending_buf,n.pending-r,r)),UP(t),0!==n.pending)return n.last_flush=-1,aP;r=0}e=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,QP(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>r&&(t.adler=qO(t.adler,n.pending_buf,n.pending-r,r)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let e,r=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>r&&(t.adler=qO(t.adler,n.pending_buf,n.pending-r,r)),UP(t),0!==n.pending)return n.last_flush=-1,aP;r=0}e=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,QP(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>r&&(t.adler=qO(t.adler,n.pending_buf,n.pending-r,r))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(UP(t),0!==n.pending))return n.last_flush=-1,aP;QP(n,255&t.adler),QP(n,t.adler>>8&255),t.adler=0}if(n.status=_P,UP(t),0!==n.pending)return n.last_flush=-1,aP}if(0!==t.avail_in||0!==n.lookahead||e!==nP&&n.status!==CP){let r=0===n.level?NP(n,e):n.strategy===fP?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(PP(t),0===t.lookahead)){if(e===nP)return 1;break}if(t.match_length=0,n=tP(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(IP(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===AP?(IP(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IP(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===pP?((t,e)=>{let n,r,i,A;const s=t.window;for(;;){if(t.lookahead<=yP){if(PP(t),t.lookahead<=yP&&e===nP)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,r=s[i],r===s[++i]&&r===s[++i]&&r===s[++i])){A=t.strstart+yP;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&i<A);t.match_length=yP-(A-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=tP(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=tP(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(IP(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===AP?(IP(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IP(t,!1),0===t.strm.avail_out)?1:2})(n,e):HP[n.level].func(n,e);if(3!==r&&4!==r||(n.status=CP),1===r||3===r)return 0===t.avail_out&&(n.last_flush=-1),aP;if(2===r&&(e===rP?eP(n):e!==sP&&(JO(n,0,0,!1),e===iP&&(SP(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),UP(t),0===t.avail_out))return n.last_flush=-1,aP}return e!==AP?aP:n.wrap<=0?oP:(2===n.wrap?(QP(n,255&t.adler),QP(n,t.adler>>8&255),QP(n,t.adler>>16&255),QP(n,t.adler>>24&255),QP(n,255&t.total_in),QP(n,t.total_in>>8&255),QP(n,t.total_in>>16&255),QP(n,t.total_in>>24&255)):(kP(n,t.adler>>>16),kP(n,65535&t.adler)),UP(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?aP:oP)},deflateEnd:t=>{if(WP(t))return lP;const e=t.state.status;return t.state=null,e===_P?xP(t,cP):aP},deflateSetDictionary:(t,e)=>{let n=e.length;if(WP(t))return lP;const r=t.state,i=r.wrap;if(2===i||1===i&&r.status!==BP||r.lookahead)return lP;if(1===i&&(t.adler=GO(t.adler,e,n,0)),r.wrap=0,n>=r.w_size){0===i&&(SP(r.head),r.strstart=0,r.block_start=0,r.insert=0);let t=new Uint8Array(r.w_size);t.set(e.subarray(n-r.w_size,n),0),e=t,n=r.w_size}const A=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,PP(r);r.lookahead>=3;){let t=r.strstart,e=r.lookahead-2;do{r.ins_h=LP(r,r.ins_h,r.window[t+3-1]),r.prev[t&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=t,t++}while(--e);r.strstart=t,r.lookahead=2,PP(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=s,t.input=a,t.avail_in=A,r.wrap=i,aP},deflateInfo:"pako deflate (from Nodeca project)"};const qP=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var XP=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)qP(n,e)&&(t[e]=n[e])}}return t},YP=t=>{let e=0;for(let r=0,i=t.length;r<i;r++)e+=t[r].length;const n=new Uint8Array(e);for(let r=0,i=0,A=t.length;r<A;r++){let e=t[r];n.set(e,i),i+=e.length}return n};let $P=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(l3){$P=!1}const JP=new Uint8Array(256);for(let c3=0;c3<256;c3++)JP[c3]=c3>=252?6:c3>=248?5:c3>=240?4:c3>=224?3:c3>=192?2:1;JP[254]=JP[254]=1;var ZP=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,r,i,A,s=t.length,a=0;for(i=0;i<s;i++)n=t.charCodeAt(i),55296==(64512&n)&&i+1<s&&(r=t.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(a),A=0,i=0;A<a;i++)n=t.charCodeAt(i),55296==(64512&n)&&i+1<s&&(r=t.charCodeAt(i+1),56320==(64512&r)&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?e[A++]=n:n<2048?(e[A++]=192|n>>>6,e[A++]=128|63&n):n<65536?(e[A++]=224|n>>>12,e[A++]=128|n>>>6&63,e[A++]=128|63&n):(e[A++]=240|n>>>18,e[A++]=128|n>>>12&63,e[A++]=128|n>>>6&63,e[A++]=128|63&n);return e},tN=(t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let r,i;const A=new Array(2*n);for(i=0,r=0;r<n;){let e=t[r++];if(e<128){A[i++]=e;continue}let s=JP[e];if(s>4)A[i++]=65533,r+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&r<n;)e=e<<6|63&t[r++],s--;s>1?A[i++]=65533:e<65536?A[i++]=e:(e-=65536,A[i++]=55296|e>>10&1023,A[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&$P)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let r=0;r<e;r++)n+=String.fromCharCode(t[r]);return n})(A,i)},eN=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+JP[t[n]]>e?n:e};var nN=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const rN=Object.prototype.toString,{Z_NO_FLUSH:iN,Z_SYNC_FLUSH:AN,Z_FULL_FLUSH:sN,Z_FINISH:aN,Z_OK:oN,Z_STREAM_END:lN,Z_DEFAULT_COMPRESSION:cN,Z_DEFAULT_STRATEGY:hN,Z_DEFLATED:uN}=YO;function dN(t){this.options=XP({level:cN,method:uN,chunkSize:16384,windowBits:15,memLevel:8,strategy:hN},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new nN,this.strm.avail_out=0;let n=zP.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==oN)throw new Error(XO[n]);if(e.header&&zP.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?ZP(e.dictionary):"[object ArrayBuffer]"===rN.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=zP.deflateSetDictionary(this.strm,t),n!==oN)throw new Error(XO[n]);this._dict_set=!0}}function fN(t,e){const n=new dN(e);if(n.push(t,!0),n.err)throw n.msg||XO[n.err];return n.result}dN.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize;let i,A;if(this.ended)return!1;for(A=e===~~e?e:!0===e?aN:iN,"string"==typeof t?n.input=ZP(t):"[object ArrayBuffer]"===rN.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(A===AN||A===sN)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=zP.deflate(n,A),i===lN)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=zP.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===oN;if(0!==n.avail_out){if(A>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},dN.prototype.onData=function(t){this.chunks.push(t)},dN.prototype.onEnd=function(t){t===oN&&(this.result=YP(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var pN={Deflate:dN,deflate:fN,deflateRaw:function(t,e){return(e=e||{}).raw=!0,fN(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,fN(t,e)}};const gN=16209;var mN=function(t,e){let n,r,i,A,s,a,o,l,c,h,u,d,f,p,g,m,w,v,y,b,B,_,C,x;const E=t.state;n=t.next_in,C=t.input,r=n+(t.avail_in-5),i=t.next_out,x=t.output,A=i-(e-t.avail_out),s=i+(t.avail_out-257),a=E.dmax,o=E.wsize,l=E.whave,c=E.wnext,h=E.window,u=E.hold,d=E.bits,f=E.lencode,p=E.distcode,g=(1<<E.lenbits)-1,m=(1<<E.distbits)-1;t:do{d<15&&(u+=C[n++]<<d,d+=8,u+=C[n++]<<d,d+=8),w=f[u&g];e:for(;;){if(v=w>>>24,u>>>=v,d-=v,v=w>>>16&255,0===v)x[i++]=65535&w;else{if(!(16&v)){if(64&v){if(32&v){E.mode=16191;break t}t.msg="invalid literal/length code",E.mode=gN;break t}w=f[(65535&w)+(u&(1<<v)-1)];continue e}for(y=65535&w,v&=15,v&&(d<v&&(u+=C[n++]<<d,d+=8),y+=u&(1<<v)-1,u>>>=v,d-=v),d<15&&(u+=C[n++]<<d,d+=8,u+=C[n++]<<d,d+=8),w=p[u&m];;){if(v=w>>>24,u>>>=v,d-=v,v=w>>>16&255,16&v){if(b=65535&w,v&=15,d<v&&(u+=C[n++]<<d,d+=8,d<v&&(u+=C[n++]<<d,d+=8)),b+=u&(1<<v)-1,b>a){t.msg="invalid distance too far back",E.mode=gN;break t}if(u>>>=v,d-=v,v=i-A,b>v){if(v=b-v,v>l&&E.sane){t.msg="invalid distance too far back",E.mode=gN;break t}if(B=0,_=h,0===c){if(B+=o-v,v<y){y-=v;do{x[i++]=h[B++]}while(--v);B=i-b,_=x}}else if(c<v){if(B+=o+c-v,v-=c,v<y){y-=v;do{x[i++]=h[B++]}while(--v);if(B=0,c<y){v=c,y-=v;do{x[i++]=h[B++]}while(--v);B=i-b,_=x}}}else if(B+=c-v,v<y){y-=v;do{x[i++]=h[B++]}while(--v);B=i-b,_=x}for(;y>2;)x[i++]=_[B++],x[i++]=_[B++],x[i++]=_[B++],y-=3;y&&(x[i++]=_[B++],y>1&&(x[i++]=_[B++]))}else{B=i-b;do{x[i++]=x[B++],x[i++]=x[B++],x[i++]=x[B++],y-=3}while(y>2);y&&(x[i++]=x[B++],y>1&&(x[i++]=x[B++]))}break}if(64&v){t.msg="invalid distance code",E.mode=gN;break t}w=p[(65535&w)+(u&(1<<v)-1)]}}break}}while(n<r&&i<s);y=d>>3,n-=y,d-=y<<3,u&=(1<<d)-1,t.next_in=n,t.next_out=i,t.avail_in=n<r?r-n+5:5-(n-r),t.avail_out=i<s?s-i+257:257-(i-s),E.hold=u,E.bits=d};const wN=15,vN=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),yN=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),bN=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),BN=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var _N=(t,e,n,r,i,A,s,a)=>{const o=a.bits;let l,c,h,u,d,f,p=0,g=0,m=0,w=0,v=0,y=0,b=0,B=0,_=0,C=0,x=null;const E=new Uint16Array(16),S=new Uint16Array(16);let F,L,U,I=null;for(p=0;p<=wN;p++)E[p]=0;for(g=0;g<r;g++)E[e[n+g]]++;for(v=o,w=wN;w>=1&&0===E[w];w--);if(v>w&&(v=w),0===w)return i[A++]=20971520,i[A++]=20971520,a.bits=1,0;for(m=1;m<w&&0===E[m];m++);for(v<m&&(v=m),B=1,p=1;p<=wN;p++)if(B<<=1,B-=E[p],B<0)return-1;if(B>0&&(0===t||1!==w))return-1;for(S[1]=0,p=1;p<wN;p++)S[p+1]=S[p]+E[p];for(g=0;g<r;g++)0!==e[n+g]&&(s[S[e[n+g]]++]=g);if(0===t?(x=I=s,f=20):1===t?(x=vN,I=yN,f=257):(x=bN,I=BN,f=0),C=0,g=0,p=m,d=A,y=v,b=0,h=-1,_=1<<v,u=_-1,1===t&&_>852||2===t&&_>592)return 1;for(;;){F=p-b,s[g]+1<f?(L=0,U=s[g]):s[g]>=f?(L=I[s[g]-f],U=x[s[g]-f]):(L=96,U=0),l=1<<p-b,c=1<<y,m=c;do{c-=l,i[d+(C>>b)+c]=F<<24|L<<16|U}while(0!==c);for(l=1<<p-1;C&l;)l>>=1;if(0!==l?(C&=l-1,C+=l):C=0,g++,0===--E[p]){if(p===w)break;p=e[n+s[g]]}if(p>v&&(C&u)!==h){for(0===b&&(b=v),d+=m,y=p-b,B=1<<y;y+b<w&&(B-=E[y+b],!(B<=0));)y++,B<<=1;if(_+=1<<y,1===t&&_>852||2===t&&_>592)return 1;h=C&u,i[h]=v<<24|y<<16|d-A}}return 0!==C&&(i[d+C]=p-b<<24|64<<16),a.bits=v,0};const{Z_FINISH:CN,Z_BLOCK:xN,Z_TREES:EN,Z_OK:SN,Z_STREAM_END:FN,Z_NEED_DICT:LN,Z_STREAM_ERROR:UN,Z_DATA_ERROR:IN,Z_MEM_ERROR:QN,Z_BUF_ERROR:kN,Z_DEFLATED:MN}=YO,ON=16180,PN=16190,NN=16191,TN=16192,DN=16194,RN=16199,HN=16200,jN=16206,WN=16209,VN=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function KN(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const GN=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<ON||e.mode>16211?1:0},zN=t=>{if(GN(t))return UN;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=ON,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,SN},qN=t=>{if(GN(t))return UN;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,zN(t)},XN=(t,e)=>{let n;if(GN(t))return UN;const r=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?UN:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,qN(t))},YN=(t,e)=>{if(!t)return UN;const n=new KN;t.state=n,n.strm=t,n.window=null,n.mode=ON;const r=XN(t,e);return r!==SN&&(t.state=null),r};let $N,JN,ZN=!0;const tT=t=>{if(ZN){$N=new Int32Array(512),JN=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(_N(1,t.lens,0,288,$N,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;_N(2,t.lens,0,32,JN,0,t.work,{bits:5}),ZN=!1}t.lencode=$N,t.lenbits=9,t.distcode=JN,t.distbits=5},eT=(t,e,n,r)=>{let i;const A=t.state;return null===A.window&&(A.wsize=1<<A.wbits,A.wnext=0,A.whave=0,A.window=new Uint8Array(A.wsize)),r>=A.wsize?(A.window.set(e.subarray(n-A.wsize,n),0),A.wnext=0,A.whave=A.wsize):(i=A.wsize-A.wnext,i>r&&(i=r),A.window.set(e.subarray(n-r,n-r+i),A.wnext),(r-=i)?(A.window.set(e.subarray(n-r,n),0),A.wnext=r,A.whave=A.wsize):(A.wnext+=i,A.wnext===A.wsize&&(A.wnext=0),A.whave<A.wsize&&(A.whave+=i))),0};var nT={inflateReset:qN,inflateReset2:XN,inflateResetKeep:zN,inflateInit:t=>YN(t,15),inflateInit2:YN,inflate:(t,e)=>{let n,r,i,A,s,a,o,l,c,h,u,d,f,p,g,m,w,v,y,b,B,_,C=0;const x=new Uint8Array(4);let E,S;const F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(GN(t)||!t.output||!t.input&&0!==t.avail_in)return UN;n=t.state,n.mode===NN&&(n.mode=TN),s=t.next_out,i=t.output,o=t.avail_out,A=t.next_in,r=t.input,a=t.avail_in,l=n.hold,c=n.bits,h=a,u=o,_=SN;t:for(;;)switch(n.mode){case ON:if(0===n.wrap){n.mode=TN;break}for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(2&n.wrap&&35615===l){0===n.wbits&&(n.wbits=15),n.check=0,x[0]=255&l,x[1]=l>>>8&255,n.check=qO(n.check,x,2,0),l=0,c=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",n.mode=WN;break}if((15&l)!==MN){t.msg="unknown compression method",n.mode=WN;break}if(l>>>=4,c-=4,B=8+(15&l),0===n.wbits&&(n.wbits=B),B>15||B>n.wbits){t.msg="invalid window size",n.mode=WN;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&l?16189:NN,l=0,c=0;break;case 16181:for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(n.flags=l,(255&n.flags)!==MN){t.msg="unknown compression method",n.mode=WN;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=WN;break}n.head&&(n.head.text=l>>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&l,x[1]=l>>>8&255,n.check=qO(n.check,x,2,0)),l=0,c=0,n.mode=16182;case 16182:for(;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.head&&(n.head.time=l),512&n.flags&&4&n.wrap&&(x[0]=255&l,x[1]=l>>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,n.check=qO(n.check,x,4,0)),l=0,c=0,n.mode=16183;case 16183:for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.head&&(n.head.xflags=255&l,n.head.os=l>>8),512&n.flags&&4&n.wrap&&(x[0]=255&l,x[1]=l>>>8&255,n.check=qO(n.check,x,2,0)),l=0,c=0,n.mode=16184;case 16184:if(1024&n.flags){for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.length=l,n.head&&(n.head.extra_len=l),512&n.flags&&4&n.wrap&&(x[0]=255&l,x[1]=l>>>8&255,n.check=qO(n.check,x,2,0)),l=0,c=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(d=n.length,d>a&&(d=a),d&&(n.head&&(B=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(A,A+d),B)),512&n.flags&&4&n.wrap&&(n.check=qO(n.check,r,d,A)),a-=d,A+=d,n.length-=d),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break t;d=0;do{B=r[A+d++],n.head&&B&&n.length<65536&&(n.head.name+=String.fromCharCode(B))}while(B&&d<a);if(512&n.flags&&4&n.wrap&&(n.check=qO(n.check,r,d,A)),a-=d,A+=d,B)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===a)break t;d=0;do{B=r[A+d++],n.head&&B&&n.length<65536&&(n.head.comment+=String.fromCharCode(B))}while(B&&d<a);if(512&n.flags&&4&n.wrap&&(n.check=qO(n.check,r,d,A)),a-=d,A+=d,B)break t}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;c<16;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(4&n.wrap&&l!==(65535&n.check)){t.msg="header crc mismatch",n.mode=WN;break}l=0,c=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=NN;break;case 16189:for(;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}t.adler=n.check=VN(l),l=0,c=0,n.mode=PN;case PN:if(0===n.havedict)return t.next_out=s,t.avail_out=o,t.next_in=A,t.avail_in=a,n.hold=l,n.bits=c,LN;t.adler=n.check=1,n.mode=NN;case NN:if(e===xN||e===EN)break t;case TN:if(n.last){l>>>=7&c,c-=7&c,n.mode=jN;break}for(;c<3;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}switch(n.last=1&l,l>>>=1,c-=1,3&l){case 0:n.mode=16193;break;case 1:if(tT(n),n.mode=RN,e===EN){l>>>=2,c-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=WN}l>>>=2,c-=2;break;case 16193:for(l>>>=7&c,c-=7&c;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if((65535&l)!=(l>>>16^65535)){t.msg="invalid stored block lengths",n.mode=WN;break}if(n.length=65535&l,l=0,c=0,n.mode=DN,e===EN)break t;case DN:n.mode=16195;case 16195:if(d=n.length,d){if(d>a&&(d=a),d>o&&(d=o),0===d)break t;i.set(r.subarray(A,A+d),s),a-=d,A+=d,o-=d,s+=d,n.length-=d;break}n.mode=NN;break;case 16196:for(;c<14;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(n.nlen=257+(31&l),l>>>=5,c-=5,n.ndist=1+(31&l),l>>>=5,c-=5,n.ncode=4+(15&l),l>>>=4,c-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=WN;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;c<3;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.lens[F[n.have++]]=7&l,l>>>=3,c-=3}for(;n.have<19;)n.lens[F[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},_=_N(0,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid code lengths set",n.mode=WN;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;C=n.lencode[l&(1<<n.lenbits)-1],g=C>>>24,m=C>>>16&255,w=65535&C,!(g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(w<16)l>>>=g,c-=g,n.lens[n.have++]=w;else{if(16===w){for(S=g+2;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(l>>>=g,c-=g,0===n.have){t.msg="invalid bit length repeat",n.mode=WN;break}B=n.lens[n.have-1],d=3+(3&l),l>>>=2,c-=2}else if(17===w){for(S=g+3;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}l>>>=g,c-=g,B=0,d=3+(7&l),l>>>=3,c-=3}else{for(S=g+7;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}l>>>=g,c-=g,B=0,d=11+(127&l),l>>>=7,c-=7}if(n.have+d>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=WN;break}for(;d--;)n.lens[n.have++]=B}}if(n.mode===WN)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=WN;break}if(n.lenbits=9,E={bits:n.lenbits},_=_N(1,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid literal/lengths set",n.mode=WN;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},_=_N(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,_){t.msg="invalid distances set",n.mode=WN;break}if(n.mode=RN,e===EN)break t;case RN:n.mode=HN;case HN:if(a>=6&&o>=258){t.next_out=s,t.avail_out=o,t.next_in=A,t.avail_in=a,n.hold=l,n.bits=c,mN(t,u),s=t.next_out,i=t.output,o=t.avail_out,A=t.next_in,r=t.input,a=t.avail_in,l=n.hold,c=n.bits,n.mode===NN&&(n.back=-1);break}for(n.back=0;C=n.lencode[l&(1<<n.lenbits)-1],g=C>>>24,m=C>>>16&255,w=65535&C,!(g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(m&&!(240&m)){for(v=g,y=m,b=w;C=n.lencode[b+((l&(1<<v+y)-1)>>v)],g=C>>>24,m=C>>>16&255,w=65535&C,!(v+g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}l>>>=v,c-=v,n.back+=v}if(l>>>=g,c-=g,n.back+=g,n.length=w,0===m){n.mode=16205;break}if(32&m){n.back=-1,n.mode=NN;break}if(64&m){t.msg="invalid literal/length code",n.mode=WN;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(S=n.extra;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,c-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;C=n.distcode[l&(1<<n.distbits)-1],g=C>>>24,m=C>>>16&255,w=65535&C,!(g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(!(240&m)){for(v=g,y=m,b=w;C=n.distcode[b+((l&(1<<v+y)-1)>>v)],g=C>>>24,m=C>>>16&255,w=65535&C,!(v+g<=c);){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}l>>>=v,c-=v,n.back+=v}if(l>>>=g,c-=g,n.back+=g,64&m){t.msg="invalid distance code",n.mode=WN;break}n.offset=w,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(S=n.extra;c<S;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,c-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=WN;break}n.mode=16204;case 16204:if(0===o)break t;if(d=u-o,n.offset>d){if(d=n.offset-d,d>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=WN;break}d>n.wnext?(d-=n.wnext,f=n.wsize-d):f=n.wnext-d,d>n.length&&(d=n.length),p=n.window}else p=i,f=s-n.offset,d=n.length;d>o&&(d=o),o-=d,n.length-=d;do{i[s++]=p[f++]}while(--d);0===n.length&&(n.mode=HN);break;case 16205:if(0===o)break t;i[s++]=n.length,o--,n.mode=HN;break;case jN:if(n.wrap){for(;c<32;){if(0===a)break t;a--,l|=r[A++]<<c,c+=8}if(u-=o,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?qO(n.check,i,u,s-u):GO(n.check,i,u,s-u)),u=o,4&n.wrap&&(n.flags?l:VN(l))!==n.check){t.msg="incorrect data check",n.mode=WN;break}l=0,c=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}if(4&n.wrap&&l!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=WN;break}l=0,c=0}n.mode=16208;case 16208:_=FN;break t;case WN:_=IN;break t;case 16210:return QN;default:return UN}return t.next_out=s,t.avail_out=o,t.next_in=A,t.avail_in=a,n.hold=l,n.bits=c,(n.wsize||u!==t.avail_out&&n.mode<WN&&(n.mode<jN||e!==CN))&&eT(t,t.output,t.next_out,u-t.avail_out),h-=t.avail_in,u-=t.avail_out,t.total_in+=h,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?qO(n.check,i,u,t.next_out-u):GO(n.check,i,u,t.next_out-u)),t.data_type=n.bits+(n.last?64:0)+(n.mode===NN?128:0)+(n.mode===RN||n.mode===DN?256:0),(0===h&&0===u||e===CN)&&_===SN&&(_=kN),_},inflateEnd:t=>{if(GN(t))return UN;let e=t.state;return e.window&&(e.window=null),t.state=null,SN},inflateGetHeader:(t,e)=>{if(GN(t))return UN;const n=t.state;return 2&n.wrap?(n.head=e,e.done=!1,SN):UN},inflateSetDictionary:(t,e)=>{const n=e.length;let r,i,A;return GN(t)?UN:(r=t.state,0!==r.wrap&&r.mode!==PN?UN:r.mode===PN&&(i=1,i=GO(i,e,n,0),i!==r.check)?IN:(A=eT(t,e,n,n),A?(r.mode=16210,QN):(r.havedict=1,SN)))},inflateInfo:"pako inflate (from Nodeca project)"};var rT=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const iT=Object.prototype.toString,{Z_NO_FLUSH:AT,Z_FINISH:sT,Z_OK:aT,Z_STREAM_END:oT,Z_NEED_DICT:lT,Z_STREAM_ERROR:cT,Z_DATA_ERROR:hT,Z_MEM_ERROR:uT}=YO;function dT(t){this.options=XP({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new nN,this.strm.avail_out=0;let n=nT.inflateInit2(this.strm,e.windowBits);if(n!==aT)throw new Error(XO[n]);if(this.header=new rT,nT.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=ZP(e.dictionary):"[object ArrayBuffer]"===iT.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=nT.inflateSetDictionary(this.strm,e.dictionary),n!==aT)))throw new Error(XO[n])}function fT(t,e){const n=new dT(e);if(n.push(t),n.err)throw n.msg||XO[n.err];return n.result}dT.prototype.push=function(t,e){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let A,s,a;if(this.ended)return!1;for(s=e===~~e?e:!0===e?sT:AT,"[object ArrayBuffer]"===iT.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),A=nT.inflate(n,s),A===lT&&i&&(A=nT.inflateSetDictionary(n,i),A===aT?A=nT.inflate(n,s):A===hT&&(A=lT));n.avail_in>0&&A===oT&&n.state.wrap>0&&0!==t[n.next_in];)nT.inflateReset(n),A=nT.inflate(n,s);switch(A){case cT:case hT:case lT:case uT:return this.onEnd(A),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||A===oT))if("string"===this.options.to){let t=eN(n.output,n.next_out),e=n.next_out-t,i=tN(n.output,t);n.next_out=e,n.avail_out=r-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(i)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(A!==aT||0!==a){if(A===oT)return A=nT.inflateEnd(this.strm),this.onEnd(A),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},dT.prototype.onData=function(t){this.chunks.push(t)},dT.prototype.onEnd=function(t){t===aT&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=YP(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var pT={Inflate:dT,inflate:fT,inflateRaw:function(t,e){return(e=e||{}).raw=!0,fT(t,e)},ungzip:fT};const{Deflate:gT,deflate:mT,deflateRaw:wT,gzip:vT}=pN,{Inflate:yT,inflate:bT,inflateRaw:BT,ungzip:_T}=pT;var CT={Deflate:gT,deflate:mT,deflateRaw:wT,gzip:vT,Inflate:yT,inflate:bT,inflateRaw:BT,ungzip:_T,constants:YO};tk.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/5.4.54/pdf.worker.min.mjs";const xT=(t,...e)=>Wc(this,[t,...e],function*(t,e={}){const{scale:n=1.5,format:r="image/png"}=e;try{let e;if(t instanceof ArrayBuffer)e=t;else{if(!Buffer.isBuffer(t))throw new Error("Formato de PDF inválido");e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const i=Qk(e),A=yield i.promise,s=A.numPages,a=[];console.log(`🔄 Convertendo PDF para imagens: ${s} páginas`);for(let t=1;t<=s;t++){const e=yield A.getPage(t),i=e.getViewport({scale:n}),o=document.createElement("canvas"),l=o.getContext("2d");o.height=i.height,o.width=i.width,yield e.render({canvasContext:l,viewport:i}).promise,a.push(o.toDataURL(r)),console.log(`✅ Página ${t}/${s} convertida`)}return a}catch(o3){throw console.error("❌ Erro ao converter PDF para imagens:",o3),o3}}),ET=()=>Wc(this,null,function*(){try{return 200===(yield e.get("http://localhost:9999/health",{timeout:3e3})).status}catch(o3){return console.log("🖨️ Impressora não detectada:",o3.message),!1}}),ST=(t,...n)=>Wc(this,[t,...n],function*(t,n={}){try{const r={images:t,metadata:Qc({timestamp:(new Date).toISOString()},n)},i=JSON.stringify(r),A=CT.gzip(i);console.log(`🖨️ Enviando ${t.length} imagens para impressão...`);const s=yield e.post("http://localhost:9999/print/multiple/png-to-zpl",A,{headers:{"Content-Type":"application/gzip","Content-Encoding":"gzip"},timeout:3e4});return console.log("✅ Etiquetas enviadas para impressão com sucesso"),{success:!0,printed:!0,response:s.data,message:"Etiquetas enviadas para impressão com sucesso"}}catch(o3){throw console.error("❌ Erro ao enviar para impressão:",o3),o3}}),FT=(t,e="etiqueta.pdf")=>Wc(this,null,function*(){try{return yield Yc(t,e),console.log("📥 PDF baixado automaticamente:",e),{success:!0,downloaded:!0,fileName:e,message:"PDF baixado automaticamente - nenhuma impressora detectada"}}catch(o3){throw console.error("❌ Erro ao baixar PDF:",o3),o3}}),LT=(t,...e)=>Wc(this,[t,...e],function*(t,e={}){try{const{filename:r="etiqueta.pdf",metadata:i={},scale:A=1.5,autoDownloadOnError:s=!0}=e;console.log("🖨️ Iniciando processo de impressão...");if(!(yield ET()))return console.log("🖨️ Nenhuma impressora detectada. Baixando PDF automaticamente..."),yield FT(t,r);try{const e=yield xT(t,{scale:A});return yield ST(e,i)}catch(n){if(console.error("❌ Erro na conversão ou impressão:",n),s)return console.log("📥 Fazendo download do PDF como alternativa..."),kc(Qc({},yield FT(t,r)),{error:n.message,message:"Falha na impressão - PDF baixado como alternativa"});throw n}}catch(o3){return console.error("❌ Erro geral no processo de impressão:",o3),{success:!1,error:o3.message,message:"Falha no processo de impressão"}}});let UT,IT,QT;const kT=()=>{if(!Gc)throw new Error("Este módulo funciona apenas no browser");const t=Xc();UT=t.window,IT=t.document,UT.Image,QT=UT.btoa,UT.XMLSerializer;let e=IT.getElementById("label-container");e||(e=IT.createElement("div"),e.id="label-container",e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",IT.body.appendChild(e))};Gc&&kT();const MT={NO_MATERIAL:"black",MATERIAL_NOT_MATCHED:"#FF0000",MATERIAL_MATCHED:"#0f45d8"};function OT(t,e){for(var n in t=IT.createElementNS("http://www.w3.org/2000/svg",t),e)t.setAttributeNS(null,n.replace(/[A-Z]/g,function(t,e,n,r){return"-"+t.toLowerCase()}),e[n]);return t}const PT=(t,e)=>{const n={w:e.width/t.width,h:e.height/t.height};return{get ratio(){return n.w<n.h?n.w:n.h}}},NT=(t,e,n,r,i,A,s,a,o)=>{t.setLineWidth(.5),TT(t,e,n,e,i+n,A),TT(t,e+r,n,e+r,i+n,s),TT(t,e,n,e+r,n,o),TT(t,e,n+i,e+r,n+i,a)},TT=(t,e,n,r,i,A)=>{A&&(t.setDrawColor(A),t.line(e,n,r,i))},DT=(t,e)=>t&&"0"!==t?t===e?MT.MATERIAL_MATCHED:MT.MATERIAL_NOT_MATCHED:MT.NO_MATERIAL,RT=e.create({baseURL:"https://db33.dev.dinabox.net/api",timeout:1e4,headers:{"Content-Type":"application/json",Accept:"application/json"}}),HT={PART:"part",SCRAP:"scrap",THICKENED:"thickened",INPUT:"input",VOLUME:"volume"};RT.interceptors.response.use(t=>t,t=>{var e;return console.error("Erro na API:",(null==(e=t.response)?void 0:e.data)||t.message),Promise.reject(t)});class jT{static getLabels(){return Wc(this,arguments,function*(t={}){try{return(yield RT.get("/v1/labels",{params:t})).data}catch(o3){throw new Error(`Erro ao buscar etiquetas: ${o3.message}`)}})}static getLabelsByPage(){return Wc(this,arguments,function*(t=1,e={}){return this.getLabels(Qc({p:t},e))})}static searchLabels(t){return Wc(this,arguments,function*(t,e={}){return this.getLabels(Qc({s:t},e))})}static getLabelsByType(t){return Wc(this,arguments,function*(t,e={}){return this.validateLabelType(t,!0),this.getLabels(Qc({label_type:t},e))})}static getLabel(t){return Wc(this,null,function*(){try{const e=yield RT.get("/v1/label",{params:{label_id:t}});return e.data&&e.data.labels&&e.data.labels.length&&e.data.labels.filter(e=>e.label_id==t)[0]||null}catch(o3){throw new Error(`Erro ao buscar etiqueta ${t}: ${o3.message}`)}})}static createLabel(t){return Wc(this,null,function*(){try{t.label_type&&this.validateLabelType(t.label_type,!0);return(yield RT.post("/v1/label",t)).data}catch(o3){throw new Error(`Erro ao criar etiqueta: ${o3.message}`)}})}static validateLabelType(t,e=!1){const n=Object.values(HT).includes(t);if(!n&&e)throw new Error(`Tipo de etiqueta inválido: "${t}" não é um de part, scrap, thickened, input e volume.`);return n}static labelByType(t){return this.validateLabelType(t,!0),t}static updateLabel(t,e){return Wc(this,null,function*(){try{e.label_type&&this.validateLabelType(e.label_type,!0);return(yield RT.post("/v1/label",Qc({label_id:t},e))).data}catch(o3){throw new Error(`Erro ao atualizar etiqueta ${t}: ${o3.message}`)}})}static deleteLabel(t){return Wc(this,null,function*(){try{return(yield RT.delete("/v1/label",{params:{label_id:t}})).data}catch(o3){throw new Error(`Erro ao deletar etiqueta ${t}: ${o3.message}`)}})}static setAuthToken(t){RT.defaults.headers.common.Authorization=`${t}`}static removeAuthToken(){delete RT.defaults.headers.common.Authorization}static setBaseURL(t){RT.defaults.baseURL=t}}const WT=TL((t,e)=>Qc(Qc({},(t=>({printerStatus:{name:"Aguardando...",connected:!1,status:"disconnected",hasDefaultPrinter:!1,message:"Conectando ao servidor...",printer:null},setPrinterStatus:e=>t(()=>({printerStatus:e})),updatePrinterStatus:e=>t(t=>({printerStatus:Qc(Qc({},t.printerStatus),e)}))}))(t)),((t,e)=>({sseConnected:!1,eventSource:null,setSseConnected:e=>t(()=>({sseConnected:e})),setEventSource:e=>t(()=>({eventSource:e})),connectToSSE:()=>{const{eventSource:t,setSseConnected:n,updatePrinterStatus:r,setEventSource:i}=e();if("undefined"==typeof EventSource)return console.log("EventSource não disponível em ambiente Node.js"),n(!1),void r({connected:!1,status:"disconnected"});t&&t.close();try{const t=new EventSource("http://localhost:9999/printer/status/stream");i(t),t.onopen=()=>{console.log("Conexão SSE estabelecida com a impressora"),n(!0),r({status:"connecting"})},t.addEventListener("printer-status",t=>{var e;try{const n=JSON.parse(t.data);console.log("message =>>>>>>>>>",n);let i="disconnected",A="Nenhuma impressora";n.hasDefaultPrinter?n.isConnected&&n.printer?(i="connected",A=n.printer.name||"Impressora"):(i="disconnected",A=(null==(e=n.printer)?void 0:e.name)||"Impressora"):(i="no-printer",A="Sem impressora configurada"),r({name:A,connected:n.isConnected||!1,status:i,hasDefaultPrinter:n.hasDefaultPrinter||!1,message:n.message||"",printer:n.printer||null})}catch(o3){console.warn("Erro ao processar dados da impressora:",o3)}}),t.onerror=A=>{console.error("Erro na conexão SSE:",A),n(!1),r({connected:!1,status:"disconnected"}),t.close(),i(null),setTimeout(()=>{e().connectToSSE()},5e3)}}catch(o3){console.error("Erro ao conectar SSE:",o3),n(!1),r({connected:!1,status:"disconnected"})}},disconnectSSE:()=>{const{eventSource:t,setSseConnected:n,setEventSource:r}=e();t&&(t.close(),r(null)),n(!1)}}))(t,e))),VT=(t,e)=>{if(!t||"object"!=typeof t)return t;const n=Qc({},t);for(const[r,i]of Object.entries(e)){switch(typeof i){case"string":void 0!==t[i]&&(n[r]=t[i]);break;case"object":if(Array.isArray(i)){const e=t[r.toLowerCase()];"number"==typeof e&&e>=0&&e<i.length&&(n[r]=i[e])}break;case"function":const e=i(t);void 0!==e&&(n[r]=e)}}return n},KT=t=>{if(!t||"object"!=typeof t)return!1;for(const[e,n]of Object.entries(t)){const t=typeof n;if("string"!==t&&"function"!==t&&!Array.isArray(n))return console.warn(`⚠️ FieldMap inválido: campo '${e}' deve ser string, array ou function`),!1}return!0},GT={PROJETO_ID:"project_id",PROJETO_NOME:"project_description",PROJETO_OBS:"project_note",CLIENTE_ID:"project_customer_id",CLIENTE_NOME:"project_customer_name",PECA_ID:"id",PECA_CODIGO:"pid",PECA_REF:["pref","ref"],MODULO_REF:"mref",MODULO_QTD:["mqt","module_quantity"],PECA_INDICE:"index",PECA_INDICE2:"number",PECA_NOME:"name",PECA_OBS:"note",LARGURA:"width",ALTURA:"height",ESPESSURA:"thickness",MN:["materialName","material","material_name"],MA:"material_height",ML:"material_width",FURO_A:"code_a",FURO_B:"code_b",FE:"edge_left",FD:"edge_right",FS:"edge_top",FI:"edge_bottom",PECA_TIPO:"type",MODULO_NOME:"mname",MODULO_OBS:"mnote",LOTE_ID:["group_id","groupId"],DATA_CRIACAO:["date","created_at"],LADO_USINAGEM:"machining_side",INSUMO_QTD:"qt",INSUMO_PESO:"weight",INSUMO_DIMENSOES:"dimensions",INSUMO_MARCA:"manufacturer",VOLUME_ID:"volume_id",VOLUME_NOME:"volume_name",SCRAP_ID:"scrapId",FURO_A2:"code_a2",FURO_B2:"code_b2",MATERIAL_NOME:["materialName","material","material_name"],TAMPONAMENTO_ID:"id",TAMPONAMENTO_REF:["pref","ref"],TAMPONAMENTO_QT:"qt",TAMPONAMENTO_PESO:"weight",TAMPONAMENTO_NOME:"name",INSUMO_NOME:"name",INSUMO_ID:"id",INSUMO_REF:["pref","ref"],INSUMO_CATEGORIA:"category",INSUMO_FABRICANTE:"manufacturer",RETALHO_ID:"scrapId",RETALHO_INDICE:"index",RETALHO_NOME:"name",RETALHO_QT:"qt",RETALHO_PESO:"weight",RETALHO_DIMENSOES:"dimensions",RETALHO_MATERIAL:["materialName","material","material_name"],RETALHO_ORIGEM:"origin",CODIGO_A:"code_a",CODIGO_B:"code_b",FURO_A_SD:"hole_a_sd",FURO_B_SD:"hole_b_sd",FURO_TOPO:"hole_top",VOLUME_PESO:"weight",VOLUME_DATA:["date","created_at"],VOLUME_DESCRICAO:"description",VOLUME_PECAS:"itemList",VOLUME_DIMENSOES:"dimensions",FURO_A_SD:t=>t.code_a?"0"+t.code_a.slice(1):null,FURO_B_SD:t=>t.code_b?"0"+t.code_b.slice(1):null};new JE;let zT={printerName:null,paperSize:"A4",orientation:"portrait",defaultTemplate:"template-padrao",autoDownloadOnPrinterError:!0,defaultTransformer:{fieldMap:"legacy",fieldMapSource:null}};function qT(t){return Array.isArray(t)?t.map(t=>t&&(t.variableProps||t.specialProps)?Qc(Qc({},t.variableProps||{}),t.specialProps||{}):t||{}):t&&(t.variableProps||t.specialProps)?[Qc(Qc({},t.variableProps),t.specialProps)]:[t]}const XT=(t={})=>{if(t.defaultTransformer){const{fieldMap:e,fieldMapSource:n}=t.defaultTransformer;if(!["legacy","custom","none"].includes(e))throw new Error(`defaultTransformer.fieldMap inválido: "${e}". Use "legacy", "custom" ou "none"`);if("custom"===e&&!n)throw new Error('defaultTransformer.fieldMapSource é obrigatório quando fieldMap="custom"');if("custom"===e&&!KT(n))throw new Error("defaultTransformer.fieldMapSource inválido")}const e=Qc({autoConnectPrinter:!0},t);var n;if(zT=Qc(Qc({},zT),e),e.token&&(console.log("🔑 Atualizando token da API",token),(n=e.token)?(RT.defaults.headers.common.Authorization=`${n}`,console.log("🔑 Token de API atualizado")):console.warn("⚠️ Token não fornecido")),e.autoConnectPrinter)try{$T(),console.log("🖨️ Auto-conectando ao SSE da impressora...")}catch(o3){console.warn("⚠️ Falha na auto-conexão do SSE da impressora:",o3.message)}return console.log("🏷️ Etiquetas.js initialized successfully"),console.log("🔄 Default transformer:",zT.defaultTransformer.fieldMap),console.log("🖨️ Auto-connect printer:",e.autoConnectPrinter),zT},YT=()=>Wc(this,null,function*(){try{const t=WT.getState(),{printerStatus:e,sseConnected:n}=t;return{connected:e.connected,printerName:e.name,status:e.status,hasDefaultPrinter:e.hasDefaultPrinter,message:e.message,printer:e.printer,sseConnected:n,paperSize:zT.paperSize,orientation:zT.orientation,globalPrinterName:zT.printerName}}catch(o3){return{connected:!1,error:o3.message,status:"error",printerName:"Erro ao obter status",hasDefaultPrinter:!1,message:`Erro: ${o3.message}`,printer:null,sseConnected:!1,paperSize:zT.paperSize,orientation:zT.orientation}}}),$T=()=>{try{WT.getState().connectToSSE(),console.log("🔌 Conectando ao SSE da impressora...")}catch(o3){console.error("❌ Erro ao conectar SSE da impressora:",o3)}};function JT(t,e){const n=[];return e||n.push("Conecte ao servidor de impressão (SSE)"),t.hasDefaultPrinter||n.push("Configure uma impressora padrão no sistema"),!t.connected&&t.hasDefaultPrinter&&n.push("Verifique se a impressora está ligada e conectada"),"no-printer"===t.status&&n.push("Instale e configure uma impressora no sistema"),n}const ZT=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF();let i,A=t,s=!1;if(n.transformer?i=n.transformer:n.useLegacyTransformer?(console.warn("⚠️ useLegacyTransformer está deprecated. Use options.transformer ao invés."),i={fieldMap:"legacy",fieldMapSource:n.customFieldMap}):i=zT.defaultTransformer,i&&"none"!==i.fieldMap){const{fieldMap:e,fieldMapSource:r}=i;let a;switch(e){case"legacy":a=GT,console.log("🔄 Using legacy transformer");break;case"custom":if(!r)throw new Error('fieldMapSource é obrigatório quando fieldMap="custom"');if(!KT(r))throw new Error("fieldMapSource inválido");a=r,console.log("🔄 Using custom transformer");break;default:throw new Error(`fieldMap inválido: "${e}". Use "legacy", "custom" ou "none"`)}A=((t,e,n={})=>{const{validateMap:r=!0,throwOnError:i=!1,logErrors:A=!0}=n;try{if(r&&!KT(e)){const e=new Error("FieldMap inválido");if(i)throw e;return A&&console.error("❌",e.message),t}return Array.isArray(t)?t.map(t=>VT(t,e)):VT(t,e)}catch(o3){if(A&&console.error("❌ Erro ao aplicar transformações:",o3.message),i)throw o3;return t}})(t,a,{validateMap:!0,throwOnError:!0,logErrors:!0}),s=!0,n.transformer?console.log("✅ Transformer applied from options"):n.useLegacyTransformer?console.log("🔄 Legacy transformer applied (deprecated API)"):console.log("✅ Default transformer applied from init config")}else console.log("🚫 Transformer disabled");const a=Qc({dataSource:A,labels:yield oD(e),userPrefs:zT,cacheKey:`label-${Date.now()}`},n),o=yield r.generateLabels(a);if(console.log("✅ Label generated successfully"),Array.isArray(o)){const[t,e,n]=o;return n&&n.output?n.output("arraybuffer"):t}return o}catch(o3){throw console.error("❌ Error generating label:",o3),o3}}),tD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{let r=!1,i=null;if(n.transformer)r=!0,i=n.transformer.fieldMap;else if(n.useLegacyTransformer)r=!0,i="legacy (deprecated)";else{const t=zT.defaultTransformer;t&&"none"!==t.fieldMap?(r=!0,i=`${t.fieldMap} (default from init)`):(r=!1,i="none (disabled in init)")}const A=yield ZT(t,e,n),s=n.fileName||`label-${Date.now()}.pdf`;console.log("📄 PDF gerado:",A);const a=yield aD(A,Qc({filename:s,metadata:{type:"unified",labelId:e,timestamp:(new Date).toISOString(),usedTransformer:r,transformerType:i}},n));return a&&"object"==typeof a&&(a.usedTransformer=r,a.transformerType=i),a}catch(o3){throw console.error("❌ Error in smart label sending:",o3),o3}}),eD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>{return kc(Qc({},e=t),{type:e.type||"cabinet",PROJETO_ID:e.project_id,PROJETO_NOME:e.project_description,CLIENTE_NOME:e.project_customer_name,PECA_ID:e.id,PECA_CODIGO:e.ref||e.pref,PECA_NOME:e.name,PECA_INDICE:e.index||e.number,PECA_NOTA:e.note,LARGURA:e.width,ALTURA:e.height,ESPESSURA:e.thickness,MN:e.material_name,FE:e.edge_left,FD:e.edge_right,FS:e.edge_top,FI:e.edge_bottom,MODULO_REF:e.mref,MODULO_NOME:e.mname,MODULO_NOTA:e.mnote,CODIGO_A:e.code_a,CODIGO_B:e.code_b,material_name:e.material_name,material_width:e.material_width,material_height:e.material_height,edge_left:e.edge_left,edge_right:e.edge_right,edge_top:e.edge_top,edge_bottom:e.edge_bottom,code_a:e.code_a,code_b:e.code_b,code_a2:e.code_a2,code_b2:e.code_b2,machining_side:e.machining_side,project_id:e.project_id,project_description:e.project_description,project_customer_name:e.project_customer_name,project_customer_id:e.project_customer_id,project_note:e.project_note,rotated:e.rotated||!1,holes:e.holes||[]});var e}),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`part-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Part label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating part label:",o3),o3}}),nD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>{return e=t,console.log("=>>",e),Qc({},e);var e}),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`thickening-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Thickening label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating thickening label:",o3),o3}}),rD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>{return kc(Qc({},e=t),{type:"input",INSUMO_ID:e.id,INSUMO_NOME:e.name,INSUMO_DIMENSOES:e.dimensions,INSUMO_QT:e.qt||e.quantity||1,INSUMO_PESO:e.weight||"0.00",INSUMO_REF:e.ref,INSUMO_FABRICANTE:e.manufacturer,INSUMO_CATEGORIA:e.category_name,INSUMO_MATERIAL:e.material,INSUMO_DESCRICAO:e.description,PROJETO_ID:e.project_id,PROJETO_NOME:e.project_description,CLIENTE_NOME:e.project_customer_name,MODULO_REF:e.mref,MODULO_NOME:e.mname,MODULO_NOTA:e.mnote,mref:e.mref,mname:e.mname,mnote:e.mnote,project_customer_id:e.project_customer_id,project_note:e.project_note});var e}),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`input-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Input label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating input label:",o3),o3}}),iD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>{return kc(Qc({},e=t),{type:"scrap",RETALHO_ID:e.scrapId||e.id,RETALHO_NOME:e.name,RETALHO_REF:e.ref,RETALHO_QT:e.qt||e.quantity||1,RETALHO_PESO:e.weight||"0.00",RETALHO_DIMENSOES:e.dimensions||`${e.width||0}x${e.height||0}`,RETALHO_MATERIAL:e.material,RETALHO_ORIGEM:e.origin,PROJETO_ID:e.project_id,PROJETO_NOME:e.project_description,CLIENTE_NOME:e.project_customer_name,MODULO_REF:e.mref,MODULO_NOME:e.mname,MODULO_NOTA:e.mnote,mref:e.mref,mname:e.mname,mnote:e.mnote,project_customer_id:e.project_customer_id,project_note:e.project_note});var e}),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`scrap-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Scrap label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating scrap label:",o3),o3}}),AD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=qT(t).map(t=>(t=>{const e=t.parts&&Array.isArray(t.parts);return kc(Qc({},t),{type:"volume",VOLUME_ID:t.volume_id||t.id,VOLUME_NOME:t.volume_name||t.name,VOLUME_PESO:t.volume_weight||t.weight||"0.00",VOLUME_DATA:t.volume_date||t.date||(new Date).toLocaleDateString("pt-BR"),VOLUME_DESCRICAO:t.volume_description||t.note||"",VOLUME_PECAS:t.volume_parts_count||(e?t.parts.length:0)||(t.itemList?t.itemList.length:0),VOLUME_DIMENSOES:t.volume_dimensions||"",PROJETO_ID:t.project_id,PROJETO_NOME:t.project_description,CLIENTE_NOME:t.project_customer_name,VOLUME_NAME:t.volume_name||t.name,PROJECT_NAME:t.project_description,CUSTOMER_NAME:t.project_customer_name,volume_id:t.volume_id||t.id,volume_name:t.volume_name||t.name,project_customer_id:t.project_customer_id,project_note:t.project_note,parts:t.parts||[],itemList:t.itemList||[],inputs:t.inputs||[]})})(t)),A=Qc({dataSource:i,labels:yield oD(e),userPrefs:zT,cacheKey:`volume-${Date.now()}`},n),s=yield r.generateLabels(A);if(console.log("✅ Volume label generated"),Array.isArray(s)){const[t,e,n]=s;return n&&n.output?n.output("arraybuffer"):t}return s}catch(o3){throw console.error("❌ Error generating volume label:",o3),o3}}),sD=(t,e="etiqueta.pdf")=>Wc(this,null,function*(){try{if("undefined"==typeof window)return console.log("📁 PDF generated for download:",e),t;{const n=new Blob([t],{type:"application/pdf"}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}console.log("📥 Download completed:",e)}catch(o3){throw console.error("❌ Download error:",o3),o3}}),aD=(t,...e)=>Wc(this,[t,...e],function*(t,e={}){try{const n=WT.getState(),{printerStatus:r}=n,i={filename:e.filename||"etiqueta.pdf",metadata:Qc({printerName:r.name,printerConnected:r.connected,printerStatus:r.status,hasDefaultPrinter:r.hasDefaultPrinter,globalPrinterName:zT.printerName,paperSize:zT.paperSize,orientation:zT.orientation},e.metadata),scale:e.scale||1.5,autoDownloadOnError:!1!==zT.autoDownloadOnPrinterError};console.log("🖨️ Enviando PDF para impressão via printer worker..."),console.log("📊 Status da impressora:",{name:r.name,connected:r.connected,status:r.status,hasDefaultPrinter:r.hasDefaultPrinter});const A=yield LT(t,i);return A.success&&A.printed&&(A.printerName=r.name,A.printerConnected=r.connected,A.printerStatus=r.status,A.timestamp=(new Date).toISOString()),A}catch(o3){if(console.error("❌ Print error:",o3),zT.autoDownloadOnPrinterError)try{return console.log("📥 Tentando download como alternativa..."),yield sD(t,e.filename||"etiqueta.pdf"),{success:!0,downloaded:!0,fileName:e.filename||"etiqueta.pdf",message:"Falha na impressão - PDF baixado como alternativa",error:o3.message,printerError:!0}}catch(n){console.error("❌ Erro também no download:",n)}throw o3}}),oD=t=>Wc(this,null,function*(){try{const e=yield function(t){return Wc(this,null,function*(){try{const e=yield jT.getLabel(t);if(!e)throw new Error(`Template/etiqueta não encontrado com ID: ${t}`);return console.log("templateContent:",e),JSON.parse(e.label_content)}catch(o3){throw console.error(`Erro ao buscar template: ${o3.message}`),o3}})}(t);return e||(console.warn(`Template ${t} not found, using default template`),[{pageWidth:800,pageHeight:50,pageHorizontalSpace:0,pageVerticalSpace:0,pageMarginLeft:0,pageMarginTop:0,pageLines:1,pageColumns:1,pageShowBorder:!1,left:0,top:0,width:100,height:50}])}catch(o3){return console.error("❌ Error loading template:",o3),[{pageWidth:210,pageHeight:297,pageHorizontalSpace:0,pageVerticalSpace:0,pageMarginLeft:10,pageMarginTop:10,pageLines:1,pageColumns:1,pageShowBorder:!1,left:0,top:0,width:190,height:277}]}}),lD=(t,e)=>{if(!t||"object"!=typeof t)return console.error("❌ Invalid data: must be an object"),!1;switch(e){case"parts":return t.partId&&t.partName;case"thickening":return t.tamponamentoId&&t.material;case"inputs":return t.insumoId&&t.description;case"scraps":return t.scrapId&&t.material;case"volumes":return t.volume_id&&t.parts;default:return console.error(`❌ Unsupported label type: ${e}`),!1}},cD={init:XT,getPrinterStatus:YT,isPrinterReady:()=>Wc(this,null,function*(){try{const t=WT.getState(),{printerStatus:e,sseConnected:n}=t,r=e.connected&&e.hasDefaultPrinter&&"connected"===e.status;return{ready:r,connected:e.connected,hasDefaultPrinter:e.hasDefaultPrinter,status:e.status,printerName:e.name,sseConnected:n,message:r?"Impressora pronta para uso":e.message||"Impressora não está pronta",recommendations:r?[]:JT(e,n)}}catch(o3){return{ready:!1,error:o3.message,message:"Erro ao verificar status da impressora",recommendations:["Verifique a conexão com o servidor de impressão"]}}}),makeLabel:ZT,sendLabel:tD,makePartLabel:eD,makeThickeningLabel:nD,makeInputLabel:rD,makeScrapLabel:iD,makeVolumeLabel:AD,downloadPDF:sD,sendToPrinter:aD,sendPartLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield eD(t,e,n),i=`part-${t.codigo||t.id}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"part",partId:t.id,partName:t.nome||t.name}},n))}catch(o3){throw console.error("❌ Error in smart part sending:",o3),o3}}),sendTamponamentoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield nD(t,e,n),i=`thickening-${t.id}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"thickening",tamponamentoId:t.id,material:t.material}},n))}catch(o3){throw console.error("❌ Error in smart thickening sending:",o3),o3}}),sendInsumoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield rD(t,e,n),i=`input-${t.id}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"input",insumoId:t.id,description:t.description}},n))}catch(o3){throw console.error("❌ Error in smart input sending:",o3),o3}}),sendRetalhoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield iD(t,e,n),i=`scrap-${t.scrapId}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"scrap",scrapId:t.scrapId,material:t.material}},n))}catch(o3){throw console.error("❌ Error in smart scrap sending:",o3),o3}}),sendVolumeLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield AD(t,e,n),i=`volume-${t.volume_id}.pdf`;return yield aD(r,Qc({filename:i,metadata:{type:"volume",volumeId:t.volume_id,volumeName:t.volume_nome||t.name,partsCount:t.parts?t.parts.length:0}},n))}catch(o3){throw console.error("❌ Error in smart volume sending:",o3),o3}}),makeBatchLabels:(t,e,n="parts")=>Wc(this,null,function*(){const r=[];for(const i of t)try{let t;switch(n){case"parts":t=yield eD(i,e);break;case"thickening":t=yield nD(i,e);break;case"inputs":t=yield rD(i,e);break;case"scraps":t=yield iD(i,e);break;case"volumes":t=yield AD(i,e);break;default:throw new Error(`Unsupported label type: ${n}`)}r.push(t)}catch(o3){console.error(`❌ Error generating label for item ${i.id}:`,o3),r.push(null)}return r}),validateLabelData:lD,legacyFieldMap:GT,transformField:(t,e,n)=>{const r=n[e];if(!r)return t[e];switch(typeof r){case"string":default:return t[e];case"object":if(Array.isArray(r)){const n=t[e];return"number"==typeof n&&n>=0&&n<r.length?r[n]:null}return t[e];case"function":return r(t)}},applyTransformations:VT,legacyTransformer:t=>VT(t,GT)},hD=kc(Qc({},cD),{environment:{isBrowser:Gc,isNodeJS:!Gc,version:"1.0.0-alpha.1",bundler:"vite"}});
|
|
341
341
|
/*! @license DOMPurify 2.5.8 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.5.8/LICENSE */
|
|
342
342
|
function uD(t){return(uD="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function dD(t,e){return(dD=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function fD(t,e,n){return(fD=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(hw){return!1}}()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&dD(i,n.prototype),i}).apply(null,arguments)}function pD(t){return function(t){if(Array.isArray(t))return gD(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return gD(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gD(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function gD(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var mD=Object.hasOwnProperty,wD=Object.setPrototypeOf,vD=Object.isFrozen,yD=Object.getPrototypeOf,bD=Object.getOwnPropertyDescriptor,BD=Object.freeze,_D=Object.seal,CD=Object.create,xD="undefined"!=typeof Reflect&&Reflect,ED=xD.apply,SD=xD.construct;ED||(ED=function(t,e,n){return t.apply(e,n)}),BD||(BD=function(t){return t}),_D||(_D=function(t){return t}),SD||(SD=function(t,e){return fD(t,pD(e))});var FD,LD=RD(Array.prototype.forEach),UD=RD(Array.prototype.pop),ID=RD(Array.prototype.push),QD=RD(String.prototype.toLowerCase),kD=RD(String.prototype.toString),MD=RD(String.prototype.match),OD=RD(String.prototype.replace),PD=RD(String.prototype.indexOf),ND=RD(String.prototype.trim),TD=RD(RegExp.prototype.test),DD=(FD=TypeError,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return SD(FD,e)});function RD(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return ED(t,e,r)}}function HD(t,e,n){var r;n=null!==(r=n)&&void 0!==r?r:QD,wD&&wD(t,null);for(var i=e.length;i--;){var A=e[i];if("string"==typeof A){var s=n(A);s!==A&&(vD(e)||(e[i]=s),A=s)}t[A]=!0}return t}function jD(t){var e,n=CD(null);for(e in t)!0===ED(mD,t,[e])&&(n[e]=t[e]);return n}function WD(t,e){for(;null!==t;){var n=bD(t,e);if(n){if(n.get)return RD(n.get);if("function"==typeof n.value)return RD(n.value)}t=yD(t)}return function(t){return console.warn("fallback value for",t),null}}var VD=BD(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),KD=BD(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),GD=BD(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),zD=BD(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),qD=BD(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),XD=BD(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),YD=BD(["#text"]),$D=BD(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),JD=BD(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),ZD=BD(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),tR=BD(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),eR=_D(/\{\{[\w\W]*|[\w\W]*\}\}/gm),nR=_D(/<%[\w\W]*|[\w\W]*%>/gm),rR=_D(/\${[\w\W]*}/gm),iR=_D(/^data-[\-\w.\u00B7-\uFFFF]+$/),AR=_D(/^aria-[\-\w]+$/),sR=_D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),aR=_D(/^(?:\w+script|data):/i),oR=_D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),lR=_D(/^html$/i),cR=_D(/^[a-z][.\w]*(-[.\w]+)+$/i);var hR=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window,n=function(e){return t(e)};if(n.version="2.5.8",n.removed=[],!e||!e.document||9!==e.document.nodeType)return n.isSupported=!1,n;var r=e.document,i=e.document,A=e.DocumentFragment,s=e.HTMLTemplateElement,a=e.Node,o=e.Element,l=e.NodeFilter,c=e.NamedNodeMap,h=void 0===c?e.NamedNodeMap||e.MozNamedAttrMap:c,u=e.HTMLFormElement,d=e.DOMParser,f=e.trustedTypes,p=o.prototype,g=WD(p,"cloneNode"),m=WD(p,"nextSibling"),w=WD(p,"childNodes"),v=WD(p,"parentNode");if("function"==typeof s){var y=i.createElement("template");y.content&&y.content.ownerDocument&&(i=y.content.ownerDocument)}var b=function(t,e){if("object"!==uD(t)||"function"!=typeof t.createPolicy)return null;var n=null,r="data-tt-policy-suffix";e.currentScript&&e.currentScript.hasAttribute(r)&&(n=e.currentScript.getAttribute(r));var i="dompurify"+(n?"#"+n:"");try{return t.createPolicy(i,{createHTML:function(t){return t},createScriptURL:function(t){return t}})}catch(A){return console.warn("TrustedTypes policy "+i+" could not be created."),null}}(f,r),B=b?b.createHTML(""):"",_=i,C=_.implementation,x=_.createNodeIterator,E=_.createDocumentFragment,S=_.getElementsByTagName,F=r.importNode,L={};try{L=jD(i).documentMode?i.documentMode:{}}catch(zt){}var U={};n.isSupported="function"==typeof v&&C&&void 0!==C.createHTMLDocument&&9!==L;var I,Q,k=eR,M=nR,O=rR,P=iR,N=AR,T=aR,D=oR,R=cR,H=sR,j=null,W=HD({},[].concat(pD(VD),pD(KD),pD(GD),pD(qD),pD(YD))),V=null,K=HD({},[].concat(pD($D),pD(JD),pD(ZD),pD(tR))),G=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),z=null,q=null,X=!0,Y=!0,$=!1,J=!0,Z=!1,tt=!0,et=!1,nt=!1,rt=!1,it=!1,At=!1,st=!1,at=!0,ot=!1,lt=!0,ct=!1,ht={},ut=null,dt=HD({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ft=null,pt=HD({},["audio","video","img","source","image","track"]),gt=null,mt=HD({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),wt="http://www.w3.org/1998/Math/MathML",vt="http://www.w3.org/2000/svg",yt="http://www.w3.org/1999/xhtml",bt=yt,Bt=!1,_t=null,Ct=HD({},[wt,vt,yt],kD),xt=["application/xhtml+xml","text/html"],Et=null,St=i.createElement("form"),Ft=function(t){return t instanceof RegExp||t instanceof Function},Lt=function(t){Et&&Et===t||(t&&"object"===uD(t)||(t={}),t=jD(t),I=I=-1===xt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Q="application/xhtml+xml"===I?kD:QD,j="ALLOWED_TAGS"in t?HD({},t.ALLOWED_TAGS,Q):W,V="ALLOWED_ATTR"in t?HD({},t.ALLOWED_ATTR,Q):K,_t="ALLOWED_NAMESPACES"in t?HD({},t.ALLOWED_NAMESPACES,kD):Ct,gt="ADD_URI_SAFE_ATTR"in t?HD(jD(mt),t.ADD_URI_SAFE_ATTR,Q):mt,ft="ADD_DATA_URI_TAGS"in t?HD(jD(pt),t.ADD_DATA_URI_TAGS,Q):pt,ut="FORBID_CONTENTS"in t?HD({},t.FORBID_CONTENTS,Q):dt,z="FORBID_TAGS"in t?HD({},t.FORBID_TAGS,Q):{},q="FORBID_ATTR"in t?HD({},t.FORBID_ATTR,Q):{},ht="USE_PROFILES"in t&&t.USE_PROFILES,X=!1!==t.ALLOW_ARIA_ATTR,Y=!1!==t.ALLOW_DATA_ATTR,$=t.ALLOW_UNKNOWN_PROTOCOLS||!1,J=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Z=t.SAFE_FOR_TEMPLATES||!1,tt=!1!==t.SAFE_FOR_XML,et=t.WHOLE_DOCUMENT||!1,it=t.RETURN_DOM||!1,At=t.RETURN_DOM_FRAGMENT||!1,st=t.RETURN_TRUSTED_TYPE||!1,rt=t.FORCE_BODY||!1,at=!1!==t.SANITIZE_DOM,ot=t.SANITIZE_NAMED_PROPS||!1,lt=!1!==t.KEEP_CONTENT,ct=t.IN_PLACE||!1,H=t.ALLOWED_URI_REGEXP||H,bt=t.NAMESPACE||yt,G=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&Ft(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(G.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&Ft(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(G.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(G.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Z&&(Y=!1),At&&(it=!0),ht&&(j=HD({},pD(YD)),V=[],!0===ht.html&&(HD(j,VD),HD(V,$D)),!0===ht.svg&&(HD(j,KD),HD(V,JD),HD(V,tR)),!0===ht.svgFilters&&(HD(j,GD),HD(V,JD),HD(V,tR)),!0===ht.mathMl&&(HD(j,qD),HD(V,ZD),HD(V,tR))),t.ADD_TAGS&&(j===W&&(j=jD(j)),HD(j,t.ADD_TAGS,Q)),t.ADD_ATTR&&(V===K&&(V=jD(V)),HD(V,t.ADD_ATTR,Q)),t.ADD_URI_SAFE_ATTR&&HD(gt,t.ADD_URI_SAFE_ATTR,Q),t.FORBID_CONTENTS&&(ut===dt&&(ut=jD(ut)),HD(ut,t.FORBID_CONTENTS,Q)),lt&&(j["#text"]=!0),et&&HD(j,["html","head","body"]),j.table&&(HD(j,["tbody"]),delete z.tbody),BD&&BD(t),Et=t)},Ut=HD({},["mi","mo","mn","ms","mtext"]),It=HD({},["annotation-xml"]),Qt=HD({},["title","style","font","a","script"]),kt=HD({},KD);HD(kt,GD),HD(kt,zD);var Mt=HD({},qD);HD(Mt,XD);var Ot=function(t){ID(n.removed,{element:t});try{t.parentNode.removeChild(t)}catch(zt){try{t.outerHTML=B}catch(e){t.remove()}}},Pt=function(t,e){try{ID(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(zt){ID(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t&&!V[t])if(it||At)try{Ot(e)}catch(zt){}else try{e.setAttribute(t,"")}catch(zt){}},Nt=function(t){var e,n;if(rt)t="<remove></remove>"+t;else{var r=MD(t,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===I&&bt===yt&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");var A=b?b.createHTML(t):t;if(bt===yt)try{e=(new d).parseFromString(A,I)}catch(zt){}if(!e||!e.documentElement){e=C.createDocument(bt,"template",null);try{e.documentElement.innerHTML=Bt?B:A}catch(zt){}}var s=e.body||e.documentElement;return t&&n&&s.insertBefore(i.createTextNode(n),s.childNodes[0]||null),bt===yt?S.call(e,et?"html":"body")[0]:et?e.documentElement:s},Tt=function(t){return x.call(t.ownerDocument||t,t,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null,!1)},Dt=function(t){return t instanceof u&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof h)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},Rt=function(t){return"object"===uD(a)?t instanceof a:t&&"object"===uD(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Ht=function(t,e,r){U[t]&&LD(U[t],function(t){t.call(n,e,r,Et)})},jt=function(t){var e;if(Ht("beforeSanitizeElements",t,null),Dt(t))return Ot(t),!0;if(TD(/[\u0080-\uFFFF]/,t.nodeName))return Ot(t),!0;var r=Q(t.nodeName);if(Ht("uponSanitizeElement",t,{tagName:r,allowedTags:j}),t.hasChildNodes()&&!Rt(t.firstElementChild)&&(!Rt(t.content)||!Rt(t.content.firstElementChild))&&TD(/<[/\w]/g,t.innerHTML)&&TD(/<[/\w]/g,t.textContent))return Ot(t),!0;if("select"===r&&TD(/<template/i,t.innerHTML))return Ot(t),!0;if(7===t.nodeType)return Ot(t),!0;if(tt&&8===t.nodeType&&TD(/<[/\w]/g,t.data))return Ot(t),!0;if(!j[r]||z[r]){if(!z[r]&&Vt(r)){if(G.tagNameCheck instanceof RegExp&&TD(G.tagNameCheck,r))return!1;if(G.tagNameCheck instanceof Function&&G.tagNameCheck(r))return!1}if(lt&&!ut[r]){var i=v(t)||t.parentNode,A=w(t)||t.childNodes;if(A&&i)for(var s=A.length-1;s>=0;--s){var a=g(A[s],!0);a.__removalCount=(t.__removalCount||0)+1,i.insertBefore(a,m(t))}}return Ot(t),!0}return t instanceof o&&!function(t){var e=v(t);e&&e.tagName||(e={namespaceURI:bt,tagName:"template"});var n=QD(t.tagName),r=QD(e.tagName);return!!_t[t.namespaceURI]&&(t.namespaceURI===vt?e.namespaceURI===yt?"svg"===n:e.namespaceURI===wt?"svg"===n&&("annotation-xml"===r||Ut[r]):Boolean(kt[n]):t.namespaceURI===wt?e.namespaceURI===yt?"math"===n:e.namespaceURI===vt?"math"===n&&It[r]:Boolean(Mt[n]):t.namespaceURI===yt?!(e.namespaceURI===vt&&!It[r])&&!(e.namespaceURI===wt&&!Ut[r])&&!Mt[n]&&(Qt[n]||!kt[n]):!("application/xhtml+xml"!==I||!_t[t.namespaceURI]))}(t)?(Ot(t),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!TD(/<\/no(script|embed|frames)/i,t.innerHTML)?(Z&&3===t.nodeType&&(e=t.textContent,e=OD(e,k," "),e=OD(e,M," "),e=OD(e,O," "),t.textContent!==e&&(ID(n.removed,{element:t.cloneNode()}),t.textContent=e)),Ht("afterSanitizeElements",t,null),!1):(Ot(t),!0)},Wt=function(t,e,n){if(at&&("id"===e||"name"===e)&&(n in i||n in St))return!1;if(Y&&!q[e]&&TD(P,e));else if(X&&TD(N,e));else if(!V[e]||q[e]){if(!(Vt(t)&&(G.tagNameCheck instanceof RegExp&&TD(G.tagNameCheck,t)||G.tagNameCheck instanceof Function&&G.tagNameCheck(t))&&(G.attributeNameCheck instanceof RegExp&&TD(G.attributeNameCheck,e)||G.attributeNameCheck instanceof Function&&G.attributeNameCheck(e))||"is"===e&&G.allowCustomizedBuiltInElements&&(G.tagNameCheck instanceof RegExp&&TD(G.tagNameCheck,n)||G.tagNameCheck instanceof Function&&G.tagNameCheck(n))))return!1}else if(gt[e]);else if(TD(H,OD(n,D,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==PD(n,"data:")||!ft[t]){if($&&!TD(T,OD(n,D,"")));else if(n)return!1}else;return!0},Vt=function(t){return"annotation-xml"!==t&&MD(t,R)},Kt=function(t){var e,r,i,A;Ht("beforeSanitizeAttributes",t,null);var s=t.attributes;if(s&&!Dt(t)){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V};for(A=s.length;A--;){var o=e=s[A],l=o.name,c=o.namespaceURI;if(r="value"===l?e.value:ND(e.value),i=Q(l),a.attrName=i,a.attrValue=r,a.keepAttr=!0,a.forceKeepAttr=void 0,Ht("uponSanitizeAttribute",t,a),r=a.attrValue,!a.forceKeepAttr&&(Pt(l,t),a.keepAttr))if(J||!TD(/\/>/i,r)){Z&&(r=OD(r,k," "),r=OD(r,M," "),r=OD(r,O," "));var h=Q(t.nodeName);if(Wt(h,i,r))if(!ot||"id"!==i&&"name"!==i||(Pt(l,t),r="user-content-"+r),tt&&TD(/((--!?|])>)|<\/(style|title)/i,r))Pt(l,t);else{if(b&&"object"===uD(f)&&"function"==typeof f.getAttributeType)if(c);else switch(f.getAttributeType(h,i)){case"TrustedHTML":r=b.createHTML(r);break;case"TrustedScriptURL":r=b.createScriptURL(r)}try{c?t.setAttributeNS(c,l,r):t.setAttribute(l,r),Dt(t)?Ot(t):UD(n.removed)}catch(zt){}}}else Pt(l,t)}Ht("afterSanitizeAttributes",t,null)}},Gt=function t(e){var n,r=Tt(e);for(Ht("beforeSanitizeShadowDOM",e,null);n=r.nextNode();)Ht("uponSanitizeShadowNode",n,null),jt(n),Kt(n),n.content instanceof A&&t(n.content);Ht("afterSanitizeShadowDOM",e,null)};return n.sanitize=function(t){var i,s,o,l,c,h=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((Bt=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Rt(t)){if("function"!=typeof t.toString)throw DD("toString is not a function");if("string"!=typeof(t=t.toString()))throw DD("dirty is not a string, aborting")}if(!n.isSupported){if("object"===uD(e.toStaticHTML)||"function"==typeof e.toStaticHTML){if("string"==typeof t)return e.toStaticHTML(t);if(Rt(t))return e.toStaticHTML(t.outerHTML)}return t}if(nt||Lt(h),n.removed=[],"string"==typeof t&&(ct=!1),ct){if(t.nodeName){var u=Q(t.nodeName);if(!j[u]||z[u])throw DD("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof a)1===(s=(i=Nt("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===s.nodeName||"HTML"===s.nodeName?i=s:i.appendChild(s);else{if(!it&&!Z&&!et&&-1===t.indexOf("<"))return b&&st?b.createHTML(t):t;if(!(i=Nt(t)))return it?null:st?B:""}i&&rt&&Ot(i.firstChild);for(var d=Tt(ct?t:i);o=d.nextNode();)3===o.nodeType&&o===l||(jt(o),Kt(o),o.content instanceof A&&Gt(o.content),l=o);if(l=null,ct)return t;if(it){if(At)for(c=E.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(V.shadowroot||V.shadowrootmod)&&(c=F.call(r,c,!0)),c}var f=et?i.outerHTML:i.innerHTML;return et&&j["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&TD(lR,i.ownerDocument.doctype.name)&&(f="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+f),Z&&(f=OD(f,k," "),f=OD(f,M," "),f=OD(f,O," ")),b&&st?b.createHTML(f):f},n.setConfig=function(t){Lt(t),nt=!0},n.clearConfig=function(){Et=null,nt=!1},n.isValidAttribute=function(t,e,n){Et||Lt({});var r=Q(t),i=Q(e);return Wt(r,i,n)},n.addHook=function(t,e){"function"==typeof e&&(U[t]=U[t]||[],ID(U[t],e))},n.removeHook=function(t){if(U[t])return UD(U[t])},n.removeHooks=function(t){U[t]&&(U[t]=[])},n.removeAllHooks=function(){U={}},n}();const uR=Object.freeze(Object.defineProperty({__proto__:null,default:hR},Symbol.toStringTag,{value:"Module"}));var dR=function(t){return t&&t.Math===Math&&t},fR=dR("object"==typeof globalThis&&globalThis)||dR("object"==typeof window&&window)||dR("object"==typeof self&&self)||dR("object"==typeof Jc&&Jc)||dR("object"==typeof Jc&&Jc)||function(){return this}()||Function("return this")(),pR={},gR=function(t){try{return!!t()}catch(o3){return!0}},mR=!gR(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),wR=!gR(function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}),vR=wR,yR=Function.prototype.call,bR=vR?yR.bind(yR):function(){return yR.apply(yR,arguments)},BR={},_R={}.propertyIsEnumerable,CR=Object.getOwnPropertyDescriptor,xR=CR&&!_R.call({1:2},1);BR.f=xR?function(t){var e=CR(this,t);return!!e&&e.enumerable}:_R;var ER,SR,FR=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},LR=wR,UR=Function.prototype,IR=UR.call,QR=LR&&UR.bind.bind(IR,IR),kR=LR?QR:function(t){return function(){return IR.apply(t,arguments)}},MR=kR,OR=MR({}.toString),PR=MR("".slice),NR=function(t){return PR(OR(t),8,-1)},TR=gR,DR=NR,RR=Object,HR=kR("".split),jR=TR(function(){return!RR("z").propertyIsEnumerable(0)})?function(t){return"String"===DR(t)?HR(t,""):RR(t)}:RR,WR=function(t){return null==t},VR=WR,KR=TypeError,GR=function(t){if(VR(t))throw new KR("Can't call method on "+t);return t},zR=jR,qR=GR,XR=function(t){return zR(qR(t))},YR="object"==typeof document&&document.all,$R=void 0===YR&&void 0!==YR?function(t){return"function"==typeof t||t===YR}:function(t){return"function"==typeof t},JR=$R,ZR=function(t){return"object"==typeof t?null!==t:JR(t)},tH=fR,eH=$R,nH=function(t,e){return arguments.length<2?(n=tH[t],eH(n)?n:void 0):tH[t]&&tH[t][e];var n},rH=kR({}.isPrototypeOf),iH=fR.navigator,AH=iH&&iH.userAgent,sH=AH?String(AH):"",aH=fR,oH=sH,lH=aH.process,cH=aH.Deno,hH=lH&&lH.versions||cH&&cH.version,uH=hH&&hH.v8;uH&&(SR=(ER=uH.split("."))[0]>0&&ER[0]<4?1:+(ER[0]+ER[1])),!SR&&oH&&(!(ER=oH.match(/Edge\/(\d+)/))||ER[1]>=74)&&(ER=oH.match(/Chrome\/(\d+)/))&&(SR=+ER[1]);var dH=SR,fH=dH,pH=gR,gH=fR.String,mH=!!Object.getOwnPropertySymbols&&!pH(function(){var t=Symbol("symbol detection");return!gH(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&fH&&fH<41}),wH=mH&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,vH=nH,yH=$R,bH=rH,BH=Object,_H=wH?function(t){return"symbol"==typeof t}:function(t){var e=vH("Symbol");return yH(e)&&bH(e.prototype,BH(t))},CH=String,xH=function(t){try{return CH(t)}catch(o3){return"Object"}},EH=$R,SH=xH,FH=TypeError,LH=function(t){if(EH(t))return t;throw new FH(SH(t)+" is not a function")},UH=LH,IH=WR,QH=function(t,e){var n=t[e];return IH(n)?void 0:UH(n)},kH=bR,MH=$R,OH=ZR,PH=TypeError,NH={exports:{}},TH=fR,DH=Object.defineProperty,RH=function(t,e){try{DH(TH,t,{value:e,configurable:!0,writable:!0})}catch(o3){TH[t]=e}return e},HH=fR,jH=RH,WH="__core-js_shared__",VH=NH.exports=HH[WH]||jH(WH,{});(VH.versions||(VH.versions=[])).push({version:"3.44.0",mode:"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.44.0/LICENSE",source:"https://github.com/zloirock/core-js"});var KH=NH.exports,GH=KH,zH=function(t,e){return GH[t]||(GH[t]=e||{})},qH=GR,XH=Object,YH=function(t){return XH(qH(t))},$H=YH,JH=kR({}.hasOwnProperty),ZH=Object.hasOwn||function(t,e){return JH($H(t),e)},tj=kR,ej=0,nj=Math.random(),rj=tj(1.1.toString),ij=function(t){return"Symbol("+(void 0===t?"":t)+")_"+rj(++ej+nj,36)},Aj=zH,sj=ZH,aj=ij,oj=mH,lj=wH,cj=fR.Symbol,hj=Aj("wks"),uj=lj?cj.for||cj:cj&&cj.withoutSetter||aj,dj=function(t){return sj(hj,t)||(hj[t]=oj&&sj(cj,t)?cj[t]:uj("Symbol."+t)),hj[t]},fj=bR,pj=ZR,gj=_H,mj=QH,wj=function(t,e){var n,r;if("string"===e&&MH(n=t.toString)&&!OH(r=kH(n,t)))return r;if(MH(n=t.valueOf)&&!OH(r=kH(n,t)))return r;if("string"!==e&&MH(n=t.toString)&&!OH(r=kH(n,t)))return r;throw new PH("Can't convert object to primitive value")},vj=TypeError,yj=dj("toPrimitive"),bj=function(t,e){if(!pj(t)||gj(t))return t;var n,r=mj(t,yj);if(r){if(void 0===e&&(e="default"),n=fj(r,t,e),!pj(n)||gj(n))return n;throw new vj("Can't convert object to primitive value")}return void 0===e&&(e="number"),wj(t,e)},Bj=_H,_j=function(t){var e=bj(t,"string");return Bj(e)?e:e+""},Cj=ZR,xj=fR.document,Ej=Cj(xj)&&Cj(xj.createElement),Sj=function(t){return Ej?xj.createElement(t):{}},Fj=Sj,Lj=!mR&&!gR(function(){return 7!==Object.defineProperty(Fj("div"),"a",{get:function(){return 7}}).a}),Uj=mR,Ij=bR,Qj=BR,kj=FR,Mj=XR,Oj=_j,Pj=ZH,Nj=Lj,Tj=Object.getOwnPropertyDescriptor;pR.f=Uj?Tj:function(t,e){if(t=Mj(t),e=Oj(e),Nj)try{return Tj(t,e)}catch(o3){}if(Pj(t,e))return kj(!Ij(Qj.f,t,e),t[e])};var Dj={},Rj=mR&&gR(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),Hj=ZR,jj=String,Wj=TypeError,Vj=function(t){if(Hj(t))return t;throw new Wj(jj(t)+" is not an object")},Kj=mR,Gj=Lj,zj=Rj,qj=Vj,Xj=_j,Yj=TypeError,$j=Object.defineProperty,Jj=Object.getOwnPropertyDescriptor,Zj="enumerable",tW="configurable",eW="writable";Dj.f=Kj?zj?function(t,e,n){if(qj(t),e=Xj(e),qj(n),"function"==typeof t&&"prototype"===e&&"value"in n&&eW in n&&!n[eW]){var r=Jj(t,e);r&&r[eW]&&(t[e]=n.value,n={configurable:tW in n?n[tW]:r[tW],enumerable:Zj in n?n[Zj]:r[Zj],writable:!1})}return $j(t,e,n)}:$j:function(t,e,n){if(qj(t),e=Xj(e),qj(n),Gj)try{return $j(t,e,n)}catch(o3){}if("get"in n||"set"in n)throw new Yj("Accessors not supported");return"value"in n&&(t[e]=n.value),t};var nW=Dj,rW=FR,iW=mR?function(t,e,n){return nW.f(t,e,rW(1,n))}:function(t,e,n){return t[e]=n,t},AW={exports:{}},sW=mR,aW=ZH,oW=Function.prototype,lW=sW&&Object.getOwnPropertyDescriptor,cW=aW(oW,"name"),hW={PROPER:cW&&"something"===function(){}.name,CONFIGURABLE:cW&&(!sW||sW&&lW(oW,"name").configurable)},uW=$R,dW=KH,fW=kR(Function.toString);uW(dW.inspectSource)||(dW.inspectSource=function(t){return fW(t)});var pW,gW,mW,wW=dW.inspectSource,vW=$R,yW=fR.WeakMap,bW=vW(yW)&&/native code/.test(String(yW)),BW=ij,_W=zH("keys"),CW=function(t){return _W[t]||(_W[t]=BW(t))},xW={},EW=bW,SW=fR,FW=ZR,LW=iW,UW=ZH,IW=KH,QW=CW,kW=xW,MW="Object already initialized",OW=SW.TypeError,PW=SW.WeakMap;if(EW||IW.state){var NW=IW.state||(IW.state=new PW);NW.get=NW.get,NW.has=NW.has,NW.set=NW.set,pW=function(t,e){if(NW.has(t))throw new OW(MW);return e.facade=t,NW.set(t,e),e},gW=function(t){return NW.get(t)||{}},mW=function(t){return NW.has(t)}}else{var TW=QW("state");kW[TW]=!0,pW=function(t,e){if(UW(t,TW))throw new OW(MW);return e.facade=t,LW(t,TW,e),e},gW=function(t){return UW(t,TW)?t[TW]:{}},mW=function(t){return UW(t,TW)}}var DW={set:pW,get:gW,has:mW,enforce:function(t){return mW(t)?gW(t):pW(t,{})},getterFor:function(t){return function(e){var n;if(!FW(e)||(n=gW(e)).type!==t)throw new OW("Incompatible receiver, "+t+" required");return n}}},RW=kR,HW=gR,jW=$R,WW=ZH,VW=mR,KW=hW.CONFIGURABLE,GW=wW,zW=DW.enforce,qW=DW.get,XW=String,YW=Object.defineProperty,$W=RW("".slice),JW=RW("".replace),ZW=RW([].join),tV=VW&&!HW(function(){return 8!==YW(function(){},"length",{value:8}).length}),eV=String(String).split("String"),nV=AW.exports=function(t,e,n){"Symbol("===$W(XW(e),0,7)&&(e="["+JW(XW(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!WW(t,"name")||KW&&t.name!==e)&&(VW?YW(t,"name",{value:e,configurable:!0}):t.name=e),tV&&n&&WW(n,"arity")&&t.length!==n.arity&&YW(t,"length",{value:n.arity});try{n&&WW(n,"constructor")&&n.constructor?VW&&YW(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(o3){}var r=zW(t);return WW(r,"source")||(r.source=ZW(eV,"string"==typeof e?e:"")),t};Function.prototype.toString=nV(function(){return jW(this)&&qW(this).source||GW(this)},"toString");var rV,iV=AW.exports,AV=$R,sV=Dj,aV=iV,oV=RH,lV=function(t,e,n,r){r||(r={});var i=r.enumerable,A=void 0!==r.name?r.name:e;if(AV(n)&&aV(n,A,r),r.global)i?t[e]=n:oV(e,n);else{try{r.unsafe?t[e]&&(i=!0):delete t[e]}catch(o3){}i?t[e]=n:sV.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},cV={},hV=Math.ceil,uV=Math.floor,dV=Math.trunc||function(t){var e=+t;return(e>0?uV:hV)(e)},fV=function(t){var e=+t;return e!=e||0===e?0:dV(e)},pV=fV,gV=Math.max,mV=Math.min,wV=fV,vV=Math.min,yV=function(t){var e=wV(t);return e>0?vV(e,9007199254740991):0},bV=yV,BV=function(t){return bV(t.length)},_V=XR,CV=function(t,e){var n=pV(t);return n<0?gV(n+e,0):mV(n,e)},xV=BV,EV={indexOf:(rV=!1,function(t,e,n){var r=_V(t),i=xV(r);if(0===i)return!rV&&-1;var A,s=CV(n,i);if(rV&&e!=e){for(;i>s;)if((A=r[s++])!=A)return!0}else for(;i>s;s++)if((rV||s in r)&&r[s]===e)return rV||s||0;return!rV&&-1})},SV=ZH,FV=XR,LV=EV.indexOf,UV=xW,IV=kR([].push),QV=function(t,e){var n,r=FV(t),i=0,A=[];for(n in r)!SV(UV,n)&&SV(r,n)&&IV(A,n);for(;e.length>i;)SV(r,n=e[i++])&&(~LV(A,n)||IV(A,n));return A},kV=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],MV=QV,OV=kV.concat("length","prototype");cV.f=Object.getOwnPropertyNames||function(t){return MV(t,OV)};var PV={};PV.f=Object.getOwnPropertySymbols;var NV=nH,TV=cV,DV=PV,RV=Vj,HV=kR([].concat),jV=NV("Reflect","ownKeys")||function(t){var e=TV.f(RV(t)),n=DV.f;return n?HV(e,n(t)):e},WV=ZH,VV=jV,KV=pR,GV=Dj,zV=gR,qV=$R,XV=/#|\.prototype\./,YV=function(t,e){var n=JV[$V(t)];return n===tK||n!==ZV&&(qV(e)?zV(e):!!e)},$V=YV.normalize=function(t){return String(t).replace(XV,".").toLowerCase()},JV=YV.data={},ZV=YV.NATIVE="N",tK=YV.POLYFILL="P",eK=YV,nK=fR,rK=pR.f,iK=iW,AK=lV,sK=RH,aK=function(t,e,n){for(var r=VV(e),i=GV.f,A=KV.f,s=0;s<r.length;s++){var a=r[s];WV(t,a)||n&&WV(n,a)||i(t,a,A(e,a))}},oK=eK,lK=function(t,e){var n,r,i,A,s,a=t.target,o=t.global,l=t.stat;if(n=o?nK:l?nK[a]||sK(a,{}):nK[a]&&nK[a].prototype)for(r in e){if(A=e[r],i=t.dontCallGetSet?(s=rK(n,r))&&s.value:n[r],!oK(o?r:a+(l?".":"#")+r,t.forced)&&void 0!==i){if(typeof A==typeof i)continue;aK(A,i)}(t.sham||i&&i.sham)&&iK(A,"sham",!0),AK(n,r,A,t)}},cK=fR,hK=sH,uK=NR,dK=function(t){return hK.slice(0,t.length)===t},fK=dK("Bun/")?"BUN":dK("Cloudflare-Workers")?"CLOUDFLARE":dK("Deno/")?"DENO":dK("Node.js/")?"NODE":cK.Bun&&"string"==typeof Bun.version?"BUN":cK.Deno&&"object"==typeof Deno.version?"DENO":"process"===uK(cK.process)?"NODE":cK.window&&cK.document?"BROWSER":"REST",pK="NODE"===fK,gK=fR,mK=kR,wK=LH,vK=ZR,yK=function(t){return vK(t)||null===t},bK=String,BK=TypeError,_K=function(t,e,n){try{return mK(wK(Object.getOwnPropertyDescriptor(t,e)[n]))}catch(o3){}},CK=ZR,xK=GR,EK=function(t){if(yK(t))return t;throw new BK("Can't set "+bK(t)+" as a prototype")},SK=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=_K(Object.prototype,"__proto__","set"))(n,[]),e=n instanceof Array}catch(o3){}return function(n,r){return xK(n),EK(r),CK(n)?(e?t(n,r):n.__proto__=r,n):n}}():void 0),FK=Dj.f,LK=ZH,UK=dj("toStringTag"),IK=function(t,e,n){t&&!n&&(t=t.prototype),t&&!LK(t,UK)&&FK(t,UK,{configurable:!0,value:e})},QK=iV,kK=Dj,MK=nH,OK=function(t,e,n){return n.get&&QK(n.get,e,{getter:!0}),n.set&&QK(n.set,e,{setter:!0}),kK.f(t,e,n)},PK=mR,NK=dj("species"),TK=rH,DK=TypeError,RK={};RK[dj("toStringTag")]="z";var HK="[object z]"===String(RK),jK=$R,WK=NR,VK=dj("toStringTag"),KK=Object,GK="Arguments"===WK(function(){return arguments}()),zK=HK?WK:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(o3){}}(e=KK(t),VK))?n:GK?WK(e):"Object"===(r=WK(e))&&jK(e.callee)?"Arguments":r},qK=kR,XK=gR,YK=$R,$K=zK,JK=wW,ZK=function(){},tG=nH("Reflect","construct"),eG=/^\s*(?:class|function)\b/,nG=qK(eG.exec),rG=!eG.test(ZK),iG=function(t){if(!YK(t))return!1;try{return tG(ZK,[],t),!0}catch(o3){return!1}},AG=function(t){if(!YK(t))return!1;switch($K(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return rG||!!nG(eG,JK(t))}catch(o3){return!0}};AG.sham=!0;var sG,aG,oG,lG,cG=!tG||XK(function(){var t;return iG(iG.call)||!iG(Object)||!iG(function(){t=!0})||t})?AG:iG,hG=xH,uG=TypeError,dG=Vj,fG=function(t){if(cG(t))return t;throw new uG(hG(t)+" is not a constructor")},pG=WR,gG=dj("species"),mG=function(t,e){var n,r=dG(t).constructor;return void 0===r||pG(n=dG(r)[gG])?e:fG(n)},wG=wR,vG=Function.prototype,yG=vG.apply,bG=vG.call,BG="object"==typeof Reflect&&Reflect.apply||(wG?bG.bind(yG):function(){return bG.apply(yG,arguments)}),_G=NR,CG=kR,xG=function(t){if("Function"===_G(t))return CG(t)},EG=LH,SG=wR,FG=xG(xG.bind),LG=function(t,e){return EG(t),void 0===e?t:SG?FG(t,e):function(){return t.apply(e,arguments)}},UG=nH("document","documentElement"),IG=kR([].slice),QG=TypeError,kG=/(?:ipad|iphone|ipod).*applewebkit/i.test(sH),MG=fR,OG=BG,PG=LG,NG=$R,TG=ZH,DG=gR,RG=UG,HG=IG,jG=Sj,WG=function(t,e){if(t<e)throw new QG("Not enough arguments");return t},VG=kG,KG=pK,GG=MG.setImmediate,zG=MG.clearImmediate,qG=MG.process,XG=MG.Dispatch,YG=MG.Function,$G=MG.MessageChannel,JG=MG.String,ZG=0,tz={},ez="onreadystatechange";DG(function(){sG=MG.location});var nz=function(t){if(TG(tz,t)){var e=tz[t];delete tz[t],e()}},rz=function(t){return function(){nz(t)}},iz=function(t){nz(t.data)},Az=function(t){MG.postMessage(JG(t),sG.protocol+"//"+sG.host)};GG&&zG||(GG=function(t){WG(arguments.length,1);var e=NG(t)?t:YG(t),n=HG(arguments,1);return tz[++ZG]=function(){OG(e,void 0,n)},aG(ZG),ZG},zG=function(t){delete tz[t]},KG?aG=function(t){qG.nextTick(rz(t))}:XG&&XG.now?aG=function(t){XG.now(rz(t))}:$G&&!VG?(lG=(oG=new $G).port2,oG.port1.onmessage=iz,aG=PG(lG.postMessage,lG)):MG.addEventListener&&NG(MG.postMessage)&&!MG.importScripts&&sG&&"file:"!==sG.protocol&&!DG(Az)?(aG=Az,MG.addEventListener("message",iz,!1)):aG=ez in jG("script")?function(t){RG.appendChild(jG("script"))[ez]=function(){RG.removeChild(this),nz(t)}}:function(t){setTimeout(rz(t),0)});var sz={set:GG},az=fR,oz=mR,lz=Object.getOwnPropertyDescriptor,cz=function(){this.head=null,this.tail=null};cz.prototype={add:function(t){var e={item:t,next:null},n=this.tail;n?n.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t)return null===(this.head=t.next)&&(this.tail=null),t.item}};var hz,uz,dz,fz,pz,gz=cz,mz=/ipad|iphone|ipod/i.test(sH)&&"undefined"!=typeof Pebble,wz=/web0s(?!.*chrome)/i.test(sH),vz=fR,yz=function(t){if(!oz)return az[t];var e=lz(az,t);return e&&e.value},bz=LG,Bz=sz.set,_z=gz,Cz=kG,xz=mz,Ez=wz,Sz=pK,Fz=vz.MutationObserver||vz.WebKitMutationObserver,Lz=vz.document,Uz=vz.process,Iz=vz.Promise,Qz=yz("queueMicrotask");if(!Qz){var kz=new _z,Mz=function(){var t,e;for(Sz&&(t=Uz.domain)&&t.exit();e=kz.get();)try{e()}catch(o3){throw kz.head&&hz(),o3}t&&t.enter()};Cz||Sz||Ez||!Fz||!Lz?!xz&&Iz&&Iz.resolve?((fz=Iz.resolve(void 0)).constructor=Iz,pz=bz(fz.then,fz),hz=function(){pz(Mz)}):Sz?hz=function(){Uz.nextTick(Mz)}:(Bz=bz(Bz,vz),hz=function(){Bz(Mz)}):(uz=!0,dz=Lz.createTextNode(""),new Fz(Mz).observe(dz,{characterData:!0}),hz=function(){dz.data=uz=!uz}),Qz=function(t){kz.head||hz(),kz.add(t)}}var Oz=Qz,Pz=function(t){try{return{error:!1,value:t()}}catch(o3){return{error:!0,value:o3}}},Nz=fR.Promise,Tz=fR,Dz=Nz,Rz=$R,Hz=eK,jz=wW,Wz=dj,Vz=fK,Kz=dH;Dz&&Dz.prototype;var Gz=Wz("species"),zz=!1,qz=Rz(Tz.PromiseRejectionEvent),Xz={CONSTRUCTOR:Hz("Promise",function(){var t=jz(Dz),e=t!==String(Dz);if(!e&&66===Kz)return!0;if(!Kz||Kz<51||!/native code/.test(t)){var n=new Dz(function(t){t(1)}),r=function(t){t(function(){},function(){})};if((n.constructor={})[Gz]=r,!(zz=n.then(function(){})instanceof r))return!0}return!(e||"BROWSER"!==Vz&&"DENO"!==Vz||qz)}),REJECTION_EVENT:qz,SUBCLASSING:zz},Yz={},$z=LH,Jz=TypeError,Zz=function(t){var e,n;this.promise=new t(function(t,r){if(void 0!==e||void 0!==n)throw new Jz("Bad Promise constructor");e=t,n=r}),this.resolve=$z(e),this.reject=$z(n)};Yz.f=function(t){return new Zz(t)};var tq,eq,nq,rq,iq=lK,Aq=pK,sq=fR,aq=gK,oq=bR,lq=lV,cq=SK,hq=IK,uq=function(t){var e=MK(t);PK&&e&&!e[NK]&&OK(e,NK,{configurable:!0,get:function(){return this}})},dq=LH,fq=$R,pq=ZR,gq=function(t,e){if(TK(e,t))return t;throw new DK("Incorrect invocation")},mq=mG,wq=sz.set,vq=Oz,yq=function(t,e){try{1===arguments.length?console.error(t):console.error(t,e)}catch(o3){}},bq=Pz,Bq=gz,_q=DW,Cq=Nz,xq=Yz,Eq="Promise",Sq=Xz.CONSTRUCTOR,Fq=Xz.REJECTION_EVENT,Lq=Xz.SUBCLASSING,Uq=_q.getterFor(Eq),Iq=_q.set,Qq=Cq&&Cq.prototype,kq=Cq,Mq=Qq,Oq=sq.TypeError,Pq=sq.document,Nq=sq.process,Tq=xq.f,Dq=Tq,Rq=!!(Pq&&Pq.createEvent&&sq.dispatchEvent),Hq="unhandledrejection",jq=function(t){var e;return!(!pq(t)||!fq(e=t.then))&&e},Wq=function(t,e){var n,r,i,A=e.value,s=1===e.state,a=s?t.ok:t.fail,o=t.resolve,l=t.reject,c=t.domain;try{a?(s||(2===e.rejection&&qq(e),e.rejection=1),!0===a?n=A:(c&&c.enter(),n=a(A),c&&(c.exit(),i=!0)),n===t.promise?l(new Oq("Promise-chain cycle")):(r=jq(n))?oq(r,n,o,l):o(n)):l(A)}catch(o3){c&&!i&&c.exit(),l(o3)}},Vq=function(t,e){t.notified||(t.notified=!0,vq(function(){for(var n,r=t.reactions;n=r.get();)Wq(n,t);t.notified=!1,e&&!t.rejection&&Gq(t)}))},Kq=function(t,e,n){var r,i;Rq?((r=Pq.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),sq.dispatchEvent(r)):r={promise:e,reason:n},!Fq&&(i=sq["on"+t])?i(r):t===Hq&&yq("Unhandled promise rejection",n)},Gq=function(t){oq(wq,sq,function(){var e,n=t.facade,r=t.value;if(zq(t)&&(e=bq(function(){Aq?Nq.emit("unhandledRejection",r,n):Kq(Hq,n,r)}),t.rejection=Aq||zq(t)?2:1,e.error))throw e.value})},zq=function(t){return 1!==t.rejection&&!t.parent},qq=function(t){oq(wq,sq,function(){var e=t.facade;Aq?Nq.emit("rejectionHandled",e):Kq("rejectionhandled",e,t.value)})},Xq=function(t,e,n){return function(r){t(e,r,n)}},Yq=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,Vq(t,!0))},$q=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw new Oq("Promise can't be resolved itself");var r=jq(e);r?vq(function(){var n={done:!1};try{oq(r,e,Xq($q,n,t),Xq(Yq,n,t))}catch(o3){Yq(n,o3,t)}}):(t.value=e,t.state=1,Vq(t,!1))}catch(o3){Yq({done:!1},o3,t)}}};if(Sq&&(Mq=(kq=function(t){gq(this,Mq),dq(t),oq(tq,this);var e=Uq(this);try{t(Xq($q,e),Xq(Yq,e))}catch(o3){Yq(e,o3)}}).prototype,(tq=function(t){Iq(this,{type:Eq,done:!1,notified:!1,parent:!1,reactions:new Bq,rejection:!1,state:0,value:null})}).prototype=lq(Mq,"then",function(t,e){var n=Uq(this),r=Tq(mq(this,kq));return n.parent=!0,r.ok=!fq(t)||t,r.fail=fq(e)&&e,r.domain=Aq?Nq.domain:void 0,0===n.state?n.reactions.add(r):vq(function(){Wq(r,n)}),r.promise}),eq=function(){var t=new tq,e=Uq(t);this.promise=t,this.resolve=Xq($q,e),this.reject=Xq(Yq,e)},xq.f=Tq=function(t){return t===kq||t===nq?new eq(t):Dq(t)},fq(Cq)&&Qq!==Object.prototype)){rq=Qq.then,Lq||lq(Qq,"then",function(t,e){var n=this;return new kq(function(t,e){oq(rq,n,t,e)}).then(t,e)},{unsafe:!0});try{delete Qq.constructor}catch(o3){}cq&&cq(Qq,Mq)}iq({global:!0,constructor:!0,wrap:!0,forced:Sq},{Promise:kq}),nq=aq.Promise,hq(kq,Eq,!1),uq(Eq);var Jq={},Zq=Jq,tX=dj("iterator"),eX=Array.prototype,nX=zK,rX=QH,iX=WR,AX=Jq,sX=dj("iterator"),aX=function(t){if(!iX(t))return rX(t,sX)||rX(t,"@@iterator")||AX[nX(t)]},oX=bR,lX=LH,cX=Vj,hX=xH,uX=aX,dX=TypeError,fX=bR,pX=Vj,gX=QH,mX=LG,wX=bR,vX=Vj,yX=xH,bX=function(t){return void 0!==t&&(Zq.Array===t||eX[tX]===t)},BX=BV,_X=rH,CX=function(t,e){var n=arguments.length<2?uX(t):e;if(lX(n))return cX(oX(n,t));throw new dX(hX(t)+" is not iterable")},xX=aX,EX=function(t,e,n){var r,i;pX(t);try{if(!(r=gX(t,"return"))){if("throw"===e)throw n;return n}r=fX(r,t)}catch(o3){i=!0,r=o3}if("throw"===e)throw n;if(i)throw r;return pX(r),n},SX=TypeError,FX=function(t,e){this.stopped=t,this.result=e},LX=FX.prototype,UX=function(t,e,n){var r,i,A,s,a,o,l,c=n&&n.that,h=!(!n||!n.AS_ENTRIES),u=!(!n||!n.IS_RECORD),d=!(!n||!n.IS_ITERATOR),f=!(!n||!n.INTERRUPTED),p=mX(e,c),g=function(t){return r&&EX(r,"normal"),new FX(!0,t)},m=function(t){return h?(vX(t),f?p(t[0],t[1],g):p(t[0],t[1])):f?p(t,g):p(t)};if(u)r=t.iterator;else if(d)r=t;else{if(!(i=xX(t)))throw new SX(yX(t)+" is not iterable");if(bX(i)){for(A=0,s=BX(t);s>A;A++)if((a=m(t[A]))&&_X(LX,a))return a;return new FX(!1)}r=CX(t,i)}for(o=u?t.next:r.next;!(l=wX(o,r)).done;){try{a=m(l.value)}catch(o3){EX(r,"throw",o3)}if("object"==typeof a&&a&&_X(LX,a))return a}return new FX(!1)},IX=dj("iterator"),QX=!1;try{var kX=0,MX={next:function(){return{done:!!kX++}},return:function(){QX=!0}};MX[IX]=function(){return this},Array.from(MX,function(){throw 2})}catch(o3){}var OX=Nz,PX=Xz.CONSTRUCTOR||!function(t,e){try{if(!e&&!QX)return!1}catch(o3){return!1}var n=!1;try{var r={};r[IX]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(o3){}return n}(function(t){OX.all(t).then(void 0,function(){})}),NX=bR,TX=LH,DX=Yz,RX=Pz,HX=UX;lK({target:"Promise",stat:!0,forced:PX},{all:function(t){var e=this,n=DX.f(e),r=n.resolve,i=n.reject,A=RX(function(){var n=TX(e.resolve),A=[],s=0,a=1;HX(t,function(t){var o=s++,l=!1;a++,NX(n,e,t).then(function(t){l||(l=!0,A[o]=t,--a||r(A))},i)}),--a||r(A)});return A.error&&i(A.value),n.promise}});var jX=lK,WX=Xz.CONSTRUCTOR,VX=Nz,KX=nH,GX=$R,zX=lV,qX=VX&&VX.prototype;if(jX({target:"Promise",proto:!0,forced:WX,real:!0},{catch:function(t){return this.then(void 0,t)}}),GX(VX)){var XX=KX("Promise").prototype.catch;qX.catch!==XX&&zX(qX,"catch",XX,{unsafe:!0})}var YX=bR,$X=LH,JX=Yz,ZX=Pz,tY=UX;lK({target:"Promise",stat:!0,forced:PX},{race:function(t){var e=this,n=JX.f(e),r=n.reject,i=ZX(function(){var i=$X(e.resolve);tY(t,function(t){YX(i,e,t).then(n.resolve,r)})});return i.error&&r(i.value),n.promise}});var eY=Yz;lK({target:"Promise",stat:!0,forced:Xz.CONSTRUCTOR},{reject:function(t){var e=eY.f(this);return(0,e.reject)(t),e.promise}});var nY=Vj,rY=ZR,iY=Yz,AY=lK,sY=Xz.CONSTRUCTOR,aY=function(t,e){if(nY(t),rY(e)&&e.constructor===t)return e;var n=iY.f(t);return(0,n.resolve)(e),n.promise};function oY(t,e,n,r,i,A,s){try{var a=t[A](s),o=a.value}catch(l){return void n(l)}a.done?e(o):Promise.resolve(o).then(r,i)}function lY(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var A=t.apply(e,n);function s(t){oY(A,r,i,s,a,"next",t)}function a(t){oY(A,r,i,s,a,"throw",t)}s(void 0)})}}nH("Promise"),AY({target:"Promise",stat:!0,forced:sY},{resolve:function(t){return aY(this,t)}});var cY=zK,hY=String,uY=function(t){if("Symbol"===cY(t))throw new TypeError("Cannot convert a Symbol value to a string");return hY(t)},dY=Vj,fY=function(){var t=dY(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e},pY=gR,gY=fR.RegExp,mY=pY(function(){var t=gY("a","y");return t.lastIndex=2,null!==t.exec("abcd")});mY||pY(function(){return!gY("a","y").sticky});var wY=mY||pY(function(){var t=gY("^r","gy");return t.lastIndex=2,null!==t.exec("str")}),vY={BROKEN_CARET:wY,UNSUPPORTED_Y:mY},yY={},bY=QV,BY=kV,_Y=Object.keys||function(t){return bY(t,BY)},CY=mR,xY=Rj,EY=Dj,SY=Vj,FY=XR,LY=_Y;yY.f=CY&&!xY?Object.defineProperties:function(t,e){SY(t);for(var n,r=FY(e),i=LY(e),A=i.length,s=0;A>s;)EY.f(t,n=i[s++],r[n]);return t};var UY,IY=Vj,QY=yY,kY=kV,MY=xW,OY=UG,PY=Sj,NY="prototype",TY="script",DY=CW("IE_PROTO"),RY=function(){},HY=function(t){return"<"+TY+">"+t+"</"+TY+">"},jY=function(t){t.write(HY("")),t.close();var e=t.parentWindow.Object;return t=null,e},WY=function(){try{UY=new ActiveXObject("htmlfile")}catch(o3){}var t,e,n;WY="undefined"!=typeof document?document.domain&&UY?jY(UY):(e=PY("iframe"),n="java"+TY+":",e.style.display="none",OY.appendChild(e),e.src=String(n),(t=e.contentWindow.document).open(),t.write(HY("document.F=Object")),t.close(),t.F):jY(UY);for(var r=kY.length;r--;)delete WY[NY][kY[r]];return WY()};MY[DY]=!0;var VY,KY,GY=Object.create||function(t,e){var n;return null!==t?(RY[NY]=IY(t),n=new RY,RY[NY]=null,n[DY]=t):n=WY(),void 0===e?n:QY.f(n,e)},zY=gR,qY=fR.RegExp,XY=zY(function(){var t=qY(".","s");return!(t.dotAll&&t.test("\n")&&"s"===t.flags)}),YY=gR,$Y=fR.RegExp,JY=YY(function(){var t=$Y("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")}),ZY=bR,t$=kR,e$=uY,n$=fY,r$=vY,i$=GY,A$=DW.get,s$=XY,a$=JY,o$=zH("native-string-replace",String.prototype.replace),l$=RegExp.prototype.exec,c$=l$,h$=t$("".charAt),u$=t$("".indexOf),d$=t$("".replace),f$=t$("".slice),p$=(KY=/b*/g,ZY(l$,VY=/a/,"a"),ZY(l$,KY,"a"),0!==VY.lastIndex||0!==KY.lastIndex),g$=r$.BROKEN_CARET,m$=void 0!==/()??/.exec("")[1];(p$||m$||g$||s$||a$)&&(c$=function(t){var e,n,r,i,A,s,a,o=this,l=A$(o),c=e$(t),h=l.raw;if(h)return h.lastIndex=o.lastIndex,e=ZY(c$,h,c),o.lastIndex=h.lastIndex,e;var u=l.groups,d=g$&&o.sticky,f=ZY(n$,o),p=o.source,g=0,m=c;if(d&&(f=d$(f,"y",""),-1===u$(f,"g")&&(f+="g"),m=f$(c,o.lastIndex),o.lastIndex>0&&(!o.multiline||o.multiline&&"\n"!==h$(c,o.lastIndex-1))&&(p="(?: "+p+")",m=" "+m,g++),n=new RegExp("^(?:"+p+")",f)),m$&&(n=new RegExp("^"+p+"$(?!\\s)",f)),p$&&(r=o.lastIndex),i=ZY(l$,d?n:o,m),d?i?(i.input=f$(i.input,g),i[0]=f$(i[0],g),i.index=o.lastIndex,o.lastIndex+=i[0].length):o.lastIndex=0:p$&&i&&(o.lastIndex=o.global?i.index+i[0].length:r),m$&&i&&i.length>1&&ZY(o$,i[0],n,function(){for(A=1;A<arguments.length-2;A++)void 0===arguments[A]&&(i[A]=void 0)}),i&&u)for(i.groups=s=i$(null),A=0;A<u.length;A++)s[(a=u[A])[0]]=i[a[1]];return i});var w$=c$;lK({target:"RegExp",proto:!0,forced:/./.exec!==w$},{exec:w$});var v$,y$=bR,b$=lV,B$=w$,_$=gR,C$=dj,x$=iW,E$=C$("species"),S$=RegExp.prototype,F$=function(t,e,n,r){var i=C$(t),A=!_$(function(){var e={};return e[i]=function(){return 7},7!==""[t](e)}),s=A&&!_$(function(){var e=!1,n=/a/;return"split"===t&&((n={}).constructor={},n.constructor[E$]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return e=!0,null},n[i](""),!e});if(!A||!s||n){var a=/./[i],o=e(i,""[t],function(t,e,n,r,i){var s=e.exec;return s===B$||s===S$.exec?A&&!i?{done:!0,value:y$(a,e,n,r)}:{done:!0,value:y$(t,n,e,r)}:{done:!1}});b$(String.prototype,t,o[0]),b$(S$,i,o[1])}r&&x$(S$[i],"sham",!0)},L$=kR,U$=fV,I$=uY,Q$=GR,k$=L$("".charAt),M$=L$("".charCodeAt),O$=L$("".slice),P$={charAt:(v$=!0,function(t,e){var n,r,i=I$(Q$(t)),A=U$(e),s=i.length;return A<0||A>=s?v$?"":void 0:(n=M$(i,A))<55296||n>56319||A+1===s||(r=M$(i,A+1))<56320||r>57343?v$?k$(i,A):n:v$?O$(i,A,A+2):r-56320+(n-55296<<10)+65536})}.charAt,N$=function(t,e,n){return e+(n?P$(t,e).length:1)},T$=gR,D$=fR.RegExp,R$=!T$(function(){var t=!0;try{D$(".","d")}catch(o3){t=!1}var e={},n="",r=t?"dgimsy":"gimsy",i=function(t,r){Object.defineProperty(e,t,{get:function(){return n+=r,!0}})},A={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var s in t&&(A.hasIndices="d"),A)i(s,A[s]);return Object.getOwnPropertyDescriptor(D$.prototype,"flags").get.call(e)!==r||n!==r}),H$=bR,j$=ZH,W$=rH,V$={correct:R$},K$=fY,G$=RegExp.prototype,z$=V$.correct?function(t){return t.flags}:function(t){return V$.correct||!W$(G$,t)||j$(t,"flags")?t.flags:H$(K$,t)},q$=bR,X$=Vj,Y$=$R,$$=NR,J$=w$,Z$=TypeError,tJ=function(t,e){var n=t.exec;if(Y$(n)){var r=q$(n,t,e);return null!==r&&X$(r),r}if("RegExp"===$$(t))return q$(J$,t,e);throw new Z$("RegExp#exec called on incompatible receiver")},eJ=bR,nJ=F$,rJ=Vj,iJ=ZR,AJ=yV,sJ=uY,aJ=GR,oJ=QH,lJ=N$,cJ=z$,hJ=tJ,uJ=kR("".indexOf);nJ("match",function(t,e,n){return[function(e){var n=aJ(this),r=iJ(e)?oJ(e,t):void 0;return r?eJ(r,e,n):new RegExp(e)[t](sJ(n))},function(t){var r=rJ(this),i=sJ(t),A=n(e,r,i);if(A.done)return A.value;var s=sJ(cJ(r));if(-1===uJ(s,"g"))return hJ(r,i);var a=-1!==uJ(s,"u");r.lastIndex=0;for(var o,l=[],c=0;null!==(o=hJ(r,i));){var h=sJ(o[0]);l[c]=h,""===h&&(r.lastIndex=lJ(i,AJ(r.lastIndex),a)),c++}return 0===c?null:l}]});var dJ=kR,fJ=YH,pJ=Math.floor,gJ=dJ("".charAt),mJ=dJ("".replace),wJ=dJ("".slice),vJ=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,yJ=/\$([$&'`]|\d{1,2})/g,bJ=BG,BJ=bR,_J=kR,CJ=F$,xJ=gR,EJ=Vj,SJ=$R,FJ=ZR,LJ=fV,UJ=yV,IJ=uY,QJ=GR,kJ=N$,MJ=QH,OJ=function(t,e,n,r,i,A){var s=n+t.length,a=r.length,o=yJ;return void 0!==i&&(i=fJ(i),o=vJ),mJ(A,o,function(A,o){var l;switch(gJ(o,0)){case"$":return"$";case"&":return t;case"`":return wJ(e,0,n);case"'":return wJ(e,s);case"<":l=i[wJ(o,1,-1)];break;default:var c=+o;if(0===c)return A;if(c>a){var h=pJ(c/10);return 0===h?A:h<=a?void 0===r[h-1]?gJ(o,1):r[h-1]+gJ(o,1):A}l=r[c-1]}return void 0===l?"":l})},PJ=z$,NJ=tJ,TJ=dj("replace"),DJ=Math.max,RJ=Math.min,HJ=_J([].concat),jJ=_J([].push),WJ=_J("".indexOf),VJ=_J("".slice),KJ=function(t){return void 0===t?t:String(t)},GJ="$0"==="a".replace(/./,"$0"),zJ=!!/./[TJ]&&""===/./[TJ]("a","$0"),qJ=!xJ(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")});CJ("replace",function(t,e,n){var r=zJ?"$":"$0";return[function(t,n){var r=QJ(this),i=FJ(t)?MJ(t,TJ):void 0;return i?BJ(i,t,r,n):BJ(e,IJ(r),t,n)},function(t,i){var A=EJ(this),s=IJ(t);if("string"==typeof i&&-1===WJ(i,r)&&-1===WJ(i,"$<")){var a=n(e,A,s,i);if(a.done)return a.value}var o=SJ(i);o||(i=IJ(i));var l,c=IJ(PJ(A)),h=-1!==WJ(c,"g");h&&(l=-1!==WJ(c,"u"),A.lastIndex=0);for(var u,d=[];null!==(u=NJ(A,s))&&(jJ(d,u),h);){""===IJ(u[0])&&(A.lastIndex=kJ(s,UJ(A.lastIndex),l))}for(var f="",p=0,g=0;g<d.length;g++){for(var m,w=IJ((u=d[g])[0]),v=DJ(RJ(LJ(u.index),s.length),0),y=[],b=1;b<u.length;b++)jJ(y,KJ(u[b]));var B=u.groups;if(o){var _=HJ([w],y,v,s);void 0!==B&&jJ(_,B),m=IJ(bJ(i,void 0,_))}else m=OJ(w,s,v,y,B,i);v>=p&&(f+=VJ(s,p,v)+m,p=v+w.length)}return f+VJ(s,p)}]},!qJ||!GJ||zJ);var XJ,YJ=ZR,$J=NR,JJ=dj("match"),ZJ=function(t){var e;return YJ(t)&&(void 0!==(e=t[JJ])?!!e:"RegExp"===$J(t))},tZ=TypeError,eZ=function(t){if(ZJ(t))throw new tZ("The method doesn't accept regular expressions");return t},nZ=dj("match"),rZ=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[nZ]=!1,"/./"[t](e)}catch(r){}}return!1},iZ=lK,AZ=xG,sZ=pR.f,aZ=yV,oZ=uY,lZ=eZ,cZ=GR,hZ=rZ,uZ=AZ("".slice),dZ=Math.min,fZ=hZ("startsWith");iZ({target:"String",proto:!0,forced:!!(fZ||(XJ=sZ(String.prototype,"startsWith"),!XJ||XJ.writable))&&!fZ},{startsWith:function(t){var e=oZ(cZ(this));lZ(t);var n=aZ(dZ(arguments.length>1?arguments[1]:void 0,e.length)),r=oZ(t);return uZ(e,n,n+r.length)===r}});var pZ=dj,gZ=GY,mZ=Dj.f,wZ=pZ("unscopables"),vZ=Array.prototype;void 0===vZ[wZ]&&mZ(vZ,wZ,{configurable:!0,value:gZ(null)});var yZ,bZ,BZ,_Z=!gR(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),CZ=ZH,xZ=$R,EZ=YH,SZ=_Z,FZ=CW("IE_PROTO"),LZ=Object,UZ=LZ.prototype,IZ=SZ?LZ.getPrototypeOf:function(t){var e=EZ(t);if(CZ(e,FZ))return e[FZ];var n=e.constructor;return xZ(n)&&e instanceof n?n.prototype:e instanceof LZ?UZ:null},QZ=gR,kZ=$R,MZ=ZR,OZ=IZ,PZ=lV,NZ=dj("iterator"),TZ=!1;[].keys&&("next"in(BZ=[].keys())?(bZ=OZ(OZ(BZ)))!==Object.prototype&&(yZ=bZ):TZ=!0),(!MZ(yZ)||QZ(function(){var t={};return yZ[NZ].call(t)!==t}))&&(yZ={}),kZ(yZ[NZ])||PZ(yZ,NZ,function(){return this});var DZ={IteratorPrototype:yZ,BUGGY_SAFARI_ITERATORS:TZ},RZ=DZ.IteratorPrototype,HZ=GY,jZ=FR,WZ=IK,VZ=Jq,KZ=function(){return this},GZ=lK,zZ=bR,qZ=$R,XZ=function(t,e,n,r){var i=e+" Iterator";return t.prototype=HZ(RZ,{next:jZ(+!r,n)}),WZ(t,i,!1),VZ[i]=KZ,t},YZ=IZ,$Z=SK,JZ=IK,ZZ=iW,t0=lV,e0=Jq,n0=hW.PROPER,r0=hW.CONFIGURABLE,i0=DZ.IteratorPrototype,A0=DZ.BUGGY_SAFARI_ITERATORS,s0=dj("iterator"),a0="keys",o0="values",l0="entries",c0=function(){return this},h0=XR,u0=function(t){vZ[wZ][t]=!0},d0=Jq,f0=DW,p0=Dj.f,g0=function(t,e,n,r,i,A,s){XZ(n,e,r);var a,o,l,c=function(t){if(t===i&&p)return p;if(!A0&&t&&t in d)return d[t];switch(t){case a0:case o0:case l0:return function(){return new n(this,t)}}return function(){return new n(this)}},h=e+" Iterator",u=!1,d=t.prototype,f=d[s0]||d["@@iterator"]||i&&d[i],p=!A0&&f||c(i),g="Array"===e&&d.entries||f;if(g&&(a=YZ(g.call(new t)))!==Object.prototype&&a.next&&(YZ(a)!==i0&&($Z?$Z(a,i0):qZ(a[s0])||t0(a,s0,c0)),JZ(a,h,!0)),n0&&i===o0&&f&&f.name!==o0&&(r0?ZZ(d,"name",o0):(u=!0,p=function(){return zZ(f,this)})),i)if(o={values:c(o0),keys:A?p:c(a0),entries:c(l0)},s)for(l in o)(A0||u||!(l in d))&&t0(d,l,o[l]);else GZ({target:e,proto:!0,forced:A0||u},o);return d[s0]!==p&&t0(d,s0,p,{name:i}),e0[e]=p,o},m0=function(t,e){return{value:t,done:e}},w0=mR,v0="Array Iterator",y0=f0.set,b0=f0.getterFor(v0),B0=g0(Array,"Array",function(t,e){y0(this,{type:v0,target:h0(t),index:0,kind:e})},function(){var t=b0(this),e=t.target,n=t.index++;if(!e||n>=e.length)return t.target=null,m0(void 0,!0);switch(t.kind){case"keys":return m0(n,!1);case"values":return m0(e[n],!1)}return m0([n,e[n]],!1)},"values"),_0=d0.Arguments=d0.Array;if(u0("keys"),u0("values"),u0("entries"),w0&&"values"!==_0.name)try{p0(_0,"name",{value:"values"})}catch(o3){}var C0=Sj("span").classList,x0=C0&&C0.constructor&&C0.constructor.prototype,E0=x0===Object.prototype?void 0:x0,S0=fR,F0={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},L0=E0,U0=B0,I0=iW,Q0=IK,k0=dj("iterator"),M0=U0.values,O0=function(t,e){if(t){if(t[k0]!==M0)try{I0(t,k0,M0)}catch(o3){t[k0]=M0}if(Q0(t,e,!0),F0[e])for(var n in U0)if(t[n]!==U0[n])try{I0(t,n,U0[n])}catch(o3){t[n]=U0[n]}}};for(var P0 in F0)O0(S0[P0]&&S0[P0].prototype,P0);function N0(t){var e=function(t,e){if("object"!=$p(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=$p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==$p(e)?e:e+""}function T0(t,e,n){return(e=N0(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}O0(L0,"DOMTokenList");var D0,R0=LH,H0=YH,j0=jR,W0=BV,V0=TypeError,K0="Reduce of empty array with no initial value",G0={left:(D0=!1,function(t,e,n,r){var i=H0(t),A=j0(i),s=W0(i);if(R0(e),0===s&&n<2)throw new V0(K0);var a=D0?s-1:0,o=D0?-1:1;if(n<2)for(;;){if(a in A){r=A[a],a+=o;break}if(a+=o,D0?a<0:s<=a)throw new V0(K0)}for(;D0?a>=0:s>a;a+=o)a in A&&(r=e(r,A[a],a,i));return r})},z0=gR,q0=function(t,e){var n=[][t];return!!n&&z0(function(){n.call(null,e||function(){return 1},1)})},X0=G0.left;lK({target:"Array",proto:!0,forced:!pK&&dH>79&&dH<83||!q0("reduce")},{reduce:function(t){var e=arguments.length;return X0(this,t,e,e>1?arguments[1]:void 0)}});var Y0=lK,$0=xG,J0=pR.f,Z0=yV,t1=uY,e1=eZ,n1=GR,r1=rZ,i1=$0("".slice),A1=Math.min,s1=r1("endsWith"),a1=!s1&&!!function(){var t=J0(String.prototype,"endsWith");return t&&!t.writable}();Y0({target:"String",proto:!0,forced:!a1&&!s1},{endsWith:function(t){var e=t1(n1(this));e1(t);var n=arguments.length>1?arguments[1]:void 0,r=e.length,i=void 0===n?r:A1(Z0(n),r),A=t1(t);return i1(e,i-A.length,i)===A}});var o1=bR,l1=kR,c1=F$,h1=Vj,u1=ZR,d1=GR,f1=mG,p1=N$,g1=yV,m1=uY,w1=QH,v1=tJ,y1=gR,b1=vY.UNSUPPORTED_Y,B1=Math.min,_1=l1([].push),C1=l1("".slice),x1=!y1(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2!==n.length||"a"!==n[0]||"b"!==n[1]}),E1="c"==="abbc".split(/(b)*/)[1]||4!=="test".split(/(?:)/,-1).length||2!=="ab".split(/(?:ab)*/).length||4!==".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length;c1("split",function(t,e,n){var r="0".split(void 0,0).length?function(t,n){return void 0===t&&0===n?[]:o1(e,this,t,n)}:e;return[function(e,n){var i=d1(this),A=u1(e)?w1(e,t):void 0;return A?o1(A,e,i,n):o1(r,m1(i),e,n)},function(t,i){var A=h1(this),s=m1(t);if(!E1){var a=n(r,A,s,i,r!==e);if(a.done)return a.value}var o=f1(A,RegExp),l=A.unicode,c=(A.ignoreCase?"i":"")+(A.multiline?"m":"")+(A.unicode?"u":"")+(b1?"g":"y"),h=new o(b1?"^(?:"+A.source+")":A,c),u=void 0===i?4294967295:i>>>0;if(0===u)return[];if(0===s.length)return null===v1(h,s)?[s]:[];for(var d=0,f=0,p=[];f<s.length;){h.lastIndex=b1?0:f;var g,m=v1(h,b1?C1(s,f):s);if(null===m||(g=B1(g1(h.lastIndex+(b1?f:0)),s.length))===d)f=p1(s,f,l);else{if(_1(p,C1(s,d,f)),p.length===u)return p;for(var w=1;w<=m.length-1;w++)if(_1(p,m[w]),p.length===u)return p;f=d=g}}return _1(p,C1(s,d)),p}]},E1||!x1,b1);var S1={exports:{}},F1={exports:{}};(function(){var t,e,n,r,i,A;"undefined"!=typeof performance&&null!==performance&&performance.now?F1.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(F1.exports=function(){return(t()-i)/1e6},e=process.hrtime,r=(t=function(){var t;return 1e9*(t=e())[0]+t[1]})(),A=1e9*process.uptime(),i=r-A):Date.now?(F1.exports=function(){return Date.now()-n},n=Date.now()):(F1.exports=function(){return(new Date).getTime()-n},n=(new Date).getTime())}).call(Jc);for(var L1=F1.exports,U1="undefined"==typeof window?Jc:window,I1=["moz","webkit"],Q1="AnimationFrame",k1=U1["request"+Q1],M1=U1["cancel"+Q1]||U1["cancelRequest"+Q1],O1=0;!k1&&O1<I1.length;O1++)k1=U1[I1[O1]+"Request"+Q1],M1=U1[I1[O1]+"Cancel"+Q1]||U1[I1[O1]+"CancelRequest"+Q1];if(!k1||!M1){var P1=0,N1=0,T1=[],D1=1e3/60;k1=function(t){if(0===T1.length){var e=L1(),n=Math.max(0,D1-(e-P1));P1=n+e,setTimeout(function(){var t=T1.slice(0);T1.length=0;for(var e=0;e<t.length;e++)if(!t[e].cancelled)try{t[e].callback(P1)}catch(hw){setTimeout(function(){throw hw},0)}},Math.round(n))}return T1.push({handle:++N1,callback:t,cancelled:!1}),N1},M1=function(t){for(var e=0;e<T1.length;e++)T1[e].handle===t&&(T1[e].cancelled=!0)}}S1.exports=function(t){return k1.call(U1,t)},S1.exports.cancel=function(){M1.apply(U1,arguments)},S1.exports.polyfill=function(t){t||(t=U1),t.requestAnimationFrame=k1,t.cancelAnimationFrame=M1};const R1=Zc(S1.exports);var H1,j1="\t\n\v\f\r \u2028\u2029\ufeff",W1=GR,V1=uY,K1=j1,G1=kR("".replace),z1=RegExp("^["+K1+"]+"),q1=RegExp("(^|[^"+K1+"])["+K1+"]+$"),X1={trim:(H1=3,function(t){var e=V1(W1(t));return 1&H1&&(e=G1(e,z1,"")),2&H1&&(e=G1(e,q1,"$1")),e})},Y1=hW.PROPER,$1=gR,J1=j1,Z1=X1.trim;lK({target:"String",proto:!0,forced:function(t){return $1(function(){return!!J1[t]()||"
"!=="
"[t]()||Y1&&J1[t].name!==t})}("trim")},{trim:function(){return Z1(this)}});var t2=function(t){this.ok=!1,this.alpha=1,"#"==t.charAt(0)&&(t=t.substr(1,6)),t=(t=t.replace(/ /g,"")).toLowerCase();var e={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};t=e[t]||t;for(var n=[{re:/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*((?:\d?\.)?\d)\)$/,example:["rgba(123, 234, 45, 0.8)","rgba(255,234,245,1.0)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3]),parseFloat(t[4])]}},{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}],r=0;r<n.length;r++){var i=n[r].re,A=n[r].process,s=i.exec(t);if(s){var a=A(s);this.r=a[0],this.g=a[1],this.b=a[2],a.length>3&&(this.alpha=a[3]),this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.alpha=this.alpha<0?0:this.alpha>1||isNaN(this.alpha)?1:this.alpha,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.alpha+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),n=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==n.length&&(n="0"+n),"#"+t+e+n},this.getHelpXML=function(){for(var t=new Array,r=0;r<n.length;r++)for(var i=n[r].example,A=0;A<i.length;A++)t[t.length]=i[A];for(var s in e)t[t.length]=s;var a=document.createElement("ul");a.setAttribute("id","rgbcolor-examples");for(r=0;r<t.length;r++)try{var o=document.createElement("li"),l=new RGBColor(t[r]),c=document.createElement("div");c.style.cssText="margin: 3px; border: 1px solid black; background:"+l.toHex()+"; color:"+l.toHex(),c.appendChild(document.createTextNode("test"));var h=document.createTextNode(" "+t[r]+" -> "+l.toRGB()+" -> "+l.toHex());o.appendChild(c),o.appendChild(h),a.appendChild(o)}catch(hw){}return a}};const e2=Zc(t2);var n2=lK,r2=EV.indexOf,i2=q0,A2=xG([].indexOf),s2=!!A2&&1/A2([1],1,-0)<0;n2({target:"Array",proto:!0,forced:s2||!i2("indexOf")},{indexOf:function(t){var e=arguments.length>1?arguments[1]:void 0;return s2?A2(this,t,e)||0:r2(this,t,e)}});var a2=lK,o2=eZ,l2=GR,c2=uY,h2=rZ,u2=kR("".indexOf);a2({target:"String",proto:!0,forced:!h2("includes")},{includes:function(t){return!!~u2(c2(l2(this)),c2(o2(t)),arguments.length>1?arguments[1]:void 0)}});var d2=NR,f2=lK,p2=Array.isArray||function(t){return"Array"===d2(t)},g2=kR([].reverse),m2=[1,2];f2({target:"Array",proto:!0,forced:String(m2)===String(m2.reverse())},{reverse:function(){return p2(this)&&(this.length=this.length),g2(this)}});
|
|
343
343
|
/*! *****************************************************************************
|
|
@@ -354,5 +354,5 @@ function uD(t){return(uD="function"==typeof Symbol&&"symbol"==typeof Symbol.iter
|
|
|
354
354
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
355
355
|
PERFORMANCE OF THIS SOFTWARE.
|
|
356
356
|
***************************************************************************** */
|
|
357
|
-
var w2=function(t,e){return(w2=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function v2(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}w2(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function y2(t,e){var n=t[0],r=t[1];return[n*Math.cos(e)-r*Math.sin(e),n*Math.sin(e)+r*Math.cos(e)]}function b2(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0;n<t.length;n++)if("number"!=typeof t[n])throw new Error("assertNumbers arguments["+n+"] is not a number. "+typeof t[n]+" == typeof "+t[n]);return!0}var B2=Math.PI;function _2(t,e,n){t.lArcFlag=0===t.lArcFlag?0:1,t.sweepFlag=0===t.sweepFlag?0:1;var r=t.rX,i=t.rY,A=t.x,s=t.y;r=Math.abs(t.rX),i=Math.abs(t.rY);var a=y2([(e-A)/2,(n-s)/2],-t.xRot/180*B2),o=a[0],l=a[1],c=Math.pow(o,2)/Math.pow(r,2)+Math.pow(l,2)/Math.pow(i,2);1<c&&(r*=Math.sqrt(c),i*=Math.sqrt(c)),t.rX=r,t.rY=i;var h=Math.pow(r,2)*Math.pow(l,2)+Math.pow(i,2)*Math.pow(o,2),u=(t.lArcFlag!==t.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(r,2)*Math.pow(i,2)-h)/h)),d=r*l/i*u,f=-i*o/r*u,p=y2([d,f],t.xRot/180*B2);t.cX=p[0]+(e+A)/2,t.cY=p[1]+(n+s)/2,t.phi1=Math.atan2((l-f)/i,(o-d)/r),t.phi2=Math.atan2((-l-f)/i,(-o-d)/r),0===t.sweepFlag&&t.phi2>t.phi1&&(t.phi2-=2*B2),1===t.sweepFlag&&t.phi2<t.phi1&&(t.phi2+=2*B2),t.phi1*=180/B2,t.phi2*=180/B2}function C2(t,e,n){b2(t,e,n);var r=t*t+e*e-n*n;if(0>r)return[];if(0===r)return[[t*n/(t*t+e*e),e*n/(t*t+e*e)]];var i=Math.sqrt(r);return[[(t*n+e*i)/(t*t+e*e),(e*n-t*i)/(t*t+e*e)],[(t*n-e*i)/(t*t+e*e),(e*n+t*i)/(t*t+e*e)]]}var x2,E2=Math.PI/180;function S2(t,e,n){return(1-n)*t+n*e}function F2(t,e,n,r){return t+Math.cos(r/180*B2)*e+Math.sin(r/180*B2)*n}function L2(t,e,n,r){var i=1e-6,A=e-t,s=n-e,a=3*A+3*(r-n)-6*s,o=6*(s-A),l=3*A;return Math.abs(a)<i?[-l/o]:function(t,e,n){var r=t*t/4-e;if(r<-n)return[];if(r<=n)return[-t/2];var i=Math.sqrt(r);return[-t/2-i,-t/2+i]}(o/a,l/a,i)}function U2(t,e,n,r,i){var A=1-i;return t*(A*A*A)+e*(3*A*A*i)+n*(3*A*i*i)+r*(i*i*i)}!function(t){function e(){return i(function(t,e,n){return t.relative&&(void 0!==t.x1&&(t.x1+=e),void 0!==t.y1&&(t.y1+=n),void 0!==t.x2&&(t.x2+=e),void 0!==t.y2&&(t.y2+=n),void 0!==t.x&&(t.x+=e),void 0!==t.y&&(t.y+=n),t.relative=!1),t})}function n(){var t=NaN,e=NaN,n=NaN,r=NaN;return i(function(i,A,s){return i.type&P2.SMOOTH_CURVE_TO&&(i.type=P2.CURVE_TO,t=isNaN(t)?A:t,e=isNaN(e)?s:e,i.x1=i.relative?A-t:2*A-t,i.y1=i.relative?s-e:2*s-e),i.type&P2.CURVE_TO?(t=i.relative?A+i.x2:i.x2,e=i.relative?s+i.y2:i.y2):(t=NaN,e=NaN),i.type&P2.SMOOTH_QUAD_TO&&(i.type=P2.QUAD_TO,n=isNaN(n)?A:n,r=isNaN(r)?s:r,i.x1=i.relative?A-n:2*A-n,i.y1=i.relative?s-r:2*s-r),i.type&P2.QUAD_TO?(n=i.relative?A+i.x1:i.x1,r=i.relative?s+i.y1:i.y1):(n=NaN,r=NaN),i})}function r(){var t=NaN,e=NaN;return i(function(n,r,i){if(n.type&P2.SMOOTH_QUAD_TO&&(n.type=P2.QUAD_TO,t=isNaN(t)?r:t,e=isNaN(e)?i:e,n.x1=n.relative?r-t:2*r-t,n.y1=n.relative?i-e:2*i-e),n.type&P2.QUAD_TO){t=n.relative?r+n.x1:n.x1,e=n.relative?i+n.y1:n.y1;var A=n.x1,s=n.y1;n.type=P2.CURVE_TO,n.x1=((n.relative?0:r)+2*A)/3,n.y1=((n.relative?0:i)+2*s)/3,n.x2=(n.x+2*A)/3,n.y2=(n.y+2*s)/3}else t=NaN,e=NaN;return n})}function i(t){var e=0,n=0,r=NaN,i=NaN;return function(A){if(isNaN(r)&&!(A.type&P2.MOVE_TO))throw new Error("path must start with moveto");var s=t(A,e,n,r,i);return A.type&P2.CLOSE_PATH&&(e=r,n=i),void 0!==A.x&&(e=A.relative?e+A.x:A.x),void 0!==A.y&&(n=A.relative?n+A.y:A.y),A.type&P2.MOVE_TO&&(r=e,i=n),s}}function A(t,e,n,r,A,s){return b2(t,e,n,r,A,s),i(function(i,a,o,l){var c=i.x1,h=i.x2,u=i.relative&&!isNaN(l),d=void 0!==i.x?i.x:u?0:a,f=void 0!==i.y?i.y:u?0:o;function p(t){return t*t}i.type&P2.HORIZ_LINE_TO&&0!==e&&(i.type=P2.LINE_TO,i.y=i.relative?0:o),i.type&P2.VERT_LINE_TO&&0!==n&&(i.type=P2.LINE_TO,i.x=i.relative?0:a),void 0!==i.x&&(i.x=i.x*t+f*n+(u?0:A)),void 0!==i.y&&(i.y=d*e+i.y*r+(u?0:s)),void 0!==i.x1&&(i.x1=i.x1*t+i.y1*n+(u?0:A)),void 0!==i.y1&&(i.y1=c*e+i.y1*r+(u?0:s)),void 0!==i.x2&&(i.x2=i.x2*t+i.y2*n+(u?0:A)),void 0!==i.y2&&(i.y2=h*e+i.y2*r+(u?0:s));var g=t*r-e*n;if(void 0!==i.xRot&&(1!==t||0!==e||0!==n||1!==r))if(0===g)delete i.rX,delete i.rY,delete i.xRot,delete i.lArcFlag,delete i.sweepFlag,i.type=P2.LINE_TO;else{var m=i.xRot*Math.PI/180,w=Math.sin(m),v=Math.cos(m),y=1/p(i.rX),b=1/p(i.rY),B=p(v)*y+p(w)*b,_=2*w*v*(y-b),C=p(w)*y+p(v)*b,x=B*r*r-_*e*r+C*e*e,E=_*(t*r+e*n)-2*(B*n*r+C*t*e),S=B*n*n-_*t*n+C*t*t,F=(Math.atan2(E,x-S)+Math.PI)%Math.PI/2,L=Math.sin(F),U=Math.cos(F);i.rX=Math.abs(g)/Math.sqrt(x*p(U)+E*L*U+S*p(L)),i.rY=Math.abs(g)/Math.sqrt(x*p(L)-E*L*U+S*p(U)),i.xRot=180*F/Math.PI}return void 0!==i.sweepFlag&&0>g&&(i.sweepFlag=+!i.sweepFlag),i})}t.ROUND=function(t){function e(e){return Math.round(e*t)/t}return void 0===t&&(t=1e13),b2(t),function(t){return void 0!==t.x1&&(t.x1=e(t.x1)),void 0!==t.y1&&(t.y1=e(t.y1)),void 0!==t.x2&&(t.x2=e(t.x2)),void 0!==t.y2&&(t.y2=e(t.y2)),void 0!==t.x&&(t.x=e(t.x)),void 0!==t.y&&(t.y=e(t.y)),void 0!==t.rX&&(t.rX=e(t.rX)),void 0!==t.rY&&(t.rY=e(t.rY)),t}},t.TO_ABS=e,t.TO_REL=function(){return i(function(t,e,n){return t.relative||(void 0!==t.x1&&(t.x1-=e),void 0!==t.y1&&(t.y1-=n),void 0!==t.x2&&(t.x2-=e),void 0!==t.y2&&(t.y2-=n),void 0!==t.x&&(t.x-=e),void 0!==t.y&&(t.y-=n),t.relative=!0),t})},t.NORMALIZE_HVZ=function(t,e,n){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===n&&(n=!0),i(function(r,i,A,s,a){if(isNaN(s)&&!(r.type&P2.MOVE_TO))throw new Error("path must start with moveto");return e&&r.type&P2.HORIZ_LINE_TO&&(r.type=P2.LINE_TO,r.y=r.relative?0:A),n&&r.type&P2.VERT_LINE_TO&&(r.type=P2.LINE_TO,r.x=r.relative?0:i),t&&r.type&P2.CLOSE_PATH&&(r.type=P2.LINE_TO,r.x=r.relative?s-i:s,r.y=r.relative?a-A:a),r.type&P2.ARC&&(0===r.rX||0===r.rY)&&(r.type=P2.LINE_TO,delete r.rX,delete r.rY,delete r.xRot,delete r.lArcFlag,delete r.sweepFlag),r})},t.NORMALIZE_ST=n,t.QT_TO_C=r,t.INFO=i,t.SANITIZE=function(t){void 0===t&&(t=0),b2(t);var e=NaN,n=NaN,r=NaN,A=NaN;return i(function(i,s,a,o,l){var c=Math.abs,h=!1,u=0,d=0;if(i.type&P2.SMOOTH_CURVE_TO&&(u=isNaN(e)?0:s-e,d=isNaN(n)?0:a-n),i.type&(P2.CURVE_TO|P2.SMOOTH_CURVE_TO)?(e=i.relative?s+i.x2:i.x2,n=i.relative?a+i.y2:i.y2):(e=NaN,n=NaN),i.type&P2.SMOOTH_QUAD_TO?(r=isNaN(r)?s:2*s-r,A=isNaN(A)?a:2*a-A):i.type&P2.QUAD_TO?(r=i.relative?s+i.x1:i.x1,A=i.relative?a+i.y1:i.y2):(r=NaN,A=NaN),i.type&P2.LINE_COMMANDS||i.type&P2.ARC&&(0===i.rX||0===i.rY||!i.lArcFlag)||i.type&P2.CURVE_TO||i.type&P2.SMOOTH_CURVE_TO||i.type&P2.QUAD_TO||i.type&P2.SMOOTH_QUAD_TO){var f=void 0===i.x?0:i.relative?i.x:i.x-s,p=void 0===i.y?0:i.relative?i.y:i.y-a;u=isNaN(r)?void 0===i.x1?u:i.relative?i.x:i.x1-s:r-s,d=isNaN(A)?void 0===i.y1?d:i.relative?i.y:i.y1-a:A-a;var g=void 0===i.x2?0:i.relative?i.x:i.x2-s,m=void 0===i.y2?0:i.relative?i.y:i.y2-a;c(f)<=t&&c(p)<=t&&c(u)<=t&&c(d)<=t&&c(g)<=t&&c(m)<=t&&(h=!0)}return i.type&P2.CLOSE_PATH&&c(s-o)<=t&&c(a-l)<=t&&(h=!0),h?[]:i})},t.MATRIX=A,t.ROTATE=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=0),b2(t,e,n);var r=Math.sin(t),i=Math.cos(t);return A(i,r,-r,i,e-e*i+n*r,n-e*r-n*i)},t.TRANSLATE=function(t,e){return void 0===e&&(e=0),b2(t,e),A(1,0,0,1,t,e)},t.SCALE=function(t,e){return void 0===e&&(e=t),b2(t,e),A(t,0,0,e,0,0)},t.SKEW_X=function(t){return b2(t),A(1,0,Math.atan(t),1,0,0)},t.SKEW_Y=function(t){return b2(t),A(1,Math.atan(t),0,1,0,0)},t.X_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),b2(t),A(-1,0,0,1,t,0)},t.Y_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),b2(t),A(1,0,0,-1,0,t)},t.A_TO_C=function(){return i(function(t,e,n){return P2.ARC===t.type?function(t,e,n){var r,i,A,s;t.cX||_2(t,e,n);for(var a=Math.min(t.phi1,t.phi2),o=Math.max(t.phi1,t.phi2)-a,l=Math.ceil(o/90),c=new Array(l),h=e,u=n,d=0;d<l;d++){var f=S2(t.phi1,t.phi2,d/l),p=S2(t.phi1,t.phi2,(d+1)/l),g=p-f,m=4/3*Math.tan(g*E2/4),w=[Math.cos(f*E2)-m*Math.sin(f*E2),Math.sin(f*E2)+m*Math.cos(f*E2)],v=w[0],y=w[1],b=[Math.cos(p*E2),Math.sin(p*E2)],B=b[0],_=b[1],C=[B+m*Math.sin(p*E2),_-m*Math.cos(p*E2)],x=C[0],E=C[1];c[d]={relative:t.relative,type:P2.CURVE_TO};var S=function(e,n){var r=y2([e*t.rX,n*t.rY],t.xRot),i=r[0],A=r[1];return[t.cX+i,t.cY+A]};r=S(v,y),c[d].x1=r[0],c[d].y1=r[1],i=S(x,E),c[d].x2=i[0],c[d].y2=i[1],A=S(B,_),c[d].x=A[0],c[d].y=A[1],t.relative&&(c[d].x1-=h,c[d].y1-=u,c[d].x2-=h,c[d].y2-=u,c[d].x-=h,c[d].y-=u),h=(s=[c[d].x,c[d].y])[0],u=s[1]}return c}(t,t.relative?0:e,t.relative?0:n):t})},t.ANNOTATE_ARCS=function(){return i(function(t,e,n){return t.relative&&(e=0,n=0),P2.ARC===t.type&&_2(t,e,n),t})},t.CLONE=function(){return function(t){var e={};for(var n in t)e[n]=t[n];return e}},t.CALCULATE_BOUNDS=function(){var t=e(),A=r(),s=n(),a=i(function(e,n,r){var i=s(A(t(function(t){var e={};for(var n in t)e[n]=t[n];return e}(e))));function o(t){t>a.maxX&&(a.maxX=t),t<a.minX&&(a.minX=t)}function l(t){t>a.maxY&&(a.maxY=t),t<a.minY&&(a.minY=t)}if(i.type&P2.DRAWING_COMMANDS&&(o(n),l(r)),i.type&P2.HORIZ_LINE_TO&&o(i.x),i.type&P2.VERT_LINE_TO&&l(i.y),i.type&P2.LINE_TO&&(o(i.x),l(i.y)),i.type&P2.CURVE_TO){o(i.x),l(i.y);for(var c=0,h=L2(n,i.x1,i.x2,i.x);c<h.length;c++)0<(S=h[c])&&1>S&&o(U2(n,i.x1,i.x2,i.x,S));for(var u=0,d=L2(r,i.y1,i.y2,i.y);u<d.length;u++)0<(S=d[u])&&1>S&&l(U2(r,i.y1,i.y2,i.y,S))}if(i.type&P2.ARC){o(i.x),l(i.y),_2(i,n,r);for(var f=i.xRot/180*Math.PI,p=Math.cos(f)*i.rX,g=Math.sin(f)*i.rX,m=-Math.sin(f)*i.rY,w=Math.cos(f)*i.rY,v=i.phi1<i.phi2?[i.phi1,i.phi2]:-180>i.phi2?[i.phi2+360,i.phi1+360]:[i.phi2,i.phi1],y=v[0],b=v[1],B=function(t){var e=t[0],n=t[1],r=180*Math.atan2(n,e)/Math.PI;return r<y?r+360:r},_=0,C=C2(m,-p,0).map(B);_<C.length;_++)(S=C[_])>y&&S<b&&o(F2(i.cX,p,m,S));for(var x=0,E=C2(w,-g,0).map(B);x<E.length;x++){var S;(S=E[x])>y&&S<b&&l(F2(i.cY,g,w,S))}}return e});return a.minX=1/0,a.maxX=-1/0,a.minY=1/0,a.maxY=-1/0,a}}(x2||(x2={}));var I2,Q2=function(){function t(){}return t.prototype.round=function(t){return this.transform(x2.ROUND(t))},t.prototype.toAbs=function(){return this.transform(x2.TO_ABS())},t.prototype.toRel=function(){return this.transform(x2.TO_REL())},t.prototype.normalizeHVZ=function(t,e,n){return this.transform(x2.NORMALIZE_HVZ(t,e,n))},t.prototype.normalizeST=function(){return this.transform(x2.NORMALIZE_ST())},t.prototype.qtToC=function(){return this.transform(x2.QT_TO_C())},t.prototype.aToC=function(){return this.transform(x2.A_TO_C())},t.prototype.sanitize=function(t){return this.transform(x2.SANITIZE(t))},t.prototype.translate=function(t,e){return this.transform(x2.TRANSLATE(t,e))},t.prototype.scale=function(t,e){return this.transform(x2.SCALE(t,e))},t.prototype.rotate=function(t,e,n){return this.transform(x2.ROTATE(t,e,n))},t.prototype.matrix=function(t,e,n,r,i,A){return this.transform(x2.MATRIX(t,e,n,r,i,A))},t.prototype.skewX=function(t){return this.transform(x2.SKEW_X(t))},t.prototype.skewY=function(t){return this.transform(x2.SKEW_Y(t))},t.prototype.xSymmetry=function(t){return this.transform(x2.X_AXIS_SYMMETRY(t))},t.prototype.ySymmetry=function(t){return this.transform(x2.Y_AXIS_SYMMETRY(t))},t.prototype.annotateArcs=function(){return this.transform(x2.ANNOTATE_ARCS())},t}(),k2=function(t){return" "===t||"\t"===t||"\r"===t||"\n"===t},M2=function(t){return"0".charCodeAt(0)<=t.charCodeAt(0)&&t.charCodeAt(0)<="9".charCodeAt(0)},O2=function(t){function e(){var e=t.call(this)||this;return e.curNumber="",e.curCommandType=-1,e.curCommandRelative=!1,e.canParseCommandOrComma=!0,e.curNumberHasExp=!1,e.curNumberHasExpDigits=!1,e.curNumberHasDecimal=!1,e.curArgs=[],e}return v2(e,t),e.prototype.finish=function(t){if(void 0===t&&(t=[]),this.parse(" ",t),0!==this.curArgs.length||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return t},e.prototype.parse=function(t,e){var n=this;void 0===e&&(e=[]);for(var r=function(t){e.push(t),n.curArgs.length=0,n.canParseCommandOrComma=!0},i=0;i<t.length;i++){var A=t[i],s=!(this.curCommandType!==P2.ARC||3!==this.curArgs.length&&4!==this.curArgs.length||1!==this.curNumber.length||"0"!==this.curNumber&&"1"!==this.curNumber),a=M2(A)&&("0"===this.curNumber&&"0"===A||s);if(!M2(A)||a)if("e"!==A&&"E"!==A)if("-"!==A&&"+"!==A||!this.curNumberHasExp||this.curNumberHasExpDigits)if("."!==A||this.curNumberHasExp||this.curNumberHasDecimal||s){if(this.curNumber&&-1!==this.curCommandType){var o=Number(this.curNumber);if(isNaN(o))throw new SyntaxError("Invalid number ending at "+i);if(this.curCommandType===P2.ARC)if(0===this.curArgs.length||1===this.curArgs.length){if(0>o)throw new SyntaxError('Expected positive number, got "'+o+'" at index "'+i+'"')}else if((3===this.curArgs.length||4===this.curArgs.length)&&"0"!==this.curNumber&&"1"!==this.curNumber)throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+i+'"');this.curArgs.push(o),this.curArgs.length===N2[this.curCommandType]&&(P2.HORIZ_LINE_TO===this.curCommandType?r({type:P2.HORIZ_LINE_TO,relative:this.curCommandRelative,x:o}):P2.VERT_LINE_TO===this.curCommandType?r({type:P2.VERT_LINE_TO,relative:this.curCommandRelative,y:o}):this.curCommandType===P2.MOVE_TO||this.curCommandType===P2.LINE_TO||this.curCommandType===P2.SMOOTH_QUAD_TO?(r({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),P2.MOVE_TO===this.curCommandType&&(this.curCommandType=P2.LINE_TO)):this.curCommandType===P2.CURVE_TO?r({type:P2.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===P2.SMOOTH_CURVE_TO?r({type:P2.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===P2.QUAD_TO?r({type:P2.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===P2.ARC&&r({type:P2.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!k2(A))if(","===A&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if("+"!==A&&"-"!==A&&"."!==A)if(a)this.curNumber=A,this.curNumberHasDecimal=!1;else{if(0!==this.curArgs.length)throw new SyntaxError("Unterminated command at index "+i+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+A+'" at index '+i+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,"z"!==A&&"Z"!==A)if("h"===A||"H"===A)this.curCommandType=P2.HORIZ_LINE_TO,this.curCommandRelative="h"===A;else if("v"===A||"V"===A)this.curCommandType=P2.VERT_LINE_TO,this.curCommandRelative="v"===A;else if("m"===A||"M"===A)this.curCommandType=P2.MOVE_TO,this.curCommandRelative="m"===A;else if("l"===A||"L"===A)this.curCommandType=P2.LINE_TO,this.curCommandRelative="l"===A;else if("c"===A||"C"===A)this.curCommandType=P2.CURVE_TO,this.curCommandRelative="c"===A;else if("s"===A||"S"===A)this.curCommandType=P2.SMOOTH_CURVE_TO,this.curCommandRelative="s"===A;else if("q"===A||"Q"===A)this.curCommandType=P2.QUAD_TO,this.curCommandRelative="q"===A;else if("t"===A||"T"===A)this.curCommandType=P2.SMOOTH_QUAD_TO,this.curCommandRelative="t"===A;else{if("a"!==A&&"A"!==A)throw new SyntaxError('Unexpected character "'+A+'" at index '+i+".");this.curCommandType=P2.ARC,this.curCommandRelative="a"===A}else e.push({type:P2.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=A,this.curNumberHasDecimal="."===A}else this.curNumber+=A,this.curNumberHasDecimal=!0;else this.curNumber+=A;else this.curNumber+=A,this.curNumberHasExp=!0;else this.curNumber+=A,this.curNumberHasExpDigits=this.curNumberHasExp}return e},e.prototype.transform=function(t){return Object.create(this,{parse:{value:function(e,n){void 0===n&&(n=[]);for(var r=0,i=Object.getPrototypeOf(this).parse.call(this,e);r<i.length;r++){var A=i[r],s=t(A);Array.isArray(s)?n.push.apply(n,s):n.push(s)}return n}}})},e}(Q2),P2=function(t){function e(n){var r=t.call(this)||this;return r.commands="string"==typeof n?e.parse(n):n,r}return v2(e,t),e.prototype.encode=function(){return e.encode(this.commands)},e.prototype.getBounds=function(){var t=x2.CALCULATE_BOUNDS();return this.transform(t),t},e.prototype.transform=function(t){for(var e=[],n=0,r=this.commands;n<r.length;n++){var i=t(r[n]);Array.isArray(i)?e.push.apply(e,i):e.push(i)}return this.commands=e,this},e.encode=function(t){return function(t){var e="";Array.isArray(t)||(t=[t]);for(var n=0;n<t.length;n++){var r=t[n];if(r.type===P2.CLOSE_PATH)e+="z";else if(r.type===P2.HORIZ_LINE_TO)e+=(r.relative?"h":"H")+r.x;else if(r.type===P2.VERT_LINE_TO)e+=(r.relative?"v":"V")+r.y;else if(r.type===P2.MOVE_TO)e+=(r.relative?"m":"M")+r.x+" "+r.y;else if(r.type===P2.LINE_TO)e+=(r.relative?"l":"L")+r.x+" "+r.y;else if(r.type===P2.CURVE_TO)e+=(r.relative?"c":"C")+r.x1+" "+r.y1+" "+r.x2+" "+r.y2+" "+r.x+" "+r.y;else if(r.type===P2.SMOOTH_CURVE_TO)e+=(r.relative?"s":"S")+r.x2+" "+r.y2+" "+r.x+" "+r.y;else if(r.type===P2.QUAD_TO)e+=(r.relative?"q":"Q")+r.x1+" "+r.y1+" "+r.x+" "+r.y;else if(r.type===P2.SMOOTH_QUAD_TO)e+=(r.relative?"t":"T")+r.x+" "+r.y;else{if(r.type!==P2.ARC)throw new Error('Unexpected command type "'+r.type+'" at index '+n+".");e+=(r.relative?"a":"A")+r.rX+" "+r.rY+" "+r.xRot+" "+ +r.lArcFlag+" "+ +r.sweepFlag+" "+r.x+" "+r.y}}return e}(t)},e.parse=function(t){var e=new O2,n=[];return e.parse(t,n),e.finish(n),n},e.CLOSE_PATH=1,e.MOVE_TO=2,e.HORIZ_LINE_TO=4,e.VERT_LINE_TO=8,e.LINE_TO=16,e.CURVE_TO=32,e.SMOOTH_CURVE_TO=64,e.QUAD_TO=128,e.SMOOTH_QUAD_TO=256,e.ARC=512,e.LINE_COMMANDS=e.LINE_TO|e.HORIZ_LINE_TO|e.VERT_LINE_TO,e.DRAWING_COMMANDS=e.HORIZ_LINE_TO|e.VERT_LINE_TO|e.LINE_TO|e.CURVE_TO|e.SMOOTH_CURVE_TO|e.QUAD_TO|e.SMOOTH_QUAD_TO|e.ARC,e}(Q2),N2=((I2={})[P2.MOVE_TO]=2,I2[P2.LINE_TO]=2,I2[P2.HORIZ_LINE_TO]=1,I2[P2.VERT_LINE_TO]=1,I2[P2.CLOSE_PATH]=0,I2[P2.QUAD_TO]=4,I2[P2.SMOOTH_QUAD_TO]=2,I2[P2.CURVE_TO]=6,I2[P2.SMOOTH_CURVE_TO]=4,I2[P2.ARC]=7,I2),T2=hW.PROPER,D2=lV,R2=Vj,H2=uY,j2=gR,W2=z$,V2="toString",K2=RegExp.prototype,G2=K2[V2],z2=j2(function(){return"/a/b"!==G2.call({source:"a",flags:"b"})}),q2=T2&&G2.name!==V2;function X2(t){return(X2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}(z2||q2)&&D2(K2,V2,function(){var t=R2(this);return"/"+H2(t.source)+"/"+H2(W2(t))},{unsafe:!0});var Y2=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],$2=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function J2(t,e,n,r,i,A){if(!(isNaN(A)||A<1)){A|=0;var s=function(t,e,n,r,i){if("string"==typeof t&&(t=document.getElementById(t)),!t||"object"!==X2(t)||!("getContext"in t))throw new TypeError("Expecting canvas with `getContext` method in processCanvasRGB(A) calls!");var A=t.getContext("2d");try{return A.getImageData(e,n,r,i)}catch(hw){throw new Error("unable to access image data: "+hw)}}(t,e,n,r,i);s=function(t,e,n,r,i,A){for(var s,a=t.data,o=2*A+1,l=r-1,c=i-1,h=A+1,u=h*(h+1)/2,d=new Z2,f=d,p=1;p<o;p++)f=f.next=new Z2,p===h&&(s=f);f.next=d;for(var g=null,m=null,w=0,v=0,y=Y2[A],b=$2[A],B=0;B<i;B++){f=d;for(var _=a[v],C=a[v+1],x=a[v+2],E=a[v+3],S=0;S<h;S++)f.r=_,f.g=C,f.b=x,f.a=E,f=f.next;for(var F=0,L=0,U=0,I=0,Q=h*_,k=h*C,M=h*x,O=h*E,P=u*_,N=u*C,T=u*x,D=u*E,R=1;R<h;R++){var H=v+((l<R?l:R)<<2),j=a[H],W=a[H+1],V=a[H+2],K=a[H+3],G=h-R;P+=(f.r=j)*G,N+=(f.g=W)*G,T+=(f.b=V)*G,D+=(f.a=K)*G,F+=j,L+=W,U+=V,I+=K,f=f.next}g=d,m=s;for(var z=0;z<r;z++){var q=D*y>>>b;if(a[v+3]=q,0!==q){var X=255/q;a[v]=(P*y>>>b)*X,a[v+1]=(N*y>>>b)*X,a[v+2]=(T*y>>>b)*X}else a[v]=a[v+1]=a[v+2]=0;P-=Q,N-=k,T-=M,D-=O,Q-=g.r,k-=g.g,M-=g.b,O-=g.a;var Y=z+A+1;Y=w+(Y<l?Y:l)<<2,P+=F+=g.r=a[Y],N+=L+=g.g=a[Y+1],T+=U+=g.b=a[Y+2],D+=I+=g.a=a[Y+3],g=g.next;var $=m,J=$.r,Z=$.g,tt=$.b,et=$.a;Q+=J,k+=Z,M+=tt,O+=et,F-=J,L-=Z,U-=tt,I-=et,m=m.next,v+=4}w+=r}for(var nt=0;nt<r;nt++){var rt=a[v=nt<<2],it=a[v+1],At=a[v+2],st=a[v+3],at=h*rt,ot=h*it,lt=h*At,ct=h*st,ht=u*rt,ut=u*it,dt=u*At,ft=u*st;f=d;for(var pt=0;pt<h;pt++)f.r=rt,f.g=it,f.b=At,f.a=st,f=f.next;for(var gt=r,mt=0,wt=0,vt=0,yt=0,bt=1;bt<=A;bt++){v=gt+nt<<2;var Bt=h-bt;ht+=(f.r=rt=a[v])*Bt,ut+=(f.g=it=a[v+1])*Bt,dt+=(f.b=At=a[v+2])*Bt,ft+=(f.a=st=a[v+3])*Bt,yt+=rt,mt+=it,wt+=At,vt+=st,f=f.next,bt<c&&(gt+=r)}v=nt,g=d,m=s;for(var _t=0;_t<i;_t++){var Ct=v<<2;a[Ct+3]=st=ft*y>>>b,st>0?(st=255/st,a[Ct]=(ht*y>>>b)*st,a[Ct+1]=(ut*y>>>b)*st,a[Ct+2]=(dt*y>>>b)*st):a[Ct]=a[Ct+1]=a[Ct+2]=0,ht-=at,ut-=ot,dt-=lt,ft-=ct,at-=g.r,ot-=g.g,lt-=g.b,ct-=g.a,Ct=nt+((Ct=_t+h)<c?Ct:c)*r<<2,ht+=yt+=g.r=a[Ct],ut+=mt+=g.g=a[Ct+1],dt+=wt+=g.b=a[Ct+2],ft+=vt+=g.a=a[Ct+3],g=g.next,at+=rt=m.r,ot+=it=m.g,lt+=At=m.b,ct+=st=m.a,yt-=rt,mt-=it,wt-=At,vt-=st,m=m.next,v+=r}}return t}(s,0,0,r,i,A),t.getContext("2d").putImageData(s,e,n)}}var Z2=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.r=0,this.g=0,this.b=0,this.a=0,this.next=null};var t5=Object.freeze({__proto__:null,offscreen:function(){var{DOMParser:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:t,createCanvas:(t,e)=>new OffscreenCanvas(t,e),createImage:t=>lY(function*(){var e=yield fetch(t),n=yield e.blob();return yield createImageBitmap(n)})()};return"undefined"==typeof DOMParser&&void 0!==t||Reflect.deleteProperty(e,"DOMParser"),e},node:function(t){var{DOMParser:e,canvas:n,fetch:r}=t;return{window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:e,fetch:r,createCanvas:n.createCanvas,createImage:n.loadImage}}});function e5(t){return t.replace(/(?!\u3000)\s+/gm," ")}function n5(t){return t.replace(/^[\n \t]+/,"")}function r5(t){return t.replace(/[\n \t]+$/,"")}function i5(t){return((t||"").match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm)||[]).map(parseFloat)}var A5=/^[A-Z-]+$/;function s5(t){return A5.test(t)?t.toLowerCase():t}function a5(t){var e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t)||[];return e[2]||e[3]||e[4]}function o5(t){if(!t.startsWith("rgb"))return t;var e=3;return t.replace(/\d+(\.\d+)?/g,(t,n)=>e--&&n?String(Math.round(parseFloat(t))):t)}var l5=/(\[[^\]]+\])/g,c5=/(#[^\s+>~.[:]+)/g,h5=/(\.[^\s+>~.[:]+)/g,u5=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,d5=/(:[\w-]+\([^)]*\))/gi,f5=/(:[^\s+>~.[:]+)/g,p5=/([^\s+>~.[:]+)/g;function g5(t,e){var n=e.exec(t);return n?[t.replace(e," "),n.length]:[t,0]}function m5(t){var e=[0,0,0],n=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),r=0;return[n,r]=g5(n,l5),e[1]+=r,[n,r]=g5(n,c5),e[0]+=r,[n,r]=g5(n,h5),e[1]+=r,[n,r]=g5(n,u5),e[2]+=r,[n,r]=g5(n,d5),e[1]+=r,[n,r]=g5(n,f5),e[1]+=r,n=n.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[n,r]=g5(n,p5),e[2]+=r,e.join("")}var w5=1e-8;function v5(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function y5(t,e){return(t[0]*e[0]+t[1]*e[1])/(v5(t)*v5(e))}function b5(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y5(t,e))}function B5(t){return t*t*t}function _5(t){return 3*t*t*(1-t)}function C5(t){return 3*t*(1-t)*(1-t)}function x5(t){return(1-t)*(1-t)*(1-t)}function E5(t){return t*t}function S5(t){return 2*t*(1-t)}function F5(t){return(1-t)*(1-t)}class L5{constructor(t,e,n){this.document=t,this.name=e,this.value=n,this.isNormalizedColor=!1}static empty(t){return new L5(t,"EMPTY","")}split(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:" ",{document:e,name:n}=this;return e5(this.getString()).trim().split(t).map(t=>new L5(e,n,t))}hasValue(t){var{value:e}=this;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){var{value:e}=this,n="string"==typeof e;return n&&t?t.test(e):n}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;var t=this.getString();switch(!0){case t.endsWith("px"):case/^[0-9]+$/.test(t):return!0;default:return!1}}setValue(t){return this.value=t,this}getValue(t){return void 0===t||this.hasValue()?this.value:t}getNumber(t){if(!this.hasValue())return void 0===t?0:parseFloat(t);var{value:e}=this,n=parseFloat(e);return this.isString(/%$/)&&(n/=100),n}getString(t){return void 0===t||this.hasValue()?void 0===this.value?"":String(this.value):String(t)}getColor(t){var e=this.getString(t);return this.isNormalizedColor||(this.isNormalizedColor=!0,e=o5(e),this.value=e),e}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasValue())return 0;var[n,r]="boolean"==typeof t?[void 0,t]:[t],{viewPort:i}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(i.computeSize("x"),i.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(i.computeSize("x"),i.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*i.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*i.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return 15*this.getNumber();case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case this.isString(/%$/)&&r:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*i.computeSize(n);default:var A=this.getNumber();return e&&A<1?A*i.computeSize(n):A}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():1e3*this.getNumber():0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){var t=this.getString(),e=/#([^)'"]+)/.exec(t);return e&&(e=e[1]),e||(e=t),this.document.definitions[e]}getFillStyleDefinition(t,e){var n=this.getDefinition();if(!n)return null;if("function"==typeof n.createGradient)return n.createGradient(this.document.ctx,t,e);if("function"==typeof n.createPattern){if(n.getHrefAttribute().hasValue()){var r=n.getAttribute("patternTransform");n=n.getHrefAttribute().getDefinition(),r.hasValue()&&n.getAttribute("patternTransform",!0).setValue(r.value)}return n.createPattern(this.document.ctx,t,e)}return null}getTextBaseline(){return this.hasValue()?L5.textBaselineMapping[this.getString()]:null}addOpacity(t){for(var e=this.getColor(),n=e.length,r=0,i=0;i<n&&(","===e[i]&&r++,3!==r);i++);if(t.hasValue()&&this.isString()&&3!==r){var A=new e2(e);A.ok&&(A.alpha=t.getNumber(),e=A.toRGBA())}return new L5(this.document,this.name,e)}}L5.textBaselineMapping={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};class U5{constructor(){this.viewPorts=[]}clear(){this.viewPorts=[]}setCurrent(t,e){this.viewPorts.push({width:t,height:e})}removeCurrent(){this.viewPorts.pop()}getCurrent(){var{viewPorts:t}=this;return t[t.length-1]}get width(){return this.getCurrent().width}get height(){return this.getCurrent().height}computeSize(t){return"number"==typeof t?t:"x"===t?this.width:"y"===t?this.height:Math.sqrt(Math.pow(this.width,2)+Math.pow(this.height,2))/Math.sqrt(2)}}class I5{constructor(t,e){this.x=t,this.y=e}static parse(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,[n=e,r=e]=i5(t);return new I5(n,r)}static parseScale(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,[n=e,r=n]=i5(t);return new I5(n,r)}static parsePath(t){for(var e=i5(t),n=e.length,r=[],i=0;i<n;i+=2)r.push(new I5(e[i],e[i+1]));return r}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){var{x:e,y:n}=this,r=e*t[0]+n*t[2]+t[4],i=e*t[1]+n*t[3]+t[5];this.x=r,this.y=i}}class Q5{constructor(t){this.screen=t,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}isWorking(){return this.working}start(){if(!this.working){var{screen:t,onClick:e,onMouseMove:n}=this,r=t.ctx.canvas;r.onclick=e,r.onmousemove=n,this.working=!0}}stop(){if(this.working){var t=this.screen.ctx.canvas;this.working=!1,t.onclick=null,t.onmousemove=null}}hasEvents(){return this.working&&this.events.length>0}runEvents(){if(this.working){var{screen:t,events:e,eventElements:n}=this,{style:r}=t.ctx.canvas;r&&(r.cursor=""),e.forEach((t,e)=>{for(var{run:r}=t,i=n[e];i;)r(i),i=i.parent}),this.events=[],this.eventElements=[]}}checkPath(t,e){if(this.working&&e){var{events:n,eventElements:r}=this;n.forEach((n,i)=>{var{x:A,y:s}=n;!r[i]&&e.isPointInPath&&e.isPointInPath(A,s)&&(r[i]=t)})}}checkBoundingBox(t,e){if(this.working&&e){var{events:n,eventElements:r}=this;n.forEach((n,i)=>{var{x:A,y:s}=n;!r[i]&&e.isPointInBox(A,s)&&(r[i]=t)})}}mapXY(t,e){for(var{window:n,ctx:r}=this.screen,i=new I5(t,e),A=r.canvas;A;)i.x-=A.offsetLeft,i.y-=A.offsetTop,A=A.offsetParent;return n.scrollX&&(i.x+=n.scrollX),n.scrollY&&(i.y+=n.scrollY),i}onClick(t){var{x:e,y:n}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:n,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){var{x:e,y:n}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:n,run(t){t.onMouseMove&&t.onMouseMove()}})}}var k5="undefined"!=typeof window?window:null,M5="undefined"!=typeof fetch?fetch.bind(void 0):null;class O5{constructor(t){var{fetch:e=M5,window:n=k5}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.ctx=t,this.FRAMERATE=30,this.MAX_VIRTUAL_PIXELS=3e4,this.CLIENT_WIDTH=800,this.CLIENT_HEIGHT=600,this.viewPort=new U5,this.mouse=new Q5(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=n,this.fetch=e}wait(t){this.waits.push(t)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;var t=this.waits.every(t=>t());return t&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=t,t}setDefaults(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4}setViewBox(t){var{document:e,ctx:n,aspectRatio:r,width:i,desiredWidth:A,height:s,desiredHeight:a,minX:o=0,minY:l=0,refX:c,refY:h,clip:u=!1,clipX:d=0,clipY:f=0}=t,p=e5(r).replace(/^defer\s/,""),[g,m]=p.split(" "),w=g||"xMidYMid",v=m||"meet",y=i/A,b=s/a,B=Math.min(y,b),_=Math.max(y,b),C=A,x=a;"meet"===v&&(C*=B,x*=B),"slice"===v&&(C*=_,x*=_);var E=new L5(e,"refX",c),S=new L5(e,"refY",h),F=E.hasValue()&&S.hasValue();if(F&&n.translate(-B*E.getPixels("x"),-B*S.getPixels("y")),u){var L=B*d,U=B*f;n.beginPath(),n.moveTo(L,U),n.lineTo(i,U),n.lineTo(i,s),n.lineTo(L,s),n.closePath(),n.clip()}if(!F){var I="meet"===v&&B===b,Q="slice"===v&&_===b,k="meet"===v&&B===y,M="slice"===v&&_===y;w.startsWith("xMid")&&(I||Q)&&n.translate(i/2-C/2,0),w.endsWith("YMid")&&(k||M)&&n.translate(0,s/2-x/2),w.startsWith("xMax")&&(I||Q)&&n.translate(i-C,0),w.endsWith("YMax")&&(k||M)&&n.translate(0,s-x)}switch(!0){case"none"===w:n.scale(y,b);break;case"meet"===v:n.scale(B,B);break;case"slice"===v:n.scale(_,_)}n.translate(-o,-l)}start(t){var{enableRedraw:e=!1,ignoreMouse:n=!1,ignoreAnimation:r=!1,ignoreDimensions:i=!1,ignoreClear:A=!1,forceRedraw:s,scaleWidth:a,scaleHeight:o,offsetX:l,offsetY:c}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{FRAMERATE:h,mouse:u}=this,d=1e3/h;if(this.frameDuration=d,this.readyPromise=new Promise(t=>{this.resolveReady=t}),this.isReady()&&this.render(t,i,A,a,o,l,c),e){var f=Date.now(),p=f,g=0,m=()=>{f=Date.now(),(g=f-p)>=d&&(p=f-g%d,this.shouldUpdate(r,s)&&(this.render(t,i,A,a,o,l,c),u.runEvents())),this.intervalId=R1(m)};n||u.start(),this.intervalId=R1(m)}}stop(){this.intervalId&&(R1.cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(t,e){if(!t){var{frameDuration:n}=this;if(this.animations.reduce((t,e)=>e.update(n)||t,!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,n,r,i,A,s){var{CLIENT_WIDTH:a,CLIENT_HEIGHT:o,viewPort:l,ctx:c,isFirstRender:h}=this,u=c.canvas;l.clear(),u.width&&u.height?l.setCurrent(u.width,u.height):l.setCurrent(a,o);var d=t.getStyle("width"),f=t.getStyle("height");!e&&(h||"number"!=typeof r&&"number"!=typeof i)&&(d.hasValue()&&(u.width=d.getPixels("x"),u.style&&(u.style.width="".concat(u.width,"px"))),f.hasValue()&&(u.height=f.getPixels("y"),u.style&&(u.style.height="".concat(u.height,"px"))));var p=u.clientWidth||u.width,g=u.clientHeight||u.height;if(e&&d.hasValue()&&f.hasValue()&&(p=d.getPixels("x"),g=f.getPixels("y")),l.setCurrent(p,g),"number"==typeof A&&t.getAttribute("x",!0).setValue(A),"number"==typeof s&&t.getAttribute("y",!0).setValue(s),"number"==typeof r||"number"==typeof i){var m=i5(t.getAttribute("viewBox").getString()),w=0,v=0;if("number"==typeof r){var y=t.getStyle("width");y.hasValue()?w=y.getPixels("x")/r:isNaN(m[2])||(w=m[2]/r)}if("number"==typeof i){var b=t.getStyle("height");b.hasValue()?v=b.getPixels("y")/i:isNaN(m[3])||(v=m[3]/i)}w||(w=v),v||(v=w),t.getAttribute("width",!0).setValue(r),t.getAttribute("height",!0).setValue(i);var B=t.getStyle("transform",!0,!0);B.setValue("".concat(B.getString()," scale(").concat(1/w,", ").concat(1/v,")"))}n||c.clearRect(0,0,p,g),t.render(c),h&&(this.isFirstRender=!1)}}O5.defaultWindow=k5,O5.defaultFetch=M5;var{defaultFetch:P5}=O5,N5="undefined"!=typeof DOMParser?DOMParser:null;class T5{constructor(){var{fetch:t=P5,DOMParser:e=N5}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.fetch=t,this.DOMParser=e}parse(t){var e=this;return lY(function*(){return t.startsWith("<")?e.parseFromString(t):e.load(t)})()}parseFromString(t){var e=new this.DOMParser;try{return this.checkDocument(e.parseFromString(t,"image/svg+xml"))}catch(n){return this.checkDocument(e.parseFromString(t,"text/xml"))}}checkDocument(t){var e=t.getElementsByTagName("parsererror")[0];if(e)throw new Error(e.textContent);return t}load(t){var e=this;return lY(function*(){var n=yield e.fetch(t),r=yield n.text();return e.parseFromString(r)})()}}class D5{constructor(t,e){this.type="translate",this.point=null,this.point=I5.parse(e)}apply(t){var{x:e,y:n}=this.point;t.translate(e||0,n||0)}unapply(t){var{x:e,y:n}=this.point;t.translate(-1*e||0,-1*n||0)}applyToPoint(t){var{x:e,y:n}=this.point;t.applyTransform([1,0,0,1,e||0,n||0])}}class R5{constructor(t,e,n){this.type="rotate",this.angle=null,this.originX=null,this.originY=null,this.cx=0,this.cy=0;var r=i5(e);this.angle=new L5(t,"angle",r[0]),this.originX=n[0],this.originY=n[1],this.cx=r[1]||0,this.cy=r[2]||0}apply(t){var{cx:e,cy:n,originX:r,originY:i,angle:A}=this,s=e+r.getPixels("x"),a=n+i.getPixels("y");t.translate(s,a),t.rotate(A.getRadians()),t.translate(-s,-a)}unapply(t){var{cx:e,cy:n,originX:r,originY:i,angle:A}=this,s=e+r.getPixels("x"),a=n+i.getPixels("y");t.translate(s,a),t.rotate(-1*A.getRadians()),t.translate(-s,-a)}applyToPoint(t){var{cx:e,cy:n,angle:r}=this,i=r.getRadians();t.applyTransform([1,0,0,1,e||0,n||0]),t.applyTransform([Math.cos(i),Math.sin(i),-Math.sin(i),Math.cos(i),0,0]),t.applyTransform([1,0,0,1,-e||0,-n||0])}}class H5{constructor(t,e,n){this.type="scale",this.scale=null,this.originX=null,this.originY=null;var r=I5.parseScale(e);0!==r.x&&0!==r.y||(r.x=w5,r.y=w5),this.scale=r,this.originX=n[0],this.originY=n[1]}apply(t){var{scale:{x:e,y:n},originX:r,originY:i}=this,A=r.getPixels("x"),s=i.getPixels("y");t.translate(A,s),t.scale(e,n||e),t.translate(-A,-s)}unapply(t){var{scale:{x:e,y:n},originX:r,originY:i}=this,A=r.getPixels("x"),s=i.getPixels("y");t.translate(A,s),t.scale(1/e,1/n||e),t.translate(-A,-s)}applyToPoint(t){var{x:e,y:n}=this.scale;t.applyTransform([e||0,0,0,n||0,0,0])}}class j5{constructor(t,e,n){this.type="matrix",this.matrix=[],this.originX=null,this.originY=null,this.matrix=i5(e),this.originX=n[0],this.originY=n[1]}apply(t){var{originX:e,originY:n,matrix:r}=this,i=e.getPixels("x"),A=n.getPixels("y");t.translate(i,A),t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),t.translate(-i,-A)}unapply(t){var{originX:e,originY:n,matrix:r}=this,i=r[0],A=r[2],s=r[4],a=r[1],o=r[3],l=r[5],c=1/(i*(1*o-0*l)-A*(1*a-0*l)+s*(0*a-0*o)),h=e.getPixels("x"),u=n.getPixels("y");t.translate(h,u),t.transform(c*(1*o-0*l),c*(0*l-1*a),c*(0*s-1*A),c*(1*i-0*s),c*(A*l-s*o),c*(s*a-i*l)),t.translate(-h,-u)}applyToPoint(t){t.applyTransform(this.matrix)}}class W5 extends j5{constructor(t,e,n){super(t,e,n),this.type="skew",this.angle=null,this.angle=new L5(t,"angle",e)}}class V5 extends W5{constructor(t,e,n){super(t,e,n),this.type="skewX",this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}}class K5 extends W5{constructor(t,e,n){super(t,e,n),this.type="skewY",this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}class G5{constructor(t,e,n){this.document=t,this.transforms=[];var r=function(t){return e5(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);r.forEach(t=>{if("none"!==t){var[e,r]=function(t){var[e,n]=t.split("(");return[e.trim(),n.trim().replace(")","")]}(t),i=G5.transformTypes[e];void 0!==i&&this.transforms.push(new i(this.document,r,n))}})}static fromElement(t,e){var n=e.getStyle("transform",!1,!0),[r,i=r]=e.getStyle("transform-origin",!1,!0).split(),A=[r,i];return n.hasValue()?new G5(t,n.getString(),A):null}apply(t){for(var{transforms:e}=this,n=e.length,r=0;r<n;r++)e[r].apply(t)}unapply(t){for(var{transforms:e}=this,n=e.length-1;n>=0;n--)e[n].unapply(t)}applyToPoint(t){for(var{transforms:e}=this,n=e.length,r=0;r<n;r++)e[r].applyToPoint(t)}}G5.transformTypes={translate:D5,rotate:R5,scale:H5,matrix:j5,skewX:V5,skewY:K5};class z5{constructor(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.document=t,this.node=e,this.captureTextNodes=n,this.attributes=Object.create(null),this.styles=Object.create(null),this.stylesSpecificity=Object.create(null),this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],e&&1===e.nodeType){if(Array.from(e.attributes).forEach(e=>{var n=s5(e.nodeName);this.attributes[n]=new L5(t,n,e.value)}),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue())this.getAttribute("style").getString().split(";").map(t=>t.trim()).forEach(e=>{if(e){var[n,r]=e.split(":").map(t=>t.trim());this.styles[n]=new L5(t,n,r)}});var{definitions:r}=t,i=this.getAttribute("id");i.hasValue()&&(r[i.getString()]||(r[i.getString()]=this)),Array.from(e.childNodes).forEach(e=>{if(1===e.nodeType)this.addChild(e);else if(n&&(3===e.nodeType||4===e.nodeType)){var r=t.createTextNode(e);r.getText().length>0&&this.addChild(r)}})}}getAttribute(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.attributes[t];if(!n&&e){var r=new L5(this.document,t,"");return this.attributes[t]=r,r}return n||L5.empty(this.document)}getHrefAttribute(){for(var t in this.attributes)if("href"===t||t.endsWith(":href"))return this.attributes[t];return L5.empty(this.document)}getStyle(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.styles[t];if(r)return r;var i=this.getAttribute(t);if(null!=i&&i.hasValue())return this.styles[t]=i,i;if(!n){var{parent:A}=this;if(A){var s=A.getStyle(t);if(null!=s&&s.hasValue())return s}}if(e){var a=new L5(this.document,t,"");return this.styles[t]=a,a}return r||L5.empty(this.document)}render(t){if("none"!==this.getStyle("display").getString()&&"hidden"!==this.getStyle("visibility").getString()){if(t.save(),this.getStyle("mask").hasValue()){var e=this.getStyle("mask").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else if("none"!==this.getStyle("filter").getValue("none")){var n=this.getStyle("filter").getDefinition();n&&(this.applyEffects(t),n.apply(t,this))}else this.setContext(t),this.renderChildren(t),this.clearContext(t);t.restore()}}setContext(t){}applyEffects(t){var e=G5.fromElement(this.document,this);e&&e.apply(t);var n=this.getStyle("clip-path",!1,!0);if(n.hasValue()){var r=n.getDefinition();r&&r.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach(e=>{e.render(t)})}addChild(t){var e=t instanceof z5?t:this.document.createElement(t);e.parent=this,z5.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e,{node:n}=this;if("function"==typeof n.matches)return n.matches(t);var r=null===(e=n.getAttribute)||void 0===e?void 0:e.call(n,"class");return!(!r||""===r)&&r.split(" ").some(e=>".".concat(e)===t)}addStylesFromStyleDefinition(){var{styles:t,stylesSpecificity:e}=this.document;for(var n in t)if(!n.startsWith("@")&&this.matchesSelector(n)){var r=t[n],i=e[n];if(r)for(var A in r){var s=this.stylesSpecificity[A];void 0===s&&(s="000"),i>=s&&(this.styles[A]=r[A],this.stylesSpecificity[A]=i)}}}removeStyles(t,e){return e.reduce((e,n)=>{var r=t.getStyle(n);if(!r.hasValue())return e;var i=r.getString();return r.setValue(""),[...e,[n,i]]},[])}restoreStyles(t,e){e.forEach(e=>{var[n,r]=e;t.getStyle(n,!0).setValue(r)})}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}}z5.ignoreChildTypes=["title"];class q5 extends z5{constructor(t,e,n){super(t,e,n)}}function X5(t){var e=t.trim();return/^('|")/.test(e)?e:'"'.concat(e,'"')}function Y5(t){if(!t)return"";var e=t.trim().toLowerCase();switch(e){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return e;default:return/^oblique\s+(-|)\d+deg$/.test(e)?e:""}}function $5(t){if(!t)return"";var e=t.trim().toLowerCase();switch(e){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return e;default:return/^[\d.]+$/.test(e)?e:""}}class J5{constructor(t,e,n,r,i,A){var s=A?"string"==typeof A?J5.parse(A):A:{};this.fontFamily=i||s.fontFamily,this.fontSize=r||s.fontSize,this.fontStyle=t||s.fontStyle,this.fontWeight=n||s.fontWeight,this.fontVariant=e||s.fontVariant}static parse(){var t=arguments.length>1?arguments[1]:void 0,e="",n="",r="",i="",A="",s=e5(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").trim().split(" "),a={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return s.forEach(t=>{switch(!0){case!a.fontStyle&&J5.styles.includes(t):"inherit"!==t&&(e=t),a.fontStyle=!0;break;case!a.fontVariant&&J5.variants.includes(t):"inherit"!==t&&(n=t),a.fontStyle=!0,a.fontVariant=!0;break;case!a.fontWeight&&J5.weights.includes(t):"inherit"!==t&&(r=t),a.fontStyle=!0,a.fontVariant=!0,a.fontWeight=!0;break;case!a.fontSize:"inherit"!==t&&([i]=t.split("/")),a.fontStyle=!0,a.fontVariant=!0,a.fontWeight=!0,a.fontSize=!0;break;default:"inherit"!==t&&(A+=t)}}),new J5(e,n,r,i,A,t)}toString(){return[Y5(this.fontStyle),this.fontVariant,$5(this.fontWeight),this.fontSize,(t=this.fontFamily,"undefined"==typeof process?t:t.trim().split(",").map(X5).join(","))].join(" ").trim();var t}}J5.styles="normal|italic|oblique|inherit",J5.variants="normal|small-caps|inherit",J5.weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";class Z5{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number.NaN,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.NaN,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.NaN,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.NaN;this.x1=t,this.y1=e,this.x2=n,this.y2=r,this.addPoint(t,e),this.addPoint(n,r)}get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(t,e){void 0!==t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),void 0!==e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))}addX(t){this.addPoint(t,null)}addY(t){this.addPoint(null,t)}addBoundingBox(t){if(t){var{x1:e,y1:n,x2:r,y2:i}=t;this.addPoint(e,n),this.addPoint(r,i)}}sumCubic(t,e,n,r,i){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*n+3*(1-t)*Math.pow(t,2)*r+Math.pow(t,3)*i}bezierCurveAdd(t,e,n,r,i){var A=6*e-12*n+6*r,s=-3*e+9*n-9*r+3*i,a=3*n-3*e;if(0!==s){var o=Math.pow(A,2)-4*a*s;if(!(o<0)){var l=(-A+Math.sqrt(o))/(2*s);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,n,r,i)):this.addY(this.sumCubic(l,e,n,r,i)));var c=(-A-Math.sqrt(o))/(2*s);0<c&&c<1&&(t?this.addX(this.sumCubic(c,e,n,r,i)):this.addY(this.sumCubic(c,e,n,r,i)))}}else{if(0===A)return;var h=-a/A;0<h&&h<1&&(t?this.addX(this.sumCubic(h,e,n,r,i)):this.addY(this.sumCubic(h,e,n,r,i)))}}addBezierCurve(t,e,n,r,i,A,s,a){this.addPoint(t,e),this.addPoint(s,a),this.bezierCurveAdd(!0,t,n,i,s),this.bezierCurveAdd(!1,e,r,A,a)}addQuadraticCurve(t,e,n,r,i,A){var s=t+2/3*(n-t),a=e+2/3*(r-e),o=s+1/3*(i-t),l=a+1/3*(A-e);this.addBezierCurve(t,e,s,o,a,l,i,A)}isPointInBox(t,e){var{x1:n,y1:r,x2:i,y2:A}=this;return n<=t&&t<=i&&r<=e&&e<=A}}class t4 extends P2{constructor(t){super(t.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),this.control=null,this.start=null,this.current=null,this.command=null,this.commands=this.commands,this.i=-1,this.previousCommand=null,this.points=[],this.angles=[]}reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new I5(0,0),this.control=new I5(0,0),this.current=new I5(0,0),this.points=[],this.angles=[]}isEnd(){var{i:t,commands:e}=this;return t>=e.length-1}next(){var t=this.commands[++this.i];return this.previousCommand=this.command,this.command=t,t}getPoint(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"x",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",n=new I5(this.command[t],this.command[e]);return this.makeAbsolute(n)}getAsControlPoint(t,e){var n=this.getPoint(t,e);return this.control=n,n}getAsCurrentPoint(t,e){var n=this.getPoint(t,e);return this.current=n,n}getReflectedControlPoint(){var t=this.previousCommand.type;if(t!==P2.CURVE_TO&&t!==P2.SMOOTH_CURVE_TO&&t!==P2.QUAD_TO&&t!==P2.SMOOTH_QUAD_TO)return this.current;var{current:{x:e,y:n},control:{x:r,y:i}}=this;return new I5(2*e-r,2*n-i)}makeAbsolute(t){if(this.command.relative){var{x:e,y:n}=this.current;t.x+=e,t.y+=n}return t}addMarker(t,e,n){var{points:r,angles:i}=this;n&&i.length>0&&!i[i.length-1]&&(i[i.length-1]=r[r.length-1].angleTo(n)),this.addMarkerAngle(t,e?e.angleTo(t):null)}addMarkerAngle(t,e){this.points.push(t),this.angles.push(e)}getMarkerPoints(){return this.points}getMarkerAngles(){for(var{angles:t}=this,e=t.length,n=0;n<e;n++)if(!t[n])for(var r=n+1;r<e;r++)if(t[r]){t[n]=t[r];break}return t}}class e4 extends z5{constructor(){super(...arguments),this.modifiedEmSizeStack=!1}calculateOpacity(){for(var t=1,e=this;e;){var n=e.getStyle("opacity",!1,!0);n.hasValue(!0)&&(t*=n.getNumber()),e=e.parent}return t}setContext(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e){var n=this.getStyle("fill"),r=this.getStyle("fill-opacity"),i=this.getStyle("stroke"),A=this.getStyle("stroke-opacity");if(n.isUrlDefinition()){var s=n.getFillStyleDefinition(this,r);s&&(t.fillStyle=s)}else if(n.hasValue()){"currentColor"===n.getString()&&n.setValue(this.getStyle("color").getColor());var a=n.getColor();"inherit"!==a&&(t.fillStyle="none"===a?"rgba(0,0,0,0)":a)}if(r.hasValue()){var o=new L5(this.document,"fill",t.fillStyle).addOpacity(r).getColor();t.fillStyle=o}if(i.isUrlDefinition()){var l=i.getFillStyleDefinition(this,A);l&&(t.strokeStyle=l)}else if(i.hasValue()){"currentColor"===i.getString()&&i.setValue(this.getStyle("color").getColor());var c=i.getString();"inherit"!==c&&(t.strokeStyle="none"===c?"rgba(0,0,0,0)":c)}if(A.hasValue()){var h=new L5(this.document,"stroke",t.strokeStyle).addOpacity(A).getString();t.strokeStyle=h}var u=this.getStyle("stroke-width");if(u.hasValue()){var d=u.getPixels();t.lineWidth=d||w5}var f=this.getStyle("stroke-linecap"),p=this.getStyle("stroke-linejoin"),g=this.getStyle("stroke-miterlimit"),m=this.getStyle("stroke-dasharray"),w=this.getStyle("stroke-dashoffset");if(f.hasValue()&&(t.lineCap=f.getString()),p.hasValue()&&(t.lineJoin=p.getString()),g.hasValue()&&(t.miterLimit=g.getNumber()),m.hasValue()&&"none"!==m.getString()){var v=i5(m.getString());void 0!==t.setLineDash?t.setLineDash(v):void 0!==t.webkitLineDash?t.webkitLineDash=v:void 0===t.mozDash||1===v.length&&0===v[0]||(t.mozDash=v);var y=w.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=y:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=y:void 0!==t.mozDashOffset&&(t.mozDashOffset=y)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){var b=this.getStyle("font"),B=this.getStyle("font-style"),_=this.getStyle("font-variant"),C=this.getStyle("font-weight"),x=this.getStyle("font-size"),E=this.getStyle("font-family"),S=new J5(B.getString(),_.getString(),C.getString(),x.hasValue()?"".concat(x.getPixels(!0),"px"):"",E.getString(),J5.parse(b.getString(),t.font));B.setValue(S.fontStyle),_.setValue(S.fontVariant),C.setValue(S.fontWeight),x.setValue(S.fontSize),E.setValue(S.fontFamily),t.font=S.toString(),x.isPixels()&&(this.document.emSize=x.getPixels(),this.modifiedEmSizeStack=!0)}e||(this.applyEffects(t),t.globalAlpha=this.calculateOpacity())}clearContext(t){super.clearContext(t),this.modifiedEmSizeStack&&this.document.popEmSize()}}class n4 extends e4{constructor(t,e,n){super(t,e,n),this.type="path",this.pathParser=null,this.pathParser=new t4(this.getAttribute("d").getString())}path(t){var{pathParser:e}=this,n=new Z5;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case t4.MOVE_TO:this.pathM(t,n);break;case t4.LINE_TO:this.pathL(t,n);break;case t4.HORIZ_LINE_TO:this.pathH(t,n);break;case t4.VERT_LINE_TO:this.pathV(t,n);break;case t4.CURVE_TO:this.pathC(t,n);break;case t4.SMOOTH_CURVE_TO:this.pathS(t,n);break;case t4.QUAD_TO:this.pathQ(t,n);break;case t4.SMOOTH_QUAD_TO:this.pathT(t,n);break;case t4.ARC:this.pathA(t,n);break;case t4.CLOSE_PATH:this.pathZ(t,n)}return n}getBoundingBox(t){return this.path()}getMarkers(){var{pathParser:t}=this,e=t.getMarkerPoints(),n=t.getMarkerAngles();return e.map((t,e)=>[t,n[e]])}renderChildren(t){this.path(t),this.document.screen.mouse.checkPath(this,t);var e=this.getStyle("fill-rule");""!==t.fillStyle&&("inherit"!==e.getString("inherit")?t.fill(e.getString()):t.fill()),""!==t.strokeStyle&&("non-scaling-stroke"===this.getAttribute("vector-effect").getString()?(t.save(),t.setTransform(1,0,0,1,0,0),t.stroke(),t.restore()):t.stroke());var n=this.getMarkers();if(n){var r=n.length-1,i=this.getStyle("marker-start"),A=this.getStyle("marker-mid"),s=this.getStyle("marker-end");if(i.isUrlDefinition()){var a=i.getDefinition(),[o,l]=n[0];a.render(t,o,l)}if(A.isUrlDefinition())for(var c=A.getDefinition(),h=1;h<r;h++){var[u,d]=n[h];c.render(t,u,d)}if(s.isUrlDefinition()){var f=s.getDefinition(),[p,g]=n[r];f.render(t,p,g)}}}static pathM(t){var e=t.getAsCurrentPoint();return t.start=t.current,{point:e}}pathM(t,e){var{pathParser:n}=this,{point:r}=n4.pathM(n),{x:i,y:A}=r;n.addMarker(r),e.addPoint(i,A),t&&t.moveTo(i,A)}static pathL(t){var{current:e}=t;return{current:e,point:t.getAsCurrentPoint()}}pathL(t,e){var{pathParser:n}=this,{current:r,point:i}=n4.pathL(n),{x:A,y:s}=i;n.addMarker(i,r),e.addPoint(A,s),t&&t.lineTo(A,s)}static pathH(t){var{current:e,command:n}=t,r=new I5((n.relative?e.x:0)+n.x,e.y);return t.current=r,{current:e,point:r}}pathH(t,e){var{pathParser:n}=this,{current:r,point:i}=n4.pathH(n),{x:A,y:s}=i;n.addMarker(i,r),e.addPoint(A,s),t&&t.lineTo(A,s)}static pathV(t){var{current:e,command:n}=t,r=new I5(e.x,(n.relative?e.y:0)+n.y);return t.current=r,{current:e,point:r}}pathV(t,e){var{pathParser:n}=this,{current:r,point:i}=n4.pathV(n),{x:A,y:s}=i;n.addMarker(i,r),e.addPoint(A,s),t&&t.lineTo(A,s)}static pathC(t){var{current:e}=t;return{current:e,point:t.getPoint("x1","y1"),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathC(t,e){var{pathParser:n}=this,{current:r,point:i,controlPoint:A,currentPoint:s}=n4.pathC(n);n.addMarker(s,A,i),e.addBezierCurve(r.x,r.y,i.x,i.y,A.x,A.y,s.x,s.y),t&&t.bezierCurveTo(i.x,i.y,A.x,A.y,s.x,s.y)}static pathS(t){var{current:e}=t;return{current:e,point:t.getReflectedControlPoint(),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathS(t,e){var{pathParser:n}=this,{current:r,point:i,controlPoint:A,currentPoint:s}=n4.pathS(n);n.addMarker(s,A,i),e.addBezierCurve(r.x,r.y,i.x,i.y,A.x,A.y,s.x,s.y),t&&t.bezierCurveTo(i.x,i.y,A.x,A.y,s.x,s.y)}static pathQ(t){var{current:e}=t;return{current:e,controlPoint:t.getAsControlPoint("x1","y1"),currentPoint:t.getAsCurrentPoint()}}pathQ(t,e){var{pathParser:n}=this,{current:r,controlPoint:i,currentPoint:A}=n4.pathQ(n);n.addMarker(A,i,i),e.addQuadraticCurve(r.x,r.y,i.x,i.y,A.x,A.y),t&&t.quadraticCurveTo(i.x,i.y,A.x,A.y)}static pathT(t){var{current:e}=t,n=t.getReflectedControlPoint();return t.control=n,{current:e,controlPoint:n,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){var{pathParser:n}=this,{current:r,controlPoint:i,currentPoint:A}=n4.pathT(n);n.addMarker(A,i,i),e.addQuadraticCurve(r.x,r.y,i.x,i.y,A.x,A.y),t&&t.quadraticCurveTo(i.x,i.y,A.x,A.y)}static pathA(t){var{current:e,command:n}=t,{rX:r,rY:i,xRot:A,lArcFlag:s,sweepFlag:a}=n,o=A*(Math.PI/180),l=t.getAsCurrentPoint(),c=new I5(Math.cos(o)*(e.x-l.x)/2+Math.sin(o)*(e.y-l.y)/2,-Math.sin(o)*(e.x-l.x)/2+Math.cos(o)*(e.y-l.y)/2),h=Math.pow(c.x,2)/Math.pow(r,2)+Math.pow(c.y,2)/Math.pow(i,2);h>1&&(r*=Math.sqrt(h),i*=Math.sqrt(h));var u=(s===a?-1:1)*Math.sqrt((Math.pow(r,2)*Math.pow(i,2)-Math.pow(r,2)*Math.pow(c.y,2)-Math.pow(i,2)*Math.pow(c.x,2))/(Math.pow(r,2)*Math.pow(c.y,2)+Math.pow(i,2)*Math.pow(c.x,2)));isNaN(u)&&(u=0);var d=new I5(u*r*c.y/i,u*-i*c.x/r),f=new I5((e.x+l.x)/2+Math.cos(o)*d.x-Math.sin(o)*d.y,(e.y+l.y)/2+Math.sin(o)*d.x+Math.cos(o)*d.y),p=b5([1,0],[(c.x-d.x)/r,(c.y-d.y)/i]),g=[(c.x-d.x)/r,(c.y-d.y)/i],m=[(-c.x-d.x)/r,(-c.y-d.y)/i],w=b5(g,m);return y5(g,m)<=-1&&(w=Math.PI),y5(g,m)>=1&&(w=0),{currentPoint:l,rX:r,rY:i,sweepFlag:a,xAxisRotation:o,centp:f,a1:p,ad:w}}pathA(t,e){var{pathParser:n}=this,{currentPoint:r,rX:i,rY:A,sweepFlag:s,xAxisRotation:a,centp:o,a1:l,ad:c}=n4.pathA(n),h=1-s?1:-1,u=l+h*(c/2),d=new I5(o.x+i*Math.cos(u),o.y+A*Math.sin(u));if(n.addMarkerAngle(d,u-h*Math.PI/2),n.addMarkerAngle(r,u-h*Math.PI),e.addPoint(r.x,r.y),t&&!isNaN(l)&&!isNaN(c)){var f=i>A?i:A,p=i>A?1:i/A,g=i>A?A/i:1;t.translate(o.x,o.y),t.rotate(a),t.scale(p,g),t.arc(0,0,f,l,l+c,Boolean(1-s)),t.scale(1/p,1/g),t.rotate(-a),t.translate(-o.x,-o.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){n4.pathZ(this.pathParser),t&&e.x1!==e.x2&&e.y1!==e.y2&&t.closePath()}}class r4 extends n4{constructor(t,e,n){super(t,e,n),this.type="glyph",this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}class i4 extends e4{constructor(t,e,n){super(t,e,new.target===i4||n),this.type="text",this.x=0,this.y=0,this.measureCache=-1}setContext(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);var n=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();n&&(t.textBaseline=n)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(t){if("text"!==this.type)return this.getTElementBoundingBox(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t);var e=null;return this.children.forEach((n,r)=>{var i=this.getChildBoundingBox(t,this,this,r);e?e.addBoundingBox(i):e=i}),e}getFontSize(){var{document:t,parent:e}=this,n=J5.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(n)}getTElementBoundingBox(t){var e=this.getFontSize();return new Z5(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,n){var r=e[n],i=null;if(t.isArabic){var A=e.length,s=e[n-1],a=e[n+1],o="isolated";if((0===n||" "===s)&&n<A-1&&" "!==a&&(o="terminal"),n>0&&" "!==s&&n<A-1&&" "!==a&&(o="medial"),n>0&&" "!==s&&(n===A-1||" "===a)&&(o="initial"),void 0!==t.glyphs[r]){var l=t.glyphs[r];i=l instanceof r4?l:l[o]}}else i=t.glyphs[r];return i||(i=t.missingGlyph),i}getText(){return""}getTextFromNode(t){var e=t||this.node,n=Array.from(e.parentNode.childNodes),r=n.indexOf(e),i=n.length-1,A=e5(e.textContent||"");return 0===r&&(A=n5(A)),r===i&&(A=r5(A)),A}renderChildren(t){if("text"===this.type){this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t),this.children.forEach((e,n)=>{this.renderChild(t,this,this,n)});var{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}else this.renderTElementChildren(t)}renderTElementChildren(t){var{document:e,parent:n}=this,r=this.getText(),i=n.getStyle("font-family").getDefinition();if(i)for(var{unitsPerEm:A}=i.fontFace,s=J5.parse(e.ctx.font),a=n.getStyle("font-size").getNumber(s.fontSize),o=n.getStyle("font-style").getString(s.fontStyle),l=a/A,c=i.isRTL?r.split("").reverse().join(""):r,h=i5(n.getAttribute("dx").getString()),u=c.length,d=0;d<u;d++){var f=this.getGlyph(i,c,d);t.translate(this.x,this.y),t.scale(l,-l);var p=t.lineWidth;t.lineWidth=t.lineWidth*A/a,"italic"===o&&t.transform(1,0,.4,1,0,0),f.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=p,t.scale(1/l,-1/l),t.translate(-this.x,-this.y),this.x+=a*(f.horizAdvX||i.horizAdvX)/A,void 0===h[d]||isNaN(h[d])||(this.x+=h[d])}else{var{x:g,y:m}=this;t.fillStyle&&t.fillText(r,g,m),t.strokeStyle&&t.strokeText(r,g,m)}}applyAnchoring(){if(!(this.textChunkStart>=this.leafTexts.length)){var t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start"),n=0;n="start"===e?t.x-this.minX:"end"===e?t.x-this.maxX:t.x-(this.minX+this.maxX)/2;for(var r=this.textChunkStart;r<this.leafTexts.length;r++)this.leafTexts[r].x+=n;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}}adjustChildCoordinatesRecursive(t){this.children.forEach((e,n)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,n)}),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,n,r){var i=n.children[r];i.children.length>0?i.children.forEach((n,r)=>{e.adjustChildCoordinatesRecursiveCore(t,e,i,r)}):this.adjustChildCoordinates(t,e,n,r)}adjustChildCoordinates(t,e,n,r){var i=n.children[r];if("function"!=typeof i.measureText)return i;t.save(),i.setContext(t,!0);var A=i.getAttribute("x"),s=i.getAttribute("y"),a=i.getAttribute("dx"),o=i.getAttribute("dy"),l=i.getStyle("font-family").getDefinition(),c=Boolean(l)&&l.isRTL;0===r&&(A.hasValue()||A.setValue(i.getInheritedAttribute("x")),s.hasValue()||s.setValue(i.getInheritedAttribute("y")),a.hasValue()||a.setValue(i.getInheritedAttribute("dx")),o.hasValue()||o.setValue(i.getInheritedAttribute("dy")));var h=i.measureText(t);return c&&(e.x-=h),A.hasValue()?(e.applyAnchoring(),i.x=A.getPixels("x"),a.hasValue()&&(i.x+=a.getPixels("x"))):(a.hasValue()&&(e.x+=a.getPixels("x")),i.x=e.x),e.x=i.x,c||(e.x+=h),s.hasValue()?(i.y=s.getPixels("y"),o.hasValue()&&(i.y+=o.getPixels("y"))):(o.hasValue()&&(e.y+=o.getPixels("y")),i.y=e.y),e.y=i.y,e.leafTexts.push(i),e.minX=Math.min(e.minX,i.x,i.x+h),e.maxX=Math.max(e.maxX,i.x,i.x+h),i.clearContext(t),t.restore(),i}getChildBoundingBox(t,e,n,r){var i=n.children[r];if("function"!=typeof i.getBoundingBox)return null;var A=i.getBoundingBox(t);return A?(i.children.forEach((n,r)=>{var s=e.getChildBoundingBox(t,e,i,r);A.addBoundingBox(s)}),A):null}renderChild(t,e,n,r){var i=n.children[r];i.render(t),i.children.forEach((n,r)=>{e.renderChild(t,e,i,r)})}measureText(t){var{measureCache:e}=this;if(~e)return e;var n=this.getText(),r=this.measureTargetText(t,n);return this.measureCache=r,r}measureTargetText(t,e){if(!e.length)return 0;var{parent:n}=this,r=n.getStyle("font-family").getDefinition();if(r){for(var i=this.getFontSize(),A=r.isRTL?e.split("").reverse().join(""):e,s=i5(n.getAttribute("dx").getString()),a=A.length,o=0,l=0;l<a;l++){o+=(this.getGlyph(r,A,l).horizAdvX||r.horizAdvX)*i/r.fontFace.unitsPerEm,void 0===s[l]||isNaN(s[l])||(o+=s[l])}return o}if(!t.measureText)return 10*e.length;t.save(),this.setContext(t,!0);var{width:c}=t.measureText(e);return this.clearContext(t),t.restore(),c}getInheritedAttribute(t){for(var e=this;e instanceof i4&&e.isFirstChild();){var n=e.parent.getAttribute(t);if(n.hasValue(!0))return n.getValue("0");e=e.parent}return null}}class A4 extends i4{constructor(t,e,n){super(t,e,new.target===A4||n),this.type="tspan",this.text=this.children.length>0?"":this.getTextFromNode()}getText(){return this.text}}class s4 extends A4{constructor(){super(...arguments),this.type="textNode"}}let a4=class extends e4{constructor(){super(...arguments),this.type="svg",this.root=!1}setContext(t){var e,{document:n}=this,{screen:r,window:i}=n,A=t.canvas;if(r.setDefaults(t),A.style&&void 0!==t.font&&i&&void 0!==i.getComputedStyle){t.font=i.getComputedStyle(A).getPropertyValue("font");var s=new L5(n,"fontSize",J5.parse(t.font).fontSize);s.hasValue()&&(n.rootEmSize=s.getPixels("y"),n.emSize=n.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);var{width:a,height:o}=r.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");var l=this.getAttribute("refX"),c=this.getAttribute("refY"),h=this.getAttribute("viewBox"),u=h.hasValue()?i5(h.getString()):null,d=!this.root&&"visible"!==this.getStyle("overflow").getValue("hidden"),f=0,p=0,g=0,m=0;u&&(f=u[0],p=u[1]),this.root||(a=this.getStyle("width").getPixels("x"),o=this.getStyle("height").getPixels("y"),"marker"===this.type&&(g=f,m=p,f=0,p=0)),r.viewPort.setCurrent(a,o),!this.node||this.parent&&"foreignObject"!==(null===(e=this.node.parentNode)||void 0===e?void 0:e.nodeName)||!this.getStyle("transform",!1,!0).hasValue()||this.getStyle("transform-origin",!1,!0).hasValue()||this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(t),t.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),u&&(a=u[2],o=u[3]),n.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r.viewPort.width,desiredWidth:a,height:r.viewPort.height,desiredHeight:o,minX:f,minY:p,refX:l.getValue(),refY:c.getValue(),clip:d,clipX:g,clipY:m}),u&&(r.viewPort.removeCurrent(),r.viewPort.setCurrent(a,o))}clearContext(t){super.clearContext(t),this.document.screen.viewPort.removeCurrent()}resize(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.getAttribute("width",!0),i=this.getAttribute("height",!0),A=this.getAttribute("viewBox"),s=this.getAttribute("style"),a=r.getNumber(0),o=i.getNumber(0);if(n)if("string"==typeof n)this.getAttribute("preserveAspectRatio",!0).setValue(n);else{var l=this.getAttribute("preserveAspectRatio");l.hasValue()&&l.setValue(l.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(r.setValue(t),i.setValue(e),A.hasValue()||A.setValue("0 0 ".concat(a||t," ").concat(o||e)),s.hasValue()){var c=this.getStyle("width"),h=this.getStyle("height");c.hasValue()&&c.setValue("".concat(t,"px")),h.hasValue()&&h.setValue("".concat(e,"px"))}}};class o4 extends n4{constructor(){super(...arguments),this.type="rect"}path(t){var e=this.getAttribute("x").getPixels("x"),n=this.getAttribute("y").getPixels("y"),r=this.getStyle("width",!1,!0).getPixels("x"),i=this.getStyle("height",!1,!0).getPixels("y"),A=this.getAttribute("rx"),s=this.getAttribute("ry"),a=A.getPixels("x"),o=s.getPixels("y");if(A.hasValue()&&!s.hasValue()&&(o=a),s.hasValue()&&!A.hasValue()&&(a=o),a=Math.min(a,r/2),o=Math.min(o,i/2),t){var l=(Math.sqrt(2)-1)/3*4;t.beginPath(),i>0&&r>0&&(t.moveTo(e+a,n),t.lineTo(e+r-a,n),t.bezierCurveTo(e+r-a+l*a,n,e+r,n+o-l*o,e+r,n+o),t.lineTo(e+r,n+i-o),t.bezierCurveTo(e+r,n+i-o+l*o,e+r-a+l*a,n+i,e+r-a,n+i),t.lineTo(e+a,n+i),t.bezierCurveTo(e+a-l*a,n+i,e,n+i-o+l*o,e,n+i-o),t.lineTo(e,n+o),t.bezierCurveTo(e,n+o-l*o,e+a-l*a,n,e+a,n),t.closePath())}return new Z5(e,n,e+r,n+i)}getMarkers(){return null}}class l4 extends n4{constructor(){super(...arguments),this.type="circle"}path(t){var e=this.getAttribute("cx").getPixels("x"),n=this.getAttribute("cy").getPixels("y"),r=this.getAttribute("r").getPixels();return t&&r>0&&(t.beginPath(),t.arc(e,n,r,0,2*Math.PI,!1),t.closePath()),new Z5(e-r,n-r,e+r,n+r)}getMarkers(){return null}}class c4 extends n4{constructor(){super(...arguments),this.type="ellipse"}path(t){var e=(Math.sqrt(2)-1)/3*4,n=this.getAttribute("rx").getPixels("x"),r=this.getAttribute("ry").getPixels("y"),i=this.getAttribute("cx").getPixels("x"),A=this.getAttribute("cy").getPixels("y");return t&&n>0&&r>0&&(t.beginPath(),t.moveTo(i+n,A),t.bezierCurveTo(i+n,A+e*r,i+e*n,A+r,i,A+r),t.bezierCurveTo(i-e*n,A+r,i-n,A+e*r,i-n,A),t.bezierCurveTo(i-n,A-e*r,i-e*n,A-r,i,A-r),t.bezierCurveTo(i+e*n,A-r,i+n,A-e*r,i+n,A),t.closePath()),new Z5(i-n,A-r,i+n,A+r)}getMarkers(){return null}}class h4 extends n4{constructor(){super(...arguments),this.type="line"}getPoints(){return[new I5(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new I5(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(t){var[{x:e,y:n},{x:r,y:i}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,n),t.lineTo(r,i)),new Z5(e,n,r,i)}getMarkers(){var[t,e]=this.getPoints(),n=t.angleTo(e);return[[t,n],[e,n]]}}class u4 extends n4{constructor(t,e,n){super(t,e,n),this.type="polyline",this.points=[],this.points=I5.parsePath(this.getAttribute("points").getString())}path(t){var{points:e}=this,[{x:n,y:r}]=e,i=new Z5(n,r);return t&&(t.beginPath(),t.moveTo(n,r)),e.forEach(e=>{var{x:n,y:r}=e;i.addPoint(n,r),t&&t.lineTo(n,r)}),i}getMarkers(){var{points:t}=this,e=t.length-1,n=[];return t.forEach((r,i)=>{i!==e&&n.push([r,r.angleTo(t[i+1])])}),n.length>0&&n.push([t[t.length-1],n[n.length-1][1]]),n}}class d4 extends u4{constructor(){super(...arguments),this.type="polygon"}path(t){var e=super.path(t),[{x:n,y:r}]=this.points;return t&&(t.lineTo(n,r),t.closePath()),e}}class f4 extends z5{constructor(){super(...arguments),this.type="pattern"}createPattern(t,e,n){var r=this.getStyle("width").getPixels("x",!0),i=this.getStyle("height").getPixels("y",!0),A=new a4(this.document,null);A.attributes.viewBox=new L5(this.document,"viewBox",this.getAttribute("viewBox").getValue()),A.attributes.width=new L5(this.document,"width","".concat(r,"px")),A.attributes.height=new L5(this.document,"height","".concat(i,"px")),A.attributes.transform=new L5(this.document,"transform",this.getAttribute("patternTransform").getValue()),A.children=this.children;var s=this.document.createCanvas(r,i),a=s.getContext("2d"),o=this.getAttribute("x"),l=this.getAttribute("y");o.hasValue()&&l.hasValue()&&a.translate(o.getPixels("x",!0),l.getPixels("y",!0)),n.hasValue()?this.styles["fill-opacity"]=n:Reflect.deleteProperty(this.styles,"fill-opacity");for(var c=-1;c<=1;c++)for(var h=-1;h<=1;h++)a.save(),A.attributes.x=new L5(this.document,"x",c*s.width),A.attributes.y=new L5(this.document,"y",h*s.height),A.render(a),a.restore();return t.createPattern(s,"repeat")}}class p4 extends z5{constructor(){super(...arguments),this.type="marker"}render(t,e,n){if(e){var{x:r,y:i}=e,A=this.getAttribute("orient").getString("auto"),s=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(r,i),"auto"===A&&t.rotate(n),"strokeWidth"===s&&t.scale(t.lineWidth,t.lineWidth),t.save();var a=new a4(this.document,null);a.type=this.type,a.attributes.viewBox=new L5(this.document,"viewBox",this.getAttribute("viewBox").getValue()),a.attributes.refX=new L5(this.document,"refX",this.getAttribute("refX").getValue()),a.attributes.refY=new L5(this.document,"refY",this.getAttribute("refY").getValue()),a.attributes.width=new L5(this.document,"width",this.getAttribute("markerWidth").getValue()),a.attributes.height=new L5(this.document,"height",this.getAttribute("markerHeight").getValue()),a.attributes.overflow=new L5(this.document,"overflow",this.getAttribute("overflow").getValue()),a.attributes.fill=new L5(this.document,"fill",this.getAttribute("fill").getColor("black")),a.attributes.stroke=new L5(this.document,"stroke",this.getAttribute("stroke").getValue("none")),a.children=this.children,a.render(t),t.restore(),"strokeWidth"===s&&t.scale(1/t.lineWidth,1/t.lineWidth),"auto"===A&&t.rotate(-n),t.translate(-r,-i)}}}class g4 extends z5{constructor(){super(...arguments),this.type="defs"}render(){}}class m4 extends e4{constructor(){super(...arguments),this.type="g"}getBoundingBox(t){var e=new Z5;return this.children.forEach(n=>{e.addBoundingBox(n.getBoundingBox(t))}),e}}class w4 extends z5{constructor(t,e,n){super(t,e,n),this.attributesToInherit=["gradientUnits"],this.stops=[];var{stops:r,children:i}=this;i.forEach(t=>{"stop"===t.type&&r.push(t)})}getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,n){var r=this;this.getHrefAttribute().hasValue()&&(r=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(r));var{stops:i}=r,A=this.getGradient(t,e);if(!A)return this.addParentOpacity(n,i[i.length-1].color);if(i.forEach(t=>{A.addColorStop(t.offset,this.addParentOpacity(n,t.color))}),this.getAttribute("gradientTransform").hasValue()){var{document:s}=this,{MAX_VIRTUAL_PIXELS:a,viewPort:o}=s.screen,[l]=o.viewPorts,c=new o4(s,null);c.attributes.x=new L5(s,"x",-a/3),c.attributes.y=new L5(s,"y",-a/3),c.attributes.width=new L5(s,"width",a),c.attributes.height=new L5(s,"height",a);var h=new m4(s,null);h.attributes.transform=new L5(s,"transform",this.getAttribute("gradientTransform").getValue()),h.children=[c];var u=new a4(s,null);u.attributes.x=new L5(s,"x",0),u.attributes.y=new L5(s,"y",0),u.attributes.width=new L5(s,"width",l.width),u.attributes.height=new L5(s,"height",l.height),u.children=[h];var d=s.createCanvas(l.width,l.height),f=d.getContext("2d");return f.fillStyle=A,u.render(f),f.createPattern(d,"no-repeat")}return A}inheritStopContainer(t){this.attributesToInherit.forEach(e=>{!this.getAttribute(e).hasValue()&&t.getAttribute(e).hasValue()&&this.getAttribute(e,!0).setValue(t.getAttribute(e).getValue())})}addParentOpacity(t,e){return t.hasValue()?new L5(this.document,"color",e).addOpacity(t).getColor():e}}class v4 extends w4{constructor(t,e,n){super(t,e,n),this.type="linearGradient",this.attributesToInherit.push("x1","y1","x2","y2")}getGradient(t,e){var n="objectBoundingBox"===this.getGradientUnits(),r=n?e.getBoundingBox(t):null;if(n&&!r)return null;this.getAttribute("x1").hasValue()||this.getAttribute("y1").hasValue()||this.getAttribute("x2").hasValue()||this.getAttribute("y2").hasValue()||(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));var i=n?r.x+r.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),A=n?r.y+r.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),s=n?r.x+r.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),a=n?r.y+r.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return i===s&&A===a?null:t.createLinearGradient(i,A,s,a)}}class y4 extends w4{constructor(t,e,n){super(t,e,n),this.type="radialGradient",this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}getGradient(t,e){var n="objectBoundingBox"===this.getGradientUnits(),r=e.getBoundingBox(t);if(n&&!r)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");var i=n?r.x+r.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),A=n?r.y+r.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y"),s=i,a=A;this.getAttribute("fx").hasValue()&&(s=n?r.x+r.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(a=n?r.y+r.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));var o=n?(r.width+r.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),l=this.getAttribute("fr").getPixels();return t.createRadialGradient(s,a,l,i,A,o)}}class b4 extends z5{constructor(t,e,n){super(t,e,n),this.type="stop";var r=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),i=this.getStyle("stop-opacity"),A=this.getStyle("stop-color",!0);""===A.getString()&&A.setValue("#000"),i.hasValue()&&(A=A.addOpacity(i)),this.offset=r,this.color=A.getColor()}}class B4 extends z5{constructor(t,e,n){super(t,e,n),this.type="animate",this.duration=0,this.initialValue=null,this.initialUnits="",this.removed=!1,this.frozen=!1,t.screen.animations.push(this),this.begin=this.getAttribute("begin").getMilliseconds(),this.maxDuration=this.begin+this.getAttribute("dur").getMilliseconds(),this.from=this.getAttribute("from"),this.to=this.getAttribute("to"),this.values=new L5(t,"values",null);var r=this.getAttribute("values");r.hasValue()&&this.values.setValue(r.getString().split(";"))}getProperty(){var t=this.getAttribute("attributeType").getString(),e=this.getAttribute("attributeName").getString();return"CSS"===t?this.parent.getStyle(e,!0):this.parent.getAttribute(e,!0)}calcValue(){var{initialUnits:t}=this,{progress:e,from:n,to:r}=this.getProgress(),i=n.getNumber()+(r.getNumber()-n.getNumber())*e;return"%"===t&&(i*=100),"".concat(i).concat(t)}update(t){var{parent:e}=this,n=this.getProperty();if(this.initialValue||(this.initialValue=n.getString(),this.initialUnits=n.getUnits()),this.duration>this.maxDuration){var r=this.getAttribute("fill").getString("remove");if("indefinite"===this.getAttribute("repeatCount").getString()||"indefinite"===this.getAttribute("repeatDur").getString())this.duration=0;else if("freeze"!==r||this.frozen){if("remove"===r&&!this.removed)return this.removed=!0,n.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e.animationFrozen=!0,e.animationFrozenValue=n.getString();return!1}this.duration+=t;var i=!1;if(this.begin<this.duration){var A=this.calcValue(),s=this.getAttribute("type");if(s.hasValue()){var a=s.getString();A="".concat(a,"(").concat(A,")")}n.setValue(A),i=!0}return i}getProgress(){var{document:t,values:e}=this,n={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};if(e.hasValue()){var r=n.progress*(e.getValue().length-1),i=Math.floor(r),A=Math.ceil(r);n.from=new L5(t,"from",parseFloat(e.getValue()[i])),n.to=new L5(t,"to",parseFloat(e.getValue()[A])),n.progress=(r-i)/(A-i)}else n.from=this.from,n.to=this.to;return n}}class _4 extends B4{constructor(){super(...arguments),this.type="animateColor"}calcValue(){var{progress:t,from:e,to:n}=this.getProgress(),r=new e2(e.getColor()),i=new e2(n.getColor());if(r.ok&&i.ok){var A=r.r+(i.r-r.r)*t,s=r.g+(i.g-r.g)*t,a=r.b+(i.b-r.b)*t;return"rgb(".concat(Math.floor(A),", ").concat(Math.floor(s),", ").concat(Math.floor(a),")")}return this.getAttribute("from").getColor()}}class C4 extends B4{constructor(){super(...arguments),this.type="animateTransform"}calcValue(){var{progress:t,from:e,to:n}=this.getProgress(),r=i5(e.getString()),i=i5(n.getString());return r.map((e,n)=>e+(i[n]-e)*t).join(" ")}}class x4 extends z5{constructor(t,e,n){super(t,e,n),this.type="font",this.glyphs=Object.create(null),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();var{definitions:r}=t,{children:i}=this;for(var A of i)switch(A.type){case"font-face":this.fontFace=A;var s=A.getStyle("font-family");s.hasValue()&&(r[s.getString()]=this);break;case"missing-glyph":this.missingGlyph=A;break;case"glyph":var a=A;a.arabicForm?(this.isRTL=!0,this.isArabic=!0,void 0===this.glyphs[a.unicode]&&(this.glyphs[a.unicode]=Object.create(null)),this.glyphs[a.unicode][a.arabicForm]=a):this.glyphs[a.unicode]=a}}render(){}}class E4 extends z5{constructor(t,e,n){super(t,e,n),this.type="font-face",this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}class S4 extends n4{constructor(){super(...arguments),this.type="missing-glyph",this.horizAdvX=0}}class F4 extends i4{constructor(){super(...arguments),this.type="tref"}getText(){var t=this.getHrefAttribute().getDefinition();if(t){var e=t.children[0];if(e)return e.getText()}return""}}class L4 extends i4{constructor(t,e,n){super(t,e,n),this.type="a";var{childNodes:r}=e,i=r[0],A=r.length>0&&Array.from(r).every(t=>3===t.nodeType);this.hasText=A,this.text=A?this.getTextFromNode(i):""}getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);var{document:e,x:n,y:r}=this,{mouse:i}=e.screen,A=new L5(e,"fontSize",J5.parse(e.ctx.font).fontSize);i.isWorking()&&i.checkBoundingBox(this,new Z5(n,r-A.getPixels("y"),n+this.measureText(t),r))}else if(this.children.length>0){var s=new m4(this.document,null);s.children=this.children,s.parent=this,s.render(t)}}onClick(){var{window:t}=this.document;t&&t.open(this.getHrefAttribute().getString())}onMouseMove(){this.document.ctx.canvas.style.cursor="pointer"}}function U4(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function I4(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?U4(Object(n),!0).forEach(function(e){T0(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U4(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}class Q4 extends i4{constructor(t,e,n){super(t,e,n),this.type="textPath",this.textWidth=0,this.textHeight=0,this.pathLength=-1,this.glyphInfo=null,this.letterSpacingCache=[],this.measuresCache=new Map([["",0]]);var r=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(r)}getText(){return this.text}path(t){var{dataArray:e}=this;t&&t.beginPath(),e.forEach(e=>{var{type:n,points:r}=e;switch(n){case t4.LINE_TO:t&&t.lineTo(r[0],r[1]);break;case t4.MOVE_TO:t&&t.moveTo(r[0],r[1]);break;case t4.CURVE_TO:t&&t.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case t4.QUAD_TO:t&&t.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case t4.ARC:var[i,A,s,a,o,l,c,h]=r,u=s>a?s:a,d=s>a?1:s/a,f=s>a?a/s:1;t&&(t.translate(i,A),t.rotate(c),t.scale(d,f),t.arc(0,0,u,o,o+l,Boolean(1-h)),t.scale(1/d,1/f),t.rotate(-c),t.translate(-i,-A));break;case t4.CLOSE_PATH:t&&t.closePath()}})}renderChildren(t){this.setTextData(t),t.save();var e=this.parent.getStyle("text-decoration").getString(),n=this.getFontSize(),{glyphInfo:r}=this,i=t.fillStyle;"underline"===e&&t.beginPath(),r.forEach((r,i)=>{var{p0:A,p1:s,rotation:a,text:o}=r;t.save(),t.translate(A.x,A.y),t.rotate(a),t.fillStyle&&t.fillText(o,0,0),t.strokeStyle&&t.strokeText(o,0,0),t.restore(),"underline"===e&&(0===i&&t.moveTo(A.x,A.y+n/8),t.lineTo(s.x,s.y+n/5))}),"underline"===e&&(t.lineWidth=n/20,t.strokeStyle=i,t.stroke(),t.closePath()),t.restore()}getLetterSpacingAt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.letterSpacingCache[t]||0}findSegmentToFitChar(t,e,n,r,i,A,s,a,o){var l=A,c=this.measureText(t,a);" "===a&&"justify"===e&&n<r&&(c+=(r-n)/i),o>-1&&(l+=this.getLetterSpacingAt(o));var h=this.textHeight/20,u=this.getEquidistantPointOnPath(l,h,0),d=this.getEquidistantPointOnPath(l+c,h,0),f={p0:u,p1:d},p=u&&d?Math.atan2(d.y-u.y,d.x-u.x):0;if(s){var g=Math.cos(Math.PI/2+p)*s,m=Math.cos(-p)*s;f.p0=I4(I4({},u),{},{x:u.x+g,y:u.y+m}),f.p1=I4(I4({},d),{},{x:d.x+g,y:d.y+m})}return{offset:l+=c,segment:f,rotation:p}}measureText(t,e){var{measuresCache:n}=this,r=e||this.getText();if(n.has(r))return n.get(r);var i=this.measureTargetText(t,r);return n.set(r,i),i}setTextData(t){if(!this.glyphInfo){var e=this.getText(),n=e.split(""),r=e.split(" ").length-1,i=this.parent.getAttribute("dx").split().map(t=>t.getPixels("x")),A=this.parent.getAttribute("dy").getPixels("y"),s=this.parent.getStyle("text-anchor").getString("start"),a=this.getStyle("letter-spacing"),o=this.parent.getStyle("letter-spacing"),l=0;a.hasValue()&&"inherit"!==a.getValue()?a.hasValue()&&"initial"!==a.getValue()&&"unset"!==a.getValue()&&(l=a.getPixels()):l=o.getPixels();var c=[],h=e.length;this.letterSpacingCache=c;for(var u=0;u<h;u++)c.push(void 0!==i[u]?i[u]:l);var d=c.reduce((t,e,n)=>0===n?0:t+e||0,0),f=this.measureText(t),p=Math.max(f+d,0);this.textWidth=f,this.textHeight=this.getFontSize(),this.glyphInfo=[];var g=this.getPathLength(),m=this.getStyle("startOffset").getNumber(0)*g,w=0;"middle"!==s&&"center"!==s||(w=-p/2),"end"!==s&&"right"!==s||(w=-p),w+=m,n.forEach((e,i)=>{var{offset:a,segment:o,rotation:l}=this.findSegmentToFitChar(t,s,p,g,r,w,A,e,i);w=a,o.p0&&o.p1&&this.glyphInfo.push({text:n[i],p0:o.p0,p1:o.p1,rotation:l})})}}parsePathData(t){if(this.pathLength=-1,!t)return[];var e=[],{pathParser:n}=t;for(n.reset();!n.isEnd();){var{current:r}=n,i=r?r.x:0,A=r?r.y:0,s=n.next(),a=s.type,o=[];switch(s.type){case t4.MOVE_TO:this.pathM(n,o);break;case t4.LINE_TO:a=this.pathL(n,o);break;case t4.HORIZ_LINE_TO:a=this.pathH(n,o);break;case t4.VERT_LINE_TO:a=this.pathV(n,o);break;case t4.CURVE_TO:this.pathC(n,o);break;case t4.SMOOTH_CURVE_TO:a=this.pathS(n,o);break;case t4.QUAD_TO:this.pathQ(n,o);break;case t4.SMOOTH_QUAD_TO:a=this.pathT(n,o);break;case t4.ARC:o=this.pathA(n);break;case t4.CLOSE_PATH:n4.pathZ(n)}s.type!==t4.CLOSE_PATH?e.push({type:a,points:o,start:{x:i,y:A},pathLength:this.calcLength(i,A,a,o)}):e.push({type:t4.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){var{x:n,y:r}=n4.pathM(t).point;e.push(n,r)}pathL(t,e){var{x:n,y:r}=n4.pathL(t).point;return e.push(n,r),t4.LINE_TO}pathH(t,e){var{x:n,y:r}=n4.pathH(t).point;return e.push(n,r),t4.LINE_TO}pathV(t,e){var{x:n,y:r}=n4.pathV(t).point;return e.push(n,r),t4.LINE_TO}pathC(t,e){var{point:n,controlPoint:r,currentPoint:i}=n4.pathC(t);e.push(n.x,n.y,r.x,r.y,i.x,i.y)}pathS(t,e){var{point:n,controlPoint:r,currentPoint:i}=n4.pathS(t);return e.push(n.x,n.y,r.x,r.y,i.x,i.y),t4.CURVE_TO}pathQ(t,e){var{controlPoint:n,currentPoint:r}=n4.pathQ(t);e.push(n.x,n.y,r.x,r.y)}pathT(t,e){var{controlPoint:n,currentPoint:r}=n4.pathT(t);return e.push(n.x,n.y,r.x,r.y),t4.QUAD_TO}pathA(t){var{rX:e,rY:n,sweepFlag:r,xAxisRotation:i,centp:A,a1:s,ad:a}=n4.pathA(t);return 0===r&&a>0&&(a-=2*Math.PI),1===r&&a<0&&(a+=2*Math.PI),[A.x,A.y,e,n,s,a,i,r]}calcLength(t,e,n,r){var i=0,A=null,s=null,a=0;switch(n){case t4.LINE_TO:return this.getLineLength(t,e,r[0],r[1]);case t4.CURVE_TO:for(i=0,A=this.getPointOnCubicBezier(0,t,e,r[0],r[1],r[2],r[3],r[4],r[5]),a=.01;a<=1;a+=.01)s=this.getPointOnCubicBezier(a,t,e,r[0],r[1],r[2],r[3],r[4],r[5]),i+=this.getLineLength(A.x,A.y,s.x,s.y),A=s;return i;case t4.QUAD_TO:for(i=0,A=this.getPointOnQuadraticBezier(0,t,e,r[0],r[1],r[2],r[3]),a=.01;a<=1;a+=.01)s=this.getPointOnQuadraticBezier(a,t,e,r[0],r[1],r[2],r[3]),i+=this.getLineLength(A.x,A.y,s.x,s.y),A=s;return i;case t4.ARC:i=0;var o=r[4],l=r[5],c=r[4]+l,h=Math.PI/180;if(Math.abs(o-c)<h&&(h=Math.abs(o-c)),A=this.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],o,0),l<0)for(a=o-h;a>c;a-=h)s=this.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],a,0),i+=this.getLineLength(A.x,A.y,s.x,s.y),A=s;else for(a=o+h;a<c;a+=h)s=this.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],a,0),i+=this.getLineLength(A.x,A.y,s.x,s.y),A=s;return s=this.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),i+=this.getLineLength(A.x,A.y,s.x,s.y)}return 0}getPointOnLine(t,e,n,r,i){var A=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:n,a=(i-n)/(r-e+w5),o=Math.sqrt(t*t/(1+a*a));r<e&&(o*=-1);var l=a*o,c=null;if(r===e)c={x:A,y:s+l};else if((s-n)/(A-e+w5)===a)c={x:A+o,y:s+l};else{var h,u,d=this.getLineLength(e,n,r,i);if(d<w5)return null;var f=(A-e)*(r-e)+(s-n)*(i-n);h=e+(f/=d*d)*(r-e),u=n+f*(i-n);var p=this.getLineLength(A,s,h,u),g=Math.sqrt(t*t-p*p);o=Math.sqrt(g*g/(1+a*a)),r<e&&(o*=-1),c={x:h+o,y:u+(l=a*o)}}return c}getPointOnPath(t){var e=this.getPathLength(),n=0,r=null;if(t<-5e-5||t-5e-5>e)return null;var{dataArray:i}=this;for(var A of i){if(!A||!(A.pathLength<5e-5||n+A.pathLength+5e-5<t)){var s=t-n,a=0;switch(A.type){case t4.LINE_TO:r=this.getPointOnLine(s,A.start.x,A.start.y,A.points[0],A.points[1],A.start.x,A.start.y);break;case t4.ARC:var o=A.points[4],l=A.points[5],c=A.points[4]+l;if(a=o+s/A.pathLength*l,l<0&&a<c||l>=0&&a>c)break;r=this.getPointOnEllipticalArc(A.points[0],A.points[1],A.points[2],A.points[3],a,A.points[6]);break;case t4.CURVE_TO:(a=s/A.pathLength)>1&&(a=1),r=this.getPointOnCubicBezier(a,A.start.x,A.start.y,A.points[0],A.points[1],A.points[2],A.points[3],A.points[4],A.points[5]);break;case t4.QUAD_TO:(a=s/A.pathLength)>1&&(a=1),r=this.getPointOnQuadraticBezier(a,A.start.x,A.start.y,A.points[0],A.points[1],A.points[2],A.points[3])}if(r)return r;break}n+=A.pathLength}return null}getLineLength(t,e,n,r){return Math.sqrt((n-t)*(n-t)+(r-e)*(r-e))}getPathLength(){return-1===this.pathLength&&(this.pathLength=this.dataArray.reduce((t,e)=>e.pathLength>0?t+e.pathLength:t,0)),this.pathLength}getPointOnCubicBezier(t,e,n,r,i,A,s,a,o){return{x:a*B5(t)+A*_5(t)+r*C5(t)+e*x5(t),y:o*B5(t)+s*_5(t)+i*C5(t)+n*x5(t)}}getPointOnQuadraticBezier(t,e,n,r,i,A,s){return{x:A*E5(t)+r*S5(t)+e*F5(t),y:s*E5(t)+i*S5(t)+n*F5(t)}}getPointOnEllipticalArc(t,e,n,r,i,A){var s=Math.cos(A),a=Math.sin(A),o=n*Math.cos(i),l=r*Math.sin(i);return{x:t+(o*s-l*a),y:e+(o*a+l*s)}}buildEquidistantCache(t,e){var n=this.getPathLength(),r=e||.25,i=t||n/100;if(!this.equidistantCache||this.equidistantCache.step!==i||this.equidistantCache.precision!==r){this.equidistantCache={step:i,precision:r,points:[]};for(var A=0,s=0;s<=n;s+=r){var a=this.getPointOnPath(s),o=this.getPointOnPath(s+r);a&&o&&((A+=this.getLineLength(a.x,a.y,o.x,o.y))>=i&&(this.equidistantCache.points.push({x:a.x,y:a.y,distance:s}),A-=i))}}}getEquidistantPointOnPath(t,e,n){if(this.buildEquidistantCache(e,n),t<0||t-this.getPathLength()>5e-5)return null;var r=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[r]||null}}var k4=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;class M4 extends e4{constructor(t,e,n){super(t,e,n),this.type="image",this.loaded=!1;var r=this.getHrefAttribute().getString();if(r){var i=r.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(r);t.images.push(this),i?this.loadSvg(r):this.loadImage(r),this.isSvg=i}}loadImage(t){var e=this;return lY(function*(){try{var n=yield e.document.createImage(t);e.image=n}catch(r){console.error('Error while loading image "'.concat(t,'":'),r)}e.loaded=!0})()}loadSvg(t){var e=this;return lY(function*(){var n=k4.exec(t);if(n){var r=n[5];"base64"===n[4]?e.image=atob(r):e.image=decodeURIComponent(r)}else try{var i=yield e.document.fetch(t),A=yield i.text();e.image=A}catch(s){console.error('Error while loading image "'.concat(t,'":'),s)}e.loaded=!0})()}renderChildren(t){var{document:e,image:n,loaded:r}=this,i=this.getAttribute("x").getPixels("x"),A=this.getAttribute("y").getPixels("y"),s=this.getStyle("width").getPixels("x"),a=this.getStyle("height").getPixels("y");if(r&&n&&s&&a){if(t.save(),t.translate(i,A),this.isSvg){var o=e.canvg.forkString(t,this.image,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:s,scaleHeight:a});o.document.documentElement.parent=this,o.render()}else{var l=this.image;e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:s,desiredWidth:l.width,height:a,desiredHeight:l.height}),this.loaded&&(void 0===l.complete||l.complete)&&t.drawImage(l,0,0)}t.restore()}}getBoundingBox(){var t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),n=this.getStyle("width").getPixels("x"),r=this.getStyle("height").getPixels("y");return new Z5(t,e,t+n,e+r)}}class O4 extends e4{constructor(){super(...arguments),this.type="symbol"}render(t){}}class P4{constructor(t){this.document=t,this.loaded=!1,t.fonts.push(this)}load(t,e){var n=this;return lY(function*(){try{var{document:r}=n,i=(yield r.canvg.parser.load(e)).getElementsByTagName("font");Array.from(i).forEach(e=>{var n=r.createElement(e);r.definitions[t]=n})}catch(A){console.error('Error while loading font "'.concat(e,'":'),A)}n.loaded=!0})()}}class N4 extends z5{constructor(t,e,n){super(t,e,n),this.type="style",e5(Array.from(e.childNodes).map(t=>t.textContent).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach(e=>{var n=e.trim();if(n){var r=n.split("{"),i=r[0].split(","),A=r[1].split(";");i.forEach(e=>{var n=e.trim();if(n){var r=t.styles[n]||{};if(A.forEach(e=>{var n=e.indexOf(":"),i=e.substr(0,n).trim(),A=e.substr(n+1,e.length-n).trim();i&&A&&(r[i]=new L5(t,i,A))}),t.styles[n]=r,t.stylesSpecificity[n]=m5(n),"@font-face"===n){var i=r["font-family"].getString().replace(/"|'/g,"");r.src.getString().split(",").forEach(e=>{if(e.indexOf('format("svg")')>0){var n=a5(e);n&&new P4(t).load(i,n)}})}}})}})}}N4.parseExternalUrl=a5;class T4 extends e4{constructor(){super(...arguments),this.type="use"}setContext(t){super.setContext(t);var e=this.getAttribute("x"),n=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),n.hasValue()&&t.translate(0,n.getPixels("y"))}path(t){var{element:e}=this;e&&e.path(t)}renderChildren(t){var{document:e,element:n}=this;if(n){var r=n;if("symbol"===n.type&&((r=new a4(e,null)).attributes.viewBox=new L5(e,"viewBox",n.getAttribute("viewBox").getString()),r.attributes.preserveAspectRatio=new L5(e,"preserveAspectRatio",n.getAttribute("preserveAspectRatio").getString()),r.attributes.overflow=new L5(e,"overflow",n.getAttribute("overflow").getString()),r.children=n.children,n.styles.opacity=new L5(e,"opacity",this.calculateOpacity())),"svg"===r.type){var i=this.getStyle("width",!1,!0),A=this.getStyle("height",!1,!0);i.hasValue()&&(r.attributes.width=new L5(e,"width",i.getString())),A.hasValue()&&(r.attributes.height=new L5(e,"height",A.getString()))}var s=r.parent;r.parent=this,r.render(t),r.parent=s}}getBoundingBox(t){var{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){var{document:t,element:e}=this;return G5.fromElement(t,e)}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}}function D4(t,e,n,r,i,A){return t[n*r*4+4*e+A]}function R4(t,e,n,r,i,A,s){t[n*r*4+4*e+A]=s}function H4(t,e,n){return t[e]*n}function j4(t,e,n,r){return e+Math.cos(t)*n+Math.sin(t)*r}class W4 extends z5{constructor(t,e,n){super(t,e,n),this.type="feColorMatrix";var r=i5(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":var i=r[0];r=[.213+.787*i,.715-.715*i,.072-.072*i,0,0,.213-.213*i,.715+.285*i,.072-.072*i,0,0,.213-.213*i,.715-.715*i,.072+.928*i,0,0,0,0,0,1,0,0,0,0,0,1];break;case"hueRotate":var A=r[0]*Math.PI/180;r=[j4(A,.213,.787,-.213),j4(A,.715,-.715,-.715),j4(A,.072,-.072,.928),0,0,j4(A,.213,-.213,.143),j4(A,.715,.285,.14),j4(A,.072,-.072,-.283),0,0,j4(A,.213,-.213,-.787),j4(A,.715,-.715,.715),j4(A,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break;case"luminanceToAlpha":r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}this.matrix=r,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}apply(t,e,n,r,i){for(var{includeOpacity:A,matrix:s}=this,a=t.getImageData(0,0,r,i),o=0;o<i;o++)for(var l=0;l<r;l++){var c=D4(a.data,l,o,r,0,0),h=D4(a.data,l,o,r,0,1),u=D4(a.data,l,o,r,0,2),d=D4(a.data,l,o,r,0,3),f=H4(s,0,c)+H4(s,1,h)+H4(s,2,u)+H4(s,3,d)+H4(s,4,1),p=H4(s,5,c)+H4(s,6,h)+H4(s,7,u)+H4(s,8,d)+H4(s,9,1),g=H4(s,10,c)+H4(s,11,h)+H4(s,12,u)+H4(s,13,d)+H4(s,14,1),m=H4(s,15,c)+H4(s,16,h)+H4(s,17,u)+H4(s,18,d)+H4(s,19,1);A&&(f=0,p=0,g=0,m*=d/255),R4(a.data,l,o,r,0,0,f),R4(a.data,l,o,r,0,1,p),R4(a.data,l,o,r,0,2,g),R4(a.data,l,o,r,0,3,m)}t.clearRect(0,0,r,i),t.putImageData(a,0,0)}}class V4 extends z5{constructor(){super(...arguments),this.type="mask"}apply(t,e){var{document:n}=this,r=this.getAttribute("x").getPixels("x"),i=this.getAttribute("y").getPixels("y"),A=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");if(!A&&!s){var a=new Z5;this.children.forEach(e=>{a.addBoundingBox(e.getBoundingBox(t))}),r=Math.floor(a.x1),i=Math.floor(a.y1),A=Math.floor(a.width),s=Math.floor(a.height)}var o=this.removeStyles(e,V4.ignoreStyles),l=n.createCanvas(r+A,i+s),c=l.getContext("2d");n.screen.setDefaults(c),this.renderChildren(c),new W4(n,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,r+A,i+s);var h=n.createCanvas(r+A,i+s),u=h.getContext("2d");n.screen.setDefaults(u),e.render(u),u.globalCompositeOperation="destination-in",u.fillStyle=c.createPattern(l,"no-repeat"),u.fillRect(0,0,r+A,i+s),t.fillStyle=u.createPattern(h,"no-repeat"),t.fillRect(0,0,r+A,i+s),this.restoreStyles(e,o)}render(t){}}V4.ignoreStyles=["mask","transform","clip-path"];var K4=()=>{};class G4 extends z5{constructor(){super(...arguments),this.type="clipPath"}apply(t){var{document:e}=this,n=Reflect.getPrototypeOf(t),{beginPath:r,closePath:i}=t;n&&(n.beginPath=K4,n.closePath=K4),Reflect.apply(r,t,[]),this.children.forEach(r=>{if(void 0!==r.path){var A=void 0!==r.elementTransform?r.elementTransform():null;A||(A=G5.fromElement(e,r)),A&&A.apply(t),r.path(t),n&&(n.closePath=i),A&&A.unapply(t)}}),Reflect.apply(i,t,[]),t.clip(),n&&(n.beginPath=r,n.closePath=i)}render(t){}}class z4 extends z5{constructor(){super(...arguments),this.type="filter"}apply(t,e){var{document:n,children:r}=this,i=e.getBoundingBox(t);if(i){var A=0,s=0;r.forEach(t=>{var e=t.extraFilterDistance||0;A=Math.max(A,e),s=Math.max(s,e)});var a=Math.floor(i.width),o=Math.floor(i.height),l=a+2*A,c=o+2*s;if(!(l<1||c<1)){var h=Math.floor(i.x),u=Math.floor(i.y),d=this.removeStyles(e,z4.ignoreStyles),f=n.createCanvas(l,c),p=f.getContext("2d");n.screen.setDefaults(p),p.translate(-h+A,-u+s),e.render(p),r.forEach(t=>{"function"==typeof t.apply&&t.apply(p,0,0,l,c)}),t.drawImage(f,0,0,l,c,h-A,u-s,l,c),this.restoreStyles(e,d)}}}render(t){}}z4.ignoreStyles=["filter","transform","clip-path"];class q4 extends z5{constructor(t,e,n){super(t,e,n),this.type="feDropShadow",this.addStylesFromStyleDefinition()}apply(t,e,n,r,i){}}class X4 extends z5{constructor(){super(...arguments),this.type="feMorphology"}apply(t,e,n,r,i){}}class Y4 extends z5{constructor(){super(...arguments),this.type="feComposite"}apply(t,e,n,r,i){}}class $4 extends z5{constructor(t,e,n){super(t,e,n),this.type="feGaussianBlur",this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}apply(t,e,n,r,i){var{document:A,blurRadius:s}=this,a=A.window?A.window.document.body:null,o=t.canvas;o.id=A.getUniqueId(),a&&(o.style.display="none",a.appendChild(o)),J2(o,e,n,r,i,s),a&&a.removeChild(o)}}class J4 extends z5{constructor(){super(...arguments),this.type="title"}}class Z4 extends z5{constructor(){super(...arguments),this.type="desc"}}var t3={svg:a4,rect:o4,circle:l4,ellipse:c4,line:h4,polyline:u4,polygon:d4,path:n4,pattern:f4,marker:p4,defs:g4,linearGradient:v4,radialGradient:y4,stop:b4,animate:B4,animateColor:_4,animateTransform:C4,font:x4,"font-face":E4,"missing-glyph":S4,glyph:r4,text:i4,tspan:A4,tref:F4,a:L4,textPath:Q4,image:M4,g:m4,symbol:O4,style:N4,use:T4,mask:V4,clipPath:G4,filter:z4,feDropShadow:q4,feMorphology:X4,feComposite:Y4,feColorMatrix:W4,feGaussianBlur:$4,title:J4,desc:Z4};function e3(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function n3(){return n3=lY(function*(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=document.createElement("img");return e&&(n.crossOrigin="Anonymous"),new Promise((e,r)=>{n.onload=()=>{e(n)},n.onerror=(t,e,n,i,A)=>{r(A)},n.src=t})}),n3.apply(this,arguments)}class r3{constructor(t){var{rootEmSize:e=12,emSize:n=12,createCanvas:r=r3.createCanvas,createImage:i=r3.createImage,anonymousCrossOrigin:A}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.canvg=t,this.definitions=Object.create(null),this.styles=Object.create(null),this.stylesSpecificity=Object.create(null),this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=t.screen,this.rootEmSize=e,this.emSize=n,this.createCanvas=r,this.createImage=this.bindCreateImage(i,A),this.screen.wait(this.isImagesLoaded.bind(this)),this.screen.wait(this.isFontsLoaded.bind(this))}bindCreateImage(t,e){return"boolean"==typeof e?(n,r)=>t(n,"boolean"==typeof r?r:e):t}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){var{emSizeStack:t}=this;return t[t.length-1]}set emSize(t){var{emSizeStack:e}=this;e.push(t)}popEmSize(){var{emSizeStack:t}=this;t.pop()}getUniqueId(){return"canvg".concat(++this.uniqueId)}isImagesLoaded(){return this.images.every(t=>t.loaded)}isFontsLoaded(){return this.fonts.every(t=>t.loaded)}createDocumentElement(t){var e=this.createElement(t.documentElement);return e.root=!0,e.addStylesFromStyleDefinition(),this.documentElement=e,e}createElement(t){var e=t.nodeName.replace(/^[^:]+:/,""),n=r3.elementTypes[e];return void 0!==n?new n(this,t):new q5(this,t)}createTextNode(t){return new s4(this,t)}setViewBox(t){this.screen.setViewBox(function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?e3(Object(n),!0).forEach(function(e){T0(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e3(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}({document:this},t))}}function i3(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function A3(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i3(Object(n),!0).forEach(function(e){T0(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i3(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}r3.createCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},r3.createImage=function(t){return n3.apply(this,arguments)},r3.elementTypes=t3;class s3{constructor(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.parser=new T5(n),this.screen=new O5(t,n),this.options=n;var r=new r3(this,n),i=r.createDocumentElement(e);this.document=r,this.documentElement=i}static from(t,e){var n=arguments;return lY(function*(){var r=n.length>2&&void 0!==n[2]?n[2]:{},i=new T5(r),A=yield i.parse(e);return new s3(t,A,r)})()}static fromString(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=new T5(n).parseFromString(e);return new s3(t,r,n)}fork(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s3.from(t,e,A3(A3({},this.options),n))}forkString(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s3.fromString(t,e,A3(A3({},this.options),n))}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}render(){var t=arguments,e=this;return lY(function*(){var n=t.length>0&&void 0!==t[0]?t[0]:{};e.start(A3({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0},n)),yield e.ready(),e.stop()})()}start(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{documentElement:e,screen:n,options:r}=this;n.start(e,A3(A3({enableRedraw:!0},r),t))}stop(){this.screen.stop()}resize(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,n)}}const a3=Object.freeze(Object.defineProperty({__proto__:null,AElement:L4,AnimateColorElement:_4,AnimateElement:B4,AnimateTransformElement:C4,BoundingBox:Z5,CB1:B5,CB2:_5,CB3:C5,CB4:x5,Canvg:s3,CircleElement:l4,ClipPathElement:G4,DefsElement:g4,DescElement:Z4,Document:r3,Element:z5,EllipseElement:c4,FeColorMatrixElement:W4,FeCompositeElement:Y4,FeDropShadowElement:q4,FeGaussianBlurElement:$4,FeMorphologyElement:X4,FilterElement:z4,Font:J5,FontElement:x4,FontFaceElement:E4,GElement:m4,GlyphElement:r4,GradientElement:w4,ImageElement:M4,LineElement:h4,LinearGradientElement:v4,MarkerElement:p4,MaskElement:V4,Matrix:j5,MissingGlyphElement:S4,Mouse:Q5,PSEUDO_ZERO:w5,Parser:T5,PathElement:n4,PathParser:t4,PatternElement:f4,Point:I5,PolygonElement:d4,PolylineElement:u4,Property:L5,QB1:E5,QB2:S5,QB3:F5,RadialGradientElement:y4,RectElement:o4,RenderedElement:e4,Rotate:R5,SVGElement:a4,SVGFontLoader:P4,Scale:H5,Screen:O5,Skew:W5,SkewX:V5,SkewY:K5,StopElement:b4,StyleElement:N4,SymbolElement:O4,TRefElement:F4,TSpanElement:A4,TextElement:i4,TextPathElement:Q4,TitleElement:J4,Transform:G5,Translate:D5,UnknownElement:q5,UseElement:T4,ViewPort:U5,compressSpaces:e5,default:s3,getSelectorSpecificity:m5,normalizeAttributeName:s5,normalizeColor:o5,parseExternalUrl:a5,presets:t5,toNumbers:i5,trimLeft:n5,trimRight:r5,vectorMagnitude:v5,vectorsAngle:b5,vectorsRatio:y5},Symbol.toStringTag,{value:"Module"}));t.DEFAULT_LAMINATION_COLORS=MT,t.LABEL_TYPES={PART:"part",SCRAP:"scrap",THICKENED:"thickened",INPUT:"input",VOLUME:"volume"},t.LabelWorker=xF,t.LabelsAPI=class{static getLabels(){return Wc(this,arguments,function*(t={}){try{return(yield RT.get("/v1/labels",{params:t})).data}catch(o3){throw new Error(`Erro ao buscar etiquetas: ${o3.message}`)}})}static getLabelsByPage(){return Wc(this,arguments,function*(t=1,e={}){return this.getLabels(Qc({p:t},e))})}static searchLabels(t){return Wc(this,arguments,function*(t,e={}){return this.getLabels(Qc({s:t},e))})}static getLabelsByType(t){return Wc(this,arguments,function*(t,e={}){return this.validateLabelType(t,!0),this.getLabels(Qc({label_type:t},e))})}static getLabel(t){return Wc(this,null,function*(){try{const e=yield RT.get("/v1/label",{params:{label_id:t}});return e.data&&e.data.labels&&e.data.labels.length&&e.data.labels.filter(e=>e.label_id==t)[0]||null}catch(o3){throw new Error(`Erro ao buscar etiqueta ${t}: ${o3.message}`)}})}static createLabel(t){return Wc(this,null,function*(){try{t.label_type&&this.validateLabelType(t.label_type,!0);return(yield RT.post("/v1/label",t)).data}catch(o3){throw new Error(`Erro ao criar etiqueta: ${o3.message}`)}})}static validateLabelType(t,e=!1){const n=Object.values(HT).includes(t);if(!n&&e)throw new Error(`Tipo de etiqueta inválido: "${t}" não é um de part, scrap, thickened, input e volume.`);return n}static labelByType(t){return this.validateLabelType(t,!0),t}static updateLabel(t,e){return Wc(this,null,function*(){try{e.label_type&&this.validateLabelType(e.label_type,!0);return(yield RT.post("/v1/label",Qc({label_id:t},e))).data}catch(o3){throw new Error(`Erro ao atualizar etiqueta ${t}: ${o3.message}`)}})}static deleteLabel(t){return Wc(this,null,function*(){try{return(yield RT.delete("/v1/label",{params:{label_id:t}})).data}catch(o3){throw new Error(`Erro ao deletar etiqueta ${t}: ${o3.message}`)}})}static setAuthToken(t){RT.defaults.headers.common.Authorization=`${t}`}static removeAuthToken(){delete RT.defaults.headers.common.Authorization}static setBaseURL(t){RT.defaults.baseURL=t}},t.apiClient=null,t.base64Decode=t=>{if(Gc){const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}return Buffer.from(t,"base64")},t.base64Encode=t=>Gc?t instanceof Uint8Array?btoa(String.fromCharCode(...t)):btoa(t):Buffer.from(t).toString("base64"),t.checkPrinterAvailability=ET,t.convertPdfToImages=xT,t.convertSVGTableToAutoTableData=function(t){return{headers:["ID","Nome","Qtd","Dimensões"],rows:t.map(t=>[t.id,t.name,t.quantity,t.dimensions])}},t.createBrowserCanvas=(t,e)=>{if(!Gc)throw new Error("createBrowserCanvas can only be used in browser environment");const n=document.createElement("canvas");return n.width=t,n.height=e,n},t.createBrowserDOM=Xc,t.createBuffer=t=>Gc?"string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t):Buffer.from(t),t.createImage=(t,e)=>Wc(this,null,function*(){try{const n=e.getContext("2d"),r=$c(t),i=QT(r),A="data:image/svg+xml;base64,"+i,s=yield qc(A);return n.drawImage(s,0,0),e.toDataURL()}catch(o3){throw console.error("Erro ao criar imagem:",o3),o3}}),t.createImageFromPart=(t,e)=>Wc(this,null,function*(){try{const n=e.getContext("2d"),r=$c(t),i=QT(r),A="data:image/svg+xml;base64,"+i,s=yield qc(A),{ratio:a}=PT(s,e),o={height:s.height*a-2,width:s.width*a-2};let l=e.width/2-o.width/2,c=e.height/2-o.height/2;return n.save(),n.translate(l,c),n.drawImage(s,0,0,o.width,o.height),n.restore(),e.toDataURL()}catch(o3){throw console.error("Erro ao criar imagem da parte:",o3),o3}}),t.createLabelWorker=EF,t.createMiniSheet=(t,e)=>new Promise((n,r)=>{const{parts:i,vHeight:A,vWidth:s}=t,a=qS(A),o=qS(s),l=(o-5)/275,c=IT.createElementNS("http://www.w3.org/2000/svg","svg");c.id="miniSheet-"+e,c.style.width=a,c.style.height=o,c.style.transform="scaleX(1)";const h=OT("rect",{x:0,y:0,width:o,height:a,stroke:"black",strokeWidth:"2px",fill:"white"});c.appendChild(h);const u=OT("rect",{x:3,y:3,width:t.height*l,height:t.width*l,stroke:"black",strokeWidth:"2px",strokeDasharray:"4 1",fill:"white"});c.appendChild(u);for(const t of i){const e=OT("rect",{y:t.y*l+3,x:t.x*l+3,height:t.width*l,width:t.height*l,stroke:"black",fill:"white",id:t.code});c.appendChild(e)}const d=IT.createElement("canvas");d.id="miniSheetCanvas-"+e,d.width=o,d.height=a;const f=IT.getElementById("label-container");f.appendChild(c),f.appendChild(d),n()}),t.dataTypeList=(t,e)=>{const n=[...e];switch(t){case"input":let t=[];return n.map((e,n)=>{t=t.concat(...e.data.woodwork.reduce((t,n,r)=>{const i=n.inputs.map((t,r)=>kc(Qc({},t),{project_id:e.data.project_id,project_description:e.data.project_description,project_customer_id:e.data.project_customer_id,project_customer_name:e.data.project_customer_name,project_note:e.data.project_note,mref:n.ref,mname:n.name,mnote:n.note}));return t=t.concat(i)},[]))}),$S(t,"category_id");case"part":let e=[],r=1;return n.map((t,n)=>t.data.woodwork.map((n,i)=>e=e.concat(...n.parts.reduce((e,A,s)=>(e=e.concat({id:A.id,pid:A.id,pref:A.ref,mref:n.ref,mname:n.name,mnote:n.note,index:r,number:r,key:i,name:A.name,material_name:A.material_name,material_id:A.material_id,material_width:A.material_width,material_height:A.material_height,note:A.note,width:A.height,height:A.width,thickness:A.thickness,type:A.type,edge_left:A.edge_left,edge_left_id:A.edge_left_id,edge_right:A.edge_right,edge_right_id:A.edge_right_id,edge_top:A.edge_top,edge_top_id:A.edge_top_id,edge_bottom:A.edge_bottom,edge_bottom_id:A.edge_bottom_id,code_a:`${A.code_a}`,code_b:`${A.code_b}`,project_id:t.data.project_id,project_description:t.data.project_description,project_customer_id:t.data.project_customer_id,project_customer_name:t.data.project_customer_name,project_note:t.data.project_note}),r++,e),[])))),e;case"volume":return n.map(t=>{var e,n,r,i,A,s;return{project_id:null==(e=null==t?void 0:t.volume)?void 0:e.project_id,project_description:null==(n=null==t?void 0:t.volume)?void 0:n.project_name,project_customer_id:"",project_customer_name:null==(r=null==t?void 0:t.volume)?void 0:r.customer,project_note:"",itemList:[...t.inputs||[],...(t.parts||[]).map(t=>kc(Qc({},t),{name:`${t.name} ${t.thickness}mm`,dimensions:`${t.width} x ${t.height} mm`}))],volume_name:null==(i=null==t?void 0:t.volume)?void 0:i.description,volume_id:null==(A=null==t?void 0:t.volume)?void 0:A.id,volume_date:(null==(s=null==t?void 0:t.volume)?void 0:s.created_at)?new Date(t.volume.created_at).toLocaleDateString("pt-BR"):"",volume_weight:"0kg"}});case"thickened":let i=1;return n.flatMap(t=>t.data.woodwork.reduce((e,n)=>("thickened"===n.type&&(e.push(kc(Qc({},YS(n,["inputs","parts"])),{index:i,mref:n.ref,mnote:n.note,ref:null,project_id:t.data.project_id,project_description:t.data.project_description,project_customer_id:t.data.project_customer_id,project_customer_name:t.data.project_customer_name,project_note:t.data.project_note,rotated:!0})),i++),e),[]));default:return[]}},t.default=hD,t.downloadFile=Yc,t.downloadPDF=sD,t.downloadPdfFallback=FT,t.drawRect=NT,t.etiquetas=cD,t.generateLabelsFromHookData=(t,...e)=>Wc(this,[t,...e],function*(t,e={},n=null){const r=EF();console.log("labelData =>>>>>",t);const i=Qc({dataSource:t.data||[],labels:t.label||[],userPrefs:t.userPrefs||{},cacheKey:t.cacheKey},e);return yield r.generateLabels(i,n)}),t.generateTableSVG=function(t,e={}){if(!t||!Array.isArray(t))return"";const{width:n=200,height:r=100,cellPadding:i=5,fontSize:A=12,headerColor:s="#f0f0f0",borderColor:a="#000000"}=e,o=["ID","Nome","Qtd","Dimensões"],l=n/o.length;let c=`<svg width="${n}" height="${r}" xmlns="http://www.w3.org/2000/svg">`;return c+=`<rect x="0" y="0" width="${n}" height="20" fill="${s}" stroke="${a}" stroke-width="1"/>`,o.forEach((t,e)=>{c+=`<text x="${e*l+i}" y="${10+A/3}" font-size="${A}" font-weight="bold" fill="black">${t}</text>`}),t.forEach((t,e)=>{const r=20*(e+1);c+=`<rect x="0" y="${r}" width="${n}" height="20" fill="white" stroke="${a}" stroke-width="1"/>`;[t.id,t.name,t.quantity,t.dimensions].forEach((t,e)=>{c+=`<text x="${e*l+i}" y="${r+10+A/3}" font-size="${A}" fill="black">${t||""}</text>`})}),c+="</svg>",c},t.getAspectRatio=PT,t.getBorderColor=DT,t.getImagesFromUrl=t=>Wc(this,null,function*(){try{if(!t||"string"!=typeof t)throw new Error("Invalid URL provided");return t}catch(o3){return console.error("Error loading image from URL:",o3),null}}),t.getImagesFromUrlToBase64=XS,t.getInputForLabels=(t,e,n)=>kc(Qc({},t),{project_id:e.data.project_id,project_description:e.data.project_description,project_customer_id:e.data.project_customer_id,project_customer_name:e.data.project_customer_name,project_note:e.data.project_note,mref:n.ref,mname:n.name,mnote:n.note}),t.getInputLabels=null,t.getInputsByCategory=(t,e=[])=>0===e.length?Object.values(t).reduce((t,e)=>t=t.concat(e),[]):e.reduce((e,n)=>(t[n]&&(e=e.concat(t[n])),e),[]),t.getNode=OT,t.getPartLabels=null,t.getPartsForLabels=(t,e,n,r,i)=>({i:e.i,id:e.id,pid:e.pid||null,moduleLength:e.moduleLength,pref:e.pref,mref:e.mref,mtype:null==e?void 0:e.mType,mnote:e.mnote,mname:e.mname,index:e.index,number:e.number,key:i,sheetMaterial:n.material,sheetIndex:r,name:e.name,note:e.note,width:e.width,height:e.height,type:e.type,edge_left:e.edges.left,edge_left_id:e.edges.left_id,edge_right:e.edges.right,edge_right_id:e.edges.right_id,edge_top:e.edges.top,edge_top_id:e.edges.top_id,edge_bottom:e.edges.bottom,edge_bottom_id:e.edges.bottom_id,code_a:`${e.code_a}`,code_a2:`${e.code_a2}`,code_b:`${e.code_b}`,code_b2:`${e.code_b2}`,group_id:null==e?void 0:e.group,project_id:e.project_id,project_description:e.project_description,project_customer_id:e.project_customer_id,project_customer_name:e.project_customer_name,project_note:e.project_note,rotated:e.rotated,holes:e.holes_diagram,material_name:t.name,material_id:t.material,material_width:t.width,material_height:t.height,thickness:t.thickness,labelKey:`${t.material}-${t.thickness}`,machining_side:e.machining_side}),t.getPartsFromProjectToLabels=({projectPartsByCode:t,partsByCode:e,templatePartsByURef:n})=>Object.entries(Qc({},t)).flatMap(([t,r])=>r.map((r,i)=>{var A;const s=Qc(Qc({},e[r]),null==n?void 0:n[t]);return kc(Qc({},s),{edge_left:s.edge_left,edge_right:s.edge_right,edge_bottom:s.edge_bottom,edge_top:s.edge_top,width:s.width/10,height:s.height/10,moduleIndex:i+1,holes_diagram:null==(A=e[r])?void 0:A.holes})})),t.getPrinterStatus=YT,t.getScrapLabels=null,t.getThickenedLabels=null,t.getVolumeLabels=null,t.init=XT,t.initialState=RL,t.initializeBrowserEnvironment=kT,t.isBrowser=Gc,t.isNodeJS=zc,t.labelTypeNames={parts:"Peças",woodwork:"Tamponamentos",inputs:"Insumos",scraps:"Retalhos",volumes:"Volumes"},t.loadImageBrowser=qc,t.makeLabel=ZT,t.makeLamination=t=>{const{pdf:e,actualData:n,v:r,vl:i}=t;let A,s;i.lamination&&i.lamination.edges?(A={edge_left_id:i.lamination.edges.left_id,edge_right_id:i.lamination.edges.right_id,edge_bottom_id:i.lamination.edges.bottom_id,edge_top_id:i.lamination.edges.top_id},s=i.lamination.material_id):(A={edge_left_id:i.edge_left_id,edge_right_id:i.edge_right_id,edge_bottom_id:i.edge_bottom_id,edge_top_id:i.edge_top_id},s=i.material_id);const a={left:DT(A.edge_left_id,s),right:DT(A.edge_right_id,s),bottom:DT(A.edge_bottom_id,s),top:DT(A.edge_top_id,s)};return NT(e,5,5,r.width-10,r.height-10,a.left,a.right,a.bottom,a.top),r.showEdges&&(e.text(`${n.edge_left}`,2,r.height/2),e.text(`${n.edge_right}`,r.width-10,r.height/2),e.text(`${n.edge_bottom}`,r.width/2,r.height-2),e.text(`${n.edge_top}`,r.width/2,10)),e.output("datauristring")},t.mmToPx=qS,t.processLabelForParts=(...t)=>Wc(this,[...t],function*(t=[],e,n){try{console.log(`🏷️ Processando etiquetas para ${t.length} peças...`);const r=e(t);if(!r)throw new Error("Não foi possível obter dados de etiquetas");const[i,A,s]=yield n(r),a=yield fetch(i),o=yield a.arrayBuffer(),l=yield LT(o,{filename:`etiquetas-pecas-${Date.now()}.pdf`,metadata:{partCodes:t,labelData:r}});return kc(Qc({},l),{labelData:r,partCodes:t})}catch(o3){return console.error("❌ Erro ao processar etiquetas para peças:",o3),{success:!1,error:o3.message,partCodes:t}}}),t.reducer=function(t,e){switch(e.type){case"CHANGE_INDEX":return kc(Qc({},t),{index:e.payload.index});case"CHANGE_TYPE":return kc(Qc({},t),{type:e.payload.type,specific:!1,source:null,category:[],index:0});case"CHANGE_TO_SPECIFIC":return kc(Qc({},t),{type:e.payload.type,dataIndex:e.payload.source?null:e.payload.dataIndex,index:0,source:e.payload.source?e.payload.source:null,category:e.payload.category?e.payload.category:[],otherData:e.payload.otherData?e.payload.otherData:null,specific:!0});case"RESET":return RL;default:return t}},t.sendImagesToPrinter=ST,t.sendLabel=tD,t.sendToPrinter=aD,t.serializeXML=$c,t.setBorder=TT,t.stopCreatingLabels=!1,t.useLabelData=(t={})=>{const e=Qc(Qc({},{type:"parts",category:[],specific:!1,dataIndex:null,otherData:null,source:null}),t);return{isReady:!0,isGenerating:!1,progress:0,error:null,data:[],label:[],userPrefs:{},cacheKey:`label-${Date.now()}`,generateLabels:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={},r={}){const i=EF(),A=Qc({dataSource:t||[],labels:e||[],userPrefs:n,cacheKey:`label-${Date.now()}`},r);return yield i.generateLabels(A)}),downloadPDF:(t,e="etiqueta.pdf")=>{if("undefined"==typeof window)return t;const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},checkPrinterAvailability:()=>Wc(this,null,function*(){try{return!1}catch(o3){return console.warn("Não foi possível verificar impressoras:",o3),!1}}),getLabelData:(t="parts")=>({data:[],label:[],userPrefs:{},cacheKey:`${t}-${Date.now()}`}),config:e}},t.useLabelStore=DL,t.validateLabelData=lD,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
357
|
+
var w2=function(t,e){return(w2=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function v2(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}w2(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function y2(t,e){var n=t[0],r=t[1];return[n*Math.cos(e)-r*Math.sin(e),n*Math.sin(e)+r*Math.cos(e)]}function b2(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0;n<t.length;n++)if("number"!=typeof t[n])throw new Error("assertNumbers arguments["+n+"] is not a number. "+typeof t[n]+" == typeof "+t[n]);return!0}var B2=Math.PI;function _2(t,e,n){t.lArcFlag=0===t.lArcFlag?0:1,t.sweepFlag=0===t.sweepFlag?0:1;var r=t.rX,i=t.rY,A=t.x,s=t.y;r=Math.abs(t.rX),i=Math.abs(t.rY);var a=y2([(e-A)/2,(n-s)/2],-t.xRot/180*B2),o=a[0],l=a[1],c=Math.pow(o,2)/Math.pow(r,2)+Math.pow(l,2)/Math.pow(i,2);1<c&&(r*=Math.sqrt(c),i*=Math.sqrt(c)),t.rX=r,t.rY=i;var h=Math.pow(r,2)*Math.pow(l,2)+Math.pow(i,2)*Math.pow(o,2),u=(t.lArcFlag!==t.sweepFlag?1:-1)*Math.sqrt(Math.max(0,(Math.pow(r,2)*Math.pow(i,2)-h)/h)),d=r*l/i*u,f=-i*o/r*u,p=y2([d,f],t.xRot/180*B2);t.cX=p[0]+(e+A)/2,t.cY=p[1]+(n+s)/2,t.phi1=Math.atan2((l-f)/i,(o-d)/r),t.phi2=Math.atan2((-l-f)/i,(-o-d)/r),0===t.sweepFlag&&t.phi2>t.phi1&&(t.phi2-=2*B2),1===t.sweepFlag&&t.phi2<t.phi1&&(t.phi2+=2*B2),t.phi1*=180/B2,t.phi2*=180/B2}function C2(t,e,n){b2(t,e,n);var r=t*t+e*e-n*n;if(0>r)return[];if(0===r)return[[t*n/(t*t+e*e),e*n/(t*t+e*e)]];var i=Math.sqrt(r);return[[(t*n+e*i)/(t*t+e*e),(e*n-t*i)/(t*t+e*e)],[(t*n-e*i)/(t*t+e*e),(e*n+t*i)/(t*t+e*e)]]}var x2,E2=Math.PI/180;function S2(t,e,n){return(1-n)*t+n*e}function F2(t,e,n,r){return t+Math.cos(r/180*B2)*e+Math.sin(r/180*B2)*n}function L2(t,e,n,r){var i=1e-6,A=e-t,s=n-e,a=3*A+3*(r-n)-6*s,o=6*(s-A),l=3*A;return Math.abs(a)<i?[-l/o]:function(t,e,n){var r=t*t/4-e;if(r<-n)return[];if(r<=n)return[-t/2];var i=Math.sqrt(r);return[-t/2-i,-t/2+i]}(o/a,l/a,i)}function U2(t,e,n,r,i){var A=1-i;return t*(A*A*A)+e*(3*A*A*i)+n*(3*A*i*i)+r*(i*i*i)}!function(t){function e(){return i(function(t,e,n){return t.relative&&(void 0!==t.x1&&(t.x1+=e),void 0!==t.y1&&(t.y1+=n),void 0!==t.x2&&(t.x2+=e),void 0!==t.y2&&(t.y2+=n),void 0!==t.x&&(t.x+=e),void 0!==t.y&&(t.y+=n),t.relative=!1),t})}function n(){var t=NaN,e=NaN,n=NaN,r=NaN;return i(function(i,A,s){return i.type&P2.SMOOTH_CURVE_TO&&(i.type=P2.CURVE_TO,t=isNaN(t)?A:t,e=isNaN(e)?s:e,i.x1=i.relative?A-t:2*A-t,i.y1=i.relative?s-e:2*s-e),i.type&P2.CURVE_TO?(t=i.relative?A+i.x2:i.x2,e=i.relative?s+i.y2:i.y2):(t=NaN,e=NaN),i.type&P2.SMOOTH_QUAD_TO&&(i.type=P2.QUAD_TO,n=isNaN(n)?A:n,r=isNaN(r)?s:r,i.x1=i.relative?A-n:2*A-n,i.y1=i.relative?s-r:2*s-r),i.type&P2.QUAD_TO?(n=i.relative?A+i.x1:i.x1,r=i.relative?s+i.y1:i.y1):(n=NaN,r=NaN),i})}function r(){var t=NaN,e=NaN;return i(function(n,r,i){if(n.type&P2.SMOOTH_QUAD_TO&&(n.type=P2.QUAD_TO,t=isNaN(t)?r:t,e=isNaN(e)?i:e,n.x1=n.relative?r-t:2*r-t,n.y1=n.relative?i-e:2*i-e),n.type&P2.QUAD_TO){t=n.relative?r+n.x1:n.x1,e=n.relative?i+n.y1:n.y1;var A=n.x1,s=n.y1;n.type=P2.CURVE_TO,n.x1=((n.relative?0:r)+2*A)/3,n.y1=((n.relative?0:i)+2*s)/3,n.x2=(n.x+2*A)/3,n.y2=(n.y+2*s)/3}else t=NaN,e=NaN;return n})}function i(t){var e=0,n=0,r=NaN,i=NaN;return function(A){if(isNaN(r)&&!(A.type&P2.MOVE_TO))throw new Error("path must start with moveto");var s=t(A,e,n,r,i);return A.type&P2.CLOSE_PATH&&(e=r,n=i),void 0!==A.x&&(e=A.relative?e+A.x:A.x),void 0!==A.y&&(n=A.relative?n+A.y:A.y),A.type&P2.MOVE_TO&&(r=e,i=n),s}}function A(t,e,n,r,A,s){return b2(t,e,n,r,A,s),i(function(i,a,o,l){var c=i.x1,h=i.x2,u=i.relative&&!isNaN(l),d=void 0!==i.x?i.x:u?0:a,f=void 0!==i.y?i.y:u?0:o;function p(t){return t*t}i.type&P2.HORIZ_LINE_TO&&0!==e&&(i.type=P2.LINE_TO,i.y=i.relative?0:o),i.type&P2.VERT_LINE_TO&&0!==n&&(i.type=P2.LINE_TO,i.x=i.relative?0:a),void 0!==i.x&&(i.x=i.x*t+f*n+(u?0:A)),void 0!==i.y&&(i.y=d*e+i.y*r+(u?0:s)),void 0!==i.x1&&(i.x1=i.x1*t+i.y1*n+(u?0:A)),void 0!==i.y1&&(i.y1=c*e+i.y1*r+(u?0:s)),void 0!==i.x2&&(i.x2=i.x2*t+i.y2*n+(u?0:A)),void 0!==i.y2&&(i.y2=h*e+i.y2*r+(u?0:s));var g=t*r-e*n;if(void 0!==i.xRot&&(1!==t||0!==e||0!==n||1!==r))if(0===g)delete i.rX,delete i.rY,delete i.xRot,delete i.lArcFlag,delete i.sweepFlag,i.type=P2.LINE_TO;else{var m=i.xRot*Math.PI/180,w=Math.sin(m),v=Math.cos(m),y=1/p(i.rX),b=1/p(i.rY),B=p(v)*y+p(w)*b,_=2*w*v*(y-b),C=p(w)*y+p(v)*b,x=B*r*r-_*e*r+C*e*e,E=_*(t*r+e*n)-2*(B*n*r+C*t*e),S=B*n*n-_*t*n+C*t*t,F=(Math.atan2(E,x-S)+Math.PI)%Math.PI/2,L=Math.sin(F),U=Math.cos(F);i.rX=Math.abs(g)/Math.sqrt(x*p(U)+E*L*U+S*p(L)),i.rY=Math.abs(g)/Math.sqrt(x*p(L)-E*L*U+S*p(U)),i.xRot=180*F/Math.PI}return void 0!==i.sweepFlag&&0>g&&(i.sweepFlag=+!i.sweepFlag),i})}t.ROUND=function(t){function e(e){return Math.round(e*t)/t}return void 0===t&&(t=1e13),b2(t),function(t){return void 0!==t.x1&&(t.x1=e(t.x1)),void 0!==t.y1&&(t.y1=e(t.y1)),void 0!==t.x2&&(t.x2=e(t.x2)),void 0!==t.y2&&(t.y2=e(t.y2)),void 0!==t.x&&(t.x=e(t.x)),void 0!==t.y&&(t.y=e(t.y)),void 0!==t.rX&&(t.rX=e(t.rX)),void 0!==t.rY&&(t.rY=e(t.rY)),t}},t.TO_ABS=e,t.TO_REL=function(){return i(function(t,e,n){return t.relative||(void 0!==t.x1&&(t.x1-=e),void 0!==t.y1&&(t.y1-=n),void 0!==t.x2&&(t.x2-=e),void 0!==t.y2&&(t.y2-=n),void 0!==t.x&&(t.x-=e),void 0!==t.y&&(t.y-=n),t.relative=!0),t})},t.NORMALIZE_HVZ=function(t,e,n){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===n&&(n=!0),i(function(r,i,A,s,a){if(isNaN(s)&&!(r.type&P2.MOVE_TO))throw new Error("path must start with moveto");return e&&r.type&P2.HORIZ_LINE_TO&&(r.type=P2.LINE_TO,r.y=r.relative?0:A),n&&r.type&P2.VERT_LINE_TO&&(r.type=P2.LINE_TO,r.x=r.relative?0:i),t&&r.type&P2.CLOSE_PATH&&(r.type=P2.LINE_TO,r.x=r.relative?s-i:s,r.y=r.relative?a-A:a),r.type&P2.ARC&&(0===r.rX||0===r.rY)&&(r.type=P2.LINE_TO,delete r.rX,delete r.rY,delete r.xRot,delete r.lArcFlag,delete r.sweepFlag),r})},t.NORMALIZE_ST=n,t.QT_TO_C=r,t.INFO=i,t.SANITIZE=function(t){void 0===t&&(t=0),b2(t);var e=NaN,n=NaN,r=NaN,A=NaN;return i(function(i,s,a,o,l){var c=Math.abs,h=!1,u=0,d=0;if(i.type&P2.SMOOTH_CURVE_TO&&(u=isNaN(e)?0:s-e,d=isNaN(n)?0:a-n),i.type&(P2.CURVE_TO|P2.SMOOTH_CURVE_TO)?(e=i.relative?s+i.x2:i.x2,n=i.relative?a+i.y2:i.y2):(e=NaN,n=NaN),i.type&P2.SMOOTH_QUAD_TO?(r=isNaN(r)?s:2*s-r,A=isNaN(A)?a:2*a-A):i.type&P2.QUAD_TO?(r=i.relative?s+i.x1:i.x1,A=i.relative?a+i.y1:i.y2):(r=NaN,A=NaN),i.type&P2.LINE_COMMANDS||i.type&P2.ARC&&(0===i.rX||0===i.rY||!i.lArcFlag)||i.type&P2.CURVE_TO||i.type&P2.SMOOTH_CURVE_TO||i.type&P2.QUAD_TO||i.type&P2.SMOOTH_QUAD_TO){var f=void 0===i.x?0:i.relative?i.x:i.x-s,p=void 0===i.y?0:i.relative?i.y:i.y-a;u=isNaN(r)?void 0===i.x1?u:i.relative?i.x:i.x1-s:r-s,d=isNaN(A)?void 0===i.y1?d:i.relative?i.y:i.y1-a:A-a;var g=void 0===i.x2?0:i.relative?i.x:i.x2-s,m=void 0===i.y2?0:i.relative?i.y:i.y2-a;c(f)<=t&&c(p)<=t&&c(u)<=t&&c(d)<=t&&c(g)<=t&&c(m)<=t&&(h=!0)}return i.type&P2.CLOSE_PATH&&c(s-o)<=t&&c(a-l)<=t&&(h=!0),h?[]:i})},t.MATRIX=A,t.ROTATE=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=0),b2(t,e,n);var r=Math.sin(t),i=Math.cos(t);return A(i,r,-r,i,e-e*i+n*r,n-e*r-n*i)},t.TRANSLATE=function(t,e){return void 0===e&&(e=0),b2(t,e),A(1,0,0,1,t,e)},t.SCALE=function(t,e){return void 0===e&&(e=t),b2(t,e),A(t,0,0,e,0,0)},t.SKEW_X=function(t){return b2(t),A(1,0,Math.atan(t),1,0,0)},t.SKEW_Y=function(t){return b2(t),A(1,Math.atan(t),0,1,0,0)},t.X_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),b2(t),A(-1,0,0,1,t,0)},t.Y_AXIS_SYMMETRY=function(t){return void 0===t&&(t=0),b2(t),A(1,0,0,-1,0,t)},t.A_TO_C=function(){return i(function(t,e,n){return P2.ARC===t.type?function(t,e,n){var r,i,A,s;t.cX||_2(t,e,n);for(var a=Math.min(t.phi1,t.phi2),o=Math.max(t.phi1,t.phi2)-a,l=Math.ceil(o/90),c=new Array(l),h=e,u=n,d=0;d<l;d++){var f=S2(t.phi1,t.phi2,d/l),p=S2(t.phi1,t.phi2,(d+1)/l),g=p-f,m=4/3*Math.tan(g*E2/4),w=[Math.cos(f*E2)-m*Math.sin(f*E2),Math.sin(f*E2)+m*Math.cos(f*E2)],v=w[0],y=w[1],b=[Math.cos(p*E2),Math.sin(p*E2)],B=b[0],_=b[1],C=[B+m*Math.sin(p*E2),_-m*Math.cos(p*E2)],x=C[0],E=C[1];c[d]={relative:t.relative,type:P2.CURVE_TO};var S=function(e,n){var r=y2([e*t.rX,n*t.rY],t.xRot),i=r[0],A=r[1];return[t.cX+i,t.cY+A]};r=S(v,y),c[d].x1=r[0],c[d].y1=r[1],i=S(x,E),c[d].x2=i[0],c[d].y2=i[1],A=S(B,_),c[d].x=A[0],c[d].y=A[1],t.relative&&(c[d].x1-=h,c[d].y1-=u,c[d].x2-=h,c[d].y2-=u,c[d].x-=h,c[d].y-=u),h=(s=[c[d].x,c[d].y])[0],u=s[1]}return c}(t,t.relative?0:e,t.relative?0:n):t})},t.ANNOTATE_ARCS=function(){return i(function(t,e,n){return t.relative&&(e=0,n=0),P2.ARC===t.type&&_2(t,e,n),t})},t.CLONE=function(){return function(t){var e={};for(var n in t)e[n]=t[n];return e}},t.CALCULATE_BOUNDS=function(){var t=e(),A=r(),s=n(),a=i(function(e,n,r){var i=s(A(t(function(t){var e={};for(var n in t)e[n]=t[n];return e}(e))));function o(t){t>a.maxX&&(a.maxX=t),t<a.minX&&(a.minX=t)}function l(t){t>a.maxY&&(a.maxY=t),t<a.minY&&(a.minY=t)}if(i.type&P2.DRAWING_COMMANDS&&(o(n),l(r)),i.type&P2.HORIZ_LINE_TO&&o(i.x),i.type&P2.VERT_LINE_TO&&l(i.y),i.type&P2.LINE_TO&&(o(i.x),l(i.y)),i.type&P2.CURVE_TO){o(i.x),l(i.y);for(var c=0,h=L2(n,i.x1,i.x2,i.x);c<h.length;c++)0<(S=h[c])&&1>S&&o(U2(n,i.x1,i.x2,i.x,S));for(var u=0,d=L2(r,i.y1,i.y2,i.y);u<d.length;u++)0<(S=d[u])&&1>S&&l(U2(r,i.y1,i.y2,i.y,S))}if(i.type&P2.ARC){o(i.x),l(i.y),_2(i,n,r);for(var f=i.xRot/180*Math.PI,p=Math.cos(f)*i.rX,g=Math.sin(f)*i.rX,m=-Math.sin(f)*i.rY,w=Math.cos(f)*i.rY,v=i.phi1<i.phi2?[i.phi1,i.phi2]:-180>i.phi2?[i.phi2+360,i.phi1+360]:[i.phi2,i.phi1],y=v[0],b=v[1],B=function(t){var e=t[0],n=t[1],r=180*Math.atan2(n,e)/Math.PI;return r<y?r+360:r},_=0,C=C2(m,-p,0).map(B);_<C.length;_++)(S=C[_])>y&&S<b&&o(F2(i.cX,p,m,S));for(var x=0,E=C2(w,-g,0).map(B);x<E.length;x++){var S;(S=E[x])>y&&S<b&&l(F2(i.cY,g,w,S))}}return e});return a.minX=1/0,a.maxX=-1/0,a.minY=1/0,a.maxY=-1/0,a}}(x2||(x2={}));var I2,Q2=function(){function t(){}return t.prototype.round=function(t){return this.transform(x2.ROUND(t))},t.prototype.toAbs=function(){return this.transform(x2.TO_ABS())},t.prototype.toRel=function(){return this.transform(x2.TO_REL())},t.prototype.normalizeHVZ=function(t,e,n){return this.transform(x2.NORMALIZE_HVZ(t,e,n))},t.prototype.normalizeST=function(){return this.transform(x2.NORMALIZE_ST())},t.prototype.qtToC=function(){return this.transform(x2.QT_TO_C())},t.prototype.aToC=function(){return this.transform(x2.A_TO_C())},t.prototype.sanitize=function(t){return this.transform(x2.SANITIZE(t))},t.prototype.translate=function(t,e){return this.transform(x2.TRANSLATE(t,e))},t.prototype.scale=function(t,e){return this.transform(x2.SCALE(t,e))},t.prototype.rotate=function(t,e,n){return this.transform(x2.ROTATE(t,e,n))},t.prototype.matrix=function(t,e,n,r,i,A){return this.transform(x2.MATRIX(t,e,n,r,i,A))},t.prototype.skewX=function(t){return this.transform(x2.SKEW_X(t))},t.prototype.skewY=function(t){return this.transform(x2.SKEW_Y(t))},t.prototype.xSymmetry=function(t){return this.transform(x2.X_AXIS_SYMMETRY(t))},t.prototype.ySymmetry=function(t){return this.transform(x2.Y_AXIS_SYMMETRY(t))},t.prototype.annotateArcs=function(){return this.transform(x2.ANNOTATE_ARCS())},t}(),k2=function(t){return" "===t||"\t"===t||"\r"===t||"\n"===t},M2=function(t){return"0".charCodeAt(0)<=t.charCodeAt(0)&&t.charCodeAt(0)<="9".charCodeAt(0)},O2=function(t){function e(){var e=t.call(this)||this;return e.curNumber="",e.curCommandType=-1,e.curCommandRelative=!1,e.canParseCommandOrComma=!0,e.curNumberHasExp=!1,e.curNumberHasExpDigits=!1,e.curNumberHasDecimal=!1,e.curArgs=[],e}return v2(e,t),e.prototype.finish=function(t){if(void 0===t&&(t=[]),this.parse(" ",t),0!==this.curArgs.length||!this.canParseCommandOrComma)throw new SyntaxError("Unterminated command at the path end.");return t},e.prototype.parse=function(t,e){var n=this;void 0===e&&(e=[]);for(var r=function(t){e.push(t),n.curArgs.length=0,n.canParseCommandOrComma=!0},i=0;i<t.length;i++){var A=t[i],s=!(this.curCommandType!==P2.ARC||3!==this.curArgs.length&&4!==this.curArgs.length||1!==this.curNumber.length||"0"!==this.curNumber&&"1"!==this.curNumber),a=M2(A)&&("0"===this.curNumber&&"0"===A||s);if(!M2(A)||a)if("e"!==A&&"E"!==A)if("-"!==A&&"+"!==A||!this.curNumberHasExp||this.curNumberHasExpDigits)if("."!==A||this.curNumberHasExp||this.curNumberHasDecimal||s){if(this.curNumber&&-1!==this.curCommandType){var o=Number(this.curNumber);if(isNaN(o))throw new SyntaxError("Invalid number ending at "+i);if(this.curCommandType===P2.ARC)if(0===this.curArgs.length||1===this.curArgs.length){if(0>o)throw new SyntaxError('Expected positive number, got "'+o+'" at index "'+i+'"')}else if((3===this.curArgs.length||4===this.curArgs.length)&&"0"!==this.curNumber&&"1"!==this.curNumber)throw new SyntaxError('Expected a flag, got "'+this.curNumber+'" at index "'+i+'"');this.curArgs.push(o),this.curArgs.length===N2[this.curCommandType]&&(P2.HORIZ_LINE_TO===this.curCommandType?r({type:P2.HORIZ_LINE_TO,relative:this.curCommandRelative,x:o}):P2.VERT_LINE_TO===this.curCommandType?r({type:P2.VERT_LINE_TO,relative:this.curCommandRelative,y:o}):this.curCommandType===P2.MOVE_TO||this.curCommandType===P2.LINE_TO||this.curCommandType===P2.SMOOTH_QUAD_TO?(r({type:this.curCommandType,relative:this.curCommandRelative,x:this.curArgs[0],y:this.curArgs[1]}),P2.MOVE_TO===this.curCommandType&&(this.curCommandType=P2.LINE_TO)):this.curCommandType===P2.CURVE_TO?r({type:P2.CURVE_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x2:this.curArgs[2],y2:this.curArgs[3],x:this.curArgs[4],y:this.curArgs[5]}):this.curCommandType===P2.SMOOTH_CURVE_TO?r({type:P2.SMOOTH_CURVE_TO,relative:this.curCommandRelative,x2:this.curArgs[0],y2:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===P2.QUAD_TO?r({type:P2.QUAD_TO,relative:this.curCommandRelative,x1:this.curArgs[0],y1:this.curArgs[1],x:this.curArgs[2],y:this.curArgs[3]}):this.curCommandType===P2.ARC&&r({type:P2.ARC,relative:this.curCommandRelative,rX:this.curArgs[0],rY:this.curArgs[1],xRot:this.curArgs[2],lArcFlag:this.curArgs[3],sweepFlag:this.curArgs[4],x:this.curArgs[5],y:this.curArgs[6]})),this.curNumber="",this.curNumberHasExpDigits=!1,this.curNumberHasExp=!1,this.curNumberHasDecimal=!1,this.canParseCommandOrComma=!0}if(!k2(A))if(","===A&&this.canParseCommandOrComma)this.canParseCommandOrComma=!1;else if("+"!==A&&"-"!==A&&"."!==A)if(a)this.curNumber=A,this.curNumberHasDecimal=!1;else{if(0!==this.curArgs.length)throw new SyntaxError("Unterminated command at index "+i+".");if(!this.canParseCommandOrComma)throw new SyntaxError('Unexpected character "'+A+'" at index '+i+". Command cannot follow comma");if(this.canParseCommandOrComma=!1,"z"!==A&&"Z"!==A)if("h"===A||"H"===A)this.curCommandType=P2.HORIZ_LINE_TO,this.curCommandRelative="h"===A;else if("v"===A||"V"===A)this.curCommandType=P2.VERT_LINE_TO,this.curCommandRelative="v"===A;else if("m"===A||"M"===A)this.curCommandType=P2.MOVE_TO,this.curCommandRelative="m"===A;else if("l"===A||"L"===A)this.curCommandType=P2.LINE_TO,this.curCommandRelative="l"===A;else if("c"===A||"C"===A)this.curCommandType=P2.CURVE_TO,this.curCommandRelative="c"===A;else if("s"===A||"S"===A)this.curCommandType=P2.SMOOTH_CURVE_TO,this.curCommandRelative="s"===A;else if("q"===A||"Q"===A)this.curCommandType=P2.QUAD_TO,this.curCommandRelative="q"===A;else if("t"===A||"T"===A)this.curCommandType=P2.SMOOTH_QUAD_TO,this.curCommandRelative="t"===A;else{if("a"!==A&&"A"!==A)throw new SyntaxError('Unexpected character "'+A+'" at index '+i+".");this.curCommandType=P2.ARC,this.curCommandRelative="a"===A}else e.push({type:P2.CLOSE_PATH}),this.canParseCommandOrComma=!0,this.curCommandType=-1}else this.curNumber=A,this.curNumberHasDecimal="."===A}else this.curNumber+=A,this.curNumberHasDecimal=!0;else this.curNumber+=A;else this.curNumber+=A,this.curNumberHasExp=!0;else this.curNumber+=A,this.curNumberHasExpDigits=this.curNumberHasExp}return e},e.prototype.transform=function(t){return Object.create(this,{parse:{value:function(e,n){void 0===n&&(n=[]);for(var r=0,i=Object.getPrototypeOf(this).parse.call(this,e);r<i.length;r++){var A=i[r],s=t(A);Array.isArray(s)?n.push.apply(n,s):n.push(s)}return n}}})},e}(Q2),P2=function(t){function e(n){var r=t.call(this)||this;return r.commands="string"==typeof n?e.parse(n):n,r}return v2(e,t),e.prototype.encode=function(){return e.encode(this.commands)},e.prototype.getBounds=function(){var t=x2.CALCULATE_BOUNDS();return this.transform(t),t},e.prototype.transform=function(t){for(var e=[],n=0,r=this.commands;n<r.length;n++){var i=t(r[n]);Array.isArray(i)?e.push.apply(e,i):e.push(i)}return this.commands=e,this},e.encode=function(t){return function(t){var e="";Array.isArray(t)||(t=[t]);for(var n=0;n<t.length;n++){var r=t[n];if(r.type===P2.CLOSE_PATH)e+="z";else if(r.type===P2.HORIZ_LINE_TO)e+=(r.relative?"h":"H")+r.x;else if(r.type===P2.VERT_LINE_TO)e+=(r.relative?"v":"V")+r.y;else if(r.type===P2.MOVE_TO)e+=(r.relative?"m":"M")+r.x+" "+r.y;else if(r.type===P2.LINE_TO)e+=(r.relative?"l":"L")+r.x+" "+r.y;else if(r.type===P2.CURVE_TO)e+=(r.relative?"c":"C")+r.x1+" "+r.y1+" "+r.x2+" "+r.y2+" "+r.x+" "+r.y;else if(r.type===P2.SMOOTH_CURVE_TO)e+=(r.relative?"s":"S")+r.x2+" "+r.y2+" "+r.x+" "+r.y;else if(r.type===P2.QUAD_TO)e+=(r.relative?"q":"Q")+r.x1+" "+r.y1+" "+r.x+" "+r.y;else if(r.type===P2.SMOOTH_QUAD_TO)e+=(r.relative?"t":"T")+r.x+" "+r.y;else{if(r.type!==P2.ARC)throw new Error('Unexpected command type "'+r.type+'" at index '+n+".");e+=(r.relative?"a":"A")+r.rX+" "+r.rY+" "+r.xRot+" "+ +r.lArcFlag+" "+ +r.sweepFlag+" "+r.x+" "+r.y}}return e}(t)},e.parse=function(t){var e=new O2,n=[];return e.parse(t,n),e.finish(n),n},e.CLOSE_PATH=1,e.MOVE_TO=2,e.HORIZ_LINE_TO=4,e.VERT_LINE_TO=8,e.LINE_TO=16,e.CURVE_TO=32,e.SMOOTH_CURVE_TO=64,e.QUAD_TO=128,e.SMOOTH_QUAD_TO=256,e.ARC=512,e.LINE_COMMANDS=e.LINE_TO|e.HORIZ_LINE_TO|e.VERT_LINE_TO,e.DRAWING_COMMANDS=e.HORIZ_LINE_TO|e.VERT_LINE_TO|e.LINE_TO|e.CURVE_TO|e.SMOOTH_CURVE_TO|e.QUAD_TO|e.SMOOTH_QUAD_TO|e.ARC,e}(Q2),N2=((I2={})[P2.MOVE_TO]=2,I2[P2.LINE_TO]=2,I2[P2.HORIZ_LINE_TO]=1,I2[P2.VERT_LINE_TO]=1,I2[P2.CLOSE_PATH]=0,I2[P2.QUAD_TO]=4,I2[P2.SMOOTH_QUAD_TO]=2,I2[P2.CURVE_TO]=6,I2[P2.SMOOTH_CURVE_TO]=4,I2[P2.ARC]=7,I2),T2=hW.PROPER,D2=lV,R2=Vj,H2=uY,j2=gR,W2=z$,V2="toString",K2=RegExp.prototype,G2=K2[V2],z2=j2(function(){return"/a/b"!==G2.call({source:"a",flags:"b"})}),q2=T2&&G2.name!==V2;function X2(t){return(X2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}(z2||q2)&&D2(K2,V2,function(){var t=R2(this);return"/"+H2(t.source)+"/"+H2(W2(t))},{unsafe:!0});var Y2=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],$2=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function J2(t,e,n,r,i,A){if(!(isNaN(A)||A<1)){A|=0;var s=function(t,e,n,r,i){if("string"==typeof t&&(t=document.getElementById(t)),!t||"object"!==X2(t)||!("getContext"in t))throw new TypeError("Expecting canvas with `getContext` method in processCanvasRGB(A) calls!");var A=t.getContext("2d");try{return A.getImageData(e,n,r,i)}catch(hw){throw new Error("unable to access image data: "+hw)}}(t,e,n,r,i);s=function(t,e,n,r,i,A){for(var s,a=t.data,o=2*A+1,l=r-1,c=i-1,h=A+1,u=h*(h+1)/2,d=new Z2,f=d,p=1;p<o;p++)f=f.next=new Z2,p===h&&(s=f);f.next=d;for(var g=null,m=null,w=0,v=0,y=Y2[A],b=$2[A],B=0;B<i;B++){f=d;for(var _=a[v],C=a[v+1],x=a[v+2],E=a[v+3],S=0;S<h;S++)f.r=_,f.g=C,f.b=x,f.a=E,f=f.next;for(var F=0,L=0,U=0,I=0,Q=h*_,k=h*C,M=h*x,O=h*E,P=u*_,N=u*C,T=u*x,D=u*E,R=1;R<h;R++){var H=v+((l<R?l:R)<<2),j=a[H],W=a[H+1],V=a[H+2],K=a[H+3],G=h-R;P+=(f.r=j)*G,N+=(f.g=W)*G,T+=(f.b=V)*G,D+=(f.a=K)*G,F+=j,L+=W,U+=V,I+=K,f=f.next}g=d,m=s;for(var z=0;z<r;z++){var q=D*y>>>b;if(a[v+3]=q,0!==q){var X=255/q;a[v]=(P*y>>>b)*X,a[v+1]=(N*y>>>b)*X,a[v+2]=(T*y>>>b)*X}else a[v]=a[v+1]=a[v+2]=0;P-=Q,N-=k,T-=M,D-=O,Q-=g.r,k-=g.g,M-=g.b,O-=g.a;var Y=z+A+1;Y=w+(Y<l?Y:l)<<2,P+=F+=g.r=a[Y],N+=L+=g.g=a[Y+1],T+=U+=g.b=a[Y+2],D+=I+=g.a=a[Y+3],g=g.next;var $=m,J=$.r,Z=$.g,tt=$.b,et=$.a;Q+=J,k+=Z,M+=tt,O+=et,F-=J,L-=Z,U-=tt,I-=et,m=m.next,v+=4}w+=r}for(var nt=0;nt<r;nt++){var rt=a[v=nt<<2],it=a[v+1],At=a[v+2],st=a[v+3],at=h*rt,ot=h*it,lt=h*At,ct=h*st,ht=u*rt,ut=u*it,dt=u*At,ft=u*st;f=d;for(var pt=0;pt<h;pt++)f.r=rt,f.g=it,f.b=At,f.a=st,f=f.next;for(var gt=r,mt=0,wt=0,vt=0,yt=0,bt=1;bt<=A;bt++){v=gt+nt<<2;var Bt=h-bt;ht+=(f.r=rt=a[v])*Bt,ut+=(f.g=it=a[v+1])*Bt,dt+=(f.b=At=a[v+2])*Bt,ft+=(f.a=st=a[v+3])*Bt,yt+=rt,mt+=it,wt+=At,vt+=st,f=f.next,bt<c&&(gt+=r)}v=nt,g=d,m=s;for(var _t=0;_t<i;_t++){var Ct=v<<2;a[Ct+3]=st=ft*y>>>b,st>0?(st=255/st,a[Ct]=(ht*y>>>b)*st,a[Ct+1]=(ut*y>>>b)*st,a[Ct+2]=(dt*y>>>b)*st):a[Ct]=a[Ct+1]=a[Ct+2]=0,ht-=at,ut-=ot,dt-=lt,ft-=ct,at-=g.r,ot-=g.g,lt-=g.b,ct-=g.a,Ct=nt+((Ct=_t+h)<c?Ct:c)*r<<2,ht+=yt+=g.r=a[Ct],ut+=mt+=g.g=a[Ct+1],dt+=wt+=g.b=a[Ct+2],ft+=vt+=g.a=a[Ct+3],g=g.next,at+=rt=m.r,ot+=it=m.g,lt+=At=m.b,ct+=st=m.a,yt-=rt,mt-=it,wt-=At,vt-=st,m=m.next,v+=r}}return t}(s,0,0,r,i,A),t.getContext("2d").putImageData(s,e,n)}}var Z2=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.r=0,this.g=0,this.b=0,this.a=0,this.next=null};var t5=Object.freeze({__proto__:null,offscreen:function(){var{DOMParser:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:t,createCanvas:(t,e)=>new OffscreenCanvas(t,e),createImage:t=>lY(function*(){var e=yield fetch(t),n=yield e.blob();return yield createImageBitmap(n)})()};return"undefined"==typeof DOMParser&&void 0!==t||Reflect.deleteProperty(e,"DOMParser"),e},node:function(t){var{DOMParser:e,canvas:n,fetch:r}=t;return{window:null,ignoreAnimation:!0,ignoreMouse:!0,DOMParser:e,fetch:r,createCanvas:n.createCanvas,createImage:n.loadImage}}});function e5(t){return t.replace(/(?!\u3000)\s+/gm," ")}function n5(t){return t.replace(/^[\n \t]+/,"")}function r5(t){return t.replace(/[\n \t]+$/,"")}function i5(t){return((t||"").match(/-?(\d+(?:\.\d*(?:[eE][+-]?\d+)?)?|\.\d+)(?=\D|$)/gm)||[]).map(parseFloat)}var A5=/^[A-Z-]+$/;function s5(t){return A5.test(t)?t.toLowerCase():t}function a5(t){var e=/url\(('([^']+)'|"([^"]+)"|([^'")]+))\)/.exec(t)||[];return e[2]||e[3]||e[4]}function o5(t){if(!t.startsWith("rgb"))return t;var e=3;return t.replace(/\d+(\.\d+)?/g,(t,n)=>e--&&n?String(Math.round(parseFloat(t))):t)}var l5=/(\[[^\]]+\])/g,c5=/(#[^\s+>~.[:]+)/g,h5=/(\.[^\s+>~.[:]+)/g,u5=/(::[^\s+>~.[:]+|:first-line|:first-letter|:before|:after)/gi,d5=/(:[\w-]+\([^)]*\))/gi,f5=/(:[^\s+>~.[:]+)/g,p5=/([^\s+>~.[:]+)/g;function g5(t,e){var n=e.exec(t);return n?[t.replace(e," "),n.length]:[t,0]}function m5(t){var e=[0,0,0],n=t.replace(/:not\(([^)]*)\)/g," $1 ").replace(/{[\s\S]*/gm," "),r=0;return[n,r]=g5(n,l5),e[1]+=r,[n,r]=g5(n,c5),e[0]+=r,[n,r]=g5(n,h5),e[1]+=r,[n,r]=g5(n,u5),e[2]+=r,[n,r]=g5(n,d5),e[1]+=r,[n,r]=g5(n,f5),e[1]+=r,n=n.replace(/[*\s+>~]/g," ").replace(/[#.]/g," "),[n,r]=g5(n,p5),e[2]+=r,e.join("")}var w5=1e-8;function v5(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function y5(t,e){return(t[0]*e[0]+t[1]*e[1])/(v5(t)*v5(e))}function b5(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y5(t,e))}function B5(t){return t*t*t}function _5(t){return 3*t*t*(1-t)}function C5(t){return 3*t*(1-t)*(1-t)}function x5(t){return(1-t)*(1-t)*(1-t)}function E5(t){return t*t}function S5(t){return 2*t*(1-t)}function F5(t){return(1-t)*(1-t)}class L5{constructor(t,e,n){this.document=t,this.name=e,this.value=n,this.isNormalizedColor=!1}static empty(t){return new L5(t,"EMPTY","")}split(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:" ",{document:e,name:n}=this;return e5(this.getString()).trim().split(t).map(t=>new L5(e,n,t))}hasValue(t){var{value:e}=this;return null!==e&&""!==e&&(t||0!==e)&&void 0!==e}isString(t){var{value:e}=this,n="string"==typeof e;return n&&t?t.test(e):n}isUrlDefinition(){return this.isString(/^url\(/)}isPixels(){if(!this.hasValue())return!1;var t=this.getString();switch(!0){case t.endsWith("px"):case/^[0-9]+$/.test(t):return!0;default:return!1}}setValue(t){return this.value=t,this}getValue(t){return void 0===t||this.hasValue()?this.value:t}getNumber(t){if(!this.hasValue())return void 0===t?0:parseFloat(t);var{value:e}=this,n=parseFloat(e);return this.isString(/%$/)&&(n/=100),n}getString(t){return void 0===t||this.hasValue()?void 0===this.value?"":String(this.value):String(t)}getColor(t){var e=this.getString(t);return this.isNormalizedColor||(this.isNormalizedColor=!0,e=o5(e),this.value=e),e}getDpi(){return 96}getRem(){return this.document.rootEmSize}getEm(){return this.document.emSize}getUnits(){return this.getString().replace(/[0-9.-]/g,"")}getPixels(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasValue())return 0;var[n,r]="boolean"==typeof t?[void 0,t]:[t],{viewPort:i}=this.document.screen;switch(!0){case this.isString(/vmin$/):return this.getNumber()/100*Math.min(i.computeSize("x"),i.computeSize("y"));case this.isString(/vmax$/):return this.getNumber()/100*Math.max(i.computeSize("x"),i.computeSize("y"));case this.isString(/vw$/):return this.getNumber()/100*i.computeSize("x");case this.isString(/vh$/):return this.getNumber()/100*i.computeSize("y");case this.isString(/rem$/):return this.getNumber()*this.getRem();case this.isString(/em$/):return this.getNumber()*this.getEm();case this.isString(/ex$/):return this.getNumber()*this.getEm()/2;case this.isString(/px$/):return this.getNumber();case this.isString(/pt$/):return this.getNumber()*this.getDpi()*(1/72);case this.isString(/pc$/):return 15*this.getNumber();case this.isString(/cm$/):return this.getNumber()*this.getDpi()/2.54;case this.isString(/mm$/):return this.getNumber()*this.getDpi()/25.4;case this.isString(/in$/):return this.getNumber()*this.getDpi();case this.isString(/%$/)&&r:return this.getNumber()*this.getEm();case this.isString(/%$/):return this.getNumber()*i.computeSize(n);default:var A=this.getNumber();return e&&A<1?A*i.computeSize(n):A}}getMilliseconds(){return this.hasValue()?this.isString(/ms$/)?this.getNumber():1e3*this.getNumber():0}getRadians(){if(!this.hasValue())return 0;switch(!0){case this.isString(/deg$/):return this.getNumber()*(Math.PI/180);case this.isString(/grad$/):return this.getNumber()*(Math.PI/200);case this.isString(/rad$/):return this.getNumber();default:return this.getNumber()*(Math.PI/180)}}getDefinition(){var t=this.getString(),e=/#([^)'"]+)/.exec(t);return e&&(e=e[1]),e||(e=t),this.document.definitions[e]}getFillStyleDefinition(t,e){var n=this.getDefinition();if(!n)return null;if("function"==typeof n.createGradient)return n.createGradient(this.document.ctx,t,e);if("function"==typeof n.createPattern){if(n.getHrefAttribute().hasValue()){var r=n.getAttribute("patternTransform");n=n.getHrefAttribute().getDefinition(),r.hasValue()&&n.getAttribute("patternTransform",!0).setValue(r.value)}return n.createPattern(this.document.ctx,t,e)}return null}getTextBaseline(){return this.hasValue()?L5.textBaselineMapping[this.getString()]:null}addOpacity(t){for(var e=this.getColor(),n=e.length,r=0,i=0;i<n&&(","===e[i]&&r++,3!==r);i++);if(t.hasValue()&&this.isString()&&3!==r){var A=new e2(e);A.ok&&(A.alpha=t.getNumber(),e=A.toRGBA())}return new L5(this.document,this.name,e)}}L5.textBaselineMapping={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};class U5{constructor(){this.viewPorts=[]}clear(){this.viewPorts=[]}setCurrent(t,e){this.viewPorts.push({width:t,height:e})}removeCurrent(){this.viewPorts.pop()}getCurrent(){var{viewPorts:t}=this;return t[t.length-1]}get width(){return this.getCurrent().width}get height(){return this.getCurrent().height}computeSize(t){return"number"==typeof t?t:"x"===t?this.width:"y"===t?this.height:Math.sqrt(Math.pow(this.width,2)+Math.pow(this.height,2))/Math.sqrt(2)}}class I5{constructor(t,e){this.x=t,this.y=e}static parse(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,[n=e,r=e]=i5(t);return new I5(n,r)}static parseScale(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,[n=e,r=n]=i5(t);return new I5(n,r)}static parsePath(t){for(var e=i5(t),n=e.length,r=[],i=0;i<n;i+=2)r.push(new I5(e[i],e[i+1]));return r}angleTo(t){return Math.atan2(t.y-this.y,t.x-this.x)}applyTransform(t){var{x:e,y:n}=this,r=e*t[0]+n*t[2]+t[4],i=e*t[1]+n*t[3]+t[5];this.x=r,this.y=i}}class Q5{constructor(t){this.screen=t,this.working=!1,this.events=[],this.eventElements=[],this.onClick=this.onClick.bind(this),this.onMouseMove=this.onMouseMove.bind(this)}isWorking(){return this.working}start(){if(!this.working){var{screen:t,onClick:e,onMouseMove:n}=this,r=t.ctx.canvas;r.onclick=e,r.onmousemove=n,this.working=!0}}stop(){if(this.working){var t=this.screen.ctx.canvas;this.working=!1,t.onclick=null,t.onmousemove=null}}hasEvents(){return this.working&&this.events.length>0}runEvents(){if(this.working){var{screen:t,events:e,eventElements:n}=this,{style:r}=t.ctx.canvas;r&&(r.cursor=""),e.forEach((t,e)=>{for(var{run:r}=t,i=n[e];i;)r(i),i=i.parent}),this.events=[],this.eventElements=[]}}checkPath(t,e){if(this.working&&e){var{events:n,eventElements:r}=this;n.forEach((n,i)=>{var{x:A,y:s}=n;!r[i]&&e.isPointInPath&&e.isPointInPath(A,s)&&(r[i]=t)})}}checkBoundingBox(t,e){if(this.working&&e){var{events:n,eventElements:r}=this;n.forEach((n,i)=>{var{x:A,y:s}=n;!r[i]&&e.isPointInBox(A,s)&&(r[i]=t)})}}mapXY(t,e){for(var{window:n,ctx:r}=this.screen,i=new I5(t,e),A=r.canvas;A;)i.x-=A.offsetLeft,i.y-=A.offsetTop,A=A.offsetParent;return n.scrollX&&(i.x+=n.scrollX),n.scrollY&&(i.y+=n.scrollY),i}onClick(t){var{x:e,y:n}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onclick",x:e,y:n,run(t){t.onClick&&t.onClick()}})}onMouseMove(t){var{x:e,y:n}=this.mapXY(t.clientX,t.clientY);this.events.push({type:"onmousemove",x:e,y:n,run(t){t.onMouseMove&&t.onMouseMove()}})}}var k5="undefined"!=typeof window?window:null,M5="undefined"!=typeof fetch?fetch.bind(void 0):null;class O5{constructor(t){var{fetch:e=M5,window:n=k5}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.ctx=t,this.FRAMERATE=30,this.MAX_VIRTUAL_PIXELS=3e4,this.CLIENT_WIDTH=800,this.CLIENT_HEIGHT=600,this.viewPort=new U5,this.mouse=new Q5(this),this.animations=[],this.waits=[],this.frameDuration=0,this.isReadyLock=!1,this.isFirstRender=!0,this.intervalId=null,this.window=n,this.fetch=e}wait(t){this.waits.push(t)}ready(){return this.readyPromise?this.readyPromise:Promise.resolve()}isReady(){if(this.isReadyLock)return!0;var t=this.waits.every(t=>t());return t&&(this.waits=[],this.resolveReady&&this.resolveReady()),this.isReadyLock=t,t}setDefaults(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4}setViewBox(t){var{document:e,ctx:n,aspectRatio:r,width:i,desiredWidth:A,height:s,desiredHeight:a,minX:o=0,minY:l=0,refX:c,refY:h,clip:u=!1,clipX:d=0,clipY:f=0}=t,p=e5(r).replace(/^defer\s/,""),[g,m]=p.split(" "),w=g||"xMidYMid",v=m||"meet",y=i/A,b=s/a,B=Math.min(y,b),_=Math.max(y,b),C=A,x=a;"meet"===v&&(C*=B,x*=B),"slice"===v&&(C*=_,x*=_);var E=new L5(e,"refX",c),S=new L5(e,"refY",h),F=E.hasValue()&&S.hasValue();if(F&&n.translate(-B*E.getPixels("x"),-B*S.getPixels("y")),u){var L=B*d,U=B*f;n.beginPath(),n.moveTo(L,U),n.lineTo(i,U),n.lineTo(i,s),n.lineTo(L,s),n.closePath(),n.clip()}if(!F){var I="meet"===v&&B===b,Q="slice"===v&&_===b,k="meet"===v&&B===y,M="slice"===v&&_===y;w.startsWith("xMid")&&(I||Q)&&n.translate(i/2-C/2,0),w.endsWith("YMid")&&(k||M)&&n.translate(0,s/2-x/2),w.startsWith("xMax")&&(I||Q)&&n.translate(i-C,0),w.endsWith("YMax")&&(k||M)&&n.translate(0,s-x)}switch(!0){case"none"===w:n.scale(y,b);break;case"meet"===v:n.scale(B,B);break;case"slice"===v:n.scale(_,_)}n.translate(-o,-l)}start(t){var{enableRedraw:e=!1,ignoreMouse:n=!1,ignoreAnimation:r=!1,ignoreDimensions:i=!1,ignoreClear:A=!1,forceRedraw:s,scaleWidth:a,scaleHeight:o,offsetX:l,offsetY:c}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{FRAMERATE:h,mouse:u}=this,d=1e3/h;if(this.frameDuration=d,this.readyPromise=new Promise(t=>{this.resolveReady=t}),this.isReady()&&this.render(t,i,A,a,o,l,c),e){var f=Date.now(),p=f,g=0,m=()=>{f=Date.now(),(g=f-p)>=d&&(p=f-g%d,this.shouldUpdate(r,s)&&(this.render(t,i,A,a,o,l,c),u.runEvents())),this.intervalId=R1(m)};n||u.start(),this.intervalId=R1(m)}}stop(){this.intervalId&&(R1.cancel(this.intervalId),this.intervalId=null),this.mouse.stop()}shouldUpdate(t,e){if(!t){var{frameDuration:n}=this;if(this.animations.reduce((t,e)=>e.update(n)||t,!1))return!0}return!("function"!=typeof e||!e())||(!(this.isReadyLock||!this.isReady())||!!this.mouse.hasEvents())}render(t,e,n,r,i,A,s){var{CLIENT_WIDTH:a,CLIENT_HEIGHT:o,viewPort:l,ctx:c,isFirstRender:h}=this,u=c.canvas;l.clear(),u.width&&u.height?l.setCurrent(u.width,u.height):l.setCurrent(a,o);var d=t.getStyle("width"),f=t.getStyle("height");!e&&(h||"number"!=typeof r&&"number"!=typeof i)&&(d.hasValue()&&(u.width=d.getPixels("x"),u.style&&(u.style.width="".concat(u.width,"px"))),f.hasValue()&&(u.height=f.getPixels("y"),u.style&&(u.style.height="".concat(u.height,"px"))));var p=u.clientWidth||u.width,g=u.clientHeight||u.height;if(e&&d.hasValue()&&f.hasValue()&&(p=d.getPixels("x"),g=f.getPixels("y")),l.setCurrent(p,g),"number"==typeof A&&t.getAttribute("x",!0).setValue(A),"number"==typeof s&&t.getAttribute("y",!0).setValue(s),"number"==typeof r||"number"==typeof i){var m=i5(t.getAttribute("viewBox").getString()),w=0,v=0;if("number"==typeof r){var y=t.getStyle("width");y.hasValue()?w=y.getPixels("x")/r:isNaN(m[2])||(w=m[2]/r)}if("number"==typeof i){var b=t.getStyle("height");b.hasValue()?v=b.getPixels("y")/i:isNaN(m[3])||(v=m[3]/i)}w||(w=v),v||(v=w),t.getAttribute("width",!0).setValue(r),t.getAttribute("height",!0).setValue(i);var B=t.getStyle("transform",!0,!0);B.setValue("".concat(B.getString()," scale(").concat(1/w,", ").concat(1/v,")"))}n||c.clearRect(0,0,p,g),t.render(c),h&&(this.isFirstRender=!1)}}O5.defaultWindow=k5,O5.defaultFetch=M5;var{defaultFetch:P5}=O5,N5="undefined"!=typeof DOMParser?DOMParser:null;class T5{constructor(){var{fetch:t=P5,DOMParser:e=N5}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.fetch=t,this.DOMParser=e}parse(t){var e=this;return lY(function*(){return t.startsWith("<")?e.parseFromString(t):e.load(t)})()}parseFromString(t){var e=new this.DOMParser;try{return this.checkDocument(e.parseFromString(t,"image/svg+xml"))}catch(n){return this.checkDocument(e.parseFromString(t,"text/xml"))}}checkDocument(t){var e=t.getElementsByTagName("parsererror")[0];if(e)throw new Error(e.textContent);return t}load(t){var e=this;return lY(function*(){var n=yield e.fetch(t),r=yield n.text();return e.parseFromString(r)})()}}class D5{constructor(t,e){this.type="translate",this.point=null,this.point=I5.parse(e)}apply(t){var{x:e,y:n}=this.point;t.translate(e||0,n||0)}unapply(t){var{x:e,y:n}=this.point;t.translate(-1*e||0,-1*n||0)}applyToPoint(t){var{x:e,y:n}=this.point;t.applyTransform([1,0,0,1,e||0,n||0])}}class R5{constructor(t,e,n){this.type="rotate",this.angle=null,this.originX=null,this.originY=null,this.cx=0,this.cy=0;var r=i5(e);this.angle=new L5(t,"angle",r[0]),this.originX=n[0],this.originY=n[1],this.cx=r[1]||0,this.cy=r[2]||0}apply(t){var{cx:e,cy:n,originX:r,originY:i,angle:A}=this,s=e+r.getPixels("x"),a=n+i.getPixels("y");t.translate(s,a),t.rotate(A.getRadians()),t.translate(-s,-a)}unapply(t){var{cx:e,cy:n,originX:r,originY:i,angle:A}=this,s=e+r.getPixels("x"),a=n+i.getPixels("y");t.translate(s,a),t.rotate(-1*A.getRadians()),t.translate(-s,-a)}applyToPoint(t){var{cx:e,cy:n,angle:r}=this,i=r.getRadians();t.applyTransform([1,0,0,1,e||0,n||0]),t.applyTransform([Math.cos(i),Math.sin(i),-Math.sin(i),Math.cos(i),0,0]),t.applyTransform([1,0,0,1,-e||0,-n||0])}}class H5{constructor(t,e,n){this.type="scale",this.scale=null,this.originX=null,this.originY=null;var r=I5.parseScale(e);0!==r.x&&0!==r.y||(r.x=w5,r.y=w5),this.scale=r,this.originX=n[0],this.originY=n[1]}apply(t){var{scale:{x:e,y:n},originX:r,originY:i}=this,A=r.getPixels("x"),s=i.getPixels("y");t.translate(A,s),t.scale(e,n||e),t.translate(-A,-s)}unapply(t){var{scale:{x:e,y:n},originX:r,originY:i}=this,A=r.getPixels("x"),s=i.getPixels("y");t.translate(A,s),t.scale(1/e,1/n||e),t.translate(-A,-s)}applyToPoint(t){var{x:e,y:n}=this.scale;t.applyTransform([e||0,0,0,n||0,0,0])}}class j5{constructor(t,e,n){this.type="matrix",this.matrix=[],this.originX=null,this.originY=null,this.matrix=i5(e),this.originX=n[0],this.originY=n[1]}apply(t){var{originX:e,originY:n,matrix:r}=this,i=e.getPixels("x"),A=n.getPixels("y");t.translate(i,A),t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),t.translate(-i,-A)}unapply(t){var{originX:e,originY:n,matrix:r}=this,i=r[0],A=r[2],s=r[4],a=r[1],o=r[3],l=r[5],c=1/(i*(1*o-0*l)-A*(1*a-0*l)+s*(0*a-0*o)),h=e.getPixels("x"),u=n.getPixels("y");t.translate(h,u),t.transform(c*(1*o-0*l),c*(0*l-1*a),c*(0*s-1*A),c*(1*i-0*s),c*(A*l-s*o),c*(s*a-i*l)),t.translate(-h,-u)}applyToPoint(t){t.applyTransform(this.matrix)}}class W5 extends j5{constructor(t,e,n){super(t,e,n),this.type="skew",this.angle=null,this.angle=new L5(t,"angle",e)}}class V5 extends W5{constructor(t,e,n){super(t,e,n),this.type="skewX",this.matrix=[1,0,Math.tan(this.angle.getRadians()),1,0,0]}}class K5 extends W5{constructor(t,e,n){super(t,e,n),this.type="skewY",this.matrix=[1,Math.tan(this.angle.getRadians()),0,1,0,0]}}class G5{constructor(t,e,n){this.document=t,this.transforms=[];var r=function(t){return e5(t).trim().replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)}(e);r.forEach(t=>{if("none"!==t){var[e,r]=function(t){var[e,n]=t.split("(");return[e.trim(),n.trim().replace(")","")]}(t),i=G5.transformTypes[e];void 0!==i&&this.transforms.push(new i(this.document,r,n))}})}static fromElement(t,e){var n=e.getStyle("transform",!1,!0),[r,i=r]=e.getStyle("transform-origin",!1,!0).split(),A=[r,i];return n.hasValue()?new G5(t,n.getString(),A):null}apply(t){for(var{transforms:e}=this,n=e.length,r=0;r<n;r++)e[r].apply(t)}unapply(t){for(var{transforms:e}=this,n=e.length-1;n>=0;n--)e[n].unapply(t)}applyToPoint(t){for(var{transforms:e}=this,n=e.length,r=0;r<n;r++)e[r].applyToPoint(t)}}G5.transformTypes={translate:D5,rotate:R5,scale:H5,matrix:j5,skewX:V5,skewY:K5};class z5{constructor(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.document=t,this.node=e,this.captureTextNodes=n,this.attributes=Object.create(null),this.styles=Object.create(null),this.stylesSpecificity=Object.create(null),this.animationFrozen=!1,this.animationFrozenValue="",this.parent=null,this.children=[],e&&1===e.nodeType){if(Array.from(e.attributes).forEach(e=>{var n=s5(e.nodeName);this.attributes[n]=new L5(t,n,e.value)}),this.addStylesFromStyleDefinition(),this.getAttribute("style").hasValue())this.getAttribute("style").getString().split(";").map(t=>t.trim()).forEach(e=>{if(e){var[n,r]=e.split(":").map(t=>t.trim());this.styles[n]=new L5(t,n,r)}});var{definitions:r}=t,i=this.getAttribute("id");i.hasValue()&&(r[i.getString()]||(r[i.getString()]=this)),Array.from(e.childNodes).forEach(e=>{if(1===e.nodeType)this.addChild(e);else if(n&&(3===e.nodeType||4===e.nodeType)){var r=t.createTextNode(e);r.getText().length>0&&this.addChild(r)}})}}getAttribute(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.attributes[t];if(!n&&e){var r=new L5(this.document,t,"");return this.attributes[t]=r,r}return n||L5.empty(this.document)}getHrefAttribute(){for(var t in this.attributes)if("href"===t||t.endsWith(":href"))return this.attributes[t];return L5.empty(this.document)}getStyle(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.styles[t];if(r)return r;var i=this.getAttribute(t);if(null!=i&&i.hasValue())return this.styles[t]=i,i;if(!n){var{parent:A}=this;if(A){var s=A.getStyle(t);if(null!=s&&s.hasValue())return s}}if(e){var a=new L5(this.document,t,"");return this.styles[t]=a,a}return r||L5.empty(this.document)}render(t){if("none"!==this.getStyle("display").getString()&&"hidden"!==this.getStyle("visibility").getString()){if(t.save(),this.getStyle("mask").hasValue()){var e=this.getStyle("mask").getDefinition();e&&(this.applyEffects(t),e.apply(t,this))}else if("none"!==this.getStyle("filter").getValue("none")){var n=this.getStyle("filter").getDefinition();n&&(this.applyEffects(t),n.apply(t,this))}else this.setContext(t),this.renderChildren(t),this.clearContext(t);t.restore()}}setContext(t){}applyEffects(t){var e=G5.fromElement(this.document,this);e&&e.apply(t);var n=this.getStyle("clip-path",!1,!0);if(n.hasValue()){var r=n.getDefinition();r&&r.apply(t)}}clearContext(t){}renderChildren(t){this.children.forEach(e=>{e.render(t)})}addChild(t){var e=t instanceof z5?t:this.document.createElement(t);e.parent=this,z5.ignoreChildTypes.includes(e.type)||this.children.push(e)}matchesSelector(t){var e,{node:n}=this;if("function"==typeof n.matches)return n.matches(t);var r=null===(e=n.getAttribute)||void 0===e?void 0:e.call(n,"class");return!(!r||""===r)&&r.split(" ").some(e=>".".concat(e)===t)}addStylesFromStyleDefinition(){var{styles:t,stylesSpecificity:e}=this.document;for(var n in t)if(!n.startsWith("@")&&this.matchesSelector(n)){var r=t[n],i=e[n];if(r)for(var A in r){var s=this.stylesSpecificity[A];void 0===s&&(s="000"),i>=s&&(this.styles[A]=r[A],this.stylesSpecificity[A]=i)}}}removeStyles(t,e){return e.reduce((e,n)=>{var r=t.getStyle(n);if(!r.hasValue())return e;var i=r.getString();return r.setValue(""),[...e,[n,i]]},[])}restoreStyles(t,e){e.forEach(e=>{var[n,r]=e;t.getStyle(n,!0).setValue(r)})}isFirstChild(){var t;return 0===(null===(t=this.parent)||void 0===t?void 0:t.children.indexOf(this))}}z5.ignoreChildTypes=["title"];class q5 extends z5{constructor(t,e,n){super(t,e,n)}}function X5(t){var e=t.trim();return/^('|")/.test(e)?e:'"'.concat(e,'"')}function Y5(t){if(!t)return"";var e=t.trim().toLowerCase();switch(e){case"normal":case"italic":case"oblique":case"inherit":case"initial":case"unset":return e;default:return/^oblique\s+(-|)\d+deg$/.test(e)?e:""}}function $5(t){if(!t)return"";var e=t.trim().toLowerCase();switch(e){case"normal":case"bold":case"lighter":case"bolder":case"inherit":case"initial":case"unset":return e;default:return/^[\d.]+$/.test(e)?e:""}}class J5{constructor(t,e,n,r,i,A){var s=A?"string"==typeof A?J5.parse(A):A:{};this.fontFamily=i||s.fontFamily,this.fontSize=r||s.fontSize,this.fontStyle=t||s.fontStyle,this.fontWeight=n||s.fontWeight,this.fontVariant=e||s.fontVariant}static parse(){var t=arguments.length>1?arguments[1]:void 0,e="",n="",r="",i="",A="",s=e5(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").trim().split(" "),a={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1};return s.forEach(t=>{switch(!0){case!a.fontStyle&&J5.styles.includes(t):"inherit"!==t&&(e=t),a.fontStyle=!0;break;case!a.fontVariant&&J5.variants.includes(t):"inherit"!==t&&(n=t),a.fontStyle=!0,a.fontVariant=!0;break;case!a.fontWeight&&J5.weights.includes(t):"inherit"!==t&&(r=t),a.fontStyle=!0,a.fontVariant=!0,a.fontWeight=!0;break;case!a.fontSize:"inherit"!==t&&([i]=t.split("/")),a.fontStyle=!0,a.fontVariant=!0,a.fontWeight=!0,a.fontSize=!0;break;default:"inherit"!==t&&(A+=t)}}),new J5(e,n,r,i,A,t)}toString(){return[Y5(this.fontStyle),this.fontVariant,$5(this.fontWeight),this.fontSize,(t=this.fontFamily,"undefined"==typeof process?t:t.trim().split(",").map(X5).join(","))].join(" ").trim();var t}}J5.styles="normal|italic|oblique|inherit",J5.variants="normal|small-caps|inherit",J5.weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit";class Z5{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number.NaN,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.NaN,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.NaN,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.NaN;this.x1=t,this.y1=e,this.x2=n,this.y2=r,this.addPoint(t,e),this.addPoint(n,r)}get x(){return this.x1}get y(){return this.y1}get width(){return this.x2-this.x1}get height(){return this.y2-this.y1}addPoint(t,e){void 0!==t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),void 0!==e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))}addX(t){this.addPoint(t,null)}addY(t){this.addPoint(null,t)}addBoundingBox(t){if(t){var{x1:e,y1:n,x2:r,y2:i}=t;this.addPoint(e,n),this.addPoint(r,i)}}sumCubic(t,e,n,r,i){return Math.pow(1-t,3)*e+3*Math.pow(1-t,2)*t*n+3*(1-t)*Math.pow(t,2)*r+Math.pow(t,3)*i}bezierCurveAdd(t,e,n,r,i){var A=6*e-12*n+6*r,s=-3*e+9*n-9*r+3*i,a=3*n-3*e;if(0!==s){var o=Math.pow(A,2)-4*a*s;if(!(o<0)){var l=(-A+Math.sqrt(o))/(2*s);0<l&&l<1&&(t?this.addX(this.sumCubic(l,e,n,r,i)):this.addY(this.sumCubic(l,e,n,r,i)));var c=(-A-Math.sqrt(o))/(2*s);0<c&&c<1&&(t?this.addX(this.sumCubic(c,e,n,r,i)):this.addY(this.sumCubic(c,e,n,r,i)))}}else{if(0===A)return;var h=-a/A;0<h&&h<1&&(t?this.addX(this.sumCubic(h,e,n,r,i)):this.addY(this.sumCubic(h,e,n,r,i)))}}addBezierCurve(t,e,n,r,i,A,s,a){this.addPoint(t,e),this.addPoint(s,a),this.bezierCurveAdd(!0,t,n,i,s),this.bezierCurveAdd(!1,e,r,A,a)}addQuadraticCurve(t,e,n,r,i,A){var s=t+2/3*(n-t),a=e+2/3*(r-e),o=s+1/3*(i-t),l=a+1/3*(A-e);this.addBezierCurve(t,e,s,o,a,l,i,A)}isPointInBox(t,e){var{x1:n,y1:r,x2:i,y2:A}=this;return n<=t&&t<=i&&r<=e&&e<=A}}class t4 extends P2{constructor(t){super(t.replace(/([+\-.])\s+/gm,"$1").replace(/[^MmZzLlHhVvCcSsQqTtAae\d\s.,+-].*/g,"")),this.control=null,this.start=null,this.current=null,this.command=null,this.commands=this.commands,this.i=-1,this.previousCommand=null,this.points=[],this.angles=[]}reset(){this.i=-1,this.command=null,this.previousCommand=null,this.start=new I5(0,0),this.control=new I5(0,0),this.current=new I5(0,0),this.points=[],this.angles=[]}isEnd(){var{i:t,commands:e}=this;return t>=e.length-1}next(){var t=this.commands[++this.i];return this.previousCommand=this.command,this.command=t,t}getPoint(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"x",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",n=new I5(this.command[t],this.command[e]);return this.makeAbsolute(n)}getAsControlPoint(t,e){var n=this.getPoint(t,e);return this.control=n,n}getAsCurrentPoint(t,e){var n=this.getPoint(t,e);return this.current=n,n}getReflectedControlPoint(){var t=this.previousCommand.type;if(t!==P2.CURVE_TO&&t!==P2.SMOOTH_CURVE_TO&&t!==P2.QUAD_TO&&t!==P2.SMOOTH_QUAD_TO)return this.current;var{current:{x:e,y:n},control:{x:r,y:i}}=this;return new I5(2*e-r,2*n-i)}makeAbsolute(t){if(this.command.relative){var{x:e,y:n}=this.current;t.x+=e,t.y+=n}return t}addMarker(t,e,n){var{points:r,angles:i}=this;n&&i.length>0&&!i[i.length-1]&&(i[i.length-1]=r[r.length-1].angleTo(n)),this.addMarkerAngle(t,e?e.angleTo(t):null)}addMarkerAngle(t,e){this.points.push(t),this.angles.push(e)}getMarkerPoints(){return this.points}getMarkerAngles(){for(var{angles:t}=this,e=t.length,n=0;n<e;n++)if(!t[n])for(var r=n+1;r<e;r++)if(t[r]){t[n]=t[r];break}return t}}class e4 extends z5{constructor(){super(...arguments),this.modifiedEmSizeStack=!1}calculateOpacity(){for(var t=1,e=this;e;){var n=e.getStyle("opacity",!1,!0);n.hasValue(!0)&&(t*=n.getNumber()),e=e.parent}return t}setContext(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e){var n=this.getStyle("fill"),r=this.getStyle("fill-opacity"),i=this.getStyle("stroke"),A=this.getStyle("stroke-opacity");if(n.isUrlDefinition()){var s=n.getFillStyleDefinition(this,r);s&&(t.fillStyle=s)}else if(n.hasValue()){"currentColor"===n.getString()&&n.setValue(this.getStyle("color").getColor());var a=n.getColor();"inherit"!==a&&(t.fillStyle="none"===a?"rgba(0,0,0,0)":a)}if(r.hasValue()){var o=new L5(this.document,"fill",t.fillStyle).addOpacity(r).getColor();t.fillStyle=o}if(i.isUrlDefinition()){var l=i.getFillStyleDefinition(this,A);l&&(t.strokeStyle=l)}else if(i.hasValue()){"currentColor"===i.getString()&&i.setValue(this.getStyle("color").getColor());var c=i.getString();"inherit"!==c&&(t.strokeStyle="none"===c?"rgba(0,0,0,0)":c)}if(A.hasValue()){var h=new L5(this.document,"stroke",t.strokeStyle).addOpacity(A).getString();t.strokeStyle=h}var u=this.getStyle("stroke-width");if(u.hasValue()){var d=u.getPixels();t.lineWidth=d||w5}var f=this.getStyle("stroke-linecap"),p=this.getStyle("stroke-linejoin"),g=this.getStyle("stroke-miterlimit"),m=this.getStyle("stroke-dasharray"),w=this.getStyle("stroke-dashoffset");if(f.hasValue()&&(t.lineCap=f.getString()),p.hasValue()&&(t.lineJoin=p.getString()),g.hasValue()&&(t.miterLimit=g.getNumber()),m.hasValue()&&"none"!==m.getString()){var v=i5(m.getString());void 0!==t.setLineDash?t.setLineDash(v):void 0!==t.webkitLineDash?t.webkitLineDash=v:void 0===t.mozDash||1===v.length&&0===v[0]||(t.mozDash=v);var y=w.getPixels();void 0!==t.lineDashOffset?t.lineDashOffset=y:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=y:void 0!==t.mozDashOffset&&(t.mozDashOffset=y)}}if(this.modifiedEmSizeStack=!1,void 0!==t.font){var b=this.getStyle("font"),B=this.getStyle("font-style"),_=this.getStyle("font-variant"),C=this.getStyle("font-weight"),x=this.getStyle("font-size"),E=this.getStyle("font-family"),S=new J5(B.getString(),_.getString(),C.getString(),x.hasValue()?"".concat(x.getPixels(!0),"px"):"",E.getString(),J5.parse(b.getString(),t.font));B.setValue(S.fontStyle),_.setValue(S.fontVariant),C.setValue(S.fontWeight),x.setValue(S.fontSize),E.setValue(S.fontFamily),t.font=S.toString(),x.isPixels()&&(this.document.emSize=x.getPixels(),this.modifiedEmSizeStack=!0)}e||(this.applyEffects(t),t.globalAlpha=this.calculateOpacity())}clearContext(t){super.clearContext(t),this.modifiedEmSizeStack&&this.document.popEmSize()}}class n4 extends e4{constructor(t,e,n){super(t,e,n),this.type="path",this.pathParser=null,this.pathParser=new t4(this.getAttribute("d").getString())}path(t){var{pathParser:e}=this,n=new Z5;for(e.reset(),t&&t.beginPath();!e.isEnd();)switch(e.next().type){case t4.MOVE_TO:this.pathM(t,n);break;case t4.LINE_TO:this.pathL(t,n);break;case t4.HORIZ_LINE_TO:this.pathH(t,n);break;case t4.VERT_LINE_TO:this.pathV(t,n);break;case t4.CURVE_TO:this.pathC(t,n);break;case t4.SMOOTH_CURVE_TO:this.pathS(t,n);break;case t4.QUAD_TO:this.pathQ(t,n);break;case t4.SMOOTH_QUAD_TO:this.pathT(t,n);break;case t4.ARC:this.pathA(t,n);break;case t4.CLOSE_PATH:this.pathZ(t,n)}return n}getBoundingBox(t){return this.path()}getMarkers(){var{pathParser:t}=this,e=t.getMarkerPoints(),n=t.getMarkerAngles();return e.map((t,e)=>[t,n[e]])}renderChildren(t){this.path(t),this.document.screen.mouse.checkPath(this,t);var e=this.getStyle("fill-rule");""!==t.fillStyle&&("inherit"!==e.getString("inherit")?t.fill(e.getString()):t.fill()),""!==t.strokeStyle&&("non-scaling-stroke"===this.getAttribute("vector-effect").getString()?(t.save(),t.setTransform(1,0,0,1,0,0),t.stroke(),t.restore()):t.stroke());var n=this.getMarkers();if(n){var r=n.length-1,i=this.getStyle("marker-start"),A=this.getStyle("marker-mid"),s=this.getStyle("marker-end");if(i.isUrlDefinition()){var a=i.getDefinition(),[o,l]=n[0];a.render(t,o,l)}if(A.isUrlDefinition())for(var c=A.getDefinition(),h=1;h<r;h++){var[u,d]=n[h];c.render(t,u,d)}if(s.isUrlDefinition()){var f=s.getDefinition(),[p,g]=n[r];f.render(t,p,g)}}}static pathM(t){var e=t.getAsCurrentPoint();return t.start=t.current,{point:e}}pathM(t,e){var{pathParser:n}=this,{point:r}=n4.pathM(n),{x:i,y:A}=r;n.addMarker(r),e.addPoint(i,A),t&&t.moveTo(i,A)}static pathL(t){var{current:e}=t;return{current:e,point:t.getAsCurrentPoint()}}pathL(t,e){var{pathParser:n}=this,{current:r,point:i}=n4.pathL(n),{x:A,y:s}=i;n.addMarker(i,r),e.addPoint(A,s),t&&t.lineTo(A,s)}static pathH(t){var{current:e,command:n}=t,r=new I5((n.relative?e.x:0)+n.x,e.y);return t.current=r,{current:e,point:r}}pathH(t,e){var{pathParser:n}=this,{current:r,point:i}=n4.pathH(n),{x:A,y:s}=i;n.addMarker(i,r),e.addPoint(A,s),t&&t.lineTo(A,s)}static pathV(t){var{current:e,command:n}=t,r=new I5(e.x,(n.relative?e.y:0)+n.y);return t.current=r,{current:e,point:r}}pathV(t,e){var{pathParser:n}=this,{current:r,point:i}=n4.pathV(n),{x:A,y:s}=i;n.addMarker(i,r),e.addPoint(A,s),t&&t.lineTo(A,s)}static pathC(t){var{current:e}=t;return{current:e,point:t.getPoint("x1","y1"),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathC(t,e){var{pathParser:n}=this,{current:r,point:i,controlPoint:A,currentPoint:s}=n4.pathC(n);n.addMarker(s,A,i),e.addBezierCurve(r.x,r.y,i.x,i.y,A.x,A.y,s.x,s.y),t&&t.bezierCurveTo(i.x,i.y,A.x,A.y,s.x,s.y)}static pathS(t){var{current:e}=t;return{current:e,point:t.getReflectedControlPoint(),controlPoint:t.getAsControlPoint("x2","y2"),currentPoint:t.getAsCurrentPoint()}}pathS(t,e){var{pathParser:n}=this,{current:r,point:i,controlPoint:A,currentPoint:s}=n4.pathS(n);n.addMarker(s,A,i),e.addBezierCurve(r.x,r.y,i.x,i.y,A.x,A.y,s.x,s.y),t&&t.bezierCurveTo(i.x,i.y,A.x,A.y,s.x,s.y)}static pathQ(t){var{current:e}=t;return{current:e,controlPoint:t.getAsControlPoint("x1","y1"),currentPoint:t.getAsCurrentPoint()}}pathQ(t,e){var{pathParser:n}=this,{current:r,controlPoint:i,currentPoint:A}=n4.pathQ(n);n.addMarker(A,i,i),e.addQuadraticCurve(r.x,r.y,i.x,i.y,A.x,A.y),t&&t.quadraticCurveTo(i.x,i.y,A.x,A.y)}static pathT(t){var{current:e}=t,n=t.getReflectedControlPoint();return t.control=n,{current:e,controlPoint:n,currentPoint:t.getAsCurrentPoint()}}pathT(t,e){var{pathParser:n}=this,{current:r,controlPoint:i,currentPoint:A}=n4.pathT(n);n.addMarker(A,i,i),e.addQuadraticCurve(r.x,r.y,i.x,i.y,A.x,A.y),t&&t.quadraticCurveTo(i.x,i.y,A.x,A.y)}static pathA(t){var{current:e,command:n}=t,{rX:r,rY:i,xRot:A,lArcFlag:s,sweepFlag:a}=n,o=A*(Math.PI/180),l=t.getAsCurrentPoint(),c=new I5(Math.cos(o)*(e.x-l.x)/2+Math.sin(o)*(e.y-l.y)/2,-Math.sin(o)*(e.x-l.x)/2+Math.cos(o)*(e.y-l.y)/2),h=Math.pow(c.x,2)/Math.pow(r,2)+Math.pow(c.y,2)/Math.pow(i,2);h>1&&(r*=Math.sqrt(h),i*=Math.sqrt(h));var u=(s===a?-1:1)*Math.sqrt((Math.pow(r,2)*Math.pow(i,2)-Math.pow(r,2)*Math.pow(c.y,2)-Math.pow(i,2)*Math.pow(c.x,2))/(Math.pow(r,2)*Math.pow(c.y,2)+Math.pow(i,2)*Math.pow(c.x,2)));isNaN(u)&&(u=0);var d=new I5(u*r*c.y/i,u*-i*c.x/r),f=new I5((e.x+l.x)/2+Math.cos(o)*d.x-Math.sin(o)*d.y,(e.y+l.y)/2+Math.sin(o)*d.x+Math.cos(o)*d.y),p=b5([1,0],[(c.x-d.x)/r,(c.y-d.y)/i]),g=[(c.x-d.x)/r,(c.y-d.y)/i],m=[(-c.x-d.x)/r,(-c.y-d.y)/i],w=b5(g,m);return y5(g,m)<=-1&&(w=Math.PI),y5(g,m)>=1&&(w=0),{currentPoint:l,rX:r,rY:i,sweepFlag:a,xAxisRotation:o,centp:f,a1:p,ad:w}}pathA(t,e){var{pathParser:n}=this,{currentPoint:r,rX:i,rY:A,sweepFlag:s,xAxisRotation:a,centp:o,a1:l,ad:c}=n4.pathA(n),h=1-s?1:-1,u=l+h*(c/2),d=new I5(o.x+i*Math.cos(u),o.y+A*Math.sin(u));if(n.addMarkerAngle(d,u-h*Math.PI/2),n.addMarkerAngle(r,u-h*Math.PI),e.addPoint(r.x,r.y),t&&!isNaN(l)&&!isNaN(c)){var f=i>A?i:A,p=i>A?1:i/A,g=i>A?A/i:1;t.translate(o.x,o.y),t.rotate(a),t.scale(p,g),t.arc(0,0,f,l,l+c,Boolean(1-s)),t.scale(1/p,1/g),t.rotate(-a),t.translate(-o.x,-o.y)}}static pathZ(t){t.current=t.start}pathZ(t,e){n4.pathZ(this.pathParser),t&&e.x1!==e.x2&&e.y1!==e.y2&&t.closePath()}}class r4 extends n4{constructor(t,e,n){super(t,e,n),this.type="glyph",this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber(),this.unicode=this.getAttribute("unicode").getString(),this.arabicForm=this.getAttribute("arabic-form").getString()}}class i4 extends e4{constructor(t,e,n){super(t,e,new.target===i4||n),this.type="text",this.x=0,this.y=0,this.measureCache=-1}setContext(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.setContext(t,e);var n=this.getStyle("dominant-baseline").getTextBaseline()||this.getStyle("alignment-baseline").getTextBaseline();n&&(t.textBaseline=n)}initializeCoordinates(){this.x=0,this.y=0,this.leafTexts=[],this.textChunkStart=0,this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY}getBoundingBox(t){if("text"!==this.type)return this.getTElementBoundingBox(t);this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t);var e=null;return this.children.forEach((n,r)=>{var i=this.getChildBoundingBox(t,this,this,r);e?e.addBoundingBox(i):e=i}),e}getFontSize(){var{document:t,parent:e}=this,n=J5.parse(t.ctx.font).fontSize;return e.getStyle("font-size").getNumber(n)}getTElementBoundingBox(t){var e=this.getFontSize();return new Z5(this.x,this.y-e,this.x+this.measureText(t),this.y)}getGlyph(t,e,n){var r=e[n],i=null;if(t.isArabic){var A=e.length,s=e[n-1],a=e[n+1],o="isolated";if((0===n||" "===s)&&n<A-1&&" "!==a&&(o="terminal"),n>0&&" "!==s&&n<A-1&&" "!==a&&(o="medial"),n>0&&" "!==s&&(n===A-1||" "===a)&&(o="initial"),void 0!==t.glyphs[r]){var l=t.glyphs[r];i=l instanceof r4?l:l[o]}}else i=t.glyphs[r];return i||(i=t.missingGlyph),i}getText(){return""}getTextFromNode(t){var e=t||this.node,n=Array.from(e.parentNode.childNodes),r=n.indexOf(e),i=n.length-1,A=e5(e.textContent||"");return 0===r&&(A=n5(A)),r===i&&(A=r5(A)),A}renderChildren(t){if("text"===this.type){this.initializeCoordinates(),this.adjustChildCoordinatesRecursive(t),this.children.forEach((e,n)=>{this.renderChild(t,this,this,n)});var{mouse:e}=this.document.screen;e.isWorking()&&e.checkBoundingBox(this,this.getBoundingBox(t))}else this.renderTElementChildren(t)}renderTElementChildren(t){var{document:e,parent:n}=this,r=this.getText(),i=n.getStyle("font-family").getDefinition();if(i)for(var{unitsPerEm:A}=i.fontFace,s=J5.parse(e.ctx.font),a=n.getStyle("font-size").getNumber(s.fontSize),o=n.getStyle("font-style").getString(s.fontStyle),l=a/A,c=i.isRTL?r.split("").reverse().join(""):r,h=i5(n.getAttribute("dx").getString()),u=c.length,d=0;d<u;d++){var f=this.getGlyph(i,c,d);t.translate(this.x,this.y),t.scale(l,-l);var p=t.lineWidth;t.lineWidth=t.lineWidth*A/a,"italic"===o&&t.transform(1,0,.4,1,0,0),f.render(t),"italic"===o&&t.transform(1,0,-.4,1,0,0),t.lineWidth=p,t.scale(1/l,-1/l),t.translate(-this.x,-this.y),this.x+=a*(f.horizAdvX||i.horizAdvX)/A,void 0===h[d]||isNaN(h[d])||(this.x+=h[d])}else{var{x:g,y:m}=this;t.fillStyle&&t.fillText(r,g,m),t.strokeStyle&&t.strokeText(r,g,m)}}applyAnchoring(){if(!(this.textChunkStart>=this.leafTexts.length)){var t=this.leafTexts[this.textChunkStart],e=t.getStyle("text-anchor").getString("start"),n=0;n="start"===e?t.x-this.minX:"end"===e?t.x-this.maxX:t.x-(this.minX+this.maxX)/2;for(var r=this.textChunkStart;r<this.leafTexts.length;r++)this.leafTexts[r].x+=n;this.minX=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.textChunkStart=this.leafTexts.length}}adjustChildCoordinatesRecursive(t){this.children.forEach((e,n)=>{this.adjustChildCoordinatesRecursiveCore(t,this,this,n)}),this.applyAnchoring()}adjustChildCoordinatesRecursiveCore(t,e,n,r){var i=n.children[r];i.children.length>0?i.children.forEach((n,r)=>{e.adjustChildCoordinatesRecursiveCore(t,e,i,r)}):this.adjustChildCoordinates(t,e,n,r)}adjustChildCoordinates(t,e,n,r){var i=n.children[r];if("function"!=typeof i.measureText)return i;t.save(),i.setContext(t,!0);var A=i.getAttribute("x"),s=i.getAttribute("y"),a=i.getAttribute("dx"),o=i.getAttribute("dy"),l=i.getStyle("font-family").getDefinition(),c=Boolean(l)&&l.isRTL;0===r&&(A.hasValue()||A.setValue(i.getInheritedAttribute("x")),s.hasValue()||s.setValue(i.getInheritedAttribute("y")),a.hasValue()||a.setValue(i.getInheritedAttribute("dx")),o.hasValue()||o.setValue(i.getInheritedAttribute("dy")));var h=i.measureText(t);return c&&(e.x-=h),A.hasValue()?(e.applyAnchoring(),i.x=A.getPixels("x"),a.hasValue()&&(i.x+=a.getPixels("x"))):(a.hasValue()&&(e.x+=a.getPixels("x")),i.x=e.x),e.x=i.x,c||(e.x+=h),s.hasValue()?(i.y=s.getPixels("y"),o.hasValue()&&(i.y+=o.getPixels("y"))):(o.hasValue()&&(e.y+=o.getPixels("y")),i.y=e.y),e.y=i.y,e.leafTexts.push(i),e.minX=Math.min(e.minX,i.x,i.x+h),e.maxX=Math.max(e.maxX,i.x,i.x+h),i.clearContext(t),t.restore(),i}getChildBoundingBox(t,e,n,r){var i=n.children[r];if("function"!=typeof i.getBoundingBox)return null;var A=i.getBoundingBox(t);return A?(i.children.forEach((n,r)=>{var s=e.getChildBoundingBox(t,e,i,r);A.addBoundingBox(s)}),A):null}renderChild(t,e,n,r){var i=n.children[r];i.render(t),i.children.forEach((n,r)=>{e.renderChild(t,e,i,r)})}measureText(t){var{measureCache:e}=this;if(~e)return e;var n=this.getText(),r=this.measureTargetText(t,n);return this.measureCache=r,r}measureTargetText(t,e){if(!e.length)return 0;var{parent:n}=this,r=n.getStyle("font-family").getDefinition();if(r){for(var i=this.getFontSize(),A=r.isRTL?e.split("").reverse().join(""):e,s=i5(n.getAttribute("dx").getString()),a=A.length,o=0,l=0;l<a;l++){o+=(this.getGlyph(r,A,l).horizAdvX||r.horizAdvX)*i/r.fontFace.unitsPerEm,void 0===s[l]||isNaN(s[l])||(o+=s[l])}return o}if(!t.measureText)return 10*e.length;t.save(),this.setContext(t,!0);var{width:c}=t.measureText(e);return this.clearContext(t),t.restore(),c}getInheritedAttribute(t){for(var e=this;e instanceof i4&&e.isFirstChild();){var n=e.parent.getAttribute(t);if(n.hasValue(!0))return n.getValue("0");e=e.parent}return null}}class A4 extends i4{constructor(t,e,n){super(t,e,new.target===A4||n),this.type="tspan",this.text=this.children.length>0?"":this.getTextFromNode()}getText(){return this.text}}class s4 extends A4{constructor(){super(...arguments),this.type="textNode"}}let a4=class extends e4{constructor(){super(...arguments),this.type="svg",this.root=!1}setContext(t){var e,{document:n}=this,{screen:r,window:i}=n,A=t.canvas;if(r.setDefaults(t),A.style&&void 0!==t.font&&i&&void 0!==i.getComputedStyle){t.font=i.getComputedStyle(A).getPropertyValue("font");var s=new L5(n,"fontSize",J5.parse(t.font).fontSize);s.hasValue()&&(n.rootEmSize=s.getPixels("y"),n.emSize=n.rootEmSize)}this.getAttribute("x").hasValue()||this.getAttribute("x",!0).setValue(0),this.getAttribute("y").hasValue()||this.getAttribute("y",!0).setValue(0);var{width:a,height:o}=r.viewPort;this.getStyle("width").hasValue()||this.getStyle("width",!0).setValue("100%"),this.getStyle("height").hasValue()||this.getStyle("height",!0).setValue("100%"),this.getStyle("color").hasValue()||this.getStyle("color",!0).setValue("black");var l=this.getAttribute("refX"),c=this.getAttribute("refY"),h=this.getAttribute("viewBox"),u=h.hasValue()?i5(h.getString()):null,d=!this.root&&"visible"!==this.getStyle("overflow").getValue("hidden"),f=0,p=0,g=0,m=0;u&&(f=u[0],p=u[1]),this.root||(a=this.getStyle("width").getPixels("x"),o=this.getStyle("height").getPixels("y"),"marker"===this.type&&(g=f,m=p,f=0,p=0)),r.viewPort.setCurrent(a,o),!this.node||this.parent&&"foreignObject"!==(null===(e=this.node.parentNode)||void 0===e?void 0:e.nodeName)||!this.getStyle("transform",!1,!0).hasValue()||this.getStyle("transform-origin",!1,!0).hasValue()||this.getStyle("transform-origin",!0,!0).setValue("50% 50%"),super.setContext(t),t.translate(this.getAttribute("x").getPixels("x"),this.getAttribute("y").getPixels("y")),u&&(a=u[2],o=u[3]),n.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:r.viewPort.width,desiredWidth:a,height:r.viewPort.height,desiredHeight:o,minX:f,minY:p,refX:l.getValue(),refY:c.getValue(),clip:d,clipX:g,clipY:m}),u&&(r.viewPort.removeCurrent(),r.viewPort.setCurrent(a,o))}clearContext(t){super.clearContext(t),this.document.screen.viewPort.removeCurrent()}resize(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.getAttribute("width",!0),i=this.getAttribute("height",!0),A=this.getAttribute("viewBox"),s=this.getAttribute("style"),a=r.getNumber(0),o=i.getNumber(0);if(n)if("string"==typeof n)this.getAttribute("preserveAspectRatio",!0).setValue(n);else{var l=this.getAttribute("preserveAspectRatio");l.hasValue()&&l.setValue(l.getString().replace(/^\s*(\S.*\S)\s*$/,"$1"))}if(r.setValue(t),i.setValue(e),A.hasValue()||A.setValue("0 0 ".concat(a||t," ").concat(o||e)),s.hasValue()){var c=this.getStyle("width"),h=this.getStyle("height");c.hasValue()&&c.setValue("".concat(t,"px")),h.hasValue()&&h.setValue("".concat(e,"px"))}}};class o4 extends n4{constructor(){super(...arguments),this.type="rect"}path(t){var e=this.getAttribute("x").getPixels("x"),n=this.getAttribute("y").getPixels("y"),r=this.getStyle("width",!1,!0).getPixels("x"),i=this.getStyle("height",!1,!0).getPixels("y"),A=this.getAttribute("rx"),s=this.getAttribute("ry"),a=A.getPixels("x"),o=s.getPixels("y");if(A.hasValue()&&!s.hasValue()&&(o=a),s.hasValue()&&!A.hasValue()&&(a=o),a=Math.min(a,r/2),o=Math.min(o,i/2),t){var l=(Math.sqrt(2)-1)/3*4;t.beginPath(),i>0&&r>0&&(t.moveTo(e+a,n),t.lineTo(e+r-a,n),t.bezierCurveTo(e+r-a+l*a,n,e+r,n+o-l*o,e+r,n+o),t.lineTo(e+r,n+i-o),t.bezierCurveTo(e+r,n+i-o+l*o,e+r-a+l*a,n+i,e+r-a,n+i),t.lineTo(e+a,n+i),t.bezierCurveTo(e+a-l*a,n+i,e,n+i-o+l*o,e,n+i-o),t.lineTo(e,n+o),t.bezierCurveTo(e,n+o-l*o,e+a-l*a,n,e+a,n),t.closePath())}return new Z5(e,n,e+r,n+i)}getMarkers(){return null}}class l4 extends n4{constructor(){super(...arguments),this.type="circle"}path(t){var e=this.getAttribute("cx").getPixels("x"),n=this.getAttribute("cy").getPixels("y"),r=this.getAttribute("r").getPixels();return t&&r>0&&(t.beginPath(),t.arc(e,n,r,0,2*Math.PI,!1),t.closePath()),new Z5(e-r,n-r,e+r,n+r)}getMarkers(){return null}}class c4 extends n4{constructor(){super(...arguments),this.type="ellipse"}path(t){var e=(Math.sqrt(2)-1)/3*4,n=this.getAttribute("rx").getPixels("x"),r=this.getAttribute("ry").getPixels("y"),i=this.getAttribute("cx").getPixels("x"),A=this.getAttribute("cy").getPixels("y");return t&&n>0&&r>0&&(t.beginPath(),t.moveTo(i+n,A),t.bezierCurveTo(i+n,A+e*r,i+e*n,A+r,i,A+r),t.bezierCurveTo(i-e*n,A+r,i-n,A+e*r,i-n,A),t.bezierCurveTo(i-n,A-e*r,i-e*n,A-r,i,A-r),t.bezierCurveTo(i+e*n,A-r,i+n,A-e*r,i+n,A),t.closePath()),new Z5(i-n,A-r,i+n,A+r)}getMarkers(){return null}}class h4 extends n4{constructor(){super(...arguments),this.type="line"}getPoints(){return[new I5(this.getAttribute("x1").getPixels("x"),this.getAttribute("y1").getPixels("y")),new I5(this.getAttribute("x2").getPixels("x"),this.getAttribute("y2").getPixels("y"))]}path(t){var[{x:e,y:n},{x:r,y:i}]=this.getPoints();return t&&(t.beginPath(),t.moveTo(e,n),t.lineTo(r,i)),new Z5(e,n,r,i)}getMarkers(){var[t,e]=this.getPoints(),n=t.angleTo(e);return[[t,n],[e,n]]}}class u4 extends n4{constructor(t,e,n){super(t,e,n),this.type="polyline",this.points=[],this.points=I5.parsePath(this.getAttribute("points").getString())}path(t){var{points:e}=this,[{x:n,y:r}]=e,i=new Z5(n,r);return t&&(t.beginPath(),t.moveTo(n,r)),e.forEach(e=>{var{x:n,y:r}=e;i.addPoint(n,r),t&&t.lineTo(n,r)}),i}getMarkers(){var{points:t}=this,e=t.length-1,n=[];return t.forEach((r,i)=>{i!==e&&n.push([r,r.angleTo(t[i+1])])}),n.length>0&&n.push([t[t.length-1],n[n.length-1][1]]),n}}class d4 extends u4{constructor(){super(...arguments),this.type="polygon"}path(t){var e=super.path(t),[{x:n,y:r}]=this.points;return t&&(t.lineTo(n,r),t.closePath()),e}}class f4 extends z5{constructor(){super(...arguments),this.type="pattern"}createPattern(t,e,n){var r=this.getStyle("width").getPixels("x",!0),i=this.getStyle("height").getPixels("y",!0),A=new a4(this.document,null);A.attributes.viewBox=new L5(this.document,"viewBox",this.getAttribute("viewBox").getValue()),A.attributes.width=new L5(this.document,"width","".concat(r,"px")),A.attributes.height=new L5(this.document,"height","".concat(i,"px")),A.attributes.transform=new L5(this.document,"transform",this.getAttribute("patternTransform").getValue()),A.children=this.children;var s=this.document.createCanvas(r,i),a=s.getContext("2d"),o=this.getAttribute("x"),l=this.getAttribute("y");o.hasValue()&&l.hasValue()&&a.translate(o.getPixels("x",!0),l.getPixels("y",!0)),n.hasValue()?this.styles["fill-opacity"]=n:Reflect.deleteProperty(this.styles,"fill-opacity");for(var c=-1;c<=1;c++)for(var h=-1;h<=1;h++)a.save(),A.attributes.x=new L5(this.document,"x",c*s.width),A.attributes.y=new L5(this.document,"y",h*s.height),A.render(a),a.restore();return t.createPattern(s,"repeat")}}class p4 extends z5{constructor(){super(...arguments),this.type="marker"}render(t,e,n){if(e){var{x:r,y:i}=e,A=this.getAttribute("orient").getString("auto"),s=this.getAttribute("markerUnits").getString("strokeWidth");t.translate(r,i),"auto"===A&&t.rotate(n),"strokeWidth"===s&&t.scale(t.lineWidth,t.lineWidth),t.save();var a=new a4(this.document,null);a.type=this.type,a.attributes.viewBox=new L5(this.document,"viewBox",this.getAttribute("viewBox").getValue()),a.attributes.refX=new L5(this.document,"refX",this.getAttribute("refX").getValue()),a.attributes.refY=new L5(this.document,"refY",this.getAttribute("refY").getValue()),a.attributes.width=new L5(this.document,"width",this.getAttribute("markerWidth").getValue()),a.attributes.height=new L5(this.document,"height",this.getAttribute("markerHeight").getValue()),a.attributes.overflow=new L5(this.document,"overflow",this.getAttribute("overflow").getValue()),a.attributes.fill=new L5(this.document,"fill",this.getAttribute("fill").getColor("black")),a.attributes.stroke=new L5(this.document,"stroke",this.getAttribute("stroke").getValue("none")),a.children=this.children,a.render(t),t.restore(),"strokeWidth"===s&&t.scale(1/t.lineWidth,1/t.lineWidth),"auto"===A&&t.rotate(-n),t.translate(-r,-i)}}}class g4 extends z5{constructor(){super(...arguments),this.type="defs"}render(){}}class m4 extends e4{constructor(){super(...arguments),this.type="g"}getBoundingBox(t){var e=new Z5;return this.children.forEach(n=>{e.addBoundingBox(n.getBoundingBox(t))}),e}}class w4 extends z5{constructor(t,e,n){super(t,e,n),this.attributesToInherit=["gradientUnits"],this.stops=[];var{stops:r,children:i}=this;i.forEach(t=>{"stop"===t.type&&r.push(t)})}getGradientUnits(){return this.getAttribute("gradientUnits").getString("objectBoundingBox")}createGradient(t,e,n){var r=this;this.getHrefAttribute().hasValue()&&(r=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(r));var{stops:i}=r,A=this.getGradient(t,e);if(!A)return this.addParentOpacity(n,i[i.length-1].color);if(i.forEach(t=>{A.addColorStop(t.offset,this.addParentOpacity(n,t.color))}),this.getAttribute("gradientTransform").hasValue()){var{document:s}=this,{MAX_VIRTUAL_PIXELS:a,viewPort:o}=s.screen,[l]=o.viewPorts,c=new o4(s,null);c.attributes.x=new L5(s,"x",-a/3),c.attributes.y=new L5(s,"y",-a/3),c.attributes.width=new L5(s,"width",a),c.attributes.height=new L5(s,"height",a);var h=new m4(s,null);h.attributes.transform=new L5(s,"transform",this.getAttribute("gradientTransform").getValue()),h.children=[c];var u=new a4(s,null);u.attributes.x=new L5(s,"x",0),u.attributes.y=new L5(s,"y",0),u.attributes.width=new L5(s,"width",l.width),u.attributes.height=new L5(s,"height",l.height),u.children=[h];var d=s.createCanvas(l.width,l.height),f=d.getContext("2d");return f.fillStyle=A,u.render(f),f.createPattern(d,"no-repeat")}return A}inheritStopContainer(t){this.attributesToInherit.forEach(e=>{!this.getAttribute(e).hasValue()&&t.getAttribute(e).hasValue()&&this.getAttribute(e,!0).setValue(t.getAttribute(e).getValue())})}addParentOpacity(t,e){return t.hasValue()?new L5(this.document,"color",e).addOpacity(t).getColor():e}}class v4 extends w4{constructor(t,e,n){super(t,e,n),this.type="linearGradient",this.attributesToInherit.push("x1","y1","x2","y2")}getGradient(t,e){var n="objectBoundingBox"===this.getGradientUnits(),r=n?e.getBoundingBox(t):null;if(n&&!r)return null;this.getAttribute("x1").hasValue()||this.getAttribute("y1").hasValue()||this.getAttribute("x2").hasValue()||this.getAttribute("y2").hasValue()||(this.getAttribute("x1",!0).setValue(0),this.getAttribute("y1",!0).setValue(0),this.getAttribute("x2",!0).setValue(1),this.getAttribute("y2",!0).setValue(0));var i=n?r.x+r.width*this.getAttribute("x1").getNumber():this.getAttribute("x1").getPixels("x"),A=n?r.y+r.height*this.getAttribute("y1").getNumber():this.getAttribute("y1").getPixels("y"),s=n?r.x+r.width*this.getAttribute("x2").getNumber():this.getAttribute("x2").getPixels("x"),a=n?r.y+r.height*this.getAttribute("y2").getNumber():this.getAttribute("y2").getPixels("y");return i===s&&A===a?null:t.createLinearGradient(i,A,s,a)}}class y4 extends w4{constructor(t,e,n){super(t,e,n),this.type="radialGradient",this.attributesToInherit.push("cx","cy","r","fx","fy","fr")}getGradient(t,e){var n="objectBoundingBox"===this.getGradientUnits(),r=e.getBoundingBox(t);if(n&&!r)return null;this.getAttribute("cx").hasValue()||this.getAttribute("cx",!0).setValue("50%"),this.getAttribute("cy").hasValue()||this.getAttribute("cy",!0).setValue("50%"),this.getAttribute("r").hasValue()||this.getAttribute("r",!0).setValue("50%");var i=n?r.x+r.width*this.getAttribute("cx").getNumber():this.getAttribute("cx").getPixels("x"),A=n?r.y+r.height*this.getAttribute("cy").getNumber():this.getAttribute("cy").getPixels("y"),s=i,a=A;this.getAttribute("fx").hasValue()&&(s=n?r.x+r.width*this.getAttribute("fx").getNumber():this.getAttribute("fx").getPixels("x")),this.getAttribute("fy").hasValue()&&(a=n?r.y+r.height*this.getAttribute("fy").getNumber():this.getAttribute("fy").getPixels("y"));var o=n?(r.width+r.height)/2*this.getAttribute("r").getNumber():this.getAttribute("r").getPixels(),l=this.getAttribute("fr").getPixels();return t.createRadialGradient(s,a,l,i,A,o)}}class b4 extends z5{constructor(t,e,n){super(t,e,n),this.type="stop";var r=Math.max(0,Math.min(1,this.getAttribute("offset").getNumber())),i=this.getStyle("stop-opacity"),A=this.getStyle("stop-color",!0);""===A.getString()&&A.setValue("#000"),i.hasValue()&&(A=A.addOpacity(i)),this.offset=r,this.color=A.getColor()}}class B4 extends z5{constructor(t,e,n){super(t,e,n),this.type="animate",this.duration=0,this.initialValue=null,this.initialUnits="",this.removed=!1,this.frozen=!1,t.screen.animations.push(this),this.begin=this.getAttribute("begin").getMilliseconds(),this.maxDuration=this.begin+this.getAttribute("dur").getMilliseconds(),this.from=this.getAttribute("from"),this.to=this.getAttribute("to"),this.values=new L5(t,"values",null);var r=this.getAttribute("values");r.hasValue()&&this.values.setValue(r.getString().split(";"))}getProperty(){var t=this.getAttribute("attributeType").getString(),e=this.getAttribute("attributeName").getString();return"CSS"===t?this.parent.getStyle(e,!0):this.parent.getAttribute(e,!0)}calcValue(){var{initialUnits:t}=this,{progress:e,from:n,to:r}=this.getProgress(),i=n.getNumber()+(r.getNumber()-n.getNumber())*e;return"%"===t&&(i*=100),"".concat(i).concat(t)}update(t){var{parent:e}=this,n=this.getProperty();if(this.initialValue||(this.initialValue=n.getString(),this.initialUnits=n.getUnits()),this.duration>this.maxDuration){var r=this.getAttribute("fill").getString("remove");if("indefinite"===this.getAttribute("repeatCount").getString()||"indefinite"===this.getAttribute("repeatDur").getString())this.duration=0;else if("freeze"!==r||this.frozen){if("remove"===r&&!this.removed)return this.removed=!0,n.setValue(e.animationFrozen?e.animationFrozenValue:this.initialValue),!0}else this.frozen=!0,e.animationFrozen=!0,e.animationFrozenValue=n.getString();return!1}this.duration+=t;var i=!1;if(this.begin<this.duration){var A=this.calcValue(),s=this.getAttribute("type");if(s.hasValue()){var a=s.getString();A="".concat(a,"(").concat(A,")")}n.setValue(A),i=!0}return i}getProgress(){var{document:t,values:e}=this,n={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};if(e.hasValue()){var r=n.progress*(e.getValue().length-1),i=Math.floor(r),A=Math.ceil(r);n.from=new L5(t,"from",parseFloat(e.getValue()[i])),n.to=new L5(t,"to",parseFloat(e.getValue()[A])),n.progress=(r-i)/(A-i)}else n.from=this.from,n.to=this.to;return n}}class _4 extends B4{constructor(){super(...arguments),this.type="animateColor"}calcValue(){var{progress:t,from:e,to:n}=this.getProgress(),r=new e2(e.getColor()),i=new e2(n.getColor());if(r.ok&&i.ok){var A=r.r+(i.r-r.r)*t,s=r.g+(i.g-r.g)*t,a=r.b+(i.b-r.b)*t;return"rgb(".concat(Math.floor(A),", ").concat(Math.floor(s),", ").concat(Math.floor(a),")")}return this.getAttribute("from").getColor()}}class C4 extends B4{constructor(){super(...arguments),this.type="animateTransform"}calcValue(){var{progress:t,from:e,to:n}=this.getProgress(),r=i5(e.getString()),i=i5(n.getString());return r.map((e,n)=>e+(i[n]-e)*t).join(" ")}}class x4 extends z5{constructor(t,e,n){super(t,e,n),this.type="font",this.glyphs=Object.create(null),this.horizAdvX=this.getAttribute("horiz-adv-x").getNumber();var{definitions:r}=t,{children:i}=this;for(var A of i)switch(A.type){case"font-face":this.fontFace=A;var s=A.getStyle("font-family");s.hasValue()&&(r[s.getString()]=this);break;case"missing-glyph":this.missingGlyph=A;break;case"glyph":var a=A;a.arabicForm?(this.isRTL=!0,this.isArabic=!0,void 0===this.glyphs[a.unicode]&&(this.glyphs[a.unicode]=Object.create(null)),this.glyphs[a.unicode][a.arabicForm]=a):this.glyphs[a.unicode]=a}}render(){}}class E4 extends z5{constructor(t,e,n){super(t,e,n),this.type="font-face",this.ascent=this.getAttribute("ascent").getNumber(),this.descent=this.getAttribute("descent").getNumber(),this.unitsPerEm=this.getAttribute("units-per-em").getNumber()}}class S4 extends n4{constructor(){super(...arguments),this.type="missing-glyph",this.horizAdvX=0}}class F4 extends i4{constructor(){super(...arguments),this.type="tref"}getText(){var t=this.getHrefAttribute().getDefinition();if(t){var e=t.children[0];if(e)return e.getText()}return""}}class L4 extends i4{constructor(t,e,n){super(t,e,n),this.type="a";var{childNodes:r}=e,i=r[0],A=r.length>0&&Array.from(r).every(t=>3===t.nodeType);this.hasText=A,this.text=A?this.getTextFromNode(i):""}getText(){return this.text}renderChildren(t){if(this.hasText){super.renderChildren(t);var{document:e,x:n,y:r}=this,{mouse:i}=e.screen,A=new L5(e,"fontSize",J5.parse(e.ctx.font).fontSize);i.isWorking()&&i.checkBoundingBox(this,new Z5(n,r-A.getPixels("y"),n+this.measureText(t),r))}else if(this.children.length>0){var s=new m4(this.document,null);s.children=this.children,s.parent=this,s.render(t)}}onClick(){var{window:t}=this.document;t&&t.open(this.getHrefAttribute().getString())}onMouseMove(){this.document.ctx.canvas.style.cursor="pointer"}}function U4(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function I4(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?U4(Object(n),!0).forEach(function(e){T0(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U4(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}class Q4 extends i4{constructor(t,e,n){super(t,e,n),this.type="textPath",this.textWidth=0,this.textHeight=0,this.pathLength=-1,this.glyphInfo=null,this.letterSpacingCache=[],this.measuresCache=new Map([["",0]]);var r=this.getHrefAttribute().getDefinition();this.text=this.getTextFromNode(),this.dataArray=this.parsePathData(r)}getText(){return this.text}path(t){var{dataArray:e}=this;t&&t.beginPath(),e.forEach(e=>{var{type:n,points:r}=e;switch(n){case t4.LINE_TO:t&&t.lineTo(r[0],r[1]);break;case t4.MOVE_TO:t&&t.moveTo(r[0],r[1]);break;case t4.CURVE_TO:t&&t.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case t4.QUAD_TO:t&&t.quadraticCurveTo(r[0],r[1],r[2],r[3]);break;case t4.ARC:var[i,A,s,a,o,l,c,h]=r,u=s>a?s:a,d=s>a?1:s/a,f=s>a?a/s:1;t&&(t.translate(i,A),t.rotate(c),t.scale(d,f),t.arc(0,0,u,o,o+l,Boolean(1-h)),t.scale(1/d,1/f),t.rotate(-c),t.translate(-i,-A));break;case t4.CLOSE_PATH:t&&t.closePath()}})}renderChildren(t){this.setTextData(t),t.save();var e=this.parent.getStyle("text-decoration").getString(),n=this.getFontSize(),{glyphInfo:r}=this,i=t.fillStyle;"underline"===e&&t.beginPath(),r.forEach((r,i)=>{var{p0:A,p1:s,rotation:a,text:o}=r;t.save(),t.translate(A.x,A.y),t.rotate(a),t.fillStyle&&t.fillText(o,0,0),t.strokeStyle&&t.strokeText(o,0,0),t.restore(),"underline"===e&&(0===i&&t.moveTo(A.x,A.y+n/8),t.lineTo(s.x,s.y+n/5))}),"underline"===e&&(t.lineWidth=n/20,t.strokeStyle=i,t.stroke(),t.closePath()),t.restore()}getLetterSpacingAt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.letterSpacingCache[t]||0}findSegmentToFitChar(t,e,n,r,i,A,s,a,o){var l=A,c=this.measureText(t,a);" "===a&&"justify"===e&&n<r&&(c+=(r-n)/i),o>-1&&(l+=this.getLetterSpacingAt(o));var h=this.textHeight/20,u=this.getEquidistantPointOnPath(l,h,0),d=this.getEquidistantPointOnPath(l+c,h,0),f={p0:u,p1:d},p=u&&d?Math.atan2(d.y-u.y,d.x-u.x):0;if(s){var g=Math.cos(Math.PI/2+p)*s,m=Math.cos(-p)*s;f.p0=I4(I4({},u),{},{x:u.x+g,y:u.y+m}),f.p1=I4(I4({},d),{},{x:d.x+g,y:d.y+m})}return{offset:l+=c,segment:f,rotation:p}}measureText(t,e){var{measuresCache:n}=this,r=e||this.getText();if(n.has(r))return n.get(r);var i=this.measureTargetText(t,r);return n.set(r,i),i}setTextData(t){if(!this.glyphInfo){var e=this.getText(),n=e.split(""),r=e.split(" ").length-1,i=this.parent.getAttribute("dx").split().map(t=>t.getPixels("x")),A=this.parent.getAttribute("dy").getPixels("y"),s=this.parent.getStyle("text-anchor").getString("start"),a=this.getStyle("letter-spacing"),o=this.parent.getStyle("letter-spacing"),l=0;a.hasValue()&&"inherit"!==a.getValue()?a.hasValue()&&"initial"!==a.getValue()&&"unset"!==a.getValue()&&(l=a.getPixels()):l=o.getPixels();var c=[],h=e.length;this.letterSpacingCache=c;for(var u=0;u<h;u++)c.push(void 0!==i[u]?i[u]:l);var d=c.reduce((t,e,n)=>0===n?0:t+e||0,0),f=this.measureText(t),p=Math.max(f+d,0);this.textWidth=f,this.textHeight=this.getFontSize(),this.glyphInfo=[];var g=this.getPathLength(),m=this.getStyle("startOffset").getNumber(0)*g,w=0;"middle"!==s&&"center"!==s||(w=-p/2),"end"!==s&&"right"!==s||(w=-p),w+=m,n.forEach((e,i)=>{var{offset:a,segment:o,rotation:l}=this.findSegmentToFitChar(t,s,p,g,r,w,A,e,i);w=a,o.p0&&o.p1&&this.glyphInfo.push({text:n[i],p0:o.p0,p1:o.p1,rotation:l})})}}parsePathData(t){if(this.pathLength=-1,!t)return[];var e=[],{pathParser:n}=t;for(n.reset();!n.isEnd();){var{current:r}=n,i=r?r.x:0,A=r?r.y:0,s=n.next(),a=s.type,o=[];switch(s.type){case t4.MOVE_TO:this.pathM(n,o);break;case t4.LINE_TO:a=this.pathL(n,o);break;case t4.HORIZ_LINE_TO:a=this.pathH(n,o);break;case t4.VERT_LINE_TO:a=this.pathV(n,o);break;case t4.CURVE_TO:this.pathC(n,o);break;case t4.SMOOTH_CURVE_TO:a=this.pathS(n,o);break;case t4.QUAD_TO:this.pathQ(n,o);break;case t4.SMOOTH_QUAD_TO:a=this.pathT(n,o);break;case t4.ARC:o=this.pathA(n);break;case t4.CLOSE_PATH:n4.pathZ(n)}s.type!==t4.CLOSE_PATH?e.push({type:a,points:o,start:{x:i,y:A},pathLength:this.calcLength(i,A,a,o)}):e.push({type:t4.CLOSE_PATH,points:[],pathLength:0})}return e}pathM(t,e){var{x:n,y:r}=n4.pathM(t).point;e.push(n,r)}pathL(t,e){var{x:n,y:r}=n4.pathL(t).point;return e.push(n,r),t4.LINE_TO}pathH(t,e){var{x:n,y:r}=n4.pathH(t).point;return e.push(n,r),t4.LINE_TO}pathV(t,e){var{x:n,y:r}=n4.pathV(t).point;return e.push(n,r),t4.LINE_TO}pathC(t,e){var{point:n,controlPoint:r,currentPoint:i}=n4.pathC(t);e.push(n.x,n.y,r.x,r.y,i.x,i.y)}pathS(t,e){var{point:n,controlPoint:r,currentPoint:i}=n4.pathS(t);return e.push(n.x,n.y,r.x,r.y,i.x,i.y),t4.CURVE_TO}pathQ(t,e){var{controlPoint:n,currentPoint:r}=n4.pathQ(t);e.push(n.x,n.y,r.x,r.y)}pathT(t,e){var{controlPoint:n,currentPoint:r}=n4.pathT(t);return e.push(n.x,n.y,r.x,r.y),t4.QUAD_TO}pathA(t){var{rX:e,rY:n,sweepFlag:r,xAxisRotation:i,centp:A,a1:s,ad:a}=n4.pathA(t);return 0===r&&a>0&&(a-=2*Math.PI),1===r&&a<0&&(a+=2*Math.PI),[A.x,A.y,e,n,s,a,i,r]}calcLength(t,e,n,r){var i=0,A=null,s=null,a=0;switch(n){case t4.LINE_TO:return this.getLineLength(t,e,r[0],r[1]);case t4.CURVE_TO:for(i=0,A=this.getPointOnCubicBezier(0,t,e,r[0],r[1],r[2],r[3],r[4],r[5]),a=.01;a<=1;a+=.01)s=this.getPointOnCubicBezier(a,t,e,r[0],r[1],r[2],r[3],r[4],r[5]),i+=this.getLineLength(A.x,A.y,s.x,s.y),A=s;return i;case t4.QUAD_TO:for(i=0,A=this.getPointOnQuadraticBezier(0,t,e,r[0],r[1],r[2],r[3]),a=.01;a<=1;a+=.01)s=this.getPointOnQuadraticBezier(a,t,e,r[0],r[1],r[2],r[3]),i+=this.getLineLength(A.x,A.y,s.x,s.y),A=s;return i;case t4.ARC:i=0;var o=r[4],l=r[5],c=r[4]+l,h=Math.PI/180;if(Math.abs(o-c)<h&&(h=Math.abs(o-c)),A=this.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],o,0),l<0)for(a=o-h;a>c;a-=h)s=this.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],a,0),i+=this.getLineLength(A.x,A.y,s.x,s.y),A=s;else for(a=o+h;a<c;a+=h)s=this.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],a,0),i+=this.getLineLength(A.x,A.y,s.x,s.y),A=s;return s=this.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),i+=this.getLineLength(A.x,A.y,s.x,s.y)}return 0}getPointOnLine(t,e,n,r,i){var A=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:n,a=(i-n)/(r-e+w5),o=Math.sqrt(t*t/(1+a*a));r<e&&(o*=-1);var l=a*o,c=null;if(r===e)c={x:A,y:s+l};else if((s-n)/(A-e+w5)===a)c={x:A+o,y:s+l};else{var h,u,d=this.getLineLength(e,n,r,i);if(d<w5)return null;var f=(A-e)*(r-e)+(s-n)*(i-n);h=e+(f/=d*d)*(r-e),u=n+f*(i-n);var p=this.getLineLength(A,s,h,u),g=Math.sqrt(t*t-p*p);o=Math.sqrt(g*g/(1+a*a)),r<e&&(o*=-1),c={x:h+o,y:u+(l=a*o)}}return c}getPointOnPath(t){var e=this.getPathLength(),n=0,r=null;if(t<-5e-5||t-5e-5>e)return null;var{dataArray:i}=this;for(var A of i){if(!A||!(A.pathLength<5e-5||n+A.pathLength+5e-5<t)){var s=t-n,a=0;switch(A.type){case t4.LINE_TO:r=this.getPointOnLine(s,A.start.x,A.start.y,A.points[0],A.points[1],A.start.x,A.start.y);break;case t4.ARC:var o=A.points[4],l=A.points[5],c=A.points[4]+l;if(a=o+s/A.pathLength*l,l<0&&a<c||l>=0&&a>c)break;r=this.getPointOnEllipticalArc(A.points[0],A.points[1],A.points[2],A.points[3],a,A.points[6]);break;case t4.CURVE_TO:(a=s/A.pathLength)>1&&(a=1),r=this.getPointOnCubicBezier(a,A.start.x,A.start.y,A.points[0],A.points[1],A.points[2],A.points[3],A.points[4],A.points[5]);break;case t4.QUAD_TO:(a=s/A.pathLength)>1&&(a=1),r=this.getPointOnQuadraticBezier(a,A.start.x,A.start.y,A.points[0],A.points[1],A.points[2],A.points[3])}if(r)return r;break}n+=A.pathLength}return null}getLineLength(t,e,n,r){return Math.sqrt((n-t)*(n-t)+(r-e)*(r-e))}getPathLength(){return-1===this.pathLength&&(this.pathLength=this.dataArray.reduce((t,e)=>e.pathLength>0?t+e.pathLength:t,0)),this.pathLength}getPointOnCubicBezier(t,e,n,r,i,A,s,a,o){return{x:a*B5(t)+A*_5(t)+r*C5(t)+e*x5(t),y:o*B5(t)+s*_5(t)+i*C5(t)+n*x5(t)}}getPointOnQuadraticBezier(t,e,n,r,i,A,s){return{x:A*E5(t)+r*S5(t)+e*F5(t),y:s*E5(t)+i*S5(t)+n*F5(t)}}getPointOnEllipticalArc(t,e,n,r,i,A){var s=Math.cos(A),a=Math.sin(A),o=n*Math.cos(i),l=r*Math.sin(i);return{x:t+(o*s-l*a),y:e+(o*a+l*s)}}buildEquidistantCache(t,e){var n=this.getPathLength(),r=e||.25,i=t||n/100;if(!this.equidistantCache||this.equidistantCache.step!==i||this.equidistantCache.precision!==r){this.equidistantCache={step:i,precision:r,points:[]};for(var A=0,s=0;s<=n;s+=r){var a=this.getPointOnPath(s),o=this.getPointOnPath(s+r);a&&o&&((A+=this.getLineLength(a.x,a.y,o.x,o.y))>=i&&(this.equidistantCache.points.push({x:a.x,y:a.y,distance:s}),A-=i))}}}getEquidistantPointOnPath(t,e,n){if(this.buildEquidistantCache(e,n),t<0||t-this.getPathLength()>5e-5)return null;var r=Math.round(t/this.getPathLength()*(this.equidistantCache.points.length-1));return this.equidistantCache.points[r]||null}}var k4=/^\s*data:(([^/,;]+\/[^/,;]+)(?:;([^,;=]+=[^,;=]+))?)?(?:;(base64))?,(.*)$/i;class M4 extends e4{constructor(t,e,n){super(t,e,n),this.type="image",this.loaded=!1;var r=this.getHrefAttribute().getString();if(r){var i=r.endsWith(".svg")||/^\s*data:image\/svg\+xml/i.test(r);t.images.push(this),i?this.loadSvg(r):this.loadImage(r),this.isSvg=i}}loadImage(t){var e=this;return lY(function*(){try{var n=yield e.document.createImage(t);e.image=n}catch(r){console.error('Error while loading image "'.concat(t,'":'),r)}e.loaded=!0})()}loadSvg(t){var e=this;return lY(function*(){var n=k4.exec(t);if(n){var r=n[5];"base64"===n[4]?e.image=atob(r):e.image=decodeURIComponent(r)}else try{var i=yield e.document.fetch(t),A=yield i.text();e.image=A}catch(s){console.error('Error while loading image "'.concat(t,'":'),s)}e.loaded=!0})()}renderChildren(t){var{document:e,image:n,loaded:r}=this,i=this.getAttribute("x").getPixels("x"),A=this.getAttribute("y").getPixels("y"),s=this.getStyle("width").getPixels("x"),a=this.getStyle("height").getPixels("y");if(r&&n&&s&&a){if(t.save(),t.translate(i,A),this.isSvg){var o=e.canvg.forkString(t,this.image,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:0,offsetY:0,scaleWidth:s,scaleHeight:a});o.document.documentElement.parent=this,o.render()}else{var l=this.image;e.setViewBox({ctx:t,aspectRatio:this.getAttribute("preserveAspectRatio").getString(),width:s,desiredWidth:l.width,height:a,desiredHeight:l.height}),this.loaded&&(void 0===l.complete||l.complete)&&t.drawImage(l,0,0)}t.restore()}}getBoundingBox(){var t=this.getAttribute("x").getPixels("x"),e=this.getAttribute("y").getPixels("y"),n=this.getStyle("width").getPixels("x"),r=this.getStyle("height").getPixels("y");return new Z5(t,e,t+n,e+r)}}class O4 extends e4{constructor(){super(...arguments),this.type="symbol"}render(t){}}class P4{constructor(t){this.document=t,this.loaded=!1,t.fonts.push(this)}load(t,e){var n=this;return lY(function*(){try{var{document:r}=n,i=(yield r.canvg.parser.load(e)).getElementsByTagName("font");Array.from(i).forEach(e=>{var n=r.createElement(e);r.definitions[t]=n})}catch(A){console.error('Error while loading font "'.concat(e,'":'),A)}n.loaded=!0})()}}class N4 extends z5{constructor(t,e,n){super(t,e,n),this.type="style",e5(Array.from(e.childNodes).map(t=>t.textContent).join("").replace(/(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"").replace(/@import.*;/g,"")).split("}").forEach(e=>{var n=e.trim();if(n){var r=n.split("{"),i=r[0].split(","),A=r[1].split(";");i.forEach(e=>{var n=e.trim();if(n){var r=t.styles[n]||{};if(A.forEach(e=>{var n=e.indexOf(":"),i=e.substr(0,n).trim(),A=e.substr(n+1,e.length-n).trim();i&&A&&(r[i]=new L5(t,i,A))}),t.styles[n]=r,t.stylesSpecificity[n]=m5(n),"@font-face"===n){var i=r["font-family"].getString().replace(/"|'/g,"");r.src.getString().split(",").forEach(e=>{if(e.indexOf('format("svg")')>0){var n=a5(e);n&&new P4(t).load(i,n)}})}}})}})}}N4.parseExternalUrl=a5;class T4 extends e4{constructor(){super(...arguments),this.type="use"}setContext(t){super.setContext(t);var e=this.getAttribute("x"),n=this.getAttribute("y");e.hasValue()&&t.translate(e.getPixels("x"),0),n.hasValue()&&t.translate(0,n.getPixels("y"))}path(t){var{element:e}=this;e&&e.path(t)}renderChildren(t){var{document:e,element:n}=this;if(n){var r=n;if("symbol"===n.type&&((r=new a4(e,null)).attributes.viewBox=new L5(e,"viewBox",n.getAttribute("viewBox").getString()),r.attributes.preserveAspectRatio=new L5(e,"preserveAspectRatio",n.getAttribute("preserveAspectRatio").getString()),r.attributes.overflow=new L5(e,"overflow",n.getAttribute("overflow").getString()),r.children=n.children,n.styles.opacity=new L5(e,"opacity",this.calculateOpacity())),"svg"===r.type){var i=this.getStyle("width",!1,!0),A=this.getStyle("height",!1,!0);i.hasValue()&&(r.attributes.width=new L5(e,"width",i.getString())),A.hasValue()&&(r.attributes.height=new L5(e,"height",A.getString()))}var s=r.parent;r.parent=this,r.render(t),r.parent=s}}getBoundingBox(t){var{element:e}=this;return e?e.getBoundingBox(t):null}elementTransform(){var{document:t,element:e}=this;return G5.fromElement(t,e)}get element(){return this.cachedElement||(this.cachedElement=this.getHrefAttribute().getDefinition()),this.cachedElement}}function D4(t,e,n,r,i,A){return t[n*r*4+4*e+A]}function R4(t,e,n,r,i,A,s){t[n*r*4+4*e+A]=s}function H4(t,e,n){return t[e]*n}function j4(t,e,n,r){return e+Math.cos(t)*n+Math.sin(t)*r}class W4 extends z5{constructor(t,e,n){super(t,e,n),this.type="feColorMatrix";var r=i5(this.getAttribute("values").getString());switch(this.getAttribute("type").getString("matrix")){case"saturate":var i=r[0];r=[.213+.787*i,.715-.715*i,.072-.072*i,0,0,.213-.213*i,.715+.285*i,.072-.072*i,0,0,.213-.213*i,.715-.715*i,.072+.928*i,0,0,0,0,0,1,0,0,0,0,0,1];break;case"hueRotate":var A=r[0]*Math.PI/180;r=[j4(A,.213,.787,-.213),j4(A,.715,-.715,-.715),j4(A,.072,-.072,.928),0,0,j4(A,.213,-.213,.143),j4(A,.715,.285,.14),j4(A,.072,-.072,-.283),0,0,j4(A,.213,-.213,-.787),j4(A,.715,-.715,.715),j4(A,.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break;case"luminanceToAlpha":r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}this.matrix=r,this.includeOpacity=this.getAttribute("includeOpacity").hasValue()}apply(t,e,n,r,i){for(var{includeOpacity:A,matrix:s}=this,a=t.getImageData(0,0,r,i),o=0;o<i;o++)for(var l=0;l<r;l++){var c=D4(a.data,l,o,r,0,0),h=D4(a.data,l,o,r,0,1),u=D4(a.data,l,o,r,0,2),d=D4(a.data,l,o,r,0,3),f=H4(s,0,c)+H4(s,1,h)+H4(s,2,u)+H4(s,3,d)+H4(s,4,1),p=H4(s,5,c)+H4(s,6,h)+H4(s,7,u)+H4(s,8,d)+H4(s,9,1),g=H4(s,10,c)+H4(s,11,h)+H4(s,12,u)+H4(s,13,d)+H4(s,14,1),m=H4(s,15,c)+H4(s,16,h)+H4(s,17,u)+H4(s,18,d)+H4(s,19,1);A&&(f=0,p=0,g=0,m*=d/255),R4(a.data,l,o,r,0,0,f),R4(a.data,l,o,r,0,1,p),R4(a.data,l,o,r,0,2,g),R4(a.data,l,o,r,0,3,m)}t.clearRect(0,0,r,i),t.putImageData(a,0,0)}}class V4 extends z5{constructor(){super(...arguments),this.type="mask"}apply(t,e){var{document:n}=this,r=this.getAttribute("x").getPixels("x"),i=this.getAttribute("y").getPixels("y"),A=this.getStyle("width").getPixels("x"),s=this.getStyle("height").getPixels("y");if(!A&&!s){var a=new Z5;this.children.forEach(e=>{a.addBoundingBox(e.getBoundingBox(t))}),r=Math.floor(a.x1),i=Math.floor(a.y1),A=Math.floor(a.width),s=Math.floor(a.height)}var o=this.removeStyles(e,V4.ignoreStyles),l=n.createCanvas(r+A,i+s),c=l.getContext("2d");n.screen.setDefaults(c),this.renderChildren(c),new W4(n,{nodeType:1,childNodes:[],attributes:[{nodeName:"type",value:"luminanceToAlpha"},{nodeName:"includeOpacity",value:"true"}]}).apply(c,0,0,r+A,i+s);var h=n.createCanvas(r+A,i+s),u=h.getContext("2d");n.screen.setDefaults(u),e.render(u),u.globalCompositeOperation="destination-in",u.fillStyle=c.createPattern(l,"no-repeat"),u.fillRect(0,0,r+A,i+s),t.fillStyle=u.createPattern(h,"no-repeat"),t.fillRect(0,0,r+A,i+s),this.restoreStyles(e,o)}render(t){}}V4.ignoreStyles=["mask","transform","clip-path"];var K4=()=>{};class G4 extends z5{constructor(){super(...arguments),this.type="clipPath"}apply(t){var{document:e}=this,n=Reflect.getPrototypeOf(t),{beginPath:r,closePath:i}=t;n&&(n.beginPath=K4,n.closePath=K4),Reflect.apply(r,t,[]),this.children.forEach(r=>{if(void 0!==r.path){var A=void 0!==r.elementTransform?r.elementTransform():null;A||(A=G5.fromElement(e,r)),A&&A.apply(t),r.path(t),n&&(n.closePath=i),A&&A.unapply(t)}}),Reflect.apply(i,t,[]),t.clip(),n&&(n.beginPath=r,n.closePath=i)}render(t){}}class z4 extends z5{constructor(){super(...arguments),this.type="filter"}apply(t,e){var{document:n,children:r}=this,i=e.getBoundingBox(t);if(i){var A=0,s=0;r.forEach(t=>{var e=t.extraFilterDistance||0;A=Math.max(A,e),s=Math.max(s,e)});var a=Math.floor(i.width),o=Math.floor(i.height),l=a+2*A,c=o+2*s;if(!(l<1||c<1)){var h=Math.floor(i.x),u=Math.floor(i.y),d=this.removeStyles(e,z4.ignoreStyles),f=n.createCanvas(l,c),p=f.getContext("2d");n.screen.setDefaults(p),p.translate(-h+A,-u+s),e.render(p),r.forEach(t=>{"function"==typeof t.apply&&t.apply(p,0,0,l,c)}),t.drawImage(f,0,0,l,c,h-A,u-s,l,c),this.restoreStyles(e,d)}}}render(t){}}z4.ignoreStyles=["filter","transform","clip-path"];class q4 extends z5{constructor(t,e,n){super(t,e,n),this.type="feDropShadow",this.addStylesFromStyleDefinition()}apply(t,e,n,r,i){}}class X4 extends z5{constructor(){super(...arguments),this.type="feMorphology"}apply(t,e,n,r,i){}}class Y4 extends z5{constructor(){super(...arguments),this.type="feComposite"}apply(t,e,n,r,i){}}class $4 extends z5{constructor(t,e,n){super(t,e,n),this.type="feGaussianBlur",this.blurRadius=Math.floor(this.getAttribute("stdDeviation").getNumber()),this.extraFilterDistance=this.blurRadius}apply(t,e,n,r,i){var{document:A,blurRadius:s}=this,a=A.window?A.window.document.body:null,o=t.canvas;o.id=A.getUniqueId(),a&&(o.style.display="none",a.appendChild(o)),J2(o,e,n,r,i,s),a&&a.removeChild(o)}}class J4 extends z5{constructor(){super(...arguments),this.type="title"}}class Z4 extends z5{constructor(){super(...arguments),this.type="desc"}}var t3={svg:a4,rect:o4,circle:l4,ellipse:c4,line:h4,polyline:u4,polygon:d4,path:n4,pattern:f4,marker:p4,defs:g4,linearGradient:v4,radialGradient:y4,stop:b4,animate:B4,animateColor:_4,animateTransform:C4,font:x4,"font-face":E4,"missing-glyph":S4,glyph:r4,text:i4,tspan:A4,tref:F4,a:L4,textPath:Q4,image:M4,g:m4,symbol:O4,style:N4,use:T4,mask:V4,clipPath:G4,filter:z4,feDropShadow:q4,feMorphology:X4,feComposite:Y4,feColorMatrix:W4,feGaussianBlur:$4,title:J4,desc:Z4};function e3(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function n3(){return n3=lY(function*(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=document.createElement("img");return e&&(n.crossOrigin="Anonymous"),new Promise((e,r)=>{n.onload=()=>{e(n)},n.onerror=(t,e,n,i,A)=>{r(A)},n.src=t})}),n3.apply(this,arguments)}class r3{constructor(t){var{rootEmSize:e=12,emSize:n=12,createCanvas:r=r3.createCanvas,createImage:i=r3.createImage,anonymousCrossOrigin:A}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.canvg=t,this.definitions=Object.create(null),this.styles=Object.create(null),this.stylesSpecificity=Object.create(null),this.images=[],this.fonts=[],this.emSizeStack=[],this.uniqueId=0,this.screen=t.screen,this.rootEmSize=e,this.emSize=n,this.createCanvas=r,this.createImage=this.bindCreateImage(i,A),this.screen.wait(this.isImagesLoaded.bind(this)),this.screen.wait(this.isFontsLoaded.bind(this))}bindCreateImage(t,e){return"boolean"==typeof e?(n,r)=>t(n,"boolean"==typeof r?r:e):t}get window(){return this.screen.window}get fetch(){return this.screen.fetch}get ctx(){return this.screen.ctx}get emSize(){var{emSizeStack:t}=this;return t[t.length-1]}set emSize(t){var{emSizeStack:e}=this;e.push(t)}popEmSize(){var{emSizeStack:t}=this;t.pop()}getUniqueId(){return"canvg".concat(++this.uniqueId)}isImagesLoaded(){return this.images.every(t=>t.loaded)}isFontsLoaded(){return this.fonts.every(t=>t.loaded)}createDocumentElement(t){var e=this.createElement(t.documentElement);return e.root=!0,e.addStylesFromStyleDefinition(),this.documentElement=e,e}createElement(t){var e=t.nodeName.replace(/^[^:]+:/,""),n=r3.elementTypes[e];return void 0!==n?new n(this,t):new q5(this,t)}createTextNode(t){return new s4(this,t)}setViewBox(t){this.screen.setViewBox(function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?e3(Object(n),!0).forEach(function(e){T0(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e3(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}({document:this},t))}}function i3(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function A3(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i3(Object(n),!0).forEach(function(e){T0(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i3(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}r3.createCanvas=function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n},r3.createImage=function(t){return n3.apply(this,arguments)},r3.elementTypes=t3;class s3{constructor(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.parser=new T5(n),this.screen=new O5(t,n),this.options=n;var r=new r3(this,n),i=r.createDocumentElement(e);this.document=r,this.documentElement=i}static from(t,e){var n=arguments;return lY(function*(){var r=n.length>2&&void 0!==n[2]?n[2]:{},i=new T5(r),A=yield i.parse(e);return new s3(t,A,r)})()}static fromString(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=new T5(n).parseFromString(e);return new s3(t,r,n)}fork(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s3.from(t,e,A3(A3({},this.options),n))}forkString(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return s3.fromString(t,e,A3(A3({},this.options),n))}ready(){return this.screen.ready()}isReady(){return this.screen.isReady()}render(){var t=arguments,e=this;return lY(function*(){var n=t.length>0&&void 0!==t[0]?t[0]:{};e.start(A3({enableRedraw:!0,ignoreAnimation:!0,ignoreMouse:!0},n)),yield e.ready(),e.stop()})()}start(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{documentElement:e,screen:n,options:r}=this;n.start(e,A3(A3({enableRedraw:!0},r),t))}stop(){this.screen.stop()}resize(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.documentElement.resize(t,e,n)}}const a3=Object.freeze(Object.defineProperty({__proto__:null,AElement:L4,AnimateColorElement:_4,AnimateElement:B4,AnimateTransformElement:C4,BoundingBox:Z5,CB1:B5,CB2:_5,CB3:C5,CB4:x5,Canvg:s3,CircleElement:l4,ClipPathElement:G4,DefsElement:g4,DescElement:Z4,Document:r3,Element:z5,EllipseElement:c4,FeColorMatrixElement:W4,FeCompositeElement:Y4,FeDropShadowElement:q4,FeGaussianBlurElement:$4,FeMorphologyElement:X4,FilterElement:z4,Font:J5,FontElement:x4,FontFaceElement:E4,GElement:m4,GlyphElement:r4,GradientElement:w4,ImageElement:M4,LineElement:h4,LinearGradientElement:v4,MarkerElement:p4,MaskElement:V4,Matrix:j5,MissingGlyphElement:S4,Mouse:Q5,PSEUDO_ZERO:w5,Parser:T5,PathElement:n4,PathParser:t4,PatternElement:f4,Point:I5,PolygonElement:d4,PolylineElement:u4,Property:L5,QB1:E5,QB2:S5,QB3:F5,RadialGradientElement:y4,RectElement:o4,RenderedElement:e4,Rotate:R5,SVGElement:a4,SVGFontLoader:P4,Scale:H5,Screen:O5,Skew:W5,SkewX:V5,SkewY:K5,StopElement:b4,StyleElement:N4,SymbolElement:O4,TRefElement:F4,TSpanElement:A4,TextElement:i4,TextPathElement:Q4,TitleElement:J4,Transform:G5,Translate:D5,UnknownElement:q5,UseElement:T4,ViewPort:U5,compressSpaces:e5,default:s3,getSelectorSpecificity:m5,normalizeAttributeName:s5,normalizeColor:o5,parseExternalUrl:a5,presets:t5,toNumbers:i5,trimLeft:n5,trimRight:r5,vectorMagnitude:v5,vectorsAngle:b5,vectorsRatio:y5},Symbol.toStringTag,{value:"Module"}));t.DEFAULT_LAMINATION_COLORS=MT,t.LABEL_TYPES={PART:"part",SCRAP:"scrap",THICKENED:"thickened",INPUT:"input",VOLUME:"volume"},t.LabelWorker=xF,t.LabelsAPI=jT,t.apiClient=null,t.base64Decode=t=>{if(Gc){const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}return Buffer.from(t,"base64")},t.base64Encode=t=>Gc?t instanceof Uint8Array?btoa(String.fromCharCode(...t)):btoa(t):Buffer.from(t).toString("base64"),t.checkPrinterAvailability=ET,t.convertPdfToImages=xT,t.convertSVGTableToAutoTableData=function(t){return{headers:["ID","Nome","Qtd","Dimensões"],rows:t.map(t=>[t.id,t.name,t.quantity,t.dimensions])}},t.createBrowserCanvas=(t,e)=>{if(!Gc)throw new Error("createBrowserCanvas can only be used in browser environment");const n=document.createElement("canvas");return n.width=t,n.height=e,n},t.createBrowserDOM=Xc,t.createBuffer=t=>Gc?"string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t):Buffer.from(t),t.createImage=(t,e)=>Wc(this,null,function*(){try{const n=e.getContext("2d"),r=$c(t),i=QT(r),A="data:image/svg+xml;base64,"+i,s=yield qc(A);return n.drawImage(s,0,0),e.toDataURL()}catch(o3){throw console.error("Erro ao criar imagem:",o3),o3}}),t.createImageFromPart=(t,e)=>Wc(this,null,function*(){try{const n=e.getContext("2d"),r=$c(t),i=QT(r),A="data:image/svg+xml;base64,"+i,s=yield qc(A),{ratio:a}=PT(s,e),o={height:s.height*a-2,width:s.width*a-2};let l=e.width/2-o.width/2,c=e.height/2-o.height/2;return n.save(),n.translate(l,c),n.drawImage(s,0,0,o.width,o.height),n.restore(),e.toDataURL()}catch(o3){throw console.error("Erro ao criar imagem da parte:",o3),o3}}),t.createLabelWorker=EF,t.createMiniSheet=(t,e)=>new Promise((n,r)=>{const{parts:i,vHeight:A,vWidth:s}=t,a=qS(A),o=qS(s),l=(o-5)/275,c=IT.createElementNS("http://www.w3.org/2000/svg","svg");c.id="miniSheet-"+e,c.style.width=a,c.style.height=o,c.style.transform="scaleX(1)";const h=OT("rect",{x:0,y:0,width:o,height:a,stroke:"black",strokeWidth:"2px",fill:"white"});c.appendChild(h);const u=OT("rect",{x:3,y:3,width:t.height*l,height:t.width*l,stroke:"black",strokeWidth:"2px",strokeDasharray:"4 1",fill:"white"});c.appendChild(u);for(const t of i){const e=OT("rect",{y:t.y*l+3,x:t.x*l+3,height:t.width*l,width:t.height*l,stroke:"black",fill:"white",id:t.code});c.appendChild(e)}const d=IT.createElement("canvas");d.id="miniSheetCanvas-"+e,d.width=o,d.height=a;const f=IT.getElementById("label-container");f.appendChild(c),f.appendChild(d),n()}),t.dataTypeList=(t,e)=>{const n=[...e];switch(t){case"input":let t=[];return n.map((e,n)=>{t=t.concat(...e.data.woodwork.reduce((t,n,r)=>{const i=n.inputs.map((t,r)=>kc(Qc({},t),{project_id:e.data.project_id,project_description:e.data.project_description,project_customer_id:e.data.project_customer_id,project_customer_name:e.data.project_customer_name,project_note:e.data.project_note,mref:n.ref,mname:n.name,mnote:n.note}));return t=t.concat(i)},[]))}),$S(t,"category_id");case"part":let e=[],r=1;return n.map((t,n)=>t.data.woodwork.map((n,i)=>e=e.concat(...n.parts.reduce((e,A,s)=>(e=e.concat({id:A.id,pid:A.id,pref:A.ref,mref:n.ref,mname:n.name,mnote:n.note,index:r,number:r,key:i,name:A.name,material_name:A.material_name,material_id:A.material_id,material_width:A.material_width,material_height:A.material_height,note:A.note,width:A.height,height:A.width,thickness:A.thickness,type:A.type,edge_left:A.edge_left,edge_left_id:A.edge_left_id,edge_right:A.edge_right,edge_right_id:A.edge_right_id,edge_top:A.edge_top,edge_top_id:A.edge_top_id,edge_bottom:A.edge_bottom,edge_bottom_id:A.edge_bottom_id,code_a:`${A.code_a}`,code_b:`${A.code_b}`,project_id:t.data.project_id,project_description:t.data.project_description,project_customer_id:t.data.project_customer_id,project_customer_name:t.data.project_customer_name,project_note:t.data.project_note}),r++,e),[])))),e;case"volume":return n.map(t=>{var e,n,r,i,A,s;return{project_id:null==(e=null==t?void 0:t.volume)?void 0:e.project_id,project_description:null==(n=null==t?void 0:t.volume)?void 0:n.project_name,project_customer_id:"",project_customer_name:null==(r=null==t?void 0:t.volume)?void 0:r.customer,project_note:"",itemList:[...t.inputs||[],...(t.parts||[]).map(t=>kc(Qc({},t),{name:`${t.name} ${t.thickness}mm`,dimensions:`${t.width} x ${t.height} mm`}))],volume_name:null==(i=null==t?void 0:t.volume)?void 0:i.description,volume_id:null==(A=null==t?void 0:t.volume)?void 0:A.id,volume_date:(null==(s=null==t?void 0:t.volume)?void 0:s.created_at)?new Date(t.volume.created_at).toLocaleDateString("pt-BR"):"",volume_weight:"0kg"}});case"thickened":let i=1;return n.flatMap(t=>t.data.woodwork.reduce((e,n)=>("thickened"===n.type&&(e.push(kc(Qc({},YS(n,["inputs","parts"])),{index:i,mref:n.ref,mnote:n.note,ref:null,project_id:t.data.project_id,project_description:t.data.project_description,project_customer_id:t.data.project_customer_id,project_customer_name:t.data.project_customer_name,project_note:t.data.project_note,rotated:!0})),i++),e),[]));default:return[]}},t.default=hD,t.downloadFile=Yc,t.downloadPDF=sD,t.downloadPdfFallback=FT,t.drawRect=NT,t.etiquetas=cD,t.generateLabelsFromHookData=(t,...e)=>Wc(this,[t,...e],function*(t,e={},n=null){const r=EF();console.log("labelData =>>>>>",t);const i=Qc({dataSource:t.data||[],labels:t.label||[],userPrefs:t.userPrefs||{},cacheKey:t.cacheKey},e);return yield r.generateLabels(i,n)}),t.generateTableSVG=function(t,e={}){if(!t||!Array.isArray(t))return"";const{width:n=200,height:r=100,cellPadding:i=5,fontSize:A=12,headerColor:s="#f0f0f0",borderColor:a="#000000"}=e,o=["ID","Nome","Qtd","Dimensões"],l=n/o.length;let c=`<svg width="${n}" height="${r}" xmlns="http://www.w3.org/2000/svg">`;return c+=`<rect x="0" y="0" width="${n}" height="20" fill="${s}" stroke="${a}" stroke-width="1"/>`,o.forEach((t,e)=>{c+=`<text x="${e*l+i}" y="${10+A/3}" font-size="${A}" font-weight="bold" fill="black">${t}</text>`}),t.forEach((t,e)=>{const r=20*(e+1);c+=`<rect x="0" y="${r}" width="${n}" height="20" fill="white" stroke="${a}" stroke-width="1"/>`;[t.id,t.name,t.quantity,t.dimensions].forEach((t,e)=>{c+=`<text x="${e*l+i}" y="${r+10+A/3}" font-size="${A}" fill="black">${t||""}</text>`})}),c+="</svg>",c},t.getAspectRatio=PT,t.getBorderColor=DT,t.getImagesFromUrl=t=>Wc(this,null,function*(){try{if(!t||"string"!=typeof t)throw new Error("Invalid URL provided");return t}catch(o3){return console.error("Error loading image from URL:",o3),null}}),t.getImagesFromUrlToBase64=XS,t.getInputForLabels=(t,e,n)=>kc(Qc({},t),{project_id:e.data.project_id,project_description:e.data.project_description,project_customer_id:e.data.project_customer_id,project_customer_name:e.data.project_customer_name,project_note:e.data.project_note,mref:n.ref,mname:n.name,mnote:n.note}),t.getInputLabels=null,t.getInputsByCategory=(t,e=[])=>0===e.length?Object.values(t).reduce((t,e)=>t=t.concat(e),[]):e.reduce((e,n)=>(t[n]&&(e=e.concat(t[n])),e),[]),t.getNode=OT,t.getPartLabels=null,t.getPartsForLabels=(t,e,n,r,i)=>({i:e.i,id:e.id,pid:e.pid||null,moduleLength:e.moduleLength,pref:e.pref,mref:e.mref,mtype:null==e?void 0:e.mType,mnote:e.mnote,mname:e.mname,index:e.index,number:e.number,key:i,sheetMaterial:n.material,sheetIndex:r,name:e.name,note:e.note,width:e.width,height:e.height,type:e.type,edge_left:e.edges.left,edge_left_id:e.edges.left_id,edge_right:e.edges.right,edge_right_id:e.edges.right_id,edge_top:e.edges.top,edge_top_id:e.edges.top_id,edge_bottom:e.edges.bottom,edge_bottom_id:e.edges.bottom_id,code_a:`${e.code_a}`,code_a2:`${e.code_a2}`,code_b:`${e.code_b}`,code_b2:`${e.code_b2}`,group_id:null==e?void 0:e.group,project_id:e.project_id,project_description:e.project_description,project_customer_id:e.project_customer_id,project_customer_name:e.project_customer_name,project_note:e.project_note,rotated:e.rotated,holes:e.holes_diagram,material_name:t.name,material_id:t.material,material_width:t.width,material_height:t.height,thickness:t.thickness,labelKey:`${t.material}-${t.thickness}`,machining_side:e.machining_side}),t.getPartsFromProjectToLabels=({projectPartsByCode:t,partsByCode:e,templatePartsByURef:n})=>Object.entries(Qc({},t)).flatMap(([t,r])=>r.map((r,i)=>{var A;const s=Qc(Qc({},e[r]),null==n?void 0:n[t]);return kc(Qc({},s),{edge_left:s.edge_left,edge_right:s.edge_right,edge_bottom:s.edge_bottom,edge_top:s.edge_top,width:s.width/10,height:s.height/10,moduleIndex:i+1,holes_diagram:null==(A=e[r])?void 0:A.holes})})),t.getPrinterStatus=YT,t.getScrapLabels=null,t.getThickenedLabels=null,t.getVolumeLabels=null,t.init=XT,t.initialState=RL,t.initializeBrowserEnvironment=kT,t.isBrowser=Gc,t.isNodeJS=zc,t.labelTypeNames={parts:"Peças",woodwork:"Tamponamentos",inputs:"Insumos",scraps:"Retalhos",volumes:"Volumes"},t.loadImageBrowser=qc,t.makeLabel=ZT,t.makeLamination=t=>{const{pdf:e,actualData:n,v:r,vl:i}=t;let A,s;i.lamination&&i.lamination.edges?(A={edge_left_id:i.lamination.edges.left_id,edge_right_id:i.lamination.edges.right_id,edge_bottom_id:i.lamination.edges.bottom_id,edge_top_id:i.lamination.edges.top_id},s=i.lamination.material_id):(A={edge_left_id:i.edge_left_id,edge_right_id:i.edge_right_id,edge_bottom_id:i.edge_bottom_id,edge_top_id:i.edge_top_id},s=i.material_id);const a={left:DT(A.edge_left_id,s),right:DT(A.edge_right_id,s),bottom:DT(A.edge_bottom_id,s),top:DT(A.edge_top_id,s)};return NT(e,5,5,r.width-10,r.height-10,a.left,a.right,a.bottom,a.top),r.showEdges&&(e.text(`${n.edge_left}`,2,r.height/2),e.text(`${n.edge_right}`,r.width-10,r.height/2),e.text(`${n.edge_bottom}`,r.width/2,r.height-2),e.text(`${n.edge_top}`,r.width/2,10)),e.output("datauristring")},t.mmToPx=qS,t.processLabelForParts=(...t)=>Wc(this,[...t],function*(t=[],e,n){try{console.log(`🏷️ Processando etiquetas para ${t.length} peças...`);const r=e(t);if(!r)throw new Error("Não foi possível obter dados de etiquetas");const[i,A,s]=yield n(r),a=yield fetch(i),o=yield a.arrayBuffer(),l=yield LT(o,{filename:`etiquetas-pecas-${Date.now()}.pdf`,metadata:{partCodes:t,labelData:r}});return kc(Qc({},l),{labelData:r,partCodes:t})}catch(o3){return console.error("❌ Erro ao processar etiquetas para peças:",o3),{success:!1,error:o3.message,partCodes:t}}}),t.reducer=function(t,e){switch(e.type){case"CHANGE_INDEX":return kc(Qc({},t),{index:e.payload.index});case"CHANGE_TYPE":return kc(Qc({},t),{type:e.payload.type,specific:!1,source:null,category:[],index:0});case"CHANGE_TO_SPECIFIC":return kc(Qc({},t),{type:e.payload.type,dataIndex:e.payload.source?null:e.payload.dataIndex,index:0,source:e.payload.source?e.payload.source:null,category:e.payload.category?e.payload.category:[],otherData:e.payload.otherData?e.payload.otherData:null,specific:!0});case"RESET":return RL;default:return t}},t.sendImagesToPrinter=ST,t.sendLabel=tD,t.sendToPrinter=aD,t.serializeXML=$c,t.setBorder=TT,t.stopCreatingLabels=!1,t.useLabelData=(t={})=>{const e=Qc(Qc({},{type:"parts",category:[],specific:!1,dataIndex:null,otherData:null,source:null}),t);return{isReady:!0,isGenerating:!1,progress:0,error:null,data:[],label:[],userPrefs:{},cacheKey:`label-${Date.now()}`,generateLabels:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={},r={}){const i=EF(),A=Qc({dataSource:t||[],labels:e||[],userPrefs:n,cacheKey:`label-${Date.now()}`},r);return yield i.generateLabels(A)}),downloadPDF:(t,e="etiqueta.pdf")=>{if("undefined"==typeof window)return t;const n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},checkPrinterAvailability:()=>Wc(this,null,function*(){try{return!1}catch(o3){return console.warn("Não foi possível verificar impressoras:",o3),!1}}),getLabelData:(t="parts")=>({data:[],label:[],userPrefs:{},cacheKey:`${t}-${Date.now()}`}),config:e}},t.useLabelStore=DL,t.validateLabelData=lD,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
358
358
|
//# sourceMappingURL=etiquetas.umd.js.map
|