etiquetas.js 1.0.0-alpha.2 → 1.0.0-alpha.3
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/README.md +11 -7
- package/dist/etiquetas.es.js +1 -1
- package/dist/etiquetas.umd.js +1 -1
- package/dist/etiquetas.umd.js.map +1 -1
- package/dist/{index-BmMBOPX1.js → index-BkmabrFq.js} +3 -3
- package/dist/{index-BmMBOPX1.js.map → index-BkmabrFq.js.map} +1 -1
- package/dist/{index.es-DzWoeylQ.js → index.es-B4lKWyrH.js} +2 -2
- package/dist/{index.es-DzWoeylQ.js.map → index.es-B4lKWyrH.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 PL=!1;const NL=t=>t;const OL=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=NL,n){"production"!==(QL?"production":void 0)&&n&&!PL&&(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"),PL=!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?OL(t):OL,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 PU extends UU{constructor(t){super(t,"FormatError")}}class NU extends UU{constructor(t){super(t,"AbortException")}}function OU(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),OU(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(OU(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{};Pc(XU,"CSS",96),Pc(XU,"PDF",72),Pc(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(){Pc(this,"started",Object.create(null)),Pc(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;Oc(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=Oc(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),Oc(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=Oc(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=Oc(this,o).toolbarPosition;if(i){const{style:t}=e,n="ltr"===Oc(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 Oc(this,s)}hide(){var t;Oc(this,s).classList.add("hidden"),null==(t=Oc(this,a))||t.hideDropdown()}show(){var t,e;Oc(this,s).classList.remove("hidden"),null==(t=Oc(this,c))||t.shown(),null==(e=Oc(this,h))||e.shown()}addDeleteButton(){const{editorType:e,_uiManager:n}=Oc(this,o),r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",Oc(t,d)[e]),Rc(this,g,v).call(this,r),r.addEventListener("click",t=>{n.delete()},{signal:n._signal}),Oc(this,l).append(r)}addAltText(t){return Wc(this,null,function*(){const e=yield t.render();Rc(this,g,v).call(this,e),Oc(this,l).append(e,Oc(this,g,y)),Dc(this,c,t)})}addComment(t){if(Oc(this,h))return;const e=t.render();e&&(Rc(this,g,v).call(this,e),Oc(this,l).prepend(e,Oc(this,g,y)),Dc(this,h,t),t.toolbar=this)}addColorPicker(t){if(Oc(this,a))return;Dc(this,a,t);const e=t.renderButton();Rc(this,g,v).call(this,e),Oc(this,l).append(e,Oc(this,g,y))}addEditSignatureButton(t){return Wc(this,null,function*(){const e=Dc(this,u,yield t.renderEditButton(Oc(this,o)));Rc(this,g,v).call(this,e),Oc(this,l).append(e,Oc(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){Oc(this,u)&&(Oc(this,u).title=t)}remove(){var t;Oc(this,s).remove(),null==(t=Oc(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){Oc(this,o)._focusEventsAllowed=!1,AI(t)},w=function(t){Oc(this,o)._focusEventsAllowed=!0,AI(t)},v=function(t){const e=Oc(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}=Oc(this,B)||Dc(this,B,Rc(this,C,x).call(this));t.append(Oc(this,B)),A.insetInlineEnd=100*r+"%",A.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){Oc(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:Oc(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=Oc(this,_)._signal;t.addEventListener("contextmenu",iI,{signal:n}),t.addEventListener("click",()=>{Oc(this,_).highlightSelection("floating_button")},{signal:n}),Oc(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*(){Oc(this,I)||Dc(this,I,new Map);const e=Oc(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){Oc(this,I)||Dc(this,I,new Map);let n=Oc(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_${Oc(this,L)}_${Hc(this,U)._++}`,refCounter:1,isSvg:!1},Oc(this,I).set(t,n),Oc(this,I).set(n.id,n),n}getSvgUrl(t){const e=Oc(this,I).get(t);return(null==e?void 0:e.isSvg)?e.svgUrl:null}deleteId(t){var e;Oc(this,I)||Dc(this,I,new Map);const n=Oc(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_${Oc(this,L)}_`)}};L=new WeakMap,U=new WeakMap,I=new WeakMap,Q=new WeakSet,k=function(t,e){return Wc(this,null,function*(){Oc(this,I)||Dc(this,I,new Map);let n=Oc(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_${Oc(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 Oc(this,I).set(t,n),n&&Oc(this,I).set(n.id,n),n})};let vI=wI;class yI{constructor(t=128){Tc(this,M,[]),Tc(this,P,!1),Tc(this,N),Tc(this,O,-1),Dc(this,N,t)}add({cmd:t,undo:e,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:A=!1,keepUndo:s=!1}){if(r&&t(),Oc(this,P))return;const a={cmd:t,undo:e,post:n,type:i};if(-1===Oc(this,O))return Oc(this,M).length>0&&(Oc(this,M).length=0),Dc(this,O,0),void Oc(this,M).push(a);if(A&&Oc(this,M)[Oc(this,O)].type===i)return s&&(a.undo=Oc(this,M)[Oc(this,O)].undo),void(Oc(this,M)[Oc(this,O)]=a);const o=Oc(this,O)+1;o===Oc(this,N)?Oc(this,M).splice(0,1):(Dc(this,O,o),o<Oc(this,M).length&&Oc(this,M).splice(o)),Oc(this,M).push(a)}undo(){if(-1===Oc(this,O))return;Dc(this,P,!0);const{undo:t,post:e}=Oc(this,M)[Oc(this,O)];t(),null==e||e(),Dc(this,P,!1),Dc(this,O,Oc(this,O)-1)}redo(){if(Oc(this,O)<Oc(this,M).length-1){Dc(this,O,Oc(this,O)+1),Dc(this,P,!0);const{cmd:t,post:e}=Oc(this,M)[Oc(this,O)];t(),null==e||e(),Dc(this,P,!1)}}hasSomethingToUndo(){return-1!==Oc(this,O)}hasSomethingToRedo(){return Oc(this,O)<Oc(this,M).length-1}cleanType(t){if(-1!==Oc(this,O)){for(let e=Oc(this,O);e>=0;e--)if(Oc(this,M)[e].type!==t)return Oc(this,M).splice(e+1,Oc(this,O)-e),void Dc(this,O,e);Oc(this,M).length=0,Dc(this,O,-1)}}destroy(){Dc(this,M,null)}}M=new WeakMap,P=new WeakMap,N=new WeakMap,O=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}};Pc(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),Pc(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=Oc(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=>Oc(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)&&Oc(t,Ft).contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Oc(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=Oc(this,It))||t.resolve(),Dc(this,It,null),null==(e=Oc(this,R))||e.abort(),Dc(this,R,null),this._signal=null;for(const l of Oc(this,W).values())l.destroy();Oc(this,W).clear(),Oc(this,j).clear(),Oc(this,et).clear(),null==(n=Oc(this,mt))||n.clear(),Dc(this,H,null),Oc(this,yt).clear(),Oc(this,z).destroy(),null==(r=Oc(this,V))||r.destroy(),null==(i=Oc(this,q))||i.destroy(),null==(A=Oc(this,Bt))||A.destroy(),null==(s=Oc(this,ct))||s.hide(),Dc(this,ct,null),null==(a=Oc(this,gt))||a.destroy(),Dc(this,gt,null),Oc(this,st)&&(clearTimeout(Oc(this,st)),Dc(this,st,null)),Oc(this,St)&&(clearTimeout(Oc(this,St)),Dc(this,St,null)),null==(o=this._editorUndoBar)||o.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return Oc(this,wt)}get useNewAltTextFlow(){return Oc(this,rt)}get useNewAltTextWhenAddingImage(){return Oc(this,it)}get hcmFilter(){return LU(this,"hcmFilter",Oc(this,_t)?Oc(this,At).addHCMFilter(Oc(this,_t).foreground,Oc(this,_t).background):"none")}get direction(){return LU(this,"direction",getComputedStyle(Oc(this,Ft)).direction)}get _highlightColors(){return LU(this,"_highlightColors",Oc(this,ot)?new Map(Oc(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=!!Oc(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=Oc(this,V))||n.editAltText(this,t,e)}hasCommentManager(){return!!Oc(this,q)}editComment(t,e){var n;null==(n=Oc(this,q))||n.open(this,t,e)}getSignature(t){var e;null==(e=Oc(this,Bt))||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return Oc(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(){Oc(this,Ft).focus()}findParent(t,e){for(const n of Oc(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){Oc(this,Lt).classList.toggle("noUserSelect",t)}addShouldRescale(t){Oc(this,et).add(t)}removeShouldRescale(t){Oc(this,et).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*YU.PDF_TO_CSS_UNITS;for(const n of Oc(this,et))n.onScaleChanging();null==(e=Oc(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=Oc(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()||!Oc(this,K)||Oc(this,K).has(t.id)||Oc(this,K).setValue(t.id,t)}a11yAlert(t,e=null){const n=Oc(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,Oc(this,lt)&&(Dc(this,lt,!1),Rc(this,Qt,Ot).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of Oc(this,yt))if(e.div.contains(t)){Dc(this,pt,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!Oc(this,pt))return;const[t,e]=Oc(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 Oc(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 Oc(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=Oc(this,H))||e.commitOrRemove(),!this.hasSelection)return;const n=[];for(const r of Oc(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 Oc(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),Oc(this,vt)===tU.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,Oc(this,lt)&&(Dc(this,lt,!1),Rc(this,Qt,Ot).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:Oc(this,vt)!==tU.NONE,isEmpty:Rc(this,Qt,Jt).call(this),hasSomethingToUndo:Oc(this,z).hasSomethingToUndo(),hasSomethingToRedo:Oc(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(!Oc(this,tt)){Dc(this,tt,t);for(const t of Oc(this,tt))Rc(this,Qt,zt).call(this,t.defaultPropertiesToUpdate)}}getId(){return Oc(this,ht).id}get currentLayer(){return Oc(this,W).get(Oc(this,$))}getLayer(t){return Oc(this,W).get(t)}get currentPageIndex(){return Oc(this,$)}addLayer(t){Oc(this,W).set(t.pageIndex,t),Oc(this,ut)?t.enable():t.disable()}removeLayer(t){Oc(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(Oc(this,vt)!==t&&(!Oc(this,It)||(yield Oc(this,It).promise,Oc(this,It)))){if(Dc(this,It,Promise.withResolvers()),null==(A=Oc(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 Oc(this,It).resolve();t===tU.SIGNATURE&&(yield null==(a=Oc(this,Bt))?void 0:a.loadSignatures()),this.setEditingState(!0),yield Rc(this,Qt,qt).call(this),this.unselectAll();for(const e of Oc(this,W).values())e.updateMode(t);if(!e)return n&&this.addNewEditorFromKeyboard(),void Oc(this,It).resolve();for(const t of Oc(this,j).values())t.annotationElementId===e||t.id===e?(this.setSelected(t),i?t.editComment():r&&t.enterInEditMode()):t.unselect();Oc(this,It).resolve()}})}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==Oc(this,vt)&&this._eventBus.dispatch("switchannotationeditormode",Qc({source:this},t))}updateParams(t,e){if(Oc(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"}}}),(Oc(this,Ct)||Dc(this,Ct,new Map)).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const n of Oc(this,yt))n.updateParams(t,e);else for(const n of Oc(this,tt))n.updateDefaultParams(t,e)}}showAllEditors(t,e,n=!1){var r,i;for(const A of Oc(this,j).values())A.editorType===t&&A.show(e);(null==(i=null==(r=Oc(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(Oc(this,dt)!==t){Dc(this,dt,t);for(const e of Oc(this,W).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const n of Oc(this,j).values())n.pageIndex===t&&e.push(n);return e}getEditor(t){return Oc(this,j).get(t)}addEditor(t){Oc(this,j).set(t.id,t)}removeEditor(t){var e,n;t.div.contains(document.activeElement)&&(Oc(this,st)&&clearTimeout(Oc(this,st)),Dc(this,st,setTimeout(()=>{this.focusMainContainer(),Dc(this,st,null)},0))),Oc(this,j).delete(t.id),t.annotationElementId&&(null==(e=Oc(this,mt))||e.delete(t.annotationElementId)),this.unselect(t),t.annotationElementId&&Oc(this,J).has(t.annotationElementId)||null==(n=Oc(this,K))||n.remove(t.id)}addDeletedAnnotationElement(t){Oc(this,J).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return Oc(this,J).has(t)}removeDeletedAnnotationElement(t){Oc(this,J).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){Oc(this,H)!==t&&(Dc(this,H,t),t&&Rc(this,Qt,zt).call(this,t.propertiesToUpdate))}updateUI(t){Oc(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(Oc(this,yt).has(t))return Oc(this,yt).delete(t),t.unselect(),void Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection});Oc(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=Oc(this,Y))||e.commitOrRemove();for(const n of Oc(this,yt))n!==t&&n.unselect();Oc(this,yt).clear(),Oc(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 Oc(this,yt).has(t)}get firstSelectedEditor(){return Oc(this,yt).values().next().value}unselect(t){t.unselect(),Oc(this,yt).delete(t),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==Oc(this,yt).size}get isEnterHandled(){return 1===Oc(this,yt).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;Oc(this,z).undo(),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:Oc(this,z).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:Rc(this,Qt,Jt).call(this)}),null==(t=this._editorUndoBar)||t.hide()}redo(){Oc(this,z).redo(),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:Oc(this,z).hasSomethingToRedo(),isEmpty:Rc(this,Qt,Jt).call(this)})}addCommands(t){Oc(this,z).add(t),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:Rc(this,Qt,Jt).call(this)})}cleanUndoStack(t){Oc(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]:[...Oc(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=Oc(this,H))||t.commitOrRemove()}hasSomethingToControl(){return Oc(this,H)||this.hasSelection}selectAll(){for(const t of Oc(this,yt))t.commit();Rc(this,Qt,Zt).call(this,Oc(this,j).values())}unselectAll(){var t;if((!Oc(this,H)||(Oc(this,H).commitOrRemove(),Oc(this,vt)===tU.NONE))&&!(null==(t=Oc(this,Y))?void 0:t.commitOrRemove())&&this.hasSelection){for(const t of Oc(this,yt))t.unselect();Oc(this,yt).clear(),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;Oc(this,Et)[0]+=t,Oc(this,Et)[1]+=e;const[r,i]=Oc(this,Et),A=[...Oc(this,yt)];Oc(this,St)&&clearTimeout(Oc(this,St)),Dc(this,St,setTimeout(()=>{Dc(this,St,null),Oc(this,Et)[0]=Oc(this,Et)[1]=0,this.addCommands({cmd:()=>{for(const t of A)Oc(this,j).has(t.id)&&(t.translateInPage(r,i),t.translationDone())},undo:()=>{for(const t of A)Oc(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 Oc(this,yt))Oc(this,Z).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!Oc(this,Z))return!1;this.disableUserSelect(!1);const t=Oc(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(Oc(this,j).has(t.id)){const i=Oc(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(Oc(this,Z))for(const n of Oc(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===Oc(this,yt).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return Oc(this,H)===t}getActive(){return Oc(this,H)}getMode(){return Oc(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}){(Oc(this,G)||Dc(this,G,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;null==(e=Oc(this,G))||e.delete(t)}renderAnnotationElement(t){var e;const n=null==(e=Oc(this,G))?void 0:e.get(t.data.id);if(!n)return;const r=Oc(this,K).getRawValue(n);r&&(Oc(this,vt)!==tU.NONE||r.hasBeenModified)&&r.renderAnnotationElement(t)}setMissingCanvas(t,e,n){var r;const i=null==(r=Oc(this,mt))?void 0:r.get(t);i&&(i.setCanvas(e,n),Oc(this,mt).delete(t))}addMissingCanvas(t,e){(Oc(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 Oc(this,W).values())if(n.hasTextLayer(t))return n;return null},Pt=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&&(Oc(this,ct)||Dc(this,ct,new pI(this)),Oc(this,ct).show(e,n,"ltr"===this.direction))},Nt=function(){var t,e,n;const r=document.getSelection();if(!r||r.isCollapsed)return void(Oc(this,bt)&&(null==(t=Oc(this,ct))||t.hide(),Dc(this,bt,null),Rc(this,Qt,Gt).call(this,{hasSelectedText:!1})));const{anchorNode:i}=r;if(i===Oc(this,bt))return;const A=Rc(this,Qt,kt).call(this,r).closest(".textLayer");if(A){if(null==(n=Oc(this,ct))||n.hide(),Dc(this,bt,i),Rc(this,Qt,Gt).call(this,{hasSelectedText:!0}),(Oc(this,vt)===tU.HIGHLIGHT||Oc(this,vt)===tU.NONE)&&(Oc(this,vt)===tU.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),Dc(this,lt,this.isShiftKeyDown),!this.isShiftKeyDown)){const t=Oc(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,Ot).call(this,"main_toolbar"))};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}}else Oc(this,bt)&&(null==(e=Oc(this,ct))||e.hide(),Dc(this,bt,null),Rc(this,Qt,Gt).call(this,{hasSelectedText:!1}))},Ot=function(t=""){Oc(this,vt)===tU.HIGHLIGHT?this.highlightSelection(t):Oc(this,nt)&&Rc(this,Qt,Pt).call(this)},Tt=function(){document.addEventListener("selectionchange",Rc(this,Qt,Nt).bind(this),{signal:this._signal})},Dt=function(){if(Oc(this,at))return;Dc(this,at,new AbortController);const t=this.combinedSignal(Oc(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=Oc(this,at))||t.abort(),Dc(this,at,null)},Ht=function(){if(Oc(this,ft))return;Dc(this,ft,new AbortController);const t=this.combinedSignal(Oc(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=Oc(this,ft))||t.abort(),Dc(this,ft,null)},Wt=function(){if(Oc(this,X))return;Dc(this,X,new AbortController);const t=this.combinedSignal(Oc(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=Oc(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])=>Oc(this,xt)[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(Oc(this,xt),t)}),Oc(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(!Oc(this,ut)){Dc(this,ut,!0);const t=[];for(const e of Oc(this,W).values())t.push(e.enable());yield Promise.all(t);for(const e of Oc(this,j).values())e.enable()}})},Xt=function(){if(this.unselectAll(),Oc(this,ut)){Dc(this,ut,!1);for(const t of Oc(this,W).values())t.disable();for(const t of Oc(this,j).values())t.disable()}},Yt=function(t){const e=Oc(this,W).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},$t=function(){let t=null;for(t of Oc(this,yt));return t},Jt=function(){if(0===Oc(this,j).size)return!0;if(1===Oc(this,j).size)for(const t of Oc(this,j).values())return t.isEmpty();return!1},Zt=function(t){for(const e of Oc(this,yt))e.unselect();Oc(this,yt).clear();for(const e of t)e.isEmpty()||(Oc(this,yt).add(e),e.select());Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection})},Pc(CI,"TRANSLATE_SMALL",1),Pc(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),Oc(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),Oc(this,he)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Oc(t,ue).missing),n.setAttribute("data-l10n-id",Oc(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=Oc(this,oe)._uiManager._signal;e.addEventListener("contextmenu",iI,{signal:r}),e.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:r});const i=t=>{t.preventDefault(),Oc(this,oe)._uiManager.editAltText(Oc(this,oe)),Oc(this,he)&&Oc(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:Oc(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(){Oc(this,ne)&&(Oc(this,ne).focus({focusVisible:Oc(this,se)}),Dc(this,se,!1))}isEmpty(){return Oc(this,he)?null===Oc(this,te):!Oc(this,te)&&!Oc(this,ee)}hasData(){return Oc(this,he)?null!==Oc(this,te)||!!Oc(this,le):this.isEmpty()}get guessedText(){return Oc(this,le)}setGuessedText(e){return Wc(this,null,function*(){null===Oc(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(!Oc(this,he)||Oc(this,te))return null==(e=Oc(this,ae))||e.remove(),void Dc(this,ae,null);if(!Oc(this,ae)){const t=Dc(this,ae,document.createElement("div"));t.className="noAltTextBadge",Oc(this,oe).div.append(t)}Oc(this,ae).classList.toggle("hidden",!t)}serialize(t){let e=Oc(this,te);return t||Oc(this,le)!==e||(e=Oc(this,ce)),{altText:e,decorative:Oc(this,ee),guessedText:Oc(this,le),textWithDisclaimer:Oc(this,ce)}}get data(){return{altText:Oc(this,te),decorative:Oc(this,ee)}}set data({altText:t,decorative:e,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(Dc(this,le,n),Dc(this,ce,r)),Oc(this,te)===t&&Oc(this,ee)===e||(i||(Dc(this,te,t),Dc(this,ee,e)),Rc(this,de,pe).call(this))}toggle(t=!1){Oc(this,ne)&&(!t&&Oc(this,Ae)&&(clearTimeout(Oc(this,Ae)),Dc(this,Ae,null)),Oc(this,ne).disabled=!t)}shown(){Oc(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:Oc(this,de,fe)}})}destroy(){var t,e;null==(t=Oc(this,ne))||t.remove(),Dc(this,ne,null),Dc(this,re,null),Dc(this,ie,null),null==(e=Oc(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(Oc(this,te)?"added":null===Oc(this,te)&&this.guessedText&&"review")||"missing"},pe=function(){return Wc(this,null,function*(){var t,e,n;const r=Oc(this,ne);if(!r)return;if(Oc(this,he)){if(r.classList.toggle("done",!!Oc(this,te)),r.setAttribute("data-l10n-id",Oc(EI,ue)[Oc(this,de,fe)]),null==(t=Oc(this,re))||t.setAttribute("data-l10n-id",Oc(EI,ue)[`${Oc(this,de,fe)}-label`]),!Oc(this,te))return void(null==(e=Oc(this,ie))||e.remove())}else{if(!Oc(this,te)&&!Oc(this,ee))return r.classList.remove("done"),void(null==(n=Oc(this,ie))||n.remove());r.classList.add("done"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let i=Oc(this,ie);if(!i){Dc(this,ie,i=document.createElement("span")),i.className="tooltip",i.setAttribute("role","tooltip"),i.id=`alt-text-tooltip-${Oc(this,oe).id}`;const t=100,e=Oc(this,oe)._uiManager._signal;e.addEventListener("abort",()=>{clearTimeout(Oc(this,Ae)),Dc(this,Ae,null)},{once:!0}),r.addEventListener("mouseenter",()=>{Dc(this,Ae,setTimeout(()=>{Dc(this,Ae,null),Oc(this,ie).classList.add("show"),Oc(this,oe)._reportTelemetry({action:"alt_text_tooltip"})},t))},{signal:e}),r.addEventListener("mouseleave",()=>{var t;Oc(this,Ae)&&(clearTimeout(Oc(this,Ae)),Dc(this,Ae,null)),null==(t=Oc(this,ie))||t.classList.remove("show")},{signal:e})}Oc(this,ee)?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=Oc(this,te)),i.parentNode||r.append(i);const A=Oc(this,oe).getElementForAltText();null==A||A.setAttribute("aria-describedby",i.id)})},Tc(EI,ue,null),Pc(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(!Oc(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=Oc(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}=Oc(this,we).getClientDimensions(),r={top:t};"ltr"===Oc(this,we)._uiManager.direction?r.right=n:r.left=e,Oc(this,we)._uiManager.editComment(Oc(this,we),r)}finish(){Oc(this,ge)&&(Oc(this,ge).focus({focusVisible:Oc(this,me)}),Dc(this,me,!1))}isDeleted(){return Oc(this,Be)||""===Oc(this,ye)}hasBeenEdited(){return this.isDeleted()||Oc(this,ye)!==Oc(this,ve)}serialize(){return this.data}get data(){return{text:Oc(this,ye),date:Oc(this,be),deleted:Oc(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){Oc(this,ge)&&(Oc(this,ge).disabled=!t)}shown(){}destroy(){var t;null==(t=Oc(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,Pe),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,Oc(this,ke).signal])),t.addEventListener("touchstart",Rc(this,Pe,Ne).bind(this),{passive:!1,signal:Oc(this,Ie)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/hI.pixelRatio}destroy(){var t,e;null==(t=Oc(this,ke))||t.abort(),Dc(this,ke,null),null==(e=Oc(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,Pe=new WeakSet,Ne=function(t){var e,n,r;if(null==(e=Oc(this,Ee))?void 0:e.call(this))return;if(1===t.touches.length){if(Oc(this,Ue))return;const t=Dc(this,Ue,new AbortController),e=AbortSignal.any([Oc(this,Ie),t.signal]),n=Oc(this,_e),r={capture:!0,signal:e,passive:!1},i=t=>{var e;"touch"===t.pointerType&&(null==(e=Oc(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(!Oc(this,Me)){Dc(this,Me,new AbortController);const t=AbortSignal.any([Oc(this,Ie),Oc(this,Me).signal]),e=Oc(this,_e),r={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",Rc(this,Pe,Oe).bind(this),r);const i=Rc(this,Pe,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=Oc(this,Se))||n.call(this)}if(AI(t),2!==t.touches.length||(null==(r=Oc(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})},Oe=function(t){var e;if(!Oc(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=Oc(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(!Oc(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,!Oc(this,Ce))return void Dc(this,Ce,!0);const v=[(i+s)/2,(A+a)/2];null==(e=Oc(this,Fe))||e.call(this,v,w,m)},Te=function(t){var e;t.touches.length>=2||(Oc(this,Me)&&(Oc(this,Me).abort(),Dc(this,Me,null),null==(e=Oc(this,Le))||e.call(this)),Oc(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),Pc(this,"isSelected",!1),Pc(this,"_isCopy",!1),Pc(this,"_editToolbar",null),Pc(this,"_initialOptions",Object.create(null)),Pc(this,"_initialData",null),Pc(this,"_isVisible",!0),Pc(this,"_uiManager",null),Pc(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 Oc(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=Oc(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&&(Oc(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){Oc(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){Oc(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!!Oc(this,Ze)&&(Oc(this,Ze)[0]!==this.x||Oc(this,Ze)[1]!==this.y)}get _hasBeenResized(){return!!Oc(this,Ze)&&(Oc(this,Ze)[2]!==this.width||Oc(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)}%`,Oc(this,Ge)||(i.height=`${(100*e/r).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:n}=t,r=n.endsWith("%"),i=!Oc(this,Ge)&&e.endsWith("%");if(r&&i)return;const[A,s]=this.parentDimensions;r||(t.width=`${(100*parseFloat(n)/A).toFixed(2)}%`),Oc(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=Oc(this,He))||t.finish()}get toolbarButtons(){return null}addEditToolbar(){return Wc(this,null,function*(){if(this._editToolbar||Oc(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=Oc(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 Oc(this,He)||(SI.initialize(t._l10n),Dc(this,He,new SI(this)),Oc(this,De)&&(Oc(this,He).data=Oc(this,De),Dc(this,De,null))),Oc(this,He)}get altTextData(){var t;return null==(t=Oc(this,He))?void 0:t.data}set altTextData(t){Oc(this,He)&&(Oc(this,He).data=t)}get guessedAltText(){var t;return null==(t=Oc(this,He))?void 0:t.guessedText}setGuessedAltText(t){return Wc(this,null,function*(){var e;yield null==(e=Oc(this,He))?void 0:e.setGuessedText(t)})}serializeAltText(t){var e;return null==(e=Oc(this,He))?void 0:e.serialize(t)}hasAltText(){return!!Oc(this,He)&&!Oc(this,He).isEmpty()}hasAltTextData(){var t,e;return null!=(e=null==(t=Oc(this,He))?void 0:t.hasData())&&e}addCommentButton(){return Oc(this,je)?Oc(this,je):Dc(this,je,new FI(this))}get commentColor(){return null}get comment(){const t=Oc(this,je);return{text:t.data.text,date:t.data.date,deleted:t.isDeleted(),color:this.commentColor}}set comment(t){Oc(this,je)||Dc(this,je,new FI(this)),Oc(this,je).data=t}setCommentData(t){Oc(this,je)||Dc(this,je,new FI(this)),Oc(this,je).setInitialText(t)}get hasEditedComment(){var t;return null==(t=Oc(this,je))?void 0:t.hasBeenEdited()}editComment(){return Wc(this,null,function*(){Oc(this,je)||Dc(this,je,new FI(this)),Oc(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=Oc(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&&(Oc(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(){Oc(this,rn)&&clearTimeout(Oc(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 Oc(this,en)}shouldGetKeyboardEvents(){return Oc(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=Oc(this,Ye))||t.abort(),Dc(this,Ye,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),Oc(this,rn)&&(clearTimeout(Oc(this,rn)),Dc(this,rn,null)),Rc(this,hn,In).call(this),this.removeEditToolbar(),Oc(this,an)){for(const t of Oc(this,an).values())clearTimeout(t);Dc(this,an,null)}this.parent=null,null==(e=Oc(this,on))||e.destroy(),Dc(this,on,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(Rc(this,hn,gn).call(this),Oc(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=Oc(this,ze).children;if(!Oc(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 Oc(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=Oc(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*(Oc(this,Re).length/4);if(A!==i){if(A<i)for(let t=0;t<i-A;t++)Oc(this,ze).append(Oc(this,ze).firstChild);else if(A>i)for(let t=0;t<A-i;t++)Oc(this,ze).firstChild.before(Oc(this,ze).lastChild);let e=0;for(const r of n){const n=Oc(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),Oc(this,ze).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(t,e){Oc(this,nn)&&Rc(this,hn,yn).call(this,Oc(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=Oc(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=Oc(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=Oc(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 Oc(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){Oc(this,an)||Dc(this,an,new Map);const{action:n}=e;let r=Oc(this,an).get(n);return r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(e),Oc(this,an).delete(n),0===Oc(this,an).size&&Dc(this,an,null)},t._telemetryTimeout),void Oc(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(Oc(this,ze))return;Dc(this,ze,document.createElement("div")),Oc(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");Oc(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(Oc(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=Oc(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=Oc(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(!Oc(this,Xe))return;const{savedX:t,savedY:e,savedWidth:n,savedHeight:r}=Oc(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]=Oc(this,qe);[B,_]=this.screenToPageTranslation(t-r,n-i),Oc(this,qe)[0]=t,Oc(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];Oc(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=Oc(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;Oc(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=Oc(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!==Oc(this,Ve))return void AI(t);const[A,s]=this.screenToPageTranslation(e-Oc(this,An),r-Oc(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===Oc(this,Ke)&&(Oc(this,on)||t.isPrimary)&&s(t),AI(t)},A));const a=t=>{Oc(this,Ve)&&Oc(this,Ve)!==t.pointerId?AI(t):s(t)};window.addEventListener("pointerup",a,{signal:i}),window.addEventListener("blur",a,{signal:i})},En=function(){if(Oc(this,Ye)||!this.div)return;Dc(this,Ye,new AbortController);const t=this._uiManager.combinedSignal(Oc(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;Oc(this,nn)&&(null==(e=t.relatedTarget)?void 0:e.parentNode)!==Oc(this,ze)&&Rc(this,hn,In).call(this)},Ln=function(t){Dc(this,$e,Oc(this,nn)?t:"")},Un=function(t){if(Oc(this,Re))for(const e of Oc(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),Pc(II,"_l10n",null),Pc(II,"_l10nResizer",null),Pc(II,"_borderLineWidth",-1),Pc(II,"_colorManager",new _I),Pc(II,"_zIndex",1),Pc(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,PI=4294901760,NI=65535;class OI{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&PI|s*u&NI,s=s<<15|s>>>17,s=s*h&PI|s*d&NI,o^=s,o=o<<13|o>>>19,o=5*o+3864292196):(a=A[f],a=a*c&PI|a*u&NI,a=a<<15|a>>>17,a=a*h&PI|a*d&NI,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&PI|s*u&NI,s=s<<15|s>>>17,s=s*h&PI|s*d&NI,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&PI|36045*t&NI,e=4283543511*e&PI|(2950163797*(e<<16|t>>>16)&PI)>>>16,t^=e>>>1,t=444984403*t&PI|60499*t&NI,e=3301882366*e&PI|(3120437893*(e<<16|t>>>16)&PI)>>>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,Pn),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=Oc(this,Mn).get(t);return void 0===n?e:Object.assign(e,n)}getRawValue(t){return Oc(this,Mn).get(t)}remove(t){if(Oc(this,Mn).delete(t),0===Oc(this,Mn).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of Oc(this,Mn).values())if(t instanceof QI)return;this.onAnnotationEditor(null)}}setValue(t,e){const n=Oc(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,Oc(this,Mn).set(t,e);r&&Rc(this,Pn,Nn).call(this),e instanceof QI&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return Oc(this,Mn).has(t)}get size(){return Oc(this,Mn).size}resetModified(){Oc(this,Qn)&&(Dc(this,Qn,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new RI(this)}get serializable(){if(0===Oc(this,Mn).size)return TI;const t=new Map,e=new OI,n=[],r=Object.create(null);let i=!1;for(const[A,s]of Oc(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 Oc(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(Oc(this,kn))return Oc(this,kn);const t=[];for(const e of Oc(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 Oc(this,Mn).entries()}}Qn=new WeakMap,kn=new WeakMap,Mn=new WeakMap,Pn=new WeakSet,Nn=function(){Oc(this,Qn)||(Dc(this,Qn,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class RI extends DI{constructor(t){super(),Tc(this,On);const{map:e,hash:n,transfer:r}=t.serializable,i=structuredClone(e,r?{transfer:r}:null);Dc(this,On,{map:i,hash:n,transfer:r})}get print(){xU("Should not call PrintAnnotationStorage.print")}get serializable(){return Oc(this,On)}get modifiedIds(){return LU(this,"modifiedIds",{ids:new Set,hash:""})}}On=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(),Oc(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&&!Oc(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(),Oc(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)};Oc(this,Rn).then(()=>{for(const[t]of Oc(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)}Oc(this,Dn).set(e,r)}removeEventListener(t,e){const n=Oc(this,Dn).get(e);null==n||n(),Oc(this,Dn).delete(e)}terminate(){for(const[,t]of Oc(this,Dn))null==t||t();Oc(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 NU||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 NU(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:Oc(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=Oc(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:!Oc(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=Oc(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=Oc(this,er,nr).get(A),e)return Oc(this,er,nr).set(t,e),e;const s=`g_${Oc(this,$n)}_transfer_map_${Hc(this,tr)._++}`,a=Rc(this,er,sr).call(this,s);Oc(this,er,nr).set(t,a),Oc(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=Oc(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},Oc(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),Oc(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_${Oc(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=Oc(this,er,nr).get(t);if(e)return e;const[n]=Rc(this,er,Ar).call(this,[t]),r=`alpha_${n}`;if(e=Oc(this,er,nr).get(r),e)return Oc(this,er,nr).set(t,e),e;const i=`g_${Oc(this,$n)}_alpha_map_${Hc(this,tr)._++}`,A=Rc(this,er,sr).call(this,i);Oc(this,er,nr).set(t,A),Oc(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=Oc(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=Oc(this,er,nr).get(n),r)return Oc(this,er,nr).set(t,r),r;const i=`g_${Oc(this,$n)}_luminosity_map_${Hc(this,tr)._++}`,A=Rc(this,er,sr).call(this,i);Oc(this,er,nr).set(t,A),Oc(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=Oc(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},Oc(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]),Oc(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_${Oc(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=Oc(this,Zn))?void 0:e.size)||(null==(n=Oc(this,Yn))||n.parentNode.parentNode.remove(),Dc(this,Yn,null),null==(r=Oc(this,Xn))||r.clear(),Dc(this,Xn,null),null==(i=Oc(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 Oc(this,Xn)||Dc(this,Xn,new Map)},rr=function(){return Oc(this,Zn)||Dc(this,Zn,new Map)},ir=function(){if(!Oc(this,Yn)){const t=Oc(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=Oc(this,Jn).createElementNS(qU,"svg");n.setAttribute("width",0),n.setAttribute("height",0),Dc(this,Yn,Oc(this,Jn).createElementNS(qU,"defs")),t.append(n),n.append(Oc(this,Yn)),Oc(this,Jn).body.append(t)}return Oc(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===Oc(this,qn)){Dc(this,qn,"");const t=Oc(this,Jn).URL;t!==Oc(this,Jn).baseURI&&(tI(t)?CU('#createUrl: ignore "data:"-URL for performance reasons.'):Dc(this,qn,FU(t,"")))}return`url(${Oc(this,qn)}#${t})`},ar=function(t){const e=Oc(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=Oc(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=Oc(this,Jn).createElementNS(qU,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),Oc(this,er,ir).append(e),e},cr=function(t,e,n){const r=Oc(this,Jn).createElementNS(qU,e);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),t.append(r)},hr=function(t,e,n,r){const i=Oc(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=Oc(this,Jn).createElementNS(qU,"feComponentTransfer");e.append(n),Rc(this,er,cr).call(this,n,"feFuncA",t)},dr=function(t){return Oc(this,er,ir).style.color=t,aI(getComputedStyle(Oc(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,P,N,O;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,P=v-(v-x)*t,N=y-(y-E)*t,O=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-P)*t|0,c[r++]=Q-(Q-N)*t|0,c[r++]=k-(k-O)*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 PU(`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}};Pc(MQ,"MAX_PATTERN_SIZE",3e3);let PQ=MQ;function NQ({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 OQ=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){Pc(this,"alphaIsShape",!1),Pc(this,"fontSize",0),Pc(this,"fontSizeScale",1),Pc(this,"textMatrix",null),Pc(this,"textMatrixScale",1),Pc(this,"fontMatrix",jL),Pc(this,"leading",0),Pc(this,"x",0),Pc(this,"y",0),Pc(this,"lineX",0),Pc(this,"lineY",0),Pc(this,"charSpacing",0),Pc(this,"wordSpacing",0),Pc(this,"textHScale",1),Pc(this,"textRenderingMode",nU),Pc(this,"textRise",0),Pc(this,"fillColor","#000000"),Pc(this,"strokeColor","#000000"),Pc(this,"patternFill",!1),Pc(this,"patternStroke",!1),Pc(this,"fillAlpha",1),Pc(this,"strokeAlpha",1),Pc(this,"lineWidth",1),Pc(this,"activeSMask",null),Pc(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%OQ,A=(n-i)/OQ,s=0===i?A:A+1,a=t.createImageData(r,OQ);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?OQ: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*OQ)}}else if(e.kind===oU.RGBA_32BPP){for(d=0,p=r*OQ*4,u=0;u<A;u++)h.set(c.subarray(l,l+p)),l+=p,t.putImageData(a,0,d),d+=OQ;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=OQ,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*OQ)}}}function KQ(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const n=e.height,r=e.width,i=n%OQ,A=(n-i)/OQ,s=0===i?A:A+1,a=t.createImageData(r,OQ);let o=0;const l=e.data,c=a.data;for(let h=0;h<s;h++){const e=h<A?OQ:i;({srcPos:o}=NQ({src:l,srcPos:o,dest:c,width:r,height:e,nonBlackColor:0})),t.putImageData(a,0,h*OQ)}}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 PQ(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 o3 in gU)void 0!==ZQ.prototype[o3]&&(ZQ.prototype[gU[o3]]=ZQ.prototype[o3]);class tk{static get workerPort(){return Oc(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 Oc(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 Oc(this,br)}get(t){var e;return null!=(e=Oc(this,yr).get(t))?e:null}[Symbol.iterator](){return Oc(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(Oc(this,Cr))return Oc(this,xr);if(!Oc(this,xr))return!1;const{print:t,view:e}=this.usage;return Oc(this,Br)?"OFF"!==(null==e?void 0:e.viewState):!Oc(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)Oc(this,Sr).set(n.id,new rk(e,n));if("OFF"===t.baseState)for(const t of Oc(this,Sr).values())t._setVisible(nk,!1);for(const e of t.on)Oc(this,Sr).get(e)._setVisible(nk,!0);for(const e of t.off)Oc(this,Sr).get(e)._setVisible(nk,!1);Dc(this,Fr,this.getHash())}}isVisible(t){if(0===Oc(this,Sr).size)return!0;if(!t)return _U("Optional content group not defined."),!0;if("OCG"===t.type)return Oc(this,Sr).has(t.id)?Oc(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(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(Oc(this,Sr).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(!Oc(this,Sr).get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(!Oc(this,Sr).get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(Oc(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=Oc(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=Oc(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=Oc(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===Oc(this,Fr)||this.getHash()===Oc(this,Fr)}getOrder(){return Oc(this,Sr).size?Oc(this,Lr)?Oc(this,Lr).slice():[...Oc(this,Sr).keys()]:null}getGroup(t){return Oc(this,Sr).get(t)||null}getHash(){if(null!==Oc(this,Er))return Oc(this,Er);const t=new OI;for(const[e,n]of Oc(this,Sr))t.update(`${e}:${n.visible}`);return Dc(this,Er,t.hexdigest())}[Symbol.iterator](){return Oc(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(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;i=Oc(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){Pc(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 NU("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}){Pc(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 NU("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=Oc(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=Oc(this,Qr)[t];return!!e&&e.data!==Sk}delete(t){const e=Oc(this,Qr)[t];return!(!e||e.data===Sk)&&(delete Oc(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 Oc(this,Qr)){const{data:n}=Oc(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 Oc(this,Qr)){const{data:e}=Oc(this,Qr)[t];e!==Sk&&(yield[t,e])}}}Qr=new WeakMap,kr=new WeakSet,Mr=function(t){var e;return(e=Oc(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,Nr,Promise.withResolvers()),Tc(this,Or,null),Tc(this,Tr,!1),Tc(this,Dr,!!(null==(Pr=globalThis.FontInspector)?void 0:Pr.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,Or,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),Oc(this,Nr).promise.finally(()=>{Oc(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=()=>{Oc(this,Vr).read().then(({value:t,done:n})=>{n?Oc(this,Nr).resolve():(null!=Oc(this,Rr)||Dc(this,Rr,t.lang),Object.assign(Oc(this,qr),t.styles),Rc(this,Ai,si).call(this,t.items),e())},Oc(this,Nr).reject)};return Dc(this,Vr,Oc(this,Yr).getReader()),Oc(t,ii).add(this),e(),Oc(this,Nr).promise}update({viewport:e,onBefore:n=null}){var r;const i=e.scale*hI.pixelRatio,A=e.rotation;if(A!==Oc(this,Gr)&&(null==n||n(),Dc(this,Gr,A),cI(Oc(this,Kr),{rotation:A})),i!==Oc(this,zr)){null==n||n(),Dc(this,zr,i);const e={div:null,properties:null,ctx:Rc(r=t,li,ci).call(r,Oc(this,Rr))};for(const t of Oc(this,$r))e.properties=Oc(this,Jr).get(t),e.div=t,Rc(this,Ai,oi).call(this,e)}}cancel(){var t;const e=new NU("TextLayer task cancelled.");null==(t=Oc(this,Vr))||t.cancel(e).catch(()=>{}),Dc(this,Vr,null),Oc(this,Nr).reject(e)}get textDivs(){return Oc(this,$r)}get textContentItemsStr(){return Oc(this,Xr)}static cleanup(){if(!(Oc(this,ii).size>0)){Oc(this,ti).clear();for(const{canvas:t}of Oc(this,ei).values())t.remove();Oc(this,ei).clear()}}};Nr=new WeakMap,Or=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(Oc(this,Tr))return;null!=(n=Oc(this,Hr)).ctx||(n.ctx=Rc(e=Lk,li,ci).call(e,Oc(this,Rr)));const r=Oc(this,$r),i=Oc(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=Oc(this,Or);Dc(this,Or,document.createElement("span")),Oc(this,Or).classList.add("markedContent"),A.id&&Oc(this,Or).setAttribute("id",`${A.id}`),t.append(Oc(this,Or))}else"endMarkedContent"===A.type&&Dc(this,Or,Oc(this,Or).parentNode)}},ai=function(t){var e;const n=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};Oc(this,$r).push(n);const i=HU.transform(Oc(this,Zr),t.transform);let A=Math.atan2(i[1],i[0]);const s=Oc(this,qr)[t.fontName];s.vertical&&(A+=Math.PI/2);let a=Oc(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,Oc(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;Oc(this,Or)===Oc(this,Kr)?(d.left=`${(100*c/Oc(this,Wr)).toFixed(2)}%`,d.top=`${(100*h/Oc(this,jr)).toFixed(2)}%`):(d.left=`${u}${c.toFixed(2)}px)`,d.top=`${u}${h.toFixed(2)}px)`),d.fontSize=`${u}${(Oc(Lk,ri)*o).toFixed(2)}px)`,d.fontFamily=a,r.fontSize=o,n.setAttribute("role","presentation"),n.textContent=t.str,n.dir=t.dir,Oc(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),Oc(this,Jr).set(n,r),Oc(this,Hr).div=n,Oc(this,Hr).properties=r,Rc(this,Ai,oi).call(this,Oc(this,Hr)),r.hasText&&Oc(this,Or).append(n),r.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),Oc(this,Or).append(t)}},oi=function(t){var e;const{div:n,properties:r,ctx:i}=t,{style:A}=n;let s="";if(Oc(Lk,ri)>1&&(s=`scale(${1/Oc(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*Oc(this,zr),t);const{width:l}=i.measureText(n.textContent);l>0&&(s=`scaleX(${a*Oc(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=Oc(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}),Oc(this,ei).set(t,e),Oc(this,ni).set(e,{size:0,family:""})}return e},hi=function(t,e,n){const r=Oc(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!==Oc(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=Oc(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)),Oc(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 Pk?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,P=!0===t.disableAutoFetch,N=!0===t.pdfBug,O=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 O({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:P,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:N,styleElement:null,loadingParams:{disableAutoFetch:P,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(){Pc(this,"_capability",Promise.withResolvers()),Pc(this,"_transport",null),Pc(this,"_worker",null),Pc(this,"docId","d"+Hc(t,fi)._++),Pc(this,"destroyed",!1),Pc(this,"onPassword",null),Pc(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 Pk{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){Oc(this,vi).push(t)}addProgressListener(t){Oc(this,wi).push(t)}addProgressiveReadListener(t){Oc(this,mi).push(t)}addProgressiveDoneListener(t){Oc(this,gi).push(t)}onDataRange(t,e){for(const n of Oc(this,vi))n(t,e)}onDataProgress(t,e){Oc(this,pi).promise.then(()=>{for(const n of Oc(this,wi))n(t,e)})}onDataProgressiveRead(t){Oc(this,pi).promise.then(()=>{for(const e of Oc(this,mi))e(t)})}onDataProgressiveDone(){Oc(this,pi).promise.then(()=>{for(const t of Oc(this,gi))t()})}transportReady(){Oc(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 Nk{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 Ok{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 NU(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(!Oc(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(Oc(t,Li).has(n))throw new Error("Cannot use more than one PDFWorker per port.");Oc(t,Li).set(n,this),Rc(this,Ui,Qi).call(this,n)}else Rc(this,Ui,ki).call(this)}get promise(){return Oc(this,_i).promise}get port(){return Oc(this,xi)}get messageHandler(){return Oc(this,Ci)}destroy(){var e,n;this.destroyed=!0,null==(e=Oc(this,Ei))||e.terminate(),Dc(this,Ei,null),Oc(t,Li).delete(Oc(this,xi)),Dc(this,xi,null),null==(n=Oc(this,Ci))||n.destroy(),Dc(this,Ci,null)}static create(e){const n=Oc(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(Oc(this,Pi,Ni))return Oc(this,Pi,Ni);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(){Oc(this,_i).resolve(),Oc(this,Ci).send("configure",{verbosity:this.verbosity})},Qi=function(t){Dc(this,xi,t),Dc(this,Ci,new AQ("main","worker",t)),Oc(this,Ci).on("ready",()=>{}),Rc(this,Ui,Ii).call(this)},ki=function(){if(Oc(Tk,Fi)||Oc(Tk,Pi,Ni))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?Oc(this,_i).reject(new Error("Worker was destroyed")):Rc(this,Ui,Mi).call(this)},i=new AbortController;e.addEventListener("error",()=>{Oc(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(){Oc(Tk,Fi)||(CU("Setting up fake worker."),Dc(Tk,Fi,!0)),Tk._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void Oc(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=>{Oc(this,_i).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Pi=new WeakSet,Ni=function(){var t;try{return(null==(t=globalThis.pdfjsWorker)?void 0:t.WorkerMessageHandler)||null}catch(hw){return null}},Tc(Tk,Pi),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,Oi,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=Oc(this,Hi))||t.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const r of Oc(this,Ti).values())e.push(r._destroy());Oc(this,Ti).clear(),Oc(this,Di).clear(),Oc(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(),Oc(this,Oi).clear(),this.filterFactory.destroy(),Uk.cleanup(),null==(t=this._networkStream)||t.cancelAllRequests(new NU("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 Nk(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?Oc(this,Hi).reject(t):Oc(this,Hi).resolve({password:t})};e.onPassword(n,t.code)}catch(n){Oc(this,Hi).reject(n)}return Oc(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;Oc(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 Oc(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=Oc(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=Oc(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&&Oc(this,Ri).set(n.refStr,t);const r=new Ok(e,n,this,this._params.pdfBug);return Oc(this,Ti).set(e,r),r});return Oc(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=Oc(this,Oi).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 Oc(this,Oi).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 Oc(this,Ti).values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),Oc(this,Oi).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=Oc(this,Ri).get(n))?e:null}}Oi=new WeakMap,Ti=new WeakMap,Di=new WeakMap,Ri=new WeakMap,Hi=new WeakMap,ji=new WeakSet,Wi=function(t,e=null){const n=Oc(this,Oi).get(t);if(n)return n;const r=this.messageHandler.sendWithPromise(t,e);return Oc(this,Oi).set(t,r),r};class Hk{constructor(t){Tc(this,Vi,null),Pc(this,"onContinue",null),Pc(this,"onError",null),Dc(this,Vi,t)}get promise(){return Oc(this,Vi).capability.promise}cancel(t=0){Oc(this,Vi).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=Oc(this,Vi).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=Oc(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(Oc(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.");Oc(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(),Oc(this,Ki)&&(window.cancelAnimationFrame(Oc(this,Ki)),Dc(this,Ki,null)),Oc(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(),Oc(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,Oc(this,nA)._eventBus),Dc(this,Xi,(null==(r=null==e?void 0:e.color)?void 0:r.toUpperCase())||(null==(i=Oc(this,nA))?void 0:i.highlightColors.values().next().value)||"#FFFF98"),Oc(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",Oc(this,Zi)&&(t.ariaControls=`${Oc(this,Zi).id}_colorpicker_dropdown`);const e=Oc(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=Oc(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===Oc(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;Oc(this,iA,cA)?t.target!==Oc(this,zi)?null==(n=t.target.nextSibling)||n.focus():null==(e=Oc(this,Yi).firstChild)||e.focus():Rc(this,iA,oA).call(this,t)}_moveToPrevious(t){var e,n;t.target!==(null==(e=Oc(this,Yi))?void 0:e.firstChild)&&t.target!==Oc(this,zi)?(Oc(this,iA,cA)||Rc(this,iA,oA).call(this,t),null==(n=t.target.previousSibling)||n.focus()):Oc(this,iA,cA)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;Oc(this,iA,cA)?null==(e=Oc(this,Yi).firstChild)||e.focus():Rc(this,iA,oA).call(this,t)}_moveToEnd(t){var e;Oc(this,iA,cA)?null==(e=Oc(this,Yi).lastChild)||e.focus():Rc(this,iA,oA).call(this,t)}hideDropdown(){var t,e;null==(t=Oc(this,Yi))||t.classList.add("hidden"),Oc(this,zi).ariaExpanded="false",null==(e=Oc(this,eA))||e.abort(),Dc(this,eA,null)}_hideDropdownFromKeyboard(){var t;Oc(this,Ji)||(Oc(this,iA,cA)?(this.hideDropdown(),Oc(this,zi).focus({preventScroll:!0,focusVisible:Oc(this,$i)})):null==(t=Oc(this,Zi))||t.unselect())}updateColor(t){if(Oc(this,qi)&&(Oc(this,qi).style.backgroundColor=t),!Oc(this,Yi))return;const e=Oc(this,nA).highlightColors.values();for(const n of Oc(this,Yi).children)n.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;null==(t=Oc(this,zi))||t.remove(),Dc(this,zi,null),Dc(this,qi,null),null==(e=Oc(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=Oc(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"),Oc(this,Zi)&&(t.id=`${Oc(this,Zi).id}_colorpicker_dropdown`);for(const[n,r]of Oc(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",Oc(Vk,rA)[n]);const A=document.createElement("span");i.append(A),A.className="swatch",A.style.backgroundColor=r,i.ariaSelected=r===Oc(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(),Oc(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(Oc(this,iA,cA))return void this.hideDropdown();if(Dc(this,$i,0===t.detail),Oc(this,eA)||(Dc(this,eA,new AbortController),window.addEventListener("pointerdown",Rc(this,iA,lA).bind(this),{signal:Oc(this,nA).combinedSignal(Oc(this,eA))})),Oc(this,zi).ariaExpanded="true",Oc(this,Yi))return void Oc(this,Yi).classList.remove("hidden");const e=Dc(this,Yi,Rc(this,iA,AA).call(this));Oc(this,zi).append(e)},lA=function(t){var e;(null==(e=Oc(this,Yi))?void 0:e.contains(t.target))||this.hideDropdown()},cA=function(){return Oc(this,Yi)&&!Oc(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),Oc(t,fA)||Dc(t,fA,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(Oc(this,hA))return Oc(this,hA);const{editorType:e,colorType:n,colorValue:r}=Oc(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",Oc(t,fA)[e]),i.addEventListener("input",()=>{Oc(this,dA).updateParams(n,i.value)},{signal:Oc(this,dA)._signal}),i}update(t){Oc(this,hA)&&(Oc(this,hA).value=t)}destroy(){var t;null==(t=Oc(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&&(Oc(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=Oc(this,mA))?void 0:e.popup)||this.popup;!i&&(null==r?void 0:r.text)&&(this._createPopup(r),i=Oc(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;Oc(this,pA)&&(Rc(this,wA,vA).call(this,Oc(this,pA).rect),null==(t=Oc(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(Oc(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}"/>`)}Oc(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!!(Oc(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,PA,!1),Tc(this,NA,null),Tc(this,OA,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),Oc(this,LA).hidden=!0,c&&Rc(this,VA,JA).call(this)}render(){var t;if(Oc(this,NA))return;const e=Dc(this,NA,document.createElement("div"));if(e.className="popup",Oc(this,FA)){const t=e.style.outlineColor=HU.makeHexColor(...Oc(this,FA));e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const n=document.createElement("span");if(n.className="header",null==(t=Oc(this,HA))?void 0:t.str){const t=document.createElement("span");t.className="title",n.append(t),({dir:t.dir,str:t.textContent}=Oc(this,HA))}if(e.append(n),Oc(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:Oc(this,IA).valueOf()})),t.dateTime=Oc(this,IA).toISOString(),n.append(t)}const r=Oc(this,VA,GA);if(r)Zk.render({xfaHtml:r,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const t=this._formatContents(Oc(this,UA));e.append(t)}Oc(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),Oc(this,jA)||Dc(this,jA,{contentsObj:Oc(this,UA),richText:Oc(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=Oc(this,NA))||r.remove(),Dc(this,NA,null))}resetEdited(){var t;Oc(this,jA)&&(({contentsObj:Hc(this,UA)._,richText:Hc(this,RA)._}=Oc(this,jA)),Dc(this,jA,null),null==(t=Oc(this,NA))||t.remove(),Dc(this,NA,null),Dc(this,TA,null))}remove(){var t,e;null==(t=Oc(this,OA))||t.abort(),Dc(this,OA,null),null==(e=Oc(this,NA))||e.remove(),Dc(this,NA,null),Dc(this,WA,!1),Dc(this,PA,!1);for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){Dc(this,WA,this.isVisible),Oc(this,WA)&&(Oc(this,LA).hidden=!0)}maybeShow(){Rc(this,VA,KA).call(this),Oc(this,WA)&&(Oc(this,NA)||Rc(this,VA,ZA).call(this),Dc(this,WA,!1),Oc(this,LA).hidden=!1)}get isVisible(){return!1===Oc(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,PA=new WeakMap,NA=new WeakMap,OA=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(Oc(this,OA))return;Dc(this,OA,new AbortController);const{signal:e}=Oc(this,OA);for(const n of this.trigger)n.addEventListener("click",Oc(this,SA),{signal:e}),n.addEventListener("mouseenter",Oc(this,EA),{signal:e}),n.addEventListener("mouseleave",Oc(this,xA),{signal:e}),n.classList.add("popupTriggerArea");for(const n of Oc(this,QA))null==(t=n.container)||t.addEventListener("keydown",Oc(this,CA),{signal:e})},GA=function(){const t=Oc(this,RA),e=Oc(this,UA);return!(null==t?void 0:t.str)||(null==e?void 0:e.str)&&e.str!==t.str?null:Oc(this,RA).html||null},zA=function(){var t,e,n;return(null==(n=null==(e=null==(t=Oc(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=Oc(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:Oc(this,VA,qA),fontSize:Oc(this,VA,zA)?`calc(${Oc(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&&Oc(this,PA))&&Rc(this,VA,JA).call(this)},$A=function(){if(null!==Oc(this,TA))return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:n,pageX:r,pageY:i}}}=Oc(this,kA);let A=!!Oc(this,MA),s=Oc(this,A?MA:DA);for(const u of Oc(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}=Oc(this,LA);h.left=`${Oc(this,TA)[0]}%`,h.top=`${Oc(this,TA)[1]}%`},JA=function(){Dc(this,PA,!Oc(this,PA)),Oc(this,PA)?(Rc(this,VA,ZA).call(this),Oc(this,LA).addEventListener("click",Oc(this,SA)),Oc(this,LA).addEventListener("keydown",Oc(this,CA))):(Rc(this,VA,ts).call(this),Oc(this,LA).removeEventListener("click",Oc(this,SA)),Oc(this,LA).removeEventListener("keydown",Oc(this,CA)))},ZA=function(){Oc(this,NA)||this.render(),this.isVisible?Oc(this,PA)&&Oc(this,LA).classList.add("focused"):(Rc(this,VA,$A).call(this),Oc(this,LA).hidden=!1,Oc(this,LA).style.zIndex=parseInt(Oc(this,LA).style.zIndex)+1e3)},ts=function(){Oc(this,LA).classList.remove("focused"),!Oc(this,PA)&&this.isVisible&&(Oc(this,LA).hidden=!0,Oc(this,LA).style.zIndex=parseInt(Oc(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 Oc(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 Oc(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 Oc(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 Oc(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);Oc(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=Oc(this,As);if(e>=0&&i.setAttribute("stroke-width",e||1),n)for(let A=0,s=Oc(this,ss).length;A<s;A++)Oc(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 Oc(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 Oc(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=Oc(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=Oc(this,us))||i.moveElementInDOM(this.div,t,A,!1))})},ws=function(){var t;if(!Oc(this,ds))return;const e=this.div;for(const[n,r]of Oc(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=Oc(this,fs).get(n);s&&(s._hasNoCanvas?(null==(t=this._annotationEditorUIManager)||t.setMissingCanvas(n,i.id,r),s._hasNoCanvas=!1):s.canvas=r)}Oc(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 Oc(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&&(Oc(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(Oc(this,fs).values())}getEditableAnnotation(t){return Oc(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),Pc(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,Oc(this,_s)],[eU.FREETEXT_COLOR,Oc(this,vs)]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new zk(this)),[["colorPicker",this._colorPicker]]}get colorType(){return eU.FREETEXT_COLOR}get colorValue(){return Oc(this,vs)}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const e=this.parentScale;return[-t._internalPadding*e,-(t._internalPadding+Oc(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(Oc(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",Oc(this,bs)),this._isDraggable=!0,null==(t=Oc(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=Oc(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",Oc(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(${Oc(this,_s)}px * var(--total-scale-factor))`,n.color=Oc(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:Oc(this,vs)),A={annotationType:tU.FREETEXT,color:i,fontSize:Oc(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(${Oc(this,_s)}px * var(--total-scale-factor))`,r.color=Oc(this,vs),n.replaceChildren();for(const t of Oc(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:Oc(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-Oc(this,_s))*this.parentScale),Dc(this,_s,t),Rc(this,Cs,Fs).call(this)},n=Oc(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=Oc(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(),Oc(this,ys))for(const t of Oc(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 Oc(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),Pc(IM,"_freeTextDefaultContent",""),Pc(IM,"_internalPadding",0),Pc(IM,"_defaultColor",null),Pc(IM,"_defaultFontSize",10),Pc(IM,"_type","freetext"),Pc(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]}}Pc(kM,"PRECISION",1e-4);const MM=class t{constructor({x:e,y:n},r,i,A,s,a=0){Tc(this,$s),Tc(this,Ps),Tc(this,Ns,[]),Tc(this,Os),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,Ps,r),Dc(this,Gs,A*i),Dc(this,Ts,s),Oc(this,Rs).set([NaN,NaN,NaN,NaN,e,n],6),Dc(this,Os,a),Dc(this,Vs,Oc(t,qs)*i),Dc(this,Ws,Oc(t,Ys)*i),Dc(this,Ks,i),Oc(this,zs).push(e,n)}isEmpty(){return isNaN(Oc(this,Rs)[8])}add({x:t,y:e}){var n;Dc(this,Hs,t),Dc(this,js,e);const[r,i,A,s]=Oc(this,Ps);let[a,o,l,c]=Oc(this,Rs).subarray(8,12);const h=t-l,u=e-c,d=Math.hypot(h,u);if(d<Oc(this,Ws))return!1;const f=d-Oc(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=Oc(this,zs))||n.push(t,e);const y=g/f,b=-m/f*Oc(this,Gs),B=y*Oc(this,Gs);if(Oc(this,Rs).set(Oc(this,Rs).subarray(2,8),0),Oc(this,Rs).set([l+b,c+B],4),Oc(this,Rs).set(Oc(this,Rs).subarray(14,18),12),Oc(this,Rs).set([l-b,c-B],16),isNaN(Oc(this,Rs)[6]))return 0===Oc(this,Ds).length&&(Oc(this,Rs).set([a+b,o+B],2),Oc(this,Ds).push(NaN,NaN,NaN,NaN,(a+b-r)/A,(o+B-i)/s),Oc(this,Rs).set([a-b,o-B],14),Oc(this,Ns).push(NaN,NaN,NaN,NaN,(a-b-r)/A,(o-B-i)/s)),Oc(this,Rs).set([w,v,a,o,l,c],6),!this.isEmpty();Oc(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]=Oc(this,Rs).subarray(2,6),Oc(this,Ds).push(NaN,NaN,NaN,NaN,((a+l)/2-r)/A,((o+c)/2-i)/s),[a,o,w,v]=Oc(this,Rs).subarray(14,18),Oc(this,Ns).push(NaN,NaN,NaN,NaN,((w+a)/2-r)/A,((v+o)/2-i)/s),!0):([w,v,a,o,l,c]=Oc(this,Rs).subarray(0,6),Oc(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]=Oc(this,Rs).subarray(12,18),Oc(this,Ns).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=Oc(this,Ds),e=Oc(this,Ns);if(isNaN(Oc(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 NM(t,e,n,r,i,A)}getOutlines(){var t,e;const n=Oc(this,Ds),r=Oc(this,Ns),i=Oc(this,Rs),[A,s,a,o]=Oc(this,Ps),l=new Float32Array((null!=(e=null==(t=Oc(this,zs))?void 0:t.length)?e:0)+2);for(let u=0,d=l.length-2;u<d;u+=2)l[u]=(Oc(this,zs)[u]-A)/a,l[u+1]=(Oc(this,zs)[u+1]-s)/o;if(l[l.length-2]=(Oc(this,Hs)-A)/a,l[l.length-1]=(Oc(this,js)-s)/o,isNaN(i[6])&&!this.isEmpty())return Rc(this,$s,na).call(this,l);const c=new Float32Array(Oc(this,Ds).length+24+Oc(this,Ns).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,Oc(this,Ps),Oc(this,Ks),Oc(this,Os),Oc(this,Ts))}};Ps=new WeakMap,Ns=new WeakMap,Os=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=Oc(this,Rs).subarray(4,6),e=Oc(this,Rs).subarray(16,18),[n,r,i,A]=Oc(this,Ps);return[(Oc(this,Hs)+(t[0]-e[0])/2-n)/i,(Oc(this,js)+(t[1]-e[1])/2-r)/A,(Oc(this,Hs)+(e[0]-t[0])/2-n)/i,(Oc(this,js)+(e[1]-t[1])/2-r)/A]},Zs=function(){const[t,e,n,r]=Oc(this,Ps),[i,A,s,a]=Rc(this,$s,Js).call(this);return`M${(Oc(this,Rs)[2]-t)/n} ${(Oc(this,Rs)[3]-e)/r} L${(Oc(this,Rs)[4]-t)/n} ${(Oc(this,Rs)[5]-e)/r} L${i} ${A} L${s} ${a} L${(Oc(this,Rs)[16]-t)/n} ${(Oc(this,Rs)[17]-e)/r} L${(Oc(this,Rs)[14]-t)/n} ${(Oc(this,Rs)[15]-e)/r} Z`},ta=function(t){const e=Oc(this,Ns);t.push(`L${e[4]} ${e[5]} Z`)},ea=function(t){const[e,n,r,i]=Oc(this,Ps),A=Oc(this,Rs).subarray(4,6),s=Oc(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=Oc(this,Rs),[n,r,i,A]=Oc(this,Ps),[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,Oc(this,Ps),Oc(this,Ks),Oc(this,Os),Oc(this,Ts))},ra=function(t,e){const n=Oc(this,Ns);return t.set([NaN,NaN,NaN,NaN,n[4],n[5]],e),e+6},ia=function(t,e){const n=Oc(this,Rs).subarray(4,6),r=Oc(this,Rs).subarray(16,18),[i,A,s,a]=Oc(this,Ps),[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,Oc(MM,qs)+Oc(MM,Xs));let PM=MM;class NM 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]=Oc(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${Oc(this,ha)[4]} ${Oc(this,ha)[5]}`];for(let e=6,n=Oc(this,ha).length;e<n;e+=6)isNaN(Oc(this,ha)[e])?t.push(`L${Oc(this,ha)[e+4]} ${Oc(this,ha)[e+5]}`):t.push(`C${Oc(this,ha)[e]} ${Oc(this,ha)[e+1]} ${Oc(this,ha)[e+2]} ${Oc(this,ha)[e+3]} ${Oc(this,ha)[e+4]} ${Oc(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(Oc(this,ha),t,r,A,-s),o=kM._rescale(Oc(this,la),t,r,A,-s);break;case 90:a=kM._rescaleAndSwap(Oc(this,ha),t,e,A,s),o=kM._rescaleAndSwap(Oc(this,la),t,e,A,s);break;case 180:a=kM._rescale(Oc(this,ha),n,e,-A,s),o=kM._rescale(Oc(this,la),n,e,-A,s);break;case 270:a=kM._rescaleAndSwap(Oc(this,ha),n,r,-A,-s),o=kM._rescaleAndSwap(Oc(this,la),n,r,-A,-s)}return{outline:Array.from(a),points:[Array.from(o)]}}get box(){return Oc(this,sa)}newOutliner(t,e,n,r,i,A=0){return new PM(t,e,n,r,i,A)}getNewOutline(t,e){const[n,r,i,A]=Oc(this,sa),[s,a,o,l]=Oc(this,Aa),c=i*o,h=A*l,u=n*o+s,d=r*l+a,f=this.newOutliner({x:Oc(this,la)[0]*c+u,y:Oc(this,la)[1]*h+d},Oc(this,Aa),Oc(this,ca),t,Oc(this,oa),null!=e?e:Oc(this,aa));for(let p=2;p<Oc(this,la).length;p+=2)f.add({x:Oc(this,la)[p]*c+u,y:Oc(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=Oc(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=Oc(this,sa);o[0]=i[0]-Oc(this,aa),o[1]=i[1]-Oc(this,aa),o[2]=i[2]-i[0]+2*Oc(this,aa),o[3]=i[3]-i[1]+2*Oc(this,aa),this.lastPoint=[A,s]};class OM{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];Oc(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=Oc(this,ga).at(r?-1:-2),h=[c[0],c[2]];for(const u of Oc(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(){Oc(this,ga).sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of Oc(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,Oc(this,fa),Oc(this,pa))},ya=function(t){const e=Oc(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);Oc(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<Oc(this,ma).length;r++){const[n,i]=Oc(this,ma)[r];if(n!==t)break;if(n===t&&i===e)return void Oc(this,ma).splice(r,1)}for(let r=n-1;r>=0;r--){const[n,i]=Oc(this,ma)[r];if(n!==t)break;if(n===t&&i===e)return void Oc(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]=Oc(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 Oc(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 Oc(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 Oc(this,Ca)}get classNamesForOutlining(){return["highlightOutline"]}}Ca=new WeakMap,xa=new WeakMap;class DM extends PM{newFreeDrawOutline(t,e,n,r,i,A){return new RM(t,e,n,r,i,A)}}class RM extends NM{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,Pa,null),Tc(this,Na,null),Tc(this,Oa,!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,Oa,!0),Rc(this,Va,Ga).call(this,e),Rc(this,Va,$a).call(this)):Oc(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:Oc(this,Oa)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:Oc(this,ja),methodOfCreation:Oc(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 Oc(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,Oc(this,ja)||t._defaultThickness],[eU.HIGHLIGHT_FREE,Oc(this,Oa)]]}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;Oc(this,Oa)?(e=(e-this.rotation+360)%360,s=Rc(n=t,Ja,Za).call(n,Oc(this,Pa).box,e)):s=Rc(r=t,Ja,Za).call(r,[this.x,this.y,this.width,this.height],e),A.updateProperties(Oc(this,Na),{bbox:s,root:{"data-main-rotation":e}}),A.updateProperties(Oc(this,Ra),{bbox:Rc(i=t,Ja,Za).call(i,Oc(this,Ia).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const t=super.render();Oc(this,Ha)&&(t.setAttribute("aria-label",Oc(this,Ha)),t.setAttribute("role","mark")),Oc(this,Oa)?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=Oc(this,La);const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),gI(this,Oc(this,Ma),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Oc(this,Ra),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Oc(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(),Oc(this,Ra)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Oc(this,Ra),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),Oc(this,Ra)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Oc(this,Ra),{rootClass:{selected:!1}}),Oc(this,Oa)||Rc(this,Va,eo).call(this,!1))}get _mustFixPosition(){return!Oc(this,Oa)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(Oc(this,Na),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(Oc(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,Oa,!0);const t=h[0],e={x:t[0]-g,y:p-(t[1]-m)},r=new DM(e,[0,0,f,p],1,Oc(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:Oc(this,Da),thickness:Oc(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,Pa=new WeakMap,Na=new WeakMap,Oa=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 OM(Oc(this,Fa),.001);Dc(this,Pa,t.getOutlines()),[this.x,this.y,this.width,this.height]=Oc(this,Pa).box;const e=new OM(Oc(this,Fa),.0025,.001,"ltr"===this._uiManager.direction);Dc(this,Ia,e.getOutlines());const{lastPoint:n}=Oc(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,Pa,t);if(Dc(this,Ia,t.getNewOutline(Oc(this,ja)/2+1.5,.0025)),e>=0)Dc(this,Na,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:Oc(this,Ia).box,path:{d:Oc(this,Ia).toSVGPath()}},!0));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(Oc(this,Na),{bbox:Rc(r=HM,Ja,Za).call(r,Oc(this,Pa).box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(Oc(this,Ra),{bbox:Rc(i=HM,Ja,Za).call(i,Oc(this,Ia).box,e),path:{d:Oc(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}=Oc(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(Oc(this,Na),{root:{fill:t,"fill-opacity":e}}),null==(r=Oc(this,Ua))||r.updateColor(t)},n=this.color,r=Oc(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=Oc(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(!Oc(this,Oa))return;Rc(this,Va,Ga).call(this,{highlightOutlines:Oc(this,Pa).getNewOutline(t/2)}),this.fixAndSetPosition();const[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)},Ya=function(){null!==Oc(this,Na)&&this.parent&&(this.parent.drawLayer.remove(Oc(this,Na)),Dc(this,Na,null),this.parent.drawLayer.remove(Oc(this,Ra)),Dc(this,Ra,null))},$a=function(t=this.parent){null===Oc(this,Na)&&(({id:Hc(this,Na)._,clipPathId:Hc(this,La)._}=t.drawLayer.draw({bbox:Oc(this,Pa).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":Oc(this,Da)},rootClass:{highlight:!0,free:Oc(this,Oa)},path:{d:Oc(this,Pa).toSVGPath()}},!1,!0)),Dc(this,Ra,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:Oc(this,Oa)},bbox:Oc(this,Ia).box,path:{d:Oc(this,Ia).toSVGPath()}},Oc(this,Oa))),Oc(this,Ma)&&(Oc(this,Ma).style.clipPath=Oc(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(!Oc(this,Ea))return;const e=window.getSelection();t?e.setPosition(Oc(this,Ea),Oc(this,Sa)):e.setPosition(Oc(this,Qa),Oc(this,ka))},no=function(){return Oc(this,Oa)?this.rotation:0},ro=function(){if(Oc(this,Oa))return null;const[t,e]=this.pageDimensions,[n,r]=this.pageTranslation,i=Oc(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 Oc(this,Pa).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),Pc(HM,"_defaultColor",null),Pc(HM,"_defaultOpacity",1),Pc(HM,"_defaultThickness",12),Pc(HM,"_type","highlight"),Pc(HM,"_editorType",tU.HIGHLIGHT),Pc(HM,"_freeHighlightId",-1),Pc(HM,"_freeHighlight",null),Pc(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){Oc(this,oo)[t]=e}toSVGProperties(){const t=Oc(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),Pc(this,"_colorPicker",null),Pc(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&&(Oc(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=Oc(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(Oc(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(Oc(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(Oc(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,Oc(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,Oc(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)},Oc(this,lo).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&Rc(this,vo,Eo).call(this,Oc(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(Oc(t,go)&&Oc(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);Oc(t,po)||Dc(t,po,l),null!=Oc(t,go)||Dc(t,go,c),window.addEventListener("pointerup",e=>{var n;Oc(t,po)===e.pointerId?this._endDraw(e):null==(n=Oc(t,mo))||n.delete(e.pointerId)},{signal:p}),window.addEventListener("pointercancel",e=>{var n;Oc(t,po)===e.pointerId?this._currentParent.endDrawingSession():null==(n=Oc(t,mo))||n.delete(e.pointerId)},{signal:p}),window.addEventListener("pointerdown",e=>{Oc(t,go)===e.pointerType&&((Oc(t,mo)||Dc(t,mo,new Set)).add(e.pointerId),Oc(t,ho).isCancellable()&&(Oc(t,ho).removeLastElement(),Oc(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===Oc(t,wo)&&AI(e)},{signal:p}),e.toggleDrawing(),null==(A=n._editorUndoBar)||A.hide(),Oc(t,ho)?e.drawLayer.updateProperties(this._currentDrawId,Oc(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(Oc(t,fo).toSVGProperties(),Oc(t,ho).defaultSVGProperties),!0,!1)))}static _drawMove(e){var n;if(Dc(t,wo,-1),!Oc(t,ho))return;const{offsetX:r,offsetY:i,pointerId:A}=e;Oc(t,po)===A&&((null==(n=Oc(t,mo))?void 0:n.size)>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Oc(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)),Oc(t,uo)&&(Oc(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,Oc(t,ho).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=Oc(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),!Oc(t,ho).isEmpty()){const{pageDimensions:[r,i],scale:A}=n,s=n.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Oc(t,ho).getOutlines(r*A,i*A,A,this._INNER_MARGIN),drawingOptions:Oc(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 Oc(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,Oc(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]}},Pc(VM,"_currentDrawId",-1),Pc(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),Pc(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,Po,0),Tc(this,No,new zM),Tc(this,Oo),Tc(this,To),Dc(this,Oo,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:Oc(this,ko)}]),Oc(this,Fo).set(s,0)}updateProperty(t,e){"stroke-width"===t&&Dc(this,Qo,e)}isEmpty(){return!Oc(this,Uo)||0===Oc(this,Uo).length}isCancellable(){return Oc(this,ko).length<=10}add(t,e){[t,e]=Rc(this,Do,Ro).call(this,t,e);const[n,r,i,A]=Oc(this,Fo).subarray(2,6),s=t-i,a=e-A;return Math.hypot(Oc(this,Oo)*s,Oc(this,To)*a)<=2?null:(Oc(this,ko).push(t,e),isNaN(n)?(Oc(this,Fo).set([i,A,t,e],2),Oc(this,Lo).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(Oc(this,Fo)[0])&&Oc(this,Lo).splice(6,6),Oc(this,Fo).set([n,r,i,A,t,e],0),Oc(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===Oc(this,ko).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,n,r,i){Dc(this,Oo,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=Oc(this,Uo).at(-1);return s&&(s.line=new Float32Array(s.line),s.points=new Float32Array(s.points)),Oc(this,Uo).push({line:A,points:Oc(this,ko)}),Oc(this,Fo).set(A,0),Dc(this,Po,0),this.toSVGPath(),null}getLastElement(){return Oc(this,Uo).at(-1)}setLastElement(t){return Oc(this,Uo)?(Oc(this,Uo).push(t),Dc(this,Lo,t.line),Dc(this,ko,t.points),Dc(this,Po,0),{path:{d:this.toSVGPath()}}):Oc(this,No).setLastElement(t)}removeLastElement(){if(!Oc(this,Uo))return Oc(this,No).removeLastElement();Oc(this,Uo).pop(),Dc(this,Mo,"");for(let t=0,e=Oc(this,Uo).length;t<e;t++){const{line:e,points:n}=Oc(this,Uo)[t];Dc(this,Lo,e),Dc(this,ko,n),Dc(this,Po,0),this.toSVGPath()}return{path:{d:Oc(this,Mo)}}}toSVGPath(){const t=kM.svgRound(Oc(this,Lo)[4]),e=kM.svgRound(Oc(this,Lo)[5]);if(2===Oc(this,ko).length)return Dc(this,Mo,`${Oc(this,Mo)} M ${t} ${e} Z`),Oc(this,Mo);if(Oc(this,ko).length<=6){const n=Oc(this,Mo).lastIndexOf("M");Dc(this,Mo,`${Oc(this,Mo).slice(0,n)} M ${t} ${e}`),Dc(this,Po,6)}if(4===Oc(this,ko).length){const t=kM.svgRound(Oc(this,Lo)[10]),e=kM.svgRound(Oc(this,Lo)[11]);return Dc(this,Mo,`${Oc(this,Mo)} L ${t} ${e}`),Dc(this,Po,12),Oc(this,Mo)}const n=[];0===Oc(this,Po)&&(n.push(`M ${t} ${e}`),Dc(this,Po,6));for(let r=Oc(this,Po),i=Oc(this,Lo).length;r<i;r+=6){const[t,e,i,A,s,a]=Oc(this,Lo).slice(r,r+6).map(kM.svgRound);n.push(`C${t} ${e} ${i} ${A} ${s} ${a}`)}return Dc(this,Mo,Oc(this,Mo)+n.join(" ")),Dc(this,Po,Oc(this,Lo).length),Oc(this,Mo)}getOutlines(t,e,n,r){const i=Oc(this,Uo).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),Oc(this,No).build(Oc(this,Uo),t,e,n,Oc(this,Io),Oc(this,Qo),r),Dc(this,Fo,null),Dc(this,Lo,null),Dc(this,Uo,null),Dc(this,Mo,null),Oc(this,No)}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,Po=new WeakMap,No=new WeakMap,Oo=new WeakMap,To=new WeakMap,Do=new WeakSet,Ro=function(t,e){return kM._normalizePoint(t,e,Oc(this,Oo),Oc(this,To),Oc(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 Oc(this,Xo)}setLastElement(t){return Oc(this,Vo).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return Oc(this,Vo).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of Oc(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(Oc(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 Oc(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 Oc(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=Oc(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 Oc(this,Ho).map(kM.svgRound).join(" ")}get defaultProperties(){const[t,e]=Oc(this,Ho);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=Oc(this,Ho);let n=0,r=0,i=0,A=0,s=0,a=0;switch(Oc(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]=Oc(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=Oc(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 Oc(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 Oc(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=Oc(this,Ho),s=t-A[0],a=e-A[1];if(Oc(this,Ko)===r&&Oc(this,Go)===i)for(const{line:o,points:l}of Oc(this,Vo))kM._translate(o,s,a,o),kM._translate(l,s,a,l);else{const t=Oc(this,Ko)/r,e=Oc(this,Go)/i;Dc(this,Ko,r),Dc(this,Go,i);for(const{line:n,points:r}of Oc(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=Oc(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=Oc(this,Xo)){const e=Oc(this,Wo)+t/2*Oc(this,zo);return Oc(this,qo)%180==0?[e/Oc(this,Ko),e/Oc(this,Go)]:[e/Oc(this,Go),e/Oc(this,Ko)]},Jo=function(){const[t,e,n,r]=Oc(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 Oc(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=Oc(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},Pc(XM,"_type","ink"),Pc(XM,"_editorType",tU.INK),Pc(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)*Oc(this,rl).sigmaSFactor,Oc(this,rl).sigmaR,Oc(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+Oc(this,sl)[2*i])*e+(r+Oc(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+Oc(this,sl)[2*i])*e+(r+Oc(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=Oc(this,sl)[2*p],m=Oc(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=Oc(this,sl)[2*r],m=Oc(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}=Oc(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 tP extends qM{constructor(t){super(t),super.updateProperties({stroke:QI._defaultLineColor,"stroke-width":1})}clone(){const t=new tP(this._viewParameters);return t.updateAll(this),t}}const eP=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 tP(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:!!Oc(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(Oc(this,vl)){const{lines:e,mustSmooth:n,areContours:r,description:i,uuid:A,heightInPage:s}=Oc(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:Oc(this,wl)||""}));return r&&(this._isCopy=!0,this._moveAfterPaste(e,n)),this.div}setUuid(t){Dc(this,yl,t),this.addEditToolbar()}getUuid(){return Oc(this,yl)}get description(){return Oc(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}=Oc(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,Oc(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:Oc(this,ml),color:[0,0,0],thickness:Oc(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=Oc(this,yl),A.isCopy=!0):A.lines=e,Oc(this,wl)&&(A.accessibilityData={type:"Figure",alt:Oc(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,Pc(eP,"_type","signature"),Pc(eP,"_editorType",tU.SIGNATURE),Pc(eP,"_defaultDrawingOptions",null);let nP=eP;const rP=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;Oc(this,Bl)&&(Dc(this,bl,null),this._uiManager.imageManager.deleteId(Oc(this,Bl)),null==(t=Oc(this,Sl))||t.remove(),Dc(this,Sl,null),Oc(this,Ll)&&(clearTimeout(Oc(this,Ll)),Dc(this,Ll,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(Oc(this,Bl)&&null===Oc(this,Sl)&&Rc(this,Ql,Pl).call(this),this.isAttachedToDOM||this.parent.add(this))):Oc(this,Bl)&&Rc(this,Ql,Pl).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(Oc(this,_l)||Oc(this,bl)||Oc(this,Cl)||Oc(this,xl)||Oc(this,Bl)||Oc(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(),Oc(this,Fl)||(Oc(this,bl)?Rc(this,Ql,Nl).call(this):Rc(this,Ql,Pl).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,Nl).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==Oc(this,Ll)&&clearTimeout(Oc(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}=Oc(this,bl),s=new hI;let a=Oc(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);Oc(this,Ul)||(a=Rc(this,Ql,Ol).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=Oc(this,bl),i>t||A>t){const r=Math.min(t/i,t/A);e=Math.floor(i*r),n=Math.floor(A*r),Oc(this,Ul)||(a=Rc(this,Ql,Ol).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:Oc(this,Bl),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:Oc(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=Oc(this,Ul)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(e.stamps.has(Oc(this,Bl))){if(Oc(this,Ul)){const t=e.stamps.get(Oc(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(Oc(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,Nl).call(this)):this.remove()},Ml=function(){if(Dc(this,_l,null),this._uiManager.enableWaiting(!1),Oc(this,Sl))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Oc(this,bl))this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Oc(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()}},Pl=function(){if(Oc(this,Bl))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(Oc(this,Bl)).then(t=>Rc(this,Ql,kl).call(this,t,!0)).finally(()=>Rc(this,Ql,Ml).call(this));if(Oc(this,Cl)){const t=Oc(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(Oc(this,xl)){const t=Oc(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()},Nl=function(){var t;const{div:e}=this;let{width:n,height:r}=Oc(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),Oc(this,Il)||(this.parent.addUndoableEditor(this),Dc(this,Il,!0)),this._reportTelemetry({action:"inserted_image"}),Oc(this,El)&&this.div.setAttribute("aria-description",Oc(this,El)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},Ol=function(t,e){const{width:n,height:r}=Oc(this,bl);let i=n,A=r,s=Oc(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=Oc(this,Sl);if(!a||a.width===A&&a.height===s)return;a.width=A,a.height=s;const o=Oc(this,Ul)?Oc(this,bl):Rc(this,Ql,Ol).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(Oc(this,Ul)){const t=this._uiManager.imageManager.getSvgUrl(Oc(this,Bl));if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=Oc(this,bl));return t.getContext("2d").drawImage(Oc(this,bl),0,0),t.toDataURL()}if(Oc(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(Oc(this,bl),0,0,Oc(this,bl).width,Oc(this,bl).height,0,0,n,r),i.transferToImageBitmap()}return structuredClone(Oc(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}},Pc(rP,"_type","stamp"),Pc(rP,"_editorType",tU.STAMP);let iP=rP;const AP=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=[...Oc(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,Oc(this,nc).addLayer(this)}get isEmpty(){return 0===Oc(this,Gl).size}get isInvisible(){return this.isEmpty&&Oc(this,nc).getMode()===tU.NONE}updateToolbar(t){Oc(this,nc).updateToolbar(t)}updateMode(e=Oc(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 Oc(t,rc).values())n.toggle(`${r._type}Editing`,e===r._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null==(e=Oc(this,Jl))?void 0:e.div)}setEditingState(t){Oc(this,nc).setEditingState(t)}addCommands(t){Oc(this,nc).addCommands(t)}cleanUndoStack(t){Oc(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=Oc(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=Oc(this,tc))||t.abort(),Dc(this,tc,null);const e=new Set;for(const r of Oc(this,Gl).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(Oc(this,nc).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(!Oc(this,Wl))return void Dc(this,Xl,!1);const n=Oc(this,Wl).getEditableAnnotations();for(const r of n){if(r.hide(),Oc(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),Oc(this,Jl)&&!Oc(this,tc)){Dc(this,tc,new AbortController);const t=Oc(this,nc).combinedSignal(Oc(this,tc));Oc(this,Jl).div.addEventListener("pointerdown",t=>{const{clientX:e,clientY:n,timeStamp:r}=t;if(r-Oc(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=Oc(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 Oc(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(Oc(this,Wl)){const t=Oc(this,Wl).getEditableAnnotations();for(const e of t){const{id:t}=e.data;if(Oc(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&&(Oc(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 Oc(t,rc).values())i.remove(`${A._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),Dc(this,ql,!1)}getEditableAnnotation(t){var e;return(null==(e=Oc(this,Wl))?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){Oc(this,nc).getActive()!==t&&Oc(this,nc).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(null==(t=Oc(this,Jl))?void 0:t.div)&&!Oc(this,Zl)){Dc(this,Zl,new AbortController);const t=Oc(this,nc).combinedSignal(Oc(this,Zl));Oc(this,Jl).div.addEventListener("pointerdown",Rc(this,ic,Ac).bind(this),{signal:t}),Oc(this,Jl).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(null==(t=Oc(this,Jl))?void 0:t.div)&&Oc(this,Zl)&&(Oc(this,Zl).abort(),Dc(this,Zl,null),Oc(this,Jl).div.classList.remove("highlighting"))}enableClick(){if(Oc(this,Vl))return;Dc(this,Vl,new AbortController);const t=Oc(this,nc).combinedSignal(Oc(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=Oc(this,Vl))||t.abort(),Dc(this,Vl,null)}attach(t){Oc(this,Gl).set(t.id,t);const{annotationElementId:e}=t;e&&Oc(this,nc).isDeletedAnnotationElement(e)&&Oc(this,nc).removeDeletedAnnotationElement(t)}detach(t){var e;Oc(this,Gl).delete(t.id),null==(e=Oc(this,Hl))||e.removePointerInTextLayer(t.contentDiv),!Oc(this,ql)&&t.annotationElementId&&Oc(this,nc).addDeletedAnnotationElement(t)}remove(t){this.detach(t),Oc(this,nc).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(Oc(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),Oc(this,nc).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!Oc(this,Xl)),Oc(this,nc).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:n}=document;t.div.contains(n)&&!Oc(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:Oc(this,nc)._signal}),n.focus())},0))),t._structTreeParentId=null==(e=Oc(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 Oc(this,nc).getId()}combinedSignal(t){return Oc(this,nc).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null==(t=Oc(this,ic,sc))?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){return Wc(this,null,function*(){this.updateToolbar(t),yield Oc(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:Oc(this,nc),isCentered:!0},e));A&&this.add(A)})}deserialize(e){return Wc(this,null,function*(){var n,r;return(yield null==(r=Oc(t,rc).get(null!=(n=e.annotationType)?n:e.annotationEditorType))?void 0:r.deserialize(e,this,Oc(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:Oc(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){Oc(this,nc).setSelected(t)}toggleSelected(t){Oc(this,nc).toggleSelected(t)}unselect(t){Oc(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(!Oc(this,zl))return;if(Dc(this,zl,!1),(null==(e=Oc(this,ic,sc))?void 0:e.isDrawer)&&Oc(this,ic,sc).supportMultipleDrawings)return;if(!Oc(this,jl))return void Dc(this,jl,!0);const r=Oc(this,nc).getMode();r!==tU.STAMP&&r!==tU.SIGNATURE?this.createAndAddNewEditor(t,!1):Oc(this,nc).unselectAll()}pointerdown(t){var e;if(Oc(this,nc).getMode()===tU.HIGHLIGHT&&this.enableTextSelection(),Oc(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=Oc(this,ic,sc))?void 0:e.isDrawer)return void this.startDrawingSession(t);const r=Oc(this,nc).getActive();Dc(this,jl,!r||r.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),Oc(this,Yl))return void Oc(this,ic,sc).startDrawing(this,Oc(this,nc),!1,t);Oc(this,nc).setCurrentDrawingSession(this),Dc(this,Yl,new AbortController);const e=Oc(this,nc).combinedSignal(Oc(this,Yl));this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(Dc(this,$l,null),this.commitOrRemove())},{signal:e}),Oc(this,ic,sc).startDrawing(this,Oc(this,nc),!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&Dc(this,$l,t))}Oc(this,$l)&&setTimeout(()=>{var t;null==(t=Oc(this,$l))||t.focus(),Dc(this,$l,null)},0)}endDrawingSession(t=!1){return Oc(this,Yl)?(Oc(this,nc).setCurrentDrawingSession(null),Oc(this,Yl).abort(),Dc(this,Yl,null),Dc(this,$l,null),Oc(this,ic,sc).endDrawing(t)):null}findNewParent(t,e,n){const r=Oc(this,nc).findParent(e,n);return null!==r&&r!==this&&(r.changeParent(t),!0)}commitOrRemove(){return!!Oc(this,Yl)&&(this.endDrawingSession(),!0)}onScaleChanging(){Oc(this,Yl)&&Oc(this,ic,sc).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),(null==(t=Oc(this,nc).getActive())?void 0:t.parent)===this&&(Oc(this,nc).commitOrRemove(),Oc(this,nc).setActiveEditor(null)),Oc(this,Kl)&&(clearTimeout(Oc(this,Kl)),Dc(this,Kl,null));for(const n of Oc(this,Gl).values())null==(e=Oc(this,Hl))||e.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,Oc(this,Gl).clear(),Oc(this,nc).removeLayer(this)}render({viewport:t}){this.viewport=t,cI(this.div,t);for(const e of Oc(this,nc).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){Oc(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 Oc(this,Gl).values())r.rotate(n)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return Oc(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){Oc(this,nc).unselectAll();const{target:e}=t;if(e===Oc(this,Jl).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&Oc(this,Jl).div.contains(e)){const{isMac:e}=DU.platform;if(0!==t.button||t.ctrlKey&&e)return;Oc(this,nc).showAllEditors("highlight",!0,!0),Oc(this,Jl).div.classList.add("free"),this.toggleDrawing(),jM.startHighlighting(this,"ltr"===Oc(this,nc).direction,{target:Oc(this,Jl).div,x:t.x,y:t.y}),Oc(this,Jl).div.addEventListener("pointerup",()=>{Oc(this,Jl).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:Oc(this,nc)._signal}),t.preventDefault()}},sc=function(){return Oc(AP,rc).get(Oc(this,nc).getMode())},ac=function(t){const e=Oc(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 Oc(this,Gl).values())t.isEmpty()&&t.remove()},Pc(AP,"_initialized",!1),Tc(AP,rc,new Map([QM,YM,iP,jM,nP].map(t=>[t._editorType,t])));let sP=AP;const aP=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(Oc(this,cc)){if(Oc(this,cc)!==t){if(Oc(this,hc).size>0)for(const e of Oc(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&&Oc(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),Oc(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),Oc(this,hc).set(r,i),r}finalizeDraw(t,e){Oc(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?Oc(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=Oc(this,hc).get(t);n&&(Oc(e,cc).append(n),Oc(this,hc).delete(t),Oc(e,hc).set(t,n))}remove(t){Oc(this,uc).delete(t),null!==Oc(this,cc)&&(Oc(this,hc).get(t).remove(),Oc(this,hc).delete(t))}destroy(){Dc(this,cc,null);for(const t of Oc(this,hc).values())t.remove();Oc(this,hc).clear(),Oc(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=aP._svgFactory.create(1,1,!0);return Oc(this,cc).append(t),t.setAttribute("aria-hidden",!0),t},wc=function(t,e){const n=aP._svgFactory.createElement("clipPath");t.append(n);const r=`clip_${e}`;n.setAttribute("id",r),n.setAttribute("clipPathUnits","objectBoundingBox");const i=aP._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(aP,fc),Tc(aP,dc,0);let oP=aP;globalThis._pdfjsTestingUtils={HighlightOutliner:OM},globalThis.pdfjsLib={AbortException:NU,AnnotationEditorLayer:sP,AnnotationEditorParamsType:eU,AnnotationEditorType:tU,AnnotationEditorUIManager:xI,AnnotationLayer:LM,AnnotationMode:JL,AnnotationType:lU,build:"295fb3ec4",ColorPicker:Kk,createValidAbsoluteUrl:SU,DOMSVGFactory:Jk,DrawLayer:oP,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:Pk,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 lP(t){let e=t.length;for(;--e>=0;)t[e]=0}const cP=256,hP=286,uP=30,dP=15,fP=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]),pP=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]),gP=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),mP=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wP=new Array(576);lP(wP);const vP=new Array(60);lP(vP);const yP=new Array(512);lP(yP);const bP=new Array(256);lP(bP);const BP=new Array(29);lP(BP);const _P=new Array(uP);function CP(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 xP,EP,SP;function FP(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}lP(_P);const LP=t=>t<256?yP[t]:yP[256+(t>>>7)],UP=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},IP=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,UP(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)},QP=(t,e,n)=>{IP(t,n[2*e],n[2*e+1])},kP=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},MP=(t,e,n)=>{const r=new Array(16);let i,A,s=0;for(i=1;i<=dP;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]=kP(r[e]++,e))}},PP=t=>{let e;for(e=0;e<hP;e++)t.dyn_ltree[2*e]=0;for(e=0;e<uP;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},NP=t=>{t.bi_valid>8?UP(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},OP=(t,e,n,r)=>{const i=2*e,A=2*n;return t[i]<t[A]||t[i]===t[A]&&r[e]<=r[n]},TP=(t,e,n)=>{const r=t.heap[n];let i=n<<1;for(;i<=t.heap_len&&(i<t.heap_len&&OP(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!OP(e,r,t.heap[i],t.depth));)t.heap[n]=t.heap[i],n=i,i<<=1;t.heap[n]=r},DP=(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?QP(t,i,e):(A=bP[i],QP(t,A+cP+1,e),s=fP[A],0!==s&&(i-=BP[A],IP(t,i,s)),r--,A=LP(r),QP(t,A,n),s=pP[A],0!==s&&(r-=_P[A],IP(t,r,s)))}while(a<t.sym_next);QP(t,256,e)},RP=(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--)TP(t,n,s);o=A;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],TP(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++,TP(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<=dP;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),MP(n,l,t.bl_count)},HP=(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))},jP=(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{QP(t,i,t.bl_tree)}while(0!==--a);else 0!==i?(i!==A&&(QP(t,i,t.bl_tree),a--),QP(t,16,t.bl_tree),IP(t,a-3,2)):a<=10?(QP(t,17,t.bl_tree),IP(t,a-3,3)):(QP(t,18,t.bl_tree),IP(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 WP=!1;const VP=(t,e,n,r)=>{IP(t,0+(r?1:0),3),NP(t),UP(t,n),UP(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n};var KP={_tr_init:t=>{WP||((()=>{let t,e,n,r,i;const A=new Array(16);for(n=0,r=0;r<28;r++)for(BP[r]=n,t=0;t<1<<fP[r];t++)bP[n++]=r;for(bP[n-1]=r,i=0,r=0;r<16;r++)for(_P[r]=i,t=0;t<1<<pP[r];t++)yP[i++]=r;for(i>>=7;r<uP;r++)for(_P[r]=i<<7,t=0;t<1<<pP[r]-7;t++)yP[256+i++]=r;for(e=0;e<=dP;e++)A[e]=0;for(t=0;t<=143;)wP[2*t+1]=8,t++,A[8]++;for(;t<=255;)wP[2*t+1]=9,t++,A[9]++;for(;t<=279;)wP[2*t+1]=7,t++,A[7]++;for(;t<=287;)wP[2*t+1]=8,t++,A[8]++;for(MP(wP,287,A),t=0;t<uP;t++)vP[2*t+1]=5,vP[2*t]=kP(t,5);xP=new CP(wP,fP,257,hP,dP),EP=new CP(vP,pP,0,uP,dP),SP=new CP(new Array(0),gP,0,19,7)})(),WP=!0),t.l_desc=new FP(t.dyn_ltree,xP),t.d_desc=new FP(t.dyn_dtree,EP),t.bl_desc=new FP(t.bl_tree,SP),t.bi_buf=0,t.bi_valid=0,PP(t)},_tr_stored_block:VP,_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<cP;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),RP(t,t.l_desc),RP(t,t.d_desc),s=(t=>{let e;for(HP(t,t.dyn_ltree,t.l_desc.max_code),HP(t,t.dyn_dtree,t.d_desc.max_code),RP(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*mP[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?VP(t,e,n,r):4===t.strategy||A===i?(IP(t,2+(r?1:0),3),DP(t,wP,vP)):(IP(t,4+(r?1:0),3),((t,e,n,r)=>{let i;for(IP(t,e-257,5),IP(t,n-1,5),IP(t,r-4,4),i=0;i<r;i++)IP(t,t.bl_tree[2*mP[i]+1],3);jP(t,t.dyn_ltree,e-1),jP(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),DP(t,t.dyn_ltree,t.dyn_dtree)),PP(t),r&&NP(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*(bP[n]+cP+1)]++,t.dyn_dtree[2*LP(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{IP(t,2,3),QP(t,256,wP),(t=>{16===t.bi_valid?(UP(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 GP=(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 zP=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 qP=(t,e,n,r)=>{const i=zP,A=r+n;t^=-1;for(let s=r;s<A;s++)t=t>>>8^i[255&(t^e[s])];return-1^t},XP={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"},YP={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:$P,_tr_stored_block:JP,_tr_flush_block:ZP,_tr_tally:tN,_tr_align:eN}=KP,{Z_NO_FLUSH:nN,Z_PARTIAL_FLUSH:rN,Z_FULL_FLUSH:iN,Z_FINISH:AN,Z_BLOCK:sN,Z_OK:aN,Z_STREAM_END:oN,Z_STREAM_ERROR:lN,Z_DATA_ERROR:cN,Z_BUF_ERROR:hN,Z_DEFAULT_COMPRESSION:uN,Z_FILTERED:dN,Z_HUFFMAN_ONLY:fN,Z_RLE:pN,Z_FIXED:gN,Z_DEFAULT_STRATEGY:mN,Z_UNKNOWN:wN,Z_DEFLATED:vN}=YP,yN=258,bN=262,BN=42,_N=113,CN=666,xN=(t,e)=>(t.msg=XP[e],e),EN=t=>2*t-(t>4?9:0),SN=t=>{let e=t.length;for(;--e>=0;)t[e]=0},FN=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 LN=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const UN=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))},IN=(t,e)=>{ZP(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,UN(t.strm)},QN=(t,e)=>{t.pending_buf[t.pending++]=e},kN=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},MN=(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=GP(t.adler,e,i,n):2===t.state.wrap&&(t.adler=qP(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)},PN=(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-bN?t.strstart-(t.w_size-bN):0,l=t.window,c=t.w_mask,h=t.prev,u=t.strstart+yN;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=yN-(u-A),A=u-yN,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},NN=t=>{const e=t.w_size;let n,r,i;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-bN)&&(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),FN(t),r+=e),0===t.strm.avail_in)break;if(n=MN(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=LN(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=LN(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<bN&&0!==t.strm.avail_in)},ON=(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!==AN||e===nN||n!==r+t.strm.avail_in))break;s=e===AN&&n===r+t.strm.avail_in?1:0,JP(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,UN(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&&(MN(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!==nN&&e!==AN&&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&&(MN(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===AN)&&e!==nN&&0===t.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=e===AN&&0===t.strm.avail_in&&n===r?1:0,JP(t,t.block_start,n,s),t.block_start+=n,UN(t.strm)),s?3:1)},TN=(t,e)=>{let n,r;for(;;){if(t.lookahead<bN){if(NN(t),t.lookahead<bN&&e===nN)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=LN(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-bN&&(t.match_length=PN(t,n)),t.match_length>=3)if(r=tN(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=LN(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=LN(t,t.ins_h,t.window[t.strstart+1]);else r=tN(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(IN(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===AN?(IN(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IN(t,!1),0===t.strm.avail_out)?1:2},DN=(t,e)=>{let n,r,i;for(;;){if(t.lookahead<bN){if(NN(t),t.lookahead<bN&&e===nN)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=LN(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-bN&&(t.match_length=PN(t,n),t.match_length<=5&&(t.strategy===dN||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=tN(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=LN(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&&(IN(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(r=tN(t,0,t.window[t.strstart-1]),r&&IN(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=tN(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===AN?(IN(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IN(t,!1),0===t.strm.avail_out)?1:2};function RN(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 HN=[new RN(0,0,0,0,ON),new RN(4,4,8,4,TN),new RN(4,5,16,8,TN),new RN(4,6,32,32,TN),new RN(4,4,16,16,DN),new RN(8,16,32,32,DN),new RN(8,16,128,128,DN),new RN(8,32,128,256,DN),new RN(32,128,258,1024,DN),new RN(32,258,258,4096,DN)];function jN(){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=vN,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),SN(this.dyn_ltree),SN(this.dyn_dtree),SN(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),SN(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),SN(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 WN=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==BN&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==_N&&e.status!==CN?1:0},VN=t=>{if(WN(t))return xN(t,lN);t.total_in=t.total_out=0,t.data_type=wN;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?BN:_N,t.adler=2===e.wrap?0:1,e.last_flush=-2,$P(e),aN},KN=t=>{const e=VN(t);var n;return e===aN&&((n=t.state).window_size=2*n.w_size,SN(n.head),n.max_lazy_match=HN[n.level].max_lazy,n.good_match=HN[n.level].good_length,n.nice_match=HN[n.level].nice_length,n.max_chain_length=HN[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},GN=(t,e,n,r,i,A)=>{if(!t)return lN;let s=1;if(e===uN&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==vN||r<8||r>15||e<0||e>9||A<0||A>gN||8===r&&1!==s)return xN(t,lN);8===r&&(r=9);const a=new jN;return t.state=a,a.strm=t,a.status=BN,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,KN(t)};var zN={deflateInit:(t,e)=>GN(t,e,vN,15,8,mN),deflateInit2:GN,deflateReset:KN,deflateResetKeep:VN,deflateSetHeader:(t,e)=>WN(t)||2!==t.state.wrap?lN:(t.state.gzhead=e,aN),deflate:(t,e)=>{if(WN(t)||e>sN||e<0)return t?xN(t,lN):lN;const n=t.state;if(!t.output||0!==t.avail_in&&!t.input||n.status===CN&&e!==AN)return xN(t,0===t.avail_out?hN:lN);const r=n.last_flush;if(n.last_flush=e,0!==n.pending){if(UN(t),0===t.avail_out)return n.last_flush=-1,aN}else if(0===t.avail_in&&EN(e)<=EN(r)&&e!==AN)return xN(t,hN);if(n.status===CN&&0!==t.avail_in)return xN(t,hN);if(n.status===BN&&0===n.wrap&&(n.status=_N),n.status===BN){let e=vN+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=fN||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,kN(n,e),0!==n.strstart&&(kN(n,t.adler>>>16),kN(n,65535&t.adler)),t.adler=1,n.status=_N,UN(t),0!==n.pending)return n.last_flush=-1,aN}if(57===n.status)if(t.adler=0,QN(n,31),QN(n,139),QN(n,8),n.gzhead)QN(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)),QN(n,255&n.gzhead.time),QN(n,n.gzhead.time>>8&255),QN(n,n.gzhead.time>>16&255),QN(n,n.gzhead.time>>24&255),QN(n,9===n.level?2:n.strategy>=fN||n.level<2?4:0),QN(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(QN(n,255&n.gzhead.extra.length),QN(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=qP(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(QN(n,0),QN(n,0),QN(n,0),QN(n,0),QN(n,0),QN(n,9===n.level?2:n.strategy>=fN||n.level<2?4:0),QN(n,3),n.status=_N,UN(t),0!==n.pending)return n.last_flush=-1,aN;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=qP(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex+=i,UN(t),0!==n.pending)return n.last_flush=-1,aN;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=qP(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=qP(t.adler,n.pending_buf,n.pending-r,r)),UN(t),0!==n.pending)return n.last_flush=-1,aN;r=0}e=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,QN(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>r&&(t.adler=qP(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=qP(t.adler,n.pending_buf,n.pending-r,r)),UN(t),0!==n.pending)return n.last_flush=-1,aN;r=0}e=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,QN(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>r&&(t.adler=qP(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&&(UN(t),0!==n.pending))return n.last_flush=-1,aN;QN(n,255&t.adler),QN(n,t.adler>>8&255),t.adler=0}if(n.status=_N,UN(t),0!==n.pending)return n.last_flush=-1,aN}if(0!==t.avail_in||0!==n.lookahead||e!==nN&&n.status!==CN){let r=0===n.level?ON(n,e):n.strategy===fN?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(NN(t),0===t.lookahead)){if(e===nN)return 1;break}if(t.match_length=0,n=tN(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(IN(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===AN?(IN(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IN(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===pN?((t,e)=>{let n,r,i,A;const s=t.window;for(;;){if(t.lookahead<=yN){if(NN(t),t.lookahead<=yN&&e===nN)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+yN;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=yN-(A-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=tN(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=tN(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(IN(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===AN?(IN(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IN(t,!1),0===t.strm.avail_out)?1:2})(n,e):HN[n.level].func(n,e);if(3!==r&&4!==r||(n.status=CN),1===r||3===r)return 0===t.avail_out&&(n.last_flush=-1),aN;if(2===r&&(e===rN?eN(n):e!==sN&&(JP(n,0,0,!1),e===iN&&(SN(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),UN(t),0===t.avail_out))return n.last_flush=-1,aN}return e!==AN?aN:n.wrap<=0?oN:(2===n.wrap?(QN(n,255&t.adler),QN(n,t.adler>>8&255),QN(n,t.adler>>16&255),QN(n,t.adler>>24&255),QN(n,255&t.total_in),QN(n,t.total_in>>8&255),QN(n,t.total_in>>16&255),QN(n,t.total_in>>24&255)):(kN(n,t.adler>>>16),kN(n,65535&t.adler)),UN(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?aN:oN)},deflateEnd:t=>{if(WN(t))return lN;const e=t.state.status;return t.state=null,e===_N?xN(t,cN):aN},deflateSetDictionary:(t,e)=>{let n=e.length;if(WN(t))return lN;const r=t.state,i=r.wrap;if(2===i||1===i&&r.status!==BN||r.lookahead)return lN;if(1===i&&(t.adler=GP(t.adler,e,n,0)),r.wrap=0,n>=r.w_size){0===i&&(SN(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,NN(r);r.lookahead>=3;){let t=r.strstart,e=r.lookahead-2;do{r.ins_h=LN(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,NN(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,aN},deflateInfo:"pako deflate (from Nodeca project)"};const qN=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var XN=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)qN(n,e)&&(t[e]=n[e])}}return t},YN=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 $N=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(a3){$N=!1}const JN=new Uint8Array(256);for(let o3=0;o3<256;o3++)JN[o3]=o3>=252?6:o3>=248?5:o3>=240?4:o3>=224?3:o3>=192?2:1;JN[254]=JN[254]=1;var ZN=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},tO=(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=JN[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&&$N)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)},eO=(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+JN[t[n]]>e?n:e};var nO=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 rO=Object.prototype.toString,{Z_NO_FLUSH:iO,Z_SYNC_FLUSH:AO,Z_FULL_FLUSH:sO,Z_FINISH:aO,Z_OK:oO,Z_STREAM_END:lO,Z_DEFAULT_COMPRESSION:cO,Z_DEFAULT_STRATEGY:hO,Z_DEFLATED:uO}=YP;function dO(t){this.options=XN({level:cO,method:uO,chunkSize:16384,windowBits:15,memLevel:8,strategy:hO},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 nO,this.strm.avail_out=0;let n=zN.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==oO)throw new Error(XP[n]);if(e.header&&zN.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?ZN(e.dictionary):"[object ArrayBuffer]"===rO.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=zN.deflateSetDictionary(this.strm,t),n!==oO)throw new Error(XP[n]);this._dict_set=!0}}function fO(t,e){const n=new dO(e);if(n.push(t,!0),n.err)throw n.msg||XP[n.err];return n.result}dO.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?aO:iO,"string"==typeof t?n.input=ZN(t):"[object ArrayBuffer]"===rO.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===AO||A===sO)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=zN.deflate(n,A),i===lO)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=zN.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===oO;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},dO.prototype.onData=function(t){this.chunks.push(t)},dO.prototype.onEnd=function(t){t===oO&&(this.result=YN(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var pO={Deflate:dO,deflate:fO,deflateRaw:function(t,e){return(e=e||{}).raw=!0,fO(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,fO(t,e)}};const gO=16209;var mO=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=gO;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=gO;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=gO;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=gO;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 wO=15,vO=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]),yO=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]),bO=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]),BO=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 _O=(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<=wO;p++)E[p]=0;for(g=0;g<r;g++)E[e[n+g]]++;for(v=o,w=wO;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<=wO;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<wO;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=vO,I=yO,f=257):(x=bO,I=BO,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:CO,Z_BLOCK:xO,Z_TREES:EO,Z_OK:SO,Z_STREAM_END:FO,Z_NEED_DICT:LO,Z_STREAM_ERROR:UO,Z_DATA_ERROR:IO,Z_MEM_ERROR:QO,Z_BUF_ERROR:kO,Z_DEFLATED:MO}=YP,PO=16180,NO=16190,OO=16191,TO=16192,DO=16194,RO=16199,HO=16200,jO=16206,WO=16209,VO=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function KO(){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 GO=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<PO||e.mode>16211?1:0},zO=t=>{if(GO(t))return UO;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=PO,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,SO},qO=t=>{if(GO(t))return UO;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,zO(t)},XO=(t,e)=>{let n;if(GO(t))return UO;const r=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?UO:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,qO(t))},YO=(t,e)=>{if(!t)return UO;const n=new KO;t.state=n,n.strm=t,n.window=null,n.mode=PO;const r=XO(t,e);return r!==SO&&(t.state=null),r};let $O,JO,ZO=!0;const tT=t=>{if(ZO){$O=new Int32Array(512),JO=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(_O(1,t.lens,0,288,$O,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;_O(2,t.lens,0,32,JO,0,t.work,{bits:5}),ZO=!1}t.lencode=$O,t.lenbits=9,t.distcode=JO,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:qO,inflateReset2:XO,inflateResetKeep:zO,inflateInit:t=>YO(t,15),inflateInit2:YO,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(GO(t)||!t.output||!t.input&&0!==t.avail_in)return UO;n=t.state,n.mode===OO&&(n.mode=TO),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,_=SO;t:for(;;)switch(n.mode){case PO:if(0===n.wrap){n.mode=TO;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=qP(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=WO;break}if((15&l)!==MO){t.msg="unknown compression method",n.mode=WO;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=WO;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&l?16189:OO,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)!==MO){t.msg="unknown compression method",n.mode=WO;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=WO;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=qP(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=qP(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=qP(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=qP(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=qP(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=qP(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=qP(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=WO;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=OO;break;case 16189:for(;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}t.adler=n.check=VO(l),l=0,c=0,n.mode=NO;case NO: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,LO;t.adler=n.check=1,n.mode=OO;case OO:if(e===xO||e===EO)break t;case TO:if(n.last){l>>>=7&c,c-=7&c,n.mode=jO;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=RO,e===EO){l>>>=2,c-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=WO}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=WO;break}if(n.length=65535&l,l=0,c=0,n.mode=DO,e===EO)break t;case DO: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=OO;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=WO;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},_=_O(0,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid code lengths set",n.mode=WO;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=WO;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=WO;break}for(;d--;)n.lens[n.have++]=B}}if(n.mode===WO)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=WO;break}if(n.lenbits=9,E={bits:n.lenbits},_=_O(1,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid literal/lengths set",n.mode=WO;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},_=_O(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,_){t.msg="invalid distances set",n.mode=WO;break}if(n.mode=RO,e===EO)break t;case RO:n.mode=HO;case HO: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,mO(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===OO&&(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=OO;break}if(64&m){t.msg="invalid literal/length code",n.mode=WO;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=WO;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=WO;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=WO;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=HO);break;case 16205:if(0===o)break t;i[s++]=n.length,o--,n.mode=HO;break;case jO: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?qP(n.check,i,u,s-u):GP(n.check,i,u,s-u)),u=o,4&n.wrap&&(n.flags?l:VO(l))!==n.check){t.msg="incorrect data check",n.mode=WO;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=WO;break}l=0,c=0}n.mode=16208;case 16208:_=FO;break t;case WO:_=IO;break t;case 16210:return QO;default:return UO}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<WO&&(n.mode<jO||e!==CO))&&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?qP(n.check,i,u,t.next_out-u):GP(n.check,i,u,t.next_out-u)),t.data_type=n.bits+(n.last?64:0)+(n.mode===OO?128:0)+(n.mode===RO||n.mode===DO?256:0),(0===h&&0===u||e===CO)&&_===SO&&(_=kO),_},inflateEnd:t=>{if(GO(t))return UO;let e=t.state;return e.window&&(e.window=null),t.state=null,SO},inflateGetHeader:(t,e)=>{if(GO(t))return UO;const n=t.state;return 2&n.wrap?(n.head=e,e.done=!1,SO):UO},inflateSetDictionary:(t,e)=>{const n=e.length;let r,i,A;return GO(t)?UO:(r=t.state,0!==r.wrap&&r.mode!==NO?UO:r.mode===NO&&(i=1,i=GP(i,e,n,0),i!==r.check)?IO:(A=eT(t,e,n,n),A?(r.mode=16210,QO):(r.havedict=1,SO)))},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}=YP;function dT(t){this.options=XN({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 nO,this.strm.avail_out=0;let n=nT.inflateInit2(this.strm,e.windowBits);if(n!==aT)throw new Error(XP[n]);if(this.header=new rT,nT.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=ZN(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(XP[n])}function fT(t,e){const n=new dT(e);if(n.push(t),n.err)throw n.msg||XP[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=eO(n.output,n.next_out),e=n.next_out-t,i=tO(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=YN(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}=pO,{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:YP};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(s3){throw console.error("❌ Erro ao converter PDF para imagens:",s3),s3}}),ET=()=>Wc(this,null,function*(){try{return 200===(yield e.get("http://localhost:9999/health",{timeout:3e3})).status}catch(s3){return console.log("🖨️ Impressora não detectada:",s3.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(s3){throw console.error("❌ Erro ao enviar para impressão:",s3),s3}}),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(s3){throw console.error("❌ Erro ao baixar PDF:",s3),s3}}),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(s3){return console.error("❌ Erro geral no processo de impressão:",s3),{success:!1,error:s3.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 PT(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 NT=(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}}},OT=(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=t=>Wc(this,null,function*(){return console.warn("LabelsAPI não carregado - usando placeholder"),null});const HT=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(s3){console.error("Erro ao processar dados da impressora:",s3)}}),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(s3){console.error("Erro ao conectar SSE:",s3),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))),jT=(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},WT=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},VT={PECA_TIPO:["Matéria Prima","Produto Acabado","Produto Intermediário"],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 KT={printerName:null,paperSize:"A4",orientation:"portrait",defaultTemplate:"template-padrao",autoDownloadOnPrinterError:!0,defaultTransformer:{fieldMap:"legacy",fieldMapSource:null}};function GT(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 zT=(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&&!WT(n))throw new Error("defaultTransformer.fieldMapSource inválido")}const e=Qc({autoConnectPrinter:!0},t);if(KT=Qc(Qc({},KT),e),e.token&&console.warn("updateApiToken não carregado - usando placeholder"),e.autoConnectPrinter)try{XT(),console.log("🖨️ Auto-conectando ao SSE da impressora...")}catch(s3){console.warn("⚠️ Falha na auto-conexão do SSE da impressora:",s3.message)}return console.log("🏷️ Etiquetas.js initialized successfully"),console.log("🔄 Default transformer:",KT.defaultTransformer.fieldMap),console.log("🖨️ Auto-connect printer:",e.autoConnectPrinter),KT},qT=()=>Wc(this,null,function*(){try{const t=HT.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:KT.paperSize,orientation:KT.orientation,globalPrinterName:KT.printerName}}catch(s3){return{connected:!1,error:s3.message,status:"error",printerName:"Erro ao obter status",hasDefaultPrinter:!1,message:`Erro: ${s3.message}`,printer:null,sseConnected:!1,paperSize:KT.paperSize,orientation:KT.orientation}}}),XT=()=>{try{HT.getState().connectToSSE(),console.log("🔌 Conectando ao SSE da impressora...")}catch(s3){console.error("❌ Erro ao conectar SSE da impressora:",s3)}};function YT(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 $T=(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=KT.defaultTransformer,i&&"none"!==i.fieldMap){const{fieldMap:e,fieldMapSource:r}=i;let a;switch(e){case"legacy":a=VT,console.log("🔄 Using legacy transformer");break;case"custom":if(!r)throw new Error('fieldMapSource é obrigatório quando fieldMap="custom"');if(!WT(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&&!WT(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=>jT(t,e)):jT(t,e)}catch(s3){if(A&&console.error("❌ Erro ao aplicar transformações:",s3.message),i)throw s3;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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating label:",s3),s3}}),JT=(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=KT.defaultTransformer;t&&"none"!==t.fieldMap?(r=!0,i=`${t.fieldMap} (default from init)`):(r=!1,i="none (disabled in init)")}const A=yield $T(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(s3){throw console.error("❌ Error in smart label sending:",s3),s3}}),ZT=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating part label:",s3),s3}}),tD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(t).map(t=>{return e=t,console.log("=>>",e),Qc({},e);var e}),A=Qc({dataSource:i,labels:yield sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating thickening label:",s3),s3}}),eD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating input label:",s3),s3}}),nD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating scrap label:",s3),s3}}),rD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating volume label:",s3),s3}}),iD=(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(s3){throw console.error("❌ Download error:",s3),s3}}),AD=(t,...e)=>Wc(this,[t,...e],function*(t,e={}){try{const n=HT.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:KT.printerName,paperSize:KT.paperSize,orientation:KT.orientation},e.metadata),scale:e.scale||1.5,autoDownloadOnError:!1!==KT.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(s3){if(console.error("❌ Print error:",s3),KT.autoDownloadOnPrinterError)try{return console.log("📥 Tentando download como alternativa..."),yield iD(t,e.filename||"etiqueta.pdf"),{success:!0,downloaded:!0,fileName:e.filename||"etiqueta.pdf",message:"Falha na impressão - PDF baixado como alternativa",error:s3.message,printerError:!0}}catch(n){console.error("❌ Erro também no download:",n)}throw s3}}),sD=t=>Wc(this,null,function*(){try{const e=yield function(t){return Wc(this,null,function*(){try{const e=yield RT(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(s3){throw console.error(`Erro ao buscar template: ${s3.message}`),s3}})}(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(s3){return console.error("❌ Error loading template:",s3),[{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}]}}),aD=(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}},oD={init:zT,getPrinterStatus:qT,isPrinterReady:()=>Wc(this,null,function*(){try{const t=HT.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?[]:YT(e,n)}}catch(s3){return{ready:!1,error:s3.message,message:"Erro ao verificar status da impressora",recommendations:["Verifique a conexão com o servidor de impressão"]}}}),makeLabel:$T,sendLabel:JT,makePartLabel:ZT,makeThickeningLabel:tD,makeInputLabel:eD,makeScrapLabel:nD,makeVolumeLabel:rD,downloadPDF:iD,sendToPrinter:AD,sendPartLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield ZT(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(s3){throw console.error("❌ Error in smart part sending:",s3),s3}}),sendTamponamentoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield tD(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(s3){throw console.error("❌ Error in smart thickening sending:",s3),s3}}),sendInsumoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield eD(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(s3){throw console.error("❌ Error in smart input sending:",s3),s3}}),sendRetalhoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield nD(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(s3){throw console.error("❌ Error in smart scrap sending:",s3),s3}}),sendVolumeLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield rD(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(s3){throw console.error("❌ Error in smart volume sending:",s3),s3}}),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 ZT(i,e);break;case"thickening":t=yield tD(i,e);break;case"inputs":t=yield eD(i,e);break;case"scraps":t=yield nD(i,e);break;case"volumes":t=yield rD(i,e);break;default:throw new Error(`Unsupported label type: ${n}`)}r.push(t)}catch(s3){console.error(`❌ Error generating label for item ${i.id}:`,s3),r.push(null)}return r}),validateLabelData:aD,legacyFieldMap:VT,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:jT,legacyTransformer:t=>jT(t,VT)},lD=kc(Qc({},oD),{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 PL=!1;const NL=t=>t;const OL=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=NL,n){"production"!==(QL?"production":void 0)&&n&&!PL&&(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"),PL=!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?OL(t):OL,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 PU extends UU{constructor(t){super(t,"FormatError")}}class NU extends UU{constructor(t){super(t,"AbortException")}}function OU(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),OU(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(OU(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{};Pc(XU,"CSS",96),Pc(XU,"PDF",72),Pc(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(){Pc(this,"started",Object.create(null)),Pc(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;Oc(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=Oc(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),Oc(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=Oc(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=Oc(this,o).toolbarPosition;if(i){const{style:t}=e,n="ltr"===Oc(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 Oc(this,s)}hide(){var t;Oc(this,s).classList.add("hidden"),null==(t=Oc(this,a))||t.hideDropdown()}show(){var t,e;Oc(this,s).classList.remove("hidden"),null==(t=Oc(this,c))||t.shown(),null==(e=Oc(this,h))||e.shown()}addDeleteButton(){const{editorType:e,_uiManager:n}=Oc(this,o),r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",Oc(t,d)[e]),Rc(this,g,v).call(this,r),r.addEventListener("click",t=>{n.delete()},{signal:n._signal}),Oc(this,l).append(r)}addAltText(t){return Wc(this,null,function*(){const e=yield t.render();Rc(this,g,v).call(this,e),Oc(this,l).append(e,Oc(this,g,y)),Dc(this,c,t)})}addComment(t){if(Oc(this,h))return;const e=t.render();e&&(Rc(this,g,v).call(this,e),Oc(this,l).prepend(e,Oc(this,g,y)),Dc(this,h,t),t.toolbar=this)}addColorPicker(t){if(Oc(this,a))return;Dc(this,a,t);const e=t.renderButton();Rc(this,g,v).call(this,e),Oc(this,l).append(e,Oc(this,g,y))}addEditSignatureButton(t){return Wc(this,null,function*(){const e=Dc(this,u,yield t.renderEditButton(Oc(this,o)));Rc(this,g,v).call(this,e),Oc(this,l).append(e,Oc(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){Oc(this,u)&&(Oc(this,u).title=t)}remove(){var t;Oc(this,s).remove(),null==(t=Oc(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){Oc(this,o)._focusEventsAllowed=!1,AI(t)},w=function(t){Oc(this,o)._focusEventsAllowed=!0,AI(t)},v=function(t){const e=Oc(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}=Oc(this,B)||Dc(this,B,Rc(this,C,x).call(this));t.append(Oc(this,B)),A.insetInlineEnd=100*r+"%",A.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){Oc(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:Oc(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=Oc(this,_)._signal;t.addEventListener("contextmenu",iI,{signal:n}),t.addEventListener("click",()=>{Oc(this,_).highlightSelection("floating_button")},{signal:n}),Oc(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*(){Oc(this,I)||Dc(this,I,new Map);const e=Oc(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){Oc(this,I)||Dc(this,I,new Map);let n=Oc(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_${Oc(this,L)}_${Hc(this,U)._++}`,refCounter:1,isSvg:!1},Oc(this,I).set(t,n),Oc(this,I).set(n.id,n),n}getSvgUrl(t){const e=Oc(this,I).get(t);return(null==e?void 0:e.isSvg)?e.svgUrl:null}deleteId(t){var e;Oc(this,I)||Dc(this,I,new Map);const n=Oc(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_${Oc(this,L)}_`)}};L=new WeakMap,U=new WeakMap,I=new WeakMap,Q=new WeakSet,k=function(t,e){return Wc(this,null,function*(){Oc(this,I)||Dc(this,I,new Map);let n=Oc(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_${Oc(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 Oc(this,I).set(t,n),n&&Oc(this,I).set(n.id,n),n})};let vI=wI;class yI{constructor(t=128){Tc(this,M,[]),Tc(this,P,!1),Tc(this,N),Tc(this,O,-1),Dc(this,N,t)}add({cmd:t,undo:e,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:A=!1,keepUndo:s=!1}){if(r&&t(),Oc(this,P))return;const a={cmd:t,undo:e,post:n,type:i};if(-1===Oc(this,O))return Oc(this,M).length>0&&(Oc(this,M).length=0),Dc(this,O,0),void Oc(this,M).push(a);if(A&&Oc(this,M)[Oc(this,O)].type===i)return s&&(a.undo=Oc(this,M)[Oc(this,O)].undo),void(Oc(this,M)[Oc(this,O)]=a);const o=Oc(this,O)+1;o===Oc(this,N)?Oc(this,M).splice(0,1):(Dc(this,O,o),o<Oc(this,M).length&&Oc(this,M).splice(o)),Oc(this,M).push(a)}undo(){if(-1===Oc(this,O))return;Dc(this,P,!0);const{undo:t,post:e}=Oc(this,M)[Oc(this,O)];t(),null==e||e(),Dc(this,P,!1),Dc(this,O,Oc(this,O)-1)}redo(){if(Oc(this,O)<Oc(this,M).length-1){Dc(this,O,Oc(this,O)+1),Dc(this,P,!0);const{cmd:t,post:e}=Oc(this,M)[Oc(this,O)];t(),null==e||e(),Dc(this,P,!1)}}hasSomethingToUndo(){return-1!==Oc(this,O)}hasSomethingToRedo(){return Oc(this,O)<Oc(this,M).length-1}cleanType(t){if(-1!==Oc(this,O)){for(let e=Oc(this,O);e>=0;e--)if(Oc(this,M)[e].type!==t)return Oc(this,M).splice(e+1,Oc(this,O)-e),void Dc(this,O,e);Oc(this,M).length=0,Dc(this,O,-1)}}destroy(){Dc(this,M,null)}}M=new WeakMap,P=new WeakMap,N=new WeakMap,O=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}};Pc(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),Pc(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=Oc(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=>Oc(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)&&Oc(t,Ft).contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&Oc(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=Oc(this,It))||t.resolve(),Dc(this,It,null),null==(e=Oc(this,R))||e.abort(),Dc(this,R,null),this._signal=null;for(const l of Oc(this,W).values())l.destroy();Oc(this,W).clear(),Oc(this,j).clear(),Oc(this,et).clear(),null==(n=Oc(this,mt))||n.clear(),Dc(this,H,null),Oc(this,yt).clear(),Oc(this,z).destroy(),null==(r=Oc(this,V))||r.destroy(),null==(i=Oc(this,q))||i.destroy(),null==(A=Oc(this,Bt))||A.destroy(),null==(s=Oc(this,ct))||s.hide(),Dc(this,ct,null),null==(a=Oc(this,gt))||a.destroy(),Dc(this,gt,null),Oc(this,st)&&(clearTimeout(Oc(this,st)),Dc(this,st,null)),Oc(this,St)&&(clearTimeout(Oc(this,St)),Dc(this,St,null)),null==(o=this._editorUndoBar)||o.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return Oc(this,wt)}get useNewAltTextFlow(){return Oc(this,rt)}get useNewAltTextWhenAddingImage(){return Oc(this,it)}get hcmFilter(){return LU(this,"hcmFilter",Oc(this,_t)?Oc(this,At).addHCMFilter(Oc(this,_t).foreground,Oc(this,_t).background):"none")}get direction(){return LU(this,"direction",getComputedStyle(Oc(this,Ft)).direction)}get _highlightColors(){return LU(this,"_highlightColors",Oc(this,ot)?new Map(Oc(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=!!Oc(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=Oc(this,V))||n.editAltText(this,t,e)}hasCommentManager(){return!!Oc(this,q)}editComment(t,e){var n;null==(n=Oc(this,q))||n.open(this,t,e)}getSignature(t){var e;null==(e=Oc(this,Bt))||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return Oc(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(){Oc(this,Ft).focus()}findParent(t,e){for(const n of Oc(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){Oc(this,Lt).classList.toggle("noUserSelect",t)}addShouldRescale(t){Oc(this,et).add(t)}removeShouldRescale(t){Oc(this,et).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*YU.PDF_TO_CSS_UNITS;for(const n of Oc(this,et))n.onScaleChanging();null==(e=Oc(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=Oc(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()||!Oc(this,K)||Oc(this,K).has(t.id)||Oc(this,K).setValue(t.id,t)}a11yAlert(t,e=null){const n=Oc(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,Oc(this,lt)&&(Dc(this,lt,!1),Rc(this,Qt,Ot).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of Oc(this,yt))if(e.div.contains(t)){Dc(this,pt,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!Oc(this,pt))return;const[t,e]=Oc(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 Oc(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 Oc(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=Oc(this,H))||e.commitOrRemove(),!this.hasSelection)return;const n=[];for(const r of Oc(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 Oc(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),Oc(this,vt)===tU.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,Oc(this,lt)&&(Dc(this,lt,!1),Rc(this,Qt,Ot).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:Oc(this,vt)!==tU.NONE,isEmpty:Rc(this,Qt,Jt).call(this),hasSomethingToUndo:Oc(this,z).hasSomethingToUndo(),hasSomethingToRedo:Oc(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(!Oc(this,tt)){Dc(this,tt,t);for(const t of Oc(this,tt))Rc(this,Qt,zt).call(this,t.defaultPropertiesToUpdate)}}getId(){return Oc(this,ht).id}get currentLayer(){return Oc(this,W).get(Oc(this,$))}getLayer(t){return Oc(this,W).get(t)}get currentPageIndex(){return Oc(this,$)}addLayer(t){Oc(this,W).set(t.pageIndex,t),Oc(this,ut)?t.enable():t.disable()}removeLayer(t){Oc(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(Oc(this,vt)!==t&&(!Oc(this,It)||(yield Oc(this,It).promise,Oc(this,It)))){if(Dc(this,It,Promise.withResolvers()),null==(A=Oc(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 Oc(this,It).resolve();t===tU.SIGNATURE&&(yield null==(a=Oc(this,Bt))?void 0:a.loadSignatures()),this.setEditingState(!0),yield Rc(this,Qt,qt).call(this),this.unselectAll();for(const e of Oc(this,W).values())e.updateMode(t);if(!e)return n&&this.addNewEditorFromKeyboard(),void Oc(this,It).resolve();for(const t of Oc(this,j).values())t.annotationElementId===e||t.id===e?(this.setSelected(t),i?t.editComment():r&&t.enterInEditMode()):t.unselect();Oc(this,It).resolve()}})}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==Oc(this,vt)&&this._eventBus.dispatch("switchannotationeditormode",Qc({source:this},t))}updateParams(t,e){if(Oc(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"}}}),(Oc(this,Ct)||Dc(this,Ct,new Map)).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const n of Oc(this,yt))n.updateParams(t,e);else for(const n of Oc(this,tt))n.updateDefaultParams(t,e)}}showAllEditors(t,e,n=!1){var r,i;for(const A of Oc(this,j).values())A.editorType===t&&A.show(e);(null==(i=null==(r=Oc(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(Oc(this,dt)!==t){Dc(this,dt,t);for(const e of Oc(this,W).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const n of Oc(this,j).values())n.pageIndex===t&&e.push(n);return e}getEditor(t){return Oc(this,j).get(t)}addEditor(t){Oc(this,j).set(t.id,t)}removeEditor(t){var e,n;t.div.contains(document.activeElement)&&(Oc(this,st)&&clearTimeout(Oc(this,st)),Dc(this,st,setTimeout(()=>{this.focusMainContainer(),Dc(this,st,null)},0))),Oc(this,j).delete(t.id),t.annotationElementId&&(null==(e=Oc(this,mt))||e.delete(t.annotationElementId)),this.unselect(t),t.annotationElementId&&Oc(this,J).has(t.annotationElementId)||null==(n=Oc(this,K))||n.remove(t.id)}addDeletedAnnotationElement(t){Oc(this,J).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return Oc(this,J).has(t)}removeDeletedAnnotationElement(t){Oc(this,J).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){Oc(this,H)!==t&&(Dc(this,H,t),t&&Rc(this,Qt,zt).call(this,t.propertiesToUpdate))}updateUI(t){Oc(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(Oc(this,yt).has(t))return Oc(this,yt).delete(t),t.unselect(),void Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection});Oc(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=Oc(this,Y))||e.commitOrRemove();for(const n of Oc(this,yt))n!==t&&n.unselect();Oc(this,yt).clear(),Oc(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 Oc(this,yt).has(t)}get firstSelectedEditor(){return Oc(this,yt).values().next().value}unselect(t){t.unselect(),Oc(this,yt).delete(t),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==Oc(this,yt).size}get isEnterHandled(){return 1===Oc(this,yt).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;Oc(this,z).undo(),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:Oc(this,z).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:Rc(this,Qt,Jt).call(this)}),null==(t=this._editorUndoBar)||t.hide()}redo(){Oc(this,z).redo(),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:Oc(this,z).hasSomethingToRedo(),isEmpty:Rc(this,Qt,Jt).call(this)})}addCommands(t){Oc(this,z).add(t),Rc(this,Qt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:Rc(this,Qt,Jt).call(this)})}cleanUndoStack(t){Oc(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]:[...Oc(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=Oc(this,H))||t.commitOrRemove()}hasSomethingToControl(){return Oc(this,H)||this.hasSelection}selectAll(){for(const t of Oc(this,yt))t.commit();Rc(this,Qt,Zt).call(this,Oc(this,j).values())}unselectAll(){var t;if((!Oc(this,H)||(Oc(this,H).commitOrRemove(),Oc(this,vt)===tU.NONE))&&!(null==(t=Oc(this,Y))?void 0:t.commitOrRemove())&&this.hasSelection){for(const t of Oc(this,yt))t.unselect();Oc(this,yt).clear(),Rc(this,Qt,Gt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;Oc(this,Et)[0]+=t,Oc(this,Et)[1]+=e;const[r,i]=Oc(this,Et),A=[...Oc(this,yt)];Oc(this,St)&&clearTimeout(Oc(this,St)),Dc(this,St,setTimeout(()=>{Dc(this,St,null),Oc(this,Et)[0]=Oc(this,Et)[1]=0,this.addCommands({cmd:()=>{for(const t of A)Oc(this,j).has(t.id)&&(t.translateInPage(r,i),t.translationDone())},undo:()=>{for(const t of A)Oc(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 Oc(this,yt))Oc(this,Z).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!Oc(this,Z))return!1;this.disableUserSelect(!1);const t=Oc(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(Oc(this,j).has(t.id)){const i=Oc(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(Oc(this,Z))for(const n of Oc(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===Oc(this,yt).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return Oc(this,H)===t}getActive(){return Oc(this,H)}getMode(){return Oc(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}){(Oc(this,G)||Dc(this,G,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;null==(e=Oc(this,G))||e.delete(t)}renderAnnotationElement(t){var e;const n=null==(e=Oc(this,G))?void 0:e.get(t.data.id);if(!n)return;const r=Oc(this,K).getRawValue(n);r&&(Oc(this,vt)!==tU.NONE||r.hasBeenModified)&&r.renderAnnotationElement(t)}setMissingCanvas(t,e,n){var r;const i=null==(r=Oc(this,mt))?void 0:r.get(t);i&&(i.setCanvas(e,n),Oc(this,mt).delete(t))}addMissingCanvas(t,e){(Oc(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 Oc(this,W).values())if(n.hasTextLayer(t))return n;return null},Pt=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&&(Oc(this,ct)||Dc(this,ct,new pI(this)),Oc(this,ct).show(e,n,"ltr"===this.direction))},Nt=function(){var t,e,n;const r=document.getSelection();if(!r||r.isCollapsed)return void(Oc(this,bt)&&(null==(t=Oc(this,ct))||t.hide(),Dc(this,bt,null),Rc(this,Qt,Gt).call(this,{hasSelectedText:!1})));const{anchorNode:i}=r;if(i===Oc(this,bt))return;const A=Rc(this,Qt,kt).call(this,r).closest(".textLayer");if(A){if(null==(n=Oc(this,ct))||n.hide(),Dc(this,bt,i),Rc(this,Qt,Gt).call(this,{hasSelectedText:!0}),(Oc(this,vt)===tU.HIGHLIGHT||Oc(this,vt)===tU.NONE)&&(Oc(this,vt)===tU.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),Dc(this,lt,this.isShiftKeyDown),!this.isShiftKeyDown)){const t=Oc(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,Ot).call(this,"main_toolbar"))};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}}else Oc(this,bt)&&(null==(e=Oc(this,ct))||e.hide(),Dc(this,bt,null),Rc(this,Qt,Gt).call(this,{hasSelectedText:!1}))},Ot=function(t=""){Oc(this,vt)===tU.HIGHLIGHT?this.highlightSelection(t):Oc(this,nt)&&Rc(this,Qt,Pt).call(this)},Tt=function(){document.addEventListener("selectionchange",Rc(this,Qt,Nt).bind(this),{signal:this._signal})},Dt=function(){if(Oc(this,at))return;Dc(this,at,new AbortController);const t=this.combinedSignal(Oc(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=Oc(this,at))||t.abort(),Dc(this,at,null)},Ht=function(){if(Oc(this,ft))return;Dc(this,ft,new AbortController);const t=this.combinedSignal(Oc(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=Oc(this,ft))||t.abort(),Dc(this,ft,null)},Wt=function(){if(Oc(this,X))return;Dc(this,X,new AbortController);const t=this.combinedSignal(Oc(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=Oc(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])=>Oc(this,xt)[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(Oc(this,xt),t)}),Oc(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(!Oc(this,ut)){Dc(this,ut,!0);const t=[];for(const e of Oc(this,W).values())t.push(e.enable());yield Promise.all(t);for(const e of Oc(this,j).values())e.enable()}})},Xt=function(){if(this.unselectAll(),Oc(this,ut)){Dc(this,ut,!1);for(const t of Oc(this,W).values())t.disable();for(const t of Oc(this,j).values())t.disable()}},Yt=function(t){const e=Oc(this,W).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},$t=function(){let t=null;for(t of Oc(this,yt));return t},Jt=function(){if(0===Oc(this,j).size)return!0;if(1===Oc(this,j).size)for(const t of Oc(this,j).values())return t.isEmpty();return!1},Zt=function(t){for(const e of Oc(this,yt))e.unselect();Oc(this,yt).clear();for(const e of t)e.isEmpty()||(Oc(this,yt).add(e),e.select());Rc(this,Qt,Gt).call(this,{hasSelectedEditor:this.hasSelection})},Pc(CI,"TRANSLATE_SMALL",1),Pc(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),Oc(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),Oc(this,he)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Oc(t,ue).missing),n.setAttribute("data-l10n-id",Oc(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=Oc(this,oe)._uiManager._signal;e.addEventListener("contextmenu",iI,{signal:r}),e.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:r});const i=t=>{t.preventDefault(),Oc(this,oe)._uiManager.editAltText(Oc(this,oe)),Oc(this,he)&&Oc(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:Oc(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(){Oc(this,ne)&&(Oc(this,ne).focus({focusVisible:Oc(this,se)}),Dc(this,se,!1))}isEmpty(){return Oc(this,he)?null===Oc(this,te):!Oc(this,te)&&!Oc(this,ee)}hasData(){return Oc(this,he)?null!==Oc(this,te)||!!Oc(this,le):this.isEmpty()}get guessedText(){return Oc(this,le)}setGuessedText(e){return Wc(this,null,function*(){null===Oc(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(!Oc(this,he)||Oc(this,te))return null==(e=Oc(this,ae))||e.remove(),void Dc(this,ae,null);if(!Oc(this,ae)){const t=Dc(this,ae,document.createElement("div"));t.className="noAltTextBadge",Oc(this,oe).div.append(t)}Oc(this,ae).classList.toggle("hidden",!t)}serialize(t){let e=Oc(this,te);return t||Oc(this,le)!==e||(e=Oc(this,ce)),{altText:e,decorative:Oc(this,ee),guessedText:Oc(this,le),textWithDisclaimer:Oc(this,ce)}}get data(){return{altText:Oc(this,te),decorative:Oc(this,ee)}}set data({altText:t,decorative:e,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(Dc(this,le,n),Dc(this,ce,r)),Oc(this,te)===t&&Oc(this,ee)===e||(i||(Dc(this,te,t),Dc(this,ee,e)),Rc(this,de,pe).call(this))}toggle(t=!1){Oc(this,ne)&&(!t&&Oc(this,Ae)&&(clearTimeout(Oc(this,Ae)),Dc(this,Ae,null)),Oc(this,ne).disabled=!t)}shown(){Oc(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:Oc(this,de,fe)}})}destroy(){var t,e;null==(t=Oc(this,ne))||t.remove(),Dc(this,ne,null),Dc(this,re,null),Dc(this,ie,null),null==(e=Oc(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(Oc(this,te)?"added":null===Oc(this,te)&&this.guessedText&&"review")||"missing"},pe=function(){return Wc(this,null,function*(){var t,e,n;const r=Oc(this,ne);if(!r)return;if(Oc(this,he)){if(r.classList.toggle("done",!!Oc(this,te)),r.setAttribute("data-l10n-id",Oc(EI,ue)[Oc(this,de,fe)]),null==(t=Oc(this,re))||t.setAttribute("data-l10n-id",Oc(EI,ue)[`${Oc(this,de,fe)}-label`]),!Oc(this,te))return void(null==(e=Oc(this,ie))||e.remove())}else{if(!Oc(this,te)&&!Oc(this,ee))return r.classList.remove("done"),void(null==(n=Oc(this,ie))||n.remove());r.classList.add("done"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let i=Oc(this,ie);if(!i){Dc(this,ie,i=document.createElement("span")),i.className="tooltip",i.setAttribute("role","tooltip"),i.id=`alt-text-tooltip-${Oc(this,oe).id}`;const t=100,e=Oc(this,oe)._uiManager._signal;e.addEventListener("abort",()=>{clearTimeout(Oc(this,Ae)),Dc(this,Ae,null)},{once:!0}),r.addEventListener("mouseenter",()=>{Dc(this,Ae,setTimeout(()=>{Dc(this,Ae,null),Oc(this,ie).classList.add("show"),Oc(this,oe)._reportTelemetry({action:"alt_text_tooltip"})},t))},{signal:e}),r.addEventListener("mouseleave",()=>{var t;Oc(this,Ae)&&(clearTimeout(Oc(this,Ae)),Dc(this,Ae,null)),null==(t=Oc(this,ie))||t.classList.remove("show")},{signal:e})}Oc(this,ee)?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=Oc(this,te)),i.parentNode||r.append(i);const A=Oc(this,oe).getElementForAltText();null==A||A.setAttribute("aria-describedby",i.id)})},Tc(EI,ue,null),Pc(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(!Oc(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=Oc(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}=Oc(this,we).getClientDimensions(),r={top:t};"ltr"===Oc(this,we)._uiManager.direction?r.right=n:r.left=e,Oc(this,we)._uiManager.editComment(Oc(this,we),r)}finish(){Oc(this,ge)&&(Oc(this,ge).focus({focusVisible:Oc(this,me)}),Dc(this,me,!1))}isDeleted(){return Oc(this,Be)||""===Oc(this,ye)}hasBeenEdited(){return this.isDeleted()||Oc(this,ye)!==Oc(this,ve)}serialize(){return this.data}get data(){return{text:Oc(this,ye),date:Oc(this,be),deleted:Oc(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){Oc(this,ge)&&(Oc(this,ge).disabled=!t)}shown(){}destroy(){var t;null==(t=Oc(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,Pe),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,Oc(this,ke).signal])),t.addEventListener("touchstart",Rc(this,Pe,Ne).bind(this),{passive:!1,signal:Oc(this,Ie)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/hI.pixelRatio}destroy(){var t,e;null==(t=Oc(this,ke))||t.abort(),Dc(this,ke,null),null==(e=Oc(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,Pe=new WeakSet,Ne=function(t){var e,n,r;if(null==(e=Oc(this,Ee))?void 0:e.call(this))return;if(1===t.touches.length){if(Oc(this,Ue))return;const t=Dc(this,Ue,new AbortController),e=AbortSignal.any([Oc(this,Ie),t.signal]),n=Oc(this,_e),r={capture:!0,signal:e,passive:!1},i=t=>{var e;"touch"===t.pointerType&&(null==(e=Oc(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(!Oc(this,Me)){Dc(this,Me,new AbortController);const t=AbortSignal.any([Oc(this,Ie),Oc(this,Me).signal]),e=Oc(this,_e),r={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",Rc(this,Pe,Oe).bind(this),r);const i=Rc(this,Pe,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=Oc(this,Se))||n.call(this)}if(AI(t),2!==t.touches.length||(null==(r=Oc(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})},Oe=function(t){var e;if(!Oc(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=Oc(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(!Oc(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,!Oc(this,Ce))return void Dc(this,Ce,!0);const v=[(i+s)/2,(A+a)/2];null==(e=Oc(this,Fe))||e.call(this,v,w,m)},Te=function(t){var e;t.touches.length>=2||(Oc(this,Me)&&(Oc(this,Me).abort(),Dc(this,Me,null),null==(e=Oc(this,Le))||e.call(this)),Oc(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),Pc(this,"isSelected",!1),Pc(this,"_isCopy",!1),Pc(this,"_editToolbar",null),Pc(this,"_initialOptions",Object.create(null)),Pc(this,"_initialData",null),Pc(this,"_isVisible",!0),Pc(this,"_uiManager",null),Pc(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 Oc(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=Oc(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&&(Oc(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){Oc(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){Oc(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!!Oc(this,Ze)&&(Oc(this,Ze)[0]!==this.x||Oc(this,Ze)[1]!==this.y)}get _hasBeenResized(){return!!Oc(this,Ze)&&(Oc(this,Ze)[2]!==this.width||Oc(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)}%`,Oc(this,Ge)||(i.height=`${(100*e/r).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:n}=t,r=n.endsWith("%"),i=!Oc(this,Ge)&&e.endsWith("%");if(r&&i)return;const[A,s]=this.parentDimensions;r||(t.width=`${(100*parseFloat(n)/A).toFixed(2)}%`),Oc(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=Oc(this,He))||t.finish()}get toolbarButtons(){return null}addEditToolbar(){return Wc(this,null,function*(){if(this._editToolbar||Oc(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=Oc(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 Oc(this,He)||(SI.initialize(t._l10n),Dc(this,He,new SI(this)),Oc(this,De)&&(Oc(this,He).data=Oc(this,De),Dc(this,De,null))),Oc(this,He)}get altTextData(){var t;return null==(t=Oc(this,He))?void 0:t.data}set altTextData(t){Oc(this,He)&&(Oc(this,He).data=t)}get guessedAltText(){var t;return null==(t=Oc(this,He))?void 0:t.guessedText}setGuessedAltText(t){return Wc(this,null,function*(){var e;yield null==(e=Oc(this,He))?void 0:e.setGuessedText(t)})}serializeAltText(t){var e;return null==(e=Oc(this,He))?void 0:e.serialize(t)}hasAltText(){return!!Oc(this,He)&&!Oc(this,He).isEmpty()}hasAltTextData(){var t,e;return null!=(e=null==(t=Oc(this,He))?void 0:t.hasData())&&e}addCommentButton(){return Oc(this,je)?Oc(this,je):Dc(this,je,new FI(this))}get commentColor(){return null}get comment(){const t=Oc(this,je);return{text:t.data.text,date:t.data.date,deleted:t.isDeleted(),color:this.commentColor}}set comment(t){Oc(this,je)||Dc(this,je,new FI(this)),Oc(this,je).data=t}setCommentData(t){Oc(this,je)||Dc(this,je,new FI(this)),Oc(this,je).setInitialText(t)}get hasEditedComment(){var t;return null==(t=Oc(this,je))?void 0:t.hasBeenEdited()}editComment(){return Wc(this,null,function*(){Oc(this,je)||Dc(this,je,new FI(this)),Oc(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=Oc(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&&(Oc(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(){Oc(this,rn)&&clearTimeout(Oc(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 Oc(this,en)}shouldGetKeyboardEvents(){return Oc(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=Oc(this,Ye))||t.abort(),Dc(this,Ye,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),Oc(this,rn)&&(clearTimeout(Oc(this,rn)),Dc(this,rn,null)),Rc(this,hn,In).call(this),this.removeEditToolbar(),Oc(this,an)){for(const t of Oc(this,an).values())clearTimeout(t);Dc(this,an,null)}this.parent=null,null==(e=Oc(this,on))||e.destroy(),Dc(this,on,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(Rc(this,hn,gn).call(this),Oc(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=Oc(this,ze).children;if(!Oc(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 Oc(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=Oc(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*(Oc(this,Re).length/4);if(A!==i){if(A<i)for(let t=0;t<i-A;t++)Oc(this,ze).append(Oc(this,ze).firstChild);else if(A>i)for(let t=0;t<A-i;t++)Oc(this,ze).firstChild.before(Oc(this,ze).lastChild);let e=0;for(const r of n){const n=Oc(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),Oc(this,ze).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(t,e){Oc(this,nn)&&Rc(this,hn,yn).call(this,Oc(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=Oc(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=Oc(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=Oc(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 Oc(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){Oc(this,an)||Dc(this,an,new Map);const{action:n}=e;let r=Oc(this,an).get(n);return r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(e),Oc(this,an).delete(n),0===Oc(this,an).size&&Dc(this,an,null)},t._telemetryTimeout),void Oc(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(Oc(this,ze))return;Dc(this,ze,document.createElement("div")),Oc(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");Oc(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(Oc(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=Oc(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=Oc(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(!Oc(this,Xe))return;const{savedX:t,savedY:e,savedWidth:n,savedHeight:r}=Oc(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]=Oc(this,qe);[B,_]=this.screenToPageTranslation(t-r,n-i),Oc(this,qe)[0]=t,Oc(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];Oc(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=Oc(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;Oc(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=Oc(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!==Oc(this,Ve))return void AI(t);const[A,s]=this.screenToPageTranslation(e-Oc(this,An),r-Oc(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===Oc(this,Ke)&&(Oc(this,on)||t.isPrimary)&&s(t),AI(t)},A));const a=t=>{Oc(this,Ve)&&Oc(this,Ve)!==t.pointerId?AI(t):s(t)};window.addEventListener("pointerup",a,{signal:i}),window.addEventListener("blur",a,{signal:i})},En=function(){if(Oc(this,Ye)||!this.div)return;Dc(this,Ye,new AbortController);const t=this._uiManager.combinedSignal(Oc(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;Oc(this,nn)&&(null==(e=t.relatedTarget)?void 0:e.parentNode)!==Oc(this,ze)&&Rc(this,hn,In).call(this)},Ln=function(t){Dc(this,$e,Oc(this,nn)?t:"")},Un=function(t){if(Oc(this,Re))for(const e of Oc(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),Pc(II,"_l10n",null),Pc(II,"_l10nResizer",null),Pc(II,"_borderLineWidth",-1),Pc(II,"_colorManager",new _I),Pc(II,"_zIndex",1),Pc(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,PI=4294901760,NI=65535;class OI{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&PI|s*u&NI,s=s<<15|s>>>17,s=s*h&PI|s*d&NI,o^=s,o=o<<13|o>>>19,o=5*o+3864292196):(a=A[f],a=a*c&PI|a*u&NI,a=a<<15|a>>>17,a=a*h&PI|a*d&NI,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&PI|s*u&NI,s=s<<15|s>>>17,s=s*h&PI|s*d&NI,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&PI|36045*t&NI,e=4283543511*e&PI|(2950163797*(e<<16|t>>>16)&PI)>>>16,t^=e>>>1,t=444984403*t&PI|60499*t&NI,e=3301882366*e&PI|(3120437893*(e<<16|t>>>16)&PI)>>>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,Pn),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=Oc(this,Mn).get(t);return void 0===n?e:Object.assign(e,n)}getRawValue(t){return Oc(this,Mn).get(t)}remove(t){if(Oc(this,Mn).delete(t),0===Oc(this,Mn).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of Oc(this,Mn).values())if(t instanceof QI)return;this.onAnnotationEditor(null)}}setValue(t,e){const n=Oc(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,Oc(this,Mn).set(t,e);r&&Rc(this,Pn,Nn).call(this),e instanceof QI&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return Oc(this,Mn).has(t)}get size(){return Oc(this,Mn).size}resetModified(){Oc(this,Qn)&&(Dc(this,Qn,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new RI(this)}get serializable(){if(0===Oc(this,Mn).size)return TI;const t=new Map,e=new OI,n=[],r=Object.create(null);let i=!1;for(const[A,s]of Oc(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 Oc(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(Oc(this,kn))return Oc(this,kn);const t=[];for(const e of Oc(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 Oc(this,Mn).entries()}}Qn=new WeakMap,kn=new WeakMap,Mn=new WeakMap,Pn=new WeakSet,Nn=function(){Oc(this,Qn)||(Dc(this,Qn,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class RI extends DI{constructor(t){super(),Tc(this,On);const{map:e,hash:n,transfer:r}=t.serializable,i=structuredClone(e,r?{transfer:r}:null);Dc(this,On,{map:i,hash:n,transfer:r})}get print(){xU("Should not call PrintAnnotationStorage.print")}get serializable(){return Oc(this,On)}get modifiedIds(){return LU(this,"modifiedIds",{ids:new Set,hash:""})}}On=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(),Oc(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&&!Oc(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(),Oc(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)};Oc(this,Rn).then(()=>{for(const[t]of Oc(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)}Oc(this,Dn).set(e,r)}removeEventListener(t,e){const n=Oc(this,Dn).get(e);null==n||n(),Oc(this,Dn).delete(e)}terminate(){for(const[,t]of Oc(this,Dn))null==t||t();Oc(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 NU||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 NU(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:Oc(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=Oc(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:!Oc(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=Oc(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=Oc(this,er,nr).get(A),e)return Oc(this,er,nr).set(t,e),e;const s=`g_${Oc(this,$n)}_transfer_map_${Hc(this,tr)._++}`,a=Rc(this,er,sr).call(this,s);Oc(this,er,nr).set(t,a),Oc(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=Oc(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},Oc(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),Oc(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_${Oc(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=Oc(this,er,nr).get(t);if(e)return e;const[n]=Rc(this,er,Ar).call(this,[t]),r=`alpha_${n}`;if(e=Oc(this,er,nr).get(r),e)return Oc(this,er,nr).set(t,e),e;const i=`g_${Oc(this,$n)}_alpha_map_${Hc(this,tr)._++}`,A=Rc(this,er,sr).call(this,i);Oc(this,er,nr).set(t,A),Oc(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=Oc(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=Oc(this,er,nr).get(n),r)return Oc(this,er,nr).set(t,r),r;const i=`g_${Oc(this,$n)}_luminosity_map_${Hc(this,tr)._++}`,A=Rc(this,er,sr).call(this,i);Oc(this,er,nr).set(t,A),Oc(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=Oc(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},Oc(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]),Oc(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_${Oc(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=Oc(this,Zn))?void 0:e.size)||(null==(n=Oc(this,Yn))||n.parentNode.parentNode.remove(),Dc(this,Yn,null),null==(r=Oc(this,Xn))||r.clear(),Dc(this,Xn,null),null==(i=Oc(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 Oc(this,Xn)||Dc(this,Xn,new Map)},rr=function(){return Oc(this,Zn)||Dc(this,Zn,new Map)},ir=function(){if(!Oc(this,Yn)){const t=Oc(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=Oc(this,Jn).createElementNS(qU,"svg");n.setAttribute("width",0),n.setAttribute("height",0),Dc(this,Yn,Oc(this,Jn).createElementNS(qU,"defs")),t.append(n),n.append(Oc(this,Yn)),Oc(this,Jn).body.append(t)}return Oc(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===Oc(this,qn)){Dc(this,qn,"");const t=Oc(this,Jn).URL;t!==Oc(this,Jn).baseURI&&(tI(t)?CU('#createUrl: ignore "data:"-URL for performance reasons.'):Dc(this,qn,FU(t,"")))}return`url(${Oc(this,qn)}#${t})`},ar=function(t){const e=Oc(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=Oc(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=Oc(this,Jn).createElementNS(qU,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),Oc(this,er,ir).append(e),e},cr=function(t,e,n){const r=Oc(this,Jn).createElementNS(qU,e);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),t.append(r)},hr=function(t,e,n,r){const i=Oc(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=Oc(this,Jn).createElementNS(qU,"feComponentTransfer");e.append(n),Rc(this,er,cr).call(this,n,"feFuncA",t)},dr=function(t){return Oc(this,er,ir).style.color=t,aI(getComputedStyle(Oc(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,P,N,O;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,P=v-(v-x)*t,N=y-(y-E)*t,O=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-P)*t|0,c[r++]=Q-(Q-N)*t|0,c[r++]=k-(k-O)*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 PU(`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}};Pc(MQ,"MAX_PATTERN_SIZE",3e3);let PQ=MQ;function NQ({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 OQ=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){Pc(this,"alphaIsShape",!1),Pc(this,"fontSize",0),Pc(this,"fontSizeScale",1),Pc(this,"textMatrix",null),Pc(this,"textMatrixScale",1),Pc(this,"fontMatrix",jL),Pc(this,"leading",0),Pc(this,"x",0),Pc(this,"y",0),Pc(this,"lineX",0),Pc(this,"lineY",0),Pc(this,"charSpacing",0),Pc(this,"wordSpacing",0),Pc(this,"textHScale",1),Pc(this,"textRenderingMode",nU),Pc(this,"textRise",0),Pc(this,"fillColor","#000000"),Pc(this,"strokeColor","#000000"),Pc(this,"patternFill",!1),Pc(this,"patternStroke",!1),Pc(this,"fillAlpha",1),Pc(this,"strokeAlpha",1),Pc(this,"lineWidth",1),Pc(this,"activeSMask",null),Pc(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%OQ,A=(n-i)/OQ,s=0===i?A:A+1,a=t.createImageData(r,OQ);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?OQ: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*OQ)}}else if(e.kind===oU.RGBA_32BPP){for(d=0,p=r*OQ*4,u=0;u<A;u++)h.set(c.subarray(l,l+p)),l+=p,t.putImageData(a,0,d),d+=OQ;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=OQ,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*OQ)}}}function KQ(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const n=e.height,r=e.width,i=n%OQ,A=(n-i)/OQ,s=0===i?A:A+1,a=t.createImageData(r,OQ);let o=0;const l=e.data,c=a.data;for(let h=0;h<s;h++){const e=h<A?OQ:i;({srcPos:o}=NQ({src:l,srcPos:o,dest:c,width:r,height:e,nonBlackColor:0})),t.putImageData(a,0,h*OQ)}}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 PQ(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 o3 in gU)void 0!==ZQ.prototype[o3]&&(ZQ.prototype[gU[o3]]=ZQ.prototype[o3]);class tk{static get workerPort(){return Oc(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 Oc(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 Oc(this,br)}get(t){var e;return null!=(e=Oc(this,yr).get(t))?e:null}[Symbol.iterator](){return Oc(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(Oc(this,Cr))return Oc(this,xr);if(!Oc(this,xr))return!1;const{print:t,view:e}=this.usage;return Oc(this,Br)?"OFF"!==(null==e?void 0:e.viewState):!Oc(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)Oc(this,Sr).set(n.id,new rk(e,n));if("OFF"===t.baseState)for(const t of Oc(this,Sr).values())t._setVisible(nk,!1);for(const e of t.on)Oc(this,Sr).get(e)._setVisible(nk,!0);for(const e of t.off)Oc(this,Sr).get(e)._setVisible(nk,!1);Dc(this,Fr,this.getHash())}}isVisible(t){if(0===Oc(this,Sr).size)return!0;if(!t)return _U("Optional content group not defined."),!0;if("OCG"===t.type)return Oc(this,Sr).has(t.id)?Oc(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(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(Oc(this,Sr).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(!Oc(this,Sr).get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(!Oc(this,Sr).get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;if(Oc(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=Oc(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=Oc(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=Oc(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===Oc(this,Fr)||this.getHash()===Oc(this,Fr)}getOrder(){return Oc(this,Sr).size?Oc(this,Lr)?Oc(this,Lr).slice():[...Oc(this,Sr).keys()]:null}getGroup(t){return Oc(this,Sr).get(t)||null}getHash(){if(null!==Oc(this,Er))return Oc(this,Er);const t=new OI;for(const[e,n]of Oc(this,Sr))t.update(`${e}:${n.visible}`);return Dc(this,Er,t.hexdigest())}[Symbol.iterator](){return Oc(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(!Oc(this,Sr).has(e))return CU(`Optional content group not found: ${e}`),!0;i=Oc(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){Pc(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 NU("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}){Pc(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 NU("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=Oc(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=Oc(this,Qr)[t];return!!e&&e.data!==Sk}delete(t){const e=Oc(this,Qr)[t];return!(!e||e.data===Sk)&&(delete Oc(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 Oc(this,Qr)){const{data:n}=Oc(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 Oc(this,Qr)){const{data:e}=Oc(this,Qr)[t];e!==Sk&&(yield[t,e])}}}Qr=new WeakMap,kr=new WeakSet,Mr=function(t){var e;return(e=Oc(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,Nr,Promise.withResolvers()),Tc(this,Or,null),Tc(this,Tr,!1),Tc(this,Dr,!!(null==(Pr=globalThis.FontInspector)?void 0:Pr.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,Or,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),Oc(this,Nr).promise.finally(()=>{Oc(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=()=>{Oc(this,Vr).read().then(({value:t,done:n})=>{n?Oc(this,Nr).resolve():(null!=Oc(this,Rr)||Dc(this,Rr,t.lang),Object.assign(Oc(this,qr),t.styles),Rc(this,Ai,si).call(this,t.items),e())},Oc(this,Nr).reject)};return Dc(this,Vr,Oc(this,Yr).getReader()),Oc(t,ii).add(this),e(),Oc(this,Nr).promise}update({viewport:e,onBefore:n=null}){var r;const i=e.scale*hI.pixelRatio,A=e.rotation;if(A!==Oc(this,Gr)&&(null==n||n(),Dc(this,Gr,A),cI(Oc(this,Kr),{rotation:A})),i!==Oc(this,zr)){null==n||n(),Dc(this,zr,i);const e={div:null,properties:null,ctx:Rc(r=t,li,ci).call(r,Oc(this,Rr))};for(const t of Oc(this,$r))e.properties=Oc(this,Jr).get(t),e.div=t,Rc(this,Ai,oi).call(this,e)}}cancel(){var t;const e=new NU("TextLayer task cancelled.");null==(t=Oc(this,Vr))||t.cancel(e).catch(()=>{}),Dc(this,Vr,null),Oc(this,Nr).reject(e)}get textDivs(){return Oc(this,$r)}get textContentItemsStr(){return Oc(this,Xr)}static cleanup(){if(!(Oc(this,ii).size>0)){Oc(this,ti).clear();for(const{canvas:t}of Oc(this,ei).values())t.remove();Oc(this,ei).clear()}}};Nr=new WeakMap,Or=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(Oc(this,Tr))return;null!=(n=Oc(this,Hr)).ctx||(n.ctx=Rc(e=Lk,li,ci).call(e,Oc(this,Rr)));const r=Oc(this,$r),i=Oc(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=Oc(this,Or);Dc(this,Or,document.createElement("span")),Oc(this,Or).classList.add("markedContent"),A.id&&Oc(this,Or).setAttribute("id",`${A.id}`),t.append(Oc(this,Or))}else"endMarkedContent"===A.type&&Dc(this,Or,Oc(this,Or).parentNode)}},ai=function(t){var e;const n=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};Oc(this,$r).push(n);const i=HU.transform(Oc(this,Zr),t.transform);let A=Math.atan2(i[1],i[0]);const s=Oc(this,qr)[t.fontName];s.vertical&&(A+=Math.PI/2);let a=Oc(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,Oc(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;Oc(this,Or)===Oc(this,Kr)?(d.left=`${(100*c/Oc(this,Wr)).toFixed(2)}%`,d.top=`${(100*h/Oc(this,jr)).toFixed(2)}%`):(d.left=`${u}${c.toFixed(2)}px)`,d.top=`${u}${h.toFixed(2)}px)`),d.fontSize=`${u}${(Oc(Lk,ri)*o).toFixed(2)}px)`,d.fontFamily=a,r.fontSize=o,n.setAttribute("role","presentation"),n.textContent=t.str,n.dir=t.dir,Oc(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),Oc(this,Jr).set(n,r),Oc(this,Hr).div=n,Oc(this,Hr).properties=r,Rc(this,Ai,oi).call(this,Oc(this,Hr)),r.hasText&&Oc(this,Or).append(n),r.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),Oc(this,Or).append(t)}},oi=function(t){var e;const{div:n,properties:r,ctx:i}=t,{style:A}=n;let s="";if(Oc(Lk,ri)>1&&(s=`scale(${1/Oc(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*Oc(this,zr),t);const{width:l}=i.measureText(n.textContent);l>0&&(s=`scaleX(${a*Oc(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=Oc(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}),Oc(this,ei).set(t,e),Oc(this,ni).set(e,{size:0,family:""})}return e},hi=function(t,e,n){const r=Oc(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!==Oc(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=Oc(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)),Oc(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 Pk?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,P=!0===t.disableAutoFetch,N=!0===t.pdfBug,O=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 O({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:P,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:N,styleElement:null,loadingParams:{disableAutoFetch:P,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(){Pc(this,"_capability",Promise.withResolvers()),Pc(this,"_transport",null),Pc(this,"_worker",null),Pc(this,"docId","d"+Hc(t,fi)._++),Pc(this,"destroyed",!1),Pc(this,"onPassword",null),Pc(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 Pk{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){Oc(this,vi).push(t)}addProgressListener(t){Oc(this,wi).push(t)}addProgressiveReadListener(t){Oc(this,mi).push(t)}addProgressiveDoneListener(t){Oc(this,gi).push(t)}onDataRange(t,e){for(const n of Oc(this,vi))n(t,e)}onDataProgress(t,e){Oc(this,pi).promise.then(()=>{for(const n of Oc(this,wi))n(t,e)})}onDataProgressiveRead(t){Oc(this,pi).promise.then(()=>{for(const e of Oc(this,mi))e(t)})}onDataProgressiveDone(){Oc(this,pi).promise.then(()=>{for(const t of Oc(this,gi))t()})}transportReady(){Oc(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 Nk{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 Ok{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 NU(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(!Oc(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(Oc(t,Li).has(n))throw new Error("Cannot use more than one PDFWorker per port.");Oc(t,Li).set(n,this),Rc(this,Ui,Qi).call(this,n)}else Rc(this,Ui,ki).call(this)}get promise(){return Oc(this,_i).promise}get port(){return Oc(this,xi)}get messageHandler(){return Oc(this,Ci)}destroy(){var e,n;this.destroyed=!0,null==(e=Oc(this,Ei))||e.terminate(),Dc(this,Ei,null),Oc(t,Li).delete(Oc(this,xi)),Dc(this,xi,null),null==(n=Oc(this,Ci))||n.destroy(),Dc(this,Ci,null)}static create(e){const n=Oc(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(Oc(this,Pi,Ni))return Oc(this,Pi,Ni);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(){Oc(this,_i).resolve(),Oc(this,Ci).send("configure",{verbosity:this.verbosity})},Qi=function(t){Dc(this,xi,t),Dc(this,Ci,new AQ("main","worker",t)),Oc(this,Ci).on("ready",()=>{}),Rc(this,Ui,Ii).call(this)},ki=function(){if(Oc(Tk,Fi)||Oc(Tk,Pi,Ni))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?Oc(this,_i).reject(new Error("Worker was destroyed")):Rc(this,Ui,Mi).call(this)},i=new AbortController;e.addEventListener("error",()=>{Oc(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(){Oc(Tk,Fi)||(CU("Setting up fake worker."),Dc(Tk,Fi,!0)),Tk._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void Oc(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=>{Oc(this,_i).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Pi=new WeakSet,Ni=function(){var t;try{return(null==(t=globalThis.pdfjsWorker)?void 0:t.WorkerMessageHandler)||null}catch(hw){return null}},Tc(Tk,Pi),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,Oi,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=Oc(this,Hi))||t.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const r of Oc(this,Ti).values())e.push(r._destroy());Oc(this,Ti).clear(),Oc(this,Di).clear(),Oc(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(),Oc(this,Oi).clear(),this.filterFactory.destroy(),Uk.cleanup(),null==(t=this._networkStream)||t.cancelAllRequests(new NU("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 Nk(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?Oc(this,Hi).reject(t):Oc(this,Hi).resolve({password:t})};e.onPassword(n,t.code)}catch(n){Oc(this,Hi).reject(n)}return Oc(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;Oc(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 Oc(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=Oc(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=Oc(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&&Oc(this,Ri).set(n.refStr,t);const r=new Ok(e,n,this,this._params.pdfBug);return Oc(this,Ti).set(e,r),r});return Oc(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=Oc(this,Oi).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 Oc(this,Oi).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 Oc(this,Ti).values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),Oc(this,Oi).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=Oc(this,Ri).get(n))?e:null}}Oi=new WeakMap,Ti=new WeakMap,Di=new WeakMap,Ri=new WeakMap,Hi=new WeakMap,ji=new WeakSet,Wi=function(t,e=null){const n=Oc(this,Oi).get(t);if(n)return n;const r=this.messageHandler.sendWithPromise(t,e);return Oc(this,Oi).set(t,r),r};class Hk{constructor(t){Tc(this,Vi,null),Pc(this,"onContinue",null),Pc(this,"onError",null),Dc(this,Vi,t)}get promise(){return Oc(this,Vi).capability.promise}cancel(t=0){Oc(this,Vi).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=Oc(this,Vi).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=Oc(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(Oc(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.");Oc(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(),Oc(this,Ki)&&(window.cancelAnimationFrame(Oc(this,Ki)),Dc(this,Ki,null)),Oc(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(),Oc(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,Oc(this,nA)._eventBus),Dc(this,Xi,(null==(r=null==e?void 0:e.color)?void 0:r.toUpperCase())||(null==(i=Oc(this,nA))?void 0:i.highlightColors.values().next().value)||"#FFFF98"),Oc(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",Oc(this,Zi)&&(t.ariaControls=`${Oc(this,Zi).id}_colorpicker_dropdown`);const e=Oc(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=Oc(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===Oc(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;Oc(this,iA,cA)?t.target!==Oc(this,zi)?null==(n=t.target.nextSibling)||n.focus():null==(e=Oc(this,Yi).firstChild)||e.focus():Rc(this,iA,oA).call(this,t)}_moveToPrevious(t){var e,n;t.target!==(null==(e=Oc(this,Yi))?void 0:e.firstChild)&&t.target!==Oc(this,zi)?(Oc(this,iA,cA)||Rc(this,iA,oA).call(this,t),null==(n=t.target.previousSibling)||n.focus()):Oc(this,iA,cA)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;Oc(this,iA,cA)?null==(e=Oc(this,Yi).firstChild)||e.focus():Rc(this,iA,oA).call(this,t)}_moveToEnd(t){var e;Oc(this,iA,cA)?null==(e=Oc(this,Yi).lastChild)||e.focus():Rc(this,iA,oA).call(this,t)}hideDropdown(){var t,e;null==(t=Oc(this,Yi))||t.classList.add("hidden"),Oc(this,zi).ariaExpanded="false",null==(e=Oc(this,eA))||e.abort(),Dc(this,eA,null)}_hideDropdownFromKeyboard(){var t;Oc(this,Ji)||(Oc(this,iA,cA)?(this.hideDropdown(),Oc(this,zi).focus({preventScroll:!0,focusVisible:Oc(this,$i)})):null==(t=Oc(this,Zi))||t.unselect())}updateColor(t){if(Oc(this,qi)&&(Oc(this,qi).style.backgroundColor=t),!Oc(this,Yi))return;const e=Oc(this,nA).highlightColors.values();for(const n of Oc(this,Yi).children)n.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;null==(t=Oc(this,zi))||t.remove(),Dc(this,zi,null),Dc(this,qi,null),null==(e=Oc(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=Oc(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"),Oc(this,Zi)&&(t.id=`${Oc(this,Zi).id}_colorpicker_dropdown`);for(const[n,r]of Oc(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",Oc(Vk,rA)[n]);const A=document.createElement("span");i.append(A),A.className="swatch",A.style.backgroundColor=r,i.ariaSelected=r===Oc(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(),Oc(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(Oc(this,iA,cA))return void this.hideDropdown();if(Dc(this,$i,0===t.detail),Oc(this,eA)||(Dc(this,eA,new AbortController),window.addEventListener("pointerdown",Rc(this,iA,lA).bind(this),{signal:Oc(this,nA).combinedSignal(Oc(this,eA))})),Oc(this,zi).ariaExpanded="true",Oc(this,Yi))return void Oc(this,Yi).classList.remove("hidden");const e=Dc(this,Yi,Rc(this,iA,AA).call(this));Oc(this,zi).append(e)},lA=function(t){var e;(null==(e=Oc(this,Yi))?void 0:e.contains(t.target))||this.hideDropdown()},cA=function(){return Oc(this,Yi)&&!Oc(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),Oc(t,fA)||Dc(t,fA,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(Oc(this,hA))return Oc(this,hA);const{editorType:e,colorType:n,colorValue:r}=Oc(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",Oc(t,fA)[e]),i.addEventListener("input",()=>{Oc(this,dA).updateParams(n,i.value)},{signal:Oc(this,dA)._signal}),i}update(t){Oc(this,hA)&&(Oc(this,hA).value=t)}destroy(){var t;null==(t=Oc(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&&(Oc(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=Oc(this,mA))?void 0:e.popup)||this.popup;!i&&(null==r?void 0:r.text)&&(this._createPopup(r),i=Oc(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;Oc(this,pA)&&(Rc(this,wA,vA).call(this,Oc(this,pA).rect),null==(t=Oc(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(Oc(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}"/>`)}Oc(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!!(Oc(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,PA,!1),Tc(this,NA,null),Tc(this,OA,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),Oc(this,LA).hidden=!0,c&&Rc(this,VA,JA).call(this)}render(){var t;if(Oc(this,NA))return;const e=Dc(this,NA,document.createElement("div"));if(e.className="popup",Oc(this,FA)){const t=e.style.outlineColor=HU.makeHexColor(...Oc(this,FA));e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const n=document.createElement("span");if(n.className="header",null==(t=Oc(this,HA))?void 0:t.str){const t=document.createElement("span");t.className="title",n.append(t),({dir:t.dir,str:t.textContent}=Oc(this,HA))}if(e.append(n),Oc(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:Oc(this,IA).valueOf()})),t.dateTime=Oc(this,IA).toISOString(),n.append(t)}const r=Oc(this,VA,GA);if(r)Zk.render({xfaHtml:r,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const t=this._formatContents(Oc(this,UA));e.append(t)}Oc(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),Oc(this,jA)||Dc(this,jA,{contentsObj:Oc(this,UA),richText:Oc(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=Oc(this,NA))||r.remove(),Dc(this,NA,null))}resetEdited(){var t;Oc(this,jA)&&(({contentsObj:Hc(this,UA)._,richText:Hc(this,RA)._}=Oc(this,jA)),Dc(this,jA,null),null==(t=Oc(this,NA))||t.remove(),Dc(this,NA,null),Dc(this,TA,null))}remove(){var t,e;null==(t=Oc(this,OA))||t.abort(),Dc(this,OA,null),null==(e=Oc(this,NA))||e.remove(),Dc(this,NA,null),Dc(this,WA,!1),Dc(this,PA,!1);for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){Dc(this,WA,this.isVisible),Oc(this,WA)&&(Oc(this,LA).hidden=!0)}maybeShow(){Rc(this,VA,KA).call(this),Oc(this,WA)&&(Oc(this,NA)||Rc(this,VA,ZA).call(this),Dc(this,WA,!1),Oc(this,LA).hidden=!1)}get isVisible(){return!1===Oc(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,PA=new WeakMap,NA=new WeakMap,OA=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(Oc(this,OA))return;Dc(this,OA,new AbortController);const{signal:e}=Oc(this,OA);for(const n of this.trigger)n.addEventListener("click",Oc(this,SA),{signal:e}),n.addEventListener("mouseenter",Oc(this,EA),{signal:e}),n.addEventListener("mouseleave",Oc(this,xA),{signal:e}),n.classList.add("popupTriggerArea");for(const n of Oc(this,QA))null==(t=n.container)||t.addEventListener("keydown",Oc(this,CA),{signal:e})},GA=function(){const t=Oc(this,RA),e=Oc(this,UA);return!(null==t?void 0:t.str)||(null==e?void 0:e.str)&&e.str!==t.str?null:Oc(this,RA).html||null},zA=function(){var t,e,n;return(null==(n=null==(e=null==(t=Oc(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=Oc(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:Oc(this,VA,qA),fontSize:Oc(this,VA,zA)?`calc(${Oc(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&&Oc(this,PA))&&Rc(this,VA,JA).call(this)},$A=function(){if(null!==Oc(this,TA))return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:n,pageX:r,pageY:i}}}=Oc(this,kA);let A=!!Oc(this,MA),s=Oc(this,A?MA:DA);for(const u of Oc(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}=Oc(this,LA);h.left=`${Oc(this,TA)[0]}%`,h.top=`${Oc(this,TA)[1]}%`},JA=function(){Dc(this,PA,!Oc(this,PA)),Oc(this,PA)?(Rc(this,VA,ZA).call(this),Oc(this,LA).addEventListener("click",Oc(this,SA)),Oc(this,LA).addEventListener("keydown",Oc(this,CA))):(Rc(this,VA,ts).call(this),Oc(this,LA).removeEventListener("click",Oc(this,SA)),Oc(this,LA).removeEventListener("keydown",Oc(this,CA)))},ZA=function(){Oc(this,NA)||this.render(),this.isVisible?Oc(this,PA)&&Oc(this,LA).classList.add("focused"):(Rc(this,VA,$A).call(this),Oc(this,LA).hidden=!1,Oc(this,LA).style.zIndex=parseInt(Oc(this,LA).style.zIndex)+1e3)},ts=function(){Oc(this,LA).classList.remove("focused"),!Oc(this,PA)&&this.isVisible&&(Oc(this,LA).hidden=!0,Oc(this,LA).style.zIndex=parseInt(Oc(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 Oc(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 Oc(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 Oc(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 Oc(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);Oc(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=Oc(this,As);if(e>=0&&i.setAttribute("stroke-width",e||1),n)for(let A=0,s=Oc(this,ss).length;A<s;A++)Oc(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 Oc(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 Oc(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=Oc(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=Oc(this,us))||i.moveElementInDOM(this.div,t,A,!1))})},ws=function(){var t;if(!Oc(this,ds))return;const e=this.div;for(const[n,r]of Oc(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=Oc(this,fs).get(n);s&&(s._hasNoCanvas?(null==(t=this._annotationEditorUIManager)||t.setMissingCanvas(n,i.id,r),s._hasNoCanvas=!1):s.canvas=r)}Oc(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 Oc(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&&(Oc(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(Oc(this,fs).values())}getEditableAnnotation(t){return Oc(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),Pc(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,Oc(this,_s)],[eU.FREETEXT_COLOR,Oc(this,vs)]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new zk(this)),[["colorPicker",this._colorPicker]]}get colorType(){return eU.FREETEXT_COLOR}get colorValue(){return Oc(this,vs)}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const e=this.parentScale;return[-t._internalPadding*e,-(t._internalPadding+Oc(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(Oc(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",Oc(this,bs)),this._isDraggable=!0,null==(t=Oc(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=Oc(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",Oc(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(${Oc(this,_s)}px * var(--total-scale-factor))`,n.color=Oc(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:Oc(this,vs)),A={annotationType:tU.FREETEXT,color:i,fontSize:Oc(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(${Oc(this,_s)}px * var(--total-scale-factor))`,r.color=Oc(this,vs),n.replaceChildren();for(const t of Oc(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:Oc(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-Oc(this,_s))*this.parentScale),Dc(this,_s,t),Rc(this,Cs,Fs).call(this)},n=Oc(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=Oc(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(),Oc(this,ys))for(const t of Oc(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 Oc(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),Pc(IM,"_freeTextDefaultContent",""),Pc(IM,"_internalPadding",0),Pc(IM,"_defaultColor",null),Pc(IM,"_defaultFontSize",10),Pc(IM,"_type","freetext"),Pc(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]}}Pc(kM,"PRECISION",1e-4);const MM=class t{constructor({x:e,y:n},r,i,A,s,a=0){Tc(this,$s),Tc(this,Ps),Tc(this,Ns,[]),Tc(this,Os),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,Ps,r),Dc(this,Gs,A*i),Dc(this,Ts,s),Oc(this,Rs).set([NaN,NaN,NaN,NaN,e,n],6),Dc(this,Os,a),Dc(this,Vs,Oc(t,qs)*i),Dc(this,Ws,Oc(t,Ys)*i),Dc(this,Ks,i),Oc(this,zs).push(e,n)}isEmpty(){return isNaN(Oc(this,Rs)[8])}add({x:t,y:e}){var n;Dc(this,Hs,t),Dc(this,js,e);const[r,i,A,s]=Oc(this,Ps);let[a,o,l,c]=Oc(this,Rs).subarray(8,12);const h=t-l,u=e-c,d=Math.hypot(h,u);if(d<Oc(this,Ws))return!1;const f=d-Oc(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=Oc(this,zs))||n.push(t,e);const y=g/f,b=-m/f*Oc(this,Gs),B=y*Oc(this,Gs);if(Oc(this,Rs).set(Oc(this,Rs).subarray(2,8),0),Oc(this,Rs).set([l+b,c+B],4),Oc(this,Rs).set(Oc(this,Rs).subarray(14,18),12),Oc(this,Rs).set([l-b,c-B],16),isNaN(Oc(this,Rs)[6]))return 0===Oc(this,Ds).length&&(Oc(this,Rs).set([a+b,o+B],2),Oc(this,Ds).push(NaN,NaN,NaN,NaN,(a+b-r)/A,(o+B-i)/s),Oc(this,Rs).set([a-b,o-B],14),Oc(this,Ns).push(NaN,NaN,NaN,NaN,(a-b-r)/A,(o-B-i)/s)),Oc(this,Rs).set([w,v,a,o,l,c],6),!this.isEmpty();Oc(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]=Oc(this,Rs).subarray(2,6),Oc(this,Ds).push(NaN,NaN,NaN,NaN,((a+l)/2-r)/A,((o+c)/2-i)/s),[a,o,w,v]=Oc(this,Rs).subarray(14,18),Oc(this,Ns).push(NaN,NaN,NaN,NaN,((w+a)/2-r)/A,((v+o)/2-i)/s),!0):([w,v,a,o,l,c]=Oc(this,Rs).subarray(0,6),Oc(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]=Oc(this,Rs).subarray(12,18),Oc(this,Ns).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=Oc(this,Ds),e=Oc(this,Ns);if(isNaN(Oc(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 NM(t,e,n,r,i,A)}getOutlines(){var t,e;const n=Oc(this,Ds),r=Oc(this,Ns),i=Oc(this,Rs),[A,s,a,o]=Oc(this,Ps),l=new Float32Array((null!=(e=null==(t=Oc(this,zs))?void 0:t.length)?e:0)+2);for(let u=0,d=l.length-2;u<d;u+=2)l[u]=(Oc(this,zs)[u]-A)/a,l[u+1]=(Oc(this,zs)[u+1]-s)/o;if(l[l.length-2]=(Oc(this,Hs)-A)/a,l[l.length-1]=(Oc(this,js)-s)/o,isNaN(i[6])&&!this.isEmpty())return Rc(this,$s,na).call(this,l);const c=new Float32Array(Oc(this,Ds).length+24+Oc(this,Ns).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,Oc(this,Ps),Oc(this,Ks),Oc(this,Os),Oc(this,Ts))}};Ps=new WeakMap,Ns=new WeakMap,Os=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=Oc(this,Rs).subarray(4,6),e=Oc(this,Rs).subarray(16,18),[n,r,i,A]=Oc(this,Ps);return[(Oc(this,Hs)+(t[0]-e[0])/2-n)/i,(Oc(this,js)+(t[1]-e[1])/2-r)/A,(Oc(this,Hs)+(e[0]-t[0])/2-n)/i,(Oc(this,js)+(e[1]-t[1])/2-r)/A]},Zs=function(){const[t,e,n,r]=Oc(this,Ps),[i,A,s,a]=Rc(this,$s,Js).call(this);return`M${(Oc(this,Rs)[2]-t)/n} ${(Oc(this,Rs)[3]-e)/r} L${(Oc(this,Rs)[4]-t)/n} ${(Oc(this,Rs)[5]-e)/r} L${i} ${A} L${s} ${a} L${(Oc(this,Rs)[16]-t)/n} ${(Oc(this,Rs)[17]-e)/r} L${(Oc(this,Rs)[14]-t)/n} ${(Oc(this,Rs)[15]-e)/r} Z`},ta=function(t){const e=Oc(this,Ns);t.push(`L${e[4]} ${e[5]} Z`)},ea=function(t){const[e,n,r,i]=Oc(this,Ps),A=Oc(this,Rs).subarray(4,6),s=Oc(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=Oc(this,Rs),[n,r,i,A]=Oc(this,Ps),[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,Oc(this,Ps),Oc(this,Ks),Oc(this,Os),Oc(this,Ts))},ra=function(t,e){const n=Oc(this,Ns);return t.set([NaN,NaN,NaN,NaN,n[4],n[5]],e),e+6},ia=function(t,e){const n=Oc(this,Rs).subarray(4,6),r=Oc(this,Rs).subarray(16,18),[i,A,s,a]=Oc(this,Ps),[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,Oc(MM,qs)+Oc(MM,Xs));let PM=MM;class NM 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]=Oc(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${Oc(this,ha)[4]} ${Oc(this,ha)[5]}`];for(let e=6,n=Oc(this,ha).length;e<n;e+=6)isNaN(Oc(this,ha)[e])?t.push(`L${Oc(this,ha)[e+4]} ${Oc(this,ha)[e+5]}`):t.push(`C${Oc(this,ha)[e]} ${Oc(this,ha)[e+1]} ${Oc(this,ha)[e+2]} ${Oc(this,ha)[e+3]} ${Oc(this,ha)[e+4]} ${Oc(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(Oc(this,ha),t,r,A,-s),o=kM._rescale(Oc(this,la),t,r,A,-s);break;case 90:a=kM._rescaleAndSwap(Oc(this,ha),t,e,A,s),o=kM._rescaleAndSwap(Oc(this,la),t,e,A,s);break;case 180:a=kM._rescale(Oc(this,ha),n,e,-A,s),o=kM._rescale(Oc(this,la),n,e,-A,s);break;case 270:a=kM._rescaleAndSwap(Oc(this,ha),n,r,-A,-s),o=kM._rescaleAndSwap(Oc(this,la),n,r,-A,-s)}return{outline:Array.from(a),points:[Array.from(o)]}}get box(){return Oc(this,sa)}newOutliner(t,e,n,r,i,A=0){return new PM(t,e,n,r,i,A)}getNewOutline(t,e){const[n,r,i,A]=Oc(this,sa),[s,a,o,l]=Oc(this,Aa),c=i*o,h=A*l,u=n*o+s,d=r*l+a,f=this.newOutliner({x:Oc(this,la)[0]*c+u,y:Oc(this,la)[1]*h+d},Oc(this,Aa),Oc(this,ca),t,Oc(this,oa),null!=e?e:Oc(this,aa));for(let p=2;p<Oc(this,la).length;p+=2)f.add({x:Oc(this,la)[p]*c+u,y:Oc(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=Oc(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=Oc(this,sa);o[0]=i[0]-Oc(this,aa),o[1]=i[1]-Oc(this,aa),o[2]=i[2]-i[0]+2*Oc(this,aa),o[3]=i[3]-i[1]+2*Oc(this,aa),this.lastPoint=[A,s]};class OM{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];Oc(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=Oc(this,ga).at(r?-1:-2),h=[c[0],c[2]];for(const u of Oc(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(){Oc(this,ga).sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of Oc(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,Oc(this,fa),Oc(this,pa))},ya=function(t){const e=Oc(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);Oc(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<Oc(this,ma).length;r++){const[n,i]=Oc(this,ma)[r];if(n!==t)break;if(n===t&&i===e)return void Oc(this,ma).splice(r,1)}for(let r=n-1;r>=0;r--){const[n,i]=Oc(this,ma)[r];if(n!==t)break;if(n===t&&i===e)return void Oc(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]=Oc(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 Oc(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 Oc(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 Oc(this,Ca)}get classNamesForOutlining(){return["highlightOutline"]}}Ca=new WeakMap,xa=new WeakMap;class DM extends PM{newFreeDrawOutline(t,e,n,r,i,A){return new RM(t,e,n,r,i,A)}}class RM extends NM{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,Pa,null),Tc(this,Na,null),Tc(this,Oa,!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,Oa,!0),Rc(this,Va,Ga).call(this,e),Rc(this,Va,$a).call(this)):Oc(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:Oc(this,Oa)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:Oc(this,ja),methodOfCreation:Oc(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 Oc(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,Oc(this,ja)||t._defaultThickness],[eU.HIGHLIGHT_FREE,Oc(this,Oa)]]}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;Oc(this,Oa)?(e=(e-this.rotation+360)%360,s=Rc(n=t,Ja,Za).call(n,Oc(this,Pa).box,e)):s=Rc(r=t,Ja,Za).call(r,[this.x,this.y,this.width,this.height],e),A.updateProperties(Oc(this,Na),{bbox:s,root:{"data-main-rotation":e}}),A.updateProperties(Oc(this,Ra),{bbox:Rc(i=t,Ja,Za).call(i,Oc(this,Ia).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const t=super.render();Oc(this,Ha)&&(t.setAttribute("aria-label",Oc(this,Ha)),t.setAttribute("role","mark")),Oc(this,Oa)?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=Oc(this,La);const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),gI(this,Oc(this,Ma),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Oc(this,Ra),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(Oc(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(),Oc(this,Ra)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Oc(this,Ra),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),Oc(this,Ra)&&(null==(t=this.parent)||t.drawLayer.updateProperties(Oc(this,Ra),{rootClass:{selected:!1}}),Oc(this,Oa)||Rc(this,Va,eo).call(this,!1))}get _mustFixPosition(){return!Oc(this,Oa)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(Oc(this,Na),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(Oc(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,Oa,!0);const t=h[0],e={x:t[0]-g,y:p-(t[1]-m)},r=new DM(e,[0,0,f,p],1,Oc(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:Oc(this,Da),thickness:Oc(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,Pa=new WeakMap,Na=new WeakMap,Oa=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 OM(Oc(this,Fa),.001);Dc(this,Pa,t.getOutlines()),[this.x,this.y,this.width,this.height]=Oc(this,Pa).box;const e=new OM(Oc(this,Fa),.0025,.001,"ltr"===this._uiManager.direction);Dc(this,Ia,e.getOutlines());const{lastPoint:n}=Oc(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,Pa,t);if(Dc(this,Ia,t.getNewOutline(Oc(this,ja)/2+1.5,.0025)),e>=0)Dc(this,Na,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:Oc(this,Ia).box,path:{d:Oc(this,Ia).toSVGPath()}},!0));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(Oc(this,Na),{bbox:Rc(r=HM,Ja,Za).call(r,Oc(this,Pa).box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(Oc(this,Ra),{bbox:Rc(i=HM,Ja,Za).call(i,Oc(this,Ia).box,e),path:{d:Oc(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}=Oc(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(Oc(this,Na),{root:{fill:t,"fill-opacity":e}}),null==(r=Oc(this,Ua))||r.updateColor(t)},n=this.color,r=Oc(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=Oc(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(!Oc(this,Oa))return;Rc(this,Va,Ga).call(this,{highlightOutlines:Oc(this,Pa).getNewOutline(t/2)}),this.fixAndSetPosition();const[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)},Ya=function(){null!==Oc(this,Na)&&this.parent&&(this.parent.drawLayer.remove(Oc(this,Na)),Dc(this,Na,null),this.parent.drawLayer.remove(Oc(this,Ra)),Dc(this,Ra,null))},$a=function(t=this.parent){null===Oc(this,Na)&&(({id:Hc(this,Na)._,clipPathId:Hc(this,La)._}=t.drawLayer.draw({bbox:Oc(this,Pa).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":Oc(this,Da)},rootClass:{highlight:!0,free:Oc(this,Oa)},path:{d:Oc(this,Pa).toSVGPath()}},!1,!0)),Dc(this,Ra,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:Oc(this,Oa)},bbox:Oc(this,Ia).box,path:{d:Oc(this,Ia).toSVGPath()}},Oc(this,Oa))),Oc(this,Ma)&&(Oc(this,Ma).style.clipPath=Oc(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(!Oc(this,Ea))return;const e=window.getSelection();t?e.setPosition(Oc(this,Ea),Oc(this,Sa)):e.setPosition(Oc(this,Qa),Oc(this,ka))},no=function(){return Oc(this,Oa)?this.rotation:0},ro=function(){if(Oc(this,Oa))return null;const[t,e]=this.pageDimensions,[n,r]=this.pageTranslation,i=Oc(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 Oc(this,Pa).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),Pc(HM,"_defaultColor",null),Pc(HM,"_defaultOpacity",1),Pc(HM,"_defaultThickness",12),Pc(HM,"_type","highlight"),Pc(HM,"_editorType",tU.HIGHLIGHT),Pc(HM,"_freeHighlightId",-1),Pc(HM,"_freeHighlight",null),Pc(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){Oc(this,oo)[t]=e}toSVGProperties(){const t=Oc(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),Pc(this,"_colorPicker",null),Pc(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&&(Oc(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=Oc(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(Oc(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(Oc(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(Oc(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,Oc(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,Oc(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)},Oc(this,lo).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&Rc(this,vo,Eo).call(this,Oc(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(Oc(t,go)&&Oc(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);Oc(t,po)||Dc(t,po,l),null!=Oc(t,go)||Dc(t,go,c),window.addEventListener("pointerup",e=>{var n;Oc(t,po)===e.pointerId?this._endDraw(e):null==(n=Oc(t,mo))||n.delete(e.pointerId)},{signal:p}),window.addEventListener("pointercancel",e=>{var n;Oc(t,po)===e.pointerId?this._currentParent.endDrawingSession():null==(n=Oc(t,mo))||n.delete(e.pointerId)},{signal:p}),window.addEventListener("pointerdown",e=>{Oc(t,go)===e.pointerType&&((Oc(t,mo)||Dc(t,mo,new Set)).add(e.pointerId),Oc(t,ho).isCancellable()&&(Oc(t,ho).removeLastElement(),Oc(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===Oc(t,wo)&&AI(e)},{signal:p}),e.toggleDrawing(),null==(A=n._editorUndoBar)||A.hide(),Oc(t,ho)?e.drawLayer.updateProperties(this._currentDrawId,Oc(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(Oc(t,fo).toSVGProperties(),Oc(t,ho).defaultSVGProperties),!0,!1)))}static _drawMove(e){var n;if(Dc(t,wo,-1),!Oc(t,ho))return;const{offsetX:r,offsetY:i,pointerId:A}=e;Oc(t,po)===A&&((null==(n=Oc(t,mo))?void 0:n.size)>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Oc(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)),Oc(t,uo)&&(Oc(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,Oc(t,ho).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=Oc(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),!Oc(t,ho).isEmpty()){const{pageDimensions:[r,i],scale:A}=n,s=n.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Oc(t,ho).getOutlines(r*A,i*A,A,this._INNER_MARGIN),drawingOptions:Oc(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 Oc(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,Oc(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]}},Pc(VM,"_currentDrawId",-1),Pc(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),Pc(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,Po,0),Tc(this,No,new zM),Tc(this,Oo),Tc(this,To),Dc(this,Oo,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:Oc(this,ko)}]),Oc(this,Fo).set(s,0)}updateProperty(t,e){"stroke-width"===t&&Dc(this,Qo,e)}isEmpty(){return!Oc(this,Uo)||0===Oc(this,Uo).length}isCancellable(){return Oc(this,ko).length<=10}add(t,e){[t,e]=Rc(this,Do,Ro).call(this,t,e);const[n,r,i,A]=Oc(this,Fo).subarray(2,6),s=t-i,a=e-A;return Math.hypot(Oc(this,Oo)*s,Oc(this,To)*a)<=2?null:(Oc(this,ko).push(t,e),isNaN(n)?(Oc(this,Fo).set([i,A,t,e],2),Oc(this,Lo).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(Oc(this,Fo)[0])&&Oc(this,Lo).splice(6,6),Oc(this,Fo).set([n,r,i,A,t,e],0),Oc(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===Oc(this,ko).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,n,r,i){Dc(this,Oo,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=Oc(this,Uo).at(-1);return s&&(s.line=new Float32Array(s.line),s.points=new Float32Array(s.points)),Oc(this,Uo).push({line:A,points:Oc(this,ko)}),Oc(this,Fo).set(A,0),Dc(this,Po,0),this.toSVGPath(),null}getLastElement(){return Oc(this,Uo).at(-1)}setLastElement(t){return Oc(this,Uo)?(Oc(this,Uo).push(t),Dc(this,Lo,t.line),Dc(this,ko,t.points),Dc(this,Po,0),{path:{d:this.toSVGPath()}}):Oc(this,No).setLastElement(t)}removeLastElement(){if(!Oc(this,Uo))return Oc(this,No).removeLastElement();Oc(this,Uo).pop(),Dc(this,Mo,"");for(let t=0,e=Oc(this,Uo).length;t<e;t++){const{line:e,points:n}=Oc(this,Uo)[t];Dc(this,Lo,e),Dc(this,ko,n),Dc(this,Po,0),this.toSVGPath()}return{path:{d:Oc(this,Mo)}}}toSVGPath(){const t=kM.svgRound(Oc(this,Lo)[4]),e=kM.svgRound(Oc(this,Lo)[5]);if(2===Oc(this,ko).length)return Dc(this,Mo,`${Oc(this,Mo)} M ${t} ${e} Z`),Oc(this,Mo);if(Oc(this,ko).length<=6){const n=Oc(this,Mo).lastIndexOf("M");Dc(this,Mo,`${Oc(this,Mo).slice(0,n)} M ${t} ${e}`),Dc(this,Po,6)}if(4===Oc(this,ko).length){const t=kM.svgRound(Oc(this,Lo)[10]),e=kM.svgRound(Oc(this,Lo)[11]);return Dc(this,Mo,`${Oc(this,Mo)} L ${t} ${e}`),Dc(this,Po,12),Oc(this,Mo)}const n=[];0===Oc(this,Po)&&(n.push(`M ${t} ${e}`),Dc(this,Po,6));for(let r=Oc(this,Po),i=Oc(this,Lo).length;r<i;r+=6){const[t,e,i,A,s,a]=Oc(this,Lo).slice(r,r+6).map(kM.svgRound);n.push(`C${t} ${e} ${i} ${A} ${s} ${a}`)}return Dc(this,Mo,Oc(this,Mo)+n.join(" ")),Dc(this,Po,Oc(this,Lo).length),Oc(this,Mo)}getOutlines(t,e,n,r){const i=Oc(this,Uo).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),Oc(this,No).build(Oc(this,Uo),t,e,n,Oc(this,Io),Oc(this,Qo),r),Dc(this,Fo,null),Dc(this,Lo,null),Dc(this,Uo,null),Dc(this,Mo,null),Oc(this,No)}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,Po=new WeakMap,No=new WeakMap,Oo=new WeakMap,To=new WeakMap,Do=new WeakSet,Ro=function(t,e){return kM._normalizePoint(t,e,Oc(this,Oo),Oc(this,To),Oc(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 Oc(this,Xo)}setLastElement(t){return Oc(this,Vo).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return Oc(this,Vo).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of Oc(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(Oc(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 Oc(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 Oc(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=Oc(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 Oc(this,Ho).map(kM.svgRound).join(" ")}get defaultProperties(){const[t,e]=Oc(this,Ho);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${kM.svgRound(t)} ${kM.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=Oc(this,Ho);let n=0,r=0,i=0,A=0,s=0,a=0;switch(Oc(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]=Oc(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=Oc(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 Oc(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 Oc(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=Oc(this,Ho),s=t-A[0],a=e-A[1];if(Oc(this,Ko)===r&&Oc(this,Go)===i)for(const{line:o,points:l}of Oc(this,Vo))kM._translate(o,s,a,o),kM._translate(l,s,a,l);else{const t=Oc(this,Ko)/r,e=Oc(this,Go)/i;Dc(this,Ko,r),Dc(this,Go,i);for(const{line:n,points:r}of Oc(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=Oc(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=Oc(this,Xo)){const e=Oc(this,Wo)+t/2*Oc(this,zo);return Oc(this,qo)%180==0?[e/Oc(this,Ko),e/Oc(this,Go)]:[e/Oc(this,Go),e/Oc(this,Ko)]},Jo=function(){const[t,e,n,r]=Oc(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 Oc(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=Oc(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},Pc(XM,"_type","ink"),Pc(XM,"_editorType",tU.INK),Pc(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)*Oc(this,rl).sigmaSFactor,Oc(this,rl).sigmaR,Oc(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+Oc(this,sl)[2*i])*e+(r+Oc(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+Oc(this,sl)[2*i])*e+(r+Oc(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=Oc(this,sl)[2*p],m=Oc(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=Oc(this,sl)[2*r],m=Oc(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}=Oc(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 tP extends qM{constructor(t){super(t),super.updateProperties({stroke:QI._defaultLineColor,"stroke-width":1})}clone(){const t=new tP(this._viewParameters);return t.updateAll(this),t}}const eP=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 tP(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:!!Oc(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(Oc(this,vl)){const{lines:e,mustSmooth:n,areContours:r,description:i,uuid:A,heightInPage:s}=Oc(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:Oc(this,wl)||""}));return r&&(this._isCopy=!0,this._moveAfterPaste(e,n)),this.div}setUuid(t){Dc(this,yl,t),this.addEditToolbar()}getUuid(){return Oc(this,yl)}get description(){return Oc(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}=Oc(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,Oc(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:Oc(this,ml),color:[0,0,0],thickness:Oc(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=Oc(this,yl),A.isCopy=!0):A.lines=e,Oc(this,wl)&&(A.accessibilityData={type:"Figure",alt:Oc(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,Pc(eP,"_type","signature"),Pc(eP,"_editorType",tU.SIGNATURE),Pc(eP,"_defaultDrawingOptions",null);let nP=eP;const rP=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;Oc(this,Bl)&&(Dc(this,bl,null),this._uiManager.imageManager.deleteId(Oc(this,Bl)),null==(t=Oc(this,Sl))||t.remove(),Dc(this,Sl,null),Oc(this,Ll)&&(clearTimeout(Oc(this,Ll)),Dc(this,Ll,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(Oc(this,Bl)&&null===Oc(this,Sl)&&Rc(this,Ql,Pl).call(this),this.isAttachedToDOM||this.parent.add(this))):Oc(this,Bl)&&Rc(this,Ql,Pl).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(Oc(this,_l)||Oc(this,bl)||Oc(this,Cl)||Oc(this,xl)||Oc(this,Bl)||Oc(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(),Oc(this,Fl)||(Oc(this,bl)?Rc(this,Ql,Nl).call(this):Rc(this,Ql,Pl).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,Nl).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==Oc(this,Ll)&&clearTimeout(Oc(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}=Oc(this,bl),s=new hI;let a=Oc(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);Oc(this,Ul)||(a=Rc(this,Ql,Ol).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=Oc(this,bl),i>t||A>t){const r=Math.min(t/i,t/A);e=Math.floor(i*r),n=Math.floor(A*r),Oc(this,Ul)||(a=Rc(this,Ql,Ol).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:Oc(this,Bl),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:Oc(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=Oc(this,Ul)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(e.stamps.has(Oc(this,Bl))){if(Oc(this,Ul)){const t=e.stamps.get(Oc(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(Oc(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,Nl).call(this)):this.remove()},Ml=function(){if(Dc(this,_l,null),this._uiManager.enableWaiting(!1),Oc(this,Sl))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Oc(this,bl))this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&Oc(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()}},Pl=function(){if(Oc(this,Bl))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(Oc(this,Bl)).then(t=>Rc(this,Ql,kl).call(this,t,!0)).finally(()=>Rc(this,Ql,Ml).call(this));if(Oc(this,Cl)){const t=Oc(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(Oc(this,xl)){const t=Oc(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()},Nl=function(){var t;const{div:e}=this;let{width:n,height:r}=Oc(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),Oc(this,Il)||(this.parent.addUndoableEditor(this),Dc(this,Il,!0)),this._reportTelemetry({action:"inserted_image"}),Oc(this,El)&&this.div.setAttribute("aria-description",Oc(this,El)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},Ol=function(t,e){const{width:n,height:r}=Oc(this,bl);let i=n,A=r,s=Oc(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=Oc(this,Sl);if(!a||a.width===A&&a.height===s)return;a.width=A,a.height=s;const o=Oc(this,Ul)?Oc(this,bl):Rc(this,Ql,Ol).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(Oc(this,Ul)){const t=this._uiManager.imageManager.getSvgUrl(Oc(this,Bl));if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=Oc(this,bl));return t.getContext("2d").drawImage(Oc(this,bl),0,0),t.toDataURL()}if(Oc(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(Oc(this,bl),0,0,Oc(this,bl).width,Oc(this,bl).height,0,0,n,r),i.transferToImageBitmap()}return structuredClone(Oc(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}},Pc(rP,"_type","stamp"),Pc(rP,"_editorType",tU.STAMP);let iP=rP;const AP=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=[...Oc(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,Oc(this,nc).addLayer(this)}get isEmpty(){return 0===Oc(this,Gl).size}get isInvisible(){return this.isEmpty&&Oc(this,nc).getMode()===tU.NONE}updateToolbar(t){Oc(this,nc).updateToolbar(t)}updateMode(e=Oc(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 Oc(t,rc).values())n.toggle(`${r._type}Editing`,e===r._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null==(e=Oc(this,Jl))?void 0:e.div)}setEditingState(t){Oc(this,nc).setEditingState(t)}addCommands(t){Oc(this,nc).addCommands(t)}cleanUndoStack(t){Oc(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=Oc(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=Oc(this,tc))||t.abort(),Dc(this,tc,null);const e=new Set;for(const r of Oc(this,Gl).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(Oc(this,nc).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(!Oc(this,Wl))return void Dc(this,Xl,!1);const n=Oc(this,Wl).getEditableAnnotations();for(const r of n){if(r.hide(),Oc(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),Oc(this,Jl)&&!Oc(this,tc)){Dc(this,tc,new AbortController);const t=Oc(this,nc).combinedSignal(Oc(this,tc));Oc(this,Jl).div.addEventListener("pointerdown",t=>{const{clientX:e,clientY:n,timeStamp:r}=t;if(r-Oc(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=Oc(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 Oc(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(Oc(this,Wl)){const t=Oc(this,Wl).getEditableAnnotations();for(const e of t){const{id:t}=e.data;if(Oc(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&&(Oc(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 Oc(t,rc).values())i.remove(`${A._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),Dc(this,ql,!1)}getEditableAnnotation(t){var e;return(null==(e=Oc(this,Wl))?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){Oc(this,nc).getActive()!==t&&Oc(this,nc).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(null==(t=Oc(this,Jl))?void 0:t.div)&&!Oc(this,Zl)){Dc(this,Zl,new AbortController);const t=Oc(this,nc).combinedSignal(Oc(this,Zl));Oc(this,Jl).div.addEventListener("pointerdown",Rc(this,ic,Ac).bind(this),{signal:t}),Oc(this,Jl).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(null==(t=Oc(this,Jl))?void 0:t.div)&&Oc(this,Zl)&&(Oc(this,Zl).abort(),Dc(this,Zl,null),Oc(this,Jl).div.classList.remove("highlighting"))}enableClick(){if(Oc(this,Vl))return;Dc(this,Vl,new AbortController);const t=Oc(this,nc).combinedSignal(Oc(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=Oc(this,Vl))||t.abort(),Dc(this,Vl,null)}attach(t){Oc(this,Gl).set(t.id,t);const{annotationElementId:e}=t;e&&Oc(this,nc).isDeletedAnnotationElement(e)&&Oc(this,nc).removeDeletedAnnotationElement(t)}detach(t){var e;Oc(this,Gl).delete(t.id),null==(e=Oc(this,Hl))||e.removePointerInTextLayer(t.contentDiv),!Oc(this,ql)&&t.annotationElementId&&Oc(this,nc).addDeletedAnnotationElement(t)}remove(t){this.detach(t),Oc(this,nc).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(Oc(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),Oc(this,nc).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!Oc(this,Xl)),Oc(this,nc).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:n}=document;t.div.contains(n)&&!Oc(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:Oc(this,nc)._signal}),n.focus())},0))),t._structTreeParentId=null==(e=Oc(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 Oc(this,nc).getId()}combinedSignal(t){return Oc(this,nc).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null==(t=Oc(this,ic,sc))?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){return Wc(this,null,function*(){this.updateToolbar(t),yield Oc(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:Oc(this,nc),isCentered:!0},e));A&&this.add(A)})}deserialize(e){return Wc(this,null,function*(){var n,r;return(yield null==(r=Oc(t,rc).get(null!=(n=e.annotationType)?n:e.annotationEditorType))?void 0:r.deserialize(e,this,Oc(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:Oc(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){Oc(this,nc).setSelected(t)}toggleSelected(t){Oc(this,nc).toggleSelected(t)}unselect(t){Oc(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(!Oc(this,zl))return;if(Dc(this,zl,!1),(null==(e=Oc(this,ic,sc))?void 0:e.isDrawer)&&Oc(this,ic,sc).supportMultipleDrawings)return;if(!Oc(this,jl))return void Dc(this,jl,!0);const r=Oc(this,nc).getMode();r!==tU.STAMP&&r!==tU.SIGNATURE?this.createAndAddNewEditor(t,!1):Oc(this,nc).unselectAll()}pointerdown(t){var e;if(Oc(this,nc).getMode()===tU.HIGHLIGHT&&this.enableTextSelection(),Oc(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=Oc(this,ic,sc))?void 0:e.isDrawer)return void this.startDrawingSession(t);const r=Oc(this,nc).getActive();Dc(this,jl,!r||r.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),Oc(this,Yl))return void Oc(this,ic,sc).startDrawing(this,Oc(this,nc),!1,t);Oc(this,nc).setCurrentDrawingSession(this),Dc(this,Yl,new AbortController);const e=Oc(this,nc).combinedSignal(Oc(this,Yl));this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(Dc(this,$l,null),this.commitOrRemove())},{signal:e}),Oc(this,ic,sc).startDrawing(this,Oc(this,nc),!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&Dc(this,$l,t))}Oc(this,$l)&&setTimeout(()=>{var t;null==(t=Oc(this,$l))||t.focus(),Dc(this,$l,null)},0)}endDrawingSession(t=!1){return Oc(this,Yl)?(Oc(this,nc).setCurrentDrawingSession(null),Oc(this,Yl).abort(),Dc(this,Yl,null),Dc(this,$l,null),Oc(this,ic,sc).endDrawing(t)):null}findNewParent(t,e,n){const r=Oc(this,nc).findParent(e,n);return null!==r&&r!==this&&(r.changeParent(t),!0)}commitOrRemove(){return!!Oc(this,Yl)&&(this.endDrawingSession(),!0)}onScaleChanging(){Oc(this,Yl)&&Oc(this,ic,sc).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),(null==(t=Oc(this,nc).getActive())?void 0:t.parent)===this&&(Oc(this,nc).commitOrRemove(),Oc(this,nc).setActiveEditor(null)),Oc(this,Kl)&&(clearTimeout(Oc(this,Kl)),Dc(this,Kl,null));for(const n of Oc(this,Gl).values())null==(e=Oc(this,Hl))||e.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,Oc(this,Gl).clear(),Oc(this,nc).removeLayer(this)}render({viewport:t}){this.viewport=t,cI(this.div,t);for(const e of Oc(this,nc).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){Oc(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 Oc(this,Gl).values())r.rotate(n)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return Oc(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){Oc(this,nc).unselectAll();const{target:e}=t;if(e===Oc(this,Jl).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&Oc(this,Jl).div.contains(e)){const{isMac:e}=DU.platform;if(0!==t.button||t.ctrlKey&&e)return;Oc(this,nc).showAllEditors("highlight",!0,!0),Oc(this,Jl).div.classList.add("free"),this.toggleDrawing(),jM.startHighlighting(this,"ltr"===Oc(this,nc).direction,{target:Oc(this,Jl).div,x:t.x,y:t.y}),Oc(this,Jl).div.addEventListener("pointerup",()=>{Oc(this,Jl).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:Oc(this,nc)._signal}),t.preventDefault()}},sc=function(){return Oc(AP,rc).get(Oc(this,nc).getMode())},ac=function(t){const e=Oc(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 Oc(this,Gl).values())t.isEmpty()&&t.remove()},Pc(AP,"_initialized",!1),Tc(AP,rc,new Map([QM,YM,iP,jM,nP].map(t=>[t._editorType,t])));let sP=AP;const aP=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(Oc(this,cc)){if(Oc(this,cc)!==t){if(Oc(this,hc).size>0)for(const e of Oc(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&&Oc(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),Oc(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),Oc(this,hc).set(r,i),r}finalizeDraw(t,e){Oc(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?Oc(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=Oc(this,hc).get(t);n&&(Oc(e,cc).append(n),Oc(this,hc).delete(t),Oc(e,hc).set(t,n))}remove(t){Oc(this,uc).delete(t),null!==Oc(this,cc)&&(Oc(this,hc).get(t).remove(),Oc(this,hc).delete(t))}destroy(){Dc(this,cc,null);for(const t of Oc(this,hc).values())t.remove();Oc(this,hc).clear(),Oc(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=aP._svgFactory.create(1,1,!0);return Oc(this,cc).append(t),t.setAttribute("aria-hidden",!0),t},wc=function(t,e){const n=aP._svgFactory.createElement("clipPath");t.append(n);const r=`clip_${e}`;n.setAttribute("id",r),n.setAttribute("clipPathUnits","objectBoundingBox");const i=aP._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(aP,fc),Tc(aP,dc,0);let oP=aP;globalThis._pdfjsTestingUtils={HighlightOutliner:OM},globalThis.pdfjsLib={AbortException:NU,AnnotationEditorLayer:sP,AnnotationEditorParamsType:eU,AnnotationEditorType:tU,AnnotationEditorUIManager:xI,AnnotationLayer:LM,AnnotationMode:JL,AnnotationType:lU,build:"295fb3ec4",ColorPicker:Kk,createValidAbsoluteUrl:SU,DOMSVGFactory:Jk,DrawLayer:oP,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:Pk,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 lP(t){let e=t.length;for(;--e>=0;)t[e]=0}const cP=256,hP=286,uP=30,dP=15,fP=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]),pP=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]),gP=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),mP=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wP=new Array(576);lP(wP);const vP=new Array(60);lP(vP);const yP=new Array(512);lP(yP);const bP=new Array(256);lP(bP);const BP=new Array(29);lP(BP);const _P=new Array(uP);function CP(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 xP,EP,SP;function FP(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}lP(_P);const LP=t=>t<256?yP[t]:yP[256+(t>>>7)],UP=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},IP=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,UP(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)},QP=(t,e,n)=>{IP(t,n[2*e],n[2*e+1])},kP=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},MP=(t,e,n)=>{const r=new Array(16);let i,A,s=0;for(i=1;i<=dP;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]=kP(r[e]++,e))}},PP=t=>{let e;for(e=0;e<hP;e++)t.dyn_ltree[2*e]=0;for(e=0;e<uP;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},NP=t=>{t.bi_valid>8?UP(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},OP=(t,e,n,r)=>{const i=2*e,A=2*n;return t[i]<t[A]||t[i]===t[A]&&r[e]<=r[n]},TP=(t,e,n)=>{const r=t.heap[n];let i=n<<1;for(;i<=t.heap_len&&(i<t.heap_len&&OP(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!OP(e,r,t.heap[i],t.depth));)t.heap[n]=t.heap[i],n=i,i<<=1;t.heap[n]=r},DP=(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?QP(t,i,e):(A=bP[i],QP(t,A+cP+1,e),s=fP[A],0!==s&&(i-=BP[A],IP(t,i,s)),r--,A=LP(r),QP(t,A,n),s=pP[A],0!==s&&(r-=_P[A],IP(t,r,s)))}while(a<t.sym_next);QP(t,256,e)},RP=(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--)TP(t,n,s);o=A;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],TP(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++,TP(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<=dP;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),MP(n,l,t.bl_count)},HP=(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))},jP=(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{QP(t,i,t.bl_tree)}while(0!==--a);else 0!==i?(i!==A&&(QP(t,i,t.bl_tree),a--),QP(t,16,t.bl_tree),IP(t,a-3,2)):a<=10?(QP(t,17,t.bl_tree),IP(t,a-3,3)):(QP(t,18,t.bl_tree),IP(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 WP=!1;const VP=(t,e,n,r)=>{IP(t,0+(r?1:0),3),NP(t),UP(t,n),UP(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n};var KP={_tr_init:t=>{WP||((()=>{let t,e,n,r,i;const A=new Array(16);for(n=0,r=0;r<28;r++)for(BP[r]=n,t=0;t<1<<fP[r];t++)bP[n++]=r;for(bP[n-1]=r,i=0,r=0;r<16;r++)for(_P[r]=i,t=0;t<1<<pP[r];t++)yP[i++]=r;for(i>>=7;r<uP;r++)for(_P[r]=i<<7,t=0;t<1<<pP[r]-7;t++)yP[256+i++]=r;for(e=0;e<=dP;e++)A[e]=0;for(t=0;t<=143;)wP[2*t+1]=8,t++,A[8]++;for(;t<=255;)wP[2*t+1]=9,t++,A[9]++;for(;t<=279;)wP[2*t+1]=7,t++,A[7]++;for(;t<=287;)wP[2*t+1]=8,t++,A[8]++;for(MP(wP,287,A),t=0;t<uP;t++)vP[2*t+1]=5,vP[2*t]=kP(t,5);xP=new CP(wP,fP,257,hP,dP),EP=new CP(vP,pP,0,uP,dP),SP=new CP(new Array(0),gP,0,19,7)})(),WP=!0),t.l_desc=new FP(t.dyn_ltree,xP),t.d_desc=new FP(t.dyn_dtree,EP),t.bl_desc=new FP(t.bl_tree,SP),t.bi_buf=0,t.bi_valid=0,PP(t)},_tr_stored_block:VP,_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<cP;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),RP(t,t.l_desc),RP(t,t.d_desc),s=(t=>{let e;for(HP(t,t.dyn_ltree,t.l_desc.max_code),HP(t,t.dyn_dtree,t.d_desc.max_code),RP(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*mP[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?VP(t,e,n,r):4===t.strategy||A===i?(IP(t,2+(r?1:0),3),DP(t,wP,vP)):(IP(t,4+(r?1:0),3),((t,e,n,r)=>{let i;for(IP(t,e-257,5),IP(t,n-1,5),IP(t,r-4,4),i=0;i<r;i++)IP(t,t.bl_tree[2*mP[i]+1],3);jP(t,t.dyn_ltree,e-1),jP(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),DP(t,t.dyn_ltree,t.dyn_dtree)),PP(t),r&&NP(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*(bP[n]+cP+1)]++,t.dyn_dtree[2*LP(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{IP(t,2,3),QP(t,256,wP),(t=>{16===t.bi_valid?(UP(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 GP=(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 zP=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 qP=(t,e,n,r)=>{const i=zP,A=r+n;t^=-1;for(let s=r;s<A;s++)t=t>>>8^i[255&(t^e[s])];return-1^t},XP={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"},YP={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:$P,_tr_stored_block:JP,_tr_flush_block:ZP,_tr_tally:tN,_tr_align:eN}=KP,{Z_NO_FLUSH:nN,Z_PARTIAL_FLUSH:rN,Z_FULL_FLUSH:iN,Z_FINISH:AN,Z_BLOCK:sN,Z_OK:aN,Z_STREAM_END:oN,Z_STREAM_ERROR:lN,Z_DATA_ERROR:cN,Z_BUF_ERROR:hN,Z_DEFAULT_COMPRESSION:uN,Z_FILTERED:dN,Z_HUFFMAN_ONLY:fN,Z_RLE:pN,Z_FIXED:gN,Z_DEFAULT_STRATEGY:mN,Z_UNKNOWN:wN,Z_DEFLATED:vN}=YP,yN=258,bN=262,BN=42,_N=113,CN=666,xN=(t,e)=>(t.msg=XP[e],e),EN=t=>2*t-(t>4?9:0),SN=t=>{let e=t.length;for(;--e>=0;)t[e]=0},FN=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 LN=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const UN=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))},IN=(t,e)=>{ZP(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,UN(t.strm)},QN=(t,e)=>{t.pending_buf[t.pending++]=e},kN=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},MN=(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=GP(t.adler,e,i,n):2===t.state.wrap&&(t.adler=qP(t.adler,e,i,n)),t.next_in+=i,t.total_in+=i,i)},PN=(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-bN?t.strstart-(t.w_size-bN):0,l=t.window,c=t.w_mask,h=t.prev,u=t.strstart+yN;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=yN-(u-A),A=u-yN,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},NN=t=>{const e=t.w_size;let n,r,i;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-bN)&&(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),FN(t),r+=e),0===t.strm.avail_in)break;if(n=MN(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=LN(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=LN(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<bN&&0!==t.strm.avail_in)},ON=(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!==AN||e===nN||n!==r+t.strm.avail_in))break;s=e===AN&&n===r+t.strm.avail_in?1:0,JP(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,UN(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&&(MN(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!==nN&&e!==AN&&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&&(MN(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===AN)&&e!==nN&&0===t.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=e===AN&&0===t.strm.avail_in&&n===r?1:0,JP(t,t.block_start,n,s),t.block_start+=n,UN(t.strm)),s?3:1)},TN=(t,e)=>{let n,r;for(;;){if(t.lookahead<bN){if(NN(t),t.lookahead<bN&&e===nN)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=LN(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-bN&&(t.match_length=PN(t,n)),t.match_length>=3)if(r=tN(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=LN(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=LN(t,t.ins_h,t.window[t.strstart+1]);else r=tN(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(r&&(IN(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===AN?(IN(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IN(t,!1),0===t.strm.avail_out)?1:2},DN=(t,e)=>{let n,r,i;for(;;){if(t.lookahead<bN){if(NN(t),t.lookahead<bN&&e===nN)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=LN(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-bN&&(t.match_length=PN(t,n),t.match_length<=5&&(t.strategy===dN||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=tN(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=LN(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&&(IN(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(r=tN(t,0,t.window[t.strstart-1]),r&&IN(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=tN(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===AN?(IN(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IN(t,!1),0===t.strm.avail_out)?1:2};function RN(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 HN=[new RN(0,0,0,0,ON),new RN(4,4,8,4,TN),new RN(4,5,16,8,TN),new RN(4,6,32,32,TN),new RN(4,4,16,16,DN),new RN(8,16,32,32,DN),new RN(8,16,128,128,DN),new RN(8,32,128,256,DN),new RN(32,128,258,1024,DN),new RN(32,258,258,4096,DN)];function jN(){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=vN,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),SN(this.dyn_ltree),SN(this.dyn_dtree),SN(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),SN(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),SN(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 WN=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==BN&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==_N&&e.status!==CN?1:0},VN=t=>{if(WN(t))return xN(t,lN);t.total_in=t.total_out=0,t.data_type=wN;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?BN:_N,t.adler=2===e.wrap?0:1,e.last_flush=-2,$P(e),aN},KN=t=>{const e=VN(t);var n;return e===aN&&((n=t.state).window_size=2*n.w_size,SN(n.head),n.max_lazy_match=HN[n.level].max_lazy,n.good_match=HN[n.level].good_length,n.nice_match=HN[n.level].nice_length,n.max_chain_length=HN[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},GN=(t,e,n,r,i,A)=>{if(!t)return lN;let s=1;if(e===uN&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==vN||r<8||r>15||e<0||e>9||A<0||A>gN||8===r&&1!==s)return xN(t,lN);8===r&&(r=9);const a=new jN;return t.state=a,a.strm=t,a.status=BN,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,KN(t)};var zN={deflateInit:(t,e)=>GN(t,e,vN,15,8,mN),deflateInit2:GN,deflateReset:KN,deflateResetKeep:VN,deflateSetHeader:(t,e)=>WN(t)||2!==t.state.wrap?lN:(t.state.gzhead=e,aN),deflate:(t,e)=>{if(WN(t)||e>sN||e<0)return t?xN(t,lN):lN;const n=t.state;if(!t.output||0!==t.avail_in&&!t.input||n.status===CN&&e!==AN)return xN(t,0===t.avail_out?hN:lN);const r=n.last_flush;if(n.last_flush=e,0!==n.pending){if(UN(t),0===t.avail_out)return n.last_flush=-1,aN}else if(0===t.avail_in&&EN(e)<=EN(r)&&e!==AN)return xN(t,hN);if(n.status===CN&&0!==t.avail_in)return xN(t,hN);if(n.status===BN&&0===n.wrap&&(n.status=_N),n.status===BN){let e=vN+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=fN||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,kN(n,e),0!==n.strstart&&(kN(n,t.adler>>>16),kN(n,65535&t.adler)),t.adler=1,n.status=_N,UN(t),0!==n.pending)return n.last_flush=-1,aN}if(57===n.status)if(t.adler=0,QN(n,31),QN(n,139),QN(n,8),n.gzhead)QN(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)),QN(n,255&n.gzhead.time),QN(n,n.gzhead.time>>8&255),QN(n,n.gzhead.time>>16&255),QN(n,n.gzhead.time>>24&255),QN(n,9===n.level?2:n.strategy>=fN||n.level<2?4:0),QN(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(QN(n,255&n.gzhead.extra.length),QN(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=qP(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(QN(n,0),QN(n,0),QN(n,0),QN(n,0),QN(n,0),QN(n,9===n.level?2:n.strategy>=fN||n.level<2?4:0),QN(n,3),n.status=_N,UN(t),0!==n.pending)return n.last_flush=-1,aN;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=qP(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex+=i,UN(t),0!==n.pending)return n.last_flush=-1,aN;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=qP(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=qP(t.adler,n.pending_buf,n.pending-r,r)),UN(t),0!==n.pending)return n.last_flush=-1,aN;r=0}e=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,QN(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>r&&(t.adler=qP(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=qP(t.adler,n.pending_buf,n.pending-r,r)),UN(t),0!==n.pending)return n.last_flush=-1,aN;r=0}e=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,QN(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>r&&(t.adler=qP(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&&(UN(t),0!==n.pending))return n.last_flush=-1,aN;QN(n,255&t.adler),QN(n,t.adler>>8&255),t.adler=0}if(n.status=_N,UN(t),0!==n.pending)return n.last_flush=-1,aN}if(0!==t.avail_in||0!==n.lookahead||e!==nN&&n.status!==CN){let r=0===n.level?ON(n,e):n.strategy===fN?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(NN(t),0===t.lookahead)){if(e===nN)return 1;break}if(t.match_length=0,n=tN(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(IN(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===AN?(IN(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IN(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===pN?((t,e)=>{let n,r,i,A;const s=t.window;for(;;){if(t.lookahead<=yN){if(NN(t),t.lookahead<=yN&&e===nN)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+yN;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=yN-(A-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=tN(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=tN(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(IN(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===AN?(IN(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(IN(t,!1),0===t.strm.avail_out)?1:2})(n,e):HN[n.level].func(n,e);if(3!==r&&4!==r||(n.status=CN),1===r||3===r)return 0===t.avail_out&&(n.last_flush=-1),aN;if(2===r&&(e===rN?eN(n):e!==sN&&(JP(n,0,0,!1),e===iN&&(SN(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),UN(t),0===t.avail_out))return n.last_flush=-1,aN}return e!==AN?aN:n.wrap<=0?oN:(2===n.wrap?(QN(n,255&t.adler),QN(n,t.adler>>8&255),QN(n,t.adler>>16&255),QN(n,t.adler>>24&255),QN(n,255&t.total_in),QN(n,t.total_in>>8&255),QN(n,t.total_in>>16&255),QN(n,t.total_in>>24&255)):(kN(n,t.adler>>>16),kN(n,65535&t.adler)),UN(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?aN:oN)},deflateEnd:t=>{if(WN(t))return lN;const e=t.state.status;return t.state=null,e===_N?xN(t,cN):aN},deflateSetDictionary:(t,e)=>{let n=e.length;if(WN(t))return lN;const r=t.state,i=r.wrap;if(2===i||1===i&&r.status!==BN||r.lookahead)return lN;if(1===i&&(t.adler=GP(t.adler,e,n,0)),r.wrap=0,n>=r.w_size){0===i&&(SN(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,NN(r);r.lookahead>=3;){let t=r.strstart,e=r.lookahead-2;do{r.ins_h=LN(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,NN(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,aN},deflateInfo:"pako deflate (from Nodeca project)"};const qN=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var XN=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)qN(n,e)&&(t[e]=n[e])}}return t},YN=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 $N=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(a3){$N=!1}const JN=new Uint8Array(256);for(let o3=0;o3<256;o3++)JN[o3]=o3>=252?6:o3>=248?5:o3>=240?4:o3>=224?3:o3>=192?2:1;JN[254]=JN[254]=1;var ZN=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},tO=(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=JN[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&&$N)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)},eO=(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+JN[t[n]]>e?n:e};var nO=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 rO=Object.prototype.toString,{Z_NO_FLUSH:iO,Z_SYNC_FLUSH:AO,Z_FULL_FLUSH:sO,Z_FINISH:aO,Z_OK:oO,Z_STREAM_END:lO,Z_DEFAULT_COMPRESSION:cO,Z_DEFAULT_STRATEGY:hO,Z_DEFLATED:uO}=YP;function dO(t){this.options=XN({level:cO,method:uO,chunkSize:16384,windowBits:15,memLevel:8,strategy:hO},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 nO,this.strm.avail_out=0;let n=zN.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==oO)throw new Error(XP[n]);if(e.header&&zN.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?ZN(e.dictionary):"[object ArrayBuffer]"===rO.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=zN.deflateSetDictionary(this.strm,t),n!==oO)throw new Error(XP[n]);this._dict_set=!0}}function fO(t,e){const n=new dO(e);if(n.push(t,!0),n.err)throw n.msg||XP[n.err];return n.result}dO.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?aO:iO,"string"==typeof t?n.input=ZN(t):"[object ArrayBuffer]"===rO.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===AO||A===sO)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=zN.deflate(n,A),i===lO)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=zN.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===oO;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},dO.prototype.onData=function(t){this.chunks.push(t)},dO.prototype.onEnd=function(t){t===oO&&(this.result=YN(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var pO={Deflate:dO,deflate:fO,deflateRaw:function(t,e){return(e=e||{}).raw=!0,fO(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,fO(t,e)}};const gO=16209;var mO=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=gO;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=gO;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=gO;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=gO;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 wO=15,vO=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]),yO=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]),bO=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]),BO=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 _O=(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<=wO;p++)E[p]=0;for(g=0;g<r;g++)E[e[n+g]]++;for(v=o,w=wO;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<=wO;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<wO;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=vO,I=yO,f=257):(x=bO,I=BO,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:CO,Z_BLOCK:xO,Z_TREES:EO,Z_OK:SO,Z_STREAM_END:FO,Z_NEED_DICT:LO,Z_STREAM_ERROR:UO,Z_DATA_ERROR:IO,Z_MEM_ERROR:QO,Z_BUF_ERROR:kO,Z_DEFLATED:MO}=YP,PO=16180,NO=16190,OO=16191,TO=16192,DO=16194,RO=16199,HO=16200,jO=16206,WO=16209,VO=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function KO(){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 GO=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<PO||e.mode>16211?1:0},zO=t=>{if(GO(t))return UO;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=PO,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,SO},qO=t=>{if(GO(t))return UO;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,zO(t)},XO=(t,e)=>{let n;if(GO(t))return UO;const r=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?UO:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,qO(t))},YO=(t,e)=>{if(!t)return UO;const n=new KO;t.state=n,n.strm=t,n.window=null,n.mode=PO;const r=XO(t,e);return r!==SO&&(t.state=null),r};let $O,JO,ZO=!0;const tT=t=>{if(ZO){$O=new Int32Array(512),JO=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(_O(1,t.lens,0,288,$O,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;_O(2,t.lens,0,32,JO,0,t.work,{bits:5}),ZO=!1}t.lencode=$O,t.lenbits=9,t.distcode=JO,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:qO,inflateReset2:XO,inflateResetKeep:zO,inflateInit:t=>YO(t,15),inflateInit2:YO,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(GO(t)||!t.output||!t.input&&0!==t.avail_in)return UO;n=t.state,n.mode===OO&&(n.mode=TO),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,_=SO;t:for(;;)switch(n.mode){case PO:if(0===n.wrap){n.mode=TO;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=qP(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=WO;break}if((15&l)!==MO){t.msg="unknown compression method",n.mode=WO;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=WO;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&l?16189:OO,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)!==MO){t.msg="unknown compression method",n.mode=WO;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=WO;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=qP(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=qP(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=qP(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=qP(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=qP(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=qP(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=qP(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=WO;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=OO;break;case 16189:for(;c<32;){if(0===a)break t;a--,l+=r[A++]<<c,c+=8}t.adler=n.check=VO(l),l=0,c=0,n.mode=NO;case NO: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,LO;t.adler=n.check=1,n.mode=OO;case OO:if(e===xO||e===EO)break t;case TO:if(n.last){l>>>=7&c,c-=7&c,n.mode=jO;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=RO,e===EO){l>>>=2,c-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=WO}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=WO;break}if(n.length=65535&l,l=0,c=0,n.mode=DO,e===EO)break t;case DO: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=OO;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=WO;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},_=_O(0,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid code lengths set",n.mode=WO;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=WO;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=WO;break}for(;d--;)n.lens[n.have++]=B}}if(n.mode===WO)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=WO;break}if(n.lenbits=9,E={bits:n.lenbits},_=_O(1,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,_){t.msg="invalid literal/lengths set",n.mode=WO;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},_=_O(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,_){t.msg="invalid distances set",n.mode=WO;break}if(n.mode=RO,e===EO)break t;case RO:n.mode=HO;case HO: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,mO(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===OO&&(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=OO;break}if(64&m){t.msg="invalid literal/length code",n.mode=WO;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=WO;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=WO;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=WO;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=HO);break;case 16205:if(0===o)break t;i[s++]=n.length,o--,n.mode=HO;break;case jO: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?qP(n.check,i,u,s-u):GP(n.check,i,u,s-u)),u=o,4&n.wrap&&(n.flags?l:VO(l))!==n.check){t.msg="incorrect data check",n.mode=WO;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=WO;break}l=0,c=0}n.mode=16208;case 16208:_=FO;break t;case WO:_=IO;break t;case 16210:return QO;default:return UO}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<WO&&(n.mode<jO||e!==CO))&&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?qP(n.check,i,u,t.next_out-u):GP(n.check,i,u,t.next_out-u)),t.data_type=n.bits+(n.last?64:0)+(n.mode===OO?128:0)+(n.mode===RO||n.mode===DO?256:0),(0===h&&0===u||e===CO)&&_===SO&&(_=kO),_},inflateEnd:t=>{if(GO(t))return UO;let e=t.state;return e.window&&(e.window=null),t.state=null,SO},inflateGetHeader:(t,e)=>{if(GO(t))return UO;const n=t.state;return 2&n.wrap?(n.head=e,e.done=!1,SO):UO},inflateSetDictionary:(t,e)=>{const n=e.length;let r,i,A;return GO(t)?UO:(r=t.state,0!==r.wrap&&r.mode!==NO?UO:r.mode===NO&&(i=1,i=GP(i,e,n,0),i!==r.check)?IO:(A=eT(t,e,n,n),A?(r.mode=16210,QO):(r.havedict=1,SO)))},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}=YP;function dT(t){this.options=XN({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 nO,this.strm.avail_out=0;let n=nT.inflateInit2(this.strm,e.windowBits);if(n!==aT)throw new Error(XP[n]);if(this.header=new rT,nT.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=ZN(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(XP[n])}function fT(t,e){const n=new dT(e);if(n.push(t),n.err)throw n.msg||XP[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=eO(n.output,n.next_out),e=n.next_out-t,i=tO(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=YN(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}=pO,{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:YP};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(s3){throw console.error("❌ Erro ao converter PDF para imagens:",s3),s3}}),ET=()=>Wc(this,null,function*(){try{return 200===(yield e.get("http://localhost:9999/health",{timeout:3e3})).status}catch(s3){return console.log("🖨️ Impressora não detectada:",s3.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(s3){throw console.error("❌ Erro ao enviar para impressão:",s3),s3}}),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(s3){throw console.error("❌ Erro ao baixar PDF:",s3),s3}}),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(s3){return console.error("❌ Erro geral no processo de impressão:",s3),{success:!1,error:s3.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 PT(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 NT=(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}}},OT=(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=t=>Wc(this,null,function*(){return console.warn("LabelsAPI não carregado - usando placeholder"),null});const HT=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(s3){console.error("Erro ao processar dados da impressora:",s3)}}),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(s3){console.error("Erro ao conectar SSE:",s3),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))),jT=(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},WT=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},VT={PECA_TIPO:["Matéria Prima","Produto Acabado","Produto Intermediário"],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 KT={printerName:null,paperSize:"A4",orientation:"portrait",defaultTemplate:"template-padrao",autoDownloadOnPrinterError:!0,defaultTransformer:{fieldMap:"legacy",fieldMapSource:null}};function GT(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 zT=(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&&!WT(n))throw new Error("defaultTransformer.fieldMapSource inválido")}const e=Qc({autoConnectPrinter:!0},t);if(KT=Qc(Qc({},KT),e),e.token&&console.warn("updateApiToken não carregado - usando placeholder"),e.autoConnectPrinter)try{XT(),console.log("🖨️ Auto-conectando ao SSE da impressora...")}catch(s3){console.warn("⚠️ Falha na auto-conexão do SSE da impressora:",s3.message)}return console.log("🏷️ Etiquetas.js initialized successfully"),console.log("🔄 Default transformer:",KT.defaultTransformer.fieldMap),console.log("🖨️ Auto-connect printer:",e.autoConnectPrinter),KT},qT=()=>Wc(this,null,function*(){try{const t=HT.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:KT.paperSize,orientation:KT.orientation,globalPrinterName:KT.printerName}}catch(s3){return{connected:!1,error:s3.message,status:"error",printerName:"Erro ao obter status",hasDefaultPrinter:!1,message:`Erro: ${s3.message}`,printer:null,sseConnected:!1,paperSize:KT.paperSize,orientation:KT.orientation}}}),XT=()=>{try{HT.getState().connectToSSE(),console.log("🔌 Conectando ao SSE da impressora...")}catch(s3){console.error("❌ Erro ao conectar SSE da impressora:",s3)}};function YT(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 $T=(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=KT.defaultTransformer,i&&"none"!==i.fieldMap){const{fieldMap:e,fieldMapSource:r}=i;let a;switch(e){case"legacy":a=VT,console.log("🔄 Using legacy transformer");break;case"custom":if(!r)throw new Error('fieldMapSource é obrigatório quando fieldMap="custom"');if(!WT(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&&!WT(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=>jT(t,e)):jT(t,e)}catch(s3){if(A&&console.error("❌ Erro ao aplicar transformações:",s3.message),i)throw s3;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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating label:",s3),s3}}),JT=(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=KT.defaultTransformer;t&&"none"!==t.fieldMap?(r=!0,i=`${t.fieldMap} (default from init)`):(r=!1,i="none (disabled in init)")}const A=yield $T(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(s3){throw console.error("❌ Error in smart label sending:",s3),s3}}),ZT=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating part label:",s3),s3}}),tD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(t).map(t=>{return e=t,console.log("=>>",e),Qc({},e);var e}),A=Qc({dataSource:i,labels:yield sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating thickening label:",s3),s3}}),eD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating input label:",s3),s3}}),nD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating scrap label:",s3),s3}}),rD=(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=EF(),i=GT(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 sD(e),userPrefs:KT,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(s3){throw console.error("❌ Error generating volume label:",s3),s3}}),iD=(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(s3){throw console.error("❌ Download error:",s3),s3}}),AD=(t,...e)=>Wc(this,[t,...e],function*(t,e={}){try{const n=HT.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:KT.printerName,paperSize:KT.paperSize,orientation:KT.orientation},e.metadata),scale:e.scale||1.5,autoDownloadOnError:!1!==KT.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(s3){if(console.error("❌ Print error:",s3),KT.autoDownloadOnPrinterError)try{return console.log("📥 Tentando download como alternativa..."),yield iD(t,e.filename||"etiqueta.pdf"),{success:!0,downloaded:!0,fileName:e.filename||"etiqueta.pdf",message:"Falha na impressão - PDF baixado como alternativa",error:s3.message,printerError:!0}}catch(n){console.error("❌ Erro também no download:",n)}throw s3}}),sD=t=>Wc(this,null,function*(){try{const e=yield function(t){return Wc(this,null,function*(){try{const e=yield RT(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(s3){throw console.error(`Erro ao buscar template: ${s3.message}`),s3}})}(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(s3){return console.error("❌ Error loading template:",s3),[{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}]}}),aD=(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}},oD={init:zT,getPrinterStatus:qT,isPrinterReady:()=>Wc(this,null,function*(){try{const t=HT.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?[]:YT(e,n)}}catch(s3){return{ready:!1,error:s3.message,message:"Erro ao verificar status da impressora",recommendations:["Verifique a conexão com o servidor de impressão"]}}}),makeLabel:$T,sendLabel:JT,makePartLabel:ZT,makeThickeningLabel:tD,makeInputLabel:eD,makeScrapLabel:nD,makeVolumeLabel:rD,downloadPDF:iD,sendToPrinter:AD,sendPartLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield ZT(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(s3){throw console.error("❌ Error in smart part sending:",s3),s3}}),sendTamponamentoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield tD(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(s3){throw console.error("❌ Error in smart thickening sending:",s3),s3}}),sendInsumoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield eD(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(s3){throw console.error("❌ Error in smart input sending:",s3),s3}}),sendRetalhoLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield nD(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(s3){throw console.error("❌ Error in smart scrap sending:",s3),s3}}),sendVolumeLabel:(t,e,...n)=>Wc(this,[t,e,...n],function*(t,e,n={}){try{const r=yield rD(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(s3){throw console.error("❌ Error in smart volume sending:",s3),s3}}),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 ZT(i,e);break;case"thickening":t=yield tD(i,e);break;case"inputs":t=yield eD(i,e);break;case"scraps":t=yield nD(i,e);break;case"volumes":t=yield rD(i,e);break;default:throw new Error(`Unsupported label type: ${n}`)}r.push(t)}catch(s3){console.error(`❌ Error generating label for item ${i.id}:`,s3),r.push(null)}return r}),validateLabelData:aD,legacyFieldMap:VT,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:jT,legacyTransformer:t=>jT(t,VT)},lD=kc(Qc({},oD),{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 cD(t){return(cD="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 hD(t,e){return(hD=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function uD(t,e,n){return(uD=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&&hD(i,n.prototype),i}).apply(null,arguments)}function dD(t){return function(t){if(Array.isArray(t))return fD(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 fD(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 fD(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 fD(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 pD=Object.hasOwnProperty,gD=Object.setPrototypeOf,mD=Object.isFrozen,wD=Object.getPrototypeOf,vD=Object.getOwnPropertyDescriptor,yD=Object.freeze,bD=Object.seal,BD=Object.create,_D="undefined"!=typeof Reflect&&Reflect,CD=_D.apply,xD=_D.construct;CD||(CD=function(t,e,n){return t.apply(e,n)}),yD||(yD=function(t){return t}),bD||(bD=function(t){return t}),xD||(xD=function(t,e){return uD(t,dD(e))});var ED,SD=TD(Array.prototype.forEach),FD=TD(Array.prototype.pop),LD=TD(Array.prototype.push),UD=TD(String.prototype.toLowerCase),ID=TD(String.prototype.toString),QD=TD(String.prototype.match),kD=TD(String.prototype.replace),MD=TD(String.prototype.indexOf),PD=TD(String.prototype.trim),ND=TD(RegExp.prototype.test),OD=(ED=TypeError,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return xD(ED,e)});function TD(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 CD(t,e,r)}}function DD(t,e,n){var r;n=null!==(r=n)&&void 0!==r?r:UD,gD&&gD(t,null);for(var i=e.length;i--;){var A=e[i];if("string"==typeof A){var s=n(A);s!==A&&(mD(e)||(e[i]=s),A=s)}t[A]=!0}return t}function RD(t){var e,n=BD(null);for(e in t)!0===CD(pD,t,[e])&&(n[e]=t[e]);return n}function HD(t,e){for(;null!==t;){var n=vD(t,e);if(n){if(n.get)return TD(n.get);if("function"==typeof n.value)return TD(n.value)}t=wD(t)}return function(t){return console.warn("fallback value for",t),null}}var jD=yD(["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"]),WD=yD(["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"]),VD=yD(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),KD=yD(["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"]),GD=yD(["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"]),zD=yD(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),qD=yD(["#text"]),XD=yD(["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"]),YD=yD(["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"]),$D=yD(["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"]),JD=yD(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ZD=bD(/\{\{[\w\W]*|[\w\W]*\}\}/gm),tR=bD(/<%[\w\W]*|[\w\W]*%>/gm),eR=bD(/\${[\w\W]*}/gm),nR=bD(/^data-[\-\w.\u00B7-\uFFFF]+$/),rR=bD(/^aria-[\-\w]+$/),iR=bD(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),AR=bD(/^(?:\w+script|data):/i),sR=bD(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),aR=bD(/^html$/i),oR=bD(/^[a-z][.\w]*(-[.\w]+)+$/i);var lR=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=HD(p,"cloneNode"),m=HD(p,"nextSibling"),w=HD(p,"childNodes"),v=HD(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"!==cD(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=RD(i).documentMode?i.documentMode:{}}catch(zt){}var U={};n.isSupported="function"==typeof v&&C&&void 0!==C.createHTMLDocument&&9!==L;var I,Q,k=ZD,M=tR,P=eR,N=nR,O=rR,T=AR,D=sR,R=oR,H=iR,j=null,W=DD({},[].concat(dD(jD),dD(WD),dD(VD),dD(GD),dD(qD))),V=null,K=DD({},[].concat(dD(XD),dD(YD),dD($D),dD(JD))),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=DD({},["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=DD({},["audio","video","img","source","image","track"]),gt=null,mt=DD({},["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=DD({},[wt,vt,yt],ID),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"===cD(t)||(t={}),t=RD(t),I=I=-1===xt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Q="application/xhtml+xml"===I?ID:UD,j="ALLOWED_TAGS"in t?DD({},t.ALLOWED_TAGS,Q):W,V="ALLOWED_ATTR"in t?DD({},t.ALLOWED_ATTR,Q):K,_t="ALLOWED_NAMESPACES"in t?DD({},t.ALLOWED_NAMESPACES,ID):Ct,gt="ADD_URI_SAFE_ATTR"in t?DD(RD(mt),t.ADD_URI_SAFE_ATTR,Q):mt,ft="ADD_DATA_URI_TAGS"in t?DD(RD(pt),t.ADD_DATA_URI_TAGS,Q):pt,ut="FORBID_CONTENTS"in t?DD({},t.FORBID_CONTENTS,Q):dt,z="FORBID_TAGS"in t?DD({},t.FORBID_TAGS,Q):{},q="FORBID_ATTR"in t?DD({},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=DD({},dD(qD)),V=[],!0===ht.html&&(DD(j,jD),DD(V,XD)),!0===ht.svg&&(DD(j,WD),DD(V,YD),DD(V,JD)),!0===ht.svgFilters&&(DD(j,VD),DD(V,YD),DD(V,JD)),!0===ht.mathMl&&(DD(j,GD),DD(V,$D),DD(V,JD))),t.ADD_TAGS&&(j===W&&(j=RD(j)),DD(j,t.ADD_TAGS,Q)),t.ADD_ATTR&&(V===K&&(V=RD(V)),DD(V,t.ADD_ATTR,Q)),t.ADD_URI_SAFE_ATTR&&DD(gt,t.ADD_URI_SAFE_ATTR,Q),t.FORBID_CONTENTS&&(ut===dt&&(ut=RD(ut)),DD(ut,t.FORBID_CONTENTS,Q)),lt&&(j["#text"]=!0),et&&DD(j,["html","head","body"]),j.table&&(DD(j,["tbody"]),delete z.tbody),yD&&yD(t),Et=t)},Ut=DD({},["mi","mo","mn","ms","mtext"]),It=DD({},["annotation-xml"]),Qt=DD({},["title","style","font","a","script"]),kt=DD({},WD);DD(kt,VD),DD(kt,KD);var Mt=DD({},GD);DD(Mt,zD);var Pt=function(t){LD(n.removed,{element:t});try{t.parentNode.removeChild(t)}catch(zt){try{t.outerHTML=B}catch(e){t.remove()}}},Nt=function(t,e){try{LD(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(zt){LD(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t&&!V[t])if(it||At)try{Pt(e)}catch(zt){}else try{e.setAttribute(t,"")}catch(zt){}},Ot=function(t){var e,n;if(rt)t="<remove></remove>"+t;else{var r=QD(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"===cD(a)?t instanceof a:t&&"object"===cD(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Ht=function(t,e,r){U[t]&&SD(U[t],function(t){t.call(n,e,r,Et)})},jt=function(t){var e;if(Ht("beforeSanitizeElements",t,null),Dt(t))return Pt(t),!0;if(ND(/[\u0080-\uFFFF]/,t.nodeName))return Pt(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))&&ND(/<[/\w]/g,t.innerHTML)&&ND(/<[/\w]/g,t.textContent))return Pt(t),!0;if("select"===r&&ND(/<template/i,t.innerHTML))return Pt(t),!0;if(7===t.nodeType)return Pt(t),!0;if(tt&&8===t.nodeType&&ND(/<[/\w]/g,t.data))return Pt(t),!0;if(!j[r]||z[r]){if(!z[r]&&Vt(r)){if(G.tagNameCheck instanceof RegExp&&ND(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 Pt(t),!0}return t instanceof o&&!function(t){var e=v(t);e&&e.tagName||(e={namespaceURI:bt,tagName:"template"});var n=UD(t.tagName),r=UD(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)?(Pt(t),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!ND(/<\/no(script|embed|frames)/i,t.innerHTML)?(Z&&3===t.nodeType&&(e=t.textContent,e=kD(e,k," "),e=kD(e,M," "),e=kD(e,P," "),t.textContent!==e&&(LD(n.removed,{element:t.cloneNode()}),t.textContent=e)),Ht("afterSanitizeElements",t,null),!1):(Pt(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]&&ND(N,e));else if(X&&ND(O,e));else if(!V[e]||q[e]){if(!(Vt(t)&&(G.tagNameCheck instanceof RegExp&&ND(G.tagNameCheck,t)||G.tagNameCheck instanceof Function&&G.tagNameCheck(t))&&(G.attributeNameCheck instanceof RegExp&&ND(G.attributeNameCheck,e)||G.attributeNameCheck instanceof Function&&G.attributeNameCheck(e))||"is"===e&&G.allowCustomizedBuiltInElements&&(G.tagNameCheck instanceof RegExp&&ND(G.tagNameCheck,n)||G.tagNameCheck instanceof Function&&G.tagNameCheck(n))))return!1}else if(gt[e]);else if(ND(H,kD(n,D,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==MD(n,"data:")||!ft[t]){if($&&!ND(T,kD(n,D,"")));else if(n)return!1}else;return!0},Vt=function(t){return"annotation-xml"!==t&&QD(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:PD(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&&(Nt(l,t),a.keepAttr))if(J||!ND(/\/>/i,r)){Z&&(r=kD(r,k," "),r=kD(r,M," "),r=kD(r,P," "));var h=Q(t.nodeName);if(Wt(h,i,r))if(!ot||"id"!==i&&"name"!==i||(Nt(l,t),r="user-content-"+r),tt&&ND(/((--!?|])>)|<\/(style|title)/i,r))Nt(l,t);else{if(b&&"object"===cD(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)?Pt(t):FD(n.removed)}catch(zt){}}}else Nt(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 OD("toString is not a function");if("string"!=typeof(t=t.toString()))throw OD("dirty is not a string, aborting")}if(!n.isSupported){if("object"===cD(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 OD("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof a)1===(s=(i=Ot("\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=Ot(t)))return it?null:st?B:""}i&&rt&&Pt(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&&ND(aR,i.ownerDocument.doctype.name)&&(f="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+f),Z&&(f=kD(f,k," "),f=kD(f,M," "),f=kD(f,P," ")),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]||[],LD(U[t],e))},n.removeHook=function(t){if(U[t])return FD(U[t])},n.removeHooks=function(t){U[t]&&(U[t]=[])},n.removeAllHooks=function(){U={}},n}();const cR=Object.freeze(Object.defineProperty({__proto__:null,default:lR},Symbol.toStringTag,{value:"Module"}));var hR=function(t){return t&&t.Math===Math&&t},uR=hR("object"==typeof globalThis&&globalThis)||hR("object"==typeof window&&window)||hR("object"==typeof self&&self)||hR("object"==typeof Jc&&Jc)||hR("object"==typeof Jc&&Jc)||function(){return this}()||Function("return this")(),dR={},fR=function(t){try{return!!t()}catch(s3){return!0}},pR=!fR(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),gR=!fR(function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}),mR=gR,wR=Function.prototype.call,vR=mR?wR.bind(wR):function(){return wR.apply(wR,arguments)},yR={},bR={}.propertyIsEnumerable,BR=Object.getOwnPropertyDescriptor,_R=BR&&!bR.call({1:2},1);yR.f=_R?function(t){var e=BR(this,t);return!!e&&e.enumerable}:bR;var CR,xR,ER=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},SR=gR,FR=Function.prototype,LR=FR.call,UR=SR&&FR.bind.bind(LR,LR),IR=SR?UR:function(t){return function(){return LR.apply(t,arguments)}},QR=IR,kR=QR({}.toString),MR=QR("".slice),PR=function(t){return MR(kR(t),8,-1)},NR=fR,OR=PR,TR=Object,DR=IR("".split),RR=NR(function(){return!TR("z").propertyIsEnumerable(0)})?function(t){return"String"===OR(t)?DR(t,""):TR(t)}:TR,HR=function(t){return null==t},jR=HR,WR=TypeError,VR=function(t){if(jR(t))throw new WR("Can't call method on "+t);return t},KR=RR,GR=VR,zR=function(t){return KR(GR(t))},qR="object"==typeof document&&document.all,XR=void 0===qR&&void 0!==qR?function(t){return"function"==typeof t||t===qR}:function(t){return"function"==typeof t},YR=XR,$R=function(t){return"object"==typeof t?null!==t:YR(t)},JR=uR,ZR=XR,tH=function(t,e){return arguments.length<2?(n=JR[t],ZR(n)?n:void 0):JR[t]&&JR[t][e];var n},eH=IR({}.isPrototypeOf),nH=uR.navigator,rH=nH&&nH.userAgent,iH=rH?String(rH):"",AH=uR,sH=iH,aH=AH.process,oH=AH.Deno,lH=aH&&aH.versions||oH&&oH.version,cH=lH&&lH.v8;cH&&(xR=(CR=cH.split("."))[0]>0&&CR[0]<4?1:+(CR[0]+CR[1])),!xR&&sH&&(!(CR=sH.match(/Edge\/(\d+)/))||CR[1]>=74)&&(CR=sH.match(/Chrome\/(\d+)/))&&(xR=+CR[1]);var hH=xR,uH=hH,dH=fR,fH=uR.String,pH=!!Object.getOwnPropertySymbols&&!dH(function(){var t=Symbol("symbol detection");return!fH(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&uH&&uH<41}),gH=pH&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,mH=tH,wH=XR,vH=eH,yH=Object,bH=gH?function(t){return"symbol"==typeof t}:function(t){var e=mH("Symbol");return wH(e)&&vH(e.prototype,yH(t))},BH=String,_H=function(t){try{return BH(t)}catch(s3){return"Object"}},CH=XR,xH=_H,EH=TypeError,SH=function(t){if(CH(t))return t;throw new EH(xH(t)+" is not a function")},FH=SH,LH=HR,UH=function(t,e){var n=t[e];return LH(n)?void 0:FH(n)},IH=vR,QH=XR,kH=$R,MH=TypeError,PH={exports:{}},NH=uR,OH=Object.defineProperty,TH=function(t,e){try{OH(NH,t,{value:e,configurable:!0,writable:!0})}catch(s3){NH[t]=e}return e},DH=uR,RH=TH,HH="__core-js_shared__",jH=PH.exports=DH[HH]||RH(HH,{});(jH.versions||(jH.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 WH=PH.exports,VH=WH,KH=function(t,e){return VH[t]||(VH[t]=e||{})},GH=VR,zH=Object,qH=function(t){return zH(GH(t))},XH=qH,YH=IR({}.hasOwnProperty),$H=Object.hasOwn||function(t,e){return YH(XH(t),e)},JH=IR,ZH=0,tj=Math.random(),ej=JH(1.1.toString),nj=function(t){return"Symbol("+(void 0===t?"":t)+")_"+ej(++ZH+tj,36)},rj=KH,ij=$H,Aj=nj,sj=pH,aj=gH,oj=uR.Symbol,lj=rj("wks"),cj=aj?oj.for||oj:oj&&oj.withoutSetter||Aj,hj=function(t){return ij(lj,t)||(lj[t]=sj&&ij(oj,t)?oj[t]:cj("Symbol."+t)),lj[t]},uj=vR,dj=$R,fj=bH,pj=UH,gj=function(t,e){var n,r;if("string"===e&&QH(n=t.toString)&&!kH(r=IH(n,t)))return r;if(QH(n=t.valueOf)&&!kH(r=IH(n,t)))return r;if("string"!==e&&QH(n=t.toString)&&!kH(r=IH(n,t)))return r;throw new MH("Can't convert object to primitive value")},mj=TypeError,wj=hj("toPrimitive"),vj=function(t,e){if(!dj(t)||fj(t))return t;var n,r=pj(t,wj);if(r){if(void 0===e&&(e="default"),n=uj(r,t,e),!dj(n)||fj(n))return n;throw new mj("Can't convert object to primitive value")}return void 0===e&&(e="number"),gj(t,e)},yj=bH,bj=function(t){var e=vj(t,"string");return yj(e)?e:e+""},Bj=$R,_j=uR.document,Cj=Bj(_j)&&Bj(_j.createElement),xj=function(t){return Cj?_j.createElement(t):{}},Ej=xj,Sj=!pR&&!fR(function(){return 7!==Object.defineProperty(Ej("div"),"a",{get:function(){return 7}}).a}),Fj=pR,Lj=vR,Uj=yR,Ij=ER,Qj=zR,kj=bj,Mj=$H,Pj=Sj,Nj=Object.getOwnPropertyDescriptor;dR.f=Fj?Nj:function(t,e){if(t=Qj(t),e=kj(e),Pj)try{return Nj(t,e)}catch(s3){}if(Mj(t,e))return Ij(!Lj(Uj.f,t,e),t[e])};var Oj={},Tj=pR&&fR(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),Dj=$R,Rj=String,Hj=TypeError,jj=function(t){if(Dj(t))return t;throw new Hj(Rj(t)+" is not an object")},Wj=pR,Vj=Sj,Kj=Tj,Gj=jj,zj=bj,qj=TypeError,Xj=Object.defineProperty,Yj=Object.getOwnPropertyDescriptor,$j="enumerable",Jj="configurable",Zj="writable";Oj.f=Wj?Kj?function(t,e,n){if(Gj(t),e=zj(e),Gj(n),"function"==typeof t&&"prototype"===e&&"value"in n&&Zj in n&&!n[Zj]){var r=Yj(t,e);r&&r[Zj]&&(t[e]=n.value,n={configurable:Jj in n?n[Jj]:r[Jj],enumerable:$j in n?n[$j]:r[$j],writable:!1})}return Xj(t,e,n)}:Xj:function(t,e,n){if(Gj(t),e=zj(e),Gj(n),Vj)try{return Xj(t,e,n)}catch(s3){}if("get"in n||"set"in n)throw new qj("Accessors not supported");return"value"in n&&(t[e]=n.value),t};var tW=Oj,eW=ER,nW=pR?function(t,e,n){return tW.f(t,e,eW(1,n))}:function(t,e,n){return t[e]=n,t},rW={exports:{}},iW=pR,AW=$H,sW=Function.prototype,aW=iW&&Object.getOwnPropertyDescriptor,oW=AW(sW,"name"),lW={PROPER:oW&&"something"===function(){}.name,CONFIGURABLE:oW&&(!iW||iW&&aW(sW,"name").configurable)},cW=XR,hW=WH,uW=IR(Function.toString);cW(hW.inspectSource)||(hW.inspectSource=function(t){return uW(t)});var dW,fW,pW,gW=hW.inspectSource,mW=XR,wW=uR.WeakMap,vW=mW(wW)&&/native code/.test(String(wW)),yW=nj,bW=KH("keys"),BW=function(t){return bW[t]||(bW[t]=yW(t))},_W={},CW=vW,xW=uR,EW=$R,SW=nW,FW=$H,LW=WH,UW=BW,IW=_W,QW="Object already initialized",kW=xW.TypeError,MW=xW.WeakMap;if(CW||LW.state){var PW=LW.state||(LW.state=new MW);PW.get=PW.get,PW.has=PW.has,PW.set=PW.set,dW=function(t,e){if(PW.has(t))throw new kW(QW);return e.facade=t,PW.set(t,e),e},fW=function(t){return PW.get(t)||{}},pW=function(t){return PW.has(t)}}else{var NW=UW("state");IW[NW]=!0,dW=function(t,e){if(FW(t,NW))throw new kW(QW);return e.facade=t,SW(t,NW,e),e},fW=function(t){return FW(t,NW)?t[NW]:{}},pW=function(t){return FW(t,NW)}}var OW={set:dW,get:fW,has:pW,enforce:function(t){return pW(t)?fW(t):dW(t,{})},getterFor:function(t){return function(e){var n;if(!EW(e)||(n=fW(e)).type!==t)throw new kW("Incompatible receiver, "+t+" required");return n}}},TW=IR,DW=fR,RW=XR,HW=$H,jW=pR,WW=lW.CONFIGURABLE,VW=gW,KW=OW.enforce,GW=OW.get,zW=String,qW=Object.defineProperty,XW=TW("".slice),YW=TW("".replace),$W=TW([].join),JW=jW&&!DW(function(){return 8!==qW(function(){},"length",{value:8}).length}),ZW=String(String).split("String"),tV=rW.exports=function(t,e,n){"Symbol("===XW(zW(e),0,7)&&(e="["+YW(zW(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!HW(t,"name")||WW&&t.name!==e)&&(jW?qW(t,"name",{value:e,configurable:!0}):t.name=e),JW&&n&&HW(n,"arity")&&t.length!==n.arity&&qW(t,"length",{value:n.arity});try{n&&HW(n,"constructor")&&n.constructor?jW&&qW(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(s3){}var r=KW(t);return HW(r,"source")||(r.source=$W(ZW,"string"==typeof e?e:"")),t};Function.prototype.toString=tV(function(){return RW(this)&&GW(this).source||VW(this)},"toString");var eV,nV=rW.exports,rV=XR,iV=Oj,AV=nV,sV=TH,aV=function(t,e,n,r){r||(r={});var i=r.enumerable,A=void 0!==r.name?r.name:e;if(rV(n)&&AV(n,A,r),r.global)i?t[e]=n:sV(e,n);else{try{r.unsafe?t[e]&&(i=!0):delete t[e]}catch(s3){}i?t[e]=n:iV.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},oV={},lV=Math.ceil,cV=Math.floor,hV=Math.trunc||function(t){var e=+t;return(e>0?cV:lV)(e)},uV=function(t){var e=+t;return e!=e||0===e?0:hV(e)},dV=uV,fV=Math.max,pV=Math.min,gV=uV,mV=Math.min,wV=function(t){var e=gV(t);return e>0?mV(e,9007199254740991):0},vV=wV,yV=function(t){return vV(t.length)},bV=zR,BV=function(t,e){var n=dV(t);return n<0?fV(n+e,0):pV(n,e)},_V=yV,CV={indexOf:(eV=!1,function(t,e,n){var r=bV(t),i=_V(r);if(0===i)return!eV&&-1;var A,s=BV(n,i);if(eV&&e!=e){for(;i>s;)if((A=r[s++])!=A)return!0}else for(;i>s;s++)if((eV||s in r)&&r[s]===e)return eV||s||0;return!eV&&-1})},xV=$H,EV=zR,SV=CV.indexOf,FV=_W,LV=IR([].push),UV=function(t,e){var n,r=EV(t),i=0,A=[];for(n in r)!xV(FV,n)&&xV(r,n)&&LV(A,n);for(;e.length>i;)xV(r,n=e[i++])&&(~SV(A,n)||LV(A,n));return A},IV=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],QV=UV,kV=IV.concat("length","prototype");oV.f=Object.getOwnPropertyNames||function(t){return QV(t,kV)};var MV={};MV.f=Object.getOwnPropertySymbols;var PV=tH,NV=oV,OV=MV,TV=jj,DV=IR([].concat),RV=PV("Reflect","ownKeys")||function(t){var e=NV.f(TV(t)),n=OV.f;return n?DV(e,n(t)):e},HV=$H,jV=RV,WV=dR,VV=Oj,KV=fR,GV=XR,zV=/#|\.prototype\./,qV=function(t,e){var n=YV[XV(t)];return n===JV||n!==$V&&(GV(e)?KV(e):!!e)},XV=qV.normalize=function(t){return String(t).replace(zV,".").toLowerCase()},YV=qV.data={},$V=qV.NATIVE="N",JV=qV.POLYFILL="P",ZV=qV,tK=uR,eK=dR.f,nK=nW,rK=aV,iK=TH,AK=function(t,e,n){for(var r=jV(e),i=VV.f,A=WV.f,s=0;s<r.length;s++){var a=r[s];HV(t,a)||n&&HV(n,a)||i(t,a,A(e,a))}},sK=ZV,aK=function(t,e){var n,r,i,A,s,a=t.target,o=t.global,l=t.stat;if(n=o?tK:l?tK[a]||iK(a,{}):tK[a]&&tK[a].prototype)for(r in e){if(A=e[r],i=t.dontCallGetSet?(s=eK(n,r))&&s.value:n[r],!sK(o?r:a+(l?".":"#")+r,t.forced)&&void 0!==i){if(typeof A==typeof i)continue;AK(A,i)}(t.sham||i&&i.sham)&&nK(A,"sham",!0),rK(n,r,A,t)}},oK=uR,lK=iH,cK=PR,hK=function(t){return lK.slice(0,t.length)===t},uK=hK("Bun/")?"BUN":hK("Cloudflare-Workers")?"CLOUDFLARE":hK("Deno/")?"DENO":hK("Node.js/")?"NODE":oK.Bun&&"string"==typeof Bun.version?"BUN":oK.Deno&&"object"==typeof Deno.version?"DENO":"process"===cK(oK.process)?"NODE":oK.window&&oK.document?"BROWSER":"REST",dK="NODE"===uK,fK=uR,pK=IR,gK=SH,mK=$R,wK=function(t){return mK(t)||null===t},vK=String,yK=TypeError,bK=function(t,e,n){try{return pK(gK(Object.getOwnPropertyDescriptor(t,e)[n]))}catch(s3){}},BK=$R,_K=VR,CK=function(t){if(wK(t))return t;throw new yK("Can't set "+vK(t)+" as a prototype")},xK=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=bK(Object.prototype,"__proto__","set"))(n,[]),e=n instanceof Array}catch(s3){}return function(n,r){return _K(n),CK(r),BK(n)?(e?t(n,r):n.__proto__=r,n):n}}():void 0),EK=Oj.f,SK=$H,FK=hj("toStringTag"),LK=function(t,e,n){t&&!n&&(t=t.prototype),t&&!SK(t,FK)&&EK(t,FK,{configurable:!0,value:e})},UK=nV,IK=Oj,QK=tH,kK=function(t,e,n){return n.get&&UK(n.get,e,{getter:!0}),n.set&&UK(n.set,e,{setter:!0}),IK.f(t,e,n)},MK=pR,PK=hj("species"),NK=eH,OK=TypeError,TK={};TK[hj("toStringTag")]="z";var DK="[object z]"===String(TK),RK=XR,HK=PR,jK=hj("toStringTag"),WK=Object,VK="Arguments"===HK(function(){return arguments}()),KK=DK?HK: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(s3){}}(e=WK(t),jK))?n:VK?HK(e):"Object"===(r=HK(e))&&RK(e.callee)?"Arguments":r},GK=IR,zK=fR,qK=XR,XK=KK,YK=gW,$K=function(){},JK=tH("Reflect","construct"),ZK=/^\s*(?:class|function)\b/,tG=GK(ZK.exec),eG=!ZK.test($K),nG=function(t){if(!qK(t))return!1;try{return JK($K,[],t),!0}catch(s3){return!1}},rG=function(t){if(!qK(t))return!1;switch(XK(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return eG||!!tG(ZK,YK(t))}catch(s3){return!0}};rG.sham=!0;var iG,AG,sG,aG,oG=!JK||zK(function(){var t;return nG(nG.call)||!nG(Object)||!nG(function(){t=!0})||t})?rG:nG,lG=_H,cG=TypeError,hG=jj,uG=function(t){if(oG(t))return t;throw new cG(lG(t)+" is not a constructor")},dG=HR,fG=hj("species"),pG=function(t,e){var n,r=hG(t).constructor;return void 0===r||dG(n=hG(r)[fG])?e:uG(n)},gG=gR,mG=Function.prototype,wG=mG.apply,vG=mG.call,yG="object"==typeof Reflect&&Reflect.apply||(gG?vG.bind(wG):function(){return vG.apply(wG,arguments)}),bG=PR,BG=IR,_G=function(t){if("Function"===bG(t))return BG(t)},CG=SH,xG=gR,EG=_G(_G.bind),SG=function(t,e){return CG(t),void 0===e?t:xG?EG(t,e):function(){return t.apply(e,arguments)}},FG=tH("document","documentElement"),LG=IR([].slice),UG=TypeError,IG=/(?:ipad|iphone|ipod).*applewebkit/i.test(iH),QG=uR,kG=yG,MG=SG,PG=XR,NG=$H,OG=fR,TG=FG,DG=LG,RG=xj,HG=function(t,e){if(t<e)throw new UG("Not enough arguments");return t},jG=IG,WG=dK,VG=QG.setImmediate,KG=QG.clearImmediate,GG=QG.process,zG=QG.Dispatch,qG=QG.Function,XG=QG.MessageChannel,YG=QG.String,$G=0,JG={},ZG="onreadystatechange";OG(function(){iG=QG.location});var tz=function(t){if(NG(JG,t)){var e=JG[t];delete JG[t],e()}},ez=function(t){return function(){tz(t)}},nz=function(t){tz(t.data)},rz=function(t){QG.postMessage(YG(t),iG.protocol+"//"+iG.host)};VG&&KG||(VG=function(t){HG(arguments.length,1);var e=PG(t)?t:qG(t),n=DG(arguments,1);return JG[++$G]=function(){kG(e,void 0,n)},AG($G),$G},KG=function(t){delete JG[t]},WG?AG=function(t){GG.nextTick(ez(t))}:zG&&zG.now?AG=function(t){zG.now(ez(t))}:XG&&!jG?(aG=(sG=new XG).port2,sG.port1.onmessage=nz,AG=MG(aG.postMessage,aG)):QG.addEventListener&&PG(QG.postMessage)&&!QG.importScripts&&iG&&"file:"!==iG.protocol&&!OG(rz)?(AG=rz,QG.addEventListener("message",nz,!1)):AG=ZG in RG("script")?function(t){TG.appendChild(RG("script"))[ZG]=function(){TG.removeChild(this),tz(t)}}:function(t){setTimeout(ez(t),0)});var iz={set:VG},Az=uR,sz=pR,az=Object.getOwnPropertyDescriptor,oz=function(){this.head=null,this.tail=null};oz.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 lz,cz,hz,uz,dz,fz=oz,pz=/ipad|iphone|ipod/i.test(iH)&&"undefined"!=typeof Pebble,gz=/web0s(?!.*chrome)/i.test(iH),mz=uR,wz=function(t){if(!sz)return Az[t];var e=az(Az,t);return e&&e.value},vz=SG,yz=iz.set,bz=fz,Bz=IG,_z=pz,Cz=gz,xz=dK,Ez=mz.MutationObserver||mz.WebKitMutationObserver,Sz=mz.document,Fz=mz.process,Lz=mz.Promise,Uz=wz("queueMicrotask");if(!Uz){var Iz=new bz,Qz=function(){var t,e;for(xz&&(t=Fz.domain)&&t.exit();e=Iz.get();)try{e()}catch(s3){throw Iz.head&&lz(),s3}t&&t.enter()};Bz||xz||Cz||!Ez||!Sz?!_z&&Lz&&Lz.resolve?((uz=Lz.resolve(void 0)).constructor=Lz,dz=vz(uz.then,uz),lz=function(){dz(Qz)}):xz?lz=function(){Fz.nextTick(Qz)}:(yz=vz(yz,mz),lz=function(){yz(Qz)}):(cz=!0,hz=Sz.createTextNode(""),new Ez(Qz).observe(hz,{characterData:!0}),lz=function(){hz.data=cz=!cz}),Uz=function(t){Iz.head||lz(),Iz.add(t)}}var kz=Uz,Mz=function(t){try{return{error:!1,value:t()}}catch(s3){return{error:!0,value:s3}}},Pz=uR.Promise,Nz=uR,Oz=Pz,Tz=XR,Dz=ZV,Rz=gW,Hz=hj,jz=uK,Wz=hH;Oz&&Oz.prototype;var Vz=Hz("species"),Kz=!1,Gz=Tz(Nz.PromiseRejectionEvent),zz={CONSTRUCTOR:Dz("Promise",function(){var t=Rz(Oz),e=t!==String(Oz);if(!e&&66===Wz)return!0;if(!Wz||Wz<51||!/native code/.test(t)){var n=new Oz(function(t){t(1)}),r=function(t){t(function(){},function(){})};if((n.constructor={})[Vz]=r,!(Kz=n.then(function(){})instanceof r))return!0}return!(e||"BROWSER"!==jz&&"DENO"!==jz||Gz)}),REJECTION_EVENT:Gz,SUBCLASSING:Kz},qz={},Xz=SH,Yz=TypeError,$z=function(t){var e,n;this.promise=new t(function(t,r){if(void 0!==e||void 0!==n)throw new Yz("Bad Promise constructor");e=t,n=r}),this.resolve=Xz(e),this.reject=Xz(n)};qz.f=function(t){return new $z(t)};var Jz,Zz,tq,eq,nq=aK,rq=dK,iq=uR,Aq=fK,sq=vR,aq=aV,oq=xK,lq=LK,cq=function(t){var e=QK(t);MK&&e&&!e[PK]&&kK(e,PK,{configurable:!0,get:function(){return this}})},hq=SH,uq=XR,dq=$R,fq=function(t,e){if(NK(e,t))return t;throw new OK("Incorrect invocation")},pq=pG,gq=iz.set,mq=kz,wq=function(t,e){try{1===arguments.length?console.error(t):console.error(t,e)}catch(s3){}},vq=Mz,yq=fz,bq=OW,Bq=Pz,_q=qz,Cq="Promise",xq=zz.CONSTRUCTOR,Eq=zz.REJECTION_EVENT,Sq=zz.SUBCLASSING,Fq=bq.getterFor(Cq),Lq=bq.set,Uq=Bq&&Bq.prototype,Iq=Bq,Qq=Uq,kq=iq.TypeError,Mq=iq.document,Pq=iq.process,Nq=_q.f,Oq=Nq,Tq=!!(Mq&&Mq.createEvent&&iq.dispatchEvent),Dq="unhandledrejection",Rq=function(t){var e;return!(!dq(t)||!uq(e=t.then))&&e},Hq=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&&Gq(e),e.rejection=1),!0===a?n=A:(c&&c.enter(),n=a(A),c&&(c.exit(),i=!0)),n===t.promise?l(new kq("Promise-chain cycle")):(r=Rq(n))?sq(r,n,o,l):o(n)):l(A)}catch(s3){c&&!i&&c.exit(),l(s3)}},jq=function(t,e){t.notified||(t.notified=!0,mq(function(){for(var n,r=t.reactions;n=r.get();)Hq(n,t);t.notified=!1,e&&!t.rejection&&Vq(t)}))},Wq=function(t,e,n){var r,i;Tq?((r=Mq.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),iq.dispatchEvent(r)):r={promise:e,reason:n},!Eq&&(i=iq["on"+t])?i(r):t===Dq&&wq("Unhandled promise rejection",n)},Vq=function(t){sq(gq,iq,function(){var e,n=t.facade,r=t.value;if(Kq(t)&&(e=vq(function(){rq?Pq.emit("unhandledRejection",r,n):Wq(Dq,n,r)}),t.rejection=rq||Kq(t)?2:1,e.error))throw e.value})},Kq=function(t){return 1!==t.rejection&&!t.parent},Gq=function(t){sq(gq,iq,function(){var e=t.facade;rq?Pq.emit("rejectionHandled",e):Wq("rejectionhandled",e,t.value)})},zq=function(t,e,n){return function(r){t(e,r,n)}},qq=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,jq(t,!0))},Xq=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw new kq("Promise can't be resolved itself");var r=Rq(e);r?mq(function(){var n={done:!1};try{sq(r,e,zq(Xq,n,t),zq(qq,n,t))}catch(s3){qq(n,s3,t)}}):(t.value=e,t.state=1,jq(t,!1))}catch(s3){qq({done:!1},s3,t)}}};if(xq&&(Qq=(Iq=function(t){fq(this,Qq),hq(t),sq(Jz,this);var e=Fq(this);try{t(zq(Xq,e),zq(qq,e))}catch(s3){qq(e,s3)}}).prototype,(Jz=function(t){Lq(this,{type:Cq,done:!1,notified:!1,parent:!1,reactions:new yq,rejection:!1,state:0,value:null})}).prototype=aq(Qq,"then",function(t,e){var n=Fq(this),r=Nq(pq(this,Iq));return n.parent=!0,r.ok=!uq(t)||t,r.fail=uq(e)&&e,r.domain=rq?Pq.domain:void 0,0===n.state?n.reactions.add(r):mq(function(){Hq(r,n)}),r.promise}),Zz=function(){var t=new Jz,e=Fq(t);this.promise=t,this.resolve=zq(Xq,e),this.reject=zq(qq,e)},_q.f=Nq=function(t){return t===Iq||t===tq?new Zz(t):Oq(t)},uq(Bq)&&Uq!==Object.prototype)){eq=Uq.then,Sq||aq(Uq,"then",function(t,e){var n=this;return new Iq(function(t,e){sq(eq,n,t,e)}).then(t,e)},{unsafe:!0});try{delete Uq.constructor}catch(s3){}oq&&oq(Uq,Qq)}nq({global:!0,constructor:!0,wrap:!0,forced:xq},{Promise:Iq}),tq=Aq.Promise,lq(Iq,Cq,!1),cq(Cq);var Yq={},$q=Yq,Jq=hj("iterator"),Zq=Array.prototype,tX=KK,eX=UH,nX=HR,rX=Yq,iX=hj("iterator"),AX=function(t){if(!nX(t))return eX(t,iX)||eX(t,"@@iterator")||rX[tX(t)]},sX=vR,aX=SH,oX=jj,lX=_H,cX=AX,hX=TypeError,uX=vR,dX=jj,fX=UH,pX=SG,gX=vR,mX=jj,wX=_H,vX=function(t){return void 0!==t&&($q.Array===t||Zq[Jq]===t)},yX=yV,bX=eH,BX=function(t,e){var n=arguments.length<2?cX(t):e;if(aX(n))return oX(sX(n,t));throw new hX(lX(t)+" is not iterable")},_X=AX,CX=function(t,e,n){var r,i;dX(t);try{if(!(r=fX(t,"return"))){if("throw"===e)throw n;return n}r=uX(r,t)}catch(s3){i=!0,r=s3}if("throw"===e)throw n;if(i)throw r;return dX(r),n},xX=TypeError,EX=function(t,e){this.stopped=t,this.result=e},SX=EX.prototype,FX=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=pX(e,c),g=function(t){return r&&CX(r,"normal"),new EX(!0,t)},m=function(t){return h?(mX(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=_X(t)))throw new xX(wX(t)+" is not iterable");if(vX(i)){for(A=0,s=yX(t);s>A;A++)if((a=m(t[A]))&&bX(SX,a))return a;return new EX(!1)}r=BX(t,i)}for(o=u?t.next:r.next;!(l=gX(o,r)).done;){try{a=m(l.value)}catch(s3){CX(r,"throw",s3)}if("object"==typeof a&&a&&bX(SX,a))return a}return new EX(!1)},LX=hj("iterator"),UX=!1;try{var IX=0,QX={next:function(){return{done:!!IX++}},return:function(){UX=!0}};QX[LX]=function(){return this},Array.from(QX,function(){throw 2})}catch(s3){}var kX=Pz,MX=zz.CONSTRUCTOR||!function(t,e){try{if(!e&&!UX)return!1}catch(s3){return!1}var n=!1;try{var r={};r[LX]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(s3){}return n}(function(t){kX.all(t).then(void 0,function(){})}),PX=vR,NX=SH,OX=qz,TX=Mz,DX=FX;aK({target:"Promise",stat:!0,forced:MX},{all:function(t){var e=this,n=OX.f(e),r=n.resolve,i=n.reject,A=TX(function(){var n=NX(e.resolve),A=[],s=0,a=1;DX(t,function(t){var o=s++,l=!1;a++,PX(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 RX=aK,HX=zz.CONSTRUCTOR,jX=Pz,WX=tH,VX=XR,KX=aV,GX=jX&&jX.prototype;if(RX({target:"Promise",proto:!0,forced:HX,real:!0},{catch:function(t){return this.then(void 0,t)}}),VX(jX)){var zX=WX("Promise").prototype.catch;GX.catch!==zX&&KX(GX,"catch",zX,{unsafe:!0})}var qX=vR,XX=SH,YX=qz,$X=Mz,JX=FX;aK({target:"Promise",stat:!0,forced:MX},{race:function(t){var e=this,n=YX.f(e),r=n.reject,i=$X(function(){var i=XX(e.resolve);JX(t,function(t){qX(i,e,t).then(n.resolve,r)})});return i.error&&r(i.value),n.promise}});var ZX=qz;aK({target:"Promise",stat:!0,forced:zz.CONSTRUCTOR},{reject:function(t){var e=ZX.f(this);return(0,e.reject)(t),e.promise}});var tY=jj,eY=$R,nY=qz,rY=aK,iY=zz.CONSTRUCTOR,AY=function(t,e){if(tY(t),eY(e)&&e.constructor===t)return e;var n=nY.f(t);return(0,n.resolve)(e),n.promise};function sY(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 aY(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var A=t.apply(e,n);function s(t){sY(A,r,i,s,a,"next",t)}function a(t){sY(A,r,i,s,a,"throw",t)}s(void 0)})}}tH("Promise"),rY({target:"Promise",stat:!0,forced:iY},{resolve:function(t){return AY(this,t)}});var oY=KK,lY=String,cY=function(t){if("Symbol"===oY(t))throw new TypeError("Cannot convert a Symbol value to a string");return lY(t)},hY=jj,uY=function(){var t=hY(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},dY=fR,fY=uR.RegExp,pY=dY(function(){var t=fY("a","y");return t.lastIndex=2,null!==t.exec("abcd")});pY||dY(function(){return!fY("a","y").sticky});var gY=pY||dY(function(){var t=fY("^r","gy");return t.lastIndex=2,null!==t.exec("str")}),mY={BROKEN_CARET:gY,UNSUPPORTED_Y:pY},wY={},vY=UV,yY=IV,bY=Object.keys||function(t){return vY(t,yY)},BY=pR,_Y=Tj,CY=Oj,xY=jj,EY=zR,SY=bY;wY.f=BY&&!_Y?Object.defineProperties:function(t,e){xY(t);for(var n,r=EY(e),i=SY(e),A=i.length,s=0;A>s;)CY.f(t,n=i[s++],r[n]);return t};var FY,LY=jj,UY=wY,IY=IV,QY=_W,kY=FG,MY=xj,PY="prototype",NY="script",OY=BW("IE_PROTO"),TY=function(){},DY=function(t){return"<"+NY+">"+t+"</"+NY+">"},RY=function(t){t.write(DY("")),t.close();var e=t.parentWindow.Object;return t=null,e},HY=function(){try{FY=new ActiveXObject("htmlfile")}catch(s3){}var t,e,n;HY="undefined"!=typeof document?document.domain&&FY?RY(FY):(e=MY("iframe"),n="java"+NY+":",e.style.display="none",kY.appendChild(e),e.src=String(n),(t=e.contentWindow.document).open(),t.write(DY("document.F=Object")),t.close(),t.F):RY(FY);for(var r=IY.length;r--;)delete HY[PY][IY[r]];return HY()};QY[OY]=!0;var jY,WY,VY=Object.create||function(t,e){var n;return null!==t?(TY[PY]=LY(t),n=new TY,TY[PY]=null,n[OY]=t):n=HY(),void 0===e?n:UY.f(n,e)},KY=fR,GY=uR.RegExp,zY=KY(function(){var t=GY(".","s");return!(t.dotAll&&t.test("\n")&&"s"===t.flags)}),qY=fR,XY=uR.RegExp,YY=qY(function(){var t=XY("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")}),$Y=vR,JY=IR,ZY=cY,t$=uY,e$=mY,n$=VY,r$=OW.get,i$=zY,A$=YY,s$=KH("native-string-replace",String.prototype.replace),a$=RegExp.prototype.exec,o$=a$,l$=JY("".charAt),c$=JY("".indexOf),h$=JY("".replace),u$=JY("".slice),d$=(WY=/b*/g,$Y(a$,jY=/a/,"a"),$Y(a$,WY,"a"),0!==jY.lastIndex||0!==WY.lastIndex),f$=e$.BROKEN_CARET,p$=void 0!==/()??/.exec("")[1];(d$||p$||f$||i$||A$)&&(o$=function(t){var e,n,r,i,A,s,a,o=this,l=r$(o),c=ZY(t),h=l.raw;if(h)return h.lastIndex=o.lastIndex,e=$Y(o$,h,c),o.lastIndex=h.lastIndex,e;var u=l.groups,d=f$&&o.sticky,f=$Y(t$,o),p=o.source,g=0,m=c;if(d&&(f=h$(f,"y",""),-1===c$(f,"g")&&(f+="g"),m=u$(c,o.lastIndex),o.lastIndex>0&&(!o.multiline||o.multiline&&"\n"!==l$(c,o.lastIndex-1))&&(p="(?: "+p+")",m=" "+m,g++),n=new RegExp("^(?:"+p+")",f)),p$&&(n=new RegExp("^"+p+"$(?!\\s)",f)),d$&&(r=o.lastIndex),i=$Y(a$,d?n:o,m),d?i?(i.input=u$(i.input,g),i[0]=u$(i[0],g),i.index=o.lastIndex,o.lastIndex+=i[0].length):o.lastIndex=0:d$&&i&&(o.lastIndex=o.global?i.index+i[0].length:r),p$&&i&&i.length>1&&$Y(s$,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=n$(null),A=0;A<u.length;A++)s[(a=u[A])[0]]=i[a[1]];return i});var g$=o$;aK({target:"RegExp",proto:!0,forced:/./.exec!==g$},{exec:g$});var m$,w$=vR,v$=aV,y$=g$,b$=fR,B$=hj,_$=nW,C$=B$("species"),x$=RegExp.prototype,E$=function(t,e,n,r){var i=B$(t),A=!b$(function(){var e={};return e[i]=function(){return 7},7!==""[t](e)}),s=A&&!b$(function(){var e=!1,n=/a/;return"split"===t&&((n={}).constructor={},n.constructor[C$]=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===y$||s===x$.exec?A&&!i?{done:!0,value:w$(a,e,n,r)}:{done:!0,value:w$(t,n,e,r)}:{done:!1}});v$(String.prototype,t,o[0]),v$(x$,i,o[1])}r&&_$(x$[i],"sham",!0)},S$=IR,F$=uV,L$=cY,U$=VR,I$=S$("".charAt),Q$=S$("".charCodeAt),k$=S$("".slice),M$={charAt:(m$=!0,function(t,e){var n,r,i=L$(U$(t)),A=F$(e),s=i.length;return A<0||A>=s?m$?"":void 0:(n=Q$(i,A))<55296||n>56319||A+1===s||(r=Q$(i,A+1))<56320||r>57343?m$?I$(i,A):n:m$?k$(i,A,A+2):r-56320+(n-55296<<10)+65536})}.charAt,P$=function(t,e,n){return e+(n?M$(t,e).length:1)},N$=fR,O$=uR.RegExp,T$=!N$(function(){var t=!0;try{O$(".","d")}catch(s3){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(O$.prototype,"flags").get.call(e)!==r||n!==r}),D$=vR,R$=$H,H$=eH,j$={correct:T$},W$=uY,V$=RegExp.prototype,K$=j$.correct?function(t){return t.flags}:function(t){return j$.correct||!H$(V$,t)||R$(t,"flags")?t.flags:D$(W$,t)},G$=vR,z$=jj,q$=XR,X$=PR,Y$=g$,$$=TypeError,J$=function(t,e){var n=t.exec;if(q$(n)){var r=G$(n,t,e);return null!==r&&z$(r),r}if("RegExp"===X$(t))return G$(Y$,t,e);throw new $$("RegExp#exec called on incompatible receiver")},Z$=vR,tJ=E$,eJ=jj,nJ=$R,rJ=wV,iJ=cY,AJ=VR,sJ=UH,aJ=P$,oJ=K$,lJ=J$,cJ=IR("".indexOf);tJ("match",function(t,e,n){return[function(e){var n=AJ(this),r=nJ(e)?sJ(e,t):void 0;return r?Z$(r,e,n):new RegExp(e)[t](iJ(n))},function(t){var r=eJ(this),i=iJ(t),A=n(e,r,i);if(A.done)return A.value;var s=iJ(oJ(r));if(-1===cJ(s,"g"))return lJ(r,i);var a=-1!==cJ(s,"u");r.lastIndex=0;for(var o,l=[],c=0;null!==(o=lJ(r,i));){var h=iJ(o[0]);l[c]=h,""===h&&(r.lastIndex=aJ(i,rJ(r.lastIndex),a)),c++}return 0===c?null:l}]});var hJ=IR,uJ=qH,dJ=Math.floor,fJ=hJ("".charAt),pJ=hJ("".replace),gJ=hJ("".slice),mJ=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,wJ=/\$([$&'`]|\d{1,2})/g,vJ=yG,yJ=vR,bJ=IR,BJ=E$,_J=fR,CJ=jj,xJ=XR,EJ=$R,SJ=uV,FJ=wV,LJ=cY,UJ=VR,IJ=P$,QJ=UH,kJ=function(t,e,n,r,i,A){var s=n+t.length,a=r.length,o=wJ;return void 0!==i&&(i=uJ(i),o=mJ),pJ(A,o,function(A,o){var l;switch(fJ(o,0)){case"$":return"$";case"&":return t;case"`":return gJ(e,0,n);case"'":return gJ(e,s);case"<":l=i[gJ(o,1,-1)];break;default:var c=+o;if(0===c)return A;if(c>a){var h=dJ(c/10);return 0===h?A:h<=a?void 0===r[h-1]?fJ(o,1):r[h-1]+fJ(o,1):A}l=r[c-1]}return void 0===l?"":l})},MJ=K$,PJ=J$,NJ=hj("replace"),OJ=Math.max,TJ=Math.min,DJ=bJ([].concat),RJ=bJ([].push),HJ=bJ("".indexOf),jJ=bJ("".slice),WJ=function(t){return void 0===t?t:String(t)},VJ="$0"==="a".replace(/./,"$0"),KJ=!!/./[NJ]&&""===/./[NJ]("a","$0"),GJ=!_J(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")});BJ("replace",function(t,e,n){var r=KJ?"$":"$0";return[function(t,n){var r=UJ(this),i=EJ(t)?QJ(t,NJ):void 0;return i?yJ(i,t,r,n):yJ(e,LJ(r),t,n)},function(t,i){var A=CJ(this),s=LJ(t);if("string"==typeof i&&-1===HJ(i,r)&&-1===HJ(i,"$<")){var a=n(e,A,s,i);if(a.done)return a.value}var o=xJ(i);o||(i=LJ(i));var l,c=LJ(MJ(A)),h=-1!==HJ(c,"g");h&&(l=-1!==HJ(c,"u"),A.lastIndex=0);for(var u,d=[];null!==(u=PJ(A,s))&&(RJ(d,u),h);){""===LJ(u[0])&&(A.lastIndex=IJ(s,FJ(A.lastIndex),l))}for(var f="",p=0,g=0;g<d.length;g++){for(var m,w=LJ((u=d[g])[0]),v=OJ(TJ(SJ(u.index),s.length),0),y=[],b=1;b<u.length;b++)RJ(y,WJ(u[b]));var B=u.groups;if(o){var _=DJ([w],y,v,s);void 0!==B&&RJ(_,B),m=LJ(vJ(i,void 0,_))}else m=kJ(w,s,v,y,B,i);v>=p&&(f+=jJ(s,p,v)+m,p=v+w.length)}return f+jJ(s,p)}]},!GJ||!VJ||KJ);var zJ,qJ=$R,XJ=PR,YJ=hj("match"),$J=function(t){var e;return qJ(t)&&(void 0!==(e=t[YJ])?!!e:"RegExp"===XJ(t))},JJ=TypeError,ZJ=function(t){if($J(t))throw new JJ("The method doesn't accept regular expressions");return t},tZ=hj("match"),eZ=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[tZ]=!1,"/./"[t](e)}catch(r){}}return!1},nZ=aK,rZ=_G,iZ=dR.f,AZ=wV,sZ=cY,aZ=ZJ,oZ=VR,lZ=eZ,cZ=rZ("".slice),hZ=Math.min,uZ=lZ("startsWith");nZ({target:"String",proto:!0,forced:!!(uZ||(zJ=iZ(String.prototype,"startsWith"),!zJ||zJ.writable))&&!uZ},{startsWith:function(t){var e=sZ(oZ(this));aZ(t);var n=AZ(hZ(arguments.length>1?arguments[1]:void 0,e.length)),r=sZ(t);return cZ(e,n,n+r.length)===r}});var dZ=hj,fZ=VY,pZ=Oj.f,gZ=dZ("unscopables"),mZ=Array.prototype;void 0===mZ[gZ]&&pZ(mZ,gZ,{configurable:!0,value:fZ(null)});var wZ,vZ,yZ,bZ=!fR(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),BZ=$H,_Z=XR,CZ=qH,xZ=bZ,EZ=BW("IE_PROTO"),SZ=Object,FZ=SZ.prototype,LZ=xZ?SZ.getPrototypeOf:function(t){var e=CZ(t);if(BZ(e,EZ))return e[EZ];var n=e.constructor;return _Z(n)&&e instanceof n?n.prototype:e instanceof SZ?FZ:null},UZ=fR,IZ=XR,QZ=$R,kZ=LZ,MZ=aV,PZ=hj("iterator"),NZ=!1;[].keys&&("next"in(yZ=[].keys())?(vZ=kZ(kZ(yZ)))!==Object.prototype&&(wZ=vZ):NZ=!0),(!QZ(wZ)||UZ(function(){var t={};return wZ[PZ].call(t)!==t}))&&(wZ={}),IZ(wZ[PZ])||MZ(wZ,PZ,function(){return this});var OZ={IteratorPrototype:wZ,BUGGY_SAFARI_ITERATORS:NZ},TZ=OZ.IteratorPrototype,DZ=VY,RZ=ER,HZ=LK,jZ=Yq,WZ=function(){return this},VZ=aK,KZ=vR,GZ=XR,zZ=function(t,e,n,r){var i=e+" Iterator";return t.prototype=DZ(TZ,{next:RZ(+!r,n)}),HZ(t,i,!1),jZ[i]=WZ,t},qZ=LZ,XZ=xK,YZ=LK,$Z=nW,JZ=aV,ZZ=Yq,t0=lW.PROPER,e0=lW.CONFIGURABLE,n0=OZ.IteratorPrototype,r0=OZ.BUGGY_SAFARI_ITERATORS,i0=hj("iterator"),A0="keys",s0="values",a0="entries",o0=function(){return this},l0=zR,c0=function(t){mZ[gZ][t]=!0},h0=Yq,u0=OW,d0=Oj.f,f0=function(t,e,n,r,i,A,s){zZ(n,e,r);var a,o,l,c=function(t){if(t===i&&p)return p;if(!r0&&t&&t in d)return d[t];switch(t){case A0:case s0:case a0:return function(){return new n(this,t)}}return function(){return new n(this)}},h=e+" Iterator",u=!1,d=t.prototype,f=d[i0]||d["@@iterator"]||i&&d[i],p=!r0&&f||c(i),g="Array"===e&&d.entries||f;if(g&&(a=qZ(g.call(new t)))!==Object.prototype&&a.next&&(qZ(a)!==n0&&(XZ?XZ(a,n0):GZ(a[i0])||JZ(a,i0,o0)),YZ(a,h,!0)),t0&&i===s0&&f&&f.name!==s0&&(e0?$Z(d,"name",s0):(u=!0,p=function(){return KZ(f,this)})),i)if(o={values:c(s0),keys:A?p:c(A0),entries:c(a0)},s)for(l in o)(r0||u||!(l in d))&&JZ(d,l,o[l]);else VZ({target:e,proto:!0,forced:r0||u},o);return d[i0]!==p&&JZ(d,i0,p,{name:i}),ZZ[e]=p,o},p0=function(t,e){return{value:t,done:e}},g0=pR,m0="Array Iterator",w0=u0.set,v0=u0.getterFor(m0),y0=f0(Array,"Array",function(t,e){w0(this,{type:m0,target:l0(t),index:0,kind:e})},function(){var t=v0(this),e=t.target,n=t.index++;if(!e||n>=e.length)return t.target=null,p0(void 0,!0);switch(t.kind){case"keys":return p0(n,!1);case"values":return p0(e[n],!1)}return p0([n,e[n]],!1)},"values"),b0=h0.Arguments=h0.Array;if(c0("keys"),c0("values"),c0("entries"),g0&&"values"!==b0.name)try{d0(b0,"name",{value:"values"})}catch(s3){}var B0=xj("span").classList,_0=B0&&B0.constructor&&B0.constructor.prototype,C0=_0===Object.prototype?void 0:_0,x0=uR,E0={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},S0=C0,F0=y0,L0=nW,U0=LK,I0=hj("iterator"),Q0=F0.values,k0=function(t,e){if(t){if(t[I0]!==Q0)try{L0(t,I0,Q0)}catch(s3){t[I0]=Q0}if(U0(t,e,!0),E0[e])for(var n in F0)if(t[n]!==F0[n])try{L0(t,n,F0[n])}catch(s3){t[n]=F0[n]}}};for(var M0 in E0)k0(x0[M0]&&x0[M0].prototype,M0);function P0(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 N0(t,e,n){return(e=P0(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}k0(S0,"DOMTokenList");var O0,T0=SH,D0=qH,R0=RR,H0=yV,j0=TypeError,W0="Reduce of empty array with no initial value",V0={left:(O0=!1,function(t,e,n,r){var i=D0(t),A=R0(i),s=H0(i);if(T0(e),0===s&&n<2)throw new j0(W0);var a=O0?s-1:0,o=O0?-1:1;if(n<2)for(;;){if(a in A){r=A[a],a+=o;break}if(a+=o,O0?a<0:s<=a)throw new j0(W0)}for(;O0?a>=0:s>a;a+=o)a in A&&(r=e(r,A[a],a,i));return r})},K0=fR,G0=function(t,e){var n=[][t];return!!n&&K0(function(){n.call(null,e||function(){return 1},1)})},z0=V0.left;aK({target:"Array",proto:!0,forced:!dK&&hH>79&&hH<83||!G0("reduce")},{reduce:function(t){var e=arguments.length;return z0(this,t,e,e>1?arguments[1]:void 0)}});var q0=aK,X0=_G,Y0=dR.f,$0=wV,J0=cY,Z0=ZJ,t1=VR,e1=eZ,n1=X0("".slice),r1=Math.min,i1=e1("endsWith"),A1=!i1&&!!function(){var t=Y0(String.prototype,"endsWith");return t&&!t.writable}();q0({target:"String",proto:!0,forced:!A1&&!i1},{endsWith:function(t){var e=J0(t1(this));Z0(t);var n=arguments.length>1?arguments[1]:void 0,r=e.length,i=void 0===n?r:r1($0(n),r),A=J0(t);return n1(e,i-A.length,i)===A}});var s1=vR,a1=IR,o1=E$,l1=jj,c1=$R,h1=VR,u1=pG,d1=P$,f1=wV,p1=cY,g1=UH,m1=J$,w1=fR,v1=mY.UNSUPPORTED_Y,y1=Math.min,b1=a1([].push),B1=a1("".slice),_1=!w1(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]}),C1="c"==="abbc".split(/(b)*/)[1]||4!=="test".split(/(?:)/,-1).length||2!=="ab".split(/(?:ab)*/).length||4!==".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length;o1("split",function(t,e,n){var r="0".split(void 0,0).length?function(t,n){return void 0===t&&0===n?[]:s1(e,this,t,n)}:e;return[function(e,n){var i=h1(this),A=c1(e)?g1(e,t):void 0;return A?s1(A,e,i,n):s1(r,p1(i),e,n)},function(t,i){var A=l1(this),s=p1(t);if(!C1){var a=n(r,A,s,i,r!==e);if(a.done)return a.value}var o=u1(A,RegExp),l=A.unicode,c=(A.ignoreCase?"i":"")+(A.multiline?"m":"")+(A.unicode?"u":"")+(v1?"g":"y"),h=new o(v1?"^(?:"+A.source+")":A,c),u=void 0===i?4294967295:i>>>0;if(0===u)return[];if(0===s.length)return null===m1(h,s)?[s]:[];for(var d=0,f=0,p=[];f<s.length;){h.lastIndex=v1?0:f;var g,m=m1(h,v1?B1(s,f):s);if(null===m||(g=y1(f1(h.lastIndex+(v1?f:0)),s.length))===d)f=d1(s,f,l);else{if(b1(p,B1(s,d,f)),p.length===u)return p;for(var w=1;w<=m.length-1;w++)if(b1(p,m[w]),p.length===u)return p;f=d=g}}return b1(p,B1(s,d)),p}]},C1||!_1,v1);var x1={exports:{}},E1={exports:{}};(function(){var t,e,n,r,i,A;"undefined"!=typeof performance&&null!==performance&&performance.now?E1.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(E1.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?(E1.exports=function(){return Date.now()-n},n=Date.now()):(E1.exports=function(){return(new Date).getTime()-n},n=(new Date).getTime())}).call(Jc);for(var S1=E1.exports,F1="undefined"==typeof window?Jc:window,L1=["moz","webkit"],U1="AnimationFrame",I1=F1["request"+U1],Q1=F1["cancel"+U1]||F1["cancelRequest"+U1],k1=0;!I1&&k1<L1.length;k1++)I1=F1[L1[k1]+"Request"+U1],Q1=F1[L1[k1]+"Cancel"+U1]||F1[L1[k1]+"CancelRequest"+U1];if(!I1||!Q1){var M1=0,P1=0,N1=[],O1=1e3/60;I1=function(t){if(0===N1.length){var e=S1(),n=Math.max(0,O1-(e-M1));M1=n+e,setTimeout(function(){var t=N1.slice(0);N1.length=0;for(var e=0;e<t.length;e++)if(!t[e].cancelled)try{t[e].callback(M1)}catch(hw){setTimeout(function(){throw hw},0)}},Math.round(n))}return N1.push({handle:++P1,callback:t,cancelled:!1}),P1},Q1=function(t){for(var e=0;e<N1.length;e++)N1[e].handle===t&&(N1[e].cancelled=!0)}}x1.exports=function(t){return I1.call(F1,t)},x1.exports.cancel=function(){Q1.apply(F1,arguments)},x1.exports.polyfill=function(t){t||(t=F1),t.requestAnimationFrame=I1,t.cancelAnimationFrame=Q1};const T1=Zc(x1.exports);var D1,R1="\t\n\v\f\r \u2028\u2029\ufeff",H1=VR,j1=cY,W1=R1,V1=IR("".replace),K1=RegExp("^["+W1+"]+"),G1=RegExp("(^|[^"+W1+"])["+W1+"]+$"),z1={trim:(D1=3,function(t){var e=j1(H1(t));return 1&D1&&(e=V1(e,K1,"")),2&D1&&(e=V1(e,G1,"$1")),e})},q1=lW.PROPER,X1=fR,Y1=R1,$1=z1.trim;aK({target:"String",proto:!0,forced:function(t){return X1(function(){return!!Y1[t]()||"
"!=="
"[t]()||q1&&Y1[t].name!==t})}("trim")},{trim:function(){return $1(this)}});var J1=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 Z1=Zc(J1);var t2=aK,e2=CV.indexOf,n2=G0,r2=_G([].indexOf),i2=!!r2&&1/r2([1],1,-0)<0;t2({target:"Array",proto:!0,forced:i2||!n2("indexOf")},{indexOf:function(t){var e=arguments.length>1?arguments[1]:void 0;return i2?r2(this,t,e)||0:e2(this,t,e)}});var A2=aK,s2=ZJ,a2=VR,o2=cY,l2=eZ,c2=IR("".indexOf);A2({target:"String",proto:!0,forced:!l2("includes")},{includes:function(t){return!!~c2(o2(a2(this)),o2(s2(t)),arguments.length>1?arguments[1]:void 0)}});var h2=PR,u2=aK,d2=Array.isArray||function(t){return"Array"===h2(t)},f2=IR([].reverse),p2=[1,2];u2({target:"Array",proto:!0,forced:String(p2)===String(p2.reverse())},{reverse:function(){return d2(this)&&(this.length=this.length),f2(this)}});
|
|
343
343
|
/*! *****************************************************************************
|