asma-doc-viewer 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/asmaDocViewer.es.js
CHANGED
|
@@ -151,7 +151,7 @@ var r=Object.defineProperty,e=(e,a,t)=>(((e,a,t)=>{a in e?r(e,a,{enumerable:!0,c
|
|
|
151
151
|
width: 100%;
|
|
152
152
|
height: 100%;
|
|
153
153
|
border: 0;
|
|
154
|
-
`;var Vs={d:(r,e)=>{for(var a in e)Vs.o(e,a)&&!Vs.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:e[a]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e)},Ns=globalThis.pdfjsLib={};Vs.d(Ns,{AbortException:()=>zf,AnnotationEditorLayer:()=>s_,AnnotationEditorParamsType:()=>$s,AnnotationEditorType:()=>qs,AnnotationEditorUIManager:()=>$d,AnnotationLayer:()=>Hk,AnnotationMode:()=>zs,CMapCompressionType:()=>Sf,ColorPicker:()=>Qy,DOMSVGFactory:()=>ou,DrawLayer:()=>k_,FeatureTest:()=>rl,GlobalWorkerOptions:()=>lg,ImageKind:()=>of,InvalidPDFException:()=>Hf,MissingPDFException:()=>Qf,OPS:()=>xf,Outliner:()=>ty,PDFDataRangeTransport:()=>hv,PDFDateString:()=>mu,PDFWorker:()=>xv,PasswordResponses:()=>Mf,PermissionFlag:()=>Ks,PixelsPerInch:()=>Il,RenderingCancelledException:()=>fu,TextLayer:()=>rv,UnexpectedResponseException:()=>Uf,Util:()=>nl,VerbosityLevel:()=>Ff,XfaLayer:()=>im,build:()=>rm,createValidAbsoluteUrl:()=>Pf,fetchData:()=>iu,getDocument:()=>fv,getFilenameFromUrl:()=>cu,getPdfFilenameFromUrl:()=>du,getXfaPageViewport:()=>ku,isDataScheme:()=>lu,isPdfFile:()=>uu,noContextMenu:()=>gu,normalizeUnicode:()=>fl,renderTextLayer:()=>ev,setLayerDimensions:()=>Cu,shadow:()=>jf,updateTextLayer:()=>av,version:()=>Kv});const Ds=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Ts=[1,0,0,1,0,0],Ps=[.001,0,0,.001,0,0],js=1.35,Ls=1,Os=2,Ys=4,Hs=16,Qs=32,Us=64,Js=256,zs={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},qs={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},$s={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},Ks={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},rf=0,ef=1,af=2,tf=3,Af=3,nf=4,of={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},sf=1,ff=2,lf=3,uf=4,cf=5,df=6,hf=7,bf=8,gf=9,pf=10,vf=11,mf=12,kf=13,wf=14,yf=15,Ef=16,Cf=17,Bf=20,_f=1,Zf=2,Wf=3,If=4,Rf=5,Ff={ERRORS:0,WARNINGS:1,INFOS:5},Sf={NONE:0,BINARY:1},xf={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},Mf={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Gf=Ff.WARNINGS;function Xf(){return Gf}function Vf(r){Gf>=Ff.INFOS&&console.log(`Info: ${r}`)}function Nf(r){Gf>=Ff.WARNINGS&&console.log(`Warning: ${r}`)}function Df(r){throw new Error(r)}function Tf(r,e){r||Df(e)}function Pf(r,e=null,a=null){if(!r)return null;try{if(a&&"string"==typeof r){if(a.addDefaultProtocol&&r.startsWith("www.")){const e=r.match(/\./g);(null==e?void 0:e.length)>=2&&(r=`http://${r}`)}if(a.tryConvertEncoding)try{r=function(r){return decodeURIComponent(escape(r))}(r)}catch{}}const t=e?new URL(r,e):new URL(r);if(function(r){switch(null==r?void 0:r.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(t))return t}catch{}return null}function jf(r,e,a,t=!1){return Object.defineProperty(r,e,{value:a,enumerable:!t,configurable:!0,writable:!1}),a}const Lf=function(){function r(e,a){this.constructor===r&&Df("Cannot initialize BaseException."),this.message=e,this.name=a}return r.prototype=new Error,r.constructor=r,r}();class Of extends Lf{constructor(r,e){super(r,"PasswordException"),this.code=e}}class Yf extends Lf{constructor(r,e){super(r,"UnknownErrorException"),this.details=e}}class Hf extends Lf{constructor(r){super(r,"InvalidPDFException")}}class Qf extends Lf{constructor(r){super(r,"MissingPDFException")}}class Uf extends Lf{constructor(r,e){super(r,"UnexpectedResponseException"),this.status=e}}class Jf extends Lf{constructor(r){super(r,"FormatError")}}class zf extends Lf{constructor(r){super(r,"AbortException")}}function qf(r){("object"!=typeof r||void 0===(null==r?void 0:r.length))&&Df("Invalid argument for bytesToString");const e=r.length,a=8192;if(e<a)return String.fromCharCode.apply(null,r);const t=[];for(let i=0;i<e;i+=a){const A=Math.min(i+a,e),n=r.subarray(i,A);t.push(String.fromCharCode.apply(null,n))}return t.join("")}function $f(r){"string"!=typeof r&&Df("Invalid argument for stringToBytes");const e=r.length,a=new Uint8Array(e);for(let t=0;t<e;++t)a[t]=255&r.charCodeAt(t);return a}function Kf(r){const e=Object.create(null);for(const[a,t]of r)e[a]=t;return e}class rl{static get isLittleEndian(){return jf(this,"isLittleEndian",function(){const r=new Uint8Array(4);return r[0]=1,1===new Uint32Array(r.buffer,0,1)[0]}())}static get isEvalSupported(){return jf(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return jf(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&"string"==typeof(null==navigator?void 0:navigator.platform)?jf(this,"platform",{isMac:navigator.platform.includes("Mac")}):jf(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){var r,e;return jf(this,"isCSSRoundSupported",null==(e=null==(r=globalThis.CSS)?void 0:r.supports)?void 0:e.call(r,"width: round(1.5px, 1px)"))}}const el=Array.from(Array(256).keys(),(r=>r.toString(16).padStart(2,"0")));var al,tl,il,Al;class nl{static makeHexColor(r,e,a){return`#${el[r]}${el[e]}${el[a]}`}static scaleMinMax(r,e){let a;r[0]?(r[0]<0&&(a=e[0],e[0]=e[2],e[2]=a),e[0]*=r[0],e[2]*=r[0],r[3]<0&&(a=e[1],e[1]=e[3],e[3]=a),e[1]*=r[3],e[3]*=r[3]):(a=e[0],e[0]=e[1],e[1]=a,a=e[2],e[2]=e[3],e[3]=a,r[1]<0&&(a=e[1],e[1]=e[3],e[3]=a),e[1]*=r[1],e[3]*=r[1],r[2]<0&&(a=e[0],e[0]=e[2],e[2]=a),e[0]*=r[2],e[2]*=r[2]),e[0]+=r[4],e[1]+=r[5],e[2]+=r[4],e[3]+=r[5]}static transform(r,e){return[r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],r[0]*e[4]+r[2]*e[5]+r[4],r[1]*e[4]+r[3]*e[5]+r[5]]}static applyTransform(r,e){return[r[0]*e[0]+r[1]*e[2]+e[4],r[0]*e[1]+r[1]*e[3]+e[5]]}static applyInverseTransform(r,e){const a=e[0]*e[3]-e[1]*e[2];return[(r[0]*e[3]-r[1]*e[2]+e[2]*e[5]-e[4]*e[3])/a,(-r[0]*e[1]+r[1]*e[0]+e[4]*e[1]-e[5]*e[0])/a]}static getAxialAlignedBoundingBox(r,e){const a=this.applyTransform(r,e),t=this.applyTransform(r.slice(2,4),e),i=this.applyTransform([r[0],r[3]],e),A=this.applyTransform([r[2],r[1]],e);return[Math.min(a[0],t[0],i[0],A[0]),Math.min(a[1],t[1],i[1],A[1]),Math.max(a[0],t[0],i[0],A[0]),Math.max(a[1],t[1],i[1],A[1])]}static inverseTransform(r){const e=r[0]*r[3]-r[1]*r[2];return[r[3]/e,-r[1]/e,-r[2]/e,r[0]/e,(r[2]*r[5]-r[4]*r[3])/e,(r[4]*r[1]-r[5]*r[0])/e]}static singularValueDecompose2dScale(r){const e=[r[0],r[2],r[1],r[3]],a=r[0]*e[0]+r[1]*e[2],t=r[0]*e[1]+r[1]*e[3],i=r[2]*e[0]+r[3]*e[2],A=r[2]*e[1]+r[3]*e[3],n=(a+A)/2,o=Math.sqrt((a+A)**2-4*(a*A-i*t))/2,s=n+o||1,f=n-o||1;return[Math.sqrt(s),Math.sqrt(f)]}static normalizeRect(r){const e=r.slice(0);return r[0]>r[2]&&(e[0]=r[2],e[2]=r[0]),r[1]>r[3]&&(e[1]=r[3],e[3]=r[1]),e}static intersect(r,e){const a=Math.max(Math.min(r[0],r[2]),Math.min(e[0],e[2])),t=Math.min(Math.max(r[0],r[2]),Math.max(e[0],e[2]));if(a>t)return null;const i=Math.max(Math.min(r[1],r[3]),Math.min(e[1],e[3])),A=Math.min(Math.max(r[1],r[3]),Math.max(e[1],e[3]));return i>A?null:[a,i,t,A]}static bezierBoundingBox(r,e,a,t,i,A,n,s,f){return f?(f[0]=Math.min(f[0],r,n),f[1]=Math.min(f[1],e,s),f[2]=Math.max(f[2],r,n),f[3]=Math.max(f[3],e,s)):f=[Math.min(r,n),Math.min(e,s),Math.max(r,n),Math.max(e,s)],o(this,il,Al).call(this,r,a,i,n,e,t,A,s,3*(3*(a-i)-r+n),6*(r-2*a+i),3*(a-r),f),o(this,il,Al).call(this,r,a,i,n,e,t,A,s,3*(3*(t-A)-e+s),6*(e-2*t+A),3*(t-e),f),f}}al=new WeakSet,tl=function(r,e,a,t,i,A,n,o,s,f){if(s<=0||s>=1)return;const l=1-s,u=s*s,c=u*s,d=l*(l*(l*r+3*s*e)+3*u*a)+c*t,h=l*(l*(l*i+3*s*A)+3*u*n)+c*o;f[0]=Math.min(f[0],d),f[1]=Math.min(f[1],h),f[2]=Math.max(f[2],d),f[3]=Math.max(f[3],h)},il=new WeakSet,Al=function(r,e,a,t,i,A,n,s,f,l,u,c){if(Math.abs(f)<1e-12)return void(Math.abs(l)>=1e-12&&o(this,al,tl).call(this,r,e,a,t,i,A,n,s,-u/l,c));const d=l**2-4*u*f;if(d<0)return;const h=Math.sqrt(d),b=2*f;o(this,al,tl).call(this,r,e,a,t,i,A,n,s,(-l+h)/b,c),o(this,al,tl).call(this,r,e,a,t,i,A,n,s,(-l-h)/b,c)},i(nl,al),i(nl,il);let ol=null,sl=null;function fl(r){return ol||(ol=/([\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,sl=new Map([["ſt","ſt"]])),r.replaceAll(ol,((r,e,a)=>e?e.normalize("NFKC"):sl.get(a)))}const ll="pdfjs_internal_id_",ul=0,cl=1,dl=2,hl=3,bl=4,gl=5,pl=6,vl=7,ml=8;class kl{constructor(){this.constructor===kl&&Df("Cannot initialize BaseFilterFactory.")}addFilter(r){return"none"}addHCMFilter(r,e){return"none"}addAlphaFilter(r){return"none"}addLuminosityFilter(r){return"none"}addHighlightHCMFilter(r,e,a,t,i){return"none"}destroy(r=!1){}}var wl;const yl=class{constructor({enableHWA:r=!1}={}){i(this,wl,!1),this.constructor===yl&&Df("Cannot initialize BaseCanvasFactory."),A(this,wl,r)}create(r,e){if(r<=0||e<=0)throw new Error("Invalid canvas size");const a=this._createCanvas(r,e);return{canvas:a,context:a.getContext("2d",{willReadFrequently:!t(this,wl)})}}reset(r,e,a){if(!r.canvas)throw new Error("Canvas is not specified");if(e<=0||a<=0)throw new Error("Invalid canvas size");r.canvas.width=e,r.canvas.height=a}destroy(r){if(!r.canvas)throw new Error("Canvas is not specified");r.canvas.width=0,r.canvas.height=0,r.canvas=null,r.context=null}_createCanvas(r,e){Df("Abstract method `_createCanvas` called.")}};let El=yl;wl=new WeakMap;class Cl{constructor({baseUrl:r=null,isCompressed:e=!0}){this.constructor===Cl&&Df("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=r,this.isCompressed=e}async fetch({name:r}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!r)throw new Error("CMap name must be specified.");const e=this.baseUrl+r+(this.isCompressed?".bcmap":""),a=this.isCompressed?Sf.BINARY:Sf.NONE;return this._fetchData(e,a).catch((r=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}_fetchData(r,e){Df("Abstract method `_fetchData` called.")}}class Bl{constructor({baseUrl:r=null}){this.constructor===Bl&&Df("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=r}async fetch({filename:r}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!r)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${r}`;return this._fetchData(e).catch((r=>{throw new Error(`Unable to load font data at: ${e}`)}))}_fetchData(r){Df("Abstract method `_fetchData` called.")}}class _l{constructor(){this.constructor===_l&&Df("Cannot initialize BaseSVGFactory.")}create(r,e,a=!1){if(r<=0||e<=0)throw new Error("Invalid SVG dimensions");const t=this._createSVG("svg:svg");return t.setAttribute("version","1.1"),a||(t.setAttribute("width",`${r}px`),t.setAttribute("height",`${e}px`)),t.setAttribute("preserveAspectRatio","none"),t.setAttribute("viewBox",`0 0 ${r} ${e}`),t}createElement(r){if("string"!=typeof r)throw new Error("Invalid SVG element type");return this._createSVG(r)}_createSVG(r){Df("Abstract method `_createSVG` called.")}}const Zl="http://www.w3.org/2000/svg",Wl=class{};let Il=Wl;var Rl,Fl,Sl,xl,Ml,Gl,Xl,Vl,Nl,Dl,Tl,Pl,jl,Ll,Ol,Yl,Hl,Ql,Ul,Jl,zl,ql,$l,Kl,ru,eu,au,tu;e(Il,"CSS",96),e(Il,"PDF",72),e(Il,"PDF_TO_CSS_UNITS",Wl.CSS/Wl.PDF);Rl=new WeakMap,Fl=new WeakMap,Sl=new WeakMap,xl=new WeakMap,Ml=new WeakMap,Gl=new WeakMap,Xl=new WeakSet,Vl=function(){return t(this,Rl)||A(this,Rl,new Map)},Nl=new WeakSet,Dl=function(){return t(this,Ml)||A(this,Ml,new Map)},Tl=new WeakSet,Pl=function(){if(!t(this,Fl)){const r=t(this,xl).createElement("div"),{style:e}=r;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const a=t(this,xl).createElementNS(Zl,"svg");a.setAttribute("width",0),a.setAttribute("height",0),A(this,Fl,t(this,xl).createElementNS(Zl,"defs")),r.append(a),a.append(t(this,Fl)),t(this,xl).body.append(r)}return t(this,Fl)},jl=new WeakSet,Ll=function(r){if(1===r.length){const e=r[0],a=new Array(256);for(let r=0;r<256;r++)a[r]=e[r]/255;const t=a.join(",");return[t,t,t]}const[e,a,t]=r,i=new Array(256),A=new Array(256),n=new Array(256);for(let r=0;r<256;r++)i[r]=e[r]/255,A[r]=a[r]/255,n[r]=t[r]/255;return[i.join(","),A.join(","),n.join(",")]},Ol=new WeakSet,Yl=function(r){const e=t(this,xl).createElementNS(Zl,"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"),r.append(e)},Hl=new WeakSet,Ql=function(r){const e=t(this,xl).createElementNS(Zl,"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"),r.append(e)},Ul=new WeakSet,Jl=function(r){const e=t(this,xl).createElementNS(Zl,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",r),t(this,Tl,Pl).append(e),e},zl=new WeakSet,ql=function(r,e,a){const i=t(this,xl).createElementNS(Zl,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",a),r.append(i)},$l=new WeakSet,Kl=function(r,e,a,i){const A=t(this,xl).createElementNS(Zl,"feComponentTransfer");i.append(A),o(this,zl,ql).call(this,A,"feFuncR",r),o(this,zl,ql).call(this,A,"feFuncG",e),o(this,zl,ql).call(this,A,"feFuncB",a)},ru=new WeakSet,eu=function(r,e){const a=t(this,xl).createElementNS(Zl,"feComponentTransfer");e.append(a),o(this,zl,ql).call(this,a,"feFuncA",r)},au=new WeakSet,tu=function(r){return t(this,Tl,Pl).style.color=r,wu(getComputedStyle(t(this,Tl,Pl)).getPropertyValue("color"))};async function iu(r,e="text"){if(bu(r,document.baseURI)){const a=await fetch(r);if(!a.ok)throw new Error(a.statusText);switch(e){case"arraybuffer":return a.arrayBuffer();case"blob":return a.blob();case"json":return a.json()}return a.text()}return new Promise(((a,t)=>{const i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(200===i.status||0===i.status){switch(e){case"arraybuffer":case"blob":case"json":return void a(i.response)}return void a(i.responseText)}t(new Error(i.statusText))}},i.send(null)}))}class Au extends Cl{_fetchData(r,e){return iu(r,this.isCompressed?"arraybuffer":"text").then((r=>({cMapData:r instanceof ArrayBuffer?new Uint8Array(r):$f(r),compressionType:e})))}}class nu extends Bl{_fetchData(r){return iu(r,"arraybuffer").then((r=>new Uint8Array(r)))}}class ou extends _l{_createSVG(r){return document.createElementNS(Zl,r)}}class su{constructor({viewBox:r,scale:e,rotation:a,offsetX:t=0,offsetY:i=0,dontFlip:A=!1}){this.viewBox=r,this.scale=e,this.rotation=a,this.offsetX=t,this.offsetY=i;const n=(r[2]+r[0])/2,o=(r[3]+r[1])/2;let s,f,l,u,c,d,h,b;switch((a%=360)<0&&(a+=360),a){case 180:s=-1,f=0,l=0,u=1;break;case 90:s=0,f=1,l=1,u=0;break;case 270:s=0,f=-1,l=-1,u=0;break;case 0:s=1,f=0,l=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}A&&(l=-l,u=-u),0===s?(c=Math.abs(o-r[1])*e+t,d=Math.abs(n-r[0])*e+i,h=(r[3]-r[1])*e,b=(r[2]-r[0])*e):(c=Math.abs(n-r[0])*e+t,d=Math.abs(o-r[1])*e+i,h=(r[2]-r[0])*e,b=(r[3]-r[1])*e),this.transform=[s*e,f*e,l*e,u*e,c-s*e*n-l*e*o,d-f*e*n-u*e*o],this.width=h,this.height=b}get rawDims(){const{viewBox:r}=this;return jf(this,"rawDims",{pageWidth:r[2]-r[0],pageHeight:r[3]-r[1],pageX:r[0],pageY:r[1]})}clone({scale:r=this.scale,rotation:e=this.rotation,offsetX:a=this.offsetX,offsetY:t=this.offsetY,dontFlip:i=!1}={}){return new su({viewBox:this.viewBox.slice(),scale:r,rotation:e,offsetX:a,offsetY:t,dontFlip:i})}convertToViewportPoint(r,e){return nl.applyTransform([r,e],this.transform)}convertToViewportRectangle(r){const e=nl.applyTransform([r[0],r[1]],this.transform),a=nl.applyTransform([r[2],r[3]],this.transform);return[e[0],e[1],a[0],a[1]]}convertToPdfPoint(r,e){return nl.applyInverseTransform([r,e],this.transform)}}class fu extends Lf{constructor(r,e=0){super(r,"RenderingCancelledException"),this.extraDelay=e}}function lu(r){const e=r.length;let a=0;for(;a<e&&""===r[a].trim();)a++;return"data:"===r.substring(a,a+5).toLowerCase()}function uu(r){return"string"==typeof r&&/\.pdf$/i.test(r)}function cu(r){return[r]=r.split(/[#?]/,1),r.substring(r.lastIndexOf("/")+1)}function du(r,e="document.pdf"){if("string"!=typeof r)return e;if(lu(r))return Nf('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const a=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,t=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(r);let i=a.exec(t[1])||a.exec(t[2])||a.exec(t[3]);if(i&&(i=i[0],i.includes("%")))try{i=a.exec(decodeURIComponent(i))[0]}catch{}return i||e}class hu{constructor(){e(this,"started",Object.create(null)),e(this,"times",[])}time(r){r in this.started&&Nf(`Timer is already running for ${r}`),this.started[r]=Date.now()}timeEnd(r){r in this.started||Nf(`Timer has not been started for ${r}`),this.times.push({name:r,start:this.started[r],end:Date.now()}),delete this.started[r]}toString(){const r=[];let e=0;for(const{name:r}of this.times)e=Math.max(r.length,e);for(const{name:a,start:t,end:i}of this.times)r.push(`${a.padEnd(e)} ${i-t}ms\n`);return r.join("")}}function bu(r,e){try{const{protocol:a}=e?new URL(r,e):new URL(r);return"http:"===a||"https:"===a}catch{return!1}}function gu(r){r.preventDefault()}function pu(r){console.log("Deprecated API usage: "+r)}let vu;class mu{static toDateObject(r){if(!r||"string"!=typeof r)return null;vu||(vu=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=vu.exec(r);if(!e)return null;const a=parseInt(e[1],10);let t=parseInt(e[2],10);t=t>=1&&t<=12?t-1:0;let i=parseInt(e[3],10);i=i>=1&&i<=31?i:1;let A=parseInt(e[4],10);A=A>=0&&A<=23?A:0;let n=parseInt(e[5],10);n=n>=0&&n<=59?n:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const s=e[7]||"Z";let f=parseInt(e[8],10);f=f>=0&&f<=23?f:0;let l=parseInt(e[9],10)||0;return l=l>=0&&l<=59?l:0,"-"===s?(A+=f,n+=l):"+"===s&&(A-=f,n-=l),new Date(Date.UTC(a,t,i,A,n,o))}}function ku(r,{scale:e=1,rotation:a=0}){const{width:t,height:i}=r.attributes.style,A=[0,0,parseInt(t),parseInt(i)];return new su({viewBox:A,scale:e,rotation:a})}function wu(r){if(r.startsWith("#")){const e=parseInt(r.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return r.startsWith("rgb(")?r.slice(4,-1).split(",").map((r=>parseInt(r))):r.startsWith("rgba(")?r.slice(5,-1).split(",").map((r=>parseInt(r))).slice(0,3):(Nf(`Not a valid color format: "${r}"`),[0,0,0])}function yu(r){const{a:e,b:a,c:t,d:i,e:A,f:n}=r.getTransform();return[e,a,t,i,A,n]}function Eu(r){const{a:e,b:a,c:t,d:i,e:A,f:n}=r.getTransform().invertSelf();return[e,a,t,i,A,n]}function Cu(r,e,a=!1,t=!0){if(e instanceof su){const{pageWidth:t,pageHeight:i}=e.rawDims,{style:A}=r,n=rl.isCSSRoundSupported,o=`var(--scale-factor) * ${t}px`,s=`var(--scale-factor) * ${i}px`,f=n?`round(${o}, 1px)`:`calc(${o})`,l=n?`round(${s}, 1px)`:`calc(${s})`;a&&e.rotation%180!=0?(A.width=l,A.height=f):(A.width=f,A.height=l)}t&&r.setAttribute("data-main-rotation",e.rotation)}var Bu,_u,Zu,Wu,Iu,Ru,Fu,Su,xu,Mu,Gu,Xu,Vu,Nu,Du,Tu;const Pu=class{constructor(r){i(this,Fu),i(this,xu),i(this,Gu),i(this,Vu),i(this,Du),i(this,Bu,null),i(this,_u,null),i(this,Zu,void 0),i(this,Wu,null),A(this,Zu,r)}render(){const r=A(this,Bu,document.createElement("div"));r.className="editToolbar",r.setAttribute("role","toolbar");const e=t(this,Zu)._uiManager._signal;r.addEventListener("contextmenu",gu,{signal:e}),r.addEventListener("pointerdown",o(Pu,Iu,Ru),{signal:e});const a=A(this,Wu,document.createElement("div"));a.className="buttons",r.append(a);const i=t(this,Zu).toolbarPosition;if(i){const{style:e}=r,a="ltr"===t(this,Zu)._uiManager.direction?1-i[0]:i[0];e.insetInlineEnd=100*a+"%",e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return o(this,Vu,Nu).call(this),r}hide(){var r;t(this,Bu).classList.add("hidden"),null==(r=t(this,_u))||r.hideDropdown()}show(){t(this,Bu).classList.remove("hidden")}addAltTextButton(r){o(this,Gu,Xu).call(this,r),t(this,Wu).prepend(r,t(this,Du,Tu))}addColorPicker(r){A(this,_u,r);const e=r.renderButton();o(this,Gu,Xu).call(this,e),t(this,Wu).prepend(e,t(this,Du,Tu))}remove(){var r;t(this,Bu).remove(),null==(r=t(this,_u))||r.destroy(),A(this,_u,null)}};let ju=Pu;var Lu,Ou,Yu,Hu,Qu,Uu,Ju,zu,qu,$u,Ku,rc,ec,ac,tc;Bu=new WeakMap,_u=new WeakMap,Zu=new WeakMap,Wu=new WeakMap,Iu=new WeakSet,Ru=function(r){r.stopPropagation()},Fu=new WeakSet,Su=function(r){t(this,Zu)._focusEventsAllowed=!1,r.preventDefault(),r.stopPropagation()},xu=new WeakSet,Mu=function(r){t(this,Zu)._focusEventsAllowed=!0,r.preventDefault(),r.stopPropagation()},Gu=new WeakSet,Xu=function(r){const e=t(this,Zu)._uiManager._signal;r.addEventListener("focusin",o(this,Fu,Su).bind(this),{capture:!0,signal:e}),r.addEventListener("focusout",o(this,xu,Mu).bind(this),{capture:!0,signal:e}),r.addEventListener("contextmenu",gu,{signal:e})},Vu=new WeakSet,Nu=function(){const r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",`pdfjs-editor-remove-${t(this,Zu).editorType}-button`),o(this,Gu,Xu).call(this,r),r.addEventListener("click",(r=>{t(this,Zu)._uiManager.delete()}),{signal:t(this,Zu)._uiManager._signal}),t(this,Wu).append(r)},Du=new WeakSet,Tu=function(){const r=document.createElement("div");return r.className="divider",r},i(ju,Iu);class ic{constructor(r){i(this,Hu),i(this,Uu),i(this,zu),i(this,Lu,null),i(this,Ou,null),i(this,Yu,void 0),A(this,Yu,r)}show(r,e,a){const[i,n]=o(this,Uu,Ju).call(this,e,a),{style:s}=t(this,Ou)||A(this,Ou,o(this,Hu,Qu).call(this));r.append(t(this,Ou)),s.insetInlineEnd=100*i+"%",s.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){t(this,Ou).remove()}}function Ac(r,e,a){for(const t of a)e.addEventListener(t,r[t].bind(r))}Lu=new WeakMap,Ou=new WeakMap,Yu=new WeakMap,Hu=new WeakSet,Qu=function(){const r=A(this,Ou,document.createElement("div"));r.className="editToolbar",r.setAttribute("role","toolbar"),r.addEventListener("contextmenu",gu,{signal:t(this,Yu)._signal});const e=A(this,Lu,document.createElement("div"));return e.className="buttons",r.append(e),o(this,zu,qu).call(this),r},Uu=new WeakSet,Ju=function(r,e){let a=0,t=0;for(const i of r){const r=i.y+i.height;if(r<a)continue;const A=i.x+(e?i.width:0);r>a?(t=A,a=r):e?A>t&&(t=A):A<t&&(t=A)}return[e?1-t:t,a]},zu=new WeakSet,qu=function(){const r=document.createElement("button");r.className="highlightButton",r.tabIndex=0,r.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");r.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const a=t(this,Yu)._signal;r.addEventListener("contextmenu",gu,{signal:a}),r.addEventListener("click",(()=>{t(this,Yu).highlightSelection("floating_button")}),{signal:a}),t(this,Lu).append(r)};class nc{constructor(){i(this,$u,0)}get id(){return"pdfjs_internal_editor_"+n(this,$u)._++}}$u=new WeakMap;const oc=class{constructor(){i(this,ac),i(this,Ku,function(){if(typeof crypto<"u"&&"function"==typeof(null==crypto?void 0:crypto.randomUUID))return crypto.randomUUID();const r=new Uint8Array(32);if(typeof crypto<"u"&&"function"==typeof(null==crypto?void 0:crypto.getRandomValues))crypto.getRandomValues(r);else for(let e=0;e<32;e++)r[e]=Math.floor(255*Math.random());return qf(r)}()),i(this,rc,0),i(this,ec,null)}static get _isSVGFittingCanvas(){const r=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 jf(this,"_isSVGFittingCanvas",e.decode().then((()=>(r.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(r.getImageData(0,0,1,1).data.buffer)[0]))))}async getFromFile(r){const{lastModified:e,name:a,size:t,type:i}=r;return o(this,ac,tc).call(this,`${e}_${a}_${t}_${i}`,r)}async getFromUrl(r){return o(this,ac,tc).call(this,r,r)}async getFromId(r){t(this,ec)||A(this,ec,new Map);const e=t(this,ec).get(r);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(r){const e=t(this,ec).get(r);return null!=e&&e.isSvg?e.svgUrl:null}deleteId(r){t(this,ec)||A(this,ec,new Map);const e=t(this,ec).get(r);e&&(e.refCounter-=1,0===e.refCounter&&(e.bitmap=null))}isValidId(r){return r.startsWith(`image_${t(this,Ku)}_`)}};let sc=oc;var fc,lc,uc,cc,dc,hc;Ku=new WeakMap,rc=new WeakMap,ec=new WeakMap,ac=new WeakSet,tc=async function(r,e){t(this,ec)||A(this,ec,new Map);let a=t(this,ec).get(r);if(null===a)return null;if(null!=a&&a.bitmap)return a.refCounter+=1,a;try{let r;if(a||(a={bitmap:null,id:`image_${t(this,Ku)}_${n(this,rc)._++}`,refCounter:0,isSvg:!1}),"string"==typeof e?(a.url=e,r=await iu(e,"blob")):r=a.file=e,"image/svg+xml"===r.type){const e=oc._isSVGFittingCanvas,t=new FileReader,i=new Image,A=new Promise(((r,A)=>{i.onload=()=>{a.bitmap=i,a.isSvg=!0,r()},t.onload=async()=>{const r=a.svgUrl=t.result;i.src=await e?`${r}#svgView(preserveAspectRatio(none))`:r},i.onerror=t.onerror=A}));t.readAsDataURL(r),await A}else a.bitmap=await createImageBitmap(r);a.refCounter=1}catch(r){console.error(r),a=null}return t(this,ec).set(r,a),a&&t(this,ec).set(a.id,a),a};class bc{constructor(r=128){i(this,fc,[]),i(this,lc,!1),i(this,uc,void 0),i(this,cc,-1),A(this,uc,r)}add({cmd:r,undo:e,post:a,mustExec:i,type:n=NaN,overwriteIfSameType:o=!1,keepUndo:s=!1}){if(i&&r(),t(this,lc))return;const f={cmd:r,undo:e,post:a,type:n};if(-1===t(this,cc))return t(this,fc).length>0&&(t(this,fc).length=0),A(this,cc,0),void t(this,fc).push(f);if(o&&t(this,fc)[t(this,cc)].type===n)return s&&(f.undo=t(this,fc)[t(this,cc)].undo),void(t(this,fc)[t(this,cc)]=f);const l=t(this,cc)+1;l===t(this,uc)?t(this,fc).splice(0,1):(A(this,cc,l),l<t(this,fc).length&&t(this,fc).splice(l)),t(this,fc).push(f)}undo(){if(-1===t(this,cc))return;A(this,lc,!0);const{undo:r,post:e}=t(this,fc)[t(this,cc)];r(),null==e||e(),A(this,lc,!1),A(this,cc,t(this,cc)-1)}redo(){if(t(this,cc)<t(this,fc).length-1){A(this,cc,t(this,cc)+1),A(this,lc,!0);const{cmd:r,post:e}=t(this,fc)[t(this,cc)];r(),null==e||e(),A(this,lc,!1)}}hasSomethingToUndo(){return-1!==t(this,cc)}hasSomethingToRedo(){return t(this,cc)<t(this,fc).length-1}destroy(){A(this,fc,null)}}fc=new WeakMap,lc=new WeakMap,uc=new WeakMap,cc=new WeakMap;class gc{constructor(r){i(this,dc),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=rl.platform;for(const[a,t,i={}]of r)for(const r of a){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:t,options:i}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:t,options:i}),this.allKeys.add(r.split("+").at(-1)))}}exec(r,e){if(!this.allKeys.has(e.key))return;const a=this.callbacks.get(o(this,dc,hc).call(this,e));if(!a)return;const{callback:t,options:{bubbles:i=!1,args:A=[],checker:n=null}}=a;n&&!n(r,e)||(t.bind(r,...A,e)(),i||(e.stopPropagation(),e.preventDefault()))}}dc=new WeakSet,hc=function(r){r.altKey&&this.buffer.push("alt"),r.ctrlKey&&this.buffer.push("ctrl"),r.metaKey&&this.buffer.push("meta"),r.shiftKey&&this.buffer.push("shift"),this.buffer.push(r.key);const e=this.buffer.join("+");return this.buffer.length=0,e};const pc=class{get _colors(){const r=new Map([["CanvasText",null],["Canvas",null]]);return function(r){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const a of r.keys()){e.style.color=a;const t=window.getComputedStyle(e).color;r.set(a,wu(t))}e.remove()}(r),jf(this,"_colors",r)}convert(r){const e=wu(r);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[r,a]of this._colors)if(a.every(((r,a)=>r===e[a])))return pc._colorsMapping.get(r);return e}getHexCode(r){const e=this._colors.get(r);return e?nl.makeHexColor(...e):r}};let vc=pc;var mc,kc,wc,yc,Ec,Cc,Bc,_c,Zc,Wc,Ic,Rc,Fc,Sc,xc,Mc,Gc,Xc,Vc,Nc,Dc,Tc,Pc,jc,Lc,Oc,Yc,Hc,Qc,Uc,Jc,zc,qc,$c,Kc,rd,ed,ad,td,id,Ad,nd,od,sd,fd,ld,ud,cd,dd,hd,bd,gd,pd,vd,md,kd,wd,yd,Ed,Cd,Bd,_d,Zd,Wd,Id,Rd,Fd,Sd,xd,Md,Gd,Xd,Vd,Nd,Dd,Td,Pd,jd,Ld,Od,Yd,Hd,Qd,Ud,Jd,zd;e(vc,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));const qd=class{constructor(r,e,a,n,s,f,l,u,c){i(this,ud),i(this,dd),i(this,bd),i(this,pd),i(this,md),i(this,wd),i(this,Ed),i(this,Bd),i(this,Zd),i(this,Id),i(this,Fd),i(this,xd),i(this,Gd),i(this,Vd),i(this,Dd),i(this,Pd),i(this,Ld),i(this,Yd),i(this,Qd),i(this,Jd),i(this,mc,new AbortController),i(this,kc,null),i(this,wc,new Map),i(this,yc,new Map),i(this,Ec,null),i(this,Cc,null),i(this,Bc,null),i(this,_c,new bc),i(this,Zc,0),i(this,Wc,new Set),i(this,Ic,null),i(this,Rc,null),i(this,Fc,new Set),i(this,Sc,!1),i(this,xc,null),i(this,Mc,null),i(this,Gc,null),i(this,Xc,!1),i(this,Vc,null),i(this,Nc,new nc),i(this,Dc,!1),i(this,Tc,!1),i(this,Pc,null),i(this,jc,null),i(this,Lc,null),i(this,Oc,qs.NONE),i(this,Yc,new Set),i(this,Hc,null),i(this,Qc,null),i(this,Uc,null),i(this,Jc,this.blur.bind(this)),i(this,zc,this.focus.bind(this)),i(this,qc,this.copy.bind(this)),i(this,$c,this.cut.bind(this)),i(this,Kc,this.paste.bind(this)),i(this,rd,this.keydown.bind(this)),i(this,ed,this.keyup.bind(this)),i(this,ad,this.onEditingAction.bind(this)),i(this,td,this.onPageChanging.bind(this)),i(this,id,this.onScaleChanging.bind(this)),i(this,Ad,this.onRotationChanging.bind(this)),i(this,nd,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),i(this,od,[0,0]),i(this,sd,null),i(this,fd,null),i(this,ld,null),this._signal=t(this,mc).signal,A(this,fd,r),A(this,ld,e),A(this,Ec,a),this._eventBus=n,this._eventBus._on("editingaction",t(this,ad)),this._eventBus._on("pagechanging",t(this,td)),this._eventBus._on("scalechanging",t(this,id)),this._eventBus._on("rotationchanging",t(this,Ad)),o(this,md,kd).call(this),o(this,xd,Md).call(this),o(this,Bd,_d).call(this),A(this,Cc,s.annotationStorage),A(this,xc,s.filterFactory),A(this,Qc,f),A(this,Gc,l||null),A(this,Sc,u),A(this,Lc,c||null),this.viewParameters={realScale:Il.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const r=qd.prototype,e=r=>t(r,fd).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&r.hasSomethingToControl(),a=(r,{target:e})=>{if(e instanceof HTMLInputElement){const{type:r}=e;return"text"!==r&&"number"!==r}return!0},i=this.TRANSLATE_SMALL,A=this.TRANSLATE_BIG;return jf(this,"_keyboardManager",new gc([[["ctrl+a","mac+meta+a"],r.selectAll,{checker:a}],[["ctrl+z","mac+meta+z"],r.undo,{checker:a}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],r.redo,{checker:a}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],r.delete,{checker:a}],[["Enter","mac+Enter"],r.addNewEditorFromKeyboard,{checker:(r,{target:e})=>!(e instanceof HTMLButtonElement)&&t(r,fd).contains(e)&&!r.isEnterHandled}],[[" ","mac+ "],r.addNewEditorFromKeyboard,{checker:(r,{target:e})=>!(e instanceof HTMLButtonElement)&&t(r,fd).contains(document.activeElement)}],[["Escape","mac+Escape"],r.unselectAll],[["ArrowLeft","mac+ArrowLeft"],r.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r.translateSelectedEditors,{args:[-A,0],checker:e}],[["ArrowRight","mac+ArrowRight"],r.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r.translateSelectedEditors,{args:[A,0],checker:e}],[["ArrowUp","mac+ArrowUp"],r.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r.translateSelectedEditors,{args:[0,-A],checker:e}],[["ArrowDown","mac+ArrowDown"],r.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r.translateSelectedEditors,{args:[0,A],checker:e}]]))}destroy(){var r,e,a;null==(r=t(this,mc))||r.abort(),A(this,mc,null),this._signal=null,this._eventBus._off("editingaction",t(this,ad)),this._eventBus._off("pagechanging",t(this,td)),this._eventBus._off("scalechanging",t(this,id)),this._eventBus._off("rotationchanging",t(this,Ad));for(const r of t(this,yc).values())r.destroy();t(this,yc).clear(),t(this,wc).clear(),t(this,Fc).clear(),A(this,kc,null),t(this,Yc).clear(),t(this,_c).destroy(),null==(e=t(this,Ec))||e.destroy(),null==(a=t(this,Vc))||a.hide(),A(this,Vc,null),t(this,Mc)&&(clearTimeout(t(this,Mc)),A(this,Mc,null)),t(this,sd)&&(clearTimeout(t(this,sd)),A(this,sd,null))}async mlGuess(r){var e;return(null==(e=t(this,Lc))?void 0:e.guess(r))||null}get hasMLManager(){return!!t(this,Lc)}get hcmFilter(){return jf(this,"hcmFilter",t(this,Qc)?t(this,xc).addHCMFilter(t(this,Qc).foreground,t(this,Qc).background):"none")}get direction(){return jf(this,"direction",getComputedStyle(t(this,fd)).direction)}get highlightColors(){return jf(this,"highlightColors",t(this,Gc)?new Map(t(this,Gc).split(",").map((r=>r.split("=").map((r=>r.trim()))))):null)}get highlightColorNames(){return jf(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(r=>r.reverse()))):null)}setMainHighlightColorPicker(r){A(this,jc,r)}editAltText(r){var e;null==(e=t(this,Ec))||e.editAltText(this,r)}onPageChanging({pageNumber:r}){A(this,Zc,r-1)}focusMainContainer(){t(this,fd).focus()}findParent(r,e){for(const a of t(this,yc).values()){const{x:t,y:i,width:A,height:n}=a.div.getBoundingClientRect();if(r>=t&&r<=t+A&&e>=i&&e<=i+n)return a}return null}disableUserSelect(r=!1){t(this,ld).classList.toggle("noUserSelect",r)}addShouldRescale(r){t(this,Fc).add(r)}removeShouldRescale(r){t(this,Fc).delete(r)}onScaleChanging({scale:r}){this.commitOrRemove(),this.viewParameters.realScale=r*Il.PDF_TO_CSS_UNITS;for(const r of t(this,Fc))r.onScaleChanging()}onRotationChanging({pagesRotation:r}){this.commitOrRemove(),this.viewParameters.rotation=r}highlightSelection(r=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:a,anchorOffset:i,focusNode:A,focusOffset:n}=e,s=e.toString(),f=o(this,ud,cd).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(f);if(l){e.empty(),t(this,Oc)===qs.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:qs.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const e of t(this,yc).values())if(e.hasTextLayer(f)){e.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:r,boxes:l,anchorNode:a,anchorOffset:i,focusNode:A,focusOffset:n,text:s});break}}}addToAnnotationStorage(r){!r.isEmpty()&&t(this,Cc)&&!t(this,Cc).has(r.id)&&t(this,Cc).setValue(r.id,r)}blur(){if(this.isShiftKeyDown=!1,t(this,Xc)&&(A(this,Xc,!1),o(this,pd,vd).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:r}=document;for(const e of t(this,Yc))if(e.div.contains(r)){A(this,Pc,[e,r]),e._focusEventsAllowed=!1;break}}focus(){if(!t(this,Pc))return;const[r,e]=t(this,Pc);A(this,Pc,null),e.addEventListener("focusin",(()=>{r._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}addEditListeners(){o(this,Bd,_d).call(this),o(this,Id,Rd).call(this)}removeEditListeners(){o(this,Zd,Wd).call(this),o(this,Fd,Sd).call(this)}dragOver(r){for(const{type:e}of r.dataTransfer.items)for(const a of t(this,Rc))if(a.isHandlingMimeForPasting(e))return r.dataTransfer.dropEffect="copy",void r.preventDefault()}drop(r){for(const e of r.dataTransfer.items)for(const a of t(this,Rc))if(a.isHandlingMimeForPasting(e.type))return a.paste(e,this.currentLayer),void r.preventDefault()}copy(r){var e;if(r.preventDefault(),null==(e=t(this,kc))||e.commitOrRemove(),!this.hasSelection)return;const a=[];for(const r of t(this,Yc)){const e=r.serialize(!0);e&&a.push(e)}0!==a.length&&r.clipboardData.setData("application/pdfjs",JSON.stringify(a))}cut(r){this.copy(r),this.delete()}paste(r){r.preventDefault();const{clipboardData:e}=r;for(const r of e.items)for(const e of t(this,Rc))if(e.isHandlingMimeForPasting(r.type))return void e.paste(r,this.currentLayer);let a=e.getData("application/pdfjs");if(!a)return;try{a=JSON.parse(a)}catch(r){return void Nf(`paste: "${r.message}".`)}if(!Array.isArray(a))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const e of a){const a=i.deserialize(e);if(!a)return;r.push(a)}const e=()=>{for(const e of r)o(this,Ld,Od).call(this,e);o(this,Jd,zd).call(this,r)},t=()=>{for(const e of r)e.remove()};this.addCommands({cmd:e,undo:t,mustExec:!0})}catch(r){Nf(`paste: "${r.message}".`)}}keydown(r){!this.isShiftKeyDown&&"Shift"===r.key&&(this.isShiftKeyDown=!0),t(this,Oc)!==qs.NONE&&!this.isEditorHandlingKeyboard&&qd._keyboardManager.exec(this,r)}keyup(r){this.isShiftKeyDown&&"Shift"===r.key&&(this.isShiftKeyDown=!1,t(this,Xc)&&(A(this,Xc,!1),o(this,pd,vd).call(this,"main_toolbar")))}onEditingAction({name:r}){switch(r){case"undo":case"redo":case"delete":case"selectAll":this[r]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(r){r?(o(this,wd,yd).call(this),o(this,Id,Rd).call(this),o(this,Gd,Xd).call(this,{isEditing:t(this,Oc)!==qs.NONE,isEmpty:o(this,Qd,Ud).call(this),hasSomethingToUndo:t(this,_c).hasSomethingToUndo(),hasSomethingToRedo:t(this,_c).hasSomethingToRedo(),hasSelectedEditor:!1})):(o(this,Ed,Cd).call(this),o(this,Fd,Sd).call(this),o(this,Gd,Xd).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(r){if(!t(this,Rc)){A(this,Rc,r);for(const r of t(this,Rc))o(this,Vd,Nd).call(this,r.defaultPropertiesToUpdate)}}getId(){return t(this,Nc).id}get currentLayer(){return t(this,yc).get(t(this,Zc))}getLayer(r){return t(this,yc).get(r)}get currentPageIndex(){return t(this,Zc)}addLayer(r){t(this,yc).set(r.pageIndex,r),t(this,Dc)?r.enable():r.disable()}removeLayer(r){t(this,yc).delete(r.pageIndex)}updateMode(r,e=null,a=!1){if(t(this,Oc)!==r){if(A(this,Oc,r),r===qs.NONE)return this.setEditingState(!1),void o(this,Pd,jd).call(this);this.setEditingState(!0),o(this,Dd,Td).call(this),this.unselectAll();for(const e of t(this,yc).values())e.updateMode(r);if(!e&&a)return void this.addNewEditorFromKeyboard();if(e)for(const r of t(this,wc).values())if(r.annotationElementId===e){this.setSelected(r),r.enterInEditMode();break}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(r){r!==t(this,Oc)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:r})}updateParams(r,e){var a;if(t(this,Rc)){switch(r){case $s.CREATE:return void this.currentLayer.addNewEditor();case $s.HIGHLIGHT_DEFAULT_COLOR:null==(a=t(this,jc))||a.updateColor(e);break;case $s.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(t(this,Uc)||A(this,Uc,new Map)).set(r,e),this.showAllEditors("highlight",e)}for(const a of t(this,Yc))a.updateParams(r,e);for(const a of t(this,Rc))a.updateDefaultParams(r,e)}}showAllEditors(r,e,a=!1){var i;for(const a of t(this,wc).values())a.editorType===r&&a.show(e);((null==(i=t(this,Uc))?void 0:i.get($s.HIGHLIGHT_SHOW_ALL))??!0)!==e&&o(this,Vd,Nd).call(this,[[$s.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(r=!1){if(t(this,Tc)!==r){A(this,Tc,r);for(const e of t(this,yc).values())r?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",r)}}getEditors(r){const e=[];for(const a of t(this,wc).values())a.pageIndex===r&&e.push(a);return e}getEditor(r){return t(this,wc).get(r)}addEditor(r){t(this,wc).set(r.id,r)}removeEditor(r){var e;r.div.contains(document.activeElement)&&(t(this,Mc)&&clearTimeout(t(this,Mc)),A(this,Mc,setTimeout((()=>{this.focusMainContainer(),A(this,Mc,null)}),0))),t(this,wc).delete(r.id),this.unselect(r),(!r.annotationElementId||!t(this,Wc).has(r.annotationElementId))&&(null==(e=t(this,Cc))||e.remove(r.id))}addDeletedAnnotationElement(r){t(this,Wc).add(r.annotationElementId),this.addChangedExistingAnnotation(r),r.deleted=!0}isDeletedAnnotationElement(r){return t(this,Wc).has(r)}removeDeletedAnnotationElement(r){t(this,Wc).delete(r.annotationElementId),this.removeChangedExistingAnnotation(r),r.deleted=!1}setActiveEditor(r){t(this,kc)!==r&&(A(this,kc,r),r&&o(this,Vd,Nd).call(this,r.propertiesToUpdate))}updateUI(r){t(this,Yd,Hd)===r&&o(this,Vd,Nd).call(this,r.propertiesToUpdate)}toggleSelected(r){if(t(this,Yc).has(r))return t(this,Yc).delete(r),r.unselect(),void o(this,Gd,Xd).call(this,{hasSelectedEditor:this.hasSelection});t(this,Yc).add(r),r.select(),o(this,Vd,Nd).call(this,r.propertiesToUpdate),o(this,Gd,Xd).call(this,{hasSelectedEditor:!0})}setSelected(r){for(const e of t(this,Yc))e!==r&&e.unselect();t(this,Yc).clear(),t(this,Yc).add(r),r.select(),o(this,Vd,Nd).call(this,r.propertiesToUpdate),o(this,Gd,Xd).call(this,{hasSelectedEditor:!0})}isSelected(r){return t(this,Yc).has(r)}get firstSelectedEditor(){return t(this,Yc).values().next().value}unselect(r){r.unselect(),t(this,Yc).delete(r),o(this,Gd,Xd).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==t(this,Yc).size}get isEnterHandled(){return 1===t(this,Yc).size&&this.firstSelectedEditor.isEnterHandled}undo(){t(this,_c).undo(),o(this,Gd,Xd).call(this,{hasSomethingToUndo:t(this,_c).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:o(this,Qd,Ud).call(this)})}redo(){t(this,_c).redo(),o(this,Gd,Xd).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:t(this,_c).hasSomethingToRedo(),isEmpty:o(this,Qd,Ud).call(this)})}addCommands(r){t(this,_c).add(r),o(this,Gd,Xd).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:o(this,Qd,Ud).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const r=[...t(this,Yc)];this.addCommands({cmd:()=>{for(const e of r)e.remove()},undo:()=>{for(const e of r)o(this,Ld,Od).call(this,e)},mustExec:!0})}commitOrRemove(){var r;null==(r=t(this,kc))||r.commitOrRemove()}hasSomethingToControl(){return t(this,kc)||this.hasSelection}selectAll(){for(const r of t(this,Yc))r.commit();o(this,Jd,zd).call(this,t(this,wc).values())}unselectAll(){if((!t(this,kc)||(t(this,kc).commitOrRemove(),t(this,Oc)===qs.NONE))&&this.hasSelection){for(const r of t(this,Yc))r.unselect();t(this,Yc).clear(),o(this,Gd,Xd).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(r,e,a=!1){if(a||this.commitOrRemove(),!this.hasSelection)return;t(this,od)[0]+=r,t(this,od)[1]+=e;const[i,n]=t(this,od),o=[...t(this,Yc)];t(this,sd)&&clearTimeout(t(this,sd)),A(this,sd,setTimeout((()=>{A(this,sd,null),t(this,od)[0]=t(this,od)[1]=0,this.addCommands({cmd:()=>{for(const r of o)t(this,wc).has(r.id)&&r.translateInPage(i,n)},undo:()=>{for(const r of o)t(this,wc).has(r.id)&&r.translateInPage(-i,-n)},mustExec:!1})}),1e3));for(const a of o)a.translateInPage(r,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),A(this,Ic,new Map);for(const r of t(this,Yc))t(this,Ic).set(r,{savedX:r.x,savedY:r.y,savedPageIndex:r.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!t(this,Ic))return!1;this.disableUserSelect(!1);const r=t(this,Ic);A(this,Ic,null);let e=!1;for(const[{x:a,y:t,pageIndex:i},A]of r)A.newX=a,A.newY=t,A.newPageIndex=i,e||(e=a!==A.savedX||t!==A.savedY||i!==A.savedPageIndex);if(!e)return!1;const a=(r,e,a,i)=>{if(t(this,wc).has(r.id)){const A=t(this,yc).get(i);A?r._setParentAndPosition(A,e,a):(r.pageIndex=i,r.x=e,r.y=a)}};return this.addCommands({cmd:()=>{for(const[e,{newX:t,newY:i,newPageIndex:A}]of r)a(e,t,i,A)},undo:()=>{for(const[e,{savedX:t,savedY:i,savedPageIndex:A}]of r)a(e,t,i,A)},mustExec:!0}),!0}dragSelectedEditors(r,e){if(t(this,Ic))for(const a of t(this,Ic).keys())a.drag(r,e)}rebuild(r){if(null===r.parent){const e=this.getLayer(r.pageIndex);e?(e.changeParent(r),e.addOrRebuild(r)):(this.addEditor(r),this.addToAnnotationStorage(r),r.rebuild())}else r.parent.addOrRebuild(r)}get isEditorHandlingKeyboard(){var r;return(null==(r=this.getActive())?void 0:r.shouldGetKeyboardEvents())||1===t(this,Yc).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(r){return t(this,kc)===r}getActive(){return t(this,kc)}getMode(){return t(this,Oc)}get imageManager(){return jf(this,"imageManager",new sc)}getSelectionBoxes(r){if(!r)return null;const e=document.getSelection();for(let a=0,t=e.rangeCount;a<t;a++)if(!r.contains(e.getRangeAt(a).commonAncestorContainer))return null;const{x:a,y:t,width:i,height:A}=r.getBoundingClientRect();let n;switch(r.getAttribute("data-main-rotation")){case"90":n=(r,e,n,o)=>({x:(e-t)/A,y:1-(r+n-a)/i,width:o/A,height:n/i});break;case"180":n=(r,e,n,o)=>({x:1-(r+n-a)/i,y:1-(e+o-t)/A,width:n/i,height:o/A});break;case"270":n=(r,e,n,o)=>({x:1-(e+o-t)/A,y:(r-a)/i,width:o/A,height:n/i});break;default:n=(r,e,n,o)=>({x:(r-a)/i,y:(e-t)/A,width:n/i,height:o/A})}const o=[];for(let r=0,a=e.rangeCount;r<a;r++){const a=e.getRangeAt(r);if(!a.collapsed)for(const{x:r,y:e,width:t,height:i}of a.getClientRects())0===t||0===i||o.push(n(r,e,t,i))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:r,id:e}){(t(this,Bc)||A(this,Bc,new Map)).set(r,e)}removeChangedExistingAnnotation({annotationElementId:r}){var e;null==(e=t(this,Bc))||e.delete(r)}renderAnnotationElement(r){var e;const a=null==(e=t(this,Bc))?void 0:e.get(r.data.id);if(!a)return;const i=t(this,Cc).getRawValue(a);i&&(t(this,Oc)===qs.NONE&&!i.hasBeenModified||i.renderAnnotationElement(r))}};let $d=qd;var Kd,rh,eh,ah,th,ih,Ah,nh,oh;mc=new WeakMap,kc=new WeakMap,wc=new WeakMap,yc=new WeakMap,Ec=new WeakMap,Cc=new WeakMap,Bc=new WeakMap,_c=new WeakMap,Zc=new WeakMap,Wc=new WeakMap,Ic=new WeakMap,Rc=new WeakMap,Fc=new WeakMap,Sc=new WeakMap,xc=new WeakMap,Mc=new WeakMap,Gc=new WeakMap,Xc=new WeakMap,Vc=new WeakMap,Nc=new WeakMap,Dc=new WeakMap,Tc=new WeakMap,Pc=new WeakMap,jc=new WeakMap,Lc=new WeakMap,Oc=new WeakMap,Yc=new WeakMap,Hc=new WeakMap,Qc=new WeakMap,Uc=new WeakMap,Jc=new WeakMap,zc=new WeakMap,qc=new WeakMap,$c=new WeakMap,Kc=new WeakMap,rd=new WeakMap,ed=new WeakMap,ad=new WeakMap,td=new WeakMap,id=new WeakMap,Ad=new WeakMap,nd=new WeakMap,od=new WeakMap,sd=new WeakMap,fd=new WeakMap,ld=new WeakMap,ud=new WeakSet,cd=function({anchorNode:r}){return r.nodeType===Node.TEXT_NODE?r.parentElement:r},dd=new WeakSet,hd=function(){const r=document.getSelection();if(!r||r.isCollapsed)return;const e=o(this,ud,cd).call(this,r).closest(".textLayer"),a=this.getSelectionBoxes(e);a&&(t(this,Vc)||A(this,Vc,new ic(this)),t(this,Vc).show(e,a,"ltr"===this.direction))},bd=new WeakSet,gd=function(){var r,e,a;const i=document.getSelection();if(!i||i.isCollapsed)return void(t(this,Hc)&&(null==(r=t(this,Vc))||r.hide(),A(this,Hc,null),o(this,Gd,Xd).call(this,{hasSelectedText:!1})));const{anchorNode:n}=i;if(n!==t(this,Hc))if(o(this,ud,cd).call(this,i).closest(".textLayer")){if(null==(a=t(this,Vc))||a.hide(),A(this,Hc,n),o(this,Gd,Xd).call(this,{hasSelectedText:!0}),(t(this,Oc)===qs.HIGHLIGHT||t(this,Oc)===qs.NONE)&&(t(this,Oc)===qs.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),A(this,Xc,this.isShiftKeyDown),!this.isShiftKeyDown)){const r=this._signal,e=r=>{"pointerup"===r.type&&0!==r.button||(window.removeEventListener("pointerup",e),window.removeEventListener("blur",e),"pointerup"===r.type&&o(this,pd,vd).call(this,"main_toolbar"))};window.addEventListener("pointerup",e,{signal:r}),window.addEventListener("blur",e,{signal:r})}}else t(this,Hc)&&(null==(e=t(this,Vc))||e.hide(),A(this,Hc,null),o(this,Gd,Xd).call(this,{hasSelectedText:!1}))},pd=new WeakSet,vd=function(r=""){t(this,Oc)===qs.HIGHLIGHT?this.highlightSelection(r):t(this,Sc)&&o(this,dd,hd).call(this)},md=new WeakSet,kd=function(){document.addEventListener("selectionchange",o(this,bd,gd).bind(this),{signal:this._signal})},wd=new WeakSet,yd=function(){const r=this._signal;window.addEventListener("focus",t(this,zc),{signal:r}),window.addEventListener("blur",t(this,Jc),{signal:r})},Ed=new WeakSet,Cd=function(){window.removeEventListener("focus",t(this,zc)),window.removeEventListener("blur",t(this,Jc))},Bd=new WeakSet,_d=function(){const r=this._signal;window.addEventListener("keydown",t(this,rd),{signal:r}),window.addEventListener("keyup",t(this,ed),{signal:r})},Zd=new WeakSet,Wd=function(){window.removeEventListener("keydown",t(this,rd)),window.removeEventListener("keyup",t(this,ed))},Id=new WeakSet,Rd=function(){const r=this._signal;document.addEventListener("copy",t(this,qc),{signal:r}),document.addEventListener("cut",t(this,$c),{signal:r}),document.addEventListener("paste",t(this,Kc),{signal:r})},Fd=new WeakSet,Sd=function(){document.removeEventListener("copy",t(this,qc)),document.removeEventListener("cut",t(this,$c)),document.removeEventListener("paste",t(this,Kc))},xd=new WeakSet,Md=function(){const r=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:r}),document.addEventListener("drop",this.drop.bind(this),{signal:r})},Gd=new WeakSet,Xd=function(r){Object.entries(r).some((([r,e])=>t(this,nd)[r]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(t(this,nd),r)}),t(this,Oc)===qs.HIGHLIGHT&&!1===r.hasSelectedEditor&&o(this,Vd,Nd).call(this,[[$s.HIGHLIGHT_FREE,!0]]))},Vd=new WeakSet,Nd=function(r){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:r})},Dd=new WeakSet,Td=function(){if(!t(this,Dc)){A(this,Dc,!0);for(const r of t(this,yc).values())r.enable();for(const r of t(this,wc).values())r.enable()}},Pd=new WeakSet,jd=function(){if(this.unselectAll(),t(this,Dc)){A(this,Dc,!1);for(const r of t(this,yc).values())r.disable();for(const r of t(this,wc).values())r.disable()}},Ld=new WeakSet,Od=function(r){const e=t(this,yc).get(r.pageIndex);e?e.addOrRebuild(r):(this.addEditor(r),this.addToAnnotationStorage(r))},Yd=new WeakSet,Hd=function(){let r=null;for(r of t(this,Yc));return r},Qd=new WeakSet,Ud=function(){if(0===t(this,wc).size)return!0;if(1===t(this,wc).size)for(const r of t(this,wc).values())return r.isEmpty();return!1},Jd=new WeakSet,zd=function(r){for(const r of t(this,Yc))r.unselect();t(this,Yc).clear();for(const e of r)e.isEmpty()||(t(this,Yc).add(e),e.select());o(this,Gd,Xd).call(this,{hasSelectedEditor:this.hasSelection})},e($d,"TRANSLATE_SMALL",1),e($d,"TRANSLATE_BIG",10);const sh=class{constructor(r){i(this,nh),i(this,Kd,""),i(this,rh,!1),i(this,eh,null),i(this,ah,null),i(this,th,null),i(this,ih,!1),i(this,Ah,null),A(this,Ah,r)}static initialize(r){sh._l10nPromise||(sh._l10nPromise=r)}async render(){const r=A(this,eh,document.createElement("button"));r.className="altText";const e=await sh._l10nPromise.get("pdfjs-editor-alt-text-button-label");r.textContent=e,r.setAttribute("aria-label",e),r.tabIndex="0";const a=t(this,Ah)._uiManager._signal;r.addEventListener("contextmenu",gu,{signal:a}),r.addEventListener("pointerdown",(r=>r.stopPropagation()),{signal:a});const i=r=>{r.preventDefault(),t(this,Ah)._uiManager.editAltText(t(this,Ah))};return r.addEventListener("click",i,{capture:!0,signal:a}),r.addEventListener("keydown",(e=>{e.target===r&&"Enter"===e.key&&(A(this,ih,!0),i(e))}),{signal:a}),await o(this,nh,oh).call(this),r}finish(){t(this,eh)&&(t(this,eh).focus({focusVisible:t(this,ih)}),A(this,ih,!1))}isEmpty(){return!t(this,Kd)&&!t(this,rh)}get data(){return{altText:t(this,Kd),decorative:t(this,rh)}}set data({altText:r,decorative:e}){t(this,Kd)===r&&t(this,rh)===e||(A(this,Kd,r),A(this,rh,e),o(this,nh,oh).call(this))}toggle(r=!1){t(this,eh)&&(!r&&t(this,th)&&(clearTimeout(t(this,th)),A(this,th,null)),t(this,eh).disabled=!r)}destroy(){var r;null==(r=t(this,eh))||r.remove(),A(this,eh,null),A(this,ah,null)}};let fh=sh;var lh,uh,ch,dh,hh,bh,gh,ph,vh,mh,kh,wh,yh,Eh,Ch,Bh,_h,Zh,Wh,Ih,Rh,Fh,Sh,xh,Mh,Gh,Xh,Vh,Nh,Dh,Th,Ph,jh,Lh,Oh,Yh,Hh,Qh,Uh,Jh,zh,qh,$h,Kh,rb,eb,ab,tb,ib,Ab;Kd=new WeakMap,rh=new WeakMap,eh=new WeakMap,ah=new WeakMap,th=new WeakMap,ih=new WeakMap,Ah=new WeakMap,nh=new WeakSet,oh=async function(){var r;const e=t(this,eh);if(!e)return;if(!t(this,Kd)&&!t(this,rh))return e.classList.remove("done"),void(null==(r=t(this,ah))||r.remove());e.classList.add("done"),sh._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then((r=>{e.setAttribute("aria-label",r)}));let a=t(this,ah);if(!a){A(this,ah,a=document.createElement("span")),a.className="tooltip",a.setAttribute("role","tooltip");const r=a.id=`alt-text-tooltip-${t(this,Ah).id}`;e.setAttribute("aria-describedby",r);const i=100,n=t(this,Ah)._uiManager._signal;n.addEventListener("abort",(()=>{clearTimeout(t(this,th)),A(this,th,null)}),{once:!0}),e.addEventListener("mouseenter",(()=>{A(this,th,setTimeout((()=>{A(this,th,null),t(this,ah).classList.add("show"),t(this,Ah)._reportTelemetry({action:"alt_text_tooltip"})}),i))}),{signal:n}),e.addEventListener("mouseleave",(()=>{var r;t(this,th)&&(clearTimeout(t(this,th)),A(this,th,null)),null==(r=t(this,ah))||r.classList.remove("show")}),{signal:n})}a.innerText=t(this,rh)?await sh._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):t(this,Kd),a.parentNode||e.append(a);const i=t(this,Ah).getImageForAltText();null==i||i.setAttribute("aria-describedby",a.id)},e(fh,"_l10nPromise",null);const nb=class{constructor(r){i(this,Sh),i(this,Xh),i(this,Nh),i(this,Th),i(this,jh),i(this,Oh),i(this,Hh),i(this,Uh),i(this,zh),i(this,$h),i(this,rb),i(this,ab),i(this,ib),i(this,lh,null),i(this,uh,null),i(this,ch,null),i(this,dh,!1),i(this,hh,!1),i(this,bh,null),i(this,gh,null),i(this,ph,this.focusin.bind(this)),i(this,vh,this.focusout.bind(this)),i(this,mh,null),i(this,kh,""),i(this,wh,!1),i(this,yh,null),i(this,Eh,!1),i(this,Ch,!1),i(this,Bh,!1),i(this,_h,null),i(this,Zh,0),i(this,Wh,0),i(this,Ih,null),e(this,"_initialOptions",Object.create(null)),e(this,"_isVisible",!0),e(this,"_uiManager",null),e(this,"_focusEventsAllowed",!0),e(this,"_l10nPromise",null),i(this,Rh,!1),i(this,Fh,nb._zIndex++),this.constructor===nb&&Df("Cannot initialize AnnotationEditor."),this.parent=r.parent,this.id=r.id,this.width=this.height=null,this.pageIndex=r.parent.pageIndex,this.name=r.name,this.div=null,this._uiManager=r.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=r.isCentered,this._structTreeParentId=null;const{rotation:a,rawDims:{pageWidth:t,pageHeight:A,pageX:n,pageY:o}}=this.parent.viewport;this.rotation=a,this.pageRotation=(360+a-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[t,A],this.pageTranslation=[n,o];const[s,f]=this.parentDimensions;this.x=r.x/s,this.y=r.y/f,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const r=nb.prototype._resizeWithKeyboard,e=$d.TRANSLATE_SMALL,a=$d.TRANSLATE_BIG;return jf(this,"_resizerKeyboardManager",new gc([[["ArrowLeft","mac+ArrowLeft"],r,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r,{args:[-a,0]}],[["ArrowRight","mac+ArrowRight"],r,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r,{args:[a,0]}],[["ArrowUp","mac+ArrowUp"],r,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r,{args:[0,-a]}],[["ArrowDown","mac+ArrowDown"],r,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r,{args:[0,a]}],[["Escape","mac+Escape"],nb.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return jf(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(r){const e=new sb({id:r.parent.getNextId(),parent:r.parent,uiManager:r._uiManager});e.annotationElementId=r.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(r,e,a){if(nb._l10nPromise||(nb._l10nPromise=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map((e=>[e,r.get(e.replaceAll(/([A-Z])/g,(r=>`-${r.toLowerCase()}`)))])))),null!=a&&a.strings)for(const e of a.strings)nb._l10nPromise.set(e,r.get(e));if(-1!==nb._borderLineWidth)return;const t=getComputedStyle(document.documentElement);nb._borderLineWidth=parseFloat(t.getPropertyValue("--outline-width"))||0}static updateDefaultParams(r,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(r){return!1}static paste(r,e){Df("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return t(this,Rh)}set _isDraggable(r){var e;A(this,Rh,r),null==(e=this.div)||e.classList.toggle("draggable",r)}get isEnterHandled(){return!0}center(){const[r,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*r),this.y+=this.width*r/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*r),this.y-=this.width*r/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(r){this._uiManager.addCommands(r)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=t(this,Fh)}setParent(r){null!==r?(this.pageIndex=r.pageIndex,this.pageDimensions=r.pageDimensions):o(this,ib,Ab).call(this),this.parent=r}focusin(r){this._focusEventsAllowed&&(t(this,wh)?A(this,wh,!1):this.parent.setSelected(this))}focusout(r){var e;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const a=r.relatedTarget;null!=a&&a.closest(`#${this.id}`)||(r.preventDefault(),null!=(e=this.parent)&&e.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(r,e,a,t){const[i,A]=this.parentDimensions;[a,t]=this.screenToPageTranslation(a,t),this.x=(r+a)/i,this.y=(e+t)/A,this.fixAndSetPosition()}translate(r,e){o(this,Sh,xh).call(this,this.parentDimensions,r,e)}translateInPage(r,e){t(this,yh)||A(this,yh,[this.x,this.y]),o(this,Sh,xh).call(this,this.pageDimensions,r,e),this.div.scrollIntoView({block:"nearest"})}drag(r,e){t(this,yh)||A(this,yh,[this.x,this.y]);const[a,i]=this.parentDimensions;if(this.x+=r/a,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:r,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,r,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:o}=this;const[s,f]=this.getBaseTranslation();n+=s,o+=f,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*o).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!t(this,yh)&&(t(this,yh)[0]!==this.x||t(this,yh)[1]!==this.y)}getBaseTranslation(){const[r,e]=this.parentDimensions,{_borderLineWidth:a}=nb,t=a/r,i=a/e;switch(this.rotation){case 90:return[-t,i];case 180:return[t,i];case 270:return[t,-i];default:return[-t,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(r=this.rotation){const[e,a]=this.pageDimensions;let{x:t,y:i,width:A,height:n}=this;if(A*=e,n*=a,t*=e,i*=a,this._mustFixPosition)switch(r){case 0:t=Math.max(0,Math.min(e-A,t)),i=Math.max(0,Math.min(a-n,i));break;case 90:t=Math.max(0,Math.min(e-n,t)),i=Math.min(a,Math.max(A,i));break;case 180:t=Math.min(e,Math.max(A,t)),i=Math.min(a,Math.max(n,i));break;case 270:t=Math.min(e,Math.max(n,t)),i=Math.max(0,Math.min(a-A,i))}this.x=t/=e,this.y=i/=a;const[o,s]=this.getBaseTranslation();t+=o,i+=s;const{style:f}=this.div;f.left=`${(100*t).toFixed(2)}%`,f.top=`${(100*i).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(r,e){var a;return o(a=nb,Mh,Gh).call(a,r,e,this.parentRotation)}pageTranslationToScreen(r,e){var a;return o(a=nb,Mh,Gh).call(a,r,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:r,pageDimensions:[e,a]}=this,t=e*r,i=a*r;return rl.isCSSRoundSupported?[Math.round(t),Math.round(i)]:[t,i]}setDims(r,e){const[a,i]=this.parentDimensions;this.div.style.width=`${(100*r/a).toFixed(2)}%`,t(this,hh)||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:r}=this.div,{height:e,width:a}=r,i=a.endsWith("%"),A=!t(this,hh)&&e.endsWith("%");if(i&&A)return;const[n,o]=this.parentDimensions;i||(r.width=`${(100*parseFloat(a)/n).toFixed(2)}%`),!t(this,hh)&&!A&&(r.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var r;null==(r=t(this,ch))||r.finish()}async addEditToolbar(){return t(this,mh)||t(this,Ch)||(A(this,mh,new ju(this)),this.div.append(t(this,mh).render()),t(this,ch)&&t(this,mh).addAltTextButton(await t(this,ch).render())),t(this,mh)}removeEditToolbar(){var r;t(this,mh)&&(t(this,mh).remove(),A(this,mh,null),null==(r=t(this,ch))||r.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){t(this,ch)||(fh.initialize(nb._l10nPromise),A(this,ch,new fh(this)),t(this,lh)&&(t(this,ch).data=t(this,lh),A(this,lh,null)),await this.addEditToolbar())}get altTextData(){var r;return null==(r=t(this,ch))?void 0:r.data}set altTextData(r){t(this,ch)&&(t(this,ch).data=r)}hasAltText(){var r;return!(null!=(r=t(this,ch))&&r.isEmpty())}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=t(this,dh)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const r=this._uiManager._signal;this.div.addEventListener("focusin",t(this,ph),{signal:r}),this.div.addEventListener("focusout",t(this,vh),{signal:r});const[e,a]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*a/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/a).toFixed(2)}%`);const[i,A]=this.getInitialTranslation();return this.translate(i,A),Ac(this,this.div,["pointerdown"]),this.div}pointerdown(r){const{isMac:e}=rl.platform;0!==r.button||r.ctrlKey&&e?r.preventDefault():(A(this,wh,!0),this._isDraggable?o(this,Uh,Jh).call(this,r):o(this,Hh,Qh).call(this,r))}moveInDOM(){t(this,_h)&&clearTimeout(t(this,_h)),A(this,_h,setTimeout((()=>{var r;A(this,_h,null),null==(r=this.parent)||r.moveEditorInDOM(this)}),0))}_setParentAndPosition(r,e,a){r.changeParent(this),this.x=e,this.y=a,this.fixAndSetPosition()}getRect(r,e,a=this.rotation){const t=this.parentScale,[i,A]=this.pageDimensions,[n,o]=this.pageTranslation,s=r/t,f=e/t,l=this.x*i,u=this.y*A,c=this.width*i,d=this.height*A;switch(a){case 0:return[l+s+n,A-u-f-d+o,l+s+c+n,A-u-f+o];case 90:return[l+f+n,A-u+s+o,l+f+d+n,A-u+s+c+o];case 180:return[l-s-c+n,A-u+f+o,l-s+n,A-u+f+d+o];case 270:return[l-f-d+n,A-u-s-c+o,l-f+n,A-u-s+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(r,e){const[a,t,i,A]=r,n=i-a,o=A-t;switch(this.rotation){case 0:return[a,e-A,n,o];case 90:return[a,e-t,o,n];case 180:return[i,e-t,n,o];case 270:return[i,e-A,o,n];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){A(this,Ch,!0)}disableEditMode(){A(this,Ch,!1)}isInEditMode(){return t(this,Ch)}shouldGetKeyboardEvents(){return t(this,Bh)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var r,e;const a=this._uiManager._signal;null==(r=this.div)||r.addEventListener("focusin",t(this,ph),{signal:a}),null==(e=this.div)||e.addEventListener("focusout",t(this,vh),{signal:a})}rotate(r){}serialize(r=!1,e=null){Df("An editor must be serializable")}static deserialize(r,e,a){const t=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:a});t.rotation=r.rotation,A(t,lh,r.accessibilityData);const[i,n]=t.pageDimensions,[o,s,f,l]=t.getRectInCurrentCoords(r.rect,n);return t.x=o/i,t.y=s/n,t.width=f/i,t.height=l/n,t}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.div.removeEventListener("focusin",t(this,ph)),this.div.removeEventListener("focusout",t(this,vh)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),t(this,_h)&&(clearTimeout(t(this,_h)),A(this,_h,null)),o(this,ib,Ab).call(this),this.removeEditToolbar(),t(this,Ih)){for(const r of t(this,Ih).values())clearTimeout(r);A(this,Ih,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(o(this,Nh,Dh).call(this),t(this,bh).classList.remove("hidden"),Ac(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(r){if(!this.isResizable||r.target!==this.div||"Enter"!==r.key)return;this._uiManager.setSelected(this),A(this,gh,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=t(this,bh).children;if(!t(this,uh)){A(this,uh,Array.from(e));const r=o(this,zh,qh).bind(this),a=o(this,$h,Kh).bind(this),i=this._uiManager._signal;for(const e of t(this,uh)){const t=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",r,{signal:i}),e.addEventListener("blur",a,{signal:i}),e.addEventListener("focus",o(this,rb,eb).bind(this,t),{signal:i}),nb._l10nPromise.get(`pdfjs-editor-resizer-label-${t}`).then((r=>e.setAttribute("aria-label",r)))}}const a=t(this,uh)[0];let i=0;for(const r of e){if(r===a)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(t(this,uh).length/4);if(n!==i){if(n<i)for(let r=0;r<i-n;r++)t(this,bh).append(t(this,bh).firstChild);else if(n>i)for(let r=0;r<n-i;r++)t(this,bh).firstChild.before(t(this,bh).lastChild);let r=0;for(const a of e){const e=t(this,uh)[r++].getAttribute("data-resizer-name");nb._l10nPromise.get(`pdfjs-editor-resizer-label-${e}`).then((r=>a.setAttribute("aria-label",r)))}}o(this,ab,tb).call(this,0),A(this,Bh,!0),t(this,bh).firstChild.focus({focusVisible:!0}),r.preventDefault(),r.stopImmediatePropagation()}_resizeWithKeyboard(r,e){t(this,Bh)&&o(this,Oh,Yh).call(this,t(this,kh),{movementX:r,movementY:e})}_stopResizingWithKeyboard(){o(this,ib,Ab).call(this),this.div.focus()}select(){var r,e;this.makeResizable(),null==(r=this.div)||r.classList.add("selectedEditor"),t(this,mh)?null==(e=t(this,mh))||e.show():this.addEditToolbar().then((()=>{var r,e;null!=(r=this.div)&&r.classList.contains("selectedEditor")&&(null==(e=t(this,mh))||e.show())}))}unselect(){var r,e,a,i;null==(r=t(this,bh))||r.classList.add("hidden"),null==(e=this.div)||e.classList.remove("selectedEditor"),null!=(a=this.div)&&a.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null==(i=t(this,mh))||i.hide()}updateParams(r,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return t(this,Eh)}set isEditing(r){A(this,Eh,r),this.parent&&(r?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(r,e){A(this,hh,!0);const a=r/e,{style:t}=this.div;t.aspectRatio=a,t.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(r,e=!1){if(e){t(this,Ih)||A(this,Ih,new Map);const{action:e}=r;let a=t(this,Ih).get(e);return a&&clearTimeout(a),a=setTimeout((()=>{this._reportTelemetry(r),t(this,Ih).delete(e),0===t(this,Ih).size&&A(this,Ih,null)}),nb._telemetryTimeout),void t(this,Ih).set(e,a)}r.type||(r.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:r}})}show(r=this._isVisible){this.div.classList.toggle("hidden",!r),this._isVisible=r}enable(){this.div&&(this.div.tabIndex=0),A(this,dh,!1)}disable(){this.div&&(this.div.tabIndex=-1),A(this,dh,!0)}renderAnnotationElement(r){let e=r.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const r=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),r.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),r.container.prepend(e);return e}resetAnnotationElement(r){const{firstChild:e}=r.container;"DIV"===e.nodeName&&e.classList.contains("annotationContent")&&e.remove()}};let ob=nb;lh=new WeakMap,uh=new WeakMap,ch=new WeakMap,dh=new WeakMap,hh=new WeakMap,bh=new WeakMap,gh=new WeakMap,ph=new WeakMap,vh=new WeakMap,mh=new WeakMap,kh=new WeakMap,wh=new WeakMap,yh=new WeakMap,Eh=new WeakMap,Ch=new WeakMap,Bh=new WeakMap,_h=new WeakMap,Zh=new WeakMap,Wh=new WeakMap,Ih=new WeakMap,Rh=new WeakMap,Fh=new WeakMap,Sh=new WeakSet,xh=function([r,e],a,t){[a,t]=this.screenToPageTranslation(a,t),this.x+=a/r,this.y+=t/e,this.fixAndSetPosition()},Mh=new WeakSet,Gh=function(r,e,a){switch(a){case 90:return[e,-r];case 180:return[-r,-e];case 270:return[-e,r];default:return[r,e]}},Xh=new WeakSet,Vh=function(r){switch(r){case 90:{const[r,e]=this.pageDimensions;return[0,-r/e,e/r,0]}case 180:return[-1,0,0,-1];case 270:{const[r,e]=this.pageDimensions;return[0,r/e,-e/r,0]}default:return[1,0,0,1]}},Nh=new WeakSet,Dh=function(){if(t(this,bh))return;A(this,bh,document.createElement("div")),t(this,bh).classList.add("resizers");const r=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const a of r){const r=document.createElement("div");t(this,bh).append(r),r.classList.add("resizer",a),r.setAttribute("data-resizer-name",a),r.addEventListener("pointerdown",o(this,Th,Ph).bind(this,a),{signal:e}),r.addEventListener("contextmenu",gu,{signal:e}),r.tabIndex=-1}this.div.prepend(t(this,bh))},Th=new WeakSet,Ph=function(r,e){var a;e.preventDefault();const{isMac:i}=rl.platform;if(0!==e.button||e.ctrlKey&&i)return;null==(a=t(this,ch))||a.toggle(!1);const A=o(this,Oh,Yh).bind(this,r),n=this._isDraggable;this._isDraggable=!1;const s=this._uiManager._signal,f={passive:!0,capture:!0,signal:s};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",A,f),window.addEventListener("contextmenu",gu,{signal:s});const l=this.x,u=this.y,c=this.width,d=this.height,h=this.parent.div.style.cursor,b=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const g=()=>{var r;this.parent.togglePointerEvents(!0),null==(r=t(this,ch))||r.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",A,f),window.removeEventListener("contextmenu",gu),this.parent.div.style.cursor=h,this.div.style.cursor=b,o(this,jh,Lh).call(this,l,u,c,d)};window.addEventListener("pointerup",g,{signal:s}),window.addEventListener("blur",g,{signal:s})},jh=new WeakSet,Lh=function(r,e,a,t){const i=this.x,A=this.y,n=this.width,o=this.height;i===r&&A===e&&n===a&&o===t||this.addCommands({cmd:()=>{this.width=n,this.height=o,this.x=i,this.y=A;const[r,e]=this.parentDimensions;this.setDims(r*n,e*o),this.fixAndSetPosition()},undo:()=>{this.width=a,this.height=t,this.x=r,this.y=e;const[i,A]=this.parentDimensions;this.setDims(i*a,A*t),this.fixAndSetPosition()},mustExec:!0})},Oh=new WeakSet,Yh=function(r,e){const[a,t]=this.parentDimensions,i=this.x,A=this.y,n=this.width,s=this.height,f=nb.MIN_SIZE/a,l=nb.MIN_SIZE/t,u=r=>Math.round(1e4*r)/1e4,c=o(this,Xh,Vh).call(this,this.rotation),d=(r,e)=>[c[0]*r+c[2]*e,c[1]*r+c[3]*e],h=o(this,Xh,Vh).call(this,360-this.rotation);let b,g,p=!1,v=!1;switch(r){case"topLeft":p=!0,b=(r,e)=>[0,0],g=(r,e)=>[r,e];break;case"topMiddle":b=(r,e)=>[r/2,0],g=(r,e)=>[r/2,e];break;case"topRight":p=!0,b=(r,e)=>[r,0],g=(r,e)=>[0,e];break;case"middleRight":v=!0,b=(r,e)=>[r,e/2],g=(r,e)=>[0,e/2];break;case"bottomRight":p=!0,b=(r,e)=>[r,e],g=(r,e)=>[0,0];break;case"bottomMiddle":b=(r,e)=>[r/2,e],g=(r,e)=>[r/2,0];break;case"bottomLeft":p=!0,b=(r,e)=>[0,e],g=(r,e)=>[r,0];break;case"middleLeft":v=!0,b=(r,e)=>[0,e/2],g=(r,e)=>[r,e/2]}const m=b(n,s),k=g(n,s);let w=d(...k);const y=u(i+w[0]),E=u(A+w[1]);let C=1,B=1,[_,Z]=this.screenToPageTranslation(e.movementX,e.movementY);if([_,Z]=(W=_/a,I=Z/t,[h[0]*W+h[2]*I,h[1]*W+h[3]*I]),p){const r=Math.hypot(n,s);C=B=Math.max(Math.min(Math.hypot(k[0]-m[0]-_,k[1]-m[1]-Z)/r,1/n,1/s),f/n,l/s)}else v?C=Math.max(f,Math.min(1,Math.abs(k[0]-m[0]-_)))/n:B=Math.max(l,Math.min(1,Math.abs(k[1]-m[1]-Z)))/s;var W,I;const R=u(n*C),F=u(s*B);w=d(...g(R,F));const S=y-w[0],x=E-w[1];this.width=R,this.height=F,this.x=S,this.y=x,this.setDims(a*R,t*F),this.fixAndSetPosition()},Hh=new WeakSet,Qh=function(r){const{isMac:e}=rl.platform;r.ctrlKey&&!e||r.shiftKey||r.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Uh=new WeakSet,Jh=function(r){const e=this._uiManager.isSelected(this);let a,i;this._uiManager.setUpDragSession();const n=this._uiManager._signal;e&&(this.div.classList.add("moving"),a={passive:!0,capture:!0,signal:n},A(this,Zh,r.clientX),A(this,Wh,r.clientY),i=r=>{const{clientX:e,clientY:a}=r,[i,n]=this.screenToPageTranslation(e-t(this,Zh),a-t(this,Wh));A(this,Zh,e),A(this,Wh,a),this._uiManager.dragSelectedEditors(i,n)},window.addEventListener("pointermove",i,a));const s=()=>{window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,a)),A(this,wh,!1),this._uiManager.endDragSession()||o(this,Hh,Qh).call(this,r)};window.addEventListener("pointerup",s,{signal:n}),window.addEventListener("blur",s,{signal:n})},zh=new WeakSet,qh=function(r){nb._resizerKeyboardManager.exec(this,r)},$h=new WeakSet,Kh=function(r){var e;t(this,Bh)&&(null==(e=r.relatedTarget)?void 0:e.parentNode)!==t(this,bh)&&o(this,ib,Ab).call(this)},rb=new WeakSet,eb=function(r){A(this,kh,t(this,Bh)?r:"")},ab=new WeakSet,tb=function(r){if(t(this,uh))for(const e of t(this,uh))e.tabIndex=r},ib=new WeakSet,Ab=function(){if(A(this,Bh,!1),o(this,ab,tb).call(this,-1),t(this,gh)){const{savedX:r,savedY:e,savedWidth:a,savedHeight:i}=t(this,gh);o(this,jh,Lh).call(this,r,e,a,i),A(this,gh,null)}},i(ob,Mh),e(ob,"_borderLineWidth",-1),e(ob,"_colorManager",new vc),e(ob,"_zIndex",1),e(ob,"_telemetryTimeout",1e3);class sb extends ob{constructor(r){super(r),this.annotationElementId=r.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const fb=3285377520,lb=4294901760,ub=65535;class cb{constructor(r){this.h1=r?4294967295&r:fb,this.h2=r?4294967295&r:fb}update(r){let e,a;if("string"==typeof r){e=new Uint8Array(2*r.length),a=0;for(let t=0,i=r.length;t<i;t++){const i=r.charCodeAt(t);i<=255?e[a++]=i:(e[a++]=i>>>8,e[a++]=255&i)}}else{if(!ArrayBuffer.isView(r))throw new Error("Invalid data format, must be a string or TypedArray.");e=r.slice(),a=e.byteLength}const t=a>>2,i=a-4*t,A=new Uint32Array(e.buffer,0,t);let n=0,o=0,s=this.h1,f=this.h2;const l=3432918353,u=461845907,c=l&ub,d=u&ub;for(let r=0;r<t;r++)1&r?(n=A[r],n=n*l&lb|n*c&ub,n=n<<15|n>>>17,n=n*u&lb|n*d&ub,s^=n,s=s<<13|s>>>19,s=5*s+3864292196):(o=A[r],o=o*l&lb|o*c&ub,o=o<<15|o>>>17,o=o*u&lb|o*d&ub,f^=o,f=f<<13|f>>>19,f=5*f+3864292196);switch(n=0,i){case 3:n^=e[4*t+2]<<16;case 2:n^=e[4*t+1]<<8;case 1:n^=e[4*t],n=n*l&lb|n*c&ub,n=n<<15|n>>>17,n=n*u&lb|n*d&ub,1&t?s^=n:f^=n}this.h1=s,this.h2=f}hexdigest(){let r=this.h1,e=this.h2;return r^=e>>>1,r=3981806797*r&lb|36045*r&ub,e=4283543511*e&lb|(2950163797*(e<<16|r>>>16)&lb)>>>16,r^=e>>>1,r=444984403*r&lb|60499*r&ub,e=3301882366*e&lb|(3120437893*(e<<16|r>>>16)&lb)>>>16,r^=e>>>1,(r>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const db=Object.freeze({map:null,hash:"",transfer:void 0});var hb,bb,gb,pb,vb,mb;class kb{constructor(){i(this,gb),i(this,hb,!1),i(this,bb,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(r,e){const a=t(this,bb).get(r);return void 0===a?e:Object.assign(e,a)}getRawValue(r){return t(this,bb).get(r)}remove(r){if(t(this,bb).delete(r),0===t(this,bb).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const r of t(this,bb).values())if(r instanceof ob)return;this.onAnnotationEditor(null)}}setValue(r,e){const a=t(this,bb).get(r);let i=!1;if(void 0!==a)for(const[r,t]of Object.entries(e))a[r]!==t&&(i=!0,a[r]=t);else i=!0,t(this,bb).set(r,e);i&&o(this,gb,pb).call(this),e instanceof ob&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(r){return t(this,bb).has(r)}getAll(){return t(this,bb).size>0?Kf(t(this,bb)):null}setAll(r){for(const[e,a]of Object.entries(r))this.setValue(e,a)}get size(){return t(this,bb).size}resetModified(){t(this,hb)&&(A(this,hb,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new wb(this)}get serializable(){if(0===t(this,bb).size)return db;const r=new Map,e=new cb,a=[],i=Object.create(null);let A=!1;for(const[a,n]of t(this,bb)){const t=n instanceof ob?n.serialize(!1,i):n;t&&(r.set(a,t),e.update(`${a}:${JSON.stringify(t)}`),A||(A=!!t.bitmap))}if(A)for(const e of r.values())e.bitmap&&a.push(e.bitmap);return r.size>0?{map:r,hash:e.hexdigest(),transfer:a}:db}get editorStats(){let r=null;const e=new Map;for(const a of t(this,bb).values()){if(!(a instanceof ob))continue;const t=a.telemetryFinalData;if(!t)continue;const{type:i}=t;e.has(i)||e.set(i,Object.getPrototypeOf(a).constructor),r||(r=Object.create(null));const A=r[i]||(r[i]=new Map);for(const[r,e]of Object.entries(t)){if("type"===r)continue;let a=A.get(r);a||(a=new Map,A.set(r,a));const t=a.get(e)??0;a.set(e,t+1)}}for(const[a,t]of e)r[a]=t.computeTelemetryFinalData(r[a]);return r}}hb=new WeakMap,bb=new WeakMap,gb=new WeakSet,pb=function(){t(this,hb)||(A(this,hb,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class wb extends kb{constructor(r){super(),i(this,vb,void 0);const{map:e,hash:a,transfer:t}=r.serializable,n=structuredClone(e,t?{transfer:t}:null);A(this,vb,{map:n,hash:a,transfer:t})}get print(){Df("Should not call PrintAnnotationStorage.print")}get serializable(){return t(this,vb)}}vb=new WeakMap;class yb{constructor({ownerDocument:r=globalThis.document,styleElement:e=null}){i(this,mb,new Set),this._document=r,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(r){this.nativeFontFaces.add(r),this._document.fonts.add(r)}removeNativeFontFace(r){this.nativeFontFaces.delete(r),this._document.fonts.delete(r)}insertRule(r){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(r,e.cssRules.length)}clear(){for(const r of this.nativeFontFaces)this._document.fonts.delete(r);this.nativeFontFaces.clear(),t(this,mb).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:r,_inspectFont:e}){if(r&&!t(this,mb).has(r.loadedName)){if(Tf(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:a,src:i,style:A}=r,n=new FontFace(a,i,A);this.addNativeFontFace(n);try{await n.load(),t(this,mb).add(a),null==e||e(r)}catch{Nf(`Cannot load system font: ${r.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(n)}return}Df("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(r){if(r.attached||r.missingFile&&!r.systemFontInfo)return;if(r.attached=!0,r.systemFontInfo)return void await this.loadSystemFont(r);if(this.isFontLoadingAPISupported){const e=r.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(a){throw Nf(`Failed to load font '${e.family}': '${a}'.`),r.disableFontFace=!0,a}}return}const e=r.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const a=this._queueLoadingCallback(e);this._prepareFontLoadEvent(r,a)}))}}get isFontLoadingAPISupported(){var r;return jf(this,"isFontLoadingAPISupported",!(null==(r=this._document)||!r.fonts))}get isSyncFontLoadingSupported(){let r=!1;return(Ds||typeof navigator<"u"&&"string"==typeof(null==navigator?void 0:navigator.userAgent)&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(r=!0),jf(this,"isSyncFontLoadingSupported",r)}_queueLoadingCallback(r){const{loadingRequests:e}=this,a={done:!1,complete:function(){for(Tf(!a.done,"completeRequest() cannot be called twice."),a.done=!0;e.length>0&&e[0].done;){const r=e.shift();setTimeout(r.callback,0)}},callback:r};return e.push(a),a}get _loadTestFont(){return jf(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(r,e){function a(r,e){return r.charCodeAt(e)<<24|r.charCodeAt(e+1)<<16|r.charCodeAt(e+2)<<8|255&r.charCodeAt(e+3)}function t(r,e,a,t){return r.substring(0,e)+t+r.substring(e+a)}let i,A;const n=this._document.createElement("canvas");n.width=1,n.height=1;const o=n.getContext("2d");let s=0;const f=`lt${Date.now()}${this.loadTestFontId++}`;let l=this._loadTestFont;l=t(l,976,f.length,f);const u=1482184792;let c=a(l,16);for(i=0,A=f.length-3;i<A;i+=4)c=c-u+a(f,i)|0;var d;i<f.length&&(c=c-u+a(f+"XXX",i)|0),l=t(l,16,4,(d=c,String.fromCharCode(d>>24&255,d>>16&255,d>>8&255,255&d)));const h=`@font-face {font-family:"${f}";src:${`url(data:font/opentype;base64,${btoa(l)});`}}`;this.insertRule(h);const b=this._document.createElement("div");b.style.visibility="hidden",b.style.width=b.style.height="10px",b.style.position="absolute",b.style.top=b.style.left="0px";for(const e of[r.loadedName,f]){const r=this._document.createElement("span");r.textContent="Hi",r.style.fontFamily=e,b.append(r)}this._document.body.append(b),function r(e,a){if(++s>30)return Nf("Load test font never loaded."),void a();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?a():setTimeout(r.bind(null,e,a))}(f,(()=>{b.remove(),e.complete()}))}}mb=new WeakMap;class Eb{constructor(r,{disableFontFace:e=!1,inspectFont:a=null}){this.compiledGlyphs=Object.create(null);for(const e in r)this[e]=r[e];this.disableFontFace=!0===e,this._inspectFont=a}createNativeFontFace(){var r;if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const r={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(r.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,r)}else e=new FontFace(this.loadedName,this.data,{});return null==(r=this._inspectFont)||r.call(this,this),e}createFontFaceRule(){var r;if(!this.data||this.disableFontFace)return null;const e=qf(this.data),a=`url(data:${this.mimetype};base64,${btoa(e)});`;let t;if(this.cssFontInfo){let r=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(r+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${r}src:${a}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${a}}`;return null==(r=this._inspectFont)||r.call(this,this,a),t}getPathGenerator(r,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let a;try{a=r.get(this.loadedName+"_path_"+e)}catch(r){Nf(`getPathGenerator - ignoring character: "${r}".`)}if(!Array.isArray(a)||0===a.length)return this.compiledGlyphs[e]=function(r,e){};const t=[];for(let r=0,e=a.length;r<e;)switch(a[r++]){case ul:{const[e,i,A,n,o,s]=a.slice(r,r+6);t.push((r=>r.bezierCurveTo(e,i,A,n,o,s))),r+=6}break;case cl:{const[e,i]=a.slice(r,r+2);t.push((r=>r.moveTo(e,i))),r+=2}break;case dl:{const[e,i]=a.slice(r,r+2);t.push((r=>r.lineTo(e,i))),r+=2}break;case hl:{const[e,i,A,n]=a.slice(r,r+4);t.push((r=>r.quadraticCurveTo(e,i,A,n))),r+=4}break;case bl:t.push((r=>r.restore()));break;case gl:t.push((r=>r.save()));break;case pl:Tf(2===t.length,"Scale command is only valid at the third position.");break;case vl:{const[e,i,A,n,o,s]=a.slice(r,r+6);t.push((r=>r.transform(e,i,A,n,o,s))),r+=6}break;case ml:{const[e,i]=a.slice(r,r+2);t.push((r=>r.translate(e,i))),r+=2}}return this.compiledGlyphs[e]=function(r,e){t[0](r),t[1](r),r.scale(e,-e);for(let e=2,a=t.length;e<a;e++)t[e](r)}}}if(Ds){var Cb=Promise.withResolvers(),Bb=null;(async()=>{const r=await import("./__vite-browser-external-afb87ea8.js"),e=await import("./__vite-browser-external-afb87ea8.js"),a=await import("./__vite-browser-external-afb87ea8.js"),t=await import("./__vite-browser-external-afb87ea8.js");return new Map(Object.entries({fs:r,http:e,https:a,url:t,canvas:undefined,path2d:undefined}))})().then((r=>{Bb=r,Cb.resolve()}),(r=>{Nf(`loadPackages: ${r}`),Bb=new Map,Cb.resolve()}))}class _b{static get promise(){return Cb.promise}static get(r){return null==Bb?void 0:Bb.get(r)}}const Zb=function(r){return _b.get("fs").promises.readFile(r).then((r=>new Uint8Array(r)))};const Wb="Fill",Ib="Stroke",Rb="Shading";function Fb(r,e){if(!e)return;const a=e[2]-e[0],t=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],a,t),r.clip(i)}class Sb{constructor(){this.constructor===Sb&&Df("Cannot initialize BaseShadingPattern.")}getPattern(){Df("Abstract method `getPattern` called.")}}class xb extends Sb{constructor(r){super(),this._type=r[1],this._bbox=r[2],this._colorStops=r[3],this._p0=r[4],this._p1=r[5],this._r0=r[6],this._r1=r[7],this.matrix=null}_createGradient(r){let e;"axial"===this._type?e=r.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=r.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const r of this._colorStops)e.addColorStop(r[0],r[1]);return e}getPattern(r,e,a,t){let i;if(t===Ib||t===Wb){const A=e.current.getClippedPathBoundingBox(t,yu(r))||[0,0,0,0],n=Math.ceil(A[2]-A[0])||1,o=Math.ceil(A[3]-A[1])||1,s=e.cachedCanvases.getCanvas("pattern",n,o,!0),f=s.context;f.clearRect(0,0,f.canvas.width,f.canvas.height),f.beginPath(),f.rect(0,0,f.canvas.width,f.canvas.height),f.translate(-A[0],-A[1]),a=nl.transform(a,[1,0,0,1,A[0],A[1]]),f.transform(...e.baseTransform),this.matrix&&f.transform(...this.matrix),Fb(f,this._bbox),f.fillStyle=this._createGradient(f),f.fill(),i=r.createPattern(s.canvas,"no-repeat");const l=new DOMMatrix(a);i.setTransform(l)}else Fb(r,this._bbox),i=this._createGradient(r);return i}}function Mb(r,e,a,t,i,A,n,o){const s=e.coords,f=e.colors,l=r.data,u=4*r.width;let c;s[a+1]>s[t+1]&&(c=a,a=t,t=c,c=A,A=n,n=c),s[t+1]>s[i+1]&&(c=t,t=i,i=c,c=n,n=o,o=c),s[a+1]>s[t+1]&&(c=a,a=t,t=c,c=A,A=n,n=c);const d=(s[a]+e.offsetX)*e.scaleX,h=(s[a+1]+e.offsetY)*e.scaleY,b=(s[t]+e.offsetX)*e.scaleX,g=(s[t+1]+e.offsetY)*e.scaleY,p=(s[i]+e.offsetX)*e.scaleX,v=(s[i+1]+e.offsetY)*e.scaleY;if(h>=v)return;const m=f[A],k=f[A+1],w=f[A+2],y=f[n],E=f[n+1],C=f[n+2],B=f[o],_=f[o+1],Z=f[o+2],W=Math.round(h),I=Math.round(v);let R,F,S,x,M,G,X,V;for(let r=W;r<=I;r++){if(r<g){const e=r<h?0:(h-r)/(h-g);R=d-(d-b)*e,F=m-(m-y)*e,S=k-(k-E)*e,x=w-(w-C)*e}else{let e;e=r>v?1:g===v?0:(g-r)/(g-v),R=b-(b-p)*e,F=y-(y-B)*e,S=E-(E-_)*e,x=C-(C-Z)*e}let e;e=r<h?0:r>v?1:(h-r)/(h-v),M=d-(d-p)*e,G=m-(m-B)*e,X=k-(k-_)*e,V=w-(w-Z)*e;const a=Math.round(Math.min(R,M)),t=Math.round(Math.max(R,M));let i=u*r+4*a;for(let r=a;r<=t;r++)e=(R-r)/(R-M),e<0?e=0:e>1&&(e=1),l[i++]=F-(F-G)*e|0,l[i++]=S-(S-X)*e|0,l[i++]=x-(x-V)*e|0,l[i++]=255}}function Gb(r,e,a){const t=e.coords,i=e.colors;let A,n;switch(e.type){case"lattice":const o=e.verticesPerRow,s=Math.floor(t.length/o)-1,f=o-1;for(A=0;A<s;A++){let e=A*o;for(let A=0;A<f;A++,e++)Mb(r,a,t[e],t[e+1],t[e+o],i[e],i[e+1],i[e+o]),Mb(r,a,t[e+o+1],t[e+1],t[e+o],i[e+o+1],i[e+1],i[e+o])}break;case"triangles":for(A=0,n=t.length;A<n;A+=3)Mb(r,a,t[A],t[A+1],t[A+2],i[A],i[A+1],i[A+2]);break;default:throw new Error("illegal figure")}}class Xb extends Sb{constructor(r){super(),this._coords=r[2],this._colors=r[3],this._figures=r[4],this._bounds=r[5],this._bbox=r[7],this._background=r[8],this.matrix=null}_createMeshCanvas(r,e,a){const t=Math.floor(this._bounds[0]),i=Math.floor(this._bounds[1]),A=Math.ceil(this._bounds[2])-t,n=Math.ceil(this._bounds[3])-i,o=Math.min(Math.ceil(Math.abs(A*r[0]*1.1)),3e3),s=Math.min(Math.ceil(Math.abs(n*r[1]*1.1)),3e3),f=A/o,l=n/s,u={coords:this._coords,colors:this._colors,offsetX:-t,offsetY:-i,scaleX:1/f,scaleY:1/l},c=o+4,d=s+4,h=a.getCanvas("mesh",c,d,!1),b=h.context,g=b.createImageData(o,s);if(e){const r=g.data;for(let a=0,t=r.length;a<t;a+=4)r[a]=e[0],r[a+1]=e[1],r[a+2]=e[2],r[a+3]=255}for(const r of this._figures)Gb(g,r,u);return b.putImageData(g,2,2),{canvas:h.canvas,offsetX:t-2*f,offsetY:i-2*l,scaleX:f,scaleY:l}}getPattern(r,e,a,t){let i;if(Fb(r,this._bbox),t===Rb)i=nl.singularValueDecompose2dScale(yu(r));else if(i=nl.singularValueDecompose2dScale(e.baseTransform),this.matrix){const r=nl.singularValueDecompose2dScale(this.matrix);i=[i[0]*r[0],i[1]*r[1]]}const A=this._createMeshCanvas(i,t===Rb?null:this._background,e.cachedCanvases);return t!==Rb&&(r.setTransform(...e.baseTransform),this.matrix&&r.transform(...this.matrix)),r.translate(A.offsetX,A.offsetY),r.scale(A.scaleX,A.scaleY),r.createPattern(A.canvas,"no-repeat")}}class Vb extends Sb{getPattern(){return"hotpink"}}const Nb=1,Db=2,Tb=class{constructor(r,e,a,t,i){this.operatorList=r[2],this.matrix=r[3],this.bbox=r[4],this.xstep=r[5],this.ystep=r[6],this.paintType=r[7],this.tilingType=r[8],this.color=e,this.ctx=a,this.canvasGraphicsFactory=t,this.baseTransform=i}createPatternCanvas(r){const e=this.operatorList,a=this.bbox,t=this.xstep,i=this.ystep,A=this.paintType,n=this.tilingType,o=this.color,s=this.canvasGraphicsFactory;Vf("TilingType: "+n);const f=a[0],l=a[1],u=a[2],c=a[3],d=nl.singularValueDecompose2dScale(this.matrix),h=nl.singularValueDecompose2dScale(this.baseTransform),b=[d[0]*h[0],d[1]*h[1]],g=this.getSizeAndScale(t,this.ctx.canvas.width,b[0]),p=this.getSizeAndScale(i,this.ctx.canvas.height,b[1]),v=r.cachedCanvases.getCanvas("pattern",g.size,p.size,!0),m=v.context,k=s.createCanvasGraphics(m);k.groupLevel=r.groupLevel,this.setFillAndStrokeStyleToContext(k,A,o);let w=f,y=l,E=u,C=c;return f<0&&(w=0,E+=Math.abs(f)),l<0&&(y=0,C+=Math.abs(l)),m.translate(-g.scale*w,-p.scale*y),k.transform(g.scale,0,0,p.scale,0,0),m.save(),this.clipBbox(k,w,y,E,C),k.baseTransform=yu(k.ctx),k.executeOperatorList(e),k.endDrawing(),{canvas:v.canvas,scaleX:g.scale,scaleY:p.scale,offsetX:w,offsetY:y}}getSizeAndScale(r,e,a){r=Math.abs(r);const t=Math.max(Tb.MAX_PATTERN_SIZE,e);let i=Math.ceil(r*a);return i>=t?i=t:a=i/r,{scale:a,size:i}}clipBbox(r,e,a,t,i){const A=t-e,n=i-a;r.ctx.rect(e,a,A,n),r.current.updateRectMinMax(yu(r.ctx),[e,a,t,i]),r.clip(),r.endPath()}setFillAndStrokeStyleToContext(r,e,a){const t=r.ctx,i=r.current;switch(e){case Nb:const r=this.ctx;t.fillStyle=r.fillStyle,t.strokeStyle=r.strokeStyle,i.fillColor=r.fillStyle,i.strokeColor=r.strokeStyle;break;case Db:const A=nl.makeHexColor(a[0],a[1],a[2]);t.fillStyle=A,t.strokeStyle=A,i.fillColor=A,i.strokeColor=A;break;default:throw new Jf(`Unsupported paint type: ${e}`)}}getPattern(r,e,a,t){let i=a;t!==Rb&&(i=nl.transform(i,e.baseTransform),this.matrix&&(i=nl.transform(i,this.matrix)));const A=this.createPatternCanvas(e);let n=new DOMMatrix(i);n=n.translate(A.offsetX,A.offsetY),n=n.scale(1/A.scaleX,1/A.scaleY);const o=r.createPattern(A.canvas,"repeat");return o.setTransform(n),o}};let Pb=Tb;function jb({src:r,srcPos:e=0,dest:a,width:t,height:i,nonBlackColor:A=4294967295,inverseDecode:n=!1}){const o=rl.isLittleEndian?4278190080:255,[s,f]=n?[A,o]:[o,A],l=t>>3,u=7&t,c=r.length;a=new Uint32Array(a.buffer);let d=0;for(let t=0;t<i;t++){for(const t=e+l;e<t;e++){const t=e<c?r[e]:255;a[d++]=128&t?f:s,a[d++]=64&t?f:s,a[d++]=32&t?f:s,a[d++]=16&t?f:s,a[d++]=8&t?f:s,a[d++]=4&t?f:s,a[d++]=2&t?f:s,a[d++]=1&t?f:s}if(0===u)continue;const t=e<c?r[e++]:255;for(let r=0;r<u;r++)a[d++]=t&1<<7-r?f:s}return{srcPos:e,destPos:d}}e(Pb,"MAX_PATTERN_SIZE",3e3);const Lb=16;class Ob{constructor(r){this.canvasFactory=r,this.cache=Object.create(null)}getCanvas(r,e,a){let t;return void 0!==this.cache[r]?(t=this.cache[r],this.canvasFactory.reset(t,e,a)):(t=this.canvasFactory.create(e,a),this.cache[r]=t),t}delete(r){delete this.cache[r]}clear(){for(const r in this.cache){const e=this.cache[r];this.canvasFactory.destroy(e),delete this.cache[r]}}}function Yb(r,e,a,t,i,A,n,o,s,f){const[l,u,c,d,h,b]=yu(r);if(0===u&&0===c){const g=n*l+h,p=Math.round(g),v=o*d+b,m=Math.round(v),k=(n+s)*l+h,w=Math.abs(Math.round(k)-p)||1,y=(o+f)*d+b,E=Math.abs(Math.round(y)-m)||1;return r.setTransform(Math.sign(l),0,0,Math.sign(d),p,m),r.drawImage(e,a,t,i,A,0,0,w,E),r.setTransform(l,u,c,d,h,b),[w,E]}if(0===l&&0===d){const g=o*c+h,p=Math.round(g),v=n*u+b,m=Math.round(v),k=(o+f)*c+h,w=Math.abs(Math.round(k)-p)||1,y=(n+s)*u+b,E=Math.abs(Math.round(y)-m)||1;return r.setTransform(0,Math.sign(u),Math.sign(c),0,p,m),r.drawImage(e,a,t,i,A,0,0,E,w),r.setTransform(l,u,c,d,h,b),[E,w]}r.drawImage(e,a,t,i,A,n,o,s,f);return[Math.hypot(l,u)*s,Math.hypot(c,d)*f]}class Hb{constructor(r,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Ts,this.textMatrixScale=1,this.fontMatrix=Ps,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=rf,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,r,e])}clone(){const r=Object.create(this);return r.clipBox=this.clipBox.slice(),r}setCurrentPoint(r,e){this.x=r,this.y=e}updatePathMinMax(r,e,a){[e,a]=nl.applyTransform([e,a],r),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,a),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,a)}updateRectMinMax(r,e){const a=nl.applyTransform(e,r),t=nl.applyTransform(e.slice(2),r),i=nl.applyTransform([e[0],e[3]],r),A=nl.applyTransform([e[2],e[1]],r);this.minX=Math.min(this.minX,a[0],t[0],i[0],A[0]),this.minY=Math.min(this.minY,a[1],t[1],i[1],A[1]),this.maxX=Math.max(this.maxX,a[0],t[0],i[0],A[0]),this.maxY=Math.max(this.maxY,a[1],t[1],i[1],A[1])}updateScalingPathMinMax(r,e){nl.scaleMinMax(r,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(r,e,a,t,i,A,n,o,s,f){const l=nl.bezierBoundingBox(e,a,t,i,A,n,o,s,f);f||this.updateRectMinMax(r,l)}getPathBoundingBox(r=Wb,e=null){const a=[this.minX,this.minY,this.maxX,this.maxY];if(r===Ib){e||Df("Stroke bounding box must include transform.");const r=nl.singularValueDecompose2dScale(e),t=r[0]*this.lineWidth/2,i=r[1]*this.lineWidth/2;a[0]-=t,a[1]-=i,a[2]+=t,a[3]+=i}return a}updateClipFromPath(){const r=nl.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(r||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(r){this.clipBox=r,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(r=Wb,e=null){return nl.intersect(this.clipBox,this.getPathBoundingBox(r,e))}}function Qb(r,e){if(typeof ImageData<"u"&&e instanceof ImageData)return void r.putImageData(e,0,0);const a=e.height,t=e.width,i=a%Lb,A=(a-i)/Lb,n=0===i?A:A+1,o=r.createImageData(t,Lb);let s,f=0;const l=e.data,u=o.data;let c,d,h,b;if(e.kind===of.GRAYSCALE_1BPP){const e=l.byteLength,a=new Uint32Array(u.buffer,0,u.byteLength>>2),b=a.length,g=t+7>>3,p=4294967295,v=rl.isLittleEndian?4278190080:255;for(c=0;c<n;c++){for(h=c<A?Lb:i,s=0,d=0;d<h;d++){const r=e-f;let i=0;const A=r>g?t:8*r-7,n=-8&A;let o=0,u=0;for(;i<n;i+=8)u=l[f++],a[s++]=128&u?p:v,a[s++]=64&u?p:v,a[s++]=32&u?p:v,a[s++]=16&u?p:v,a[s++]=8&u?p:v,a[s++]=4&u?p:v,a[s++]=2&u?p:v,a[s++]=1&u?p:v;for(;i<A;i++)0===o&&(u=l[f++],o=128),a[s++]=u&o?p:v,o>>=1}for(;s<b;)a[s++]=0;r.putImageData(o,0,c*Lb)}}else if(e.kind===of.RGBA_32BPP){for(d=0,b=t*Lb*4,c=0;c<A;c++)u.set(l.subarray(f,f+b)),f+=b,r.putImageData(o,0,d),d+=Lb;c<n&&(b=t*i*4,u.set(l.subarray(f,f+b)),r.putImageData(o,0,d))}else{if(e.kind!==of.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(h=Lb,b=t*h,c=0;c<n;c++){for(c>=A&&(h=i,b=t*h),s=0,d=b;d--;)u[s++]=l[f++],u[s++]=l[f++],u[s++]=l[f++],u[s++]=255;r.putImageData(o,0,c*Lb)}}}function Ub(r,e){if(e.bitmap)return void r.drawImage(e.bitmap,0,0);const a=e.height,t=e.width,i=a%Lb,A=(a-i)/Lb,n=0===i?A:A+1,o=r.createImageData(t,Lb);let s=0;const f=e.data,l=o.data;for(let e=0;e<n;e++){const a=e<A?Lb:i;({srcPos:s}=jb({src:f,srcPos:s,dest:l,width:t,height:a,nonBlackColor:0})),r.putImageData(o,0,e*Lb)}}function Jb(r,e){const a=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const t of a)void 0!==r[t]&&(e[t]=r[t]);void 0!==r.setLineDash&&(e.setLineDash(r.getLineDash()),e.lineDashOffset=r.lineDashOffset)}function zb(r){if(r.strokeStyle=r.fillStyle="#000000",r.fillRule="nonzero",r.globalAlpha=1,r.lineWidth=1,r.lineCap="butt",r.lineJoin="miter",r.miterLimit=10,r.globalCompositeOperation="source-over",r.font="10px sans-serif",void 0!==r.setLineDash&&(r.setLineDash([]),r.lineDashOffset=0),!Ds){const{filter:e}=r;"none"!==e&&""!==e&&(r.filter="none")}}function qb(r,e){if(e)return!0;const a=nl.singularValueDecompose2dScale(r);a[0]=Math.fround(a[0]),a[1]=Math.fround(a[1]);const t=Math.fround((globalThis.devicePixelRatio||1)*Il.PDF_TO_CSS_UNITS);return a[0]<=t&&a[1]<=t}const $b=["butt","round","square"],Kb=["miter","round","bevel"],rg={},eg={};var ag,tg,ig,Ag;const ng=class{constructor(r,e,a,t,A,{optionalContentConfig:n,markedContentStack:o=null},s,f){i(this,ag),i(this,ig),this.ctx=r,this.current=new Hb(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=a,this.canvasFactory=t,this.filterFactory=A,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=n,this.cachedCanvases=new Ob(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=f,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(r,e=null){return"string"==typeof r?r.startsWith("g_")?this.commonObjs.get(r):this.objs.get(r):e}beginDrawing({transform:r,viewport:e,transparency:a=!1,background:t=null}){const i=this.ctx.canvas.width,A=this.ctx.canvas.height,n=this.ctx.fillStyle;if(this.ctx.fillStyle=t||"#ffffff",this.ctx.fillRect(0,0,i,A),this.ctx.fillStyle=n,a){const r=this.cachedCanvases.getCanvas("transparent",i,A);this.compositeCtx=this.ctx,this.transparentCanvas=r.canvas,this.ctx=r.context,this.ctx.save(),this.ctx.transform(...yu(this.compositeCtx))}this.ctx.save(),zb(this.ctx),r&&(this.ctx.transform(...r),this.outputScaleX=r[0],this.outputScaleY=r[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=yu(this.ctx)}executeOperatorList(r,e,a,t){const i=r.argsArray,A=r.fnArray;let n=e||0;const o=i.length;if(o===n)return n;const s=o-n>10&&"function"==typeof a,f=s?Date.now()+15:0;let l=0;const u=this.commonObjs,c=this.objs;let d;for(;;){if(void 0!==t&&n===t.nextBreakPoint)return t.breakIt(n,a),n;if(d=A[n],d!==xf.dependency)this[d].apply(this,i[n]);else for(const r of i[n]){const e=r.startsWith("g_")?u:c;if(!e.has(r))return e.get(r,a),n}if(n++,n===o)return n;if(s&&++l>10){if(Date.now()>f)return a(),n;l=0}}}endDrawing(){o(this,ag,tg).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const r of this._cachedBitmapsMap.values()){for(const e of r.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);r.clear()}this._cachedBitmapsMap.clear(),o(this,ig,Ag).call(this)}_scaleImage(r,e){const a=r.width,t=r.height;let i,A,n=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),s=a,f=t,l="prescale1";for(;n>2&&s>1||o>2&&f>1;){let e=s,a=f;n>2&&s>1&&(e=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s/2),n/=s/e),o>2&&f>1&&(a=f>=16384?Math.floor(f/2)-1||1:Math.ceil(f)/2,o/=f/a),i=this.cachedCanvases.getCanvas(l,e,a),A=i.context,A.clearRect(0,0,e,a),A.drawImage(r,0,0,s,f,0,0,e,a),r=i.canvas,s=e,f=a,l="prescale1"===l?"prescale2":"prescale1"}return{img:r,paintWidth:s,paintHeight:f}}_createMaskCanvas(r){const e=this.ctx,{width:a,height:t}=r,i=this.current.fillColor,A=this.current.patternFill,n=yu(e);let o,s,f,l;if((r.bitmap||r.data)&&r.count>1){const e=r.bitmap||r.data.buffer;s=JSON.stringify(A?n:[n.slice(0,4),i]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const a=o.get(s);if(a&&!A){return{canvas:a,offsetX:Math.round(Math.min(n[0],n[2])+n[4]),offsetY:Math.round(Math.min(n[1],n[3])+n[5])}}f=a}f||(l=this.cachedCanvases.getCanvas("maskCanvas",a,t),Ub(l.context,r));let u=nl.transform(n,[1/a,0,0,-1/t,0,0]);u=nl.transform(u,[1,0,0,1,0,-t]);const[c,d,h,b]=nl.getAxialAlignedBoundingBox([0,0,a,t],u),g=Math.round(h-c)||1,p=Math.round(b-d)||1,v=this.cachedCanvases.getCanvas("fillCanvas",g,p),m=v.context,k=c,w=d;m.translate(-k,-w),m.transform(...u),f||(f=this._scaleImage(l.canvas,Eu(m)),f=f.img,o&&A&&o.set(s,f)),m.imageSmoothingEnabled=qb(yu(m),r.interpolate),Yb(m,f,0,0,f.width,f.height,0,0,a,t),m.globalCompositeOperation="source-in";const y=nl.transform(Eu(m),[1,0,0,1,-k,-w]);return m.fillStyle=A?i.getPattern(e,this,y,Wb):i,m.fillRect(0,0,a,t),o&&!A&&(this.cachedCanvases.delete("fillCanvas"),o.set(s,v.canvas)),{canvas:v.canvas,offsetX:Math.round(k),offsetY:Math.round(w)}}setLineWidth(r){r!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=r,this.ctx.lineWidth=r}setLineCap(r){this.ctx.lineCap=$b[r]}setLineJoin(r){this.ctx.lineJoin=Kb[r]}setMiterLimit(r){this.ctx.miterLimit=r}setDash(r,e){const a=this.ctx;void 0!==a.setLineDash&&(a.setLineDash(r),a.lineDashOffset=e)}setRenderingIntent(r){}setFlatness(r){}setGState(r){for(const[e,a]of r)switch(e){case"LW":this.setLineWidth(a);break;case"LC":this.setLineCap(a);break;case"LJ":this.setLineJoin(a);break;case"ML":this.setMiterLimit(a);break;case"D":this.setDash(a[0],a[1]);break;case"RI":this.setRenderingIntent(a);break;case"FL":this.setFlatness(a);break;case"Font":this.setFont(a[0],a[1]);break;case"CA":this.current.strokeAlpha=a;break;case"ca":this.current.fillAlpha=a,this.ctx.globalAlpha=a;break;case"BM":this.ctx.globalCompositeOperation=a;break;case"SMask":this.current.activeSMask=a?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(a)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const r=this.inSMaskMode;this.current.activeSMask&&!r?this.beginSMaskMode():!this.current.activeSMask&&r&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const r=this.ctx.canvas.width,e=this.ctx.canvas.height,a="smaskGroupAt"+this.groupLevel,t=this.cachedCanvases.getCanvas(a,r,e);this.suspendedCtx=this.ctx,this.ctx=t.context;const i=this.ctx;i.setTransform(...yu(this.suspendedCtx)),Jb(this.suspendedCtx,i),function(r,e){if(r._removeMirroring)throw new Error("Context is already forwarding operations.");r.__originalSave=r.save,r.__originalRestore=r.restore,r.__originalRotate=r.rotate,r.__originalScale=r.scale,r.__originalTranslate=r.translate,r.__originalTransform=r.transform,r.__originalSetTransform=r.setTransform,r.__originalResetTransform=r.resetTransform,r.__originalClip=r.clip,r.__originalMoveTo=r.moveTo,r.__originalLineTo=r.lineTo,r.__originalBezierCurveTo=r.bezierCurveTo,r.__originalRect=r.rect,r.__originalClosePath=r.closePath,r.__originalBeginPath=r.beginPath,r._removeMirroring=()=>{r.save=r.__originalSave,r.restore=r.__originalRestore,r.rotate=r.__originalRotate,r.scale=r.__originalScale,r.translate=r.__originalTranslate,r.transform=r.__originalTransform,r.setTransform=r.__originalSetTransform,r.resetTransform=r.__originalResetTransform,r.clip=r.__originalClip,r.moveTo=r.__originalMoveTo,r.lineTo=r.__originalLineTo,r.bezierCurveTo=r.__originalBezierCurveTo,r.rect=r.__originalRect,r.closePath=r.__originalClosePath,r.beginPath=r.__originalBeginPath,delete r._removeMirroring},r.save=function(){e.save(),this.__originalSave()},r.restore=function(){e.restore(),this.__originalRestore()},r.translate=function(r,a){e.translate(r,a),this.__originalTranslate(r,a)},r.scale=function(r,a){e.scale(r,a),this.__originalScale(r,a)},r.transform=function(r,a,t,i,A,n){e.transform(r,a,t,i,A,n),this.__originalTransform(r,a,t,i,A,n)},r.setTransform=function(r,a,t,i,A,n){e.setTransform(r,a,t,i,A,n),this.__originalSetTransform(r,a,t,i,A,n)},r.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},r.rotate=function(r){e.rotate(r),this.__originalRotate(r)},r.clip=function(r){e.clip(r),this.__originalClip(r)},r.moveTo=function(r,a){e.moveTo(r,a),this.__originalMoveTo(r,a)},r.lineTo=function(r,a){e.lineTo(r,a),this.__originalLineTo(r,a)},r.bezierCurveTo=function(r,a,t,i,A,n){e.bezierCurveTo(r,a,t,i,A,n),this.__originalBezierCurveTo(r,a,t,i,A,n)},r.rect=function(r,a,t,i){e.rect(r,a,t,i),this.__originalRect(r,a,t,i)},r.closePath=function(){e.closePath(),this.__originalClosePath()},r.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(i,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Jb(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(r){if(!this.current.activeSMask)return;r?(r[0]=Math.floor(r[0]),r[1]=Math.floor(r[1]),r[2]=Math.ceil(r[2]),r[3]=Math.ceil(r[3])):r=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,a=this.suspendedCtx;this.composeSMask(a,e,this.ctx,r),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(r,e,a,t){const i=t[0],A=t[1],n=t[2]-i,o=t[3]-A;0===n||0===o||(this.genericComposeSMask(e.context,a,n,o,e.subtype,e.backdrop,e.transferMap,i,A,e.offsetX,e.offsetY),r.save(),r.globalAlpha=1,r.globalCompositeOperation="source-over",r.setTransform(1,0,0,1,0,0),r.drawImage(a.canvas,0,0),r.restore())}genericComposeSMask(r,e,a,t,i,A,n,o,s,f,l){let u=r.canvas,c=o-f,d=s-l;if(A)if(c<0||d<0||c+a>u.width||d+t>u.height){const r=this.cachedCanvases.getCanvas("maskExtension",a,t),e=r.context;e.drawImage(u,-c,-d),A.some((r=>0!==r))&&(e.globalCompositeOperation="destination-atop",e.fillStyle=nl.makeHexColor(...A),e.fillRect(0,0,a,t),e.globalCompositeOperation="source-over"),u=r.canvas,c=d=0}else if(A.some((r=>0!==r))){r.save(),r.globalAlpha=1,r.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(c,d,a,t),r.clip(e),r.globalCompositeOperation="destination-atop",r.fillStyle=nl.makeHexColor(...A),r.fillRect(c,d,a,t),r.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===i&&n?e.filter=this.filterFactory.addAlphaFilter(n):"Luminosity"===i&&(e.filter=this.filterFactory.addLuminosityFilter(n));const h=new Path2D;h.rect(o,s,a,t),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(u,c,d,a,t,o,s,a,t),e.restore()}save(){this.inSMaskMode?(Jb(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const r=this.current;this.stateStack.push(r),this.current=r.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Jb(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(r,e,a,t,i,A){this.ctx.transform(r,e,a,t,i,A),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(r,e,a){const t=this.ctx,i=this.current;let A,n,o=i.x,s=i.y;const f=yu(t),l=0===f[0]&&0===f[3]||0===f[1]&&0===f[2],u=l?a.slice(0):null;for(let a=0,c=0,d=r.length;a<d;a++)switch(0|r[a]){case xf.rectangle:o=e[c++],s=e[c++];const r=e[c++],a=e[c++],d=o+r,h=s+a;t.moveTo(o,s),0===r||0===a?t.lineTo(d,h):(t.lineTo(d,s),t.lineTo(d,h),t.lineTo(o,h)),l||i.updateRectMinMax(f,[o,s,d,h]),t.closePath();break;case xf.moveTo:o=e[c++],s=e[c++],t.moveTo(o,s),l||i.updatePathMinMax(f,o,s);break;case xf.lineTo:o=e[c++],s=e[c++],t.lineTo(o,s),l||i.updatePathMinMax(f,o,s);break;case xf.curveTo:A=o,n=s,o=e[c+4],s=e[c+5],t.bezierCurveTo(e[c],e[c+1],e[c+2],e[c+3],o,s),i.updateCurvePathMinMax(f,A,n,e[c],e[c+1],e[c+2],e[c+3],o,s,u),c+=6;break;case xf.curveTo2:A=o,n=s,t.bezierCurveTo(o,s,e[c],e[c+1],e[c+2],e[c+3]),i.updateCurvePathMinMax(f,A,n,o,s,e[c],e[c+1],e[c+2],e[c+3],u),o=e[c+2],s=e[c+3],c+=4;break;case xf.curveTo3:A=o,n=s,o=e[c+2],s=e[c+3],t.bezierCurveTo(e[c],e[c+1],o,s,o,s),i.updateCurvePathMinMax(f,A,n,e[c],e[c+1],o,s,o,s,u),c+=4;break;case xf.closePath:t.closePath()}l&&i.updateScalingPathMinMax(f,u),i.setCurrentPoint(o,s)}closePath(){this.ctx.closePath()}stroke(r=!0){const e=this.ctx,a=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof a&&null!=a&&a.getPattern?(e.save(),e.strokeStyle=a.getPattern(e,this,Eu(e),Ib),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),r&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(r=!0){const e=this.ctx,a=this.current.fillColor;let t=!1;this.current.patternFill&&(e.save(),e.fillStyle=a.getPattern(e,this,Eu(e),Wb),t=!0);const i=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==i&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),t&&e.restore(),r&&this.consumePath(i)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=rg}eoClip(){this.pendingClip=eg}beginText(){this.current.textMatrix=Ts,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const r=this.pendingTextPaths,e=this.ctx;if(void 0!==r){e.save(),e.beginPath();for(const a of r)e.setTransform(...a.transform),e.translate(a.x,a.y),a.addToPath(e,a.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(r){this.current.charSpacing=r}setWordSpacing(r){this.current.wordSpacing=r}setHScale(r){this.current.textHScale=r/100}setLeading(r){this.current.leading=-r}setFont(r,e){var a;const t=this.commonObjs.get(r),i=this.current;if(!t)throw new Error(`Can't find font for ${r}`);if(i.fontMatrix=t.fontMatrix||Ps,(0===i.fontMatrix[0]||0===i.fontMatrix[3])&&Nf("Invalid font matrix for font "+r),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=t,this.current.fontSize=e,t.isType3Font)return;const A=t.loadedName||"sans-serif",n=(null==(a=t.systemFontInfo)?void 0:a.css)||`"${A}", ${t.fallbackName}`;let o="normal";t.black?o="900":t.bold&&(o="bold");const s=t.italic?"italic":"normal";let f=e;e<16?f=16:e>100&&(f=100),this.current.fontSizeScale=e/f,this.ctx.font=`${s} ${o} ${f}px ${n}`}setTextRenderingMode(r){this.current.textRenderingMode=r}setTextRise(r){this.current.textRise=r}moveText(r,e){this.current.x=this.current.lineX+=r,this.current.y=this.current.lineY+=e}setLeadingMoveText(r,e){this.setLeading(-e),this.moveText(r,e)}setTextMatrix(r,e,a,t,i,A){this.current.textMatrix=[r,e,a,t,i,A],this.current.textMatrixScale=Math.hypot(r,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(r,e,a,t){const i=this.ctx,A=this.current,n=A.font,o=A.textRenderingMode,s=A.fontSize/A.fontSizeScale,f=o&Af,l=!!(o&nf),u=A.patternFill&&!n.missingFile;let c;(n.disableFontFace||l||u)&&(c=n.getPathGenerator(this.commonObjs,r)),n.disableFontFace||u?(i.save(),i.translate(e,a),i.beginPath(),c(i,s),t&&i.setTransform(...t),(f===rf||f===af)&&i.fill(),(f===ef||f===af)&&i.stroke(),i.restore()):((f===rf||f===af)&&i.fillText(r,e,a),(f===ef||f===af)&&i.strokeText(r,e,a)),l&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:yu(i),x:e,y:a,fontSize:s,addToPath:c})}get isFontSubpixelAAEnabled(){const{context:r}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);r.scale(1.5,1),r.fillText("I",0,10);const e=r.getImageData(0,0,10,10).data;let a=!1;for(let r=3;r<e.length;r+=4)if(e[r]>0&&e[r]<255){a=!0;break}return jf(this,"isFontSubpixelAAEnabled",a)}showText(r){const e=this.current,a=e.font;if(a.isType3Font)return this.showType3Text(r);const t=e.fontSize;if(0===t)return;const i=this.ctx,A=e.fontSizeScale,n=e.charSpacing,o=e.wordSpacing,s=e.fontDirection,f=e.textHScale*s,l=r.length,u=a.vertical,c=u?1:-1,d=a.defaultVMetrics,h=t*e.fontMatrix[0],b=e.textRenderingMode===rf&&!a.disableFontFace&&!e.patternFill;let g;if(i.save(),i.transform(...e.textMatrix),i.translate(e.x,e.y+e.textRise),s>0?i.scale(f,-1):i.scale(f,1),e.patternFill){i.save();const r=e.fillColor.getPattern(i,this,Eu(i),Wb);g=yu(i),i.restore(),i.fillStyle=r}let p=e.lineWidth;const v=e.textMatrixScale;if(0===v||0===p){const r=e.textRenderingMode&Af;(r===ef||r===af)&&(p=this.getSinglePixelWidth())}else p/=v;if(1!==A&&(i.scale(A,A),p/=A),i.lineWidth=p,a.isInvalidPDFjsFont){const a=[];let t=0;for(const e of r)a.push(e.unicode),t+=e.width;return i.fillText(a.join(""),0,0),e.x+=t*h*f,i.restore(),void this.compose()}let m,k=0;for(m=0;m<l;++m){const e=r[m];if("number"==typeof e){k+=c*e*t/1e3;continue}let f=!1;const l=(e.isSpace?o:0)+n,p=e.fontChar,v=e.accent;let w,y,E=e.width;if(u){const r=e.vmetric||d,a=-(e.vmetric?r[1]:.5*E)*h,t=r[2]*h;E=r?-r[0]:E,w=a/A,y=(k+t)/A}else w=k/A,y=0;if(a.remeasure&&E>0){const r=1e3*i.measureText(p).width/t*A;if(E<r&&this.isFontSubpixelAAEnabled){const e=E/r;f=!0,i.save(),i.scale(e,1),w/=e}else E!==r&&(w+=(E-r)/2e3*t/A)}if(this.contentVisible&&(e.isInFont||a.missingFile))if(b&&!v)i.fillText(p,w,y);else if(this.paintChar(p,w,y,g),v){const r=w+t*v.offset.x/A,e=y-t*v.offset.y/A;this.paintChar(v.fontChar,r,e,g)}k+=u?E*h-l*s:E*h+l*s,f&&i.restore()}u?e.y-=k:e.x+=k*f,i.restore(),this.compose()}showType3Text(r){const e=this.ctx,a=this.current,t=a.font,i=a.fontSize,A=a.fontDirection,n=t.vertical?1:-1,o=a.charSpacing,s=a.wordSpacing,f=a.textHScale*A,l=a.fontMatrix||Ps,u=r.length;let c,d,h,b;if(!(a.textRenderingMode===tf)&&0!==i){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...a.textMatrix),e.translate(a.x,a.y),e.scale(f,A),c=0;c<u;++c){if(d=r[c],"number"==typeof d){b=n*d*i/1e3,this.ctx.translate(b,0),a.x+=b*f;continue}const A=(d.isSpace?s:0)+o,u=t.charProcOperatorList[d.operatorListId];u?(this.contentVisible&&(this.processingType3=d,this.save(),e.scale(i,i),e.transform(...l),this.executeOperatorList(u),this.restore()),h=nl.applyTransform([d.width,0],l)[0]*i+A,e.translate(h,0),a.x+=h*f):Nf(`Type3 character "${d.operatorListId}" is not available.`)}e.restore(),this.processingType3=null}}setCharWidth(r,e){}setCharWidthAndBounds(r,e,a,t,i,A){this.ctx.rect(a,t,i-a,A-t),this.ctx.clip(),this.endPath()}getColorN_Pattern(r){let e;if("TilingPattern"===r[0]){const a=r[1],t=this.baseTransform||yu(this.ctx),i={createCanvasGraphics:r=>new ng(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Pb(r,a,this.ctx,i,t)}else e=this._getPattern(r[1],r[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(r,e,a){const t=nl.makeHexColor(r,e,a);this.ctx.strokeStyle=t,this.current.strokeColor=t}setFillRGBColor(r,e,a){const t=nl.makeHexColor(r,e,a);this.ctx.fillStyle=t,this.current.fillColor=t,this.current.patternFill=!1}_getPattern(r,e=null){let a;return this.cachedPatterns.has(r)?a=this.cachedPatterns.get(r):(a=function(r){switch(r[0]){case"RadialAxial":return new xb(r);case"Mesh":return new Xb(r);case"Dummy":return new Vb}throw new Error(`Unknown IR type: ${r[0]}`)}(this.getObject(r)),this.cachedPatterns.set(r,a)),e&&(a.matrix=e),a}shadingFill(r){if(!this.contentVisible)return;const e=this.ctx;this.save();const a=this._getPattern(r);e.fillStyle=a.getPattern(e,this,Eu(e),Rb);const t=Eu(e);if(t){const{width:r,height:a}=e.canvas,[i,A,n,o]=nl.getAxialAlignedBoundingBox([0,0,r,a],t);this.ctx.fillRect(i,A,n-i,o-A)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Df("Should not call beginInlineImage")}beginImageData(){Df("Should not call beginImageData")}paintFormXObjectBegin(r,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),r&&this.transform(...r),this.baseTransform=yu(this.ctx),e)){const r=e[2]-e[0],a=e[3]-e[1];this.ctx.rect(e[0],e[1],r,a),this.current.updateRectMinMax(yu(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(r){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;r.isolated||Vf("TODO: Support non-isolated groups."),r.knockout&&Nf("Knockout groups not supported.");const a=yu(e);if(r.matrix&&e.transform(...r.matrix),!r.bbox)throw new Error("Bounding box is required.");let t=nl.getAxialAlignedBoundingBox(r.bbox,yu(e));const i=[0,0,e.canvas.width,e.canvas.height];t=nl.intersect(t,i)||[0,0,0,0];const A=Math.floor(t[0]),n=Math.floor(t[1]),o=Math.max(Math.ceil(t[2])-A,1),s=Math.max(Math.ceil(t[3])-n,1);this.current.startNewPathAndClipBox([0,0,o,s]);let f="groupAt"+this.groupLevel;r.smask&&(f+="_smask_"+this.smaskCounter++%2);const l=this.cachedCanvases.getCanvas(f,o,s),u=l.context;u.translate(-A,-n),u.transform(...a),r.smask?this.smaskStack.push({canvas:l.canvas,context:u,offsetX:A,offsetY:n,subtype:r.smask.subtype,backdrop:r.smask.backdrop,transferMap:r.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(A,n),e.save()),Jb(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(r){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,a=this.groupStack.pop();if(this.ctx=a,this.ctx.imageSmoothingEnabled=!1,r.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const r=yu(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);const a=nl.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],r);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(r,e,a,t,i){if(o(this,ag,tg).call(this),zb(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const t=e[2]-e[0],A=e[3]-e[1];if(i&&this.annotationCanvasMap){(a=a.slice())[4]-=e[0],a[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=t,e[3]=A;const[i,n]=nl.singularValueDecompose2dScale(yu(this.ctx)),{viewportScale:o}=this,s=Math.ceil(t*this.outputScaleX*o),f=Math.ceil(A*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(s,f);const{canvas:l,context:u}=this.annotationCanvas;this.annotationCanvasMap.set(r,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=u,this.ctx.save(),this.ctx.setTransform(i,0,0,-n,0,A*n),zb(this.ctx)}else zb(this.ctx),this.ctx.rect(e[0],e[1],t,A),this.ctx.clip(),this.endPath()}this.current=new Hb(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...a),this.transform(...t)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),o(this,ig,Ag).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(r){if(!this.contentVisible)return;const e=r.count;(r=this.getObject(r.data,r)).count=e;const a=this.ctx,t=this.processingType3;if(t&&(void 0===t.compiled&&(t.compiled=function(r){const{width:e,height:a}=r;if(e>1e3||a>1e3)return null;const t=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),i=e+1;let A,n,o,s=new Uint8Array(i*(a+1));const f=e+7&-8;let l=new Uint8Array(f*a),u=0;for(const e of r.data){let r=128;for(;r>0;)l[u++]=e&r?0:255,r>>=1}let c=0;for(u=0,0!==l[u]&&(s[0]=1,++c),n=1;n<e;n++)l[u]!==l[u+1]&&(s[n]=l[u]?2:1,++c),u++;for(0!==l[u]&&(s[n]=2,++c),A=1;A<a;A++){u=A*f,o=A*i,l[u-f]!==l[u]&&(s[o]=l[u]?1:8,++c);let r=(l[u]?4:0)+(l[u-f]?8:0);for(n=1;n<e;n++)r=(r>>2)+(l[u+1]?4:0)+(l[u-f+1]?8:0),t[r]&&(s[o+n]=t[r],++c),u++;if(l[u-f]!==l[u]&&(s[o+n]=l[u]?2:4,++c),c>1e3)return null}for(u=f*(a-1),o=A*i,0!==l[u]&&(s[o]=8,++c),n=1;n<e;n++)l[u]!==l[u+1]&&(s[o+n]=l[u]?4:8,++c),u++;if(0!==l[u]&&(s[o+n]=4,++c),c>1e3)return null;const d=new Int32Array([0,i,-1,0,-i,0,0,0,1]),h=new Path2D;for(A=0;c&&A<=a;A++){let r=A*i;const a=r+e;for(;r<a&&!s[r];)r++;if(r===a)continue;h.moveTo(r%i,A);const t=r;let n=s[r];do{const e=d[n];do{r+=e}while(!s[r]);const a=s[r];5!==a&&10!==a?(n=a,s[r]=0):(n=a&51*n>>4,s[r]&=n>>2|n<<2),h.lineTo(r%i,r/i|0),s[r]||--c}while(t!==r);--A}return l=null,s=null,function(r){r.save(),r.scale(1/e,-1/a),r.translate(0,-a),r.fill(h),r.beginPath(),r.restore()}}(r)),t.compiled))return void t.compiled(a);const i=this._createMaskCanvas(r),A=i.canvas;a.save(),a.setTransform(1,0,0,1,0,0),a.drawImage(A,i.offsetX,i.offsetY),a.restore(),this.compose()}paintImageMaskXObjectRepeat(r,e,a=0,t=0,i,A){if(!this.contentVisible)return;r=this.getObject(r.data,r);const n=this.ctx;n.save();const o=yu(n);n.transform(e,a,t,i,0,0);const s=this._createMaskCanvas(r);n.setTransform(1,0,0,1,s.offsetX-o[4],s.offsetY-o[5]);for(let r=0,f=A.length;r<f;r+=2){const f=nl.transform(o,[e,a,t,i,A[r],A[r+1]]),[l,u]=nl.applyTransform([0,0],f);n.drawImage(s.canvas,l,u)}n.restore(),this.compose()}paintImageMaskXObjectGroup(r){if(!this.contentVisible)return;const e=this.ctx,a=this.current.fillColor,t=this.current.patternFill;for(const i of r){const{data:r,width:A,height:n,transform:o}=i,s=this.cachedCanvases.getCanvas("maskCanvas",A,n),f=s.context;f.save();Ub(f,this.getObject(r,i)),f.globalCompositeOperation="source-in",f.fillStyle=t?a.getPattern(f,this,Eu(e),Wb):a,f.fillRect(0,0,A,n),f.restore(),e.save(),e.transform(...o),e.scale(1,-1),Yb(e,s.canvas,0,0,A,n,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(r){if(!this.contentVisible)return;const e=this.getObject(r);e?this.paintInlineImageXObject(e):Nf("Dependent image isn't ready yet")}paintImageXObjectRepeat(r,e,a,t){if(!this.contentVisible)return;const i=this.getObject(r);if(!i)return void Nf("Dependent image isn't ready yet");const A=i.width,n=i.height,o=[];for(let r=0,i=t.length;r<i;r+=2)o.push({transform:[e,0,0,a,t[r],t[r+1]],x:0,y:0,w:A,h:n});this.paintInlineImageXObjectGroup(i,o)}applyTransferMapsToCanvas(r){return"none"!==this.current.transferMaps&&(r.filter=this.current.transferMaps,r.drawImage(r.canvas,0,0),r.filter="none"),r.canvas}applyTransferMapsToBitmap(r){if("none"===this.current.transferMaps)return r.bitmap;const{bitmap:e,width:a,height:t}=r,i=this.cachedCanvases.getCanvas("inlineImage",a,t),A=i.context;return A.filter=this.current.transferMaps,A.drawImage(e,0,0),A.filter="none",i.canvas}paintInlineImageXObject(r){if(!this.contentVisible)return;const e=r.width,a=r.height,t=this.ctx;if(this.save(),!Ds){const{filter:r}=t;"none"!==r&&""!==r&&(t.filter="none")}let i;if(t.scale(1/e,-1/a),r.bitmap)i=this.applyTransferMapsToBitmap(r);else if("function"==typeof HTMLElement&&r instanceof HTMLElement||!r.data)i=r;else{const t=this.cachedCanvases.getCanvas("inlineImage",e,a).context;Qb(t,r),i=this.applyTransferMapsToCanvas(t)}const A=this._scaleImage(i,Eu(t));t.imageSmoothingEnabled=qb(yu(t),r.interpolate),Yb(t,A.img,0,0,A.paintWidth,A.paintHeight,0,-a,e,a),this.compose(),this.restore()}paintInlineImageXObjectGroup(r,e){if(!this.contentVisible)return;const a=this.ctx;let t;if(r.bitmap)t=r.bitmap;else{const e=r.width,a=r.height,i=this.cachedCanvases.getCanvas("inlineImage",e,a).context;Qb(i,r),t=this.applyTransferMapsToCanvas(i)}for(const r of e)a.save(),a.transform(...r.transform),a.scale(1,-1),Yb(a,t,r.x,r.y,r.w,r.h,0,-1,1,1),a.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(r){}markPointProps(r,e){}beginMarkedContent(r){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(r,e){"OC"===r?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(r){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(r);const a=this.ctx;this.pendingClip&&(e||(this.pendingClip===eg?a.clip("evenodd"):a.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),a.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const r=yu(this.ctx);if(0===r[1]&&0===r[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(r[0]),Math.abs(r[3]));else{const e=Math.abs(r[0]*r[3]-r[2]*r[1]),a=Math.hypot(r[0],r[2]),t=Math.hypot(r[1],r[3]);this._cachedGetSinglePixelWidth=Math.max(a,t)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:r}=this.current,{a:e,b:a,c:t,d:i}=this.ctx.getTransform();let A,n;if(0===a&&0===t){const a=Math.abs(e),t=Math.abs(i);if(a===t)if(0===r)A=n=1/a;else{const e=a*r;A=n=e<1?1/e:1}else if(0===r)A=1/a,n=1/t;else{const e=a*r,i=t*r;A=e<1?1/e:1,n=i<1?1/i:1}}else{const o=Math.abs(e*i-a*t),s=Math.hypot(e,a),f=Math.hypot(t,i);if(0===r)A=f/o,n=s/o;else{const e=r*o;A=f>e?f/e:1,n=s>e?s/e:1}}this._cachedScaleForStroking[0]=A,this._cachedScaleForStroking[1]=n}return this._cachedScaleForStroking}rescaleAndStroke(r){const{ctx:e}=this,{lineWidth:a}=this.current,[t,i]=this.getScaleForStroking();if(e.lineWidth=a||1,1===t&&1===i)return void e.stroke();const A=e.getLineDash();if(r&&e.save(),e.scale(t,i),A.length>0){const r=Math.max(t,i);e.setLineDash(A.map((e=>e/r))),e.lineDashOffset/=r}e.stroke(),r&&e.restore()}isContentVisible(){for(let r=this.markedContentStack.length-1;r>=0;r--)if(!this.markedContentStack[r].visible)return!1;return!0}};let og=ng;ag=new WeakSet,tg=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();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)},ig=new WeakSet,Ag=function(){if(this.pageColors){const r=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==r){const e=this.ctx.filter;this.ctx.filter=r,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}};for(const r in xf)void 0!==og.prototype[r]&&(og.prototype[xf[r]]=og.prototype[r]);var sg,fg;class lg{static get workerPort(){return t(this,sg)}static set workerPort(r){if(!(typeof Worker<"u"&&r instanceof Worker)&&null!==r)throw new Error("Invalid `workerPort` type.");A(this,sg,r)}static get workerSrc(){return t(this,fg)}static set workerSrc(r){if("string"!=typeof r)throw new Error("Invalid `workerSrc` type.");A(this,fg,r)}}sg=new WeakMap,fg=new WeakMap,i(lg,sg,null),i(lg,fg,"");const ug=1,cg=2,dg=1,hg=2,bg=3,gg=4,pg=5,vg=6,mg=7,kg=8;function wg(r){switch(r instanceof Error||"object"==typeof r&&null!==r||Df('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),r.name){case"AbortException":return new zf(r.message);case"MissingPDFException":return new Qf(r.message);case"PasswordException":return new Of(r.message,r.code);case"UnexpectedResponseException":return new Uf(r.message,r.status);case"UnknownErrorException":return new Yf(r.message,r.details);default:return new Yf(r.message,r.toString())}}var yg,Eg,Cg,Bg,_g,Zg,Wg,Ig;class Rg{constructor(r,e,a){i(this,yg),i(this,Cg),i(this,_g),this.sourceName=r,this.targetName=e,this.comObj=a,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),this._onComObjOnMessage=r=>{const e=r.data;if(e.targetName!==this.sourceName)return;if(e.stream)return void o(this,Cg,Bg).call(this,e);if(e.callback){const r=e.callbackId,a=this.callbackCapabilities[r];if(!a)throw new Error(`Cannot resolve callback ${r}`);if(delete this.callbackCapabilities[r],e.callback===ug)a.resolve(e.data);else{if(e.callback!==cg)throw new Error("Unexpected callback case");a.reject(wg(e.reason))}return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const r=this.sourceName,i=e.sourceName;new Promise((function(r){r(t(e.data))})).then((function(t){a.postMessage({sourceName:r,targetName:i,callback:ug,callbackId:e.callbackId,data:t})}),(function(t){a.postMessage({sourceName:r,targetName:i,callback:cg,callbackId:e.callbackId,reason:wg(t)})}))}else e.streamId?o(this,yg,Eg).call(this,e):t(e.data)},a.addEventListener("message",this._onComObjOnMessage)}on(r,e){const a=this.actionHandler;if(a[r])throw new Error(`There is already an actionName called "${r}"`);a[r]=e}send(r,e,a){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:r,data:e},a)}sendWithPromise(r,e,a){const t=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[t]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:r,callbackId:t,data:e},a)}catch(r){i.reject(r)}return i.promise}sendWithStream(r,e,a,t){const i=this.streamId++,A=this.sourceName,n=this.targetName,o=this.comObj;return new ReadableStream({start:a=>{const s=Promise.withResolvers();return this.streamControllers[i]={controller:a,startCall:s,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:A,targetName:n,action:r,streamId:i,data:e,desiredSize:a.desiredSize},t),s.promise},pull:r=>{const e=Promise.withResolvers();return this.streamControllers[i].pullCall=e,o.postMessage({sourceName:A,targetName:n,stream:vg,streamId:i,desiredSize:r.desiredSize}),e.promise},cancel:r=>{Tf(r instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[i].cancelCall=e,this.streamControllers[i].isClosed=!0,o.postMessage({sourceName:A,targetName:n,stream:dg,streamId:i,reason:wg(r)}),e.promise}},a)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}yg=new WeakSet,Eg=function(r){const e=r.streamId,a=this.sourceName,t=r.sourceName,i=this.comObj,A=this,n=this.actionHandler[r.action],o={enqueue(r,A=1,n){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=A,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:a,targetName:t,stream:gg,streamId:e,chunk:r},n)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:a,targetName:t,stream:bg,streamId:e}),delete A.streamSinks[e])},error(r){Tf(r instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:a,targetName:t,stream:pg,streamId:e,reason:wg(r)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:r.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise((function(e){e(n(r.data,o))})).then((function(){i.postMessage({sourceName:a,targetName:t,stream:kg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:kg,streamId:e,reason:wg(r)})}))},Cg=new WeakSet,Bg=function(r){const e=r.streamId,a=this.sourceName,t=r.sourceName,i=this.comObj,A=this.streamControllers[e],n=this.streamSinks[e];switch(r.stream){case kg:r.success?A.startCall.resolve():A.startCall.reject(wg(r.reason));break;case mg:r.success?A.pullCall.resolve():A.pullCall.reject(wg(r.reason));break;case vg:if(!n){i.postMessage({sourceName:a,targetName:t,stream:mg,streamId:e,success:!0});break}n.desiredSize<=0&&r.desiredSize>0&&n.sinkCapability.resolve(),n.desiredSize=r.desiredSize,new Promise((function(r){var e;r(null==(e=n.onPull)?void 0:e.call(n))})).then((function(){i.postMessage({sourceName:a,targetName:t,stream:mg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:mg,streamId:e,reason:wg(r)})}));break;case gg:if(Tf(A,"enqueue should have stream controller"),A.isClosed)break;A.controller.enqueue(r.chunk);break;case bg:if(Tf(A,"close should have stream controller"),A.isClosed)break;A.isClosed=!0,A.controller.close(),o(this,_g,Zg).call(this,A,e);break;case pg:Tf(A,"error should have stream controller"),A.controller.error(wg(r.reason)),o(this,_g,Zg).call(this,A,e);break;case hg:r.success?A.cancelCall.resolve():A.cancelCall.reject(wg(r.reason)),o(this,_g,Zg).call(this,A,e);break;case dg:if(!n)break;new Promise((function(e){var a;e(null==(a=n.onCancel)?void 0:a.call(n,wg(r.reason)))})).then((function(){i.postMessage({sourceName:a,targetName:t,stream:hg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:hg,streamId:e,reason:wg(r)})})),n.sinkCapability.reject(wg(r.reason)),n.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},_g=new WeakSet,Zg=async function(r,e){var a,t,i;await Promise.allSettled([null==(a=r.startCall)?void 0:a.promise,null==(t=r.pullCall)?void 0:t.promise,null==(i=r.cancelCall)?void 0:i.promise]),delete this.streamControllers[e]};class Fg{constructor({parsedData:r,rawData:e}){i(this,Wg,void 0),i(this,Ig,void 0),A(this,Wg,r),A(this,Ig,e)}getRaw(){return t(this,Ig)}get(r){return t(this,Wg).get(r)??null}getAll(){return Kf(t(this,Wg))}has(r){return t(this,Wg).has(r)}}Wg=new WeakMap,Ig=new WeakMap;const Sg=Symbol("INTERNAL");var xg,Mg,Gg,Xg,Vg,Ng,Dg,Tg,Pg,jg;class Lg{constructor(r,{name:e,intent:a,usage:t}){i(this,xg,!1),i(this,Mg,!1),i(this,Gg,!1),i(this,Xg,!0),A(this,xg,!!(r&Os)),A(this,Mg,!!(r&Ys)),this.name=e,this.intent=a,this.usage=t}get visible(){if(t(this,Gg))return t(this,Xg);if(!t(this,Xg))return!1;const{print:r,view:e}=this.usage;return t(this,xg)?"OFF"!==(null==e?void 0:e.viewState):!t(this,Mg)||"OFF"!==(null==r?void 0:r.printState)}_setVisible(r,e,a=!1){r!==Sg&&Df("Internal method `_setVisible` called."),A(this,Gg,a),A(this,Xg,e)}}xg=new WeakMap,Mg=new WeakMap,Gg=new WeakMap,Xg=new WeakMap;class Og{constructor(r,e=Os){if(i(this,Pg),i(this,Vg,null),i(this,Ng,new Map),i(this,Dg,null),i(this,Tg,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==r){this.name=r.name,this.creator=r.creator,A(this,Tg,r.order);for(const a of r.groups)t(this,Ng).set(a.id,new Lg(e,a));if("OFF"===r.baseState)for(const r of t(this,Ng).values())r._setVisible(Sg,!1);for(const e of r.on)t(this,Ng).get(e)._setVisible(Sg,!0);for(const e of r.off)t(this,Ng).get(e)._setVisible(Sg,!1);A(this,Dg,this.getHash())}}isVisible(r){if(0===t(this,Ng).size)return!0;if(!r)return Vf("Optional content group not defined."),!0;if("OCG"===r.type)return t(this,Ng).has(r.id)?t(this,Ng).get(r.id).visible:(Nf(`Optional content group not found: ${r.id}`),!0);if("OCMD"===r.type){if(r.expression)return o(this,Pg,jg).call(this,r.expression);if(!r.policy||"AnyOn"===r.policy){for(const e of r.ids){if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;if(t(this,Ng).get(e).visible)return!0}return!1}if("AllOn"===r.policy){for(const e of r.ids){if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;if(!t(this,Ng).get(e).visible)return!1}return!0}if("AnyOff"===r.policy){for(const e of r.ids){if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;if(!t(this,Ng).get(e).visible)return!0}return!1}if("AllOff"===r.policy){for(const e of r.ids){if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;if(t(this,Ng).get(e).visible)return!1}return!0}return Nf(`Unknown optional content policy ${r.policy}.`),!0}return Nf(`Unknown group type ${r.type}.`),!0}setVisibility(r,e=!0){const a=t(this,Ng).get(r);a?(a._setVisible(Sg,!!e,!0),A(this,Vg,null)):Nf(`Optional content group not found: ${r}`)}setOCGState({state:r,preserveRB:e}){let a;for(const e of r){switch(e){case"ON":case"OFF":case"Toggle":a=e;continue}const r=t(this,Ng).get(e);if(r)switch(a){case"ON":r._setVisible(Sg,!0);break;case"OFF":r._setVisible(Sg,!1);break;case"Toggle":r._setVisible(Sg,!r.visible)}}A(this,Vg,null)}get hasInitialVisibility(){return null===t(this,Dg)||this.getHash()===t(this,Dg)}getOrder(){return t(this,Ng).size?t(this,Tg)?t(this,Tg).slice():[...t(this,Ng).keys()]:null}getGroups(){return t(this,Ng).size>0?Kf(t(this,Ng)):null}getGroup(r){return t(this,Ng).get(r)||null}getHash(){if(null!==t(this,Vg))return t(this,Vg);const r=new cb;for(const[e,a]of t(this,Ng))r.update(`${e}:${a.visible}`);return A(this,Vg,r.hexdigest())}}Vg=new WeakMap,Ng=new WeakMap,Dg=new WeakMap,Tg=new WeakMap,Pg=new WeakSet,jg=function(r){const e=r.length;if(e<2)return!0;const a=r[0];for(let i=1;i<e;i++){const e=r[i];let A;if(Array.isArray(e))A=o(this,Pg,jg).call(this,e);else{if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;A=t(this,Ng).get(e).visible}switch(a){case"And":if(!A)return!1;break;case"Or":if(A)return!0;break;case"Not":return!A;default:return!0}}return"And"===a};class Yg{constructor(r,{disableRange:e=!1,disableStream:a=!1}){Tf(r,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:t,initialData:i,progressiveDone:A,contentDispositionFilename:n}=r;if(this._queuedChunks=[],this._progressiveDone=A,this._contentDispositionFilename=n,(null==i?void 0:i.length)>0){const r=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(r)}this._pdfDataRangeTransport=r,this._isStreamingSupported=!a,this._isRangeSupported=!e,this._contentLength=t,this._fullRequestReader=null,this._rangeReaders=[],r.addRangeListener(((r,e)=>{this._onReceiveData({begin:r,chunk:e})})),r.addProgressListener(((r,e)=>{this._onProgress({loaded:r,total:e})})),r.addProgressiveReadListener((r=>{this._onReceiveData({chunk:r})})),r.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),r.transportReady()}_onReceiveData({begin:r,chunk:e}){const a=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===r)this._fullRequestReader?this._fullRequestReader._enqueue(a):this._queuedChunks.push(a);else{Tf(this._rangeReaders.some((function(e){return e._begin===r&&(e._enqueue(a),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var r;return(null==(r=this._fullRequestReader)?void 0:r._loaded)??0}_onProgress(r){var e,a,t,i;void 0===r.total?null==(a=null==(e=this._rangeReaders[0])?void 0:e.onProgress)||a.call(e,{loaded:r.loaded}):null==(i=null==(t=this._fullRequestReader)?void 0:t.onProgress)||i.call(t,{loaded:r.loaded,total:r.total})}_onProgressiveDone(){var r;null==(r=this._fullRequestReader)||r.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(r){const e=this._rangeReaders.indexOf(r);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Tf(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const r=this._queuedChunks;return this._queuedChunks=null,new Hg(this,r,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=new Qg(this,r,e);return this._pdfDataRangeTransport.requestDataRange(r,e),this._rangeReaders.push(a),a}cancelAllRequests(r){var e;null==(e=this._fullRequestReader)||e.cancel(r);for(const e of this._rangeReaders.slice(0))e.cancel(r);this._pdfDataRangeTransport.abort()}}class Hg{constructor(r,e,a=!1,t=null){this._stream=r,this._done=a||!1,this._filename=uu(t)?t:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),r._fullRequestReader=this,this.onProgress=null}_enqueue(r){this._done||(this._requests.length>0?this._requests.shift().resolve({value:r,done:!1}):this._queuedChunks.push(r),this._loaded+=r.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const r=Promise.withResolvers();return this._requests.push(r),r.promise}cancel(r){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Qg{constructor(r,e,a){this._stream=r,this._begin=e,this._end=a,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(r){if(!this._done){if(0===this._requests.length)this._queuedChunk=r;else{this._requests.shift().resolve({value:r,done:!1});for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const r=Promise.withResolvers();return this._requests.push(r),r.promise}cancel(r){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ug({getResponseHeader:r,isHttp:e,rangeChunkSize:a,disableRange:t}){const i={allowRangeRequests:!1,suggestedLength:void 0},A=parseInt(r("Content-Length"),10);return!Number.isInteger(A)||(i.suggestedLength=A,A<=2*a)||t||!e||"bytes"!==r("Accept-Ranges")||"identity"!==(r("Content-Encoding")||"identity")||(i.allowRangeRequests=!0),i}function Jg(r){const e=r("Content-Disposition");if(e){let r=function(r){let e=!0,a=t("filename\\*","i").exec(r);if(a){a=a[1];let r=n(a);return r=unescape(r),r=o(r),r=s(r),A(r)}if(a=function(r){const e=[];let a;const i=t("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(a=i.exec(r));){let[,r,t,i]=a;if(r=parseInt(r,10),r in e){if(0===r)break}else e[r]=[t,i]}const A=[];for(let r=0;r<e.length&&r in e;++r){let[a,t]=e[r];t=n(t),a&&(t=unescape(t),0===r&&(t=o(t))),A.push(t)}return A.join("")}(r),a)return A(s(a));if(a=t("filename","i").exec(r),a){a=a[1];let r=n(a);return r=s(r),A(r)}function t(r,e){return new RegExp("(?:^|;)\\s*"+r+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function i(r,a){if(r){if(!/^[\x00-\xFF]+$/.test(a))return a;try{const t=new TextDecoder(r,{fatal:!0}),i=$f(a);a=t.decode(i),e=!1}catch{}}return a}function A(r){return e&&/[\x80-\xff]/.test(r)&&(r=i("utf-8",r),e&&(r=i("iso-8859-1",r))),r}function n(r){if(r.startsWith('"')){const e=r.slice(1).split('\\"');for(let r=0;r<e.length;++r){const a=e[r].indexOf('"');-1!==a&&(e[r]=e[r].slice(0,a),e.length=r+1),e[r]=e[r].replaceAll(/\\(.)/g,"$1")}r=e.join('"')}return r}function o(r){const e=r.indexOf("'");return-1===e?r:i(r.slice(0,e),r.slice(e+1).replace(/^[^']*'/,""))}function s(r){return!r.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(r)?r:r.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(r,e,a,t){if("q"===a||"Q"===a)return i(e,t=(t=t.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(r,e){return String.fromCharCode(parseInt(e,16))})));try{t=atob(t)}catch{}return i(e,t)}))}return""}(e);if(r.includes("%"))try{r=decodeURIComponent(r)}catch{}if(uu(r))return r}return null}function zg(r,e){return 404===r||0===r&&e.startsWith("file:")?new Qf('Missing PDF "'+e+'".'):new Uf(`Unexpected server response (${r}) while retrieving PDF "${e}".`,r)}function qg(r){return 200===r||206===r}function $g(r,e,a){return{method:"GET",headers:r,signal:a.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Kg(r){const e=new Headers;for(const a in r){const t=r[a];void 0!==t&&e.append(a,t)}return e}function rp(r){return r instanceof Uint8Array?r.buffer:r instanceof ArrayBuffer?r:(Nf(`getArrayBuffer - unexpected data format: ${r}`),new Uint8Array(r).buffer)}class ep{constructor(r){this.source=r,this.isHttp=/^https?:/i.test(r.url),this.httpHeaders=this.isHttp&&r.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var r;return(null==(r=this._fullRequestReader)?void 0:r._loaded)??0}getFullReader(){return Tf(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ap(this),this._fullRequestReader}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=new tp(this,r,e);return this._rangeRequestReaders.push(a),a}cancelAllRequests(r){var e;null==(e=this._fullRequestReader)||e.cancel(r);for(const e of this._rangeRequestReaders.slice(0))e.cancel(r)}}class ap{constructor(r){this._stream=r,this._reader=null,this._loaded=0,this._filename=null;const e=r.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,this._headers=Kg(this._stream.httpHeaders);const a=e.url;fetch(a,$g(this._headers,this._withCredentials,this._abortController)).then((r=>{if(!qg(r.status))throw zg(r.status,a);this._reader=r.body.getReader(),this._headersCapability.resolve();const e=e=>r.headers.get(e),{allowRangeRequests:t,suggestedLength:i}=Ug({getResponseHeader:e,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t,this._contentLength=i||this._contentLength,this._filename=Jg(e),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new zf("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._headersCapability.promise;const{value:e,done:a}=await this._reader.read();return a?{value:e,done:a}:(this._loaded+=e.byteLength,null==(r=this.onProgress)||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:rp(e),done:!1})}cancel(r){var e;null==(e=this._reader)||e.cancel(r),this._abortController.abort()}}class tp{constructor(r,e,a){this._stream=r,this._reader=null,this._loaded=0;const t=r.source;this._withCredentials=t.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!t.disableStream,this._abortController=new AbortController,this._headers=Kg(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${a-1}`);const i=t.url;fetch(i,$g(this._headers,this._withCredentials,this._abortController)).then((r=>{if(!qg(r.status))throw zg(r.status,i);this._readCapability.resolve(),this._reader=r.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._readCapability.promise;const{value:e,done:a}=await this._reader.read();return a?{value:e,done:a}:(this._loaded+=e.byteLength,null==(r=this.onProgress)||r.call(this,{loaded:this._loaded}),{value:rp(e),done:!1})}cancel(r){var e;null==(e=this._reader)||e.cancel(r),this._abortController.abort()}}class ip{constructor(r,e={}){this.url=r,this.isHttp=/^https?:/i.test(r),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(r,e,a){const t={begin:r,end:e};for(const r in a)t[r]=a[r];return this.request(t)}requestFull(r){return this.request(r)}request(r){const e=new XMLHttpRequest,a=this.currXhrId++,t=this.pendingRequests[a]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const r in this.httpHeaders){const a=this.httpHeaders[r];void 0!==a&&e.setRequestHeader(r,a)}return this.isHttp&&"begin"in r&&"end"in r?(e.setRequestHeader("Range",`bytes=${r.begin}-${r.end-1}`),t.expectedStatus=206):t.expectedStatus=200,e.responseType="arraybuffer",r.onError&&(e.onerror=function(a){r.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,a),e.onprogress=this.onProgress.bind(this,a),t.onHeadersReceived=r.onHeadersReceived,t.onDone=r.onDone,t.onError=r.onError,t.onProgress=r.onProgress,e.send(null),a}onProgress(r,e){var a;const t=this.pendingRequests[r];t&&(null==(a=t.onProgress)||a.call(t,e))}onStateChange(r,e){var a,t,i;const A=this.pendingRequests[r];if(!A)return;const n=A.xhr;if(n.readyState>=2&&A.onHeadersReceived&&(A.onHeadersReceived(),delete A.onHeadersReceived),4!==n.readyState||!(r in this.pendingRequests))return;if(delete this.pendingRequests[r],0===n.status&&this.isHttp)return void(null==(a=A.onError)||a.call(A,n.status));const o=n.status||200;if((200!==o||206!==A.expectedStatus)&&o!==A.expectedStatus)return void(null==(t=A.onError)||t.call(A,n.status));const s=function(r){const e=r.response;return"string"!=typeof e?e:$f(e).buffer}(n);if(206===o){const r=n.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(r);A.onDone({begin:parseInt(e[1],10),chunk:s})}else s?A.onDone({begin:0,chunk:s}):null==(i=A.onError)||i.call(A,n.status)}getRequestXhr(r){return this.pendingRequests[r].xhr}isPendingRequest(r){return r in this.pendingRequests}abortRequest(r){const e=this.pendingRequests[r].xhr;delete this.pendingRequests[r],e.abort()}}class Ap{constructor(r){this._source=r,this._manager=new ip(r.url,{httpHeaders:r.httpHeaders,withCredentials:r.withCredentials}),this._rangeChunkSize=r.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(r){const e=this._rangeRequestReaders.indexOf(r);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Tf(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new np(this._manager,this._source),this._fullRequestReader}getRangeReader(r,e){const a=new op(this._manager,r,e);return a.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(a),a}cancelAllRequests(r){var e;null==(e=this._fullRequestReader)||e.cancel(r);for(const e of this._rangeRequestReaders.slice(0))e.cancel(r)}}class np{constructor(r,e){this._manager=r;const a={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=r.requestFull(a),this._headersReceivedCapability=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 r=this._fullRequestId,e=this._manager.getRequestXhr(r),a=r=>e.getResponseHeader(r),{allowRangeRequests:t,suggestedLength:i}=Ug({getResponseHeader:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});t&&(this._isRangeSupported=!0),this._contentLength=i||this._contentLength,this._filename=Jg(a),this._isRangeSupported&&this._manager.abortRequest(r),this._headersReceivedCapability.resolve()}_onDone(r){if(r&&(this._requests.length>0?this._requests.shift().resolve({value:r.chunk,done:!1}):this._cachedChunks.push(r.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(r){this._storedError=zg(r,this._url),this._headersReceivedCapability.reject(this._storedError);for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(r){var e;null==(e=this.onProgress)||e.call(this,{loaded:r.loaded,total:r.lengthComputable?r.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._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const r=Promise.withResolvers();return this._requests.push(r),r.promise}cancel(r){this._done=!0,this._headersReceivedCapability.reject(r);for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class op{constructor(r,e,a){this._manager=r;const t={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=r.url,this._requestId=r.requestRange(e,a,t),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var r;null==(r=this.onClosed)||r.call(this,this)}_onDone(r){const e=r.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(r){this._storedError=zg(r,this._url);for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(r){var e;this.isStreamingSupported||null==(e=this.onProgress)||e.call(this,{loaded:r.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const r=Promise.withResolvers();return this._requests.push(r),r.promise}cancel(r){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const sp=/^file:\/\/\/[a-zA-Z]:\//;class fp{constructor(r){this.source=r,this.url=function(r){const e=_b.get("url"),a=e.parse(r);return"file:"===a.protocol||a.host?a:/^[a-z]:[/\\]/i.test(r)?e.parse(`file:///${r}`):(a.host||(a.protocol="file:"),a)}(r.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&r.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var r;return(null==(r=this._fullRequestReader)?void 0:r._loaded)??0}getFullReader(){return Tf(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new bp(this):new dp(this),this._fullRequestReader}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=this.isFsUrl?new gp(this,r,e):new hp(this,r,e);return this._rangeRequestReaders.push(a),a}cancelAllRequests(r){var e;null==(e=this._fullRequestReader)||e.cancel(r);for(const e of this._rangeRequestReaders.slice(0))e.cancel(r)}}class lp{constructor(r){this._url=r.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=r.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,null==(r=this.onProgress)||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(r){this._readableStream?this._readableStream.destroy(r):this._error(r)}_error(r){this._storedError=r,this._readCapability.resolve()}_setReadableStream(r){this._readableStream=r,r.on("readable",(()=>{this._readCapability.resolve()})),r.on("end",(()=>{r.destroy(),this._done=!0,this._readCapability.resolve()})),r.on("error",(r=>{this._error(r)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new zf("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class up{constructor(r){this._url=r.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=r.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,null==(r=this.onProgress)||r.call(this,{loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(r){this._readableStream?this._readableStream.destroy(r):this._error(r)}_error(r){this._storedError=r,this._readCapability.resolve()}_setReadableStream(r){this._readableStream=r,r.on("readable",(()=>{this._readCapability.resolve()})),r.on("end",(()=>{r.destroy(),this._done=!0,this._readCapability.resolve()})),r.on("error",(r=>{this._error(r)})),this._storedError&&this._readableStream.destroy(this._storedError)}}function cp(r,e){return{protocol:r.protocol,auth:r.auth,host:r.hostname,port:r.port,path:r.path,method:"GET",headers:e}}class dp extends lp{constructor(r){super(r);const e=e=>{if(404===e.statusCode){const r=new Qf(`Missing PDF "${this._url}".`);return this._storedError=r,void this._headersCapability.reject(r)}this._headersCapability.resolve(),this._setReadableStream(e);const a=r=>this._readableStream.headers[r.toLowerCase()],{allowRangeRequests:t,suggestedLength:i}=Ug({getResponseHeader:a,isHttp:r.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t,this._contentLength=i||this._contentLength,this._filename=Jg(a)};if(this._request=null,"http:"===this._url.protocol){const a=_b.get("http");this._request=a.request(cp(this._url,r.httpHeaders),e)}else{const a=_b.get("https");this._request=a.request(cp(this._url,r.httpHeaders),e)}this._request.on("error",(r=>{this._storedError=r,this._headersCapability.reject(r)})),this._request.end()}}class hp extends up{constructor(r,e,a){super(r),this._httpHeaders={};for(const e in r.httpHeaders){const a=r.httpHeaders[e];void 0!==a&&(this._httpHeaders[e]=a)}this._httpHeaders.Range=`bytes=${e}-${a-1}`;const t=r=>{if(404!==r.statusCode)this._setReadableStream(r);else{const r=new Qf(`Missing PDF "${this._url}".`);this._storedError=r}};if(this._request=null,"http:"===this._url.protocol){const r=_b.get("http");this._request=r.request(cp(this._url,this._httpHeaders),t)}else{const r=_b.get("https");this._request=r.request(cp(this._url,this._httpHeaders),t)}this._request.on("error",(r=>{this._storedError=r})),this._request.end()}}class bp extends lp{constructor(r){super(r);let e=decodeURIComponent(this._url.path);sp.test(this._url.href)&&(e=e.replace(/^\//,""));const a=_b.get("fs");a.promises.lstat(e).then((r=>{this._contentLength=r.size,this._setReadableStream(a.createReadStream(e)),this._headersCapability.resolve()}),(r=>{"ENOENT"===r.code&&(r=new Qf(`Missing PDF "${e}".`)),this._storedError=r,this._headersCapability.reject(r)}))}}class gp extends up{constructor(r,e,a){super(r);let t=decodeURIComponent(this._url.path);sp.test(this._url.href)&&(t=t.replace(/^\//,""));const i=_b.get("fs");this._setReadableStream(i.createReadStream(t,{start:e,end:a-1}))}}const pp=30;var vp,mp,kp,wp,yp,Ep,Cp,Bp,_p,Zp,Wp,Ip,Rp,Fp,Sp,xp,Mp,Gp,Xp,Vp,Np,Dp,Tp,Pp,jp,Lp,Op,Yp,Hp,Qp,Up,Jp,zp,qp,$p,Kp;let rv=(Vp=class{constructor({textContentSource:r,container:e,viewport:a}){var n;if(i(this,jp),i(this,Op),i(this,Hp),i(this,mp,Promise.withResolvers()),i(this,kp,null),i(this,wp,!1),i(this,yp,!(null==(vp=globalThis.FontInspector)||!vp.enabled)),i(this,Ep,null),i(this,Cp,null),i(this,Bp,0),i(this,_p,0),i(this,Zp,null),i(this,Wp,null),i(this,Ip,0),i(this,Rp,0),i(this,Fp,Object.create(null)),i(this,Sp,[]),i(this,xp,null),i(this,Mp,[]),i(this,Gp,new WeakMap),i(this,Xp,null),r instanceof ReadableStream)A(this,xp,r);else{if("object"!=typeof r)throw new Error('No "textContentSource" parameter specified.');A(this,xp,new ReadableStream({start(e){e.enqueue(r),e.close()}}))}A(this,kp,A(this,Wp,e)),A(this,Rp,a.scale*(globalThis.devicePixelRatio||1)),A(this,Ip,a.rotation),A(this,Cp,{prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null});const{pageWidth:s,pageHeight:f,pageX:l,pageY:u}=a.rawDims;A(this,Xp,[1,0,0,-1,-l,u+f]),A(this,_p,s),A(this,Bp,f),o(n=Vp,zp,qp).call(n),Cu(e,a),t(this,mp).promise.catch((()=>{})).then((()=>{t(Vp,Pp).delete(this),A(this,Cp,null),A(this,Fp,null)}))}render(){const r=()=>{t(this,Zp).read().then((({value:e,done:a})=>{a?t(this,mp).resolve():(t(this,Ep)??A(this,Ep,e.lang),Object.assign(t(this,Fp),e.styles),o(this,jp,Lp).call(this,e.items),r())}),t(this,mp).reject)};return A(this,Zp,t(this,xp).getReader()),t(Vp,Pp).add(this),r(),t(this,mp).promise}update({viewport:r,onBefore:e=null}){var a;const i=r.scale*(globalThis.devicePixelRatio||1),n=r.rotation;if(n!==t(this,Ip)&&(null==e||e(),A(this,Ip,n),Cu(t(this,Wp),{rotation:n})),i!==t(this,Rp)){null==e||e(),A(this,Rp,i);const r={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:o(a=Vp,Up,Jp).call(a,t(this,Ep))};for(const e of t(this,Mp))r.properties=t(this,Gp).get(e),r.div=e,o(this,Hp,Qp).call(this,r)}}cancel(){var r;const e=new zf("TextLayer task cancelled.");null==(r=t(this,Zp))||r.cancel(e).catch((()=>{})),A(this,Zp,null),t(this,mp).reject(e)}get textDivs(){return t(this,Mp)}get textContentItemsStr(){return t(this,Sp)}static cleanup(){if(!(t(this,Pp).size>0)){t(this,Np).clear();for(const{canvas:r}of t(this,Dp).values())r.remove();t(this,Dp).clear()}}},mp=new WeakMap,kp=new WeakMap,wp=new WeakMap,yp=new WeakMap,Ep=new WeakMap,Cp=new WeakMap,Bp=new WeakMap,_p=new WeakMap,Zp=new WeakMap,Wp=new WeakMap,Ip=new WeakMap,Rp=new WeakMap,Fp=new WeakMap,Sp=new WeakMap,xp=new WeakMap,Mp=new WeakMap,Gp=new WeakMap,Xp=new WeakMap,Np=new WeakMap,Dp=new WeakMap,Tp=new WeakMap,Pp=new WeakMap,jp=new WeakSet,Lp=function(r){var e,a;if(t(this,wp))return;(a=t(this,Cp)).ctx??(a.ctx=o(e=Vp,Up,Jp).call(e,t(this,Ep)));const i=t(this,Mp),n=t(this,Sp);for(const e of r){if(i.length>1e5)return Nf("Ignoring additional textDivs for performance reasons."),void A(this,wp,!0);if(void 0!==e.str)n.push(e.str),o(this,Op,Yp).call(this,e);else if("beginMarkedContentProps"===e.type||"beginMarkedContent"===e.type){const r=t(this,kp);A(this,kp,document.createElement("span")),t(this,kp).classList.add("markedContent"),null!==e.id&&t(this,kp).setAttribute("id",`${e.id}`),r.append(t(this,kp))}else"endMarkedContent"===e.type&&A(this,kp,t(this,kp).parentNode)}},Op=new WeakSet,Yp=function(r){var e;const a=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==r.str,hasEOL:r.hasEOL,fontSize:0};t(this,Mp).push(a);const A=nl.transform(t(this,Xp),r.transform);let n=Math.atan2(A[1],A[0]);const s=t(this,Fp)[r.fontName];s.vertical&&(n+=Math.PI/2);const f=t(this,yp)&&s.fontSubstitution||s.fontFamily,l=Math.hypot(A[2],A[3]),u=l*o(e=Vp,$p,Kp).call(e,f,t(this,Ep));let c,d;0===n?(c=A[4],d=A[5]-u):(c=A[4]+u*Math.sin(n),d=A[5]-u*Math.cos(n));const h="calc(var(--scale-factor)*",b=a.style;t(this,kp)===t(this,Wp)?(b.left=`${(100*c/t(this,_p)).toFixed(2)}%`,b.top=`${(100*d/t(this,Bp)).toFixed(2)}%`):(b.left=`${h}${c.toFixed(2)}px)`,b.top=`${h}${d.toFixed(2)}px)`),b.fontSize=`${h}${(t(Vp,Tp)*l).toFixed(2)}px)`,b.fontFamily=f,i.fontSize=l,a.setAttribute("role","presentation"),a.textContent=r.str,a.dir=r.dir,t(this,yp)&&(a.dataset.fontName=s.fontSubstitutionLoadedName||r.fontName),0!==n&&(i.angle=n*(180/Math.PI));let g=!1;if(r.str.length>1)g=!0;else if(" "!==r.str&&r.transform[0]!==r.transform[3]){const e=Math.abs(r.transform[0]),a=Math.abs(r.transform[3]);e!==a&&Math.max(e,a)/Math.min(e,a)>1.5&&(g=!0)}if(g&&(i.canvasWidth=s.vertical?r.height:r.width),t(this,Gp).set(a,i),t(this,Cp).div=a,t(this,Cp).properties=i,o(this,Hp,Qp).call(this,t(this,Cp)),i.hasText&&t(this,kp).append(a),i.hasEOL){const r=document.createElement("br");r.setAttribute("role","presentation"),t(this,kp).append(r)}},Hp=new WeakSet,Qp=function(r){const{div:e,properties:a,ctx:i,prevFontSize:A,prevFontFamily:n}=r,{style:o}=e;let s="";if(t(Vp,Tp)>1&&(s=`scale(${1/t(Vp,Tp)})`),0!==a.canvasWidth&&a.hasText){const{fontFamily:f}=o,{canvasWidth:l,fontSize:u}=a;(A!==u||n!==f)&&(i.font=`${u*t(this,Rp)}px ${f}`,r.prevFontSize=u,r.prevFontFamily=f);const{width:c}=i.measureText(e.textContent);c>0&&(s=`scaleX(${l*t(this,Rp)/c}) ${s}`)}0!==a.angle&&(s=`rotate(${a.angle}deg) ${s}`),s.length>0&&(o.transform=s)},Up=new WeakSet,Jp=function(r=null){let e=t(this,Dp).get(r||(r=""));if(!e){const a=document.createElement("canvas");a.className="hiddenCanvasElement",a.lang=r,document.body.append(a),e=a.getContext("2d",{alpha:!1,willReadFrequently:!0}),t(this,Dp).set(r,e)}return e},zp=new WeakSet,qp=function(){if(null!==t(this,Tp))return;const r=document.createElement("div");r.style.opacity=0,r.style.lineHeight=1,r.style.fontSize="1px",r.textContent="X",document.body.append(r),A(this,Tp,r.getBoundingClientRect().height),r.remove()},$p=new WeakSet,Kp=function(r,e){const a=t(this,Np).get(r);if(a)return a;const i=o(this,Up,Jp).call(this,e),A=i.font;i.canvas.width=i.canvas.height=pp,i.font=`30px ${r}`;const n=i.measureText("");let s=n.fontBoundingBoxAscent,f=Math.abs(n.fontBoundingBoxDescent);if(s){const e=s/(s+f);return t(this,Np).set(r,e),i.canvas.width=i.canvas.height=0,i.font=A,e}i.strokeStyle="red",i.clearRect(0,0,pp,pp),i.strokeText("g",0,0);let l=i.getImageData(0,0,pp,pp).data;f=0;for(let r=l.length-1-3;r>=0;r-=4)if(l[r]>0){f=Math.ceil(r/4/pp);break}i.clearRect(0,0,pp,pp),i.strokeText("A",0,pp),l=i.getImageData(0,0,pp,pp).data,s=0;for(let r=0,e=l.length;r<e;r+=4)if(l[r]>0){s=pp-Math.floor(r/4/pp);break}i.canvas.width=i.canvas.height=0,i.font=A;const u=s?s/(s+f):.8;return t(this,Np).set(r,u),u},i(Vp,Up),i(Vp,zp),i(Vp,$p),i(Vp,Np,new Map),i(Vp,Dp,new Map),i(Vp,Tp,null),i(Vp,Pp,new Set),Vp);function ev(){pu("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:r,container:e,viewport:a,...t}=arguments[0],i=Object.keys(t);i.length>0&&Nf("Ignoring `renderTextLayer` parameters: "+i.join(", "));const A=new rv({textContentSource:r,container:e,viewport:a}),{textDivs:n,textContentItemsStr:o}=A;return{promise:A.render(),textDivs:n,textContentItemsStr:o}}function av(){pu("`updateTextLayer`, please use `TextLayer` instead.")}class tv{static textContent(r){const e=[],a={items:e,styles:Object.create(null)};return function r(a){var t;if(!a)return;let i=null;const A=a.name;if("#text"===A)i=a.value;else{if(!tv.shouldBuildText(A))return;null!=(t=null==a?void 0:a.attributes)&&t.textContent?i=a.attributes.textContent:a.value&&(i=a.value)}if(null!==i&&e.push({str:i}),a.children)for(const e of a.children)r(e)}(r),a}static shouldBuildText(r){return!("textarea"===r||"input"===r||"option"===r||"select"===r)}}const iv=65536,Av=Ds?class extends El{_createCanvas(r,e){return _b.get("canvas").createCanvas(r,e)}}:class extends El{constructor({ownerDocument:r=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=r}_createCanvas(r,e){const a=this._document.createElement("canvas");return a.width=r,a.height=e,a}},nv=Ds?class extends Cl{_fetchData(r,e){return Zb(r).then((r=>({cMapData:r,compressionType:e})))}}:Au,ov=Ds?class extends kl{}:class extends kl{constructor({docId:r,ownerDocument:e=globalThis.document}={}){super(),i(this,Xl),i(this,Nl),i(this,Tl),i(this,jl),i(this,Ol),i(this,Hl),i(this,Ul),i(this,zl),i(this,$l),i(this,ru),i(this,au),i(this,Rl,void 0),i(this,Fl,void 0),i(this,Sl,void 0),i(this,xl,void 0),i(this,Ml,void 0),i(this,Gl,0),A(this,Sl,r),A(this,xl,e)}addFilter(r){if(!r)return"none";let e=t(this,Xl,Vl).get(r);if(e)return e;const[a,i,A]=o(this,jl,Ll).call(this,r),s=1===r.length?a:`${a}${i}${A}`;if(e=t(this,Xl,Vl).get(s),e)return t(this,Xl,Vl).set(r,e),e;const f=`g_${t(this,Sl)}_transfer_map_${n(this,Gl)._++}`,l=`url(#${f})`;t(this,Xl,Vl).set(r,l),t(this,Xl,Vl).set(s,l);const u=o(this,Ul,Jl).call(this,f);return o(this,$l,Kl).call(this,a,i,A,u),l}addHCMFilter(r,e){var a;const i=`${r}-${e}`,A="base";let n=t(this,Nl,Dl).get(A);if((null==n?void 0:n.key)===i||(n?(null==(a=n.filter)||a.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},t(this,Nl,Dl).set(A,n)),!r||!e))return n.url;const s=o(this,au,tu).call(this,r);r=nl.makeHexColor(...s);const f=o(this,au,tu).call(this,e);if(e=nl.makeHexColor(...f),t(this,Tl,Pl).style.color="","#000000"===r&&"#ffffff"===e||r===e)return n.url;const l=new Array(256);for(let r=0;r<=255;r++){const e=r/255;l[r]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const u=l.join(","),c=`g_${t(this,Sl)}_hcm_filter`,d=n.filter=o(this,Ul,Jl).call(this,c);o(this,$l,Kl).call(this,u,u,u,d),o(this,Hl,Ql).call(this,d);const h=(r,e)=>{const a=s[r]/255,t=f[r]/255,i=new Array(e+1);for(let r=0;r<=e;r++)i[r]=a+r/e*(t-a);return i.join(",")};return o(this,$l,Kl).call(this,h(0,5),h(1,5),h(2,5),d),n.url=`url(#${c})`,n.url}addAlphaFilter(r){let e=t(this,Xl,Vl).get(r);if(e)return e;const[a]=o(this,jl,Ll).call(this,[r]),i=`alpha_${a}`;if(e=t(this,Xl,Vl).get(i),e)return t(this,Xl,Vl).set(r,e),e;const A=`g_${t(this,Sl)}_alpha_map_${n(this,Gl)._++}`,s=`url(#${A})`;t(this,Xl,Vl).set(r,s),t(this,Xl,Vl).set(i,s);const f=o(this,Ul,Jl).call(this,A);return o(this,ru,eu).call(this,a,f),s}addLuminosityFilter(r){let e,a,i=t(this,Xl,Vl).get(r||"luminosity");if(i)return i;if(r?([e]=o(this,jl,Ll).call(this,[r]),a=`luminosity_${e}`):a="luminosity",i=t(this,Xl,Vl).get(a),i)return t(this,Xl,Vl).set(r,i),i;const A=`g_${t(this,Sl)}_luminosity_map_${n(this,Gl)._++}`,s=`url(#${A})`;t(this,Xl,Vl).set(r,s),t(this,Xl,Vl).set(a,s);const f=o(this,Ul,Jl).call(this,A);return o(this,Ol,Yl).call(this,f),r&&o(this,ru,eu).call(this,e,f),s}addHighlightHCMFilter(r,e,a,i,A){var n;const s=`${e}-${a}-${i}-${A}`;let f=t(this,Nl,Dl).get(r);if((null==f?void 0:f.key)===s||(f?(null==(n=f.filter)||n.remove(),f.key=s,f.url="none",f.filter=null):(f={key:s,url:"none",filter:null},t(this,Nl,Dl).set(r,f)),!e||!a))return f.url;const[l,u]=[e,a].map(o(this,au,tu).bind(this));let c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),d=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),[h,b]=[i,A].map(o(this,au,tu).bind(this));d<c&&([c,d,h,b]=[d,c,b,h]),t(this,Tl,Pl).style.color="";const g=(r,e,a)=>{const t=new Array(256),i=(d-c)/a,A=r/255,n=(e-r)/(255*a);let o=0;for(let r=0;r<=a;r++){const e=Math.round(c+r*i),a=A+r*n;for(let r=o;r<=e;r++)t[r]=a;o=e+1}for(let r=o;r<256;r++)t[r]=t[o-1];return t.join(",")},p=`g_${t(this,Sl)}_hcm_${r}_filter`,v=f.filter=o(this,Ul,Jl).call(this,p);return o(this,Hl,Ql).call(this,v),o(this,$l,Kl).call(this,g(h[0],b[0],5),g(h[1],b[1],5),g(h[2],b[2],5),v),f.url=`url(#${p})`,f.url}destroy(r=!1){r&&0!==t(this,Nl,Dl).size||(t(this,Fl)&&(t(this,Fl).parentNode.parentNode.remove(),A(this,Fl,null)),t(this,Rl)&&(t(this,Rl).clear(),A(this,Rl,null)),A(this,Gl,0))}},sv=Ds?class extends Bl{_fetchData(r){return Zb(r)}}:nu;function fv(r={}){"string"==typeof r||r instanceof URL?r={url:r}:(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});const e=new dv,{docId:a}=e,t=r.url?function(r){if(r instanceof URL)return r.href;try{return new URL(r,window.location).href}catch{if(Ds&&"string"==typeof r)return r}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(r.url):null,i=r.data?function(r){if(Ds&&typeof Buffer<"u"&&r instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength)return r;if("string"==typeof r)return $f(r);if(r instanceof ArrayBuffer||ArrayBuffer.isView(r)||"object"==typeof r&&!isNaN(null==r?void 0:r.length))return new Uint8Array(r);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(r.data):null,A=r.httpHeaders||null,n=!0===r.withCredentials,o=r.password??null,s=r.range instanceof hv?r.range:null,f=Number.isInteger(r.rangeChunkSize)&&r.rangeChunkSize>0?r.rangeChunkSize:iv;let l=r.worker instanceof xv?r.worker:null;const u=r.verbosity,c="string"!=typeof r.docBaseUrl||lu(r.docBaseUrl)?null:r.docBaseUrl,d="string"==typeof r.cMapUrl?r.cMapUrl:null,h=!1!==r.cMapPacked,b=r.CMapReaderFactory||nv,g="string"==typeof r.standardFontDataUrl?r.standardFontDataUrl:null,p=r.StandardFontDataFactory||sv,v=!0!==r.stopAtErrors,m=Number.isInteger(r.maxImageSize)&&r.maxImageSize>-1?r.maxImageSize:-1,k=!1!==r.isEvalSupported,w="boolean"==typeof r.isOffscreenCanvasSupported?r.isOffscreenCanvasSupported:!Ds,y=Number.isInteger(r.canvasMaxAreaInBytes)?r.canvasMaxAreaInBytes:-1,E="boolean"==typeof r.disableFontFace?r.disableFontFace:Ds,C=!0===r.fontExtraProperties,B=!0===r.enableXfa,_=r.ownerDocument||globalThis.document,Z=!0===r.disableRange,W=!0===r.disableStream,I=!0===r.disableAutoFetch,R=!0===r.pdfBug,F=!0===r.enableHWA,S=s?s.length:r.length??NaN,x="boolean"==typeof r.useSystemFonts?r.useSystemFonts:!Ds&&!E,M="boolean"==typeof r.useWorkerFetch?r.useWorkerFetch:b===Au&&p===nu&&d&&g&&bu(d,document.baseURI)&&bu(g,document.baseURI),G=r.canvasFactory||new Av({ownerDocument:_,enableHWA:F}),X=r.filterFactory||new ov({docId:a,ownerDocument:_});!function(r){Number.isInteger(r)&&(Gf=r)}(u);const V={canvasFactory:G,filterFactory:X};if(M||(V.cMapReaderFactory=new b({baseUrl:d,isCompressed:h}),V.standardFontDataFactory=new p({baseUrl:g})),!l){const r={verbosity:u,port:lg.workerPort};l=r.port?xv.fromPort(r):new xv(r),e._worker=l}const N={docId:a,apiVersion:"4.4.168",data:i,password:o,disableAutoFetch:I,rangeChunkSize:f,length:S,docBaseUrl:c,enableXfa:B,evaluatorOptions:{maxImageSize:m,disableFontFace:E,ignoreErrors:v,isEvalSupported:k,isOffscreenCanvasSupported:w,canvasMaxAreaInBytes:y,fontExtraProperties:C,useSystemFonts:x,cMapUrl:M?d:null,standardFontDataUrl:M?g:null}},D={disableFontFace:E,fontExtraProperties:C,ownerDocument:_,pdfBug:R,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:B}};return l.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(l.destroyed)throw new Error("Worker was destroyed");const r=l.messageHandler.sendWithPromise("GetDocRequest",N,i?[i.buffer]:null);let o;if(s)o=new Yg(s,{disableRange:Z,disableStream:W});else if(!i){if(!t)throw new Error("getDocument - no `url` parameter provided.");u={url:t,length:S,httpHeaders:A,withCredentials:n,rangeChunkSize:f,disableRange:Z,disableStream:W},o=Ds?typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&bu(u.url)?new ep(u):new fp(u):bu(u.url)?new ep(u):new Ap(u)}var u;return r.then((r=>{if(e.destroyed)throw new Error("Loading aborted");if(l.destroyed)throw new Error("Worker was destroyed");const t=new Rg(a,r,l.port),i=new Pv(t,e,o,D,V);e._transport=i,t.send("Ready",null)}))})).catch(e._capability.reject),e}function lv(r){return"object"==typeof r&&Number.isInteger(null==r?void 0:r.num)&&r.num>=0&&Number.isInteger(null==r?void 0:r.gen)&&r.gen>=0}var uv;const cv=class{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+n(cv,uv)._++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var r,e,a;this.destroyed=!0;try{null!=(r=this._worker)&&r.port&&(this._worker._pendingDestroy=!0),await(null==(e=this._transport)?void 0:e.destroy())}catch(r){throw null!=(a=this._worker)&&a.port&&delete this._worker._pendingDestroy,r}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};let dv=cv;uv=new WeakMap,i(dv,uv,0);let hv=class{constructor(r,e,a=!1,t=null){this.length=r,this.initialData=e,this.progressiveDone=a,this.contentDispositionFilename=t,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(r){this._rangeListeners.push(r)}addProgressListener(r){this._progressListeners.push(r)}addProgressiveReadListener(r){this._progressiveReadListeners.push(r)}addProgressiveDoneListener(r){this._progressiveDoneListeners.push(r)}onDataRange(r,e){for(const a of this._rangeListeners)a(r,e)}onDataProgress(r,e){this._readyCapability.promise.then((()=>{for(const a of this._progressListeners)a(r,e)}))}onDataProgressiveRead(r){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(r)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const r of this._progressiveDoneListeners)r()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(r,e){Df("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class bv{constructor(r,e){this._pdfInfo=r,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return jf(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(r){return this._transport.getPage(r)}getPageIndex(r){return this._transport.getPageIndex(r)}getDestinations(){return this._transport.getDestinations()}getDestination(r){return this._transport.getDestination(r)}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:r="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(r);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(r=!1){return this._transport.startCleanup(r||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(r){return this._transport.cachedPageNumber(r)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var gv,pv,vv,mv,kv,wv,yv,Ev;class Cv{constructor(r,e,a,t=!1){i(this,vv),i(this,kv),i(this,gv,null),i(this,pv,!1),this._pageIndex=r,this._pageInfo=e,this._transport=a,this._stats=t?new hu:null,this._pdfBug=t,this.commonObjs=a.commonObjs,this.objs=new Jv,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:r,rotation:e=this.rotate,offsetX:a=0,offsetY:t=0,dontFlip:i=!1}={}){return new su({viewBox:this.view,scale:r,rotation:e,offsetX:a,offsetY:t,dontFlip:i})}getAnnotations({intent:r="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(r);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return jf(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var r;return(null==(r=this._transport._htmlForXfa)?void 0:r.children[this._pageIndex])||null}render({canvasContext:r,viewport:e,intent:a="display",annotationMode:t=zs.ENABLE,transform:i=null,background:n=null,optionalContentConfigPromise:s=null,annotationCanvasMap:f=null,pageColors:l=null,printAnnotationStorage:u=null}){var c,d;null==(c=this._stats)||c.time("Overall");const h=this._transport.getRenderingIntent(a,t,u),{renderingIntent:b,cacheKey:g}=h;A(this,pv,!1),o(this,kv,wv).call(this),s||(s=this._transport.getOptionalContentConfig(b));let p=this._intentStates.get(g);p||(p=Object.create(null),this._intentStates.set(g,p)),p.streamReaderCancelTimeout&&(clearTimeout(p.streamReaderCancelTimeout),p.streamReaderCancelTimeout=null);const v=!!(b&Ys);p.displayReadyCapability||(p.displayReadyCapability=Promise.withResolvers(),p.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(d=this._stats)||d.time("Page Request"),this._pumpOperatorList(h));const m=r=>{var e;p.renderTasks.delete(k),(this._maybeCleanupAfterRender||v)&&A(this,pv,!0),o(this,vv,mv).call(this,!v),r?(k.capability.reject(r),this._abortOperatorList({intentState:p,reason:r instanceof Error?r:new Error(r)})):k.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),null!=(e=globalThis.Stats)&&e.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},k=new $v({callback:m,params:{canvasContext:r,viewport:e,transform:i,background:n},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:f,operatorList:p.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:l});(p.renderTasks||(p.renderTasks=new Set)).add(k);const w=k.task;return Promise.all([p.displayReadyCapability.promise,s]).then((([r,e])=>{var a;if(this.destroyed)m();else{if(null==(a=this._stats)||a.time("Rendering"),!(e.renderingIntent&b))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");k.initializeGraphics({transparency:r,optionalContentConfig:e}),k.operatorListChanged()}})).catch(m),w}getOperatorList({intent:r="display",annotationMode:e=zs.ENABLE,printAnnotationStorage:a=null}={}){var t;const i=this._transport.getRenderingIntent(r,e,a,!0);let A,n=this._intentStates.get(i.cacheKey);return n||(n=Object.create(null),this._intentStates.set(i.cacheKey,n)),n.opListReadCapability||(A=Object.create(null),A.operatorListChanged=function(){n.operatorList.lastChunk&&(n.opListReadCapability.resolve(n.operatorList),n.renderTasks.delete(A))},n.opListReadCapability=Promise.withResolvers(),(n.renderTasks||(n.renderTasks=new Set)).add(A),n.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(t=this._stats)||t.time("Page Request"),this._pumpOperatorList(i)),n.opListReadCapability.promise}streamTextContent({includeMarkedContent:r=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===r,disableNormalization:!0===e},{highWaterMark:100,size:r=>r.items.length})}getTextContent(r={}){if(this._transport._htmlForXfa)return this.getXfa().then((r=>tv.textContent(r)));const e=this.streamTextContent(r);return new Promise((function(r,a){const t=e.getReader(),i={items:[],styles:Object.create(null),lang:null};!function e(){t.read().then((function({value:a,done:t}){t?r(i):(i.lang??(i.lang=a.lang),Object.assign(i.styles,a.styles),i.items.push(...a.items),e())}),a)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const r=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const a of e.renderTasks)r.push(a.completed),a.cancel();return this.objs.clear(),A(this,pv,!1),o(this,kv,wv).call(this),Promise.all(r)}cleanup(r=!1){A(this,pv,!0);const e=o(this,vv,mv).call(this,!1);return r&&e&&this._stats&&(this._stats=new hu),e}_startRenderPage(r,e){var a,t;const i=this._intentStates.get(e);i&&(null==(a=this._stats)||a.timeEnd("Page Request"),null==(t=i.displayReadyCapability)||t.resolve(r))}_renderPageChunk(r,e){for(let a=0,t=r.length;a<t;a++)e.operatorList.fnArray.push(r.fnArray[a]),e.operatorList.argsArray.push(r.argsArray[a]);e.operatorList.lastChunk=r.lastChunk,e.operatorList.separateAnnots=r.separateAnnots;for(const r of e.renderTasks)r.operatorListChanged();r.lastChunk&&o(this,vv,mv).call(this,!0)}_pumpOperatorList({renderingIntent:r,cacheKey:e,annotationStorageSerializable:a}){const{map:t,transfer:i}=a,A=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:r,cacheKey:e,annotationStorage:t},i).getReader(),n=this._intentStates.get(e);n.streamReader=A;const s=()=>{A.read().then((({value:r,done:e})=>{e?n.streamReader=null:this._transport.destroyed||(this._renderPageChunk(r,n),s())}),(r=>{if(n.streamReader=null,!this._transport.destroyed){if(n.operatorList){n.operatorList.lastChunk=!0;for(const r of n.renderTasks)r.operatorListChanged();o(this,vv,mv).call(this,!0)}if(n.displayReadyCapability)n.displayReadyCapability.reject(r);else{if(!n.opListReadCapability)throw r;n.opListReadCapability.reject(r)}}}))};s()}_abortOperatorList({intentState:r,reason:e,force:a=!1}){if(r.streamReader){if(r.streamReaderCancelTimeout&&(clearTimeout(r.streamReaderCancelTimeout),r.streamReaderCancelTimeout=null),!a){if(r.renderTasks.size>0)return;if(e instanceof fu){let a=100;return e.extraDelay>0&&e.extraDelay<1e3&&(a+=e.extraDelay),void(r.streamReaderCancelTimeout=setTimeout((()=>{r.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:r,reason:e,force:!0})}),a))}}if(r.streamReader.cancel(new zf(e.message)).catch((()=>{})),r.streamReader=null,!this._transport.destroyed){for(const[e,a]of this._intentStates)if(a===r){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}gv=new WeakMap,pv=new WeakMap,vv=new WeakSet,mv=function(r=!1){if(o(this,kv,wv).call(this),!t(this,pv)||this.destroyed)return!1;if(r)return A(this,gv,setTimeout((()=>{A(this,gv,null),o(this,vv,mv).call(this,!1)}),5e3)),!1;for(const{renderTasks:r,operatorList:e}of this._intentStates.values())if(r.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),A(this,pv,!1),!0},kv=new WeakSet,wv=function(){t(this,gv)&&(clearTimeout(t(this,gv)),A(this,gv,null))};class Bv{constructor(){i(this,yv,new Set),i(this,Ev,Promise.resolve())}postMessage(r,e){const a={data:structuredClone(r,e?{transfer:e}:null)};t(this,Ev).then((()=>{for(const r of t(this,yv))r.call(this,a)}))}addEventListener(r,e){t(this,yv).add(e)}removeEventListener(r,e){t(this,yv).delete(e)}terminate(){t(this,yv).clear()}}yv=new WeakMap,Ev=new WeakMap;const _v={isWorkerDisabled:!1,fakeWorkerId:0};var Zv,Wv,Iv,Rv,Fv;Ds&&(_v.isWorkerDisabled=!0,lg.workerSrc||(lg.workerSrc="./pdf.worker.mjs")),_v.isSameOrigin=function(r,e){let a;try{if(a=new URL(r),!a.origin||"null"===a.origin)return!1}catch{return!1}const t=new URL(e,a);return a.origin===t.origin},_v.createCDNWrapper=function(r){const e=`await import("${r}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};const Sv=class{constructor({name:r=null,port:e=null,verbosity:a=Xf()}={}){var n;if(i(this,Wv),this.name=r,this.destroyed=!1,this.verbosity=a,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(null!=(n=t(Sv,Zv))&&n.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(t(Sv,Zv)||A(Sv,Zv,new WeakMap)).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return Ds?Promise.all([_b.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(r){this._port=r,this._messageHandler=new Rg("main","worker",r),this._messageHandler.on("ready",(function(){})),o(this,Wv,Iv).call(this)}_initialize(){if(_v.isWorkerDisabled||t(Sv,Rv,Fv))return void this._setupFakeWorker();let{workerSrc:r}=Sv;try{_v.isSameOrigin(window.location.href,r)||(r=_v.createCDNWrapper(new URL(r,window.location).href));const e=new Worker(r,{type:"module"}),a=new Rg("main","worker",e),t=()=>{i.abort(),a.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},i=new AbortController;e.addEventListener("error",(()=>{this._webWorker||t()}),{signal:i.signal}),a.on("test",(r=>{i.abort(),!this.destroyed&&r?(this._messageHandler=a,this._port=e,this._webWorker=e,o(this,Wv,Iv).call(this)):t()})),a.on("ready",(r=>{if(i.abort(),this.destroyed)t();else try{A()}catch{this._setupFakeWorker()}}));const A=()=>{const r=new Uint8Array;a.send("test",r,[r.buffer])};return void A()}catch{Vf("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){_v.isWorkerDisabled||(Nf("Setting up fake worker."),_v.isWorkerDisabled=!0),Sv._setupFakeWorkerGlobal.then((r=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new Bv;this._port=e;const a="fake"+_v.fakeWorkerId++,t=new Rg(a+"_worker",a,e);r.setup(t,e),this._messageHandler=new Rg(a,a+"_worker",e),o(this,Wv,Iv).call(this)})).catch((r=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${r.message}".`))}))}destroy(){var r;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),null==(r=t(Sv,Zv))||r.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(r){var e;if(null==r||!r.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const a=null==(e=t(this,Zv))?void 0:e.get(r.port);if(a){if(a._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return a}return new Sv(r)}static get workerSrc(){if(lg.workerSrc)return lg.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return jf(this,"_setupFakeWorkerGlobal",(async()=>t(this,Rv,Fv)?t(this,Rv,Fv):(await import(this.workerSrc)).WorkerMessageHandler)())}};let xv=Sv;var Mv,Gv,Xv,Vv,Nv,Dv,Tv;Zv=new WeakMap,Wv=new WeakSet,Iv=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Rv=new WeakSet,Fv=function(){var r;try{return(null==(r=globalThis.pdfjsWorker)?void 0:r.WorkerMessageHandler)||null}catch{return null}},i(xv,Rv),i(xv,Zv,void 0);class Pv{constructor(r,e,a,t,A){i(this,Dv),i(this,Mv,new Map),i(this,Gv,new Map),i(this,Xv,new Map),i(this,Vv,new Map),i(this,Nv,null),this.messageHandler=r,this.loadingTask=e,this.commonObjs=new Jv,this.fontLoader=new yb({ownerDocument:t.ownerDocument,styleElement:t.styleElement}),this.loadingParams=t.loadingParams,this._params=t,this.canvasFactory=A.canvasFactory,this.filterFactory=A.filterFactory,this.cMapReaderFactory=A.cMapReaderFactory,this.standardFontDataFactory=A.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=a,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return jf(this,"annotationStorage",new kb)}getRenderingIntent(r,e=zs.ENABLE,a=null,t=!1){let i=Os,A=db;switch(r){case"any":i=Ls;break;case"display":break;case"print":i=Ys;break;default:Nf(`getRenderingIntent - invalid intent: ${r}`)}switch(e){case zs.DISABLE:i+=Us;break;case zs.ENABLE:break;case zs.ENABLE_FORMS:i+=Hs;break;case zs.ENABLE_STORAGE:i+=Qs,A=(i&Ys&&a instanceof wb?a:this.annotationStorage).serializable;break;default:Nf(`getRenderingIntent - invalid annotationMode: ${e}`)}return t&&(i+=Js),{renderingIntent:i,cacheKey:`${i}_${A.hash}`,annotationStorageSerializable:A}}destroy(){var r;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null==(r=t(this,Nv))||r.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const r of t(this,Gv).values())e.push(r._destroy());t(this,Gv).clear(),t(this,Xv).clear(),t(this,Vv).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const a=this.messageHandler.sendWithPromise("Terminate",null);return e.push(a),Promise.all(e).then((()=>{var r;this.commonObjs.clear(),this.fontLoader.clear(),t(this,Mv).clear(),this.filterFactory.destroy(),rv.cleanup(),null==(r=this._networkStream)||r.cancelAllRequests(new zf("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:r,loadingTask:e}=this;r.on("GetReader",((r,e)=>{Tf(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},e.onPull=()=>{this._fullReader.read().then((function({value:r,done:a}){a?e.close():(Tf(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((r=>{e.error(r)}))},e.onCancel=r=>{this._fullReader.cancel(r),e.ready.catch((r=>{if(!this.destroyed)throw r}))}})),r.on("ReaderHeadersReady",(r=>{const a=Promise.withResolvers(),t=this._fullReader;return t.headersReady.then((()=>{var r;(!t.isStreamingSupported||!t.isRangeSupported)&&(this._lastProgress&&(null==(r=e.onProgress)||r.call(e,this._lastProgress)),t.onProgress=r=>{var a;null==(a=e.onProgress)||a.call(e,{loaded:r.loaded,total:r.total})}),a.resolve({isStreamingSupported:t.isStreamingSupported,isRangeSupported:t.isRangeSupported,contentLength:t.contentLength})}),a.reject),a.promise})),r.on("GetRangeReader",((r,e)=>{Tf(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const a=this._networkStream.getRangeReader(r.begin,r.end);a?(e.onPull=()=>{a.read().then((function({value:r,done:a}){a?e.close():(Tf(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((r=>{e.error(r)}))},e.onCancel=r=>{a.cancel(r),e.ready.catch((r=>{if(!this.destroyed)throw r}))}):e.close()})),r.on("GetDoc",(({pdfInfo:r})=>{this._numPages=r.numPages,this._htmlForXfa=r.htmlForXfa,delete r.htmlForXfa,e._capability.resolve(new bv(r,this))})),r.on("DocException",(function(r){let a;switch(r.name){case"PasswordException":a=new Of(r.message,r.code);break;case"InvalidPDFException":a=new Hf(r.message);break;case"MissingPDFException":a=new Qf(r.message);break;case"UnexpectedResponseException":a=new Uf(r.message,r.status);break;case"UnknownErrorException":a=new Yf(r.message,r.details);break;default:Df("DocException - expected a valid Error.")}e._capability.reject(a)})),r.on("PasswordRequest",(r=>{if(A(this,Nv,Promise.withResolvers()),e.onPassword){const a=r=>{r instanceof Error?t(this,Nv).reject(r):t(this,Nv).resolve({password:r})};try{e.onPassword(a,r.code)}catch(r){t(this,Nv).reject(r)}}else t(this,Nv).reject(new Of(r.message,r.code));return t(this,Nv).promise})),r.on("DataLoaded",(r=>{var a;null==(a=e.onProgress)||a.call(e,{loaded:r.length,total:r.length}),this.downloadInfoCapability.resolve(r)})),r.on("StartRenderPage",(r=>{this.destroyed||t(this,Gv).get(r.pageIndex)._startRenderPage(r.transparency,r.cacheKey)})),r.on("commonobj",(([e,a,i])=>{var A;if(this.destroyed||this.commonObjs.has(e))return null;switch(a){case"Font":const{disableFontFace:n,fontExtraProperties:o,pdfBug:s}=this._params;if("error"in i){const r=i.error;Nf(`Error during font loading: ${r}`),this.commonObjs.resolve(e,r);break}const f=s&&null!=(A=globalThis.FontInspector)&&A.enabled?(r,e)=>globalThis.FontInspector.fontAdded(r,e):null,l=new Eb(i,{disableFontFace:n,inspectFont:f});this.fontLoader.bind(l).catch((()=>r.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!o&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:u}=i;Tf(u,"The imageRef must be defined.");for(const r of t(this,Gv).values())for(const[,a]of r.objs)if((null==a?void 0:a.ref)===u)return a.dataLen?(this.commonObjs.resolve(e,structuredClone(a)),a.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,i);break;default:throw new Error(`Got unknown common object type ${a}`)}return null})),r.on("obj",(([r,e,a,i])=>{var A;if(this.destroyed)return;const n=t(this,Gv).get(e);if(!n.objs.has(r)){if(0===n._intentStates.size)return void(null==(A=null==i?void 0:i.bitmap)||A.close());switch(a){case"Image":n.objs.resolve(r,i),(null==i?void 0:i.dataLen)>1e7&&(n._maybeCleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(r,i);break;default:throw new Error(`Got unknown object type ${a}`)}}})),r.on("DocProgress",(r=>{var a;this.destroyed||null==(a=e.onProgress)||a.call(e,{loaded:r.loaded,total:r.total})})),r.on("FetchBuiltInCMap",(r=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(r):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),r.on("FetchStandardFontData",(r=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(r):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var r;this.annotationStorage.size<=0&&Nf("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:a}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:(null==(r=this._fullReader)?void 0:r.filename)??null},a).finally((()=>{this.annotationStorage.resetModified()}))}getPage(r){if(!Number.isInteger(r)||r<=0||r>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=r-1,a=t(this,Xv).get(e);if(a)return a;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&t(this,Vv).set(a.refStr,r);const i=new Cv(e,a,this,this._params.pdfBug);return t(this,Gv).set(e,i),i}));return t(this,Xv).set(e,i),i}getPageIndex(r){return lv(r)?this.messageHandler.sendWithPromise("GetPageIndex",{num:r.num,gen:r.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(r,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:r,intent:e})}getFieldObjects(){return o(this,Dv,Tv).call(this,"GetFieldObjects")}hasJSActions(){return o(this,Dv,Tv).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(r){return"string"!=typeof r?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:r})}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 o(this,Dv,Tv).call(this,"GetDocJSActions")}getPageJSActions(r){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:r})}getStructTree(r){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:r})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(r){return o(this,Dv,Tv).call(this,"GetOptionalContentConfig").then((e=>new Og(e,r)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const r="GetMetadata",e=t(this,Mv).get(r);if(e)return e;const a=this.messageHandler.sendWithPromise(r,null).then((r=>{var e,a;return{info:r[0],metadata:r[1]?new Fg(r[1]):null,contentDispositionFilename:(null==(e=this._fullReader)?void 0:e.filename)??null,contentLength:(null==(a=this._fullReader)?void 0:a.contentLength)??null}}));return t(this,Mv).set(r,a),a}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(r=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const r of t(this,Gv).values())if(!r.cleanup())throw new Error(`startCleanup: Page ${r.pageNumber} is currently rendering.`);this.commonObjs.clear(),r||this.fontLoader.clear(),t(this,Mv).clear(),this.filterFactory.destroy(!0),rv.cleanup()}}cachedPageNumber(r){if(!lv(r))return null;const e=0===r.gen?`${r.num}R`:`${r.num}R${r.gen}`;return t(this,Vv).get(e)??null}}Mv=new WeakMap,Gv=new WeakMap,Xv=new WeakMap,Vv=new WeakMap,Nv=new WeakMap,Dv=new WeakSet,Tv=function(r,e=null){const a=t(this,Mv).get(r);if(a)return a;const i=this.messageHandler.sendWithPromise(r,e);return t(this,Mv).set(r,i),i};const jv=Symbol("INITIAL_DATA");var Lv,Ov,Yv,Hv,Qv,Uv;class Jv{constructor(){i(this,Ov),i(this,Lv,Object.create(null))}get(r,e=null){if(e){const a=o(this,Ov,Yv).call(this,r);return a.promise.then((()=>e(a.data))),null}const a=t(this,Lv)[r];if(!a||a.data===jv)throw new Error(`Requesting object that isn't resolved yet ${r}.`);return a.data}has(r){const e=t(this,Lv)[r];return!!e&&e.data!==jv}resolve(r,e=null){const a=o(this,Ov,Yv).call(this,r);a.data=e,a.resolve()}clear(){var r;for(const e in t(this,Lv)){const{data:a}=t(this,Lv)[e];null==(r=null==a?void 0:a.bitmap)||r.close()}A(this,Lv,Object.create(null))}*[Symbol.iterator](){for(const r in t(this,Lv)){const{data:e}=t(this,Lv)[r];e!==jv&&(yield[r,e])}}}Lv=new WeakMap,Ov=new WeakSet,Yv=function(r){var e;return(e=t(this,Lv))[r]||(e[r]={...Promise.withResolvers(),data:jv})};class zv{constructor(r){i(this,Hv,null),A(this,Hv,r),this.onContinue=null}get promise(){return t(this,Hv).capability.promise}cancel(r=0){t(this,Hv).cancel(null,r)}get separateAnnots(){const{separateAnnots:r}=t(this,Hv).operatorList;if(!r)return!1;const{annotationCanvasMap:e}=t(this,Hv);return r.form||r.canvas&&(null==e?void 0:e.size)>0}}Hv=new WeakMap;const qv=class{constructor({callback:r,params:e,objs:a,commonObjs:t,annotationCanvasMap:A,operatorList:n,pageIndex:o,canvasFactory:s,filterFactory:f,useRequestAnimationFrame:l=!1,pdfBug:u=!1,pageColors:c=null}){i(this,Qv,null),this.callback=r,this.params=e,this.objs=a,this.commonObjs=t,this.annotationCanvasMap=A,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=o,this.canvasFactory=s,this.filterFactory=f,this._pdfBug=u,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===l&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new zv(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:r=!1,optionalContentConfig:e}){var a,i;if(this.cancelled)return;if(this._canvas){if(t(qv,Uv).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.");t(qv,Uv).add(this._canvas)}this._pdfBug&&null!=(a=globalThis.StepperManager)&&a.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:A,viewport:n,transform:o,background:s}=this.params;this.gfx=new og(A,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:o,viewport:n,transparency:r,background:s}),this.operatorListIdx=0,this.graphicsReady=!0,null==(i=this.graphicsReadyCallback)||i.call(this)}cancel(r=null,e=0){var a;this.running=!1,this.cancelled=!0,null==(a=this.gfx)||a.endDrawing(),t(this,Qv)&&(window.cancelAnimationFrame(t(this,Qv)),A(this,Qv,null)),t(qv,Uv).delete(this._canvas),this.callback(r||new fu(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){var r;this.graphicsReady?(null==(r=this.stepper)||r.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?A(this,Qv,window.requestAnimationFrame((()=>{A(this,Qv,null),this._nextBound().catch(this._cancelBound)}))):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),t(qv,Uv).delete(this._canvas),this.callback())))}};let $v=qv;Qv=new WeakMap,Uv=new WeakMap,i($v,Uv,new WeakSet);const Kv="4.4.168",rm="19fbc8998";function em(r){return Math.floor(255*Math.max(0,Math.min(1,r))).toString(16).padStart(2,"0")}function am(r){return Math.max(0,Math.min(255,255*r))}class tm{static CMYK_G([r,e,a,t]){return["G",1-Math.min(1,.3*r+.59*a+.11*e+t)]}static G_CMYK([r]){return["CMYK",0,0,0,1-r]}static G_RGB([r]){return["RGB",r,r,r]}static G_rgb([r]){return[r=am(r),r,r]}static G_HTML([r]){const e=em(r);return`#${e}${e}${e}`}static RGB_G([r,e,a]){return["G",.3*r+.59*e+.11*a]}static RGB_rgb(r){return r.map(am)}static RGB_HTML(r){return`#${r.map(em).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([r,e,a,t]){return["RGB",1-Math.min(1,r+t),1-Math.min(1,a+t),1-Math.min(1,e+t)]}static CMYK_rgb([r,e,a,t]){return[am(1-Math.min(1,r+t)),am(1-Math.min(1,a+t)),am(1-Math.min(1,e+t))]}static CMYK_HTML(r){const e=this.CMYK_RGB(r).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([r,e,a]){const t=1-r,i=1-e,A=1-a;return["CMYK",t,i,A,Math.min(t,i,A)]}}class im{static setupStorage(r,e,a,t,i){const A=t.getValue(e,{value:null});switch(a.name){case"textarea":if(null!==A.value&&(r.textContent=A.value),"print"===i)break;r.addEventListener("input",(r=>{t.setValue(e,{value:r.target.value})}));break;case"input":if("radio"===a.attributes.type||"checkbox"===a.attributes.type){if(A.value===a.attributes.xfaOn?r.setAttribute("checked",!0):A.value===a.attributes.xfaOff&&r.removeAttribute("checked"),"print"===i)break;r.addEventListener("change",(r=>{t.setValue(e,{value:r.target.checked?r.target.getAttribute("xfaOn"):r.target.getAttribute("xfaOff")})}))}else{if(null!==A.value&&r.setAttribute("value",A.value),"print"===i)break;r.addEventListener("input",(r=>{t.setValue(e,{value:r.target.value})}))}break;case"select":if(null!==A.value){r.setAttribute("value",A.value);for(const r of a.children)r.attributes.value===A.value?r.attributes.selected=!0:r.attributes.hasOwnProperty("selected")&&delete r.attributes.selected}r.addEventListener("input",(r=>{const a=r.target.options,i=-1===a.selectedIndex?"":a[a.selectedIndex].value;t.setValue(e,{value:i})}))}}static setAttributes({html:r,element:e,storage:a=null,intent:t,linkService:i}){const{attributes:A}=e,n=r instanceof HTMLAnchorElement;"radio"===A.type&&(A.name=`${A.name}-${t}`);for(const[e,a]of Object.entries(A))if(null!=a)switch(e){case"class":a.length&&r.setAttribute(e,a.join(" "));break;case"dataId":break;case"id":r.setAttribute("data-element-id",a);break;case"style":Object.assign(r.style,a);break;case"textContent":r.textContent=a;break;default:(!n||"href"!==e&&"newWindow"!==e)&&r.setAttribute(e,a)}n&&i.addLinkAttributes(r,A.href,A.newWindow),a&&A.dataId&&this.setupStorage(r,A.dataId,e,a)}static render(r){var e,a;const t=r.annotationStorage,i=r.linkService,A=r.xfaHtml,n=r.intent||"display",o=document.createElement(A.name);A.attributes&&this.setAttributes({html:o,element:A,intent:n,linkService:i});const s="richText"!==n,f=r.div;if(f.append(o),r.viewport){const e=`matrix(${r.viewport.transform.join(",")})`;f.style.transform=e}s&&f.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===A.children.length){if(A.value){const r=document.createTextNode(A.value);o.append(r),s&&tv.shouldBuildText(A.name)&&l.push(r)}return{textDivs:l}}const u=[[A,-1,o]];for(;u.length>0;){const[r,A,o]=u.at(-1);if(A+1===r.children.length){u.pop();continue}const f=r.children[++u.at(-1)[1]];if(null===f)continue;const{name:c}=f;if("#text"===c){const r=document.createTextNode(f.value);l.push(r),o.append(r);continue}const d=null!=(e=null==f?void 0:f.attributes)&&e.xmlns?document.createElementNS(f.attributes.xmlns,c):document.createElement(c);if(o.append(d),f.attributes&&this.setAttributes({html:d,element:f,storage:t,intent:n,linkService:i}),(null==(a=f.children)?void 0:a.length)>0)u.push([f,-1,d]);else if(f.value){const r=document.createTextNode(f.value);s&&tv.shouldBuildText(c)&&l.push(r),d.append(r)}}for(const r of f.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))r.setAttribute("readOnly",!0);return{textDivs:l}}static update(r){const e=`matrix(${r.viewport.transform.join(",")})`;r.div.style.transform=e,r.div.hidden=!1}}const Am=1e3,nm=new WeakSet;function om(r){return{width:r[2]-r[0],height:r[3]-r[1]}}class sm{static create(r){switch(r.data.annotationType){case ff:return new wk(r);case sf:return new yk(r);case Bf:switch(r.data.fieldType){case"Tx":return new Ck(r);case"Btn":return r.data.radioButton?new Zk(r):r.data.checkBox?new _k(r):new Wk(r);case"Ch":return new Ik(r);case"Sig":return new Bk(r)}return new Ek(r);case Ef:return new Rk(r);case lf:return new Sk(r);case uf:return new xk(r);case cf:return new Mk(r);case df:return new Gk(r);case bf:return new Xk(r);case wf:return new Nk(r);case yf:return new Dk(r);case hf:return new Vk(r);case gf:return new Tk(r);case pf:return new Pk(r);case vf:return new jk(r);case mf:return new Lk(r);case kf:return new Ok(r);case Cf:return new Yk(r);default:return new bm(r)}}}var fm,lm,um,cm,dm;const hm=class{constructor(r,{isRenderable:e=!1,ignoreBorder:a=!1,createQuadrilaterals:t=!1}={}){i(this,cm),i(this,fm,null),i(this,lm,!1),i(this,um,null),this.isRenderable=e,this.data=r.data,this.layer=r.layer,this.linkService=r.linkService,this.downloadManager=r.downloadManager,this.imageResourcesPath=r.imageResourcesPath,this.renderForms=r.renderForms,this.svgFactory=r.svgFactory,this.annotationStorage=r.annotationStorage,this.enableScripting=r.enableScripting,this.hasJSActions=r.hasJSActions,this._fieldObjects=r.fieldObjects,this.parent=r.parent,e&&(this.container=this._createContainer(a)),t&&this._createQuadrilaterals()}static _hasPopupData({titleObj:r,contentsObj:e,richText:a}){return!!(null!=r&&r.str||null!=e&&e.str||null!=a&&a.str)}get hasPopupData(){return hm._hasPopupData(this.data)}updateEdited(r){var e;if(!this.container)return;t(this,fm)||A(this,fm,{rect:this.data.rect.slice(0)});const{rect:a}=r;a&&o(this,cm,dm).call(this,a),null==(e=t(this,um))||e.popup.updateEdited(r)}resetEdited(){var r;t(this,fm)&&(o(this,cm,dm).call(this,t(this,fm).rect),null==(r=t(this,um))||r.popup.resetEdited(),A(this,fm,null))}_createContainer(r){const{data:e,parent:{page:a,viewport:t}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",e.id),this instanceof Ek||(i.tabIndex=Am);const{style:n}=i;if(n.zIndex=this.parent.zIndex++,e.popupRef&&i.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(i.title=e.alternativeText),e.noRotate&&i.classList.add("norotate"),!e.rect||this instanceof Rk){const{rotation:r}=e;return!e.hasOwnCanvas&&0!==r&&this.setRotation(r,i),i}const{width:o,height:s}=om(e.rect);if(!r&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;const r=e.borderStyle.horizontalCornerRadius,a=e.borderStyle.verticalCornerRadius;if(r>0||a>0){const e=`calc(${r}px * var(--scale-factor)) / calc(${a}px * var(--scale-factor))`;n.borderRadius=e}else if(this instanceof Zk){const r=`calc(${o}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`;n.borderRadius=r}switch(e.borderStyle.style){case _f:n.borderStyle="solid";break;case Zf:n.borderStyle="dashed";break;case Wf:Nf("Unimplemented border style: beveled");break;case If:Nf("Unimplemented border style: inset");break;case Rf:n.borderBottomStyle="solid"}const t=e.borderColor||null;t?(A(this,lm,!0),n.borderColor=nl.makeHexColor(0|t[0],0|t[1],0|t[2])):n.borderWidth=0}const f=nl.normalizeRect([e.rect[0],a.view[3]-e.rect[1]+a.view[1],e.rect[2],a.view[3]-e.rect[3]+a.view[1]]),{pageWidth:l,pageHeight:u,pageX:c,pageY:d}=t.rawDims;n.left=100*(f[0]-c)/l+"%",n.top=100*(f[1]-d)/u+"%";const{rotation:h}=e;return e.hasOwnCanvas||0===h?(n.width=100*o/l+"%",n.height=100*s/u+"%"):this.setRotation(h,i),i}setRotation(r,e=this.container){if(!this.data.rect)return;const{pageWidth:a,pageHeight:t}=this.parent.viewport.rawDims,{width:i,height:A}=om(this.data.rect);let n,o;r%180==0?(n=100*i/a,o=100*A/t):(n=100*A/a,o=100*i/t),e.style.width=`${n}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-r)%360)}get _commonActions(){const r=(r,e,a)=>{const t=a.detail[r],i=t[0],A=t.slice(1);a.target.style[e]=tm[`${i}_HTML`](A),this.annotationStorage.setValue(this.data.id,{[e]:tm[`${i}_rgb`](A)})};return jf(this,"_commonActions",{display:r=>{const{display:e}=r.detail,a=e%2==1;this.container.style.visibility=a?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:a,noPrint:1===e||2===e})},print:r=>{this.annotationStorage.setValue(this.data.id,{noPrint:!r.detail.print})},hidden:r=>{const{hidden:e}=r.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:r=>{setTimeout((()=>r.target.focus({preventScroll:!1})),0)},userName:r=>{r.target.title=r.detail.userName},readonly:r=>{r.target.disabled=r.detail.readonly},required:r=>{this._setRequired(r.target,r.detail.required)},bgColor:e=>{r("bgColor","backgroundColor",e)},fillColor:e=>{r("fillColor","backgroundColor",e)},fgColor:e=>{r("fgColor","color",e)},textColor:e=>{r("textColor","color",e)},borderColor:e=>{r("borderColor","borderColor",e)},strokeColor:e=>{r("strokeColor","borderColor",e)},rotation:r=>{const e=r.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(r,e){const a=this._commonActions;for(const t of Object.keys(e.detail)){const i=r[t]||a[t];null==i||i(e)}}_setDefaultPropertiesFromJS(r){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const a=this._commonActions;for(const[t,i]of Object.entries(e)){const A=a[t];if(A){A({detail:{[t]:i},target:r}),delete e[t]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:r}=this.data;if(!r)return;const[e,a,i,A]=this.data.rect.map((r=>Math.fround(r)));if(8===r.length){const[t,n,o,s]=r.subarray(2,6);if(i===t&&A===n&&e===o&&a===s)return}const{style:n}=this.container;let o;if(t(this,lm)){const{borderColor:r,borderWidth:e}=n;n.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${r}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const s=i-e,f=A-a,{svgFactory:l}=this,u=l.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const c=l.createElement("defs");u.append(c);const d=l.createElement("clipPath"),h=`clippath_${this.data.id}`;d.setAttribute("id",h),d.setAttribute("clipPathUnits","objectBoundingBox"),c.append(d);for(let a=2,t=r.length;a<t;a+=8){const t=r[a],i=r[a+1],n=r[a+2],u=r[a+3],c=l.createElement("rect"),h=(n-e)/s,b=(A-i)/f,g=(t-n)/s,p=(i-u)/f;c.setAttribute("x",h),c.setAttribute("y",b),c.setAttribute("width",g),c.setAttribute("height",p),d.append(c),null==o||o.push(`<rect vector-effect="non-scaling-stroke" x="${h}" y="${b}" width="${g}" height="${p}"/>`)}t(this,lm)&&(o.push("</g></svg>')"),n.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${h})`}_createPopup(){const{container:r,data:e}=this;r.setAttribute("aria-haspopup","dialog");const a=A(this,um,new Rk({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(a.render())}render(){Df("Abstract method `AnnotationElement.render` called")}_getElementsByName(r,e=null){const a=[];if(this._fieldObjects){const t=this._fieldObjects[r];if(t)for(const{page:r,id:i,exportValues:A}of t){if(-1===r||i===e)continue;const t="string"==typeof A?A:null,n=document.querySelector(`[data-element-id="${i}"]`);!n||nm.has(n)?a.push({id:i,exportValue:t,domElement:n}):Nf(`_getElementsByName - element not allowed: ${i}`)}return a}for(const t of document.getElementsByName(r)){const{exportValue:r}=t,i=t.getAttribute("data-element-id");i!==e&&nm.has(t)&&a.push({id:i,exportValue:r,domElement:t})}return a}show(){var r;this.container&&(this.container.hidden=!1),null==(r=this.popup)||r.maybeShow()}hide(){var r;this.container&&(this.container.hidden=!0),null==(r=this.popup)||r.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const r=this.getElementsToTriggerPopup();if(Array.isArray(r))for(const e of r)e.classList.add("highlightArea");else r.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:r,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{var a;null==(a=this.linkService.eventBus)||a.dispatch("switchannotationeditormode",{source:this,mode:r,editId:e})}))}};let bm=hm;var gm,pm,vm,mm,km,wm,ym,Em,Cm,Bm,_m,Zm,Wm,Im,Rm,Fm,Sm,xm,Mm,Gm,Xm,Vm,Nm,Dm,Tm,Pm,jm,Lm,Om,Ym,Hm,Qm,Um,Jm,zm,qm,$m,Km,rk,ek,ak,tk,ik,Ak,nk,ok,sk,fk,lk,uk,ck,dk,hk,bk,gk,pk,vk,mk,kk;fm=new WeakMap,lm=new WeakMap,um=new WeakMap,cm=new WeakSet,dm=function(r){const{container:{style:e},data:{rect:a,rotation:t},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:A,pageX:n,pageY:o}}}}=this;null==a||a.splice(0,4,...r);const{width:s,height:f}=om(r);e.left=100*(r[0]-n)/i+"%",e.top=100*(A-r[3]+o)/A+"%",0===t?(e.width=100*s/i+"%",e.height=100*f/A+"%"):this.setRotation(t)};class wk extends bm{constructor(r,e=null){super(r,{isRenderable:!0,ignoreBorder:!(null==e||!e.ignoreBorder),createQuadrilaterals:!0}),i(this,gm),i(this,vm),i(this,km),this.isTooltipOnly=r.data.isTooltipOnly}render(){const{data:r,linkService:e}=this,a=document.createElement("a");a.setAttribute("data-element-id",r.id);let t=!1;return r.url?(e.addLinkAttributes(a,r.url,r.newWindow),t=!0):r.action?(this._bindNamedAction(a,r.action),t=!0):r.attachment?(o(this,vm,mm).call(this,a,r.attachment,r.attachmentDest),t=!0):r.setOCGState?(o(this,km,wm).call(this,a,r.setOCGState),t=!0):r.dest?(this._bindLink(a,r.dest),t=!0):(r.actions&&(r.actions.Action||r.actions["Mouse Up"]||r.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(a,r),t=!0),r.resetForm?(this._bindResetFormAction(a,r.resetForm),t=!0):this.isTooltipOnly&&!t&&(this._bindLink(a,""),t=!0)),this.container.classList.add("linkAnnotation"),t&&this.container.append(a),this.container}_bindLink(r,e){r.href=this.linkService.getDestinationHash(e),r.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&o(this,gm,pm).call(this)}_bindNamedAction(r,e){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeNamedAction(e),!1),o(this,gm,pm).call(this)}_bindJSAction(r,e){r.href=this.linkService.getAnchorUrl("");const a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const t of Object.keys(e.actions)){const i=a.get(t);i&&(r[i]=()=>{var r;return null==(r=this.linkService.eventBus)||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:t}}),!1})}r.onclick||(r.onclick=()=>!1),o(this,gm,pm).call(this)}_bindResetFormAction(r,e){const a=r.onclick;if(a||(r.href=this.linkService.getAnchorUrl("")),o(this,gm,pm).call(this),!this._fieldObjects)return Nf('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(a||(r.onclick=()=>!1));r.onclick=()=>{var r;null==a||a();const{fields:t,refs:i,include:A}=e,n=[];if(0!==t.length||0!==i.length){const r=new Set(i);for(const e of t){const a=this._fieldObjects[e]||[];for(const{id:e}of a)r.add(e)}for(const e of Object.values(this._fieldObjects))for(const a of e)r.has(a.id)===A&&n.push(a)}else for(const r of Object.values(this._fieldObjects))n.push(...r);const o=this.annotationStorage,s=[];for(const r of n){const{id:e}=r;switch(s.push(e),r.type){case"text":{const a=r.defaultValue||"";o.setValue(e,{value:a});break}case"checkbox":case"radiobutton":{const a=r.defaultValue===r.exportValues;o.setValue(e,{value:a});break}case"combobox":case"listbox":{const a=r.defaultValue||"";o.setValue(e,{value:a});break}default:continue}const a=document.querySelector(`[data-element-id="${e}"]`);a&&(nm.has(a)?a.dispatchEvent(new Event("resetform")):Nf(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&(null==(r=this.linkService.eventBus)||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:s,name:"ResetForm"}})),!1}}}gm=new WeakSet,pm=function(){this.container.setAttribute("data-internal-link","")},vm=new WeakSet,mm=function(r,e,a=null){r.href=this.linkService.getAnchorUrl(""),e.description&&(r.title=e.description),r.onclick=()=>{var r;return null==(r=this.downloadManager)||r.openOrDownloadData(e.content,e.filename,a),!1},o(this,gm,pm).call(this)},km=new WeakSet,wm=function(r,e){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeSetOCGState(e),!1),o(this,gm,pm).call(this)};class yk extends bm{constructor(r){super(r,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const r=document.createElement("img");return r.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",r.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),r.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(r),this.container}}class Ek extends bm{render(){return this.container}showElementAndHideCanvas(r){var e;this.data.hasOwnCanvas&&("CANVAS"===(null==(e=r.previousSibling)?void 0:e.nodeName)&&(r.previousSibling.hidden=!0),r.hidden=!1)}_getKeyModifier(r){return rl.platform.isMac?r.metaKey:r.ctrlKey}_setEventListener(r,e,a,t,i){a.includes("mouse")?r.addEventListener(a,(r=>{var e;null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:t,value:i(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})})):r.addEventListener(a,(r=>{var A;if("blur"===a){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if("focus"===a){if(e.focused)return;e.focused=!0}i&&(null==(A=this.linkService.eventBus)||A.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:t,value:i(r)}}))}))}_setEventListeners(r,e,a,t){var i,A,n;for(const[o,s]of a)("Action"===s||null!=(i=this.data.actions)&&i[s])&&(("Focus"===s||"Blur"===s)&&(e||(e={focused:!1})),this._setEventListener(r,e,o,s,t),"Focus"!==s||null!=(A=this.data.actions)&&A.Blur?"Blur"===s&&(null==(n=this.data.actions)||!n.Focus)&&this._setEventListener(r,e,"focus","Focus",null):this._setEventListener(r,e,"blur","Blur",null))}_setBackgroundColor(r){const e=this.data.backgroundColor||null;r.style.backgroundColor=null===e?"transparent":nl.makeHexColor(e[0],e[1],e[2])}_setTextStyle(r){const{fontColor:e}=this.data.defaultAppearanceData,a=this.data.defaultAppearanceData.fontSize||9,t=r.style;let i;const A=r=>Math.round(10*r)/10;if(this.data.multiLine){const r=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=r/(Math.round(r/(js*a))||1);i=Math.min(a,A(e/js))}else{const r=Math.abs(this.data.rect[3]-this.data.rect[1]-2);i=Math.min(a,A(r/js))}t.fontSize=`calc(${i}px * var(--scale-factor))`,t.color=nl.makeHexColor(e[0],e[1],e[2]),null!==this.data.textAlignment&&(t.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(r,e){e?r.setAttribute("required",!0):r.removeAttribute("required"),r.setAttribute("aria-required",e)}}class Ck extends Ek{constructor(r){super(r,{isRenderable:r.renderForms||r.data.hasOwnCanvas||!r.data.hasAppearance&&!!r.data.fieldValue})}setPropertyOnSiblings(r,e,a,t){const i=this.annotationStorage;for(const A of this._getElementsByName(r.name,r.id))A.domElement&&(A.domElement[e]=a),i.setValue(A.id,{[t]:a})}render(){var r,e;const a=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const A=a.getValue(t,{value:this.data.fieldValue});let n=A.value||"";const o=a.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&n.length>o&&(n=n.slice(0,o));let s=A.formattedValue||(null==(r=this.data.textContent)?void 0:r.join("\n"))||null;s&&this.data.comb&&(s=s.replaceAll(/\s+/g,""));const f={userValue:n,formattedValue:s,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=s??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",s??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),nm.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Am,this._setRequired(i,this.data.required),o&&(i.maxLength=o),i.addEventListener("input",(r=>{a.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(i,"value",r.target.value,"value"),f.formattedValue=null})),i.addEventListener("resetform",(r=>{const e=this.data.defaultFieldValue??"";i.value=f.userValue=e,f.formattedValue=null}));let l=r=>{const{formattedValue:e}=f;null!=e&&(r.target.value=e),r.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(r=>{var e;if(f.focused)return;const{target:a}=r;f.userValue&&(a.value=f.userValue),f.lastCommittedValue=a.value,f.commitKey=1,null!=(e=this.data.actions)&&e.Focus||(f.focused=!0)})),i.addEventListener("updatefromsandbox",(r=>{this.showElementAndHideCanvas(r.target);const e={value(r){f.userValue=r.detail.value??"",a.setValue(t,{value:f.userValue.toString()}),r.target.value=f.userValue},formattedValue(r){const{formattedValue:e}=r.detail;f.formattedValue=e,null!=e&&r.target!==document.activeElement&&(r.target.value=e),a.setValue(t,{formattedValue:e})},selRange(r){r.target.setSelectionRange(...r.detail.selRange)},charLimit:r=>{var e;const{charLimit:i}=r.detail,{target:A}=r;if(0===i)return void A.removeAttribute("maxLength");A.setAttribute("maxLength",i);let n=f.userValue;!n||n.length<=i||(n=n.slice(0,i),A.value=f.userValue=n,a.setValue(t,{value:n}),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:1,selStart:A.selectionStart,selEnd:A.selectionEnd}}))}};this._dispatchEventFromSandbox(e,r)})),i.addEventListener("keydown",(r=>{var e;f.commitKey=1;let a=-1;if("Escape"===r.key?a=0:"Enter"!==r.key||this.data.multiLine?"Tab"===r.key&&(f.commitKey=3):a=2,-1===a)return;const{value:i}=r.target;f.lastCommittedValue!==i&&(f.lastCommittedValue=i,f.userValue=i,null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:i,willCommit:!0,commitKey:a,selStart:r.target.selectionStart,selEnd:r.target.selectionEnd}}))}));const r=l;l=null,i.addEventListener("blur",(e=>{var a,i;if(!f.focused||!e.relatedTarget)return;null!=(a=this.data.actions)&&a.Blur||(f.focused=!1);const{value:A}=e.target;f.userValue=A,f.lastCommittedValue!==A&&(null==(i=this.linkService.eventBus)||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:A,willCommit:!0,commitKey:f.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})),r(e)})),null!=(e=this.data.actions)&&e.Keystroke&&i.addEventListener("beforeinput",(r=>{var e;f.lastCommittedValue=null;const{data:a,target:i}=r,{value:A,selectionStart:n,selectionEnd:o}=i;let s=n,l=o;switch(r.inputType){case"deleteWordBackward":{const r=A.substring(0,n).match(/\w*[^\w]*$/);r&&(s-=r[0].length);break}case"deleteWordForward":{const r=A.substring(n).match(/^[^\w]*\w*/);r&&(l+=r[0].length);break}case"deleteContentBackward":n===o&&(s-=1);break;case"deleteContentForward":n===o&&(l+=1)}r.preventDefault(),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:A,change:a||"",willCommit:!1,selStart:s,selEnd:l}})})),this._setEventListeners(i,f,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(r=>r.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const r=(this.data.rect[2]-this.data.rect[0])/o;i.classList.add("comb"),i.style.letterSpacing=`calc(${r}px * var(--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 Bk extends Ek{constructor(r){super(r,{isRenderable:!!r.data.hasOwnCanvas})}}class _k extends Ek{constructor(r){super(r,{isRenderable:r.renderForms})}render(){const r=this.annotationStorage,e=this.data,a=e.id;let t=r.getValue(a,{value:e.exportValue===e.fieldValue}).value;"string"==typeof t&&(t="Off"!==t,r.setValue(a,{value:t})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const i=document.createElement("input");return nm.add(i),i.setAttribute("data-element-id",a),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=e.fieldName,t&&i.setAttribute("checked",!0),i.setAttribute("exportValue",e.exportValue),i.tabIndex=Am,i.addEventListener("change",(t=>{const{name:i,checked:A}=t.target;for(const t of this._getElementsByName(i,a)){const a=A&&t.exportValue===e.exportValue;t.domElement&&(t.domElement.checked=a),r.setValue(t.id,{value:a})}r.setValue(a,{value:A})})),i.addEventListener("resetform",(r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue})),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",(e=>{const t={value(e){e.target.checked="Off"!==e.detail.value,r.setValue(a,{value:e.target.checked})}};this._dispatchEventFromSandbox(t,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"]],(r=>r.target.checked))),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Zk extends Ek{constructor(r){super(r,{isRenderable:r.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const r=this.annotationStorage,e=this.data,a=e.id;let t=r.getValue(a,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof t&&(t=t!==e.buttonValue,r.setValue(a,{value:t})),t)for(const t of this._getElementsByName(e.fieldName,a))r.setValue(t.id,{value:!1});const i=document.createElement("input");if(nm.add(i),i.setAttribute("data-element-id",a),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="radio",i.name=e.fieldName,t&&i.setAttribute("checked",!0),i.tabIndex=Am,i.addEventListener("change",(e=>{const{name:t,checked:i}=e.target;for(const e of this._getElementsByName(t,a))r.setValue(e.id,{value:!1});r.setValue(a,{value:i})})),i.addEventListener("resetform",(r=>{const a=e.defaultFieldValue;r.target.checked=null!=a&&a===e.buttonValue})),this.enableScripting&&this.hasJSActions){const t=e.buttonValue;i.addEventListener("updatefromsandbox",(e=>{const i={value:e=>{const i=t===e.detail.value;for(const t of this._getElementsByName(e.target.name)){const e=i&&t.id===a;t.domElement&&(t.domElement.checked=e),r.setValue(t.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"]],(r=>r.target.checked))}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Wk extends wk{constructor(r){super(r,{ignoreBorder:r.data.hasAppearance})}render(){const r=super.render();r.classList.add("buttonWidgetAnnotation","pushButton");const e=r.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(r=>{this._dispatchEventFromSandbox({},r)}))),r}}class Ik extends Ek{constructor(r){super(r,{isRenderable:r.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const r=this.annotationStorage,e=this.data.id,a=r.getValue(e,{value:this.data.fieldValue}),t=document.createElement("select");nm.add(t),t.setAttribute("data-element-id",e),t.disabled=this.data.readOnly,this._setRequired(t,this.data.required),t.name=this.data.fieldName,t.tabIndex=Am;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(t.size=this.data.options.length,this.data.multiSelect&&(t.multiple=!0)),t.addEventListener("resetform",(r=>{const e=this.data.defaultFieldValue;for(const r of t.options)r.selected=r.value===e}));for(const r of this.data.options){const e=document.createElement("option");e.textContent=r.displayValue,e.value=r.exportValue,a.value.includes(r.exportValue)&&(e.setAttribute("selected",!0),i=!1),t.append(e)}let A=null;if(i){const r=document.createElement("option");r.value=" ",r.setAttribute("hidden",!0),r.setAttribute("selected",!0),t.prepend(r),A=()=>{r.remove(),t.removeEventListener("input",A),A=null},t.addEventListener("input",A)}const n=r=>{const e=r?"value":"textContent",{options:a,multiple:i}=t;return i?Array.prototype.filter.call(a,(r=>r.selected)).map((r=>r[e])):-1===a.selectedIndex?null:a[a.selectedIndex][e]};let o=n(!1);const s=r=>{const e=r.target.options;return Array.prototype.map.call(e,(r=>({displayValue:r.textContent,exportValue:r.value})))};return this.enableScripting&&this.hasJSActions?(t.addEventListener("updatefromsandbox",(a=>{const i={value(a){null==A||A();const i=a.detail.value,s=new Set(Array.isArray(i)?i:[i]);for(const r of t.options)r.selected=s.has(r.value);r.setValue(e,{value:n(!0)}),o=n(!1)},multipleSelection(r){t.multiple=!0},remove(a){const i=t.options,A=a.detail.remove;i[A].selected=!1,t.remove(A),i.length>0&&-1===Array.prototype.findIndex.call(i,(r=>r.selected))&&(i[0].selected=!0),r.setValue(e,{value:n(!0),items:s(a)}),o=n(!1)},clear(a){for(;0!==t.length;)t.remove(0);r.setValue(e,{value:null,items:[]}),o=n(!1)},insert(a){const{index:i,displayValue:A,exportValue:f}=a.detail.insert,l=t.children[i],u=document.createElement("option");u.textContent=A,u.value=f,l?l.before(u):t.append(u),r.setValue(e,{value:n(!0),items:s(a)}),o=n(!1)},items(a){const{items:i}=a.detail;for(;0!==t.length;)t.remove(0);for(const r of i){const{displayValue:e,exportValue:a}=r,i=document.createElement("option");i.textContent=e,i.value=a,t.append(i)}t.options.length>0&&(t.options[0].selected=!0),r.setValue(e,{value:n(!0),items:s(a)}),o=n(!1)},indices(a){const t=new Set(a.detail.indices);for(const r of a.target.options)r.selected=t.has(r.index);r.setValue(e,{value:n(!0)}),o=n(!1)},editable(r){r.target.disabled=!r.detail.editable}};this._dispatchEventFromSandbox(i,a)})),t.addEventListener("input",(a=>{var t;const i=n(!0),A=n(!1);r.setValue(e,{value:i}),a.preventDefault(),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:A,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(t,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(r=>r.target.value))):t.addEventListener("input",(function(a){r.setValue(e,{value:n(!0)})})),this.data.combo&&this._setTextStyle(t),this._setBackgroundColor(t),this._setDefaultPropertiesFromJS(t),this.container.append(t),this.container}}class Rk extends bm{constructor(r){const{data:e,elements:a}=r;super(r,{isRenderable:bm._hasPopupData(e)}),this.elements=a,this.popup=null}render(){this.container.classList.add("popupAnnotation");const r=this.popup=new Fk({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const a of this.elements)a.popup=r,e.push(a.data.id),a.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((r=>`${ll}${r}`)).join(",")),this.container}}class Fk{constructor({container:r,color:e,elements:a,titleObj:n,modificationDate:s,contentsObj:f,richText:l,parent:u,rect:c,parentRect:d,open:h}){var b;i(this,Pm),i(this,Lm),i(this,Ym),i(this,Qm),i(this,Jm),i(this,qm),i(this,Km),i(this,ek),i(this,tk),i(this,ym,o(this,Jm,zm).bind(this)),i(this,Em,o(this,tk,ik).bind(this)),i(this,Cm,o(this,ek,ak).bind(this)),i(this,Bm,o(this,Km,rk).bind(this)),i(this,_m,null),i(this,Zm,null),i(this,Wm,null),i(this,Im,null),i(this,Rm,null),i(this,Fm,null),i(this,Sm,null),i(this,xm,!1),i(this,Mm,null),i(this,Gm,null),i(this,Xm,null),i(this,Vm,null),i(this,Nm,null),i(this,Dm,null),i(this,Tm,!1),A(this,Zm,r),A(this,Nm,n),A(this,Wm,f),A(this,Vm,l),A(this,Fm,u),A(this,_m,e),A(this,Xm,c),A(this,Sm,d),A(this,Rm,a),A(this,Im,mu.toDateObject(s)),this.trigger=a.flatMap((r=>r.getElementsToTriggerPopup()));for(const r of this.trigger)r.addEventListener("click",t(this,Bm)),r.addEventListener("mouseenter",t(this,Cm)),r.addEventListener("mouseleave",t(this,Em)),r.classList.add("popupTriggerArea");for(const r of a)null==(b=r.container)||b.addEventListener("keydown",t(this,ym));t(this,Zm).hidden=!0,h&&o(this,Km,rk).call(this)}render(){if(t(this,Mm))return;const r=A(this,Mm,document.createElement("div"));if(r.className="popup",t(this,_m)){const e=r.style.outlineColor=nl.makeHexColor(...t(this,_m));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?r.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:r.style.backgroundColor=nl.makeHexColor(...t(this,_m).map((r=>Math.floor(.7*(255-r)+r))))}const e=document.createElement("span");e.className="header";const a=document.createElement("h1");if(e.append(a),({dir:a.dir,str:a.textContent}=t(this,Nm)),r.append(e),t(this,Im)){const r=document.createElement("span");r.classList.add("popupDate"),r.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),r.setAttribute("data-l10n-args",JSON.stringify({date:t(this,Im).toLocaleDateString(),time:t(this,Im).toLocaleTimeString()})),e.append(r)}const i=t(this,Pm,jm);if(i)im.render({xfaHtml:i,intent:"richText",div:r}),r.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(t(this,Wm));r.append(e)}t(this,Zm).append(r)}_formatContents({str:r,dir:e}){const a=document.createElement("p");a.classList.add("popupContent"),a.dir=e;const t=r.split(/(?:\r\n?|\n)/);for(let r=0,e=t.length;r<e;++r){const i=t[r];a.append(document.createTextNode(i)),r<e-1&&a.append(document.createElement("br"))}return a}updateEdited({rect:r,popupContent:e}){var a;t(this,Dm)||A(this,Dm,{contentsObj:t(this,Wm),richText:t(this,Vm)}),r&&A(this,Gm,null),e&&(A(this,Vm,o(this,Qm,Um).call(this,e)),A(this,Wm,null)),null==(a=t(this,Mm))||a.remove(),A(this,Mm,null)}resetEdited(){var r;t(this,Dm)&&(({contentsObj:n(this,Wm)._,richText:n(this,Vm)._}=t(this,Dm)),A(this,Dm,null),null==(r=t(this,Mm))||r.remove(),A(this,Mm,null),A(this,Gm,null))}forceHide(){A(this,Tm,this.isVisible),t(this,Tm)&&(t(this,Zm).hidden=!0)}maybeShow(){t(this,Tm)&&(t(this,Mm)||o(this,ek,ak).call(this),A(this,Tm,!1),t(this,Zm).hidden=!1)}get isVisible(){return!1===t(this,Zm).hidden}}ym=new WeakMap,Em=new WeakMap,Cm=new WeakMap,Bm=new WeakMap,_m=new WeakMap,Zm=new WeakMap,Wm=new WeakMap,Im=new WeakMap,Rm=new WeakMap,Fm=new WeakMap,Sm=new WeakMap,xm=new WeakMap,Mm=new WeakMap,Gm=new WeakMap,Xm=new WeakMap,Vm=new WeakMap,Nm=new WeakMap,Dm=new WeakMap,Tm=new WeakMap,Pm=new WeakSet,jm=function(){const r=t(this,Vm),e=t(this,Wm);return null!=r&&r.str&&(!(null!=e&&e.str)||e.str===r.str)&&t(this,Vm).html||null},Lm=new WeakSet,Om=function(){var r,e,a;return(null==(a=null==(e=null==(r=t(this,Pm,jm))?void 0:r.attributes)?void 0:e.style)?void 0:a.fontSize)||0},Ym=new WeakSet,Hm=function(){var r,e,a;return(null==(a=null==(e=null==(r=t(this,Pm,jm))?void 0:r.attributes)?void 0:e.style)?void 0:a.color)||null},Qm=new WeakSet,Um=function(r){const e=[],a={str:r,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:t(this,Ym,Hm),fontSize:t(this,Lm,Om)?`calc(${t(this,Lm,Om)}px * var(--scale-factor))`:""}};for(const a of r.split("\n"))e.push({name:"span",value:a,attributes:i});return a},Jm=new WeakSet,zm=function(r){r.altKey||r.shiftKey||r.ctrlKey||r.metaKey||("Enter"===r.key||"Escape"===r.key&&t(this,xm))&&o(this,Km,rk).call(this)},qm=new WeakSet,$m=function(){if(null!==t(this,Gm))return;const{page:{view:r},viewport:{rawDims:{pageWidth:e,pageHeight:a,pageX:i,pageY:n}}}=t(this,Fm);let o=!!t(this,Sm),s=t(this,o?Sm:Xm);for(const r of t(this,Rm))if(!s||null!==nl.intersect(r.data.rect,s)){s=r.data.rect,o=!0;break}const f=nl.normalizeRect([s[0],r[3]-s[1]+r[1],s[2],r[3]-s[3]+r[1]]),l=o?s[2]-s[0]+5:0,u=f[0]+l,c=f[1];A(this,Gm,[100*(u-i)/e,100*(c-n)/a]);const{style:d}=t(this,Zm);d.left=`${t(this,Gm)[0]}%`,d.top=`${t(this,Gm)[1]}%`},Km=new WeakSet,rk=function(){A(this,xm,!t(this,xm)),t(this,xm)?(o(this,ek,ak).call(this),t(this,Zm).addEventListener("click",t(this,Bm)),t(this,Zm).addEventListener("keydown",t(this,ym))):(o(this,tk,ik).call(this),t(this,Zm).removeEventListener("click",t(this,Bm)),t(this,Zm).removeEventListener("keydown",t(this,ym)))},ek=new WeakSet,ak=function(){t(this,Mm)||this.render(),this.isVisible?t(this,xm)&&t(this,Zm).classList.add("focused"):(o(this,qm,$m).call(this),t(this,Zm).hidden=!1,t(this,Zm).style.zIndex=parseInt(t(this,Zm).style.zIndex)+1e3)},tk=new WeakSet,ik=function(){t(this,Zm).classList.remove("focused"),!t(this,xm)&&this.isVisible&&(t(this,Zm).hidden=!0,t(this,Zm).style.zIndex=parseInt(t(this,Zm).style.zIndex)-1e3)};class Sk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),this.textContent=r.data.textContent,this.textPosition=r.data.textPosition,this.annotationEditorType=qs.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const r=document.createElement("div");r.classList.add("annotationTextContent"),r.setAttribute("role","comment");for(const e of this.textContent){const a=document.createElement("span");a.textContent=e,r.append(a)}this.container.append(r)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class xk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,Ak,null)}render(){this.container.classList.add("lineAnnotation");const r=this.data,{width:e,height:a}=om(r.rect),t=this.svgFactory.create(e,a,!0),i=A(this,Ak,this.svgFactory.createElement("svg:line"));return i.setAttribute("x1",r.rect[2]-r.lineCoordinates[0]),i.setAttribute("y1",r.rect[3]-r.lineCoordinates[1]),i.setAttribute("x2",r.rect[2]-r.lineCoordinates[2]),i.setAttribute("y2",r.rect[3]-r.lineCoordinates[3]),i.setAttribute("stroke-width",r.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),t.append(i),this.container.append(t),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,Ak)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ak=new WeakMap;class Mk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,nk,null)}render(){this.container.classList.add("squareAnnotation");const r=this.data,{width:e,height:a}=om(r.rect),t=this.svgFactory.create(e,a,!0),i=r.borderStyle.width,n=A(this,nk,this.svgFactory.createElement("svg:rect"));return n.setAttribute("x",i/2),n.setAttribute("y",i/2),n.setAttribute("width",e-i),n.setAttribute("height",a-i),n.setAttribute("stroke-width",i||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),t.append(n),this.container.append(t),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,nk)}addHighlightArea(){this.container.classList.add("highlightArea")}}nk=new WeakMap;class Gk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,ok,null)}render(){this.container.classList.add("circleAnnotation");const r=this.data,{width:e,height:a}=om(r.rect),t=this.svgFactory.create(e,a,!0),i=r.borderStyle.width,n=A(this,ok,this.svgFactory.createElement("svg:ellipse"));return n.setAttribute("cx",e/2),n.setAttribute("cy",a/2),n.setAttribute("rx",e/2-i/2),n.setAttribute("ry",a/2-i/2),n.setAttribute("stroke-width",i||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),t.append(n),this.container.append(t),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,ok)}addHighlightArea(){this.container.classList.add("highlightArea")}}ok=new WeakMap;class Xk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,sk,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,vertices:e,borderStyle:a,popupRef:t}}=this;if(!e)return this.container;const{width:i,height:n}=om(r),o=this.svgFactory.create(i,n,!0);let s=[];for(let a=0,t=e.length;a<t;a+=2){const t=e[a]-r[0],i=r[3]-e[a+1];s.push(`${t},${i}`)}s=s.join(" ");const f=A(this,sk,this.svgFactory.createElement(this.svgElementName));return f.setAttribute("points",s),f.setAttribute("stroke-width",a.width||1),f.setAttribute("stroke","transparent"),f.setAttribute("fill","transparent"),o.append(f),this.container.append(o),!t&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,sk)}addHighlightArea(){this.container.classList.add("highlightArea")}}sk=new WeakMap;class Vk extends Xk{constructor(r){super(r),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Nk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Dk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,fk,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=qs.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,inkLists:e,borderStyle:a,popupRef:i}}=this,{width:A,height:n}=om(r),o=this.svgFactory.create(A,n,!0);for(const A of e){let e=[];for(let a=0,t=A.length;a<t;a+=2){const t=A[a]-r[0],i=r[3]-A[a+1];e.push(`${t},${i}`)}e=e.join(" ");const n=this.svgFactory.createElement(this.svgElementName);t(this,fk).push(n),n.setAttribute("points",e),n.setAttribute("stroke-width",a.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),!i&&this.hasPopupData&&this._createPopup(),o.append(n)}return this.container.append(o),this.container}getElementsToTriggerPopup(){return t(this,fk)}addHighlightArea(){this.container.classList.add("highlightArea")}}fk=new WeakMap;class Tk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class Pk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class jk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Lk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Ok extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Yk extends bm{constructor(r){var e;super(r,{isRenderable:!0}),i(this,uk),i(this,lk,null);const{file:a}=this.data;this.filename=a.filename,this.content=a.content,null==(e=this.linkService.eventBus)||e.dispatch("fileattachmentannotation",{source:this,...a})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:r,data:e}=this;let a;e.hasAppearance||0===e.fillAlpha?a=document.createElement("div"):(a=document.createElement("img"),a.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(a.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),a.addEventListener("dblclick",o(this,uk,ck).bind(this)),A(this,lk,a);const{isMac:t}=rl.platform;return r.addEventListener("keydown",(r=>{"Enter"===r.key&&(t?r.metaKey:r.ctrlKey)&&o(this,uk,ck).call(this)})),!e.popupRef&&this.hasPopupData?this._createPopup():a.classList.add("popupTriggerArea"),r.append(a),r}getElementsToTriggerPopup(){return t(this,lk)}addHighlightArea(){this.container.classList.add("highlightArea")}}lk=new WeakMap,uk=new WeakSet,ck=function(){var r;null==(r=this.downloadManager)||r.openOrDownloadData(this.content,this.filename)};let Hk=(kk=class{constructor({div:r,accessibilityManager:e,annotationCanvasMap:a,annotationEditorUIManager:t,page:n,viewport:o}){i(this,gk),i(this,vk),i(this,dk,null),i(this,hk,null),i(this,bk,new Map),this.div=r,A(this,dk,e),A(this,hk,a),this.page=n,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=t}async render(r){var e;const{annotations:a}=r,i=this.div;Cu(i,this.viewport);const A=new Map,n={data:null,layer:i,linkService:r.linkService,downloadManager:r.downloadManager,imageResourcesPath:r.imageResourcesPath||"",renderForms:!1!==r.renderForms,svgFactory:new ou,annotationStorage:r.annotationStorage||new kb,enableScripting:!0===r.enableScripting,hasJSActions:r.hasJSActions,fieldObjects:r.fieldObjects,parent:this,elements:null};for(const r of a){if(r.noHTML)continue;const a=r.annotationType===Ef;if(a){const e=A.get(r.id);if(!e)continue;n.elements=e}else{const{width:e,height:a}=om(r.rect);if(e<=0||a<=0)continue}n.data=r;const i=sm.create(n);if(!i.isRenderable)continue;if(!a&&r.popupRef){const e=A.get(r.popupRef);e?e.push(i):A.set(r.popupRef,[i])}const s=i.render();r.hidden&&(s.style.visibility="hidden"),o(this,gk,pk).call(this,s,r.id),i.annotationEditorType>0&&(t(this,bk).set(i.data.id,i),null==(e=this._annotationEditorUIManager)||e.renderAnnotationElement(i))}o(this,vk,mk).call(this)}update({viewport:r}){const e=this.div;this.viewport=r,Cu(e,{rotation:r.rotation}),o(this,vk,mk).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(t(this,bk).values())}getEditableAnnotation(r){return t(this,bk).get(r)}},dk=new WeakMap,hk=new WeakMap,bk=new WeakMap,gk=new WeakSet,pk=function(r,e){var a;const i=r.firstChild||r;i.id=`${ll}${e}`,this.div.append(r),null==(a=t(this,dk))||a.moveElementInDOM(this.div,r,i,!1)},vk=new WeakSet,mk=function(){if(!t(this,hk))return;const r=this.div;for(const[e,a]of t(this,hk)){const t=r.querySelector(`[data-annotation-id="${e}"]`);if(!t)continue;a.className="annotationContent";const{firstChild:i}=t;i?"CANVAS"===i.nodeName?i.replaceWith(a):i.classList.contains("annotationContent")?i.after(a):i.before(a):t.append(a)}t(this,hk).clear()},kk);const Qk=/\r\n?|\n/g;var Uk,Jk,zk,qk,$k,Kk,rw,ew,aw,tw,iw,Aw,nw,ow,sw,fw,lw,uw,cw,dw,hw,bw,gw,pw,vw,mw,kw,ww;const yw=class extends ob{constructor(r){super({...r,name:"freeTextEditor"}),i(this,iw),i(this,nw),i(this,sw),i(this,lw),i(this,hw),i(this,gw),i(this,kw),i(this,Uk,this.editorDivBlur.bind(this)),i(this,Jk,this.editorDivFocus.bind(this)),i(this,zk,this.editorDivInput.bind(this)),i(this,qk,this.editorDivKeydown.bind(this)),i(this,$k,this.editorDivPaste.bind(this)),i(this,Kk,void 0),i(this,rw,""),i(this,ew,`${this.id}-editor`),i(this,aw,void 0),i(this,tw,null),A(this,Kk,r.color||yw._defaultColor||ob._defaultLineColor),A(this,aw,r.fontSize||yw._defaultFontSize)}static get _keyboardManager(){const r=yw.prototype,e=r=>r.isEmpty(),a=$d.TRANSLATE_SMALL,t=$d.TRANSLATE_BIG;return jf(this,"_keyboardManager",new gc([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],r.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],r.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],r._translateEmpty,{args:[-a,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r._translateEmpty,{args:[-t,0],checker:e}],[["ArrowRight","mac+ArrowRight"],r._translateEmpty,{args:[a,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r._translateEmpty,{args:[t,0],checker:e}],[["ArrowUp","mac+ArrowUp"],r._translateEmpty,{args:[0,-a],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r._translateEmpty,{args:[0,-t],checker:e}],[["ArrowDown","mac+ArrowDown"],r._translateEmpty,{args:[0,a],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r._translateEmpty,{args:[0,t],checker:e}]]))}static initialize(r,e){ob.initialize(r,e,{strings:["pdfjs-free-text-default-content"]});const a=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(a.getPropertyValue("--freetext-padding"))}static updateDefaultParams(r,e){switch(r){case $s.FREETEXT_SIZE:yw._defaultFontSize=e;break;case $s.FREETEXT_COLOR:yw._defaultColor=e}}updateParams(r,e){switch(r){case $s.FREETEXT_SIZE:o(this,iw,Aw).call(this,e);break;case $s.FREETEXT_COLOR:o(this,nw,ow).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$s.FREETEXT_SIZE,yw._defaultFontSize],[$s.FREETEXT_COLOR,yw._defaultColor||ob._defaultLineColor]]}get propertiesToUpdate(){return[[$s.FREETEXT_SIZE,t(this,aw)],[$s.FREETEXT_COLOR,t(this,Kk)]]}_translateEmpty(r,e){this._uiManager.translateSelectedEditors(r,e,!0)}getInitialTranslation(){const r=this.parentScale;return[-yw._internalPadding*r,-(yw._internalPadding+t(this,aw))*r]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(qs.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const r=this._uiManager._signal;this.editorDiv.addEventListener("keydown",t(this,qk),{signal:r}),this.editorDiv.addEventListener("focus",t(this,Jk),{signal:r}),this.editorDiv.addEventListener("blur",t(this,Uk),{signal:r}),this.editorDiv.addEventListener("input",t(this,zk),{signal:r}),this.editorDiv.addEventListener("paste",t(this,$k),{signal:r})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",t(this,ew)),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",t(this,qk)),this.editorDiv.removeEventListener("focus",t(this,Jk)),this.editorDiv.removeEventListener("blur",t(this,Uk)),this.editorDiv.removeEventListener("input",t(this,zk)),this.editorDiv.removeEventListener("paste",t(this,$k)),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(r){this._focusEventsAllowed&&(super.focusin(r),r.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var r;this.width||(this.enableEditMode(),this.editorDiv.focus(),null!=(r=this._initialOptions)&&r.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 r=t(this,rw),e=A(this,rw,o(this,sw,fw).call(this).trimEnd());if(r===e)return;const a=r=>{A(this,rw,r),r?(o(this,hw,bw).call(this),this._uiManager.rebuild(this),o(this,lw,uw).call(this)):this.remove()};this.addCommands({cmd:()=>{a(e)},undo:()=>{a(r)},mustExec:!1}),o(this,lw,uw).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(r){this.enterInEditMode()}keydown(r){r.target===this.div&&"Enter"===r.key&&(this.enterInEditMode(),r.preventDefault())}editorDivKeydown(r){yw._keyboardManager.exec(this,r)}editorDivFocus(r){this.isEditing=!0}editorDivBlur(r){this.isEditing=!1}editorDivInput(r){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let r,e;this.width&&(r=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",t(this,ew)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),ob._l10nPromise.get("pdfjs-free-text-default-content").then((r=>{var e;return null==(e=this.editorDiv)?void 0:e.setAttribute("default-content",r)})),this.editorDiv.contentEditable=!0;const{style:a}=this.editorDiv;if(a.fontSize=`calc(${t(this,aw)}px * var(--scale-factor))`,a.color=t(this,Kk),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Ac(this,this.div,["dblclick","keydown"]),this.width){const[a,i]=this.parentDimensions;if(this.annotationElementId){const{position:A}=t(this,tw);let[n,o]=this.getInitialTranslation();[n,o]=this.pageTranslationToScreen(n,o);const[s,f]=this.pageDimensions,[l,u]=this.pageTranslation;let c,d;switch(this.rotation){case 0:c=r+(A[0]-l)/s,d=e+this.height-(A[1]-u)/f;break;case 90:c=r+(A[0]-l)/s,d=e-(A[1]-u)/f,[n,o]=[o,-n];break;case 180:c=r-this.width+(A[0]-l)/s,d=e-(A[1]-u)/f,[n,o]=[-n,-o];break;case 270:c=r+(A[0]-l-this.height*f)/s,d=e+(A[1]-u-this.width*s)/f,[n,o]=[-o,n]}this.setAt(c*a,d*i,n,o)}else this.setAt(r*a,e*i,this.width*a,this.height*i);o(this,hw,bw).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(r){var e,a,t;const i=r.clipboardData||window.clipboardData,{types:n}=i;if(1===n.length&&"text/plain"===n[0])return;r.preventDefault();const s=o(e=yw,vw,mw).call(e,i.getData("text")||"").replaceAll(Qk,"\n");if(!s)return;const f=window.getSelection();if(!f.rangeCount)return;this.editorDiv.normalize(),f.deleteFromDocument();const l=f.getRangeAt(0);if(!s.includes("\n"))return l.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void f.collapseToStart();const{startContainer:u,startOffset:c}=l,d=[],h=[];if(u.nodeType===Node.TEXT_NODE){const r=u.parentElement;if(h.push(u.nodeValue.slice(c).replaceAll(Qk,"")),r!==this.editorDiv){let e=d;for(const t of this.editorDiv.childNodes)t!==r?e.push(o(a=yw,cw,dw).call(a,t)):e=h}d.push(u.nodeValue.slice(0,c).replaceAll(Qk,""))}else if(u===this.editorDiv){let r=d,e=0;for(const a of this.editorDiv.childNodes)e++===c&&(r=h),r.push(o(t=yw,cw,dw).call(t,a))}A(this,rw,`${d.join("\n")}${s}${h.join("\n")}`),o(this,hw,bw).call(this);const b=new Range;let g=d.reduce(((r,e)=>r+e.length),0);for(const{firstChild:r}of this.editorDiv.childNodes)if(r.nodeType===Node.TEXT_NODE){const e=r.nodeValue.length;if(g<=e){b.setStart(r,g),b.setEnd(r,g);break}g-=e}f.removeAllRanges(),f.addRange(b)}get contentDiv(){return this.editorDiv}static deserialize(r,e,a){var t;let i=null;if(r instanceof Sk){const{data:{defaultAppearanceData:{fontSize:e,fontColor:a},rect:t,rotation:A,id:n},textContent:o,textPosition:s,parent:{page:{pageNumber:f}}}=r;if(!o||0===o.length)return null;i=r={annotationType:qs.FREETEXT,color:Array.from(a),fontSize:e,value:o.join("\n"),position:s,pageIndex:f-1,rect:t.slice(0),rotation:A,id:n,deleted:!1}}const n=super.deserialize(r,e,a);return A(n,aw,r.fontSize),A(n,Kk,nl.makeHexColor(...r.color)),A(n,rw,o(t=yw,vw,mw).call(t,r.value)),n.annotationElementId=r.id||null,A(n,tw,i),n}serialize(r=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=yw._internalPadding*this.parentScale,a=this.getRect(e,e),i=ob._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:t(this,Kk)),A={annotationType:qs.FREETEXT,color:i,fontSize:t(this,aw),value:o(this,gw,pw).call(this),pageIndex:this.pageIndex,rect:a,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return r?A:this.annotationElementId&&!o(this,kw,ww).call(this,A)?null:(A.id=this.annotationElementId,A)}renderAnnotationElement(r){const e=super.renderAnnotationElement(r);if(this.deleted)return e;const{style:a}=e;a.fontSize=`calc(${t(this,aw)}px * var(--scale-factor))`,a.color=t(this,Kk),e.replaceChildren();for(const r of t(this,rw).split("\n")){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),e.append(a)}const i=yw._internalPadding*this.parentScale;return r.updateEdited({rect:this.getRect(i,i),popupContent:t(this,rw)}),e}resetAnnotationElement(r){super.resetAnnotationElement(r),r.resetEdited()}};let Ew=yw;var Cw,Bw,_w,Zw,Ww,Iw,Rw,Fw,Sw,xw,Mw,Gw,Xw,Vw,Nw,Dw,Tw,Pw,jw,Lw,Ow,Yw,Hw,Qw,Uw,Jw,zw,qw,$w,Kw,ry,ey,ay;Uk=new WeakMap,Jk=new WeakMap,zk=new WeakMap,qk=new WeakMap,$k=new WeakMap,Kk=new WeakMap,rw=new WeakMap,ew=new WeakMap,aw=new WeakMap,tw=new WeakMap,iw=new WeakSet,Aw=function(r){const e=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-t(this,aw))*this.parentScale),A(this,aw,r),o(this,lw,uw).call(this)},a=t(this,aw);this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},nw=new WeakSet,ow=function(r){const e=r=>{A(this,Kk,this.editorDiv.style.color=r)},a=t(this,Kk);this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},sw=new WeakSet,fw=function(){var r;const e=[];this.editorDiv.normalize();for(const a of this.editorDiv.childNodes)e.push(o(r=yw,cw,dw).call(r,a));return e.join("\n")},lw=new WeakSet,uw=function(){const[r,e]=this.parentDimensions;let a;if(this.isAttachedToDOM)a=this.div.getBoundingClientRect();else{const{currentLayer:r,div:e}=this,t=e.style.display,i=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",r.div.append(this.div),a=e.getBoundingClientRect(),e.remove(),e.style.display=t,e.classList.toggle("hidden",i)}this.rotation%180==this.parentRotation%180?(this.width=a.width/r,this.height=a.height/e):(this.width=a.height/r,this.height=a.width/e),this.fixAndSetPosition()},cw=new WeakSet,dw=function(r){return(r.nodeType===Node.TEXT_NODE?r.nodeValue:r.innerText).replaceAll(Qk,"")},hw=new WeakSet,bw=function(){if(this.editorDiv.replaceChildren(),t(this,rw))for(const r of t(this,rw).split("\n")){const e=document.createElement("div");e.append(r?document.createTextNode(r):document.createElement("br")),this.editorDiv.append(e)}},gw=new WeakSet,pw=function(){return t(this,rw).replaceAll(" "," ")},vw=new WeakSet,mw=function(r){return r.replaceAll(" "," ")},kw=new WeakSet,ww=function(r){const{value:e,fontSize:a,color:i,pageIndex:A}=t(this,tw);return this._hasBeenMoved||r.value!==e||r.fontSize!==a||r.color.some(((r,e)=>r!==i[e]))||r.pageIndex!==A},i(Ew,cw),i(Ew,vw),e(Ew,"_freeTextDefaultContent",""),e(Ew,"_internalPadding",0),e(Ew,"_defaultColor",null),e(Ew,"_defaultFontSize",10),e(Ew,"_type","freetext"),e(Ew,"_editorType",qs.FREETEXT);class ty{constructor(r,e=0,a=0,n=!0){i(this,Zw),i(this,Iw),i(this,Fw),i(this,xw),i(this,Gw),i(this,Cw,void 0),i(this,Bw,[]),i(this,_w,[]);let o=1/0,s=-1/0,f=1/0,l=-1/0;const u=10**-4;for(const{x:a,y:i,width:A,height:n}of r){const r=Math.floor((a-e)/u)*u,c=Math.ceil((a+A+e)/u)*u,d=Math.floor((i-e)/u)*u,h=Math.ceil((i+n+e)/u)*u,b=[r,d,h,!0],g=[c,d,h,!1];t(this,Bw).push(b,g),o=Math.min(o,r),s=Math.max(s,c),f=Math.min(f,d),l=Math.max(l,h)}const c=s-o+2*a,d=l-f+2*a,h=o-a,b=f-a,g=t(this,Bw).at(n?-1:-2),p=[g[0],g[2]];for(const r of t(this,Bw)){const[e,a,t]=r;r[0]=(e-h)/c,r[1]=(a-b)/d,r[2]=(t-b)/d}A(this,Cw,{x:h,y:b,width:c,height:d,lastPoint:p})}getOutlines(){t(this,Bw).sort(((r,e)=>r[0]-e[0]||r[1]-e[1]||r[2]-e[2]));const r=[];for(const e of t(this,Bw))e[3]?(r.push(...o(this,Gw,Xw).call(this,e)),o(this,Fw,Sw).call(this,e)):(o(this,xw,Mw).call(this,e),r.push(...o(this,Gw,Xw).call(this,e)));return o(this,Zw,Ww).call(this,r)}}Cw=new WeakMap,Bw=new WeakMap,_w=new WeakMap,Zw=new WeakSet,Ww=function(r){const e=[],a=new Set;for(const a of r){const[r,t,i]=a;e.push([r,t,a],[r,i,a])}e.sort(((r,e)=>r[1]-e[1]||r[0]-e[0]));for(let r=0,t=e.length;r<t;r+=2){const t=e[r][2],i=e[r+1][2];t.push(i),i.push(t),a.add(t),a.add(i)}const i=[];let A;for(;a.size>0;){const r=a.values().next().value;let[e,t,n,o,s]=r;a.delete(r);let f=e,l=t;for(A=[e,n],i.push(A);;){let r;if(a.has(o))r=o;else{if(!a.has(s))break;r=s}a.delete(r),[e,t,n,o,s]=r,f!==e&&(A.push(f,l,e,l===t?t:n),f=e),l=l===t?n:t}A.push(f,l)}return new Ay(i,t(this,Cw))},Iw=new WeakSet,Rw=function(r){const e=t(this,_w);let a=0,i=e.length-1;for(;a<=i;){const t=a+i>>1,A=e[t][0];if(A===r)return t;A<r?a=t+1:i=t-1}return i+1},Fw=new WeakSet,Sw=function([,r,e]){const a=o(this,Iw,Rw).call(this,r);t(this,_w).splice(a,0,[r,e])},xw=new WeakSet,Mw=function([,r,e]){const a=o(this,Iw,Rw).call(this,r);for(let i=a;i<t(this,_w).length;i++){const[a,A]=t(this,_w)[i];if(a!==r)break;if(a===r&&A===e)return void t(this,_w).splice(i,1)}for(let i=a-1;i>=0;i--){const[a,A]=t(this,_w)[i];if(a!==r)break;if(a===r&&A===e)return void t(this,_w).splice(i,1)}},Gw=new WeakSet,Xw=function(r){const[e,a,i]=r,A=[[e,a,i]],n=o(this,Iw,Rw).call(this,i);for(let r=0;r<n;r++){const[a,i]=t(this,_w)[r];for(let r=0,t=A.length;r<t;r++){const[,n,o]=A[r];if(!(i<=n||o<=a)){if(n>=a){if(o>i)A[r][1]=i;else{if(1===t)return[];A.splice(r,1),r--,t--}continue}A[r][2]=a,o>i&&A.push([e,i,o])}}}return A};class iy{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(r,e){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof Yy}}class Ay extends iy{constructor(r,e){super(),i(this,Vw,void 0),i(this,Nw,void 0),A(this,Nw,r),A(this,Vw,e)}toSVGPath(){const r=[];for(const e of t(this,Nw)){let[a,t]=e;r.push(`M${a} ${t}`);for(let i=2;i<e.length;i+=2){const A=e[i],n=e[i+1];A===a?(r.push(`V${n}`),t=n):n===t&&(r.push(`H${A}`),a=A)}r.push("Z")}return r.join(" ")}serialize([r,e,a,i],A){const n=[],o=a-r,s=i-e;for(const e of t(this,Nw)){const a=new Array(e.length);for(let t=0;t<e.length;t+=2)a[t]=r+e[t]*o,a[t+1]=i-e[t+1]*s;n.push(a)}return n}get box(){return t(this,Vw)}}Vw=new WeakMap,Nw=new WeakMap;const ny=class{constructor({x:r,y:e},a,n,o,s,f=0){i(this,ey),i(this,Dw,void 0),i(this,Tw,[]),i(this,Pw,void 0),i(this,jw,void 0),i(this,Lw,[]),i(this,Ow,new Float64Array(18)),i(this,Yw,void 0),i(this,Hw,void 0),i(this,Qw,void 0),i(this,Uw,void 0),i(this,Jw,void 0),i(this,zw,void 0),i(this,qw,[]),A(this,Dw,a),A(this,zw,o*n),A(this,jw,s),t(this,Ow).set([NaN,NaN,NaN,NaN,r,e],6),A(this,Pw,f),A(this,Uw,t(ny,$w)*n),A(this,Qw,t(ny,ry)*n),A(this,Jw,n),t(this,qw).push(r,e)}get free(){return!0}isEmpty(){return isNaN(t(this,Ow)[8])}add({x:r,y:e}){var a;A(this,Yw,r),A(this,Hw,e);const[i,n,o,s]=t(this,Dw);let[f,l,u,c]=t(this,Ow).subarray(8,12);const d=r-u,h=e-c,b=Math.hypot(d,h);if(b<t(this,Qw))return!1;const g=b-t(this,Uw),p=g/b,v=p*d,m=p*h;let k=f,w=l;f=u,l=c,u+=v,c+=m,null==(a=t(this,qw))||a.push(r,e);const y=v/g,E=-m/g*t(this,zw),C=y*t(this,zw);return t(this,Ow).set(t(this,Ow).subarray(2,8),0),t(this,Ow).set([u+E,c+C],4),t(this,Ow).set(t(this,Ow).subarray(14,18),12),t(this,Ow).set([u-E,c-C],16),isNaN(t(this,Ow)[6])?(0===t(this,Lw).length&&(t(this,Ow).set([f+E,l+C],2),t(this,Lw).push(NaN,NaN,NaN,NaN,(f+E-i)/o,(l+C-n)/s),t(this,Ow).set([f-E,l-C],14),t(this,Tw).push(NaN,NaN,NaN,NaN,(f-E-i)/o,(l-C-n)/s)),t(this,Ow).set([k,w,f,l,u,c],6),!this.isEmpty()):(t(this,Ow).set([k,w,f,l,u,c],6),Math.abs(Math.atan2(w-l,k-f)-Math.atan2(m,v))<Math.PI/2?([f,l,u,c]=t(this,Ow).subarray(2,6),t(this,Lw).push(NaN,NaN,NaN,NaN,((f+u)/2-i)/o,((l+c)/2-n)/s),[f,l,k,w]=t(this,Ow).subarray(14,18),t(this,Tw).push(NaN,NaN,NaN,NaN,((k+f)/2-i)/o,((w+l)/2-n)/s),!0):([k,w,f,l,u,c]=t(this,Ow).subarray(0,6),t(this,Lw).push(((k+5*f)/6-i)/o,((w+5*l)/6-n)/s,((5*f+u)/6-i)/o,((5*l+c)/6-n)/s,((f+u)/2-i)/o,((l+c)/2-n)/s),[u,c,f,l,k,w]=t(this,Ow).subarray(12,18),t(this,Tw).push(((k+5*f)/6-i)/o,((w+5*l)/6-n)/s,((5*f+u)/6-i)/o,((5*l+c)/6-n)/s,((f+u)/2-i)/o,((l+c)/2-n)/s),!0))}toSVGPath(){if(this.isEmpty())return"";const r=t(this,Lw),e=t(this,Tw),a=t(this,Ow).subarray(4,6),i=t(this,Ow).subarray(16,18),[A,n,s,f]=t(this,Dw),[l,u,c,d]=o(this,ey,ay).call(this);if(isNaN(t(this,Ow)[6])&&!this.isEmpty())return`M${(t(this,Ow)[2]-A)/s} ${(t(this,Ow)[3]-n)/f} L${(t(this,Ow)[4]-A)/s} ${(t(this,Ow)[5]-n)/f} L${l} ${u} L${c} ${d} L${(t(this,Ow)[16]-A)/s} ${(t(this,Ow)[17]-n)/f} L${(t(this,Ow)[14]-A)/s} ${(t(this,Ow)[15]-n)/f} Z`;const h=[];h.push(`M${r[4]} ${r[5]}`);for(let e=6;e<r.length;e+=6)isNaN(r[e])?h.push(`L${r[e+4]} ${r[e+5]}`):h.push(`C${r[e]} ${r[e+1]} ${r[e+2]} ${r[e+3]} ${r[e+4]} ${r[e+5]}`);h.push(`L${(a[0]-A)/s} ${(a[1]-n)/f} L${l} ${u} L${c} ${d} L${(i[0]-A)/s} ${(i[1]-n)/f}`);for(let r=e.length-6;r>=6;r-=6)isNaN(e[r])?h.push(`L${e[r+4]} ${e[r+5]}`):h.push(`C${e[r]} ${e[r+1]} ${e[r+2]} ${e[r+3]} ${e[r+4]} ${e[r+5]}`);return h.push(`L${e[4]} ${e[5]} Z`),h.join(" ")}getOutlines(){var r;const e=t(this,Lw),a=t(this,Tw),i=t(this,Ow),A=i.subarray(4,6),n=i.subarray(16,18),[s,f,l,u]=t(this,Dw),c=new Float64Array(((null==(r=t(this,qw))?void 0:r.length)??0)+2);for(let r=0,e=c.length-2;r<e;r+=2)c[r]=(t(this,qw)[r]-s)/l,c[r+1]=(t(this,qw)[r+1]-f)/u;c[c.length-2]=(t(this,Yw)-s)/l,c[c.length-1]=(t(this,Hw)-f)/u;const[d,h,b,g]=o(this,ey,ay).call(this);if(isNaN(i[6])&&!this.isEmpty()){const r=new Float64Array(36);return r.set([NaN,NaN,NaN,NaN,(i[2]-s)/l,(i[3]-f)/u,NaN,NaN,NaN,NaN,(i[4]-s)/l,(i[5]-f)/u,NaN,NaN,NaN,NaN,d,h,NaN,NaN,NaN,NaN,b,g,NaN,NaN,NaN,NaN,(i[16]-s)/l,(i[17]-f)/u,NaN,NaN,NaN,NaN,(i[14]-s)/l,(i[15]-f)/u],0),new Yy(r,c,t(this,Dw),t(this,Jw),t(this,Pw),t(this,jw))}const p=new Float64Array(t(this,Lw).length+24+t(this,Tw).length);let v=e.length;for(let r=0;r<v;r+=2)isNaN(e[r])?p[r]=p[r+1]=NaN:(p[r]=e[r],p[r+1]=e[r+1]);p.set([NaN,NaN,NaN,NaN,(A[0]-s)/l,(A[1]-f)/u,NaN,NaN,NaN,NaN,d,h,NaN,NaN,NaN,NaN,b,g,NaN,NaN,NaN,NaN,(n[0]-s)/l,(n[1]-f)/u],v),v+=24;for(let r=a.length-6;r>=6;r-=6)for(let e=0;e<6;e+=2)isNaN(a[r+e])?(p[v]=p[v+1]=NaN,v+=2):(p[v]=a[r+e],p[v+1]=a[r+e+1],v+=2);return p.set([NaN,NaN,NaN,NaN,a[4],a[5]],v),new Yy(p,c,t(this,Dw),t(this,Jw),t(this,Pw),t(this,jw))}};let oy=ny;var sy,fy,ly,uy,cy,dy,hy,by,gy,py,vy,my,ky,wy,yy,Ey,Cy,By,_y,Zy,Wy,Iy,Ry,Fy,Sy,xy,My,Gy,Xy,Vy,Ny,Dy,Ty,Py,jy,Ly,Oy;Dw=new WeakMap,Tw=new WeakMap,Pw=new WeakMap,jw=new WeakMap,Lw=new WeakMap,Ow=new WeakMap,Yw=new WeakMap,Hw=new WeakMap,Qw=new WeakMap,Uw=new WeakMap,Jw=new WeakMap,zw=new WeakMap,qw=new WeakMap,$w=new WeakMap,Kw=new WeakMap,ry=new WeakMap,ey=new WeakSet,ay=function(){const r=t(this,Ow).subarray(4,6),e=t(this,Ow).subarray(16,18),[a,i,A,n]=t(this,Dw);return[(t(this,Yw)+(r[0]-e[0])/2-a)/A,(t(this,Hw)+(r[1]-e[1])/2-i)/n,(t(this,Yw)+(e[0]-r[0])/2-a)/A,(t(this,Hw)+(e[1]-r[1])/2-i)/n]},i(oy,$w,8),i(oy,Kw,2),i(oy,ry,t(ny,$w)+t(ny,Kw));class Yy extends iy{constructor(r,e,a,n,s,f){super(),i(this,by),i(this,py),i(this,my),i(this,sy,void 0),i(this,fy,null),i(this,ly,void 0),i(this,uy,void 0),i(this,cy,void 0),i(this,dy,void 0),i(this,hy,void 0),A(this,hy,r),A(this,cy,e),A(this,sy,a),A(this,dy,n),A(this,ly,s),A(this,uy,f),o(this,my,ky).call(this,f);const{x:l,y:u,width:c,height:d}=t(this,fy);for(let e=0,a=r.length;e<a;e+=2)r[e]=(r[e]-l)/c,r[e+1]=(r[e+1]-u)/d;for(let r=0,a=e.length;r<a;r+=2)e[r]=(e[r]-l)/c,e[r+1]=(e[r+1]-u)/d}toSVGPath(){const r=[`M${t(this,hy)[4]} ${t(this,hy)[5]}`];for(let e=6,a=t(this,hy).length;e<a;e+=6)isNaN(t(this,hy)[e])?r.push(`L${t(this,hy)[e+4]} ${t(this,hy)[e+5]}`):r.push(`C${t(this,hy)[e]} ${t(this,hy)[e+1]} ${t(this,hy)[e+2]} ${t(this,hy)[e+3]} ${t(this,hy)[e+4]} ${t(this,hy)[e+5]}`);return r.push("Z"),r.join(" ")}serialize([r,e,a,i],A){const n=a-r,s=i-e;let f,l;switch(A){case 0:f=o(this,by,gy).call(this,t(this,hy),r,i,n,-s),l=o(this,by,gy).call(this,t(this,cy),r,i,n,-s);break;case 90:f=o(this,py,vy).call(this,t(this,hy),r,e,n,s),l=o(this,py,vy).call(this,t(this,cy),r,e,n,s);break;case 180:f=o(this,by,gy).call(this,t(this,hy),a,e,-n,s),l=o(this,by,gy).call(this,t(this,cy),a,e,-n,s);break;case 270:f=o(this,py,vy).call(this,t(this,hy),a,i,-n,-s),l=o(this,py,vy).call(this,t(this,cy),a,i,-n,-s)}return{outline:Array.from(f),points:[Array.from(l)]}}get box(){return t(this,fy)}getNewOutline(r,e){const{x:a,y:i,width:A,height:n}=t(this,fy),[o,s,f,l]=t(this,sy),u=A*f,c=n*l,d=a*f+o,h=i*l+s,b=new oy({x:t(this,cy)[0]*u+d,y:t(this,cy)[1]*c+h},t(this,sy),t(this,dy),r,t(this,uy),e??t(this,ly));for(let r=2;r<t(this,cy).length;r+=2)b.add({x:t(this,cy)[r]*u+d,y:t(this,cy)[r+1]*c+h});return b.getOutlines()}}sy=new WeakMap,fy=new WeakMap,ly=new WeakMap,uy=new WeakMap,cy=new WeakMap,dy=new WeakMap,hy=new WeakMap,by=new WeakSet,gy=function(r,e,a,t,i){const A=new Float64Array(r.length);for(let n=0,o=r.length;n<o;n+=2)A[n]=e+r[n]*t,A[n+1]=a+r[n+1]*i;return A},py=new WeakSet,vy=function(r,e,a,t,i){const A=new Float64Array(r.length);for(let n=0,o=r.length;n<o;n+=2)A[n]=e+r[n+1]*t,A[n+1]=a+r[n]*i;return A},my=new WeakSet,ky=function(r){const e=t(this,hy);let a=e[4],i=e[5],n=a,o=i,s=a,f=i,l=a,u=i;const c=r?Math.max:Math.min;for(let r=6,t=e.length;r<t;r+=6){if(isNaN(e[r]))n=Math.min(n,e[r+4]),o=Math.min(o,e[r+5]),s=Math.max(s,e[r+4]),f=Math.max(f,e[r+5]),u<e[r+5]?(l=e[r+4],u=e[r+5]):u===e[r+5]&&(l=c(l,e[r+4]));else{const t=nl.bezierBoundingBox(a,i,...e.slice(r,r+6));n=Math.min(n,t[0]),o=Math.min(o,t[1]),s=Math.max(s,t[2]),f=Math.max(f,t[3]),u<t[3]?(l=t[2],u=t[3]):u===t[3]&&(l=c(l,t[2]))}a=e[r+4],i=e[r+5]}const d=n-t(this,ly),h=o-t(this,ly),b=s-n+2*t(this,ly),g=f-o+2*t(this,ly);A(this,fy,{x:d,y:h,width:b,height:g,lastPoint:[l,u]})};const Hy=class{constructor({editor:r=null,uiManager:e=null}){var a;i(this,xy),i(this,Gy),i(this,Vy),i(this,Dy),i(this,Py),i(this,Ly),i(this,wy,o(this,Vy,Ny).bind(this)),i(this,yy,o(this,Py,jy).bind(this)),i(this,Ey,null),i(this,Cy,null),i(this,By,void 0),i(this,_y,null),i(this,Zy,!1),i(this,Wy,!1),i(this,Iy,null),i(this,Ry,void 0),i(this,Fy,null),i(this,Sy,void 0),r?(A(this,Wy,!1),A(this,Sy,$s.HIGHLIGHT_COLOR),A(this,Iy,r)):(A(this,Wy,!0),A(this,Sy,$s.HIGHLIGHT_DEFAULT_COLOR)),A(this,Fy,(null==r?void 0:r._uiManager)||e),A(this,Ry,t(this,Fy)._eventBus),A(this,By,(null==r?void 0:r.color)||(null==(a=t(this,Fy))?void 0:a.highlightColors.values().next().value)||"#FFFF98")}static get _keyboardManager(){return jf(this,"_keyboardManager",new gc([[["Escape","mac+Escape"],Hy.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Hy.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Hy.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Hy.prototype._moveToPrevious],[["Home","mac+Home"],Hy.prototype._moveToBeginning],[["End","mac+End"],Hy.prototype._moveToEnd]]))}renderButton(){const r=A(this,Ey,document.createElement("button"));r.className="colorPicker",r.tabIndex="0",r.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),r.setAttribute("aria-haspopup",!0);const e=t(this,Fy)._signal;r.addEventListener("click",o(this,Dy,Ty).bind(this),{signal:e}),r.addEventListener("keydown",t(this,wy),{signal:e});const a=A(this,Cy,document.createElement("span"));return a.className="swatch",a.setAttribute("aria-hidden",!0),a.style.backgroundColor=t(this,By),r.append(a),r}renderMainDropdown(){const r=A(this,_y,o(this,xy,My).call(this));return r.setAttribute("aria-orientation","horizontal"),r.setAttribute("aria-labelledby","highlightColorPickerLabel"),r}_colorSelectFromKeyboard(r){if(r.target===t(this,Ey))return void o(this,Dy,Ty).call(this,r);const e=r.target.getAttribute("data-color");e&&o(this,Gy,Xy).call(this,e,r)}_moveToNext(r){var e,a;t(this,Ly,Oy)?r.target!==t(this,Ey)?null==(a=r.target.nextSibling)||a.focus():null==(e=t(this,_y).firstChild)||e.focus():o(this,Dy,Ty).call(this,r)}_moveToPrevious(r){var e,a;r.target!==(null==(e=t(this,_y))?void 0:e.firstChild)&&r.target!==t(this,Ey)?(t(this,Ly,Oy)||o(this,Dy,Ty).call(this,r),null==(a=r.target.previousSibling)||a.focus()):t(this,Ly,Oy)&&this._hideDropdownFromKeyboard()}_moveToBeginning(r){var e;t(this,Ly,Oy)?null==(e=t(this,_y).firstChild)||e.focus():o(this,Dy,Ty).call(this,r)}_moveToEnd(r){var e;t(this,Ly,Oy)?null==(e=t(this,_y).lastChild)||e.focus():o(this,Dy,Ty).call(this,r)}hideDropdown(){var r;null==(r=t(this,_y))||r.classList.add("hidden"),window.removeEventListener("pointerdown",t(this,yy))}_hideDropdownFromKeyboard(){var r;if(!t(this,Wy)){if(!t(this,Ly,Oy))return void(null==(r=t(this,Iy))||r.unselect());this.hideDropdown(),t(this,Ey).focus({preventScroll:!0,focusVisible:t(this,Zy)})}}updateColor(r){if(t(this,Cy)&&(t(this,Cy).style.backgroundColor=r),!t(this,_y))return;const e=t(this,Fy).highlightColors.values();for(const a of t(this,_y).children)a.setAttribute("aria-selected",e.next().value===r)}destroy(){var r,e;null==(r=t(this,Ey))||r.remove(),A(this,Ey,null),A(this,Cy,null),null==(e=t(this,_y))||e.remove(),A(this,_y,null)}};let Qy=Hy;var Uy,Jy,zy,qy,$y,Ky,rE,eE,aE,tE,iE,AE,nE,oE,sE,fE,lE,uE,cE,dE,hE,bE,gE,pE,vE,mE,kE,wE,yE,EE,CE,BE,_E,ZE,WE,IE,RE,FE,SE,xE,ME,GE,XE,VE,NE,DE,TE,PE,jE;wy=new WeakMap,yy=new WeakMap,Ey=new WeakMap,Cy=new WeakMap,By=new WeakMap,_y=new WeakMap,Zy=new WeakMap,Wy=new WeakMap,Iy=new WeakMap,Ry=new WeakMap,Fy=new WeakMap,Sy=new WeakMap,xy=new WeakSet,My=function(){const r=document.createElement("div"),e=t(this,Fy)._signal;r.addEventListener("contextmenu",gu,{signal:e}),r.className="dropdown",r.role="listbox",r.setAttribute("aria-multiselectable",!1),r.setAttribute("aria-orientation","vertical"),r.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[a,i]of t(this,Fy).highlightColors){const A=document.createElement("button");A.tabIndex="0",A.role="option",A.setAttribute("data-color",i),A.title=a,A.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${a}`);const n=document.createElement("span");A.append(n),n.className="swatch",n.style.backgroundColor=i,A.setAttribute("aria-selected",i===t(this,By)),A.addEventListener("click",o(this,Gy,Xy).bind(this,i),{signal:e}),r.append(A)}return r.addEventListener("keydown",t(this,wy),{signal:e}),r},Gy=new WeakSet,Xy=function(r,e){e.stopPropagation(),t(this,Ry).dispatch("switchannotationeditorparams",{source:this,type:t(this,Sy),value:r})},Vy=new WeakSet,Ny=function(r){Hy._keyboardManager.exec(this,r)},Dy=new WeakSet,Ty=function(r){if(t(this,Ly,Oy))return void this.hideDropdown();if(A(this,Zy,0===r.detail),window.addEventListener("pointerdown",t(this,yy),{signal:t(this,Fy)._signal}),t(this,_y))return void t(this,_y).classList.remove("hidden");const e=A(this,_y,o(this,xy,My).call(this));t(this,Ey).append(e)},Py=new WeakSet,jy=function(r){var e;null!=(e=t(this,_y))&&e.contains(r.target)||this.hideDropdown()},Ly=new WeakSet,Oy=function(){return t(this,_y)&&!t(this,_y).classList.contains("hidden")};const LE=class extends ob{constructor(r){super({...r,name:"highlightEditor"}),i(this,dE),i(this,bE),i(this,pE),i(this,mE),i(this,wE),i(this,EE),i(this,BE),i(this,IE),i(this,FE),i(this,xE),i(this,GE),i(this,VE),i(this,Uy,null),i(this,Jy,0),i(this,zy,void 0),i(this,qy,null),i(this,$y,null),i(this,Ky,null),i(this,rE,null),i(this,eE,0),i(this,aE,null),i(this,tE,null),i(this,iE,null),i(this,AE,!1),i(this,nE,o(this,IE,RE).bind(this)),i(this,oE,null),i(this,sE,void 0),i(this,fE,null),i(this,lE,""),i(this,uE,void 0),i(this,cE,""),this.color=r.color||LE._defaultColor,A(this,uE,r.thickness||LE._defaultThickness),A(this,sE,r.opacity||LE._defaultOpacity),A(this,zy,r.boxes||null),A(this,cE,r.methodOfCreation||""),A(this,lE,r.text||""),this._isDraggable=!1,r.highlightId>-1?(A(this,AE,!0),o(this,bE,gE).call(this,r),o(this,BE,_E).call(this)):(A(this,Uy,r.anchorNode),A(this,Jy,r.anchorOffset),A(this,rE,r.focusNode),A(this,eE,r.focusOffset),o(this,dE,hE).call(this),o(this,BE,_E).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const r=LE.prototype;return jf(this,"_keyboardManager",new gc([[["ArrowLeft","mac+ArrowLeft"],r._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],r._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],r._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],r._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:t(this,AE)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:t(this,uE),methodOfCreation:t(this,cE)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(r){return{numberOfColors:r.get("color").size}}static initialize(r,e){var a;ob.initialize(r,e),LE._defaultColor||(LE._defaultColor=(null==(a=e.highlightColors)?void 0:a.values().next().value)||"#fff066")}static updateDefaultParams(r,e){switch(r){case $s.HIGHLIGHT_DEFAULT_COLOR:LE._defaultColor=e;break;case $s.HIGHLIGHT_THICKNESS:LE._defaultThickness=e}}translateInPage(r,e){}get toolbarPosition(){return t(this,oE)}updateParams(r,e){switch(r){case $s.HIGHLIGHT_COLOR:o(this,pE,vE).call(this,e);break;case $s.HIGHLIGHT_THICKNESS:o(this,mE,kE).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$s.HIGHLIGHT_DEFAULT_COLOR,LE._defaultColor],[$s.HIGHLIGHT_THICKNESS,LE._defaultThickness]]}get propertiesToUpdate(){return[[$s.HIGHLIGHT_COLOR,this.color||LE._defaultColor],[$s.HIGHLIGHT_THICKNESS,t(this,uE)||LE._defaultThickness],[$s.HIGHLIGHT_FREE,t(this,AE)]]}async addEditToolbar(){const r=await super.addEditToolbar();return r?(this._uiManager.highlightColors&&(A(this,$y,new Qy({editor:this})),r.addColorPicker(t(this,$y))),r):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(o(this,xE,ME).call(this))}getBaseTranslation(){return[0,0]}getRect(r,e){return super.getRect(r,e,o(this,xE,ME).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){o(this,EE,CE).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(o(this,BE,_E).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(r){var e;let a=!1;this.parent&&!r?o(this,EE,CE).call(this):r&&(o(this,BE,_E).call(this,r),a=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(r),this.show(this._isVisible),a&&this.select()}rotate(r){var e,a,i;const{drawLayer:A}=this.parent;let n;t(this,AE)?(r=(r-this.rotation+360)%360,n=o(e=LE,ZE,WE).call(e,t(this,tE).box,r)):n=o(a=LE,ZE,WE).call(a,this,r),A.rotate(t(this,iE),r),A.rotate(t(this,fE),r),A.updateBox(t(this,iE),n),A.updateBox(t(this,fE),o(i=LE,ZE,WE).call(i,t(this,Ky).box,r))}render(){if(this.div)return this.div;const r=super.render();t(this,lE)&&(r.setAttribute("aria-label",t(this,lE)),r.setAttribute("role","mark")),t(this,AE)?r.classList.add("free"):this.div.addEventListener("keydown",t(this,nE),{signal:this._uiManager._signal});const e=A(this,aE,document.createElement("div"));r.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=t(this,qy);const[a,i]=this.parentDimensions;return this.setDims(this.width*a,this.height*i),Ac(this,t(this,aE),["pointerover","pointerleave"]),this.enableEditing(),r}pointerover(){this.parent.drawLayer.addClass(t(this,fE),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(t(this,fE),"hovered")}_moveCaret(r){switch(this.parent.unselect(this),r){case 0:case 2:o(this,FE,SE).call(this,!0);break;case 1:case 3:o(this,FE,SE).call(this,!1)}}select(){var r,e;super.select(),t(this,fE)&&(null==(r=this.parent)||r.drawLayer.removeClass(t(this,fE),"hovered"),null==(e=this.parent)||e.drawLayer.addClass(t(this,fE),"selected"))}unselect(){var r;super.unselect(),t(this,fE)&&(null==(r=this.parent)||r.drawLayer.removeClass(t(this,fE),"selected"),t(this,AE)||o(this,FE,SE).call(this,!1))}get _mustFixPosition(){return!t(this,AE)}show(r=this._isVisible){super.show(r),this.parent&&(this.parent.drawLayer.show(t(this,iE),r),this.parent.drawLayer.show(t(this,fE),r))}static startHighlighting(r,e,{target:a,x:t,y:i}){const{x:A,y:n,width:s,height:f}=a.getBoundingClientRect(),l=e=>{o(this,DE,TE).call(this,r,e)},u=r._signal,c={capture:!0,passive:!1,signal:u},d=r=>{r.preventDefault(),r.stopPropagation()},h=e=>{a.removeEventListener("pointermove",l),window.removeEventListener("blur",h),window.removeEventListener("pointerup",h),window.removeEventListener("pointerdown",d,c),window.removeEventListener("contextmenu",gu),o(this,PE,jE).call(this,r,e)};window.addEventListener("blur",h,{signal:u}),window.addEventListener("pointerup",h,{signal:u}),window.addEventListener("pointerdown",d,c),window.addEventListener("contextmenu",gu,{signal:u}),a.addEventListener("pointermove",l,{signal:u}),this._freeHighlight=new oy({x:t,y:i},[A,n,s,f],r.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=r.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0))}static deserialize(r,e,a){var t;const i=super.deserialize(r,e,a),{rect:[n,s,f,l],color:u,quadPoints:c}=r;i.color=nl.makeHexColor(...u),A(i,sE,r.opacity);const[d,h]=i.pageDimensions;i.width=(f-n)/d,i.height=(l-s)/h;const b=A(i,zy,[]);for(let r=0;r<c.length;r+=8)b.push({x:(c[4]-f)/d,y:(l-(1-c[r+5]))/h,width:(c[r+2]-c[r])/d,height:(c[r+5]-c[r+1])/h});return o(t=i,dE,hE).call(t),i}serialize(r=!1){if(this.isEmpty()||r)return null;const e=this.getRect(0,0),a=ob._colorManager.convert(this.color);return{annotationType:qs.HIGHLIGHT,color:a,opacity:t(this,sE),thickness:t(this,uE),quadPoints:o(this,GE,XE).call(this),outlines:o(this,VE,NE).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:o(this,xE,ME).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}};let OE=LE;var YE,HE,QE,UE,JE,zE,qE,$E,KE,rC,eC,aC,tC,iC,AC,nC,oC,sC,fC,lC,uC,cC,dC,hC,bC,gC,pC,vC,mC,kC,wC,yC,EC,CC,BC,_C,ZC,WC,IC,RC,FC,SC,xC,MC,GC,XC,VC,NC,DC,TC,PC,jC,LC,OC,YC,HC,QC,UC,JC,zC,qC,$C,KC,rB,eB,aB,tB;Uy=new WeakMap,Jy=new WeakMap,zy=new WeakMap,qy=new WeakMap,$y=new WeakMap,Ky=new WeakMap,rE=new WeakMap,eE=new WeakMap,aE=new WeakMap,tE=new WeakMap,iE=new WeakMap,AE=new WeakMap,nE=new WeakMap,oE=new WeakMap,sE=new WeakMap,fE=new WeakMap,lE=new WeakMap,uE=new WeakMap,cE=new WeakMap,dE=new WeakSet,hE=function(){const r=new ty(t(this,zy),.001);A(this,tE,r.getOutlines()),({x:this.x,y:this.y,width:this.width,height:this.height}=t(this,tE).box);const e=new ty(t(this,zy),.0025,.001,"ltr"===this._uiManager.direction);A(this,Ky,e.getOutlines());const{lastPoint:a}=t(this,Ky).box;A(this,oE,[(a[0]-this.x)/this.width,(a[1]-this.y)/this.height])},bE=new WeakSet,gE=function({highlightOutlines:r,highlightId:e,clipPathId:a}){var i,n;A(this,tE,r);if(A(this,Ky,r.getNewOutline(t(this,uE)/2+1.5,.0025)),e>=0)A(this,iE,e),A(this,qy,a),this.parent.drawLayer.finalizeLine(e,r),A(this,fE,this.parent.drawLayer.highlightOutline(t(this,Ky)));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(t(this,iE),r),this.parent.drawLayer.updateBox(t(this,iE),o(i=LE,ZE,WE).call(i,t(this,tE).box,(e-this.rotation+360)%360)),this.parent.drawLayer.updateLine(t(this,fE),t(this,Ky)),this.parent.drawLayer.updateBox(t(this,fE),o(n=LE,ZE,WE).call(n,t(this,Ky).box,e))}const{x:s,y:f,width:l,height:u}=r.box;switch(this.rotation){case 0:this.x=s,this.y=f,this.width=l,this.height=u;break;case 90:{const[r,e]=this.parentDimensions;this.x=f,this.y=1-s,this.width=l*e/r,this.height=u*r/e;break}case 180:this.x=1-s,this.y=1-f,this.width=l,this.height=u;break;case 270:{const[r,e]=this.parentDimensions;this.x=1-f,this.y=s,this.width=l*e/r,this.height=u*r/e;break}}const{lastPoint:c}=t(this,Ky).box;A(this,oE,[(c[0]-s)/l,(c[1]-f)/u])},pE=new WeakSet,vE=function(r){const e=r=>{var e,a;this.color=r,null==(e=this.parent)||e.drawLayer.changeColor(t(this,iE),r),null==(a=t(this,$y))||a.updateColor(r)},a=this.color;this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(r)},!0)},mE=new WeakSet,kE=function(r){const e=t(this,uE),a=r=>{A(this,uE,r),o(this,wE,yE).call(this,r)};this.addCommands({cmd:a.bind(this,r),undo:a.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:r},!0)},wE=new WeakSet,yE=function(r){if(!t(this,AE))return;o(this,bE,gE).call(this,{highlightOutlines:t(this,tE).getNewOutline(r/2)}),this.fixAndSetPosition();const[e,a]=this.parentDimensions;this.setDims(this.width*e,this.height*a)},EE=new WeakSet,CE=function(){null===t(this,iE)||!this.parent||(this.parent.drawLayer.remove(t(this,iE)),A(this,iE,null),this.parent.drawLayer.remove(t(this,fE)),A(this,fE,null))},BE=new WeakSet,_E=function(r=this.parent){null===t(this,iE)&&(({id:n(this,iE)._,clipPathId:n(this,qy)._}=r.drawLayer.highlight(t(this,tE),this.color,t(this,sE))),A(this,fE,r.drawLayer.highlightOutline(t(this,Ky))),t(this,aE)&&(t(this,aE).style.clipPath=t(this,qy)))},ZE=new WeakSet,WE=function({x:r,y:e,width:a,height:t},i){switch(i){case 90:return{x:1-e-t,y:r,width:t,height:a};case 180:return{x:1-r-a,y:1-e-t,width:a,height:t};case 270:return{x:e,y:1-r-a,width:t,height:a}}return{x:r,y:e,width:a,height:t}},IE=new WeakSet,RE=function(r){LE._keyboardManager.exec(this,r)},FE=new WeakSet,SE=function(r){if(!t(this,Uy))return;const e=window.getSelection();r?e.setPosition(t(this,Uy),t(this,Jy)):e.setPosition(t(this,rE),t(this,eE))},xE=new WeakSet,ME=function(){return t(this,AE)?this.rotation:0},GE=new WeakSet,XE=function(){if(t(this,AE))return null;const[r,e]=this.pageDimensions,a=t(this,zy),i=new Float32Array(8*a.length);let A=0;for(const{x:t,y:n,width:o,height:s}of a){const a=t*r,f=(1-n-s)*e;i[A]=i[A+4]=a,i[A+1]=i[A+3]=f,i[A+2]=i[A+6]=a+o*r,i[A+5]=i[A+7]=f+s*e,A+=8}return i},VE=new WeakSet,NE=function(r){return t(this,tE).serialize(r,o(this,xE,ME).call(this))},DE=new WeakSet,TE=function(r,e){this._freeHighlight.add(e)&&r.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},PE=new WeakSet,jE=function(r,e){this._freeHighlight.isEmpty()?r.drawLayer.removeFreeHighlight(this._freeHighlightId):r.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},i(OE,ZE),i(OE,DE),i(OE,PE),e(OE,"_defaultColor",null),e(OE,"_defaultOpacity",1),e(OE,"_defaultThickness",12),e(OE,"_l10nPromise"),e(OE,"_type","highlight"),e(OE,"_editorType",qs.HIGHLIGHT),e(OE,"_freeHighlightId",-1),e(OE,"_freeHighlight",null),e(OE,"_freeHighlightClipId","");const iB=class extends ob{constructor(r){super({...r,name:"inkEditor"}),i(this,nC),i(this,sC),i(this,lC),i(this,cC),i(this,hC),i(this,gC),i(this,vC),i(this,kC),i(this,yC),i(this,CC),i(this,_C),i(this,WC),i(this,RC),i(this,SC),i(this,MC),i(this,XC),i(this,NC),i(this,TC),i(this,jC),i(this,zC),i(this,$C),i(this,rB),i(this,aB),i(this,YE,0),i(this,HE,0),i(this,QE,this.canvasPointermove.bind(this)),i(this,UE,this.canvasPointerleave.bind(this)),i(this,JE,this.canvasPointerup.bind(this)),i(this,zE,this.canvasPointerdown.bind(this)),i(this,qE,null),i(this,$E,new Path2D),i(this,KE,!1),i(this,rC,!1),i(this,eC,!1),i(this,aC,null),i(this,tC,0),i(this,iC,0),i(this,AC,null),this.color=r.color||null,this.thickness=r.thickness||null,this.opacity=r.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(r,e){ob.initialize(r,e)}static updateDefaultParams(r,e){switch(r){case $s.INK_THICKNESS:iB._defaultThickness=e;break;case $s.INK_COLOR:iB._defaultColor=e;break;case $s.INK_OPACITY:iB._defaultOpacity=e/100}}updateParams(r,e){switch(r){case $s.INK_THICKNESS:o(this,nC,oC).call(this,e);break;case $s.INK_COLOR:o(this,sC,fC).call(this,e);break;case $s.INK_OPACITY:o(this,lC,uC).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$s.INK_THICKNESS,iB._defaultThickness],[$s.INK_COLOR,iB._defaultColor||ob._defaultLineColor],[$s.INK_OPACITY,Math.round(100*iB._defaultOpacity)]]}get propertiesToUpdate(){return[[$s.INK_THICKNESS,this.thickness||iB._defaultThickness],[$s.INK_COLOR,this.color||iB._defaultColor||ob._defaultLineColor],[$s.INK_OPACITY,Math.round(100*(this.opacity??iB._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(o(this,MC,GC).call(this),o(this,XC,VC).call(this)),this.isAttachedToDOM||(this.parent.add(this),o(this,NC,DC).call(this)),o(this,aB,tB).call(this)))}remove(){var r;null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,t(this,qE)&&(clearTimeout(t(this,qE)),A(this,qE,null)),null==(r=t(this,aC))||r.disconnect(),A(this,aC,null),super.remove())}setParent(r){!this.parent&&r?this._uiManager.removeShouldRescale(this):this.parent&&null===r&&this._uiManager.addShouldRescale(this),super.setParent(r)}onScaleChanging(){const[r,e]=this.parentDimensions,a=this.width*r,t=this.height*e;this.setDimensions(a,t)}enableEditMode(){t(this,KE)||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",t(this,zE),{signal:this._uiManager._signal}))}disableEditMode(){!this.isInEditMode()||null===this.canvas||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",t(this,zE)))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}commit(){t(this,KE)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),A(this,KE,!0),this.div.classList.add("disabled"),o(this,aB,tB).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(r){this._focusEventsAllowed&&(super.focusin(r),this.enableEditMode())}canvasPointerdown(r){0!==r.button||!this.isInEditMode()||t(this,KE)||(this.setInForeground(),r.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),o(this,gC,pC).call(this,r.offsetX,r.offsetY))}canvasPointermove(r){r.preventDefault(),o(this,vC,mC).call(this,r.offsetX,r.offsetY)}canvasPointerup(r){r.preventDefault(),o(this,SC,xC).call(this,r)}canvasPointerleave(r){o(this,SC,xC).call(this,r)}get isResizable(){return!this.isEmpty()&&t(this,KE)}render(){if(this.div)return this.div;let r,e;this.width&&(r=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[a,t,i,n]=o(this,cC,dC).call(this);if(this.setAt(a,t,0,0),this.setDims(i,n),o(this,MC,GC).call(this),this.width){const[a,t]=this.parentDimensions;this.setAspectRatio(this.width*a,this.height*t),this.setAt(r*a,e*t,this.width*a,this.height*t),A(this,eC,!0),o(this,NC,DC).call(this),this.setDims(this.width*a,this.height*t),o(this,RC,FC).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return o(this,XC,VC).call(this),this.div}setDimensions(r,e){const a=Math.round(r),i=Math.round(e);if(t(this,tC)===a&&t(this,iC)===i)return;A(this,tC,a),A(this,iC,i),this.canvas.style.visibility="hidden";const[n,s]=this.parentDimensions;this.width=r/n,this.height=e/s,this.fixAndSetPosition(),t(this,KE)&&o(this,TC,PC).call(this,r,e),o(this,NC,DC).call(this),o(this,RC,FC).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(r,e,a){var t,i,n;if(r instanceof Dk)return null;const s=super.deserialize(r,e,a);s.thickness=r.thickness,s.color=nl.makeHexColor(...r.color),s.opacity=r.opacity;const[f,l]=s.pageDimensions,u=s.width*f,c=s.height*l,d=s.parentScale,h=r.thickness/2;A(s,KE,!0),A(s,tC,Math.round(u)),A(s,iC,Math.round(c));const{paths:b,rect:g,rotation:p}=r;for(let{bezier:r}of b){r=o(t=iB,UC,JC).call(t,r,g,p);const e=[];s.paths.push(e);let a=d*(r[0]-h),i=d*(r[1]-h);for(let t=2,A=r.length;t<A;t+=6){const A=d*(r[t]-h),n=d*(r[t+1]-h),o=d*(r[t+2]-h),s=d*(r[t+3]-h),f=d*(r[t+4]-h),l=d*(r[t+5]-h);e.push([[a,i],[A,n],[o,s],[f,l]]),a=f,i=l}const A=o(this,OC,YC).call(this,e);s.bezierPath2D.push(A)}const v=o(i=s,$C,KC).call(i);return A(s,HE,Math.max(ob.MIN_SIZE,v[2]-v[0])),A(s,YE,Math.max(ob.MIN_SIZE,v[3]-v[1])),o(n=s,TC,PC).call(n,u,c),s}serialize(){if(this.isEmpty())return null;const r=this.getRect(0,0),e=ob._colorManager.convert(this.ctx.strokeStyle);return{annotationType:qs.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:o(this,zC,qC).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,r),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};let AB=iB;var nB,oB,sB,fB,lB,uB,cB,dB,hB,bB,gB,pB,vB,mB,kB,wB,yB,EB,CB,BB,_B,ZB,WB,IB,RB,FB,SB,xB,MB;YE=new WeakMap,HE=new WeakMap,QE=new WeakMap,UE=new WeakMap,JE=new WeakMap,zE=new WeakMap,qE=new WeakMap,$E=new WeakMap,KE=new WeakMap,rC=new WeakMap,eC=new WeakMap,aC=new WeakMap,tC=new WeakMap,iC=new WeakMap,AC=new WeakMap,nC=new WeakSet,oC=function(r){const e=r=>{this.thickness=r,o(this,aB,tB).call(this)},a=this.thickness;this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},sC=new WeakSet,fC=function(r){const e=r=>{this.color=r,o(this,RC,FC).call(this)},a=this.color;this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},lC=new WeakSet,uC=function(r){const e=r=>{this.opacity=r,o(this,RC,FC).call(this)};r/=100;const a=this.opacity;this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},cC=new WeakSet,dC=function(){const{parentRotation:r,parentDimensions:[e,a]}=this;switch(r){case 90:return[0,a,a,e];case 180:return[e,a,e,a];case 270:return[e,0,a,e];default:return[0,0,e,a]}},hC=new WeakSet,bC=function(){const{ctx:r,color:e,opacity:a,thickness:t,parentScale:i,scaleFactor:A}=this;var n;r.lineWidth=t*i/A,r.lineCap="round",r.lineJoin="round",r.miterLimit=10,r.strokeStyle=`${e}${n=a,Math.round(Math.min(255,Math.max(1,255*n))).toString(16).padStart(2,"0")}`},gC=new WeakSet,pC=function(r,e){const a=this._uiManager._signal;this.canvas.addEventListener("contextmenu",gu,{signal:a}),this.canvas.addEventListener("pointerleave",t(this,UE),{signal:a}),this.canvas.addEventListener("pointermove",t(this,QE),{signal:a}),this.canvas.addEventListener("pointerup",t(this,JE),{signal:a}),this.canvas.removeEventListener("pointerdown",t(this,zE)),this.isEditing=!0,t(this,eC)||(A(this,eC,!0),o(this,NC,DC).call(this),this.thickness||(this.thickness=iB._defaultThickness),this.color||(this.color=iB._defaultColor||ob._defaultLineColor),this.opacity??(this.opacity=iB._defaultOpacity)),this.currentPath.push([r,e]),A(this,rC,!1),o(this,hC,bC).call(this),A(this,AC,(()=>{o(this,CC,BC).call(this),t(this,AC)&&window.requestAnimationFrame(t(this,AC))})),window.requestAnimationFrame(t(this,AC))},vC=new WeakSet,mC=function(r,e){const[a,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&r===a&&e===i)return;const n=this.currentPath;let s=t(this,$E);if(n.push([r,e]),A(this,rC,!0),n.length<=2)return s.moveTo(...n[0]),void s.lineTo(r,e);3===n.length&&(A(this,$E,s=new Path2D),s.moveTo(...n[0])),o(this,_C,ZC).call(this,s,...n.at(-3),...n.at(-2),r,e)},kC=new WeakSet,wC=function(){if(0===this.currentPath.length)return;const r=this.currentPath.at(-1);t(this,$E).lineTo(...r)},yC=new WeakSet,EC=function(r,e){let a;if(A(this,AC,null),r=Math.min(Math.max(r,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),o(this,vC,mC).call(this,r,e),o(this,kC,wC).call(this),1!==this.currentPath.length)a=o(this,WC,IC).call(this);else{const t=[r,e];a=[[t,t.slice(),t.slice(),t]]}const i=t(this,$E),n=this.currentPath;this.currentPath=[],A(this,$E,new Path2D);this.addCommands({cmd:()=>{this.allRawPaths.push(n),this.paths.push(a),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(o(this,MC,GC).call(this),o(this,XC,VC).call(this)),o(this,aB,tB).call(this))},mustExec:!0})},CC=new WeakSet,BC=function(){if(!t(this,rC))return;A(this,rC,!1);Math.ceil(this.thickness*this.parentScale);const r=this.currentPath.slice(-3),e=r.map((r=>r[0])),a=r.map((r=>r[1]));Math.min(...e),Math.max(...e),Math.min(...a),Math.max(...a);const{ctx:i}=this;i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(const r of this.bezierPath2D)i.stroke(r);i.stroke(t(this,$E)),i.restore()},_C=new WeakSet,ZC=function(r,e,a,t,i,A,n){const o=(e+t)/2,s=(a+i)/2,f=(t+A)/2,l=(i+n)/2;r.bezierCurveTo(o+2*(t-o)/3,s+2*(i-s)/3,f+2*(t-f)/3,l+2*(i-l)/3,f,l)},WC=new WeakSet,IC=function(){const r=this.currentPath;if(r.length<=2)return[[r[0],r[0],r.at(-1),r.at(-1)]];const e=[];let a,[t,i]=r[0];for(a=1;a<r.length-2;a++){const[A,n]=r[a],[o,s]=r[a+1],f=(A+o)/2,l=(n+s)/2,u=[t+2*(A-t)/3,i+2*(n-i)/3],c=[f+2*(A-f)/3,l+2*(n-l)/3];e.push([[t,i],u,c,[f,l]]),[t,i]=[f,l]}const[A,n]=r[a],[o,s]=r[a+1],f=[t+2*(A-t)/3,i+2*(n-i)/3],l=[o+2*(A-o)/3,s+2*(n-s)/3];return e.push([[t,i],f,l,[o,s]]),e},RC=new WeakSet,FC=function(){if(this.isEmpty())return void o(this,jC,LC).call(this);o(this,hC,bC).call(this);const{canvas:r,ctx:e}=this;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,r.width,r.height),o(this,jC,LC).call(this);for(const r of this.bezierPath2D)e.stroke(r)},SC=new WeakSet,xC=function(r){this.canvas.removeEventListener("pointerleave",t(this,UE)),this.canvas.removeEventListener("pointermove",t(this,QE)),this.canvas.removeEventListener("pointerup",t(this,JE)),this.canvas.addEventListener("pointerdown",t(this,zE),{signal:this._uiManager._signal}),t(this,qE)&&clearTimeout(t(this,qE)),A(this,qE,setTimeout((()=>{A(this,qE,null),this.canvas.removeEventListener("contextmenu",gu)}),10)),o(this,yC,EC).call(this,r.offsetX,r.offsetY),this.addToAnnotationStorage(),this.setInBackground()},MC=new WeakSet,GC=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},XC=new WeakSet,VC=function(){A(this,aC,new ResizeObserver((r=>{const e=r[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}))),t(this,aC).observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{var r;null==(r=t(this,aC))||r.disconnect(),A(this,aC,null)}),{once:!0})},NC=new WeakSet,DC=function(){if(!t(this,eC))return;const[r,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*r),this.canvas.height=Math.ceil(this.height*e),o(this,jC,LC).call(this)},TC=new WeakSet,PC=function(r,e){const a=o(this,rB,eB).call(this),i=(r-a)/t(this,HE),A=(e-a)/t(this,YE);this.scaleFactor=Math.min(i,A)},jC=new WeakSet,LC=function(){const r=o(this,rB,eB).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+r,this.translationY*this.scaleFactor+r)},OC=new WeakSet,YC=function(r){const e=new Path2D;for(let a=0,t=r.length;a<t;a++){const[t,i,A,n]=r[a];0===a&&e.moveTo(...t),e.bezierCurveTo(i[0],i[1],A[0],A[1],n[0],n[1])}return e},HC=new WeakSet,QC=function(r,e,a){const[t,i,A,n]=e;switch(a){case 0:for(let e=0,a=r.length;e<a;e+=2)r[e]+=t,r[e+1]=n-r[e+1];break;case 90:for(let e=0,a=r.length;e<a;e+=2){const a=r[e];r[e]=r[e+1]+t,r[e+1]=a+i}break;case 180:for(let e=0,a=r.length;e<a;e+=2)r[e]=A-r[e],r[e+1]+=i;break;case 270:for(let e=0,a=r.length;e<a;e+=2){const a=r[e];r[e]=A-r[e+1],r[e+1]=n-a}break;default:throw new Error("Invalid rotation")}return r},UC=new WeakSet,JC=function(r,e,a){const[t,i,A,n]=e;switch(a){case 0:for(let e=0,a=r.length;e<a;e+=2)r[e]-=t,r[e+1]=n-r[e+1];break;case 90:for(let e=0,a=r.length;e<a;e+=2){const a=r[e];r[e]=r[e+1]-i,r[e+1]=a-t}break;case 180:for(let e=0,a=r.length;e<a;e+=2)r[e]=A-r[e],r[e+1]-=i;break;case 270:for(let e=0,a=r.length;e<a;e+=2){const a=r[e];r[e]=n-r[e+1],r[e+1]=A-a}break;default:throw new Error("Invalid rotation")}return r},zC=new WeakSet,qC=function(r,e,a,t){var i,A;const n=[],s=this.thickness/2,f=r*e+s,l=r*a+s;for(const e of this.paths){const a=[],s=[];for(let t=0,i=e.length;t<i;t++){const[A,n,o,u]=e[t];if(A[0]===u[0]&&A[1]===u[1]&&1===i){const e=r*A[0]+f,t=r*A[1]+l;a.push(e,t),s.push(e,t);break}const c=r*A[0]+f,d=r*A[1]+l,h=r*n[0]+f,b=r*n[1]+l,g=r*o[0]+f,p=r*o[1]+l,v=r*u[0]+f,m=r*u[1]+l;0===t&&(a.push(c,d),s.push(c,d)),a.push(h,b,g,p,v,m),s.push(h,b),t===i-1&&s.push(v,m)}n.push({bezier:o(i=iB,HC,QC).call(i,a,t,this.rotation),points:o(A=iB,HC,QC).call(A,s,t,this.rotation)})}return n},$C=new WeakSet,KC=function(){let r=1/0,e=-1/0,a=1/0,t=-1/0;for(const i of this.paths)for(const[A,n,o,s]of i){const i=nl.bezierBoundingBox(...A,...n,...o,...s);r=Math.min(r,i[0]),a=Math.min(a,i[1]),e=Math.max(e,i[2]),t=Math.max(t,i[3])}return[r,a,e,t]},rB=new WeakSet,eB=function(){return t(this,KE)?Math.ceil(this.thickness*this.parentScale):0},aB=new WeakSet,tB=function(r=!1){if(this.isEmpty())return;if(!t(this,KE))return void o(this,RC,FC).call(this);const e=o(this,$C,KC).call(this),a=o(this,rB,eB).call(this);A(this,HE,Math.max(ob.MIN_SIZE,e[2]-e[0])),A(this,YE,Math.max(ob.MIN_SIZE,e[3]-e[1]));const i=Math.ceil(a+t(this,HE)*this.scaleFactor),n=Math.ceil(a+t(this,YE)*this.scaleFactor),[s,f]=this.parentDimensions;this.width=i/s,this.height=n/f,this.setAspectRatio(i,n);const l=this.translationX,u=this.translationY;this.translationX=-e[0],this.translationY=-e[1],o(this,NC,DC).call(this),o(this,RC,FC).call(this),A(this,tC,i),A(this,iC,n),this.setDims(i,n);const c=r?a/this.scaleFactor/2:0;this.translate(l-this.translationX-c,u-this.translationY-c)},i(AB,OC),i(AB,HC),i(AB,UC),e(AB,"_defaultColor",null),e(AB,"_defaultOpacity",1),e(AB,"_defaultThickness",1),e(AB,"_type","ink"),e(AB,"_editorType",qs.INK);const GB=class extends ob{constructor(r){super({...r,name:"stampEditor"}),i(this,pB),i(this,mB),i(this,wB),i(this,EB),i(this,BB),i(this,ZB),i(this,IB),i(this,FB),i(this,xB),i(this,nB,null),i(this,oB,null),i(this,sB,null),i(this,fB,null),i(this,lB,null),i(this,uB,""),i(this,cB,null),i(this,dB,null),i(this,hB,null),i(this,bB,!1),i(this,gB,!1),A(this,fB,r.bitmapUrl),A(this,lB,r.bitmapFile)}static initialize(r,e){ob.initialize(r,e)}static get supportedTypes(){return jf(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((r=>`image/${r}`)))}static get supportedTypesStr(){return jf(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(r){return this.supportedTypes.includes(r)}static paste(r,e){e.pasteEditor(qs.STAMP,{bitmapFile:r.getAsFile()})}remove(){var r,e;t(this,oB)&&(A(this,nB,null),this._uiManager.imageManager.deleteId(t(this,oB)),null==(r=t(this,cB))||r.remove(),A(this,cB,null),null==(e=t(this,dB))||e.disconnect(),A(this,dB,null),t(this,hB)&&(clearTimeout(t(this,hB)),A(this,hB,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(t(this,oB)&&null===t(this,cB)&&o(this,wB,yB).call(this),this.isAttachedToDOM||this.parent.add(this))):t(this,oB)&&o(this,wB,yB).call(this)}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(t(this,sB)||t(this,nB)||t(this,fB)||t(this,lB)||t(this,oB))}get isResizable(){return!0}render(){if(this.div)return this.div;let r,e;if(this.width&&(r=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),t(this,nB)?o(this,EB,CB).call(this):o(this,wB,yB).call(this),this.width){const[a,t]=this.parentDimensions;this.setAt(r*a,e*t,this.width*a,this.height*t)}return this.div}getImageForAltText(){return t(this,cB)}static deserialize(r,e,a){if(r instanceof Ok)return null;const t=super.deserialize(r,e,a),{rect:i,bitmapUrl:n,bitmapId:o,isSvg:s,accessibilityData:f}=r;o&&a.imageManager.isValidId(o)?A(t,oB,o):A(t,fB,n),A(t,bB,s);const[l,u]=t.pageDimensions;return t.width=(i[2]-i[0])/l,t.height=(i[3]-i[1])/u,f&&(t.altTextData=f),t}serialize(r=!1,e=null){if(this.isEmpty())return null;const a={annotationType:qs.STAMP,bitmapId:t(this,oB),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:t(this,bB),structTreeParentId:this._structTreeParentId};if(r)return a.bitmapUrl=o(this,FB,SB).call(this,!0),a.accessibilityData=this.altTextData,a;const{decorative:i,altText:A}=this.altTextData;if(!i&&A&&(a.accessibilityData={type:"Figure",alt:A}),null===e)return a;e.stamps||(e.stamps=new Map);const n=t(this,bB)?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(e.stamps.has(t(this,oB))){if(t(this,bB)){const r=e.stamps.get(t(this,oB));n>r.area&&(r.area=n,r.serialized.bitmap.close(),r.serialized.bitmap=o(this,FB,SB).call(this,!1))}}else e.stamps.set(t(this,oB),{area:n,serialized:a}),a.bitmap=o(this,FB,SB).call(this,!1);return a}};let XB=GB;var VB,NB,DB,TB,PB,jB,LB,OB,YB,HB,QB,UB,JB,zB,qB,$B,KB,r_,e_,a_,t_,i_,A_,n_;nB=new WeakMap,oB=new WeakMap,sB=new WeakMap,fB=new WeakMap,lB=new WeakMap,uB=new WeakMap,cB=new WeakMap,dB=new WeakMap,hB=new WeakMap,bB=new WeakMap,gB=new WeakMap,pB=new WeakSet,vB=function(r,e=!1){r?(A(this,nB,r.bitmap),e||(A(this,oB,r.id),A(this,bB,r.isSvg)),r.file&&A(this,uB,r.file.name),o(this,EB,CB).call(this)):this.remove()},mB=new WeakSet,kB=function(){A(this,sB,null),this._uiManager.enableWaiting(!1),t(this,cB)&&this.div.focus()},wB=new WeakSet,yB=function(){if(t(this,oB))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(t(this,oB)).then((r=>o(this,pB,vB).call(this,r,!0))).finally((()=>o(this,mB,kB).call(this)));if(t(this,fB)){const r=t(this,fB);return A(this,fB,null),this._uiManager.enableWaiting(!0),void A(this,sB,this._uiManager.imageManager.getFromUrl(r).then((r=>o(this,pB,vB).call(this,r))).finally((()=>o(this,mB,kB).call(this))))}if(t(this,lB)){const r=t(this,lB);return A(this,lB,null),this._uiManager.enableWaiting(!0),void A(this,sB,this._uiManager.imageManager.getFromFile(r).then((r=>o(this,pB,vB).call(this,r))).finally((()=>o(this,mB,kB).call(this))))}const r=document.createElement("input");r.type="file",r.accept=GB.supportedTypesStr;const e=this._uiManager._signal;A(this,sB,new Promise((a=>{r.addEventListener("change",(async()=>{if(r.files&&0!==r.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(r.files[0]);o(this,pB,vB).call(this,e)}else this.remove();a()}),{signal:e}),r.addEventListener("cancel",(()=>{this.remove(),a()}),{signal:e})})).finally((()=>o(this,mB,kB).call(this)))),r.click()},EB=new WeakSet,CB=function(){const{div:r}=this;let{width:e,height:a}=t(this,nB);const[i,n]=this.pageDimensions,s=.75;if(this.width)e=this.width*i,a=this.height*n;else if(e>s*i||a>s*n){const r=Math.min(s*i/e,s*n/a);e*=r,a*=r}const[f,l]=this.parentDimensions;this.setDims(e*f/i,a*l/n),this._uiManager.enableWaiting(!1);const u=A(this,cB,document.createElement("canvas"));r.append(u),r.hidden=!1,o(this,IB,RB).call(this,e,a),o(this,xB,MB).call(this),t(this,gB)||(this.parent.addUndoableEditor(this),A(this,gB,!0)),this._reportTelemetry({action:"inserted_image"}),t(this,uB)&&u.setAttribute("aria-label",t(this,uB))},BB=new WeakSet,_B=function(r,e){var a;const[i,n]=this.parentDimensions;this.width=r/i,this.height=e/n,this.setDims(r,e),null!=(a=this._initialOptions)&&a.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==t(this,hB)&&clearTimeout(t(this,hB)),A(this,hB,setTimeout((()=>{A(this,hB,null),o(this,IB,RB).call(this,r,e)}),200))},ZB=new WeakSet,WB=function(r,e){const{width:a,height:i}=t(this,nB);let A=a,n=i,o=t(this,nB);for(;A>2*r||n>2*e;){const a=A,t=n;A>2*r&&(A=A>=16384?Math.floor(A/2)-1:Math.ceil(A/2)),n>2*e&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2));const i=new OffscreenCanvas(A,n);i.getContext("2d").drawImage(o,0,0,a,t,0,0,A,n),o=i.transferToImageBitmap()}return o},IB=new WeakSet,RB=function(r,e){r=Math.ceil(r),e=Math.ceil(e);const a=t(this,cB);if(!a||a.width===r&&a.height===e)return;a.width=r,a.height=e;const i=t(this,bB)?t(this,nB):o(this,ZB,WB).call(this,r,e);if(this._uiManager.hasMLManager&&!this.hasAltText()){const a=new OffscreenCanvas(r,e).getContext("2d");a.drawImage(i,0,0,i.width,i.height,0,0,r,e),this._uiManager.mlGuess({service:"image-to-text",request:{data:a.getImageData(0,0,r,e).data,width:r,height:e,channels:4}}).then((r=>{const e=(null==r?void 0:r.output)||"";this.parent&&e&&!this.hasAltText()&&(this.altTextData={altText:e,decorative:!1})}))}const A=a.getContext("2d");A.filter=this._uiManager.hcmFilter,A.drawImage(i,0,0,i.width,i.height,0,0,r,e)},FB=new WeakSet,SB=function(r){if(r){if(t(this,bB)){const r=this._uiManager.imageManager.getSvgUrl(t(this,oB));if(r)return r}const r=document.createElement("canvas");return({width:r.width,height:r.height}=t(this,nB)),r.getContext("2d").drawImage(t(this,nB),0,0),r.toDataURL()}if(t(this,bB)){const[r,e]=this.pageDimensions,a=Math.round(this.width*r*Il.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*Il.PDF_TO_CSS_UNITS),A=new OffscreenCanvas(a,i);return A.getContext("2d").drawImage(t(this,nB),0,0,t(this,nB).width,t(this,nB).height,0,0,a,i),A.transferToImageBitmap()}return structuredClone(t(this,nB))},xB=new WeakSet,MB=function(){this._uiManager._signal&&(A(this,dB,new ResizeObserver((r=>{const e=r[0].contentRect;e.width&&e.height&&o(this,BB,_B).call(this,e.width,e.height)}))),t(this,dB).observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{var r;null==(r=t(this,dB))||r.disconnect(),A(this,dB,null)}),{once:!0}))},e(XB,"_type","stamp"),e(XB,"_editorType",qs.STAMP);const o_=class{constructor({uiManager:r,pageIndex:e,div:a,accessibilityManager:n,annotationLayer:o,drawLayer:s,textLayer:f,viewport:l,l10n:u}){i(this,qB),i(this,KB),i(this,e_),i(this,t_),i(this,A_),i(this,VB,void 0),i(this,NB,!1),i(this,DB,null),i(this,TB,null),i(this,PB,null),i(this,jB,null),i(this,LB,null),i(this,OB,new Map),i(this,YB,!1),i(this,HB,!1),i(this,QB,!1),i(this,UB,null),i(this,JB,void 0);const c=[...t(o_,zB).values()];if(!o_._initialized){o_._initialized=!0;for(const e of c)e.initialize(u,r)}r.registerEditorTypes(c),A(this,JB,r),this.pageIndex=e,this.div=a,A(this,VB,n),A(this,DB,o),this.viewport=l,A(this,UB,f),this.drawLayer=s,t(this,JB).addLayer(this)}get isEmpty(){return 0===t(this,OB).size}get isInvisible(){return this.isEmpty&&t(this,JB).getMode()===qs.NONE}updateToolbar(r){t(this,JB).updateToolbar(r)}updateMode(r=t(this,JB).getMode()){switch(o(this,A_,n_).call(this),r){case qs.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case qs.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case qs.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const a of t(o_,zB).values())e.toggle(`${a._type}Editing`,r===a._editorType);this.div.hidden=!1}hasTextLayer(r){var e;return r===(null==(e=t(this,UB))?void 0:e.div)}addInkEditorIfNeeded(r){if(t(this,JB).getMode()===qs.INK){if(!r)for(const r of t(this,OB).values())if(r.isEmpty())return void r.setInBackground();this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(r){t(this,JB).setEditingState(r)}addCommands(r){t(this,JB).addCommands(r)}togglePointerEvents(r=!1){this.div.classList.toggle("disabled",!r)}toggleAnnotationLayerPointerEvents(r=!1){var e;null==(e=t(this,DB))||e.div.classList.toggle("disabled",!r)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const r=new Set;for(const e of t(this,OB).values())e.enableEditing(),e.show(!0),e.annotationElementId&&(t(this,JB).removeChangedExistingAnnotation(e),r.add(e.annotationElementId));if(!t(this,DB))return;const e=t(this,DB).getEditableAnnotations();for(const a of e){if(a.hide(),t(this,JB).isDeletedAnnotationElement(a.data.id)||r.has(a.data.id))continue;const e=this.deserialize(a);e&&(this.addOrRebuild(e),e.enableEditing())}}disable(){var r;A(this,QB,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,a=new Map;for(const i of t(this,OB).values())if(i.disableEditing(),i.annotationElementId){if(null!==i.serialize()){e.set(i.annotationElementId,i);continue}a.set(i.annotationElementId,i),null==(r=this.getEditableAnnotation(i.annotationElementId))||r.show(),i.remove()}if(t(this,DB)){const r=t(this,DB).getEditableAnnotations();for(const i of r){const{id:r}=i.data;if(t(this,JB).isDeletedAnnotationElement(r))continue;let A=a.get(r);A?(A.resetAnnotationElement(i),A.show(!1),i.show()):(A=e.get(r),A&&(t(this,JB).addChangedExistingAnnotation(A),A.renderAnnotationElement(i),A.show(!1)),i.show())}}o(this,A_,n_).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const r of t(o_,zB).values())i.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),A(this,QB,!1)}getEditableAnnotation(r){var e;return(null==(e=t(this,DB))?void 0:e.getEditableAnnotation(r))||null}setActiveEditor(r){t(this,JB).getActive()!==r&&t(this,JB).setActiveEditor(r)}enableTextSelection(){var r;this.div.tabIndex=-1,null!=(r=t(this,UB))&&r.div&&!t(this,jB)&&(A(this,jB,o(this,qB,$B).bind(this)),t(this,UB).div.addEventListener("pointerdown",t(this,jB),{signal:t(this,JB)._signal}),t(this,UB).div.classList.add("highlighting"))}disableTextSelection(){var r;this.div.tabIndex=0,null!=(r=t(this,UB))&&r.div&&t(this,jB)&&(t(this,UB).div.removeEventListener("pointerdown",t(this,jB)),A(this,jB,null),t(this,UB).div.classList.remove("highlighting"))}enableClick(){if(t(this,PB))return;const r=t(this,JB)._signal;A(this,PB,this.pointerdown.bind(this)),A(this,TB,this.pointerup.bind(this)),this.div.addEventListener("pointerdown",t(this,PB),{signal:r}),this.div.addEventListener("pointerup",t(this,TB),{signal:r})}disableClick(){t(this,PB)&&(this.div.removeEventListener("pointerdown",t(this,PB)),this.div.removeEventListener("pointerup",t(this,TB)),A(this,PB,null),A(this,TB,null))}attach(r){t(this,OB).set(r.id,r);const{annotationElementId:e}=r;e&&t(this,JB).isDeletedAnnotationElement(e)&&t(this,JB).removeDeletedAnnotationElement(r)}detach(r){var e;t(this,OB).delete(r.id),null==(e=t(this,VB))||e.removePointerInTextLayer(r.contentDiv),!t(this,QB)&&r.annotationElementId&&t(this,JB).addDeletedAnnotationElement(r)}remove(r){this.detach(r),t(this,JB).removeEditor(r),r.div.remove(),r.isAttachedToDOM=!1,t(this,HB)||this.addInkEditorIfNeeded(!1)}changeParent(r){var e;r.parent!==this&&(r.parent&&r.annotationElementId&&(t(this,JB).addDeletedAnnotationElement(r.annotationElementId),ob.deleteAnnotationElement(r),r.annotationElementId=null),this.attach(r),null==(e=r.parent)||e.detach(r),r.setParent(this),r.div&&r.isAttachedToDOM&&(r.div.remove(),this.div.append(r.div)))}add(r){if(r.parent!==this||!r.isAttachedToDOM){if(this.changeParent(r),t(this,JB).addEditor(r),this.attach(r),!r.isAttachedToDOM){const e=r.render();this.div.append(e),r.isAttachedToDOM=!0}r.fixAndSetPosition(),r.onceAdded(),t(this,JB).addToAnnotationStorage(r),r._reportTelemetry(r.telemetryInitialData)}}moveEditorInDOM(r){var e;if(!r.isAttachedToDOM)return;const{activeElement:a}=document;r.div.contains(a)&&!t(this,LB)&&(r._focusEventsAllowed=!1,A(this,LB,setTimeout((()=>{A(this,LB,null),r.div.contains(document.activeElement)?r._focusEventsAllowed=!0:(r.div.addEventListener("focusin",(()=>{r._focusEventsAllowed=!0}),{once:!0,signal:t(this,JB)._signal}),a.focus())}),0))),r._structTreeParentId=null==(e=t(this,VB))?void 0:e.moveElementInDOM(this.div,r.div,r.contentDiv,!0)}addOrRebuild(r){r.needsToBeRebuilt()?(r.parent||(r.parent=this),r.rebuild(),r.show()):this.add(r)}addUndoableEditor(r){this.addCommands({cmd:()=>r._uiManager.rebuild(r),undo:()=>{r.remove()},mustExec:!1})}getNextId(){return t(this,JB).getId()}get _signal(){return t(this,JB)._signal}canCreateNewEmptyEditor(){var r;return null==(r=t(this,KB,r_))?void 0:r.canCreateNewEmptyEditor()}pasteEditor(r,e){t(this,JB).updateToolbar(r),t(this,JB).updateMode(r);const{offsetX:a,offsetY:i}=o(this,t_,i_).call(this),A=this.getNextId(),n=o(this,e_,a_).call(this,{parent:this,id:A,x:a,y:i,uiManager:t(this,JB),isCentered:!0,...e});n&&this.add(n)}deserialize(r){var e;return(null==(e=t(o_,zB).get(r.annotationType??r.annotationEditorType))?void 0:e.deserialize(r,this,t(this,JB)))||null}createAndAddNewEditor(r,e,a={}){const i=this.getNextId(),A=o(this,e_,a_).call(this,{parent:this,id:i,x:r.offsetX,y:r.offsetY,uiManager:t(this,JB),isCentered:e,...a});return A&&this.add(A),A}addNewEditor(){this.createAndAddNewEditor(o(this,t_,i_).call(this),!0)}setSelected(r){t(this,JB).setSelected(r)}toggleSelected(r){t(this,JB).toggleSelected(r)}isSelected(r){return t(this,JB).isSelected(r)}unselect(r){t(this,JB).unselect(r)}pointerup(r){const{isMac:e}=rl.platform;if(!(0!==r.button||r.ctrlKey&&e)&&r.target===this.div&&t(this,YB)){if(A(this,YB,!1),!t(this,NB))return void A(this,NB,!0);if(t(this,JB).getMode()===qs.STAMP)return void t(this,JB).unselectAll();this.createAndAddNewEditor(r,!1)}}pointerdown(r){if(t(this,JB).getMode()===qs.HIGHLIGHT&&this.enableTextSelection(),t(this,YB))return void A(this,YB,!1);const{isMac:e}=rl.platform;if(0!==r.button||r.ctrlKey&&e||r.target!==this.div)return;A(this,YB,!0);const a=t(this,JB).getActive();A(this,NB,!a||a.isEmpty())}findNewParent(r,e,a){const i=t(this,JB).findParent(e,a);return null!==i&&i!==this&&(i.changeParent(r),!0)}destroy(){var r,e;(null==(r=t(this,JB).getActive())?void 0:r.parent)===this&&(t(this,JB).commitOrRemove(),t(this,JB).setActiveEditor(null)),t(this,LB)&&(clearTimeout(t(this,LB)),A(this,LB,null));for(const r of t(this,OB).values())null==(e=t(this,VB))||e.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,t(this,OB).clear(),t(this,JB).removeLayer(this)}render({viewport:r}){this.viewport=r,Cu(this.div,r);for(const r of t(this,JB).getEditors(this.pageIndex))this.add(r),r.rebuild();this.updateMode()}update({viewport:r}){t(this,JB).commitOrRemove(),o(this,A_,n_).call(this);const e=this.viewport.rotation,a=r.rotation;if(this.viewport=r,Cu(this.div,{rotation:a}),e!==a)for(const r of t(this,OB).values())r.rotate(a);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:r,pageHeight:e}=this.viewport.rawDims;return[r,e]}get scale(){return t(this,JB).viewParameters.realScale}};let s_=o_;var f_,l_,u_,c_,d_,h_,b_,g_,p_,v_;VB=new WeakMap,NB=new WeakMap,DB=new WeakMap,TB=new WeakMap,PB=new WeakMap,jB=new WeakMap,LB=new WeakMap,OB=new WeakMap,YB=new WeakMap,HB=new WeakMap,QB=new WeakMap,UB=new WeakMap,JB=new WeakMap,zB=new WeakMap,qB=new WeakSet,$B=function(r){if(t(this,JB).unselectAll(),r.target===t(this,UB).div){const{isMac:e}=rl.platform;if(0!==r.button||r.ctrlKey&&e)return;t(this,JB).showAllEditors("highlight",!0,!0),t(this,UB).div.classList.add("free"),OE.startHighlighting(this,"ltr"===t(this,JB).direction,r),t(this,UB).div.addEventListener("pointerup",(()=>{t(this,UB).div.classList.remove("free")}),{once:!0,signal:t(this,JB)._signal}),r.preventDefault()}},KB=new WeakSet,r_=function(){return t(o_,zB).get(t(this,JB).getMode())},e_=new WeakSet,a_=function(r){const e=t(this,KB,r_);return e?new e.prototype.constructor(r):null},t_=new WeakSet,i_=function(){const{x:r,y:e,width:a,height:t}=this.div.getBoundingClientRect(),i=Math.max(0,r),A=Math.max(0,e),n=(i+Math.min(window.innerWidth,r+a))/2-r,o=(A+Math.min(window.innerHeight,e+t))/2-e,[s,f]=this.viewport.rotation%180==0?[n,o]:[o,n];return{offsetX:s,offsetY:f}},A_=new WeakSet,n_=function(){A(this,HB,!0);for(const r of t(this,OB).values())r.isEmpty()&&r.remove();A(this,HB,!1)},e(s_,"_initialized",!1),i(s_,zB,new Map([Ew,AB,XB,OE].map((r=>[r._editorType,r]))));const m_=class{constructor({pageIndex:r}){i(this,b_),i(this,p_),i(this,f_,null),i(this,l_,0),i(this,u_,new Map),i(this,c_,new Map),this.pageIndex=r}setParent(r){if(t(this,f_)){if(t(this,f_)!==r){if(t(this,u_).size>0)for(const e of t(this,u_).values())e.remove(),r.append(e);A(this,f_,r)}}else A(this,f_,r)}static get _svgFactory(){return jf(this,"_svgFactory",new ou)}highlight(r,e,a,i=!1){const A=n(this,l_)._++,s=o(this,b_,g_).call(this,r.box);s.classList.add("highlight"),r.free&&s.classList.add("free");const f=m_._svgFactory.createElement("defs");s.append(f);const l=m_._svgFactory.createElement("path");f.append(l);const u=`path_p${this.pageIndex}_${A}`;l.setAttribute("id",u),l.setAttribute("d",r.toSVGPath()),i&&t(this,c_).set(A,l);const c=o(this,p_,v_).call(this,f,u),d=m_._svgFactory.createElement("use");return s.append(d),s.setAttribute("fill",e),s.setAttribute("fill-opacity",a),d.setAttribute("href",`#${u}`),t(this,u_).set(A,s),{id:A,clipPathId:`url(#${c})`}}highlightOutline(r){const e=n(this,l_)._++,a=o(this,b_,g_).call(this,r.box);a.classList.add("highlightOutline");const i=m_._svgFactory.createElement("defs");a.append(i);const A=m_._svgFactory.createElement("path");i.append(A);const s=`path_p${this.pageIndex}_${e}`;let f;if(A.setAttribute("id",s),A.setAttribute("d",r.toSVGPath()),A.setAttribute("vector-effect","non-scaling-stroke"),r.free){a.classList.add("free");const r=m_._svgFactory.createElement("mask");i.append(r),f=`mask_p${this.pageIndex}_${e}`,r.setAttribute("id",f),r.setAttribute("maskUnits","objectBoundingBox");const t=m_._svgFactory.createElement("rect");r.append(t),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("fill","white");const A=m_._svgFactory.createElement("use");r.append(A),A.setAttribute("href",`#${s}`),A.setAttribute("stroke","none"),A.setAttribute("fill","black"),A.setAttribute("fill-rule","nonzero"),A.classList.add("mask")}const l=m_._svgFactory.createElement("use");a.append(l),l.setAttribute("href",`#${s}`),f&&l.setAttribute("mask",`url(#${f})`);const u=l.cloneNode();return a.append(u),l.classList.add("mainOutline"),u.classList.add("secondaryOutline"),t(this,u_).set(e,a),e}finalizeLine(r,e){const a=t(this,c_).get(r);t(this,c_).delete(r),this.updateBox(r,e.box),a.setAttribute("d",e.toSVGPath())}updateLine(r,e){t(this,u_).get(r).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(r){this.remove(r),t(this,c_).delete(r)}updatePath(r,e){t(this,c_).get(r).setAttribute("d",e.toSVGPath())}updateBox(r,e){var a;o(a=m_,d_,h_).call(a,t(this,u_).get(r),e)}show(r,e){t(this,u_).get(r).classList.toggle("hidden",!e)}rotate(r,e){t(this,u_).get(r).setAttribute("data-main-rotation",e)}changeColor(r,e){t(this,u_).get(r).setAttribute("fill",e)}changeOpacity(r,e){t(this,u_).get(r).setAttribute("fill-opacity",e)}addClass(r,e){t(this,u_).get(r).classList.add(e)}removeClass(r,e){t(this,u_).get(r).classList.remove(e)}remove(r){null!==t(this,f_)&&(t(this,u_).get(r).remove(),t(this,u_).delete(r))}destroy(){A(this,f_,null);for(const r of t(this,u_).values())r.remove();t(this,u_).clear()}};let k_=m_;f_=new WeakMap,l_=new WeakMap,u_=new WeakMap,c_=new WeakMap,d_=new WeakSet,h_=function(r,{x:e=0,y:a=0,width:t=1,height:i=1}={}){const{style:A}=r;A.top=100*a+"%",A.left=100*e+"%",A.width=100*t+"%",A.height=100*i+"%"},b_=new WeakSet,g_=function(r){var e;const a=m_._svgFactory.create(1,1,!0);return t(this,f_).append(a),a.setAttribute("aria-hidden",!0),o(e=m_,d_,h_).call(e,a,r),a},p_=new WeakSet,v_=function(r,e){const a=m_._svgFactory.createElement("clipPath");r.append(a);const t=`clip_${e}`;a.setAttribute("id",t),a.setAttribute("clipPathUnits","objectBoundingBox");const i=m_._svgFactory.createElement("use");return a.append(i),i.setAttribute("href",`#${e}`),i.classList.add("clip"),t},i(k_,d_);var w_=Ns.AbortException,y_=Ns.AnnotationEditorLayer,E_=Ns.AnnotationEditorParamsType,C_=Ns.AnnotationEditorType,B_=Ns.AnnotationEditorUIManager,__=Ns.AnnotationLayer,Z_=Ns.AnnotationMode,W_=Ns.CMapCompressionType,I_=Ns.ColorPicker,R_=Ns.DOMSVGFactory,F_=Ns.DrawLayer,S_=Ns.FeatureTest,x_=Ns.GlobalWorkerOptions,M_=Ns.ImageKind,G_=Ns.InvalidPDFException,X_=Ns.MissingPDFException,V_=Ns.OPS,N_=Ns.Outliner,D_=Ns.PDFDataRangeTransport,T_=Ns.PDFDateString,P_=Ns.PDFWorker,j_=Ns.PasswordResponses,L_=Ns.PermissionFlag,O_=Ns.PixelsPerInch,Y_=Ns.RenderingCancelledException,H_=Ns.TextLayer,Q_=Ns.UnexpectedResponseException,U_=Ns.Util,J_=Ns.VerbosityLevel,z_=Ns.XfaLayer,q_=Ns.build,$_=Ns.createValidAbsoluteUrl,K_=Ns.fetchData,rZ=Ns.getDocument,eZ=Ns.getFilenameFromUrl,aZ=Ns.getPdfFilenameFromUrl,tZ=Ns.getXfaPageViewport,iZ=Ns.isDataScheme,AZ=Ns.isPdfFile,nZ=Ns.noContextMenu,oZ=Ns.normalizeUnicode,sZ=Ns.renderTextLayer,fZ=Ns.setLayerDimensions,lZ=Ns.shadow,uZ=Ns.updateTextLayer,cZ=Ns.version;const dZ=Object.freeze(Object.defineProperty({__proto__:null,AbortException:w_,AnnotationEditorLayer:y_,AnnotationEditorParamsType:E_,AnnotationEditorType:C_,AnnotationEditorUIManager:B_,AnnotationLayer:__,AnnotationMode:Z_,CMapCompressionType:W_,ColorPicker:I_,DOMSVGFactory:R_,DrawLayer:F_,FeatureTest:S_,GlobalWorkerOptions:x_,ImageKind:M_,InvalidPDFException:G_,MissingPDFException:X_,OPS:V_,Outliner:N_,PDFDataRangeTransport:D_,PDFDateString:T_,PDFWorker:P_,PasswordResponses:j_,PermissionFlag:L_,PixelsPerInch:O_,RenderingCancelledException:Y_,TextLayer:H_,UnexpectedResponseException:Q_,Util:U_,VerbosityLevel:J_,XfaLayer:z_,build:q_,createValidAbsoluteUrl:$_,fetchData:K_,getDocument:rZ,getFilenameFromUrl:eZ,getPdfFilenameFromUrl:aZ,getXfaPageViewport:tZ,isDataScheme:iZ,isPdfFile:AZ,noContextMenu:nZ,normalizeUnicode:oZ,renderTextLayer:sZ,setLayerDimensions:fZ,shadow:lZ,updateTextLayer:uZ,version:cZ},Symbol.toStringTag,{value:"Module"}));var hZ=globalThis&&globalThis.__spreadArray||function(r,e,a){if(a||2===arguments.length)for(var t,i=0,A=e.length;i<A;i++)(t||!(i in e))&&(t||(t=Array.prototype.slice.call(e,0,i)),t[i]=e[i]);return r.concat(t||Array.prototype.slice.call(e))},bZ=hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ([],["onCopy","onCut","onPaste"],!0),["onCompositionEnd","onCompositionStart","onCompositionUpdate"],!0),["onFocus","onBlur"],!0),["onInput","onInvalid","onReset","onSubmit"],!0),["onLoad","onError"],!0),["onKeyDown","onKeyPress","onKeyUp"],!0),["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],!0),["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],!0),["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],!0),["onSelect"],!0),["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],!0),["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],!0),["onScroll"],!0),["onWheel"],!0),["onAnimationStart","onAnimationEnd","onAnimationIteration"],!0),["onTransitionEnd"],!0),["onChange"],!0),["onToggle"],!0);function gZ(r,e){var a={};return bZ.forEach((function(t){var i=r[t];i&&(a[t]=e?function(r){return i(r,e(t))}:i)})),a}function pZ(r){var e=!1;return{promise:new Promise((function(a,t){r.then((function(r){return!e&&a(r)})).catch((function(r){return!e&&t(r)}))})),cancel:function(){e=!0}}}function vZ(r){var e,a,t="";if("string"==typeof r||"number"==typeof r)t+=r;else if("object"==typeof r)if(Array.isArray(r)){var i=r.length;for(e=0;e<i;e++)r[e]&&(a=vZ(r[e]))&&(t&&(t+=" "),t+=a)}else for(a in r)r[a]&&(t&&(t+=" "),t+=a);return t}function mZ(){for(var r,e,a=0,t="",i=arguments.length;a<i;a++)(r=arguments[a])&&(e=vZ(r))&&(t&&(t+=" "),t+=e);return t}var kZ="production"===process.env.NODE_ENV,wZ="Invariant failed";function yZ(r,e){if(!r){if(kZ)throw new Error(wZ);var a="function"==typeof e?e():e,t=a?"".concat(wZ,": ").concat(a):wZ;throw new Error(t)}}var EZ=function(){};if("production"!==process.env.NODE_ENV){var CZ=function(r,e){var a=arguments.length;e=new Array(a>1?a-1:0);for(var t=1;t<a;t++)e[t-1]=arguments[t];var i=0,A="Warning: "+r.replace(/%s/g,(function(){return e[i++]}));typeof console<"u"&&console.error(A);try{throw new Error(A)}catch{}};EZ=function(r,e,a){var t=arguments.length;a=new Array(t>2?t-2:0);for(var i=2;i<t;i++)a[i-2]=arguments[i];if(void 0===e)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");r||CZ.apply(null,[e].concat(a))}}const BZ=W(EZ);var _Z=Object.prototype.hasOwnProperty;function ZZ(r,e,a){for(a of r.keys())if(WZ(a,e))return a}function WZ(r,e){var a,t,i;if(r===e)return!0;if(r&&e&&(a=r.constructor)===e.constructor){if(a===Date)return r.getTime()===e.getTime();if(a===RegExp)return r.toString()===e.toString();if(a===Array){if((t=r.length)===e.length)for(;t--&&WZ(r[t],e[t]););return-1===t}if(a===Set){if(r.size!==e.size)return!1;for(t of r)if((i=t)&&"object"==typeof i&&!(i=ZZ(e,i))||!e.has(i))return!1;return!0}if(a===Map){if(r.size!==e.size)return!1;for(t of r)if((i=t[0])&&"object"==typeof i&&!(i=ZZ(e,i))||!WZ(t[1],e.get(i)))return!1;return!0}if(a===ArrayBuffer)r=new Uint8Array(r),e=new Uint8Array(e);else if(a===DataView){if((t=r.byteLength)===e.byteLength)for(;t--&&r.getInt8(t)===e.getInt8(t););return-1===t}if(ArrayBuffer.isView(r)){if((t=r.byteLength)===e.byteLength)for(;t--&&r[t]===e[t];);return-1===t}if(!a||"object"==typeof r){for(a in t=0,r)if(_Z.call(r,a)&&++t&&!_Z.call(e,a)||!(a in e)||!WZ(r[a],e[a]))return!1;return Object.keys(e).length===t}}return r!=r&&e!=e}const IZ=p(null);function RZ({children:r,type:e}){return s("div",{className:`react-pdf__message react-pdf__message--${e}`,children:r})}class FZ{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(r){this.pdfDocument=r}setViewer(r){this.pdfViewer=r}setExternalLinkRel(r){this.externalLinkRel=r}setExternalLinkTarget(r){this.externalLinkTarget=r}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return yZ(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(r){yZ(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=r}get rotation(){return 0}set rotation(r){}goToDestination(r){return new Promise((e=>{yZ(this.pdfDocument,"PDF document not loaded."),yZ(r,"Destination is not specified."),"string"==typeof r?this.pdfDocument.getDestination(r).then(e):Array.isArray(r)?e(r):r.then(e)})).then((r=>{yZ(Array.isArray(r),`"${r}" is not a valid destination array.`);const e=r[0];new Promise((r=>{yZ(this.pdfDocument,"PDF document not loaded."),e instanceof Object?this.pdfDocument.getPageIndex(e).then((e=>{r(e)})).catch((()=>{yZ(!1,`"${e}" is not a valid page reference.`)})):"number"==typeof e?r(e):yZ(!1,`"${e}" is not a valid destination reference.`)})).then((e=>{const a=e+1;yZ(this.pdfViewer,"PDF viewer is not initialized."),yZ(a>=1&&a<=this.pagesCount,`"${a}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({dest:r,pageIndex:e,pageNumber:a})}))}))}navigateTo(r){this.goToDestination(r)}goToPage(r){const e=r-1;yZ(this.pdfViewer,"PDF viewer is not initialized."),yZ(r>=1&&r<=this.pagesCount,`"${r}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:r})}addLinkAttributes(r,e,a){r.href=e,r.rel=this.externalLinkRel||"noopener noreferrer nofollow",r.target=a?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const SZ={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},xZ=typeof document<"u",MZ=xZ&&"file:"===window.location.protocol;function GZ(r){return function(r){return typeof r<"u"}(r)&&null!==r}function XZ(r){return function(r){return"string"==typeof r}(r)&&/^data:/.test(r)}function VZ(r){yZ(XZ(r),"Invalid data URI.");const[e="",a=""]=r.split(",");return-1!==e.split(";").indexOf("base64")?atob(a):unescape(a)}function NZ(){return xZ&&window.devicePixelRatio||1}const DZ="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function TZ(){BZ(!MZ,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${DZ}`)}function PZ(r){null!=r&&r.cancel&&r.cancel()}function jZ(r,e){return Object.defineProperty(r,"width",{get(){return this.view[2]*e},configurable:!0}),Object.defineProperty(r,"height",{get(){return this.view[3]*e},configurable:!0}),Object.defineProperty(r,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(r,"originalHeight",{get(){return this.view[3]},configurable:!0}),r}function LZ(r){return new Promise(((e,a)=>{const t=new FileReader;t.onload=()=>{if(!t.result)return a(new Error("Error while reading a file."));e(t.result)},t.onerror=r=>{if(!r.target)return a(new Error("Error while reading a file."));const{error:e}=r.target;if(!e)return a(new Error("Error while reading a file."));switch(e.code){case e.NOT_FOUND_ERR:return a(new Error("Error while reading a file: File not found."));case e.SECURITY_ERR:return a(new Error("Error while reading a file: Security error."));case e.ABORT_ERR:return a(new Error("Error while reading a file: Aborted."));default:return a(new Error("Error while reading a file."))}},t.readAsArrayBuffer(r)}))}function OZ(r,e){switch(e.type){case"RESOLVE":return{value:e.value,error:void 0};case"REJECT":return{value:!1,error:e.error};case"RESET":return{value:void 0,error:void 0};default:return r}}function YZ(){return m(OZ,{value:void 0,error:void 0})}var HZ=globalThis&&globalThis.__awaiter||function(r,e,a,t){return new(a||(a=Promise))((function(i,A){function n(r){try{s(t.next(r))}catch(r){A(r)}}function o(r){try{s(t.throw(r))}catch(r){A(r)}}function s(r){r.done?i(r.value):function(r){return r instanceof a?r:new a((function(e){e(r)}))}(r.value).then(n,o)}s((t=t.apply(r,e||[])).next())}))},QZ=globalThis&&globalThis.__rest||function(r,e){var a={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.indexOf(t)<0&&(a[t]=r[t]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(r);i<t.length;i++)e.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(r,t[i])&&(a[t[i]]=r[t[i]])}return a};const{PDFDataRangeTransport:UZ}=dZ,JZ=(r,e)=>{switch(e){case SZ.NEED_PASSWORD:r(prompt("Enter the password to open this PDF file."));break;case SZ.INCORRECT_PASSWORD:r(prompt("Invalid password. Please try again."));break}};function zZ(r){return"object"==typeof r&&null!==r&&("data"in r||"range"in r||"url"in r)}const qZ=v((function(r,e){var{children:a,className:t,error:i="Failed to load PDF file.",externalLinkRel:A,externalLinkTarget:n,file:o,inputRef:f,imageResourcesPath:l,loading:u="Loading PDF…",noData:h="No PDF file specified.",onItemClick:b,onLoadError:g,onLoadProgress:p,onLoadSuccess:v,onPassword:m=JZ,onSourceError:E,onSourceSuccess:C,options:B,renderMode:_,rotate:Z}=r,W=QZ(r,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[I,R]=YZ(),{value:F,error:S}=I,[x,M]=YZ(),{value:G,error:X}=x,V=d(new FZ),N=d([]),D=d(void 0),T=d(void 0);o&&o!==D.current&&zZ(o)&&(BZ(!WZ(o,D.current),'File prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.'),D.current=o),B&&B!==T.current&&(BZ(!WZ(B,T.current),'Options prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.'),T.current=B);const P=d({scrollPageIntoView:r=>{const{dest:e,pageNumber:a,pageIndex:t=a-1}=r;if(b)return void b({dest:e,pageIndex:t,pageNumber:a});const i=N.current[t];i?i.scrollIntoView():BZ(!1,`An internal link leading to page ${a} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});w(e,(()=>({linkService:V,pages:N,viewer:P})),[]),k((function(){R({type:"RESET"})}),[o,R]);const j=y((()=>HZ(this,void 0,void 0,(function*(){if(!o)return null;if("string"==typeof o)return XZ(o)?{data:VZ(o)}:(TZ(),{url:o});if(o instanceof UZ)return{range:o};if(o instanceof ArrayBuffer)return{data:o};if(xZ&&function(r){return yZ(xZ,"isBlob can only be used in a browser environment"),r instanceof Blob}(o))return{data:yield LZ(o)};if(yZ("object"==typeof o,"Invalid parameter in file, need either Uint8Array, string or a parameter object"),yZ(zZ(o),"Invalid parameter object: need either .data, .range or .url"),"url"in o&&"string"==typeof o.url){if(XZ(o.url)){const{url:r}=o,e=QZ(o,["url"]),a=VZ(r);return Object.assign({data:a},e)}TZ()}return o}))),[o]);k((()=>{const r=pZ(j());return r.promise.then((r=>{R({type:"RESOLVE",value:r})})).catch((r=>{R({type:"REJECT",error:r})})),()=>{PZ(r)}}),[j,R]),k((()=>{if(!(typeof F>"u")){if(!1===F)return void(S&&(BZ(!1,S.toString()),E&&E(S)));C&&C()}}),[F]),k((function(){M({type:"RESET"})}),[M,F]),k((function(){if(!F)return;const r=Object.assign(Object.assign({},F),B),e=rZ(r);p&&(e.onProgress=p),m&&(e.onPassword=m);const a=e;return a.promise.then((r=>{M({type:"RESOLVE",value:r})})).catch((r=>{a.destroyed||M({type:"REJECT",error:r})})),()=>{a.destroy()}}),[B,M,F]),k((()=>{if(!(typeof G>"u")){if(!1===G)return void(X&&(BZ(!1,X.toString()),g&&g(X)));G&&(v&&v(G),N.current=new Array(G.numPages),V.current.setDocument(G))}}),[G]),k((function(){V.current.setViewer(P.current),V.current.setExternalLinkRel(A),V.current.setExternalLinkTarget(n)}),[A,n]);const L=y(((r,e)=>{N.current[r]=e}),[]),O=y((r=>{delete N.current[r]}),[]),Y=c((()=>({imageResourcesPath:l,linkService:V.current,onItemClick:b,pdf:G,registerPage:L,renderMode:_,rotate:Z,unregisterPage:O})),[l,b,G,L,_,Z,O]),H=c((()=>gZ(W,(()=>G))),[W,G]);return s("div",Object.assign({className:mZ("react-pdf__Document",t),ref:f,style:{"--scale-factor":"1"}},H,{children:o?null==G?s(RZ,{type:"loading",children:"function"==typeof u?u():u}):!1===G?s(RZ,{type:"error",children:"function"==typeof i?i():i}):s(IZ.Provider,{value:Y,children:a}):s(RZ,{type:"no-data",children:"function"==typeof h?h():h})}))})),$Z=qZ;function KZ(){return g(IZ)}function rW(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var a=r.filter(Boolean);return a.length<=1?a[0]||null:function(r){a.forEach((function(e){"function"==typeof e?e(r):e&&(e.current=r)}))}}const eW=p(null),aW={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},tW=/^H(\d+)$/;function iW(r){return"children"in r}function AW(r){return!!iW(r)&&(1===r.children.length&&0 in r.children&&"id"in r.children[0])}function nW(r){const e={};if(iW(r)){const{role:a}=r,t=a.match(tW);if(t)e.role="heading",e["aria-level"]=Number(t[1]);else if(function(r){return r in aW}(a)){const r=aW[a];r&&(e.role=r)}}return e}function oW(r){const e={};if(iW(r)){if(void 0!==r.alt&&(e["aria-label"]=r.alt),void 0!==r.lang&&(e.lang=r.lang),AW(r)){const[a]=r.children;if(a){const r=oW(a);return Object.assign(Object.assign({},e),r)}}}else"id"in r&&(e["aria-owns"]=r.id);return e}function sW(r){return r?Object.assign(Object.assign({},nW(r)),oW(r)):null}function fW({className:r,node:e}){const a=c((()=>sW(e)),[e]),t=c((()=>!iW(e)||AW(e)?null:e.children.map(((r,e)=>s(fW,{node:r},e)))),[e]);return s("span",Object.assign({className:r},a,{children:t}))}function lW(){return g(eW)}function uW(){const r=lW();yZ(r,"Unable to find Page context.");const{onGetStructTreeError:e,onGetStructTreeSuccess:a}=r,[t,i]=YZ(),{value:A,error:n}=t,{customTextRenderer:o,page:f}=r;return k((function(){i({type:"RESET"})}),[i,f]),k((function(){if(o||!f)return;const r=pZ(f.getStructTree()),e=r;return r.promise.then((r=>{i({type:"RESOLVE",value:r})})).catch((r=>{i({type:"REJECT",error:r})})),()=>PZ(e)}),[o,f,i]),k((()=>{if(void 0!==A){if(!1===A)return void(n&&(BZ(!1,n.toString()),e&&e(n)));A&&a&&a(A)}}),[A]),A?s(fW,{className:"react-pdf__Page__structTree structTree",node:A}):null}const cW=Z_;function dW(r){const e=lW();yZ(e,"Unable to find Page context.");const a=Object.assign(Object.assign({},e),r),{_className:t,canvasBackground:i,devicePixelRatio:A=NZ(),onRenderError:n,onRenderSuccess:o,page:f,renderForms:l,renderTextLayer:u,rotate:h,scale:b}=a,{canvasRef:g}=r;yZ(f,"Attempted to render page canvas, but no page was specified.");const p=d(null);function v(r){(function(r){return"RenderingCancelledException"===r.name})(r)||(BZ(!1,r.toString()),n&&n(r))}const m=c((()=>f.getViewport({scale:b*A,rotation:h})),[A,f,h,b]),w=c((()=>f.getViewport({scale:b,rotation:h})),[f,h,b]);k((function(){if(!f)return;f.cleanup();const{current:r}=p;if(!r)return;r.width=m.width,r.height=m.height,r.style.width=`${Math.floor(w.width)}px`,r.style.height=`${Math.floor(w.height)}px`,r.style.visibility="hidden";const e={annotationMode:l?cW.ENABLE_FORMS:cW.ENABLE,canvasContext:r.getContext("2d",{alpha:!1}),viewport:m};i&&(e.background=i);const a=f.render(e),t=a;return a.promise.then((()=>{r.style.visibility="",f&&o&&o(jZ(f,b))})).catch(v),()=>PZ(t)}),[i,f,l,m,w]);const E=y((()=>{const{current:r}=p;r&&(r.width=0,r.height=0)}),[]);return k((()=>E),[E]),s("canvas",{className:`${t}__canvas`,dir:"ltr",ref:rW(g,p),style:{display:"block",userSelect:"none"},children:u?s(uW,{}):null})}function hW(){const r=lW();yZ(r,"Unable to find Page context.");const{customTextRenderer:e,onGetTextError:a,onGetTextSuccess:t,onRenderTextLayerError:i,onRenderTextLayerSuccess:A,page:n,pageIndex:o,pageNumber:f,rotate:l,scale:u}=r;yZ(n,"Attempted to load page text content, but no page was specified.");const[h,b]=YZ(),{value:g,error:p}=h,v=d(null),m=d(void 0);BZ(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10),"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer"),k((function(){b({type:"RESET"})}),[n,b]),k((function(){if(!n)return;const r=pZ(n.getTextContent()),e=r;return r.promise.then((r=>{b({type:"RESOLVE",value:r})})).catch((r=>{b({type:"REJECT",error:r})})),()=>PZ(e)}),[n,b]),k((()=>{if(void 0!==g){if(!1===g)return void(p&&(BZ(!1,p.toString()),a&&a(p)));g&&t&&t(g)}}),[g]);const w=y((()=>{A&&A()}),[A]),E=y((r=>{BZ(!1,r.toString()),i&&i(r)}),[i]);const B=c((()=>n.getViewport({scale:u,rotation:l})),[n,l,u]);return C((function(){if(!n||!g)return;const{current:r}=v;if(!r)return;r.innerHTML="";const a=n.streamTextContent({includeMarkedContent:!0}),t=new H_({container:r,textContentSource:a,viewport:B}),i=t;return t.render().then((()=>{const a=document.createElement("div");a.className="endOfContent",r.append(a),m.current=a;const t=r.querySelectorAll('[role="presentation"]');if(e){let r=0;g.items.forEach(((a,i)=>{if(!function(r){return"str"in r}(a))return;const A=t[r];if(!A)return;const n=e(Object.assign({pageIndex:o,pageNumber:f,itemIndex:i},a));A.innerHTML=n,r+=a.str&&a.hasEOL?2:1}))}w()})).catch(E),()=>PZ(i)}),[e,E,w,n,o,f,g,B]),s("div",{className:mZ("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){const r=m.current;r&&r.classList.remove("active")},onMouseDown:function(){const r=m.current;r&&r.classList.add("active")},ref:v})}function bW(){const r=KZ(),e=lW();yZ(e,"Unable to find Page context.");const a=Object.assign(Object.assign({},r),e),{imageResourcesPath:t,linkService:i,onGetAnnotationsError:A,onGetAnnotationsSuccess:n,onRenderAnnotationLayerError:o,onRenderAnnotationLayerSuccess:f,page:l,pdf:u,renderForms:h,rotate:b,scale:g=1}=a;yZ(u,"Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."),yZ(l,"Attempted to load page annotations, but no page was specified."),yZ(i,"Attempted to load page annotations, but no linkService was specified.");const[p,v]=YZ(),{value:m,error:w}=p,y=d(null);BZ(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10),"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations"),k((function(){v({type:"RESET"})}),[v,l]),k((function(){if(!l)return;const r=pZ(l.getAnnotations()),e=r;return r.promise.then((r=>{v({type:"RESOLVE",value:r})})).catch((r=>{v({type:"REJECT",error:r})})),()=>{PZ(e)}}),[v,l]),k((()=>{if(void 0!==m){if(!1===m)return void(w&&(BZ(!1,w.toString()),A&&A(w)));m&&n&&n(m)}}),[m]);const E=c((()=>l.getViewport({scale:g,rotation:b})),[l,b,g]);return k((function(){if(!(u&&l&&i&&m))return;const{current:r}=y;if(!r)return;const e=E.clone({dontFlip:!0}),a={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:r,l10n:null,page:l,viewport:e},A={annotations:m,annotationStorage:u.annotationStorage,div:r,imageResourcesPath:t,linkService:i,page:l,renderForms:h,viewport:e};r.innerHTML="";try{new __(a).render(A),f&&f()}catch(r){BZ(!1,`${n=r}`),o&&o(n)}var n;return()=>{}}),[m,t,i,l,u,h,E]),s("div",{className:mZ("react-pdf__Page__annotations","annotationLayer"),ref:y})}var gW=globalThis&&globalThis.__rest||function(r,e){var a={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.indexOf(t)<0&&(a[t]=r[t]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(r);i<t.length;i++)e.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(r,t[i])&&(a[t[i]]=r[t[i]])}return a};const pW=1;function vW(r){const e=KZ(),a=Object.assign(Object.assign({},e),r),{_className:t="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:A,canvasRef:n,children:o,className:l,customRenderer:u,customTextRenderer:h,devicePixelRatio:b,error:g="Failed to load the page.",height:p,inputRef:v,loading:m="Loading page…",noData:w="No page specified.",onGetAnnotationsError:y,onGetAnnotationsSuccess:E,onGetStructTreeError:C,onGetStructTreeSuccess:B,onGetTextError:_,onGetTextSuccess:Z,onLoadError:W,onLoadSuccess:I,onRenderAnnotationLayerError:R,onRenderAnnotationLayerSuccess:F,onRenderError:S,onRenderSuccess:x,onRenderTextLayerError:M,onRenderTextLayerSuccess:G,pageIndex:X,pageNumber:V,pdf:N,registerPage:D,renderAnnotationLayer:T=!0,renderForms:P=!1,renderMode:j="canvas",renderTextLayer:L=!0,rotate:O,scale:Y=pW,unregisterPage:H,width:Q}=a,U=gW(a,["_className","_enableRegisterUnregisterPage","canvasBackground","canvasRef","children","className","customRenderer","customTextRenderer","devicePixelRatio","error","height","inputRef","loading","noData","onGetAnnotationsError","onGetAnnotationsSuccess","onGetStructTreeError","onGetStructTreeSuccess","onGetTextError","onGetTextSuccess","onLoadError","onLoadSuccess","onRenderAnnotationLayerError","onRenderAnnotationLayerSuccess","onRenderError","onRenderSuccess","onRenderTextLayerError","onRenderTextLayerSuccess","pageIndex","pageNumber","pdf","registerPage","renderAnnotationLayer","renderForms","renderMode","renderTextLayer","rotate","scale","unregisterPage","width"]),[J,z]=YZ(),{value:q,error:$}=J,K=d(null);yZ(N,"Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.");const rr=GZ(V)?V-1:X??null,er=V??(GZ(X)?X+1:null),ar=O??(q?q.rotate:null),tr=c((()=>{if(!q)return null;let r=1;const e=Y??pW;if(Q||p){const e=q.getViewport({scale:1,rotation:ar});Q?r=Q/e.width:p&&(r=p/e.height)}return e*r}),[p,q,ar,Y,Q]);k((function(){return()=>{GZ(rr)&&i&&H&&H(rr)}}),[i,N,rr,H]),k((function(){z({type:"RESET"})}),[z,N,rr]),k((function(){if(!N||!er)return;const r=pZ(N.getPage(er)),e=r;return r.promise.then((r=>{z({type:"RESOLVE",value:r})})).catch((r=>{z({type:"REJECT",error:r})})),()=>PZ(e)}),[z,N,er]),k((()=>{if(void 0!==q){if(!1===q)return void($&&(BZ(!1,$.toString()),W&&W($)));!function(){if(I){if(!q||!tr)return;I(jZ(q,tr))}if(i&&D){if(!GZ(rr)||!K.current)return;D(rr,K.current)}}()}}),[q,tr]);const ir=c((()=>q&&GZ(rr)&&er&&GZ(ar)&&GZ(tr)?{_className:t,canvasBackground:A,customTextRenderer:h,devicePixelRatio:b,onGetAnnotationsError:y,onGetAnnotationsSuccess:E,onGetStructTreeError:C,onGetStructTreeSuccess:B,onGetTextError:_,onGetTextSuccess:Z,onRenderAnnotationLayerError:R,onRenderAnnotationLayerSuccess:F,onRenderError:S,onRenderSuccess:x,onRenderTextLayerError:M,onRenderTextLayerSuccess:G,page:q,pageIndex:rr,pageNumber:er,renderForms:P,renderTextLayer:L,rotate:ar,scale:tr}:null),[t,A,h,b,y,E,C,B,_,Z,R,F,S,x,M,G,q,rr,er,P,L,ar,tr]),Ar=c((()=>gZ(U,(()=>q&&(tr?jZ(q,tr):void 0)))),[U,q,tr]),nr=`${rr}@${tr}/${ar}`;function or(){switch(j){case"custom":return yZ(u,'renderMode was set to "custom", but no customRenderer was passed.'),s(u,{},`${nr}_custom`);case"none":return null;default:return s(dW,{canvasRef:n},`${nr}_canvas`)}}return s("div",Object.assign({className:mZ(t,l),"data-page-number":er,ref:rW(v,K),style:{"--scale-factor":`${tr}`,backgroundColor:A||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},Ar,{children:er?null===N||null==q?s(RZ,{type:"loading",children:"function"==typeof m?m():m}):!1===N||!1===q?s(RZ,{type:"error",children:"function"==typeof g?g():g}):f(eW.Provider,{value:ir,children:[or(),L?s(hW,{},`${nr}_text`):null,T?s(bW,{},`${nr}_annotations`):null,o]}):s(RZ,{type:"no-data",children:"function"==typeof w?w():w})}))}BZ(!MZ,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${DZ}`),x_.workerSrc="pdf.worker.mjs";const mW="SET_ZOOM_LEVEL",kW=r=>({type:mW,value:r}),wW="SET_PDF_PAGINATED",yW="SET_NUM_PAGES",EW=r=>({type:yW,value:r}),CW="SET_CURRENT_PAGE",BW=r=>({type:CW,value:r}),_W="SET_CONTAINER_WIDTH",ZW={defaultZoomLevel:1,zoomLevel:1,zoomJump:.1,paginated:!0,numPages:0,currentPage:1,containerWidth:0,disablePageTags:!1},WW=(r=ZW,e)=>{switch(e.type){case mW:{const{value:a}=e;return{...r,zoomLevel:a}}case wW:{const{value:a}=e;return{...r,paginated:a}}case yW:{const{value:a}=e;return{...r,numPages:a}}case CW:{const{value:a}=e;return{...r,currentPage:a}}case _W:{const{value:a}=e;return{...r,containerWidth:a}}default:return r}},IW=p({state:ZW,dispatch:()=>null}),RW=({children:r,mainState:e})=>{var a,t,i,A,n,o,f,l;const[u,c]=m(WW,{...ZW,defaultZoomLevel:(null==(t=null==(a=e.config)?void 0:a.pdfZoom)?void 0:t.defaultZoom)??ZW.defaultZoomLevel,zoomLevel:(null==(A=null==(i=e.config)?void 0:i.pdfZoom)?void 0:A.defaultZoom)??ZW.zoomLevel,zoomJump:(null==(o=null==(n=e.config)?void 0:n.pdfZoom)?void 0:o.zoomJump)??ZW.zoomJump,paginated:(null==(f=e.config)||!f.pdfVerticalScrollByDefault)&&ZW.paginated,disablePageTags:(null==(l=e.config)?void 0:l.disablePageTags)||!1,mainState:e});return s(IW.Provider,{value:{state:u,dispatch:c},children:r})},FW=({pageNum:r})=>{const{state:{paginated:e,zoomLevel:a,numPages:t,currentPage:i,disablePageTags:A,containerWidth:n}}=g(IW),{t:o}=rs(),l=r??i,u=n>0?n*a:void 0;return f(SW,{id:"pdf-page-wrapper",$lastPage:l>=t,children:[!e&&!A&&s(xW,{id:"pdf-page-info",children:o("pdfPluginPageNumber",{currentPage:l,allPagesCount:t})}),s(vW,{pageNumber:l||i,width:u,loading:null})]})},SW=io.div`
|
|
154
|
+
`;var Vs={d:(r,e)=>{for(var a in e)Vs.o(e,a)&&!Vs.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:e[a]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e)},Ns=globalThis.pdfjsLib={};Vs.d(Ns,{AbortException:()=>zf,AnnotationEditorLayer:()=>s_,AnnotationEditorParamsType:()=>$s,AnnotationEditorType:()=>qs,AnnotationEditorUIManager:()=>$d,AnnotationLayer:()=>Hk,AnnotationMode:()=>zs,CMapCompressionType:()=>Sf,ColorPicker:()=>Qy,DOMSVGFactory:()=>ou,DrawLayer:()=>k_,FeatureTest:()=>rl,GlobalWorkerOptions:()=>lg,ImageKind:()=>of,InvalidPDFException:()=>Hf,MissingPDFException:()=>Qf,OPS:()=>xf,Outliner:()=>ty,PDFDataRangeTransport:()=>hv,PDFDateString:()=>mu,PDFWorker:()=>xv,PasswordResponses:()=>Mf,PermissionFlag:()=>Ks,PixelsPerInch:()=>Il,RenderingCancelledException:()=>fu,TextLayer:()=>rv,UnexpectedResponseException:()=>Uf,Util:()=>nl,VerbosityLevel:()=>Ff,XfaLayer:()=>im,build:()=>rm,createValidAbsoluteUrl:()=>Pf,fetchData:()=>iu,getDocument:()=>fv,getFilenameFromUrl:()=>cu,getPdfFilenameFromUrl:()=>du,getXfaPageViewport:()=>ku,isDataScheme:()=>lu,isPdfFile:()=>uu,noContextMenu:()=>gu,normalizeUnicode:()=>fl,renderTextLayer:()=>ev,setLayerDimensions:()=>Cu,shadow:()=>jf,updateTextLayer:()=>av,version:()=>Kv});const Ds=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Ts=[1,0,0,1,0,0],Ps=[.001,0,0,.001,0,0],js=1.35,Ls=1,Os=2,Ys=4,Hs=16,Qs=32,Us=64,Js=256,zs={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},qs={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},$s={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},Ks={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},rf=0,ef=1,af=2,tf=3,Af=3,nf=4,of={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},sf=1,ff=2,lf=3,uf=4,cf=5,df=6,hf=7,bf=8,gf=9,pf=10,vf=11,mf=12,kf=13,wf=14,yf=15,Ef=16,Cf=17,Bf=20,_f=1,Zf=2,Wf=3,If=4,Rf=5,Ff={ERRORS:0,WARNINGS:1,INFOS:5},Sf={NONE:0,BINARY:1},xf={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},Mf={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Gf=Ff.WARNINGS;function Xf(){return Gf}function Vf(r){Gf>=Ff.INFOS&&console.log(`Info: ${r}`)}function Nf(r){Gf>=Ff.WARNINGS&&console.log(`Warning: ${r}`)}function Df(r){throw new Error(r)}function Tf(r,e){r||Df(e)}function Pf(r,e=null,a=null){if(!r)return null;try{if(a&&"string"==typeof r){if(a.addDefaultProtocol&&r.startsWith("www.")){const e=r.match(/\./g);(null==e?void 0:e.length)>=2&&(r=`http://${r}`)}if(a.tryConvertEncoding)try{r=function(r){return decodeURIComponent(escape(r))}(r)}catch{}}const t=e?new URL(r,e):new URL(r);if(function(r){switch(null==r?void 0:r.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(t))return t}catch{}return null}function jf(r,e,a,t=!1){return Object.defineProperty(r,e,{value:a,enumerable:!t,configurable:!0,writable:!1}),a}const Lf=function(){function r(e,a){this.constructor===r&&Df("Cannot initialize BaseException."),this.message=e,this.name=a}return r.prototype=new Error,r.constructor=r,r}();class Of extends Lf{constructor(r,e){super(r,"PasswordException"),this.code=e}}class Yf extends Lf{constructor(r,e){super(r,"UnknownErrorException"),this.details=e}}class Hf extends Lf{constructor(r){super(r,"InvalidPDFException")}}class Qf extends Lf{constructor(r){super(r,"MissingPDFException")}}class Uf extends Lf{constructor(r,e){super(r,"UnexpectedResponseException"),this.status=e}}class Jf extends Lf{constructor(r){super(r,"FormatError")}}class zf extends Lf{constructor(r){super(r,"AbortException")}}function qf(r){("object"!=typeof r||void 0===(null==r?void 0:r.length))&&Df("Invalid argument for bytesToString");const e=r.length,a=8192;if(e<a)return String.fromCharCode.apply(null,r);const t=[];for(let i=0;i<e;i+=a){const A=Math.min(i+a,e),n=r.subarray(i,A);t.push(String.fromCharCode.apply(null,n))}return t.join("")}function $f(r){"string"!=typeof r&&Df("Invalid argument for stringToBytes");const e=r.length,a=new Uint8Array(e);for(let t=0;t<e;++t)a[t]=255&r.charCodeAt(t);return a}function Kf(r){const e=Object.create(null);for(const[a,t]of r)e[a]=t;return e}class rl{static get isLittleEndian(){return jf(this,"isLittleEndian",function(){const r=new Uint8Array(4);return r[0]=1,1===new Uint32Array(r.buffer,0,1)[0]}())}static get isEvalSupported(){return jf(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return jf(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&"string"==typeof(null==navigator?void 0:navigator.platform)?jf(this,"platform",{isMac:navigator.platform.includes("Mac")}):jf(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){var r,e;return jf(this,"isCSSRoundSupported",null==(e=null==(r=globalThis.CSS)?void 0:r.supports)?void 0:e.call(r,"width: round(1.5px, 1px)"))}}const el=Array.from(Array(256).keys(),(r=>r.toString(16).padStart(2,"0")));var al,tl,il,Al;class nl{static makeHexColor(r,e,a){return`#${el[r]}${el[e]}${el[a]}`}static scaleMinMax(r,e){let a;r[0]?(r[0]<0&&(a=e[0],e[0]=e[2],e[2]=a),e[0]*=r[0],e[2]*=r[0],r[3]<0&&(a=e[1],e[1]=e[3],e[3]=a),e[1]*=r[3],e[3]*=r[3]):(a=e[0],e[0]=e[1],e[1]=a,a=e[2],e[2]=e[3],e[3]=a,r[1]<0&&(a=e[1],e[1]=e[3],e[3]=a),e[1]*=r[1],e[3]*=r[1],r[2]<0&&(a=e[0],e[0]=e[2],e[2]=a),e[0]*=r[2],e[2]*=r[2]),e[0]+=r[4],e[1]+=r[5],e[2]+=r[4],e[3]+=r[5]}static transform(r,e){return[r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],r[0]*e[4]+r[2]*e[5]+r[4],r[1]*e[4]+r[3]*e[5]+r[5]]}static applyTransform(r,e){return[r[0]*e[0]+r[1]*e[2]+e[4],r[0]*e[1]+r[1]*e[3]+e[5]]}static applyInverseTransform(r,e){const a=e[0]*e[3]-e[1]*e[2];return[(r[0]*e[3]-r[1]*e[2]+e[2]*e[5]-e[4]*e[3])/a,(-r[0]*e[1]+r[1]*e[0]+e[4]*e[1]-e[5]*e[0])/a]}static getAxialAlignedBoundingBox(r,e){const a=this.applyTransform(r,e),t=this.applyTransform(r.slice(2,4),e),i=this.applyTransform([r[0],r[3]],e),A=this.applyTransform([r[2],r[1]],e);return[Math.min(a[0],t[0],i[0],A[0]),Math.min(a[1],t[1],i[1],A[1]),Math.max(a[0],t[0],i[0],A[0]),Math.max(a[1],t[1],i[1],A[1])]}static inverseTransform(r){const e=r[0]*r[3]-r[1]*r[2];return[r[3]/e,-r[1]/e,-r[2]/e,r[0]/e,(r[2]*r[5]-r[4]*r[3])/e,(r[4]*r[1]-r[5]*r[0])/e]}static singularValueDecompose2dScale(r){const e=[r[0],r[2],r[1],r[3]],a=r[0]*e[0]+r[1]*e[2],t=r[0]*e[1]+r[1]*e[3],i=r[2]*e[0]+r[3]*e[2],A=r[2]*e[1]+r[3]*e[3],n=(a+A)/2,o=Math.sqrt((a+A)**2-4*(a*A-i*t))/2,s=n+o||1,f=n-o||1;return[Math.sqrt(s),Math.sqrt(f)]}static normalizeRect(r){const e=r.slice(0);return r[0]>r[2]&&(e[0]=r[2],e[2]=r[0]),r[1]>r[3]&&(e[1]=r[3],e[3]=r[1]),e}static intersect(r,e){const a=Math.max(Math.min(r[0],r[2]),Math.min(e[0],e[2])),t=Math.min(Math.max(r[0],r[2]),Math.max(e[0],e[2]));if(a>t)return null;const i=Math.max(Math.min(r[1],r[3]),Math.min(e[1],e[3])),A=Math.min(Math.max(r[1],r[3]),Math.max(e[1],e[3]));return i>A?null:[a,i,t,A]}static bezierBoundingBox(r,e,a,t,i,A,n,s,f){return f?(f[0]=Math.min(f[0],r,n),f[1]=Math.min(f[1],e,s),f[2]=Math.max(f[2],r,n),f[3]=Math.max(f[3],e,s)):f=[Math.min(r,n),Math.min(e,s),Math.max(r,n),Math.max(e,s)],o(this,il,Al).call(this,r,a,i,n,e,t,A,s,3*(3*(a-i)-r+n),6*(r-2*a+i),3*(a-r),f),o(this,il,Al).call(this,r,a,i,n,e,t,A,s,3*(3*(t-A)-e+s),6*(e-2*t+A),3*(t-e),f),f}}al=new WeakSet,tl=function(r,e,a,t,i,A,n,o,s,f){if(s<=0||s>=1)return;const l=1-s,u=s*s,c=u*s,d=l*(l*(l*r+3*s*e)+3*u*a)+c*t,h=l*(l*(l*i+3*s*A)+3*u*n)+c*o;f[0]=Math.min(f[0],d),f[1]=Math.min(f[1],h),f[2]=Math.max(f[2],d),f[3]=Math.max(f[3],h)},il=new WeakSet,Al=function(r,e,a,t,i,A,n,s,f,l,u,c){if(Math.abs(f)<1e-12)return void(Math.abs(l)>=1e-12&&o(this,al,tl).call(this,r,e,a,t,i,A,n,s,-u/l,c));const d=l**2-4*u*f;if(d<0)return;const h=Math.sqrt(d),b=2*f;o(this,al,tl).call(this,r,e,a,t,i,A,n,s,(-l+h)/b,c),o(this,al,tl).call(this,r,e,a,t,i,A,n,s,(-l-h)/b,c)},i(nl,al),i(nl,il);let ol=null,sl=null;function fl(r){return ol||(ol=/([\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,sl=new Map([["ſt","ſt"]])),r.replaceAll(ol,((r,e,a)=>e?e.normalize("NFKC"):sl.get(a)))}const ll="pdfjs_internal_id_",ul=0,cl=1,dl=2,hl=3,bl=4,gl=5,pl=6,vl=7,ml=8;class kl{constructor(){this.constructor===kl&&Df("Cannot initialize BaseFilterFactory.")}addFilter(r){return"none"}addHCMFilter(r,e){return"none"}addAlphaFilter(r){return"none"}addLuminosityFilter(r){return"none"}addHighlightHCMFilter(r,e,a,t,i){return"none"}destroy(r=!1){}}var wl;const yl=class{constructor({enableHWA:r=!1}={}){i(this,wl,!1),this.constructor===yl&&Df("Cannot initialize BaseCanvasFactory."),A(this,wl,r)}create(r,e){if(r<=0||e<=0)throw new Error("Invalid canvas size");const a=this._createCanvas(r,e);return{canvas:a,context:a.getContext("2d",{willReadFrequently:!t(this,wl)})}}reset(r,e,a){if(!r.canvas)throw new Error("Canvas is not specified");if(e<=0||a<=0)throw new Error("Invalid canvas size");r.canvas.width=e,r.canvas.height=a}destroy(r){if(!r.canvas)throw new Error("Canvas is not specified");r.canvas.width=0,r.canvas.height=0,r.canvas=null,r.context=null}_createCanvas(r,e){Df("Abstract method `_createCanvas` called.")}};let El=yl;wl=new WeakMap;class Cl{constructor({baseUrl:r=null,isCompressed:e=!0}){this.constructor===Cl&&Df("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=r,this.isCompressed=e}async fetch({name:r}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!r)throw new Error("CMap name must be specified.");const e=this.baseUrl+r+(this.isCompressed?".bcmap":""),a=this.isCompressed?Sf.BINARY:Sf.NONE;return this._fetchData(e,a).catch((r=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}_fetchData(r,e){Df("Abstract method `_fetchData` called.")}}class Bl{constructor({baseUrl:r=null}){this.constructor===Bl&&Df("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=r}async fetch({filename:r}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!r)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${r}`;return this._fetchData(e).catch((r=>{throw new Error(`Unable to load font data at: ${e}`)}))}_fetchData(r){Df("Abstract method `_fetchData` called.")}}class _l{constructor(){this.constructor===_l&&Df("Cannot initialize BaseSVGFactory.")}create(r,e,a=!1){if(r<=0||e<=0)throw new Error("Invalid SVG dimensions");const t=this._createSVG("svg:svg");return t.setAttribute("version","1.1"),a||(t.setAttribute("width",`${r}px`),t.setAttribute("height",`${e}px`)),t.setAttribute("preserveAspectRatio","none"),t.setAttribute("viewBox",`0 0 ${r} ${e}`),t}createElement(r){if("string"!=typeof r)throw new Error("Invalid SVG element type");return this._createSVG(r)}_createSVG(r){Df("Abstract method `_createSVG` called.")}}const Zl="http://www.w3.org/2000/svg",Wl=class{};let Il=Wl;var Rl,Fl,Sl,xl,Ml,Gl,Xl,Vl,Nl,Dl,Tl,Pl,jl,Ll,Ol,Yl,Hl,Ql,Ul,Jl,zl,ql,$l,Kl,ru,eu,au,tu;e(Il,"CSS",96),e(Il,"PDF",72),e(Il,"PDF_TO_CSS_UNITS",Wl.CSS/Wl.PDF);Rl=new WeakMap,Fl=new WeakMap,Sl=new WeakMap,xl=new WeakMap,Ml=new WeakMap,Gl=new WeakMap,Xl=new WeakSet,Vl=function(){return t(this,Rl)||A(this,Rl,new Map)},Nl=new WeakSet,Dl=function(){return t(this,Ml)||A(this,Ml,new Map)},Tl=new WeakSet,Pl=function(){if(!t(this,Fl)){const r=t(this,xl).createElement("div"),{style:e}=r;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const a=t(this,xl).createElementNS(Zl,"svg");a.setAttribute("width",0),a.setAttribute("height",0),A(this,Fl,t(this,xl).createElementNS(Zl,"defs")),r.append(a),a.append(t(this,Fl)),t(this,xl).body.append(r)}return t(this,Fl)},jl=new WeakSet,Ll=function(r){if(1===r.length){const e=r[0],a=new Array(256);for(let r=0;r<256;r++)a[r]=e[r]/255;const t=a.join(",");return[t,t,t]}const[e,a,t]=r,i=new Array(256),A=new Array(256),n=new Array(256);for(let r=0;r<256;r++)i[r]=e[r]/255,A[r]=a[r]/255,n[r]=t[r]/255;return[i.join(","),A.join(","),n.join(",")]},Ol=new WeakSet,Yl=function(r){const e=t(this,xl).createElementNS(Zl,"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"),r.append(e)},Hl=new WeakSet,Ql=function(r){const e=t(this,xl).createElementNS(Zl,"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"),r.append(e)},Ul=new WeakSet,Jl=function(r){const e=t(this,xl).createElementNS(Zl,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",r),t(this,Tl,Pl).append(e),e},zl=new WeakSet,ql=function(r,e,a){const i=t(this,xl).createElementNS(Zl,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",a),r.append(i)},$l=new WeakSet,Kl=function(r,e,a,i){const A=t(this,xl).createElementNS(Zl,"feComponentTransfer");i.append(A),o(this,zl,ql).call(this,A,"feFuncR",r),o(this,zl,ql).call(this,A,"feFuncG",e),o(this,zl,ql).call(this,A,"feFuncB",a)},ru=new WeakSet,eu=function(r,e){const a=t(this,xl).createElementNS(Zl,"feComponentTransfer");e.append(a),o(this,zl,ql).call(this,a,"feFuncA",r)},au=new WeakSet,tu=function(r){return t(this,Tl,Pl).style.color=r,wu(getComputedStyle(t(this,Tl,Pl)).getPropertyValue("color"))};async function iu(r,e="text"){if(bu(r,document.baseURI)){const a=await fetch(r);if(!a.ok)throw new Error(a.statusText);switch(e){case"arraybuffer":return a.arrayBuffer();case"blob":return a.blob();case"json":return a.json()}return a.text()}return new Promise(((a,t)=>{const i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(200===i.status||0===i.status){switch(e){case"arraybuffer":case"blob":case"json":return void a(i.response)}return void a(i.responseText)}t(new Error(i.statusText))}},i.send(null)}))}class Au extends Cl{_fetchData(r,e){return iu(r,this.isCompressed?"arraybuffer":"text").then((r=>({cMapData:r instanceof ArrayBuffer?new Uint8Array(r):$f(r),compressionType:e})))}}class nu extends Bl{_fetchData(r){return iu(r,"arraybuffer").then((r=>new Uint8Array(r)))}}class ou extends _l{_createSVG(r){return document.createElementNS(Zl,r)}}class su{constructor({viewBox:r,scale:e,rotation:a,offsetX:t=0,offsetY:i=0,dontFlip:A=!1}){this.viewBox=r,this.scale=e,this.rotation=a,this.offsetX=t,this.offsetY=i;const n=(r[2]+r[0])/2,o=(r[3]+r[1])/2;let s,f,l,u,c,d,h,b;switch((a%=360)<0&&(a+=360),a){case 180:s=-1,f=0,l=0,u=1;break;case 90:s=0,f=1,l=1,u=0;break;case 270:s=0,f=-1,l=-1,u=0;break;case 0:s=1,f=0,l=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}A&&(l=-l,u=-u),0===s?(c=Math.abs(o-r[1])*e+t,d=Math.abs(n-r[0])*e+i,h=(r[3]-r[1])*e,b=(r[2]-r[0])*e):(c=Math.abs(n-r[0])*e+t,d=Math.abs(o-r[1])*e+i,h=(r[2]-r[0])*e,b=(r[3]-r[1])*e),this.transform=[s*e,f*e,l*e,u*e,c-s*e*n-l*e*o,d-f*e*n-u*e*o],this.width=h,this.height=b}get rawDims(){const{viewBox:r}=this;return jf(this,"rawDims",{pageWidth:r[2]-r[0],pageHeight:r[3]-r[1],pageX:r[0],pageY:r[1]})}clone({scale:r=this.scale,rotation:e=this.rotation,offsetX:a=this.offsetX,offsetY:t=this.offsetY,dontFlip:i=!1}={}){return new su({viewBox:this.viewBox.slice(),scale:r,rotation:e,offsetX:a,offsetY:t,dontFlip:i})}convertToViewportPoint(r,e){return nl.applyTransform([r,e],this.transform)}convertToViewportRectangle(r){const e=nl.applyTransform([r[0],r[1]],this.transform),a=nl.applyTransform([r[2],r[3]],this.transform);return[e[0],e[1],a[0],a[1]]}convertToPdfPoint(r,e){return nl.applyInverseTransform([r,e],this.transform)}}class fu extends Lf{constructor(r,e=0){super(r,"RenderingCancelledException"),this.extraDelay=e}}function lu(r){const e=r.length;let a=0;for(;a<e&&""===r[a].trim();)a++;return"data:"===r.substring(a,a+5).toLowerCase()}function uu(r){return"string"==typeof r&&/\.pdf$/i.test(r)}function cu(r){return[r]=r.split(/[#?]/,1),r.substring(r.lastIndexOf("/")+1)}function du(r,e="document.pdf"){if("string"!=typeof r)return e;if(lu(r))return Nf('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const a=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,t=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(r);let i=a.exec(t[1])||a.exec(t[2])||a.exec(t[3]);if(i&&(i=i[0],i.includes("%")))try{i=a.exec(decodeURIComponent(i))[0]}catch{}return i||e}class hu{constructor(){e(this,"started",Object.create(null)),e(this,"times",[])}time(r){r in this.started&&Nf(`Timer is already running for ${r}`),this.started[r]=Date.now()}timeEnd(r){r in this.started||Nf(`Timer has not been started for ${r}`),this.times.push({name:r,start:this.started[r],end:Date.now()}),delete this.started[r]}toString(){const r=[];let e=0;for(const{name:r}of this.times)e=Math.max(r.length,e);for(const{name:a,start:t,end:i}of this.times)r.push(`${a.padEnd(e)} ${i-t}ms\n`);return r.join("")}}function bu(r,e){try{const{protocol:a}=e?new URL(r,e):new URL(r);return"http:"===a||"https:"===a}catch{return!1}}function gu(r){r.preventDefault()}function pu(r){console.log("Deprecated API usage: "+r)}let vu;class mu{static toDateObject(r){if(!r||"string"!=typeof r)return null;vu||(vu=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=vu.exec(r);if(!e)return null;const a=parseInt(e[1],10);let t=parseInt(e[2],10);t=t>=1&&t<=12?t-1:0;let i=parseInt(e[3],10);i=i>=1&&i<=31?i:1;let A=parseInt(e[4],10);A=A>=0&&A<=23?A:0;let n=parseInt(e[5],10);n=n>=0&&n<=59?n:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const s=e[7]||"Z";let f=parseInt(e[8],10);f=f>=0&&f<=23?f:0;let l=parseInt(e[9],10)||0;return l=l>=0&&l<=59?l:0,"-"===s?(A+=f,n+=l):"+"===s&&(A-=f,n-=l),new Date(Date.UTC(a,t,i,A,n,o))}}function ku(r,{scale:e=1,rotation:a=0}){const{width:t,height:i}=r.attributes.style,A=[0,0,parseInt(t),parseInt(i)];return new su({viewBox:A,scale:e,rotation:a})}function wu(r){if(r.startsWith("#")){const e=parseInt(r.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return r.startsWith("rgb(")?r.slice(4,-1).split(",").map((r=>parseInt(r))):r.startsWith("rgba(")?r.slice(5,-1).split(",").map((r=>parseInt(r))).slice(0,3):(Nf(`Not a valid color format: "${r}"`),[0,0,0])}function yu(r){const{a:e,b:a,c:t,d:i,e:A,f:n}=r.getTransform();return[e,a,t,i,A,n]}function Eu(r){const{a:e,b:a,c:t,d:i,e:A,f:n}=r.getTransform().invertSelf();return[e,a,t,i,A,n]}function Cu(r,e,a=!1,t=!0){if(e instanceof su){const{pageWidth:t,pageHeight:i}=e.rawDims,{style:A}=r,n=rl.isCSSRoundSupported,o=`var(--scale-factor) * ${t}px`,s=`var(--scale-factor) * ${i}px`,f=n?`round(${o}, 1px)`:`calc(${o})`,l=n?`round(${s}, 1px)`:`calc(${s})`;a&&e.rotation%180!=0?(A.width=l,A.height=f):(A.width=f,A.height=l)}t&&r.setAttribute("data-main-rotation",e.rotation)}var Bu,_u,Zu,Wu,Iu,Ru,Fu,Su,xu,Mu,Gu,Xu,Vu,Nu,Du,Tu;const Pu=class{constructor(r){i(this,Fu),i(this,xu),i(this,Gu),i(this,Vu),i(this,Du),i(this,Bu,null),i(this,_u,null),i(this,Zu,void 0),i(this,Wu,null),A(this,Zu,r)}render(){const r=A(this,Bu,document.createElement("div"));r.className="editToolbar",r.setAttribute("role","toolbar");const e=t(this,Zu)._uiManager._signal;r.addEventListener("contextmenu",gu,{signal:e}),r.addEventListener("pointerdown",o(Pu,Iu,Ru),{signal:e});const a=A(this,Wu,document.createElement("div"));a.className="buttons",r.append(a);const i=t(this,Zu).toolbarPosition;if(i){const{style:e}=r,a="ltr"===t(this,Zu)._uiManager.direction?1-i[0]:i[0];e.insetInlineEnd=100*a+"%",e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return o(this,Vu,Nu).call(this),r}hide(){var r;t(this,Bu).classList.add("hidden"),null==(r=t(this,_u))||r.hideDropdown()}show(){t(this,Bu).classList.remove("hidden")}addAltTextButton(r){o(this,Gu,Xu).call(this,r),t(this,Wu).prepend(r,t(this,Du,Tu))}addColorPicker(r){A(this,_u,r);const e=r.renderButton();o(this,Gu,Xu).call(this,e),t(this,Wu).prepend(e,t(this,Du,Tu))}remove(){var r;t(this,Bu).remove(),null==(r=t(this,_u))||r.destroy(),A(this,_u,null)}};let ju=Pu;var Lu,Ou,Yu,Hu,Qu,Uu,Ju,zu,qu,$u,Ku,rc,ec,ac,tc;Bu=new WeakMap,_u=new WeakMap,Zu=new WeakMap,Wu=new WeakMap,Iu=new WeakSet,Ru=function(r){r.stopPropagation()},Fu=new WeakSet,Su=function(r){t(this,Zu)._focusEventsAllowed=!1,r.preventDefault(),r.stopPropagation()},xu=new WeakSet,Mu=function(r){t(this,Zu)._focusEventsAllowed=!0,r.preventDefault(),r.stopPropagation()},Gu=new WeakSet,Xu=function(r){const e=t(this,Zu)._uiManager._signal;r.addEventListener("focusin",o(this,Fu,Su).bind(this),{capture:!0,signal:e}),r.addEventListener("focusout",o(this,xu,Mu).bind(this),{capture:!0,signal:e}),r.addEventListener("contextmenu",gu,{signal:e})},Vu=new WeakSet,Nu=function(){const r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",`pdfjs-editor-remove-${t(this,Zu).editorType}-button`),o(this,Gu,Xu).call(this,r),r.addEventListener("click",(r=>{t(this,Zu)._uiManager.delete()}),{signal:t(this,Zu)._uiManager._signal}),t(this,Wu).append(r)},Du=new WeakSet,Tu=function(){const r=document.createElement("div");return r.className="divider",r},i(ju,Iu);class ic{constructor(r){i(this,Hu),i(this,Uu),i(this,zu),i(this,Lu,null),i(this,Ou,null),i(this,Yu,void 0),A(this,Yu,r)}show(r,e,a){const[i,n]=o(this,Uu,Ju).call(this,e,a),{style:s}=t(this,Ou)||A(this,Ou,o(this,Hu,Qu).call(this));r.append(t(this,Ou)),s.insetInlineEnd=100*i+"%",s.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){t(this,Ou).remove()}}function Ac(r,e,a){for(const t of a)e.addEventListener(t,r[t].bind(r))}Lu=new WeakMap,Ou=new WeakMap,Yu=new WeakMap,Hu=new WeakSet,Qu=function(){const r=A(this,Ou,document.createElement("div"));r.className="editToolbar",r.setAttribute("role","toolbar"),r.addEventListener("contextmenu",gu,{signal:t(this,Yu)._signal});const e=A(this,Lu,document.createElement("div"));return e.className="buttons",r.append(e),o(this,zu,qu).call(this),r},Uu=new WeakSet,Ju=function(r,e){let a=0,t=0;for(const i of r){const r=i.y+i.height;if(r<a)continue;const A=i.x+(e?i.width:0);r>a?(t=A,a=r):e?A>t&&(t=A):A<t&&(t=A)}return[e?1-t:t,a]},zu=new WeakSet,qu=function(){const r=document.createElement("button");r.className="highlightButton",r.tabIndex=0,r.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");r.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const a=t(this,Yu)._signal;r.addEventListener("contextmenu",gu,{signal:a}),r.addEventListener("click",(()=>{t(this,Yu).highlightSelection("floating_button")}),{signal:a}),t(this,Lu).append(r)};class nc{constructor(){i(this,$u,0)}get id(){return"pdfjs_internal_editor_"+n(this,$u)._++}}$u=new WeakMap;const oc=class{constructor(){i(this,ac),i(this,Ku,function(){if(typeof crypto<"u"&&"function"==typeof(null==crypto?void 0:crypto.randomUUID))return crypto.randomUUID();const r=new Uint8Array(32);if(typeof crypto<"u"&&"function"==typeof(null==crypto?void 0:crypto.getRandomValues))crypto.getRandomValues(r);else for(let e=0;e<32;e++)r[e]=Math.floor(255*Math.random());return qf(r)}()),i(this,rc,0),i(this,ec,null)}static get _isSVGFittingCanvas(){const r=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 jf(this,"_isSVGFittingCanvas",e.decode().then((()=>(r.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(r.getImageData(0,0,1,1).data.buffer)[0]))))}async getFromFile(r){const{lastModified:e,name:a,size:t,type:i}=r;return o(this,ac,tc).call(this,`${e}_${a}_${t}_${i}`,r)}async getFromUrl(r){return o(this,ac,tc).call(this,r,r)}async getFromId(r){t(this,ec)||A(this,ec,new Map);const e=t(this,ec).get(r);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(r){const e=t(this,ec).get(r);return null!=e&&e.isSvg?e.svgUrl:null}deleteId(r){t(this,ec)||A(this,ec,new Map);const e=t(this,ec).get(r);e&&(e.refCounter-=1,0===e.refCounter&&(e.bitmap=null))}isValidId(r){return r.startsWith(`image_${t(this,Ku)}_`)}};let sc=oc;var fc,lc,uc,cc,dc,hc;Ku=new WeakMap,rc=new WeakMap,ec=new WeakMap,ac=new WeakSet,tc=async function(r,e){t(this,ec)||A(this,ec,new Map);let a=t(this,ec).get(r);if(null===a)return null;if(null!=a&&a.bitmap)return a.refCounter+=1,a;try{let r;if(a||(a={bitmap:null,id:`image_${t(this,Ku)}_${n(this,rc)._++}`,refCounter:0,isSvg:!1}),"string"==typeof e?(a.url=e,r=await iu(e,"blob")):r=a.file=e,"image/svg+xml"===r.type){const e=oc._isSVGFittingCanvas,t=new FileReader,i=new Image,A=new Promise(((r,A)=>{i.onload=()=>{a.bitmap=i,a.isSvg=!0,r()},t.onload=async()=>{const r=a.svgUrl=t.result;i.src=await e?`${r}#svgView(preserveAspectRatio(none))`:r},i.onerror=t.onerror=A}));t.readAsDataURL(r),await A}else a.bitmap=await createImageBitmap(r);a.refCounter=1}catch(r){console.error(r),a=null}return t(this,ec).set(r,a),a&&t(this,ec).set(a.id,a),a};class bc{constructor(r=128){i(this,fc,[]),i(this,lc,!1),i(this,uc,void 0),i(this,cc,-1),A(this,uc,r)}add({cmd:r,undo:e,post:a,mustExec:i,type:n=NaN,overwriteIfSameType:o=!1,keepUndo:s=!1}){if(i&&r(),t(this,lc))return;const f={cmd:r,undo:e,post:a,type:n};if(-1===t(this,cc))return t(this,fc).length>0&&(t(this,fc).length=0),A(this,cc,0),void t(this,fc).push(f);if(o&&t(this,fc)[t(this,cc)].type===n)return s&&(f.undo=t(this,fc)[t(this,cc)].undo),void(t(this,fc)[t(this,cc)]=f);const l=t(this,cc)+1;l===t(this,uc)?t(this,fc).splice(0,1):(A(this,cc,l),l<t(this,fc).length&&t(this,fc).splice(l)),t(this,fc).push(f)}undo(){if(-1===t(this,cc))return;A(this,lc,!0);const{undo:r,post:e}=t(this,fc)[t(this,cc)];r(),null==e||e(),A(this,lc,!1),A(this,cc,t(this,cc)-1)}redo(){if(t(this,cc)<t(this,fc).length-1){A(this,cc,t(this,cc)+1),A(this,lc,!0);const{cmd:r,post:e}=t(this,fc)[t(this,cc)];r(),null==e||e(),A(this,lc,!1)}}hasSomethingToUndo(){return-1!==t(this,cc)}hasSomethingToRedo(){return t(this,cc)<t(this,fc).length-1}destroy(){A(this,fc,null)}}fc=new WeakMap,lc=new WeakMap,uc=new WeakMap,cc=new WeakMap;class gc{constructor(r){i(this,dc),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=rl.platform;for(const[a,t,i={}]of r)for(const r of a){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:t,options:i}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:t,options:i}),this.allKeys.add(r.split("+").at(-1)))}}exec(r,e){if(!this.allKeys.has(e.key))return;const a=this.callbacks.get(o(this,dc,hc).call(this,e));if(!a)return;const{callback:t,options:{bubbles:i=!1,args:A=[],checker:n=null}}=a;n&&!n(r,e)||(t.bind(r,...A,e)(),i||(e.stopPropagation(),e.preventDefault()))}}dc=new WeakSet,hc=function(r){r.altKey&&this.buffer.push("alt"),r.ctrlKey&&this.buffer.push("ctrl"),r.metaKey&&this.buffer.push("meta"),r.shiftKey&&this.buffer.push("shift"),this.buffer.push(r.key);const e=this.buffer.join("+");return this.buffer.length=0,e};const pc=class{get _colors(){const r=new Map([["CanvasText",null],["Canvas",null]]);return function(r){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const a of r.keys()){e.style.color=a;const t=window.getComputedStyle(e).color;r.set(a,wu(t))}e.remove()}(r),jf(this,"_colors",r)}convert(r){const e=wu(r);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[r,a]of this._colors)if(a.every(((r,a)=>r===e[a])))return pc._colorsMapping.get(r);return e}getHexCode(r){const e=this._colors.get(r);return e?nl.makeHexColor(...e):r}};let vc=pc;var mc,kc,wc,yc,Ec,Cc,Bc,_c,Zc,Wc,Ic,Rc,Fc,Sc,xc,Mc,Gc,Xc,Vc,Nc,Dc,Tc,Pc,jc,Lc,Oc,Yc,Hc,Qc,Uc,Jc,zc,qc,$c,Kc,rd,ed,ad,td,id,Ad,nd,od,sd,fd,ld,ud,cd,dd,hd,bd,gd,pd,vd,md,kd,wd,yd,Ed,Cd,Bd,_d,Zd,Wd,Id,Rd,Fd,Sd,xd,Md,Gd,Xd,Vd,Nd,Dd,Td,Pd,jd,Ld,Od,Yd,Hd,Qd,Ud,Jd,zd;e(vc,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));const qd=class{constructor(r,e,a,n,s,f,l,u,c){i(this,ud),i(this,dd),i(this,bd),i(this,pd),i(this,md),i(this,wd),i(this,Ed),i(this,Bd),i(this,Zd),i(this,Id),i(this,Fd),i(this,xd),i(this,Gd),i(this,Vd),i(this,Dd),i(this,Pd),i(this,Ld),i(this,Yd),i(this,Qd),i(this,Jd),i(this,mc,new AbortController),i(this,kc,null),i(this,wc,new Map),i(this,yc,new Map),i(this,Ec,null),i(this,Cc,null),i(this,Bc,null),i(this,_c,new bc),i(this,Zc,0),i(this,Wc,new Set),i(this,Ic,null),i(this,Rc,null),i(this,Fc,new Set),i(this,Sc,!1),i(this,xc,null),i(this,Mc,null),i(this,Gc,null),i(this,Xc,!1),i(this,Vc,null),i(this,Nc,new nc),i(this,Dc,!1),i(this,Tc,!1),i(this,Pc,null),i(this,jc,null),i(this,Lc,null),i(this,Oc,qs.NONE),i(this,Yc,new Set),i(this,Hc,null),i(this,Qc,null),i(this,Uc,null),i(this,Jc,this.blur.bind(this)),i(this,zc,this.focus.bind(this)),i(this,qc,this.copy.bind(this)),i(this,$c,this.cut.bind(this)),i(this,Kc,this.paste.bind(this)),i(this,rd,this.keydown.bind(this)),i(this,ed,this.keyup.bind(this)),i(this,ad,this.onEditingAction.bind(this)),i(this,td,this.onPageChanging.bind(this)),i(this,id,this.onScaleChanging.bind(this)),i(this,Ad,this.onRotationChanging.bind(this)),i(this,nd,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),i(this,od,[0,0]),i(this,sd,null),i(this,fd,null),i(this,ld,null),this._signal=t(this,mc).signal,A(this,fd,r),A(this,ld,e),A(this,Ec,a),this._eventBus=n,this._eventBus._on("editingaction",t(this,ad)),this._eventBus._on("pagechanging",t(this,td)),this._eventBus._on("scalechanging",t(this,id)),this._eventBus._on("rotationchanging",t(this,Ad)),o(this,md,kd).call(this),o(this,xd,Md).call(this),o(this,Bd,_d).call(this),A(this,Cc,s.annotationStorage),A(this,xc,s.filterFactory),A(this,Qc,f),A(this,Gc,l||null),A(this,Sc,u),A(this,Lc,c||null),this.viewParameters={realScale:Il.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const r=qd.prototype,e=r=>t(r,fd).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&r.hasSomethingToControl(),a=(r,{target:e})=>{if(e instanceof HTMLInputElement){const{type:r}=e;return"text"!==r&&"number"!==r}return!0},i=this.TRANSLATE_SMALL,A=this.TRANSLATE_BIG;return jf(this,"_keyboardManager",new gc([[["ctrl+a","mac+meta+a"],r.selectAll,{checker:a}],[["ctrl+z","mac+meta+z"],r.undo,{checker:a}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],r.redo,{checker:a}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],r.delete,{checker:a}],[["Enter","mac+Enter"],r.addNewEditorFromKeyboard,{checker:(r,{target:e})=>!(e instanceof HTMLButtonElement)&&t(r,fd).contains(e)&&!r.isEnterHandled}],[[" ","mac+ "],r.addNewEditorFromKeyboard,{checker:(r,{target:e})=>!(e instanceof HTMLButtonElement)&&t(r,fd).contains(document.activeElement)}],[["Escape","mac+Escape"],r.unselectAll],[["ArrowLeft","mac+ArrowLeft"],r.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r.translateSelectedEditors,{args:[-A,0],checker:e}],[["ArrowRight","mac+ArrowRight"],r.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r.translateSelectedEditors,{args:[A,0],checker:e}],[["ArrowUp","mac+ArrowUp"],r.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r.translateSelectedEditors,{args:[0,-A],checker:e}],[["ArrowDown","mac+ArrowDown"],r.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r.translateSelectedEditors,{args:[0,A],checker:e}]]))}destroy(){var r,e,a;null==(r=t(this,mc))||r.abort(),A(this,mc,null),this._signal=null,this._eventBus._off("editingaction",t(this,ad)),this._eventBus._off("pagechanging",t(this,td)),this._eventBus._off("scalechanging",t(this,id)),this._eventBus._off("rotationchanging",t(this,Ad));for(const r of t(this,yc).values())r.destroy();t(this,yc).clear(),t(this,wc).clear(),t(this,Fc).clear(),A(this,kc,null),t(this,Yc).clear(),t(this,_c).destroy(),null==(e=t(this,Ec))||e.destroy(),null==(a=t(this,Vc))||a.hide(),A(this,Vc,null),t(this,Mc)&&(clearTimeout(t(this,Mc)),A(this,Mc,null)),t(this,sd)&&(clearTimeout(t(this,sd)),A(this,sd,null))}async mlGuess(r){var e;return(null==(e=t(this,Lc))?void 0:e.guess(r))||null}get hasMLManager(){return!!t(this,Lc)}get hcmFilter(){return jf(this,"hcmFilter",t(this,Qc)?t(this,xc).addHCMFilter(t(this,Qc).foreground,t(this,Qc).background):"none")}get direction(){return jf(this,"direction",getComputedStyle(t(this,fd)).direction)}get highlightColors(){return jf(this,"highlightColors",t(this,Gc)?new Map(t(this,Gc).split(",").map((r=>r.split("=").map((r=>r.trim()))))):null)}get highlightColorNames(){return jf(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(r=>r.reverse()))):null)}setMainHighlightColorPicker(r){A(this,jc,r)}editAltText(r){var e;null==(e=t(this,Ec))||e.editAltText(this,r)}onPageChanging({pageNumber:r}){A(this,Zc,r-1)}focusMainContainer(){t(this,fd).focus()}findParent(r,e){for(const a of t(this,yc).values()){const{x:t,y:i,width:A,height:n}=a.div.getBoundingClientRect();if(r>=t&&r<=t+A&&e>=i&&e<=i+n)return a}return null}disableUserSelect(r=!1){t(this,ld).classList.toggle("noUserSelect",r)}addShouldRescale(r){t(this,Fc).add(r)}removeShouldRescale(r){t(this,Fc).delete(r)}onScaleChanging({scale:r}){this.commitOrRemove(),this.viewParameters.realScale=r*Il.PDF_TO_CSS_UNITS;for(const r of t(this,Fc))r.onScaleChanging()}onRotationChanging({pagesRotation:r}){this.commitOrRemove(),this.viewParameters.rotation=r}highlightSelection(r=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:a,anchorOffset:i,focusNode:A,focusOffset:n}=e,s=e.toString(),f=o(this,ud,cd).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(f);if(l){e.empty(),t(this,Oc)===qs.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:qs.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const e of t(this,yc).values())if(e.hasTextLayer(f)){e.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:r,boxes:l,anchorNode:a,anchorOffset:i,focusNode:A,focusOffset:n,text:s});break}}}addToAnnotationStorage(r){!r.isEmpty()&&t(this,Cc)&&!t(this,Cc).has(r.id)&&t(this,Cc).setValue(r.id,r)}blur(){if(this.isShiftKeyDown=!1,t(this,Xc)&&(A(this,Xc,!1),o(this,pd,vd).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:r}=document;for(const e of t(this,Yc))if(e.div.contains(r)){A(this,Pc,[e,r]),e._focusEventsAllowed=!1;break}}focus(){if(!t(this,Pc))return;const[r,e]=t(this,Pc);A(this,Pc,null),e.addEventListener("focusin",(()=>{r._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}addEditListeners(){o(this,Bd,_d).call(this),o(this,Id,Rd).call(this)}removeEditListeners(){o(this,Zd,Wd).call(this),o(this,Fd,Sd).call(this)}dragOver(r){for(const{type:e}of r.dataTransfer.items)for(const a of t(this,Rc))if(a.isHandlingMimeForPasting(e))return r.dataTransfer.dropEffect="copy",void r.preventDefault()}drop(r){for(const e of r.dataTransfer.items)for(const a of t(this,Rc))if(a.isHandlingMimeForPasting(e.type))return a.paste(e,this.currentLayer),void r.preventDefault()}copy(r){var e;if(r.preventDefault(),null==(e=t(this,kc))||e.commitOrRemove(),!this.hasSelection)return;const a=[];for(const r of t(this,Yc)){const e=r.serialize(!0);e&&a.push(e)}0!==a.length&&r.clipboardData.setData("application/pdfjs",JSON.stringify(a))}cut(r){this.copy(r),this.delete()}paste(r){r.preventDefault();const{clipboardData:e}=r;for(const r of e.items)for(const e of t(this,Rc))if(e.isHandlingMimeForPasting(r.type))return void e.paste(r,this.currentLayer);let a=e.getData("application/pdfjs");if(!a)return;try{a=JSON.parse(a)}catch(r){return void Nf(`paste: "${r.message}".`)}if(!Array.isArray(a))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const e of a){const a=i.deserialize(e);if(!a)return;r.push(a)}const e=()=>{for(const e of r)o(this,Ld,Od).call(this,e);o(this,Jd,zd).call(this,r)},t=()=>{for(const e of r)e.remove()};this.addCommands({cmd:e,undo:t,mustExec:!0})}catch(r){Nf(`paste: "${r.message}".`)}}keydown(r){!this.isShiftKeyDown&&"Shift"===r.key&&(this.isShiftKeyDown=!0),t(this,Oc)!==qs.NONE&&!this.isEditorHandlingKeyboard&&qd._keyboardManager.exec(this,r)}keyup(r){this.isShiftKeyDown&&"Shift"===r.key&&(this.isShiftKeyDown=!1,t(this,Xc)&&(A(this,Xc,!1),o(this,pd,vd).call(this,"main_toolbar")))}onEditingAction({name:r}){switch(r){case"undo":case"redo":case"delete":case"selectAll":this[r]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(r){r?(o(this,wd,yd).call(this),o(this,Id,Rd).call(this),o(this,Gd,Xd).call(this,{isEditing:t(this,Oc)!==qs.NONE,isEmpty:o(this,Qd,Ud).call(this),hasSomethingToUndo:t(this,_c).hasSomethingToUndo(),hasSomethingToRedo:t(this,_c).hasSomethingToRedo(),hasSelectedEditor:!1})):(o(this,Ed,Cd).call(this),o(this,Fd,Sd).call(this),o(this,Gd,Xd).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(r){if(!t(this,Rc)){A(this,Rc,r);for(const r of t(this,Rc))o(this,Vd,Nd).call(this,r.defaultPropertiesToUpdate)}}getId(){return t(this,Nc).id}get currentLayer(){return t(this,yc).get(t(this,Zc))}getLayer(r){return t(this,yc).get(r)}get currentPageIndex(){return t(this,Zc)}addLayer(r){t(this,yc).set(r.pageIndex,r),t(this,Dc)?r.enable():r.disable()}removeLayer(r){t(this,yc).delete(r.pageIndex)}updateMode(r,e=null,a=!1){if(t(this,Oc)!==r){if(A(this,Oc,r),r===qs.NONE)return this.setEditingState(!1),void o(this,Pd,jd).call(this);this.setEditingState(!0),o(this,Dd,Td).call(this),this.unselectAll();for(const e of t(this,yc).values())e.updateMode(r);if(!e&&a)return void this.addNewEditorFromKeyboard();if(e)for(const r of t(this,wc).values())if(r.annotationElementId===e){this.setSelected(r),r.enterInEditMode();break}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(r){r!==t(this,Oc)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:r})}updateParams(r,e){var a;if(t(this,Rc)){switch(r){case $s.CREATE:return void this.currentLayer.addNewEditor();case $s.HIGHLIGHT_DEFAULT_COLOR:null==(a=t(this,jc))||a.updateColor(e);break;case $s.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(t(this,Uc)||A(this,Uc,new Map)).set(r,e),this.showAllEditors("highlight",e)}for(const a of t(this,Yc))a.updateParams(r,e);for(const a of t(this,Rc))a.updateDefaultParams(r,e)}}showAllEditors(r,e,a=!1){var i;for(const a of t(this,wc).values())a.editorType===r&&a.show(e);((null==(i=t(this,Uc))?void 0:i.get($s.HIGHLIGHT_SHOW_ALL))??!0)!==e&&o(this,Vd,Nd).call(this,[[$s.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(r=!1){if(t(this,Tc)!==r){A(this,Tc,r);for(const e of t(this,yc).values())r?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",r)}}getEditors(r){const e=[];for(const a of t(this,wc).values())a.pageIndex===r&&e.push(a);return e}getEditor(r){return t(this,wc).get(r)}addEditor(r){t(this,wc).set(r.id,r)}removeEditor(r){var e;r.div.contains(document.activeElement)&&(t(this,Mc)&&clearTimeout(t(this,Mc)),A(this,Mc,setTimeout((()=>{this.focusMainContainer(),A(this,Mc,null)}),0))),t(this,wc).delete(r.id),this.unselect(r),(!r.annotationElementId||!t(this,Wc).has(r.annotationElementId))&&(null==(e=t(this,Cc))||e.remove(r.id))}addDeletedAnnotationElement(r){t(this,Wc).add(r.annotationElementId),this.addChangedExistingAnnotation(r),r.deleted=!0}isDeletedAnnotationElement(r){return t(this,Wc).has(r)}removeDeletedAnnotationElement(r){t(this,Wc).delete(r.annotationElementId),this.removeChangedExistingAnnotation(r),r.deleted=!1}setActiveEditor(r){t(this,kc)!==r&&(A(this,kc,r),r&&o(this,Vd,Nd).call(this,r.propertiesToUpdate))}updateUI(r){t(this,Yd,Hd)===r&&o(this,Vd,Nd).call(this,r.propertiesToUpdate)}toggleSelected(r){if(t(this,Yc).has(r))return t(this,Yc).delete(r),r.unselect(),void o(this,Gd,Xd).call(this,{hasSelectedEditor:this.hasSelection});t(this,Yc).add(r),r.select(),o(this,Vd,Nd).call(this,r.propertiesToUpdate),o(this,Gd,Xd).call(this,{hasSelectedEditor:!0})}setSelected(r){for(const e of t(this,Yc))e!==r&&e.unselect();t(this,Yc).clear(),t(this,Yc).add(r),r.select(),o(this,Vd,Nd).call(this,r.propertiesToUpdate),o(this,Gd,Xd).call(this,{hasSelectedEditor:!0})}isSelected(r){return t(this,Yc).has(r)}get firstSelectedEditor(){return t(this,Yc).values().next().value}unselect(r){r.unselect(),t(this,Yc).delete(r),o(this,Gd,Xd).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==t(this,Yc).size}get isEnterHandled(){return 1===t(this,Yc).size&&this.firstSelectedEditor.isEnterHandled}undo(){t(this,_c).undo(),o(this,Gd,Xd).call(this,{hasSomethingToUndo:t(this,_c).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:o(this,Qd,Ud).call(this)})}redo(){t(this,_c).redo(),o(this,Gd,Xd).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:t(this,_c).hasSomethingToRedo(),isEmpty:o(this,Qd,Ud).call(this)})}addCommands(r){t(this,_c).add(r),o(this,Gd,Xd).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:o(this,Qd,Ud).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const r=[...t(this,Yc)];this.addCommands({cmd:()=>{for(const e of r)e.remove()},undo:()=>{for(const e of r)o(this,Ld,Od).call(this,e)},mustExec:!0})}commitOrRemove(){var r;null==(r=t(this,kc))||r.commitOrRemove()}hasSomethingToControl(){return t(this,kc)||this.hasSelection}selectAll(){for(const r of t(this,Yc))r.commit();o(this,Jd,zd).call(this,t(this,wc).values())}unselectAll(){if((!t(this,kc)||(t(this,kc).commitOrRemove(),t(this,Oc)===qs.NONE))&&this.hasSelection){for(const r of t(this,Yc))r.unselect();t(this,Yc).clear(),o(this,Gd,Xd).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(r,e,a=!1){if(a||this.commitOrRemove(),!this.hasSelection)return;t(this,od)[0]+=r,t(this,od)[1]+=e;const[i,n]=t(this,od),o=[...t(this,Yc)];t(this,sd)&&clearTimeout(t(this,sd)),A(this,sd,setTimeout((()=>{A(this,sd,null),t(this,od)[0]=t(this,od)[1]=0,this.addCommands({cmd:()=>{for(const r of o)t(this,wc).has(r.id)&&r.translateInPage(i,n)},undo:()=>{for(const r of o)t(this,wc).has(r.id)&&r.translateInPage(-i,-n)},mustExec:!1})}),1e3));for(const a of o)a.translateInPage(r,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),A(this,Ic,new Map);for(const r of t(this,Yc))t(this,Ic).set(r,{savedX:r.x,savedY:r.y,savedPageIndex:r.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!t(this,Ic))return!1;this.disableUserSelect(!1);const r=t(this,Ic);A(this,Ic,null);let e=!1;for(const[{x:a,y:t,pageIndex:i},A]of r)A.newX=a,A.newY=t,A.newPageIndex=i,e||(e=a!==A.savedX||t!==A.savedY||i!==A.savedPageIndex);if(!e)return!1;const a=(r,e,a,i)=>{if(t(this,wc).has(r.id)){const A=t(this,yc).get(i);A?r._setParentAndPosition(A,e,a):(r.pageIndex=i,r.x=e,r.y=a)}};return this.addCommands({cmd:()=>{for(const[e,{newX:t,newY:i,newPageIndex:A}]of r)a(e,t,i,A)},undo:()=>{for(const[e,{savedX:t,savedY:i,savedPageIndex:A}]of r)a(e,t,i,A)},mustExec:!0}),!0}dragSelectedEditors(r,e){if(t(this,Ic))for(const a of t(this,Ic).keys())a.drag(r,e)}rebuild(r){if(null===r.parent){const e=this.getLayer(r.pageIndex);e?(e.changeParent(r),e.addOrRebuild(r)):(this.addEditor(r),this.addToAnnotationStorage(r),r.rebuild())}else r.parent.addOrRebuild(r)}get isEditorHandlingKeyboard(){var r;return(null==(r=this.getActive())?void 0:r.shouldGetKeyboardEvents())||1===t(this,Yc).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(r){return t(this,kc)===r}getActive(){return t(this,kc)}getMode(){return t(this,Oc)}get imageManager(){return jf(this,"imageManager",new sc)}getSelectionBoxes(r){if(!r)return null;const e=document.getSelection();for(let a=0,t=e.rangeCount;a<t;a++)if(!r.contains(e.getRangeAt(a).commonAncestorContainer))return null;const{x:a,y:t,width:i,height:A}=r.getBoundingClientRect();let n;switch(r.getAttribute("data-main-rotation")){case"90":n=(r,e,n,o)=>({x:(e-t)/A,y:1-(r+n-a)/i,width:o/A,height:n/i});break;case"180":n=(r,e,n,o)=>({x:1-(r+n-a)/i,y:1-(e+o-t)/A,width:n/i,height:o/A});break;case"270":n=(r,e,n,o)=>({x:1-(e+o-t)/A,y:(r-a)/i,width:o/A,height:n/i});break;default:n=(r,e,n,o)=>({x:(r-a)/i,y:(e-t)/A,width:n/i,height:o/A})}const o=[];for(let r=0,a=e.rangeCount;r<a;r++){const a=e.getRangeAt(r);if(!a.collapsed)for(const{x:r,y:e,width:t,height:i}of a.getClientRects())0===t||0===i||o.push(n(r,e,t,i))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:r,id:e}){(t(this,Bc)||A(this,Bc,new Map)).set(r,e)}removeChangedExistingAnnotation({annotationElementId:r}){var e;null==(e=t(this,Bc))||e.delete(r)}renderAnnotationElement(r){var e;const a=null==(e=t(this,Bc))?void 0:e.get(r.data.id);if(!a)return;const i=t(this,Cc).getRawValue(a);i&&(t(this,Oc)===qs.NONE&&!i.hasBeenModified||i.renderAnnotationElement(r))}};let $d=qd;var Kd,rh,eh,ah,th,ih,Ah,nh,oh;mc=new WeakMap,kc=new WeakMap,wc=new WeakMap,yc=new WeakMap,Ec=new WeakMap,Cc=new WeakMap,Bc=new WeakMap,_c=new WeakMap,Zc=new WeakMap,Wc=new WeakMap,Ic=new WeakMap,Rc=new WeakMap,Fc=new WeakMap,Sc=new WeakMap,xc=new WeakMap,Mc=new WeakMap,Gc=new WeakMap,Xc=new WeakMap,Vc=new WeakMap,Nc=new WeakMap,Dc=new WeakMap,Tc=new WeakMap,Pc=new WeakMap,jc=new WeakMap,Lc=new WeakMap,Oc=new WeakMap,Yc=new WeakMap,Hc=new WeakMap,Qc=new WeakMap,Uc=new WeakMap,Jc=new WeakMap,zc=new WeakMap,qc=new WeakMap,$c=new WeakMap,Kc=new WeakMap,rd=new WeakMap,ed=new WeakMap,ad=new WeakMap,td=new WeakMap,id=new WeakMap,Ad=new WeakMap,nd=new WeakMap,od=new WeakMap,sd=new WeakMap,fd=new WeakMap,ld=new WeakMap,ud=new WeakSet,cd=function({anchorNode:r}){return r.nodeType===Node.TEXT_NODE?r.parentElement:r},dd=new WeakSet,hd=function(){const r=document.getSelection();if(!r||r.isCollapsed)return;const e=o(this,ud,cd).call(this,r).closest(".textLayer"),a=this.getSelectionBoxes(e);a&&(t(this,Vc)||A(this,Vc,new ic(this)),t(this,Vc).show(e,a,"ltr"===this.direction))},bd=new WeakSet,gd=function(){var r,e,a;const i=document.getSelection();if(!i||i.isCollapsed)return void(t(this,Hc)&&(null==(r=t(this,Vc))||r.hide(),A(this,Hc,null),o(this,Gd,Xd).call(this,{hasSelectedText:!1})));const{anchorNode:n}=i;if(n!==t(this,Hc))if(o(this,ud,cd).call(this,i).closest(".textLayer")){if(null==(a=t(this,Vc))||a.hide(),A(this,Hc,n),o(this,Gd,Xd).call(this,{hasSelectedText:!0}),(t(this,Oc)===qs.HIGHLIGHT||t(this,Oc)===qs.NONE)&&(t(this,Oc)===qs.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),A(this,Xc,this.isShiftKeyDown),!this.isShiftKeyDown)){const r=this._signal,e=r=>{"pointerup"===r.type&&0!==r.button||(window.removeEventListener("pointerup",e),window.removeEventListener("blur",e),"pointerup"===r.type&&o(this,pd,vd).call(this,"main_toolbar"))};window.addEventListener("pointerup",e,{signal:r}),window.addEventListener("blur",e,{signal:r})}}else t(this,Hc)&&(null==(e=t(this,Vc))||e.hide(),A(this,Hc,null),o(this,Gd,Xd).call(this,{hasSelectedText:!1}))},pd=new WeakSet,vd=function(r=""){t(this,Oc)===qs.HIGHLIGHT?this.highlightSelection(r):t(this,Sc)&&o(this,dd,hd).call(this)},md=new WeakSet,kd=function(){document.addEventListener("selectionchange",o(this,bd,gd).bind(this),{signal:this._signal})},wd=new WeakSet,yd=function(){const r=this._signal;window.addEventListener("focus",t(this,zc),{signal:r}),window.addEventListener("blur",t(this,Jc),{signal:r})},Ed=new WeakSet,Cd=function(){window.removeEventListener("focus",t(this,zc)),window.removeEventListener("blur",t(this,Jc))},Bd=new WeakSet,_d=function(){const r=this._signal;window.addEventListener("keydown",t(this,rd),{signal:r}),window.addEventListener("keyup",t(this,ed),{signal:r})},Zd=new WeakSet,Wd=function(){window.removeEventListener("keydown",t(this,rd)),window.removeEventListener("keyup",t(this,ed))},Id=new WeakSet,Rd=function(){const r=this._signal;document.addEventListener("copy",t(this,qc),{signal:r}),document.addEventListener("cut",t(this,$c),{signal:r}),document.addEventListener("paste",t(this,Kc),{signal:r})},Fd=new WeakSet,Sd=function(){document.removeEventListener("copy",t(this,qc)),document.removeEventListener("cut",t(this,$c)),document.removeEventListener("paste",t(this,Kc))},xd=new WeakSet,Md=function(){const r=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:r}),document.addEventListener("drop",this.drop.bind(this),{signal:r})},Gd=new WeakSet,Xd=function(r){Object.entries(r).some((([r,e])=>t(this,nd)[r]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(t(this,nd),r)}),t(this,Oc)===qs.HIGHLIGHT&&!1===r.hasSelectedEditor&&o(this,Vd,Nd).call(this,[[$s.HIGHLIGHT_FREE,!0]]))},Vd=new WeakSet,Nd=function(r){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:r})},Dd=new WeakSet,Td=function(){if(!t(this,Dc)){A(this,Dc,!0);for(const r of t(this,yc).values())r.enable();for(const r of t(this,wc).values())r.enable()}},Pd=new WeakSet,jd=function(){if(this.unselectAll(),t(this,Dc)){A(this,Dc,!1);for(const r of t(this,yc).values())r.disable();for(const r of t(this,wc).values())r.disable()}},Ld=new WeakSet,Od=function(r){const e=t(this,yc).get(r.pageIndex);e?e.addOrRebuild(r):(this.addEditor(r),this.addToAnnotationStorage(r))},Yd=new WeakSet,Hd=function(){let r=null;for(r of t(this,Yc));return r},Qd=new WeakSet,Ud=function(){if(0===t(this,wc).size)return!0;if(1===t(this,wc).size)for(const r of t(this,wc).values())return r.isEmpty();return!1},Jd=new WeakSet,zd=function(r){for(const r of t(this,Yc))r.unselect();t(this,Yc).clear();for(const e of r)e.isEmpty()||(t(this,Yc).add(e),e.select());o(this,Gd,Xd).call(this,{hasSelectedEditor:this.hasSelection})},e($d,"TRANSLATE_SMALL",1),e($d,"TRANSLATE_BIG",10);const sh=class{constructor(r){i(this,nh),i(this,Kd,""),i(this,rh,!1),i(this,eh,null),i(this,ah,null),i(this,th,null),i(this,ih,!1),i(this,Ah,null),A(this,Ah,r)}static initialize(r){sh._l10nPromise||(sh._l10nPromise=r)}async render(){const r=A(this,eh,document.createElement("button"));r.className="altText";const e=await sh._l10nPromise.get("pdfjs-editor-alt-text-button-label");r.textContent=e,r.setAttribute("aria-label",e),r.tabIndex="0";const a=t(this,Ah)._uiManager._signal;r.addEventListener("contextmenu",gu,{signal:a}),r.addEventListener("pointerdown",(r=>r.stopPropagation()),{signal:a});const i=r=>{r.preventDefault(),t(this,Ah)._uiManager.editAltText(t(this,Ah))};return r.addEventListener("click",i,{capture:!0,signal:a}),r.addEventListener("keydown",(e=>{e.target===r&&"Enter"===e.key&&(A(this,ih,!0),i(e))}),{signal:a}),await o(this,nh,oh).call(this),r}finish(){t(this,eh)&&(t(this,eh).focus({focusVisible:t(this,ih)}),A(this,ih,!1))}isEmpty(){return!t(this,Kd)&&!t(this,rh)}get data(){return{altText:t(this,Kd),decorative:t(this,rh)}}set data({altText:r,decorative:e}){t(this,Kd)===r&&t(this,rh)===e||(A(this,Kd,r),A(this,rh,e),o(this,nh,oh).call(this))}toggle(r=!1){t(this,eh)&&(!r&&t(this,th)&&(clearTimeout(t(this,th)),A(this,th,null)),t(this,eh).disabled=!r)}destroy(){var r;null==(r=t(this,eh))||r.remove(),A(this,eh,null),A(this,ah,null)}};let fh=sh;var lh,uh,ch,dh,hh,bh,gh,ph,vh,mh,kh,wh,yh,Eh,Ch,Bh,_h,Zh,Wh,Ih,Rh,Fh,Sh,xh,Mh,Gh,Xh,Vh,Nh,Dh,Th,Ph,jh,Lh,Oh,Yh,Hh,Qh,Uh,Jh,zh,qh,$h,Kh,rb,eb,ab,tb,ib,Ab;Kd=new WeakMap,rh=new WeakMap,eh=new WeakMap,ah=new WeakMap,th=new WeakMap,ih=new WeakMap,Ah=new WeakMap,nh=new WeakSet,oh=async function(){var r;const e=t(this,eh);if(!e)return;if(!t(this,Kd)&&!t(this,rh))return e.classList.remove("done"),void(null==(r=t(this,ah))||r.remove());e.classList.add("done"),sh._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then((r=>{e.setAttribute("aria-label",r)}));let a=t(this,ah);if(!a){A(this,ah,a=document.createElement("span")),a.className="tooltip",a.setAttribute("role","tooltip");const r=a.id=`alt-text-tooltip-${t(this,Ah).id}`;e.setAttribute("aria-describedby",r);const i=100,n=t(this,Ah)._uiManager._signal;n.addEventListener("abort",(()=>{clearTimeout(t(this,th)),A(this,th,null)}),{once:!0}),e.addEventListener("mouseenter",(()=>{A(this,th,setTimeout((()=>{A(this,th,null),t(this,ah).classList.add("show"),t(this,Ah)._reportTelemetry({action:"alt_text_tooltip"})}),i))}),{signal:n}),e.addEventListener("mouseleave",(()=>{var r;t(this,th)&&(clearTimeout(t(this,th)),A(this,th,null)),null==(r=t(this,ah))||r.classList.remove("show")}),{signal:n})}a.innerText=t(this,rh)?await sh._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):t(this,Kd),a.parentNode||e.append(a);const i=t(this,Ah).getImageForAltText();null==i||i.setAttribute("aria-describedby",a.id)},e(fh,"_l10nPromise",null);const nb=class{constructor(r){i(this,Sh),i(this,Xh),i(this,Nh),i(this,Th),i(this,jh),i(this,Oh),i(this,Hh),i(this,Uh),i(this,zh),i(this,$h),i(this,rb),i(this,ab),i(this,ib),i(this,lh,null),i(this,uh,null),i(this,ch,null),i(this,dh,!1),i(this,hh,!1),i(this,bh,null),i(this,gh,null),i(this,ph,this.focusin.bind(this)),i(this,vh,this.focusout.bind(this)),i(this,mh,null),i(this,kh,""),i(this,wh,!1),i(this,yh,null),i(this,Eh,!1),i(this,Ch,!1),i(this,Bh,!1),i(this,_h,null),i(this,Zh,0),i(this,Wh,0),i(this,Ih,null),e(this,"_initialOptions",Object.create(null)),e(this,"_isVisible",!0),e(this,"_uiManager",null),e(this,"_focusEventsAllowed",!0),e(this,"_l10nPromise",null),i(this,Rh,!1),i(this,Fh,nb._zIndex++),this.constructor===nb&&Df("Cannot initialize AnnotationEditor."),this.parent=r.parent,this.id=r.id,this.width=this.height=null,this.pageIndex=r.parent.pageIndex,this.name=r.name,this.div=null,this._uiManager=r.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=r.isCentered,this._structTreeParentId=null;const{rotation:a,rawDims:{pageWidth:t,pageHeight:A,pageX:n,pageY:o}}=this.parent.viewport;this.rotation=a,this.pageRotation=(360+a-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[t,A],this.pageTranslation=[n,o];const[s,f]=this.parentDimensions;this.x=r.x/s,this.y=r.y/f,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const r=nb.prototype._resizeWithKeyboard,e=$d.TRANSLATE_SMALL,a=$d.TRANSLATE_BIG;return jf(this,"_resizerKeyboardManager",new gc([[["ArrowLeft","mac+ArrowLeft"],r,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r,{args:[-a,0]}],[["ArrowRight","mac+ArrowRight"],r,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r,{args:[a,0]}],[["ArrowUp","mac+ArrowUp"],r,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r,{args:[0,-a]}],[["ArrowDown","mac+ArrowDown"],r,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r,{args:[0,a]}],[["Escape","mac+Escape"],nb.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return jf(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(r){const e=new sb({id:r.parent.getNextId(),parent:r.parent,uiManager:r._uiManager});e.annotationElementId=r.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(r,e,a){if(nb._l10nPromise||(nb._l10nPromise=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map((e=>[e,r.get(e.replaceAll(/([A-Z])/g,(r=>`-${r.toLowerCase()}`)))])))),null!=a&&a.strings)for(const e of a.strings)nb._l10nPromise.set(e,r.get(e));if(-1!==nb._borderLineWidth)return;const t=getComputedStyle(document.documentElement);nb._borderLineWidth=parseFloat(t.getPropertyValue("--outline-width"))||0}static updateDefaultParams(r,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(r){return!1}static paste(r,e){Df("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return t(this,Rh)}set _isDraggable(r){var e;A(this,Rh,r),null==(e=this.div)||e.classList.toggle("draggable",r)}get isEnterHandled(){return!0}center(){const[r,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*r),this.y+=this.width*r/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*r),this.y-=this.width*r/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(r){this._uiManager.addCommands(r)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=t(this,Fh)}setParent(r){null!==r?(this.pageIndex=r.pageIndex,this.pageDimensions=r.pageDimensions):o(this,ib,Ab).call(this),this.parent=r}focusin(r){this._focusEventsAllowed&&(t(this,wh)?A(this,wh,!1):this.parent.setSelected(this))}focusout(r){var e;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const a=r.relatedTarget;null!=a&&a.closest(`#${this.id}`)||(r.preventDefault(),null!=(e=this.parent)&&e.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(r,e,a,t){const[i,A]=this.parentDimensions;[a,t]=this.screenToPageTranslation(a,t),this.x=(r+a)/i,this.y=(e+t)/A,this.fixAndSetPosition()}translate(r,e){o(this,Sh,xh).call(this,this.parentDimensions,r,e)}translateInPage(r,e){t(this,yh)||A(this,yh,[this.x,this.y]),o(this,Sh,xh).call(this,this.pageDimensions,r,e),this.div.scrollIntoView({block:"nearest"})}drag(r,e){t(this,yh)||A(this,yh,[this.x,this.y]);const[a,i]=this.parentDimensions;if(this.x+=r/a,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:r,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,r,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:o}=this;const[s,f]=this.getBaseTranslation();n+=s,o+=f,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*o).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!t(this,yh)&&(t(this,yh)[0]!==this.x||t(this,yh)[1]!==this.y)}getBaseTranslation(){const[r,e]=this.parentDimensions,{_borderLineWidth:a}=nb,t=a/r,i=a/e;switch(this.rotation){case 90:return[-t,i];case 180:return[t,i];case 270:return[t,-i];default:return[-t,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(r=this.rotation){const[e,a]=this.pageDimensions;let{x:t,y:i,width:A,height:n}=this;if(A*=e,n*=a,t*=e,i*=a,this._mustFixPosition)switch(r){case 0:t=Math.max(0,Math.min(e-A,t)),i=Math.max(0,Math.min(a-n,i));break;case 90:t=Math.max(0,Math.min(e-n,t)),i=Math.min(a,Math.max(A,i));break;case 180:t=Math.min(e,Math.max(A,t)),i=Math.min(a,Math.max(n,i));break;case 270:t=Math.min(e,Math.max(n,t)),i=Math.max(0,Math.min(a-A,i))}this.x=t/=e,this.y=i/=a;const[o,s]=this.getBaseTranslation();t+=o,i+=s;const{style:f}=this.div;f.left=`${(100*t).toFixed(2)}%`,f.top=`${(100*i).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(r,e){var a;return o(a=nb,Mh,Gh).call(a,r,e,this.parentRotation)}pageTranslationToScreen(r,e){var a;return o(a=nb,Mh,Gh).call(a,r,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:r,pageDimensions:[e,a]}=this,t=e*r,i=a*r;return rl.isCSSRoundSupported?[Math.round(t),Math.round(i)]:[t,i]}setDims(r,e){const[a,i]=this.parentDimensions;this.div.style.width=`${(100*r/a).toFixed(2)}%`,t(this,hh)||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:r}=this.div,{height:e,width:a}=r,i=a.endsWith("%"),A=!t(this,hh)&&e.endsWith("%");if(i&&A)return;const[n,o]=this.parentDimensions;i||(r.width=`${(100*parseFloat(a)/n).toFixed(2)}%`),!t(this,hh)&&!A&&(r.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var r;null==(r=t(this,ch))||r.finish()}async addEditToolbar(){return t(this,mh)||t(this,Ch)||(A(this,mh,new ju(this)),this.div.append(t(this,mh).render()),t(this,ch)&&t(this,mh).addAltTextButton(await t(this,ch).render())),t(this,mh)}removeEditToolbar(){var r;t(this,mh)&&(t(this,mh).remove(),A(this,mh,null),null==(r=t(this,ch))||r.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){t(this,ch)||(fh.initialize(nb._l10nPromise),A(this,ch,new fh(this)),t(this,lh)&&(t(this,ch).data=t(this,lh),A(this,lh,null)),await this.addEditToolbar())}get altTextData(){var r;return null==(r=t(this,ch))?void 0:r.data}set altTextData(r){t(this,ch)&&(t(this,ch).data=r)}hasAltText(){var r;return!(null!=(r=t(this,ch))&&r.isEmpty())}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=t(this,dh)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const r=this._uiManager._signal;this.div.addEventListener("focusin",t(this,ph),{signal:r}),this.div.addEventListener("focusout",t(this,vh),{signal:r});const[e,a]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*a/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/a).toFixed(2)}%`);const[i,A]=this.getInitialTranslation();return this.translate(i,A),Ac(this,this.div,["pointerdown"]),this.div}pointerdown(r){const{isMac:e}=rl.platform;0!==r.button||r.ctrlKey&&e?r.preventDefault():(A(this,wh,!0),this._isDraggable?o(this,Uh,Jh).call(this,r):o(this,Hh,Qh).call(this,r))}moveInDOM(){t(this,_h)&&clearTimeout(t(this,_h)),A(this,_h,setTimeout((()=>{var r;A(this,_h,null),null==(r=this.parent)||r.moveEditorInDOM(this)}),0))}_setParentAndPosition(r,e,a){r.changeParent(this),this.x=e,this.y=a,this.fixAndSetPosition()}getRect(r,e,a=this.rotation){const t=this.parentScale,[i,A]=this.pageDimensions,[n,o]=this.pageTranslation,s=r/t,f=e/t,l=this.x*i,u=this.y*A,c=this.width*i,d=this.height*A;switch(a){case 0:return[l+s+n,A-u-f-d+o,l+s+c+n,A-u-f+o];case 90:return[l+f+n,A-u+s+o,l+f+d+n,A-u+s+c+o];case 180:return[l-s-c+n,A-u+f+o,l-s+n,A-u+f+d+o];case 270:return[l-f-d+n,A-u-s-c+o,l-f+n,A-u-s+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(r,e){const[a,t,i,A]=r,n=i-a,o=A-t;switch(this.rotation){case 0:return[a,e-A,n,o];case 90:return[a,e-t,o,n];case 180:return[i,e-t,n,o];case 270:return[i,e-A,o,n];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){A(this,Ch,!0)}disableEditMode(){A(this,Ch,!1)}isInEditMode(){return t(this,Ch)}shouldGetKeyboardEvents(){return t(this,Bh)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var r,e;const a=this._uiManager._signal;null==(r=this.div)||r.addEventListener("focusin",t(this,ph),{signal:a}),null==(e=this.div)||e.addEventListener("focusout",t(this,vh),{signal:a})}rotate(r){}serialize(r=!1,e=null){Df("An editor must be serializable")}static deserialize(r,e,a){const t=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:a});t.rotation=r.rotation,A(t,lh,r.accessibilityData);const[i,n]=t.pageDimensions,[o,s,f,l]=t.getRectInCurrentCoords(r.rect,n);return t.x=o/i,t.y=s/n,t.width=f/i,t.height=l/n,t}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.div.removeEventListener("focusin",t(this,ph)),this.div.removeEventListener("focusout",t(this,vh)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),t(this,_h)&&(clearTimeout(t(this,_h)),A(this,_h,null)),o(this,ib,Ab).call(this),this.removeEditToolbar(),t(this,Ih)){for(const r of t(this,Ih).values())clearTimeout(r);A(this,Ih,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(o(this,Nh,Dh).call(this),t(this,bh).classList.remove("hidden"),Ac(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(r){if(!this.isResizable||r.target!==this.div||"Enter"!==r.key)return;this._uiManager.setSelected(this),A(this,gh,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=t(this,bh).children;if(!t(this,uh)){A(this,uh,Array.from(e));const r=o(this,zh,qh).bind(this),a=o(this,$h,Kh).bind(this),i=this._uiManager._signal;for(const e of t(this,uh)){const t=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",r,{signal:i}),e.addEventListener("blur",a,{signal:i}),e.addEventListener("focus",o(this,rb,eb).bind(this,t),{signal:i}),nb._l10nPromise.get(`pdfjs-editor-resizer-label-${t}`).then((r=>e.setAttribute("aria-label",r)))}}const a=t(this,uh)[0];let i=0;for(const r of e){if(r===a)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(t(this,uh).length/4);if(n!==i){if(n<i)for(let r=0;r<i-n;r++)t(this,bh).append(t(this,bh).firstChild);else if(n>i)for(let r=0;r<n-i;r++)t(this,bh).firstChild.before(t(this,bh).lastChild);let r=0;for(const a of e){const e=t(this,uh)[r++].getAttribute("data-resizer-name");nb._l10nPromise.get(`pdfjs-editor-resizer-label-${e}`).then((r=>a.setAttribute("aria-label",r)))}}o(this,ab,tb).call(this,0),A(this,Bh,!0),t(this,bh).firstChild.focus({focusVisible:!0}),r.preventDefault(),r.stopImmediatePropagation()}_resizeWithKeyboard(r,e){t(this,Bh)&&o(this,Oh,Yh).call(this,t(this,kh),{movementX:r,movementY:e})}_stopResizingWithKeyboard(){o(this,ib,Ab).call(this),this.div.focus()}select(){var r,e;this.makeResizable(),null==(r=this.div)||r.classList.add("selectedEditor"),t(this,mh)?null==(e=t(this,mh))||e.show():this.addEditToolbar().then((()=>{var r,e;null!=(r=this.div)&&r.classList.contains("selectedEditor")&&(null==(e=t(this,mh))||e.show())}))}unselect(){var r,e,a,i;null==(r=t(this,bh))||r.classList.add("hidden"),null==(e=this.div)||e.classList.remove("selectedEditor"),null!=(a=this.div)&&a.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null==(i=t(this,mh))||i.hide()}updateParams(r,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return t(this,Eh)}set isEditing(r){A(this,Eh,r),this.parent&&(r?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(r,e){A(this,hh,!0);const a=r/e,{style:t}=this.div;t.aspectRatio=a,t.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(r,e=!1){if(e){t(this,Ih)||A(this,Ih,new Map);const{action:e}=r;let a=t(this,Ih).get(e);return a&&clearTimeout(a),a=setTimeout((()=>{this._reportTelemetry(r),t(this,Ih).delete(e),0===t(this,Ih).size&&A(this,Ih,null)}),nb._telemetryTimeout),void t(this,Ih).set(e,a)}r.type||(r.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:r}})}show(r=this._isVisible){this.div.classList.toggle("hidden",!r),this._isVisible=r}enable(){this.div&&(this.div.tabIndex=0),A(this,dh,!1)}disable(){this.div&&(this.div.tabIndex=-1),A(this,dh,!0)}renderAnnotationElement(r){let e=r.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const r=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),r.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),r.container.prepend(e);return e}resetAnnotationElement(r){const{firstChild:e}=r.container;"DIV"===e.nodeName&&e.classList.contains("annotationContent")&&e.remove()}};let ob=nb;lh=new WeakMap,uh=new WeakMap,ch=new WeakMap,dh=new WeakMap,hh=new WeakMap,bh=new WeakMap,gh=new WeakMap,ph=new WeakMap,vh=new WeakMap,mh=new WeakMap,kh=new WeakMap,wh=new WeakMap,yh=new WeakMap,Eh=new WeakMap,Ch=new WeakMap,Bh=new WeakMap,_h=new WeakMap,Zh=new WeakMap,Wh=new WeakMap,Ih=new WeakMap,Rh=new WeakMap,Fh=new WeakMap,Sh=new WeakSet,xh=function([r,e],a,t){[a,t]=this.screenToPageTranslation(a,t),this.x+=a/r,this.y+=t/e,this.fixAndSetPosition()},Mh=new WeakSet,Gh=function(r,e,a){switch(a){case 90:return[e,-r];case 180:return[-r,-e];case 270:return[-e,r];default:return[r,e]}},Xh=new WeakSet,Vh=function(r){switch(r){case 90:{const[r,e]=this.pageDimensions;return[0,-r/e,e/r,0]}case 180:return[-1,0,0,-1];case 270:{const[r,e]=this.pageDimensions;return[0,r/e,-e/r,0]}default:return[1,0,0,1]}},Nh=new WeakSet,Dh=function(){if(t(this,bh))return;A(this,bh,document.createElement("div")),t(this,bh).classList.add("resizers");const r=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const a of r){const r=document.createElement("div");t(this,bh).append(r),r.classList.add("resizer",a),r.setAttribute("data-resizer-name",a),r.addEventListener("pointerdown",o(this,Th,Ph).bind(this,a),{signal:e}),r.addEventListener("contextmenu",gu,{signal:e}),r.tabIndex=-1}this.div.prepend(t(this,bh))},Th=new WeakSet,Ph=function(r,e){var a;e.preventDefault();const{isMac:i}=rl.platform;if(0!==e.button||e.ctrlKey&&i)return;null==(a=t(this,ch))||a.toggle(!1);const A=o(this,Oh,Yh).bind(this,r),n=this._isDraggable;this._isDraggable=!1;const s=this._uiManager._signal,f={passive:!0,capture:!0,signal:s};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",A,f),window.addEventListener("contextmenu",gu,{signal:s});const l=this.x,u=this.y,c=this.width,d=this.height,h=this.parent.div.style.cursor,b=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const g=()=>{var r;this.parent.togglePointerEvents(!0),null==(r=t(this,ch))||r.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",A,f),window.removeEventListener("contextmenu",gu),this.parent.div.style.cursor=h,this.div.style.cursor=b,o(this,jh,Lh).call(this,l,u,c,d)};window.addEventListener("pointerup",g,{signal:s}),window.addEventListener("blur",g,{signal:s})},jh=new WeakSet,Lh=function(r,e,a,t){const i=this.x,A=this.y,n=this.width,o=this.height;i===r&&A===e&&n===a&&o===t||this.addCommands({cmd:()=>{this.width=n,this.height=o,this.x=i,this.y=A;const[r,e]=this.parentDimensions;this.setDims(r*n,e*o),this.fixAndSetPosition()},undo:()=>{this.width=a,this.height=t,this.x=r,this.y=e;const[i,A]=this.parentDimensions;this.setDims(i*a,A*t),this.fixAndSetPosition()},mustExec:!0})},Oh=new WeakSet,Yh=function(r,e){const[a,t]=this.parentDimensions,i=this.x,A=this.y,n=this.width,s=this.height,f=nb.MIN_SIZE/a,l=nb.MIN_SIZE/t,u=r=>Math.round(1e4*r)/1e4,c=o(this,Xh,Vh).call(this,this.rotation),d=(r,e)=>[c[0]*r+c[2]*e,c[1]*r+c[3]*e],h=o(this,Xh,Vh).call(this,360-this.rotation);let b,g,p=!1,v=!1;switch(r){case"topLeft":p=!0,b=(r,e)=>[0,0],g=(r,e)=>[r,e];break;case"topMiddle":b=(r,e)=>[r/2,0],g=(r,e)=>[r/2,e];break;case"topRight":p=!0,b=(r,e)=>[r,0],g=(r,e)=>[0,e];break;case"middleRight":v=!0,b=(r,e)=>[r,e/2],g=(r,e)=>[0,e/2];break;case"bottomRight":p=!0,b=(r,e)=>[r,e],g=(r,e)=>[0,0];break;case"bottomMiddle":b=(r,e)=>[r/2,e],g=(r,e)=>[r/2,0];break;case"bottomLeft":p=!0,b=(r,e)=>[0,e],g=(r,e)=>[r,0];break;case"middleLeft":v=!0,b=(r,e)=>[0,e/2],g=(r,e)=>[r,e/2]}const m=b(n,s),k=g(n,s);let w=d(...k);const y=u(i+w[0]),E=u(A+w[1]);let C=1,B=1,[_,Z]=this.screenToPageTranslation(e.movementX,e.movementY);if([_,Z]=(W=_/a,I=Z/t,[h[0]*W+h[2]*I,h[1]*W+h[3]*I]),p){const r=Math.hypot(n,s);C=B=Math.max(Math.min(Math.hypot(k[0]-m[0]-_,k[1]-m[1]-Z)/r,1/n,1/s),f/n,l/s)}else v?C=Math.max(f,Math.min(1,Math.abs(k[0]-m[0]-_)))/n:B=Math.max(l,Math.min(1,Math.abs(k[1]-m[1]-Z)))/s;var W,I;const R=u(n*C),F=u(s*B);w=d(...g(R,F));const S=y-w[0],x=E-w[1];this.width=R,this.height=F,this.x=S,this.y=x,this.setDims(a*R,t*F),this.fixAndSetPosition()},Hh=new WeakSet,Qh=function(r){const{isMac:e}=rl.platform;r.ctrlKey&&!e||r.shiftKey||r.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Uh=new WeakSet,Jh=function(r){const e=this._uiManager.isSelected(this);let a,i;this._uiManager.setUpDragSession();const n=this._uiManager._signal;e&&(this.div.classList.add("moving"),a={passive:!0,capture:!0,signal:n},A(this,Zh,r.clientX),A(this,Wh,r.clientY),i=r=>{const{clientX:e,clientY:a}=r,[i,n]=this.screenToPageTranslation(e-t(this,Zh),a-t(this,Wh));A(this,Zh,e),A(this,Wh,a),this._uiManager.dragSelectedEditors(i,n)},window.addEventListener("pointermove",i,a));const s=()=>{window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,a)),A(this,wh,!1),this._uiManager.endDragSession()||o(this,Hh,Qh).call(this,r)};window.addEventListener("pointerup",s,{signal:n}),window.addEventListener("blur",s,{signal:n})},zh=new WeakSet,qh=function(r){nb._resizerKeyboardManager.exec(this,r)},$h=new WeakSet,Kh=function(r){var e;t(this,Bh)&&(null==(e=r.relatedTarget)?void 0:e.parentNode)!==t(this,bh)&&o(this,ib,Ab).call(this)},rb=new WeakSet,eb=function(r){A(this,kh,t(this,Bh)?r:"")},ab=new WeakSet,tb=function(r){if(t(this,uh))for(const e of t(this,uh))e.tabIndex=r},ib=new WeakSet,Ab=function(){if(A(this,Bh,!1),o(this,ab,tb).call(this,-1),t(this,gh)){const{savedX:r,savedY:e,savedWidth:a,savedHeight:i}=t(this,gh);o(this,jh,Lh).call(this,r,e,a,i),A(this,gh,null)}},i(ob,Mh),e(ob,"_borderLineWidth",-1),e(ob,"_colorManager",new vc),e(ob,"_zIndex",1),e(ob,"_telemetryTimeout",1e3);class sb extends ob{constructor(r){super(r),this.annotationElementId=r.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const fb=3285377520,lb=4294901760,ub=65535;class cb{constructor(r){this.h1=r?4294967295&r:fb,this.h2=r?4294967295&r:fb}update(r){let e,a;if("string"==typeof r){e=new Uint8Array(2*r.length),a=0;for(let t=0,i=r.length;t<i;t++){const i=r.charCodeAt(t);i<=255?e[a++]=i:(e[a++]=i>>>8,e[a++]=255&i)}}else{if(!ArrayBuffer.isView(r))throw new Error("Invalid data format, must be a string or TypedArray.");e=r.slice(),a=e.byteLength}const t=a>>2,i=a-4*t,A=new Uint32Array(e.buffer,0,t);let n=0,o=0,s=this.h1,f=this.h2;const l=3432918353,u=461845907,c=l&ub,d=u&ub;for(let r=0;r<t;r++)1&r?(n=A[r],n=n*l&lb|n*c&ub,n=n<<15|n>>>17,n=n*u&lb|n*d&ub,s^=n,s=s<<13|s>>>19,s=5*s+3864292196):(o=A[r],o=o*l&lb|o*c&ub,o=o<<15|o>>>17,o=o*u&lb|o*d&ub,f^=o,f=f<<13|f>>>19,f=5*f+3864292196);switch(n=0,i){case 3:n^=e[4*t+2]<<16;case 2:n^=e[4*t+1]<<8;case 1:n^=e[4*t],n=n*l&lb|n*c&ub,n=n<<15|n>>>17,n=n*u&lb|n*d&ub,1&t?s^=n:f^=n}this.h1=s,this.h2=f}hexdigest(){let r=this.h1,e=this.h2;return r^=e>>>1,r=3981806797*r&lb|36045*r&ub,e=4283543511*e&lb|(2950163797*(e<<16|r>>>16)&lb)>>>16,r^=e>>>1,r=444984403*r&lb|60499*r&ub,e=3301882366*e&lb|(3120437893*(e<<16|r>>>16)&lb)>>>16,r^=e>>>1,(r>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const db=Object.freeze({map:null,hash:"",transfer:void 0});var hb,bb,gb,pb,vb,mb;class kb{constructor(){i(this,gb),i(this,hb,!1),i(this,bb,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(r,e){const a=t(this,bb).get(r);return void 0===a?e:Object.assign(e,a)}getRawValue(r){return t(this,bb).get(r)}remove(r){if(t(this,bb).delete(r),0===t(this,bb).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const r of t(this,bb).values())if(r instanceof ob)return;this.onAnnotationEditor(null)}}setValue(r,e){const a=t(this,bb).get(r);let i=!1;if(void 0!==a)for(const[r,t]of Object.entries(e))a[r]!==t&&(i=!0,a[r]=t);else i=!0,t(this,bb).set(r,e);i&&o(this,gb,pb).call(this),e instanceof ob&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(r){return t(this,bb).has(r)}getAll(){return t(this,bb).size>0?Kf(t(this,bb)):null}setAll(r){for(const[e,a]of Object.entries(r))this.setValue(e,a)}get size(){return t(this,bb).size}resetModified(){t(this,hb)&&(A(this,hb,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new wb(this)}get serializable(){if(0===t(this,bb).size)return db;const r=new Map,e=new cb,a=[],i=Object.create(null);let A=!1;for(const[a,n]of t(this,bb)){const t=n instanceof ob?n.serialize(!1,i):n;t&&(r.set(a,t),e.update(`${a}:${JSON.stringify(t)}`),A||(A=!!t.bitmap))}if(A)for(const e of r.values())e.bitmap&&a.push(e.bitmap);return r.size>0?{map:r,hash:e.hexdigest(),transfer:a}:db}get editorStats(){let r=null;const e=new Map;for(const a of t(this,bb).values()){if(!(a instanceof ob))continue;const t=a.telemetryFinalData;if(!t)continue;const{type:i}=t;e.has(i)||e.set(i,Object.getPrototypeOf(a).constructor),r||(r=Object.create(null));const A=r[i]||(r[i]=new Map);for(const[r,e]of Object.entries(t)){if("type"===r)continue;let a=A.get(r);a||(a=new Map,A.set(r,a));const t=a.get(e)??0;a.set(e,t+1)}}for(const[a,t]of e)r[a]=t.computeTelemetryFinalData(r[a]);return r}}hb=new WeakMap,bb=new WeakMap,gb=new WeakSet,pb=function(){t(this,hb)||(A(this,hb,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class wb extends kb{constructor(r){super(),i(this,vb,void 0);const{map:e,hash:a,transfer:t}=r.serializable,n=structuredClone(e,t?{transfer:t}:null);A(this,vb,{map:n,hash:a,transfer:t})}get print(){Df("Should not call PrintAnnotationStorage.print")}get serializable(){return t(this,vb)}}vb=new WeakMap;class yb{constructor({ownerDocument:r=globalThis.document,styleElement:e=null}){i(this,mb,new Set),this._document=r,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(r){this.nativeFontFaces.add(r),this._document.fonts.add(r)}removeNativeFontFace(r){this.nativeFontFaces.delete(r),this._document.fonts.delete(r)}insertRule(r){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(r,e.cssRules.length)}clear(){for(const r of this.nativeFontFaces)this._document.fonts.delete(r);this.nativeFontFaces.clear(),t(this,mb).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:r,_inspectFont:e}){if(r&&!t(this,mb).has(r.loadedName)){if(Tf(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:a,src:i,style:A}=r,n=new FontFace(a,i,A);this.addNativeFontFace(n);try{await n.load(),t(this,mb).add(a),null==e||e(r)}catch{Nf(`Cannot load system font: ${r.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(n)}return}Df("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(r){if(r.attached||r.missingFile&&!r.systemFontInfo)return;if(r.attached=!0,r.systemFontInfo)return void await this.loadSystemFont(r);if(this.isFontLoadingAPISupported){const e=r.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(a){throw Nf(`Failed to load font '${e.family}': '${a}'.`),r.disableFontFace=!0,a}}return}const e=r.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const a=this._queueLoadingCallback(e);this._prepareFontLoadEvent(r,a)}))}}get isFontLoadingAPISupported(){var r;return jf(this,"isFontLoadingAPISupported",!(null==(r=this._document)||!r.fonts))}get isSyncFontLoadingSupported(){let r=!1;return(Ds||typeof navigator<"u"&&"string"==typeof(null==navigator?void 0:navigator.userAgent)&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(r=!0),jf(this,"isSyncFontLoadingSupported",r)}_queueLoadingCallback(r){const{loadingRequests:e}=this,a={done:!1,complete:function(){for(Tf(!a.done,"completeRequest() cannot be called twice."),a.done=!0;e.length>0&&e[0].done;){const r=e.shift();setTimeout(r.callback,0)}},callback:r};return e.push(a),a}get _loadTestFont(){return jf(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(r,e){function a(r,e){return r.charCodeAt(e)<<24|r.charCodeAt(e+1)<<16|r.charCodeAt(e+2)<<8|255&r.charCodeAt(e+3)}function t(r,e,a,t){return r.substring(0,e)+t+r.substring(e+a)}let i,A;const n=this._document.createElement("canvas");n.width=1,n.height=1;const o=n.getContext("2d");let s=0;const f=`lt${Date.now()}${this.loadTestFontId++}`;let l=this._loadTestFont;l=t(l,976,f.length,f);const u=1482184792;let c=a(l,16);for(i=0,A=f.length-3;i<A;i+=4)c=c-u+a(f,i)|0;var d;i<f.length&&(c=c-u+a(f+"XXX",i)|0),l=t(l,16,4,(d=c,String.fromCharCode(d>>24&255,d>>16&255,d>>8&255,255&d)));const h=`@font-face {font-family:"${f}";src:${`url(data:font/opentype;base64,${btoa(l)});`}}`;this.insertRule(h);const b=this._document.createElement("div");b.style.visibility="hidden",b.style.width=b.style.height="10px",b.style.position="absolute",b.style.top=b.style.left="0px";for(const e of[r.loadedName,f]){const r=this._document.createElement("span");r.textContent="Hi",r.style.fontFamily=e,b.append(r)}this._document.body.append(b),function r(e,a){if(++s>30)return Nf("Load test font never loaded."),void a();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?a():setTimeout(r.bind(null,e,a))}(f,(()=>{b.remove(),e.complete()}))}}mb=new WeakMap;class Eb{constructor(r,{disableFontFace:e=!1,inspectFont:a=null}){this.compiledGlyphs=Object.create(null);for(const e in r)this[e]=r[e];this.disableFontFace=!0===e,this._inspectFont=a}createNativeFontFace(){var r;if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const r={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(r.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,r)}else e=new FontFace(this.loadedName,this.data,{});return null==(r=this._inspectFont)||r.call(this,this),e}createFontFaceRule(){var r;if(!this.data||this.disableFontFace)return null;const e=qf(this.data),a=`url(data:${this.mimetype};base64,${btoa(e)});`;let t;if(this.cssFontInfo){let r=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(r+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${r}src:${a}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${a}}`;return null==(r=this._inspectFont)||r.call(this,this,a),t}getPathGenerator(r,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let a;try{a=r.get(this.loadedName+"_path_"+e)}catch(r){Nf(`getPathGenerator - ignoring character: "${r}".`)}if(!Array.isArray(a)||0===a.length)return this.compiledGlyphs[e]=function(r,e){};const t=[];for(let r=0,e=a.length;r<e;)switch(a[r++]){case ul:{const[e,i,A,n,o,s]=a.slice(r,r+6);t.push((r=>r.bezierCurveTo(e,i,A,n,o,s))),r+=6}break;case cl:{const[e,i]=a.slice(r,r+2);t.push((r=>r.moveTo(e,i))),r+=2}break;case dl:{const[e,i]=a.slice(r,r+2);t.push((r=>r.lineTo(e,i))),r+=2}break;case hl:{const[e,i,A,n]=a.slice(r,r+4);t.push((r=>r.quadraticCurveTo(e,i,A,n))),r+=4}break;case bl:t.push((r=>r.restore()));break;case gl:t.push((r=>r.save()));break;case pl:Tf(2===t.length,"Scale command is only valid at the third position.");break;case vl:{const[e,i,A,n,o,s]=a.slice(r,r+6);t.push((r=>r.transform(e,i,A,n,o,s))),r+=6}break;case ml:{const[e,i]=a.slice(r,r+2);t.push((r=>r.translate(e,i))),r+=2}}return this.compiledGlyphs[e]=function(r,e){t[0](r),t[1](r),r.scale(e,-e);for(let e=2,a=t.length;e<a;e++)t[e](r)}}}if(Ds){var Cb=Promise.withResolvers(),Bb=null;(async()=>{const r=await import("./__vite-browser-external-afb87ea8.js"),e=await import("./__vite-browser-external-afb87ea8.js"),a=await import("./__vite-browser-external-afb87ea8.js"),t=await import("./__vite-browser-external-afb87ea8.js");return new Map(Object.entries({fs:r,http:e,https:a,url:t,canvas:undefined,path2d:undefined}))})().then((r=>{Bb=r,Cb.resolve()}),(r=>{Nf(`loadPackages: ${r}`),Bb=new Map,Cb.resolve()}))}class _b{static get promise(){return Cb.promise}static get(r){return null==Bb?void 0:Bb.get(r)}}const Zb=function(r){return _b.get("fs").promises.readFile(r).then((r=>new Uint8Array(r)))};const Wb="Fill",Ib="Stroke",Rb="Shading";function Fb(r,e){if(!e)return;const a=e[2]-e[0],t=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],a,t),r.clip(i)}class Sb{constructor(){this.constructor===Sb&&Df("Cannot initialize BaseShadingPattern.")}getPattern(){Df("Abstract method `getPattern` called.")}}class xb extends Sb{constructor(r){super(),this._type=r[1],this._bbox=r[2],this._colorStops=r[3],this._p0=r[4],this._p1=r[5],this._r0=r[6],this._r1=r[7],this.matrix=null}_createGradient(r){let e;"axial"===this._type?e=r.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=r.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const r of this._colorStops)e.addColorStop(r[0],r[1]);return e}getPattern(r,e,a,t){let i;if(t===Ib||t===Wb){const A=e.current.getClippedPathBoundingBox(t,yu(r))||[0,0,0,0],n=Math.ceil(A[2]-A[0])||1,o=Math.ceil(A[3]-A[1])||1,s=e.cachedCanvases.getCanvas("pattern",n,o,!0),f=s.context;f.clearRect(0,0,f.canvas.width,f.canvas.height),f.beginPath(),f.rect(0,0,f.canvas.width,f.canvas.height),f.translate(-A[0],-A[1]),a=nl.transform(a,[1,0,0,1,A[0],A[1]]),f.transform(...e.baseTransform),this.matrix&&f.transform(...this.matrix),Fb(f,this._bbox),f.fillStyle=this._createGradient(f),f.fill(),i=r.createPattern(s.canvas,"no-repeat");const l=new DOMMatrix(a);i.setTransform(l)}else Fb(r,this._bbox),i=this._createGradient(r);return i}}function Mb(r,e,a,t,i,A,n,o){const s=e.coords,f=e.colors,l=r.data,u=4*r.width;let c;s[a+1]>s[t+1]&&(c=a,a=t,t=c,c=A,A=n,n=c),s[t+1]>s[i+1]&&(c=t,t=i,i=c,c=n,n=o,o=c),s[a+1]>s[t+1]&&(c=a,a=t,t=c,c=A,A=n,n=c);const d=(s[a]+e.offsetX)*e.scaleX,h=(s[a+1]+e.offsetY)*e.scaleY,b=(s[t]+e.offsetX)*e.scaleX,g=(s[t+1]+e.offsetY)*e.scaleY,p=(s[i]+e.offsetX)*e.scaleX,v=(s[i+1]+e.offsetY)*e.scaleY;if(h>=v)return;const m=f[A],k=f[A+1],w=f[A+2],y=f[n],E=f[n+1],C=f[n+2],B=f[o],_=f[o+1],Z=f[o+2],W=Math.round(h),I=Math.round(v);let R,F,S,x,M,G,X,V;for(let r=W;r<=I;r++){if(r<g){const e=r<h?0:(h-r)/(h-g);R=d-(d-b)*e,F=m-(m-y)*e,S=k-(k-E)*e,x=w-(w-C)*e}else{let e;e=r>v?1:g===v?0:(g-r)/(g-v),R=b-(b-p)*e,F=y-(y-B)*e,S=E-(E-_)*e,x=C-(C-Z)*e}let e;e=r<h?0:r>v?1:(h-r)/(h-v),M=d-(d-p)*e,G=m-(m-B)*e,X=k-(k-_)*e,V=w-(w-Z)*e;const a=Math.round(Math.min(R,M)),t=Math.round(Math.max(R,M));let i=u*r+4*a;for(let r=a;r<=t;r++)e=(R-r)/(R-M),e<0?e=0:e>1&&(e=1),l[i++]=F-(F-G)*e|0,l[i++]=S-(S-X)*e|0,l[i++]=x-(x-V)*e|0,l[i++]=255}}function Gb(r,e,a){const t=e.coords,i=e.colors;let A,n;switch(e.type){case"lattice":const o=e.verticesPerRow,s=Math.floor(t.length/o)-1,f=o-1;for(A=0;A<s;A++){let e=A*o;for(let A=0;A<f;A++,e++)Mb(r,a,t[e],t[e+1],t[e+o],i[e],i[e+1],i[e+o]),Mb(r,a,t[e+o+1],t[e+1],t[e+o],i[e+o+1],i[e+1],i[e+o])}break;case"triangles":for(A=0,n=t.length;A<n;A+=3)Mb(r,a,t[A],t[A+1],t[A+2],i[A],i[A+1],i[A+2]);break;default:throw new Error("illegal figure")}}class Xb extends Sb{constructor(r){super(),this._coords=r[2],this._colors=r[3],this._figures=r[4],this._bounds=r[5],this._bbox=r[7],this._background=r[8],this.matrix=null}_createMeshCanvas(r,e,a){const t=Math.floor(this._bounds[0]),i=Math.floor(this._bounds[1]),A=Math.ceil(this._bounds[2])-t,n=Math.ceil(this._bounds[3])-i,o=Math.min(Math.ceil(Math.abs(A*r[0]*1.1)),3e3),s=Math.min(Math.ceil(Math.abs(n*r[1]*1.1)),3e3),f=A/o,l=n/s,u={coords:this._coords,colors:this._colors,offsetX:-t,offsetY:-i,scaleX:1/f,scaleY:1/l},c=o+4,d=s+4,h=a.getCanvas("mesh",c,d,!1),b=h.context,g=b.createImageData(o,s);if(e){const r=g.data;for(let a=0,t=r.length;a<t;a+=4)r[a]=e[0],r[a+1]=e[1],r[a+2]=e[2],r[a+3]=255}for(const r of this._figures)Gb(g,r,u);return b.putImageData(g,2,2),{canvas:h.canvas,offsetX:t-2*f,offsetY:i-2*l,scaleX:f,scaleY:l}}getPattern(r,e,a,t){let i;if(Fb(r,this._bbox),t===Rb)i=nl.singularValueDecompose2dScale(yu(r));else if(i=nl.singularValueDecompose2dScale(e.baseTransform),this.matrix){const r=nl.singularValueDecompose2dScale(this.matrix);i=[i[0]*r[0],i[1]*r[1]]}const A=this._createMeshCanvas(i,t===Rb?null:this._background,e.cachedCanvases);return t!==Rb&&(r.setTransform(...e.baseTransform),this.matrix&&r.transform(...this.matrix)),r.translate(A.offsetX,A.offsetY),r.scale(A.scaleX,A.scaleY),r.createPattern(A.canvas,"no-repeat")}}class Vb extends Sb{getPattern(){return"hotpink"}}const Nb=1,Db=2,Tb=class{constructor(r,e,a,t,i){this.operatorList=r[2],this.matrix=r[3],this.bbox=r[4],this.xstep=r[5],this.ystep=r[6],this.paintType=r[7],this.tilingType=r[8],this.color=e,this.ctx=a,this.canvasGraphicsFactory=t,this.baseTransform=i}createPatternCanvas(r){const e=this.operatorList,a=this.bbox,t=this.xstep,i=this.ystep,A=this.paintType,n=this.tilingType,o=this.color,s=this.canvasGraphicsFactory;Vf("TilingType: "+n);const f=a[0],l=a[1],u=a[2],c=a[3],d=nl.singularValueDecompose2dScale(this.matrix),h=nl.singularValueDecompose2dScale(this.baseTransform),b=[d[0]*h[0],d[1]*h[1]],g=this.getSizeAndScale(t,this.ctx.canvas.width,b[0]),p=this.getSizeAndScale(i,this.ctx.canvas.height,b[1]),v=r.cachedCanvases.getCanvas("pattern",g.size,p.size,!0),m=v.context,k=s.createCanvasGraphics(m);k.groupLevel=r.groupLevel,this.setFillAndStrokeStyleToContext(k,A,o);let w=f,y=l,E=u,C=c;return f<0&&(w=0,E+=Math.abs(f)),l<0&&(y=0,C+=Math.abs(l)),m.translate(-g.scale*w,-p.scale*y),k.transform(g.scale,0,0,p.scale,0,0),m.save(),this.clipBbox(k,w,y,E,C),k.baseTransform=yu(k.ctx),k.executeOperatorList(e),k.endDrawing(),{canvas:v.canvas,scaleX:g.scale,scaleY:p.scale,offsetX:w,offsetY:y}}getSizeAndScale(r,e,a){r=Math.abs(r);const t=Math.max(Tb.MAX_PATTERN_SIZE,e);let i=Math.ceil(r*a);return i>=t?i=t:a=i/r,{scale:a,size:i}}clipBbox(r,e,a,t,i){const A=t-e,n=i-a;r.ctx.rect(e,a,A,n),r.current.updateRectMinMax(yu(r.ctx),[e,a,t,i]),r.clip(),r.endPath()}setFillAndStrokeStyleToContext(r,e,a){const t=r.ctx,i=r.current;switch(e){case Nb:const r=this.ctx;t.fillStyle=r.fillStyle,t.strokeStyle=r.strokeStyle,i.fillColor=r.fillStyle,i.strokeColor=r.strokeStyle;break;case Db:const A=nl.makeHexColor(a[0],a[1],a[2]);t.fillStyle=A,t.strokeStyle=A,i.fillColor=A,i.strokeColor=A;break;default:throw new Jf(`Unsupported paint type: ${e}`)}}getPattern(r,e,a,t){let i=a;t!==Rb&&(i=nl.transform(i,e.baseTransform),this.matrix&&(i=nl.transform(i,this.matrix)));const A=this.createPatternCanvas(e);let n=new DOMMatrix(i);n=n.translate(A.offsetX,A.offsetY),n=n.scale(1/A.scaleX,1/A.scaleY);const o=r.createPattern(A.canvas,"repeat");return o.setTransform(n),o}};let Pb=Tb;function jb({src:r,srcPos:e=0,dest:a,width:t,height:i,nonBlackColor:A=4294967295,inverseDecode:n=!1}){const o=rl.isLittleEndian?4278190080:255,[s,f]=n?[A,o]:[o,A],l=t>>3,u=7&t,c=r.length;a=new Uint32Array(a.buffer);let d=0;for(let t=0;t<i;t++){for(const t=e+l;e<t;e++){const t=e<c?r[e]:255;a[d++]=128&t?f:s,a[d++]=64&t?f:s,a[d++]=32&t?f:s,a[d++]=16&t?f:s,a[d++]=8&t?f:s,a[d++]=4&t?f:s,a[d++]=2&t?f:s,a[d++]=1&t?f:s}if(0===u)continue;const t=e<c?r[e++]:255;for(let r=0;r<u;r++)a[d++]=t&1<<7-r?f:s}return{srcPos:e,destPos:d}}e(Pb,"MAX_PATTERN_SIZE",3e3);const Lb=16;class Ob{constructor(r){this.canvasFactory=r,this.cache=Object.create(null)}getCanvas(r,e,a){let t;return void 0!==this.cache[r]?(t=this.cache[r],this.canvasFactory.reset(t,e,a)):(t=this.canvasFactory.create(e,a),this.cache[r]=t),t}delete(r){delete this.cache[r]}clear(){for(const r in this.cache){const e=this.cache[r];this.canvasFactory.destroy(e),delete this.cache[r]}}}function Yb(r,e,a,t,i,A,n,o,s,f){const[l,u,c,d,h,b]=yu(r);if(0===u&&0===c){const g=n*l+h,p=Math.round(g),v=o*d+b,m=Math.round(v),k=(n+s)*l+h,w=Math.abs(Math.round(k)-p)||1,y=(o+f)*d+b,E=Math.abs(Math.round(y)-m)||1;return r.setTransform(Math.sign(l),0,0,Math.sign(d),p,m),r.drawImage(e,a,t,i,A,0,0,w,E),r.setTransform(l,u,c,d,h,b),[w,E]}if(0===l&&0===d){const g=o*c+h,p=Math.round(g),v=n*u+b,m=Math.round(v),k=(o+f)*c+h,w=Math.abs(Math.round(k)-p)||1,y=(n+s)*u+b,E=Math.abs(Math.round(y)-m)||1;return r.setTransform(0,Math.sign(u),Math.sign(c),0,p,m),r.drawImage(e,a,t,i,A,0,0,E,w),r.setTransform(l,u,c,d,h,b),[E,w]}r.drawImage(e,a,t,i,A,n,o,s,f);return[Math.hypot(l,u)*s,Math.hypot(c,d)*f]}class Hb{constructor(r,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Ts,this.textMatrixScale=1,this.fontMatrix=Ps,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=rf,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,r,e])}clone(){const r=Object.create(this);return r.clipBox=this.clipBox.slice(),r}setCurrentPoint(r,e){this.x=r,this.y=e}updatePathMinMax(r,e,a){[e,a]=nl.applyTransform([e,a],r),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,a),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,a)}updateRectMinMax(r,e){const a=nl.applyTransform(e,r),t=nl.applyTransform(e.slice(2),r),i=nl.applyTransform([e[0],e[3]],r),A=nl.applyTransform([e[2],e[1]],r);this.minX=Math.min(this.minX,a[0],t[0],i[0],A[0]),this.minY=Math.min(this.minY,a[1],t[1],i[1],A[1]),this.maxX=Math.max(this.maxX,a[0],t[0],i[0],A[0]),this.maxY=Math.max(this.maxY,a[1],t[1],i[1],A[1])}updateScalingPathMinMax(r,e){nl.scaleMinMax(r,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(r,e,a,t,i,A,n,o,s,f){const l=nl.bezierBoundingBox(e,a,t,i,A,n,o,s,f);f||this.updateRectMinMax(r,l)}getPathBoundingBox(r=Wb,e=null){const a=[this.minX,this.minY,this.maxX,this.maxY];if(r===Ib){e||Df("Stroke bounding box must include transform.");const r=nl.singularValueDecompose2dScale(e),t=r[0]*this.lineWidth/2,i=r[1]*this.lineWidth/2;a[0]-=t,a[1]-=i,a[2]+=t,a[3]+=i}return a}updateClipFromPath(){const r=nl.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(r||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(r){this.clipBox=r,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(r=Wb,e=null){return nl.intersect(this.clipBox,this.getPathBoundingBox(r,e))}}function Qb(r,e){if(typeof ImageData<"u"&&e instanceof ImageData)return void r.putImageData(e,0,0);const a=e.height,t=e.width,i=a%Lb,A=(a-i)/Lb,n=0===i?A:A+1,o=r.createImageData(t,Lb);let s,f=0;const l=e.data,u=o.data;let c,d,h,b;if(e.kind===of.GRAYSCALE_1BPP){const e=l.byteLength,a=new Uint32Array(u.buffer,0,u.byteLength>>2),b=a.length,g=t+7>>3,p=4294967295,v=rl.isLittleEndian?4278190080:255;for(c=0;c<n;c++){for(h=c<A?Lb:i,s=0,d=0;d<h;d++){const r=e-f;let i=0;const A=r>g?t:8*r-7,n=-8&A;let o=0,u=0;for(;i<n;i+=8)u=l[f++],a[s++]=128&u?p:v,a[s++]=64&u?p:v,a[s++]=32&u?p:v,a[s++]=16&u?p:v,a[s++]=8&u?p:v,a[s++]=4&u?p:v,a[s++]=2&u?p:v,a[s++]=1&u?p:v;for(;i<A;i++)0===o&&(u=l[f++],o=128),a[s++]=u&o?p:v,o>>=1}for(;s<b;)a[s++]=0;r.putImageData(o,0,c*Lb)}}else if(e.kind===of.RGBA_32BPP){for(d=0,b=t*Lb*4,c=0;c<A;c++)u.set(l.subarray(f,f+b)),f+=b,r.putImageData(o,0,d),d+=Lb;c<n&&(b=t*i*4,u.set(l.subarray(f,f+b)),r.putImageData(o,0,d))}else{if(e.kind!==of.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(h=Lb,b=t*h,c=0;c<n;c++){for(c>=A&&(h=i,b=t*h),s=0,d=b;d--;)u[s++]=l[f++],u[s++]=l[f++],u[s++]=l[f++],u[s++]=255;r.putImageData(o,0,c*Lb)}}}function Ub(r,e){if(e.bitmap)return void r.drawImage(e.bitmap,0,0);const a=e.height,t=e.width,i=a%Lb,A=(a-i)/Lb,n=0===i?A:A+1,o=r.createImageData(t,Lb);let s=0;const f=e.data,l=o.data;for(let e=0;e<n;e++){const a=e<A?Lb:i;({srcPos:s}=jb({src:f,srcPos:s,dest:l,width:t,height:a,nonBlackColor:0})),r.putImageData(o,0,e*Lb)}}function Jb(r,e){const a=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const t of a)void 0!==r[t]&&(e[t]=r[t]);void 0!==r.setLineDash&&(e.setLineDash(r.getLineDash()),e.lineDashOffset=r.lineDashOffset)}function zb(r){if(r.strokeStyle=r.fillStyle="#000000",r.fillRule="nonzero",r.globalAlpha=1,r.lineWidth=1,r.lineCap="butt",r.lineJoin="miter",r.miterLimit=10,r.globalCompositeOperation="source-over",r.font="10px sans-serif",void 0!==r.setLineDash&&(r.setLineDash([]),r.lineDashOffset=0),!Ds){const{filter:e}=r;"none"!==e&&""!==e&&(r.filter="none")}}function qb(r,e){if(e)return!0;const a=nl.singularValueDecompose2dScale(r);a[0]=Math.fround(a[0]),a[1]=Math.fround(a[1]);const t=Math.fround((globalThis.devicePixelRatio||1)*Il.PDF_TO_CSS_UNITS);return a[0]<=t&&a[1]<=t}const $b=["butt","round","square"],Kb=["miter","round","bevel"],rg={},eg={};var ag,tg,ig,Ag;const ng=class{constructor(r,e,a,t,A,{optionalContentConfig:n,markedContentStack:o=null},s,f){i(this,ag),i(this,ig),this.ctx=r,this.current=new Hb(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=a,this.canvasFactory=t,this.filterFactory=A,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=n,this.cachedCanvases=new Ob(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=f,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(r,e=null){return"string"==typeof r?r.startsWith("g_")?this.commonObjs.get(r):this.objs.get(r):e}beginDrawing({transform:r,viewport:e,transparency:a=!1,background:t=null}){const i=this.ctx.canvas.width,A=this.ctx.canvas.height,n=this.ctx.fillStyle;if(this.ctx.fillStyle=t||"#ffffff",this.ctx.fillRect(0,0,i,A),this.ctx.fillStyle=n,a){const r=this.cachedCanvases.getCanvas("transparent",i,A);this.compositeCtx=this.ctx,this.transparentCanvas=r.canvas,this.ctx=r.context,this.ctx.save(),this.ctx.transform(...yu(this.compositeCtx))}this.ctx.save(),zb(this.ctx),r&&(this.ctx.transform(...r),this.outputScaleX=r[0],this.outputScaleY=r[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=yu(this.ctx)}executeOperatorList(r,e,a,t){const i=r.argsArray,A=r.fnArray;let n=e||0;const o=i.length;if(o===n)return n;const s=o-n>10&&"function"==typeof a,f=s?Date.now()+15:0;let l=0;const u=this.commonObjs,c=this.objs;let d;for(;;){if(void 0!==t&&n===t.nextBreakPoint)return t.breakIt(n,a),n;if(d=A[n],d!==xf.dependency)this[d].apply(this,i[n]);else for(const r of i[n]){const e=r.startsWith("g_")?u:c;if(!e.has(r))return e.get(r,a),n}if(n++,n===o)return n;if(s&&++l>10){if(Date.now()>f)return a(),n;l=0}}}endDrawing(){o(this,ag,tg).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const r of this._cachedBitmapsMap.values()){for(const e of r.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);r.clear()}this._cachedBitmapsMap.clear(),o(this,ig,Ag).call(this)}_scaleImage(r,e){const a=r.width,t=r.height;let i,A,n=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),s=a,f=t,l="prescale1";for(;n>2&&s>1||o>2&&f>1;){let e=s,a=f;n>2&&s>1&&(e=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s/2),n/=s/e),o>2&&f>1&&(a=f>=16384?Math.floor(f/2)-1||1:Math.ceil(f)/2,o/=f/a),i=this.cachedCanvases.getCanvas(l,e,a),A=i.context,A.clearRect(0,0,e,a),A.drawImage(r,0,0,s,f,0,0,e,a),r=i.canvas,s=e,f=a,l="prescale1"===l?"prescale2":"prescale1"}return{img:r,paintWidth:s,paintHeight:f}}_createMaskCanvas(r){const e=this.ctx,{width:a,height:t}=r,i=this.current.fillColor,A=this.current.patternFill,n=yu(e);let o,s,f,l;if((r.bitmap||r.data)&&r.count>1){const e=r.bitmap||r.data.buffer;s=JSON.stringify(A?n:[n.slice(0,4),i]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const a=o.get(s);if(a&&!A){return{canvas:a,offsetX:Math.round(Math.min(n[0],n[2])+n[4]),offsetY:Math.round(Math.min(n[1],n[3])+n[5])}}f=a}f||(l=this.cachedCanvases.getCanvas("maskCanvas",a,t),Ub(l.context,r));let u=nl.transform(n,[1/a,0,0,-1/t,0,0]);u=nl.transform(u,[1,0,0,1,0,-t]);const[c,d,h,b]=nl.getAxialAlignedBoundingBox([0,0,a,t],u),g=Math.round(h-c)||1,p=Math.round(b-d)||1,v=this.cachedCanvases.getCanvas("fillCanvas",g,p),m=v.context,k=c,w=d;m.translate(-k,-w),m.transform(...u),f||(f=this._scaleImage(l.canvas,Eu(m)),f=f.img,o&&A&&o.set(s,f)),m.imageSmoothingEnabled=qb(yu(m),r.interpolate),Yb(m,f,0,0,f.width,f.height,0,0,a,t),m.globalCompositeOperation="source-in";const y=nl.transform(Eu(m),[1,0,0,1,-k,-w]);return m.fillStyle=A?i.getPattern(e,this,y,Wb):i,m.fillRect(0,0,a,t),o&&!A&&(this.cachedCanvases.delete("fillCanvas"),o.set(s,v.canvas)),{canvas:v.canvas,offsetX:Math.round(k),offsetY:Math.round(w)}}setLineWidth(r){r!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=r,this.ctx.lineWidth=r}setLineCap(r){this.ctx.lineCap=$b[r]}setLineJoin(r){this.ctx.lineJoin=Kb[r]}setMiterLimit(r){this.ctx.miterLimit=r}setDash(r,e){const a=this.ctx;void 0!==a.setLineDash&&(a.setLineDash(r),a.lineDashOffset=e)}setRenderingIntent(r){}setFlatness(r){}setGState(r){for(const[e,a]of r)switch(e){case"LW":this.setLineWidth(a);break;case"LC":this.setLineCap(a);break;case"LJ":this.setLineJoin(a);break;case"ML":this.setMiterLimit(a);break;case"D":this.setDash(a[0],a[1]);break;case"RI":this.setRenderingIntent(a);break;case"FL":this.setFlatness(a);break;case"Font":this.setFont(a[0],a[1]);break;case"CA":this.current.strokeAlpha=a;break;case"ca":this.current.fillAlpha=a,this.ctx.globalAlpha=a;break;case"BM":this.ctx.globalCompositeOperation=a;break;case"SMask":this.current.activeSMask=a?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(a)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const r=this.inSMaskMode;this.current.activeSMask&&!r?this.beginSMaskMode():!this.current.activeSMask&&r&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const r=this.ctx.canvas.width,e=this.ctx.canvas.height,a="smaskGroupAt"+this.groupLevel,t=this.cachedCanvases.getCanvas(a,r,e);this.suspendedCtx=this.ctx,this.ctx=t.context;const i=this.ctx;i.setTransform(...yu(this.suspendedCtx)),Jb(this.suspendedCtx,i),function(r,e){if(r._removeMirroring)throw new Error("Context is already forwarding operations.");r.__originalSave=r.save,r.__originalRestore=r.restore,r.__originalRotate=r.rotate,r.__originalScale=r.scale,r.__originalTranslate=r.translate,r.__originalTransform=r.transform,r.__originalSetTransform=r.setTransform,r.__originalResetTransform=r.resetTransform,r.__originalClip=r.clip,r.__originalMoveTo=r.moveTo,r.__originalLineTo=r.lineTo,r.__originalBezierCurveTo=r.bezierCurveTo,r.__originalRect=r.rect,r.__originalClosePath=r.closePath,r.__originalBeginPath=r.beginPath,r._removeMirroring=()=>{r.save=r.__originalSave,r.restore=r.__originalRestore,r.rotate=r.__originalRotate,r.scale=r.__originalScale,r.translate=r.__originalTranslate,r.transform=r.__originalTransform,r.setTransform=r.__originalSetTransform,r.resetTransform=r.__originalResetTransform,r.clip=r.__originalClip,r.moveTo=r.__originalMoveTo,r.lineTo=r.__originalLineTo,r.bezierCurveTo=r.__originalBezierCurveTo,r.rect=r.__originalRect,r.closePath=r.__originalClosePath,r.beginPath=r.__originalBeginPath,delete r._removeMirroring},r.save=function(){e.save(),this.__originalSave()},r.restore=function(){e.restore(),this.__originalRestore()},r.translate=function(r,a){e.translate(r,a),this.__originalTranslate(r,a)},r.scale=function(r,a){e.scale(r,a),this.__originalScale(r,a)},r.transform=function(r,a,t,i,A,n){e.transform(r,a,t,i,A,n),this.__originalTransform(r,a,t,i,A,n)},r.setTransform=function(r,a,t,i,A,n){e.setTransform(r,a,t,i,A,n),this.__originalSetTransform(r,a,t,i,A,n)},r.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},r.rotate=function(r){e.rotate(r),this.__originalRotate(r)},r.clip=function(r){e.clip(r),this.__originalClip(r)},r.moveTo=function(r,a){e.moveTo(r,a),this.__originalMoveTo(r,a)},r.lineTo=function(r,a){e.lineTo(r,a),this.__originalLineTo(r,a)},r.bezierCurveTo=function(r,a,t,i,A,n){e.bezierCurveTo(r,a,t,i,A,n),this.__originalBezierCurveTo(r,a,t,i,A,n)},r.rect=function(r,a,t,i){e.rect(r,a,t,i),this.__originalRect(r,a,t,i)},r.closePath=function(){e.closePath(),this.__originalClosePath()},r.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(i,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Jb(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(r){if(!this.current.activeSMask)return;r?(r[0]=Math.floor(r[0]),r[1]=Math.floor(r[1]),r[2]=Math.ceil(r[2]),r[3]=Math.ceil(r[3])):r=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,a=this.suspendedCtx;this.composeSMask(a,e,this.ctx,r),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(r,e,a,t){const i=t[0],A=t[1],n=t[2]-i,o=t[3]-A;0===n||0===o||(this.genericComposeSMask(e.context,a,n,o,e.subtype,e.backdrop,e.transferMap,i,A,e.offsetX,e.offsetY),r.save(),r.globalAlpha=1,r.globalCompositeOperation="source-over",r.setTransform(1,0,0,1,0,0),r.drawImage(a.canvas,0,0),r.restore())}genericComposeSMask(r,e,a,t,i,A,n,o,s,f,l){let u=r.canvas,c=o-f,d=s-l;if(A)if(c<0||d<0||c+a>u.width||d+t>u.height){const r=this.cachedCanvases.getCanvas("maskExtension",a,t),e=r.context;e.drawImage(u,-c,-d),A.some((r=>0!==r))&&(e.globalCompositeOperation="destination-atop",e.fillStyle=nl.makeHexColor(...A),e.fillRect(0,0,a,t),e.globalCompositeOperation="source-over"),u=r.canvas,c=d=0}else if(A.some((r=>0!==r))){r.save(),r.globalAlpha=1,r.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(c,d,a,t),r.clip(e),r.globalCompositeOperation="destination-atop",r.fillStyle=nl.makeHexColor(...A),r.fillRect(c,d,a,t),r.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===i&&n?e.filter=this.filterFactory.addAlphaFilter(n):"Luminosity"===i&&(e.filter=this.filterFactory.addLuminosityFilter(n));const h=new Path2D;h.rect(o,s,a,t),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(u,c,d,a,t,o,s,a,t),e.restore()}save(){this.inSMaskMode?(Jb(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const r=this.current;this.stateStack.push(r),this.current=r.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Jb(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(r,e,a,t,i,A){this.ctx.transform(r,e,a,t,i,A),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(r,e,a){const t=this.ctx,i=this.current;let A,n,o=i.x,s=i.y;const f=yu(t),l=0===f[0]&&0===f[3]||0===f[1]&&0===f[2],u=l?a.slice(0):null;for(let a=0,c=0,d=r.length;a<d;a++)switch(0|r[a]){case xf.rectangle:o=e[c++],s=e[c++];const r=e[c++],a=e[c++],d=o+r,h=s+a;t.moveTo(o,s),0===r||0===a?t.lineTo(d,h):(t.lineTo(d,s),t.lineTo(d,h),t.lineTo(o,h)),l||i.updateRectMinMax(f,[o,s,d,h]),t.closePath();break;case xf.moveTo:o=e[c++],s=e[c++],t.moveTo(o,s),l||i.updatePathMinMax(f,o,s);break;case xf.lineTo:o=e[c++],s=e[c++],t.lineTo(o,s),l||i.updatePathMinMax(f,o,s);break;case xf.curveTo:A=o,n=s,o=e[c+4],s=e[c+5],t.bezierCurveTo(e[c],e[c+1],e[c+2],e[c+3],o,s),i.updateCurvePathMinMax(f,A,n,e[c],e[c+1],e[c+2],e[c+3],o,s,u),c+=6;break;case xf.curveTo2:A=o,n=s,t.bezierCurveTo(o,s,e[c],e[c+1],e[c+2],e[c+3]),i.updateCurvePathMinMax(f,A,n,o,s,e[c],e[c+1],e[c+2],e[c+3],u),o=e[c+2],s=e[c+3],c+=4;break;case xf.curveTo3:A=o,n=s,o=e[c+2],s=e[c+3],t.bezierCurveTo(e[c],e[c+1],o,s,o,s),i.updateCurvePathMinMax(f,A,n,e[c],e[c+1],o,s,o,s,u),c+=4;break;case xf.closePath:t.closePath()}l&&i.updateScalingPathMinMax(f,u),i.setCurrentPoint(o,s)}closePath(){this.ctx.closePath()}stroke(r=!0){const e=this.ctx,a=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof a&&null!=a&&a.getPattern?(e.save(),e.strokeStyle=a.getPattern(e,this,Eu(e),Ib),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),r&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(r=!0){const e=this.ctx,a=this.current.fillColor;let t=!1;this.current.patternFill&&(e.save(),e.fillStyle=a.getPattern(e,this,Eu(e),Wb),t=!0);const i=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==i&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),t&&e.restore(),r&&this.consumePath(i)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=rg}eoClip(){this.pendingClip=eg}beginText(){this.current.textMatrix=Ts,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const r=this.pendingTextPaths,e=this.ctx;if(void 0!==r){e.save(),e.beginPath();for(const a of r)e.setTransform(...a.transform),e.translate(a.x,a.y),a.addToPath(e,a.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(r){this.current.charSpacing=r}setWordSpacing(r){this.current.wordSpacing=r}setHScale(r){this.current.textHScale=r/100}setLeading(r){this.current.leading=-r}setFont(r,e){var a;const t=this.commonObjs.get(r),i=this.current;if(!t)throw new Error(`Can't find font for ${r}`);if(i.fontMatrix=t.fontMatrix||Ps,(0===i.fontMatrix[0]||0===i.fontMatrix[3])&&Nf("Invalid font matrix for font "+r),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=t,this.current.fontSize=e,t.isType3Font)return;const A=t.loadedName||"sans-serif",n=(null==(a=t.systemFontInfo)?void 0:a.css)||`"${A}", ${t.fallbackName}`;let o="normal";t.black?o="900":t.bold&&(o="bold");const s=t.italic?"italic":"normal";let f=e;e<16?f=16:e>100&&(f=100),this.current.fontSizeScale=e/f,this.ctx.font=`${s} ${o} ${f}px ${n}`}setTextRenderingMode(r){this.current.textRenderingMode=r}setTextRise(r){this.current.textRise=r}moveText(r,e){this.current.x=this.current.lineX+=r,this.current.y=this.current.lineY+=e}setLeadingMoveText(r,e){this.setLeading(-e),this.moveText(r,e)}setTextMatrix(r,e,a,t,i,A){this.current.textMatrix=[r,e,a,t,i,A],this.current.textMatrixScale=Math.hypot(r,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(r,e,a,t){const i=this.ctx,A=this.current,n=A.font,o=A.textRenderingMode,s=A.fontSize/A.fontSizeScale,f=o&Af,l=!!(o&nf),u=A.patternFill&&!n.missingFile;let c;(n.disableFontFace||l||u)&&(c=n.getPathGenerator(this.commonObjs,r)),n.disableFontFace||u?(i.save(),i.translate(e,a),i.beginPath(),c(i,s),t&&i.setTransform(...t),(f===rf||f===af)&&i.fill(),(f===ef||f===af)&&i.stroke(),i.restore()):((f===rf||f===af)&&i.fillText(r,e,a),(f===ef||f===af)&&i.strokeText(r,e,a)),l&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:yu(i),x:e,y:a,fontSize:s,addToPath:c})}get isFontSubpixelAAEnabled(){const{context:r}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);r.scale(1.5,1),r.fillText("I",0,10);const e=r.getImageData(0,0,10,10).data;let a=!1;for(let r=3;r<e.length;r+=4)if(e[r]>0&&e[r]<255){a=!0;break}return jf(this,"isFontSubpixelAAEnabled",a)}showText(r){const e=this.current,a=e.font;if(a.isType3Font)return this.showType3Text(r);const t=e.fontSize;if(0===t)return;const i=this.ctx,A=e.fontSizeScale,n=e.charSpacing,o=e.wordSpacing,s=e.fontDirection,f=e.textHScale*s,l=r.length,u=a.vertical,c=u?1:-1,d=a.defaultVMetrics,h=t*e.fontMatrix[0],b=e.textRenderingMode===rf&&!a.disableFontFace&&!e.patternFill;let g;if(i.save(),i.transform(...e.textMatrix),i.translate(e.x,e.y+e.textRise),s>0?i.scale(f,-1):i.scale(f,1),e.patternFill){i.save();const r=e.fillColor.getPattern(i,this,Eu(i),Wb);g=yu(i),i.restore(),i.fillStyle=r}let p=e.lineWidth;const v=e.textMatrixScale;if(0===v||0===p){const r=e.textRenderingMode&Af;(r===ef||r===af)&&(p=this.getSinglePixelWidth())}else p/=v;if(1!==A&&(i.scale(A,A),p/=A),i.lineWidth=p,a.isInvalidPDFjsFont){const a=[];let t=0;for(const e of r)a.push(e.unicode),t+=e.width;return i.fillText(a.join(""),0,0),e.x+=t*h*f,i.restore(),void this.compose()}let m,k=0;for(m=0;m<l;++m){const e=r[m];if("number"==typeof e){k+=c*e*t/1e3;continue}let f=!1;const l=(e.isSpace?o:0)+n,p=e.fontChar,v=e.accent;let w,y,E=e.width;if(u){const r=e.vmetric||d,a=-(e.vmetric?r[1]:.5*E)*h,t=r[2]*h;E=r?-r[0]:E,w=a/A,y=(k+t)/A}else w=k/A,y=0;if(a.remeasure&&E>0){const r=1e3*i.measureText(p).width/t*A;if(E<r&&this.isFontSubpixelAAEnabled){const e=E/r;f=!0,i.save(),i.scale(e,1),w/=e}else E!==r&&(w+=(E-r)/2e3*t/A)}if(this.contentVisible&&(e.isInFont||a.missingFile))if(b&&!v)i.fillText(p,w,y);else if(this.paintChar(p,w,y,g),v){const r=w+t*v.offset.x/A,e=y-t*v.offset.y/A;this.paintChar(v.fontChar,r,e,g)}k+=u?E*h-l*s:E*h+l*s,f&&i.restore()}u?e.y-=k:e.x+=k*f,i.restore(),this.compose()}showType3Text(r){const e=this.ctx,a=this.current,t=a.font,i=a.fontSize,A=a.fontDirection,n=t.vertical?1:-1,o=a.charSpacing,s=a.wordSpacing,f=a.textHScale*A,l=a.fontMatrix||Ps,u=r.length;let c,d,h,b;if(!(a.textRenderingMode===tf)&&0!==i){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...a.textMatrix),e.translate(a.x,a.y),e.scale(f,A),c=0;c<u;++c){if(d=r[c],"number"==typeof d){b=n*d*i/1e3,this.ctx.translate(b,0),a.x+=b*f;continue}const A=(d.isSpace?s:0)+o,u=t.charProcOperatorList[d.operatorListId];u?(this.contentVisible&&(this.processingType3=d,this.save(),e.scale(i,i),e.transform(...l),this.executeOperatorList(u),this.restore()),h=nl.applyTransform([d.width,0],l)[0]*i+A,e.translate(h,0),a.x+=h*f):Nf(`Type3 character "${d.operatorListId}" is not available.`)}e.restore(),this.processingType3=null}}setCharWidth(r,e){}setCharWidthAndBounds(r,e,a,t,i,A){this.ctx.rect(a,t,i-a,A-t),this.ctx.clip(),this.endPath()}getColorN_Pattern(r){let e;if("TilingPattern"===r[0]){const a=r[1],t=this.baseTransform||yu(this.ctx),i={createCanvasGraphics:r=>new ng(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Pb(r,a,this.ctx,i,t)}else e=this._getPattern(r[1],r[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(r,e,a){const t=nl.makeHexColor(r,e,a);this.ctx.strokeStyle=t,this.current.strokeColor=t}setFillRGBColor(r,e,a){const t=nl.makeHexColor(r,e,a);this.ctx.fillStyle=t,this.current.fillColor=t,this.current.patternFill=!1}_getPattern(r,e=null){let a;return this.cachedPatterns.has(r)?a=this.cachedPatterns.get(r):(a=function(r){switch(r[0]){case"RadialAxial":return new xb(r);case"Mesh":return new Xb(r);case"Dummy":return new Vb}throw new Error(`Unknown IR type: ${r[0]}`)}(this.getObject(r)),this.cachedPatterns.set(r,a)),e&&(a.matrix=e),a}shadingFill(r){if(!this.contentVisible)return;const e=this.ctx;this.save();const a=this._getPattern(r);e.fillStyle=a.getPattern(e,this,Eu(e),Rb);const t=Eu(e);if(t){const{width:r,height:a}=e.canvas,[i,A,n,o]=nl.getAxialAlignedBoundingBox([0,0,r,a],t);this.ctx.fillRect(i,A,n-i,o-A)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Df("Should not call beginInlineImage")}beginImageData(){Df("Should not call beginImageData")}paintFormXObjectBegin(r,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),r&&this.transform(...r),this.baseTransform=yu(this.ctx),e)){const r=e[2]-e[0],a=e[3]-e[1];this.ctx.rect(e[0],e[1],r,a),this.current.updateRectMinMax(yu(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(r){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;r.isolated||Vf("TODO: Support non-isolated groups."),r.knockout&&Nf("Knockout groups not supported.");const a=yu(e);if(r.matrix&&e.transform(...r.matrix),!r.bbox)throw new Error("Bounding box is required.");let t=nl.getAxialAlignedBoundingBox(r.bbox,yu(e));const i=[0,0,e.canvas.width,e.canvas.height];t=nl.intersect(t,i)||[0,0,0,0];const A=Math.floor(t[0]),n=Math.floor(t[1]),o=Math.max(Math.ceil(t[2])-A,1),s=Math.max(Math.ceil(t[3])-n,1);this.current.startNewPathAndClipBox([0,0,o,s]);let f="groupAt"+this.groupLevel;r.smask&&(f+="_smask_"+this.smaskCounter++%2);const l=this.cachedCanvases.getCanvas(f,o,s),u=l.context;u.translate(-A,-n),u.transform(...a),r.smask?this.smaskStack.push({canvas:l.canvas,context:u,offsetX:A,offsetY:n,subtype:r.smask.subtype,backdrop:r.smask.backdrop,transferMap:r.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(A,n),e.save()),Jb(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(r){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,a=this.groupStack.pop();if(this.ctx=a,this.ctx.imageSmoothingEnabled=!1,r.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const r=yu(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);const a=nl.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],r);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(r,e,a,t,i){if(o(this,ag,tg).call(this),zb(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const t=e[2]-e[0],A=e[3]-e[1];if(i&&this.annotationCanvasMap){(a=a.slice())[4]-=e[0],a[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=t,e[3]=A;const[i,n]=nl.singularValueDecompose2dScale(yu(this.ctx)),{viewportScale:o}=this,s=Math.ceil(t*this.outputScaleX*o),f=Math.ceil(A*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(s,f);const{canvas:l,context:u}=this.annotationCanvas;this.annotationCanvasMap.set(r,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=u,this.ctx.save(),this.ctx.setTransform(i,0,0,-n,0,A*n),zb(this.ctx)}else zb(this.ctx),this.ctx.rect(e[0],e[1],t,A),this.ctx.clip(),this.endPath()}this.current=new Hb(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...a),this.transform(...t)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),o(this,ig,Ag).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(r){if(!this.contentVisible)return;const e=r.count;(r=this.getObject(r.data,r)).count=e;const a=this.ctx,t=this.processingType3;if(t&&(void 0===t.compiled&&(t.compiled=function(r){const{width:e,height:a}=r;if(e>1e3||a>1e3)return null;const t=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),i=e+1;let A,n,o,s=new Uint8Array(i*(a+1));const f=e+7&-8;let l=new Uint8Array(f*a),u=0;for(const e of r.data){let r=128;for(;r>0;)l[u++]=e&r?0:255,r>>=1}let c=0;for(u=0,0!==l[u]&&(s[0]=1,++c),n=1;n<e;n++)l[u]!==l[u+1]&&(s[n]=l[u]?2:1,++c),u++;for(0!==l[u]&&(s[n]=2,++c),A=1;A<a;A++){u=A*f,o=A*i,l[u-f]!==l[u]&&(s[o]=l[u]?1:8,++c);let r=(l[u]?4:0)+(l[u-f]?8:0);for(n=1;n<e;n++)r=(r>>2)+(l[u+1]?4:0)+(l[u-f+1]?8:0),t[r]&&(s[o+n]=t[r],++c),u++;if(l[u-f]!==l[u]&&(s[o+n]=l[u]?2:4,++c),c>1e3)return null}for(u=f*(a-1),o=A*i,0!==l[u]&&(s[o]=8,++c),n=1;n<e;n++)l[u]!==l[u+1]&&(s[o+n]=l[u]?4:8,++c),u++;if(0!==l[u]&&(s[o+n]=4,++c),c>1e3)return null;const d=new Int32Array([0,i,-1,0,-i,0,0,0,1]),h=new Path2D;for(A=0;c&&A<=a;A++){let r=A*i;const a=r+e;for(;r<a&&!s[r];)r++;if(r===a)continue;h.moveTo(r%i,A);const t=r;let n=s[r];do{const e=d[n];do{r+=e}while(!s[r]);const a=s[r];5!==a&&10!==a?(n=a,s[r]=0):(n=a&51*n>>4,s[r]&=n>>2|n<<2),h.lineTo(r%i,r/i|0),s[r]||--c}while(t!==r);--A}return l=null,s=null,function(r){r.save(),r.scale(1/e,-1/a),r.translate(0,-a),r.fill(h),r.beginPath(),r.restore()}}(r)),t.compiled))return void t.compiled(a);const i=this._createMaskCanvas(r),A=i.canvas;a.save(),a.setTransform(1,0,0,1,0,0),a.drawImage(A,i.offsetX,i.offsetY),a.restore(),this.compose()}paintImageMaskXObjectRepeat(r,e,a=0,t=0,i,A){if(!this.contentVisible)return;r=this.getObject(r.data,r);const n=this.ctx;n.save();const o=yu(n);n.transform(e,a,t,i,0,0);const s=this._createMaskCanvas(r);n.setTransform(1,0,0,1,s.offsetX-o[4],s.offsetY-o[5]);for(let r=0,f=A.length;r<f;r+=2){const f=nl.transform(o,[e,a,t,i,A[r],A[r+1]]),[l,u]=nl.applyTransform([0,0],f);n.drawImage(s.canvas,l,u)}n.restore(),this.compose()}paintImageMaskXObjectGroup(r){if(!this.contentVisible)return;const e=this.ctx,a=this.current.fillColor,t=this.current.patternFill;for(const i of r){const{data:r,width:A,height:n,transform:o}=i,s=this.cachedCanvases.getCanvas("maskCanvas",A,n),f=s.context;f.save();Ub(f,this.getObject(r,i)),f.globalCompositeOperation="source-in",f.fillStyle=t?a.getPattern(f,this,Eu(e),Wb):a,f.fillRect(0,0,A,n),f.restore(),e.save(),e.transform(...o),e.scale(1,-1),Yb(e,s.canvas,0,0,A,n,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(r){if(!this.contentVisible)return;const e=this.getObject(r);e?this.paintInlineImageXObject(e):Nf("Dependent image isn't ready yet")}paintImageXObjectRepeat(r,e,a,t){if(!this.contentVisible)return;const i=this.getObject(r);if(!i)return void Nf("Dependent image isn't ready yet");const A=i.width,n=i.height,o=[];for(let r=0,i=t.length;r<i;r+=2)o.push({transform:[e,0,0,a,t[r],t[r+1]],x:0,y:0,w:A,h:n});this.paintInlineImageXObjectGroup(i,o)}applyTransferMapsToCanvas(r){return"none"!==this.current.transferMaps&&(r.filter=this.current.transferMaps,r.drawImage(r.canvas,0,0),r.filter="none"),r.canvas}applyTransferMapsToBitmap(r){if("none"===this.current.transferMaps)return r.bitmap;const{bitmap:e,width:a,height:t}=r,i=this.cachedCanvases.getCanvas("inlineImage",a,t),A=i.context;return A.filter=this.current.transferMaps,A.drawImage(e,0,0),A.filter="none",i.canvas}paintInlineImageXObject(r){if(!this.contentVisible)return;const e=r.width,a=r.height,t=this.ctx;if(this.save(),!Ds){const{filter:r}=t;"none"!==r&&""!==r&&(t.filter="none")}let i;if(t.scale(1/e,-1/a),r.bitmap)i=this.applyTransferMapsToBitmap(r);else if("function"==typeof HTMLElement&&r instanceof HTMLElement||!r.data)i=r;else{const t=this.cachedCanvases.getCanvas("inlineImage",e,a).context;Qb(t,r),i=this.applyTransferMapsToCanvas(t)}const A=this._scaleImage(i,Eu(t));t.imageSmoothingEnabled=qb(yu(t),r.interpolate),Yb(t,A.img,0,0,A.paintWidth,A.paintHeight,0,-a,e,a),this.compose(),this.restore()}paintInlineImageXObjectGroup(r,e){if(!this.contentVisible)return;const a=this.ctx;let t;if(r.bitmap)t=r.bitmap;else{const e=r.width,a=r.height,i=this.cachedCanvases.getCanvas("inlineImage",e,a).context;Qb(i,r),t=this.applyTransferMapsToCanvas(i)}for(const r of e)a.save(),a.transform(...r.transform),a.scale(1,-1),Yb(a,t,r.x,r.y,r.w,r.h,0,-1,1,1),a.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(r){}markPointProps(r,e){}beginMarkedContent(r){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(r,e){"OC"===r?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(r){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(r);const a=this.ctx;this.pendingClip&&(e||(this.pendingClip===eg?a.clip("evenodd"):a.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),a.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const r=yu(this.ctx);if(0===r[1]&&0===r[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(r[0]),Math.abs(r[3]));else{const e=Math.abs(r[0]*r[3]-r[2]*r[1]),a=Math.hypot(r[0],r[2]),t=Math.hypot(r[1],r[3]);this._cachedGetSinglePixelWidth=Math.max(a,t)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:r}=this.current,{a:e,b:a,c:t,d:i}=this.ctx.getTransform();let A,n;if(0===a&&0===t){const a=Math.abs(e),t=Math.abs(i);if(a===t)if(0===r)A=n=1/a;else{const e=a*r;A=n=e<1?1/e:1}else if(0===r)A=1/a,n=1/t;else{const e=a*r,i=t*r;A=e<1?1/e:1,n=i<1?1/i:1}}else{const o=Math.abs(e*i-a*t),s=Math.hypot(e,a),f=Math.hypot(t,i);if(0===r)A=f/o,n=s/o;else{const e=r*o;A=f>e?f/e:1,n=s>e?s/e:1}}this._cachedScaleForStroking[0]=A,this._cachedScaleForStroking[1]=n}return this._cachedScaleForStroking}rescaleAndStroke(r){const{ctx:e}=this,{lineWidth:a}=this.current,[t,i]=this.getScaleForStroking();if(e.lineWidth=a||1,1===t&&1===i)return void e.stroke();const A=e.getLineDash();if(r&&e.save(),e.scale(t,i),A.length>0){const r=Math.max(t,i);e.setLineDash(A.map((e=>e/r))),e.lineDashOffset/=r}e.stroke(),r&&e.restore()}isContentVisible(){for(let r=this.markedContentStack.length-1;r>=0;r--)if(!this.markedContentStack[r].visible)return!1;return!0}};let og=ng;ag=new WeakSet,tg=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();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)},ig=new WeakSet,Ag=function(){if(this.pageColors){const r=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==r){const e=this.ctx.filter;this.ctx.filter=r,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}};for(const r in xf)void 0!==og.prototype[r]&&(og.prototype[xf[r]]=og.prototype[r]);var sg,fg;class lg{static get workerPort(){return t(this,sg)}static set workerPort(r){if(!(typeof Worker<"u"&&r instanceof Worker)&&null!==r)throw new Error("Invalid `workerPort` type.");A(this,sg,r)}static get workerSrc(){return t(this,fg)}static set workerSrc(r){if("string"!=typeof r)throw new Error("Invalid `workerSrc` type.");A(this,fg,r)}}sg=new WeakMap,fg=new WeakMap,i(lg,sg,null),i(lg,fg,"");const ug=1,cg=2,dg=1,hg=2,bg=3,gg=4,pg=5,vg=6,mg=7,kg=8;function wg(r){switch(r instanceof Error||"object"==typeof r&&null!==r||Df('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),r.name){case"AbortException":return new zf(r.message);case"MissingPDFException":return new Qf(r.message);case"PasswordException":return new Of(r.message,r.code);case"UnexpectedResponseException":return new Uf(r.message,r.status);case"UnknownErrorException":return new Yf(r.message,r.details);default:return new Yf(r.message,r.toString())}}var yg,Eg,Cg,Bg,_g,Zg,Wg,Ig;class Rg{constructor(r,e,a){i(this,yg),i(this,Cg),i(this,_g),this.sourceName=r,this.targetName=e,this.comObj=a,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),this._onComObjOnMessage=r=>{const e=r.data;if(e.targetName!==this.sourceName)return;if(e.stream)return void o(this,Cg,Bg).call(this,e);if(e.callback){const r=e.callbackId,a=this.callbackCapabilities[r];if(!a)throw new Error(`Cannot resolve callback ${r}`);if(delete this.callbackCapabilities[r],e.callback===ug)a.resolve(e.data);else{if(e.callback!==cg)throw new Error("Unexpected callback case");a.reject(wg(e.reason))}return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const r=this.sourceName,i=e.sourceName;new Promise((function(r){r(t(e.data))})).then((function(t){a.postMessage({sourceName:r,targetName:i,callback:ug,callbackId:e.callbackId,data:t})}),(function(t){a.postMessage({sourceName:r,targetName:i,callback:cg,callbackId:e.callbackId,reason:wg(t)})}))}else e.streamId?o(this,yg,Eg).call(this,e):t(e.data)},a.addEventListener("message",this._onComObjOnMessage)}on(r,e){const a=this.actionHandler;if(a[r])throw new Error(`There is already an actionName called "${r}"`);a[r]=e}send(r,e,a){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:r,data:e},a)}sendWithPromise(r,e,a){const t=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[t]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:r,callbackId:t,data:e},a)}catch(r){i.reject(r)}return i.promise}sendWithStream(r,e,a,t){const i=this.streamId++,A=this.sourceName,n=this.targetName,o=this.comObj;return new ReadableStream({start:a=>{const s=Promise.withResolvers();return this.streamControllers[i]={controller:a,startCall:s,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:A,targetName:n,action:r,streamId:i,data:e,desiredSize:a.desiredSize},t),s.promise},pull:r=>{const e=Promise.withResolvers();return this.streamControllers[i].pullCall=e,o.postMessage({sourceName:A,targetName:n,stream:vg,streamId:i,desiredSize:r.desiredSize}),e.promise},cancel:r=>{Tf(r instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[i].cancelCall=e,this.streamControllers[i].isClosed=!0,o.postMessage({sourceName:A,targetName:n,stream:dg,streamId:i,reason:wg(r)}),e.promise}},a)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}yg=new WeakSet,Eg=function(r){const e=r.streamId,a=this.sourceName,t=r.sourceName,i=this.comObj,A=this,n=this.actionHandler[r.action],o={enqueue(r,A=1,n){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=A,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:a,targetName:t,stream:gg,streamId:e,chunk:r},n)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:a,targetName:t,stream:bg,streamId:e}),delete A.streamSinks[e])},error(r){Tf(r instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:a,targetName:t,stream:pg,streamId:e,reason:wg(r)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:r.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise((function(e){e(n(r.data,o))})).then((function(){i.postMessage({sourceName:a,targetName:t,stream:kg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:kg,streamId:e,reason:wg(r)})}))},Cg=new WeakSet,Bg=function(r){const e=r.streamId,a=this.sourceName,t=r.sourceName,i=this.comObj,A=this.streamControllers[e],n=this.streamSinks[e];switch(r.stream){case kg:r.success?A.startCall.resolve():A.startCall.reject(wg(r.reason));break;case mg:r.success?A.pullCall.resolve():A.pullCall.reject(wg(r.reason));break;case vg:if(!n){i.postMessage({sourceName:a,targetName:t,stream:mg,streamId:e,success:!0});break}n.desiredSize<=0&&r.desiredSize>0&&n.sinkCapability.resolve(),n.desiredSize=r.desiredSize,new Promise((function(r){var e;r(null==(e=n.onPull)?void 0:e.call(n))})).then((function(){i.postMessage({sourceName:a,targetName:t,stream:mg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:mg,streamId:e,reason:wg(r)})}));break;case gg:if(Tf(A,"enqueue should have stream controller"),A.isClosed)break;A.controller.enqueue(r.chunk);break;case bg:if(Tf(A,"close should have stream controller"),A.isClosed)break;A.isClosed=!0,A.controller.close(),o(this,_g,Zg).call(this,A,e);break;case pg:Tf(A,"error should have stream controller"),A.controller.error(wg(r.reason)),o(this,_g,Zg).call(this,A,e);break;case hg:r.success?A.cancelCall.resolve():A.cancelCall.reject(wg(r.reason)),o(this,_g,Zg).call(this,A,e);break;case dg:if(!n)break;new Promise((function(e){var a;e(null==(a=n.onCancel)?void 0:a.call(n,wg(r.reason)))})).then((function(){i.postMessage({sourceName:a,targetName:t,stream:hg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:hg,streamId:e,reason:wg(r)})})),n.sinkCapability.reject(wg(r.reason)),n.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},_g=new WeakSet,Zg=async function(r,e){var a,t,i;await Promise.allSettled([null==(a=r.startCall)?void 0:a.promise,null==(t=r.pullCall)?void 0:t.promise,null==(i=r.cancelCall)?void 0:i.promise]),delete this.streamControllers[e]};class Fg{constructor({parsedData:r,rawData:e}){i(this,Wg,void 0),i(this,Ig,void 0),A(this,Wg,r),A(this,Ig,e)}getRaw(){return t(this,Ig)}get(r){return t(this,Wg).get(r)??null}getAll(){return Kf(t(this,Wg))}has(r){return t(this,Wg).has(r)}}Wg=new WeakMap,Ig=new WeakMap;const Sg=Symbol("INTERNAL");var xg,Mg,Gg,Xg,Vg,Ng,Dg,Tg,Pg,jg;class Lg{constructor(r,{name:e,intent:a,usage:t}){i(this,xg,!1),i(this,Mg,!1),i(this,Gg,!1),i(this,Xg,!0),A(this,xg,!!(r&Os)),A(this,Mg,!!(r&Ys)),this.name=e,this.intent=a,this.usage=t}get visible(){if(t(this,Gg))return t(this,Xg);if(!t(this,Xg))return!1;const{print:r,view:e}=this.usage;return t(this,xg)?"OFF"!==(null==e?void 0:e.viewState):!t(this,Mg)||"OFF"!==(null==r?void 0:r.printState)}_setVisible(r,e,a=!1){r!==Sg&&Df("Internal method `_setVisible` called."),A(this,Gg,a),A(this,Xg,e)}}xg=new WeakMap,Mg=new WeakMap,Gg=new WeakMap,Xg=new WeakMap;class Og{constructor(r,e=Os){if(i(this,Pg),i(this,Vg,null),i(this,Ng,new Map),i(this,Dg,null),i(this,Tg,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==r){this.name=r.name,this.creator=r.creator,A(this,Tg,r.order);for(const a of r.groups)t(this,Ng).set(a.id,new Lg(e,a));if("OFF"===r.baseState)for(const r of t(this,Ng).values())r._setVisible(Sg,!1);for(const e of r.on)t(this,Ng).get(e)._setVisible(Sg,!0);for(const e of r.off)t(this,Ng).get(e)._setVisible(Sg,!1);A(this,Dg,this.getHash())}}isVisible(r){if(0===t(this,Ng).size)return!0;if(!r)return Vf("Optional content group not defined."),!0;if("OCG"===r.type)return t(this,Ng).has(r.id)?t(this,Ng).get(r.id).visible:(Nf(`Optional content group not found: ${r.id}`),!0);if("OCMD"===r.type){if(r.expression)return o(this,Pg,jg).call(this,r.expression);if(!r.policy||"AnyOn"===r.policy){for(const e of r.ids){if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;if(t(this,Ng).get(e).visible)return!0}return!1}if("AllOn"===r.policy){for(const e of r.ids){if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;if(!t(this,Ng).get(e).visible)return!1}return!0}if("AnyOff"===r.policy){for(const e of r.ids){if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;if(!t(this,Ng).get(e).visible)return!0}return!1}if("AllOff"===r.policy){for(const e of r.ids){if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;if(t(this,Ng).get(e).visible)return!1}return!0}return Nf(`Unknown optional content policy ${r.policy}.`),!0}return Nf(`Unknown group type ${r.type}.`),!0}setVisibility(r,e=!0){const a=t(this,Ng).get(r);a?(a._setVisible(Sg,!!e,!0),A(this,Vg,null)):Nf(`Optional content group not found: ${r}`)}setOCGState({state:r,preserveRB:e}){let a;for(const e of r){switch(e){case"ON":case"OFF":case"Toggle":a=e;continue}const r=t(this,Ng).get(e);if(r)switch(a){case"ON":r._setVisible(Sg,!0);break;case"OFF":r._setVisible(Sg,!1);break;case"Toggle":r._setVisible(Sg,!r.visible)}}A(this,Vg,null)}get hasInitialVisibility(){return null===t(this,Dg)||this.getHash()===t(this,Dg)}getOrder(){return t(this,Ng).size?t(this,Tg)?t(this,Tg).slice():[...t(this,Ng).keys()]:null}getGroups(){return t(this,Ng).size>0?Kf(t(this,Ng)):null}getGroup(r){return t(this,Ng).get(r)||null}getHash(){if(null!==t(this,Vg))return t(this,Vg);const r=new cb;for(const[e,a]of t(this,Ng))r.update(`${e}:${a.visible}`);return A(this,Vg,r.hexdigest())}}Vg=new WeakMap,Ng=new WeakMap,Dg=new WeakMap,Tg=new WeakMap,Pg=new WeakSet,jg=function(r){const e=r.length;if(e<2)return!0;const a=r[0];for(let i=1;i<e;i++){const e=r[i];let A;if(Array.isArray(e))A=o(this,Pg,jg).call(this,e);else{if(!t(this,Ng).has(e))return Nf(`Optional content group not found: ${e}`),!0;A=t(this,Ng).get(e).visible}switch(a){case"And":if(!A)return!1;break;case"Or":if(A)return!0;break;case"Not":return!A;default:return!0}}return"And"===a};class Yg{constructor(r,{disableRange:e=!1,disableStream:a=!1}){Tf(r,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:t,initialData:i,progressiveDone:A,contentDispositionFilename:n}=r;if(this._queuedChunks=[],this._progressiveDone=A,this._contentDispositionFilename=n,(null==i?void 0:i.length)>0){const r=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(r)}this._pdfDataRangeTransport=r,this._isStreamingSupported=!a,this._isRangeSupported=!e,this._contentLength=t,this._fullRequestReader=null,this._rangeReaders=[],r.addRangeListener(((r,e)=>{this._onReceiveData({begin:r,chunk:e})})),r.addProgressListener(((r,e)=>{this._onProgress({loaded:r,total:e})})),r.addProgressiveReadListener((r=>{this._onReceiveData({chunk:r})})),r.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),r.transportReady()}_onReceiveData({begin:r,chunk:e}){const a=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===r)this._fullRequestReader?this._fullRequestReader._enqueue(a):this._queuedChunks.push(a);else{Tf(this._rangeReaders.some((function(e){return e._begin===r&&(e._enqueue(a),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var r;return(null==(r=this._fullRequestReader)?void 0:r._loaded)??0}_onProgress(r){var e,a,t,i;void 0===r.total?null==(a=null==(e=this._rangeReaders[0])?void 0:e.onProgress)||a.call(e,{loaded:r.loaded}):null==(i=null==(t=this._fullRequestReader)?void 0:t.onProgress)||i.call(t,{loaded:r.loaded,total:r.total})}_onProgressiveDone(){var r;null==(r=this._fullRequestReader)||r.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(r){const e=this._rangeReaders.indexOf(r);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Tf(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const r=this._queuedChunks;return this._queuedChunks=null,new Hg(this,r,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=new Qg(this,r,e);return this._pdfDataRangeTransport.requestDataRange(r,e),this._rangeReaders.push(a),a}cancelAllRequests(r){var e;null==(e=this._fullRequestReader)||e.cancel(r);for(const e of this._rangeReaders.slice(0))e.cancel(r);this._pdfDataRangeTransport.abort()}}class Hg{constructor(r,e,a=!1,t=null){this._stream=r,this._done=a||!1,this._filename=uu(t)?t:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),r._fullRequestReader=this,this.onProgress=null}_enqueue(r){this._done||(this._requests.length>0?this._requests.shift().resolve({value:r,done:!1}):this._queuedChunks.push(r),this._loaded+=r.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const r=Promise.withResolvers();return this._requests.push(r),r.promise}cancel(r){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Qg{constructor(r,e,a){this._stream=r,this._begin=e,this._end=a,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(r){if(!this._done){if(0===this._requests.length)this._queuedChunk=r;else{this._requests.shift().resolve({value:r,done:!1});for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const r=Promise.withResolvers();return this._requests.push(r),r.promise}cancel(r){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ug({getResponseHeader:r,isHttp:e,rangeChunkSize:a,disableRange:t}){const i={allowRangeRequests:!1,suggestedLength:void 0},A=parseInt(r("Content-Length"),10);return!Number.isInteger(A)||(i.suggestedLength=A,A<=2*a)||t||!e||"bytes"!==r("Accept-Ranges")||"identity"!==(r("Content-Encoding")||"identity")||(i.allowRangeRequests=!0),i}function Jg(r){const e=r("Content-Disposition");if(e){let r=function(r){let e=!0,a=t("filename\\*","i").exec(r);if(a){a=a[1];let r=n(a);return r=unescape(r),r=o(r),r=s(r),A(r)}if(a=function(r){const e=[];let a;const i=t("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(a=i.exec(r));){let[,r,t,i]=a;if(r=parseInt(r,10),r in e){if(0===r)break}else e[r]=[t,i]}const A=[];for(let r=0;r<e.length&&r in e;++r){let[a,t]=e[r];t=n(t),a&&(t=unescape(t),0===r&&(t=o(t))),A.push(t)}return A.join("")}(r),a)return A(s(a));if(a=t("filename","i").exec(r),a){a=a[1];let r=n(a);return r=s(r),A(r)}function t(r,e){return new RegExp("(?:^|;)\\s*"+r+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function i(r,a){if(r){if(!/^[\x00-\xFF]+$/.test(a))return a;try{const t=new TextDecoder(r,{fatal:!0}),i=$f(a);a=t.decode(i),e=!1}catch{}}return a}function A(r){return e&&/[\x80-\xff]/.test(r)&&(r=i("utf-8",r),e&&(r=i("iso-8859-1",r))),r}function n(r){if(r.startsWith('"')){const e=r.slice(1).split('\\"');for(let r=0;r<e.length;++r){const a=e[r].indexOf('"');-1!==a&&(e[r]=e[r].slice(0,a),e.length=r+1),e[r]=e[r].replaceAll(/\\(.)/g,"$1")}r=e.join('"')}return r}function o(r){const e=r.indexOf("'");return-1===e?r:i(r.slice(0,e),r.slice(e+1).replace(/^[^']*'/,""))}function s(r){return!r.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(r)?r:r.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(r,e,a,t){if("q"===a||"Q"===a)return i(e,t=(t=t.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(r,e){return String.fromCharCode(parseInt(e,16))})));try{t=atob(t)}catch{}return i(e,t)}))}return""}(e);if(r.includes("%"))try{r=decodeURIComponent(r)}catch{}if(uu(r))return r}return null}function zg(r,e){return 404===r||0===r&&e.startsWith("file:")?new Qf('Missing PDF "'+e+'".'):new Uf(`Unexpected server response (${r}) while retrieving PDF "${e}".`,r)}function qg(r){return 200===r||206===r}function $g(r,e,a){return{method:"GET",headers:r,signal:a.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Kg(r){const e=new Headers;for(const a in r){const t=r[a];void 0!==t&&e.append(a,t)}return e}function rp(r){return r instanceof Uint8Array?r.buffer:r instanceof ArrayBuffer?r:(Nf(`getArrayBuffer - unexpected data format: ${r}`),new Uint8Array(r).buffer)}class ep{constructor(r){this.source=r,this.isHttp=/^https?:/i.test(r.url),this.httpHeaders=this.isHttp&&r.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var r;return(null==(r=this._fullRequestReader)?void 0:r._loaded)??0}getFullReader(){return Tf(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ap(this),this._fullRequestReader}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=new tp(this,r,e);return this._rangeRequestReaders.push(a),a}cancelAllRequests(r){var e;null==(e=this._fullRequestReader)||e.cancel(r);for(const e of this._rangeRequestReaders.slice(0))e.cancel(r)}}class ap{constructor(r){this._stream=r,this._reader=null,this._loaded=0,this._filename=null;const e=r.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,this._headers=Kg(this._stream.httpHeaders);const a=e.url;fetch(a,$g(this._headers,this._withCredentials,this._abortController)).then((r=>{if(!qg(r.status))throw zg(r.status,a);this._reader=r.body.getReader(),this._headersCapability.resolve();const e=e=>r.headers.get(e),{allowRangeRequests:t,suggestedLength:i}=Ug({getResponseHeader:e,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t,this._contentLength=i||this._contentLength,this._filename=Jg(e),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new zf("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._headersCapability.promise;const{value:e,done:a}=await this._reader.read();return a?{value:e,done:a}:(this._loaded+=e.byteLength,null==(r=this.onProgress)||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:rp(e),done:!1})}cancel(r){var e;null==(e=this._reader)||e.cancel(r),this._abortController.abort()}}class tp{constructor(r,e,a){this._stream=r,this._reader=null,this._loaded=0;const t=r.source;this._withCredentials=t.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!t.disableStream,this._abortController=new AbortController,this._headers=Kg(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${a-1}`);const i=t.url;fetch(i,$g(this._headers,this._withCredentials,this._abortController)).then((r=>{if(!qg(r.status))throw zg(r.status,i);this._readCapability.resolve(),this._reader=r.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._readCapability.promise;const{value:e,done:a}=await this._reader.read();return a?{value:e,done:a}:(this._loaded+=e.byteLength,null==(r=this.onProgress)||r.call(this,{loaded:this._loaded}),{value:rp(e),done:!1})}cancel(r){var e;null==(e=this._reader)||e.cancel(r),this._abortController.abort()}}class ip{constructor(r,e={}){this.url=r,this.isHttp=/^https?:/i.test(r),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(r,e,a){const t={begin:r,end:e};for(const r in a)t[r]=a[r];return this.request(t)}requestFull(r){return this.request(r)}request(r){const e=new XMLHttpRequest,a=this.currXhrId++,t=this.pendingRequests[a]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const r in this.httpHeaders){const a=this.httpHeaders[r];void 0!==a&&e.setRequestHeader(r,a)}return this.isHttp&&"begin"in r&&"end"in r?(e.setRequestHeader("Range",`bytes=${r.begin}-${r.end-1}`),t.expectedStatus=206):t.expectedStatus=200,e.responseType="arraybuffer",r.onError&&(e.onerror=function(a){r.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,a),e.onprogress=this.onProgress.bind(this,a),t.onHeadersReceived=r.onHeadersReceived,t.onDone=r.onDone,t.onError=r.onError,t.onProgress=r.onProgress,e.send(null),a}onProgress(r,e){var a;const t=this.pendingRequests[r];t&&(null==(a=t.onProgress)||a.call(t,e))}onStateChange(r,e){var a,t,i;const A=this.pendingRequests[r];if(!A)return;const n=A.xhr;if(n.readyState>=2&&A.onHeadersReceived&&(A.onHeadersReceived(),delete A.onHeadersReceived),4!==n.readyState||!(r in this.pendingRequests))return;if(delete this.pendingRequests[r],0===n.status&&this.isHttp)return void(null==(a=A.onError)||a.call(A,n.status));const o=n.status||200;if((200!==o||206!==A.expectedStatus)&&o!==A.expectedStatus)return void(null==(t=A.onError)||t.call(A,n.status));const s=function(r){const e=r.response;return"string"!=typeof e?e:$f(e).buffer}(n);if(206===o){const r=n.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(r);A.onDone({begin:parseInt(e[1],10),chunk:s})}else s?A.onDone({begin:0,chunk:s}):null==(i=A.onError)||i.call(A,n.status)}getRequestXhr(r){return this.pendingRequests[r].xhr}isPendingRequest(r){return r in this.pendingRequests}abortRequest(r){const e=this.pendingRequests[r].xhr;delete this.pendingRequests[r],e.abort()}}class Ap{constructor(r){this._source=r,this._manager=new ip(r.url,{httpHeaders:r.httpHeaders,withCredentials:r.withCredentials}),this._rangeChunkSize=r.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(r){const e=this._rangeRequestReaders.indexOf(r);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Tf(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new np(this._manager,this._source),this._fullRequestReader}getRangeReader(r,e){const a=new op(this._manager,r,e);return a.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(a),a}cancelAllRequests(r){var e;null==(e=this._fullRequestReader)||e.cancel(r);for(const e of this._rangeRequestReaders.slice(0))e.cancel(r)}}class np{constructor(r,e){this._manager=r;const a={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=r.requestFull(a),this._headersReceivedCapability=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 r=this._fullRequestId,e=this._manager.getRequestXhr(r),a=r=>e.getResponseHeader(r),{allowRangeRequests:t,suggestedLength:i}=Ug({getResponseHeader:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});t&&(this._isRangeSupported=!0),this._contentLength=i||this._contentLength,this._filename=Jg(a),this._isRangeSupported&&this._manager.abortRequest(r),this._headersReceivedCapability.resolve()}_onDone(r){if(r&&(this._requests.length>0?this._requests.shift().resolve({value:r.chunk,done:!1}):this._cachedChunks.push(r.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(r){this._storedError=zg(r,this._url),this._headersReceivedCapability.reject(this._storedError);for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(r){var e;null==(e=this.onProgress)||e.call(this,{loaded:r.loaded,total:r.lengthComputable?r.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._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const r=Promise.withResolvers();return this._requests.push(r),r.promise}cancel(r){this._done=!0,this._headersReceivedCapability.reject(r);for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class op{constructor(r,e,a){this._manager=r;const t={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=r.url,this._requestId=r.requestRange(e,a,t),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var r;null==(r=this.onClosed)||r.call(this,this)}_onDone(r){const e=r.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(r){this._storedError=zg(r,this._url);for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(r){var e;this.isStreamingSupported||null==(e=this.onProgress)||e.call(this,{loaded:r.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const r=Promise.withResolvers();return this._requests.push(r),r.promise}cancel(r){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const sp=/^file:\/\/\/[a-zA-Z]:\//;class fp{constructor(r){this.source=r,this.url=function(r){const e=_b.get("url"),a=e.parse(r);return"file:"===a.protocol||a.host?a:/^[a-z]:[/\\]/i.test(r)?e.parse(`file:///${r}`):(a.host||(a.protocol="file:"),a)}(r.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&r.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var r;return(null==(r=this._fullRequestReader)?void 0:r._loaded)??0}getFullReader(){return Tf(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new bp(this):new dp(this),this._fullRequestReader}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=this.isFsUrl?new gp(this,r,e):new hp(this,r,e);return this._rangeRequestReaders.push(a),a}cancelAllRequests(r){var e;null==(e=this._fullRequestReader)||e.cancel(r);for(const e of this._rangeRequestReaders.slice(0))e.cancel(r)}}class lp{constructor(r){this._url=r.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=r.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,null==(r=this.onProgress)||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(r){this._readableStream?this._readableStream.destroy(r):this._error(r)}_error(r){this._storedError=r,this._readCapability.resolve()}_setReadableStream(r){this._readableStream=r,r.on("readable",(()=>{this._readCapability.resolve()})),r.on("end",(()=>{r.destroy(),this._done=!0,this._readCapability.resolve()})),r.on("error",(r=>{this._error(r)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new zf("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class up{constructor(r){this._url=r.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=r.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,null==(r=this.onProgress)||r.call(this,{loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(r){this._readableStream?this._readableStream.destroy(r):this._error(r)}_error(r){this._storedError=r,this._readCapability.resolve()}_setReadableStream(r){this._readableStream=r,r.on("readable",(()=>{this._readCapability.resolve()})),r.on("end",(()=>{r.destroy(),this._done=!0,this._readCapability.resolve()})),r.on("error",(r=>{this._error(r)})),this._storedError&&this._readableStream.destroy(this._storedError)}}function cp(r,e){return{protocol:r.protocol,auth:r.auth,host:r.hostname,port:r.port,path:r.path,method:"GET",headers:e}}class dp extends lp{constructor(r){super(r);const e=e=>{if(404===e.statusCode){const r=new Qf(`Missing PDF "${this._url}".`);return this._storedError=r,void this._headersCapability.reject(r)}this._headersCapability.resolve(),this._setReadableStream(e);const a=r=>this._readableStream.headers[r.toLowerCase()],{allowRangeRequests:t,suggestedLength:i}=Ug({getResponseHeader:a,isHttp:r.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t,this._contentLength=i||this._contentLength,this._filename=Jg(a)};if(this._request=null,"http:"===this._url.protocol){const a=_b.get("http");this._request=a.request(cp(this._url,r.httpHeaders),e)}else{const a=_b.get("https");this._request=a.request(cp(this._url,r.httpHeaders),e)}this._request.on("error",(r=>{this._storedError=r,this._headersCapability.reject(r)})),this._request.end()}}class hp extends up{constructor(r,e,a){super(r),this._httpHeaders={};for(const e in r.httpHeaders){const a=r.httpHeaders[e];void 0!==a&&(this._httpHeaders[e]=a)}this._httpHeaders.Range=`bytes=${e}-${a-1}`;const t=r=>{if(404!==r.statusCode)this._setReadableStream(r);else{const r=new Qf(`Missing PDF "${this._url}".`);this._storedError=r}};if(this._request=null,"http:"===this._url.protocol){const r=_b.get("http");this._request=r.request(cp(this._url,this._httpHeaders),t)}else{const r=_b.get("https");this._request=r.request(cp(this._url,this._httpHeaders),t)}this._request.on("error",(r=>{this._storedError=r})),this._request.end()}}class bp extends lp{constructor(r){super(r);let e=decodeURIComponent(this._url.path);sp.test(this._url.href)&&(e=e.replace(/^\//,""));const a=_b.get("fs");a.promises.lstat(e).then((r=>{this._contentLength=r.size,this._setReadableStream(a.createReadStream(e)),this._headersCapability.resolve()}),(r=>{"ENOENT"===r.code&&(r=new Qf(`Missing PDF "${e}".`)),this._storedError=r,this._headersCapability.reject(r)}))}}class gp extends up{constructor(r,e,a){super(r);let t=decodeURIComponent(this._url.path);sp.test(this._url.href)&&(t=t.replace(/^\//,""));const i=_b.get("fs");this._setReadableStream(i.createReadStream(t,{start:e,end:a-1}))}}const pp=30;var vp,mp,kp,wp,yp,Ep,Cp,Bp,_p,Zp,Wp,Ip,Rp,Fp,Sp,xp,Mp,Gp,Xp,Vp,Np,Dp,Tp,Pp,jp,Lp,Op,Yp,Hp,Qp,Up,Jp,zp,qp,$p,Kp;let rv=(Vp=class{constructor({textContentSource:r,container:e,viewport:a}){var n;if(i(this,jp),i(this,Op),i(this,Hp),i(this,mp,Promise.withResolvers()),i(this,kp,null),i(this,wp,!1),i(this,yp,!(null==(vp=globalThis.FontInspector)||!vp.enabled)),i(this,Ep,null),i(this,Cp,null),i(this,Bp,0),i(this,_p,0),i(this,Zp,null),i(this,Wp,null),i(this,Ip,0),i(this,Rp,0),i(this,Fp,Object.create(null)),i(this,Sp,[]),i(this,xp,null),i(this,Mp,[]),i(this,Gp,new WeakMap),i(this,Xp,null),r instanceof ReadableStream)A(this,xp,r);else{if("object"!=typeof r)throw new Error('No "textContentSource" parameter specified.');A(this,xp,new ReadableStream({start(e){e.enqueue(r),e.close()}}))}A(this,kp,A(this,Wp,e)),A(this,Rp,a.scale*(globalThis.devicePixelRatio||1)),A(this,Ip,a.rotation),A(this,Cp,{prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null});const{pageWidth:s,pageHeight:f,pageX:l,pageY:u}=a.rawDims;A(this,Xp,[1,0,0,-1,-l,u+f]),A(this,_p,s),A(this,Bp,f),o(n=Vp,zp,qp).call(n),Cu(e,a),t(this,mp).promise.catch((()=>{})).then((()=>{t(Vp,Pp).delete(this),A(this,Cp,null),A(this,Fp,null)}))}render(){const r=()=>{t(this,Zp).read().then((({value:e,done:a})=>{a?t(this,mp).resolve():(t(this,Ep)??A(this,Ep,e.lang),Object.assign(t(this,Fp),e.styles),o(this,jp,Lp).call(this,e.items),r())}),t(this,mp).reject)};return A(this,Zp,t(this,xp).getReader()),t(Vp,Pp).add(this),r(),t(this,mp).promise}update({viewport:r,onBefore:e=null}){var a;const i=r.scale*(globalThis.devicePixelRatio||1),n=r.rotation;if(n!==t(this,Ip)&&(null==e||e(),A(this,Ip,n),Cu(t(this,Wp),{rotation:n})),i!==t(this,Rp)){null==e||e(),A(this,Rp,i);const r={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:o(a=Vp,Up,Jp).call(a,t(this,Ep))};for(const e of t(this,Mp))r.properties=t(this,Gp).get(e),r.div=e,o(this,Hp,Qp).call(this,r)}}cancel(){var r;const e=new zf("TextLayer task cancelled.");null==(r=t(this,Zp))||r.cancel(e).catch((()=>{})),A(this,Zp,null),t(this,mp).reject(e)}get textDivs(){return t(this,Mp)}get textContentItemsStr(){return t(this,Sp)}static cleanup(){if(!(t(this,Pp).size>0)){t(this,Np).clear();for(const{canvas:r}of t(this,Dp).values())r.remove();t(this,Dp).clear()}}},mp=new WeakMap,kp=new WeakMap,wp=new WeakMap,yp=new WeakMap,Ep=new WeakMap,Cp=new WeakMap,Bp=new WeakMap,_p=new WeakMap,Zp=new WeakMap,Wp=new WeakMap,Ip=new WeakMap,Rp=new WeakMap,Fp=new WeakMap,Sp=new WeakMap,xp=new WeakMap,Mp=new WeakMap,Gp=new WeakMap,Xp=new WeakMap,Np=new WeakMap,Dp=new WeakMap,Tp=new WeakMap,Pp=new WeakMap,jp=new WeakSet,Lp=function(r){var e,a;if(t(this,wp))return;(a=t(this,Cp)).ctx??(a.ctx=o(e=Vp,Up,Jp).call(e,t(this,Ep)));const i=t(this,Mp),n=t(this,Sp);for(const e of r){if(i.length>1e5)return Nf("Ignoring additional textDivs for performance reasons."),void A(this,wp,!0);if(void 0!==e.str)n.push(e.str),o(this,Op,Yp).call(this,e);else if("beginMarkedContentProps"===e.type||"beginMarkedContent"===e.type){const r=t(this,kp);A(this,kp,document.createElement("span")),t(this,kp).classList.add("markedContent"),null!==e.id&&t(this,kp).setAttribute("id",`${e.id}`),r.append(t(this,kp))}else"endMarkedContent"===e.type&&A(this,kp,t(this,kp).parentNode)}},Op=new WeakSet,Yp=function(r){var e;const a=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==r.str,hasEOL:r.hasEOL,fontSize:0};t(this,Mp).push(a);const A=nl.transform(t(this,Xp),r.transform);let n=Math.atan2(A[1],A[0]);const s=t(this,Fp)[r.fontName];s.vertical&&(n+=Math.PI/2);const f=t(this,yp)&&s.fontSubstitution||s.fontFamily,l=Math.hypot(A[2],A[3]),u=l*o(e=Vp,$p,Kp).call(e,f,t(this,Ep));let c,d;0===n?(c=A[4],d=A[5]-u):(c=A[4]+u*Math.sin(n),d=A[5]-u*Math.cos(n));const h="calc(var(--scale-factor)*",b=a.style;t(this,kp)===t(this,Wp)?(b.left=`${(100*c/t(this,_p)).toFixed(2)}%`,b.top=`${(100*d/t(this,Bp)).toFixed(2)}%`):(b.left=`${h}${c.toFixed(2)}px)`,b.top=`${h}${d.toFixed(2)}px)`),b.fontSize=`${h}${(t(Vp,Tp)*l).toFixed(2)}px)`,b.fontFamily=f,i.fontSize=l,a.setAttribute("role","presentation"),a.textContent=r.str,a.dir=r.dir,t(this,yp)&&(a.dataset.fontName=s.fontSubstitutionLoadedName||r.fontName),0!==n&&(i.angle=n*(180/Math.PI));let g=!1;if(r.str.length>1)g=!0;else if(" "!==r.str&&r.transform[0]!==r.transform[3]){const e=Math.abs(r.transform[0]),a=Math.abs(r.transform[3]);e!==a&&Math.max(e,a)/Math.min(e,a)>1.5&&(g=!0)}if(g&&(i.canvasWidth=s.vertical?r.height:r.width),t(this,Gp).set(a,i),t(this,Cp).div=a,t(this,Cp).properties=i,o(this,Hp,Qp).call(this,t(this,Cp)),i.hasText&&t(this,kp).append(a),i.hasEOL){const r=document.createElement("br");r.setAttribute("role","presentation"),t(this,kp).append(r)}},Hp=new WeakSet,Qp=function(r){const{div:e,properties:a,ctx:i,prevFontSize:A,prevFontFamily:n}=r,{style:o}=e;let s="";if(t(Vp,Tp)>1&&(s=`scale(${1/t(Vp,Tp)})`),0!==a.canvasWidth&&a.hasText){const{fontFamily:f}=o,{canvasWidth:l,fontSize:u}=a;(A!==u||n!==f)&&(i.font=`${u*t(this,Rp)}px ${f}`,r.prevFontSize=u,r.prevFontFamily=f);const{width:c}=i.measureText(e.textContent);c>0&&(s=`scaleX(${l*t(this,Rp)/c}) ${s}`)}0!==a.angle&&(s=`rotate(${a.angle}deg) ${s}`),s.length>0&&(o.transform=s)},Up=new WeakSet,Jp=function(r=null){let e=t(this,Dp).get(r||(r=""));if(!e){const a=document.createElement("canvas");a.className="hiddenCanvasElement",a.lang=r,document.body.append(a),e=a.getContext("2d",{alpha:!1,willReadFrequently:!0}),t(this,Dp).set(r,e)}return e},zp=new WeakSet,qp=function(){if(null!==t(this,Tp))return;const r=document.createElement("div");r.style.opacity=0,r.style.lineHeight=1,r.style.fontSize="1px",r.textContent="X",document.body.append(r),A(this,Tp,r.getBoundingClientRect().height),r.remove()},$p=new WeakSet,Kp=function(r,e){const a=t(this,Np).get(r);if(a)return a;const i=o(this,Up,Jp).call(this,e),A=i.font;i.canvas.width=i.canvas.height=pp,i.font=`30px ${r}`;const n=i.measureText("");let s=n.fontBoundingBoxAscent,f=Math.abs(n.fontBoundingBoxDescent);if(s){const e=s/(s+f);return t(this,Np).set(r,e),i.canvas.width=i.canvas.height=0,i.font=A,e}i.strokeStyle="red",i.clearRect(0,0,pp,pp),i.strokeText("g",0,0);let l=i.getImageData(0,0,pp,pp).data;f=0;for(let r=l.length-1-3;r>=0;r-=4)if(l[r]>0){f=Math.ceil(r/4/pp);break}i.clearRect(0,0,pp,pp),i.strokeText("A",0,pp),l=i.getImageData(0,0,pp,pp).data,s=0;for(let r=0,e=l.length;r<e;r+=4)if(l[r]>0){s=pp-Math.floor(r/4/pp);break}i.canvas.width=i.canvas.height=0,i.font=A;const u=s?s/(s+f):.8;return t(this,Np).set(r,u),u},i(Vp,Up),i(Vp,zp),i(Vp,$p),i(Vp,Np,new Map),i(Vp,Dp,new Map),i(Vp,Tp,null),i(Vp,Pp,new Set),Vp);function ev(){pu("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:r,container:e,viewport:a,...t}=arguments[0],i=Object.keys(t);i.length>0&&Nf("Ignoring `renderTextLayer` parameters: "+i.join(", "));const A=new rv({textContentSource:r,container:e,viewport:a}),{textDivs:n,textContentItemsStr:o}=A;return{promise:A.render(),textDivs:n,textContentItemsStr:o}}function av(){pu("`updateTextLayer`, please use `TextLayer` instead.")}class tv{static textContent(r){const e=[],a={items:e,styles:Object.create(null)};return function r(a){var t;if(!a)return;let i=null;const A=a.name;if("#text"===A)i=a.value;else{if(!tv.shouldBuildText(A))return;null!=(t=null==a?void 0:a.attributes)&&t.textContent?i=a.attributes.textContent:a.value&&(i=a.value)}if(null!==i&&e.push({str:i}),a.children)for(const e of a.children)r(e)}(r),a}static shouldBuildText(r){return!("textarea"===r||"input"===r||"option"===r||"select"===r)}}const iv=65536,Av=Ds?class extends El{_createCanvas(r,e){return _b.get("canvas").createCanvas(r,e)}}:class extends El{constructor({ownerDocument:r=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=r}_createCanvas(r,e){const a=this._document.createElement("canvas");return a.width=r,a.height=e,a}},nv=Ds?class extends Cl{_fetchData(r,e){return Zb(r).then((r=>({cMapData:r,compressionType:e})))}}:Au,ov=Ds?class extends kl{}:class extends kl{constructor({docId:r,ownerDocument:e=globalThis.document}={}){super(),i(this,Xl),i(this,Nl),i(this,Tl),i(this,jl),i(this,Ol),i(this,Hl),i(this,Ul),i(this,zl),i(this,$l),i(this,ru),i(this,au),i(this,Rl,void 0),i(this,Fl,void 0),i(this,Sl,void 0),i(this,xl,void 0),i(this,Ml,void 0),i(this,Gl,0),A(this,Sl,r),A(this,xl,e)}addFilter(r){if(!r)return"none";let e=t(this,Xl,Vl).get(r);if(e)return e;const[a,i,A]=o(this,jl,Ll).call(this,r),s=1===r.length?a:`${a}${i}${A}`;if(e=t(this,Xl,Vl).get(s),e)return t(this,Xl,Vl).set(r,e),e;const f=`g_${t(this,Sl)}_transfer_map_${n(this,Gl)._++}`,l=`url(#${f})`;t(this,Xl,Vl).set(r,l),t(this,Xl,Vl).set(s,l);const u=o(this,Ul,Jl).call(this,f);return o(this,$l,Kl).call(this,a,i,A,u),l}addHCMFilter(r,e){var a;const i=`${r}-${e}`,A="base";let n=t(this,Nl,Dl).get(A);if((null==n?void 0:n.key)===i||(n?(null==(a=n.filter)||a.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},t(this,Nl,Dl).set(A,n)),!r||!e))return n.url;const s=o(this,au,tu).call(this,r);r=nl.makeHexColor(...s);const f=o(this,au,tu).call(this,e);if(e=nl.makeHexColor(...f),t(this,Tl,Pl).style.color="","#000000"===r&&"#ffffff"===e||r===e)return n.url;const l=new Array(256);for(let r=0;r<=255;r++){const e=r/255;l[r]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const u=l.join(","),c=`g_${t(this,Sl)}_hcm_filter`,d=n.filter=o(this,Ul,Jl).call(this,c);o(this,$l,Kl).call(this,u,u,u,d),o(this,Hl,Ql).call(this,d);const h=(r,e)=>{const a=s[r]/255,t=f[r]/255,i=new Array(e+1);for(let r=0;r<=e;r++)i[r]=a+r/e*(t-a);return i.join(",")};return o(this,$l,Kl).call(this,h(0,5),h(1,5),h(2,5),d),n.url=`url(#${c})`,n.url}addAlphaFilter(r){let e=t(this,Xl,Vl).get(r);if(e)return e;const[a]=o(this,jl,Ll).call(this,[r]),i=`alpha_${a}`;if(e=t(this,Xl,Vl).get(i),e)return t(this,Xl,Vl).set(r,e),e;const A=`g_${t(this,Sl)}_alpha_map_${n(this,Gl)._++}`,s=`url(#${A})`;t(this,Xl,Vl).set(r,s),t(this,Xl,Vl).set(i,s);const f=o(this,Ul,Jl).call(this,A);return o(this,ru,eu).call(this,a,f),s}addLuminosityFilter(r){let e,a,i=t(this,Xl,Vl).get(r||"luminosity");if(i)return i;if(r?([e]=o(this,jl,Ll).call(this,[r]),a=`luminosity_${e}`):a="luminosity",i=t(this,Xl,Vl).get(a),i)return t(this,Xl,Vl).set(r,i),i;const A=`g_${t(this,Sl)}_luminosity_map_${n(this,Gl)._++}`,s=`url(#${A})`;t(this,Xl,Vl).set(r,s),t(this,Xl,Vl).set(a,s);const f=o(this,Ul,Jl).call(this,A);return o(this,Ol,Yl).call(this,f),r&&o(this,ru,eu).call(this,e,f),s}addHighlightHCMFilter(r,e,a,i,A){var n;const s=`${e}-${a}-${i}-${A}`;let f=t(this,Nl,Dl).get(r);if((null==f?void 0:f.key)===s||(f?(null==(n=f.filter)||n.remove(),f.key=s,f.url="none",f.filter=null):(f={key:s,url:"none",filter:null},t(this,Nl,Dl).set(r,f)),!e||!a))return f.url;const[l,u]=[e,a].map(o(this,au,tu).bind(this));let c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),d=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),[h,b]=[i,A].map(o(this,au,tu).bind(this));d<c&&([c,d,h,b]=[d,c,b,h]),t(this,Tl,Pl).style.color="";const g=(r,e,a)=>{const t=new Array(256),i=(d-c)/a,A=r/255,n=(e-r)/(255*a);let o=0;for(let r=0;r<=a;r++){const e=Math.round(c+r*i),a=A+r*n;for(let r=o;r<=e;r++)t[r]=a;o=e+1}for(let r=o;r<256;r++)t[r]=t[o-1];return t.join(",")},p=`g_${t(this,Sl)}_hcm_${r}_filter`,v=f.filter=o(this,Ul,Jl).call(this,p);return o(this,Hl,Ql).call(this,v),o(this,$l,Kl).call(this,g(h[0],b[0],5),g(h[1],b[1],5),g(h[2],b[2],5),v),f.url=`url(#${p})`,f.url}destroy(r=!1){r&&0!==t(this,Nl,Dl).size||(t(this,Fl)&&(t(this,Fl).parentNode.parentNode.remove(),A(this,Fl,null)),t(this,Rl)&&(t(this,Rl).clear(),A(this,Rl,null)),A(this,Gl,0))}},sv=Ds?class extends Bl{_fetchData(r){return Zb(r)}}:nu;function fv(r={}){"string"==typeof r||r instanceof URL?r={url:r}:(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});const e=new dv,{docId:a}=e,t=r.url?function(r){if(r instanceof URL)return r.href;try{return new URL(r,window.location).href}catch{if(Ds&&"string"==typeof r)return r}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(r.url):null,i=r.data?function(r){if(Ds&&typeof Buffer<"u"&&r instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength)return r;if("string"==typeof r)return $f(r);if(r instanceof ArrayBuffer||ArrayBuffer.isView(r)||"object"==typeof r&&!isNaN(null==r?void 0:r.length))return new Uint8Array(r);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(r.data):null,A=r.httpHeaders||null,n=!0===r.withCredentials,o=r.password??null,s=r.range instanceof hv?r.range:null,f=Number.isInteger(r.rangeChunkSize)&&r.rangeChunkSize>0?r.rangeChunkSize:iv;let l=r.worker instanceof xv?r.worker:null;const u=r.verbosity,c="string"!=typeof r.docBaseUrl||lu(r.docBaseUrl)?null:r.docBaseUrl,d="string"==typeof r.cMapUrl?r.cMapUrl:null,h=!1!==r.cMapPacked,b=r.CMapReaderFactory||nv,g="string"==typeof r.standardFontDataUrl?r.standardFontDataUrl:null,p=r.StandardFontDataFactory||sv,v=!0!==r.stopAtErrors,m=Number.isInteger(r.maxImageSize)&&r.maxImageSize>-1?r.maxImageSize:-1,k=!1!==r.isEvalSupported,w="boolean"==typeof r.isOffscreenCanvasSupported?r.isOffscreenCanvasSupported:!Ds,y=Number.isInteger(r.canvasMaxAreaInBytes)?r.canvasMaxAreaInBytes:-1,E="boolean"==typeof r.disableFontFace?r.disableFontFace:Ds,C=!0===r.fontExtraProperties,B=!0===r.enableXfa,_=r.ownerDocument||globalThis.document,Z=!0===r.disableRange,W=!0===r.disableStream,I=!0===r.disableAutoFetch,R=!0===r.pdfBug,F=!0===r.enableHWA,S=s?s.length:r.length??NaN,x="boolean"==typeof r.useSystemFonts?r.useSystemFonts:!Ds&&!E,M="boolean"==typeof r.useWorkerFetch?r.useWorkerFetch:b===Au&&p===nu&&d&&g&&bu(d,document.baseURI)&&bu(g,document.baseURI),G=r.canvasFactory||new Av({ownerDocument:_,enableHWA:F}),X=r.filterFactory||new ov({docId:a,ownerDocument:_});!function(r){Number.isInteger(r)&&(Gf=r)}(u);const V={canvasFactory:G,filterFactory:X};if(M||(V.cMapReaderFactory=new b({baseUrl:d,isCompressed:h}),V.standardFontDataFactory=new p({baseUrl:g})),!l){const r={verbosity:u,port:lg.workerPort};l=r.port?xv.fromPort(r):new xv(r),e._worker=l}const N={docId:a,apiVersion:"4.4.168",data:i,password:o,disableAutoFetch:I,rangeChunkSize:f,length:S,docBaseUrl:c,enableXfa:B,evaluatorOptions:{maxImageSize:m,disableFontFace:E,ignoreErrors:v,isEvalSupported:k,isOffscreenCanvasSupported:w,canvasMaxAreaInBytes:y,fontExtraProperties:C,useSystemFonts:x,cMapUrl:M?d:null,standardFontDataUrl:M?g:null}},D={disableFontFace:E,fontExtraProperties:C,ownerDocument:_,pdfBug:R,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:B}};return l.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(l.destroyed)throw new Error("Worker was destroyed");const r=l.messageHandler.sendWithPromise("GetDocRequest",N,i?[i.buffer]:null);let o;if(s)o=new Yg(s,{disableRange:Z,disableStream:W});else if(!i){if(!t)throw new Error("getDocument - no `url` parameter provided.");u={url:t,length:S,httpHeaders:A,withCredentials:n,rangeChunkSize:f,disableRange:Z,disableStream:W},o=Ds?typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&bu(u.url)?new ep(u):new fp(u):bu(u.url)?new ep(u):new Ap(u)}var u;return r.then((r=>{if(e.destroyed)throw new Error("Loading aborted");if(l.destroyed)throw new Error("Worker was destroyed");const t=new Rg(a,r,l.port),i=new Pv(t,e,o,D,V);e._transport=i,t.send("Ready",null)}))})).catch(e._capability.reject),e}function lv(r){return"object"==typeof r&&Number.isInteger(null==r?void 0:r.num)&&r.num>=0&&Number.isInteger(null==r?void 0:r.gen)&&r.gen>=0}var uv;const cv=class{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+n(cv,uv)._++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var r,e,a;this.destroyed=!0;try{null!=(r=this._worker)&&r.port&&(this._worker._pendingDestroy=!0),await(null==(e=this._transport)?void 0:e.destroy())}catch(r){throw null!=(a=this._worker)&&a.port&&delete this._worker._pendingDestroy,r}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};let dv=cv;uv=new WeakMap,i(dv,uv,0);let hv=class{constructor(r,e,a=!1,t=null){this.length=r,this.initialData=e,this.progressiveDone=a,this.contentDispositionFilename=t,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(r){this._rangeListeners.push(r)}addProgressListener(r){this._progressListeners.push(r)}addProgressiveReadListener(r){this._progressiveReadListeners.push(r)}addProgressiveDoneListener(r){this._progressiveDoneListeners.push(r)}onDataRange(r,e){for(const a of this._rangeListeners)a(r,e)}onDataProgress(r,e){this._readyCapability.promise.then((()=>{for(const a of this._progressListeners)a(r,e)}))}onDataProgressiveRead(r){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(r)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const r of this._progressiveDoneListeners)r()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(r,e){Df("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class bv{constructor(r,e){this._pdfInfo=r,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return jf(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(r){return this._transport.getPage(r)}getPageIndex(r){return this._transport.getPageIndex(r)}getDestinations(){return this._transport.getDestinations()}getDestination(r){return this._transport.getDestination(r)}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:r="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(r);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(r=!1){return this._transport.startCleanup(r||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(r){return this._transport.cachedPageNumber(r)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var gv,pv,vv,mv,kv,wv,yv,Ev;class Cv{constructor(r,e,a,t=!1){i(this,vv),i(this,kv),i(this,gv,null),i(this,pv,!1),this._pageIndex=r,this._pageInfo=e,this._transport=a,this._stats=t?new hu:null,this._pdfBug=t,this.commonObjs=a.commonObjs,this.objs=new Jv,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:r,rotation:e=this.rotate,offsetX:a=0,offsetY:t=0,dontFlip:i=!1}={}){return new su({viewBox:this.view,scale:r,rotation:e,offsetX:a,offsetY:t,dontFlip:i})}getAnnotations({intent:r="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(r);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return jf(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var r;return(null==(r=this._transport._htmlForXfa)?void 0:r.children[this._pageIndex])||null}render({canvasContext:r,viewport:e,intent:a="display",annotationMode:t=zs.ENABLE,transform:i=null,background:n=null,optionalContentConfigPromise:s=null,annotationCanvasMap:f=null,pageColors:l=null,printAnnotationStorage:u=null}){var c,d;null==(c=this._stats)||c.time("Overall");const h=this._transport.getRenderingIntent(a,t,u),{renderingIntent:b,cacheKey:g}=h;A(this,pv,!1),o(this,kv,wv).call(this),s||(s=this._transport.getOptionalContentConfig(b));let p=this._intentStates.get(g);p||(p=Object.create(null),this._intentStates.set(g,p)),p.streamReaderCancelTimeout&&(clearTimeout(p.streamReaderCancelTimeout),p.streamReaderCancelTimeout=null);const v=!!(b&Ys);p.displayReadyCapability||(p.displayReadyCapability=Promise.withResolvers(),p.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(d=this._stats)||d.time("Page Request"),this._pumpOperatorList(h));const m=r=>{var e;p.renderTasks.delete(k),(this._maybeCleanupAfterRender||v)&&A(this,pv,!0),o(this,vv,mv).call(this,!v),r?(k.capability.reject(r),this._abortOperatorList({intentState:p,reason:r instanceof Error?r:new Error(r)})):k.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),null!=(e=globalThis.Stats)&&e.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},k=new $v({callback:m,params:{canvasContext:r,viewport:e,transform:i,background:n},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:f,operatorList:p.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:l});(p.renderTasks||(p.renderTasks=new Set)).add(k);const w=k.task;return Promise.all([p.displayReadyCapability.promise,s]).then((([r,e])=>{var a;if(this.destroyed)m();else{if(null==(a=this._stats)||a.time("Rendering"),!(e.renderingIntent&b))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");k.initializeGraphics({transparency:r,optionalContentConfig:e}),k.operatorListChanged()}})).catch(m),w}getOperatorList({intent:r="display",annotationMode:e=zs.ENABLE,printAnnotationStorage:a=null}={}){var t;const i=this._transport.getRenderingIntent(r,e,a,!0);let A,n=this._intentStates.get(i.cacheKey);return n||(n=Object.create(null),this._intentStates.set(i.cacheKey,n)),n.opListReadCapability||(A=Object.create(null),A.operatorListChanged=function(){n.operatorList.lastChunk&&(n.opListReadCapability.resolve(n.operatorList),n.renderTasks.delete(A))},n.opListReadCapability=Promise.withResolvers(),(n.renderTasks||(n.renderTasks=new Set)).add(A),n.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(t=this._stats)||t.time("Page Request"),this._pumpOperatorList(i)),n.opListReadCapability.promise}streamTextContent({includeMarkedContent:r=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===r,disableNormalization:!0===e},{highWaterMark:100,size:r=>r.items.length})}getTextContent(r={}){if(this._transport._htmlForXfa)return this.getXfa().then((r=>tv.textContent(r)));const e=this.streamTextContent(r);return new Promise((function(r,a){const t=e.getReader(),i={items:[],styles:Object.create(null),lang:null};!function e(){t.read().then((function({value:a,done:t}){t?r(i):(i.lang??(i.lang=a.lang),Object.assign(i.styles,a.styles),i.items.push(...a.items),e())}),a)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const r=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const a of e.renderTasks)r.push(a.completed),a.cancel();return this.objs.clear(),A(this,pv,!1),o(this,kv,wv).call(this),Promise.all(r)}cleanup(r=!1){A(this,pv,!0);const e=o(this,vv,mv).call(this,!1);return r&&e&&this._stats&&(this._stats=new hu),e}_startRenderPage(r,e){var a,t;const i=this._intentStates.get(e);i&&(null==(a=this._stats)||a.timeEnd("Page Request"),null==(t=i.displayReadyCapability)||t.resolve(r))}_renderPageChunk(r,e){for(let a=0,t=r.length;a<t;a++)e.operatorList.fnArray.push(r.fnArray[a]),e.operatorList.argsArray.push(r.argsArray[a]);e.operatorList.lastChunk=r.lastChunk,e.operatorList.separateAnnots=r.separateAnnots;for(const r of e.renderTasks)r.operatorListChanged();r.lastChunk&&o(this,vv,mv).call(this,!0)}_pumpOperatorList({renderingIntent:r,cacheKey:e,annotationStorageSerializable:a}){const{map:t,transfer:i}=a,A=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:r,cacheKey:e,annotationStorage:t},i).getReader(),n=this._intentStates.get(e);n.streamReader=A;const s=()=>{A.read().then((({value:r,done:e})=>{e?n.streamReader=null:this._transport.destroyed||(this._renderPageChunk(r,n),s())}),(r=>{if(n.streamReader=null,!this._transport.destroyed){if(n.operatorList){n.operatorList.lastChunk=!0;for(const r of n.renderTasks)r.operatorListChanged();o(this,vv,mv).call(this,!0)}if(n.displayReadyCapability)n.displayReadyCapability.reject(r);else{if(!n.opListReadCapability)throw r;n.opListReadCapability.reject(r)}}}))};s()}_abortOperatorList({intentState:r,reason:e,force:a=!1}){if(r.streamReader){if(r.streamReaderCancelTimeout&&(clearTimeout(r.streamReaderCancelTimeout),r.streamReaderCancelTimeout=null),!a){if(r.renderTasks.size>0)return;if(e instanceof fu){let a=100;return e.extraDelay>0&&e.extraDelay<1e3&&(a+=e.extraDelay),void(r.streamReaderCancelTimeout=setTimeout((()=>{r.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:r,reason:e,force:!0})}),a))}}if(r.streamReader.cancel(new zf(e.message)).catch((()=>{})),r.streamReader=null,!this._transport.destroyed){for(const[e,a]of this._intentStates)if(a===r){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}gv=new WeakMap,pv=new WeakMap,vv=new WeakSet,mv=function(r=!1){if(o(this,kv,wv).call(this),!t(this,pv)||this.destroyed)return!1;if(r)return A(this,gv,setTimeout((()=>{A(this,gv,null),o(this,vv,mv).call(this,!1)}),5e3)),!1;for(const{renderTasks:r,operatorList:e}of this._intentStates.values())if(r.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),A(this,pv,!1),!0},kv=new WeakSet,wv=function(){t(this,gv)&&(clearTimeout(t(this,gv)),A(this,gv,null))};class Bv{constructor(){i(this,yv,new Set),i(this,Ev,Promise.resolve())}postMessage(r,e){const a={data:structuredClone(r,e?{transfer:e}:null)};t(this,Ev).then((()=>{for(const r of t(this,yv))r.call(this,a)}))}addEventListener(r,e){t(this,yv).add(e)}removeEventListener(r,e){t(this,yv).delete(e)}terminate(){t(this,yv).clear()}}yv=new WeakMap,Ev=new WeakMap;const _v={isWorkerDisabled:!1,fakeWorkerId:0};var Zv,Wv,Iv,Rv,Fv;Ds&&(_v.isWorkerDisabled=!0,lg.workerSrc||(lg.workerSrc="./pdf.worker.mjs")),_v.isSameOrigin=function(r,e){let a;try{if(a=new URL(r),!a.origin||"null"===a.origin)return!1}catch{return!1}const t=new URL(e,a);return a.origin===t.origin},_v.createCDNWrapper=function(r){const e=`await import("${r}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};const Sv=class{constructor({name:r=null,port:e=null,verbosity:a=Xf()}={}){var n;if(i(this,Wv),this.name=r,this.destroyed=!1,this.verbosity=a,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(null!=(n=t(Sv,Zv))&&n.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(t(Sv,Zv)||A(Sv,Zv,new WeakMap)).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return Ds?Promise.all([_b.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(r){this._port=r,this._messageHandler=new Rg("main","worker",r),this._messageHandler.on("ready",(function(){})),o(this,Wv,Iv).call(this)}_initialize(){if(_v.isWorkerDisabled||t(Sv,Rv,Fv))return void this._setupFakeWorker();let{workerSrc:r}=Sv;try{_v.isSameOrigin(window.location.href,r)||(r=_v.createCDNWrapper(new URL(r,window.location).href));const e=new Worker(r,{type:"module"}),a=new Rg("main","worker",e),t=()=>{i.abort(),a.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},i=new AbortController;e.addEventListener("error",(()=>{this._webWorker||t()}),{signal:i.signal}),a.on("test",(r=>{i.abort(),!this.destroyed&&r?(this._messageHandler=a,this._port=e,this._webWorker=e,o(this,Wv,Iv).call(this)):t()})),a.on("ready",(r=>{if(i.abort(),this.destroyed)t();else try{A()}catch{this._setupFakeWorker()}}));const A=()=>{const r=new Uint8Array;a.send("test",r,[r.buffer])};return void A()}catch{Vf("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){_v.isWorkerDisabled||(Nf("Setting up fake worker."),_v.isWorkerDisabled=!0),Sv._setupFakeWorkerGlobal.then((r=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new Bv;this._port=e;const a="fake"+_v.fakeWorkerId++,t=new Rg(a+"_worker",a,e);r.setup(t,e),this._messageHandler=new Rg(a,a+"_worker",e),o(this,Wv,Iv).call(this)})).catch((r=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${r.message}".`))}))}destroy(){var r;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),null==(r=t(Sv,Zv))||r.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(r){var e;if(null==r||!r.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const a=null==(e=t(this,Zv))?void 0:e.get(r.port);if(a){if(a._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return a}return new Sv(r)}static get workerSrc(){if(lg.workerSrc)return lg.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return jf(this,"_setupFakeWorkerGlobal",(async()=>t(this,Rv,Fv)?t(this,Rv,Fv):(await import(this.workerSrc)).WorkerMessageHandler)())}};let xv=Sv;var Mv,Gv,Xv,Vv,Nv,Dv,Tv;Zv=new WeakMap,Wv=new WeakSet,Iv=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Rv=new WeakSet,Fv=function(){var r;try{return(null==(r=globalThis.pdfjsWorker)?void 0:r.WorkerMessageHandler)||null}catch{return null}},i(xv,Rv),i(xv,Zv,void 0);class Pv{constructor(r,e,a,t,A){i(this,Dv),i(this,Mv,new Map),i(this,Gv,new Map),i(this,Xv,new Map),i(this,Vv,new Map),i(this,Nv,null),this.messageHandler=r,this.loadingTask=e,this.commonObjs=new Jv,this.fontLoader=new yb({ownerDocument:t.ownerDocument,styleElement:t.styleElement}),this.loadingParams=t.loadingParams,this._params=t,this.canvasFactory=A.canvasFactory,this.filterFactory=A.filterFactory,this.cMapReaderFactory=A.cMapReaderFactory,this.standardFontDataFactory=A.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=a,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return jf(this,"annotationStorage",new kb)}getRenderingIntent(r,e=zs.ENABLE,a=null,t=!1){let i=Os,A=db;switch(r){case"any":i=Ls;break;case"display":break;case"print":i=Ys;break;default:Nf(`getRenderingIntent - invalid intent: ${r}`)}switch(e){case zs.DISABLE:i+=Us;break;case zs.ENABLE:break;case zs.ENABLE_FORMS:i+=Hs;break;case zs.ENABLE_STORAGE:i+=Qs,A=(i&Ys&&a instanceof wb?a:this.annotationStorage).serializable;break;default:Nf(`getRenderingIntent - invalid annotationMode: ${e}`)}return t&&(i+=Js),{renderingIntent:i,cacheKey:`${i}_${A.hash}`,annotationStorageSerializable:A}}destroy(){var r;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null==(r=t(this,Nv))||r.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const r of t(this,Gv).values())e.push(r._destroy());t(this,Gv).clear(),t(this,Xv).clear(),t(this,Vv).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const a=this.messageHandler.sendWithPromise("Terminate",null);return e.push(a),Promise.all(e).then((()=>{var r;this.commonObjs.clear(),this.fontLoader.clear(),t(this,Mv).clear(),this.filterFactory.destroy(),rv.cleanup(),null==(r=this._networkStream)||r.cancelAllRequests(new zf("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:r,loadingTask:e}=this;r.on("GetReader",((r,e)=>{Tf(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},e.onPull=()=>{this._fullReader.read().then((function({value:r,done:a}){a?e.close():(Tf(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((r=>{e.error(r)}))},e.onCancel=r=>{this._fullReader.cancel(r),e.ready.catch((r=>{if(!this.destroyed)throw r}))}})),r.on("ReaderHeadersReady",(r=>{const a=Promise.withResolvers(),t=this._fullReader;return t.headersReady.then((()=>{var r;(!t.isStreamingSupported||!t.isRangeSupported)&&(this._lastProgress&&(null==(r=e.onProgress)||r.call(e,this._lastProgress)),t.onProgress=r=>{var a;null==(a=e.onProgress)||a.call(e,{loaded:r.loaded,total:r.total})}),a.resolve({isStreamingSupported:t.isStreamingSupported,isRangeSupported:t.isRangeSupported,contentLength:t.contentLength})}),a.reject),a.promise})),r.on("GetRangeReader",((r,e)=>{Tf(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const a=this._networkStream.getRangeReader(r.begin,r.end);a?(e.onPull=()=>{a.read().then((function({value:r,done:a}){a?e.close():(Tf(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((r=>{e.error(r)}))},e.onCancel=r=>{a.cancel(r),e.ready.catch((r=>{if(!this.destroyed)throw r}))}):e.close()})),r.on("GetDoc",(({pdfInfo:r})=>{this._numPages=r.numPages,this._htmlForXfa=r.htmlForXfa,delete r.htmlForXfa,e._capability.resolve(new bv(r,this))})),r.on("DocException",(function(r){let a;switch(r.name){case"PasswordException":a=new Of(r.message,r.code);break;case"InvalidPDFException":a=new Hf(r.message);break;case"MissingPDFException":a=new Qf(r.message);break;case"UnexpectedResponseException":a=new Uf(r.message,r.status);break;case"UnknownErrorException":a=new Yf(r.message,r.details);break;default:Df("DocException - expected a valid Error.")}e._capability.reject(a)})),r.on("PasswordRequest",(r=>{if(A(this,Nv,Promise.withResolvers()),e.onPassword){const a=r=>{r instanceof Error?t(this,Nv).reject(r):t(this,Nv).resolve({password:r})};try{e.onPassword(a,r.code)}catch(r){t(this,Nv).reject(r)}}else t(this,Nv).reject(new Of(r.message,r.code));return t(this,Nv).promise})),r.on("DataLoaded",(r=>{var a;null==(a=e.onProgress)||a.call(e,{loaded:r.length,total:r.length}),this.downloadInfoCapability.resolve(r)})),r.on("StartRenderPage",(r=>{this.destroyed||t(this,Gv).get(r.pageIndex)._startRenderPage(r.transparency,r.cacheKey)})),r.on("commonobj",(([e,a,i])=>{var A;if(this.destroyed||this.commonObjs.has(e))return null;switch(a){case"Font":const{disableFontFace:n,fontExtraProperties:o,pdfBug:s}=this._params;if("error"in i){const r=i.error;Nf(`Error during font loading: ${r}`),this.commonObjs.resolve(e,r);break}const f=s&&null!=(A=globalThis.FontInspector)&&A.enabled?(r,e)=>globalThis.FontInspector.fontAdded(r,e):null,l=new Eb(i,{disableFontFace:n,inspectFont:f});this.fontLoader.bind(l).catch((()=>r.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!o&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:u}=i;Tf(u,"The imageRef must be defined.");for(const r of t(this,Gv).values())for(const[,a]of r.objs)if((null==a?void 0:a.ref)===u)return a.dataLen?(this.commonObjs.resolve(e,structuredClone(a)),a.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,i);break;default:throw new Error(`Got unknown common object type ${a}`)}return null})),r.on("obj",(([r,e,a,i])=>{var A;if(this.destroyed)return;const n=t(this,Gv).get(e);if(!n.objs.has(r)){if(0===n._intentStates.size)return void(null==(A=null==i?void 0:i.bitmap)||A.close());switch(a){case"Image":n.objs.resolve(r,i),(null==i?void 0:i.dataLen)>1e7&&(n._maybeCleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(r,i);break;default:throw new Error(`Got unknown object type ${a}`)}}})),r.on("DocProgress",(r=>{var a;this.destroyed||null==(a=e.onProgress)||a.call(e,{loaded:r.loaded,total:r.total})})),r.on("FetchBuiltInCMap",(r=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(r):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),r.on("FetchStandardFontData",(r=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(r):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var r;this.annotationStorage.size<=0&&Nf("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:a}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:(null==(r=this._fullReader)?void 0:r.filename)??null},a).finally((()=>{this.annotationStorage.resetModified()}))}getPage(r){if(!Number.isInteger(r)||r<=0||r>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=r-1,a=t(this,Xv).get(e);if(a)return a;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&t(this,Vv).set(a.refStr,r);const i=new Cv(e,a,this,this._params.pdfBug);return t(this,Gv).set(e,i),i}));return t(this,Xv).set(e,i),i}getPageIndex(r){return lv(r)?this.messageHandler.sendWithPromise("GetPageIndex",{num:r.num,gen:r.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(r,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:r,intent:e})}getFieldObjects(){return o(this,Dv,Tv).call(this,"GetFieldObjects")}hasJSActions(){return o(this,Dv,Tv).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(r){return"string"!=typeof r?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:r})}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 o(this,Dv,Tv).call(this,"GetDocJSActions")}getPageJSActions(r){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:r})}getStructTree(r){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:r})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(r){return o(this,Dv,Tv).call(this,"GetOptionalContentConfig").then((e=>new Og(e,r)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const r="GetMetadata",e=t(this,Mv).get(r);if(e)return e;const a=this.messageHandler.sendWithPromise(r,null).then((r=>{var e,a;return{info:r[0],metadata:r[1]?new Fg(r[1]):null,contentDispositionFilename:(null==(e=this._fullReader)?void 0:e.filename)??null,contentLength:(null==(a=this._fullReader)?void 0:a.contentLength)??null}}));return t(this,Mv).set(r,a),a}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(r=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const r of t(this,Gv).values())if(!r.cleanup())throw new Error(`startCleanup: Page ${r.pageNumber} is currently rendering.`);this.commonObjs.clear(),r||this.fontLoader.clear(),t(this,Mv).clear(),this.filterFactory.destroy(!0),rv.cleanup()}}cachedPageNumber(r){if(!lv(r))return null;const e=0===r.gen?`${r.num}R`:`${r.num}R${r.gen}`;return t(this,Vv).get(e)??null}}Mv=new WeakMap,Gv=new WeakMap,Xv=new WeakMap,Vv=new WeakMap,Nv=new WeakMap,Dv=new WeakSet,Tv=function(r,e=null){const a=t(this,Mv).get(r);if(a)return a;const i=this.messageHandler.sendWithPromise(r,e);return t(this,Mv).set(r,i),i};const jv=Symbol("INITIAL_DATA");var Lv,Ov,Yv,Hv,Qv,Uv;class Jv{constructor(){i(this,Ov),i(this,Lv,Object.create(null))}get(r,e=null){if(e){const a=o(this,Ov,Yv).call(this,r);return a.promise.then((()=>e(a.data))),null}const a=t(this,Lv)[r];if(!a||a.data===jv)throw new Error(`Requesting object that isn't resolved yet ${r}.`);return a.data}has(r){const e=t(this,Lv)[r];return!!e&&e.data!==jv}resolve(r,e=null){const a=o(this,Ov,Yv).call(this,r);a.data=e,a.resolve()}clear(){var r;for(const e in t(this,Lv)){const{data:a}=t(this,Lv)[e];null==(r=null==a?void 0:a.bitmap)||r.close()}A(this,Lv,Object.create(null))}*[Symbol.iterator](){for(const r in t(this,Lv)){const{data:e}=t(this,Lv)[r];e!==jv&&(yield[r,e])}}}Lv=new WeakMap,Ov=new WeakSet,Yv=function(r){var e;return(e=t(this,Lv))[r]||(e[r]={...Promise.withResolvers(),data:jv})};class zv{constructor(r){i(this,Hv,null),A(this,Hv,r),this.onContinue=null}get promise(){return t(this,Hv).capability.promise}cancel(r=0){t(this,Hv).cancel(null,r)}get separateAnnots(){const{separateAnnots:r}=t(this,Hv).operatorList;if(!r)return!1;const{annotationCanvasMap:e}=t(this,Hv);return r.form||r.canvas&&(null==e?void 0:e.size)>0}}Hv=new WeakMap;const qv=class{constructor({callback:r,params:e,objs:a,commonObjs:t,annotationCanvasMap:A,operatorList:n,pageIndex:o,canvasFactory:s,filterFactory:f,useRequestAnimationFrame:l=!1,pdfBug:u=!1,pageColors:c=null}){i(this,Qv,null),this.callback=r,this.params=e,this.objs=a,this.commonObjs=t,this.annotationCanvasMap=A,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=o,this.canvasFactory=s,this.filterFactory=f,this._pdfBug=u,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===l&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new zv(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:r=!1,optionalContentConfig:e}){var a,i;if(this.cancelled)return;if(this._canvas){if(t(qv,Uv).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.");t(qv,Uv).add(this._canvas)}this._pdfBug&&null!=(a=globalThis.StepperManager)&&a.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:A,viewport:n,transform:o,background:s}=this.params;this.gfx=new og(A,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:o,viewport:n,transparency:r,background:s}),this.operatorListIdx=0,this.graphicsReady=!0,null==(i=this.graphicsReadyCallback)||i.call(this)}cancel(r=null,e=0){var a;this.running=!1,this.cancelled=!0,null==(a=this.gfx)||a.endDrawing(),t(this,Qv)&&(window.cancelAnimationFrame(t(this,Qv)),A(this,Qv,null)),t(qv,Uv).delete(this._canvas),this.callback(r||new fu(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){var r;this.graphicsReady?(null==(r=this.stepper)||r.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?A(this,Qv,window.requestAnimationFrame((()=>{A(this,Qv,null),this._nextBound().catch(this._cancelBound)}))):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),t(qv,Uv).delete(this._canvas),this.callback())))}};let $v=qv;Qv=new WeakMap,Uv=new WeakMap,i($v,Uv,new WeakSet);const Kv="4.4.168",rm="19fbc8998";function em(r){return Math.floor(255*Math.max(0,Math.min(1,r))).toString(16).padStart(2,"0")}function am(r){return Math.max(0,Math.min(255,255*r))}class tm{static CMYK_G([r,e,a,t]){return["G",1-Math.min(1,.3*r+.59*a+.11*e+t)]}static G_CMYK([r]){return["CMYK",0,0,0,1-r]}static G_RGB([r]){return["RGB",r,r,r]}static G_rgb([r]){return[r=am(r),r,r]}static G_HTML([r]){const e=em(r);return`#${e}${e}${e}`}static RGB_G([r,e,a]){return["G",.3*r+.59*e+.11*a]}static RGB_rgb(r){return r.map(am)}static RGB_HTML(r){return`#${r.map(em).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([r,e,a,t]){return["RGB",1-Math.min(1,r+t),1-Math.min(1,a+t),1-Math.min(1,e+t)]}static CMYK_rgb([r,e,a,t]){return[am(1-Math.min(1,r+t)),am(1-Math.min(1,a+t)),am(1-Math.min(1,e+t))]}static CMYK_HTML(r){const e=this.CMYK_RGB(r).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([r,e,a]){const t=1-r,i=1-e,A=1-a;return["CMYK",t,i,A,Math.min(t,i,A)]}}class im{static setupStorage(r,e,a,t,i){const A=t.getValue(e,{value:null});switch(a.name){case"textarea":if(null!==A.value&&(r.textContent=A.value),"print"===i)break;r.addEventListener("input",(r=>{t.setValue(e,{value:r.target.value})}));break;case"input":if("radio"===a.attributes.type||"checkbox"===a.attributes.type){if(A.value===a.attributes.xfaOn?r.setAttribute("checked",!0):A.value===a.attributes.xfaOff&&r.removeAttribute("checked"),"print"===i)break;r.addEventListener("change",(r=>{t.setValue(e,{value:r.target.checked?r.target.getAttribute("xfaOn"):r.target.getAttribute("xfaOff")})}))}else{if(null!==A.value&&r.setAttribute("value",A.value),"print"===i)break;r.addEventListener("input",(r=>{t.setValue(e,{value:r.target.value})}))}break;case"select":if(null!==A.value){r.setAttribute("value",A.value);for(const r of a.children)r.attributes.value===A.value?r.attributes.selected=!0:r.attributes.hasOwnProperty("selected")&&delete r.attributes.selected}r.addEventListener("input",(r=>{const a=r.target.options,i=-1===a.selectedIndex?"":a[a.selectedIndex].value;t.setValue(e,{value:i})}))}}static setAttributes({html:r,element:e,storage:a=null,intent:t,linkService:i}){const{attributes:A}=e,n=r instanceof HTMLAnchorElement;"radio"===A.type&&(A.name=`${A.name}-${t}`);for(const[e,a]of Object.entries(A))if(null!=a)switch(e){case"class":a.length&&r.setAttribute(e,a.join(" "));break;case"dataId":break;case"id":r.setAttribute("data-element-id",a);break;case"style":Object.assign(r.style,a);break;case"textContent":r.textContent=a;break;default:(!n||"href"!==e&&"newWindow"!==e)&&r.setAttribute(e,a)}n&&i.addLinkAttributes(r,A.href,A.newWindow),a&&A.dataId&&this.setupStorage(r,A.dataId,e,a)}static render(r){var e,a;const t=r.annotationStorage,i=r.linkService,A=r.xfaHtml,n=r.intent||"display",o=document.createElement(A.name);A.attributes&&this.setAttributes({html:o,element:A,intent:n,linkService:i});const s="richText"!==n,f=r.div;if(f.append(o),r.viewport){const e=`matrix(${r.viewport.transform.join(",")})`;f.style.transform=e}s&&f.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===A.children.length){if(A.value){const r=document.createTextNode(A.value);o.append(r),s&&tv.shouldBuildText(A.name)&&l.push(r)}return{textDivs:l}}const u=[[A,-1,o]];for(;u.length>0;){const[r,A,o]=u.at(-1);if(A+1===r.children.length){u.pop();continue}const f=r.children[++u.at(-1)[1]];if(null===f)continue;const{name:c}=f;if("#text"===c){const r=document.createTextNode(f.value);l.push(r),o.append(r);continue}const d=null!=(e=null==f?void 0:f.attributes)&&e.xmlns?document.createElementNS(f.attributes.xmlns,c):document.createElement(c);if(o.append(d),f.attributes&&this.setAttributes({html:d,element:f,storage:t,intent:n,linkService:i}),(null==(a=f.children)?void 0:a.length)>0)u.push([f,-1,d]);else if(f.value){const r=document.createTextNode(f.value);s&&tv.shouldBuildText(c)&&l.push(r),d.append(r)}}for(const r of f.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))r.setAttribute("readOnly",!0);return{textDivs:l}}static update(r){const e=`matrix(${r.viewport.transform.join(",")})`;r.div.style.transform=e,r.div.hidden=!1}}const Am=1e3,nm=new WeakSet;function om(r){return{width:r[2]-r[0],height:r[3]-r[1]}}class sm{static create(r){switch(r.data.annotationType){case ff:return new wk(r);case sf:return new yk(r);case Bf:switch(r.data.fieldType){case"Tx":return new Ck(r);case"Btn":return r.data.radioButton?new Zk(r):r.data.checkBox?new _k(r):new Wk(r);case"Ch":return new Ik(r);case"Sig":return new Bk(r)}return new Ek(r);case Ef:return new Rk(r);case lf:return new Sk(r);case uf:return new xk(r);case cf:return new Mk(r);case df:return new Gk(r);case bf:return new Xk(r);case wf:return new Nk(r);case yf:return new Dk(r);case hf:return new Vk(r);case gf:return new Tk(r);case pf:return new Pk(r);case vf:return new jk(r);case mf:return new Lk(r);case kf:return new Ok(r);case Cf:return new Yk(r);default:return new bm(r)}}}var fm,lm,um,cm,dm;const hm=class{constructor(r,{isRenderable:e=!1,ignoreBorder:a=!1,createQuadrilaterals:t=!1}={}){i(this,cm),i(this,fm,null),i(this,lm,!1),i(this,um,null),this.isRenderable=e,this.data=r.data,this.layer=r.layer,this.linkService=r.linkService,this.downloadManager=r.downloadManager,this.imageResourcesPath=r.imageResourcesPath,this.renderForms=r.renderForms,this.svgFactory=r.svgFactory,this.annotationStorage=r.annotationStorage,this.enableScripting=r.enableScripting,this.hasJSActions=r.hasJSActions,this._fieldObjects=r.fieldObjects,this.parent=r.parent,e&&(this.container=this._createContainer(a)),t&&this._createQuadrilaterals()}static _hasPopupData({titleObj:r,contentsObj:e,richText:a}){return!!(null!=r&&r.str||null!=e&&e.str||null!=a&&a.str)}get hasPopupData(){return hm._hasPopupData(this.data)}updateEdited(r){var e;if(!this.container)return;t(this,fm)||A(this,fm,{rect:this.data.rect.slice(0)});const{rect:a}=r;a&&o(this,cm,dm).call(this,a),null==(e=t(this,um))||e.popup.updateEdited(r)}resetEdited(){var r;t(this,fm)&&(o(this,cm,dm).call(this,t(this,fm).rect),null==(r=t(this,um))||r.popup.resetEdited(),A(this,fm,null))}_createContainer(r){const{data:e,parent:{page:a,viewport:t}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",e.id),this instanceof Ek||(i.tabIndex=Am);const{style:n}=i;if(n.zIndex=this.parent.zIndex++,e.popupRef&&i.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(i.title=e.alternativeText),e.noRotate&&i.classList.add("norotate"),!e.rect||this instanceof Rk){const{rotation:r}=e;return!e.hasOwnCanvas&&0!==r&&this.setRotation(r,i),i}const{width:o,height:s}=om(e.rect);if(!r&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;const r=e.borderStyle.horizontalCornerRadius,a=e.borderStyle.verticalCornerRadius;if(r>0||a>0){const e=`calc(${r}px * var(--scale-factor)) / calc(${a}px * var(--scale-factor))`;n.borderRadius=e}else if(this instanceof Zk){const r=`calc(${o}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`;n.borderRadius=r}switch(e.borderStyle.style){case _f:n.borderStyle="solid";break;case Zf:n.borderStyle="dashed";break;case Wf:Nf("Unimplemented border style: beveled");break;case If:Nf("Unimplemented border style: inset");break;case Rf:n.borderBottomStyle="solid"}const t=e.borderColor||null;t?(A(this,lm,!0),n.borderColor=nl.makeHexColor(0|t[0],0|t[1],0|t[2])):n.borderWidth=0}const f=nl.normalizeRect([e.rect[0],a.view[3]-e.rect[1]+a.view[1],e.rect[2],a.view[3]-e.rect[3]+a.view[1]]),{pageWidth:l,pageHeight:u,pageX:c,pageY:d}=t.rawDims;n.left=100*(f[0]-c)/l+"%",n.top=100*(f[1]-d)/u+"%";const{rotation:h}=e;return e.hasOwnCanvas||0===h?(n.width=100*o/l+"%",n.height=100*s/u+"%"):this.setRotation(h,i),i}setRotation(r,e=this.container){if(!this.data.rect)return;const{pageWidth:a,pageHeight:t}=this.parent.viewport.rawDims,{width:i,height:A}=om(this.data.rect);let n,o;r%180==0?(n=100*i/a,o=100*A/t):(n=100*A/a,o=100*i/t),e.style.width=`${n}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-r)%360)}get _commonActions(){const r=(r,e,a)=>{const t=a.detail[r],i=t[0],A=t.slice(1);a.target.style[e]=tm[`${i}_HTML`](A),this.annotationStorage.setValue(this.data.id,{[e]:tm[`${i}_rgb`](A)})};return jf(this,"_commonActions",{display:r=>{const{display:e}=r.detail,a=e%2==1;this.container.style.visibility=a?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:a,noPrint:1===e||2===e})},print:r=>{this.annotationStorage.setValue(this.data.id,{noPrint:!r.detail.print})},hidden:r=>{const{hidden:e}=r.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:r=>{setTimeout((()=>r.target.focus({preventScroll:!1})),0)},userName:r=>{r.target.title=r.detail.userName},readonly:r=>{r.target.disabled=r.detail.readonly},required:r=>{this._setRequired(r.target,r.detail.required)},bgColor:e=>{r("bgColor","backgroundColor",e)},fillColor:e=>{r("fillColor","backgroundColor",e)},fgColor:e=>{r("fgColor","color",e)},textColor:e=>{r("textColor","color",e)},borderColor:e=>{r("borderColor","borderColor",e)},strokeColor:e=>{r("strokeColor","borderColor",e)},rotation:r=>{const e=r.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(r,e){const a=this._commonActions;for(const t of Object.keys(e.detail)){const i=r[t]||a[t];null==i||i(e)}}_setDefaultPropertiesFromJS(r){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const a=this._commonActions;for(const[t,i]of Object.entries(e)){const A=a[t];if(A){A({detail:{[t]:i},target:r}),delete e[t]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:r}=this.data;if(!r)return;const[e,a,i,A]=this.data.rect.map((r=>Math.fround(r)));if(8===r.length){const[t,n,o,s]=r.subarray(2,6);if(i===t&&A===n&&e===o&&a===s)return}const{style:n}=this.container;let o;if(t(this,lm)){const{borderColor:r,borderWidth:e}=n;n.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${r}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const s=i-e,f=A-a,{svgFactory:l}=this,u=l.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const c=l.createElement("defs");u.append(c);const d=l.createElement("clipPath"),h=`clippath_${this.data.id}`;d.setAttribute("id",h),d.setAttribute("clipPathUnits","objectBoundingBox"),c.append(d);for(let a=2,t=r.length;a<t;a+=8){const t=r[a],i=r[a+1],n=r[a+2],u=r[a+3],c=l.createElement("rect"),h=(n-e)/s,b=(A-i)/f,g=(t-n)/s,p=(i-u)/f;c.setAttribute("x",h),c.setAttribute("y",b),c.setAttribute("width",g),c.setAttribute("height",p),d.append(c),null==o||o.push(`<rect vector-effect="non-scaling-stroke" x="${h}" y="${b}" width="${g}" height="${p}"/>`)}t(this,lm)&&(o.push("</g></svg>')"),n.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${h})`}_createPopup(){const{container:r,data:e}=this;r.setAttribute("aria-haspopup","dialog");const a=A(this,um,new Rk({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(a.render())}render(){Df("Abstract method `AnnotationElement.render` called")}_getElementsByName(r,e=null){const a=[];if(this._fieldObjects){const t=this._fieldObjects[r];if(t)for(const{page:r,id:i,exportValues:A}of t){if(-1===r||i===e)continue;const t="string"==typeof A?A:null,n=document.querySelector(`[data-element-id="${i}"]`);!n||nm.has(n)?a.push({id:i,exportValue:t,domElement:n}):Nf(`_getElementsByName - element not allowed: ${i}`)}return a}for(const t of document.getElementsByName(r)){const{exportValue:r}=t,i=t.getAttribute("data-element-id");i!==e&&nm.has(t)&&a.push({id:i,exportValue:r,domElement:t})}return a}show(){var r;this.container&&(this.container.hidden=!1),null==(r=this.popup)||r.maybeShow()}hide(){var r;this.container&&(this.container.hidden=!0),null==(r=this.popup)||r.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const r=this.getElementsToTriggerPopup();if(Array.isArray(r))for(const e of r)e.classList.add("highlightArea");else r.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:r,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{var a;null==(a=this.linkService.eventBus)||a.dispatch("switchannotationeditormode",{source:this,mode:r,editId:e})}))}};let bm=hm;var gm,pm,vm,mm,km,wm,ym,Em,Cm,Bm,_m,Zm,Wm,Im,Rm,Fm,Sm,xm,Mm,Gm,Xm,Vm,Nm,Dm,Tm,Pm,jm,Lm,Om,Ym,Hm,Qm,Um,Jm,zm,qm,$m,Km,rk,ek,ak,tk,ik,Ak,nk,ok,sk,fk,lk,uk,ck,dk,hk,bk,gk,pk,vk,mk,kk;fm=new WeakMap,lm=new WeakMap,um=new WeakMap,cm=new WeakSet,dm=function(r){const{container:{style:e},data:{rect:a,rotation:t},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:A,pageX:n,pageY:o}}}}=this;null==a||a.splice(0,4,...r);const{width:s,height:f}=om(r);e.left=100*(r[0]-n)/i+"%",e.top=100*(A-r[3]+o)/A+"%",0===t?(e.width=100*s/i+"%",e.height=100*f/A+"%"):this.setRotation(t)};class wk extends bm{constructor(r,e=null){super(r,{isRenderable:!0,ignoreBorder:!(null==e||!e.ignoreBorder),createQuadrilaterals:!0}),i(this,gm),i(this,vm),i(this,km),this.isTooltipOnly=r.data.isTooltipOnly}render(){const{data:r,linkService:e}=this,a=document.createElement("a");a.setAttribute("data-element-id",r.id);let t=!1;return r.url?(e.addLinkAttributes(a,r.url,r.newWindow),t=!0):r.action?(this._bindNamedAction(a,r.action),t=!0):r.attachment?(o(this,vm,mm).call(this,a,r.attachment,r.attachmentDest),t=!0):r.setOCGState?(o(this,km,wm).call(this,a,r.setOCGState),t=!0):r.dest?(this._bindLink(a,r.dest),t=!0):(r.actions&&(r.actions.Action||r.actions["Mouse Up"]||r.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(a,r),t=!0),r.resetForm?(this._bindResetFormAction(a,r.resetForm),t=!0):this.isTooltipOnly&&!t&&(this._bindLink(a,""),t=!0)),this.container.classList.add("linkAnnotation"),t&&this.container.append(a),this.container}_bindLink(r,e){r.href=this.linkService.getDestinationHash(e),r.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&o(this,gm,pm).call(this)}_bindNamedAction(r,e){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeNamedAction(e),!1),o(this,gm,pm).call(this)}_bindJSAction(r,e){r.href=this.linkService.getAnchorUrl("");const a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const t of Object.keys(e.actions)){const i=a.get(t);i&&(r[i]=()=>{var r;return null==(r=this.linkService.eventBus)||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:t}}),!1})}r.onclick||(r.onclick=()=>!1),o(this,gm,pm).call(this)}_bindResetFormAction(r,e){const a=r.onclick;if(a||(r.href=this.linkService.getAnchorUrl("")),o(this,gm,pm).call(this),!this._fieldObjects)return Nf('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(a||(r.onclick=()=>!1));r.onclick=()=>{var r;null==a||a();const{fields:t,refs:i,include:A}=e,n=[];if(0!==t.length||0!==i.length){const r=new Set(i);for(const e of t){const a=this._fieldObjects[e]||[];for(const{id:e}of a)r.add(e)}for(const e of Object.values(this._fieldObjects))for(const a of e)r.has(a.id)===A&&n.push(a)}else for(const r of Object.values(this._fieldObjects))n.push(...r);const o=this.annotationStorage,s=[];for(const r of n){const{id:e}=r;switch(s.push(e),r.type){case"text":{const a=r.defaultValue||"";o.setValue(e,{value:a});break}case"checkbox":case"radiobutton":{const a=r.defaultValue===r.exportValues;o.setValue(e,{value:a});break}case"combobox":case"listbox":{const a=r.defaultValue||"";o.setValue(e,{value:a});break}default:continue}const a=document.querySelector(`[data-element-id="${e}"]`);a&&(nm.has(a)?a.dispatchEvent(new Event("resetform")):Nf(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&(null==(r=this.linkService.eventBus)||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:s,name:"ResetForm"}})),!1}}}gm=new WeakSet,pm=function(){this.container.setAttribute("data-internal-link","")},vm=new WeakSet,mm=function(r,e,a=null){r.href=this.linkService.getAnchorUrl(""),e.description&&(r.title=e.description),r.onclick=()=>{var r;return null==(r=this.downloadManager)||r.openOrDownloadData(e.content,e.filename,a),!1},o(this,gm,pm).call(this)},km=new WeakSet,wm=function(r,e){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeSetOCGState(e),!1),o(this,gm,pm).call(this)};class yk extends bm{constructor(r){super(r,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const r=document.createElement("img");return r.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",r.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),r.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(r),this.container}}class Ek extends bm{render(){return this.container}showElementAndHideCanvas(r){var e;this.data.hasOwnCanvas&&("CANVAS"===(null==(e=r.previousSibling)?void 0:e.nodeName)&&(r.previousSibling.hidden=!0),r.hidden=!1)}_getKeyModifier(r){return rl.platform.isMac?r.metaKey:r.ctrlKey}_setEventListener(r,e,a,t,i){a.includes("mouse")?r.addEventListener(a,(r=>{var e;null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:t,value:i(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})})):r.addEventListener(a,(r=>{var A;if("blur"===a){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if("focus"===a){if(e.focused)return;e.focused=!0}i&&(null==(A=this.linkService.eventBus)||A.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:t,value:i(r)}}))}))}_setEventListeners(r,e,a,t){var i,A,n;for(const[o,s]of a)("Action"===s||null!=(i=this.data.actions)&&i[s])&&(("Focus"===s||"Blur"===s)&&(e||(e={focused:!1})),this._setEventListener(r,e,o,s,t),"Focus"!==s||null!=(A=this.data.actions)&&A.Blur?"Blur"===s&&(null==(n=this.data.actions)||!n.Focus)&&this._setEventListener(r,e,"focus","Focus",null):this._setEventListener(r,e,"blur","Blur",null))}_setBackgroundColor(r){const e=this.data.backgroundColor||null;r.style.backgroundColor=null===e?"transparent":nl.makeHexColor(e[0],e[1],e[2])}_setTextStyle(r){const{fontColor:e}=this.data.defaultAppearanceData,a=this.data.defaultAppearanceData.fontSize||9,t=r.style;let i;const A=r=>Math.round(10*r)/10;if(this.data.multiLine){const r=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=r/(Math.round(r/(js*a))||1);i=Math.min(a,A(e/js))}else{const r=Math.abs(this.data.rect[3]-this.data.rect[1]-2);i=Math.min(a,A(r/js))}t.fontSize=`calc(${i}px * var(--scale-factor))`,t.color=nl.makeHexColor(e[0],e[1],e[2]),null!==this.data.textAlignment&&(t.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(r,e){e?r.setAttribute("required",!0):r.removeAttribute("required"),r.setAttribute("aria-required",e)}}class Ck extends Ek{constructor(r){super(r,{isRenderable:r.renderForms||r.data.hasOwnCanvas||!r.data.hasAppearance&&!!r.data.fieldValue})}setPropertyOnSiblings(r,e,a,t){const i=this.annotationStorage;for(const A of this._getElementsByName(r.name,r.id))A.domElement&&(A.domElement[e]=a),i.setValue(A.id,{[t]:a})}render(){var r,e;const a=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const A=a.getValue(t,{value:this.data.fieldValue});let n=A.value||"";const o=a.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&n.length>o&&(n=n.slice(0,o));let s=A.formattedValue||(null==(r=this.data.textContent)?void 0:r.join("\n"))||null;s&&this.data.comb&&(s=s.replaceAll(/\s+/g,""));const f={userValue:n,formattedValue:s,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=s??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",s??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),nm.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Am,this._setRequired(i,this.data.required),o&&(i.maxLength=o),i.addEventListener("input",(r=>{a.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(i,"value",r.target.value,"value"),f.formattedValue=null})),i.addEventListener("resetform",(r=>{const e=this.data.defaultFieldValue??"";i.value=f.userValue=e,f.formattedValue=null}));let l=r=>{const{formattedValue:e}=f;null!=e&&(r.target.value=e),r.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(r=>{var e;if(f.focused)return;const{target:a}=r;f.userValue&&(a.value=f.userValue),f.lastCommittedValue=a.value,f.commitKey=1,null!=(e=this.data.actions)&&e.Focus||(f.focused=!0)})),i.addEventListener("updatefromsandbox",(r=>{this.showElementAndHideCanvas(r.target);const e={value(r){f.userValue=r.detail.value??"",a.setValue(t,{value:f.userValue.toString()}),r.target.value=f.userValue},formattedValue(r){const{formattedValue:e}=r.detail;f.formattedValue=e,null!=e&&r.target!==document.activeElement&&(r.target.value=e),a.setValue(t,{formattedValue:e})},selRange(r){r.target.setSelectionRange(...r.detail.selRange)},charLimit:r=>{var e;const{charLimit:i}=r.detail,{target:A}=r;if(0===i)return void A.removeAttribute("maxLength");A.setAttribute("maxLength",i);let n=f.userValue;!n||n.length<=i||(n=n.slice(0,i),A.value=f.userValue=n,a.setValue(t,{value:n}),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:1,selStart:A.selectionStart,selEnd:A.selectionEnd}}))}};this._dispatchEventFromSandbox(e,r)})),i.addEventListener("keydown",(r=>{var e;f.commitKey=1;let a=-1;if("Escape"===r.key?a=0:"Enter"!==r.key||this.data.multiLine?"Tab"===r.key&&(f.commitKey=3):a=2,-1===a)return;const{value:i}=r.target;f.lastCommittedValue!==i&&(f.lastCommittedValue=i,f.userValue=i,null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:i,willCommit:!0,commitKey:a,selStart:r.target.selectionStart,selEnd:r.target.selectionEnd}}))}));const r=l;l=null,i.addEventListener("blur",(e=>{var a,i;if(!f.focused||!e.relatedTarget)return;null!=(a=this.data.actions)&&a.Blur||(f.focused=!1);const{value:A}=e.target;f.userValue=A,f.lastCommittedValue!==A&&(null==(i=this.linkService.eventBus)||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:A,willCommit:!0,commitKey:f.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})),r(e)})),null!=(e=this.data.actions)&&e.Keystroke&&i.addEventListener("beforeinput",(r=>{var e;f.lastCommittedValue=null;const{data:a,target:i}=r,{value:A,selectionStart:n,selectionEnd:o}=i;let s=n,l=o;switch(r.inputType){case"deleteWordBackward":{const r=A.substring(0,n).match(/\w*[^\w]*$/);r&&(s-=r[0].length);break}case"deleteWordForward":{const r=A.substring(n).match(/^[^\w]*\w*/);r&&(l+=r[0].length);break}case"deleteContentBackward":n===o&&(s-=1);break;case"deleteContentForward":n===o&&(l+=1)}r.preventDefault(),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:A,change:a||"",willCommit:!1,selStart:s,selEnd:l}})})),this._setEventListeners(i,f,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(r=>r.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const r=(this.data.rect[2]-this.data.rect[0])/o;i.classList.add("comb"),i.style.letterSpacing=`calc(${r}px * var(--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 Bk extends Ek{constructor(r){super(r,{isRenderable:!!r.data.hasOwnCanvas})}}class _k extends Ek{constructor(r){super(r,{isRenderable:r.renderForms})}render(){const r=this.annotationStorage,e=this.data,a=e.id;let t=r.getValue(a,{value:e.exportValue===e.fieldValue}).value;"string"==typeof t&&(t="Off"!==t,r.setValue(a,{value:t})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const i=document.createElement("input");return nm.add(i),i.setAttribute("data-element-id",a),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=e.fieldName,t&&i.setAttribute("checked",!0),i.setAttribute("exportValue",e.exportValue),i.tabIndex=Am,i.addEventListener("change",(t=>{const{name:i,checked:A}=t.target;for(const t of this._getElementsByName(i,a)){const a=A&&t.exportValue===e.exportValue;t.domElement&&(t.domElement.checked=a),r.setValue(t.id,{value:a})}r.setValue(a,{value:A})})),i.addEventListener("resetform",(r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue})),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",(e=>{const t={value(e){e.target.checked="Off"!==e.detail.value,r.setValue(a,{value:e.target.checked})}};this._dispatchEventFromSandbox(t,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"]],(r=>r.target.checked))),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Zk extends Ek{constructor(r){super(r,{isRenderable:r.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const r=this.annotationStorage,e=this.data,a=e.id;let t=r.getValue(a,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof t&&(t=t!==e.buttonValue,r.setValue(a,{value:t})),t)for(const t of this._getElementsByName(e.fieldName,a))r.setValue(t.id,{value:!1});const i=document.createElement("input");if(nm.add(i),i.setAttribute("data-element-id",a),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="radio",i.name=e.fieldName,t&&i.setAttribute("checked",!0),i.tabIndex=Am,i.addEventListener("change",(e=>{const{name:t,checked:i}=e.target;for(const e of this._getElementsByName(t,a))r.setValue(e.id,{value:!1});r.setValue(a,{value:i})})),i.addEventListener("resetform",(r=>{const a=e.defaultFieldValue;r.target.checked=null!=a&&a===e.buttonValue})),this.enableScripting&&this.hasJSActions){const t=e.buttonValue;i.addEventListener("updatefromsandbox",(e=>{const i={value:e=>{const i=t===e.detail.value;for(const t of this._getElementsByName(e.target.name)){const e=i&&t.id===a;t.domElement&&(t.domElement.checked=e),r.setValue(t.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"]],(r=>r.target.checked))}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Wk extends wk{constructor(r){super(r,{ignoreBorder:r.data.hasAppearance})}render(){const r=super.render();r.classList.add("buttonWidgetAnnotation","pushButton");const e=r.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(r=>{this._dispatchEventFromSandbox({},r)}))),r}}class Ik extends Ek{constructor(r){super(r,{isRenderable:r.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const r=this.annotationStorage,e=this.data.id,a=r.getValue(e,{value:this.data.fieldValue}),t=document.createElement("select");nm.add(t),t.setAttribute("data-element-id",e),t.disabled=this.data.readOnly,this._setRequired(t,this.data.required),t.name=this.data.fieldName,t.tabIndex=Am;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(t.size=this.data.options.length,this.data.multiSelect&&(t.multiple=!0)),t.addEventListener("resetform",(r=>{const e=this.data.defaultFieldValue;for(const r of t.options)r.selected=r.value===e}));for(const r of this.data.options){const e=document.createElement("option");e.textContent=r.displayValue,e.value=r.exportValue,a.value.includes(r.exportValue)&&(e.setAttribute("selected",!0),i=!1),t.append(e)}let A=null;if(i){const r=document.createElement("option");r.value=" ",r.setAttribute("hidden",!0),r.setAttribute("selected",!0),t.prepend(r),A=()=>{r.remove(),t.removeEventListener("input",A),A=null},t.addEventListener("input",A)}const n=r=>{const e=r?"value":"textContent",{options:a,multiple:i}=t;return i?Array.prototype.filter.call(a,(r=>r.selected)).map((r=>r[e])):-1===a.selectedIndex?null:a[a.selectedIndex][e]};let o=n(!1);const s=r=>{const e=r.target.options;return Array.prototype.map.call(e,(r=>({displayValue:r.textContent,exportValue:r.value})))};return this.enableScripting&&this.hasJSActions?(t.addEventListener("updatefromsandbox",(a=>{const i={value(a){null==A||A();const i=a.detail.value,s=new Set(Array.isArray(i)?i:[i]);for(const r of t.options)r.selected=s.has(r.value);r.setValue(e,{value:n(!0)}),o=n(!1)},multipleSelection(r){t.multiple=!0},remove(a){const i=t.options,A=a.detail.remove;i[A].selected=!1,t.remove(A),i.length>0&&-1===Array.prototype.findIndex.call(i,(r=>r.selected))&&(i[0].selected=!0),r.setValue(e,{value:n(!0),items:s(a)}),o=n(!1)},clear(a){for(;0!==t.length;)t.remove(0);r.setValue(e,{value:null,items:[]}),o=n(!1)},insert(a){const{index:i,displayValue:A,exportValue:f}=a.detail.insert,l=t.children[i],u=document.createElement("option");u.textContent=A,u.value=f,l?l.before(u):t.append(u),r.setValue(e,{value:n(!0),items:s(a)}),o=n(!1)},items(a){const{items:i}=a.detail;for(;0!==t.length;)t.remove(0);for(const r of i){const{displayValue:e,exportValue:a}=r,i=document.createElement("option");i.textContent=e,i.value=a,t.append(i)}t.options.length>0&&(t.options[0].selected=!0),r.setValue(e,{value:n(!0),items:s(a)}),o=n(!1)},indices(a){const t=new Set(a.detail.indices);for(const r of a.target.options)r.selected=t.has(r.index);r.setValue(e,{value:n(!0)}),o=n(!1)},editable(r){r.target.disabled=!r.detail.editable}};this._dispatchEventFromSandbox(i,a)})),t.addEventListener("input",(a=>{var t;const i=n(!0),A=n(!1);r.setValue(e,{value:i}),a.preventDefault(),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:A,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(t,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(r=>r.target.value))):t.addEventListener("input",(function(a){r.setValue(e,{value:n(!0)})})),this.data.combo&&this._setTextStyle(t),this._setBackgroundColor(t),this._setDefaultPropertiesFromJS(t),this.container.append(t),this.container}}class Rk extends bm{constructor(r){const{data:e,elements:a}=r;super(r,{isRenderable:bm._hasPopupData(e)}),this.elements=a,this.popup=null}render(){this.container.classList.add("popupAnnotation");const r=this.popup=new Fk({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const a of this.elements)a.popup=r,e.push(a.data.id),a.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((r=>`${ll}${r}`)).join(",")),this.container}}class Fk{constructor({container:r,color:e,elements:a,titleObj:n,modificationDate:s,contentsObj:f,richText:l,parent:u,rect:c,parentRect:d,open:h}){var b;i(this,Pm),i(this,Lm),i(this,Ym),i(this,Qm),i(this,Jm),i(this,qm),i(this,Km),i(this,ek),i(this,tk),i(this,ym,o(this,Jm,zm).bind(this)),i(this,Em,o(this,tk,ik).bind(this)),i(this,Cm,o(this,ek,ak).bind(this)),i(this,Bm,o(this,Km,rk).bind(this)),i(this,_m,null),i(this,Zm,null),i(this,Wm,null),i(this,Im,null),i(this,Rm,null),i(this,Fm,null),i(this,Sm,null),i(this,xm,!1),i(this,Mm,null),i(this,Gm,null),i(this,Xm,null),i(this,Vm,null),i(this,Nm,null),i(this,Dm,null),i(this,Tm,!1),A(this,Zm,r),A(this,Nm,n),A(this,Wm,f),A(this,Vm,l),A(this,Fm,u),A(this,_m,e),A(this,Xm,c),A(this,Sm,d),A(this,Rm,a),A(this,Im,mu.toDateObject(s)),this.trigger=a.flatMap((r=>r.getElementsToTriggerPopup()));for(const r of this.trigger)r.addEventListener("click",t(this,Bm)),r.addEventListener("mouseenter",t(this,Cm)),r.addEventListener("mouseleave",t(this,Em)),r.classList.add("popupTriggerArea");for(const r of a)null==(b=r.container)||b.addEventListener("keydown",t(this,ym));t(this,Zm).hidden=!0,h&&o(this,Km,rk).call(this)}render(){if(t(this,Mm))return;const r=A(this,Mm,document.createElement("div"));if(r.className="popup",t(this,_m)){const e=r.style.outlineColor=nl.makeHexColor(...t(this,_m));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?r.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:r.style.backgroundColor=nl.makeHexColor(...t(this,_m).map((r=>Math.floor(.7*(255-r)+r))))}const e=document.createElement("span");e.className="header";const a=document.createElement("h1");if(e.append(a),({dir:a.dir,str:a.textContent}=t(this,Nm)),r.append(e),t(this,Im)){const r=document.createElement("span");r.classList.add("popupDate"),r.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),r.setAttribute("data-l10n-args",JSON.stringify({date:t(this,Im).toLocaleDateString(),time:t(this,Im).toLocaleTimeString()})),e.append(r)}const i=t(this,Pm,jm);if(i)im.render({xfaHtml:i,intent:"richText",div:r}),r.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(t(this,Wm));r.append(e)}t(this,Zm).append(r)}_formatContents({str:r,dir:e}){const a=document.createElement("p");a.classList.add("popupContent"),a.dir=e;const t=r.split(/(?:\r\n?|\n)/);for(let r=0,e=t.length;r<e;++r){const i=t[r];a.append(document.createTextNode(i)),r<e-1&&a.append(document.createElement("br"))}return a}updateEdited({rect:r,popupContent:e}){var a;t(this,Dm)||A(this,Dm,{contentsObj:t(this,Wm),richText:t(this,Vm)}),r&&A(this,Gm,null),e&&(A(this,Vm,o(this,Qm,Um).call(this,e)),A(this,Wm,null)),null==(a=t(this,Mm))||a.remove(),A(this,Mm,null)}resetEdited(){var r;t(this,Dm)&&(({contentsObj:n(this,Wm)._,richText:n(this,Vm)._}=t(this,Dm)),A(this,Dm,null),null==(r=t(this,Mm))||r.remove(),A(this,Mm,null),A(this,Gm,null))}forceHide(){A(this,Tm,this.isVisible),t(this,Tm)&&(t(this,Zm).hidden=!0)}maybeShow(){t(this,Tm)&&(t(this,Mm)||o(this,ek,ak).call(this),A(this,Tm,!1),t(this,Zm).hidden=!1)}get isVisible(){return!1===t(this,Zm).hidden}}ym=new WeakMap,Em=new WeakMap,Cm=new WeakMap,Bm=new WeakMap,_m=new WeakMap,Zm=new WeakMap,Wm=new WeakMap,Im=new WeakMap,Rm=new WeakMap,Fm=new WeakMap,Sm=new WeakMap,xm=new WeakMap,Mm=new WeakMap,Gm=new WeakMap,Xm=new WeakMap,Vm=new WeakMap,Nm=new WeakMap,Dm=new WeakMap,Tm=new WeakMap,Pm=new WeakSet,jm=function(){const r=t(this,Vm),e=t(this,Wm);return null!=r&&r.str&&(!(null!=e&&e.str)||e.str===r.str)&&t(this,Vm).html||null},Lm=new WeakSet,Om=function(){var r,e,a;return(null==(a=null==(e=null==(r=t(this,Pm,jm))?void 0:r.attributes)?void 0:e.style)?void 0:a.fontSize)||0},Ym=new WeakSet,Hm=function(){var r,e,a;return(null==(a=null==(e=null==(r=t(this,Pm,jm))?void 0:r.attributes)?void 0:e.style)?void 0:a.color)||null},Qm=new WeakSet,Um=function(r){const e=[],a={str:r,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:t(this,Ym,Hm),fontSize:t(this,Lm,Om)?`calc(${t(this,Lm,Om)}px * var(--scale-factor))`:""}};for(const a of r.split("\n"))e.push({name:"span",value:a,attributes:i});return a},Jm=new WeakSet,zm=function(r){r.altKey||r.shiftKey||r.ctrlKey||r.metaKey||("Enter"===r.key||"Escape"===r.key&&t(this,xm))&&o(this,Km,rk).call(this)},qm=new WeakSet,$m=function(){if(null!==t(this,Gm))return;const{page:{view:r},viewport:{rawDims:{pageWidth:e,pageHeight:a,pageX:i,pageY:n}}}=t(this,Fm);let o=!!t(this,Sm),s=t(this,o?Sm:Xm);for(const r of t(this,Rm))if(!s||null!==nl.intersect(r.data.rect,s)){s=r.data.rect,o=!0;break}const f=nl.normalizeRect([s[0],r[3]-s[1]+r[1],s[2],r[3]-s[3]+r[1]]),l=o?s[2]-s[0]+5:0,u=f[0]+l,c=f[1];A(this,Gm,[100*(u-i)/e,100*(c-n)/a]);const{style:d}=t(this,Zm);d.left=`${t(this,Gm)[0]}%`,d.top=`${t(this,Gm)[1]}%`},Km=new WeakSet,rk=function(){A(this,xm,!t(this,xm)),t(this,xm)?(o(this,ek,ak).call(this),t(this,Zm).addEventListener("click",t(this,Bm)),t(this,Zm).addEventListener("keydown",t(this,ym))):(o(this,tk,ik).call(this),t(this,Zm).removeEventListener("click",t(this,Bm)),t(this,Zm).removeEventListener("keydown",t(this,ym)))},ek=new WeakSet,ak=function(){t(this,Mm)||this.render(),this.isVisible?t(this,xm)&&t(this,Zm).classList.add("focused"):(o(this,qm,$m).call(this),t(this,Zm).hidden=!1,t(this,Zm).style.zIndex=parseInt(t(this,Zm).style.zIndex)+1e3)},tk=new WeakSet,ik=function(){t(this,Zm).classList.remove("focused"),!t(this,xm)&&this.isVisible&&(t(this,Zm).hidden=!0,t(this,Zm).style.zIndex=parseInt(t(this,Zm).style.zIndex)-1e3)};class Sk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),this.textContent=r.data.textContent,this.textPosition=r.data.textPosition,this.annotationEditorType=qs.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const r=document.createElement("div");r.classList.add("annotationTextContent"),r.setAttribute("role","comment");for(const e of this.textContent){const a=document.createElement("span");a.textContent=e,r.append(a)}this.container.append(r)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class xk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,Ak,null)}render(){this.container.classList.add("lineAnnotation");const r=this.data,{width:e,height:a}=om(r.rect),t=this.svgFactory.create(e,a,!0),i=A(this,Ak,this.svgFactory.createElement("svg:line"));return i.setAttribute("x1",r.rect[2]-r.lineCoordinates[0]),i.setAttribute("y1",r.rect[3]-r.lineCoordinates[1]),i.setAttribute("x2",r.rect[2]-r.lineCoordinates[2]),i.setAttribute("y2",r.rect[3]-r.lineCoordinates[3]),i.setAttribute("stroke-width",r.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),t.append(i),this.container.append(t),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,Ak)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ak=new WeakMap;class Mk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,nk,null)}render(){this.container.classList.add("squareAnnotation");const r=this.data,{width:e,height:a}=om(r.rect),t=this.svgFactory.create(e,a,!0),i=r.borderStyle.width,n=A(this,nk,this.svgFactory.createElement("svg:rect"));return n.setAttribute("x",i/2),n.setAttribute("y",i/2),n.setAttribute("width",e-i),n.setAttribute("height",a-i),n.setAttribute("stroke-width",i||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),t.append(n),this.container.append(t),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,nk)}addHighlightArea(){this.container.classList.add("highlightArea")}}nk=new WeakMap;class Gk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,ok,null)}render(){this.container.classList.add("circleAnnotation");const r=this.data,{width:e,height:a}=om(r.rect),t=this.svgFactory.create(e,a,!0),i=r.borderStyle.width,n=A(this,ok,this.svgFactory.createElement("svg:ellipse"));return n.setAttribute("cx",e/2),n.setAttribute("cy",a/2),n.setAttribute("rx",e/2-i/2),n.setAttribute("ry",a/2-i/2),n.setAttribute("stroke-width",i||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),t.append(n),this.container.append(t),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,ok)}addHighlightArea(){this.container.classList.add("highlightArea")}}ok=new WeakMap;class Xk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,sk,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,vertices:e,borderStyle:a,popupRef:t}}=this;if(!e)return this.container;const{width:i,height:n}=om(r),o=this.svgFactory.create(i,n,!0);let s=[];for(let a=0,t=e.length;a<t;a+=2){const t=e[a]-r[0],i=r[3]-e[a+1];s.push(`${t},${i}`)}s=s.join(" ");const f=A(this,sk,this.svgFactory.createElement(this.svgElementName));return f.setAttribute("points",s),f.setAttribute("stroke-width",a.width||1),f.setAttribute("stroke","transparent"),f.setAttribute("fill","transparent"),o.append(f),this.container.append(o),!t&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return t(this,sk)}addHighlightArea(){this.container.classList.add("highlightArea")}}sk=new WeakMap;class Vk extends Xk{constructor(r){super(r),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Nk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Dk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,fk,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=qs.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,inkLists:e,borderStyle:a,popupRef:i}}=this,{width:A,height:n}=om(r),o=this.svgFactory.create(A,n,!0);for(const A of e){let e=[];for(let a=0,t=A.length;a<t;a+=2){const t=A[a]-r[0],i=r[3]-A[a+1];e.push(`${t},${i}`)}e=e.join(" ");const n=this.svgFactory.createElement(this.svgElementName);t(this,fk).push(n),n.setAttribute("points",e),n.setAttribute("stroke-width",a.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),!i&&this.hasPopupData&&this._createPopup(),o.append(n)}return this.container.append(o),this.container}getElementsToTriggerPopup(){return t(this,fk)}addHighlightArea(){this.container.classList.add("highlightArea")}}fk=new WeakMap;class Tk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class Pk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class jk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Lk extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Ok extends bm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Yk extends bm{constructor(r){var e;super(r,{isRenderable:!0}),i(this,uk),i(this,lk,null);const{file:a}=this.data;this.filename=a.filename,this.content=a.content,null==(e=this.linkService.eventBus)||e.dispatch("fileattachmentannotation",{source:this,...a})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:r,data:e}=this;let a;e.hasAppearance||0===e.fillAlpha?a=document.createElement("div"):(a=document.createElement("img"),a.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(a.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),a.addEventListener("dblclick",o(this,uk,ck).bind(this)),A(this,lk,a);const{isMac:t}=rl.platform;return r.addEventListener("keydown",(r=>{"Enter"===r.key&&(t?r.metaKey:r.ctrlKey)&&o(this,uk,ck).call(this)})),!e.popupRef&&this.hasPopupData?this._createPopup():a.classList.add("popupTriggerArea"),r.append(a),r}getElementsToTriggerPopup(){return t(this,lk)}addHighlightArea(){this.container.classList.add("highlightArea")}}lk=new WeakMap,uk=new WeakSet,ck=function(){var r;null==(r=this.downloadManager)||r.openOrDownloadData(this.content,this.filename)};let Hk=(kk=class{constructor({div:r,accessibilityManager:e,annotationCanvasMap:a,annotationEditorUIManager:t,page:n,viewport:o}){i(this,gk),i(this,vk),i(this,dk,null),i(this,hk,null),i(this,bk,new Map),this.div=r,A(this,dk,e),A(this,hk,a),this.page=n,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=t}async render(r){var e;const{annotations:a}=r,i=this.div;Cu(i,this.viewport);const A=new Map,n={data:null,layer:i,linkService:r.linkService,downloadManager:r.downloadManager,imageResourcesPath:r.imageResourcesPath||"",renderForms:!1!==r.renderForms,svgFactory:new ou,annotationStorage:r.annotationStorage||new kb,enableScripting:!0===r.enableScripting,hasJSActions:r.hasJSActions,fieldObjects:r.fieldObjects,parent:this,elements:null};for(const r of a){if(r.noHTML)continue;const a=r.annotationType===Ef;if(a){const e=A.get(r.id);if(!e)continue;n.elements=e}else{const{width:e,height:a}=om(r.rect);if(e<=0||a<=0)continue}n.data=r;const i=sm.create(n);if(!i.isRenderable)continue;if(!a&&r.popupRef){const e=A.get(r.popupRef);e?e.push(i):A.set(r.popupRef,[i])}const s=i.render();r.hidden&&(s.style.visibility="hidden"),o(this,gk,pk).call(this,s,r.id),i.annotationEditorType>0&&(t(this,bk).set(i.data.id,i),null==(e=this._annotationEditorUIManager)||e.renderAnnotationElement(i))}o(this,vk,mk).call(this)}update({viewport:r}){const e=this.div;this.viewport=r,Cu(e,{rotation:r.rotation}),o(this,vk,mk).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(t(this,bk).values())}getEditableAnnotation(r){return t(this,bk).get(r)}},dk=new WeakMap,hk=new WeakMap,bk=new WeakMap,gk=new WeakSet,pk=function(r,e){var a;const i=r.firstChild||r;i.id=`${ll}${e}`,this.div.append(r),null==(a=t(this,dk))||a.moveElementInDOM(this.div,r,i,!1)},vk=new WeakSet,mk=function(){if(!t(this,hk))return;const r=this.div;for(const[e,a]of t(this,hk)){const t=r.querySelector(`[data-annotation-id="${e}"]`);if(!t)continue;a.className="annotationContent";const{firstChild:i}=t;i?"CANVAS"===i.nodeName?i.replaceWith(a):i.classList.contains("annotationContent")?i.after(a):i.before(a):t.append(a)}t(this,hk).clear()},kk);const Qk=/\r\n?|\n/g;var Uk,Jk,zk,qk,$k,Kk,rw,ew,aw,tw,iw,Aw,nw,ow,sw,fw,lw,uw,cw,dw,hw,bw,gw,pw,vw,mw,kw,ww;const yw=class extends ob{constructor(r){super({...r,name:"freeTextEditor"}),i(this,iw),i(this,nw),i(this,sw),i(this,lw),i(this,hw),i(this,gw),i(this,kw),i(this,Uk,this.editorDivBlur.bind(this)),i(this,Jk,this.editorDivFocus.bind(this)),i(this,zk,this.editorDivInput.bind(this)),i(this,qk,this.editorDivKeydown.bind(this)),i(this,$k,this.editorDivPaste.bind(this)),i(this,Kk,void 0),i(this,rw,""),i(this,ew,`${this.id}-editor`),i(this,aw,void 0),i(this,tw,null),A(this,Kk,r.color||yw._defaultColor||ob._defaultLineColor),A(this,aw,r.fontSize||yw._defaultFontSize)}static get _keyboardManager(){const r=yw.prototype,e=r=>r.isEmpty(),a=$d.TRANSLATE_SMALL,t=$d.TRANSLATE_BIG;return jf(this,"_keyboardManager",new gc([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],r.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],r.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],r._translateEmpty,{args:[-a,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r._translateEmpty,{args:[-t,0],checker:e}],[["ArrowRight","mac+ArrowRight"],r._translateEmpty,{args:[a,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r._translateEmpty,{args:[t,0],checker:e}],[["ArrowUp","mac+ArrowUp"],r._translateEmpty,{args:[0,-a],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r._translateEmpty,{args:[0,-t],checker:e}],[["ArrowDown","mac+ArrowDown"],r._translateEmpty,{args:[0,a],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r._translateEmpty,{args:[0,t],checker:e}]]))}static initialize(r,e){ob.initialize(r,e,{strings:["pdfjs-free-text-default-content"]});const a=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(a.getPropertyValue("--freetext-padding"))}static updateDefaultParams(r,e){switch(r){case $s.FREETEXT_SIZE:yw._defaultFontSize=e;break;case $s.FREETEXT_COLOR:yw._defaultColor=e}}updateParams(r,e){switch(r){case $s.FREETEXT_SIZE:o(this,iw,Aw).call(this,e);break;case $s.FREETEXT_COLOR:o(this,nw,ow).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$s.FREETEXT_SIZE,yw._defaultFontSize],[$s.FREETEXT_COLOR,yw._defaultColor||ob._defaultLineColor]]}get propertiesToUpdate(){return[[$s.FREETEXT_SIZE,t(this,aw)],[$s.FREETEXT_COLOR,t(this,Kk)]]}_translateEmpty(r,e){this._uiManager.translateSelectedEditors(r,e,!0)}getInitialTranslation(){const r=this.parentScale;return[-yw._internalPadding*r,-(yw._internalPadding+t(this,aw))*r]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(qs.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const r=this._uiManager._signal;this.editorDiv.addEventListener("keydown",t(this,qk),{signal:r}),this.editorDiv.addEventListener("focus",t(this,Jk),{signal:r}),this.editorDiv.addEventListener("blur",t(this,Uk),{signal:r}),this.editorDiv.addEventListener("input",t(this,zk),{signal:r}),this.editorDiv.addEventListener("paste",t(this,$k),{signal:r})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",t(this,ew)),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",t(this,qk)),this.editorDiv.removeEventListener("focus",t(this,Jk)),this.editorDiv.removeEventListener("blur",t(this,Uk)),this.editorDiv.removeEventListener("input",t(this,zk)),this.editorDiv.removeEventListener("paste",t(this,$k)),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(r){this._focusEventsAllowed&&(super.focusin(r),r.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var r;this.width||(this.enableEditMode(),this.editorDiv.focus(),null!=(r=this._initialOptions)&&r.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 r=t(this,rw),e=A(this,rw,o(this,sw,fw).call(this).trimEnd());if(r===e)return;const a=r=>{A(this,rw,r),r?(o(this,hw,bw).call(this),this._uiManager.rebuild(this),o(this,lw,uw).call(this)):this.remove()};this.addCommands({cmd:()=>{a(e)},undo:()=>{a(r)},mustExec:!1}),o(this,lw,uw).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(r){this.enterInEditMode()}keydown(r){r.target===this.div&&"Enter"===r.key&&(this.enterInEditMode(),r.preventDefault())}editorDivKeydown(r){yw._keyboardManager.exec(this,r)}editorDivFocus(r){this.isEditing=!0}editorDivBlur(r){this.isEditing=!1}editorDivInput(r){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let r,e;this.width&&(r=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",t(this,ew)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),ob._l10nPromise.get("pdfjs-free-text-default-content").then((r=>{var e;return null==(e=this.editorDiv)?void 0:e.setAttribute("default-content",r)})),this.editorDiv.contentEditable=!0;const{style:a}=this.editorDiv;if(a.fontSize=`calc(${t(this,aw)}px * var(--scale-factor))`,a.color=t(this,Kk),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Ac(this,this.div,["dblclick","keydown"]),this.width){const[a,i]=this.parentDimensions;if(this.annotationElementId){const{position:A}=t(this,tw);let[n,o]=this.getInitialTranslation();[n,o]=this.pageTranslationToScreen(n,o);const[s,f]=this.pageDimensions,[l,u]=this.pageTranslation;let c,d;switch(this.rotation){case 0:c=r+(A[0]-l)/s,d=e+this.height-(A[1]-u)/f;break;case 90:c=r+(A[0]-l)/s,d=e-(A[1]-u)/f,[n,o]=[o,-n];break;case 180:c=r-this.width+(A[0]-l)/s,d=e-(A[1]-u)/f,[n,o]=[-n,-o];break;case 270:c=r+(A[0]-l-this.height*f)/s,d=e+(A[1]-u-this.width*s)/f,[n,o]=[-o,n]}this.setAt(c*a,d*i,n,o)}else this.setAt(r*a,e*i,this.width*a,this.height*i);o(this,hw,bw).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(r){var e,a,t;const i=r.clipboardData||window.clipboardData,{types:n}=i;if(1===n.length&&"text/plain"===n[0])return;r.preventDefault();const s=o(e=yw,vw,mw).call(e,i.getData("text")||"").replaceAll(Qk,"\n");if(!s)return;const f=window.getSelection();if(!f.rangeCount)return;this.editorDiv.normalize(),f.deleteFromDocument();const l=f.getRangeAt(0);if(!s.includes("\n"))return l.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void f.collapseToStart();const{startContainer:u,startOffset:c}=l,d=[],h=[];if(u.nodeType===Node.TEXT_NODE){const r=u.parentElement;if(h.push(u.nodeValue.slice(c).replaceAll(Qk,"")),r!==this.editorDiv){let e=d;for(const t of this.editorDiv.childNodes)t!==r?e.push(o(a=yw,cw,dw).call(a,t)):e=h}d.push(u.nodeValue.slice(0,c).replaceAll(Qk,""))}else if(u===this.editorDiv){let r=d,e=0;for(const a of this.editorDiv.childNodes)e++===c&&(r=h),r.push(o(t=yw,cw,dw).call(t,a))}A(this,rw,`${d.join("\n")}${s}${h.join("\n")}`),o(this,hw,bw).call(this);const b=new Range;let g=d.reduce(((r,e)=>r+e.length),0);for(const{firstChild:r}of this.editorDiv.childNodes)if(r.nodeType===Node.TEXT_NODE){const e=r.nodeValue.length;if(g<=e){b.setStart(r,g),b.setEnd(r,g);break}g-=e}f.removeAllRanges(),f.addRange(b)}get contentDiv(){return this.editorDiv}static deserialize(r,e,a){var t;let i=null;if(r instanceof Sk){const{data:{defaultAppearanceData:{fontSize:e,fontColor:a},rect:t,rotation:A,id:n},textContent:o,textPosition:s,parent:{page:{pageNumber:f}}}=r;if(!o||0===o.length)return null;i=r={annotationType:qs.FREETEXT,color:Array.from(a),fontSize:e,value:o.join("\n"),position:s,pageIndex:f-1,rect:t.slice(0),rotation:A,id:n,deleted:!1}}const n=super.deserialize(r,e,a);return A(n,aw,r.fontSize),A(n,Kk,nl.makeHexColor(...r.color)),A(n,rw,o(t=yw,vw,mw).call(t,r.value)),n.annotationElementId=r.id||null,A(n,tw,i),n}serialize(r=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=yw._internalPadding*this.parentScale,a=this.getRect(e,e),i=ob._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:t(this,Kk)),A={annotationType:qs.FREETEXT,color:i,fontSize:t(this,aw),value:o(this,gw,pw).call(this),pageIndex:this.pageIndex,rect:a,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return r?A:this.annotationElementId&&!o(this,kw,ww).call(this,A)?null:(A.id=this.annotationElementId,A)}renderAnnotationElement(r){const e=super.renderAnnotationElement(r);if(this.deleted)return e;const{style:a}=e;a.fontSize=`calc(${t(this,aw)}px * var(--scale-factor))`,a.color=t(this,Kk),e.replaceChildren();for(const r of t(this,rw).split("\n")){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),e.append(a)}const i=yw._internalPadding*this.parentScale;return r.updateEdited({rect:this.getRect(i,i),popupContent:t(this,rw)}),e}resetAnnotationElement(r){super.resetAnnotationElement(r),r.resetEdited()}};let Ew=yw;var Cw,Bw,_w,Zw,Ww,Iw,Rw,Fw,Sw,xw,Mw,Gw,Xw,Vw,Nw,Dw,Tw,Pw,jw,Lw,Ow,Yw,Hw,Qw,Uw,Jw,zw,qw,$w,Kw,ry,ey,ay;Uk=new WeakMap,Jk=new WeakMap,zk=new WeakMap,qk=new WeakMap,$k=new WeakMap,Kk=new WeakMap,rw=new WeakMap,ew=new WeakMap,aw=new WeakMap,tw=new WeakMap,iw=new WeakSet,Aw=function(r){const e=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-t(this,aw))*this.parentScale),A(this,aw,r),o(this,lw,uw).call(this)},a=t(this,aw);this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},nw=new WeakSet,ow=function(r){const e=r=>{A(this,Kk,this.editorDiv.style.color=r)},a=t(this,Kk);this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},sw=new WeakSet,fw=function(){var r;const e=[];this.editorDiv.normalize();for(const a of this.editorDiv.childNodes)e.push(o(r=yw,cw,dw).call(r,a));return e.join("\n")},lw=new WeakSet,uw=function(){const[r,e]=this.parentDimensions;let a;if(this.isAttachedToDOM)a=this.div.getBoundingClientRect();else{const{currentLayer:r,div:e}=this,t=e.style.display,i=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",r.div.append(this.div),a=e.getBoundingClientRect(),e.remove(),e.style.display=t,e.classList.toggle("hidden",i)}this.rotation%180==this.parentRotation%180?(this.width=a.width/r,this.height=a.height/e):(this.width=a.height/r,this.height=a.width/e),this.fixAndSetPosition()},cw=new WeakSet,dw=function(r){return(r.nodeType===Node.TEXT_NODE?r.nodeValue:r.innerText).replaceAll(Qk,"")},hw=new WeakSet,bw=function(){if(this.editorDiv.replaceChildren(),t(this,rw))for(const r of t(this,rw).split("\n")){const e=document.createElement("div");e.append(r?document.createTextNode(r):document.createElement("br")),this.editorDiv.append(e)}},gw=new WeakSet,pw=function(){return t(this,rw).replaceAll(" "," ")},vw=new WeakSet,mw=function(r){return r.replaceAll(" "," ")},kw=new WeakSet,ww=function(r){const{value:e,fontSize:a,color:i,pageIndex:A}=t(this,tw);return this._hasBeenMoved||r.value!==e||r.fontSize!==a||r.color.some(((r,e)=>r!==i[e]))||r.pageIndex!==A},i(Ew,cw),i(Ew,vw),e(Ew,"_freeTextDefaultContent",""),e(Ew,"_internalPadding",0),e(Ew,"_defaultColor",null),e(Ew,"_defaultFontSize",10),e(Ew,"_type","freetext"),e(Ew,"_editorType",qs.FREETEXT);class ty{constructor(r,e=0,a=0,n=!0){i(this,Zw),i(this,Iw),i(this,Fw),i(this,xw),i(this,Gw),i(this,Cw,void 0),i(this,Bw,[]),i(this,_w,[]);let o=1/0,s=-1/0,f=1/0,l=-1/0;const u=1e-4;for(const{x:a,y:i,width:A,height:n}of r){const r=Math.floor((a-e)/u)*u,c=Math.ceil((a+A+e)/u)*u,d=Math.floor((i-e)/u)*u,h=Math.ceil((i+n+e)/u)*u,b=[r,d,h,!0],g=[c,d,h,!1];t(this,Bw).push(b,g),o=Math.min(o,r),s=Math.max(s,c),f=Math.min(f,d),l=Math.max(l,h)}const c=s-o+2*a,d=l-f+2*a,h=o-a,b=f-a,g=t(this,Bw).at(n?-1:-2),p=[g[0],g[2]];for(const r of t(this,Bw)){const[e,a,t]=r;r[0]=(e-h)/c,r[1]=(a-b)/d,r[2]=(t-b)/d}A(this,Cw,{x:h,y:b,width:c,height:d,lastPoint:p})}getOutlines(){t(this,Bw).sort(((r,e)=>r[0]-e[0]||r[1]-e[1]||r[2]-e[2]));const r=[];for(const e of t(this,Bw))e[3]?(r.push(...o(this,Gw,Xw).call(this,e)),o(this,Fw,Sw).call(this,e)):(o(this,xw,Mw).call(this,e),r.push(...o(this,Gw,Xw).call(this,e)));return o(this,Zw,Ww).call(this,r)}}Cw=new WeakMap,Bw=new WeakMap,_w=new WeakMap,Zw=new WeakSet,Ww=function(r){const e=[],a=new Set;for(const a of r){const[r,t,i]=a;e.push([r,t,a],[r,i,a])}e.sort(((r,e)=>r[1]-e[1]||r[0]-e[0]));for(let r=0,t=e.length;r<t;r+=2){const t=e[r][2],i=e[r+1][2];t.push(i),i.push(t),a.add(t),a.add(i)}const i=[];let A;for(;a.size>0;){const r=a.values().next().value;let[e,t,n,o,s]=r;a.delete(r);let f=e,l=t;for(A=[e,n],i.push(A);;){let r;if(a.has(o))r=o;else{if(!a.has(s))break;r=s}a.delete(r),[e,t,n,o,s]=r,f!==e&&(A.push(f,l,e,l===t?t:n),f=e),l=l===t?n:t}A.push(f,l)}return new Ay(i,t(this,Cw))},Iw=new WeakSet,Rw=function(r){const e=t(this,_w);let a=0,i=e.length-1;for(;a<=i;){const t=a+i>>1,A=e[t][0];if(A===r)return t;A<r?a=t+1:i=t-1}return i+1},Fw=new WeakSet,Sw=function([,r,e]){const a=o(this,Iw,Rw).call(this,r);t(this,_w).splice(a,0,[r,e])},xw=new WeakSet,Mw=function([,r,e]){const a=o(this,Iw,Rw).call(this,r);for(let i=a;i<t(this,_w).length;i++){const[a,A]=t(this,_w)[i];if(a!==r)break;if(a===r&&A===e)return void t(this,_w).splice(i,1)}for(let i=a-1;i>=0;i--){const[a,A]=t(this,_w)[i];if(a!==r)break;if(a===r&&A===e)return void t(this,_w).splice(i,1)}},Gw=new WeakSet,Xw=function(r){const[e,a,i]=r,A=[[e,a,i]],n=o(this,Iw,Rw).call(this,i);for(let r=0;r<n;r++){const[a,i]=t(this,_w)[r];for(let r=0,t=A.length;r<t;r++){const[,n,o]=A[r];if(!(i<=n||o<=a)){if(n>=a){if(o>i)A[r][1]=i;else{if(1===t)return[];A.splice(r,1),r--,t--}continue}A[r][2]=a,o>i&&A.push([e,i,o])}}}return A};class iy{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(r,e){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof Yy}}class Ay extends iy{constructor(r,e){super(),i(this,Vw,void 0),i(this,Nw,void 0),A(this,Nw,r),A(this,Vw,e)}toSVGPath(){const r=[];for(const e of t(this,Nw)){let[a,t]=e;r.push(`M${a} ${t}`);for(let i=2;i<e.length;i+=2){const A=e[i],n=e[i+1];A===a?(r.push(`V${n}`),t=n):n===t&&(r.push(`H${A}`),a=A)}r.push("Z")}return r.join(" ")}serialize([r,e,a,i],A){const n=[],o=a-r,s=i-e;for(const e of t(this,Nw)){const a=new Array(e.length);for(let t=0;t<e.length;t+=2)a[t]=r+e[t]*o,a[t+1]=i-e[t+1]*s;n.push(a)}return n}get box(){return t(this,Vw)}}Vw=new WeakMap,Nw=new WeakMap;const ny=class{constructor({x:r,y:e},a,n,o,s,f=0){i(this,ey),i(this,Dw,void 0),i(this,Tw,[]),i(this,Pw,void 0),i(this,jw,void 0),i(this,Lw,[]),i(this,Ow,new Float64Array(18)),i(this,Yw,void 0),i(this,Hw,void 0),i(this,Qw,void 0),i(this,Uw,void 0),i(this,Jw,void 0),i(this,zw,void 0),i(this,qw,[]),A(this,Dw,a),A(this,zw,o*n),A(this,jw,s),t(this,Ow).set([NaN,NaN,NaN,NaN,r,e],6),A(this,Pw,f),A(this,Uw,t(ny,$w)*n),A(this,Qw,t(ny,ry)*n),A(this,Jw,n),t(this,qw).push(r,e)}get free(){return!0}isEmpty(){return isNaN(t(this,Ow)[8])}add({x:r,y:e}){var a;A(this,Yw,r),A(this,Hw,e);const[i,n,o,s]=t(this,Dw);let[f,l,u,c]=t(this,Ow).subarray(8,12);const d=r-u,h=e-c,b=Math.hypot(d,h);if(b<t(this,Qw))return!1;const g=b-t(this,Uw),p=g/b,v=p*d,m=p*h;let k=f,w=l;f=u,l=c,u+=v,c+=m,null==(a=t(this,qw))||a.push(r,e);const y=v/g,E=-m/g*t(this,zw),C=y*t(this,zw);return t(this,Ow).set(t(this,Ow).subarray(2,8),0),t(this,Ow).set([u+E,c+C],4),t(this,Ow).set(t(this,Ow).subarray(14,18),12),t(this,Ow).set([u-E,c-C],16),isNaN(t(this,Ow)[6])?(0===t(this,Lw).length&&(t(this,Ow).set([f+E,l+C],2),t(this,Lw).push(NaN,NaN,NaN,NaN,(f+E-i)/o,(l+C-n)/s),t(this,Ow).set([f-E,l-C],14),t(this,Tw).push(NaN,NaN,NaN,NaN,(f-E-i)/o,(l-C-n)/s)),t(this,Ow).set([k,w,f,l,u,c],6),!this.isEmpty()):(t(this,Ow).set([k,w,f,l,u,c],6),Math.abs(Math.atan2(w-l,k-f)-Math.atan2(m,v))<Math.PI/2?([f,l,u,c]=t(this,Ow).subarray(2,6),t(this,Lw).push(NaN,NaN,NaN,NaN,((f+u)/2-i)/o,((l+c)/2-n)/s),[f,l,k,w]=t(this,Ow).subarray(14,18),t(this,Tw).push(NaN,NaN,NaN,NaN,((k+f)/2-i)/o,((w+l)/2-n)/s),!0):([k,w,f,l,u,c]=t(this,Ow).subarray(0,6),t(this,Lw).push(((k+5*f)/6-i)/o,((w+5*l)/6-n)/s,((5*f+u)/6-i)/o,((5*l+c)/6-n)/s,((f+u)/2-i)/o,((l+c)/2-n)/s),[u,c,f,l,k,w]=t(this,Ow).subarray(12,18),t(this,Tw).push(((k+5*f)/6-i)/o,((w+5*l)/6-n)/s,((5*f+u)/6-i)/o,((5*l+c)/6-n)/s,((f+u)/2-i)/o,((l+c)/2-n)/s),!0))}toSVGPath(){if(this.isEmpty())return"";const r=t(this,Lw),e=t(this,Tw),a=t(this,Ow).subarray(4,6),i=t(this,Ow).subarray(16,18),[A,n,s,f]=t(this,Dw),[l,u,c,d]=o(this,ey,ay).call(this);if(isNaN(t(this,Ow)[6])&&!this.isEmpty())return`M${(t(this,Ow)[2]-A)/s} ${(t(this,Ow)[3]-n)/f} L${(t(this,Ow)[4]-A)/s} ${(t(this,Ow)[5]-n)/f} L${l} ${u} L${c} ${d} L${(t(this,Ow)[16]-A)/s} ${(t(this,Ow)[17]-n)/f} L${(t(this,Ow)[14]-A)/s} ${(t(this,Ow)[15]-n)/f} Z`;const h=[];h.push(`M${r[4]} ${r[5]}`);for(let e=6;e<r.length;e+=6)isNaN(r[e])?h.push(`L${r[e+4]} ${r[e+5]}`):h.push(`C${r[e]} ${r[e+1]} ${r[e+2]} ${r[e+3]} ${r[e+4]} ${r[e+5]}`);h.push(`L${(a[0]-A)/s} ${(a[1]-n)/f} L${l} ${u} L${c} ${d} L${(i[0]-A)/s} ${(i[1]-n)/f}`);for(let r=e.length-6;r>=6;r-=6)isNaN(e[r])?h.push(`L${e[r+4]} ${e[r+5]}`):h.push(`C${e[r]} ${e[r+1]} ${e[r+2]} ${e[r+3]} ${e[r+4]} ${e[r+5]}`);return h.push(`L${e[4]} ${e[5]} Z`),h.join(" ")}getOutlines(){var r;const e=t(this,Lw),a=t(this,Tw),i=t(this,Ow),A=i.subarray(4,6),n=i.subarray(16,18),[s,f,l,u]=t(this,Dw),c=new Float64Array(((null==(r=t(this,qw))?void 0:r.length)??0)+2);for(let r=0,e=c.length-2;r<e;r+=2)c[r]=(t(this,qw)[r]-s)/l,c[r+1]=(t(this,qw)[r+1]-f)/u;c[c.length-2]=(t(this,Yw)-s)/l,c[c.length-1]=(t(this,Hw)-f)/u;const[d,h,b,g]=o(this,ey,ay).call(this);if(isNaN(i[6])&&!this.isEmpty()){const r=new Float64Array(36);return r.set([NaN,NaN,NaN,NaN,(i[2]-s)/l,(i[3]-f)/u,NaN,NaN,NaN,NaN,(i[4]-s)/l,(i[5]-f)/u,NaN,NaN,NaN,NaN,d,h,NaN,NaN,NaN,NaN,b,g,NaN,NaN,NaN,NaN,(i[16]-s)/l,(i[17]-f)/u,NaN,NaN,NaN,NaN,(i[14]-s)/l,(i[15]-f)/u],0),new Yy(r,c,t(this,Dw),t(this,Jw),t(this,Pw),t(this,jw))}const p=new Float64Array(t(this,Lw).length+24+t(this,Tw).length);let v=e.length;for(let r=0;r<v;r+=2)isNaN(e[r])?p[r]=p[r+1]=NaN:(p[r]=e[r],p[r+1]=e[r+1]);p.set([NaN,NaN,NaN,NaN,(A[0]-s)/l,(A[1]-f)/u,NaN,NaN,NaN,NaN,d,h,NaN,NaN,NaN,NaN,b,g,NaN,NaN,NaN,NaN,(n[0]-s)/l,(n[1]-f)/u],v),v+=24;for(let r=a.length-6;r>=6;r-=6)for(let e=0;e<6;e+=2)isNaN(a[r+e])?(p[v]=p[v+1]=NaN,v+=2):(p[v]=a[r+e],p[v+1]=a[r+e+1],v+=2);return p.set([NaN,NaN,NaN,NaN,a[4],a[5]],v),new Yy(p,c,t(this,Dw),t(this,Jw),t(this,Pw),t(this,jw))}};let oy=ny;var sy,fy,ly,uy,cy,dy,hy,by,gy,py,vy,my,ky,wy,yy,Ey,Cy,By,_y,Zy,Wy,Iy,Ry,Fy,Sy,xy,My,Gy,Xy,Vy,Ny,Dy,Ty,Py,jy,Ly,Oy;Dw=new WeakMap,Tw=new WeakMap,Pw=new WeakMap,jw=new WeakMap,Lw=new WeakMap,Ow=new WeakMap,Yw=new WeakMap,Hw=new WeakMap,Qw=new WeakMap,Uw=new WeakMap,Jw=new WeakMap,zw=new WeakMap,qw=new WeakMap,$w=new WeakMap,Kw=new WeakMap,ry=new WeakMap,ey=new WeakSet,ay=function(){const r=t(this,Ow).subarray(4,6),e=t(this,Ow).subarray(16,18),[a,i,A,n]=t(this,Dw);return[(t(this,Yw)+(r[0]-e[0])/2-a)/A,(t(this,Hw)+(r[1]-e[1])/2-i)/n,(t(this,Yw)+(e[0]-r[0])/2-a)/A,(t(this,Hw)+(e[1]-r[1])/2-i)/n]},i(oy,$w,8),i(oy,Kw,2),i(oy,ry,t(ny,$w)+t(ny,Kw));class Yy extends iy{constructor(r,e,a,n,s,f){super(),i(this,by),i(this,py),i(this,my),i(this,sy,void 0),i(this,fy,null),i(this,ly,void 0),i(this,uy,void 0),i(this,cy,void 0),i(this,dy,void 0),i(this,hy,void 0),A(this,hy,r),A(this,cy,e),A(this,sy,a),A(this,dy,n),A(this,ly,s),A(this,uy,f),o(this,my,ky).call(this,f);const{x:l,y:u,width:c,height:d}=t(this,fy);for(let e=0,a=r.length;e<a;e+=2)r[e]=(r[e]-l)/c,r[e+1]=(r[e+1]-u)/d;for(let r=0,a=e.length;r<a;r+=2)e[r]=(e[r]-l)/c,e[r+1]=(e[r+1]-u)/d}toSVGPath(){const r=[`M${t(this,hy)[4]} ${t(this,hy)[5]}`];for(let e=6,a=t(this,hy).length;e<a;e+=6)isNaN(t(this,hy)[e])?r.push(`L${t(this,hy)[e+4]} ${t(this,hy)[e+5]}`):r.push(`C${t(this,hy)[e]} ${t(this,hy)[e+1]} ${t(this,hy)[e+2]} ${t(this,hy)[e+3]} ${t(this,hy)[e+4]} ${t(this,hy)[e+5]}`);return r.push("Z"),r.join(" ")}serialize([r,e,a,i],A){const n=a-r,s=i-e;let f,l;switch(A){case 0:f=o(this,by,gy).call(this,t(this,hy),r,i,n,-s),l=o(this,by,gy).call(this,t(this,cy),r,i,n,-s);break;case 90:f=o(this,py,vy).call(this,t(this,hy),r,e,n,s),l=o(this,py,vy).call(this,t(this,cy),r,e,n,s);break;case 180:f=o(this,by,gy).call(this,t(this,hy),a,e,-n,s),l=o(this,by,gy).call(this,t(this,cy),a,e,-n,s);break;case 270:f=o(this,py,vy).call(this,t(this,hy),a,i,-n,-s),l=o(this,py,vy).call(this,t(this,cy),a,i,-n,-s)}return{outline:Array.from(f),points:[Array.from(l)]}}get box(){return t(this,fy)}getNewOutline(r,e){const{x:a,y:i,width:A,height:n}=t(this,fy),[o,s,f,l]=t(this,sy),u=A*f,c=n*l,d=a*f+o,h=i*l+s,b=new oy({x:t(this,cy)[0]*u+d,y:t(this,cy)[1]*c+h},t(this,sy),t(this,dy),r,t(this,uy),e??t(this,ly));for(let r=2;r<t(this,cy).length;r+=2)b.add({x:t(this,cy)[r]*u+d,y:t(this,cy)[r+1]*c+h});return b.getOutlines()}}sy=new WeakMap,fy=new WeakMap,ly=new WeakMap,uy=new WeakMap,cy=new WeakMap,dy=new WeakMap,hy=new WeakMap,by=new WeakSet,gy=function(r,e,a,t,i){const A=new Float64Array(r.length);for(let n=0,o=r.length;n<o;n+=2)A[n]=e+r[n]*t,A[n+1]=a+r[n+1]*i;return A},py=new WeakSet,vy=function(r,e,a,t,i){const A=new Float64Array(r.length);for(let n=0,o=r.length;n<o;n+=2)A[n]=e+r[n+1]*t,A[n+1]=a+r[n]*i;return A},my=new WeakSet,ky=function(r){const e=t(this,hy);let a=e[4],i=e[5],n=a,o=i,s=a,f=i,l=a,u=i;const c=r?Math.max:Math.min;for(let r=6,t=e.length;r<t;r+=6){if(isNaN(e[r]))n=Math.min(n,e[r+4]),o=Math.min(o,e[r+5]),s=Math.max(s,e[r+4]),f=Math.max(f,e[r+5]),u<e[r+5]?(l=e[r+4],u=e[r+5]):u===e[r+5]&&(l=c(l,e[r+4]));else{const t=nl.bezierBoundingBox(a,i,...e.slice(r,r+6));n=Math.min(n,t[0]),o=Math.min(o,t[1]),s=Math.max(s,t[2]),f=Math.max(f,t[3]),u<t[3]?(l=t[2],u=t[3]):u===t[3]&&(l=c(l,t[2]))}a=e[r+4],i=e[r+5]}const d=n-t(this,ly),h=o-t(this,ly),b=s-n+2*t(this,ly),g=f-o+2*t(this,ly);A(this,fy,{x:d,y:h,width:b,height:g,lastPoint:[l,u]})};const Hy=class{constructor({editor:r=null,uiManager:e=null}){var a;i(this,xy),i(this,Gy),i(this,Vy),i(this,Dy),i(this,Py),i(this,Ly),i(this,wy,o(this,Vy,Ny).bind(this)),i(this,yy,o(this,Py,jy).bind(this)),i(this,Ey,null),i(this,Cy,null),i(this,By,void 0),i(this,_y,null),i(this,Zy,!1),i(this,Wy,!1),i(this,Iy,null),i(this,Ry,void 0),i(this,Fy,null),i(this,Sy,void 0),r?(A(this,Wy,!1),A(this,Sy,$s.HIGHLIGHT_COLOR),A(this,Iy,r)):(A(this,Wy,!0),A(this,Sy,$s.HIGHLIGHT_DEFAULT_COLOR)),A(this,Fy,(null==r?void 0:r._uiManager)||e),A(this,Ry,t(this,Fy)._eventBus),A(this,By,(null==r?void 0:r.color)||(null==(a=t(this,Fy))?void 0:a.highlightColors.values().next().value)||"#FFFF98")}static get _keyboardManager(){return jf(this,"_keyboardManager",new gc([[["Escape","mac+Escape"],Hy.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Hy.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Hy.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Hy.prototype._moveToPrevious],[["Home","mac+Home"],Hy.prototype._moveToBeginning],[["End","mac+End"],Hy.prototype._moveToEnd]]))}renderButton(){const r=A(this,Ey,document.createElement("button"));r.className="colorPicker",r.tabIndex="0",r.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),r.setAttribute("aria-haspopup",!0);const e=t(this,Fy)._signal;r.addEventListener("click",o(this,Dy,Ty).bind(this),{signal:e}),r.addEventListener("keydown",t(this,wy),{signal:e});const a=A(this,Cy,document.createElement("span"));return a.className="swatch",a.setAttribute("aria-hidden",!0),a.style.backgroundColor=t(this,By),r.append(a),r}renderMainDropdown(){const r=A(this,_y,o(this,xy,My).call(this));return r.setAttribute("aria-orientation","horizontal"),r.setAttribute("aria-labelledby","highlightColorPickerLabel"),r}_colorSelectFromKeyboard(r){if(r.target===t(this,Ey))return void o(this,Dy,Ty).call(this,r);const e=r.target.getAttribute("data-color");e&&o(this,Gy,Xy).call(this,e,r)}_moveToNext(r){var e,a;t(this,Ly,Oy)?r.target!==t(this,Ey)?null==(a=r.target.nextSibling)||a.focus():null==(e=t(this,_y).firstChild)||e.focus():o(this,Dy,Ty).call(this,r)}_moveToPrevious(r){var e,a;r.target!==(null==(e=t(this,_y))?void 0:e.firstChild)&&r.target!==t(this,Ey)?(t(this,Ly,Oy)||o(this,Dy,Ty).call(this,r),null==(a=r.target.previousSibling)||a.focus()):t(this,Ly,Oy)&&this._hideDropdownFromKeyboard()}_moveToBeginning(r){var e;t(this,Ly,Oy)?null==(e=t(this,_y).firstChild)||e.focus():o(this,Dy,Ty).call(this,r)}_moveToEnd(r){var e;t(this,Ly,Oy)?null==(e=t(this,_y).lastChild)||e.focus():o(this,Dy,Ty).call(this,r)}hideDropdown(){var r;null==(r=t(this,_y))||r.classList.add("hidden"),window.removeEventListener("pointerdown",t(this,yy))}_hideDropdownFromKeyboard(){var r;if(!t(this,Wy)){if(!t(this,Ly,Oy))return void(null==(r=t(this,Iy))||r.unselect());this.hideDropdown(),t(this,Ey).focus({preventScroll:!0,focusVisible:t(this,Zy)})}}updateColor(r){if(t(this,Cy)&&(t(this,Cy).style.backgroundColor=r),!t(this,_y))return;const e=t(this,Fy).highlightColors.values();for(const a of t(this,_y).children)a.setAttribute("aria-selected",e.next().value===r)}destroy(){var r,e;null==(r=t(this,Ey))||r.remove(),A(this,Ey,null),A(this,Cy,null),null==(e=t(this,_y))||e.remove(),A(this,_y,null)}};let Qy=Hy;var Uy,Jy,zy,qy,$y,Ky,rE,eE,aE,tE,iE,AE,nE,oE,sE,fE,lE,uE,cE,dE,hE,bE,gE,pE,vE,mE,kE,wE,yE,EE,CE,BE,_E,ZE,WE,IE,RE,FE,SE,xE,ME,GE,XE,VE,NE,DE,TE,PE,jE;wy=new WeakMap,yy=new WeakMap,Ey=new WeakMap,Cy=new WeakMap,By=new WeakMap,_y=new WeakMap,Zy=new WeakMap,Wy=new WeakMap,Iy=new WeakMap,Ry=new WeakMap,Fy=new WeakMap,Sy=new WeakMap,xy=new WeakSet,My=function(){const r=document.createElement("div"),e=t(this,Fy)._signal;r.addEventListener("contextmenu",gu,{signal:e}),r.className="dropdown",r.role="listbox",r.setAttribute("aria-multiselectable",!1),r.setAttribute("aria-orientation","vertical"),r.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[a,i]of t(this,Fy).highlightColors){const A=document.createElement("button");A.tabIndex="0",A.role="option",A.setAttribute("data-color",i),A.title=a,A.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${a}`);const n=document.createElement("span");A.append(n),n.className="swatch",n.style.backgroundColor=i,A.setAttribute("aria-selected",i===t(this,By)),A.addEventListener("click",o(this,Gy,Xy).bind(this,i),{signal:e}),r.append(A)}return r.addEventListener("keydown",t(this,wy),{signal:e}),r},Gy=new WeakSet,Xy=function(r,e){e.stopPropagation(),t(this,Ry).dispatch("switchannotationeditorparams",{source:this,type:t(this,Sy),value:r})},Vy=new WeakSet,Ny=function(r){Hy._keyboardManager.exec(this,r)},Dy=new WeakSet,Ty=function(r){if(t(this,Ly,Oy))return void this.hideDropdown();if(A(this,Zy,0===r.detail),window.addEventListener("pointerdown",t(this,yy),{signal:t(this,Fy)._signal}),t(this,_y))return void t(this,_y).classList.remove("hidden");const e=A(this,_y,o(this,xy,My).call(this));t(this,Ey).append(e)},Py=new WeakSet,jy=function(r){var e;null!=(e=t(this,_y))&&e.contains(r.target)||this.hideDropdown()},Ly=new WeakSet,Oy=function(){return t(this,_y)&&!t(this,_y).classList.contains("hidden")};const LE=class extends ob{constructor(r){super({...r,name:"highlightEditor"}),i(this,dE),i(this,bE),i(this,pE),i(this,mE),i(this,wE),i(this,EE),i(this,BE),i(this,IE),i(this,FE),i(this,xE),i(this,GE),i(this,VE),i(this,Uy,null),i(this,Jy,0),i(this,zy,void 0),i(this,qy,null),i(this,$y,null),i(this,Ky,null),i(this,rE,null),i(this,eE,0),i(this,aE,null),i(this,tE,null),i(this,iE,null),i(this,AE,!1),i(this,nE,o(this,IE,RE).bind(this)),i(this,oE,null),i(this,sE,void 0),i(this,fE,null),i(this,lE,""),i(this,uE,void 0),i(this,cE,""),this.color=r.color||LE._defaultColor,A(this,uE,r.thickness||LE._defaultThickness),A(this,sE,r.opacity||LE._defaultOpacity),A(this,zy,r.boxes||null),A(this,cE,r.methodOfCreation||""),A(this,lE,r.text||""),this._isDraggable=!1,r.highlightId>-1?(A(this,AE,!0),o(this,bE,gE).call(this,r),o(this,BE,_E).call(this)):(A(this,Uy,r.anchorNode),A(this,Jy,r.anchorOffset),A(this,rE,r.focusNode),A(this,eE,r.focusOffset),o(this,dE,hE).call(this),o(this,BE,_E).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const r=LE.prototype;return jf(this,"_keyboardManager",new gc([[["ArrowLeft","mac+ArrowLeft"],r._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],r._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],r._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],r._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:t(this,AE)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:t(this,uE),methodOfCreation:t(this,cE)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(r){return{numberOfColors:r.get("color").size}}static initialize(r,e){var a;ob.initialize(r,e),LE._defaultColor||(LE._defaultColor=(null==(a=e.highlightColors)?void 0:a.values().next().value)||"#fff066")}static updateDefaultParams(r,e){switch(r){case $s.HIGHLIGHT_DEFAULT_COLOR:LE._defaultColor=e;break;case $s.HIGHLIGHT_THICKNESS:LE._defaultThickness=e}}translateInPage(r,e){}get toolbarPosition(){return t(this,oE)}updateParams(r,e){switch(r){case $s.HIGHLIGHT_COLOR:o(this,pE,vE).call(this,e);break;case $s.HIGHLIGHT_THICKNESS:o(this,mE,kE).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$s.HIGHLIGHT_DEFAULT_COLOR,LE._defaultColor],[$s.HIGHLIGHT_THICKNESS,LE._defaultThickness]]}get propertiesToUpdate(){return[[$s.HIGHLIGHT_COLOR,this.color||LE._defaultColor],[$s.HIGHLIGHT_THICKNESS,t(this,uE)||LE._defaultThickness],[$s.HIGHLIGHT_FREE,t(this,AE)]]}async addEditToolbar(){const r=await super.addEditToolbar();return r?(this._uiManager.highlightColors&&(A(this,$y,new Qy({editor:this})),r.addColorPicker(t(this,$y))),r):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(o(this,xE,ME).call(this))}getBaseTranslation(){return[0,0]}getRect(r,e){return super.getRect(r,e,o(this,xE,ME).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){o(this,EE,CE).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(o(this,BE,_E).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(r){var e;let a=!1;this.parent&&!r?o(this,EE,CE).call(this):r&&(o(this,BE,_E).call(this,r),a=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(r),this.show(this._isVisible),a&&this.select()}rotate(r){var e,a,i;const{drawLayer:A}=this.parent;let n;t(this,AE)?(r=(r-this.rotation+360)%360,n=o(e=LE,ZE,WE).call(e,t(this,tE).box,r)):n=o(a=LE,ZE,WE).call(a,this,r),A.rotate(t(this,iE),r),A.rotate(t(this,fE),r),A.updateBox(t(this,iE),n),A.updateBox(t(this,fE),o(i=LE,ZE,WE).call(i,t(this,Ky).box,r))}render(){if(this.div)return this.div;const r=super.render();t(this,lE)&&(r.setAttribute("aria-label",t(this,lE)),r.setAttribute("role","mark")),t(this,AE)?r.classList.add("free"):this.div.addEventListener("keydown",t(this,nE),{signal:this._uiManager._signal});const e=A(this,aE,document.createElement("div"));r.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=t(this,qy);const[a,i]=this.parentDimensions;return this.setDims(this.width*a,this.height*i),Ac(this,t(this,aE),["pointerover","pointerleave"]),this.enableEditing(),r}pointerover(){this.parent.drawLayer.addClass(t(this,fE),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(t(this,fE),"hovered")}_moveCaret(r){switch(this.parent.unselect(this),r){case 0:case 2:o(this,FE,SE).call(this,!0);break;case 1:case 3:o(this,FE,SE).call(this,!1)}}select(){var r,e;super.select(),t(this,fE)&&(null==(r=this.parent)||r.drawLayer.removeClass(t(this,fE),"hovered"),null==(e=this.parent)||e.drawLayer.addClass(t(this,fE),"selected"))}unselect(){var r;super.unselect(),t(this,fE)&&(null==(r=this.parent)||r.drawLayer.removeClass(t(this,fE),"selected"),t(this,AE)||o(this,FE,SE).call(this,!1))}get _mustFixPosition(){return!t(this,AE)}show(r=this._isVisible){super.show(r),this.parent&&(this.parent.drawLayer.show(t(this,iE),r),this.parent.drawLayer.show(t(this,fE),r))}static startHighlighting(r,e,{target:a,x:t,y:i}){const{x:A,y:n,width:s,height:f}=a.getBoundingClientRect(),l=e=>{o(this,DE,TE).call(this,r,e)},u=r._signal,c={capture:!0,passive:!1,signal:u},d=r=>{r.preventDefault(),r.stopPropagation()},h=e=>{a.removeEventListener("pointermove",l),window.removeEventListener("blur",h),window.removeEventListener("pointerup",h),window.removeEventListener("pointerdown",d,c),window.removeEventListener("contextmenu",gu),o(this,PE,jE).call(this,r,e)};window.addEventListener("blur",h,{signal:u}),window.addEventListener("pointerup",h,{signal:u}),window.addEventListener("pointerdown",d,c),window.addEventListener("contextmenu",gu,{signal:u}),a.addEventListener("pointermove",l,{signal:u}),this._freeHighlight=new oy({x:t,y:i},[A,n,s,f],r.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=r.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0))}static deserialize(r,e,a){var t;const i=super.deserialize(r,e,a),{rect:[n,s,f,l],color:u,quadPoints:c}=r;i.color=nl.makeHexColor(...u),A(i,sE,r.opacity);const[d,h]=i.pageDimensions;i.width=(f-n)/d,i.height=(l-s)/h;const b=A(i,zy,[]);for(let r=0;r<c.length;r+=8)b.push({x:(c[4]-f)/d,y:(l-(1-c[r+5]))/h,width:(c[r+2]-c[r])/d,height:(c[r+5]-c[r+1])/h});return o(t=i,dE,hE).call(t),i}serialize(r=!1){if(this.isEmpty()||r)return null;const e=this.getRect(0,0),a=ob._colorManager.convert(this.color);return{annotationType:qs.HIGHLIGHT,color:a,opacity:t(this,sE),thickness:t(this,uE),quadPoints:o(this,GE,XE).call(this),outlines:o(this,VE,NE).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:o(this,xE,ME).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}};let OE=LE;var YE,HE,QE,UE,JE,zE,qE,$E,KE,rC,eC,aC,tC,iC,AC,nC,oC,sC,fC,lC,uC,cC,dC,hC,bC,gC,pC,vC,mC,kC,wC,yC,EC,CC,BC,_C,ZC,WC,IC,RC,FC,SC,xC,MC,GC,XC,VC,NC,DC,TC,PC,jC,LC,OC,YC,HC,QC,UC,JC,zC,qC,$C,KC,rB,eB,aB,tB;Uy=new WeakMap,Jy=new WeakMap,zy=new WeakMap,qy=new WeakMap,$y=new WeakMap,Ky=new WeakMap,rE=new WeakMap,eE=new WeakMap,aE=new WeakMap,tE=new WeakMap,iE=new WeakMap,AE=new WeakMap,nE=new WeakMap,oE=new WeakMap,sE=new WeakMap,fE=new WeakMap,lE=new WeakMap,uE=new WeakMap,cE=new WeakMap,dE=new WeakSet,hE=function(){const r=new ty(t(this,zy),.001);A(this,tE,r.getOutlines()),({x:this.x,y:this.y,width:this.width,height:this.height}=t(this,tE).box);const e=new ty(t(this,zy),.0025,.001,"ltr"===this._uiManager.direction);A(this,Ky,e.getOutlines());const{lastPoint:a}=t(this,Ky).box;A(this,oE,[(a[0]-this.x)/this.width,(a[1]-this.y)/this.height])},bE=new WeakSet,gE=function({highlightOutlines:r,highlightId:e,clipPathId:a}){var i,n;A(this,tE,r);if(A(this,Ky,r.getNewOutline(t(this,uE)/2+1.5,.0025)),e>=0)A(this,iE,e),A(this,qy,a),this.parent.drawLayer.finalizeLine(e,r),A(this,fE,this.parent.drawLayer.highlightOutline(t(this,Ky)));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(t(this,iE),r),this.parent.drawLayer.updateBox(t(this,iE),o(i=LE,ZE,WE).call(i,t(this,tE).box,(e-this.rotation+360)%360)),this.parent.drawLayer.updateLine(t(this,fE),t(this,Ky)),this.parent.drawLayer.updateBox(t(this,fE),o(n=LE,ZE,WE).call(n,t(this,Ky).box,e))}const{x:s,y:f,width:l,height:u}=r.box;switch(this.rotation){case 0:this.x=s,this.y=f,this.width=l,this.height=u;break;case 90:{const[r,e]=this.parentDimensions;this.x=f,this.y=1-s,this.width=l*e/r,this.height=u*r/e;break}case 180:this.x=1-s,this.y=1-f,this.width=l,this.height=u;break;case 270:{const[r,e]=this.parentDimensions;this.x=1-f,this.y=s,this.width=l*e/r,this.height=u*r/e;break}}const{lastPoint:c}=t(this,Ky).box;A(this,oE,[(c[0]-s)/l,(c[1]-f)/u])},pE=new WeakSet,vE=function(r){const e=r=>{var e,a;this.color=r,null==(e=this.parent)||e.drawLayer.changeColor(t(this,iE),r),null==(a=t(this,$y))||a.updateColor(r)},a=this.color;this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(r)},!0)},mE=new WeakSet,kE=function(r){const e=t(this,uE),a=r=>{A(this,uE,r),o(this,wE,yE).call(this,r)};this.addCommands({cmd:a.bind(this,r),undo:a.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:r},!0)},wE=new WeakSet,yE=function(r){if(!t(this,AE))return;o(this,bE,gE).call(this,{highlightOutlines:t(this,tE).getNewOutline(r/2)}),this.fixAndSetPosition();const[e,a]=this.parentDimensions;this.setDims(this.width*e,this.height*a)},EE=new WeakSet,CE=function(){null===t(this,iE)||!this.parent||(this.parent.drawLayer.remove(t(this,iE)),A(this,iE,null),this.parent.drawLayer.remove(t(this,fE)),A(this,fE,null))},BE=new WeakSet,_E=function(r=this.parent){null===t(this,iE)&&(({id:n(this,iE)._,clipPathId:n(this,qy)._}=r.drawLayer.highlight(t(this,tE),this.color,t(this,sE))),A(this,fE,r.drawLayer.highlightOutline(t(this,Ky))),t(this,aE)&&(t(this,aE).style.clipPath=t(this,qy)))},ZE=new WeakSet,WE=function({x:r,y:e,width:a,height:t},i){switch(i){case 90:return{x:1-e-t,y:r,width:t,height:a};case 180:return{x:1-r-a,y:1-e-t,width:a,height:t};case 270:return{x:e,y:1-r-a,width:t,height:a}}return{x:r,y:e,width:a,height:t}},IE=new WeakSet,RE=function(r){LE._keyboardManager.exec(this,r)},FE=new WeakSet,SE=function(r){if(!t(this,Uy))return;const e=window.getSelection();r?e.setPosition(t(this,Uy),t(this,Jy)):e.setPosition(t(this,rE),t(this,eE))},xE=new WeakSet,ME=function(){return t(this,AE)?this.rotation:0},GE=new WeakSet,XE=function(){if(t(this,AE))return null;const[r,e]=this.pageDimensions,a=t(this,zy),i=new Float32Array(8*a.length);let A=0;for(const{x:t,y:n,width:o,height:s}of a){const a=t*r,f=(1-n-s)*e;i[A]=i[A+4]=a,i[A+1]=i[A+3]=f,i[A+2]=i[A+6]=a+o*r,i[A+5]=i[A+7]=f+s*e,A+=8}return i},VE=new WeakSet,NE=function(r){return t(this,tE).serialize(r,o(this,xE,ME).call(this))},DE=new WeakSet,TE=function(r,e){this._freeHighlight.add(e)&&r.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},PE=new WeakSet,jE=function(r,e){this._freeHighlight.isEmpty()?r.drawLayer.removeFreeHighlight(this._freeHighlightId):r.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},i(OE,ZE),i(OE,DE),i(OE,PE),e(OE,"_defaultColor",null),e(OE,"_defaultOpacity",1),e(OE,"_defaultThickness",12),e(OE,"_l10nPromise"),e(OE,"_type","highlight"),e(OE,"_editorType",qs.HIGHLIGHT),e(OE,"_freeHighlightId",-1),e(OE,"_freeHighlight",null),e(OE,"_freeHighlightClipId","");const iB=class extends ob{constructor(r){super({...r,name:"inkEditor"}),i(this,nC),i(this,sC),i(this,lC),i(this,cC),i(this,hC),i(this,gC),i(this,vC),i(this,kC),i(this,yC),i(this,CC),i(this,_C),i(this,WC),i(this,RC),i(this,SC),i(this,MC),i(this,XC),i(this,NC),i(this,TC),i(this,jC),i(this,zC),i(this,$C),i(this,rB),i(this,aB),i(this,YE,0),i(this,HE,0),i(this,QE,this.canvasPointermove.bind(this)),i(this,UE,this.canvasPointerleave.bind(this)),i(this,JE,this.canvasPointerup.bind(this)),i(this,zE,this.canvasPointerdown.bind(this)),i(this,qE,null),i(this,$E,new Path2D),i(this,KE,!1),i(this,rC,!1),i(this,eC,!1),i(this,aC,null),i(this,tC,0),i(this,iC,0),i(this,AC,null),this.color=r.color||null,this.thickness=r.thickness||null,this.opacity=r.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(r,e){ob.initialize(r,e)}static updateDefaultParams(r,e){switch(r){case $s.INK_THICKNESS:iB._defaultThickness=e;break;case $s.INK_COLOR:iB._defaultColor=e;break;case $s.INK_OPACITY:iB._defaultOpacity=e/100}}updateParams(r,e){switch(r){case $s.INK_THICKNESS:o(this,nC,oC).call(this,e);break;case $s.INK_COLOR:o(this,sC,fC).call(this,e);break;case $s.INK_OPACITY:o(this,lC,uC).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$s.INK_THICKNESS,iB._defaultThickness],[$s.INK_COLOR,iB._defaultColor||ob._defaultLineColor],[$s.INK_OPACITY,Math.round(100*iB._defaultOpacity)]]}get propertiesToUpdate(){return[[$s.INK_THICKNESS,this.thickness||iB._defaultThickness],[$s.INK_COLOR,this.color||iB._defaultColor||ob._defaultLineColor],[$s.INK_OPACITY,Math.round(100*(this.opacity??iB._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(o(this,MC,GC).call(this),o(this,XC,VC).call(this)),this.isAttachedToDOM||(this.parent.add(this),o(this,NC,DC).call(this)),o(this,aB,tB).call(this)))}remove(){var r;null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,t(this,qE)&&(clearTimeout(t(this,qE)),A(this,qE,null)),null==(r=t(this,aC))||r.disconnect(),A(this,aC,null),super.remove())}setParent(r){!this.parent&&r?this._uiManager.removeShouldRescale(this):this.parent&&null===r&&this._uiManager.addShouldRescale(this),super.setParent(r)}onScaleChanging(){const[r,e]=this.parentDimensions,a=this.width*r,t=this.height*e;this.setDimensions(a,t)}enableEditMode(){t(this,KE)||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",t(this,zE),{signal:this._uiManager._signal}))}disableEditMode(){!this.isInEditMode()||null===this.canvas||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",t(this,zE)))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}commit(){t(this,KE)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),A(this,KE,!0),this.div.classList.add("disabled"),o(this,aB,tB).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(r){this._focusEventsAllowed&&(super.focusin(r),this.enableEditMode())}canvasPointerdown(r){0!==r.button||!this.isInEditMode()||t(this,KE)||(this.setInForeground(),r.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),o(this,gC,pC).call(this,r.offsetX,r.offsetY))}canvasPointermove(r){r.preventDefault(),o(this,vC,mC).call(this,r.offsetX,r.offsetY)}canvasPointerup(r){r.preventDefault(),o(this,SC,xC).call(this,r)}canvasPointerleave(r){o(this,SC,xC).call(this,r)}get isResizable(){return!this.isEmpty()&&t(this,KE)}render(){if(this.div)return this.div;let r,e;this.width&&(r=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[a,t,i,n]=o(this,cC,dC).call(this);if(this.setAt(a,t,0,0),this.setDims(i,n),o(this,MC,GC).call(this),this.width){const[a,t]=this.parentDimensions;this.setAspectRatio(this.width*a,this.height*t),this.setAt(r*a,e*t,this.width*a,this.height*t),A(this,eC,!0),o(this,NC,DC).call(this),this.setDims(this.width*a,this.height*t),o(this,RC,FC).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return o(this,XC,VC).call(this),this.div}setDimensions(r,e){const a=Math.round(r),i=Math.round(e);if(t(this,tC)===a&&t(this,iC)===i)return;A(this,tC,a),A(this,iC,i),this.canvas.style.visibility="hidden";const[n,s]=this.parentDimensions;this.width=r/n,this.height=e/s,this.fixAndSetPosition(),t(this,KE)&&o(this,TC,PC).call(this,r,e),o(this,NC,DC).call(this),o(this,RC,FC).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(r,e,a){var t,i,n;if(r instanceof Dk)return null;const s=super.deserialize(r,e,a);s.thickness=r.thickness,s.color=nl.makeHexColor(...r.color),s.opacity=r.opacity;const[f,l]=s.pageDimensions,u=s.width*f,c=s.height*l,d=s.parentScale,h=r.thickness/2;A(s,KE,!0),A(s,tC,Math.round(u)),A(s,iC,Math.round(c));const{paths:b,rect:g,rotation:p}=r;for(let{bezier:r}of b){r=o(t=iB,UC,JC).call(t,r,g,p);const e=[];s.paths.push(e);let a=d*(r[0]-h),i=d*(r[1]-h);for(let t=2,A=r.length;t<A;t+=6){const A=d*(r[t]-h),n=d*(r[t+1]-h),o=d*(r[t+2]-h),s=d*(r[t+3]-h),f=d*(r[t+4]-h),l=d*(r[t+5]-h);e.push([[a,i],[A,n],[o,s],[f,l]]),a=f,i=l}const A=o(this,OC,YC).call(this,e);s.bezierPath2D.push(A)}const v=o(i=s,$C,KC).call(i);return A(s,HE,Math.max(ob.MIN_SIZE,v[2]-v[0])),A(s,YE,Math.max(ob.MIN_SIZE,v[3]-v[1])),o(n=s,TC,PC).call(n,u,c),s}serialize(){if(this.isEmpty())return null;const r=this.getRect(0,0),e=ob._colorManager.convert(this.ctx.strokeStyle);return{annotationType:qs.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:o(this,zC,qC).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,r),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};let AB=iB;var nB,oB,sB,fB,lB,uB,cB,dB,hB,bB,gB,pB,vB,mB,kB,wB,yB,EB,CB,BB,_B,ZB,WB,IB,RB,FB,SB,xB,MB;YE=new WeakMap,HE=new WeakMap,QE=new WeakMap,UE=new WeakMap,JE=new WeakMap,zE=new WeakMap,qE=new WeakMap,$E=new WeakMap,KE=new WeakMap,rC=new WeakMap,eC=new WeakMap,aC=new WeakMap,tC=new WeakMap,iC=new WeakMap,AC=new WeakMap,nC=new WeakSet,oC=function(r){const e=r=>{this.thickness=r,o(this,aB,tB).call(this)},a=this.thickness;this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},sC=new WeakSet,fC=function(r){const e=r=>{this.color=r,o(this,RC,FC).call(this)},a=this.color;this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},lC=new WeakSet,uC=function(r){const e=r=>{this.opacity=r,o(this,RC,FC).call(this)};r/=100;const a=this.opacity;this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$s.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},cC=new WeakSet,dC=function(){const{parentRotation:r,parentDimensions:[e,a]}=this;switch(r){case 90:return[0,a,a,e];case 180:return[e,a,e,a];case 270:return[e,0,a,e];default:return[0,0,e,a]}},hC=new WeakSet,bC=function(){const{ctx:r,color:e,opacity:a,thickness:t,parentScale:i,scaleFactor:A}=this;var n;r.lineWidth=t*i/A,r.lineCap="round",r.lineJoin="round",r.miterLimit=10,r.strokeStyle=`${e}${n=a,Math.round(Math.min(255,Math.max(1,255*n))).toString(16).padStart(2,"0")}`},gC=new WeakSet,pC=function(r,e){const a=this._uiManager._signal;this.canvas.addEventListener("contextmenu",gu,{signal:a}),this.canvas.addEventListener("pointerleave",t(this,UE),{signal:a}),this.canvas.addEventListener("pointermove",t(this,QE),{signal:a}),this.canvas.addEventListener("pointerup",t(this,JE),{signal:a}),this.canvas.removeEventListener("pointerdown",t(this,zE)),this.isEditing=!0,t(this,eC)||(A(this,eC,!0),o(this,NC,DC).call(this),this.thickness||(this.thickness=iB._defaultThickness),this.color||(this.color=iB._defaultColor||ob._defaultLineColor),this.opacity??(this.opacity=iB._defaultOpacity)),this.currentPath.push([r,e]),A(this,rC,!1),o(this,hC,bC).call(this),A(this,AC,(()=>{o(this,CC,BC).call(this),t(this,AC)&&window.requestAnimationFrame(t(this,AC))})),window.requestAnimationFrame(t(this,AC))},vC=new WeakSet,mC=function(r,e){const[a,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&r===a&&e===i)return;const n=this.currentPath;let s=t(this,$E);if(n.push([r,e]),A(this,rC,!0),n.length<=2)return s.moveTo(...n[0]),void s.lineTo(r,e);3===n.length&&(A(this,$E,s=new Path2D),s.moveTo(...n[0])),o(this,_C,ZC).call(this,s,...n.at(-3),...n.at(-2),r,e)},kC=new WeakSet,wC=function(){if(0===this.currentPath.length)return;const r=this.currentPath.at(-1);t(this,$E).lineTo(...r)},yC=new WeakSet,EC=function(r,e){let a;if(A(this,AC,null),r=Math.min(Math.max(r,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),o(this,vC,mC).call(this,r,e),o(this,kC,wC).call(this),1!==this.currentPath.length)a=o(this,WC,IC).call(this);else{const t=[r,e];a=[[t,t.slice(),t.slice(),t]]}const i=t(this,$E),n=this.currentPath;this.currentPath=[],A(this,$E,new Path2D);this.addCommands({cmd:()=>{this.allRawPaths.push(n),this.paths.push(a),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(o(this,MC,GC).call(this),o(this,XC,VC).call(this)),o(this,aB,tB).call(this))},mustExec:!0})},CC=new WeakSet,BC=function(){if(!t(this,rC))return;A(this,rC,!1);Math.ceil(this.thickness*this.parentScale);const r=this.currentPath.slice(-3),e=r.map((r=>r[0])),a=r.map((r=>r[1]));Math.min(...e),Math.max(...e),Math.min(...a),Math.max(...a);const{ctx:i}=this;i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(const r of this.bezierPath2D)i.stroke(r);i.stroke(t(this,$E)),i.restore()},_C=new WeakSet,ZC=function(r,e,a,t,i,A,n){const o=(e+t)/2,s=(a+i)/2,f=(t+A)/2,l=(i+n)/2;r.bezierCurveTo(o+2*(t-o)/3,s+2*(i-s)/3,f+2*(t-f)/3,l+2*(i-l)/3,f,l)},WC=new WeakSet,IC=function(){const r=this.currentPath;if(r.length<=2)return[[r[0],r[0],r.at(-1),r.at(-1)]];const e=[];let a,[t,i]=r[0];for(a=1;a<r.length-2;a++){const[A,n]=r[a],[o,s]=r[a+1],f=(A+o)/2,l=(n+s)/2,u=[t+2*(A-t)/3,i+2*(n-i)/3],c=[f+2*(A-f)/3,l+2*(n-l)/3];e.push([[t,i],u,c,[f,l]]),[t,i]=[f,l]}const[A,n]=r[a],[o,s]=r[a+1],f=[t+2*(A-t)/3,i+2*(n-i)/3],l=[o+2*(A-o)/3,s+2*(n-s)/3];return e.push([[t,i],f,l,[o,s]]),e},RC=new WeakSet,FC=function(){if(this.isEmpty())return void o(this,jC,LC).call(this);o(this,hC,bC).call(this);const{canvas:r,ctx:e}=this;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,r.width,r.height),o(this,jC,LC).call(this);for(const r of this.bezierPath2D)e.stroke(r)},SC=new WeakSet,xC=function(r){this.canvas.removeEventListener("pointerleave",t(this,UE)),this.canvas.removeEventListener("pointermove",t(this,QE)),this.canvas.removeEventListener("pointerup",t(this,JE)),this.canvas.addEventListener("pointerdown",t(this,zE),{signal:this._uiManager._signal}),t(this,qE)&&clearTimeout(t(this,qE)),A(this,qE,setTimeout((()=>{A(this,qE,null),this.canvas.removeEventListener("contextmenu",gu)}),10)),o(this,yC,EC).call(this,r.offsetX,r.offsetY),this.addToAnnotationStorage(),this.setInBackground()},MC=new WeakSet,GC=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},XC=new WeakSet,VC=function(){A(this,aC,new ResizeObserver((r=>{const e=r[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}))),t(this,aC).observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{var r;null==(r=t(this,aC))||r.disconnect(),A(this,aC,null)}),{once:!0})},NC=new WeakSet,DC=function(){if(!t(this,eC))return;const[r,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*r),this.canvas.height=Math.ceil(this.height*e),o(this,jC,LC).call(this)},TC=new WeakSet,PC=function(r,e){const a=o(this,rB,eB).call(this),i=(r-a)/t(this,HE),A=(e-a)/t(this,YE);this.scaleFactor=Math.min(i,A)},jC=new WeakSet,LC=function(){const r=o(this,rB,eB).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+r,this.translationY*this.scaleFactor+r)},OC=new WeakSet,YC=function(r){const e=new Path2D;for(let a=0,t=r.length;a<t;a++){const[t,i,A,n]=r[a];0===a&&e.moveTo(...t),e.bezierCurveTo(i[0],i[1],A[0],A[1],n[0],n[1])}return e},HC=new WeakSet,QC=function(r,e,a){const[t,i,A,n]=e;switch(a){case 0:for(let e=0,a=r.length;e<a;e+=2)r[e]+=t,r[e+1]=n-r[e+1];break;case 90:for(let e=0,a=r.length;e<a;e+=2){const a=r[e];r[e]=r[e+1]+t,r[e+1]=a+i}break;case 180:for(let e=0,a=r.length;e<a;e+=2)r[e]=A-r[e],r[e+1]+=i;break;case 270:for(let e=0,a=r.length;e<a;e+=2){const a=r[e];r[e]=A-r[e+1],r[e+1]=n-a}break;default:throw new Error("Invalid rotation")}return r},UC=new WeakSet,JC=function(r,e,a){const[t,i,A,n]=e;switch(a){case 0:for(let e=0,a=r.length;e<a;e+=2)r[e]-=t,r[e+1]=n-r[e+1];break;case 90:for(let e=0,a=r.length;e<a;e+=2){const a=r[e];r[e]=r[e+1]-i,r[e+1]=a-t}break;case 180:for(let e=0,a=r.length;e<a;e+=2)r[e]=A-r[e],r[e+1]-=i;break;case 270:for(let e=0,a=r.length;e<a;e+=2){const a=r[e];r[e]=n-r[e+1],r[e+1]=A-a}break;default:throw new Error("Invalid rotation")}return r},zC=new WeakSet,qC=function(r,e,a,t){var i,A;const n=[],s=this.thickness/2,f=r*e+s,l=r*a+s;for(const e of this.paths){const a=[],s=[];for(let t=0,i=e.length;t<i;t++){const[A,n,o,u]=e[t];if(A[0]===u[0]&&A[1]===u[1]&&1===i){const e=r*A[0]+f,t=r*A[1]+l;a.push(e,t),s.push(e,t);break}const c=r*A[0]+f,d=r*A[1]+l,h=r*n[0]+f,b=r*n[1]+l,g=r*o[0]+f,p=r*o[1]+l,v=r*u[0]+f,m=r*u[1]+l;0===t&&(a.push(c,d),s.push(c,d)),a.push(h,b,g,p,v,m),s.push(h,b),t===i-1&&s.push(v,m)}n.push({bezier:o(i=iB,HC,QC).call(i,a,t,this.rotation),points:o(A=iB,HC,QC).call(A,s,t,this.rotation)})}return n},$C=new WeakSet,KC=function(){let r=1/0,e=-1/0,a=1/0,t=-1/0;for(const i of this.paths)for(const[A,n,o,s]of i){const i=nl.bezierBoundingBox(...A,...n,...o,...s);r=Math.min(r,i[0]),a=Math.min(a,i[1]),e=Math.max(e,i[2]),t=Math.max(t,i[3])}return[r,a,e,t]},rB=new WeakSet,eB=function(){return t(this,KE)?Math.ceil(this.thickness*this.parentScale):0},aB=new WeakSet,tB=function(r=!1){if(this.isEmpty())return;if(!t(this,KE))return void o(this,RC,FC).call(this);const e=o(this,$C,KC).call(this),a=o(this,rB,eB).call(this);A(this,HE,Math.max(ob.MIN_SIZE,e[2]-e[0])),A(this,YE,Math.max(ob.MIN_SIZE,e[3]-e[1]));const i=Math.ceil(a+t(this,HE)*this.scaleFactor),n=Math.ceil(a+t(this,YE)*this.scaleFactor),[s,f]=this.parentDimensions;this.width=i/s,this.height=n/f,this.setAspectRatio(i,n);const l=this.translationX,u=this.translationY;this.translationX=-e[0],this.translationY=-e[1],o(this,NC,DC).call(this),o(this,RC,FC).call(this),A(this,tC,i),A(this,iC,n),this.setDims(i,n);const c=r?a/this.scaleFactor/2:0;this.translate(l-this.translationX-c,u-this.translationY-c)},i(AB,OC),i(AB,HC),i(AB,UC),e(AB,"_defaultColor",null),e(AB,"_defaultOpacity",1),e(AB,"_defaultThickness",1),e(AB,"_type","ink"),e(AB,"_editorType",qs.INK);const GB=class extends ob{constructor(r){super({...r,name:"stampEditor"}),i(this,pB),i(this,mB),i(this,wB),i(this,EB),i(this,BB),i(this,ZB),i(this,IB),i(this,FB),i(this,xB),i(this,nB,null),i(this,oB,null),i(this,sB,null),i(this,fB,null),i(this,lB,null),i(this,uB,""),i(this,cB,null),i(this,dB,null),i(this,hB,null),i(this,bB,!1),i(this,gB,!1),A(this,fB,r.bitmapUrl),A(this,lB,r.bitmapFile)}static initialize(r,e){ob.initialize(r,e)}static get supportedTypes(){return jf(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((r=>`image/${r}`)))}static get supportedTypesStr(){return jf(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(r){return this.supportedTypes.includes(r)}static paste(r,e){e.pasteEditor(qs.STAMP,{bitmapFile:r.getAsFile()})}remove(){var r,e;t(this,oB)&&(A(this,nB,null),this._uiManager.imageManager.deleteId(t(this,oB)),null==(r=t(this,cB))||r.remove(),A(this,cB,null),null==(e=t(this,dB))||e.disconnect(),A(this,dB,null),t(this,hB)&&(clearTimeout(t(this,hB)),A(this,hB,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(t(this,oB)&&null===t(this,cB)&&o(this,wB,yB).call(this),this.isAttachedToDOM||this.parent.add(this))):t(this,oB)&&o(this,wB,yB).call(this)}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(t(this,sB)||t(this,nB)||t(this,fB)||t(this,lB)||t(this,oB))}get isResizable(){return!0}render(){if(this.div)return this.div;let r,e;if(this.width&&(r=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),t(this,nB)?o(this,EB,CB).call(this):o(this,wB,yB).call(this),this.width){const[a,t]=this.parentDimensions;this.setAt(r*a,e*t,this.width*a,this.height*t)}return this.div}getImageForAltText(){return t(this,cB)}static deserialize(r,e,a){if(r instanceof Ok)return null;const t=super.deserialize(r,e,a),{rect:i,bitmapUrl:n,bitmapId:o,isSvg:s,accessibilityData:f}=r;o&&a.imageManager.isValidId(o)?A(t,oB,o):A(t,fB,n),A(t,bB,s);const[l,u]=t.pageDimensions;return t.width=(i[2]-i[0])/l,t.height=(i[3]-i[1])/u,f&&(t.altTextData=f),t}serialize(r=!1,e=null){if(this.isEmpty())return null;const a={annotationType:qs.STAMP,bitmapId:t(this,oB),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:t(this,bB),structTreeParentId:this._structTreeParentId};if(r)return a.bitmapUrl=o(this,FB,SB).call(this,!0),a.accessibilityData=this.altTextData,a;const{decorative:i,altText:A}=this.altTextData;if(!i&&A&&(a.accessibilityData={type:"Figure",alt:A}),null===e)return a;e.stamps||(e.stamps=new Map);const n=t(this,bB)?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(e.stamps.has(t(this,oB))){if(t(this,bB)){const r=e.stamps.get(t(this,oB));n>r.area&&(r.area=n,r.serialized.bitmap.close(),r.serialized.bitmap=o(this,FB,SB).call(this,!1))}}else e.stamps.set(t(this,oB),{area:n,serialized:a}),a.bitmap=o(this,FB,SB).call(this,!1);return a}};let XB=GB;var VB,NB,DB,TB,PB,jB,LB,OB,YB,HB,QB,UB,JB,zB,qB,$B,KB,r_,e_,a_,t_,i_,A_,n_;nB=new WeakMap,oB=new WeakMap,sB=new WeakMap,fB=new WeakMap,lB=new WeakMap,uB=new WeakMap,cB=new WeakMap,dB=new WeakMap,hB=new WeakMap,bB=new WeakMap,gB=new WeakMap,pB=new WeakSet,vB=function(r,e=!1){r?(A(this,nB,r.bitmap),e||(A(this,oB,r.id),A(this,bB,r.isSvg)),r.file&&A(this,uB,r.file.name),o(this,EB,CB).call(this)):this.remove()},mB=new WeakSet,kB=function(){A(this,sB,null),this._uiManager.enableWaiting(!1),t(this,cB)&&this.div.focus()},wB=new WeakSet,yB=function(){if(t(this,oB))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(t(this,oB)).then((r=>o(this,pB,vB).call(this,r,!0))).finally((()=>o(this,mB,kB).call(this)));if(t(this,fB)){const r=t(this,fB);return A(this,fB,null),this._uiManager.enableWaiting(!0),void A(this,sB,this._uiManager.imageManager.getFromUrl(r).then((r=>o(this,pB,vB).call(this,r))).finally((()=>o(this,mB,kB).call(this))))}if(t(this,lB)){const r=t(this,lB);return A(this,lB,null),this._uiManager.enableWaiting(!0),void A(this,sB,this._uiManager.imageManager.getFromFile(r).then((r=>o(this,pB,vB).call(this,r))).finally((()=>o(this,mB,kB).call(this))))}const r=document.createElement("input");r.type="file",r.accept=GB.supportedTypesStr;const e=this._uiManager._signal;A(this,sB,new Promise((a=>{r.addEventListener("change",(async()=>{if(r.files&&0!==r.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(r.files[0]);o(this,pB,vB).call(this,e)}else this.remove();a()}),{signal:e}),r.addEventListener("cancel",(()=>{this.remove(),a()}),{signal:e})})).finally((()=>o(this,mB,kB).call(this)))),r.click()},EB=new WeakSet,CB=function(){const{div:r}=this;let{width:e,height:a}=t(this,nB);const[i,n]=this.pageDimensions,s=.75;if(this.width)e=this.width*i,a=this.height*n;else if(e>s*i||a>s*n){const r=Math.min(s*i/e,s*n/a);e*=r,a*=r}const[f,l]=this.parentDimensions;this.setDims(e*f/i,a*l/n),this._uiManager.enableWaiting(!1);const u=A(this,cB,document.createElement("canvas"));r.append(u),r.hidden=!1,o(this,IB,RB).call(this,e,a),o(this,xB,MB).call(this),t(this,gB)||(this.parent.addUndoableEditor(this),A(this,gB,!0)),this._reportTelemetry({action:"inserted_image"}),t(this,uB)&&u.setAttribute("aria-label",t(this,uB))},BB=new WeakSet,_B=function(r,e){var a;const[i,n]=this.parentDimensions;this.width=r/i,this.height=e/n,this.setDims(r,e),null!=(a=this._initialOptions)&&a.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==t(this,hB)&&clearTimeout(t(this,hB)),A(this,hB,setTimeout((()=>{A(this,hB,null),o(this,IB,RB).call(this,r,e)}),200))},ZB=new WeakSet,WB=function(r,e){const{width:a,height:i}=t(this,nB);let A=a,n=i,o=t(this,nB);for(;A>2*r||n>2*e;){const a=A,t=n;A>2*r&&(A=A>=16384?Math.floor(A/2)-1:Math.ceil(A/2)),n>2*e&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2));const i=new OffscreenCanvas(A,n);i.getContext("2d").drawImage(o,0,0,a,t,0,0,A,n),o=i.transferToImageBitmap()}return o},IB=new WeakSet,RB=function(r,e){r=Math.ceil(r),e=Math.ceil(e);const a=t(this,cB);if(!a||a.width===r&&a.height===e)return;a.width=r,a.height=e;const i=t(this,bB)?t(this,nB):o(this,ZB,WB).call(this,r,e);if(this._uiManager.hasMLManager&&!this.hasAltText()){const a=new OffscreenCanvas(r,e).getContext("2d");a.drawImage(i,0,0,i.width,i.height,0,0,r,e),this._uiManager.mlGuess({service:"image-to-text",request:{data:a.getImageData(0,0,r,e).data,width:r,height:e,channels:4}}).then((r=>{const e=(null==r?void 0:r.output)||"";this.parent&&e&&!this.hasAltText()&&(this.altTextData={altText:e,decorative:!1})}))}const A=a.getContext("2d");A.filter=this._uiManager.hcmFilter,A.drawImage(i,0,0,i.width,i.height,0,0,r,e)},FB=new WeakSet,SB=function(r){if(r){if(t(this,bB)){const r=this._uiManager.imageManager.getSvgUrl(t(this,oB));if(r)return r}const r=document.createElement("canvas");return({width:r.width,height:r.height}=t(this,nB)),r.getContext("2d").drawImage(t(this,nB),0,0),r.toDataURL()}if(t(this,bB)){const[r,e]=this.pageDimensions,a=Math.round(this.width*r*Il.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*Il.PDF_TO_CSS_UNITS),A=new OffscreenCanvas(a,i);return A.getContext("2d").drawImage(t(this,nB),0,0,t(this,nB).width,t(this,nB).height,0,0,a,i),A.transferToImageBitmap()}return structuredClone(t(this,nB))},xB=new WeakSet,MB=function(){this._uiManager._signal&&(A(this,dB,new ResizeObserver((r=>{const e=r[0].contentRect;e.width&&e.height&&o(this,BB,_B).call(this,e.width,e.height)}))),t(this,dB).observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{var r;null==(r=t(this,dB))||r.disconnect(),A(this,dB,null)}),{once:!0}))},e(XB,"_type","stamp"),e(XB,"_editorType",qs.STAMP);const o_=class{constructor({uiManager:r,pageIndex:e,div:a,accessibilityManager:n,annotationLayer:o,drawLayer:s,textLayer:f,viewport:l,l10n:u}){i(this,qB),i(this,KB),i(this,e_),i(this,t_),i(this,A_),i(this,VB,void 0),i(this,NB,!1),i(this,DB,null),i(this,TB,null),i(this,PB,null),i(this,jB,null),i(this,LB,null),i(this,OB,new Map),i(this,YB,!1),i(this,HB,!1),i(this,QB,!1),i(this,UB,null),i(this,JB,void 0);const c=[...t(o_,zB).values()];if(!o_._initialized){o_._initialized=!0;for(const e of c)e.initialize(u,r)}r.registerEditorTypes(c),A(this,JB,r),this.pageIndex=e,this.div=a,A(this,VB,n),A(this,DB,o),this.viewport=l,A(this,UB,f),this.drawLayer=s,t(this,JB).addLayer(this)}get isEmpty(){return 0===t(this,OB).size}get isInvisible(){return this.isEmpty&&t(this,JB).getMode()===qs.NONE}updateToolbar(r){t(this,JB).updateToolbar(r)}updateMode(r=t(this,JB).getMode()){switch(o(this,A_,n_).call(this),r){case qs.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case qs.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case qs.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const a of t(o_,zB).values())e.toggle(`${a._type}Editing`,r===a._editorType);this.div.hidden=!1}hasTextLayer(r){var e;return r===(null==(e=t(this,UB))?void 0:e.div)}addInkEditorIfNeeded(r){if(t(this,JB).getMode()===qs.INK){if(!r)for(const r of t(this,OB).values())if(r.isEmpty())return void r.setInBackground();this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(r){t(this,JB).setEditingState(r)}addCommands(r){t(this,JB).addCommands(r)}togglePointerEvents(r=!1){this.div.classList.toggle("disabled",!r)}toggleAnnotationLayerPointerEvents(r=!1){var e;null==(e=t(this,DB))||e.div.classList.toggle("disabled",!r)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const r=new Set;for(const e of t(this,OB).values())e.enableEditing(),e.show(!0),e.annotationElementId&&(t(this,JB).removeChangedExistingAnnotation(e),r.add(e.annotationElementId));if(!t(this,DB))return;const e=t(this,DB).getEditableAnnotations();for(const a of e){if(a.hide(),t(this,JB).isDeletedAnnotationElement(a.data.id)||r.has(a.data.id))continue;const e=this.deserialize(a);e&&(this.addOrRebuild(e),e.enableEditing())}}disable(){var r;A(this,QB,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,a=new Map;for(const i of t(this,OB).values())if(i.disableEditing(),i.annotationElementId){if(null!==i.serialize()){e.set(i.annotationElementId,i);continue}a.set(i.annotationElementId,i),null==(r=this.getEditableAnnotation(i.annotationElementId))||r.show(),i.remove()}if(t(this,DB)){const r=t(this,DB).getEditableAnnotations();for(const i of r){const{id:r}=i.data;if(t(this,JB).isDeletedAnnotationElement(r))continue;let A=a.get(r);A?(A.resetAnnotationElement(i),A.show(!1),i.show()):(A=e.get(r),A&&(t(this,JB).addChangedExistingAnnotation(A),A.renderAnnotationElement(i),A.show(!1)),i.show())}}o(this,A_,n_).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const r of t(o_,zB).values())i.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),A(this,QB,!1)}getEditableAnnotation(r){var e;return(null==(e=t(this,DB))?void 0:e.getEditableAnnotation(r))||null}setActiveEditor(r){t(this,JB).getActive()!==r&&t(this,JB).setActiveEditor(r)}enableTextSelection(){var r;this.div.tabIndex=-1,null!=(r=t(this,UB))&&r.div&&!t(this,jB)&&(A(this,jB,o(this,qB,$B).bind(this)),t(this,UB).div.addEventListener("pointerdown",t(this,jB),{signal:t(this,JB)._signal}),t(this,UB).div.classList.add("highlighting"))}disableTextSelection(){var r;this.div.tabIndex=0,null!=(r=t(this,UB))&&r.div&&t(this,jB)&&(t(this,UB).div.removeEventListener("pointerdown",t(this,jB)),A(this,jB,null),t(this,UB).div.classList.remove("highlighting"))}enableClick(){if(t(this,PB))return;const r=t(this,JB)._signal;A(this,PB,this.pointerdown.bind(this)),A(this,TB,this.pointerup.bind(this)),this.div.addEventListener("pointerdown",t(this,PB),{signal:r}),this.div.addEventListener("pointerup",t(this,TB),{signal:r})}disableClick(){t(this,PB)&&(this.div.removeEventListener("pointerdown",t(this,PB)),this.div.removeEventListener("pointerup",t(this,TB)),A(this,PB,null),A(this,TB,null))}attach(r){t(this,OB).set(r.id,r);const{annotationElementId:e}=r;e&&t(this,JB).isDeletedAnnotationElement(e)&&t(this,JB).removeDeletedAnnotationElement(r)}detach(r){var e;t(this,OB).delete(r.id),null==(e=t(this,VB))||e.removePointerInTextLayer(r.contentDiv),!t(this,QB)&&r.annotationElementId&&t(this,JB).addDeletedAnnotationElement(r)}remove(r){this.detach(r),t(this,JB).removeEditor(r),r.div.remove(),r.isAttachedToDOM=!1,t(this,HB)||this.addInkEditorIfNeeded(!1)}changeParent(r){var e;r.parent!==this&&(r.parent&&r.annotationElementId&&(t(this,JB).addDeletedAnnotationElement(r.annotationElementId),ob.deleteAnnotationElement(r),r.annotationElementId=null),this.attach(r),null==(e=r.parent)||e.detach(r),r.setParent(this),r.div&&r.isAttachedToDOM&&(r.div.remove(),this.div.append(r.div)))}add(r){if(r.parent!==this||!r.isAttachedToDOM){if(this.changeParent(r),t(this,JB).addEditor(r),this.attach(r),!r.isAttachedToDOM){const e=r.render();this.div.append(e),r.isAttachedToDOM=!0}r.fixAndSetPosition(),r.onceAdded(),t(this,JB).addToAnnotationStorage(r),r._reportTelemetry(r.telemetryInitialData)}}moveEditorInDOM(r){var e;if(!r.isAttachedToDOM)return;const{activeElement:a}=document;r.div.contains(a)&&!t(this,LB)&&(r._focusEventsAllowed=!1,A(this,LB,setTimeout((()=>{A(this,LB,null),r.div.contains(document.activeElement)?r._focusEventsAllowed=!0:(r.div.addEventListener("focusin",(()=>{r._focusEventsAllowed=!0}),{once:!0,signal:t(this,JB)._signal}),a.focus())}),0))),r._structTreeParentId=null==(e=t(this,VB))?void 0:e.moveElementInDOM(this.div,r.div,r.contentDiv,!0)}addOrRebuild(r){r.needsToBeRebuilt()?(r.parent||(r.parent=this),r.rebuild(),r.show()):this.add(r)}addUndoableEditor(r){this.addCommands({cmd:()=>r._uiManager.rebuild(r),undo:()=>{r.remove()},mustExec:!1})}getNextId(){return t(this,JB).getId()}get _signal(){return t(this,JB)._signal}canCreateNewEmptyEditor(){var r;return null==(r=t(this,KB,r_))?void 0:r.canCreateNewEmptyEditor()}pasteEditor(r,e){t(this,JB).updateToolbar(r),t(this,JB).updateMode(r);const{offsetX:a,offsetY:i}=o(this,t_,i_).call(this),A=this.getNextId(),n=o(this,e_,a_).call(this,{parent:this,id:A,x:a,y:i,uiManager:t(this,JB),isCentered:!0,...e});n&&this.add(n)}deserialize(r){var e;return(null==(e=t(o_,zB).get(r.annotationType??r.annotationEditorType))?void 0:e.deserialize(r,this,t(this,JB)))||null}createAndAddNewEditor(r,e,a={}){const i=this.getNextId(),A=o(this,e_,a_).call(this,{parent:this,id:i,x:r.offsetX,y:r.offsetY,uiManager:t(this,JB),isCentered:e,...a});return A&&this.add(A),A}addNewEditor(){this.createAndAddNewEditor(o(this,t_,i_).call(this),!0)}setSelected(r){t(this,JB).setSelected(r)}toggleSelected(r){t(this,JB).toggleSelected(r)}isSelected(r){return t(this,JB).isSelected(r)}unselect(r){t(this,JB).unselect(r)}pointerup(r){const{isMac:e}=rl.platform;if(!(0!==r.button||r.ctrlKey&&e)&&r.target===this.div&&t(this,YB)){if(A(this,YB,!1),!t(this,NB))return void A(this,NB,!0);if(t(this,JB).getMode()===qs.STAMP)return void t(this,JB).unselectAll();this.createAndAddNewEditor(r,!1)}}pointerdown(r){if(t(this,JB).getMode()===qs.HIGHLIGHT&&this.enableTextSelection(),t(this,YB))return void A(this,YB,!1);const{isMac:e}=rl.platform;if(0!==r.button||r.ctrlKey&&e||r.target!==this.div)return;A(this,YB,!0);const a=t(this,JB).getActive();A(this,NB,!a||a.isEmpty())}findNewParent(r,e,a){const i=t(this,JB).findParent(e,a);return null!==i&&i!==this&&(i.changeParent(r),!0)}destroy(){var r,e;(null==(r=t(this,JB).getActive())?void 0:r.parent)===this&&(t(this,JB).commitOrRemove(),t(this,JB).setActiveEditor(null)),t(this,LB)&&(clearTimeout(t(this,LB)),A(this,LB,null));for(const r of t(this,OB).values())null==(e=t(this,VB))||e.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,t(this,OB).clear(),t(this,JB).removeLayer(this)}render({viewport:r}){this.viewport=r,Cu(this.div,r);for(const r of t(this,JB).getEditors(this.pageIndex))this.add(r),r.rebuild();this.updateMode()}update({viewport:r}){t(this,JB).commitOrRemove(),o(this,A_,n_).call(this);const e=this.viewport.rotation,a=r.rotation;if(this.viewport=r,Cu(this.div,{rotation:a}),e!==a)for(const r of t(this,OB).values())r.rotate(a);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:r,pageHeight:e}=this.viewport.rawDims;return[r,e]}get scale(){return t(this,JB).viewParameters.realScale}};let s_=o_;var f_,l_,u_,c_,d_,h_,b_,g_,p_,v_;VB=new WeakMap,NB=new WeakMap,DB=new WeakMap,TB=new WeakMap,PB=new WeakMap,jB=new WeakMap,LB=new WeakMap,OB=new WeakMap,YB=new WeakMap,HB=new WeakMap,QB=new WeakMap,UB=new WeakMap,JB=new WeakMap,zB=new WeakMap,qB=new WeakSet,$B=function(r){if(t(this,JB).unselectAll(),r.target===t(this,UB).div){const{isMac:e}=rl.platform;if(0!==r.button||r.ctrlKey&&e)return;t(this,JB).showAllEditors("highlight",!0,!0),t(this,UB).div.classList.add("free"),OE.startHighlighting(this,"ltr"===t(this,JB).direction,r),t(this,UB).div.addEventListener("pointerup",(()=>{t(this,UB).div.classList.remove("free")}),{once:!0,signal:t(this,JB)._signal}),r.preventDefault()}},KB=new WeakSet,r_=function(){return t(o_,zB).get(t(this,JB).getMode())},e_=new WeakSet,a_=function(r){const e=t(this,KB,r_);return e?new e.prototype.constructor(r):null},t_=new WeakSet,i_=function(){const{x:r,y:e,width:a,height:t}=this.div.getBoundingClientRect(),i=Math.max(0,r),A=Math.max(0,e),n=(i+Math.min(window.innerWidth,r+a))/2-r,o=(A+Math.min(window.innerHeight,e+t))/2-e,[s,f]=this.viewport.rotation%180==0?[n,o]:[o,n];return{offsetX:s,offsetY:f}},A_=new WeakSet,n_=function(){A(this,HB,!0);for(const r of t(this,OB).values())r.isEmpty()&&r.remove();A(this,HB,!1)},e(s_,"_initialized",!1),i(s_,zB,new Map([Ew,AB,XB,OE].map((r=>[r._editorType,r]))));const m_=class{constructor({pageIndex:r}){i(this,b_),i(this,p_),i(this,f_,null),i(this,l_,0),i(this,u_,new Map),i(this,c_,new Map),this.pageIndex=r}setParent(r){if(t(this,f_)){if(t(this,f_)!==r){if(t(this,u_).size>0)for(const e of t(this,u_).values())e.remove(),r.append(e);A(this,f_,r)}}else A(this,f_,r)}static get _svgFactory(){return jf(this,"_svgFactory",new ou)}highlight(r,e,a,i=!1){const A=n(this,l_)._++,s=o(this,b_,g_).call(this,r.box);s.classList.add("highlight"),r.free&&s.classList.add("free");const f=m_._svgFactory.createElement("defs");s.append(f);const l=m_._svgFactory.createElement("path");f.append(l);const u=`path_p${this.pageIndex}_${A}`;l.setAttribute("id",u),l.setAttribute("d",r.toSVGPath()),i&&t(this,c_).set(A,l);const c=o(this,p_,v_).call(this,f,u),d=m_._svgFactory.createElement("use");return s.append(d),s.setAttribute("fill",e),s.setAttribute("fill-opacity",a),d.setAttribute("href",`#${u}`),t(this,u_).set(A,s),{id:A,clipPathId:`url(#${c})`}}highlightOutline(r){const e=n(this,l_)._++,a=o(this,b_,g_).call(this,r.box);a.classList.add("highlightOutline");const i=m_._svgFactory.createElement("defs");a.append(i);const A=m_._svgFactory.createElement("path");i.append(A);const s=`path_p${this.pageIndex}_${e}`;let f;if(A.setAttribute("id",s),A.setAttribute("d",r.toSVGPath()),A.setAttribute("vector-effect","non-scaling-stroke"),r.free){a.classList.add("free");const r=m_._svgFactory.createElement("mask");i.append(r),f=`mask_p${this.pageIndex}_${e}`,r.setAttribute("id",f),r.setAttribute("maskUnits","objectBoundingBox");const t=m_._svgFactory.createElement("rect");r.append(t),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("fill","white");const A=m_._svgFactory.createElement("use");r.append(A),A.setAttribute("href",`#${s}`),A.setAttribute("stroke","none"),A.setAttribute("fill","black"),A.setAttribute("fill-rule","nonzero"),A.classList.add("mask")}const l=m_._svgFactory.createElement("use");a.append(l),l.setAttribute("href",`#${s}`),f&&l.setAttribute("mask",`url(#${f})`);const u=l.cloneNode();return a.append(u),l.classList.add("mainOutline"),u.classList.add("secondaryOutline"),t(this,u_).set(e,a),e}finalizeLine(r,e){const a=t(this,c_).get(r);t(this,c_).delete(r),this.updateBox(r,e.box),a.setAttribute("d",e.toSVGPath())}updateLine(r,e){t(this,u_).get(r).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(r){this.remove(r),t(this,c_).delete(r)}updatePath(r,e){t(this,c_).get(r).setAttribute("d",e.toSVGPath())}updateBox(r,e){var a;o(a=m_,d_,h_).call(a,t(this,u_).get(r),e)}show(r,e){t(this,u_).get(r).classList.toggle("hidden",!e)}rotate(r,e){t(this,u_).get(r).setAttribute("data-main-rotation",e)}changeColor(r,e){t(this,u_).get(r).setAttribute("fill",e)}changeOpacity(r,e){t(this,u_).get(r).setAttribute("fill-opacity",e)}addClass(r,e){t(this,u_).get(r).classList.add(e)}removeClass(r,e){t(this,u_).get(r).classList.remove(e)}remove(r){null!==t(this,f_)&&(t(this,u_).get(r).remove(),t(this,u_).delete(r))}destroy(){A(this,f_,null);for(const r of t(this,u_).values())r.remove();t(this,u_).clear()}};let k_=m_;f_=new WeakMap,l_=new WeakMap,u_=new WeakMap,c_=new WeakMap,d_=new WeakSet,h_=function(r,{x:e=0,y:a=0,width:t=1,height:i=1}={}){const{style:A}=r;A.top=100*a+"%",A.left=100*e+"%",A.width=100*t+"%",A.height=100*i+"%"},b_=new WeakSet,g_=function(r){var e;const a=m_._svgFactory.create(1,1,!0);return t(this,f_).append(a),a.setAttribute("aria-hidden",!0),o(e=m_,d_,h_).call(e,a,r),a},p_=new WeakSet,v_=function(r,e){const a=m_._svgFactory.createElement("clipPath");r.append(a);const t=`clip_${e}`;a.setAttribute("id",t),a.setAttribute("clipPathUnits","objectBoundingBox");const i=m_._svgFactory.createElement("use");return a.append(i),i.setAttribute("href",`#${e}`),i.classList.add("clip"),t},i(k_,d_);var w_=Ns.AbortException,y_=Ns.AnnotationEditorLayer,E_=Ns.AnnotationEditorParamsType,C_=Ns.AnnotationEditorType,B_=Ns.AnnotationEditorUIManager,__=Ns.AnnotationLayer,Z_=Ns.AnnotationMode,W_=Ns.CMapCompressionType,I_=Ns.ColorPicker,R_=Ns.DOMSVGFactory,F_=Ns.DrawLayer,S_=Ns.FeatureTest,x_=Ns.GlobalWorkerOptions,M_=Ns.ImageKind,G_=Ns.InvalidPDFException,X_=Ns.MissingPDFException,V_=Ns.OPS,N_=Ns.Outliner,D_=Ns.PDFDataRangeTransport,T_=Ns.PDFDateString,P_=Ns.PDFWorker,j_=Ns.PasswordResponses,L_=Ns.PermissionFlag,O_=Ns.PixelsPerInch,Y_=Ns.RenderingCancelledException,H_=Ns.TextLayer,Q_=Ns.UnexpectedResponseException,U_=Ns.Util,J_=Ns.VerbosityLevel,z_=Ns.XfaLayer,q_=Ns.build,$_=Ns.createValidAbsoluteUrl,K_=Ns.fetchData,rZ=Ns.getDocument,eZ=Ns.getFilenameFromUrl,aZ=Ns.getPdfFilenameFromUrl,tZ=Ns.getXfaPageViewport,iZ=Ns.isDataScheme,AZ=Ns.isPdfFile,nZ=Ns.noContextMenu,oZ=Ns.normalizeUnicode,sZ=Ns.renderTextLayer,fZ=Ns.setLayerDimensions,lZ=Ns.shadow,uZ=Ns.updateTextLayer,cZ=Ns.version;const dZ=Object.freeze(Object.defineProperty({__proto__:null,AbortException:w_,AnnotationEditorLayer:y_,AnnotationEditorParamsType:E_,AnnotationEditorType:C_,AnnotationEditorUIManager:B_,AnnotationLayer:__,AnnotationMode:Z_,CMapCompressionType:W_,ColorPicker:I_,DOMSVGFactory:R_,DrawLayer:F_,FeatureTest:S_,GlobalWorkerOptions:x_,ImageKind:M_,InvalidPDFException:G_,MissingPDFException:X_,OPS:V_,Outliner:N_,PDFDataRangeTransport:D_,PDFDateString:T_,PDFWorker:P_,PasswordResponses:j_,PermissionFlag:L_,PixelsPerInch:O_,RenderingCancelledException:Y_,TextLayer:H_,UnexpectedResponseException:Q_,Util:U_,VerbosityLevel:J_,XfaLayer:z_,build:q_,createValidAbsoluteUrl:$_,fetchData:K_,getDocument:rZ,getFilenameFromUrl:eZ,getPdfFilenameFromUrl:aZ,getXfaPageViewport:tZ,isDataScheme:iZ,isPdfFile:AZ,noContextMenu:nZ,normalizeUnicode:oZ,renderTextLayer:sZ,setLayerDimensions:fZ,shadow:lZ,updateTextLayer:uZ,version:cZ},Symbol.toStringTag,{value:"Module"}));var hZ=globalThis&&globalThis.__spreadArray||function(r,e,a){if(a||2===arguments.length)for(var t,i=0,A=e.length;i<A;i++)(t||!(i in e))&&(t||(t=Array.prototype.slice.call(e,0,i)),t[i]=e[i]);return r.concat(t||Array.prototype.slice.call(e))},bZ=hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ(hZ([],["onCopy","onCut","onPaste"],!0),["onCompositionEnd","onCompositionStart","onCompositionUpdate"],!0),["onFocus","onBlur"],!0),["onInput","onInvalid","onReset","onSubmit"],!0),["onLoad","onError"],!0),["onKeyDown","onKeyPress","onKeyUp"],!0),["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],!0),["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],!0),["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],!0),["onSelect"],!0),["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],!0),["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],!0),["onScroll"],!0),["onWheel"],!0),["onAnimationStart","onAnimationEnd","onAnimationIteration"],!0),["onTransitionEnd"],!0),["onChange"],!0),["onToggle"],!0);function gZ(r,e){var a={};return bZ.forEach((function(t){var i=r[t];i&&(a[t]=e?function(r){return i(r,e(t))}:i)})),a}function pZ(r){var e=!1;return{promise:new Promise((function(a,t){r.then((function(r){return!e&&a(r)})).catch((function(r){return!e&&t(r)}))})),cancel:function(){e=!0}}}function vZ(r){var e,a,t="";if("string"==typeof r||"number"==typeof r)t+=r;else if("object"==typeof r)if(Array.isArray(r)){var i=r.length;for(e=0;e<i;e++)r[e]&&(a=vZ(r[e]))&&(t&&(t+=" "),t+=a)}else for(a in r)r[a]&&(t&&(t+=" "),t+=a);return t}function mZ(){for(var r,e,a=0,t="",i=arguments.length;a<i;a++)(r=arguments[a])&&(e=vZ(r))&&(t&&(t+=" "),t+=e);return t}var kZ="production"===process.env.NODE_ENV,wZ="Invariant failed";function yZ(r,e){if(!r){if(kZ)throw new Error(wZ);var a="function"==typeof e?e():e,t=a?"".concat(wZ,": ").concat(a):wZ;throw new Error(t)}}var EZ=function(){};if("production"!==process.env.NODE_ENV){var CZ=function(r,e){var a=arguments.length;e=new Array(a>1?a-1:0);for(var t=1;t<a;t++)e[t-1]=arguments[t];var i=0,A="Warning: "+r.replace(/%s/g,(function(){return e[i++]}));typeof console<"u"&&console.error(A);try{throw new Error(A)}catch{}};EZ=function(r,e,a){var t=arguments.length;a=new Array(t>2?t-2:0);for(var i=2;i<t;i++)a[i-2]=arguments[i];if(void 0===e)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");r||CZ.apply(null,[e].concat(a))}}const BZ=W(EZ);var _Z=Object.prototype.hasOwnProperty;function ZZ(r,e,a){for(a of r.keys())if(WZ(a,e))return a}function WZ(r,e){var a,t,i;if(r===e)return!0;if(r&&e&&(a=r.constructor)===e.constructor){if(a===Date)return r.getTime()===e.getTime();if(a===RegExp)return r.toString()===e.toString();if(a===Array){if((t=r.length)===e.length)for(;t--&&WZ(r[t],e[t]););return-1===t}if(a===Set){if(r.size!==e.size)return!1;for(t of r)if((i=t)&&"object"==typeof i&&!(i=ZZ(e,i))||!e.has(i))return!1;return!0}if(a===Map){if(r.size!==e.size)return!1;for(t of r)if((i=t[0])&&"object"==typeof i&&!(i=ZZ(e,i))||!WZ(t[1],e.get(i)))return!1;return!0}if(a===ArrayBuffer)r=new Uint8Array(r),e=new Uint8Array(e);else if(a===DataView){if((t=r.byteLength)===e.byteLength)for(;t--&&r.getInt8(t)===e.getInt8(t););return-1===t}if(ArrayBuffer.isView(r)){if((t=r.byteLength)===e.byteLength)for(;t--&&r[t]===e[t];);return-1===t}if(!a||"object"==typeof r){for(a in t=0,r)if(_Z.call(r,a)&&++t&&!_Z.call(e,a)||!(a in e)||!WZ(r[a],e[a]))return!1;return Object.keys(e).length===t}}return r!=r&&e!=e}const IZ=p(null);function RZ({children:r,type:e}){return s("div",{className:`react-pdf__message react-pdf__message--${e}`,children:r})}class FZ{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(r){this.pdfDocument=r}setViewer(r){this.pdfViewer=r}setExternalLinkRel(r){this.externalLinkRel=r}setExternalLinkTarget(r){this.externalLinkTarget=r}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return yZ(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(r){yZ(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=r}get rotation(){return 0}set rotation(r){}goToDestination(r){return new Promise((e=>{yZ(this.pdfDocument,"PDF document not loaded."),yZ(r,"Destination is not specified."),"string"==typeof r?this.pdfDocument.getDestination(r).then(e):Array.isArray(r)?e(r):r.then(e)})).then((r=>{yZ(Array.isArray(r),`"${r}" is not a valid destination array.`);const e=r[0];new Promise((r=>{yZ(this.pdfDocument,"PDF document not loaded."),e instanceof Object?this.pdfDocument.getPageIndex(e).then((e=>{r(e)})).catch((()=>{yZ(!1,`"${e}" is not a valid page reference.`)})):"number"==typeof e?r(e):yZ(!1,`"${e}" is not a valid destination reference.`)})).then((e=>{const a=e+1;yZ(this.pdfViewer,"PDF viewer is not initialized."),yZ(a>=1&&a<=this.pagesCount,`"${a}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({dest:r,pageIndex:e,pageNumber:a})}))}))}navigateTo(r){this.goToDestination(r)}goToPage(r){const e=r-1;yZ(this.pdfViewer,"PDF viewer is not initialized."),yZ(r>=1&&r<=this.pagesCount,`"${r}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:r})}addLinkAttributes(r,e,a){r.href=e,r.rel=this.externalLinkRel||"noopener noreferrer nofollow",r.target=a?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const SZ={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},xZ=typeof document<"u",MZ=xZ&&"file:"===window.location.protocol;function GZ(r){return function(r){return typeof r<"u"}(r)&&null!==r}function XZ(r){return function(r){return"string"==typeof r}(r)&&/^data:/.test(r)}function VZ(r){yZ(XZ(r),"Invalid data URI.");const[e="",a=""]=r.split(",");return-1!==e.split(";").indexOf("base64")?atob(a):unescape(a)}function NZ(){return xZ&&window.devicePixelRatio||1}const DZ="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function TZ(){BZ(!MZ,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${DZ}`)}function PZ(r){null!=r&&r.cancel&&r.cancel()}function jZ(r,e){return Object.defineProperty(r,"width",{get(){return this.view[2]*e},configurable:!0}),Object.defineProperty(r,"height",{get(){return this.view[3]*e},configurable:!0}),Object.defineProperty(r,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(r,"originalHeight",{get(){return this.view[3]},configurable:!0}),r}function LZ(r){return new Promise(((e,a)=>{const t=new FileReader;t.onload=()=>{if(!t.result)return a(new Error("Error while reading a file."));e(t.result)},t.onerror=r=>{if(!r.target)return a(new Error("Error while reading a file."));const{error:e}=r.target;if(!e)return a(new Error("Error while reading a file."));switch(e.code){case e.NOT_FOUND_ERR:return a(new Error("Error while reading a file: File not found."));case e.SECURITY_ERR:return a(new Error("Error while reading a file: Security error."));case e.ABORT_ERR:return a(new Error("Error while reading a file: Aborted."));default:return a(new Error("Error while reading a file."))}},t.readAsArrayBuffer(r)}))}function OZ(r,e){switch(e.type){case"RESOLVE":return{value:e.value,error:void 0};case"REJECT":return{value:!1,error:e.error};case"RESET":return{value:void 0,error:void 0};default:return r}}function YZ(){return m(OZ,{value:void 0,error:void 0})}var HZ=globalThis&&globalThis.__awaiter||function(r,e,a,t){return new(a||(a=Promise))((function(i,A){function n(r){try{s(t.next(r))}catch(r){A(r)}}function o(r){try{s(t.throw(r))}catch(r){A(r)}}function s(r){r.done?i(r.value):function(r){return r instanceof a?r:new a((function(e){e(r)}))}(r.value).then(n,o)}s((t=t.apply(r,e||[])).next())}))},QZ=globalThis&&globalThis.__rest||function(r,e){var a={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.indexOf(t)<0&&(a[t]=r[t]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(r);i<t.length;i++)e.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(r,t[i])&&(a[t[i]]=r[t[i]])}return a};const{PDFDataRangeTransport:UZ}=dZ,JZ=(r,e)=>{switch(e){case SZ.NEED_PASSWORD:r(prompt("Enter the password to open this PDF file."));break;case SZ.INCORRECT_PASSWORD:r(prompt("Invalid password. Please try again."));break}};function zZ(r){return"object"==typeof r&&null!==r&&("data"in r||"range"in r||"url"in r)}const qZ=v((function(r,e){var{children:a,className:t,error:i="Failed to load PDF file.",externalLinkRel:A,externalLinkTarget:n,file:o,inputRef:f,imageResourcesPath:l,loading:u="Loading PDF…",noData:h="No PDF file specified.",onItemClick:b,onLoadError:g,onLoadProgress:p,onLoadSuccess:v,onPassword:m=JZ,onSourceError:E,onSourceSuccess:C,options:B,renderMode:_,rotate:Z}=r,W=QZ(r,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[I,R]=YZ(),{value:F,error:S}=I,[x,M]=YZ(),{value:G,error:X}=x,V=d(new FZ),N=d([]),D=d(void 0),T=d(void 0);o&&o!==D.current&&zZ(o)&&(BZ(!WZ(o,D.current),'File prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.'),D.current=o),B&&B!==T.current&&(BZ(!WZ(B,T.current),'Options prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.'),T.current=B);const P=d({scrollPageIntoView:r=>{const{dest:e,pageNumber:a,pageIndex:t=a-1}=r;if(b)return void b({dest:e,pageIndex:t,pageNumber:a});const i=N.current[t];i?i.scrollIntoView():BZ(!1,`An internal link leading to page ${a} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});w(e,(()=>({linkService:V,pages:N,viewer:P})),[]),k((function(){R({type:"RESET"})}),[o,R]);const j=y((()=>HZ(this,void 0,void 0,(function*(){if(!o)return null;if("string"==typeof o)return XZ(o)?{data:VZ(o)}:(TZ(),{url:o});if(o instanceof UZ)return{range:o};if(o instanceof ArrayBuffer)return{data:o};if(xZ&&function(r){return yZ(xZ,"isBlob can only be used in a browser environment"),r instanceof Blob}(o))return{data:yield LZ(o)};if(yZ("object"==typeof o,"Invalid parameter in file, need either Uint8Array, string or a parameter object"),yZ(zZ(o),"Invalid parameter object: need either .data, .range or .url"),"url"in o&&"string"==typeof o.url){if(XZ(o.url)){const{url:r}=o,e=QZ(o,["url"]),a=VZ(r);return Object.assign({data:a},e)}TZ()}return o}))),[o]);k((()=>{const r=pZ(j());return r.promise.then((r=>{R({type:"RESOLVE",value:r})})).catch((r=>{R({type:"REJECT",error:r})})),()=>{PZ(r)}}),[j,R]),k((()=>{if(!(typeof F>"u")){if(!1===F)return void(S&&(BZ(!1,S.toString()),E&&E(S)));C&&C()}}),[F]),k((function(){M({type:"RESET"})}),[M,F]),k((function(){if(!F)return;const r=Object.assign(Object.assign({},F),B),e=rZ(r);p&&(e.onProgress=p),m&&(e.onPassword=m);const a=e;return a.promise.then((r=>{M({type:"RESOLVE",value:r})})).catch((r=>{a.destroyed||M({type:"REJECT",error:r})})),()=>{a.destroy()}}),[B,M,F]),k((()=>{if(!(typeof G>"u")){if(!1===G)return void(X&&(BZ(!1,X.toString()),g&&g(X)));G&&(v&&v(G),N.current=new Array(G.numPages),V.current.setDocument(G))}}),[G]),k((function(){V.current.setViewer(P.current),V.current.setExternalLinkRel(A),V.current.setExternalLinkTarget(n)}),[A,n]);const L=y(((r,e)=>{N.current[r]=e}),[]),O=y((r=>{delete N.current[r]}),[]),Y=c((()=>({imageResourcesPath:l,linkService:V.current,onItemClick:b,pdf:G,registerPage:L,renderMode:_,rotate:Z,unregisterPage:O})),[l,b,G,L,_,Z,O]),H=c((()=>gZ(W,(()=>G))),[W,G]);return s("div",Object.assign({className:mZ("react-pdf__Document",t),ref:f,style:{"--scale-factor":"1"}},H,{children:o?null==G?s(RZ,{type:"loading",children:"function"==typeof u?u():u}):!1===G?s(RZ,{type:"error",children:"function"==typeof i?i():i}):s(IZ.Provider,{value:Y,children:a}):s(RZ,{type:"no-data",children:"function"==typeof h?h():h})}))})),$Z=qZ;function KZ(){return g(IZ)}function rW(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var a=r.filter(Boolean);return a.length<=1?a[0]||null:function(r){a.forEach((function(e){"function"==typeof e?e(r):e&&(e.current=r)}))}}const eW=p(null),aW={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},tW=/^H(\d+)$/;function iW(r){return"children"in r}function AW(r){return!!iW(r)&&(1===r.children.length&&0 in r.children&&"id"in r.children[0])}function nW(r){const e={};if(iW(r)){const{role:a}=r,t=a.match(tW);if(t)e.role="heading",e["aria-level"]=Number(t[1]);else if(function(r){return r in aW}(a)){const r=aW[a];r&&(e.role=r)}}return e}function oW(r){const e={};if(iW(r)){if(void 0!==r.alt&&(e["aria-label"]=r.alt),void 0!==r.lang&&(e.lang=r.lang),AW(r)){const[a]=r.children;if(a){const r=oW(a);return Object.assign(Object.assign({},e),r)}}}else"id"in r&&(e["aria-owns"]=r.id);return e}function sW(r){return r?Object.assign(Object.assign({},nW(r)),oW(r)):null}function fW({className:r,node:e}){const a=c((()=>sW(e)),[e]),t=c((()=>!iW(e)||AW(e)?null:e.children.map(((r,e)=>s(fW,{node:r},e)))),[e]);return s("span",Object.assign({className:r},a,{children:t}))}function lW(){return g(eW)}function uW(){const r=lW();yZ(r,"Unable to find Page context.");const{onGetStructTreeError:e,onGetStructTreeSuccess:a}=r,[t,i]=YZ(),{value:A,error:n}=t,{customTextRenderer:o,page:f}=r;return k((function(){i({type:"RESET"})}),[i,f]),k((function(){if(o||!f)return;const r=pZ(f.getStructTree()),e=r;return r.promise.then((r=>{i({type:"RESOLVE",value:r})})).catch((r=>{i({type:"REJECT",error:r})})),()=>PZ(e)}),[o,f,i]),k((()=>{if(void 0!==A){if(!1===A)return void(n&&(BZ(!1,n.toString()),e&&e(n)));A&&a&&a(A)}}),[A]),A?s(fW,{className:"react-pdf__Page__structTree structTree",node:A}):null}const cW=Z_;function dW(r){const e=lW();yZ(e,"Unable to find Page context.");const a=Object.assign(Object.assign({},e),r),{_className:t,canvasBackground:i,devicePixelRatio:A=NZ(),onRenderError:n,onRenderSuccess:o,page:f,renderForms:l,renderTextLayer:u,rotate:h,scale:b}=a,{canvasRef:g}=r;yZ(f,"Attempted to render page canvas, but no page was specified.");const p=d(null);function v(r){(function(r){return"RenderingCancelledException"===r.name})(r)||(BZ(!1,r.toString()),n&&n(r))}const m=c((()=>f.getViewport({scale:b*A,rotation:h})),[A,f,h,b]),w=c((()=>f.getViewport({scale:b,rotation:h})),[f,h,b]);k((function(){if(!f)return;f.cleanup();const{current:r}=p;if(!r)return;r.width=m.width,r.height=m.height,r.style.width=`${Math.floor(w.width)}px`,r.style.height=`${Math.floor(w.height)}px`,r.style.visibility="hidden";const e={annotationMode:l?cW.ENABLE_FORMS:cW.ENABLE,canvasContext:r.getContext("2d",{alpha:!1}),viewport:m};i&&(e.background=i);const a=f.render(e),t=a;return a.promise.then((()=>{r.style.visibility="",f&&o&&o(jZ(f,b))})).catch(v),()=>PZ(t)}),[i,f,l,m,w]);const E=y((()=>{const{current:r}=p;r&&(r.width=0,r.height=0)}),[]);return k((()=>E),[E]),s("canvas",{className:`${t}__canvas`,dir:"ltr",ref:rW(g,p),style:{display:"block",userSelect:"none"},children:u?s(uW,{}):null})}function hW(){const r=lW();yZ(r,"Unable to find Page context.");const{customTextRenderer:e,onGetTextError:a,onGetTextSuccess:t,onRenderTextLayerError:i,onRenderTextLayerSuccess:A,page:n,pageIndex:o,pageNumber:f,rotate:l,scale:u}=r;yZ(n,"Attempted to load page text content, but no page was specified.");const[h,b]=YZ(),{value:g,error:p}=h,v=d(null),m=d(void 0);BZ(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10),"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer"),k((function(){b({type:"RESET"})}),[n,b]),k((function(){if(!n)return;const r=pZ(n.getTextContent()),e=r;return r.promise.then((r=>{b({type:"RESOLVE",value:r})})).catch((r=>{b({type:"REJECT",error:r})})),()=>PZ(e)}),[n,b]),k((()=>{if(void 0!==g){if(!1===g)return void(p&&(BZ(!1,p.toString()),a&&a(p)));g&&t&&t(g)}}),[g]);const w=y((()=>{A&&A()}),[A]),E=y((r=>{BZ(!1,r.toString()),i&&i(r)}),[i]);const B=c((()=>n.getViewport({scale:u,rotation:l})),[n,l,u]);return C((function(){if(!n||!g)return;const{current:r}=v;if(!r)return;r.innerHTML="";const a=n.streamTextContent({includeMarkedContent:!0}),t=new H_({container:r,textContentSource:a,viewport:B}),i=t;return t.render().then((()=>{const a=document.createElement("div");a.className="endOfContent",r.append(a),m.current=a;const t=r.querySelectorAll('[role="presentation"]');if(e){let r=0;g.items.forEach(((a,i)=>{if(!function(r){return"str"in r}(a))return;const A=t[r];if(!A)return;const n=e(Object.assign({pageIndex:o,pageNumber:f,itemIndex:i},a));A.innerHTML=n,r+=a.str&&a.hasEOL?2:1}))}w()})).catch(E),()=>PZ(i)}),[e,E,w,n,o,f,g,B]),s("div",{className:mZ("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){const r=m.current;r&&r.classList.remove("active")},onMouseDown:function(){const r=m.current;r&&r.classList.add("active")},ref:v})}function bW(){const r=KZ(),e=lW();yZ(e,"Unable to find Page context.");const a=Object.assign(Object.assign({},r),e),{imageResourcesPath:t,linkService:i,onGetAnnotationsError:A,onGetAnnotationsSuccess:n,onRenderAnnotationLayerError:o,onRenderAnnotationLayerSuccess:f,page:l,pdf:u,renderForms:h,rotate:b,scale:g=1}=a;yZ(u,"Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."),yZ(l,"Attempted to load page annotations, but no page was specified."),yZ(i,"Attempted to load page annotations, but no linkService was specified.");const[p,v]=YZ(),{value:m,error:w}=p,y=d(null);BZ(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10),"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations"),k((function(){v({type:"RESET"})}),[v,l]),k((function(){if(!l)return;const r=pZ(l.getAnnotations()),e=r;return r.promise.then((r=>{v({type:"RESOLVE",value:r})})).catch((r=>{v({type:"REJECT",error:r})})),()=>{PZ(e)}}),[v,l]),k((()=>{if(void 0!==m){if(!1===m)return void(w&&(BZ(!1,w.toString()),A&&A(w)));m&&n&&n(m)}}),[m]);const E=c((()=>l.getViewport({scale:g,rotation:b})),[l,b,g]);return k((function(){if(!(u&&l&&i&&m))return;const{current:r}=y;if(!r)return;const e=E.clone({dontFlip:!0}),a={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:r,l10n:null,page:l,viewport:e},A={annotations:m,annotationStorage:u.annotationStorage,div:r,imageResourcesPath:t,linkService:i,page:l,renderForms:h,viewport:e};r.innerHTML="";try{new __(a).render(A),f&&f()}catch(r){BZ(!1,`${n=r}`),o&&o(n)}var n;return()=>{}}),[m,t,i,l,u,h,E]),s("div",{className:mZ("react-pdf__Page__annotations","annotationLayer"),ref:y})}var gW=globalThis&&globalThis.__rest||function(r,e){var a={};for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.indexOf(t)<0&&(a[t]=r[t]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(t=Object.getOwnPropertySymbols(r);i<t.length;i++)e.indexOf(t[i])<0&&Object.prototype.propertyIsEnumerable.call(r,t[i])&&(a[t[i]]=r[t[i]])}return a};const pW=1;function vW(r){const e=KZ(),a=Object.assign(Object.assign({},e),r),{_className:t="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:A,canvasRef:n,children:o,className:l,customRenderer:u,customTextRenderer:h,devicePixelRatio:b,error:g="Failed to load the page.",height:p,inputRef:v,loading:m="Loading page…",noData:w="No page specified.",onGetAnnotationsError:y,onGetAnnotationsSuccess:E,onGetStructTreeError:C,onGetStructTreeSuccess:B,onGetTextError:_,onGetTextSuccess:Z,onLoadError:W,onLoadSuccess:I,onRenderAnnotationLayerError:R,onRenderAnnotationLayerSuccess:F,onRenderError:S,onRenderSuccess:x,onRenderTextLayerError:M,onRenderTextLayerSuccess:G,pageIndex:X,pageNumber:V,pdf:N,registerPage:D,renderAnnotationLayer:T=!0,renderForms:P=!1,renderMode:j="canvas",renderTextLayer:L=!0,rotate:O,scale:Y=pW,unregisterPage:H,width:Q}=a,U=gW(a,["_className","_enableRegisterUnregisterPage","canvasBackground","canvasRef","children","className","customRenderer","customTextRenderer","devicePixelRatio","error","height","inputRef","loading","noData","onGetAnnotationsError","onGetAnnotationsSuccess","onGetStructTreeError","onGetStructTreeSuccess","onGetTextError","onGetTextSuccess","onLoadError","onLoadSuccess","onRenderAnnotationLayerError","onRenderAnnotationLayerSuccess","onRenderError","onRenderSuccess","onRenderTextLayerError","onRenderTextLayerSuccess","pageIndex","pageNumber","pdf","registerPage","renderAnnotationLayer","renderForms","renderMode","renderTextLayer","rotate","scale","unregisterPage","width"]),[J,z]=YZ(),{value:q,error:$}=J,K=d(null);yZ(N,"Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.");const rr=GZ(V)?V-1:X??null,er=V??(GZ(X)?X+1:null),ar=O??(q?q.rotate:null),tr=c((()=>{if(!q)return null;let r=1;const e=Y??pW;if(Q||p){const e=q.getViewport({scale:1,rotation:ar});Q?r=Q/e.width:p&&(r=p/e.height)}return e*r}),[p,q,ar,Y,Q]);k((function(){return()=>{GZ(rr)&&i&&H&&H(rr)}}),[i,N,rr,H]),k((function(){z({type:"RESET"})}),[z,N,rr]),k((function(){if(!N||!er)return;const r=pZ(N.getPage(er)),e=r;return r.promise.then((r=>{z({type:"RESOLVE",value:r})})).catch((r=>{z({type:"REJECT",error:r})})),()=>PZ(e)}),[z,N,er]),k((()=>{if(void 0!==q){if(!1===q)return void($&&(BZ(!1,$.toString()),W&&W($)));!function(){if(I){if(!q||!tr)return;I(jZ(q,tr))}if(i&&D){if(!GZ(rr)||!K.current)return;D(rr,K.current)}}()}}),[q,tr]);const ir=c((()=>q&&GZ(rr)&&er&&GZ(ar)&&GZ(tr)?{_className:t,canvasBackground:A,customTextRenderer:h,devicePixelRatio:b,onGetAnnotationsError:y,onGetAnnotationsSuccess:E,onGetStructTreeError:C,onGetStructTreeSuccess:B,onGetTextError:_,onGetTextSuccess:Z,onRenderAnnotationLayerError:R,onRenderAnnotationLayerSuccess:F,onRenderError:S,onRenderSuccess:x,onRenderTextLayerError:M,onRenderTextLayerSuccess:G,page:q,pageIndex:rr,pageNumber:er,renderForms:P,renderTextLayer:L,rotate:ar,scale:tr}:null),[t,A,h,b,y,E,C,B,_,Z,R,F,S,x,M,G,q,rr,er,P,L,ar,tr]),Ar=c((()=>gZ(U,(()=>q&&(tr?jZ(q,tr):void 0)))),[U,q,tr]),nr=`${rr}@${tr}/${ar}`;function or(){switch(j){case"custom":return yZ(u,'renderMode was set to "custom", but no customRenderer was passed.'),s(u,{},`${nr}_custom`);case"none":return null;default:return s(dW,{canvasRef:n},`${nr}_canvas`)}}return s("div",Object.assign({className:mZ(t,l),"data-page-number":er,ref:rW(v,K),style:{"--scale-factor":`${tr}`,backgroundColor:A||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},Ar,{children:er?null===N||null==q?s(RZ,{type:"loading",children:"function"==typeof m?m():m}):!1===N||!1===q?s(RZ,{type:"error",children:"function"==typeof g?g():g}):f(eW.Provider,{value:ir,children:[or(),L?s(hW,{},`${nr}_text`):null,T?s(bW,{},`${nr}_annotations`):null,o]}):s(RZ,{type:"no-data",children:"function"==typeof w?w():w})}))}BZ(!MZ,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${DZ}`),x_.workerSrc="pdf.worker.mjs";const mW="SET_ZOOM_LEVEL",kW=r=>({type:mW,value:r}),wW="SET_PDF_PAGINATED",yW="SET_NUM_PAGES",EW=r=>({type:yW,value:r}),CW="SET_CURRENT_PAGE",BW=r=>({type:CW,value:r}),_W="SET_CONTAINER_WIDTH",ZW={defaultZoomLevel:1,zoomLevel:1,zoomJump:.1,paginated:!0,numPages:0,currentPage:1,containerWidth:0,disablePageTags:!1},WW=(r=ZW,e)=>{switch(e.type){case mW:{const{value:a}=e;return{...r,zoomLevel:a}}case wW:{const{value:a}=e;return{...r,paginated:a}}case yW:{const{value:a}=e;return{...r,numPages:a}}case CW:{const{value:a}=e;return{...r,currentPage:a}}case _W:{const{value:a}=e;return{...r,containerWidth:a}}default:return r}},IW=p({state:ZW,dispatch:()=>null}),RW=({children:r,mainState:e})=>{var a,t,i,A,n,o,f,l;const[u,c]=m(WW,{...ZW,defaultZoomLevel:(null==(t=null==(a=e.config)?void 0:a.pdfZoom)?void 0:t.defaultZoom)??ZW.defaultZoomLevel,zoomLevel:(null==(A=null==(i=e.config)?void 0:i.pdfZoom)?void 0:A.defaultZoom)??ZW.zoomLevel,zoomJump:(null==(o=null==(n=e.config)?void 0:n.pdfZoom)?void 0:o.zoomJump)??ZW.zoomJump,paginated:(null==(f=e.config)||!f.pdfVerticalScrollByDefault)&&ZW.paginated,disablePageTags:(null==(l=e.config)?void 0:l.disablePageTags)||!1,mainState:e});return s(IW.Provider,{value:{state:u,dispatch:c},children:r})},FW=({pageNum:r})=>{const{state:{paginated:e,zoomLevel:a,numPages:t,currentPage:i,disablePageTags:A,containerWidth:n}}=g(IW),{t:o}=rs(),l=r??i,u=n>0?n*a:void 0;return f(SW,{id:"pdf-page-wrapper",$lastPage:l>=t,children:[!e&&!A&&s(xW,{id:"pdf-page-info",children:o("pdfPluginPageNumber",{currentPage:l,allPagesCount:t})}),s(vW,{pageNumber:l||i,width:u,loading:null})]})},SW=io.div`
|
|
155
155
|
margin-bottom: ${r=>r.$lastPage?"20px":void 0};
|
|
156
156
|
`,xW=io.div`
|
|
157
157
|
padding: 0 0 10px 10px;
|
|
@@ -167,6 +167,7 @@ var r=Object.defineProperty,e=(e,a,t)=>(((e,a,t)=>{a in e?r(e,a,{enumerable:!0,c
|
|
|
167
167
|
flex-direction: column;
|
|
168
168
|
margin: 0 auto;
|
|
169
169
|
overflow-x: auto;
|
|
170
|
+
overflow-y: hidden;
|
|
170
171
|
width: 100%;
|
|
171
172
|
`,VW=r=>s(DW,{...r,reverse:!0}),NW=r=>s(DW,{...r}),DW=r=>{const{color:e,size:a,reverse:t}=r;return s("svg",{width:a||"100%",height:a||"100%",style:{transform:""+(t?"rotate(180deg)":"")},viewBox:"0 0 12 12",version:"1.1",children:s("g",{id:"Icons",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:s("g",{id:"Rounded",transform:"translate(-548.000000, -1000.000000)",children:s("g",{id:"AV",transform:"translate(100.000000, 852.000000)",children:s("g",{id:"-Round-/-AV-/-skip_next",transform:"translate(442.000000, 142.000000)",children:f("g",{children:[s("rect",{id:"Rectangle-Copy-52",x:"0",y:"0",width:"24",height:"24"}),s("path",{d:"M7.58,16.89 L13.35,12.82 C13.91,12.42 13.91,11.58 13.35,11.19 L7.58,7.11 C6.91,6.65 6,7.12 6,7.93 L6,16.07 C6,16.88 6.91,17.35 7.58,16.89 Z M16,7 L16,17 C16,17.55 16.45,18 17,18 C17.55,18 18,17.55 18,17 L18,7 C18,6.45 17.55,6 17,6 C16.45,6 16,6.45 16,7 Z",id:"icon_color",fill:e||"#aaa"})]})})})})})})},TW=r=>{const{color:e,size:a,reverse:t}=r;return f("svg",{width:a||"100%",height:a||"100%",style:{transform:""+(t?"rotate(180deg)":"")},id:"Layer_1",viewBox:"0 0 24 24",children:[s("path",{d:"M20.57,9.43A8,8,0,0,0,5.26,10,5,5,0,1,0,5,20h5V18H5a3,3,0,0,1,0-6,3.1,3.1,0,0,1,.79.12l1.12.31.14-1.15a6,6,0,0,1,11.74-.82l.15.54.54.16A3.46,3.46,0,0,1,22,14.5,3.5,3.5,0,0,1,18.5,18H16v2h2.5A5.48,5.48,0,0,0,20.57,9.43Z",fill:e||"#aaa"}),s("polygon",{points:"12 11 12 15.59 10.71 14.29 9.29 15.71 13 19.41 16.71 15.71 15.29 14.29 14 15.59 14 11 12 11",fill:e||"#aaa"})]})},PW=r=>s(LW,{...r}),jW=r=>s(LW,{...r,reverse:!0}),LW=r=>{const{color:e,size:a,reverse:t}=r;return s("svg",{width:a||"100%",height:a||"100%",viewBox:"0 0 32 32",version:"1.1",children:s("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:s("g",{id:"search-plus-icon",fill:e||"#aaa",children:s("path",{id:"search-plus",d:t?"M 13 13 L 16 13 L 19 13 L 19 16 L 16 16 L 13 16 L 10 16 L 10 13 Z M 19.4271 21.4271 C 18.0372 22.4175 16.3367 23 14.5 23 C 9.8056 23 6 19.1944 6 14.5 C 6 9.8056 9.8056 6 14.5 6 C 19.1944 6 23 9.8056 23 14.5 C 23 16.3367 22.4175 18.0372 21.4271 19.4271 L 27.0119 25.0119 C 27.5621 25.5621 27.5575 26.4425 27.0117 26.9883 L 26.9883 27.0117 C 26.4439 27.5561 25.5576 27.5576 25.0119 27.0119 L 19.4271 21.4271 L 19.4271 21.4271 L 19.4271 21.4271 Z M 14.5 21 C 18.0899 21 21 18.0899 21 14.5 C 21 10.9101 18.0899 8 14.5 8 C 10.9101 8 8 10.9101 8 14.5 C 8 18.0899 10.9101 21 14.5 21 L 14.5 21 Z":"M 13 13 L 13 10 L 16 10 L 16 13 L 19 13 L 19 16 L 16 16 L 16 19 L 13 19 L 13 16 L 10 16 L 10 13 Z M 19.4271 21.4271 C 18.0372 22.4175 16.3367 23 14.5 23 C 9.8056 23 6 19.1944 6 14.5 C 6 9.8056 9.8056 6 14.5 6 C 19.1944 6 23 9.8056 23 14.5 C 23 16.3367 22.4175 18.0372 21.4271 19.4271 L 27.0119 25.0119 C 27.5621 25.5621 27.5575 26.4425 27.0117 26.9883 L 26.9883 27.0117 C 26.4439 27.5561 25.5576 27.5576 25.0119 27.0119 L 19.4271 21.4271 L 19.4271 21.4271 L 19.4271 21.4271 Z M 14.5 21 C 18.0899 21 21 18.0899 21 14.5 C 21 10.9101 18.0899 8 14.5 8 C 10.9101 8 8 10.9101 8 14.5 C 8 18.0899 10.9101 21 14.5 21 L 14.5 21 Z"})})})})},OW=r=>{const{color:e,size:a}=r;return s("svg",{width:a||"100%",height:a||"100%",viewBox:"0 0 24 24",children:s("path",{fill:e||"#aaa",d:"M9.29,13.29,4,18.59V17a1,1,0,0,0-2,0v4a1,1,0,0,0,.08.38,1,1,0,0,0,.54.54A1,1,0,0,0,3,22H7a1,1,0,0,0,0-2H5.41l5.3-5.29a1,1,0,0,0-1.42-1.42ZM5.41,4H7A1,1,0,0,0,7,2H3a1,1,0,0,0-.38.08,1,1,0,0,0-.54.54A1,1,0,0,0,2,3V7A1,1,0,0,0,4,7V5.41l5.29,5.3a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42ZM21,16a1,1,0,0,0-1,1v1.59l-5.29-5.3a1,1,0,0,0-1.42,1.42L18.59,20H17a1,1,0,0,0,0,2h4a1,1,0,0,0,.38-.08,1,1,0,0,0,.54-.54A1,1,0,0,0,22,21V17A1,1,0,0,0,21,16Zm.92-13.38a1,1,0,0,0-.54-.54A1,1,0,0,0,21,2H17a1,1,0,0,0,0,2h1.59l-5.3,5.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L20,5.41V7a1,1,0,0,0,2,0V3A1,1,0,0,0,21.92,2.62Z"})})},YW=r=>{const{color:e,size:a,reverse:t}=r;return s("svg",{width:a||"100%",height:a||"100%",style:{transform:""+(t?"rotate(90deg)":"")},version:"1.1",id:"Scroll_1",viewBox:"0 0 297 297",xmlSpace:"preserve",children:s("path",{fill:e||"#aaa",d:"M206.004,200.723h-31.231V96.277h31.231c0.005,0,0.014,0,0.019,0c5.289,0,9.575-4.287,9.575-9.574\n c0-2.342-0.841-4.488-2.236-6.151L156.168,3.851C154.36,1.428,151.515,0,148.492,0c-3.023,0-5.868,1.428-7.675,3.851L83.302,80.98\n c-2.166,2.902-2.507,6.779-0.883,10.017c1.624,3.236,4.936,5.28,8.559,5.28h31.231v104.445H90.978c-3.623,0-6.934,2.044-8.559,5.28\n c-1.624,3.237-1.283,7.114,0.883,10.017l57.513,77.129c1.808,2.424,4.652,3.852,7.675,3.852c3.023,0,5.868-1.428,7.676-3.852\n l57.514-77.129c2.164-2.902,2.507-6.779,0.883-10.017C212.938,202.767,209.627,200.723,206.004,200.723z"})})},HW=({color:r,size:e,reverse:a})=>s("svg",{width:e||"100%",height:e||"100%",style:{transform:a?"rotate(180deg)":void 0},id:"Layer_1",viewBox:"0 0 512 512",fill:r||"currentColor",xmlns:"http://www.w3.org/2000/svg",children:s("path",{d:"M128 0C92.7 0 64 28.7 64 64v96h64V64H354.7L384 93.3V160h64V93.3c0-17-6.7-33.3-18.7-45.3L400 18.7C388 6.7 371.7 0 354.7 0H128zM384 352v32 64H128V384 368 352H384zm64 32h32c17.7 0 32-14.3 32-32V256c0-35.3-28.7-64-64-64H64c-35.3 0-64 28.7-64 64v96c0 17.7 14.3 32 32 32H64v64c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V384zM432 248a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"})}),QW=()=>{const{state:{currentPage:r,numPages:e},dispatch:a}=g(IW),{t:t}=rs();return f(UW,{id:"pdf-pagination",children:[s(JW,{id:"pdf-pagination-prev",onClick:()=>a(BW(r-1)),disabled:1===r,children:s(VW,{color:"#000",size:"50%"})}),s(qW,{id:"pdf-pagination-info",children:t("pdfPluginPageNumber",{currentPage:r,allPagesCount:e})}),s(zW,{id:"pdf-pagination-next",onClick:()=>a(BW(r+1)),disabled:r>=e,children:s(NW,{color:"#000",size:"50%"})})]})},UW=io.div`
|
|
172
173
|
display: flex;
|