asma-doc-viewer 1.0.28 → 1.0.30
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 +3 -1
- package/dist/asmaDocViewer.es.js.map +1 -1
- package/package.json +121 -117
package/dist/asmaDocViewer.es.js
CHANGED
|
@@ -169,7 +169,7 @@ var r=Object.defineProperty,e=(e,a,t)=>(((e,a,t)=>{a in e?r(e,a,{enumerable:!0,c
|
|
|
169
169
|
width: 100%;
|
|
170
170
|
height: 100%;
|
|
171
171
|
border: 0;
|
|
172
|
-
`;var Ds={d:(r,e)=>{for(var a in e)Ds.o(e,a)&&!Ds.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:e[a]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e)},Ts=globalThis.pdfjsLib={};Ds.d(Ts,{AbortException:()=>qf,AnnotationEditorLayer:()=>lB,AnnotationEditorParamsType:()=>rf,AnnotationEditorType:()=>Ks,AnnotationEditorUIManager:()=>rh,AnnotationLayer:()=>Uk,AnnotationMode:()=>qs,CMapCompressionType:()=>Mf,ColorPicker:()=>Jy,DOMSVGFactory:()=>fu,DrawLayer:()=>yB,FeatureTest:()=>al,GlobalWorkerOptions:()=>cg,ImageKind:()=>ff,InvalidPDFException:()=>Uf,MissingPDFException:()=>Jf,OPS:()=>Gf,Outliner:()=>Ay,PDFDataRangeTransport:()=>gv,PDFDateString:()=>wu,PDFWorker:()=>Gv,PasswordResponses:()=>Xf,PermissionFlag:()=>ef,PixelsPerInch:()=>Fl,RenderingCancelledException:()=>uu,TextLayer:()=>av,UnexpectedResponseException:()=>zf,Util:()=>sl,VerbosityLevel:()=>Sf,XfaLayer:()=>nm,build:()=>am,createValidAbsoluteUrl:()=>Of,fetchData:()=>nu,getDocument:()=>uv,getFilenameFromUrl:()=>hu,getPdfFilenameFromUrl:()=>bu,getXfaPageViewport:()=>yu,isDataScheme:()=>cu,isPdfFile:()=>du,noContextMenu:()=>vu,normalizeUnicode:()=>ul,renderTextLayer:()=>tv,setLayerDimensions:()=>Bu,shadow:()=>Lf,updateTextLayer:()=>iv,version:()=>em});const Ps=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),js=[1,0,0,1,0,0],Os=[.001,0,0,.001,0,0],Ls=1.35,Ys=1,Hs=2,Qs=4,Us=16,Js=32,zs=64,$s=256,qs={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Ks={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},rf={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},ef={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},af=0,tf=1,Af=2,nf=3,of=3,sf=4,ff={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},lf=1,uf=2,cf=3,df=4,hf=5,bf=6,gf=7,pf=8,vf=9,mf=10,kf=11,wf=12,yf=13,Ef=14,Cf=15,_f=16,Bf=17,Zf=20,Wf=1,If=2,Rf=3,Ff=4,xf=5,Sf={ERRORS:0,WARNINGS:1,INFOS:5},Mf={NONE:0,BINARY:1},Gf={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},Xf={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Vf=Sf.WARNINGS;function Nf(){return Vf}function Df(r){Vf>=Sf.INFOS&&console.log(`Info: ${r}`)}function Tf(r){Vf>=Sf.WARNINGS&&console.log(`Warning: ${r}`)}function Pf(r){throw new Error(r)}function jf(r,e){r||Pf(e)}function Of(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 Lf(r,e,a,t=!1){return Object.defineProperty(r,e,{value:a,enumerable:!t,configurable:!0,writable:!1}),a}const Yf=function(){function r(e,a){this.constructor===r&&Pf("Cannot initialize BaseException."),this.message=e,this.name=a}return r.prototype=new Error,r.constructor=r,r}();class Hf extends Yf{constructor(r,e){super(r,"PasswordException"),this.code=e}}class Qf extends Yf{constructor(r,e){super(r,"UnknownErrorException"),this.details=e}}class Uf extends Yf{constructor(r){super(r,"InvalidPDFException")}}class Jf extends Yf{constructor(r){super(r,"MissingPDFException")}}class zf extends Yf{constructor(r,e){super(r,"UnexpectedResponseException"),this.status=e}}class $f extends Yf{constructor(r){super(r,"FormatError")}}class qf extends Yf{constructor(r){super(r,"AbortException")}}function Kf(r){("object"!=typeof r||void 0===(null==r?void 0:r.length))&&Pf("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 rl(r){"string"!=typeof r&&Pf("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 el(r){const e=Object.create(null);for(const[a,t]of r)e[a]=t;return e}class al{static get isLittleEndian(){return Lf(this,"isLittleEndian",function(){const r=new Uint8Array(4);return r[0]=1,1===new Uint32Array(r.buffer,0,1)[0]}())}static get isEvalSupported(){return Lf(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Lf(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&"string"==typeof(null==navigator?void 0:navigator.platform)?Lf(this,"platform",{isMac:navigator.platform.includes("Mac")}):Lf(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){var r,e;return Lf(this,"isCSSRoundSupported",null==(e=null==(r=globalThis.CSS)?void 0:r.supports)?void 0:e.call(r,"width: round(1.5px, 1px)"))}}const tl=Array.from(Array(256).keys(),(r=>r.toString(16).padStart(2,"0")));var il,Al,nl,ol;class sl{static makeHexColor(r,e,a){return`#${tl[r]}${tl[e]}${tl[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,nl,ol).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,nl,ol).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}}il=new WeakSet,Al=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)},nl=new WeakSet,ol=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,il,Al).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,il,Al).call(this,r,e,a,t,i,A,n,s,(-l+h)/b,c),o(this,il,Al).call(this,r,e,a,t,i,A,n,s,(-l-h)/b,c)},i(sl,il),i(sl,nl);let fl=null,ll=null;function ul(r){return fl||(fl=/([\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,ll=new Map([["ſt","ſt"]])),r.replaceAll(fl,((r,e,a)=>e?e.normalize("NFKC"):ll.get(a)))}const cl="pdfjs_internal_id_",dl=0,hl=1,bl=2,gl=3,pl=4,vl=5,ml=6,kl=7,wl=8;class yl{constructor(){this.constructor===yl&&Pf("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 El;const Cl=class{constructor({enableHWA:r=!1}={}){i(this,El,!1),this.constructor===Cl&&Pf("Cannot initialize BaseCanvasFactory."),A(this,El,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,El)})}}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){Pf("Abstract method `_createCanvas` called.")}};let _l=Cl;El=new WeakMap;class Bl{constructor({baseUrl:r=null,isCompressed:e=!0}){this.constructor===Bl&&Pf("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?Mf.BINARY:Mf.NONE;return this._fetchData(e,a).catch((r=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}_fetchData(r,e){Pf("Abstract method `_fetchData` called.")}}class Zl{constructor({baseUrl:r=null}){this.constructor===Zl&&Pf("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){Pf("Abstract method `_fetchData` called.")}}class Wl{constructor(){this.constructor===Wl&&Pf("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){Pf("Abstract method `_createSVG` called.")}}const Il="http://www.w3.org/2000/svg",Rl=class{};let Fl=Rl;var xl,Sl,Ml,Gl,Xl,Vl,Nl,Dl,Tl,Pl,jl,Ol,Ll,Yl,Hl,Ql,Ul,Jl,zl,$l,ql,Kl,ru,eu,au,tu,iu,Au;e(Fl,"CSS",96),e(Fl,"PDF",72),e(Fl,"PDF_TO_CSS_UNITS",Rl.CSS/Rl.PDF);xl=new WeakMap,Sl=new WeakMap,Ml=new WeakMap,Gl=new WeakMap,Xl=new WeakMap,Vl=new WeakMap,Nl=new WeakSet,Dl=function(){return t(this,xl)||A(this,xl,new Map)},Tl=new WeakSet,Pl=function(){return t(this,Xl)||A(this,Xl,new Map)},jl=new WeakSet,Ol=function(){if(!t(this,Sl)){const r=t(this,Gl).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,Gl).createElementNS(Il,"svg");a.setAttribute("width",0),a.setAttribute("height",0),A(this,Sl,t(this,Gl).createElementNS(Il,"defs")),r.append(a),a.append(t(this,Sl)),t(this,Gl).body.append(r)}return t(this,Sl)},Ll=new WeakSet,Yl=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(",")]},Hl=new WeakSet,Ql=function(r){const e=t(this,Gl).createElementNS(Il,"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)},Ul=new WeakSet,Jl=function(r){const e=t(this,Gl).createElementNS(Il,"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)},zl=new WeakSet,$l=function(r){const e=t(this,Gl).createElementNS(Il,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",r),t(this,jl,Ol).append(e),e},ql=new WeakSet,Kl=function(r,e,a){const i=t(this,Gl).createElementNS(Il,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",a),r.append(i)},ru=new WeakSet,eu=function(r,e,a,i){const A=t(this,Gl).createElementNS(Il,"feComponentTransfer");i.append(A),o(this,ql,Kl).call(this,A,"feFuncR",r),o(this,ql,Kl).call(this,A,"feFuncG",e),o(this,ql,Kl).call(this,A,"feFuncB",a)},au=new WeakSet,tu=function(r,e){const a=t(this,Gl).createElementNS(Il,"feComponentTransfer");e.append(a),o(this,ql,Kl).call(this,a,"feFuncA",r)},iu=new WeakSet,Au=function(r){return t(this,jl,Ol).style.color=r,Eu(getComputedStyle(t(this,jl,Ol)).getPropertyValue("color"))};async function nu(r,e="text"){if(pu(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 ou extends Bl{_fetchData(r,e){return nu(r,this.isCompressed?"arraybuffer":"text").then((r=>({cMapData:r instanceof ArrayBuffer?new Uint8Array(r):rl(r),compressionType:e})))}}class su extends Zl{_fetchData(r){return nu(r,"arraybuffer").then((r=>new Uint8Array(r)))}}class fu extends Wl{_createSVG(r){return document.createElementNS(Il,r)}}class lu{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 Lf(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 lu({viewBox:this.viewBox.slice(),scale:r,rotation:e,offsetX:a,offsetY:t,dontFlip:i})}convertToViewportPoint(r,e){return sl.applyTransform([r,e],this.transform)}convertToViewportRectangle(r){const e=sl.applyTransform([r[0],r[1]],this.transform),a=sl.applyTransform([r[2],r[3]],this.transform);return[e[0],e[1],a[0],a[1]]}convertToPdfPoint(r,e){return sl.applyInverseTransform([r,e],this.transform)}}class uu extends Yf{constructor(r,e=0){super(r,"RenderingCancelledException"),this.extraDelay=e}}function cu(r){const e=r.length;let a=0;for(;a<e&&""===r[a].trim();)a++;return"data:"===r.substring(a,a+5).toLowerCase()}function du(r){return"string"==typeof r&&/\.pdf$/i.test(r)}function hu(r){return[r]=r.split(/[#?]/,1),r.substring(r.lastIndexOf("/")+1)}function bu(r,e="document.pdf"){if("string"!=typeof r)return e;if(cu(r))return Tf('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 gu{constructor(){e(this,"started",Object.create(null)),e(this,"times",[])}time(r){r in this.started&&Tf(`Timer is already running for ${r}`),this.started[r]=Date.now()}timeEnd(r){r in this.started||Tf(`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 pu(r,e){try{const{protocol:a}=e?new URL(r,e):new URL(r);return"http:"===a||"https:"===a}catch{return!1}}function vu(r){r.preventDefault()}function mu(r){console.log("Deprecated API usage: "+r)}let ku;class wu{static toDateObject(r){if(!r||"string"!=typeof r)return null;ku||(ku=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=ku.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 yu(r,{scale:e=1,rotation:a=0}){const{width:t,height:i}=r.attributes.style,A=[0,0,parseInt(t),parseInt(i)];return new lu({viewBox:A,scale:e,rotation:a})}function Eu(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):(Tf(`Not a valid color format: "${r}"`),[0,0,0])}function Cu(r){const{a:e,b:a,c:t,d:i,e:A,f:n}=r.getTransform();return[e,a,t,i,A,n]}function _u(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 Bu(r,e,a=!1,t=!0){if(e instanceof lu){const{pageWidth:t,pageHeight:i}=e.rawDims,{style:A}=r,n=al.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 Zu,Wu,Iu,Ru,Fu,xu,Su,Mu,Gu,Xu,Vu,Nu,Du,Tu,Pu,ju;const Ou=class{constructor(r){i(this,Su),i(this,Gu),i(this,Vu),i(this,Du),i(this,Pu),i(this,Zu,null),i(this,Wu,null),i(this,Iu,void 0),i(this,Ru,null),A(this,Iu,r)}render(){const r=A(this,Zu,document.createElement("div"));r.className="editToolbar",r.setAttribute("role","toolbar");const e=t(this,Iu)._uiManager._signal;r.addEventListener("contextmenu",vu,{signal:e}),r.addEventListener("pointerdown",o(Ou,Fu,xu),{signal:e});const a=A(this,Ru,document.createElement("div"));a.className="buttons",r.append(a);const i=t(this,Iu).toolbarPosition;if(i){const{style:e}=r,a="ltr"===t(this,Iu)._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,Du,Tu).call(this),r}hide(){var r;t(this,Zu).classList.add("hidden"),null==(r=t(this,Wu))||r.hideDropdown()}show(){t(this,Zu).classList.remove("hidden")}addAltTextButton(r){o(this,Vu,Nu).call(this,r),t(this,Ru).prepend(r,t(this,Pu,ju))}addColorPicker(r){A(this,Wu,r);const e=r.renderButton();o(this,Vu,Nu).call(this,e),t(this,Ru).prepend(e,t(this,Pu,ju))}remove(){var r;t(this,Zu).remove(),null==(r=t(this,Wu))||r.destroy(),A(this,Wu,null)}};let Lu=Ou;var Yu,Hu,Qu,Uu,Ju,zu,$u,qu,Ku,rc,ec,ac,tc,ic,Ac;Zu=new WeakMap,Wu=new WeakMap,Iu=new WeakMap,Ru=new WeakMap,Fu=new WeakSet,xu=function(r){r.stopPropagation()},Su=new WeakSet,Mu=function(r){t(this,Iu)._focusEventsAllowed=!1,r.preventDefault(),r.stopPropagation()},Gu=new WeakSet,Xu=function(r){t(this,Iu)._focusEventsAllowed=!0,r.preventDefault(),r.stopPropagation()},Vu=new WeakSet,Nu=function(r){const e=t(this,Iu)._uiManager._signal;r.addEventListener("focusin",o(this,Su,Mu).bind(this),{capture:!0,signal:e}),r.addEventListener("focusout",o(this,Gu,Xu).bind(this),{capture:!0,signal:e}),r.addEventListener("contextmenu",vu,{signal:e})},Du=new WeakSet,Tu=function(){const r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",`pdfjs-editor-remove-${t(this,Iu).editorType}-button`),o(this,Vu,Nu).call(this,r),r.addEventListener("click",(r=>{t(this,Iu)._uiManager.delete()}),{signal:t(this,Iu)._uiManager._signal}),t(this,Ru).append(r)},Pu=new WeakSet,ju=function(){const r=document.createElement("div");return r.className="divider",r},i(Lu,Fu);class nc{constructor(r){i(this,Uu),i(this,zu),i(this,qu),i(this,Yu,null),i(this,Hu,null),i(this,Qu,void 0),A(this,Qu,r)}show(r,e,a){const[i,n]=o(this,zu,$u).call(this,e,a),{style:s}=t(this,Hu)||A(this,Hu,o(this,Uu,Ju).call(this));r.append(t(this,Hu)),s.insetInlineEnd=100*i+"%",s.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){t(this,Hu).remove()}}function oc(r,e,a){for(const t of a)e.addEventListener(t,r[t].bind(r))}Yu=new WeakMap,Hu=new WeakMap,Qu=new WeakMap,Uu=new WeakSet,Ju=function(){const r=A(this,Hu,document.createElement("div"));r.className="editToolbar",r.setAttribute("role","toolbar"),r.addEventListener("contextmenu",vu,{signal:t(this,Qu)._signal});const e=A(this,Yu,document.createElement("div"));return e.className="buttons",r.append(e),o(this,qu,Ku).call(this),r},zu=new WeakSet,$u=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]},qu=new WeakSet,Ku=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,Qu)._signal;r.addEventListener("contextmenu",vu,{signal:a}),r.addEventListener("click",(()=>{t(this,Qu).highlightSelection("floating_button")}),{signal:a}),t(this,Yu).append(r)};class sc{constructor(){i(this,rc,0)}get id(){return"pdfjs_internal_editor_"+n(this,rc)._++}}rc=new WeakMap;const fc=class{constructor(){i(this,ic),i(this,ec,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 Kf(r)}()),i(this,ac,0),i(this,tc,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 Lf(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,ic,Ac).call(this,`${e}_${a}_${t}_${i}`,r)}async getFromUrl(r){return o(this,ic,Ac).call(this,r,r)}async getFromId(r){t(this,tc)||A(this,tc,new Map);const e=t(this,tc).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,tc).get(r);return null!=e&&e.isSvg?e.svgUrl:null}deleteId(r){t(this,tc)||A(this,tc,new Map);const e=t(this,tc).get(r);e&&(e.refCounter-=1,0===e.refCounter&&(e.bitmap=null))}isValidId(r){return r.startsWith(`image_${t(this,ec)}_`)}};let lc=fc;var uc,cc,dc,hc,bc,gc;ec=new WeakMap,ac=new WeakMap,tc=new WeakMap,ic=new WeakSet,Ac=async function(r,e){t(this,tc)||A(this,tc,new Map);let a=t(this,tc).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,ec)}_${n(this,ac)._++}`,refCounter:0,isSvg:!1}),"string"==typeof e?(a.url=e,r=await nu(e,"blob")):r=a.file=e,"image/svg+xml"===r.type){const e=fc._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,tc).set(r,a),a&&t(this,tc).set(a.id,a),a};class pc{constructor(r=128){i(this,uc,[]),i(this,cc,!1),i(this,dc,void 0),i(this,hc,-1),A(this,dc,r)}add({cmd:r,undo:e,post:a,mustExec:i,type:n=NaN,overwriteIfSameType:o=!1,keepUndo:s=!1}){if(i&&r(),t(this,cc))return;const f={cmd:r,undo:e,post:a,type:n};if(-1===t(this,hc))return t(this,uc).length>0&&(t(this,uc).length=0),A(this,hc,0),void t(this,uc).push(f);if(o&&t(this,uc)[t(this,hc)].type===n)return s&&(f.undo=t(this,uc)[t(this,hc)].undo),void(t(this,uc)[t(this,hc)]=f);const l=t(this,hc)+1;l===t(this,dc)?t(this,uc).splice(0,1):(A(this,hc,l),l<t(this,uc).length&&t(this,uc).splice(l)),t(this,uc).push(f)}undo(){if(-1===t(this,hc))return;A(this,cc,!0);const{undo:r,post:e}=t(this,uc)[t(this,hc)];r(),null==e||e(),A(this,cc,!1),A(this,hc,t(this,hc)-1)}redo(){if(t(this,hc)<t(this,uc).length-1){A(this,hc,t(this,hc)+1),A(this,cc,!0);const{cmd:r,post:e}=t(this,uc)[t(this,hc)];r(),null==e||e(),A(this,cc,!1)}}hasSomethingToUndo(){return-1!==t(this,hc)}hasSomethingToRedo(){return t(this,hc)<t(this,uc).length-1}destroy(){A(this,uc,null)}}uc=new WeakMap,cc=new WeakMap,dc=new WeakMap,hc=new WeakMap;class vc{constructor(r){i(this,bc),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=al.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,bc,gc).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()))}}bc=new WeakSet,gc=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 mc=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,Eu(t))}e.remove()}(r),Lf(this,"_colors",r)}convert(r){const e=Eu(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 mc._colorsMapping.get(r);return e}getHexCode(r){const e=this._colors.get(r);return e?sl.makeHexColor(...e):r}};let kc=mc;var wc,yc,Ec,Cc,_c,Bc,Zc,Wc,Ic,Rc,Fc,xc,Sc,Mc,Gc,Xc,Vc,Nc,Dc,Tc,Pc,jc,Oc,Lc,Yc,Hc,Qc,Uc,Jc,zc,$c,qc,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,_d,Bd,Zd,Wd,Id,Rd,Fd,xd,Sd,Md,Gd,Xd,Vd,Nd,Dd,Td,Pd,jd,Od,Ld,Yd,Hd,Qd,Ud,Jd,zd,$d,qd;e(kc,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));const Kd=class{constructor(r,e,a,n,s,f,l,u,c){i(this,dd),i(this,bd),i(this,pd),i(this,md),i(this,wd),i(this,Ed),i(this,_d),i(this,Zd),i(this,Id),i(this,Fd),i(this,Sd),i(this,Gd),i(this,Vd),i(this,Dd),i(this,Pd),i(this,Od),i(this,Yd),i(this,Qd),i(this,Jd),i(this,$d),i(this,wc,new AbortController),i(this,yc,null),i(this,Ec,new Map),i(this,Cc,new Map),i(this,_c,null),i(this,Bc,null),i(this,Zc,null),i(this,Wc,new pc),i(this,Ic,0),i(this,Rc,new Set),i(this,Fc,null),i(this,xc,null),i(this,Sc,new Set),i(this,Mc,!1),i(this,Gc,null),i(this,Xc,null),i(this,Vc,null),i(this,Nc,!1),i(this,Dc,null),i(this,Tc,new sc),i(this,Pc,!1),i(this,jc,!1),i(this,Oc,null),i(this,Lc,null),i(this,Yc,null),i(this,Hc,Ks.NONE),i(this,Qc,new Set),i(this,Uc,null),i(this,Jc,null),i(this,zc,null),i(this,$c,this.blur.bind(this)),i(this,qc,this.focus.bind(this)),i(this,Kc,this.copy.bind(this)),i(this,rd,this.cut.bind(this)),i(this,ed,this.paste.bind(this)),i(this,ad,this.keydown.bind(this)),i(this,td,this.keyup.bind(this)),i(this,id,this.onEditingAction.bind(this)),i(this,Ad,this.onPageChanging.bind(this)),i(this,nd,this.onScaleChanging.bind(this)),i(this,od,this.onRotationChanging.bind(this)),i(this,sd,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),i(this,fd,[0,0]),i(this,ld,null),i(this,ud,null),i(this,cd,null),this._signal=t(this,wc).signal,A(this,ud,r),A(this,cd,e),A(this,_c,a),this._eventBus=n,this._eventBus._on("editingaction",t(this,id)),this._eventBus._on("pagechanging",t(this,Ad)),this._eventBus._on("scalechanging",t(this,nd)),this._eventBus._on("rotationchanging",t(this,od)),o(this,wd,yd).call(this),o(this,Gd,Xd).call(this),o(this,Zd,Wd).call(this),A(this,Bc,s.annotationStorage),A(this,Gc,s.filterFactory),A(this,Jc,f),A(this,Vc,l||null),A(this,Mc,u),A(this,Yc,c||null),this.viewParameters={realScale:Fl.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const r=Kd.prototype,e=r=>t(r,ud).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 Lf(this,"_keyboardManager",new vc([[["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,ud).contains(e)&&!r.isEnterHandled}],[[" ","mac+ "],r.addNewEditorFromKeyboard,{checker:(r,{target:e})=>!(e instanceof HTMLButtonElement)&&t(r,ud).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,wc))||r.abort(),A(this,wc,null),this._signal=null,this._eventBus._off("editingaction",t(this,id)),this._eventBus._off("pagechanging",t(this,Ad)),this._eventBus._off("scalechanging",t(this,nd)),this._eventBus._off("rotationchanging",t(this,od));for(const r of t(this,Cc).values())r.destroy();t(this,Cc).clear(),t(this,Ec).clear(),t(this,Sc).clear(),A(this,yc,null),t(this,Qc).clear(),t(this,Wc).destroy(),null==(e=t(this,_c))||e.destroy(),null==(a=t(this,Dc))||a.hide(),A(this,Dc,null),t(this,Xc)&&(clearTimeout(t(this,Xc)),A(this,Xc,null)),t(this,ld)&&(clearTimeout(t(this,ld)),A(this,ld,null))}async mlGuess(r){var e;return(null==(e=t(this,Yc))?void 0:e.guess(r))||null}get hasMLManager(){return!!t(this,Yc)}get hcmFilter(){return Lf(this,"hcmFilter",t(this,Jc)?t(this,Gc).addHCMFilter(t(this,Jc).foreground,t(this,Jc).background):"none")}get direction(){return Lf(this,"direction",getComputedStyle(t(this,ud)).direction)}get highlightColors(){return Lf(this,"highlightColors",t(this,Vc)?new Map(t(this,Vc).split(",").map((r=>r.split("=").map((r=>r.trim()))))):null)}get highlightColorNames(){return Lf(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(r=>r.reverse()))):null)}setMainHighlightColorPicker(r){A(this,Lc,r)}editAltText(r){var e;null==(e=t(this,_c))||e.editAltText(this,r)}onPageChanging({pageNumber:r}){A(this,Ic,r-1)}focusMainContainer(){t(this,ud).focus()}findParent(r,e){for(const a of t(this,Cc).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,cd).classList.toggle("noUserSelect",r)}addShouldRescale(r){t(this,Sc).add(r)}removeShouldRescale(r){t(this,Sc).delete(r)}onScaleChanging({scale:r}){this.commitOrRemove(),this.viewParameters.realScale=r*Fl.PDF_TO_CSS_UNITS;for(const r of t(this,Sc))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,dd,hd).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(f);if(l){e.empty(),t(this,Hc)===Ks.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:Ks.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const e of t(this,Cc).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,Bc)&&!t(this,Bc).has(r.id)&&t(this,Bc).setValue(r.id,r)}blur(){if(this.isShiftKeyDown=!1,t(this,Nc)&&(A(this,Nc,!1),o(this,md,kd).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:r}=document;for(const e of t(this,Qc))if(e.div.contains(r)){A(this,Oc,[e,r]),e._focusEventsAllowed=!1;break}}focus(){if(!t(this,Oc))return;const[r,e]=t(this,Oc);A(this,Oc,null),e.addEventListener("focusin",(()=>{r._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}addEditListeners(){o(this,Zd,Wd).call(this),o(this,Fd,xd).call(this)}removeEditListeners(){o(this,Id,Rd).call(this),o(this,Sd,Md).call(this)}dragOver(r){for(const{type:e}of r.dataTransfer.items)for(const a of t(this,xc))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,xc))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,yc))||e.commitOrRemove(),!this.hasSelection)return;const a=[];for(const r of t(this,Qc)){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,xc))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 Tf(`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,Yd,Hd).call(this,e);o(this,$d,qd).call(this,r)},t=()=>{for(const e of r)e.remove()};this.addCommands({cmd:e,undo:t,mustExec:!0})}catch(r){Tf(`paste: "${r.message}".`)}}keydown(r){!this.isShiftKeyDown&&"Shift"===r.key&&(this.isShiftKeyDown=!0),t(this,Hc)!==Ks.NONE&&!this.isEditorHandlingKeyboard&&Kd._keyboardManager.exec(this,r)}keyup(r){this.isShiftKeyDown&&"Shift"===r.key&&(this.isShiftKeyDown=!1,t(this,Nc)&&(A(this,Nc,!1),o(this,md,kd).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,Ed,Cd).call(this),o(this,Fd,xd).call(this),o(this,Vd,Nd).call(this,{isEditing:t(this,Hc)!==Ks.NONE,isEmpty:o(this,Jd,zd).call(this),hasSomethingToUndo:t(this,Wc).hasSomethingToUndo(),hasSomethingToRedo:t(this,Wc).hasSomethingToRedo(),hasSelectedEditor:!1})):(o(this,_d,Bd).call(this),o(this,Sd,Md).call(this),o(this,Vd,Nd).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(r){if(!t(this,xc)){A(this,xc,r);for(const r of t(this,xc))o(this,Dd,Td).call(this,r.defaultPropertiesToUpdate)}}getId(){return t(this,Tc).id}get currentLayer(){return t(this,Cc).get(t(this,Ic))}getLayer(r){return t(this,Cc).get(r)}get currentPageIndex(){return t(this,Ic)}addLayer(r){t(this,Cc).set(r.pageIndex,r),t(this,Pc)?r.enable():r.disable()}removeLayer(r){t(this,Cc).delete(r.pageIndex)}updateMode(r,e=null,a=!1){if(t(this,Hc)!==r){if(A(this,Hc,r),r===Ks.NONE)return this.setEditingState(!1),void o(this,Od,Ld).call(this);this.setEditingState(!0),o(this,Pd,jd).call(this),this.unselectAll();for(const e of t(this,Cc).values())e.updateMode(r);if(!e&&a)return void this.addNewEditorFromKeyboard();if(e)for(const r of t(this,Ec).values())if(r.annotationElementId===e){this.setSelected(r),r.enterInEditMode();break}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(r){r!==t(this,Hc)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:r})}updateParams(r,e){var a;if(t(this,xc)){switch(r){case rf.CREATE:return void this.currentLayer.addNewEditor();case rf.HIGHLIGHT_DEFAULT_COLOR:null==(a=t(this,Lc))||a.updateColor(e);break;case rf.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(t(this,zc)||A(this,zc,new Map)).set(r,e),this.showAllEditors("highlight",e)}for(const a of t(this,Qc))a.updateParams(r,e);for(const a of t(this,xc))a.updateDefaultParams(r,e)}}showAllEditors(r,e,a=!1){var i;for(const a of t(this,Ec).values())a.editorType===r&&a.show(e);((null==(i=t(this,zc))?void 0:i.get(rf.HIGHLIGHT_SHOW_ALL))??!0)!==e&&o(this,Dd,Td).call(this,[[rf.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(r=!1){if(t(this,jc)!==r){A(this,jc,r);for(const e of t(this,Cc).values())r?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",r)}}getEditors(r){const e=[];for(const a of t(this,Ec).values())a.pageIndex===r&&e.push(a);return e}getEditor(r){return t(this,Ec).get(r)}addEditor(r){t(this,Ec).set(r.id,r)}removeEditor(r){var e;r.div.contains(document.activeElement)&&(t(this,Xc)&&clearTimeout(t(this,Xc)),A(this,Xc,setTimeout((()=>{this.focusMainContainer(),A(this,Xc,null)}),0))),t(this,Ec).delete(r.id),this.unselect(r),(!r.annotationElementId||!t(this,Rc).has(r.annotationElementId))&&(null==(e=t(this,Bc))||e.remove(r.id))}addDeletedAnnotationElement(r){t(this,Rc).add(r.annotationElementId),this.addChangedExistingAnnotation(r),r.deleted=!0}isDeletedAnnotationElement(r){return t(this,Rc).has(r)}removeDeletedAnnotationElement(r){t(this,Rc).delete(r.annotationElementId),this.removeChangedExistingAnnotation(r),r.deleted=!1}setActiveEditor(r){t(this,yc)!==r&&(A(this,yc,r),r&&o(this,Dd,Td).call(this,r.propertiesToUpdate))}updateUI(r){t(this,Qd,Ud)===r&&o(this,Dd,Td).call(this,r.propertiesToUpdate)}toggleSelected(r){if(t(this,Qc).has(r))return t(this,Qc).delete(r),r.unselect(),void o(this,Vd,Nd).call(this,{hasSelectedEditor:this.hasSelection});t(this,Qc).add(r),r.select(),o(this,Dd,Td).call(this,r.propertiesToUpdate),o(this,Vd,Nd).call(this,{hasSelectedEditor:!0})}setSelected(r){for(const e of t(this,Qc))e!==r&&e.unselect();t(this,Qc).clear(),t(this,Qc).add(r),r.select(),o(this,Dd,Td).call(this,r.propertiesToUpdate),o(this,Vd,Nd).call(this,{hasSelectedEditor:!0})}isSelected(r){return t(this,Qc).has(r)}get firstSelectedEditor(){return t(this,Qc).values().next().value}unselect(r){r.unselect(),t(this,Qc).delete(r),o(this,Vd,Nd).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==t(this,Qc).size}get isEnterHandled(){return 1===t(this,Qc).size&&this.firstSelectedEditor.isEnterHandled}undo(){t(this,Wc).undo(),o(this,Vd,Nd).call(this,{hasSomethingToUndo:t(this,Wc).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:o(this,Jd,zd).call(this)})}redo(){t(this,Wc).redo(),o(this,Vd,Nd).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:t(this,Wc).hasSomethingToRedo(),isEmpty:o(this,Jd,zd).call(this)})}addCommands(r){t(this,Wc).add(r),o(this,Vd,Nd).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:o(this,Jd,zd).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const r=[...t(this,Qc)];this.addCommands({cmd:()=>{for(const e of r)e.remove()},undo:()=>{for(const e of r)o(this,Yd,Hd).call(this,e)},mustExec:!0})}commitOrRemove(){var r;null==(r=t(this,yc))||r.commitOrRemove()}hasSomethingToControl(){return t(this,yc)||this.hasSelection}selectAll(){for(const r of t(this,Qc))r.commit();o(this,$d,qd).call(this,t(this,Ec).values())}unselectAll(){if((!t(this,yc)||(t(this,yc).commitOrRemove(),t(this,Hc)===Ks.NONE))&&this.hasSelection){for(const r of t(this,Qc))r.unselect();t(this,Qc).clear(),o(this,Vd,Nd).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(r,e,a=!1){if(a||this.commitOrRemove(),!this.hasSelection)return;t(this,fd)[0]+=r,t(this,fd)[1]+=e;const[i,n]=t(this,fd),o=[...t(this,Qc)];t(this,ld)&&clearTimeout(t(this,ld)),A(this,ld,setTimeout((()=>{A(this,ld,null),t(this,fd)[0]=t(this,fd)[1]=0,this.addCommands({cmd:()=>{for(const r of o)t(this,Ec).has(r.id)&&r.translateInPage(i,n)},undo:()=>{for(const r of o)t(this,Ec).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,Fc,new Map);for(const r of t(this,Qc))t(this,Fc).set(r,{savedX:r.x,savedY:r.y,savedPageIndex:r.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!t(this,Fc))return!1;this.disableUserSelect(!1);const r=t(this,Fc);A(this,Fc,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,Ec).has(r.id)){const A=t(this,Cc).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,Fc))for(const a of t(this,Fc).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,Qc).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(r){return t(this,yc)===r}getActive(){return t(this,yc)}getMode(){return t(this,Hc)}get imageManager(){return Lf(this,"imageManager",new lc)}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,Zc)||A(this,Zc,new Map)).set(r,e)}removeChangedExistingAnnotation({annotationElementId:r}){var e;null==(e=t(this,Zc))||e.delete(r)}renderAnnotationElement(r){var e;const a=null==(e=t(this,Zc))?void 0:e.get(r.data.id);if(!a)return;const i=t(this,Bc).getRawValue(a);i&&(t(this,Hc)===Ks.NONE&&!i.hasBeenModified||i.renderAnnotationElement(r))}};let rh=Kd;var eh,ah,th,ih,Ah,nh,oh,sh,fh;wc=new WeakMap,yc=new WeakMap,Ec=new WeakMap,Cc=new WeakMap,_c=new WeakMap,Bc=new WeakMap,Zc=new WeakMap,Wc=new WeakMap,Ic=new WeakMap,Rc=new WeakMap,Fc=new WeakMap,xc=new WeakMap,Sc=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,Oc=new WeakMap,Lc=new WeakMap,Yc=new WeakMap,Hc=new WeakMap,Qc=new WeakMap,Uc=new WeakMap,Jc=new WeakMap,zc=new WeakMap,$c=new WeakMap,qc=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 WeakMap,cd=new WeakMap,dd=new WeakSet,hd=function({anchorNode:r}){return r.nodeType===Node.TEXT_NODE?r.parentElement:r},bd=new WeakSet,gd=function(){const r=document.getSelection();if(!r||r.isCollapsed)return;const e=o(this,dd,hd).call(this,r).closest(".textLayer"),a=this.getSelectionBoxes(e);a&&(t(this,Dc)||A(this,Dc,new nc(this)),t(this,Dc).show(e,a,"ltr"===this.direction))},pd=new WeakSet,vd=function(){var r,e,a;const i=document.getSelection();if(!i||i.isCollapsed)return void(t(this,Uc)&&(null==(r=t(this,Dc))||r.hide(),A(this,Uc,null),o(this,Vd,Nd).call(this,{hasSelectedText:!1})));const{anchorNode:n}=i;if(n!==t(this,Uc))if(o(this,dd,hd).call(this,i).closest(".textLayer")){if(null==(a=t(this,Dc))||a.hide(),A(this,Uc,n),o(this,Vd,Nd).call(this,{hasSelectedText:!0}),(t(this,Hc)===Ks.HIGHLIGHT||t(this,Hc)===Ks.NONE)&&(t(this,Hc)===Ks.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),A(this,Nc,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,md,kd).call(this,"main_toolbar"))};window.addEventListener("pointerup",e,{signal:r}),window.addEventListener("blur",e,{signal:r})}}else t(this,Uc)&&(null==(e=t(this,Dc))||e.hide(),A(this,Uc,null),o(this,Vd,Nd).call(this,{hasSelectedText:!1}))},md=new WeakSet,kd=function(r=""){t(this,Hc)===Ks.HIGHLIGHT?this.highlightSelection(r):t(this,Mc)&&o(this,bd,gd).call(this)},wd=new WeakSet,yd=function(){document.addEventListener("selectionchange",o(this,pd,vd).bind(this),{signal:this._signal})},Ed=new WeakSet,Cd=function(){const r=this._signal;window.addEventListener("focus",t(this,qc),{signal:r}),window.addEventListener("blur",t(this,$c),{signal:r})},_d=new WeakSet,Bd=function(){window.removeEventListener("focus",t(this,qc)),window.removeEventListener("blur",t(this,$c))},Zd=new WeakSet,Wd=function(){const r=this._signal;window.addEventListener("keydown",t(this,ad),{signal:r}),window.addEventListener("keyup",t(this,td),{signal:r})},Id=new WeakSet,Rd=function(){window.removeEventListener("keydown",t(this,ad)),window.removeEventListener("keyup",t(this,td))},Fd=new WeakSet,xd=function(){const r=this._signal;document.addEventListener("copy",t(this,Kc),{signal:r}),document.addEventListener("cut",t(this,rd),{signal:r}),document.addEventListener("paste",t(this,ed),{signal:r})},Sd=new WeakSet,Md=function(){document.removeEventListener("copy",t(this,Kc)),document.removeEventListener("cut",t(this,rd)),document.removeEventListener("paste",t(this,ed))},Gd=new WeakSet,Xd=function(){const r=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:r}),document.addEventListener("drop",this.drop.bind(this),{signal:r})},Vd=new WeakSet,Nd=function(r){Object.entries(r).some((([r,e])=>t(this,sd)[r]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(t(this,sd),r)}),t(this,Hc)===Ks.HIGHLIGHT&&!1===r.hasSelectedEditor&&o(this,Dd,Td).call(this,[[rf.HIGHLIGHT_FREE,!0]]))},Dd=new WeakSet,Td=function(r){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:r})},Pd=new WeakSet,jd=function(){if(!t(this,Pc)){A(this,Pc,!0);for(const r of t(this,Cc).values())r.enable();for(const r of t(this,Ec).values())r.enable()}},Od=new WeakSet,Ld=function(){if(this.unselectAll(),t(this,Pc)){A(this,Pc,!1);for(const r of t(this,Cc).values())r.disable();for(const r of t(this,Ec).values())r.disable()}},Yd=new WeakSet,Hd=function(r){const e=t(this,Cc).get(r.pageIndex);e?e.addOrRebuild(r):(this.addEditor(r),this.addToAnnotationStorage(r))},Qd=new WeakSet,Ud=function(){let r=null;for(r of t(this,Qc));return r},Jd=new WeakSet,zd=function(){if(0===t(this,Ec).size)return!0;if(1===t(this,Ec).size)for(const r of t(this,Ec).values())return r.isEmpty();return!1},$d=new WeakSet,qd=function(r){for(const r of t(this,Qc))r.unselect();t(this,Qc).clear();for(const e of r)e.isEmpty()||(t(this,Qc).add(e),e.select());o(this,Vd,Nd).call(this,{hasSelectedEditor:this.hasSelection})},e(rh,"TRANSLATE_SMALL",1),e(rh,"TRANSLATE_BIG",10);const lh=class{constructor(r){i(this,sh),i(this,eh,""),i(this,ah,!1),i(this,th,null),i(this,ih,null),i(this,Ah,null),i(this,nh,!1),i(this,oh,null),A(this,oh,r)}static initialize(r){lh._l10nPromise||(lh._l10nPromise=r)}async render(){const r=A(this,th,document.createElement("button"));r.className="altText";const e=await lh._l10nPromise.get("pdfjs-editor-alt-text-button-label");r.textContent=e,r.setAttribute("aria-label",e),r.tabIndex="0";const a=t(this,oh)._uiManager._signal;r.addEventListener("contextmenu",vu,{signal:a}),r.addEventListener("pointerdown",(r=>r.stopPropagation()),{signal:a});const i=r=>{r.preventDefault(),t(this,oh)._uiManager.editAltText(t(this,oh))};return r.addEventListener("click",i,{capture:!0,signal:a}),r.addEventListener("keydown",(e=>{e.target===r&&"Enter"===e.key&&(A(this,nh,!0),i(e))}),{signal:a}),await o(this,sh,fh).call(this),r}finish(){t(this,th)&&(t(this,th).focus({focusVisible:t(this,nh)}),A(this,nh,!1))}isEmpty(){return!t(this,eh)&&!t(this,ah)}get data(){return{altText:t(this,eh),decorative:t(this,ah)}}set data({altText:r,decorative:e}){t(this,eh)===r&&t(this,ah)===e||(A(this,eh,r),A(this,ah,e),o(this,sh,fh).call(this))}toggle(r=!1){t(this,th)&&(!r&&t(this,Ah)&&(clearTimeout(t(this,Ah)),A(this,Ah,null)),t(this,th).disabled=!r)}destroy(){var r;null==(r=t(this,th))||r.remove(),A(this,th,null),A(this,ih,null)}};let uh=lh;var ch,dh,hh,bh,gh,ph,vh,mh,kh,wh,yh,Eh,Ch,_h,Bh,Zh,Wh,Ih,Rh,Fh,xh,Sh,Mh,Gh,Xh,Vh,Nh,Dh,Th,Ph,jh,Oh,Lh,Yh,Hh,Qh,Uh,Jh,zh,$h,qh,Kh,rb,eb,ab,tb,ib,Ab,nb,ob;eh=new WeakMap,ah=new WeakMap,th=new WeakMap,ih=new WeakMap,Ah=new WeakMap,nh=new WeakMap,oh=new WeakMap,sh=new WeakSet,fh=async function(){var r;const e=t(this,th);if(!e)return;if(!t(this,eh)&&!t(this,ah))return e.classList.remove("done"),void(null==(r=t(this,ih))||r.remove());e.classList.add("done"),lh._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then((r=>{e.setAttribute("aria-label",r)}));let a=t(this,ih);if(!a){A(this,ih,a=document.createElement("span")),a.className="tooltip",a.setAttribute("role","tooltip");const r=a.id=`alt-text-tooltip-${t(this,oh).id}`;e.setAttribute("aria-describedby",r);const i=100,n=t(this,oh)._uiManager._signal;n.addEventListener("abort",(()=>{clearTimeout(t(this,Ah)),A(this,Ah,null)}),{once:!0}),e.addEventListener("mouseenter",(()=>{A(this,Ah,setTimeout((()=>{A(this,Ah,null),t(this,ih).classList.add("show"),t(this,oh)._reportTelemetry({action:"alt_text_tooltip"})}),i))}),{signal:n}),e.addEventListener("mouseleave",(()=>{var r;t(this,Ah)&&(clearTimeout(t(this,Ah)),A(this,Ah,null)),null==(r=t(this,ih))||r.classList.remove("show")}),{signal:n})}a.innerText=t(this,ah)?await lh._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):t(this,eh),a.parentNode||e.append(a);const i=t(this,oh).getImageForAltText();null==i||i.setAttribute("aria-describedby",a.id)},e(uh,"_l10nPromise",null);const sb=class{constructor(r){i(this,Mh),i(this,Nh),i(this,Th),i(this,jh),i(this,Lh),i(this,Hh),i(this,Uh),i(this,zh),i(this,qh),i(this,rb),i(this,ab),i(this,ib),i(this,nb),i(this,ch,null),i(this,dh,null),i(this,hh,null),i(this,bh,!1),i(this,gh,!1),i(this,ph,null),i(this,vh,null),i(this,mh,this.focusin.bind(this)),i(this,kh,this.focusout.bind(this)),i(this,wh,null),i(this,yh,""),i(this,Eh,!1),i(this,Ch,null),i(this,_h,!1),i(this,Bh,!1),i(this,Zh,!1),i(this,Wh,null),i(this,Ih,0),i(this,Rh,0),i(this,Fh,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,xh,!1),i(this,Sh,sb._zIndex++),this.constructor===sb&&Pf("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=sb.prototype._resizeWithKeyboard,e=rh.TRANSLATE_SMALL,a=rh.TRANSLATE_BIG;return Lf(this,"_resizerKeyboardManager",new vc([[["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"],sb.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return Lf(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(r){const e=new lb({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(sb._l10nPromise||(sb._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)sb._l10nPromise.set(e,r.get(e));if(-1!==sb._borderLineWidth)return;const t=getComputedStyle(document.documentElement);sb._borderLineWidth=parseFloat(t.getPropertyValue("--outline-width"))||0}static updateDefaultParams(r,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(r){return!1}static paste(r,e){Pf("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return t(this,xh)}set _isDraggable(r){var e;A(this,xh,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,Sh)}setParent(r){null!==r?(this.pageIndex=r.pageIndex,this.pageDimensions=r.pageDimensions):o(this,nb,ob).call(this),this.parent=r}focusin(r){this._focusEventsAllowed&&(t(this,Eh)?A(this,Eh,!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,Mh,Gh).call(this,this.parentDimensions,r,e)}translateInPage(r,e){t(this,Ch)||A(this,Ch,[this.x,this.y]),o(this,Mh,Gh).call(this,this.pageDimensions,r,e),this.div.scrollIntoView({block:"nearest"})}drag(r,e){t(this,Ch)||A(this,Ch,[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,Ch)&&(t(this,Ch)[0]!==this.x||t(this,Ch)[1]!==this.y)}getBaseTranslation(){const[r,e]=this.parentDimensions,{_borderLineWidth:a}=sb,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=sb,Xh,Vh).call(a,r,e,this.parentRotation)}pageTranslationToScreen(r,e){var a;return o(a=sb,Xh,Vh).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 al.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,gh)||(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,gh)&&e.endsWith("%");if(i&&A)return;const[n,o]=this.parentDimensions;i||(r.width=`${(100*parseFloat(a)/n).toFixed(2)}%`),!t(this,gh)&&!A&&(r.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var r;null==(r=t(this,hh))||r.finish()}async addEditToolbar(){return t(this,wh)||t(this,Bh)||(A(this,wh,new Lu(this)),this.div.append(t(this,wh).render()),t(this,hh)&&t(this,wh).addAltTextButton(await t(this,hh).render())),t(this,wh)}removeEditToolbar(){var r;t(this,wh)&&(t(this,wh).remove(),A(this,wh,null),null==(r=t(this,hh))||r.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){t(this,hh)||(uh.initialize(sb._l10nPromise),A(this,hh,new uh(this)),t(this,ch)&&(t(this,hh).data=t(this,ch),A(this,ch,null)),await this.addEditToolbar())}get altTextData(){var r;return null==(r=t(this,hh))?void 0:r.data}set altTextData(r){t(this,hh)&&(t(this,hh).data=r)}hasAltText(){var r;return!(null!=(r=t(this,hh))&&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,bh)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const r=this._uiManager._signal;this.div.addEventListener("focusin",t(this,mh),{signal:r}),this.div.addEventListener("focusout",t(this,kh),{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),oc(this,this.div,["pointerdown"]),this.div}pointerdown(r){const{isMac:e}=al.platform;0!==r.button||r.ctrlKey&&e?r.preventDefault():(A(this,Eh,!0),this._isDraggable?o(this,zh,$h).call(this,r):o(this,Uh,Jh).call(this,r))}moveInDOM(){t(this,Wh)&&clearTimeout(t(this,Wh)),A(this,Wh,setTimeout((()=>{var r;A(this,Wh,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,Bh,!0)}disableEditMode(){A(this,Bh,!1)}isInEditMode(){return t(this,Bh)}shouldGetKeyboardEvents(){return t(this,Zh)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var r,e;const a=this._uiManager._signal;null==(r=this.div)||r.addEventListener("focusin",t(this,mh),{signal:a}),null==(e=this.div)||e.addEventListener("focusout",t(this,kh),{signal:a})}rotate(r){}serialize(r=!1,e=null){Pf("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,ch,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,mh)),this.div.removeEventListener("focusout",t(this,kh)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),t(this,Wh)&&(clearTimeout(t(this,Wh)),A(this,Wh,null)),o(this,nb,ob).call(this),this.removeEditToolbar(),t(this,Fh)){for(const r of t(this,Fh).values())clearTimeout(r);A(this,Fh,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(o(this,Th,Ph).call(this),t(this,ph).classList.remove("hidden"),oc(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,vh,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=t(this,ph).children;if(!t(this,dh)){A(this,dh,Array.from(e));const r=o(this,qh,Kh).bind(this),a=o(this,rb,eb).bind(this),i=this._uiManager._signal;for(const e of t(this,dh)){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,ab,tb).bind(this,t),{signal:i}),sb._l10nPromise.get(`pdfjs-editor-resizer-label-${t}`).then((r=>e.setAttribute("aria-label",r)))}}const a=t(this,dh)[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,dh).length/4);if(n!==i){if(n<i)for(let r=0;r<i-n;r++)t(this,ph).append(t(this,ph).firstChild);else if(n>i)for(let r=0;r<n-i;r++)t(this,ph).firstChild.before(t(this,ph).lastChild);let r=0;for(const a of e){const e=t(this,dh)[r++].getAttribute("data-resizer-name");sb._l10nPromise.get(`pdfjs-editor-resizer-label-${e}`).then((r=>a.setAttribute("aria-label",r)))}}o(this,ib,Ab).call(this,0),A(this,Zh,!0),t(this,ph).firstChild.focus({focusVisible:!0}),r.preventDefault(),r.stopImmediatePropagation()}_resizeWithKeyboard(r,e){t(this,Zh)&&o(this,Hh,Qh).call(this,t(this,yh),{movementX:r,movementY:e})}_stopResizingWithKeyboard(){o(this,nb,ob).call(this),this.div.focus()}select(){var r,e;this.makeResizable(),null==(r=this.div)||r.classList.add("selectedEditor"),t(this,wh)?null==(e=t(this,wh))||e.show():this.addEditToolbar().then((()=>{var r,e;null!=(r=this.div)&&r.classList.contains("selectedEditor")&&(null==(e=t(this,wh))||e.show())}))}unselect(){var r,e,a,i;null==(r=t(this,ph))||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,wh))||i.hide()}updateParams(r,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return t(this,_h)}set isEditing(r){A(this,_h,r),this.parent&&(r?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(r,e){A(this,gh,!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,Fh)||A(this,Fh,new Map);const{action:e}=r;let a=t(this,Fh).get(e);return a&&clearTimeout(a),a=setTimeout((()=>{this._reportTelemetry(r),t(this,Fh).delete(e),0===t(this,Fh).size&&A(this,Fh,null)}),sb._telemetryTimeout),void t(this,Fh).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,bh,!1)}disable(){this.div&&(this.div.tabIndex=-1),A(this,bh,!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 fb=sb;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,_h=new WeakMap,Bh=new WeakMap,Zh=new WeakMap,Wh=new WeakMap,Ih=new WeakMap,Rh=new WeakMap,Fh=new WeakMap,xh=new WeakMap,Sh=new WeakMap,Mh=new WeakSet,Gh=function([r,e],a,t){[a,t]=this.screenToPageTranslation(a,t),this.x+=a/r,this.y+=t/e,this.fixAndSetPosition()},Xh=new WeakSet,Vh=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]}},Nh=new WeakSet,Dh=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]}},Th=new WeakSet,Ph=function(){if(t(this,ph))return;A(this,ph,document.createElement("div")),t(this,ph).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,ph).append(r),r.classList.add("resizer",a),r.setAttribute("data-resizer-name",a),r.addEventListener("pointerdown",o(this,jh,Oh).bind(this,a),{signal:e}),r.addEventListener("contextmenu",vu,{signal:e}),r.tabIndex=-1}this.div.prepend(t(this,ph))},jh=new WeakSet,Oh=function(r,e){var a;e.preventDefault();const{isMac:i}=al.platform;if(0!==e.button||e.ctrlKey&&i)return;null==(a=t(this,hh))||a.toggle(!1);const A=o(this,Hh,Qh).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",vu,{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,hh))||r.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",A,f),window.removeEventListener("contextmenu",vu),this.parent.div.style.cursor=h,this.div.style.cursor=b,o(this,Lh,Yh).call(this,l,u,c,d)};window.addEventListener("pointerup",g,{signal:s}),window.addEventListener("blur",g,{signal:s})},Lh=new WeakSet,Yh=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})},Hh=new WeakSet,Qh=function(r,e){const[a,t]=this.parentDimensions,i=this.x,A=this.y,n=this.width,s=this.height,f=sb.MIN_SIZE/a,l=sb.MIN_SIZE/t,u=r=>Math.round(1e4*r)/1e4,c=o(this,Nh,Dh).call(this,this.rotation),d=(r,e)=>[c[0]*r+c[2]*e,c[1]*r+c[3]*e],h=o(this,Nh,Dh).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,_=1,[B,Z]=this.screenToPageTranslation(e.movementX,e.movementY);if([B,Z]=(W=B/a,I=Z/t,[h[0]*W+h[2]*I,h[1]*W+h[3]*I]),p){const r=Math.hypot(n,s);C=_=Math.max(Math.min(Math.hypot(k[0]-m[0]-B,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]-B)))/n:_=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*_);w=d(...g(R,F));const x=y-w[0],S=E-w[1];this.width=R,this.height=F,this.x=x,this.y=S,this.setDims(a*R,t*F),this.fixAndSetPosition()},Uh=new WeakSet,Jh=function(r){const{isMac:e}=al.platform;r.ctrlKey&&!e||r.shiftKey||r.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},zh=new WeakSet,$h=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,Ih,r.clientX),A(this,Rh,r.clientY),i=r=>{const{clientX:e,clientY:a}=r,[i,n]=this.screenToPageTranslation(e-t(this,Ih),a-t(this,Rh));A(this,Ih,e),A(this,Rh,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,Eh,!1),this._uiManager.endDragSession()||o(this,Uh,Jh).call(this,r)};window.addEventListener("pointerup",s,{signal:n}),window.addEventListener("blur",s,{signal:n})},qh=new WeakSet,Kh=function(r){sb._resizerKeyboardManager.exec(this,r)},rb=new WeakSet,eb=function(r){var e;t(this,Zh)&&(null==(e=r.relatedTarget)?void 0:e.parentNode)!==t(this,ph)&&o(this,nb,ob).call(this)},ab=new WeakSet,tb=function(r){A(this,yh,t(this,Zh)?r:"")},ib=new WeakSet,Ab=function(r){if(t(this,dh))for(const e of t(this,dh))e.tabIndex=r},nb=new WeakSet,ob=function(){if(A(this,Zh,!1),o(this,ib,Ab).call(this,-1),t(this,vh)){const{savedX:r,savedY:e,savedWidth:a,savedHeight:i}=t(this,vh);o(this,Lh,Yh).call(this,r,e,a,i),A(this,vh,null)}},i(fb,Xh),e(fb,"_borderLineWidth",-1),e(fb,"_colorManager",new kc),e(fb,"_zIndex",1),e(fb,"_telemetryTimeout",1e3);class lb extends fb{constructor(r){super(r),this.annotationElementId=r.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const ub=3285377520,cb=4294901760,db=65535;class hb{constructor(r){this.h1=r?4294967295&r:ub,this.h2=r?4294967295&r:ub}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&db,d=u&db;for(let r=0;r<t;r++)1&r?(n=A[r],n=n*l&cb|n*c&db,n=n<<15|n>>>17,n=n*u&cb|n*d&db,s^=n,s=s<<13|s>>>19,s=5*s+3864292196):(o=A[r],o=o*l&cb|o*c&db,o=o<<15|o>>>17,o=o*u&cb|o*d&db,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&cb|n*c&db,n=n<<15|n>>>17,n=n*u&cb|n*d&db,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&cb|36045*r&db,e=4283543511*e&cb|(2950163797*(e<<16|r>>>16)&cb)>>>16,r^=e>>>1,r=444984403*r&cb|60499*r&db,e=3301882366*e&cb|(3120437893*(e<<16|r>>>16)&cb)>>>16,r^=e>>>1,(r>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const bb=Object.freeze({map:null,hash:"",transfer:void 0});var gb,pb,vb,mb,kb,wb;class yb{constructor(){i(this,vb),i(this,gb,!1),i(this,pb,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(r,e){const a=t(this,pb).get(r);return void 0===a?e:Object.assign(e,a)}getRawValue(r){return t(this,pb).get(r)}remove(r){if(t(this,pb).delete(r),0===t(this,pb).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const r of t(this,pb).values())if(r instanceof fb)return;this.onAnnotationEditor(null)}}setValue(r,e){const a=t(this,pb).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,pb).set(r,e);i&&o(this,vb,mb).call(this),e instanceof fb&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(r){return t(this,pb).has(r)}getAll(){return t(this,pb).size>0?el(t(this,pb)):null}setAll(r){for(const[e,a]of Object.entries(r))this.setValue(e,a)}get size(){return t(this,pb).size}resetModified(){t(this,gb)&&(A(this,gb,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Eb(this)}get serializable(){if(0===t(this,pb).size)return bb;const r=new Map,e=new hb,a=[],i=Object.create(null);let A=!1;for(const[a,n]of t(this,pb)){const t=n instanceof fb?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}:bb}get editorStats(){let r=null;const e=new Map;for(const a of t(this,pb).values()){if(!(a instanceof fb))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}}gb=new WeakMap,pb=new WeakMap,vb=new WeakSet,mb=function(){t(this,gb)||(A(this,gb,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class Eb extends yb{constructor(r){super(),i(this,kb,void 0);const{map:e,hash:a,transfer:t}=r.serializable,n=structuredClone(e,t?{transfer:t}:null);A(this,kb,{map:n,hash:a,transfer:t})}get print(){Pf("Should not call PrintAnnotationStorage.print")}get serializable(){return t(this,kb)}}kb=new WeakMap;class Cb{constructor({ownerDocument:r=globalThis.document,styleElement:e=null}){i(this,wb,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,wb).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:r,_inspectFont:e}){if(r&&!t(this,wb).has(r.loadedName)){if(jf(!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,wb).add(a),null==e||e(r)}catch{Tf(`Cannot load system font: ${r.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(n)}return}Pf("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 Tf(`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 Lf(this,"isFontLoadingAPISupported",!(null==(r=this._document)||!r.fonts))}get isSyncFontLoadingSupported(){let r=!1;return(Ps||typeof navigator<"u"&&"string"==typeof(null==navigator?void 0:navigator.userAgent)&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(r=!0),Lf(this,"isSyncFontLoadingSupported",r)}_queueLoadingCallback(r){const{loadingRequests:e}=this,a={done:!1,complete:function(){for(jf(!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 Lf(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 Tf("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()}))}}wb=new WeakMap;class _b{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=Kf(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){Tf(`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 dl:{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 hl:{const[e,i]=a.slice(r,r+2);t.push((r=>r.moveTo(e,i))),r+=2}break;case bl:{const[e,i]=a.slice(r,r+2);t.push((r=>r.lineTo(e,i))),r+=2}break;case gl:{const[e,i,A,n]=a.slice(r,r+4);t.push((r=>r.quadraticCurveTo(e,i,A,n))),r+=4}break;case pl:t.push((r=>r.restore()));break;case vl:t.push((r=>r.save()));break;case ml:jf(2===t.length,"Scale command is only valid at the third position.");break;case kl:{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 wl:{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(Ps){var Bb=Promise.withResolvers(),Zb=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=>{Zb=r,Bb.resolve()}),(r=>{Tf(`loadPackages: ${r}`),Zb=new Map,Bb.resolve()}))}class Wb{static get promise(){return Bb.promise}static get(r){return null==Zb?void 0:Zb.get(r)}}const Ib=function(r){return Wb.get("fs").promises.readFile(r).then((r=>new Uint8Array(r)))};const Rb="Fill",Fb="Stroke",xb="Shading";function Sb(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 Mb{constructor(){this.constructor===Mb&&Pf("Cannot initialize BaseShadingPattern.")}getPattern(){Pf("Abstract method `getPattern` called.")}}class Gb extends Mb{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===Fb||t===Rb){const A=e.current.getClippedPathBoundingBox(t,Cu(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=sl.transform(a,[1,0,0,1,A[0],A[1]]),f.transform(...e.baseTransform),this.matrix&&f.transform(...this.matrix),Sb(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 Sb(r,this._bbox),i=this._createGradient(r);return i}}function Xb(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],_=f[o],B=f[o+1],Z=f[o+2],W=Math.round(h),I=Math.round(v);let R,F,x,S,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,x=k-(k-E)*e,S=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-_)*e,x=E-(E-B)*e,S=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-_)*e,X=k-(k-B)*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++]=x-(x-X)*e|0,l[i++]=S-(S-V)*e|0,l[i++]=255}}function Vb(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++)Xb(r,a,t[e],t[e+1],t[e+o],i[e],i[e+1],i[e+o]),Xb(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)Xb(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 Nb extends Mb{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)Vb(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(Sb(r,this._bbox),t===xb)i=sl.singularValueDecompose2dScale(Cu(r));else if(i=sl.singularValueDecompose2dScale(e.baseTransform),this.matrix){const r=sl.singularValueDecompose2dScale(this.matrix);i=[i[0]*r[0],i[1]*r[1]]}const A=this._createMeshCanvas(i,t===xb?null:this._background,e.cachedCanvases);return t!==xb&&(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 Db extends Mb{getPattern(){return"hotpink"}}const Tb=1,Pb=2,jb=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;Df("TilingType: "+n);const f=a[0],l=a[1],u=a[2],c=a[3],d=sl.singularValueDecompose2dScale(this.matrix),h=sl.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=Cu(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(jb.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(Cu(r.ctx),[e,a,t,i]),r.clip(),r.endPath()}setFillAndStrokeStyleToContext(r,e,a){const t=r.ctx,i=r.current;switch(e){case Tb:const r=this.ctx;t.fillStyle=r.fillStyle,t.strokeStyle=r.strokeStyle,i.fillColor=r.fillStyle,i.strokeColor=r.strokeStyle;break;case Pb:const A=sl.makeHexColor(a[0],a[1],a[2]);t.fillStyle=A,t.strokeStyle=A,i.fillColor=A,i.strokeColor=A;break;default:throw new $f(`Unsupported paint type: ${e}`)}}getPattern(r,e,a,t){let i=a;t!==xb&&(i=sl.transform(i,e.baseTransform),this.matrix&&(i=sl.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 Ob=jb;function Lb({src:r,srcPos:e=0,dest:a,width:t,height:i,nonBlackColor:A=4294967295,inverseDecode:n=!1}){const o=al.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(Ob,"MAX_PATTERN_SIZE",3e3);const Yb=16;class Hb{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 Qb(r,e,a,t,i,A,n,o,s,f){const[l,u,c,d,h,b]=Cu(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 Ub{constructor(r,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=js,this.textMatrixScale=1,this.fontMatrix=Os,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=af,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]=sl.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=sl.applyTransform(e,r),t=sl.applyTransform(e.slice(2),r),i=sl.applyTransform([e[0],e[3]],r),A=sl.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){sl.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=sl.bezierBoundingBox(e,a,t,i,A,n,o,s,f);f||this.updateRectMinMax(r,l)}getPathBoundingBox(r=Rb,e=null){const a=[this.minX,this.minY,this.maxX,this.maxY];if(r===Fb){e||Pf("Stroke bounding box must include transform.");const r=sl.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=sl.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=Rb,e=null){return sl.intersect(this.clipBox,this.getPathBoundingBox(r,e))}}function Jb(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%Yb,A=(a-i)/Yb,n=0===i?A:A+1,o=r.createImageData(t,Yb);let s,f=0;const l=e.data,u=o.data;let c,d,h,b;if(e.kind===ff.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=al.isLittleEndian?4278190080:255;for(c=0;c<n;c++){for(h=c<A?Yb: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*Yb)}}else if(e.kind===ff.RGBA_32BPP){for(d=0,b=t*Yb*4,c=0;c<A;c++)u.set(l.subarray(f,f+b)),f+=b,r.putImageData(o,0,d),d+=Yb;c<n&&(b=t*i*4,u.set(l.subarray(f,f+b)),r.putImageData(o,0,d))}else{if(e.kind!==ff.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(h=Yb,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*Yb)}}}function zb(r,e){if(e.bitmap)return void r.drawImage(e.bitmap,0,0);const a=e.height,t=e.width,i=a%Yb,A=(a-i)/Yb,n=0===i?A:A+1,o=r.createImageData(t,Yb);let s=0;const f=e.data,l=o.data;for(let e=0;e<n;e++){const a=e<A?Yb:i;({srcPos:s}=Lb({src:f,srcPos:s,dest:l,width:t,height:a,nonBlackColor:0})),r.putImageData(o,0,e*Yb)}}function $b(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 qb(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),!Ps){const{filter:e}=r;"none"!==e&&""!==e&&(r.filter="none")}}function Kb(r,e){if(e)return!0;const a=sl.singularValueDecompose2dScale(r);a[0]=Math.fround(a[0]),a[1]=Math.fround(a[1]);const t=Math.fround((globalThis.devicePixelRatio||1)*Fl.PDF_TO_CSS_UNITS);return a[0]<=t&&a[1]<=t}const rg=["butt","round","square"],eg=["miter","round","bevel"],ag={},tg={};var ig,Ag,ng,og;const sg=class{constructor(r,e,a,t,A,{optionalContentConfig:n,markedContentStack:o=null},s,f){i(this,ig),i(this,ng),this.ctx=r,this.current=new Ub(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 Hb(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(...Cu(this.compositeCtx))}this.ctx.save(),qb(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=Cu(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!==Gf.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,ig,Ag).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,ng,og).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=Cu(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),zb(l.context,r));let u=sl.transform(n,[1/a,0,0,-1/t,0,0]);u=sl.transform(u,[1,0,0,1,0,-t]);const[c,d,h,b]=sl.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,_u(m)),f=f.img,o&&A&&o.set(s,f)),m.imageSmoothingEnabled=Kb(Cu(m),r.interpolate),Qb(m,f,0,0,f.width,f.height,0,0,a,t),m.globalCompositeOperation="source-in";const y=sl.transform(_u(m),[1,0,0,1,-k,-w]);return m.fillStyle=A?i.getPattern(e,this,y,Rb):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=rg[r]}setLineJoin(r){this.ctx.lineJoin=eg[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(...Cu(this.suspendedCtx)),$b(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(),$b(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=sl.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=sl.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?($b(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(),$b(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=Cu(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 Gf.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 Gf.moveTo:o=e[c++],s=e[c++],t.moveTo(o,s),l||i.updatePathMinMax(f,o,s);break;case Gf.lineTo:o=e[c++],s=e[c++],t.lineTo(o,s),l||i.updatePathMinMax(f,o,s);break;case Gf.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 Gf.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 Gf.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 Gf.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,_u(e),Fb),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,_u(e),Rb),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=ag}eoClip(){this.pendingClip=tg}beginText(){this.current.textMatrix=js,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||Os,(0===i.fontMatrix[0]||0===i.fontMatrix[3])&&Tf("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&of,l=!!(o&sf),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===af||f===Af)&&i.fill(),(f===tf||f===Af)&&i.stroke(),i.restore()):((f===af||f===Af)&&i.fillText(r,e,a),(f===tf||f===Af)&&i.strokeText(r,e,a)),l&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Cu(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 Lf(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===af&&!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,_u(i),Rb);g=Cu(i),i.restore(),i.fillStyle=r}let p=e.lineWidth;const v=e.textMatrixScale;if(0===v||0===p){const r=e.textRenderingMode&of;(r===tf||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||Os,u=r.length;let c,d,h,b;if(!(a.textRenderingMode===nf)&&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=sl.applyTransform([d.width,0],l)[0]*i+A,e.translate(h,0),a.x+=h*f):Tf(`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||Cu(this.ctx),i={createCanvasGraphics:r=>new sg(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ob(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=sl.makeHexColor(r,e,a);this.ctx.strokeStyle=t,this.current.strokeColor=t}setFillRGBColor(r,e,a){const t=sl.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 Gb(r);case"Mesh":return new Nb(r);case"Dummy":return new Db}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,_u(e),xb);const t=_u(e);if(t){const{width:r,height:a}=e.canvas,[i,A,n,o]=sl.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(){Pf("Should not call beginInlineImage")}beginImageData(){Pf("Should not call beginImageData")}paintFormXObjectBegin(r,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),r&&this.transform(...r),this.baseTransform=Cu(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(Cu(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||Df("TODO: Support non-isolated groups."),r.knockout&&Tf("Knockout groups not supported.");const a=Cu(e);if(r.matrix&&e.transform(...r.matrix),!r.bbox)throw new Error("Bounding box is required.");let t=sl.getAxialAlignedBoundingBox(r.bbox,Cu(e));const i=[0,0,e.canvas.width,e.canvas.height];t=sl.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()),$b(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=Cu(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);const a=sl.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,ig,Ag).call(this),qb(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]=sl.singularValueDecompose2dScale(Cu(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),qb(this.ctx)}else qb(this.ctx),this.ctx.rect(e[0],e[1],t,A),this.ctx.clip(),this.endPath()}this.current=new Ub(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...a),this.transform(...t)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),o(this,ng,og).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=Cu(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=sl.transform(o,[e,a,t,i,A[r],A[r+1]]),[l,u]=sl.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();zb(f,this.getObject(r,i)),f.globalCompositeOperation="source-in",f.fillStyle=t?a.getPattern(f,this,_u(e),Rb):a,f.fillRect(0,0,A,n),f.restore(),e.save(),e.transform(...o),e.scale(1,-1),Qb(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):Tf("Dependent image isn't ready yet")}paintImageXObjectRepeat(r,e,a,t){if(!this.contentVisible)return;const i=this.getObject(r);if(!i)return void Tf("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(),!Ps){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;Jb(t,r),i=this.applyTransferMapsToCanvas(t)}const A=this._scaleImage(i,_u(t));t.imageSmoothingEnabled=Kb(Cu(t),r.interpolate),Qb(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;Jb(i,r),t=this.applyTransferMapsToCanvas(i)}for(const r of e)a.save(),a.transform(...r.transform),a.scale(1,-1),Qb(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===tg?a.clip("evenodd"):a.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),a.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const r=Cu(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 fg=sg;ig=new WeakSet,Ag=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)},ng=new WeakSet,og=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 Gf)void 0!==fg.prototype[r]&&(fg.prototype[Gf[r]]=fg.prototype[r]);var lg,ug;class cg{static get workerPort(){return t(this,lg)}static set workerPort(r){if(!(typeof Worker<"u"&&r instanceof Worker)&&null!==r)throw new Error("Invalid `workerPort` type.");A(this,lg,r)}static get workerSrc(){return t(this,ug)}static set workerSrc(r){if("string"!=typeof r)throw new Error("Invalid `workerSrc` type.");A(this,ug,r)}}lg=new WeakMap,ug=new WeakMap,i(cg,lg,null),i(cg,ug,"");const dg=1,hg=2,bg=1,gg=2,pg=3,vg=4,mg=5,kg=6,wg=7,yg=8;function Eg(r){switch(r instanceof Error||"object"==typeof r&&null!==r||Pf('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),r.name){case"AbortException":return new qf(r.message);case"MissingPDFException":return new Jf(r.message);case"PasswordException":return new Hf(r.message,r.code);case"UnexpectedResponseException":return new zf(r.message,r.status);case"UnknownErrorException":return new Qf(r.message,r.details);default:return new Qf(r.message,r.toString())}}var Cg,_g,Bg,Zg,Wg,Ig,Rg,Fg;class xg{constructor(r,e,a){i(this,Cg),i(this,Bg),i(this,Wg),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,Bg,Zg).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===dg)a.resolve(e.data);else{if(e.callback!==hg)throw new Error("Unexpected callback case");a.reject(Eg(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:dg,callbackId:e.callbackId,data:t})}),(function(t){a.postMessage({sourceName:r,targetName:i,callback:hg,callbackId:e.callbackId,reason:Eg(t)})}))}else e.streamId?o(this,Cg,_g).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:kg,streamId:i,desiredSize:r.desiredSize}),e.promise},cancel:r=>{jf(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:bg,streamId:i,reason:Eg(r)}),e.promise}},a)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}Cg=new WeakSet,_g=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:vg,streamId:e,chunk:r},n)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:a,targetName:t,stream:pg,streamId:e}),delete A.streamSinks[e])},error(r){jf(r instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:a,targetName:t,stream:mg,streamId:e,reason:Eg(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:yg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:yg,streamId:e,reason:Eg(r)})}))},Bg=new WeakSet,Zg=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 yg:r.success?A.startCall.resolve():A.startCall.reject(Eg(r.reason));break;case wg:r.success?A.pullCall.resolve():A.pullCall.reject(Eg(r.reason));break;case kg:if(!n){i.postMessage({sourceName:a,targetName:t,stream:wg,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:wg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:wg,streamId:e,reason:Eg(r)})}));break;case vg:if(jf(A,"enqueue should have stream controller"),A.isClosed)break;A.controller.enqueue(r.chunk);break;case pg:if(jf(A,"close should have stream controller"),A.isClosed)break;A.isClosed=!0,A.controller.close(),o(this,Wg,Ig).call(this,A,e);break;case mg:jf(A,"error should have stream controller"),A.controller.error(Eg(r.reason)),o(this,Wg,Ig).call(this,A,e);break;case gg:r.success?A.cancelCall.resolve():A.cancelCall.reject(Eg(r.reason)),o(this,Wg,Ig).call(this,A,e);break;case bg:if(!n)break;new Promise((function(e){var a;e(null==(a=n.onCancel)?void 0:a.call(n,Eg(r.reason)))})).then((function(){i.postMessage({sourceName:a,targetName:t,stream:gg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:gg,streamId:e,reason:Eg(r)})})),n.sinkCapability.reject(Eg(r.reason)),n.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Wg=new WeakSet,Ig=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 Sg{constructor({parsedData:r,rawData:e}){i(this,Rg,void 0),i(this,Fg,void 0),A(this,Rg,r),A(this,Fg,e)}getRaw(){return t(this,Fg)}get(r){return t(this,Rg).get(r)??null}getAll(){return el(t(this,Rg))}has(r){return t(this,Rg).has(r)}}Rg=new WeakMap,Fg=new WeakMap;const Mg=Symbol("INTERNAL");var Gg,Xg,Vg,Ng,Dg,Tg,Pg,jg,Og,Lg;class Yg{constructor(r,{name:e,intent:a,usage:t}){i(this,Gg,!1),i(this,Xg,!1),i(this,Vg,!1),i(this,Ng,!0),A(this,Gg,!!(r&Hs)),A(this,Xg,!!(r&Qs)),this.name=e,this.intent=a,this.usage=t}get visible(){if(t(this,Vg))return t(this,Ng);if(!t(this,Ng))return!1;const{print:r,view:e}=this.usage;return t(this,Gg)?"OFF"!==(null==e?void 0:e.viewState):!t(this,Xg)||"OFF"!==(null==r?void 0:r.printState)}_setVisible(r,e,a=!1){r!==Mg&&Pf("Internal method `_setVisible` called."),A(this,Vg,a),A(this,Ng,e)}}Gg=new WeakMap,Xg=new WeakMap,Vg=new WeakMap,Ng=new WeakMap;class Hg{constructor(r,e=Hs){if(i(this,Og),i(this,Dg,null),i(this,Tg,new Map),i(this,Pg,null),i(this,jg,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==r){this.name=r.name,this.creator=r.creator,A(this,jg,r.order);for(const a of r.groups)t(this,Tg).set(a.id,new Yg(e,a));if("OFF"===r.baseState)for(const r of t(this,Tg).values())r._setVisible(Mg,!1);for(const e of r.on)t(this,Tg).get(e)._setVisible(Mg,!0);for(const e of r.off)t(this,Tg).get(e)._setVisible(Mg,!1);A(this,Pg,this.getHash())}}isVisible(r){if(0===t(this,Tg).size)return!0;if(!r)return Df("Optional content group not defined."),!0;if("OCG"===r.type)return t(this,Tg).has(r.id)?t(this,Tg).get(r.id).visible:(Tf(`Optional content group not found: ${r.id}`),!0);if("OCMD"===r.type){if(r.expression)return o(this,Og,Lg).call(this,r.expression);if(!r.policy||"AnyOn"===r.policy){for(const e of r.ids){if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;if(t(this,Tg).get(e).visible)return!0}return!1}if("AllOn"===r.policy){for(const e of r.ids){if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;if(!t(this,Tg).get(e).visible)return!1}return!0}if("AnyOff"===r.policy){for(const e of r.ids){if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;if(!t(this,Tg).get(e).visible)return!0}return!1}if("AllOff"===r.policy){for(const e of r.ids){if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;if(t(this,Tg).get(e).visible)return!1}return!0}return Tf(`Unknown optional content policy ${r.policy}.`),!0}return Tf(`Unknown group type ${r.type}.`),!0}setVisibility(r,e=!0){const a=t(this,Tg).get(r);a?(a._setVisible(Mg,!!e,!0),A(this,Dg,null)):Tf(`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,Tg).get(e);if(r)switch(a){case"ON":r._setVisible(Mg,!0);break;case"OFF":r._setVisible(Mg,!1);break;case"Toggle":r._setVisible(Mg,!r.visible)}}A(this,Dg,null)}get hasInitialVisibility(){return null===t(this,Pg)||this.getHash()===t(this,Pg)}getOrder(){return t(this,Tg).size?t(this,jg)?t(this,jg).slice():[...t(this,Tg).keys()]:null}getGroups(){return t(this,Tg).size>0?el(t(this,Tg)):null}getGroup(r){return t(this,Tg).get(r)||null}getHash(){if(null!==t(this,Dg))return t(this,Dg);const r=new hb;for(const[e,a]of t(this,Tg))r.update(`${e}:${a.visible}`);return A(this,Dg,r.hexdigest())}}Dg=new WeakMap,Tg=new WeakMap,Pg=new WeakMap,jg=new WeakMap,Og=new WeakSet,Lg=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,Og,Lg).call(this,e);else{if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;A=t(this,Tg).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 Qg{constructor(r,{disableRange:e=!1,disableStream:a=!1}){jf(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{jf(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(){jf(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const r=this._queuedChunks;return this._queuedChunks=null,new Ug(this,r,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=new Jg(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 Ug{constructor(r,e,a=!1,t=null){this._stream=r,this._done=a||!1,this._filename=du(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 Jg{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 zg({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 $g(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=rl(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(du(r))return r}return null}function qg(r,e){return 404===r||0===r&&e.startsWith("file:")?new Jf('Missing PDF "'+e+'".'):new zf(`Unexpected server response (${r}) while retrieving PDF "${e}".`,r)}function Kg(r){return 200===r||206===r}function rp(r,e,a){return{method:"GET",headers:r,signal:a.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function ep(r){const e=new Headers;for(const a in r){const t=r[a];void 0!==t&&e.append(a,t)}return e}function ap(r){return r instanceof Uint8Array?r.buffer:r instanceof ArrayBuffer?r:(Tf(`getArrayBuffer - unexpected data format: ${r}`),new Uint8Array(r).buffer)}class tp{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 jf(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ip(this),this._fullRequestReader}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=new Ap(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 ip{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=ep(this._stream.httpHeaders);const a=e.url;fetch(a,rp(this._headers,this._withCredentials,this._abortController)).then((r=>{if(!Kg(r.status))throw qg(r.status,a);this._reader=r.body.getReader(),this._headersCapability.resolve();const e=e=>r.headers.get(e),{allowRangeRequests:t,suggestedLength:i}=zg({getResponseHeader:e,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t,this._contentLength=i||this._contentLength,this._filename=$g(e),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new qf("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:ap(e),done:!1})}cancel(r){var e;null==(e=this._reader)||e.cancel(r),this._abortController.abort()}}class Ap{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=ep(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${a-1}`);const i=t.url;fetch(i,rp(this._headers,this._withCredentials,this._abortController)).then((r=>{if(!Kg(r.status))throw qg(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:ap(e),done:!1})}cancel(r){var e;null==(e=this._reader)||e.cancel(r),this._abortController.abort()}}class np{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:rl(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 op{constructor(r){this._source=r,this._manager=new np(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 jf(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new sp(this._manager,this._source),this._fullRequestReader}getRangeReader(r,e){const a=new fp(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 sp{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}=zg({getResponseHeader:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});t&&(this._isRangeSupported=!0),this._contentLength=i||this._contentLength,this._filename=$g(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=qg(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 fp{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=qg(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 lp=/^file:\/\/\/[a-zA-Z]:\//;class up{constructor(r){this.source=r,this.url=function(r){const e=Wb.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 jf(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new pp(this):new bp(this),this._fullRequestReader}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=this.isFsUrl?new vp(this,r,e):new gp(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 cp{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 qf("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class dp{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 hp(r,e){return{protocol:r.protocol,auth:r.auth,host:r.hostname,port:r.port,path:r.path,method:"GET",headers:e}}class bp extends cp{constructor(r){super(r);const e=e=>{if(404===e.statusCode){const r=new Jf(`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}=zg({getResponseHeader:a,isHttp:r.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t,this._contentLength=i||this._contentLength,this._filename=$g(a)};if(this._request=null,"http:"===this._url.protocol){const a=Wb.get("http");this._request=a.request(hp(this._url,r.httpHeaders),e)}else{const a=Wb.get("https");this._request=a.request(hp(this._url,r.httpHeaders),e)}this._request.on("error",(r=>{this._storedError=r,this._headersCapability.reject(r)})),this._request.end()}}class gp extends dp{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 Jf(`Missing PDF "${this._url}".`);this._storedError=r}};if(this._request=null,"http:"===this._url.protocol){const r=Wb.get("http");this._request=r.request(hp(this._url,this._httpHeaders),t)}else{const r=Wb.get("https");this._request=r.request(hp(this._url,this._httpHeaders),t)}this._request.on("error",(r=>{this._storedError=r})),this._request.end()}}class pp extends cp{constructor(r){super(r);let e=decodeURIComponent(this._url.path);lp.test(this._url.href)&&(e=e.replace(/^\//,""));const a=Wb.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 Jf(`Missing PDF "${e}".`)),this._storedError=r,this._headersCapability.reject(r)}))}}class vp extends dp{constructor(r,e,a){super(r);let t=decodeURIComponent(this._url.path);lp.test(this._url.href)&&(t=t.replace(/^\//,""));const i=Wb.get("fs");this._setReadableStream(i.createReadStream(t,{start:e,end:a-1}))}}const mp=30;var kp,wp,yp,Ep,Cp,_p,Bp,Zp,Wp,Ip,Rp,Fp,xp,Sp,Mp,Gp,Xp,Vp,Np,Dp,Tp,Pp,jp,Op,Lp,Yp,Hp,Qp,Up,Jp,zp,$p,qp,Kp,rv,ev;let av=(Dp=class{constructor({textContentSource:r,container:e,viewport:a}){var n;if(i(this,Lp),i(this,Hp),i(this,Up),i(this,wp,Promise.withResolvers()),i(this,yp,null),i(this,Ep,!1),i(this,Cp,!(null==(kp=globalThis.FontInspector)||!kp.enabled)),i(this,_p,null),i(this,Bp,null),i(this,Zp,0),i(this,Wp,0),i(this,Ip,null),i(this,Rp,null),i(this,Fp,0),i(this,xp,0),i(this,Sp,Object.create(null)),i(this,Mp,[]),i(this,Gp,null),i(this,Xp,[]),i(this,Vp,new WeakMap),i(this,Np,null),r instanceof ReadableStream)A(this,Gp,r);else{if("object"!=typeof r)throw new Error('No "textContentSource" parameter specified.');A(this,Gp,new ReadableStream({start(e){e.enqueue(r),e.close()}}))}A(this,yp,A(this,Rp,e)),A(this,xp,a.scale*(globalThis.devicePixelRatio||1)),A(this,Fp,a.rotation),A(this,Bp,{prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null});const{pageWidth:s,pageHeight:f,pageX:l,pageY:u}=a.rawDims;A(this,Np,[1,0,0,-1,-l,u+f]),A(this,Wp,s),A(this,Zp,f),o(n=Dp,qp,Kp).call(n),Bu(e,a),t(this,wp).promise.catch((()=>{})).then((()=>{t(Dp,Op).delete(this),A(this,Bp,null),A(this,Sp,null)}))}render(){const r=()=>{t(this,Ip).read().then((({value:e,done:a})=>{a?t(this,wp).resolve():(t(this,_p)??A(this,_p,e.lang),Object.assign(t(this,Sp),e.styles),o(this,Lp,Yp).call(this,e.items),r())}),t(this,wp).reject)};return A(this,Ip,t(this,Gp).getReader()),t(Dp,Op).add(this),r(),t(this,wp).promise}update({viewport:r,onBefore:e=null}){var a;const i=r.scale*(globalThis.devicePixelRatio||1),n=r.rotation;if(n!==t(this,Fp)&&(null==e||e(),A(this,Fp,n),Bu(t(this,Rp),{rotation:n})),i!==t(this,xp)){null==e||e(),A(this,xp,i);const r={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:o(a=Dp,zp,$p).call(a,t(this,_p))};for(const e of t(this,Xp))r.properties=t(this,Vp).get(e),r.div=e,o(this,Up,Jp).call(this,r)}}cancel(){var r;const e=new qf("TextLayer task cancelled.");null==(r=t(this,Ip))||r.cancel(e).catch((()=>{})),A(this,Ip,null),t(this,wp).reject(e)}get textDivs(){return t(this,Xp)}get textContentItemsStr(){return t(this,Mp)}static cleanup(){if(!(t(this,Op).size>0)){t(this,Tp).clear();for(const{canvas:r}of t(this,Pp).values())r.remove();t(this,Pp).clear()}}},wp=new WeakMap,yp=new WeakMap,Ep=new WeakMap,Cp=new WeakMap,_p=new WeakMap,Bp=new WeakMap,Zp=new WeakMap,Wp=new WeakMap,Ip=new WeakMap,Rp=new WeakMap,Fp=new WeakMap,xp=new WeakMap,Sp=new WeakMap,Mp=new WeakMap,Gp=new WeakMap,Xp=new WeakMap,Vp=new WeakMap,Np=new WeakMap,Tp=new WeakMap,Pp=new WeakMap,jp=new WeakMap,Op=new WeakMap,Lp=new WeakSet,Yp=function(r){var e,a;if(t(this,Ep))return;(a=t(this,Bp)).ctx??(a.ctx=o(e=Dp,zp,$p).call(e,t(this,_p)));const i=t(this,Xp),n=t(this,Mp);for(const e of r){if(i.length>1e5)return Tf("Ignoring additional textDivs for performance reasons."),void A(this,Ep,!0);if(void 0!==e.str)n.push(e.str),o(this,Hp,Qp).call(this,e);else if("beginMarkedContentProps"===e.type||"beginMarkedContent"===e.type){const r=t(this,yp);A(this,yp,document.createElement("span")),t(this,yp).classList.add("markedContent"),null!==e.id&&t(this,yp).setAttribute("id",`${e.id}`),r.append(t(this,yp))}else"endMarkedContent"===e.type&&A(this,yp,t(this,yp).parentNode)}},Hp=new WeakSet,Qp=function(r){var e;const a=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==r.str,hasEOL:r.hasEOL,fontSize:0};t(this,Xp).push(a);const A=sl.transform(t(this,Np),r.transform);let n=Math.atan2(A[1],A[0]);const s=t(this,Sp)[r.fontName];s.vertical&&(n+=Math.PI/2);const f=t(this,Cp)&&s.fontSubstitution||s.fontFamily,l=Math.hypot(A[2],A[3]),u=l*o(e=Dp,rv,ev).call(e,f,t(this,_p));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,yp)===t(this,Rp)?(b.left=`${(100*c/t(this,Wp)).toFixed(2)}%`,b.top=`${(100*d/t(this,Zp)).toFixed(2)}%`):(b.left=`${h}${c.toFixed(2)}px)`,b.top=`${h}${d.toFixed(2)}px)`),b.fontSize=`${h}${(t(Dp,jp)*l).toFixed(2)}px)`,b.fontFamily=f,i.fontSize=l,a.setAttribute("role","presentation"),a.textContent=r.str,a.dir=r.dir,t(this,Cp)&&(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,Vp).set(a,i),t(this,Bp).div=a,t(this,Bp).properties=i,o(this,Up,Jp).call(this,t(this,Bp)),i.hasText&&t(this,yp).append(a),i.hasEOL){const r=document.createElement("br");r.setAttribute("role","presentation"),t(this,yp).append(r)}},Up=new WeakSet,Jp=function(r){const{div:e,properties:a,ctx:i,prevFontSize:A,prevFontFamily:n}=r,{style:o}=e;let s="";if(t(Dp,jp)>1&&(s=`scale(${1/t(Dp,jp)})`),0!==a.canvasWidth&&a.hasText){const{fontFamily:f}=o,{canvasWidth:l,fontSize:u}=a;(A!==u||n!==f)&&(i.font=`${u*t(this,xp)}px ${f}`,r.prevFontSize=u,r.prevFontFamily=f);const{width:c}=i.measureText(e.textContent);c>0&&(s=`scaleX(${l*t(this,xp)/c}) ${s}`)}0!==a.angle&&(s=`rotate(${a.angle}deg) ${s}`),s.length>0&&(o.transform=s)},zp=new WeakSet,$p=function(r=null){let e=t(this,Pp).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,Pp).set(r,e)}return e},qp=new WeakSet,Kp=function(){if(null!==t(this,jp))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,jp,r.getBoundingClientRect().height),r.remove()},rv=new WeakSet,ev=function(r,e){const a=t(this,Tp).get(r);if(a)return a;const i=o(this,zp,$p).call(this,e),A=i.font;i.canvas.width=i.canvas.height=mp,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,Tp).set(r,e),i.canvas.width=i.canvas.height=0,i.font=A,e}i.strokeStyle="red",i.clearRect(0,0,mp,mp),i.strokeText("g",0,0);let l=i.getImageData(0,0,mp,mp).data;f=0;for(let r=l.length-1-3;r>=0;r-=4)if(l[r]>0){f=Math.ceil(r/4/mp);break}i.clearRect(0,0,mp,mp),i.strokeText("A",0,mp),l=i.getImageData(0,0,mp,mp).data,s=0;for(let r=0,e=l.length;r<e;r+=4)if(l[r]>0){s=mp-Math.floor(r/4/mp);break}i.canvas.width=i.canvas.height=0,i.font=A;const u=s?s/(s+f):.8;return t(this,Tp).set(r,u),u},i(Dp,zp),i(Dp,qp),i(Dp,rv),i(Dp,Tp,new Map),i(Dp,Pp,new Map),i(Dp,jp,null),i(Dp,Op,new Set),Dp);function tv(){mu("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:r,container:e,viewport:a,...t}=arguments[0],i=Object.keys(t);i.length>0&&Tf("Ignoring `renderTextLayer` parameters: "+i.join(", "));const A=new av({textContentSource:r,container:e,viewport:a}),{textDivs:n,textContentItemsStr:o}=A;return{promise:A.render(),textDivs:n,textContentItemsStr:o}}function iv(){mu("`updateTextLayer`, please use `TextLayer` instead.")}class Av{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(!Av.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 nv=65536,ov=Ps?class extends _l{_createCanvas(r,e){return Wb.get("canvas").createCanvas(r,e)}}:class extends _l{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}},sv=Ps?class extends Bl{_fetchData(r,e){return Ib(r).then((r=>({cMapData:r,compressionType:e})))}}:ou,fv=Ps?class extends yl{}:class extends yl{constructor({docId:r,ownerDocument:e=globalThis.document}={}){super(),i(this,Nl),i(this,Tl),i(this,jl),i(this,Ll),i(this,Hl),i(this,Ul),i(this,zl),i(this,ql),i(this,ru),i(this,au),i(this,iu),i(this,xl,void 0),i(this,Sl,void 0),i(this,Ml,void 0),i(this,Gl,void 0),i(this,Xl,void 0),i(this,Vl,0),A(this,Ml,r),A(this,Gl,e)}addFilter(r){if(!r)return"none";let e=t(this,Nl,Dl).get(r);if(e)return e;const[a,i,A]=o(this,Ll,Yl).call(this,r),s=1===r.length?a:`${a}${i}${A}`;if(e=t(this,Nl,Dl).get(s),e)return t(this,Nl,Dl).set(r,e),e;const f=`g_${t(this,Ml)}_transfer_map_${n(this,Vl)._++}`,l=`url(#${f})`;t(this,Nl,Dl).set(r,l),t(this,Nl,Dl).set(s,l);const u=o(this,zl,$l).call(this,f);return o(this,ru,eu).call(this,a,i,A,u),l}addHCMFilter(r,e){var a;const i=`${r}-${e}`,A="base";let n=t(this,Tl,Pl).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,Tl,Pl).set(A,n)),!r||!e))return n.url;const s=o(this,iu,Au).call(this,r);r=sl.makeHexColor(...s);const f=o(this,iu,Au).call(this,e);if(e=sl.makeHexColor(...f),t(this,jl,Ol).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,Ml)}_hcm_filter`,d=n.filter=o(this,zl,$l).call(this,c);o(this,ru,eu).call(this,u,u,u,d),o(this,Ul,Jl).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,ru,eu).call(this,h(0,5),h(1,5),h(2,5),d),n.url=`url(#${c})`,n.url}addAlphaFilter(r){let e=t(this,Nl,Dl).get(r);if(e)return e;const[a]=o(this,Ll,Yl).call(this,[r]),i=`alpha_${a}`;if(e=t(this,Nl,Dl).get(i),e)return t(this,Nl,Dl).set(r,e),e;const A=`g_${t(this,Ml)}_alpha_map_${n(this,Vl)._++}`,s=`url(#${A})`;t(this,Nl,Dl).set(r,s),t(this,Nl,Dl).set(i,s);const f=o(this,zl,$l).call(this,A);return o(this,au,tu).call(this,a,f),s}addLuminosityFilter(r){let e,a,i=t(this,Nl,Dl).get(r||"luminosity");if(i)return i;if(r?([e]=o(this,Ll,Yl).call(this,[r]),a=`luminosity_${e}`):a="luminosity",i=t(this,Nl,Dl).get(a),i)return t(this,Nl,Dl).set(r,i),i;const A=`g_${t(this,Ml)}_luminosity_map_${n(this,Vl)._++}`,s=`url(#${A})`;t(this,Nl,Dl).set(r,s),t(this,Nl,Dl).set(a,s);const f=o(this,zl,$l).call(this,A);return o(this,Hl,Ql).call(this,f),r&&o(this,au,tu).call(this,e,f),s}addHighlightHCMFilter(r,e,a,i,A){var n;const s=`${e}-${a}-${i}-${A}`;let f=t(this,Tl,Pl).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,Tl,Pl).set(r,f)),!e||!a))return f.url;const[l,u]=[e,a].map(o(this,iu,Au).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,iu,Au).bind(this));d<c&&([c,d,h,b]=[d,c,b,h]),t(this,jl,Ol).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,Ml)}_hcm_${r}_filter`,v=f.filter=o(this,zl,$l).call(this,p);return o(this,Ul,Jl).call(this,v),o(this,ru,eu).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,Tl,Pl).size||(t(this,Sl)&&(t(this,Sl).parentNode.parentNode.remove(),A(this,Sl,null)),t(this,xl)&&(t(this,xl).clear(),A(this,xl,null)),A(this,Vl,0))}},lv=Ps?class extends Zl{_fetchData(r){return Ib(r)}}:su;function uv(r={}){"string"==typeof r||r instanceof URL?r={url:r}:(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});const e=new bv,{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(Ps&&"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(Ps&&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 rl(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 gv?r.range:null,f=Number.isInteger(r.rangeChunkSize)&&r.rangeChunkSize>0?r.rangeChunkSize:nv;let l=r.worker instanceof Gv?r.worker:null;const u=r.verbosity,c="string"!=typeof r.docBaseUrl||cu(r.docBaseUrl)?null:r.docBaseUrl,d="string"==typeof r.cMapUrl?r.cMapUrl:null,h=!1!==r.cMapPacked,b=r.CMapReaderFactory||sv,g="string"==typeof r.standardFontDataUrl?r.standardFontDataUrl:null,p=r.StandardFontDataFactory||lv,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:!Ps,y=Number.isInteger(r.canvasMaxAreaInBytes)?r.canvasMaxAreaInBytes:-1,E="boolean"==typeof r.disableFontFace?r.disableFontFace:Ps,C=!0===r.fontExtraProperties,_=!0===r.enableXfa,B=r.ownerDocument||globalThis.document,Z=!0===r.disableRange,W=!0===r.disableStream,I=!0===r.disableAutoFetch,R=!0===r.pdfBug,F=!0===r.enableHWA,x=s?s.length:r.length??NaN,S="boolean"==typeof r.useSystemFonts?r.useSystemFonts:!Ps&&!E,M="boolean"==typeof r.useWorkerFetch?r.useWorkerFetch:b===ou&&p===su&&d&&g&&pu(d,document.baseURI)&&pu(g,document.baseURI),G=r.canvasFactory||new ov({ownerDocument:B,enableHWA:F}),X=r.filterFactory||new fv({docId:a,ownerDocument:B});!function(r){Number.isInteger(r)&&(Vf=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:cg.workerPort};l=r.port?Gv.fromPort(r):new Gv(r),e._worker=l}const N={docId:a,apiVersion:"4.4.168",data:i,password:o,disableAutoFetch:I,rangeChunkSize:f,length:x,docBaseUrl:c,enableXfa:_,evaluatorOptions:{maxImageSize:m,disableFontFace:E,ignoreErrors:v,isEvalSupported:k,isOffscreenCanvasSupported:w,canvasMaxAreaInBytes:y,fontExtraProperties:C,useSystemFonts:S,cMapUrl:M?d:null,standardFontDataUrl:M?g:null}},D={disableFontFace:E,fontExtraProperties:C,ownerDocument:B,pdfBug:R,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:_}};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 Qg(s,{disableRange:Z,disableStream:W});else if(!i){if(!t)throw new Error("getDocument - no `url` parameter provided.");u={url:t,length:x,httpHeaders:A,withCredentials:n,rangeChunkSize:f,disableRange:Z,disableStream:W},o=Ps?typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&pu(u.url)?new tp(u):new up(u):pu(u.url)?new tp(u):new op(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 xg(a,r,l.port),i=new Ov(t,e,o,D,V);e._transport=i,t.send("Ready",null)}))})).catch(e._capability.reject),e}function cv(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 dv;const hv=class{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+n(hv,dv)._++,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 bv=hv;dv=new WeakMap,i(bv,dv,0);let gv=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){Pf("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class pv{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 Lf(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 vv,mv,kv,wv,yv,Ev,Cv,_v;class Bv{constructor(r,e,a,t=!1){i(this,kv),i(this,yv),i(this,vv,null),i(this,mv,!1),this._pageIndex=r,this._pageInfo=e,this._transport=a,this._stats=t?new gu:null,this._pdfBug=t,this.commonObjs=a.commonObjs,this.objs=new $v,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 lu({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 Lf(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=qs.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,mv,!1),o(this,yv,Ev).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&Qs);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,mv,!0),o(this,kv,wv).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 rm({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=qs.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=>Av.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,mv,!1),o(this,yv,Ev).call(this),Promise.all(r)}cleanup(r=!1){A(this,mv,!0);const e=o(this,kv,wv).call(this,!1);return r&&e&&this._stats&&(this._stats=new gu),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,kv,wv).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,kv,wv).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 uu){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 qf(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}}vv=new WeakMap,mv=new WeakMap,kv=new WeakSet,wv=function(r=!1){if(o(this,yv,Ev).call(this),!t(this,mv)||this.destroyed)return!1;if(r)return A(this,vv,setTimeout((()=>{A(this,vv,null),o(this,kv,wv).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,mv,!1),!0},yv=new WeakSet,Ev=function(){t(this,vv)&&(clearTimeout(t(this,vv)),A(this,vv,null))};class Zv{constructor(){i(this,Cv,new Set),i(this,_v,Promise.resolve())}postMessage(r,e){const a={data:structuredClone(r,e?{transfer:e}:null)};t(this,_v).then((()=>{for(const r of t(this,Cv))r.call(this,a)}))}addEventListener(r,e){t(this,Cv).add(e)}removeEventListener(r,e){t(this,Cv).delete(e)}terminate(){t(this,Cv).clear()}}Cv=new WeakMap,_v=new WeakMap;const Wv={isWorkerDisabled:!1,fakeWorkerId:0};var Iv,Rv,Fv,xv,Sv;Ps&&(Wv.isWorkerDisabled=!0,cg.workerSrc||(cg.workerSrc="./pdf.worker.mjs")),Wv.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},Wv.createCDNWrapper=function(r){const e=`await import("${r}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};const Mv=class{constructor({name:r=null,port:e=null,verbosity:a=Nf()}={}){var n;if(i(this,Rv),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(Mv,Iv))&&n.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(t(Mv,Iv)||A(Mv,Iv,new WeakMap)).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return Ps?Promise.all([Wb.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 xg("main","worker",r),this._messageHandler.on("ready",(function(){})),o(this,Rv,Fv).call(this)}_initialize(){if(Wv.isWorkerDisabled||t(Mv,xv,Sv))return void this._setupFakeWorker();let{workerSrc:r}=Mv;try{Wv.isSameOrigin(window.location.href,r)||(r=Wv.createCDNWrapper(new URL(r,window.location).href));const e=new Worker(r,{type:"module"}),a=new xg("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,Rv,Fv).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{Df("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Wv.isWorkerDisabled||(Tf("Setting up fake worker."),Wv.isWorkerDisabled=!0),Mv._setupFakeWorkerGlobal.then((r=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new Zv;this._port=e;const a="fake"+Wv.fakeWorkerId++,t=new xg(a+"_worker",a,e);r.setup(t,e),this._messageHandler=new xg(a,a+"_worker",e),o(this,Rv,Fv).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(Mv,Iv))||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,Iv))?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 Mv(r)}static get workerSrc(){if(cg.workerSrc)return cg.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Lf(this,"_setupFakeWorkerGlobal",(async()=>t(this,xv,Sv)?t(this,xv,Sv):(await import(this.workerSrc)).WorkerMessageHandler)())}};let Gv=Mv;var Xv,Vv,Nv,Dv,Tv,Pv,jv;Iv=new WeakMap,Rv=new WeakSet,Fv=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},xv=new WeakSet,Sv=function(){var r;try{return(null==(r=globalThis.pdfjsWorker)?void 0:r.WorkerMessageHandler)||null}catch{return null}},i(Gv,xv),i(Gv,Iv,void 0);class Ov{constructor(r,e,a,t,A){i(this,Pv),i(this,Xv,new Map),i(this,Vv,new Map),i(this,Nv,new Map),i(this,Dv,new Map),i(this,Tv,null),this.messageHandler=r,this.loadingTask=e,this.commonObjs=new $v,this.fontLoader=new Cb({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 Lf(this,"annotationStorage",new yb)}getRenderingIntent(r,e=qs.ENABLE,a=null,t=!1){let i=Hs,A=bb;switch(r){case"any":i=Ys;break;case"display":break;case"print":i=Qs;break;default:Tf(`getRenderingIntent - invalid intent: ${r}`)}switch(e){case qs.DISABLE:i+=zs;break;case qs.ENABLE:break;case qs.ENABLE_FORMS:i+=Us;break;case qs.ENABLE_STORAGE:i+=Js,A=(i&Qs&&a instanceof Eb?a:this.annotationStorage).serializable;break;default:Tf(`getRenderingIntent - invalid annotationMode: ${e}`)}return t&&(i+=$s),{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,Tv))||r.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const r of t(this,Vv).values())e.push(r._destroy());t(this,Vv).clear(),t(this,Nv).clear(),t(this,Dv).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,Xv).clear(),this.filterFactory.destroy(),av.cleanup(),null==(r=this._networkStream)||r.cancelAllRequests(new qf("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)=>{jf(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():(jf(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)=>{jf(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():(jf(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 pv(r,this))})),r.on("DocException",(function(r){let a;switch(r.name){case"PasswordException":a=new Hf(r.message,r.code);break;case"InvalidPDFException":a=new Uf(r.message);break;case"MissingPDFException":a=new Jf(r.message);break;case"UnexpectedResponseException":a=new zf(r.message,r.status);break;case"UnknownErrorException":a=new Qf(r.message,r.details);break;default:Pf("DocException - expected a valid Error.")}e._capability.reject(a)})),r.on("PasswordRequest",(r=>{if(A(this,Tv,Promise.withResolvers()),e.onPassword){const a=r=>{r instanceof Error?t(this,Tv).reject(r):t(this,Tv).resolve({password:r})};try{e.onPassword(a,r.code)}catch(r){t(this,Tv).reject(r)}}else t(this,Tv).reject(new Hf(r.message,r.code));return t(this,Tv).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,Vv).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;Tf(`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 _b(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;jf(u,"The imageRef must be defined.");for(const r of t(this,Vv).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,Vv).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&&Tf("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,Nv).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,Dv).set(a.refStr,r);const i=new Bv(e,a,this,this._params.pdfBug);return t(this,Vv).set(e,i),i}));return t(this,Nv).set(e,i),i}getPageIndex(r){return cv(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,Pv,jv).call(this,"GetFieldObjects")}hasJSActions(){return o(this,Pv,jv).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,Pv,jv).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,Pv,jv).call(this,"GetOptionalContentConfig").then((e=>new Hg(e,r)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const r="GetMetadata",e=t(this,Xv).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 Sg(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,Xv).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,Vv).values())if(!r.cleanup())throw new Error(`startCleanup: Page ${r.pageNumber} is currently rendering.`);this.commonObjs.clear(),r||this.fontLoader.clear(),t(this,Xv).clear(),this.filterFactory.destroy(!0),av.cleanup()}}cachedPageNumber(r){if(!cv(r))return null;const e=0===r.gen?`${r.num}R`:`${r.num}R${r.gen}`;return t(this,Dv).get(e)??null}}Xv=new WeakMap,Vv=new WeakMap,Nv=new WeakMap,Dv=new WeakMap,Tv=new WeakMap,Pv=new WeakSet,jv=function(r,e=null){const a=t(this,Xv).get(r);if(a)return a;const i=this.messageHandler.sendWithPromise(r,e);return t(this,Xv).set(r,i),i};const Lv=Symbol("INITIAL_DATA");var Yv,Hv,Qv,Uv,Jv,zv;class $v{constructor(){i(this,Hv),i(this,Yv,Object.create(null))}get(r,e=null){if(e){const a=o(this,Hv,Qv).call(this,r);return a.promise.then((()=>e(a.data))),null}const a=t(this,Yv)[r];if(!a||a.data===Lv)throw new Error(`Requesting object that isn't resolved yet ${r}.`);return a.data}has(r){const e=t(this,Yv)[r];return!!e&&e.data!==Lv}resolve(r,e=null){const a=o(this,Hv,Qv).call(this,r);a.data=e,a.resolve()}clear(){var r;for(const e in t(this,Yv)){const{data:a}=t(this,Yv)[e];null==(r=null==a?void 0:a.bitmap)||r.close()}A(this,Yv,Object.create(null))}*[Symbol.iterator](){for(const r in t(this,Yv)){const{data:e}=t(this,Yv)[r];e!==Lv&&(yield[r,e])}}}Yv=new WeakMap,Hv=new WeakSet,Qv=function(r){var e;return(e=t(this,Yv))[r]||(e[r]={...Promise.withResolvers(),data:Lv})};class qv{constructor(r){i(this,Uv,null),A(this,Uv,r),this.onContinue=null}get promise(){return t(this,Uv).capability.promise}cancel(r=0){t(this,Uv).cancel(null,r)}get separateAnnots(){const{separateAnnots:r}=t(this,Uv).operatorList;if(!r)return!1;const{annotationCanvasMap:e}=t(this,Uv);return r.form||r.canvas&&(null==e?void 0:e.size)>0}}Uv=new WeakMap;const Kv=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,Jv,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 qv(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(Kv,zv).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(Kv,zv).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 fg(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,Jv)&&(window.cancelAnimationFrame(t(this,Jv)),A(this,Jv,null)),t(Kv,zv).delete(this._canvas),this.callback(r||new uu(`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,Jv,window.requestAnimationFrame((()=>{A(this,Jv,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(Kv,zv).delete(this._canvas),this.callback())))}};let rm=Kv;Jv=new WeakMap,zv=new WeakMap,i(rm,zv,new WeakSet);const em="4.4.168",am="19fbc8998";function tm(r){return Math.floor(255*Math.max(0,Math.min(1,r))).toString(16).padStart(2,"0")}function im(r){return Math.max(0,Math.min(255,255*r))}class Am{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=im(r),r,r]}static G_HTML([r]){const e=tm(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(im)}static RGB_HTML(r){return`#${r.map(tm).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[im(1-Math.min(1,r+t)),im(1-Math.min(1,a+t)),im(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 nm{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&&Av.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&&Av.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 om=1e3,sm=new WeakSet;function fm(r){return{width:r[2]-r[0],height:r[3]-r[1]}}class lm{static create(r){switch(r.data.annotationType){case uf:return new Ek(r);case lf:return new Ck(r);case Zf:switch(r.data.fieldType){case"Tx":return new Bk(r);case"Btn":return r.data.radioButton?new Ik(r):r.data.checkBox?new Wk(r):new Rk(r);case"Ch":return new Fk(r);case"Sig":return new Zk(r)}return new _k(r);case _f:return new xk(r);case cf:return new Mk(r);case df:return new Gk(r);case hf:return new Xk(r);case bf:return new Vk(r);case pf:return new Nk(r);case Ef:return new Tk(r);case Cf:return new Pk(r);case gf:return new Dk(r);case vf:return new jk(r);case mf:return new Ok(r);case kf:return new Lk(r);case wf:return new Yk(r);case yf:return new Hk(r);case Bf:return new Qk(r);default:return new pm(r)}}}var um,cm,dm,hm,bm;const gm=class{constructor(r,{isRenderable:e=!1,ignoreBorder:a=!1,createQuadrilaterals:t=!1}={}){i(this,hm),i(this,um,null),i(this,cm,!1),i(this,dm,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 gm._hasPopupData(this.data)}updateEdited(r){var e;if(!this.container)return;t(this,um)||A(this,um,{rect:this.data.rect.slice(0)});const{rect:a}=r;a&&o(this,hm,bm).call(this,a),null==(e=t(this,dm))||e.popup.updateEdited(r)}resetEdited(){var r;t(this,um)&&(o(this,hm,bm).call(this,t(this,um).rect),null==(r=t(this,dm))||r.popup.resetEdited(),A(this,um,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 _k||(i.tabIndex=om);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 xk){const{rotation:r}=e;return!e.hasOwnCanvas&&0!==r&&this.setRotation(r,i),i}const{width:o,height:s}=fm(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 Ik){const r=`calc(${o}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`;n.borderRadius=r}switch(e.borderStyle.style){case Wf:n.borderStyle="solid";break;case If:n.borderStyle="dashed";break;case Rf:Tf("Unimplemented border style: beveled");break;case Ff:Tf("Unimplemented border style: inset");break;case xf:n.borderBottomStyle="solid"}const t=e.borderColor||null;t?(A(this,cm,!0),n.borderColor=sl.makeHexColor(0|t[0],0|t[1],0|t[2])):n.borderWidth=0}const f=sl.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}=fm(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]=Am[`${i}_HTML`](A),this.annotationStorage.setValue(this.data.id,{[e]:Am[`${i}_rgb`](A)})};return Lf(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,cm)){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,cm)&&(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,dm,new xk({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(){Pf("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||sm.has(n)?a.push({id:i,exportValue:t,domElement:n}):Tf(`_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&&sm.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 pm=gm;var vm,mm,km,wm,ym,Em,Cm,_m,Bm,Zm,Wm,Im,Rm,Fm,xm,Sm,Mm,Gm,Xm,Vm,Nm,Dm,Tm,Pm,jm,Om,Lm,Ym,Hm,Qm,Um,Jm,zm,$m,qm,Km,rk,ek,ak,tk,ik,Ak,nk,ok,sk,fk,lk,uk,ck,dk,hk,bk,gk,pk,vk,mk,kk,wk,yk;um=new WeakMap,cm=new WeakMap,dm=new WeakMap,hm=new WeakSet,bm=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}=fm(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 Ek extends pm{constructor(r,e=null){super(r,{isRenderable:!0,ignoreBorder:!(null==e||!e.ignoreBorder),createQuadrilaterals:!0}),i(this,vm),i(this,km),i(this,ym),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,km,wm).call(this,a,r.attachment,r.attachmentDest),t=!0):r.setOCGState?(o(this,ym,Em).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,vm,mm).call(this)}_bindNamedAction(r,e){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeNamedAction(e),!1),o(this,vm,mm).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,vm,mm).call(this)}_bindResetFormAction(r,e){const a=r.onclick;if(a||(r.href=this.linkService.getAnchorUrl("")),o(this,vm,mm).call(this),!this._fieldObjects)return Tf('_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&&(sm.has(a)?a.dispatchEvent(new Event("resetform")):Tf(`_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}}}vm=new WeakSet,mm=function(){this.container.setAttribute("data-internal-link","")},km=new WeakSet,wm=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,vm,mm).call(this)},ym=new WeakSet,Em=function(r,e){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeSetOCGState(e),!1),o(this,vm,mm).call(this)};class Ck extends pm{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 _k extends pm{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 al.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":sl.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/(Ls*a))||1);i=Math.min(a,A(e/Ls))}else{const r=Math.abs(this.data.rect[3]-this.data.rect[1]-2);i=Math.min(a,A(r/Ls))}t.fontSize=`calc(${i}px * var(--scale-factor))`,t.color=sl.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 Bk extends _k{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),sm.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=om,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 Zk extends _k{constructor(r){super(r,{isRenderable:!!r.data.hasOwnCanvas})}}class Wk extends _k{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 sm.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=om,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 Ik extends _k{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(sm.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=om,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 Rk extends Ek{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 Fk extends _k{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");sm.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=om;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 xk extends pm{constructor(r){const{data:e,elements:a}=r;super(r,{isRenderable:pm._hasPopupData(e)}),this.elements=a,this.popup=null}render(){this.container.classList.add("popupAnnotation");const r=this.popup=new Sk({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=>`${cl}${r}`)).join(",")),this.container}}class Sk{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,Om),i(this,Ym),i(this,Qm),i(this,Jm),i(this,$m),i(this,Km),i(this,ek),i(this,tk),i(this,Ak),i(this,Cm,o(this,$m,qm).bind(this)),i(this,_m,o(this,Ak,nk).bind(this)),i(this,Bm,o(this,tk,ik).bind(this)),i(this,Zm,o(this,ek,ak).bind(this)),i(this,Wm,null),i(this,Im,null),i(this,Rm,null),i(this,Fm,null),i(this,xm,null),i(this,Sm,null),i(this,Mm,null),i(this,Gm,!1),i(this,Xm,null),i(this,Vm,null),i(this,Nm,null),i(this,Dm,null),i(this,Tm,null),i(this,Pm,null),i(this,jm,!1),A(this,Im,r),A(this,Tm,n),A(this,Rm,f),A(this,Dm,l),A(this,Sm,u),A(this,Wm,e),A(this,Nm,c),A(this,Mm,d),A(this,xm,a),A(this,Fm,wu.toDateObject(s)),this.trigger=a.flatMap((r=>r.getElementsToTriggerPopup()));for(const r of this.trigger)r.addEventListener("click",t(this,Zm)),r.addEventListener("mouseenter",t(this,Bm)),r.addEventListener("mouseleave",t(this,_m)),r.classList.add("popupTriggerArea");for(const r of a)null==(b=r.container)||b.addEventListener("keydown",t(this,Cm));t(this,Im).hidden=!0,h&&o(this,ek,ak).call(this)}render(){if(t(this,Xm))return;const r=A(this,Xm,document.createElement("div"));if(r.className="popup",t(this,Wm)){const e=r.style.outlineColor=sl.makeHexColor(...t(this,Wm));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?r.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:r.style.backgroundColor=sl.makeHexColor(...t(this,Wm).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,Tm)),r.append(e),t(this,Fm)){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,Fm).toLocaleDateString(),time:t(this,Fm).toLocaleTimeString()})),e.append(r)}const i=t(this,Om,Lm);if(i)nm.render({xfaHtml:i,intent:"richText",div:r}),r.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(t(this,Rm));r.append(e)}t(this,Im).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,Pm)||A(this,Pm,{contentsObj:t(this,Rm),richText:t(this,Dm)}),r&&A(this,Vm,null),e&&(A(this,Dm,o(this,Jm,zm).call(this,e)),A(this,Rm,null)),null==(a=t(this,Xm))||a.remove(),A(this,Xm,null)}resetEdited(){var r;t(this,Pm)&&(({contentsObj:n(this,Rm)._,richText:n(this,Dm)._}=t(this,Pm)),A(this,Pm,null),null==(r=t(this,Xm))||r.remove(),A(this,Xm,null),A(this,Vm,null))}forceHide(){A(this,jm,this.isVisible),t(this,jm)&&(t(this,Im).hidden=!0)}maybeShow(){t(this,jm)&&(t(this,Xm)||o(this,tk,ik).call(this),A(this,jm,!1),t(this,Im).hidden=!1)}get isVisible(){return!1===t(this,Im).hidden}}Cm=new WeakMap,_m=new WeakMap,Bm=new WeakMap,Zm=new WeakMap,Wm=new WeakMap,Im=new WeakMap,Rm=new WeakMap,Fm=new WeakMap,xm=new WeakMap,Sm=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 WeakMap,jm=new WeakMap,Om=new WeakSet,Lm=function(){const r=t(this,Dm),e=t(this,Rm);return null!=r&&r.str&&(!(null!=e&&e.str)||e.str===r.str)&&t(this,Dm).html||null},Ym=new WeakSet,Hm=function(){var r,e,a;return(null==(a=null==(e=null==(r=t(this,Om,Lm))?void 0:r.attributes)?void 0:e.style)?void 0:a.fontSize)||0},Qm=new WeakSet,Um=function(){var r,e,a;return(null==(a=null==(e=null==(r=t(this,Om,Lm))?void 0:r.attributes)?void 0:e.style)?void 0:a.color)||null},Jm=new WeakSet,zm=function(r){const e=[],a={str:r,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:t(this,Qm,Um),fontSize:t(this,Ym,Hm)?`calc(${t(this,Ym,Hm)}px * var(--scale-factor))`:""}};for(const a of r.split("\n"))e.push({name:"span",value:a,attributes:i});return a},$m=new WeakSet,qm=function(r){r.altKey||r.shiftKey||r.ctrlKey||r.metaKey||("Enter"===r.key||"Escape"===r.key&&t(this,Gm))&&o(this,ek,ak).call(this)},Km=new WeakSet,rk=function(){if(null!==t(this,Vm))return;const{page:{view:r},viewport:{rawDims:{pageWidth:e,pageHeight:a,pageX:i,pageY:n}}}=t(this,Sm);let o=!!t(this,Mm),s=t(this,o?Mm:Nm);for(const r of t(this,xm))if(!s||null!==sl.intersect(r.data.rect,s)){s=r.data.rect,o=!0;break}const f=sl.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,Vm,[100*(u-i)/e,100*(c-n)/a]);const{style:d}=t(this,Im);d.left=`${t(this,Vm)[0]}%`,d.top=`${t(this,Vm)[1]}%`},ek=new WeakSet,ak=function(){A(this,Gm,!t(this,Gm)),t(this,Gm)?(o(this,tk,ik).call(this),t(this,Im).addEventListener("click",t(this,Zm)),t(this,Im).addEventListener("keydown",t(this,Cm))):(o(this,Ak,nk).call(this),t(this,Im).removeEventListener("click",t(this,Zm)),t(this,Im).removeEventListener("keydown",t(this,Cm)))},tk=new WeakSet,ik=function(){t(this,Xm)||this.render(),this.isVisible?t(this,Gm)&&t(this,Im).classList.add("focused"):(o(this,Km,rk).call(this),t(this,Im).hidden=!1,t(this,Im).style.zIndex=parseInt(t(this,Im).style.zIndex)+1e3)},Ak=new WeakSet,nk=function(){t(this,Im).classList.remove("focused"),!t(this,Gm)&&this.isVisible&&(t(this,Im).hidden=!0,t(this,Im).style.zIndex=parseInt(t(this,Im).style.zIndex)-1e3)};class Mk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),this.textContent=r.data.textContent,this.textPosition=r.data.textPosition,this.annotationEditorType=Ks.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 Gk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,ok,null)}render(){this.container.classList.add("lineAnnotation");const r=this.data,{width:e,height:a}=fm(r.rect),t=this.svgFactory.create(e,a,!0),i=A(this,ok,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,ok)}addHighlightArea(){this.container.classList.add("highlightArea")}}ok=new WeakMap;class Xk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,sk,null)}render(){this.container.classList.add("squareAnnotation");const r=this.data,{width:e,height:a}=fm(r.rect),t=this.svgFactory.create(e,a,!0),i=r.borderStyle.width,n=A(this,sk,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,sk)}addHighlightArea(){this.container.classList.add("highlightArea")}}sk=new WeakMap;class Vk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,fk,null)}render(){this.container.classList.add("circleAnnotation");const r=this.data,{width:e,height:a}=fm(r.rect),t=this.svgFactory.create(e,a,!0),i=r.borderStyle.width,n=A(this,fk,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,fk)}addHighlightArea(){this.container.classList.add("highlightArea")}}fk=new WeakMap;class Nk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,lk,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}=fm(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,lk,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,lk)}addHighlightArea(){this.container.classList.add("highlightArea")}}lk=new WeakMap;class Dk extends Nk{constructor(r){super(r),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Tk extends pm{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 Pk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,uk,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=Ks.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,inkLists:e,borderStyle:a,popupRef:i}}=this,{width:A,height:n}=fm(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,uk).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,uk)}addHighlightArea(){this.container.classList.add("highlightArea")}}uk=new WeakMap;class jk extends pm{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 Ok extends pm{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 Lk extends pm{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 Yk extends pm{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 Hk extends pm{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 Qk extends pm{constructor(r){var e;super(r,{isRenderable:!0}),i(this,dk),i(this,ck,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,dk,hk).bind(this)),A(this,ck,a);const{isMac:t}=al.platform;return r.addEventListener("keydown",(r=>{"Enter"===r.key&&(t?r.metaKey:r.ctrlKey)&&o(this,dk,hk).call(this)})),!e.popupRef&&this.hasPopupData?this._createPopup():a.classList.add("popupTriggerArea"),r.append(a),r}getElementsToTriggerPopup(){return t(this,ck)}addHighlightArea(){this.container.classList.add("highlightArea")}}ck=new WeakMap,dk=new WeakSet,hk=function(){var r;null==(r=this.downloadManager)||r.openOrDownloadData(this.content,this.filename)};let Uk=(yk=class{constructor({div:r,accessibilityManager:e,annotationCanvasMap:a,annotationEditorUIManager:t,page:n,viewport:o}){i(this,vk),i(this,kk),i(this,bk,null),i(this,gk,null),i(this,pk,new Map),this.div=r,A(this,bk,e),A(this,gk,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;Bu(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 fu,annotationStorage:r.annotationStorage||new yb,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===_f;if(a){const e=A.get(r.id);if(!e)continue;n.elements=e}else{const{width:e,height:a}=fm(r.rect);if(e<=0||a<=0)continue}n.data=r;const i=lm.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,vk,mk).call(this,s,r.id),i.annotationEditorType>0&&(t(this,pk).set(i.data.id,i),null==(e=this._annotationEditorUIManager)||e.renderAnnotationElement(i))}o(this,kk,wk).call(this)}update({viewport:r}){const e=this.div;this.viewport=r,Bu(e,{rotation:r.rotation}),o(this,kk,wk).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(t(this,pk).values())}getEditableAnnotation(r){return t(this,pk).get(r)}},bk=new WeakMap,gk=new WeakMap,pk=new WeakMap,vk=new WeakSet,mk=function(r,e){var a;const i=r.firstChild||r;i.id=`${cl}${e}`,this.div.append(r),null==(a=t(this,bk))||a.moveElementInDOM(this.div,r,i,!1)},kk=new WeakSet,wk=function(){if(!t(this,gk))return;const r=this.div;for(const[e,a]of t(this,gk)){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,gk).clear()},yk);const Jk=/\r\n?|\n/g;var zk,$k,qk,Kk,rw,ew,aw,tw,iw,Aw,nw,ow,sw,fw,lw,uw,cw,dw,hw,bw,gw,pw,vw,mw,kw,ww,yw,Ew;const Cw=class extends fb{constructor(r){super({...r,name:"freeTextEditor"}),i(this,nw),i(this,sw),i(this,lw),i(this,cw),i(this,gw),i(this,vw),i(this,yw),i(this,zk,this.editorDivBlur.bind(this)),i(this,$k,this.editorDivFocus.bind(this)),i(this,qk,this.editorDivInput.bind(this)),i(this,Kk,this.editorDivKeydown.bind(this)),i(this,rw,this.editorDivPaste.bind(this)),i(this,ew,void 0),i(this,aw,""),i(this,tw,`${this.id}-editor`),i(this,iw,void 0),i(this,Aw,null),A(this,ew,r.color||Cw._defaultColor||fb._defaultLineColor),A(this,iw,r.fontSize||Cw._defaultFontSize)}static get _keyboardManager(){const r=Cw.prototype,e=r=>r.isEmpty(),a=rh.TRANSLATE_SMALL,t=rh.TRANSLATE_BIG;return Lf(this,"_keyboardManager",new vc([[["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){fb.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 rf.FREETEXT_SIZE:Cw._defaultFontSize=e;break;case rf.FREETEXT_COLOR:Cw._defaultColor=e}}updateParams(r,e){switch(r){case rf.FREETEXT_SIZE:o(this,nw,ow).call(this,e);break;case rf.FREETEXT_COLOR:o(this,sw,fw).call(this,e)}}static get defaultPropertiesToUpdate(){return[[rf.FREETEXT_SIZE,Cw._defaultFontSize],[rf.FREETEXT_COLOR,Cw._defaultColor||fb._defaultLineColor]]}get propertiesToUpdate(){return[[rf.FREETEXT_SIZE,t(this,iw)],[rf.FREETEXT_COLOR,t(this,ew)]]}_translateEmpty(r,e){this._uiManager.translateSelectedEditors(r,e,!0)}getInitialTranslation(){const r=this.parentScale;return[-Cw._internalPadding*r,-(Cw._internalPadding+t(this,iw))*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(Ks.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,Kk),{signal:r}),this.editorDiv.addEventListener("focus",t(this,$k),{signal:r}),this.editorDiv.addEventListener("blur",t(this,zk),{signal:r}),this.editorDiv.addEventListener("input",t(this,qk),{signal:r}),this.editorDiv.addEventListener("paste",t(this,rw),{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,tw)),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",t(this,Kk)),this.editorDiv.removeEventListener("focus",t(this,$k)),this.editorDiv.removeEventListener("blur",t(this,zk)),this.editorDiv.removeEventListener("input",t(this,qk)),this.editorDiv.removeEventListener("paste",t(this,rw)),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,aw),e=A(this,aw,o(this,lw,uw).call(this).trimEnd());if(r===e)return;const a=r=>{A(this,aw,r),r?(o(this,gw,pw).call(this),this._uiManager.rebuild(this),o(this,cw,dw).call(this)):this.remove()};this.addCommands({cmd:()=>{a(e)},undo:()=>{a(r)},mustExec:!1}),o(this,cw,dw).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){Cw._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,tw)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),fb._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,iw)}px * var(--scale-factor))`,a.color=t(this,ew),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),oc(this,this.div,["dblclick","keydown"]),this.width){const[a,i]=this.parentDimensions;if(this.annotationElementId){const{position:A}=t(this,Aw);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,gw,pw).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=Cw,kw,ww).call(e,i.getData("text")||"").replaceAll(Jk,"\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(Jk,"")),r!==this.editorDiv){let e=d;for(const t of this.editorDiv.childNodes)t!==r?e.push(o(a=Cw,hw,bw).call(a,t)):e=h}d.push(u.nodeValue.slice(0,c).replaceAll(Jk,""))}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=Cw,hw,bw).call(t,a))}A(this,aw,`${d.join("\n")}${s}${h.join("\n")}`),o(this,gw,pw).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 Mk){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:Ks.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,iw,r.fontSize),A(n,ew,sl.makeHexColor(...r.color)),A(n,aw,o(t=Cw,kw,ww).call(t,r.value)),n.annotationElementId=r.id||null,A(n,Aw,i),n}serialize(r=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=Cw._internalPadding*this.parentScale,a=this.getRect(e,e),i=fb._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:t(this,ew)),A={annotationType:Ks.FREETEXT,color:i,fontSize:t(this,iw),value:o(this,vw,mw).call(this),pageIndex:this.pageIndex,rect:a,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return r?A:this.annotationElementId&&!o(this,yw,Ew).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,iw)}px * var(--scale-factor))`,a.color=t(this,ew),e.replaceChildren();for(const r of t(this,aw).split("\n")){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),e.append(a)}const i=Cw._internalPadding*this.parentScale;return r.updateEdited({rect:this.getRect(i,i),popupContent:t(this,aw)}),e}resetAnnotationElement(r){super.resetAnnotationElement(r),r.resetEdited()}};let _w=Cw;var Bw,Zw,Ww,Iw,Rw,Fw,xw,Sw,Mw,Gw,Xw,Vw,Nw,Dw,Tw,Pw,jw,Ow,Lw,Yw,Hw,Qw,Uw,Jw,zw,$w,qw,Kw,ry,ey,ay,ty,iy;zk=new WeakMap,$k=new WeakMap,qk=new WeakMap,Kk=new WeakMap,rw=new WeakMap,ew=new WeakMap,aw=new WeakMap,tw=new WeakMap,iw=new WeakMap,Aw=new WeakMap,nw=new WeakSet,ow=function(r){const e=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-t(this,iw))*this.parentScale),A(this,iw,r),o(this,cw,dw).call(this)},a=t(this,iw);this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rf.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},sw=new WeakSet,fw=function(r){const e=r=>{A(this,ew,this.editorDiv.style.color=r)},a=t(this,ew);this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rf.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},lw=new WeakSet,uw=function(){var r;const e=[];this.editorDiv.normalize();for(const a of this.editorDiv.childNodes)e.push(o(r=Cw,hw,bw).call(r,a));return e.join("\n")},cw=new WeakSet,dw=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()},hw=new WeakSet,bw=function(r){return(r.nodeType===Node.TEXT_NODE?r.nodeValue:r.innerText).replaceAll(Jk,"")},gw=new WeakSet,pw=function(){if(this.editorDiv.replaceChildren(),t(this,aw))for(const r of t(this,aw).split("\n")){const e=document.createElement("div");e.append(r?document.createTextNode(r):document.createElement("br")),this.editorDiv.append(e)}},vw=new WeakSet,mw=function(){return t(this,aw).replaceAll(" "," ")},kw=new WeakSet,ww=function(r){return r.replaceAll(" "," ")},yw=new WeakSet,Ew=function(r){const{value:e,fontSize:a,color:i,pageIndex:A}=t(this,Aw);return this._hasBeenMoved||r.value!==e||r.fontSize!==a||r.color.some(((r,e)=>r!==i[e]))||r.pageIndex!==A},i(_w,hw),i(_w,kw),e(_w,"_freeTextDefaultContent",""),e(_w,"_internalPadding",0),e(_w,"_defaultColor",null),e(_w,"_defaultFontSize",10),e(_w,"_type","freetext"),e(_w,"_editorType",Ks.FREETEXT);class Ay{constructor(r,e=0,a=0,n=!0){i(this,Iw),i(this,Fw),i(this,Sw),i(this,Gw),i(this,Vw),i(this,Bw,void 0),i(this,Zw,[]),i(this,Ww,[]);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,Zw).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,Zw).at(n?-1:-2),p=[g[0],g[2]];for(const r of t(this,Zw)){const[e,a,t]=r;r[0]=(e-h)/c,r[1]=(a-b)/d,r[2]=(t-b)/d}A(this,Bw,{x:h,y:b,width:c,height:d,lastPoint:p})}getOutlines(){t(this,Zw).sort(((r,e)=>r[0]-e[0]||r[1]-e[1]||r[2]-e[2]));const r=[];for(const e of t(this,Zw))e[3]?(r.push(...o(this,Vw,Nw).call(this,e)),o(this,Sw,Mw).call(this,e)):(o(this,Gw,Xw).call(this,e),r.push(...o(this,Vw,Nw).call(this,e)));return o(this,Iw,Rw).call(this,r)}}Bw=new WeakMap,Zw=new WeakMap,Ww=new WeakMap,Iw=new WeakSet,Rw=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 oy(i,t(this,Bw))},Fw=new WeakSet,xw=function(r){const e=t(this,Ww);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},Sw=new WeakSet,Mw=function([,r,e]){const a=o(this,Fw,xw).call(this,r);t(this,Ww).splice(a,0,[r,e])},Gw=new WeakSet,Xw=function([,r,e]){const a=o(this,Fw,xw).call(this,r);for(let i=a;i<t(this,Ww).length;i++){const[a,A]=t(this,Ww)[i];if(a!==r)break;if(a===r&&A===e)return void t(this,Ww).splice(i,1)}for(let i=a-1;i>=0;i--){const[a,A]=t(this,Ww)[i];if(a!==r)break;if(a===r&&A===e)return void t(this,Ww).splice(i,1)}},Vw=new WeakSet,Nw=function(r){const[e,a,i]=r,A=[[e,a,i]],n=o(this,Fw,xw).call(this,i);for(let r=0;r<n;r++){const[a,i]=t(this,Ww)[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 ny{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 Qy}}class oy extends ny{constructor(r,e){super(),i(this,Dw,void 0),i(this,Tw,void 0),A(this,Tw,r),A(this,Dw,e)}toSVGPath(){const r=[];for(const e of t(this,Tw)){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,Tw)){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,Dw)}}Dw=new WeakMap,Tw=new WeakMap;const sy=class{constructor({x:r,y:e},a,n,o,s,f=0){i(this,ty),i(this,Pw,void 0),i(this,jw,[]),i(this,Ow,void 0),i(this,Lw,void 0),i(this,Yw,[]),i(this,Hw,new Float64Array(18)),i(this,Qw,void 0),i(this,Uw,void 0),i(this,Jw,void 0),i(this,zw,void 0),i(this,$w,void 0),i(this,qw,void 0),i(this,Kw,[]),A(this,Pw,a),A(this,qw,o*n),A(this,Lw,s),t(this,Hw).set([NaN,NaN,NaN,NaN,r,e],6),A(this,Ow,f),A(this,zw,t(sy,ry)*n),A(this,Jw,t(sy,ay)*n),A(this,$w,n),t(this,Kw).push(r,e)}get free(){return!0}isEmpty(){return isNaN(t(this,Hw)[8])}add({x:r,y:e}){var a;A(this,Qw,r),A(this,Uw,e);const[i,n,o,s]=t(this,Pw);let[f,l,u,c]=t(this,Hw).subarray(8,12);const d=r-u,h=e-c,b=Math.hypot(d,h);if(b<t(this,Jw))return!1;const g=b-t(this,zw),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,Kw))||a.push(r,e);const y=v/g,E=-m/g*t(this,qw),C=y*t(this,qw);return t(this,Hw).set(t(this,Hw).subarray(2,8),0),t(this,Hw).set([u+E,c+C],4),t(this,Hw).set(t(this,Hw).subarray(14,18),12),t(this,Hw).set([u-E,c-C],16),isNaN(t(this,Hw)[6])?(0===t(this,Yw).length&&(t(this,Hw).set([f+E,l+C],2),t(this,Yw).push(NaN,NaN,NaN,NaN,(f+E-i)/o,(l+C-n)/s),t(this,Hw).set([f-E,l-C],14),t(this,jw).push(NaN,NaN,NaN,NaN,(f-E-i)/o,(l-C-n)/s)),t(this,Hw).set([k,w,f,l,u,c],6),!this.isEmpty()):(t(this,Hw).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,Hw).subarray(2,6),t(this,Yw).push(NaN,NaN,NaN,NaN,((f+u)/2-i)/o,((l+c)/2-n)/s),[f,l,k,w]=t(this,Hw).subarray(14,18),t(this,jw).push(NaN,NaN,NaN,NaN,((k+f)/2-i)/o,((w+l)/2-n)/s),!0):([k,w,f,l,u,c]=t(this,Hw).subarray(0,6),t(this,Yw).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,Hw).subarray(12,18),t(this,jw).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,Yw),e=t(this,jw),a=t(this,Hw).subarray(4,6),i=t(this,Hw).subarray(16,18),[A,n,s,f]=t(this,Pw),[l,u,c,d]=o(this,ty,iy).call(this);if(isNaN(t(this,Hw)[6])&&!this.isEmpty())return`M${(t(this,Hw)[2]-A)/s} ${(t(this,Hw)[3]-n)/f} L${(t(this,Hw)[4]-A)/s} ${(t(this,Hw)[5]-n)/f} L${l} ${u} L${c} ${d} L${(t(this,Hw)[16]-A)/s} ${(t(this,Hw)[17]-n)/f} L${(t(this,Hw)[14]-A)/s} ${(t(this,Hw)[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,Yw),a=t(this,jw),i=t(this,Hw),A=i.subarray(4,6),n=i.subarray(16,18),[s,f,l,u]=t(this,Pw),c=new Float64Array(((null==(r=t(this,Kw))?void 0:r.length)??0)+2);for(let r=0,e=c.length-2;r<e;r+=2)c[r]=(t(this,Kw)[r]-s)/l,c[r+1]=(t(this,Kw)[r+1]-f)/u;c[c.length-2]=(t(this,Qw)-s)/l,c[c.length-1]=(t(this,Uw)-f)/u;const[d,h,b,g]=o(this,ty,iy).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 Qy(r,c,t(this,Pw),t(this,$w),t(this,Ow),t(this,Lw))}const p=new Float64Array(t(this,Yw).length+24+t(this,jw).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 Qy(p,c,t(this,Pw),t(this,$w),t(this,Ow),t(this,Lw))}};let fy=sy;var ly,uy,cy,dy,hy,by,gy,py,vy,my,ky,wy,yy,Ey,Cy,_y,By,Zy,Wy,Iy,Ry,Fy,xy,Sy,My,Gy,Xy,Vy,Ny,Dy,Ty,Py,jy,Oy,Ly,Yy,Hy;Pw=new WeakMap,jw=new WeakMap,Ow=new WeakMap,Lw=new WeakMap,Yw=new WeakMap,Hw=new WeakMap,Qw=new WeakMap,Uw=new WeakMap,Jw=new WeakMap,zw=new WeakMap,$w=new WeakMap,qw=new WeakMap,Kw=new WeakMap,ry=new WeakMap,ey=new WeakMap,ay=new WeakMap,ty=new WeakSet,iy=function(){const r=t(this,Hw).subarray(4,6),e=t(this,Hw).subarray(16,18),[a,i,A,n]=t(this,Pw);return[(t(this,Qw)+(r[0]-e[0])/2-a)/A,(t(this,Uw)+(r[1]-e[1])/2-i)/n,(t(this,Qw)+(e[0]-r[0])/2-a)/A,(t(this,Uw)+(e[1]-r[1])/2-i)/n]},i(fy,ry,8),i(fy,ey,2),i(fy,ay,t(sy,ry)+t(sy,ey));class Qy extends ny{constructor(r,e,a,n,s,f){super(),i(this,py),i(this,my),i(this,wy),i(this,ly,void 0),i(this,uy,null),i(this,cy,void 0),i(this,dy,void 0),i(this,hy,void 0),i(this,by,void 0),i(this,gy,void 0),A(this,gy,r),A(this,hy,e),A(this,ly,a),A(this,by,n),A(this,cy,s),A(this,dy,f),o(this,wy,yy).call(this,f);const{x:l,y:u,width:c,height:d}=t(this,uy);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,gy)[4]} ${t(this,gy)[5]}`];for(let e=6,a=t(this,gy).length;e<a;e+=6)isNaN(t(this,gy)[e])?r.push(`L${t(this,gy)[e+4]} ${t(this,gy)[e+5]}`):r.push(`C${t(this,gy)[e]} ${t(this,gy)[e+1]} ${t(this,gy)[e+2]} ${t(this,gy)[e+3]} ${t(this,gy)[e+4]} ${t(this,gy)[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,py,vy).call(this,t(this,gy),r,i,n,-s),l=o(this,py,vy).call(this,t(this,hy),r,i,n,-s);break;case 90:f=o(this,my,ky).call(this,t(this,gy),r,e,n,s),l=o(this,my,ky).call(this,t(this,hy),r,e,n,s);break;case 180:f=o(this,py,vy).call(this,t(this,gy),a,e,-n,s),l=o(this,py,vy).call(this,t(this,hy),a,e,-n,s);break;case 270:f=o(this,my,ky).call(this,t(this,gy),a,i,-n,-s),l=o(this,my,ky).call(this,t(this,hy),a,i,-n,-s)}return{outline:Array.from(f),points:[Array.from(l)]}}get box(){return t(this,uy)}getNewOutline(r,e){const{x:a,y:i,width:A,height:n}=t(this,uy),[o,s,f,l]=t(this,ly),u=A*f,c=n*l,d=a*f+o,h=i*l+s,b=new fy({x:t(this,hy)[0]*u+d,y:t(this,hy)[1]*c+h},t(this,ly),t(this,by),r,t(this,dy),e??t(this,cy));for(let r=2;r<t(this,hy).length;r+=2)b.add({x:t(this,hy)[r]*u+d,y:t(this,hy)[r+1]*c+h});return b.getOutlines()}}ly=new WeakMap,uy=new WeakMap,cy=new WeakMap,dy=new WeakMap,hy=new WeakMap,by=new WeakMap,gy=new WeakMap,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]*t,A[n+1]=a+r[n+1]*i;return A},my=new WeakSet,ky=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},wy=new WeakSet,yy=function(r){const e=t(this,gy);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=sl.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,cy),h=o-t(this,cy),b=s-n+2*t(this,cy),g=f-o+2*t(this,cy);A(this,uy,{x:d,y:h,width:b,height:g,lastPoint:[l,u]})};const Uy=class{constructor({editor:r=null,uiManager:e=null}){var a;i(this,Gy),i(this,Vy),i(this,Dy),i(this,Py),i(this,Oy),i(this,Yy),i(this,Ey,o(this,Dy,Ty).bind(this)),i(this,Cy,o(this,Oy,Ly).bind(this)),i(this,_y,null),i(this,By,null),i(this,Zy,void 0),i(this,Wy,null),i(this,Iy,!1),i(this,Ry,!1),i(this,Fy,null),i(this,xy,void 0),i(this,Sy,null),i(this,My,void 0),r?(A(this,Ry,!1),A(this,My,rf.HIGHLIGHT_COLOR),A(this,Fy,r)):(A(this,Ry,!0),A(this,My,rf.HIGHLIGHT_DEFAULT_COLOR)),A(this,Sy,(null==r?void 0:r._uiManager)||e),A(this,xy,t(this,Sy)._eventBus),A(this,Zy,(null==r?void 0:r.color)||(null==(a=t(this,Sy))?void 0:a.highlightColors.values().next().value)||"#FFFF98")}static get _keyboardManager(){return Lf(this,"_keyboardManager",new vc([[["Escape","mac+Escape"],Uy.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Uy.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Uy.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Uy.prototype._moveToPrevious],[["Home","mac+Home"],Uy.prototype._moveToBeginning],[["End","mac+End"],Uy.prototype._moveToEnd]]))}renderButton(){const r=A(this,_y,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,Sy)._signal;r.addEventListener("click",o(this,Py,jy).bind(this),{signal:e}),r.addEventListener("keydown",t(this,Ey),{signal:e});const a=A(this,By,document.createElement("span"));return a.className="swatch",a.setAttribute("aria-hidden",!0),a.style.backgroundColor=t(this,Zy),r.append(a),r}renderMainDropdown(){const r=A(this,Wy,o(this,Gy,Xy).call(this));return r.setAttribute("aria-orientation","horizontal"),r.setAttribute("aria-labelledby","highlightColorPickerLabel"),r}_colorSelectFromKeyboard(r){if(r.target===t(this,_y))return void o(this,Py,jy).call(this,r);const e=r.target.getAttribute("data-color");e&&o(this,Vy,Ny).call(this,e,r)}_moveToNext(r){var e,a;t(this,Yy,Hy)?r.target!==t(this,_y)?null==(a=r.target.nextSibling)||a.focus():null==(e=t(this,Wy).firstChild)||e.focus():o(this,Py,jy).call(this,r)}_moveToPrevious(r){var e,a;r.target!==(null==(e=t(this,Wy))?void 0:e.firstChild)&&r.target!==t(this,_y)?(t(this,Yy,Hy)||o(this,Py,jy).call(this,r),null==(a=r.target.previousSibling)||a.focus()):t(this,Yy,Hy)&&this._hideDropdownFromKeyboard()}_moveToBeginning(r){var e;t(this,Yy,Hy)?null==(e=t(this,Wy).firstChild)||e.focus():o(this,Py,jy).call(this,r)}_moveToEnd(r){var e;t(this,Yy,Hy)?null==(e=t(this,Wy).lastChild)||e.focus():o(this,Py,jy).call(this,r)}hideDropdown(){var r;null==(r=t(this,Wy))||r.classList.add("hidden"),window.removeEventListener("pointerdown",t(this,Cy))}_hideDropdownFromKeyboard(){var r;if(!t(this,Ry)){if(!t(this,Yy,Hy))return void(null==(r=t(this,Fy))||r.unselect());this.hideDropdown(),t(this,_y).focus({preventScroll:!0,focusVisible:t(this,Iy)})}}updateColor(r){if(t(this,By)&&(t(this,By).style.backgroundColor=r),!t(this,Wy))return;const e=t(this,Sy).highlightColors.values();for(const a of t(this,Wy).children)a.setAttribute("aria-selected",e.next().value===r)}destroy(){var r,e;null==(r=t(this,_y))||r.remove(),A(this,_y,null),A(this,By,null),null==(e=t(this,Wy))||e.remove(),A(this,Wy,null)}};let Jy=Uy;var zy,$y,qy,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,_E,BE,ZE,WE,IE,RE,FE,xE,SE,ME,GE,XE,VE,NE,DE,TE,PE,jE,OE,LE;Ey=new WeakMap,Cy=new WeakMap,_y=new WeakMap,By=new WeakMap,Zy=new WeakMap,Wy=new WeakMap,Iy=new WeakMap,Ry=new WeakMap,Fy=new WeakMap,xy=new WeakMap,Sy=new WeakMap,My=new WeakMap,Gy=new WeakSet,Xy=function(){const r=document.createElement("div"),e=t(this,Sy)._signal;r.addEventListener("contextmenu",vu,{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,Sy).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,Zy)),A.addEventListener("click",o(this,Vy,Ny).bind(this,i),{signal:e}),r.append(A)}return r.addEventListener("keydown",t(this,Ey),{signal:e}),r},Vy=new WeakSet,Ny=function(r,e){e.stopPropagation(),t(this,xy).dispatch("switchannotationeditorparams",{source:this,type:t(this,My),value:r})},Dy=new WeakSet,Ty=function(r){Uy._keyboardManager.exec(this,r)},Py=new WeakSet,jy=function(r){if(t(this,Yy,Hy))return void this.hideDropdown();if(A(this,Iy,0===r.detail),window.addEventListener("pointerdown",t(this,Cy),{signal:t(this,Sy)._signal}),t(this,Wy))return void t(this,Wy).classList.remove("hidden");const e=A(this,Wy,o(this,Gy,Xy).call(this));t(this,_y).append(e)},Oy=new WeakSet,Ly=function(r){var e;null!=(e=t(this,Wy))&&e.contains(r.target)||this.hideDropdown()},Yy=new WeakSet,Hy=function(){return t(this,Wy)&&!t(this,Wy).classList.contains("hidden")};const YE=class extends fb{constructor(r){super({...r,name:"highlightEditor"}),i(this,bE),i(this,pE),i(this,mE),i(this,wE),i(this,EE),i(this,_E),i(this,ZE),i(this,FE),i(this,SE),i(this,GE),i(this,VE),i(this,DE),i(this,zy,null),i(this,$y,0),i(this,qy,void 0),i(this,Ky,null),i(this,rE,null),i(this,eE,null),i(this,aE,null),i(this,tE,0),i(this,iE,null),i(this,AE,null),i(this,nE,null),i(this,oE,!1),i(this,sE,o(this,FE,xE).bind(this)),i(this,fE,null),i(this,lE,void 0),i(this,uE,null),i(this,cE,""),i(this,dE,void 0),i(this,hE,""),this.color=r.color||YE._defaultColor,A(this,dE,r.thickness||YE._defaultThickness),A(this,lE,r.opacity||YE._defaultOpacity),A(this,qy,r.boxes||null),A(this,hE,r.methodOfCreation||""),A(this,cE,r.text||""),this._isDraggable=!1,r.highlightId>-1?(A(this,oE,!0),o(this,pE,vE).call(this,r),o(this,ZE,WE).call(this)):(A(this,zy,r.anchorNode),A(this,$y,r.anchorOffset),A(this,aE,r.focusNode),A(this,tE,r.focusOffset),o(this,bE,gE).call(this),o(this,ZE,WE).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const r=YE.prototype;return Lf(this,"_keyboardManager",new vc([[["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,oE)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:t(this,dE),methodOfCreation:t(this,hE)}}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;fb.initialize(r,e),YE._defaultColor||(YE._defaultColor=(null==(a=e.highlightColors)?void 0:a.values().next().value)||"#fff066")}static updateDefaultParams(r,e){switch(r){case rf.HIGHLIGHT_DEFAULT_COLOR:YE._defaultColor=e;break;case rf.HIGHLIGHT_THICKNESS:YE._defaultThickness=e}}translateInPage(r,e){}get toolbarPosition(){return t(this,fE)}updateParams(r,e){switch(r){case rf.HIGHLIGHT_COLOR:o(this,mE,kE).call(this,e);break;case rf.HIGHLIGHT_THICKNESS:o(this,wE,yE).call(this,e)}}static get defaultPropertiesToUpdate(){return[[rf.HIGHLIGHT_DEFAULT_COLOR,YE._defaultColor],[rf.HIGHLIGHT_THICKNESS,YE._defaultThickness]]}get propertiesToUpdate(){return[[rf.HIGHLIGHT_COLOR,this.color||YE._defaultColor],[rf.HIGHLIGHT_THICKNESS,t(this,dE)||YE._defaultThickness],[rf.HIGHLIGHT_FREE,t(this,oE)]]}async addEditToolbar(){const r=await super.addEditToolbar();return r?(this._uiManager.highlightColors&&(A(this,rE,new Jy({editor:this})),r.addColorPicker(t(this,rE))),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,GE,XE).call(this))}getBaseTranslation(){return[0,0]}getRect(r,e){return super.getRect(r,e,o(this,GE,XE).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){o(this,_E,BE).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(o(this,ZE,WE).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(r){var e;let a=!1;this.parent&&!r?o(this,_E,BE).call(this):r&&(o(this,ZE,WE).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,oE)?(r=(r-this.rotation+360)%360,n=o(e=YE,IE,RE).call(e,t(this,AE).box,r)):n=o(a=YE,IE,RE).call(a,this,r),A.rotate(t(this,nE),r),A.rotate(t(this,uE),r),A.updateBox(t(this,nE),n),A.updateBox(t(this,uE),o(i=YE,IE,RE).call(i,t(this,eE).box,r))}render(){if(this.div)return this.div;const r=super.render();t(this,cE)&&(r.setAttribute("aria-label",t(this,cE)),r.setAttribute("role","mark")),t(this,oE)?r.classList.add("free"):this.div.addEventListener("keydown",t(this,sE),{signal:this._uiManager._signal});const e=A(this,iE,document.createElement("div"));r.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=t(this,Ky);const[a,i]=this.parentDimensions;return this.setDims(this.width*a,this.height*i),oc(this,t(this,iE),["pointerover","pointerleave"]),this.enableEditing(),r}pointerover(){this.parent.drawLayer.addClass(t(this,uE),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(t(this,uE),"hovered")}_moveCaret(r){switch(this.parent.unselect(this),r){case 0:case 2:o(this,SE,ME).call(this,!0);break;case 1:case 3:o(this,SE,ME).call(this,!1)}}select(){var r,e;super.select(),t(this,uE)&&(null==(r=this.parent)||r.drawLayer.removeClass(t(this,uE),"hovered"),null==(e=this.parent)||e.drawLayer.addClass(t(this,uE),"selected"))}unselect(){var r;super.unselect(),t(this,uE)&&(null==(r=this.parent)||r.drawLayer.removeClass(t(this,uE),"selected"),t(this,oE)||o(this,SE,ME).call(this,!1))}get _mustFixPosition(){return!t(this,oE)}show(r=this._isVisible){super.show(r),this.parent&&(this.parent.drawLayer.show(t(this,nE),r),this.parent.drawLayer.show(t(this,uE),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,PE,jE).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",vu),o(this,OE,LE).call(this,r,e)};window.addEventListener("blur",h,{signal:u}),window.addEventListener("pointerup",h,{signal:u}),window.addEventListener("pointerdown",d,c),window.addEventListener("contextmenu",vu,{signal:u}),a.addEventListener("pointermove",l,{signal:u}),this._freeHighlight=new fy({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=sl.makeHexColor(...u),A(i,lE,r.opacity);const[d,h]=i.pageDimensions;i.width=(f-n)/d,i.height=(l-s)/h;const b=A(i,qy,[]);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,bE,gE).call(t),i}serialize(r=!1){if(this.isEmpty()||r)return null;const e=this.getRect(0,0),a=fb._colorManager.convert(this.color);return{annotationType:Ks.HIGHLIGHT,color:a,opacity:t(this,lE),thickness:t(this,dE),quadPoints:o(this,VE,NE).call(this),outlines:o(this,DE,TE).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:o(this,GE,XE).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}};let HE=YE;var QE,UE,JE,zE,$E,qE,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,_C,BC,ZC,WC,IC,RC,FC,xC,SC,MC,GC,XC,VC,NC,DC,TC,PC,jC,OC,LC,YC,HC,QC,UC,JC,zC,$C,qC,KC,r_,e_,a_,t_,i_,A_;zy=new WeakMap,$y=new WeakMap,qy=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 WeakMap,hE=new WeakMap,bE=new WeakSet,gE=function(){const r=new Ay(t(this,qy),.001);A(this,AE,r.getOutlines()),({x:this.x,y:this.y,width:this.width,height:this.height}=t(this,AE).box);const e=new Ay(t(this,qy),.0025,.001,"ltr"===this._uiManager.direction);A(this,eE,e.getOutlines());const{lastPoint:a}=t(this,eE).box;A(this,fE,[(a[0]-this.x)/this.width,(a[1]-this.y)/this.height])},pE=new WeakSet,vE=function({highlightOutlines:r,highlightId:e,clipPathId:a}){var i,n;A(this,AE,r);if(A(this,eE,r.getNewOutline(t(this,dE)/2+1.5,.0025)),e>=0)A(this,nE,e),A(this,Ky,a),this.parent.drawLayer.finalizeLine(e,r),A(this,uE,this.parent.drawLayer.highlightOutline(t(this,eE)));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(t(this,nE),r),this.parent.drawLayer.updateBox(t(this,nE),o(i=YE,IE,RE).call(i,t(this,AE).box,(e-this.rotation+360)%360)),this.parent.drawLayer.updateLine(t(this,uE),t(this,eE)),this.parent.drawLayer.updateBox(t(this,uE),o(n=YE,IE,RE).call(n,t(this,eE).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,eE).box;A(this,fE,[(c[0]-s)/l,(c[1]-f)/u])},mE=new WeakSet,kE=function(r){const e=r=>{var e,a;this.color=r,null==(e=this.parent)||e.drawLayer.changeColor(t(this,nE),r),null==(a=t(this,rE))||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:rf.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(r)},!0)},wE=new WeakSet,yE=function(r){const e=t(this,dE),a=r=>{A(this,dE,r),o(this,EE,CE).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:rf.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:r},!0)},EE=new WeakSet,CE=function(r){if(!t(this,oE))return;o(this,pE,vE).call(this,{highlightOutlines:t(this,AE).getNewOutline(r/2)}),this.fixAndSetPosition();const[e,a]=this.parentDimensions;this.setDims(this.width*e,this.height*a)},_E=new WeakSet,BE=function(){null===t(this,nE)||!this.parent||(this.parent.drawLayer.remove(t(this,nE)),A(this,nE,null),this.parent.drawLayer.remove(t(this,uE)),A(this,uE,null))},ZE=new WeakSet,WE=function(r=this.parent){null===t(this,nE)&&(({id:n(this,nE)._,clipPathId:n(this,Ky)._}=r.drawLayer.highlight(t(this,AE),this.color,t(this,lE))),A(this,uE,r.drawLayer.highlightOutline(t(this,eE))),t(this,iE)&&(t(this,iE).style.clipPath=t(this,Ky)))},IE=new WeakSet,RE=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}},FE=new WeakSet,xE=function(r){YE._keyboardManager.exec(this,r)},SE=new WeakSet,ME=function(r){if(!t(this,zy))return;const e=window.getSelection();r?e.setPosition(t(this,zy),t(this,$y)):e.setPosition(t(this,aE),t(this,tE))},GE=new WeakSet,XE=function(){return t(this,oE)?this.rotation:0},VE=new WeakSet,NE=function(){if(t(this,oE))return null;const[r,e]=this.pageDimensions,a=t(this,qy),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},DE=new WeakSet,TE=function(r){return t(this,AE).serialize(r,o(this,GE,XE).call(this))},PE=new WeakSet,jE=function(r,e){this._freeHighlight.add(e)&&r.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},OE=new WeakSet,LE=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(HE,IE),i(HE,PE),i(HE,OE),e(HE,"_defaultColor",null),e(HE,"_defaultOpacity",1),e(HE,"_defaultThickness",12),e(HE,"_l10nPromise"),e(HE,"_type","highlight"),e(HE,"_editorType",Ks.HIGHLIGHT),e(HE,"_freeHighlightId",-1),e(HE,"_freeHighlight",null),e(HE,"_freeHighlightClipId","");const n_=class extends fb{constructor(r){super({...r,name:"inkEditor"}),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,BC),i(this,WC),i(this,RC),i(this,xC),i(this,MC),i(this,XC),i(this,NC),i(this,TC),i(this,jC),i(this,LC),i(this,qC),i(this,r_),i(this,a_),i(this,i_),i(this,QE,0),i(this,UE,0),i(this,JE,this.canvasPointermove.bind(this)),i(this,zE,this.canvasPointerleave.bind(this)),i(this,$E,this.canvasPointerup.bind(this)),i(this,qE,this.canvasPointerdown.bind(this)),i(this,KE,null),i(this,rC,new Path2D),i(this,eC,!1),i(this,aC,!1),i(this,tC,!1),i(this,iC,null),i(this,AC,0),i(this,nC,0),i(this,oC,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){fb.initialize(r,e)}static updateDefaultParams(r,e){switch(r){case rf.INK_THICKNESS:n_._defaultThickness=e;break;case rf.INK_COLOR:n_._defaultColor=e;break;case rf.INK_OPACITY:n_._defaultOpacity=e/100}}updateParams(r,e){switch(r){case rf.INK_THICKNESS:o(this,sC,fC).call(this,e);break;case rf.INK_COLOR:o(this,lC,uC).call(this,e);break;case rf.INK_OPACITY:o(this,cC,dC).call(this,e)}}static get defaultPropertiesToUpdate(){return[[rf.INK_THICKNESS,n_._defaultThickness],[rf.INK_COLOR,n_._defaultColor||fb._defaultLineColor],[rf.INK_OPACITY,Math.round(100*n_._defaultOpacity)]]}get propertiesToUpdate(){return[[rf.INK_THICKNESS,this.thickness||n_._defaultThickness],[rf.INK_COLOR,this.color||n_._defaultColor||fb._defaultLineColor],[rf.INK_OPACITY,Math.round(100*(this.opacity??n_._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(o(this,XC,VC).call(this),o(this,NC,DC).call(this)),this.isAttachedToDOM||(this.parent.add(this),o(this,TC,PC).call(this)),o(this,i_,A_).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,KE)&&(clearTimeout(t(this,KE)),A(this,KE,null)),null==(r=t(this,iC))||r.disconnect(),A(this,iC,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,eC)||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",t(this,qE),{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,qE)))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}commit(){t(this,eC)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),A(this,eC,!0),this.div.classList.add("disabled"),o(this,i_,A_).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,eC)||(this.setInForeground(),r.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),o(this,vC,mC).call(this,r.offsetX,r.offsetY))}canvasPointermove(r){r.preventDefault(),o(this,kC,wC).call(this,r.offsetX,r.offsetY)}canvasPointerup(r){r.preventDefault(),o(this,MC,GC).call(this,r)}canvasPointerleave(r){o(this,MC,GC).call(this,r)}get isResizable(){return!this.isEmpty()&&t(this,eC)}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,hC,bC).call(this);if(this.setAt(a,t,0,0),this.setDims(i,n),o(this,XC,VC).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,tC,!0),o(this,TC,PC).call(this),this.setDims(this.width*a,this.height*t),o(this,xC,SC).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return o(this,NC,DC).call(this),this.div}setDimensions(r,e){const a=Math.round(r),i=Math.round(e);if(t(this,AC)===a&&t(this,nC)===i)return;A(this,AC,a),A(this,nC,i),this.canvas.style.visibility="hidden";const[n,s]=this.parentDimensions;this.width=r/n,this.height=e/s,this.fixAndSetPosition(),t(this,eC)&&o(this,jC,OC).call(this,r,e),o(this,TC,PC).call(this),o(this,xC,SC).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(r,e,a){var t,i,n;if(r instanceof Pk)return null;const s=super.deserialize(r,e,a);s.thickness=r.thickness,s.color=sl.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,eC,!0),A(s,AC,Math.round(u)),A(s,nC,Math.round(c));const{paths:b,rect:g,rotation:p}=r;for(let{bezier:r}of b){r=o(t=n_,zC,$C).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,HC,QC).call(this,e);s.bezierPath2D.push(A)}const v=o(i=s,r_,e_).call(i);return A(s,UE,Math.max(fb.MIN_SIZE,v[2]-v[0])),A(s,QE,Math.max(fb.MIN_SIZE,v[3]-v[1])),o(n=s,jC,OC).call(n,u,c),s}serialize(){if(this.isEmpty())return null;const r=this.getRect(0,0),e=fb._colorManager.convert(this.ctx.strokeStyle);return{annotationType:Ks.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:o(this,qC,KC).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,r),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};let o_=n_;var s_,f_,l_,u_,c_,d_,h_,b_,g_,p_,v_,m_,k_,w_,y_,E_,C_,__,B_,Z_,W_,I_,R_,F_,x_,S_,M_,G_,X_;QE=new WeakMap,UE=new WeakMap,JE=new WeakMap,zE=new WeakMap,$E=new WeakMap,qE=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 WeakMap,oC=new WeakMap,sC=new WeakSet,fC=function(r){const e=r=>{this.thickness=r,o(this,i_,A_).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:rf.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},lC=new WeakSet,uC=function(r){const e=r=>{this.color=r,o(this,xC,SC).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:rf.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},cC=new WeakSet,dC=function(r){const e=r=>{this.opacity=r,o(this,xC,SC).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:rf.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},hC=new WeakSet,bC=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]}},gC=new WeakSet,pC=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")}`},vC=new WeakSet,mC=function(r,e){const a=this._uiManager._signal;this.canvas.addEventListener("contextmenu",vu,{signal:a}),this.canvas.addEventListener("pointerleave",t(this,zE),{signal:a}),this.canvas.addEventListener("pointermove",t(this,JE),{signal:a}),this.canvas.addEventListener("pointerup",t(this,$E),{signal:a}),this.canvas.removeEventListener("pointerdown",t(this,qE)),this.isEditing=!0,t(this,tC)||(A(this,tC,!0),o(this,TC,PC).call(this),this.thickness||(this.thickness=n_._defaultThickness),this.color||(this.color=n_._defaultColor||fb._defaultLineColor),this.opacity??(this.opacity=n_._defaultOpacity)),this.currentPath.push([r,e]),A(this,aC,!1),o(this,gC,pC).call(this),A(this,oC,(()=>{o(this,BC,ZC).call(this),t(this,oC)&&window.requestAnimationFrame(t(this,oC))})),window.requestAnimationFrame(t(this,oC))},kC=new WeakSet,wC=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,rC);if(n.push([r,e]),A(this,aC,!0),n.length<=2)return s.moveTo(...n[0]),void s.lineTo(r,e);3===n.length&&(A(this,rC,s=new Path2D),s.moveTo(...n[0])),o(this,WC,IC).call(this,s,...n.at(-3),...n.at(-2),r,e)},yC=new WeakSet,EC=function(){if(0===this.currentPath.length)return;const r=this.currentPath.at(-1);t(this,rC).lineTo(...r)},CC=new WeakSet,_C=function(r,e){let a;if(A(this,oC,null),r=Math.min(Math.max(r,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),o(this,kC,wC).call(this,r,e),o(this,yC,EC).call(this),1!==this.currentPath.length)a=o(this,RC,FC).call(this);else{const t=[r,e];a=[[t,t.slice(),t.slice(),t]]}const i=t(this,rC),n=this.currentPath;this.currentPath=[],A(this,rC,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,XC,VC).call(this),o(this,NC,DC).call(this)),o(this,i_,A_).call(this))},mustExec:!0})},BC=new WeakSet,ZC=function(){if(!t(this,aC))return;A(this,aC,!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,rC)),i.restore()},WC=new WeakSet,IC=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)},RC=new WeakSet,FC=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},xC=new WeakSet,SC=function(){if(this.isEmpty())return void o(this,LC,YC).call(this);o(this,gC,pC).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,LC,YC).call(this);for(const r of this.bezierPath2D)e.stroke(r)},MC=new WeakSet,GC=function(r){this.canvas.removeEventListener("pointerleave",t(this,zE)),this.canvas.removeEventListener("pointermove",t(this,JE)),this.canvas.removeEventListener("pointerup",t(this,$E)),this.canvas.addEventListener("pointerdown",t(this,qE),{signal:this._uiManager._signal}),t(this,KE)&&clearTimeout(t(this,KE)),A(this,KE,setTimeout((()=>{A(this,KE,null),this.canvas.removeEventListener("contextmenu",vu)}),10)),o(this,CC,_C).call(this,r.offsetX,r.offsetY),this.addToAnnotationStorage(),this.setInBackground()},XC=new WeakSet,VC=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")},NC=new WeakSet,DC=function(){A(this,iC,new ResizeObserver((r=>{const e=r[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}))),t(this,iC).observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{var r;null==(r=t(this,iC))||r.disconnect(),A(this,iC,null)}),{once:!0})},TC=new WeakSet,PC=function(){if(!t(this,tC))return;const[r,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*r),this.canvas.height=Math.ceil(this.height*e),o(this,LC,YC).call(this)},jC=new WeakSet,OC=function(r,e){const a=o(this,a_,t_).call(this),i=(r-a)/t(this,UE),A=(e-a)/t(this,QE);this.scaleFactor=Math.min(i,A)},LC=new WeakSet,YC=function(){const r=o(this,a_,t_).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+r,this.translationY*this.scaleFactor+r)},HC=new WeakSet,QC=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},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]+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},zC=new WeakSet,$C=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},qC=new WeakSet,KC=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=n_,UC,JC).call(i,a,t,this.rotation),points:o(A=n_,UC,JC).call(A,s,t,this.rotation)})}return n},r_=new WeakSet,e_=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=sl.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]},a_=new WeakSet,t_=function(){return t(this,eC)?Math.ceil(this.thickness*this.parentScale):0},i_=new WeakSet,A_=function(r=!1){if(this.isEmpty())return;if(!t(this,eC))return void o(this,xC,SC).call(this);const e=o(this,r_,e_).call(this),a=o(this,a_,t_).call(this);A(this,UE,Math.max(fb.MIN_SIZE,e[2]-e[0])),A(this,QE,Math.max(fb.MIN_SIZE,e[3]-e[1]));const i=Math.ceil(a+t(this,UE)*this.scaleFactor),n=Math.ceil(a+t(this,QE)*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,TC,PC).call(this),o(this,xC,SC).call(this),A(this,AC,i),A(this,nC,n),this.setDims(i,n);const c=r?a/this.scaleFactor/2:0;this.translate(l-this.translationX-c,u-this.translationY-c)},i(o_,HC),i(o_,UC),i(o_,zC),e(o_,"_defaultColor",null),e(o_,"_defaultOpacity",1),e(o_,"_defaultThickness",1),e(o_,"_type","ink"),e(o_,"_editorType",Ks.INK);const V_=class extends fb{constructor(r){super({...r,name:"stampEditor"}),i(this,m_),i(this,w_),i(this,E_),i(this,__),i(this,Z_),i(this,I_),i(this,F_),i(this,S_),i(this,G_),i(this,s_,null),i(this,f_,null),i(this,l_,null),i(this,u_,null),i(this,c_,null),i(this,d_,""),i(this,h_,null),i(this,b_,null),i(this,g_,null),i(this,p_,!1),i(this,v_,!1),A(this,u_,r.bitmapUrl),A(this,c_,r.bitmapFile)}static initialize(r,e){fb.initialize(r,e)}static get supportedTypes(){return Lf(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((r=>`image/${r}`)))}static get supportedTypesStr(){return Lf(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(r){return this.supportedTypes.includes(r)}static paste(r,e){e.pasteEditor(Ks.STAMP,{bitmapFile:r.getAsFile()})}remove(){var r,e;t(this,f_)&&(A(this,s_,null),this._uiManager.imageManager.deleteId(t(this,f_)),null==(r=t(this,h_))||r.remove(),A(this,h_,null),null==(e=t(this,b_))||e.disconnect(),A(this,b_,null),t(this,g_)&&(clearTimeout(t(this,g_)),A(this,g_,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(t(this,f_)&&null===t(this,h_)&&o(this,E_,C_).call(this),this.isAttachedToDOM||this.parent.add(this))):t(this,f_)&&o(this,E_,C_).call(this)}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(t(this,l_)||t(this,s_)||t(this,u_)||t(this,c_)||t(this,f_))}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,s_)?o(this,__,B_).call(this):o(this,E_,C_).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,h_)}static deserialize(r,e,a){if(r instanceof Hk)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,f_,o):A(t,u_,n),A(t,p_,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:Ks.STAMP,bitmapId:t(this,f_),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:t(this,p_),structTreeParentId:this._structTreeParentId};if(r)return a.bitmapUrl=o(this,S_,M_).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,p_)?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(e.stamps.has(t(this,f_))){if(t(this,p_)){const r=e.stamps.get(t(this,f_));n>r.area&&(r.area=n,r.serialized.bitmap.close(),r.serialized.bitmap=o(this,S_,M_).call(this,!1))}}else e.stamps.set(t(this,f_),{area:n,serialized:a}),a.bitmap=o(this,S_,M_).call(this,!1);return a}};let N_=V_;var D_,T_,P_,j_,O_,L_,Y_,H_,Q_,U_,J_,z_,$_,q_,K_,rB,eB,aB,tB,iB,AB,nB,oB,sB;s_=new WeakMap,f_=new WeakMap,l_=new WeakMap,u_=new WeakMap,c_=new WeakMap,d_=new WeakMap,h_=new WeakMap,b_=new WeakMap,g_=new WeakMap,p_=new WeakMap,v_=new WeakMap,m_=new WeakSet,k_=function(r,e=!1){r?(A(this,s_,r.bitmap),e||(A(this,f_,r.id),A(this,p_,r.isSvg)),r.file&&A(this,d_,r.file.name),o(this,__,B_).call(this)):this.remove()},w_=new WeakSet,y_=function(){A(this,l_,null),this._uiManager.enableWaiting(!1),t(this,h_)&&this.div.focus()},E_=new WeakSet,C_=function(){if(t(this,f_))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(t(this,f_)).then((r=>o(this,m_,k_).call(this,r,!0))).finally((()=>o(this,w_,y_).call(this)));if(t(this,u_)){const r=t(this,u_);return A(this,u_,null),this._uiManager.enableWaiting(!0),void A(this,l_,this._uiManager.imageManager.getFromUrl(r).then((r=>o(this,m_,k_).call(this,r))).finally((()=>o(this,w_,y_).call(this))))}if(t(this,c_)){const r=t(this,c_);return A(this,c_,null),this._uiManager.enableWaiting(!0),void A(this,l_,this._uiManager.imageManager.getFromFile(r).then((r=>o(this,m_,k_).call(this,r))).finally((()=>o(this,w_,y_).call(this))))}const r=document.createElement("input");r.type="file",r.accept=V_.supportedTypesStr;const e=this._uiManager._signal;A(this,l_,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,m_,k_).call(this,e)}else this.remove();a()}),{signal:e}),r.addEventListener("cancel",(()=>{this.remove(),a()}),{signal:e})})).finally((()=>o(this,w_,y_).call(this)))),r.click()},__=new WeakSet,B_=function(){const{div:r}=this;let{width:e,height:a}=t(this,s_);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,h_,document.createElement("canvas"));r.append(u),r.hidden=!1,o(this,F_,x_).call(this,e,a),o(this,G_,X_).call(this),t(this,v_)||(this.parent.addUndoableEditor(this),A(this,v_,!0)),this._reportTelemetry({action:"inserted_image"}),t(this,d_)&&u.setAttribute("aria-label",t(this,d_))},Z_=new WeakSet,W_=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,g_)&&clearTimeout(t(this,g_)),A(this,g_,setTimeout((()=>{A(this,g_,null),o(this,F_,x_).call(this,r,e)}),200))},I_=new WeakSet,R_=function(r,e){const{width:a,height:i}=t(this,s_);let A=a,n=i,o=t(this,s_);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},F_=new WeakSet,x_=function(r,e){r=Math.ceil(r),e=Math.ceil(e);const a=t(this,h_);if(!a||a.width===r&&a.height===e)return;a.width=r,a.height=e;const i=t(this,p_)?t(this,s_):o(this,I_,R_).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)},S_=new WeakSet,M_=function(r){if(r){if(t(this,p_)){const r=this._uiManager.imageManager.getSvgUrl(t(this,f_));if(r)return r}const r=document.createElement("canvas");return({width:r.width,height:r.height}=t(this,s_)),r.getContext("2d").drawImage(t(this,s_),0,0),r.toDataURL()}if(t(this,p_)){const[r,e]=this.pageDimensions,a=Math.round(this.width*r*Fl.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*Fl.PDF_TO_CSS_UNITS),A=new OffscreenCanvas(a,i);return A.getContext("2d").drawImage(t(this,s_),0,0,t(this,s_).width,t(this,s_).height,0,0,a,i),A.transferToImageBitmap()}return structuredClone(t(this,s_))},G_=new WeakSet,X_=function(){this._uiManager._signal&&(A(this,b_,new ResizeObserver((r=>{const e=r[0].contentRect;e.width&&e.height&&o(this,Z_,W_).call(this,e.width,e.height)}))),t(this,b_).observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{var r;null==(r=t(this,b_))||r.disconnect(),A(this,b_,null)}),{once:!0}))},e(N_,"_type","stamp"),e(N_,"_editorType",Ks.STAMP);const fB=class{constructor({uiManager:r,pageIndex:e,div:a,accessibilityManager:n,annotationLayer:o,drawLayer:s,textLayer:f,viewport:l,l10n:u}){i(this,K_),i(this,eB),i(this,tB),i(this,AB),i(this,oB),i(this,D_,void 0),i(this,T_,!1),i(this,P_,null),i(this,j_,null),i(this,O_,null),i(this,L_,null),i(this,Y_,null),i(this,H_,new Map),i(this,Q_,!1),i(this,U_,!1),i(this,J_,!1),i(this,z_,null),i(this,$_,void 0);const c=[...t(fB,q_).values()];if(!fB._initialized){fB._initialized=!0;for(const e of c)e.initialize(u,r)}r.registerEditorTypes(c),A(this,$_,r),this.pageIndex=e,this.div=a,A(this,D_,n),A(this,P_,o),this.viewport=l,A(this,z_,f),this.drawLayer=s,t(this,$_).addLayer(this)}get isEmpty(){return 0===t(this,H_).size}get isInvisible(){return this.isEmpty&&t(this,$_).getMode()===Ks.NONE}updateToolbar(r){t(this,$_).updateToolbar(r)}updateMode(r=t(this,$_).getMode()){switch(o(this,oB,sB).call(this),r){case Ks.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Ks.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case Ks.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(fB,q_).values())e.toggle(`${a._type}Editing`,r===a._editorType);this.div.hidden=!1}hasTextLayer(r){var e;return r===(null==(e=t(this,z_))?void 0:e.div)}addInkEditorIfNeeded(r){if(t(this,$_).getMode()===Ks.INK){if(!r)for(const r of t(this,H_).values())if(r.isEmpty())return void r.setInBackground();this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(r){t(this,$_).setEditingState(r)}addCommands(r){t(this,$_).addCommands(r)}togglePointerEvents(r=!1){this.div.classList.toggle("disabled",!r)}toggleAnnotationLayerPointerEvents(r=!1){var e;null==(e=t(this,P_))||e.div.classList.toggle("disabled",!r)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const r=new Set;for(const e of t(this,H_).values())e.enableEditing(),e.show(!0),e.annotationElementId&&(t(this,$_).removeChangedExistingAnnotation(e),r.add(e.annotationElementId));if(!t(this,P_))return;const e=t(this,P_).getEditableAnnotations();for(const a of e){if(a.hide(),t(this,$_).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,J_,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,a=new Map;for(const i of t(this,H_).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,P_)){const r=t(this,P_).getEditableAnnotations();for(const i of r){const{id:r}=i.data;if(t(this,$_).isDeletedAnnotationElement(r))continue;let A=a.get(r);A?(A.resetAnnotationElement(i),A.show(!1),i.show()):(A=e.get(r),A&&(t(this,$_).addChangedExistingAnnotation(A),A.renderAnnotationElement(i),A.show(!1)),i.show())}}o(this,oB,sB).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const r of t(fB,q_).values())i.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),A(this,J_,!1)}getEditableAnnotation(r){var e;return(null==(e=t(this,P_))?void 0:e.getEditableAnnotation(r))||null}setActiveEditor(r){t(this,$_).getActive()!==r&&t(this,$_).setActiveEditor(r)}enableTextSelection(){var r;this.div.tabIndex=-1,null!=(r=t(this,z_))&&r.div&&!t(this,L_)&&(A(this,L_,o(this,K_,rB).bind(this)),t(this,z_).div.addEventListener("pointerdown",t(this,L_),{signal:t(this,$_)._signal}),t(this,z_).div.classList.add("highlighting"))}disableTextSelection(){var r;this.div.tabIndex=0,null!=(r=t(this,z_))&&r.div&&t(this,L_)&&(t(this,z_).div.removeEventListener("pointerdown",t(this,L_)),A(this,L_,null),t(this,z_).div.classList.remove("highlighting"))}enableClick(){if(t(this,O_))return;const r=t(this,$_)._signal;A(this,O_,this.pointerdown.bind(this)),A(this,j_,this.pointerup.bind(this)),this.div.addEventListener("pointerdown",t(this,O_),{signal:r}),this.div.addEventListener("pointerup",t(this,j_),{signal:r})}disableClick(){t(this,O_)&&(this.div.removeEventListener("pointerdown",t(this,O_)),this.div.removeEventListener("pointerup",t(this,j_)),A(this,O_,null),A(this,j_,null))}attach(r){t(this,H_).set(r.id,r);const{annotationElementId:e}=r;e&&t(this,$_).isDeletedAnnotationElement(e)&&t(this,$_).removeDeletedAnnotationElement(r)}detach(r){var e;t(this,H_).delete(r.id),null==(e=t(this,D_))||e.removePointerInTextLayer(r.contentDiv),!t(this,J_)&&r.annotationElementId&&t(this,$_).addDeletedAnnotationElement(r)}remove(r){this.detach(r),t(this,$_).removeEditor(r),r.div.remove(),r.isAttachedToDOM=!1,t(this,U_)||this.addInkEditorIfNeeded(!1)}changeParent(r){var e;r.parent!==this&&(r.parent&&r.annotationElementId&&(t(this,$_).addDeletedAnnotationElement(r.annotationElementId),fb.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,$_).addEditor(r),this.attach(r),!r.isAttachedToDOM){const e=r.render();this.div.append(e),r.isAttachedToDOM=!0}r.fixAndSetPosition(),r.onceAdded(),t(this,$_).addToAnnotationStorage(r),r._reportTelemetry(r.telemetryInitialData)}}moveEditorInDOM(r){var e;if(!r.isAttachedToDOM)return;const{activeElement:a}=document;r.div.contains(a)&&!t(this,Y_)&&(r._focusEventsAllowed=!1,A(this,Y_,setTimeout((()=>{A(this,Y_,null),r.div.contains(document.activeElement)?r._focusEventsAllowed=!0:(r.div.addEventListener("focusin",(()=>{r._focusEventsAllowed=!0}),{once:!0,signal:t(this,$_)._signal}),a.focus())}),0))),r._structTreeParentId=null==(e=t(this,D_))?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,$_).getId()}get _signal(){return t(this,$_)._signal}canCreateNewEmptyEditor(){var r;return null==(r=t(this,eB,aB))?void 0:r.canCreateNewEmptyEditor()}pasteEditor(r,e){t(this,$_).updateToolbar(r),t(this,$_).updateMode(r);const{offsetX:a,offsetY:i}=o(this,AB,nB).call(this),A=this.getNextId(),n=o(this,tB,iB).call(this,{parent:this,id:A,x:a,y:i,uiManager:t(this,$_),isCentered:!0,...e});n&&this.add(n)}deserialize(r){var e;return(null==(e=t(fB,q_).get(r.annotationType??r.annotationEditorType))?void 0:e.deserialize(r,this,t(this,$_)))||null}createAndAddNewEditor(r,e,a={}){const i=this.getNextId(),A=o(this,tB,iB).call(this,{parent:this,id:i,x:r.offsetX,y:r.offsetY,uiManager:t(this,$_),isCentered:e,...a});return A&&this.add(A),A}addNewEditor(){this.createAndAddNewEditor(o(this,AB,nB).call(this),!0)}setSelected(r){t(this,$_).setSelected(r)}toggleSelected(r){t(this,$_).toggleSelected(r)}isSelected(r){return t(this,$_).isSelected(r)}unselect(r){t(this,$_).unselect(r)}pointerup(r){const{isMac:e}=al.platform;if(!(0!==r.button||r.ctrlKey&&e)&&r.target===this.div&&t(this,Q_)){if(A(this,Q_,!1),!t(this,T_))return void A(this,T_,!0);if(t(this,$_).getMode()===Ks.STAMP)return void t(this,$_).unselectAll();this.createAndAddNewEditor(r,!1)}}pointerdown(r){if(t(this,$_).getMode()===Ks.HIGHLIGHT&&this.enableTextSelection(),t(this,Q_))return void A(this,Q_,!1);const{isMac:e}=al.platform;if(0!==r.button||r.ctrlKey&&e||r.target!==this.div)return;A(this,Q_,!0);const a=t(this,$_).getActive();A(this,T_,!a||a.isEmpty())}findNewParent(r,e,a){const i=t(this,$_).findParent(e,a);return null!==i&&i!==this&&(i.changeParent(r),!0)}destroy(){var r,e;(null==(r=t(this,$_).getActive())?void 0:r.parent)===this&&(t(this,$_).commitOrRemove(),t(this,$_).setActiveEditor(null)),t(this,Y_)&&(clearTimeout(t(this,Y_)),A(this,Y_,null));for(const r of t(this,H_).values())null==(e=t(this,D_))||e.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,t(this,H_).clear(),t(this,$_).removeLayer(this)}render({viewport:r}){this.viewport=r,Bu(this.div,r);for(const r of t(this,$_).getEditors(this.pageIndex))this.add(r),r.rebuild();this.updateMode()}update({viewport:r}){t(this,$_).commitOrRemove(),o(this,oB,sB).call(this);const e=this.viewport.rotation,a=r.rotation;if(this.viewport=r,Bu(this.div,{rotation:a}),e!==a)for(const r of t(this,H_).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,$_).viewParameters.realScale}};let lB=fB;var uB,cB,dB,hB,bB,gB,pB,vB,mB,kB;D_=new WeakMap,T_=new WeakMap,P_=new WeakMap,j_=new WeakMap,O_=new WeakMap,L_=new WeakMap,Y_=new WeakMap,H_=new WeakMap,Q_=new WeakMap,U_=new WeakMap,J_=new WeakMap,z_=new WeakMap,$_=new WeakMap,q_=new WeakMap,K_=new WeakSet,rB=function(r){if(t(this,$_).unselectAll(),r.target===t(this,z_).div){const{isMac:e}=al.platform;if(0!==r.button||r.ctrlKey&&e)return;t(this,$_).showAllEditors("highlight",!0,!0),t(this,z_).div.classList.add("free"),HE.startHighlighting(this,"ltr"===t(this,$_).direction,r),t(this,z_).div.addEventListener("pointerup",(()=>{t(this,z_).div.classList.remove("free")}),{once:!0,signal:t(this,$_)._signal}),r.preventDefault()}},eB=new WeakSet,aB=function(){return t(fB,q_).get(t(this,$_).getMode())},tB=new WeakSet,iB=function(r){const e=t(this,eB,aB);return e?new e.prototype.constructor(r):null},AB=new WeakSet,nB=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}},oB=new WeakSet,sB=function(){A(this,U_,!0);for(const r of t(this,H_).values())r.isEmpty()&&r.remove();A(this,U_,!1)},e(lB,"_initialized",!1),i(lB,q_,new Map([_w,o_,N_,HE].map((r=>[r._editorType,r]))));const wB=class{constructor({pageIndex:r}){i(this,pB),i(this,mB),i(this,uB,null),i(this,cB,0),i(this,dB,new Map),i(this,hB,new Map),this.pageIndex=r}setParent(r){if(t(this,uB)){if(t(this,uB)!==r){if(t(this,dB).size>0)for(const e of t(this,dB).values())e.remove(),r.append(e);A(this,uB,r)}}else A(this,uB,r)}static get _svgFactory(){return Lf(this,"_svgFactory",new fu)}highlight(r,e,a,i=!1){const A=n(this,cB)._++,s=o(this,pB,vB).call(this,r.box);s.classList.add("highlight"),r.free&&s.classList.add("free");const f=wB._svgFactory.createElement("defs");s.append(f);const l=wB._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,hB).set(A,l);const c=o(this,mB,kB).call(this,f,u),d=wB._svgFactory.createElement("use");return s.append(d),s.setAttribute("fill",e),s.setAttribute("fill-opacity",a),d.setAttribute("href",`#${u}`),t(this,dB).set(A,s),{id:A,clipPathId:`url(#${c})`}}highlightOutline(r){const e=n(this,cB)._++,a=o(this,pB,vB).call(this,r.box);a.classList.add("highlightOutline");const i=wB._svgFactory.createElement("defs");a.append(i);const A=wB._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=wB._svgFactory.createElement("mask");i.append(r),f=`mask_p${this.pageIndex}_${e}`,r.setAttribute("id",f),r.setAttribute("maskUnits","objectBoundingBox");const t=wB._svgFactory.createElement("rect");r.append(t),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("fill","white");const A=wB._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=wB._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,dB).set(e,a),e}finalizeLine(r,e){const a=t(this,hB).get(r);t(this,hB).delete(r),this.updateBox(r,e.box),a.setAttribute("d",e.toSVGPath())}updateLine(r,e){t(this,dB).get(r).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(r){this.remove(r),t(this,hB).delete(r)}updatePath(r,e){t(this,hB).get(r).setAttribute("d",e.toSVGPath())}updateBox(r,e){var a;o(a=wB,bB,gB).call(a,t(this,dB).get(r),e)}show(r,e){t(this,dB).get(r).classList.toggle("hidden",!e)}rotate(r,e){t(this,dB).get(r).setAttribute("data-main-rotation",e)}changeColor(r,e){t(this,dB).get(r).setAttribute("fill",e)}changeOpacity(r,e){t(this,dB).get(r).setAttribute("fill-opacity",e)}addClass(r,e){t(this,dB).get(r).classList.add(e)}removeClass(r,e){t(this,dB).get(r).classList.remove(e)}remove(r){null!==t(this,uB)&&(t(this,dB).get(r).remove(),t(this,dB).delete(r))}destroy(){A(this,uB,null);for(const r of t(this,dB).values())r.remove();t(this,dB).clear()}};let yB=wB;uB=new WeakMap,cB=new WeakMap,dB=new WeakMap,hB=new WeakMap,bB=new WeakSet,gB=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+"%"},pB=new WeakSet,vB=function(r){var e;const a=wB._svgFactory.create(1,1,!0);return t(this,uB).append(a),a.setAttribute("aria-hidden",!0),o(e=wB,bB,gB).call(e,a,r),a},mB=new WeakSet,kB=function(r,e){const a=wB._svgFactory.createElement("clipPath");r.append(a);const t=`clip_${e}`;a.setAttribute("id",t),a.setAttribute("clipPathUnits","objectBoundingBox");const i=wB._svgFactory.createElement("use");return a.append(i),i.setAttribute("href",`#${e}`),i.classList.add("clip"),t},i(yB,bB);var EB=Ts.AbortException,CB=Ts.AnnotationEditorLayer,_B=Ts.AnnotationEditorParamsType,BB=Ts.AnnotationEditorType,ZB=Ts.AnnotationEditorUIManager,WB=Ts.AnnotationLayer,IB=Ts.AnnotationMode,RB=Ts.CMapCompressionType,FB=Ts.ColorPicker,xB=Ts.DOMSVGFactory,SB=Ts.DrawLayer,MB=Ts.FeatureTest,GB=Ts.GlobalWorkerOptions,XB=Ts.ImageKind,VB=Ts.InvalidPDFException,NB=Ts.MissingPDFException,DB=Ts.OPS,TB=Ts.Outliner,PB=Ts.PDFDataRangeTransport,jB=Ts.PDFDateString,OB=Ts.PDFWorker,LB=Ts.PasswordResponses,YB=Ts.PermissionFlag,HB=Ts.PixelsPerInch,QB=Ts.RenderingCancelledException,UB=Ts.TextLayer,JB=Ts.UnexpectedResponseException,zB=Ts.Util,$B=Ts.VerbosityLevel,qB=Ts.XfaLayer,KB=Ts.build,rZ=Ts.createValidAbsoluteUrl,eZ=Ts.fetchData,aZ=Ts.getDocument,tZ=Ts.getFilenameFromUrl,iZ=Ts.getPdfFilenameFromUrl,AZ=Ts.getXfaPageViewport,nZ=Ts.isDataScheme,oZ=Ts.isPdfFile,sZ=Ts.noContextMenu,fZ=Ts.normalizeUnicode,lZ=Ts.renderTextLayer,uZ=Ts.setLayerDimensions,cZ=Ts.shadow,dZ=Ts.updateTextLayer,hZ=Ts.version;const bZ=Object.freeze(Object.defineProperty({__proto__:null,AbortException:EB,AnnotationEditorLayer:CB,AnnotationEditorParamsType:_B,AnnotationEditorType:BB,AnnotationEditorUIManager:ZB,AnnotationLayer:WB,AnnotationMode:IB,CMapCompressionType:RB,ColorPicker:FB,DOMSVGFactory:xB,DrawLayer:SB,FeatureTest:MB,GlobalWorkerOptions:GB,ImageKind:XB,InvalidPDFException:VB,MissingPDFException:NB,OPS:DB,Outliner:TB,PDFDataRangeTransport:PB,PDFDateString:jB,PDFWorker:OB,PasswordResponses:LB,PermissionFlag:YB,PixelsPerInch:HB,RenderingCancelledException:QB,TextLayer:UB,UnexpectedResponseException:JB,Util:zB,VerbosityLevel:$B,XfaLayer:qB,build:KB,createValidAbsoluteUrl:rZ,fetchData:eZ,getDocument:aZ,getFilenameFromUrl:tZ,getPdfFilenameFromUrl:iZ,getXfaPageViewport:AZ,isDataScheme:nZ,isPdfFile:oZ,noContextMenu:sZ,normalizeUnicode:fZ,renderTextLayer:lZ,setLayerDimensions:uZ,shadow:cZ,updateTextLayer:dZ,version:hZ},Symbol.toStringTag,{value:"Module"}));var gZ=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))},pZ=gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ([],["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 vZ(r,e){var a={};return pZ.forEach((function(t){var i=r[t];i&&(a[t]=e?function(r){return i(r,e(t))}:i)})),a}function mZ(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 kZ(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=kZ(r[e]))&&(t&&(t+=" "),t+=a)}else for(a in r)r[a]&&(t&&(t+=" "),t+=a);return t}function wZ(){for(var r,e,a=0,t="",i=arguments.length;a<i;a++)(r=arguments[a])&&(e=kZ(r))&&(t&&(t+=" "),t+=e);return t}var yZ="production"===process.env.NODE_ENV,EZ="Invariant failed";function CZ(r,e){if(!r){if(yZ)throw new Error(EZ);var a="function"==typeof e?e():e,t=a?"".concat(EZ,": ").concat(a):EZ;throw new Error(t)}}var _Z=function(){};if("production"!==process.env.NODE_ENV){var BZ=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{}};_Z=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||BZ.apply(null,[e].concat(a))}}const ZZ=C(_Z);var WZ=Object.prototype.hasOwnProperty;function IZ(r,e,a){for(a of r.keys())if(RZ(a,e))return a}function RZ(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--&&RZ(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=IZ(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=IZ(e,i))||!RZ(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(WZ.call(r,a)&&++t&&!WZ.call(e,a)||!(a in e)||!RZ(r[a],e[a]))return!1;return Object.keys(e).length===t}}return r!=r&&e!=e}const FZ=h(null);function xZ({children:r,type:e}){return R.jsx("div",{className:`react-pdf__message react-pdf__message--${e}`,children:r})}class SZ{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 CZ(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(r){CZ(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=r}get rotation(){return 0}set rotation(r){}goToDestination(r){return new Promise((e=>{CZ(this.pdfDocument,"PDF document not loaded."),CZ(r,"Destination is not specified."),"string"==typeof r?this.pdfDocument.getDestination(r).then(e):Array.isArray(r)?e(r):r.then(e)})).then((r=>{CZ(Array.isArray(r),`"${r}" is not a valid destination array.`);const e=r[0];new Promise((r=>{CZ(this.pdfDocument,"PDF document not loaded."),e instanceof Object?this.pdfDocument.getPageIndex(e).then((e=>{r(e)})).catch((()=>{CZ(!1,`"${e}" is not a valid page reference.`)})):"number"==typeof e?r(e):CZ(!1,`"${e}" is not a valid destination reference.`)})).then((e=>{const a=e+1;CZ(this.pdfViewer,"PDF viewer is not initialized."),CZ(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;CZ(this.pdfViewer,"PDF viewer is not initialized."),CZ(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 MZ={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},GZ=typeof document<"u",XZ=GZ&&"file:"===window.location.protocol;function VZ(r){return function(r){return typeof r<"u"}(r)&&null!==r}function NZ(r){return function(r){return"string"==typeof r}(r)&&/^data:/.test(r)}function DZ(r){CZ(NZ(r),"Invalid data URI.");const[e="",a=""]=r.split(",");return-1!==e.split(";").indexOf("base64")?atob(a):unescape(a)}function TZ(){return GZ&&window.devicePixelRatio||1}const PZ="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function jZ(){ZZ(!XZ,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${PZ}`)}function OZ(r){null!=r&&r.cancel&&r.cancel()}function LZ(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 YZ(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 HZ(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 QZ(){return g(HZ,{value:void 0,error:void 0})}var UZ=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())}))},JZ=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:zZ}=bZ,$Z=(r,e)=>{switch(e){case MZ.NEED_PASSWORD:r(prompt("Enter the password to open this PDF file."));break;case MZ.INCORRECT_PASSWORD:r(prompt("Invalid password. Please try again."));break}};function qZ(r){return"object"==typeof r&&null!==r&&("data"in r||"range"in r||"url"in r)}const KZ=b((function(r,e){var{children:a,className:t,error:i="Failed to load PDF file.",externalLinkRel:A,externalLinkTarget:n,file:o,inputRef:s,imageResourcesPath:u,loading:c="Loading PDF…",noData:d="No PDF file specified.",onItemClick:h,onLoadError:b,onLoadProgress:g,onLoadSuccess:k,onPassword:w=$Z,onSourceError:y,onSourceSuccess:E,options:C,renderMode:_,rotate:B}=r,Z=JZ(r,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[W,I]=QZ(),{value:F,error:x}=W,[S,M]=QZ(),{value:G,error:X}=S,V=l(new SZ),N=l([]),D=l(void 0),T=l(void 0);o&&o!==D.current&&qZ(o)&&(ZZ(!RZ(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),C&&C!==T.current&&(ZZ(!RZ(C,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=C);const P=l({scrollPageIntoView:r=>{const{dest:e,pageNumber:a,pageIndex:t=a-1}=r;if(h)return void h({dest:e,pageIndex:t,pageNumber:a});const i=N.current[t];i?i.scrollIntoView():ZZ(!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>.`)}});v(e,(()=>({linkService:V,pages:N,viewer:P})),[]),p((function(){I({type:"RESET"})}),[o,I]);const j=m((()=>UZ(this,void 0,void 0,(function*(){if(!o)return null;if("string"==typeof o)return NZ(o)?{data:DZ(o)}:(jZ(),{url:o});if(o instanceof zZ)return{range:o};if(o instanceof ArrayBuffer)return{data:o};if(GZ&&function(r){return CZ(GZ,"isBlob can only be used in a browser environment"),r instanceof Blob}(o))return{data:yield YZ(o)};if(CZ("object"==typeof o,"Invalid parameter in file, need either Uint8Array, string or a parameter object"),CZ(qZ(o),"Invalid parameter object: need either .data, .range or .url"),"url"in o&&"string"==typeof o.url){if(NZ(o.url)){const{url:r}=o,e=JZ(o,["url"]),a=DZ(r);return Object.assign({data:a},e)}jZ()}return o}))),[o]);p((()=>{const r=mZ(j());return r.promise.then((r=>{I({type:"RESOLVE",value:r})})).catch((r=>{I({type:"REJECT",error:r})})),()=>{OZ(r)}}),[j,I]),p((()=>{if(!(typeof F>"u")){if(!1===F)return void(x&&(ZZ(!1,x.toString()),y&&y(x)));E&&E()}}),[F]),p((function(){M({type:"RESET"})}),[M,F]),p((function(){if(!F)return;const r=Object.assign(Object.assign({},F),C),e=aZ(r);g&&(e.onProgress=g),w&&(e.onPassword=w);const a=e;return a.promise.then((r=>{M({type:"RESOLVE",value:r})})).catch((r=>{a.destroyed||M({type:"REJECT",error:r})})),()=>{a.destroy()}}),[C,M,F]),p((()=>{if(!(typeof G>"u")){if(!1===G)return void(X&&(ZZ(!1,X.toString()),b&&b(X)));G&&(k&&k(G),N.current=new Array(G.numPages),V.current.setDocument(G))}}),[G]),p((function(){V.current.setViewer(P.current),V.current.setExternalLinkRel(A),V.current.setExternalLinkTarget(n)}),[A,n]);const O=m(((r,e)=>{N.current[r]=e}),[]),L=m((r=>{delete N.current[r]}),[]),Y=f((()=>({imageResourcesPath:u,linkService:V.current,onItemClick:h,pdf:G,registerPage:O,renderMode:_,rotate:B,unregisterPage:L})),[u,h,G,O,_,B,L]),H=f((()=>vZ(Z,(()=>G))),[Z,G]);return R.jsx("div",Object.assign({className:wZ("react-pdf__Document",t),ref:s,style:{"--scale-factor":"1"}},H,{children:o?null==G?R.jsx(xZ,{type:"loading",children:"function"==typeof c?c():c}):!1===G?R.jsx(xZ,{type:"error",children:"function"==typeof i?i():i}):R.jsx(FZ.Provider,{value:Y,children:a}):R.jsx(xZ,{type:"no-data",children:"function"==typeof d?d():d})}))})),rW=KZ;function eW(){return d(FZ)}function aW(){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 tW=h(null),iW={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},AW=/^H(\d+)$/;function nW(r){return"children"in r}function oW(r){return!!nW(r)&&(1===r.children.length&&0 in r.children&&"id"in r.children[0])}function sW(r){const e={};if(nW(r)){const{role:a}=r,t=a.match(AW);if(t)e.role="heading",e["aria-level"]=Number(t[1]);else if(function(r){return r in iW}(a)){const r=iW[a];r&&(e.role=r)}}return e}function fW(r){const e={};if(nW(r)){if(void 0!==r.alt&&(e["aria-label"]=r.alt),void 0!==r.lang&&(e.lang=r.lang),oW(r)){const[a]=r.children;if(a){const r=fW(a);return Object.assign(Object.assign({},e),r)}}}else"id"in r&&(e["aria-owns"]=r.id);return e}function lW(r){return r?Object.assign(Object.assign({},sW(r)),fW(r)):null}function uW({className:r,node:e}){const a=f((()=>lW(e)),[e]),t=f((()=>!nW(e)||oW(e)?null:e.children.map(((r,e)=>R.jsx(uW,{node:r},e)))),[e]);return R.jsx("span",Object.assign({className:r},a,{children:t}))}function cW(){return d(tW)}function dW(){const r=cW();CZ(r,"Unable to find Page context.");const{onGetStructTreeError:e,onGetStructTreeSuccess:a}=r,[t,i]=QZ(),{value:A,error:n}=t,{customTextRenderer:o,page:s}=r;return p((function(){i({type:"RESET"})}),[i,s]),p((function(){if(o||!s)return;const r=mZ(s.getStructTree()),e=r;return r.promise.then((r=>{i({type:"RESOLVE",value:r})})).catch((r=>{i({type:"REJECT",error:r})})),()=>OZ(e)}),[o,s,i]),p((()=>{if(void 0!==A){if(!1===A)return void(n&&(ZZ(!1,n.toString()),e&&e(n)));A&&a&&a(A)}}),[A]),A?R.jsx(uW,{className:"react-pdf__Page__structTree structTree",node:A}):null}const hW=IB;function bW(r){const e=cW();CZ(e,"Unable to find Page context.");const a=Object.assign(Object.assign({},e),r),{_className:t,canvasBackground:i,devicePixelRatio:A=TZ(),onRenderError:n,onRenderSuccess:o,page:s,renderForms:u,renderTextLayer:c,rotate:d,scale:h}=a,{canvasRef:b}=r;CZ(s,"Attempted to render page canvas, but no page was specified.");const g=l(null);function v(r){(function(r){return"RenderingCancelledException"===r.name})(r)||(ZZ(!1,r.toString()),n&&n(r))}const k=f((()=>s.getViewport({scale:h*A,rotation:d})),[A,s,d,h]),w=f((()=>s.getViewport({scale:h,rotation:d})),[s,d,h]);p((function(){if(!s)return;s.cleanup();const{current:r}=g;if(!r)return;r.width=k.width,r.height=k.height,r.style.width=`${Math.floor(w.width)}px`,r.style.height=`${Math.floor(w.height)}px`,r.style.visibility="hidden";const e={annotationMode:u?hW.ENABLE_FORMS:hW.ENABLE,canvasContext:r.getContext("2d",{alpha:!1}),viewport:k};i&&(e.background=i);const a=s.render(e),t=a;return a.promise.then((()=>{r.style.visibility="",s&&o&&o(LZ(s,h))})).catch(v),()=>OZ(t)}),[i,s,u,k,w]);const y=m((()=>{const{current:r}=g;r&&(r.width=0,r.height=0)}),[]);return p((()=>y),[y]),R.jsx("canvas",{className:`${t}__canvas`,dir:"ltr",ref:aW(b,g),style:{display:"block",userSelect:"none"},children:c?R.jsx(dW,{}):null})}function gW(){const r=cW();CZ(r,"Unable to find Page context.");const{customTextRenderer:e,onGetTextError:a,onGetTextSuccess:t,onRenderTextLayerError:i,onRenderTextLayerSuccess:A,page:n,pageIndex:o,pageNumber:s,rotate:u,scale:c}=r;CZ(n,"Attempted to load page text content, but no page was specified.");const[d,h]=QZ(),{value:b,error:g}=d,v=l(null),k=l(void 0);ZZ(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"),p((function(){h({type:"RESET"})}),[n,h]),p((function(){if(!n)return;const r=mZ(n.getTextContent()),e=r;return r.promise.then((r=>{h({type:"RESOLVE",value:r})})).catch((r=>{h({type:"REJECT",error:r})})),()=>OZ(e)}),[n,h]),p((()=>{if(void 0!==b){if(!1===b)return void(g&&(ZZ(!1,g.toString()),a&&a(g)));b&&t&&t(b)}}),[b]);const y=m((()=>{A&&A()}),[A]),E=m((r=>{ZZ(!1,r.toString()),i&&i(r)}),[i]);const C=f((()=>n.getViewport({scale:c,rotation:u})),[n,u,c]);return w((function(){if(!n||!b)return;const{current:r}=v;if(!r)return;r.innerHTML="";const a=n.streamTextContent({includeMarkedContent:!0}),t=new UB({container:r,textContentSource:a,viewport:C}),i=t;return t.render().then((()=>{const a=document.createElement("div");a.className="endOfContent",r.append(a),k.current=a;const t=r.querySelectorAll('[role="presentation"]');if(e){let r=0;b.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:s,itemIndex:i},a));A.innerHTML=n,r+=a.str&&a.hasEOL?2:1}))}y()})).catch(E),()=>OZ(i)}),[e,E,y,n,o,s,b,C]),R.jsx("div",{className:wZ("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){const r=k.current;r&&r.classList.remove("active")},onMouseDown:function(){const r=k.current;r&&r.classList.add("active")},ref:v})}function pW(){const r=eW(),e=cW();CZ(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:s,page:u,pdf:c,renderForms:d,rotate:h,scale:b=1}=a;CZ(c,"Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."),CZ(u,"Attempted to load page annotations, but no page was specified."),CZ(i,"Attempted to load page annotations, but no linkService was specified.");const[g,v]=QZ(),{value:m,error:k}=g,w=l(null);ZZ(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"),p((function(){v({type:"RESET"})}),[v,u]),p((function(){if(!u)return;const r=mZ(u.getAnnotations()),e=r;return r.promise.then((r=>{v({type:"RESOLVE",value:r})})).catch((r=>{v({type:"REJECT",error:r})})),()=>{OZ(e)}}),[v,u]),p((()=>{if(void 0!==m){if(!1===m)return void(k&&(ZZ(!1,k.toString()),A&&A(k)));m&&n&&n(m)}}),[m]);const y=f((()=>u.getViewport({scale:b,rotation:h})),[u,h,b]);return p((function(){if(!(c&&u&&i&&m))return;const{current:r}=w;if(!r)return;const e=y.clone({dontFlip:!0}),a={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:r,l10n:null,page:u,viewport:e},A={annotations:m,annotationStorage:c.annotationStorage,div:r,imageResourcesPath:t,linkService:i,page:u,renderForms:d,viewport:e};r.innerHTML="";try{new WB(a).render(A),s&&s()}catch(r){ZZ(!1,`${n=r}`),o&&o(n)}var n;return()=>{}}),[m,t,i,u,c,d,y]),R.jsx("div",{className:wZ("react-pdf__Page__annotations","annotationLayer"),ref:w})}var vW=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 mW=1;function kW(r){const e=eW(),a=Object.assign(Object.assign({},e),r),{_className:t="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:A,canvasRef:n,children:o,className:s,customRenderer:u,customTextRenderer:c,devicePixelRatio:d,error:h="Failed to load the page.",height:b,inputRef:g,loading:v="Loading page…",noData:m="No page specified.",onGetAnnotationsError:k,onGetAnnotationsSuccess:w,onGetStructTreeError:y,onGetStructTreeSuccess:E,onGetTextError:C,onGetTextSuccess:_,onLoadError:B,onLoadSuccess:Z,onRenderAnnotationLayerError:W,onRenderAnnotationLayerSuccess:I,onRenderError:F,onRenderSuccess:x,onRenderTextLayerError:S,onRenderTextLayerSuccess:M,pageIndex:G,pageNumber:X,pdf:V,registerPage:N,renderAnnotationLayer:D=!0,renderForms:T=!1,renderMode:P="canvas",renderTextLayer:j=!0,rotate:O,scale:L=mW,unregisterPage:Y,width:H}=a,Q=vW(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"]),[U,J]=QZ(),{value:z,error:$}=U,q=l(null);CZ(V,"Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.");const K=VZ(X)?X-1:G??null,rr=X??(VZ(G)?G+1:null),er=O??(z?z.rotate:null),ar=f((()=>{if(!z)return null;let r=1;const e=L??mW;if(H||b){const e=z.getViewport({scale:1,rotation:er});H?r=H/e.width:b&&(r=b/e.height)}return e*r}),[b,z,er,L,H]);p((function(){return()=>{VZ(K)&&i&&Y&&Y(K)}}),[i,V,K,Y]),p((function(){J({type:"RESET"})}),[J,V,K]),p((function(){if(!V||!rr)return;const r=mZ(V.getPage(rr)),e=r;return r.promise.then((r=>{J({type:"RESOLVE",value:r})})).catch((r=>{J({type:"REJECT",error:r})})),()=>OZ(e)}),[J,V,rr]),p((()=>{if(void 0!==z){if(!1===z)return void($&&(ZZ(!1,$.toString()),B&&B($)));!function(){if(Z){if(!z||!ar)return;Z(LZ(z,ar))}if(i&&N){if(!VZ(K)||!q.current)return;N(K,q.current)}}()}}),[z,ar]);const tr=f((()=>z&&VZ(K)&&rr&&VZ(er)&&VZ(ar)?{_className:t,canvasBackground:A,customTextRenderer:c,devicePixelRatio:d,onGetAnnotationsError:k,onGetAnnotationsSuccess:w,onGetStructTreeError:y,onGetStructTreeSuccess:E,onGetTextError:C,onGetTextSuccess:_,onRenderAnnotationLayerError:W,onRenderAnnotationLayerSuccess:I,onRenderError:F,onRenderSuccess:x,onRenderTextLayerError:S,onRenderTextLayerSuccess:M,page:z,pageIndex:K,pageNumber:rr,renderForms:T,renderTextLayer:j,rotate:er,scale:ar}:null),[t,A,c,d,k,w,y,E,C,_,W,I,F,x,S,M,z,K,rr,T,j,er,ar]),ir=f((()=>vZ(Q,(()=>z&&(ar?LZ(z,ar):void 0)))),[Q,z,ar]),Ar=`${K}@${ar}/${er}`;function nr(){switch(P){case"custom":return CZ(u,'renderMode was set to "custom", but no customRenderer was passed.'),R.jsx(u,{},`${Ar}_custom`);case"none":return null;default:return R.jsx(bW,{canvasRef:n},`${Ar}_canvas`)}}return R.jsx("div",Object.assign({className:wZ(t,s),"data-page-number":rr,ref:aW(g,q),style:{"--scale-factor":`${ar}`,backgroundColor:A||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},ir,{children:rr?null===V||null==z?R.jsx(xZ,{type:"loading",children:"function"==typeof v?v():v}):!1===V||!1===z?R.jsx(xZ,{type:"error",children:"function"==typeof h?h():h}):R.jsxs(tW.Provider,{value:tr,children:[nr(),j?R.jsx(gW,{},`${Ar}_text`):null,D?R.jsx(pW,{},`${Ar}_annotations`):null,o]}):R.jsx(xZ,{type:"no-data",children:"function"==typeof m?m():m})}))}ZZ(!XZ,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${PZ}`),GB.workerSrc="pdf.worker.mjs";const wW="SET_ZOOM_LEVEL",yW=r=>({type:wW,value:r}),EW="SET_PDF_PAGINATED",CW="SET_NUM_PAGES",_W=r=>({type:CW,value:r}),BW="SET_CURRENT_PAGE",ZW=r=>({type:BW,value:r}),WW={defaultZoomLevel:1,zoomLevel:1,zoomJump:.1,paginated:!0,numPages:0,currentPage:1,disablePageTags:!1},IW=(r=WW,e)=>{switch(e.type){case wW:{const{value:a}=e;return{...r,zoomLevel:a}}case EW:{const{value:a}=e;return{...r,paginated:a}}case CW:{const{value:a}=e;return{...r,numPages:a}}case BW:{const{value:a}=e;return{...r,currentPage:a}}default:return r}},RW=h({state:WW,dispatch:()=>null}),FW=({children:r,mainState:e})=>{var a,t,i,A,n,o,s,f;const[l,u]=g(IW,{...WW,defaultZoomLevel:(null==(t=null==(a=e.config)?void 0:a.pdfZoom)?void 0:t.defaultZoom)??WW.defaultZoomLevel,zoomLevel:(null==(A=null==(i=e.config)?void 0:i.pdfZoom)?void 0:A.defaultZoom)??WW.zoomLevel,zoomJump:(null==(o=null==(n=e.config)?void 0:n.pdfZoom)?void 0:o.zoomJump)??WW.zoomJump,paginated:(null==(s=e.config)||!s.pdfVerticalScrollByDefault)&&WW.paginated,disablePageTags:(null==(f=e.config)?void 0:f.disablePageTags)||!1,mainState:e});return R.jsx(RW.Provider,{value:{state:l,dispatch:u},children:r})},xW=({pageNum:r})=>{const{state:{mainState:e,paginated:a,zoomLevel:t,numPages:i,currentPage:A,disablePageTags:n}}=d(RW),{t:o}=as(),s=(null==e?void 0:e.rendererRect)||null,f=r??A;return R.jsxs(SW,{id:"pdf-page-wrapper",$lastPage:f>=i,children:[!a&&!n&&R.jsx(MW,{id:"pdf-page-info",children:o("pdfPluginPageNumber",{currentPage:f,allPagesCount:i})}),R.jsx(kW,{pageNumber:f||A,scale:t,height:((null==s?void 0:s.height)??100)-100,width:((null==s?void 0:s.width)??100)-100,loading:o("pdfPluginLoading")})]})},SW=no.div`
|
|
172
|
+
`;var Ds={d:(r,e)=>{for(var a in e)Ds.o(e,a)&&!Ds.o(r,a)&&Object.defineProperty(r,a,{enumerable:!0,get:e[a]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e)},Ts=globalThis.pdfjsLib={};Ds.d(Ts,{AbortException:()=>qf,AnnotationEditorLayer:()=>lB,AnnotationEditorParamsType:()=>rf,AnnotationEditorType:()=>Ks,AnnotationEditorUIManager:()=>rh,AnnotationLayer:()=>Uk,AnnotationMode:()=>qs,CMapCompressionType:()=>Mf,ColorPicker:()=>Jy,DOMSVGFactory:()=>fu,DrawLayer:()=>yB,FeatureTest:()=>al,GlobalWorkerOptions:()=>cg,ImageKind:()=>ff,InvalidPDFException:()=>Uf,MissingPDFException:()=>Jf,OPS:()=>Gf,Outliner:()=>Ay,PDFDataRangeTransport:()=>gv,PDFDateString:()=>wu,PDFWorker:()=>Gv,PasswordResponses:()=>Xf,PermissionFlag:()=>ef,PixelsPerInch:()=>Fl,RenderingCancelledException:()=>uu,TextLayer:()=>av,UnexpectedResponseException:()=>zf,Util:()=>sl,VerbosityLevel:()=>Sf,XfaLayer:()=>nm,build:()=>am,createValidAbsoluteUrl:()=>Of,fetchData:()=>nu,getDocument:()=>uv,getFilenameFromUrl:()=>hu,getPdfFilenameFromUrl:()=>bu,getXfaPageViewport:()=>yu,isDataScheme:()=>cu,isPdfFile:()=>du,noContextMenu:()=>vu,normalizeUnicode:()=>ul,renderTextLayer:()=>tv,setLayerDimensions:()=>Bu,shadow:()=>Lf,updateTextLayer:()=>iv,version:()=>em});const Ps=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),js=[1,0,0,1,0,0],Os=[.001,0,0,.001,0,0],Ls=1.35,Ys=1,Hs=2,Qs=4,Us=16,Js=32,zs=64,$s=256,qs={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Ks={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},rf={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},ef={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},af=0,tf=1,Af=2,nf=3,of=3,sf=4,ff={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},lf=1,uf=2,cf=3,df=4,hf=5,bf=6,gf=7,pf=8,vf=9,mf=10,kf=11,wf=12,yf=13,Ef=14,Cf=15,_f=16,Bf=17,Zf=20,Wf=1,If=2,Rf=3,Ff=4,xf=5,Sf={ERRORS:0,WARNINGS:1,INFOS:5},Mf={NONE:0,BINARY:1},Gf={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},Xf={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Vf=Sf.WARNINGS;function Nf(){return Vf}function Df(r){Vf>=Sf.INFOS&&console.log(`Info: ${r}`)}function Tf(r){Vf>=Sf.WARNINGS&&console.log(`Warning: ${r}`)}function Pf(r){throw new Error(r)}function jf(r,e){r||Pf(e)}function Of(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 Lf(r,e,a,t=!1){return Object.defineProperty(r,e,{value:a,enumerable:!t,configurable:!0,writable:!1}),a}const Yf=function(){function r(e,a){this.constructor===r&&Pf("Cannot initialize BaseException."),this.message=e,this.name=a}return r.prototype=new Error,r.constructor=r,r}();class Hf extends Yf{constructor(r,e){super(r,"PasswordException"),this.code=e}}class Qf extends Yf{constructor(r,e){super(r,"UnknownErrorException"),this.details=e}}class Uf extends Yf{constructor(r){super(r,"InvalidPDFException")}}class Jf extends Yf{constructor(r){super(r,"MissingPDFException")}}class zf extends Yf{constructor(r,e){super(r,"UnexpectedResponseException"),this.status=e}}class $f extends Yf{constructor(r){super(r,"FormatError")}}class qf extends Yf{constructor(r){super(r,"AbortException")}}function Kf(r){("object"!=typeof r||void 0===(null==r?void 0:r.length))&&Pf("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 rl(r){"string"!=typeof r&&Pf("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 el(r){const e=Object.create(null);for(const[a,t]of r)e[a]=t;return e}class al{static get isLittleEndian(){return Lf(this,"isLittleEndian",function(){const r=new Uint8Array(4);return r[0]=1,1===new Uint32Array(r.buffer,0,1)[0]}())}static get isEvalSupported(){return Lf(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Lf(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&"string"==typeof(null==navigator?void 0:navigator.platform)?Lf(this,"platform",{isMac:navigator.platform.includes("Mac")}):Lf(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){var r,e;return Lf(this,"isCSSRoundSupported",null==(e=null==(r=globalThis.CSS)?void 0:r.supports)?void 0:e.call(r,"width: round(1.5px, 1px)"))}}const tl=Array.from(Array(256).keys(),(r=>r.toString(16).padStart(2,"0")));var il,Al,nl,ol;class sl{static makeHexColor(r,e,a){return`#${tl[r]}${tl[e]}${tl[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,nl,ol).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,nl,ol).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}}il=new WeakSet,Al=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)},nl=new WeakSet,ol=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,il,Al).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,il,Al).call(this,r,e,a,t,i,A,n,s,(-l+h)/b,c),o(this,il,Al).call(this,r,e,a,t,i,A,n,s,(-l-h)/b,c)},i(sl,il),i(sl,nl);let fl=null,ll=null;function ul(r){return fl||(fl=/([\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,ll=new Map([["ſt","ſt"]])),r.replaceAll(fl,((r,e,a)=>e?e.normalize("NFKC"):ll.get(a)))}const cl="pdfjs_internal_id_",dl=0,hl=1,bl=2,gl=3,pl=4,vl=5,ml=6,kl=7,wl=8;class yl{constructor(){this.constructor===yl&&Pf("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 El;const Cl=class{constructor({enableHWA:r=!1}={}){i(this,El,!1),this.constructor===Cl&&Pf("Cannot initialize BaseCanvasFactory."),A(this,El,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,El)})}}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){Pf("Abstract method `_createCanvas` called.")}};let _l=Cl;El=new WeakMap;class Bl{constructor({baseUrl:r=null,isCompressed:e=!0}){this.constructor===Bl&&Pf("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?Mf.BINARY:Mf.NONE;return this._fetchData(e,a).catch((r=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}_fetchData(r,e){Pf("Abstract method `_fetchData` called.")}}class Zl{constructor({baseUrl:r=null}){this.constructor===Zl&&Pf("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){Pf("Abstract method `_fetchData` called.")}}class Wl{constructor(){this.constructor===Wl&&Pf("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){Pf("Abstract method `_createSVG` called.")}}const Il="http://www.w3.org/2000/svg",Rl=class{};let Fl=Rl;var xl,Sl,Ml,Gl,Xl,Vl,Nl,Dl,Tl,Pl,jl,Ol,Ll,Yl,Hl,Ql,Ul,Jl,zl,$l,ql,Kl,ru,eu,au,tu,iu,Au;e(Fl,"CSS",96),e(Fl,"PDF",72),e(Fl,"PDF_TO_CSS_UNITS",Rl.CSS/Rl.PDF);xl=new WeakMap,Sl=new WeakMap,Ml=new WeakMap,Gl=new WeakMap,Xl=new WeakMap,Vl=new WeakMap,Nl=new WeakSet,Dl=function(){return t(this,xl)||A(this,xl,new Map)},Tl=new WeakSet,Pl=function(){return t(this,Xl)||A(this,Xl,new Map)},jl=new WeakSet,Ol=function(){if(!t(this,Sl)){const r=t(this,Gl).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,Gl).createElementNS(Il,"svg");a.setAttribute("width",0),a.setAttribute("height",0),A(this,Sl,t(this,Gl).createElementNS(Il,"defs")),r.append(a),a.append(t(this,Sl)),t(this,Gl).body.append(r)}return t(this,Sl)},Ll=new WeakSet,Yl=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(",")]},Hl=new WeakSet,Ql=function(r){const e=t(this,Gl).createElementNS(Il,"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)},Ul=new WeakSet,Jl=function(r){const e=t(this,Gl).createElementNS(Il,"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)},zl=new WeakSet,$l=function(r){const e=t(this,Gl).createElementNS(Il,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",r),t(this,jl,Ol).append(e),e},ql=new WeakSet,Kl=function(r,e,a){const i=t(this,Gl).createElementNS(Il,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",a),r.append(i)},ru=new WeakSet,eu=function(r,e,a,i){const A=t(this,Gl).createElementNS(Il,"feComponentTransfer");i.append(A),o(this,ql,Kl).call(this,A,"feFuncR",r),o(this,ql,Kl).call(this,A,"feFuncG",e),o(this,ql,Kl).call(this,A,"feFuncB",a)},au=new WeakSet,tu=function(r,e){const a=t(this,Gl).createElementNS(Il,"feComponentTransfer");e.append(a),o(this,ql,Kl).call(this,a,"feFuncA",r)},iu=new WeakSet,Au=function(r){return t(this,jl,Ol).style.color=r,Eu(getComputedStyle(t(this,jl,Ol)).getPropertyValue("color"))};async function nu(r,e="text"){if(pu(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 ou extends Bl{_fetchData(r,e){return nu(r,this.isCompressed?"arraybuffer":"text").then((r=>({cMapData:r instanceof ArrayBuffer?new Uint8Array(r):rl(r),compressionType:e})))}}class su extends Zl{_fetchData(r){return nu(r,"arraybuffer").then((r=>new Uint8Array(r)))}}class fu extends Wl{_createSVG(r){return document.createElementNS(Il,r)}}class lu{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 Lf(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 lu({viewBox:this.viewBox.slice(),scale:r,rotation:e,offsetX:a,offsetY:t,dontFlip:i})}convertToViewportPoint(r,e){return sl.applyTransform([r,e],this.transform)}convertToViewportRectangle(r){const e=sl.applyTransform([r[0],r[1]],this.transform),a=sl.applyTransform([r[2],r[3]],this.transform);return[e[0],e[1],a[0],a[1]]}convertToPdfPoint(r,e){return sl.applyInverseTransform([r,e],this.transform)}}class uu extends Yf{constructor(r,e=0){super(r,"RenderingCancelledException"),this.extraDelay=e}}function cu(r){const e=r.length;let a=0;for(;a<e&&""===r[a].trim();)a++;return"data:"===r.substring(a,a+5).toLowerCase()}function du(r){return"string"==typeof r&&/\.pdf$/i.test(r)}function hu(r){return[r]=r.split(/[#?]/,1),r.substring(r.lastIndexOf("/")+1)}function bu(r,e="document.pdf"){if("string"!=typeof r)return e;if(cu(r))return Tf('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 gu{constructor(){e(this,"started",Object.create(null)),e(this,"times",[])}time(r){r in this.started&&Tf(`Timer is already running for ${r}`),this.started[r]=Date.now()}timeEnd(r){r in this.started||Tf(`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 pu(r,e){try{const{protocol:a}=e?new URL(r,e):new URL(r);return"http:"===a||"https:"===a}catch{return!1}}function vu(r){r.preventDefault()}function mu(r){console.log("Deprecated API usage: "+r)}let ku;class wu{static toDateObject(r){if(!r||"string"!=typeof r)return null;ku||(ku=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=ku.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 yu(r,{scale:e=1,rotation:a=0}){const{width:t,height:i}=r.attributes.style,A=[0,0,parseInt(t),parseInt(i)];return new lu({viewBox:A,scale:e,rotation:a})}function Eu(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):(Tf(`Not a valid color format: "${r}"`),[0,0,0])}function Cu(r){const{a:e,b:a,c:t,d:i,e:A,f:n}=r.getTransform();return[e,a,t,i,A,n]}function _u(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 Bu(r,e,a=!1,t=!0){if(e instanceof lu){const{pageWidth:t,pageHeight:i}=e.rawDims,{style:A}=r,n=al.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 Zu,Wu,Iu,Ru,Fu,xu,Su,Mu,Gu,Xu,Vu,Nu,Du,Tu,Pu,ju;const Ou=class{constructor(r){i(this,Su),i(this,Gu),i(this,Vu),i(this,Du),i(this,Pu),i(this,Zu,null),i(this,Wu,null),i(this,Iu,void 0),i(this,Ru,null),A(this,Iu,r)}render(){const r=A(this,Zu,document.createElement("div"));r.className="editToolbar",r.setAttribute("role","toolbar");const e=t(this,Iu)._uiManager._signal;r.addEventListener("contextmenu",vu,{signal:e}),r.addEventListener("pointerdown",o(Ou,Fu,xu),{signal:e});const a=A(this,Ru,document.createElement("div"));a.className="buttons",r.append(a);const i=t(this,Iu).toolbarPosition;if(i){const{style:e}=r,a="ltr"===t(this,Iu)._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,Du,Tu).call(this),r}hide(){var r;t(this,Zu).classList.add("hidden"),null==(r=t(this,Wu))||r.hideDropdown()}show(){t(this,Zu).classList.remove("hidden")}addAltTextButton(r){o(this,Vu,Nu).call(this,r),t(this,Ru).prepend(r,t(this,Pu,ju))}addColorPicker(r){A(this,Wu,r);const e=r.renderButton();o(this,Vu,Nu).call(this,e),t(this,Ru).prepend(e,t(this,Pu,ju))}remove(){var r;t(this,Zu).remove(),null==(r=t(this,Wu))||r.destroy(),A(this,Wu,null)}};let Lu=Ou;var Yu,Hu,Qu,Uu,Ju,zu,$u,qu,Ku,rc,ec,ac,tc,ic,Ac;Zu=new WeakMap,Wu=new WeakMap,Iu=new WeakMap,Ru=new WeakMap,Fu=new WeakSet,xu=function(r){r.stopPropagation()},Su=new WeakSet,Mu=function(r){t(this,Iu)._focusEventsAllowed=!1,r.preventDefault(),r.stopPropagation()},Gu=new WeakSet,Xu=function(r){t(this,Iu)._focusEventsAllowed=!0,r.preventDefault(),r.stopPropagation()},Vu=new WeakSet,Nu=function(r){const e=t(this,Iu)._uiManager._signal;r.addEventListener("focusin",o(this,Su,Mu).bind(this),{capture:!0,signal:e}),r.addEventListener("focusout",o(this,Gu,Xu).bind(this),{capture:!0,signal:e}),r.addEventListener("contextmenu",vu,{signal:e})},Du=new WeakSet,Tu=function(){const r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",`pdfjs-editor-remove-${t(this,Iu).editorType}-button`),o(this,Vu,Nu).call(this,r),r.addEventListener("click",(r=>{t(this,Iu)._uiManager.delete()}),{signal:t(this,Iu)._uiManager._signal}),t(this,Ru).append(r)},Pu=new WeakSet,ju=function(){const r=document.createElement("div");return r.className="divider",r},i(Lu,Fu);class nc{constructor(r){i(this,Uu),i(this,zu),i(this,qu),i(this,Yu,null),i(this,Hu,null),i(this,Qu,void 0),A(this,Qu,r)}show(r,e,a){const[i,n]=o(this,zu,$u).call(this,e,a),{style:s}=t(this,Hu)||A(this,Hu,o(this,Uu,Ju).call(this));r.append(t(this,Hu)),s.insetInlineEnd=100*i+"%",s.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){t(this,Hu).remove()}}function oc(r,e,a){for(const t of a)e.addEventListener(t,r[t].bind(r))}Yu=new WeakMap,Hu=new WeakMap,Qu=new WeakMap,Uu=new WeakSet,Ju=function(){const r=A(this,Hu,document.createElement("div"));r.className="editToolbar",r.setAttribute("role","toolbar"),r.addEventListener("contextmenu",vu,{signal:t(this,Qu)._signal});const e=A(this,Yu,document.createElement("div"));return e.className="buttons",r.append(e),o(this,qu,Ku).call(this),r},zu=new WeakSet,$u=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]},qu=new WeakSet,Ku=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,Qu)._signal;r.addEventListener("contextmenu",vu,{signal:a}),r.addEventListener("click",(()=>{t(this,Qu).highlightSelection("floating_button")}),{signal:a}),t(this,Yu).append(r)};class sc{constructor(){i(this,rc,0)}get id(){return"pdfjs_internal_editor_"+n(this,rc)._++}}rc=new WeakMap;const fc=class{constructor(){i(this,ic),i(this,ec,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 Kf(r)}()),i(this,ac,0),i(this,tc,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 Lf(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,ic,Ac).call(this,`${e}_${a}_${t}_${i}`,r)}async getFromUrl(r){return o(this,ic,Ac).call(this,r,r)}async getFromId(r){t(this,tc)||A(this,tc,new Map);const e=t(this,tc).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,tc).get(r);return null!=e&&e.isSvg?e.svgUrl:null}deleteId(r){t(this,tc)||A(this,tc,new Map);const e=t(this,tc).get(r);e&&(e.refCounter-=1,0===e.refCounter&&(e.bitmap=null))}isValidId(r){return r.startsWith(`image_${t(this,ec)}_`)}};let lc=fc;var uc,cc,dc,hc,bc,gc;ec=new WeakMap,ac=new WeakMap,tc=new WeakMap,ic=new WeakSet,Ac=async function(r,e){t(this,tc)||A(this,tc,new Map);let a=t(this,tc).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,ec)}_${n(this,ac)._++}`,refCounter:0,isSvg:!1}),"string"==typeof e?(a.url=e,r=await nu(e,"blob")):r=a.file=e,"image/svg+xml"===r.type){const e=fc._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,tc).set(r,a),a&&t(this,tc).set(a.id,a),a};class pc{constructor(r=128){i(this,uc,[]),i(this,cc,!1),i(this,dc,void 0),i(this,hc,-1),A(this,dc,r)}add({cmd:r,undo:e,post:a,mustExec:i,type:n=NaN,overwriteIfSameType:o=!1,keepUndo:s=!1}){if(i&&r(),t(this,cc))return;const f={cmd:r,undo:e,post:a,type:n};if(-1===t(this,hc))return t(this,uc).length>0&&(t(this,uc).length=0),A(this,hc,0),void t(this,uc).push(f);if(o&&t(this,uc)[t(this,hc)].type===n)return s&&(f.undo=t(this,uc)[t(this,hc)].undo),void(t(this,uc)[t(this,hc)]=f);const l=t(this,hc)+1;l===t(this,dc)?t(this,uc).splice(0,1):(A(this,hc,l),l<t(this,uc).length&&t(this,uc).splice(l)),t(this,uc).push(f)}undo(){if(-1===t(this,hc))return;A(this,cc,!0);const{undo:r,post:e}=t(this,uc)[t(this,hc)];r(),null==e||e(),A(this,cc,!1),A(this,hc,t(this,hc)-1)}redo(){if(t(this,hc)<t(this,uc).length-1){A(this,hc,t(this,hc)+1),A(this,cc,!0);const{cmd:r,post:e}=t(this,uc)[t(this,hc)];r(),null==e||e(),A(this,cc,!1)}}hasSomethingToUndo(){return-1!==t(this,hc)}hasSomethingToRedo(){return t(this,hc)<t(this,uc).length-1}destroy(){A(this,uc,null)}}uc=new WeakMap,cc=new WeakMap,dc=new WeakMap,hc=new WeakMap;class vc{constructor(r){i(this,bc),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=al.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,bc,gc).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()))}}bc=new WeakSet,gc=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 mc=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,Eu(t))}e.remove()}(r),Lf(this,"_colors",r)}convert(r){const e=Eu(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 mc._colorsMapping.get(r);return e}getHexCode(r){const e=this._colors.get(r);return e?sl.makeHexColor(...e):r}};let kc=mc;var wc,yc,Ec,Cc,_c,Bc,Zc,Wc,Ic,Rc,Fc,xc,Sc,Mc,Gc,Xc,Vc,Nc,Dc,Tc,Pc,jc,Oc,Lc,Yc,Hc,Qc,Uc,Jc,zc,$c,qc,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,_d,Bd,Zd,Wd,Id,Rd,Fd,xd,Sd,Md,Gd,Xd,Vd,Nd,Dd,Td,Pd,jd,Od,Ld,Yd,Hd,Qd,Ud,Jd,zd,$d,qd;e(kc,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));const Kd=class{constructor(r,e,a,n,s,f,l,u,c){i(this,dd),i(this,bd),i(this,pd),i(this,md),i(this,wd),i(this,Ed),i(this,_d),i(this,Zd),i(this,Id),i(this,Fd),i(this,Sd),i(this,Gd),i(this,Vd),i(this,Dd),i(this,Pd),i(this,Od),i(this,Yd),i(this,Qd),i(this,Jd),i(this,$d),i(this,wc,new AbortController),i(this,yc,null),i(this,Ec,new Map),i(this,Cc,new Map),i(this,_c,null),i(this,Bc,null),i(this,Zc,null),i(this,Wc,new pc),i(this,Ic,0),i(this,Rc,new Set),i(this,Fc,null),i(this,xc,null),i(this,Sc,new Set),i(this,Mc,!1),i(this,Gc,null),i(this,Xc,null),i(this,Vc,null),i(this,Nc,!1),i(this,Dc,null),i(this,Tc,new sc),i(this,Pc,!1),i(this,jc,!1),i(this,Oc,null),i(this,Lc,null),i(this,Yc,null),i(this,Hc,Ks.NONE),i(this,Qc,new Set),i(this,Uc,null),i(this,Jc,null),i(this,zc,null),i(this,$c,this.blur.bind(this)),i(this,qc,this.focus.bind(this)),i(this,Kc,this.copy.bind(this)),i(this,rd,this.cut.bind(this)),i(this,ed,this.paste.bind(this)),i(this,ad,this.keydown.bind(this)),i(this,td,this.keyup.bind(this)),i(this,id,this.onEditingAction.bind(this)),i(this,Ad,this.onPageChanging.bind(this)),i(this,nd,this.onScaleChanging.bind(this)),i(this,od,this.onRotationChanging.bind(this)),i(this,sd,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),i(this,fd,[0,0]),i(this,ld,null),i(this,ud,null),i(this,cd,null),this._signal=t(this,wc).signal,A(this,ud,r),A(this,cd,e),A(this,_c,a),this._eventBus=n,this._eventBus._on("editingaction",t(this,id)),this._eventBus._on("pagechanging",t(this,Ad)),this._eventBus._on("scalechanging",t(this,nd)),this._eventBus._on("rotationchanging",t(this,od)),o(this,wd,yd).call(this),o(this,Gd,Xd).call(this),o(this,Zd,Wd).call(this),A(this,Bc,s.annotationStorage),A(this,Gc,s.filterFactory),A(this,Jc,f),A(this,Vc,l||null),A(this,Mc,u),A(this,Yc,c||null),this.viewParameters={realScale:Fl.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const r=Kd.prototype,e=r=>t(r,ud).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 Lf(this,"_keyboardManager",new vc([[["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,ud).contains(e)&&!r.isEnterHandled}],[[" ","mac+ "],r.addNewEditorFromKeyboard,{checker:(r,{target:e})=>!(e instanceof HTMLButtonElement)&&t(r,ud).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,wc))||r.abort(),A(this,wc,null),this._signal=null,this._eventBus._off("editingaction",t(this,id)),this._eventBus._off("pagechanging",t(this,Ad)),this._eventBus._off("scalechanging",t(this,nd)),this._eventBus._off("rotationchanging",t(this,od));for(const r of t(this,Cc).values())r.destroy();t(this,Cc).clear(),t(this,Ec).clear(),t(this,Sc).clear(),A(this,yc,null),t(this,Qc).clear(),t(this,Wc).destroy(),null==(e=t(this,_c))||e.destroy(),null==(a=t(this,Dc))||a.hide(),A(this,Dc,null),t(this,Xc)&&(clearTimeout(t(this,Xc)),A(this,Xc,null)),t(this,ld)&&(clearTimeout(t(this,ld)),A(this,ld,null))}async mlGuess(r){var e;return(null==(e=t(this,Yc))?void 0:e.guess(r))||null}get hasMLManager(){return!!t(this,Yc)}get hcmFilter(){return Lf(this,"hcmFilter",t(this,Jc)?t(this,Gc).addHCMFilter(t(this,Jc).foreground,t(this,Jc).background):"none")}get direction(){return Lf(this,"direction",getComputedStyle(t(this,ud)).direction)}get highlightColors(){return Lf(this,"highlightColors",t(this,Vc)?new Map(t(this,Vc).split(",").map((r=>r.split("=").map((r=>r.trim()))))):null)}get highlightColorNames(){return Lf(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(r=>r.reverse()))):null)}setMainHighlightColorPicker(r){A(this,Lc,r)}editAltText(r){var e;null==(e=t(this,_c))||e.editAltText(this,r)}onPageChanging({pageNumber:r}){A(this,Ic,r-1)}focusMainContainer(){t(this,ud).focus()}findParent(r,e){for(const a of t(this,Cc).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,cd).classList.toggle("noUserSelect",r)}addShouldRescale(r){t(this,Sc).add(r)}removeShouldRescale(r){t(this,Sc).delete(r)}onScaleChanging({scale:r}){this.commitOrRemove(),this.viewParameters.realScale=r*Fl.PDF_TO_CSS_UNITS;for(const r of t(this,Sc))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,dd,hd).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(f);if(l){e.empty(),t(this,Hc)===Ks.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:Ks.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const e of t(this,Cc).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,Bc)&&!t(this,Bc).has(r.id)&&t(this,Bc).setValue(r.id,r)}blur(){if(this.isShiftKeyDown=!1,t(this,Nc)&&(A(this,Nc,!1),o(this,md,kd).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:r}=document;for(const e of t(this,Qc))if(e.div.contains(r)){A(this,Oc,[e,r]),e._focusEventsAllowed=!1;break}}focus(){if(!t(this,Oc))return;const[r,e]=t(this,Oc);A(this,Oc,null),e.addEventListener("focusin",(()=>{r._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}addEditListeners(){o(this,Zd,Wd).call(this),o(this,Fd,xd).call(this)}removeEditListeners(){o(this,Id,Rd).call(this),o(this,Sd,Md).call(this)}dragOver(r){for(const{type:e}of r.dataTransfer.items)for(const a of t(this,xc))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,xc))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,yc))||e.commitOrRemove(),!this.hasSelection)return;const a=[];for(const r of t(this,Qc)){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,xc))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 Tf(`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,Yd,Hd).call(this,e);o(this,$d,qd).call(this,r)},t=()=>{for(const e of r)e.remove()};this.addCommands({cmd:e,undo:t,mustExec:!0})}catch(r){Tf(`paste: "${r.message}".`)}}keydown(r){!this.isShiftKeyDown&&"Shift"===r.key&&(this.isShiftKeyDown=!0),t(this,Hc)!==Ks.NONE&&!this.isEditorHandlingKeyboard&&Kd._keyboardManager.exec(this,r)}keyup(r){this.isShiftKeyDown&&"Shift"===r.key&&(this.isShiftKeyDown=!1,t(this,Nc)&&(A(this,Nc,!1),o(this,md,kd).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,Ed,Cd).call(this),o(this,Fd,xd).call(this),o(this,Vd,Nd).call(this,{isEditing:t(this,Hc)!==Ks.NONE,isEmpty:o(this,Jd,zd).call(this),hasSomethingToUndo:t(this,Wc).hasSomethingToUndo(),hasSomethingToRedo:t(this,Wc).hasSomethingToRedo(),hasSelectedEditor:!1})):(o(this,_d,Bd).call(this),o(this,Sd,Md).call(this),o(this,Vd,Nd).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(r){if(!t(this,xc)){A(this,xc,r);for(const r of t(this,xc))o(this,Dd,Td).call(this,r.defaultPropertiesToUpdate)}}getId(){return t(this,Tc).id}get currentLayer(){return t(this,Cc).get(t(this,Ic))}getLayer(r){return t(this,Cc).get(r)}get currentPageIndex(){return t(this,Ic)}addLayer(r){t(this,Cc).set(r.pageIndex,r),t(this,Pc)?r.enable():r.disable()}removeLayer(r){t(this,Cc).delete(r.pageIndex)}updateMode(r,e=null,a=!1){if(t(this,Hc)!==r){if(A(this,Hc,r),r===Ks.NONE)return this.setEditingState(!1),void o(this,Od,Ld).call(this);this.setEditingState(!0),o(this,Pd,jd).call(this),this.unselectAll();for(const e of t(this,Cc).values())e.updateMode(r);if(!e&&a)return void this.addNewEditorFromKeyboard();if(e)for(const r of t(this,Ec).values())if(r.annotationElementId===e){this.setSelected(r),r.enterInEditMode();break}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(r){r!==t(this,Hc)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:r})}updateParams(r,e){var a;if(t(this,xc)){switch(r){case rf.CREATE:return void this.currentLayer.addNewEditor();case rf.HIGHLIGHT_DEFAULT_COLOR:null==(a=t(this,Lc))||a.updateColor(e);break;case rf.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(t(this,zc)||A(this,zc,new Map)).set(r,e),this.showAllEditors("highlight",e)}for(const a of t(this,Qc))a.updateParams(r,e);for(const a of t(this,xc))a.updateDefaultParams(r,e)}}showAllEditors(r,e,a=!1){var i;for(const a of t(this,Ec).values())a.editorType===r&&a.show(e);((null==(i=t(this,zc))?void 0:i.get(rf.HIGHLIGHT_SHOW_ALL))??!0)!==e&&o(this,Dd,Td).call(this,[[rf.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(r=!1){if(t(this,jc)!==r){A(this,jc,r);for(const e of t(this,Cc).values())r?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",r)}}getEditors(r){const e=[];for(const a of t(this,Ec).values())a.pageIndex===r&&e.push(a);return e}getEditor(r){return t(this,Ec).get(r)}addEditor(r){t(this,Ec).set(r.id,r)}removeEditor(r){var e;r.div.contains(document.activeElement)&&(t(this,Xc)&&clearTimeout(t(this,Xc)),A(this,Xc,setTimeout((()=>{this.focusMainContainer(),A(this,Xc,null)}),0))),t(this,Ec).delete(r.id),this.unselect(r),(!r.annotationElementId||!t(this,Rc).has(r.annotationElementId))&&(null==(e=t(this,Bc))||e.remove(r.id))}addDeletedAnnotationElement(r){t(this,Rc).add(r.annotationElementId),this.addChangedExistingAnnotation(r),r.deleted=!0}isDeletedAnnotationElement(r){return t(this,Rc).has(r)}removeDeletedAnnotationElement(r){t(this,Rc).delete(r.annotationElementId),this.removeChangedExistingAnnotation(r),r.deleted=!1}setActiveEditor(r){t(this,yc)!==r&&(A(this,yc,r),r&&o(this,Dd,Td).call(this,r.propertiesToUpdate))}updateUI(r){t(this,Qd,Ud)===r&&o(this,Dd,Td).call(this,r.propertiesToUpdate)}toggleSelected(r){if(t(this,Qc).has(r))return t(this,Qc).delete(r),r.unselect(),void o(this,Vd,Nd).call(this,{hasSelectedEditor:this.hasSelection});t(this,Qc).add(r),r.select(),o(this,Dd,Td).call(this,r.propertiesToUpdate),o(this,Vd,Nd).call(this,{hasSelectedEditor:!0})}setSelected(r){for(const e of t(this,Qc))e!==r&&e.unselect();t(this,Qc).clear(),t(this,Qc).add(r),r.select(),o(this,Dd,Td).call(this,r.propertiesToUpdate),o(this,Vd,Nd).call(this,{hasSelectedEditor:!0})}isSelected(r){return t(this,Qc).has(r)}get firstSelectedEditor(){return t(this,Qc).values().next().value}unselect(r){r.unselect(),t(this,Qc).delete(r),o(this,Vd,Nd).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==t(this,Qc).size}get isEnterHandled(){return 1===t(this,Qc).size&&this.firstSelectedEditor.isEnterHandled}undo(){t(this,Wc).undo(),o(this,Vd,Nd).call(this,{hasSomethingToUndo:t(this,Wc).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:o(this,Jd,zd).call(this)})}redo(){t(this,Wc).redo(),o(this,Vd,Nd).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:t(this,Wc).hasSomethingToRedo(),isEmpty:o(this,Jd,zd).call(this)})}addCommands(r){t(this,Wc).add(r),o(this,Vd,Nd).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:o(this,Jd,zd).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const r=[...t(this,Qc)];this.addCommands({cmd:()=>{for(const e of r)e.remove()},undo:()=>{for(const e of r)o(this,Yd,Hd).call(this,e)},mustExec:!0})}commitOrRemove(){var r;null==(r=t(this,yc))||r.commitOrRemove()}hasSomethingToControl(){return t(this,yc)||this.hasSelection}selectAll(){for(const r of t(this,Qc))r.commit();o(this,$d,qd).call(this,t(this,Ec).values())}unselectAll(){if((!t(this,yc)||(t(this,yc).commitOrRemove(),t(this,Hc)===Ks.NONE))&&this.hasSelection){for(const r of t(this,Qc))r.unselect();t(this,Qc).clear(),o(this,Vd,Nd).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(r,e,a=!1){if(a||this.commitOrRemove(),!this.hasSelection)return;t(this,fd)[0]+=r,t(this,fd)[1]+=e;const[i,n]=t(this,fd),o=[...t(this,Qc)];t(this,ld)&&clearTimeout(t(this,ld)),A(this,ld,setTimeout((()=>{A(this,ld,null),t(this,fd)[0]=t(this,fd)[1]=0,this.addCommands({cmd:()=>{for(const r of o)t(this,Ec).has(r.id)&&r.translateInPage(i,n)},undo:()=>{for(const r of o)t(this,Ec).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,Fc,new Map);for(const r of t(this,Qc))t(this,Fc).set(r,{savedX:r.x,savedY:r.y,savedPageIndex:r.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!t(this,Fc))return!1;this.disableUserSelect(!1);const r=t(this,Fc);A(this,Fc,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,Ec).has(r.id)){const A=t(this,Cc).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,Fc))for(const a of t(this,Fc).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,Qc).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(r){return t(this,yc)===r}getActive(){return t(this,yc)}getMode(){return t(this,Hc)}get imageManager(){return Lf(this,"imageManager",new lc)}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,Zc)||A(this,Zc,new Map)).set(r,e)}removeChangedExistingAnnotation({annotationElementId:r}){var e;null==(e=t(this,Zc))||e.delete(r)}renderAnnotationElement(r){var e;const a=null==(e=t(this,Zc))?void 0:e.get(r.data.id);if(!a)return;const i=t(this,Bc).getRawValue(a);i&&(t(this,Hc)===Ks.NONE&&!i.hasBeenModified||i.renderAnnotationElement(r))}};let rh=Kd;var eh,ah,th,ih,Ah,nh,oh,sh,fh;wc=new WeakMap,yc=new WeakMap,Ec=new WeakMap,Cc=new WeakMap,_c=new WeakMap,Bc=new WeakMap,Zc=new WeakMap,Wc=new WeakMap,Ic=new WeakMap,Rc=new WeakMap,Fc=new WeakMap,xc=new WeakMap,Sc=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,Oc=new WeakMap,Lc=new WeakMap,Yc=new WeakMap,Hc=new WeakMap,Qc=new WeakMap,Uc=new WeakMap,Jc=new WeakMap,zc=new WeakMap,$c=new WeakMap,qc=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 WeakMap,cd=new WeakMap,dd=new WeakSet,hd=function({anchorNode:r}){return r.nodeType===Node.TEXT_NODE?r.parentElement:r},bd=new WeakSet,gd=function(){const r=document.getSelection();if(!r||r.isCollapsed)return;const e=o(this,dd,hd).call(this,r).closest(".textLayer"),a=this.getSelectionBoxes(e);a&&(t(this,Dc)||A(this,Dc,new nc(this)),t(this,Dc).show(e,a,"ltr"===this.direction))},pd=new WeakSet,vd=function(){var r,e,a;const i=document.getSelection();if(!i||i.isCollapsed)return void(t(this,Uc)&&(null==(r=t(this,Dc))||r.hide(),A(this,Uc,null),o(this,Vd,Nd).call(this,{hasSelectedText:!1})));const{anchorNode:n}=i;if(n!==t(this,Uc))if(o(this,dd,hd).call(this,i).closest(".textLayer")){if(null==(a=t(this,Dc))||a.hide(),A(this,Uc,n),o(this,Vd,Nd).call(this,{hasSelectedText:!0}),(t(this,Hc)===Ks.HIGHLIGHT||t(this,Hc)===Ks.NONE)&&(t(this,Hc)===Ks.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),A(this,Nc,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,md,kd).call(this,"main_toolbar"))};window.addEventListener("pointerup",e,{signal:r}),window.addEventListener("blur",e,{signal:r})}}else t(this,Uc)&&(null==(e=t(this,Dc))||e.hide(),A(this,Uc,null),o(this,Vd,Nd).call(this,{hasSelectedText:!1}))},md=new WeakSet,kd=function(r=""){t(this,Hc)===Ks.HIGHLIGHT?this.highlightSelection(r):t(this,Mc)&&o(this,bd,gd).call(this)},wd=new WeakSet,yd=function(){document.addEventListener("selectionchange",o(this,pd,vd).bind(this),{signal:this._signal})},Ed=new WeakSet,Cd=function(){const r=this._signal;window.addEventListener("focus",t(this,qc),{signal:r}),window.addEventListener("blur",t(this,$c),{signal:r})},_d=new WeakSet,Bd=function(){window.removeEventListener("focus",t(this,qc)),window.removeEventListener("blur",t(this,$c))},Zd=new WeakSet,Wd=function(){const r=this._signal;window.addEventListener("keydown",t(this,ad),{signal:r}),window.addEventListener("keyup",t(this,td),{signal:r})},Id=new WeakSet,Rd=function(){window.removeEventListener("keydown",t(this,ad)),window.removeEventListener("keyup",t(this,td))},Fd=new WeakSet,xd=function(){const r=this._signal;document.addEventListener("copy",t(this,Kc),{signal:r}),document.addEventListener("cut",t(this,rd),{signal:r}),document.addEventListener("paste",t(this,ed),{signal:r})},Sd=new WeakSet,Md=function(){document.removeEventListener("copy",t(this,Kc)),document.removeEventListener("cut",t(this,rd)),document.removeEventListener("paste",t(this,ed))},Gd=new WeakSet,Xd=function(){const r=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:r}),document.addEventListener("drop",this.drop.bind(this),{signal:r})},Vd=new WeakSet,Nd=function(r){Object.entries(r).some((([r,e])=>t(this,sd)[r]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(t(this,sd),r)}),t(this,Hc)===Ks.HIGHLIGHT&&!1===r.hasSelectedEditor&&o(this,Dd,Td).call(this,[[rf.HIGHLIGHT_FREE,!0]]))},Dd=new WeakSet,Td=function(r){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:r})},Pd=new WeakSet,jd=function(){if(!t(this,Pc)){A(this,Pc,!0);for(const r of t(this,Cc).values())r.enable();for(const r of t(this,Ec).values())r.enable()}},Od=new WeakSet,Ld=function(){if(this.unselectAll(),t(this,Pc)){A(this,Pc,!1);for(const r of t(this,Cc).values())r.disable();for(const r of t(this,Ec).values())r.disable()}},Yd=new WeakSet,Hd=function(r){const e=t(this,Cc).get(r.pageIndex);e?e.addOrRebuild(r):(this.addEditor(r),this.addToAnnotationStorage(r))},Qd=new WeakSet,Ud=function(){let r=null;for(r of t(this,Qc));return r},Jd=new WeakSet,zd=function(){if(0===t(this,Ec).size)return!0;if(1===t(this,Ec).size)for(const r of t(this,Ec).values())return r.isEmpty();return!1},$d=new WeakSet,qd=function(r){for(const r of t(this,Qc))r.unselect();t(this,Qc).clear();for(const e of r)e.isEmpty()||(t(this,Qc).add(e),e.select());o(this,Vd,Nd).call(this,{hasSelectedEditor:this.hasSelection})},e(rh,"TRANSLATE_SMALL",1),e(rh,"TRANSLATE_BIG",10);const lh=class{constructor(r){i(this,sh),i(this,eh,""),i(this,ah,!1),i(this,th,null),i(this,ih,null),i(this,Ah,null),i(this,nh,!1),i(this,oh,null),A(this,oh,r)}static initialize(r){lh._l10nPromise||(lh._l10nPromise=r)}async render(){const r=A(this,th,document.createElement("button"));r.className="altText";const e=await lh._l10nPromise.get("pdfjs-editor-alt-text-button-label");r.textContent=e,r.setAttribute("aria-label",e),r.tabIndex="0";const a=t(this,oh)._uiManager._signal;r.addEventListener("contextmenu",vu,{signal:a}),r.addEventListener("pointerdown",(r=>r.stopPropagation()),{signal:a});const i=r=>{r.preventDefault(),t(this,oh)._uiManager.editAltText(t(this,oh))};return r.addEventListener("click",i,{capture:!0,signal:a}),r.addEventListener("keydown",(e=>{e.target===r&&"Enter"===e.key&&(A(this,nh,!0),i(e))}),{signal:a}),await o(this,sh,fh).call(this),r}finish(){t(this,th)&&(t(this,th).focus({focusVisible:t(this,nh)}),A(this,nh,!1))}isEmpty(){return!t(this,eh)&&!t(this,ah)}get data(){return{altText:t(this,eh),decorative:t(this,ah)}}set data({altText:r,decorative:e}){t(this,eh)===r&&t(this,ah)===e||(A(this,eh,r),A(this,ah,e),o(this,sh,fh).call(this))}toggle(r=!1){t(this,th)&&(!r&&t(this,Ah)&&(clearTimeout(t(this,Ah)),A(this,Ah,null)),t(this,th).disabled=!r)}destroy(){var r;null==(r=t(this,th))||r.remove(),A(this,th,null),A(this,ih,null)}};let uh=lh;var ch,dh,hh,bh,gh,ph,vh,mh,kh,wh,yh,Eh,Ch,_h,Bh,Zh,Wh,Ih,Rh,Fh,xh,Sh,Mh,Gh,Xh,Vh,Nh,Dh,Th,Ph,jh,Oh,Lh,Yh,Hh,Qh,Uh,Jh,zh,$h,qh,Kh,rb,eb,ab,tb,ib,Ab,nb,ob;eh=new WeakMap,ah=new WeakMap,th=new WeakMap,ih=new WeakMap,Ah=new WeakMap,nh=new WeakMap,oh=new WeakMap,sh=new WeakSet,fh=async function(){var r;const e=t(this,th);if(!e)return;if(!t(this,eh)&&!t(this,ah))return e.classList.remove("done"),void(null==(r=t(this,ih))||r.remove());e.classList.add("done"),lh._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then((r=>{e.setAttribute("aria-label",r)}));let a=t(this,ih);if(!a){A(this,ih,a=document.createElement("span")),a.className="tooltip",a.setAttribute("role","tooltip");const r=a.id=`alt-text-tooltip-${t(this,oh).id}`;e.setAttribute("aria-describedby",r);const i=100,n=t(this,oh)._uiManager._signal;n.addEventListener("abort",(()=>{clearTimeout(t(this,Ah)),A(this,Ah,null)}),{once:!0}),e.addEventListener("mouseenter",(()=>{A(this,Ah,setTimeout((()=>{A(this,Ah,null),t(this,ih).classList.add("show"),t(this,oh)._reportTelemetry({action:"alt_text_tooltip"})}),i))}),{signal:n}),e.addEventListener("mouseleave",(()=>{var r;t(this,Ah)&&(clearTimeout(t(this,Ah)),A(this,Ah,null)),null==(r=t(this,ih))||r.classList.remove("show")}),{signal:n})}a.innerText=t(this,ah)?await lh._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):t(this,eh),a.parentNode||e.append(a);const i=t(this,oh).getImageForAltText();null==i||i.setAttribute("aria-describedby",a.id)},e(uh,"_l10nPromise",null);const sb=class{constructor(r){i(this,Mh),i(this,Nh),i(this,Th),i(this,jh),i(this,Lh),i(this,Hh),i(this,Uh),i(this,zh),i(this,qh),i(this,rb),i(this,ab),i(this,ib),i(this,nb),i(this,ch,null),i(this,dh,null),i(this,hh,null),i(this,bh,!1),i(this,gh,!1),i(this,ph,null),i(this,vh,null),i(this,mh,this.focusin.bind(this)),i(this,kh,this.focusout.bind(this)),i(this,wh,null),i(this,yh,""),i(this,Eh,!1),i(this,Ch,null),i(this,_h,!1),i(this,Bh,!1),i(this,Zh,!1),i(this,Wh,null),i(this,Ih,0),i(this,Rh,0),i(this,Fh,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,xh,!1),i(this,Sh,sb._zIndex++),this.constructor===sb&&Pf("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=sb.prototype._resizeWithKeyboard,e=rh.TRANSLATE_SMALL,a=rh.TRANSLATE_BIG;return Lf(this,"_resizerKeyboardManager",new vc([[["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"],sb.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return Lf(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(r){const e=new lb({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(sb._l10nPromise||(sb._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)sb._l10nPromise.set(e,r.get(e));if(-1!==sb._borderLineWidth)return;const t=getComputedStyle(document.documentElement);sb._borderLineWidth=parseFloat(t.getPropertyValue("--outline-width"))||0}static updateDefaultParams(r,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(r){return!1}static paste(r,e){Pf("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return t(this,xh)}set _isDraggable(r){var e;A(this,xh,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,Sh)}setParent(r){null!==r?(this.pageIndex=r.pageIndex,this.pageDimensions=r.pageDimensions):o(this,nb,ob).call(this),this.parent=r}focusin(r){this._focusEventsAllowed&&(t(this,Eh)?A(this,Eh,!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,Mh,Gh).call(this,this.parentDimensions,r,e)}translateInPage(r,e){t(this,Ch)||A(this,Ch,[this.x,this.y]),o(this,Mh,Gh).call(this,this.pageDimensions,r,e),this.div.scrollIntoView({block:"nearest"})}drag(r,e){t(this,Ch)||A(this,Ch,[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,Ch)&&(t(this,Ch)[0]!==this.x||t(this,Ch)[1]!==this.y)}getBaseTranslation(){const[r,e]=this.parentDimensions,{_borderLineWidth:a}=sb,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=sb,Xh,Vh).call(a,r,e,this.parentRotation)}pageTranslationToScreen(r,e){var a;return o(a=sb,Xh,Vh).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 al.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,gh)||(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,gh)&&e.endsWith("%");if(i&&A)return;const[n,o]=this.parentDimensions;i||(r.width=`${(100*parseFloat(a)/n).toFixed(2)}%`),!t(this,gh)&&!A&&(r.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var r;null==(r=t(this,hh))||r.finish()}async addEditToolbar(){return t(this,wh)||t(this,Bh)||(A(this,wh,new Lu(this)),this.div.append(t(this,wh).render()),t(this,hh)&&t(this,wh).addAltTextButton(await t(this,hh).render())),t(this,wh)}removeEditToolbar(){var r;t(this,wh)&&(t(this,wh).remove(),A(this,wh,null),null==(r=t(this,hh))||r.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){t(this,hh)||(uh.initialize(sb._l10nPromise),A(this,hh,new uh(this)),t(this,ch)&&(t(this,hh).data=t(this,ch),A(this,ch,null)),await this.addEditToolbar())}get altTextData(){var r;return null==(r=t(this,hh))?void 0:r.data}set altTextData(r){t(this,hh)&&(t(this,hh).data=r)}hasAltText(){var r;return!(null!=(r=t(this,hh))&&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,bh)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const r=this._uiManager._signal;this.div.addEventListener("focusin",t(this,mh),{signal:r}),this.div.addEventListener("focusout",t(this,kh),{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),oc(this,this.div,["pointerdown"]),this.div}pointerdown(r){const{isMac:e}=al.platform;0!==r.button||r.ctrlKey&&e?r.preventDefault():(A(this,Eh,!0),this._isDraggable?o(this,zh,$h).call(this,r):o(this,Uh,Jh).call(this,r))}moveInDOM(){t(this,Wh)&&clearTimeout(t(this,Wh)),A(this,Wh,setTimeout((()=>{var r;A(this,Wh,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,Bh,!0)}disableEditMode(){A(this,Bh,!1)}isInEditMode(){return t(this,Bh)}shouldGetKeyboardEvents(){return t(this,Zh)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var r,e;const a=this._uiManager._signal;null==(r=this.div)||r.addEventListener("focusin",t(this,mh),{signal:a}),null==(e=this.div)||e.addEventListener("focusout",t(this,kh),{signal:a})}rotate(r){}serialize(r=!1,e=null){Pf("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,ch,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,mh)),this.div.removeEventListener("focusout",t(this,kh)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),t(this,Wh)&&(clearTimeout(t(this,Wh)),A(this,Wh,null)),o(this,nb,ob).call(this),this.removeEditToolbar(),t(this,Fh)){for(const r of t(this,Fh).values())clearTimeout(r);A(this,Fh,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(o(this,Th,Ph).call(this),t(this,ph).classList.remove("hidden"),oc(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,vh,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=t(this,ph).children;if(!t(this,dh)){A(this,dh,Array.from(e));const r=o(this,qh,Kh).bind(this),a=o(this,rb,eb).bind(this),i=this._uiManager._signal;for(const e of t(this,dh)){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,ab,tb).bind(this,t),{signal:i}),sb._l10nPromise.get(`pdfjs-editor-resizer-label-${t}`).then((r=>e.setAttribute("aria-label",r)))}}const a=t(this,dh)[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,dh).length/4);if(n!==i){if(n<i)for(let r=0;r<i-n;r++)t(this,ph).append(t(this,ph).firstChild);else if(n>i)for(let r=0;r<n-i;r++)t(this,ph).firstChild.before(t(this,ph).lastChild);let r=0;for(const a of e){const e=t(this,dh)[r++].getAttribute("data-resizer-name");sb._l10nPromise.get(`pdfjs-editor-resizer-label-${e}`).then((r=>a.setAttribute("aria-label",r)))}}o(this,ib,Ab).call(this,0),A(this,Zh,!0),t(this,ph).firstChild.focus({focusVisible:!0}),r.preventDefault(),r.stopImmediatePropagation()}_resizeWithKeyboard(r,e){t(this,Zh)&&o(this,Hh,Qh).call(this,t(this,yh),{movementX:r,movementY:e})}_stopResizingWithKeyboard(){o(this,nb,ob).call(this),this.div.focus()}select(){var r,e;this.makeResizable(),null==(r=this.div)||r.classList.add("selectedEditor"),t(this,wh)?null==(e=t(this,wh))||e.show():this.addEditToolbar().then((()=>{var r,e;null!=(r=this.div)&&r.classList.contains("selectedEditor")&&(null==(e=t(this,wh))||e.show())}))}unselect(){var r,e,a,i;null==(r=t(this,ph))||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,wh))||i.hide()}updateParams(r,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return t(this,_h)}set isEditing(r){A(this,_h,r),this.parent&&(r?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(r,e){A(this,gh,!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,Fh)||A(this,Fh,new Map);const{action:e}=r;let a=t(this,Fh).get(e);return a&&clearTimeout(a),a=setTimeout((()=>{this._reportTelemetry(r),t(this,Fh).delete(e),0===t(this,Fh).size&&A(this,Fh,null)}),sb._telemetryTimeout),void t(this,Fh).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,bh,!1)}disable(){this.div&&(this.div.tabIndex=-1),A(this,bh,!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 fb=sb;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,_h=new WeakMap,Bh=new WeakMap,Zh=new WeakMap,Wh=new WeakMap,Ih=new WeakMap,Rh=new WeakMap,Fh=new WeakMap,xh=new WeakMap,Sh=new WeakMap,Mh=new WeakSet,Gh=function([r,e],a,t){[a,t]=this.screenToPageTranslation(a,t),this.x+=a/r,this.y+=t/e,this.fixAndSetPosition()},Xh=new WeakSet,Vh=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]}},Nh=new WeakSet,Dh=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]}},Th=new WeakSet,Ph=function(){if(t(this,ph))return;A(this,ph,document.createElement("div")),t(this,ph).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,ph).append(r),r.classList.add("resizer",a),r.setAttribute("data-resizer-name",a),r.addEventListener("pointerdown",o(this,jh,Oh).bind(this,a),{signal:e}),r.addEventListener("contextmenu",vu,{signal:e}),r.tabIndex=-1}this.div.prepend(t(this,ph))},jh=new WeakSet,Oh=function(r,e){var a;e.preventDefault();const{isMac:i}=al.platform;if(0!==e.button||e.ctrlKey&&i)return;null==(a=t(this,hh))||a.toggle(!1);const A=o(this,Hh,Qh).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",vu,{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,hh))||r.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",g),window.removeEventListener("blur",g),window.removeEventListener("pointermove",A,f),window.removeEventListener("contextmenu",vu),this.parent.div.style.cursor=h,this.div.style.cursor=b,o(this,Lh,Yh).call(this,l,u,c,d)};window.addEventListener("pointerup",g,{signal:s}),window.addEventListener("blur",g,{signal:s})},Lh=new WeakSet,Yh=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})},Hh=new WeakSet,Qh=function(r,e){const[a,t]=this.parentDimensions,i=this.x,A=this.y,n=this.width,s=this.height,f=sb.MIN_SIZE/a,l=sb.MIN_SIZE/t,u=r=>Math.round(1e4*r)/1e4,c=o(this,Nh,Dh).call(this,this.rotation),d=(r,e)=>[c[0]*r+c[2]*e,c[1]*r+c[3]*e],h=o(this,Nh,Dh).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,_=1,[B,Z]=this.screenToPageTranslation(e.movementX,e.movementY);if([B,Z]=(W=B/a,I=Z/t,[h[0]*W+h[2]*I,h[1]*W+h[3]*I]),p){const r=Math.hypot(n,s);C=_=Math.max(Math.min(Math.hypot(k[0]-m[0]-B,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]-B)))/n:_=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*_);w=d(...g(R,F));const x=y-w[0],S=E-w[1];this.width=R,this.height=F,this.x=x,this.y=S,this.setDims(a*R,t*F),this.fixAndSetPosition()},Uh=new WeakSet,Jh=function(r){const{isMac:e}=al.platform;r.ctrlKey&&!e||r.shiftKey||r.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},zh=new WeakSet,$h=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,Ih,r.clientX),A(this,Rh,r.clientY),i=r=>{const{clientX:e,clientY:a}=r,[i,n]=this.screenToPageTranslation(e-t(this,Ih),a-t(this,Rh));A(this,Ih,e),A(this,Rh,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,Eh,!1),this._uiManager.endDragSession()||o(this,Uh,Jh).call(this,r)};window.addEventListener("pointerup",s,{signal:n}),window.addEventListener("blur",s,{signal:n})},qh=new WeakSet,Kh=function(r){sb._resizerKeyboardManager.exec(this,r)},rb=new WeakSet,eb=function(r){var e;t(this,Zh)&&(null==(e=r.relatedTarget)?void 0:e.parentNode)!==t(this,ph)&&o(this,nb,ob).call(this)},ab=new WeakSet,tb=function(r){A(this,yh,t(this,Zh)?r:"")},ib=new WeakSet,Ab=function(r){if(t(this,dh))for(const e of t(this,dh))e.tabIndex=r},nb=new WeakSet,ob=function(){if(A(this,Zh,!1),o(this,ib,Ab).call(this,-1),t(this,vh)){const{savedX:r,savedY:e,savedWidth:a,savedHeight:i}=t(this,vh);o(this,Lh,Yh).call(this,r,e,a,i),A(this,vh,null)}},i(fb,Xh),e(fb,"_borderLineWidth",-1),e(fb,"_colorManager",new kc),e(fb,"_zIndex",1),e(fb,"_telemetryTimeout",1e3);class lb extends fb{constructor(r){super(r),this.annotationElementId=r.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const ub=3285377520,cb=4294901760,db=65535;class hb{constructor(r){this.h1=r?4294967295&r:ub,this.h2=r?4294967295&r:ub}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&db,d=u&db;for(let r=0;r<t;r++)1&r?(n=A[r],n=n*l&cb|n*c&db,n=n<<15|n>>>17,n=n*u&cb|n*d&db,s^=n,s=s<<13|s>>>19,s=5*s+3864292196):(o=A[r],o=o*l&cb|o*c&db,o=o<<15|o>>>17,o=o*u&cb|o*d&db,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&cb|n*c&db,n=n<<15|n>>>17,n=n*u&cb|n*d&db,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&cb|36045*r&db,e=4283543511*e&cb|(2950163797*(e<<16|r>>>16)&cb)>>>16,r^=e>>>1,r=444984403*r&cb|60499*r&db,e=3301882366*e&cb|(3120437893*(e<<16|r>>>16)&cb)>>>16,r^=e>>>1,(r>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const bb=Object.freeze({map:null,hash:"",transfer:void 0});var gb,pb,vb,mb,kb,wb;class yb{constructor(){i(this,vb),i(this,gb,!1),i(this,pb,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(r,e){const a=t(this,pb).get(r);return void 0===a?e:Object.assign(e,a)}getRawValue(r){return t(this,pb).get(r)}remove(r){if(t(this,pb).delete(r),0===t(this,pb).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const r of t(this,pb).values())if(r instanceof fb)return;this.onAnnotationEditor(null)}}setValue(r,e){const a=t(this,pb).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,pb).set(r,e);i&&o(this,vb,mb).call(this),e instanceof fb&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(r){return t(this,pb).has(r)}getAll(){return t(this,pb).size>0?el(t(this,pb)):null}setAll(r){for(const[e,a]of Object.entries(r))this.setValue(e,a)}get size(){return t(this,pb).size}resetModified(){t(this,gb)&&(A(this,gb,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Eb(this)}get serializable(){if(0===t(this,pb).size)return bb;const r=new Map,e=new hb,a=[],i=Object.create(null);let A=!1;for(const[a,n]of t(this,pb)){const t=n instanceof fb?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}:bb}get editorStats(){let r=null;const e=new Map;for(const a of t(this,pb).values()){if(!(a instanceof fb))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}}gb=new WeakMap,pb=new WeakMap,vb=new WeakSet,mb=function(){t(this,gb)||(A(this,gb,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class Eb extends yb{constructor(r){super(),i(this,kb,void 0);const{map:e,hash:a,transfer:t}=r.serializable,n=structuredClone(e,t?{transfer:t}:null);A(this,kb,{map:n,hash:a,transfer:t})}get print(){Pf("Should not call PrintAnnotationStorage.print")}get serializable(){return t(this,kb)}}kb=new WeakMap;class Cb{constructor({ownerDocument:r=globalThis.document,styleElement:e=null}){i(this,wb,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,wb).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:r,_inspectFont:e}){if(r&&!t(this,wb).has(r.loadedName)){if(jf(!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,wb).add(a),null==e||e(r)}catch{Tf(`Cannot load system font: ${r.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(n)}return}Pf("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 Tf(`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 Lf(this,"isFontLoadingAPISupported",!(null==(r=this._document)||!r.fonts))}get isSyncFontLoadingSupported(){let r=!1;return(Ps||typeof navigator<"u"&&"string"==typeof(null==navigator?void 0:navigator.userAgent)&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(r=!0),Lf(this,"isSyncFontLoadingSupported",r)}_queueLoadingCallback(r){const{loadingRequests:e}=this,a={done:!1,complete:function(){for(jf(!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 Lf(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 Tf("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()}))}}wb=new WeakMap;class _b{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=Kf(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){Tf(`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 dl:{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 hl:{const[e,i]=a.slice(r,r+2);t.push((r=>r.moveTo(e,i))),r+=2}break;case bl:{const[e,i]=a.slice(r,r+2);t.push((r=>r.lineTo(e,i))),r+=2}break;case gl:{const[e,i,A,n]=a.slice(r,r+4);t.push((r=>r.quadraticCurveTo(e,i,A,n))),r+=4}break;case pl:t.push((r=>r.restore()));break;case vl:t.push((r=>r.save()));break;case ml:jf(2===t.length,"Scale command is only valid at the third position.");break;case kl:{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 wl:{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(Ps){var Bb=Promise.withResolvers(),Zb=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=>{Zb=r,Bb.resolve()}),(r=>{Tf(`loadPackages: ${r}`),Zb=new Map,Bb.resolve()}))}class Wb{static get promise(){return Bb.promise}static get(r){return null==Zb?void 0:Zb.get(r)}}const Ib=function(r){return Wb.get("fs").promises.readFile(r).then((r=>new Uint8Array(r)))};const Rb="Fill",Fb="Stroke",xb="Shading";function Sb(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 Mb{constructor(){this.constructor===Mb&&Pf("Cannot initialize BaseShadingPattern.")}getPattern(){Pf("Abstract method `getPattern` called.")}}class Gb extends Mb{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===Fb||t===Rb){const A=e.current.getClippedPathBoundingBox(t,Cu(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=sl.transform(a,[1,0,0,1,A[0],A[1]]),f.transform(...e.baseTransform),this.matrix&&f.transform(...this.matrix),Sb(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 Sb(r,this._bbox),i=this._createGradient(r);return i}}function Xb(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],_=f[o],B=f[o+1],Z=f[o+2],W=Math.round(h),I=Math.round(v);let R,F,x,S,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,x=k-(k-E)*e,S=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-_)*e,x=E-(E-B)*e,S=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-_)*e,X=k-(k-B)*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++]=x-(x-X)*e|0,l[i++]=S-(S-V)*e|0,l[i++]=255}}function Vb(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++)Xb(r,a,t[e],t[e+1],t[e+o],i[e],i[e+1],i[e+o]),Xb(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)Xb(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 Nb extends Mb{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)Vb(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(Sb(r,this._bbox),t===xb)i=sl.singularValueDecompose2dScale(Cu(r));else if(i=sl.singularValueDecompose2dScale(e.baseTransform),this.matrix){const r=sl.singularValueDecompose2dScale(this.matrix);i=[i[0]*r[0],i[1]*r[1]]}const A=this._createMeshCanvas(i,t===xb?null:this._background,e.cachedCanvases);return t!==xb&&(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 Db extends Mb{getPattern(){return"hotpink"}}const Tb=1,Pb=2,jb=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;Df("TilingType: "+n);const f=a[0],l=a[1],u=a[2],c=a[3],d=sl.singularValueDecompose2dScale(this.matrix),h=sl.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=Cu(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(jb.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(Cu(r.ctx),[e,a,t,i]),r.clip(),r.endPath()}setFillAndStrokeStyleToContext(r,e,a){const t=r.ctx,i=r.current;switch(e){case Tb:const r=this.ctx;t.fillStyle=r.fillStyle,t.strokeStyle=r.strokeStyle,i.fillColor=r.fillStyle,i.strokeColor=r.strokeStyle;break;case Pb:const A=sl.makeHexColor(a[0],a[1],a[2]);t.fillStyle=A,t.strokeStyle=A,i.fillColor=A,i.strokeColor=A;break;default:throw new $f(`Unsupported paint type: ${e}`)}}getPattern(r,e,a,t){let i=a;t!==xb&&(i=sl.transform(i,e.baseTransform),this.matrix&&(i=sl.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 Ob=jb;function Lb({src:r,srcPos:e=0,dest:a,width:t,height:i,nonBlackColor:A=4294967295,inverseDecode:n=!1}){const o=al.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(Ob,"MAX_PATTERN_SIZE",3e3);const Yb=16;class Hb{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 Qb(r,e,a,t,i,A,n,o,s,f){const[l,u,c,d,h,b]=Cu(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 Ub{constructor(r,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=js,this.textMatrixScale=1,this.fontMatrix=Os,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=af,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]=sl.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=sl.applyTransform(e,r),t=sl.applyTransform(e.slice(2),r),i=sl.applyTransform([e[0],e[3]],r),A=sl.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){sl.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=sl.bezierBoundingBox(e,a,t,i,A,n,o,s,f);f||this.updateRectMinMax(r,l)}getPathBoundingBox(r=Rb,e=null){const a=[this.minX,this.minY,this.maxX,this.maxY];if(r===Fb){e||Pf("Stroke bounding box must include transform.");const r=sl.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=sl.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=Rb,e=null){return sl.intersect(this.clipBox,this.getPathBoundingBox(r,e))}}function Jb(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%Yb,A=(a-i)/Yb,n=0===i?A:A+1,o=r.createImageData(t,Yb);let s,f=0;const l=e.data,u=o.data;let c,d,h,b;if(e.kind===ff.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=al.isLittleEndian?4278190080:255;for(c=0;c<n;c++){for(h=c<A?Yb: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*Yb)}}else if(e.kind===ff.RGBA_32BPP){for(d=0,b=t*Yb*4,c=0;c<A;c++)u.set(l.subarray(f,f+b)),f+=b,r.putImageData(o,0,d),d+=Yb;c<n&&(b=t*i*4,u.set(l.subarray(f,f+b)),r.putImageData(o,0,d))}else{if(e.kind!==ff.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(h=Yb,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*Yb)}}}function zb(r,e){if(e.bitmap)return void r.drawImage(e.bitmap,0,0);const a=e.height,t=e.width,i=a%Yb,A=(a-i)/Yb,n=0===i?A:A+1,o=r.createImageData(t,Yb);let s=0;const f=e.data,l=o.data;for(let e=0;e<n;e++){const a=e<A?Yb:i;({srcPos:s}=Lb({src:f,srcPos:s,dest:l,width:t,height:a,nonBlackColor:0})),r.putImageData(o,0,e*Yb)}}function $b(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 qb(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),!Ps){const{filter:e}=r;"none"!==e&&""!==e&&(r.filter="none")}}function Kb(r,e){if(e)return!0;const a=sl.singularValueDecompose2dScale(r);a[0]=Math.fround(a[0]),a[1]=Math.fround(a[1]);const t=Math.fround((globalThis.devicePixelRatio||1)*Fl.PDF_TO_CSS_UNITS);return a[0]<=t&&a[1]<=t}const rg=["butt","round","square"],eg=["miter","round","bevel"],ag={},tg={};var ig,Ag,ng,og;const sg=class{constructor(r,e,a,t,A,{optionalContentConfig:n,markedContentStack:o=null},s,f){i(this,ig),i(this,ng),this.ctx=r,this.current=new Ub(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 Hb(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(...Cu(this.compositeCtx))}this.ctx.save(),qb(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=Cu(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!==Gf.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,ig,Ag).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,ng,og).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=Cu(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),zb(l.context,r));let u=sl.transform(n,[1/a,0,0,-1/t,0,0]);u=sl.transform(u,[1,0,0,1,0,-t]);const[c,d,h,b]=sl.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,_u(m)),f=f.img,o&&A&&o.set(s,f)),m.imageSmoothingEnabled=Kb(Cu(m),r.interpolate),Qb(m,f,0,0,f.width,f.height,0,0,a,t),m.globalCompositeOperation="source-in";const y=sl.transform(_u(m),[1,0,0,1,-k,-w]);return m.fillStyle=A?i.getPattern(e,this,y,Rb):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=rg[r]}setLineJoin(r){this.ctx.lineJoin=eg[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(...Cu(this.suspendedCtx)),$b(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(),$b(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=sl.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=sl.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?($b(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(),$b(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=Cu(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 Gf.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 Gf.moveTo:o=e[c++],s=e[c++],t.moveTo(o,s),l||i.updatePathMinMax(f,o,s);break;case Gf.lineTo:o=e[c++],s=e[c++],t.lineTo(o,s),l||i.updatePathMinMax(f,o,s);break;case Gf.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 Gf.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 Gf.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 Gf.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,_u(e),Fb),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,_u(e),Rb),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=ag}eoClip(){this.pendingClip=tg}beginText(){this.current.textMatrix=js,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||Os,(0===i.fontMatrix[0]||0===i.fontMatrix[3])&&Tf("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&of,l=!!(o&sf),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===af||f===Af)&&i.fill(),(f===tf||f===Af)&&i.stroke(),i.restore()):((f===af||f===Af)&&i.fillText(r,e,a),(f===tf||f===Af)&&i.strokeText(r,e,a)),l&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Cu(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 Lf(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===af&&!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,_u(i),Rb);g=Cu(i),i.restore(),i.fillStyle=r}let p=e.lineWidth;const v=e.textMatrixScale;if(0===v||0===p){const r=e.textRenderingMode&of;(r===tf||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||Os,u=r.length;let c,d,h,b;if(!(a.textRenderingMode===nf)&&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=sl.applyTransform([d.width,0],l)[0]*i+A,e.translate(h,0),a.x+=h*f):Tf(`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||Cu(this.ctx),i={createCanvasGraphics:r=>new sg(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ob(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=sl.makeHexColor(r,e,a);this.ctx.strokeStyle=t,this.current.strokeColor=t}setFillRGBColor(r,e,a){const t=sl.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 Gb(r);case"Mesh":return new Nb(r);case"Dummy":return new Db}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,_u(e),xb);const t=_u(e);if(t){const{width:r,height:a}=e.canvas,[i,A,n,o]=sl.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(){Pf("Should not call beginInlineImage")}beginImageData(){Pf("Should not call beginImageData")}paintFormXObjectBegin(r,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),r&&this.transform(...r),this.baseTransform=Cu(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(Cu(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||Df("TODO: Support non-isolated groups."),r.knockout&&Tf("Knockout groups not supported.");const a=Cu(e);if(r.matrix&&e.transform(...r.matrix),!r.bbox)throw new Error("Bounding box is required.");let t=sl.getAxialAlignedBoundingBox(r.bbox,Cu(e));const i=[0,0,e.canvas.width,e.canvas.height];t=sl.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()),$b(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=Cu(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...r);const a=sl.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,ig,Ag).call(this),qb(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]=sl.singularValueDecompose2dScale(Cu(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),qb(this.ctx)}else qb(this.ctx),this.ctx.rect(e[0],e[1],t,A),this.ctx.clip(),this.endPath()}this.current=new Ub(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...a),this.transform(...t)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),o(this,ng,og).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=Cu(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=sl.transform(o,[e,a,t,i,A[r],A[r+1]]),[l,u]=sl.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();zb(f,this.getObject(r,i)),f.globalCompositeOperation="source-in",f.fillStyle=t?a.getPattern(f,this,_u(e),Rb):a,f.fillRect(0,0,A,n),f.restore(),e.save(),e.transform(...o),e.scale(1,-1),Qb(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):Tf("Dependent image isn't ready yet")}paintImageXObjectRepeat(r,e,a,t){if(!this.contentVisible)return;const i=this.getObject(r);if(!i)return void Tf("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(),!Ps){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;Jb(t,r),i=this.applyTransferMapsToCanvas(t)}const A=this._scaleImage(i,_u(t));t.imageSmoothingEnabled=Kb(Cu(t),r.interpolate),Qb(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;Jb(i,r),t=this.applyTransferMapsToCanvas(i)}for(const r of e)a.save(),a.transform(...r.transform),a.scale(1,-1),Qb(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===tg?a.clip("evenodd"):a.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),a.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const r=Cu(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 fg=sg;ig=new WeakSet,Ag=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)},ng=new WeakSet,og=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 Gf)void 0!==fg.prototype[r]&&(fg.prototype[Gf[r]]=fg.prototype[r]);var lg,ug;class cg{static get workerPort(){return t(this,lg)}static set workerPort(r){if(!(typeof Worker<"u"&&r instanceof Worker)&&null!==r)throw new Error("Invalid `workerPort` type.");A(this,lg,r)}static get workerSrc(){return t(this,ug)}static set workerSrc(r){if("string"!=typeof r)throw new Error("Invalid `workerSrc` type.");A(this,ug,r)}}lg=new WeakMap,ug=new WeakMap,i(cg,lg,null),i(cg,ug,"");const dg=1,hg=2,bg=1,gg=2,pg=3,vg=4,mg=5,kg=6,wg=7,yg=8;function Eg(r){switch(r instanceof Error||"object"==typeof r&&null!==r||Pf('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),r.name){case"AbortException":return new qf(r.message);case"MissingPDFException":return new Jf(r.message);case"PasswordException":return new Hf(r.message,r.code);case"UnexpectedResponseException":return new zf(r.message,r.status);case"UnknownErrorException":return new Qf(r.message,r.details);default:return new Qf(r.message,r.toString())}}var Cg,_g,Bg,Zg,Wg,Ig,Rg,Fg;class xg{constructor(r,e,a){i(this,Cg),i(this,Bg),i(this,Wg),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,Bg,Zg).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===dg)a.resolve(e.data);else{if(e.callback!==hg)throw new Error("Unexpected callback case");a.reject(Eg(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:dg,callbackId:e.callbackId,data:t})}),(function(t){a.postMessage({sourceName:r,targetName:i,callback:hg,callbackId:e.callbackId,reason:Eg(t)})}))}else e.streamId?o(this,Cg,_g).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:kg,streamId:i,desiredSize:r.desiredSize}),e.promise},cancel:r=>{jf(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:bg,streamId:i,reason:Eg(r)}),e.promise}},a)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}Cg=new WeakSet,_g=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:vg,streamId:e,chunk:r},n)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:a,targetName:t,stream:pg,streamId:e}),delete A.streamSinks[e])},error(r){jf(r instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:a,targetName:t,stream:mg,streamId:e,reason:Eg(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:yg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:yg,streamId:e,reason:Eg(r)})}))},Bg=new WeakSet,Zg=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 yg:r.success?A.startCall.resolve():A.startCall.reject(Eg(r.reason));break;case wg:r.success?A.pullCall.resolve():A.pullCall.reject(Eg(r.reason));break;case kg:if(!n){i.postMessage({sourceName:a,targetName:t,stream:wg,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:wg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:wg,streamId:e,reason:Eg(r)})}));break;case vg:if(jf(A,"enqueue should have stream controller"),A.isClosed)break;A.controller.enqueue(r.chunk);break;case pg:if(jf(A,"close should have stream controller"),A.isClosed)break;A.isClosed=!0,A.controller.close(),o(this,Wg,Ig).call(this,A,e);break;case mg:jf(A,"error should have stream controller"),A.controller.error(Eg(r.reason)),o(this,Wg,Ig).call(this,A,e);break;case gg:r.success?A.cancelCall.resolve():A.cancelCall.reject(Eg(r.reason)),o(this,Wg,Ig).call(this,A,e);break;case bg:if(!n)break;new Promise((function(e){var a;e(null==(a=n.onCancel)?void 0:a.call(n,Eg(r.reason)))})).then((function(){i.postMessage({sourceName:a,targetName:t,stream:gg,streamId:e,success:!0})}),(function(r){i.postMessage({sourceName:a,targetName:t,stream:gg,streamId:e,reason:Eg(r)})})),n.sinkCapability.reject(Eg(r.reason)),n.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Wg=new WeakSet,Ig=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 Sg{constructor({parsedData:r,rawData:e}){i(this,Rg,void 0),i(this,Fg,void 0),A(this,Rg,r),A(this,Fg,e)}getRaw(){return t(this,Fg)}get(r){return t(this,Rg).get(r)??null}getAll(){return el(t(this,Rg))}has(r){return t(this,Rg).has(r)}}Rg=new WeakMap,Fg=new WeakMap;const Mg=Symbol("INTERNAL");var Gg,Xg,Vg,Ng,Dg,Tg,Pg,jg,Og,Lg;class Yg{constructor(r,{name:e,intent:a,usage:t}){i(this,Gg,!1),i(this,Xg,!1),i(this,Vg,!1),i(this,Ng,!0),A(this,Gg,!!(r&Hs)),A(this,Xg,!!(r&Qs)),this.name=e,this.intent=a,this.usage=t}get visible(){if(t(this,Vg))return t(this,Ng);if(!t(this,Ng))return!1;const{print:r,view:e}=this.usage;return t(this,Gg)?"OFF"!==(null==e?void 0:e.viewState):!t(this,Xg)||"OFF"!==(null==r?void 0:r.printState)}_setVisible(r,e,a=!1){r!==Mg&&Pf("Internal method `_setVisible` called."),A(this,Vg,a),A(this,Ng,e)}}Gg=new WeakMap,Xg=new WeakMap,Vg=new WeakMap,Ng=new WeakMap;class Hg{constructor(r,e=Hs){if(i(this,Og),i(this,Dg,null),i(this,Tg,new Map),i(this,Pg,null),i(this,jg,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==r){this.name=r.name,this.creator=r.creator,A(this,jg,r.order);for(const a of r.groups)t(this,Tg).set(a.id,new Yg(e,a));if("OFF"===r.baseState)for(const r of t(this,Tg).values())r._setVisible(Mg,!1);for(const e of r.on)t(this,Tg).get(e)._setVisible(Mg,!0);for(const e of r.off)t(this,Tg).get(e)._setVisible(Mg,!1);A(this,Pg,this.getHash())}}isVisible(r){if(0===t(this,Tg).size)return!0;if(!r)return Df("Optional content group not defined."),!0;if("OCG"===r.type)return t(this,Tg).has(r.id)?t(this,Tg).get(r.id).visible:(Tf(`Optional content group not found: ${r.id}`),!0);if("OCMD"===r.type){if(r.expression)return o(this,Og,Lg).call(this,r.expression);if(!r.policy||"AnyOn"===r.policy){for(const e of r.ids){if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;if(t(this,Tg).get(e).visible)return!0}return!1}if("AllOn"===r.policy){for(const e of r.ids){if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;if(!t(this,Tg).get(e).visible)return!1}return!0}if("AnyOff"===r.policy){for(const e of r.ids){if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;if(!t(this,Tg).get(e).visible)return!0}return!1}if("AllOff"===r.policy){for(const e of r.ids){if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;if(t(this,Tg).get(e).visible)return!1}return!0}return Tf(`Unknown optional content policy ${r.policy}.`),!0}return Tf(`Unknown group type ${r.type}.`),!0}setVisibility(r,e=!0){const a=t(this,Tg).get(r);a?(a._setVisible(Mg,!!e,!0),A(this,Dg,null)):Tf(`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,Tg).get(e);if(r)switch(a){case"ON":r._setVisible(Mg,!0);break;case"OFF":r._setVisible(Mg,!1);break;case"Toggle":r._setVisible(Mg,!r.visible)}}A(this,Dg,null)}get hasInitialVisibility(){return null===t(this,Pg)||this.getHash()===t(this,Pg)}getOrder(){return t(this,Tg).size?t(this,jg)?t(this,jg).slice():[...t(this,Tg).keys()]:null}getGroups(){return t(this,Tg).size>0?el(t(this,Tg)):null}getGroup(r){return t(this,Tg).get(r)||null}getHash(){if(null!==t(this,Dg))return t(this,Dg);const r=new hb;for(const[e,a]of t(this,Tg))r.update(`${e}:${a.visible}`);return A(this,Dg,r.hexdigest())}}Dg=new WeakMap,Tg=new WeakMap,Pg=new WeakMap,jg=new WeakMap,Og=new WeakSet,Lg=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,Og,Lg).call(this,e);else{if(!t(this,Tg).has(e))return Tf(`Optional content group not found: ${e}`),!0;A=t(this,Tg).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 Qg{constructor(r,{disableRange:e=!1,disableStream:a=!1}){jf(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{jf(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(){jf(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const r=this._queuedChunks;return this._queuedChunks=null,new Ug(this,r,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=new Jg(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 Ug{constructor(r,e,a=!1,t=null){this._stream=r,this._done=a||!1,this._filename=du(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 Jg{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 zg({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 $g(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=rl(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(du(r))return r}return null}function qg(r,e){return 404===r||0===r&&e.startsWith("file:")?new Jf('Missing PDF "'+e+'".'):new zf(`Unexpected server response (${r}) while retrieving PDF "${e}".`,r)}function Kg(r){return 200===r||206===r}function rp(r,e,a){return{method:"GET",headers:r,signal:a.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function ep(r){const e=new Headers;for(const a in r){const t=r[a];void 0!==t&&e.append(a,t)}return e}function ap(r){return r instanceof Uint8Array?r.buffer:r instanceof ArrayBuffer?r:(Tf(`getArrayBuffer - unexpected data format: ${r}`),new Uint8Array(r).buffer)}class tp{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 jf(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ip(this),this._fullRequestReader}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=new Ap(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 ip{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=ep(this._stream.httpHeaders);const a=e.url;fetch(a,rp(this._headers,this._withCredentials,this._abortController)).then((r=>{if(!Kg(r.status))throw qg(r.status,a);this._reader=r.body.getReader(),this._headersCapability.resolve();const e=e=>r.headers.get(e),{allowRangeRequests:t,suggestedLength:i}=zg({getResponseHeader:e,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t,this._contentLength=i||this._contentLength,this._filename=$g(e),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new qf("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:ap(e),done:!1})}cancel(r){var e;null==(e=this._reader)||e.cancel(r),this._abortController.abort()}}class Ap{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=ep(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${a-1}`);const i=t.url;fetch(i,rp(this._headers,this._withCredentials,this._abortController)).then((r=>{if(!Kg(r.status))throw qg(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:ap(e),done:!1})}cancel(r){var e;null==(e=this._reader)||e.cancel(r),this._abortController.abort()}}class np{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:rl(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 op{constructor(r){this._source=r,this._manager=new np(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 jf(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new sp(this._manager,this._source),this._fullRequestReader}getRangeReader(r,e){const a=new fp(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 sp{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}=zg({getResponseHeader:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});t&&(this._isRangeSupported=!0),this._contentLength=i||this._contentLength,this._filename=$g(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=qg(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 fp{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=qg(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 lp=/^file:\/\/\/[a-zA-Z]:\//;class up{constructor(r){this.source=r,this.url=function(r){const e=Wb.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 jf(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new pp(this):new bp(this),this._fullRequestReader}getRangeReader(r,e){if(e<=this._progressiveDataLength)return null;const a=this.isFsUrl?new vp(this,r,e):new gp(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 cp{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 qf("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class dp{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 hp(r,e){return{protocol:r.protocol,auth:r.auth,host:r.hostname,port:r.port,path:r.path,method:"GET",headers:e}}class bp extends cp{constructor(r){super(r);const e=e=>{if(404===e.statusCode){const r=new Jf(`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}=zg({getResponseHeader:a,isHttp:r.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t,this._contentLength=i||this._contentLength,this._filename=$g(a)};if(this._request=null,"http:"===this._url.protocol){const a=Wb.get("http");this._request=a.request(hp(this._url,r.httpHeaders),e)}else{const a=Wb.get("https");this._request=a.request(hp(this._url,r.httpHeaders),e)}this._request.on("error",(r=>{this._storedError=r,this._headersCapability.reject(r)})),this._request.end()}}class gp extends dp{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 Jf(`Missing PDF "${this._url}".`);this._storedError=r}};if(this._request=null,"http:"===this._url.protocol){const r=Wb.get("http");this._request=r.request(hp(this._url,this._httpHeaders),t)}else{const r=Wb.get("https");this._request=r.request(hp(this._url,this._httpHeaders),t)}this._request.on("error",(r=>{this._storedError=r})),this._request.end()}}class pp extends cp{constructor(r){super(r);let e=decodeURIComponent(this._url.path);lp.test(this._url.href)&&(e=e.replace(/^\//,""));const a=Wb.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 Jf(`Missing PDF "${e}".`)),this._storedError=r,this._headersCapability.reject(r)}))}}class vp extends dp{constructor(r,e,a){super(r);let t=decodeURIComponent(this._url.path);lp.test(this._url.href)&&(t=t.replace(/^\//,""));const i=Wb.get("fs");this._setReadableStream(i.createReadStream(t,{start:e,end:a-1}))}}const mp=30;var kp,wp,yp,Ep,Cp,_p,Bp,Zp,Wp,Ip,Rp,Fp,xp,Sp,Mp,Gp,Xp,Vp,Np,Dp,Tp,Pp,jp,Op,Lp,Yp,Hp,Qp,Up,Jp,zp,$p,qp,Kp,rv,ev;let av=(Dp=class{constructor({textContentSource:r,container:e,viewport:a}){var n;if(i(this,Lp),i(this,Hp),i(this,Up),i(this,wp,Promise.withResolvers()),i(this,yp,null),i(this,Ep,!1),i(this,Cp,!(null==(kp=globalThis.FontInspector)||!kp.enabled)),i(this,_p,null),i(this,Bp,null),i(this,Zp,0),i(this,Wp,0),i(this,Ip,null),i(this,Rp,null),i(this,Fp,0),i(this,xp,0),i(this,Sp,Object.create(null)),i(this,Mp,[]),i(this,Gp,null),i(this,Xp,[]),i(this,Vp,new WeakMap),i(this,Np,null),r instanceof ReadableStream)A(this,Gp,r);else{if("object"!=typeof r)throw new Error('No "textContentSource" parameter specified.');A(this,Gp,new ReadableStream({start(e){e.enqueue(r),e.close()}}))}A(this,yp,A(this,Rp,e)),A(this,xp,a.scale*(globalThis.devicePixelRatio||1)),A(this,Fp,a.rotation),A(this,Bp,{prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null});const{pageWidth:s,pageHeight:f,pageX:l,pageY:u}=a.rawDims;A(this,Np,[1,0,0,-1,-l,u+f]),A(this,Wp,s),A(this,Zp,f),o(n=Dp,qp,Kp).call(n),Bu(e,a),t(this,wp).promise.catch((()=>{})).then((()=>{t(Dp,Op).delete(this),A(this,Bp,null),A(this,Sp,null)}))}render(){const r=()=>{t(this,Ip).read().then((({value:e,done:a})=>{a?t(this,wp).resolve():(t(this,_p)??A(this,_p,e.lang),Object.assign(t(this,Sp),e.styles),o(this,Lp,Yp).call(this,e.items),r())}),t(this,wp).reject)};return A(this,Ip,t(this,Gp).getReader()),t(Dp,Op).add(this),r(),t(this,wp).promise}update({viewport:r,onBefore:e=null}){var a;const i=r.scale*(globalThis.devicePixelRatio||1),n=r.rotation;if(n!==t(this,Fp)&&(null==e||e(),A(this,Fp,n),Bu(t(this,Rp),{rotation:n})),i!==t(this,xp)){null==e||e(),A(this,xp,i);const r={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:o(a=Dp,zp,$p).call(a,t(this,_p))};for(const e of t(this,Xp))r.properties=t(this,Vp).get(e),r.div=e,o(this,Up,Jp).call(this,r)}}cancel(){var r;const e=new qf("TextLayer task cancelled.");null==(r=t(this,Ip))||r.cancel(e).catch((()=>{})),A(this,Ip,null),t(this,wp).reject(e)}get textDivs(){return t(this,Xp)}get textContentItemsStr(){return t(this,Mp)}static cleanup(){if(!(t(this,Op).size>0)){t(this,Tp).clear();for(const{canvas:r}of t(this,Pp).values())r.remove();t(this,Pp).clear()}}},wp=new WeakMap,yp=new WeakMap,Ep=new WeakMap,Cp=new WeakMap,_p=new WeakMap,Bp=new WeakMap,Zp=new WeakMap,Wp=new WeakMap,Ip=new WeakMap,Rp=new WeakMap,Fp=new WeakMap,xp=new WeakMap,Sp=new WeakMap,Mp=new WeakMap,Gp=new WeakMap,Xp=new WeakMap,Vp=new WeakMap,Np=new WeakMap,Tp=new WeakMap,Pp=new WeakMap,jp=new WeakMap,Op=new WeakMap,Lp=new WeakSet,Yp=function(r){var e,a;if(t(this,Ep))return;(a=t(this,Bp)).ctx??(a.ctx=o(e=Dp,zp,$p).call(e,t(this,_p)));const i=t(this,Xp),n=t(this,Mp);for(const e of r){if(i.length>1e5)return Tf("Ignoring additional textDivs for performance reasons."),void A(this,Ep,!0);if(void 0!==e.str)n.push(e.str),o(this,Hp,Qp).call(this,e);else if("beginMarkedContentProps"===e.type||"beginMarkedContent"===e.type){const r=t(this,yp);A(this,yp,document.createElement("span")),t(this,yp).classList.add("markedContent"),null!==e.id&&t(this,yp).setAttribute("id",`${e.id}`),r.append(t(this,yp))}else"endMarkedContent"===e.type&&A(this,yp,t(this,yp).parentNode)}},Hp=new WeakSet,Qp=function(r){var e;const a=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==r.str,hasEOL:r.hasEOL,fontSize:0};t(this,Xp).push(a);const A=sl.transform(t(this,Np),r.transform);let n=Math.atan2(A[1],A[0]);const s=t(this,Sp)[r.fontName];s.vertical&&(n+=Math.PI/2);const f=t(this,Cp)&&s.fontSubstitution||s.fontFamily,l=Math.hypot(A[2],A[3]),u=l*o(e=Dp,rv,ev).call(e,f,t(this,_p));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,yp)===t(this,Rp)?(b.left=`${(100*c/t(this,Wp)).toFixed(2)}%`,b.top=`${(100*d/t(this,Zp)).toFixed(2)}%`):(b.left=`${h}${c.toFixed(2)}px)`,b.top=`${h}${d.toFixed(2)}px)`),b.fontSize=`${h}${(t(Dp,jp)*l).toFixed(2)}px)`,b.fontFamily=f,i.fontSize=l,a.setAttribute("role","presentation"),a.textContent=r.str,a.dir=r.dir,t(this,Cp)&&(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,Vp).set(a,i),t(this,Bp).div=a,t(this,Bp).properties=i,o(this,Up,Jp).call(this,t(this,Bp)),i.hasText&&t(this,yp).append(a),i.hasEOL){const r=document.createElement("br");r.setAttribute("role","presentation"),t(this,yp).append(r)}},Up=new WeakSet,Jp=function(r){const{div:e,properties:a,ctx:i,prevFontSize:A,prevFontFamily:n}=r,{style:o}=e;let s="";if(t(Dp,jp)>1&&(s=`scale(${1/t(Dp,jp)})`),0!==a.canvasWidth&&a.hasText){const{fontFamily:f}=o,{canvasWidth:l,fontSize:u}=a;(A!==u||n!==f)&&(i.font=`${u*t(this,xp)}px ${f}`,r.prevFontSize=u,r.prevFontFamily=f);const{width:c}=i.measureText(e.textContent);c>0&&(s=`scaleX(${l*t(this,xp)/c}) ${s}`)}0!==a.angle&&(s=`rotate(${a.angle}deg) ${s}`),s.length>0&&(o.transform=s)},zp=new WeakSet,$p=function(r=null){let e=t(this,Pp).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,Pp).set(r,e)}return e},qp=new WeakSet,Kp=function(){if(null!==t(this,jp))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,jp,r.getBoundingClientRect().height),r.remove()},rv=new WeakSet,ev=function(r,e){const a=t(this,Tp).get(r);if(a)return a;const i=o(this,zp,$p).call(this,e),A=i.font;i.canvas.width=i.canvas.height=mp,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,Tp).set(r,e),i.canvas.width=i.canvas.height=0,i.font=A,e}i.strokeStyle="red",i.clearRect(0,0,mp,mp),i.strokeText("g",0,0);let l=i.getImageData(0,0,mp,mp).data;f=0;for(let r=l.length-1-3;r>=0;r-=4)if(l[r]>0){f=Math.ceil(r/4/mp);break}i.clearRect(0,0,mp,mp),i.strokeText("A",0,mp),l=i.getImageData(0,0,mp,mp).data,s=0;for(let r=0,e=l.length;r<e;r+=4)if(l[r]>0){s=mp-Math.floor(r/4/mp);break}i.canvas.width=i.canvas.height=0,i.font=A;const u=s?s/(s+f):.8;return t(this,Tp).set(r,u),u},i(Dp,zp),i(Dp,qp),i(Dp,rv),i(Dp,Tp,new Map),i(Dp,Pp,new Map),i(Dp,jp,null),i(Dp,Op,new Set),Dp);function tv(){mu("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:r,container:e,viewport:a,...t}=arguments[0],i=Object.keys(t);i.length>0&&Tf("Ignoring `renderTextLayer` parameters: "+i.join(", "));const A=new av({textContentSource:r,container:e,viewport:a}),{textDivs:n,textContentItemsStr:o}=A;return{promise:A.render(),textDivs:n,textContentItemsStr:o}}function iv(){mu("`updateTextLayer`, please use `TextLayer` instead.")}class Av{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(!Av.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 nv=65536,ov=Ps?class extends _l{_createCanvas(r,e){return Wb.get("canvas").createCanvas(r,e)}}:class extends _l{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}},sv=Ps?class extends Bl{_fetchData(r,e){return Ib(r).then((r=>({cMapData:r,compressionType:e})))}}:ou,fv=Ps?class extends yl{}:class extends yl{constructor({docId:r,ownerDocument:e=globalThis.document}={}){super(),i(this,Nl),i(this,Tl),i(this,jl),i(this,Ll),i(this,Hl),i(this,Ul),i(this,zl),i(this,ql),i(this,ru),i(this,au),i(this,iu),i(this,xl,void 0),i(this,Sl,void 0),i(this,Ml,void 0),i(this,Gl,void 0),i(this,Xl,void 0),i(this,Vl,0),A(this,Ml,r),A(this,Gl,e)}addFilter(r){if(!r)return"none";let e=t(this,Nl,Dl).get(r);if(e)return e;const[a,i,A]=o(this,Ll,Yl).call(this,r),s=1===r.length?a:`${a}${i}${A}`;if(e=t(this,Nl,Dl).get(s),e)return t(this,Nl,Dl).set(r,e),e;const f=`g_${t(this,Ml)}_transfer_map_${n(this,Vl)._++}`,l=`url(#${f})`;t(this,Nl,Dl).set(r,l),t(this,Nl,Dl).set(s,l);const u=o(this,zl,$l).call(this,f);return o(this,ru,eu).call(this,a,i,A,u),l}addHCMFilter(r,e){var a;const i=`${r}-${e}`,A="base";let n=t(this,Tl,Pl).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,Tl,Pl).set(A,n)),!r||!e))return n.url;const s=o(this,iu,Au).call(this,r);r=sl.makeHexColor(...s);const f=o(this,iu,Au).call(this,e);if(e=sl.makeHexColor(...f),t(this,jl,Ol).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,Ml)}_hcm_filter`,d=n.filter=o(this,zl,$l).call(this,c);o(this,ru,eu).call(this,u,u,u,d),o(this,Ul,Jl).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,ru,eu).call(this,h(0,5),h(1,5),h(2,5),d),n.url=`url(#${c})`,n.url}addAlphaFilter(r){let e=t(this,Nl,Dl).get(r);if(e)return e;const[a]=o(this,Ll,Yl).call(this,[r]),i=`alpha_${a}`;if(e=t(this,Nl,Dl).get(i),e)return t(this,Nl,Dl).set(r,e),e;const A=`g_${t(this,Ml)}_alpha_map_${n(this,Vl)._++}`,s=`url(#${A})`;t(this,Nl,Dl).set(r,s),t(this,Nl,Dl).set(i,s);const f=o(this,zl,$l).call(this,A);return o(this,au,tu).call(this,a,f),s}addLuminosityFilter(r){let e,a,i=t(this,Nl,Dl).get(r||"luminosity");if(i)return i;if(r?([e]=o(this,Ll,Yl).call(this,[r]),a=`luminosity_${e}`):a="luminosity",i=t(this,Nl,Dl).get(a),i)return t(this,Nl,Dl).set(r,i),i;const A=`g_${t(this,Ml)}_luminosity_map_${n(this,Vl)._++}`,s=`url(#${A})`;t(this,Nl,Dl).set(r,s),t(this,Nl,Dl).set(a,s);const f=o(this,zl,$l).call(this,A);return o(this,Hl,Ql).call(this,f),r&&o(this,au,tu).call(this,e,f),s}addHighlightHCMFilter(r,e,a,i,A){var n;const s=`${e}-${a}-${i}-${A}`;let f=t(this,Tl,Pl).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,Tl,Pl).set(r,f)),!e||!a))return f.url;const[l,u]=[e,a].map(o(this,iu,Au).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,iu,Au).bind(this));d<c&&([c,d,h,b]=[d,c,b,h]),t(this,jl,Ol).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,Ml)}_hcm_${r}_filter`,v=f.filter=o(this,zl,$l).call(this,p);return o(this,Ul,Jl).call(this,v),o(this,ru,eu).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,Tl,Pl).size||(t(this,Sl)&&(t(this,Sl).parentNode.parentNode.remove(),A(this,Sl,null)),t(this,xl)&&(t(this,xl).clear(),A(this,xl,null)),A(this,Vl,0))}},lv=Ps?class extends Zl{_fetchData(r){return Ib(r)}}:su;function uv(r={}){"string"==typeof r||r instanceof URL?r={url:r}:(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});const e=new bv,{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(Ps&&"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(Ps&&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 rl(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 gv?r.range:null,f=Number.isInteger(r.rangeChunkSize)&&r.rangeChunkSize>0?r.rangeChunkSize:nv;let l=r.worker instanceof Gv?r.worker:null;const u=r.verbosity,c="string"!=typeof r.docBaseUrl||cu(r.docBaseUrl)?null:r.docBaseUrl,d="string"==typeof r.cMapUrl?r.cMapUrl:null,h=!1!==r.cMapPacked,b=r.CMapReaderFactory||sv,g="string"==typeof r.standardFontDataUrl?r.standardFontDataUrl:null,p=r.StandardFontDataFactory||lv,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:!Ps,y=Number.isInteger(r.canvasMaxAreaInBytes)?r.canvasMaxAreaInBytes:-1,E="boolean"==typeof r.disableFontFace?r.disableFontFace:Ps,C=!0===r.fontExtraProperties,_=!0===r.enableXfa,B=r.ownerDocument||globalThis.document,Z=!0===r.disableRange,W=!0===r.disableStream,I=!0===r.disableAutoFetch,R=!0===r.pdfBug,F=!0===r.enableHWA,x=s?s.length:r.length??NaN,S="boolean"==typeof r.useSystemFonts?r.useSystemFonts:!Ps&&!E,M="boolean"==typeof r.useWorkerFetch?r.useWorkerFetch:b===ou&&p===su&&d&&g&&pu(d,document.baseURI)&&pu(g,document.baseURI),G=r.canvasFactory||new ov({ownerDocument:B,enableHWA:F}),X=r.filterFactory||new fv({docId:a,ownerDocument:B});!function(r){Number.isInteger(r)&&(Vf=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:cg.workerPort};l=r.port?Gv.fromPort(r):new Gv(r),e._worker=l}const N={docId:a,apiVersion:"4.4.168",data:i,password:o,disableAutoFetch:I,rangeChunkSize:f,length:x,docBaseUrl:c,enableXfa:_,evaluatorOptions:{maxImageSize:m,disableFontFace:E,ignoreErrors:v,isEvalSupported:k,isOffscreenCanvasSupported:w,canvasMaxAreaInBytes:y,fontExtraProperties:C,useSystemFonts:S,cMapUrl:M?d:null,standardFontDataUrl:M?g:null}},D={disableFontFace:E,fontExtraProperties:C,ownerDocument:B,pdfBug:R,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:_}};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 Qg(s,{disableRange:Z,disableStream:W});else if(!i){if(!t)throw new Error("getDocument - no `url` parameter provided.");u={url:t,length:x,httpHeaders:A,withCredentials:n,rangeChunkSize:f,disableRange:Z,disableStream:W},o=Ps?typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&pu(u.url)?new tp(u):new up(u):pu(u.url)?new tp(u):new op(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 xg(a,r,l.port),i=new Ov(t,e,o,D,V);e._transport=i,t.send("Ready",null)}))})).catch(e._capability.reject),e}function cv(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 dv;const hv=class{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+n(hv,dv)._++,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 bv=hv;dv=new WeakMap,i(bv,dv,0);let gv=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){Pf("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class pv{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 Lf(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 vv,mv,kv,wv,yv,Ev,Cv,_v;class Bv{constructor(r,e,a,t=!1){i(this,kv),i(this,yv),i(this,vv,null),i(this,mv,!1),this._pageIndex=r,this._pageInfo=e,this._transport=a,this._stats=t?new gu:null,this._pdfBug=t,this.commonObjs=a.commonObjs,this.objs=new $v,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 lu({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 Lf(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=qs.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,mv,!1),o(this,yv,Ev).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&Qs);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,mv,!0),o(this,kv,wv).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 rm({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=qs.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=>Av.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,mv,!1),o(this,yv,Ev).call(this),Promise.all(r)}cleanup(r=!1){A(this,mv,!0);const e=o(this,kv,wv).call(this,!1);return r&&e&&this._stats&&(this._stats=new gu),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,kv,wv).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,kv,wv).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 uu){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 qf(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}}vv=new WeakMap,mv=new WeakMap,kv=new WeakSet,wv=function(r=!1){if(o(this,yv,Ev).call(this),!t(this,mv)||this.destroyed)return!1;if(r)return A(this,vv,setTimeout((()=>{A(this,vv,null),o(this,kv,wv).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,mv,!1),!0},yv=new WeakSet,Ev=function(){t(this,vv)&&(clearTimeout(t(this,vv)),A(this,vv,null))};class Zv{constructor(){i(this,Cv,new Set),i(this,_v,Promise.resolve())}postMessage(r,e){const a={data:structuredClone(r,e?{transfer:e}:null)};t(this,_v).then((()=>{for(const r of t(this,Cv))r.call(this,a)}))}addEventListener(r,e){t(this,Cv).add(e)}removeEventListener(r,e){t(this,Cv).delete(e)}terminate(){t(this,Cv).clear()}}Cv=new WeakMap,_v=new WeakMap;const Wv={isWorkerDisabled:!1,fakeWorkerId:0};var Iv,Rv,Fv,xv,Sv;Ps&&(Wv.isWorkerDisabled=!0,cg.workerSrc||(cg.workerSrc="./pdf.worker.mjs")),Wv.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},Wv.createCDNWrapper=function(r){const e=`await import("${r}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};const Mv=class{constructor({name:r=null,port:e=null,verbosity:a=Nf()}={}){var n;if(i(this,Rv),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(Mv,Iv))&&n.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(t(Mv,Iv)||A(Mv,Iv,new WeakMap)).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return Ps?Promise.all([Wb.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 xg("main","worker",r),this._messageHandler.on("ready",(function(){})),o(this,Rv,Fv).call(this)}_initialize(){if(Wv.isWorkerDisabled||t(Mv,xv,Sv))return void this._setupFakeWorker();let{workerSrc:r}=Mv;try{Wv.isSameOrigin(window.location.href,r)||(r=Wv.createCDNWrapper(new URL(r,window.location).href));const e=new Worker(r,{type:"module"}),a=new xg("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,Rv,Fv).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{Df("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Wv.isWorkerDisabled||(Tf("Setting up fake worker."),Wv.isWorkerDisabled=!0),Mv._setupFakeWorkerGlobal.then((r=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new Zv;this._port=e;const a="fake"+Wv.fakeWorkerId++,t=new xg(a+"_worker",a,e);r.setup(t,e),this._messageHandler=new xg(a,a+"_worker",e),o(this,Rv,Fv).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(Mv,Iv))||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,Iv))?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 Mv(r)}static get workerSrc(){if(cg.workerSrc)return cg.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Lf(this,"_setupFakeWorkerGlobal",(async()=>t(this,xv,Sv)?t(this,xv,Sv):(await import(this.workerSrc)).WorkerMessageHandler)())}};let Gv=Mv;var Xv,Vv,Nv,Dv,Tv,Pv,jv;Iv=new WeakMap,Rv=new WeakSet,Fv=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},xv=new WeakSet,Sv=function(){var r;try{return(null==(r=globalThis.pdfjsWorker)?void 0:r.WorkerMessageHandler)||null}catch{return null}},i(Gv,xv),i(Gv,Iv,void 0);class Ov{constructor(r,e,a,t,A){i(this,Pv),i(this,Xv,new Map),i(this,Vv,new Map),i(this,Nv,new Map),i(this,Dv,new Map),i(this,Tv,null),this.messageHandler=r,this.loadingTask=e,this.commonObjs=new $v,this.fontLoader=new Cb({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 Lf(this,"annotationStorage",new yb)}getRenderingIntent(r,e=qs.ENABLE,a=null,t=!1){let i=Hs,A=bb;switch(r){case"any":i=Ys;break;case"display":break;case"print":i=Qs;break;default:Tf(`getRenderingIntent - invalid intent: ${r}`)}switch(e){case qs.DISABLE:i+=zs;break;case qs.ENABLE:break;case qs.ENABLE_FORMS:i+=Us;break;case qs.ENABLE_STORAGE:i+=Js,A=(i&Qs&&a instanceof Eb?a:this.annotationStorage).serializable;break;default:Tf(`getRenderingIntent - invalid annotationMode: ${e}`)}return t&&(i+=$s),{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,Tv))||r.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const r of t(this,Vv).values())e.push(r._destroy());t(this,Vv).clear(),t(this,Nv).clear(),t(this,Dv).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,Xv).clear(),this.filterFactory.destroy(),av.cleanup(),null==(r=this._networkStream)||r.cancelAllRequests(new qf("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)=>{jf(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():(jf(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)=>{jf(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():(jf(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 pv(r,this))})),r.on("DocException",(function(r){let a;switch(r.name){case"PasswordException":a=new Hf(r.message,r.code);break;case"InvalidPDFException":a=new Uf(r.message);break;case"MissingPDFException":a=new Jf(r.message);break;case"UnexpectedResponseException":a=new zf(r.message,r.status);break;case"UnknownErrorException":a=new Qf(r.message,r.details);break;default:Pf("DocException - expected a valid Error.")}e._capability.reject(a)})),r.on("PasswordRequest",(r=>{if(A(this,Tv,Promise.withResolvers()),e.onPassword){const a=r=>{r instanceof Error?t(this,Tv).reject(r):t(this,Tv).resolve({password:r})};try{e.onPassword(a,r.code)}catch(r){t(this,Tv).reject(r)}}else t(this,Tv).reject(new Hf(r.message,r.code));return t(this,Tv).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,Vv).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;Tf(`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 _b(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;jf(u,"The imageRef must be defined.");for(const r of t(this,Vv).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,Vv).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&&Tf("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,Nv).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,Dv).set(a.refStr,r);const i=new Bv(e,a,this,this._params.pdfBug);return t(this,Vv).set(e,i),i}));return t(this,Nv).set(e,i),i}getPageIndex(r){return cv(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,Pv,jv).call(this,"GetFieldObjects")}hasJSActions(){return o(this,Pv,jv).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,Pv,jv).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,Pv,jv).call(this,"GetOptionalContentConfig").then((e=>new Hg(e,r)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const r="GetMetadata",e=t(this,Xv).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 Sg(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,Xv).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,Vv).values())if(!r.cleanup())throw new Error(`startCleanup: Page ${r.pageNumber} is currently rendering.`);this.commonObjs.clear(),r||this.fontLoader.clear(),t(this,Xv).clear(),this.filterFactory.destroy(!0),av.cleanup()}}cachedPageNumber(r){if(!cv(r))return null;const e=0===r.gen?`${r.num}R`:`${r.num}R${r.gen}`;return t(this,Dv).get(e)??null}}Xv=new WeakMap,Vv=new WeakMap,Nv=new WeakMap,Dv=new WeakMap,Tv=new WeakMap,Pv=new WeakSet,jv=function(r,e=null){const a=t(this,Xv).get(r);if(a)return a;const i=this.messageHandler.sendWithPromise(r,e);return t(this,Xv).set(r,i),i};const Lv=Symbol("INITIAL_DATA");var Yv,Hv,Qv,Uv,Jv,zv;class $v{constructor(){i(this,Hv),i(this,Yv,Object.create(null))}get(r,e=null){if(e){const a=o(this,Hv,Qv).call(this,r);return a.promise.then((()=>e(a.data))),null}const a=t(this,Yv)[r];if(!a||a.data===Lv)throw new Error(`Requesting object that isn't resolved yet ${r}.`);return a.data}has(r){const e=t(this,Yv)[r];return!!e&&e.data!==Lv}resolve(r,e=null){const a=o(this,Hv,Qv).call(this,r);a.data=e,a.resolve()}clear(){var r;for(const e in t(this,Yv)){const{data:a}=t(this,Yv)[e];null==(r=null==a?void 0:a.bitmap)||r.close()}A(this,Yv,Object.create(null))}*[Symbol.iterator](){for(const r in t(this,Yv)){const{data:e}=t(this,Yv)[r];e!==Lv&&(yield[r,e])}}}Yv=new WeakMap,Hv=new WeakSet,Qv=function(r){var e;return(e=t(this,Yv))[r]||(e[r]={...Promise.withResolvers(),data:Lv})};class qv{constructor(r){i(this,Uv,null),A(this,Uv,r),this.onContinue=null}get promise(){return t(this,Uv).capability.promise}cancel(r=0){t(this,Uv).cancel(null,r)}get separateAnnots(){const{separateAnnots:r}=t(this,Uv).operatorList;if(!r)return!1;const{annotationCanvasMap:e}=t(this,Uv);return r.form||r.canvas&&(null==e?void 0:e.size)>0}}Uv=new WeakMap;const Kv=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,Jv,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 qv(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(Kv,zv).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(Kv,zv).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 fg(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,Jv)&&(window.cancelAnimationFrame(t(this,Jv)),A(this,Jv,null)),t(Kv,zv).delete(this._canvas),this.callback(r||new uu(`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,Jv,window.requestAnimationFrame((()=>{A(this,Jv,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(Kv,zv).delete(this._canvas),this.callback())))}};let rm=Kv;Jv=new WeakMap,zv=new WeakMap,i(rm,zv,new WeakSet);const em="4.4.168",am="19fbc8998";function tm(r){return Math.floor(255*Math.max(0,Math.min(1,r))).toString(16).padStart(2,"0")}function im(r){return Math.max(0,Math.min(255,255*r))}class Am{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=im(r),r,r]}static G_HTML([r]){const e=tm(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(im)}static RGB_HTML(r){return`#${r.map(tm).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[im(1-Math.min(1,r+t)),im(1-Math.min(1,a+t)),im(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 nm{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&&Av.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&&Av.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 om=1e3,sm=new WeakSet;function fm(r){return{width:r[2]-r[0],height:r[3]-r[1]}}class lm{static create(r){switch(r.data.annotationType){case uf:return new Ek(r);case lf:return new Ck(r);case Zf:switch(r.data.fieldType){case"Tx":return new Bk(r);case"Btn":return r.data.radioButton?new Ik(r):r.data.checkBox?new Wk(r):new Rk(r);case"Ch":return new Fk(r);case"Sig":return new Zk(r)}return new _k(r);case _f:return new xk(r);case cf:return new Mk(r);case df:return new Gk(r);case hf:return new Xk(r);case bf:return new Vk(r);case pf:return new Nk(r);case Ef:return new Tk(r);case Cf:return new Pk(r);case gf:return new Dk(r);case vf:return new jk(r);case mf:return new Ok(r);case kf:return new Lk(r);case wf:return new Yk(r);case yf:return new Hk(r);case Bf:return new Qk(r);default:return new pm(r)}}}var um,cm,dm,hm,bm;const gm=class{constructor(r,{isRenderable:e=!1,ignoreBorder:a=!1,createQuadrilaterals:t=!1}={}){i(this,hm),i(this,um,null),i(this,cm,!1),i(this,dm,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 gm._hasPopupData(this.data)}updateEdited(r){var e;if(!this.container)return;t(this,um)||A(this,um,{rect:this.data.rect.slice(0)});const{rect:a}=r;a&&o(this,hm,bm).call(this,a),null==(e=t(this,dm))||e.popup.updateEdited(r)}resetEdited(){var r;t(this,um)&&(o(this,hm,bm).call(this,t(this,um).rect),null==(r=t(this,dm))||r.popup.resetEdited(),A(this,um,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 _k||(i.tabIndex=om);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 xk){const{rotation:r}=e;return!e.hasOwnCanvas&&0!==r&&this.setRotation(r,i),i}const{width:o,height:s}=fm(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 Ik){const r=`calc(${o}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`;n.borderRadius=r}switch(e.borderStyle.style){case Wf:n.borderStyle="solid";break;case If:n.borderStyle="dashed";break;case Rf:Tf("Unimplemented border style: beveled");break;case Ff:Tf("Unimplemented border style: inset");break;case xf:n.borderBottomStyle="solid"}const t=e.borderColor||null;t?(A(this,cm,!0),n.borderColor=sl.makeHexColor(0|t[0],0|t[1],0|t[2])):n.borderWidth=0}const f=sl.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}=fm(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]=Am[`${i}_HTML`](A),this.annotationStorage.setValue(this.data.id,{[e]:Am[`${i}_rgb`](A)})};return Lf(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,cm)){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,cm)&&(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,dm,new xk({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(){Pf("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||sm.has(n)?a.push({id:i,exportValue:t,domElement:n}):Tf(`_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&&sm.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 pm=gm;var vm,mm,km,wm,ym,Em,Cm,_m,Bm,Zm,Wm,Im,Rm,Fm,xm,Sm,Mm,Gm,Xm,Vm,Nm,Dm,Tm,Pm,jm,Om,Lm,Ym,Hm,Qm,Um,Jm,zm,$m,qm,Km,rk,ek,ak,tk,ik,Ak,nk,ok,sk,fk,lk,uk,ck,dk,hk,bk,gk,pk,vk,mk,kk,wk,yk;um=new WeakMap,cm=new WeakMap,dm=new WeakMap,hm=new WeakSet,bm=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}=fm(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 Ek extends pm{constructor(r,e=null){super(r,{isRenderable:!0,ignoreBorder:!(null==e||!e.ignoreBorder),createQuadrilaterals:!0}),i(this,vm),i(this,km),i(this,ym),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,km,wm).call(this,a,r.attachment,r.attachmentDest),t=!0):r.setOCGState?(o(this,ym,Em).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,vm,mm).call(this)}_bindNamedAction(r,e){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeNamedAction(e),!1),o(this,vm,mm).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,vm,mm).call(this)}_bindResetFormAction(r,e){const a=r.onclick;if(a||(r.href=this.linkService.getAnchorUrl("")),o(this,vm,mm).call(this),!this._fieldObjects)return Tf('_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&&(sm.has(a)?a.dispatchEvent(new Event("resetform")):Tf(`_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}}}vm=new WeakSet,mm=function(){this.container.setAttribute("data-internal-link","")},km=new WeakSet,wm=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,vm,mm).call(this)},ym=new WeakSet,Em=function(r,e){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeSetOCGState(e),!1),o(this,vm,mm).call(this)};class Ck extends pm{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 _k extends pm{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 al.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":sl.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/(Ls*a))||1);i=Math.min(a,A(e/Ls))}else{const r=Math.abs(this.data.rect[3]-this.data.rect[1]-2);i=Math.min(a,A(r/Ls))}t.fontSize=`calc(${i}px * var(--scale-factor))`,t.color=sl.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 Bk extends _k{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),sm.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=om,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 Zk extends _k{constructor(r){super(r,{isRenderable:!!r.data.hasOwnCanvas})}}class Wk extends _k{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 sm.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=om,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 Ik extends _k{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(sm.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=om,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 Rk extends Ek{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 Fk extends _k{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");sm.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=om;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 xk extends pm{constructor(r){const{data:e,elements:a}=r;super(r,{isRenderable:pm._hasPopupData(e)}),this.elements=a,this.popup=null}render(){this.container.classList.add("popupAnnotation");const r=this.popup=new Sk({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=>`${cl}${r}`)).join(",")),this.container}}class Sk{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,Om),i(this,Ym),i(this,Qm),i(this,Jm),i(this,$m),i(this,Km),i(this,ek),i(this,tk),i(this,Ak),i(this,Cm,o(this,$m,qm).bind(this)),i(this,_m,o(this,Ak,nk).bind(this)),i(this,Bm,o(this,tk,ik).bind(this)),i(this,Zm,o(this,ek,ak).bind(this)),i(this,Wm,null),i(this,Im,null),i(this,Rm,null),i(this,Fm,null),i(this,xm,null),i(this,Sm,null),i(this,Mm,null),i(this,Gm,!1),i(this,Xm,null),i(this,Vm,null),i(this,Nm,null),i(this,Dm,null),i(this,Tm,null),i(this,Pm,null),i(this,jm,!1),A(this,Im,r),A(this,Tm,n),A(this,Rm,f),A(this,Dm,l),A(this,Sm,u),A(this,Wm,e),A(this,Nm,c),A(this,Mm,d),A(this,xm,a),A(this,Fm,wu.toDateObject(s)),this.trigger=a.flatMap((r=>r.getElementsToTriggerPopup()));for(const r of this.trigger)r.addEventListener("click",t(this,Zm)),r.addEventListener("mouseenter",t(this,Bm)),r.addEventListener("mouseleave",t(this,_m)),r.classList.add("popupTriggerArea");for(const r of a)null==(b=r.container)||b.addEventListener("keydown",t(this,Cm));t(this,Im).hidden=!0,h&&o(this,ek,ak).call(this)}render(){if(t(this,Xm))return;const r=A(this,Xm,document.createElement("div"));if(r.className="popup",t(this,Wm)){const e=r.style.outlineColor=sl.makeHexColor(...t(this,Wm));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?r.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:r.style.backgroundColor=sl.makeHexColor(...t(this,Wm).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,Tm)),r.append(e),t(this,Fm)){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,Fm).toLocaleDateString(),time:t(this,Fm).toLocaleTimeString()})),e.append(r)}const i=t(this,Om,Lm);if(i)nm.render({xfaHtml:i,intent:"richText",div:r}),r.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(t(this,Rm));r.append(e)}t(this,Im).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,Pm)||A(this,Pm,{contentsObj:t(this,Rm),richText:t(this,Dm)}),r&&A(this,Vm,null),e&&(A(this,Dm,o(this,Jm,zm).call(this,e)),A(this,Rm,null)),null==(a=t(this,Xm))||a.remove(),A(this,Xm,null)}resetEdited(){var r;t(this,Pm)&&(({contentsObj:n(this,Rm)._,richText:n(this,Dm)._}=t(this,Pm)),A(this,Pm,null),null==(r=t(this,Xm))||r.remove(),A(this,Xm,null),A(this,Vm,null))}forceHide(){A(this,jm,this.isVisible),t(this,jm)&&(t(this,Im).hidden=!0)}maybeShow(){t(this,jm)&&(t(this,Xm)||o(this,tk,ik).call(this),A(this,jm,!1),t(this,Im).hidden=!1)}get isVisible(){return!1===t(this,Im).hidden}}Cm=new WeakMap,_m=new WeakMap,Bm=new WeakMap,Zm=new WeakMap,Wm=new WeakMap,Im=new WeakMap,Rm=new WeakMap,Fm=new WeakMap,xm=new WeakMap,Sm=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 WeakMap,jm=new WeakMap,Om=new WeakSet,Lm=function(){const r=t(this,Dm),e=t(this,Rm);return null!=r&&r.str&&(!(null!=e&&e.str)||e.str===r.str)&&t(this,Dm).html||null},Ym=new WeakSet,Hm=function(){var r,e,a;return(null==(a=null==(e=null==(r=t(this,Om,Lm))?void 0:r.attributes)?void 0:e.style)?void 0:a.fontSize)||0},Qm=new WeakSet,Um=function(){var r,e,a;return(null==(a=null==(e=null==(r=t(this,Om,Lm))?void 0:r.attributes)?void 0:e.style)?void 0:a.color)||null},Jm=new WeakSet,zm=function(r){const e=[],a={str:r,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:t(this,Qm,Um),fontSize:t(this,Ym,Hm)?`calc(${t(this,Ym,Hm)}px * var(--scale-factor))`:""}};for(const a of r.split("\n"))e.push({name:"span",value:a,attributes:i});return a},$m=new WeakSet,qm=function(r){r.altKey||r.shiftKey||r.ctrlKey||r.metaKey||("Enter"===r.key||"Escape"===r.key&&t(this,Gm))&&o(this,ek,ak).call(this)},Km=new WeakSet,rk=function(){if(null!==t(this,Vm))return;const{page:{view:r},viewport:{rawDims:{pageWidth:e,pageHeight:a,pageX:i,pageY:n}}}=t(this,Sm);let o=!!t(this,Mm),s=t(this,o?Mm:Nm);for(const r of t(this,xm))if(!s||null!==sl.intersect(r.data.rect,s)){s=r.data.rect,o=!0;break}const f=sl.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,Vm,[100*(u-i)/e,100*(c-n)/a]);const{style:d}=t(this,Im);d.left=`${t(this,Vm)[0]}%`,d.top=`${t(this,Vm)[1]}%`},ek=new WeakSet,ak=function(){A(this,Gm,!t(this,Gm)),t(this,Gm)?(o(this,tk,ik).call(this),t(this,Im).addEventListener("click",t(this,Zm)),t(this,Im).addEventListener("keydown",t(this,Cm))):(o(this,Ak,nk).call(this),t(this,Im).removeEventListener("click",t(this,Zm)),t(this,Im).removeEventListener("keydown",t(this,Cm)))},tk=new WeakSet,ik=function(){t(this,Xm)||this.render(),this.isVisible?t(this,Gm)&&t(this,Im).classList.add("focused"):(o(this,Km,rk).call(this),t(this,Im).hidden=!1,t(this,Im).style.zIndex=parseInt(t(this,Im).style.zIndex)+1e3)},Ak=new WeakSet,nk=function(){t(this,Im).classList.remove("focused"),!t(this,Gm)&&this.isVisible&&(t(this,Im).hidden=!0,t(this,Im).style.zIndex=parseInt(t(this,Im).style.zIndex)-1e3)};class Mk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),this.textContent=r.data.textContent,this.textPosition=r.data.textPosition,this.annotationEditorType=Ks.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 Gk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,ok,null)}render(){this.container.classList.add("lineAnnotation");const r=this.data,{width:e,height:a}=fm(r.rect),t=this.svgFactory.create(e,a,!0),i=A(this,ok,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,ok)}addHighlightArea(){this.container.classList.add("highlightArea")}}ok=new WeakMap;class Xk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,sk,null)}render(){this.container.classList.add("squareAnnotation");const r=this.data,{width:e,height:a}=fm(r.rect),t=this.svgFactory.create(e,a,!0),i=r.borderStyle.width,n=A(this,sk,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,sk)}addHighlightArea(){this.container.classList.add("highlightArea")}}sk=new WeakMap;class Vk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,fk,null)}render(){this.container.classList.add("circleAnnotation");const r=this.data,{width:e,height:a}=fm(r.rect),t=this.svgFactory.create(e,a,!0),i=r.borderStyle.width,n=A(this,fk,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,fk)}addHighlightArea(){this.container.classList.add("highlightArea")}}fk=new WeakMap;class Nk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,lk,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}=fm(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,lk,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,lk)}addHighlightArea(){this.container.classList.add("highlightArea")}}lk=new WeakMap;class Dk extends Nk{constructor(r){super(r),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Tk extends pm{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 Pk extends pm{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0}),i(this,uk,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=Ks.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,inkLists:e,borderStyle:a,popupRef:i}}=this,{width:A,height:n}=fm(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,uk).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,uk)}addHighlightArea(){this.container.classList.add("highlightArea")}}uk=new WeakMap;class jk extends pm{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 Ok extends pm{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 Lk extends pm{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 Yk extends pm{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 Hk extends pm{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 Qk extends pm{constructor(r){var e;super(r,{isRenderable:!0}),i(this,dk),i(this,ck,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,dk,hk).bind(this)),A(this,ck,a);const{isMac:t}=al.platform;return r.addEventListener("keydown",(r=>{"Enter"===r.key&&(t?r.metaKey:r.ctrlKey)&&o(this,dk,hk).call(this)})),!e.popupRef&&this.hasPopupData?this._createPopup():a.classList.add("popupTriggerArea"),r.append(a),r}getElementsToTriggerPopup(){return t(this,ck)}addHighlightArea(){this.container.classList.add("highlightArea")}}ck=new WeakMap,dk=new WeakSet,hk=function(){var r;null==(r=this.downloadManager)||r.openOrDownloadData(this.content,this.filename)};let Uk=(yk=class{constructor({div:r,accessibilityManager:e,annotationCanvasMap:a,annotationEditorUIManager:t,page:n,viewport:o}){i(this,vk),i(this,kk),i(this,bk,null),i(this,gk,null),i(this,pk,new Map),this.div=r,A(this,bk,e),A(this,gk,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;Bu(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 fu,annotationStorage:r.annotationStorage||new yb,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===_f;if(a){const e=A.get(r.id);if(!e)continue;n.elements=e}else{const{width:e,height:a}=fm(r.rect);if(e<=0||a<=0)continue}n.data=r;const i=lm.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,vk,mk).call(this,s,r.id),i.annotationEditorType>0&&(t(this,pk).set(i.data.id,i),null==(e=this._annotationEditorUIManager)||e.renderAnnotationElement(i))}o(this,kk,wk).call(this)}update({viewport:r}){const e=this.div;this.viewport=r,Bu(e,{rotation:r.rotation}),o(this,kk,wk).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(t(this,pk).values())}getEditableAnnotation(r){return t(this,pk).get(r)}},bk=new WeakMap,gk=new WeakMap,pk=new WeakMap,vk=new WeakSet,mk=function(r,e){var a;const i=r.firstChild||r;i.id=`${cl}${e}`,this.div.append(r),null==(a=t(this,bk))||a.moveElementInDOM(this.div,r,i,!1)},kk=new WeakSet,wk=function(){if(!t(this,gk))return;const r=this.div;for(const[e,a]of t(this,gk)){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,gk).clear()},yk);const Jk=/\r\n?|\n/g;var zk,$k,qk,Kk,rw,ew,aw,tw,iw,Aw,nw,ow,sw,fw,lw,uw,cw,dw,hw,bw,gw,pw,vw,mw,kw,ww,yw,Ew;const Cw=class extends fb{constructor(r){super({...r,name:"freeTextEditor"}),i(this,nw),i(this,sw),i(this,lw),i(this,cw),i(this,gw),i(this,vw),i(this,yw),i(this,zk,this.editorDivBlur.bind(this)),i(this,$k,this.editorDivFocus.bind(this)),i(this,qk,this.editorDivInput.bind(this)),i(this,Kk,this.editorDivKeydown.bind(this)),i(this,rw,this.editorDivPaste.bind(this)),i(this,ew,void 0),i(this,aw,""),i(this,tw,`${this.id}-editor`),i(this,iw,void 0),i(this,Aw,null),A(this,ew,r.color||Cw._defaultColor||fb._defaultLineColor),A(this,iw,r.fontSize||Cw._defaultFontSize)}static get _keyboardManager(){const r=Cw.prototype,e=r=>r.isEmpty(),a=rh.TRANSLATE_SMALL,t=rh.TRANSLATE_BIG;return Lf(this,"_keyboardManager",new vc([[["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){fb.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 rf.FREETEXT_SIZE:Cw._defaultFontSize=e;break;case rf.FREETEXT_COLOR:Cw._defaultColor=e}}updateParams(r,e){switch(r){case rf.FREETEXT_SIZE:o(this,nw,ow).call(this,e);break;case rf.FREETEXT_COLOR:o(this,sw,fw).call(this,e)}}static get defaultPropertiesToUpdate(){return[[rf.FREETEXT_SIZE,Cw._defaultFontSize],[rf.FREETEXT_COLOR,Cw._defaultColor||fb._defaultLineColor]]}get propertiesToUpdate(){return[[rf.FREETEXT_SIZE,t(this,iw)],[rf.FREETEXT_COLOR,t(this,ew)]]}_translateEmpty(r,e){this._uiManager.translateSelectedEditors(r,e,!0)}getInitialTranslation(){const r=this.parentScale;return[-Cw._internalPadding*r,-(Cw._internalPadding+t(this,iw))*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(Ks.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,Kk),{signal:r}),this.editorDiv.addEventListener("focus",t(this,$k),{signal:r}),this.editorDiv.addEventListener("blur",t(this,zk),{signal:r}),this.editorDiv.addEventListener("input",t(this,qk),{signal:r}),this.editorDiv.addEventListener("paste",t(this,rw),{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,tw)),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",t(this,Kk)),this.editorDiv.removeEventListener("focus",t(this,$k)),this.editorDiv.removeEventListener("blur",t(this,zk)),this.editorDiv.removeEventListener("input",t(this,qk)),this.editorDiv.removeEventListener("paste",t(this,rw)),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,aw),e=A(this,aw,o(this,lw,uw).call(this).trimEnd());if(r===e)return;const a=r=>{A(this,aw,r),r?(o(this,gw,pw).call(this),this._uiManager.rebuild(this),o(this,cw,dw).call(this)):this.remove()};this.addCommands({cmd:()=>{a(e)},undo:()=>{a(r)},mustExec:!1}),o(this,cw,dw).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){Cw._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,tw)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),fb._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,iw)}px * var(--scale-factor))`,a.color=t(this,ew),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),oc(this,this.div,["dblclick","keydown"]),this.width){const[a,i]=this.parentDimensions;if(this.annotationElementId){const{position:A}=t(this,Aw);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,gw,pw).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=Cw,kw,ww).call(e,i.getData("text")||"").replaceAll(Jk,"\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(Jk,"")),r!==this.editorDiv){let e=d;for(const t of this.editorDiv.childNodes)t!==r?e.push(o(a=Cw,hw,bw).call(a,t)):e=h}d.push(u.nodeValue.slice(0,c).replaceAll(Jk,""))}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=Cw,hw,bw).call(t,a))}A(this,aw,`${d.join("\n")}${s}${h.join("\n")}`),o(this,gw,pw).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 Mk){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:Ks.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,iw,r.fontSize),A(n,ew,sl.makeHexColor(...r.color)),A(n,aw,o(t=Cw,kw,ww).call(t,r.value)),n.annotationElementId=r.id||null,A(n,Aw,i),n}serialize(r=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=Cw._internalPadding*this.parentScale,a=this.getRect(e,e),i=fb._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:t(this,ew)),A={annotationType:Ks.FREETEXT,color:i,fontSize:t(this,iw),value:o(this,vw,mw).call(this),pageIndex:this.pageIndex,rect:a,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return r?A:this.annotationElementId&&!o(this,yw,Ew).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,iw)}px * var(--scale-factor))`,a.color=t(this,ew),e.replaceChildren();for(const r of t(this,aw).split("\n")){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),e.append(a)}const i=Cw._internalPadding*this.parentScale;return r.updateEdited({rect:this.getRect(i,i),popupContent:t(this,aw)}),e}resetAnnotationElement(r){super.resetAnnotationElement(r),r.resetEdited()}};let _w=Cw;var Bw,Zw,Ww,Iw,Rw,Fw,xw,Sw,Mw,Gw,Xw,Vw,Nw,Dw,Tw,Pw,jw,Ow,Lw,Yw,Hw,Qw,Uw,Jw,zw,$w,qw,Kw,ry,ey,ay,ty,iy;zk=new WeakMap,$k=new WeakMap,qk=new WeakMap,Kk=new WeakMap,rw=new WeakMap,ew=new WeakMap,aw=new WeakMap,tw=new WeakMap,iw=new WeakMap,Aw=new WeakMap,nw=new WeakSet,ow=function(r){const e=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--scale-factor))`,this.translate(0,-(r-t(this,iw))*this.parentScale),A(this,iw,r),o(this,cw,dw).call(this)},a=t(this,iw);this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rf.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},sw=new WeakSet,fw=function(r){const e=r=>{A(this,ew,this.editorDiv.style.color=r)},a=t(this,ew);this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:rf.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},lw=new WeakSet,uw=function(){var r;const e=[];this.editorDiv.normalize();for(const a of this.editorDiv.childNodes)e.push(o(r=Cw,hw,bw).call(r,a));return e.join("\n")},cw=new WeakSet,dw=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()},hw=new WeakSet,bw=function(r){return(r.nodeType===Node.TEXT_NODE?r.nodeValue:r.innerText).replaceAll(Jk,"")},gw=new WeakSet,pw=function(){if(this.editorDiv.replaceChildren(),t(this,aw))for(const r of t(this,aw).split("\n")){const e=document.createElement("div");e.append(r?document.createTextNode(r):document.createElement("br")),this.editorDiv.append(e)}},vw=new WeakSet,mw=function(){return t(this,aw).replaceAll(" "," ")},kw=new WeakSet,ww=function(r){return r.replaceAll(" "," ")},yw=new WeakSet,Ew=function(r){const{value:e,fontSize:a,color:i,pageIndex:A}=t(this,Aw);return this._hasBeenMoved||r.value!==e||r.fontSize!==a||r.color.some(((r,e)=>r!==i[e]))||r.pageIndex!==A},i(_w,hw),i(_w,kw),e(_w,"_freeTextDefaultContent",""),e(_w,"_internalPadding",0),e(_w,"_defaultColor",null),e(_w,"_defaultFontSize",10),e(_w,"_type","freetext"),e(_w,"_editorType",Ks.FREETEXT);class Ay{constructor(r,e=0,a=0,n=!0){i(this,Iw),i(this,Fw),i(this,Sw),i(this,Gw),i(this,Vw),i(this,Bw,void 0),i(this,Zw,[]),i(this,Ww,[]);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,Zw).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,Zw).at(n?-1:-2),p=[g[0],g[2]];for(const r of t(this,Zw)){const[e,a,t]=r;r[0]=(e-h)/c,r[1]=(a-b)/d,r[2]=(t-b)/d}A(this,Bw,{x:h,y:b,width:c,height:d,lastPoint:p})}getOutlines(){t(this,Zw).sort(((r,e)=>r[0]-e[0]||r[1]-e[1]||r[2]-e[2]));const r=[];for(const e of t(this,Zw))e[3]?(r.push(...o(this,Vw,Nw).call(this,e)),o(this,Sw,Mw).call(this,e)):(o(this,Gw,Xw).call(this,e),r.push(...o(this,Vw,Nw).call(this,e)));return o(this,Iw,Rw).call(this,r)}}Bw=new WeakMap,Zw=new WeakMap,Ww=new WeakMap,Iw=new WeakSet,Rw=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 oy(i,t(this,Bw))},Fw=new WeakSet,xw=function(r){const e=t(this,Ww);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},Sw=new WeakSet,Mw=function([,r,e]){const a=o(this,Fw,xw).call(this,r);t(this,Ww).splice(a,0,[r,e])},Gw=new WeakSet,Xw=function([,r,e]){const a=o(this,Fw,xw).call(this,r);for(let i=a;i<t(this,Ww).length;i++){const[a,A]=t(this,Ww)[i];if(a!==r)break;if(a===r&&A===e)return void t(this,Ww).splice(i,1)}for(let i=a-1;i>=0;i--){const[a,A]=t(this,Ww)[i];if(a!==r)break;if(a===r&&A===e)return void t(this,Ww).splice(i,1)}},Vw=new WeakSet,Nw=function(r){const[e,a,i]=r,A=[[e,a,i]],n=o(this,Fw,xw).call(this,i);for(let r=0;r<n;r++){const[a,i]=t(this,Ww)[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 ny{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 Qy}}class oy extends ny{constructor(r,e){super(),i(this,Dw,void 0),i(this,Tw,void 0),A(this,Tw,r),A(this,Dw,e)}toSVGPath(){const r=[];for(const e of t(this,Tw)){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,Tw)){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,Dw)}}Dw=new WeakMap,Tw=new WeakMap;const sy=class{constructor({x:r,y:e},a,n,o,s,f=0){i(this,ty),i(this,Pw,void 0),i(this,jw,[]),i(this,Ow,void 0),i(this,Lw,void 0),i(this,Yw,[]),i(this,Hw,new Float64Array(18)),i(this,Qw,void 0),i(this,Uw,void 0),i(this,Jw,void 0),i(this,zw,void 0),i(this,$w,void 0),i(this,qw,void 0),i(this,Kw,[]),A(this,Pw,a),A(this,qw,o*n),A(this,Lw,s),t(this,Hw).set([NaN,NaN,NaN,NaN,r,e],6),A(this,Ow,f),A(this,zw,t(sy,ry)*n),A(this,Jw,t(sy,ay)*n),A(this,$w,n),t(this,Kw).push(r,e)}get free(){return!0}isEmpty(){return isNaN(t(this,Hw)[8])}add({x:r,y:e}){var a;A(this,Qw,r),A(this,Uw,e);const[i,n,o,s]=t(this,Pw);let[f,l,u,c]=t(this,Hw).subarray(8,12);const d=r-u,h=e-c,b=Math.hypot(d,h);if(b<t(this,Jw))return!1;const g=b-t(this,zw),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,Kw))||a.push(r,e);const y=v/g,E=-m/g*t(this,qw),C=y*t(this,qw);return t(this,Hw).set(t(this,Hw).subarray(2,8),0),t(this,Hw).set([u+E,c+C],4),t(this,Hw).set(t(this,Hw).subarray(14,18),12),t(this,Hw).set([u-E,c-C],16),isNaN(t(this,Hw)[6])?(0===t(this,Yw).length&&(t(this,Hw).set([f+E,l+C],2),t(this,Yw).push(NaN,NaN,NaN,NaN,(f+E-i)/o,(l+C-n)/s),t(this,Hw).set([f-E,l-C],14),t(this,jw).push(NaN,NaN,NaN,NaN,(f-E-i)/o,(l-C-n)/s)),t(this,Hw).set([k,w,f,l,u,c],6),!this.isEmpty()):(t(this,Hw).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,Hw).subarray(2,6),t(this,Yw).push(NaN,NaN,NaN,NaN,((f+u)/2-i)/o,((l+c)/2-n)/s),[f,l,k,w]=t(this,Hw).subarray(14,18),t(this,jw).push(NaN,NaN,NaN,NaN,((k+f)/2-i)/o,((w+l)/2-n)/s),!0):([k,w,f,l,u,c]=t(this,Hw).subarray(0,6),t(this,Yw).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,Hw).subarray(12,18),t(this,jw).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,Yw),e=t(this,jw),a=t(this,Hw).subarray(4,6),i=t(this,Hw).subarray(16,18),[A,n,s,f]=t(this,Pw),[l,u,c,d]=o(this,ty,iy).call(this);if(isNaN(t(this,Hw)[6])&&!this.isEmpty())return`M${(t(this,Hw)[2]-A)/s} ${(t(this,Hw)[3]-n)/f} L${(t(this,Hw)[4]-A)/s} ${(t(this,Hw)[5]-n)/f} L${l} ${u} L${c} ${d} L${(t(this,Hw)[16]-A)/s} ${(t(this,Hw)[17]-n)/f} L${(t(this,Hw)[14]-A)/s} ${(t(this,Hw)[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,Yw),a=t(this,jw),i=t(this,Hw),A=i.subarray(4,6),n=i.subarray(16,18),[s,f,l,u]=t(this,Pw),c=new Float64Array(((null==(r=t(this,Kw))?void 0:r.length)??0)+2);for(let r=0,e=c.length-2;r<e;r+=2)c[r]=(t(this,Kw)[r]-s)/l,c[r+1]=(t(this,Kw)[r+1]-f)/u;c[c.length-2]=(t(this,Qw)-s)/l,c[c.length-1]=(t(this,Uw)-f)/u;const[d,h,b,g]=o(this,ty,iy).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 Qy(r,c,t(this,Pw),t(this,$w),t(this,Ow),t(this,Lw))}const p=new Float64Array(t(this,Yw).length+24+t(this,jw).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 Qy(p,c,t(this,Pw),t(this,$w),t(this,Ow),t(this,Lw))}};let fy=sy;var ly,uy,cy,dy,hy,by,gy,py,vy,my,ky,wy,yy,Ey,Cy,_y,By,Zy,Wy,Iy,Ry,Fy,xy,Sy,My,Gy,Xy,Vy,Ny,Dy,Ty,Py,jy,Oy,Ly,Yy,Hy;Pw=new WeakMap,jw=new WeakMap,Ow=new WeakMap,Lw=new WeakMap,Yw=new WeakMap,Hw=new WeakMap,Qw=new WeakMap,Uw=new WeakMap,Jw=new WeakMap,zw=new WeakMap,$w=new WeakMap,qw=new WeakMap,Kw=new WeakMap,ry=new WeakMap,ey=new WeakMap,ay=new WeakMap,ty=new WeakSet,iy=function(){const r=t(this,Hw).subarray(4,6),e=t(this,Hw).subarray(16,18),[a,i,A,n]=t(this,Pw);return[(t(this,Qw)+(r[0]-e[0])/2-a)/A,(t(this,Uw)+(r[1]-e[1])/2-i)/n,(t(this,Qw)+(e[0]-r[0])/2-a)/A,(t(this,Uw)+(e[1]-r[1])/2-i)/n]},i(fy,ry,8),i(fy,ey,2),i(fy,ay,t(sy,ry)+t(sy,ey));class Qy extends ny{constructor(r,e,a,n,s,f){super(),i(this,py),i(this,my),i(this,wy),i(this,ly,void 0),i(this,uy,null),i(this,cy,void 0),i(this,dy,void 0),i(this,hy,void 0),i(this,by,void 0),i(this,gy,void 0),A(this,gy,r),A(this,hy,e),A(this,ly,a),A(this,by,n),A(this,cy,s),A(this,dy,f),o(this,wy,yy).call(this,f);const{x:l,y:u,width:c,height:d}=t(this,uy);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,gy)[4]} ${t(this,gy)[5]}`];for(let e=6,a=t(this,gy).length;e<a;e+=6)isNaN(t(this,gy)[e])?r.push(`L${t(this,gy)[e+4]} ${t(this,gy)[e+5]}`):r.push(`C${t(this,gy)[e]} ${t(this,gy)[e+1]} ${t(this,gy)[e+2]} ${t(this,gy)[e+3]} ${t(this,gy)[e+4]} ${t(this,gy)[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,py,vy).call(this,t(this,gy),r,i,n,-s),l=o(this,py,vy).call(this,t(this,hy),r,i,n,-s);break;case 90:f=o(this,my,ky).call(this,t(this,gy),r,e,n,s),l=o(this,my,ky).call(this,t(this,hy),r,e,n,s);break;case 180:f=o(this,py,vy).call(this,t(this,gy),a,e,-n,s),l=o(this,py,vy).call(this,t(this,hy),a,e,-n,s);break;case 270:f=o(this,my,ky).call(this,t(this,gy),a,i,-n,-s),l=o(this,my,ky).call(this,t(this,hy),a,i,-n,-s)}return{outline:Array.from(f),points:[Array.from(l)]}}get box(){return t(this,uy)}getNewOutline(r,e){const{x:a,y:i,width:A,height:n}=t(this,uy),[o,s,f,l]=t(this,ly),u=A*f,c=n*l,d=a*f+o,h=i*l+s,b=new fy({x:t(this,hy)[0]*u+d,y:t(this,hy)[1]*c+h},t(this,ly),t(this,by),r,t(this,dy),e??t(this,cy));for(let r=2;r<t(this,hy).length;r+=2)b.add({x:t(this,hy)[r]*u+d,y:t(this,hy)[r+1]*c+h});return b.getOutlines()}}ly=new WeakMap,uy=new WeakMap,cy=new WeakMap,dy=new WeakMap,hy=new WeakMap,by=new WeakMap,gy=new WeakMap,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]*t,A[n+1]=a+r[n+1]*i;return A},my=new WeakSet,ky=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},wy=new WeakSet,yy=function(r){const e=t(this,gy);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=sl.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,cy),h=o-t(this,cy),b=s-n+2*t(this,cy),g=f-o+2*t(this,cy);A(this,uy,{x:d,y:h,width:b,height:g,lastPoint:[l,u]})};const Uy=class{constructor({editor:r=null,uiManager:e=null}){var a;i(this,Gy),i(this,Vy),i(this,Dy),i(this,Py),i(this,Oy),i(this,Yy),i(this,Ey,o(this,Dy,Ty).bind(this)),i(this,Cy,o(this,Oy,Ly).bind(this)),i(this,_y,null),i(this,By,null),i(this,Zy,void 0),i(this,Wy,null),i(this,Iy,!1),i(this,Ry,!1),i(this,Fy,null),i(this,xy,void 0),i(this,Sy,null),i(this,My,void 0),r?(A(this,Ry,!1),A(this,My,rf.HIGHLIGHT_COLOR),A(this,Fy,r)):(A(this,Ry,!0),A(this,My,rf.HIGHLIGHT_DEFAULT_COLOR)),A(this,Sy,(null==r?void 0:r._uiManager)||e),A(this,xy,t(this,Sy)._eventBus),A(this,Zy,(null==r?void 0:r.color)||(null==(a=t(this,Sy))?void 0:a.highlightColors.values().next().value)||"#FFFF98")}static get _keyboardManager(){return Lf(this,"_keyboardManager",new vc([[["Escape","mac+Escape"],Uy.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Uy.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Uy.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Uy.prototype._moveToPrevious],[["Home","mac+Home"],Uy.prototype._moveToBeginning],[["End","mac+End"],Uy.prototype._moveToEnd]]))}renderButton(){const r=A(this,_y,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,Sy)._signal;r.addEventListener("click",o(this,Py,jy).bind(this),{signal:e}),r.addEventListener("keydown",t(this,Ey),{signal:e});const a=A(this,By,document.createElement("span"));return a.className="swatch",a.setAttribute("aria-hidden",!0),a.style.backgroundColor=t(this,Zy),r.append(a),r}renderMainDropdown(){const r=A(this,Wy,o(this,Gy,Xy).call(this));return r.setAttribute("aria-orientation","horizontal"),r.setAttribute("aria-labelledby","highlightColorPickerLabel"),r}_colorSelectFromKeyboard(r){if(r.target===t(this,_y))return void o(this,Py,jy).call(this,r);const e=r.target.getAttribute("data-color");e&&o(this,Vy,Ny).call(this,e,r)}_moveToNext(r){var e,a;t(this,Yy,Hy)?r.target!==t(this,_y)?null==(a=r.target.nextSibling)||a.focus():null==(e=t(this,Wy).firstChild)||e.focus():o(this,Py,jy).call(this,r)}_moveToPrevious(r){var e,a;r.target!==(null==(e=t(this,Wy))?void 0:e.firstChild)&&r.target!==t(this,_y)?(t(this,Yy,Hy)||o(this,Py,jy).call(this,r),null==(a=r.target.previousSibling)||a.focus()):t(this,Yy,Hy)&&this._hideDropdownFromKeyboard()}_moveToBeginning(r){var e;t(this,Yy,Hy)?null==(e=t(this,Wy).firstChild)||e.focus():o(this,Py,jy).call(this,r)}_moveToEnd(r){var e;t(this,Yy,Hy)?null==(e=t(this,Wy).lastChild)||e.focus():o(this,Py,jy).call(this,r)}hideDropdown(){var r;null==(r=t(this,Wy))||r.classList.add("hidden"),window.removeEventListener("pointerdown",t(this,Cy))}_hideDropdownFromKeyboard(){var r;if(!t(this,Ry)){if(!t(this,Yy,Hy))return void(null==(r=t(this,Fy))||r.unselect());this.hideDropdown(),t(this,_y).focus({preventScroll:!0,focusVisible:t(this,Iy)})}}updateColor(r){if(t(this,By)&&(t(this,By).style.backgroundColor=r),!t(this,Wy))return;const e=t(this,Sy).highlightColors.values();for(const a of t(this,Wy).children)a.setAttribute("aria-selected",e.next().value===r)}destroy(){var r,e;null==(r=t(this,_y))||r.remove(),A(this,_y,null),A(this,By,null),null==(e=t(this,Wy))||e.remove(),A(this,Wy,null)}};let Jy=Uy;var zy,$y,qy,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,_E,BE,ZE,WE,IE,RE,FE,xE,SE,ME,GE,XE,VE,NE,DE,TE,PE,jE,OE,LE;Ey=new WeakMap,Cy=new WeakMap,_y=new WeakMap,By=new WeakMap,Zy=new WeakMap,Wy=new WeakMap,Iy=new WeakMap,Ry=new WeakMap,Fy=new WeakMap,xy=new WeakMap,Sy=new WeakMap,My=new WeakMap,Gy=new WeakSet,Xy=function(){const r=document.createElement("div"),e=t(this,Sy)._signal;r.addEventListener("contextmenu",vu,{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,Sy).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,Zy)),A.addEventListener("click",o(this,Vy,Ny).bind(this,i),{signal:e}),r.append(A)}return r.addEventListener("keydown",t(this,Ey),{signal:e}),r},Vy=new WeakSet,Ny=function(r,e){e.stopPropagation(),t(this,xy).dispatch("switchannotationeditorparams",{source:this,type:t(this,My),value:r})},Dy=new WeakSet,Ty=function(r){Uy._keyboardManager.exec(this,r)},Py=new WeakSet,jy=function(r){if(t(this,Yy,Hy))return void this.hideDropdown();if(A(this,Iy,0===r.detail),window.addEventListener("pointerdown",t(this,Cy),{signal:t(this,Sy)._signal}),t(this,Wy))return void t(this,Wy).classList.remove("hidden");const e=A(this,Wy,o(this,Gy,Xy).call(this));t(this,_y).append(e)},Oy=new WeakSet,Ly=function(r){var e;null!=(e=t(this,Wy))&&e.contains(r.target)||this.hideDropdown()},Yy=new WeakSet,Hy=function(){return t(this,Wy)&&!t(this,Wy).classList.contains("hidden")};const YE=class extends fb{constructor(r){super({...r,name:"highlightEditor"}),i(this,bE),i(this,pE),i(this,mE),i(this,wE),i(this,EE),i(this,_E),i(this,ZE),i(this,FE),i(this,SE),i(this,GE),i(this,VE),i(this,DE),i(this,zy,null),i(this,$y,0),i(this,qy,void 0),i(this,Ky,null),i(this,rE,null),i(this,eE,null),i(this,aE,null),i(this,tE,0),i(this,iE,null),i(this,AE,null),i(this,nE,null),i(this,oE,!1),i(this,sE,o(this,FE,xE).bind(this)),i(this,fE,null),i(this,lE,void 0),i(this,uE,null),i(this,cE,""),i(this,dE,void 0),i(this,hE,""),this.color=r.color||YE._defaultColor,A(this,dE,r.thickness||YE._defaultThickness),A(this,lE,r.opacity||YE._defaultOpacity),A(this,qy,r.boxes||null),A(this,hE,r.methodOfCreation||""),A(this,cE,r.text||""),this._isDraggable=!1,r.highlightId>-1?(A(this,oE,!0),o(this,pE,vE).call(this,r),o(this,ZE,WE).call(this)):(A(this,zy,r.anchorNode),A(this,$y,r.anchorOffset),A(this,aE,r.focusNode),A(this,tE,r.focusOffset),o(this,bE,gE).call(this),o(this,ZE,WE).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const r=YE.prototype;return Lf(this,"_keyboardManager",new vc([[["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,oE)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:t(this,dE),methodOfCreation:t(this,hE)}}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;fb.initialize(r,e),YE._defaultColor||(YE._defaultColor=(null==(a=e.highlightColors)?void 0:a.values().next().value)||"#fff066")}static updateDefaultParams(r,e){switch(r){case rf.HIGHLIGHT_DEFAULT_COLOR:YE._defaultColor=e;break;case rf.HIGHLIGHT_THICKNESS:YE._defaultThickness=e}}translateInPage(r,e){}get toolbarPosition(){return t(this,fE)}updateParams(r,e){switch(r){case rf.HIGHLIGHT_COLOR:o(this,mE,kE).call(this,e);break;case rf.HIGHLIGHT_THICKNESS:o(this,wE,yE).call(this,e)}}static get defaultPropertiesToUpdate(){return[[rf.HIGHLIGHT_DEFAULT_COLOR,YE._defaultColor],[rf.HIGHLIGHT_THICKNESS,YE._defaultThickness]]}get propertiesToUpdate(){return[[rf.HIGHLIGHT_COLOR,this.color||YE._defaultColor],[rf.HIGHLIGHT_THICKNESS,t(this,dE)||YE._defaultThickness],[rf.HIGHLIGHT_FREE,t(this,oE)]]}async addEditToolbar(){const r=await super.addEditToolbar();return r?(this._uiManager.highlightColors&&(A(this,rE,new Jy({editor:this})),r.addColorPicker(t(this,rE))),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,GE,XE).call(this))}getBaseTranslation(){return[0,0]}getRect(r,e){return super.getRect(r,e,o(this,GE,XE).call(this))}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){o(this,_E,BE).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(o(this,ZE,WE).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(r){var e;let a=!1;this.parent&&!r?o(this,_E,BE).call(this):r&&(o(this,ZE,WE).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,oE)?(r=(r-this.rotation+360)%360,n=o(e=YE,IE,RE).call(e,t(this,AE).box,r)):n=o(a=YE,IE,RE).call(a,this,r),A.rotate(t(this,nE),r),A.rotate(t(this,uE),r),A.updateBox(t(this,nE),n),A.updateBox(t(this,uE),o(i=YE,IE,RE).call(i,t(this,eE).box,r))}render(){if(this.div)return this.div;const r=super.render();t(this,cE)&&(r.setAttribute("aria-label",t(this,cE)),r.setAttribute("role","mark")),t(this,oE)?r.classList.add("free"):this.div.addEventListener("keydown",t(this,sE),{signal:this._uiManager._signal});const e=A(this,iE,document.createElement("div"));r.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=t(this,Ky);const[a,i]=this.parentDimensions;return this.setDims(this.width*a,this.height*i),oc(this,t(this,iE),["pointerover","pointerleave"]),this.enableEditing(),r}pointerover(){this.parent.drawLayer.addClass(t(this,uE),"hovered")}pointerleave(){this.parent.drawLayer.removeClass(t(this,uE),"hovered")}_moveCaret(r){switch(this.parent.unselect(this),r){case 0:case 2:o(this,SE,ME).call(this,!0);break;case 1:case 3:o(this,SE,ME).call(this,!1)}}select(){var r,e;super.select(),t(this,uE)&&(null==(r=this.parent)||r.drawLayer.removeClass(t(this,uE),"hovered"),null==(e=this.parent)||e.drawLayer.addClass(t(this,uE),"selected"))}unselect(){var r;super.unselect(),t(this,uE)&&(null==(r=this.parent)||r.drawLayer.removeClass(t(this,uE),"selected"),t(this,oE)||o(this,SE,ME).call(this,!1))}get _mustFixPosition(){return!t(this,oE)}show(r=this._isVisible){super.show(r),this.parent&&(this.parent.drawLayer.show(t(this,nE),r),this.parent.drawLayer.show(t(this,uE),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,PE,jE).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",vu),o(this,OE,LE).call(this,r,e)};window.addEventListener("blur",h,{signal:u}),window.addEventListener("pointerup",h,{signal:u}),window.addEventListener("pointerdown",d,c),window.addEventListener("contextmenu",vu,{signal:u}),a.addEventListener("pointermove",l,{signal:u}),this._freeHighlight=new fy({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=sl.makeHexColor(...u),A(i,lE,r.opacity);const[d,h]=i.pageDimensions;i.width=(f-n)/d,i.height=(l-s)/h;const b=A(i,qy,[]);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,bE,gE).call(t),i}serialize(r=!1){if(this.isEmpty()||r)return null;const e=this.getRect(0,0),a=fb._colorManager.convert(this.color);return{annotationType:Ks.HIGHLIGHT,color:a,opacity:t(this,lE),thickness:t(this,dE),quadPoints:o(this,VE,NE).call(this),outlines:o(this,DE,TE).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:o(this,GE,XE).call(this),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}};let HE=YE;var QE,UE,JE,zE,$E,qE,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,_C,BC,ZC,WC,IC,RC,FC,xC,SC,MC,GC,XC,VC,NC,DC,TC,PC,jC,OC,LC,YC,HC,QC,UC,JC,zC,$C,qC,KC,r_,e_,a_,t_,i_,A_;zy=new WeakMap,$y=new WeakMap,qy=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 WeakMap,hE=new WeakMap,bE=new WeakSet,gE=function(){const r=new Ay(t(this,qy),.001);A(this,AE,r.getOutlines()),({x:this.x,y:this.y,width:this.width,height:this.height}=t(this,AE).box);const e=new Ay(t(this,qy),.0025,.001,"ltr"===this._uiManager.direction);A(this,eE,e.getOutlines());const{lastPoint:a}=t(this,eE).box;A(this,fE,[(a[0]-this.x)/this.width,(a[1]-this.y)/this.height])},pE=new WeakSet,vE=function({highlightOutlines:r,highlightId:e,clipPathId:a}){var i,n;A(this,AE,r);if(A(this,eE,r.getNewOutline(t(this,dE)/2+1.5,.0025)),e>=0)A(this,nE,e),A(this,Ky,a),this.parent.drawLayer.finalizeLine(e,r),A(this,uE,this.parent.drawLayer.highlightOutline(t(this,eE)));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(t(this,nE),r),this.parent.drawLayer.updateBox(t(this,nE),o(i=YE,IE,RE).call(i,t(this,AE).box,(e-this.rotation+360)%360)),this.parent.drawLayer.updateLine(t(this,uE),t(this,eE)),this.parent.drawLayer.updateBox(t(this,uE),o(n=YE,IE,RE).call(n,t(this,eE).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,eE).box;A(this,fE,[(c[0]-s)/l,(c[1]-f)/u])},mE=new WeakSet,kE=function(r){const e=r=>{var e,a;this.color=r,null==(e=this.parent)||e.drawLayer.changeColor(t(this,nE),r),null==(a=t(this,rE))||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:rf.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(r)},!0)},wE=new WeakSet,yE=function(r){const e=t(this,dE),a=r=>{A(this,dE,r),o(this,EE,CE).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:rf.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:r},!0)},EE=new WeakSet,CE=function(r){if(!t(this,oE))return;o(this,pE,vE).call(this,{highlightOutlines:t(this,AE).getNewOutline(r/2)}),this.fixAndSetPosition();const[e,a]=this.parentDimensions;this.setDims(this.width*e,this.height*a)},_E=new WeakSet,BE=function(){null===t(this,nE)||!this.parent||(this.parent.drawLayer.remove(t(this,nE)),A(this,nE,null),this.parent.drawLayer.remove(t(this,uE)),A(this,uE,null))},ZE=new WeakSet,WE=function(r=this.parent){null===t(this,nE)&&(({id:n(this,nE)._,clipPathId:n(this,Ky)._}=r.drawLayer.highlight(t(this,AE),this.color,t(this,lE))),A(this,uE,r.drawLayer.highlightOutline(t(this,eE))),t(this,iE)&&(t(this,iE).style.clipPath=t(this,Ky)))},IE=new WeakSet,RE=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}},FE=new WeakSet,xE=function(r){YE._keyboardManager.exec(this,r)},SE=new WeakSet,ME=function(r){if(!t(this,zy))return;const e=window.getSelection();r?e.setPosition(t(this,zy),t(this,$y)):e.setPosition(t(this,aE),t(this,tE))},GE=new WeakSet,XE=function(){return t(this,oE)?this.rotation:0},VE=new WeakSet,NE=function(){if(t(this,oE))return null;const[r,e]=this.pageDimensions,a=t(this,qy),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},DE=new WeakSet,TE=function(r){return t(this,AE).serialize(r,o(this,GE,XE).call(this))},PE=new WeakSet,jE=function(r,e){this._freeHighlight.add(e)&&r.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},OE=new WeakSet,LE=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(HE,IE),i(HE,PE),i(HE,OE),e(HE,"_defaultColor",null),e(HE,"_defaultOpacity",1),e(HE,"_defaultThickness",12),e(HE,"_l10nPromise"),e(HE,"_type","highlight"),e(HE,"_editorType",Ks.HIGHLIGHT),e(HE,"_freeHighlightId",-1),e(HE,"_freeHighlight",null),e(HE,"_freeHighlightClipId","");const n_=class extends fb{constructor(r){super({...r,name:"inkEditor"}),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,BC),i(this,WC),i(this,RC),i(this,xC),i(this,MC),i(this,XC),i(this,NC),i(this,TC),i(this,jC),i(this,LC),i(this,qC),i(this,r_),i(this,a_),i(this,i_),i(this,QE,0),i(this,UE,0),i(this,JE,this.canvasPointermove.bind(this)),i(this,zE,this.canvasPointerleave.bind(this)),i(this,$E,this.canvasPointerup.bind(this)),i(this,qE,this.canvasPointerdown.bind(this)),i(this,KE,null),i(this,rC,new Path2D),i(this,eC,!1),i(this,aC,!1),i(this,tC,!1),i(this,iC,null),i(this,AC,0),i(this,nC,0),i(this,oC,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){fb.initialize(r,e)}static updateDefaultParams(r,e){switch(r){case rf.INK_THICKNESS:n_._defaultThickness=e;break;case rf.INK_COLOR:n_._defaultColor=e;break;case rf.INK_OPACITY:n_._defaultOpacity=e/100}}updateParams(r,e){switch(r){case rf.INK_THICKNESS:o(this,sC,fC).call(this,e);break;case rf.INK_COLOR:o(this,lC,uC).call(this,e);break;case rf.INK_OPACITY:o(this,cC,dC).call(this,e)}}static get defaultPropertiesToUpdate(){return[[rf.INK_THICKNESS,n_._defaultThickness],[rf.INK_COLOR,n_._defaultColor||fb._defaultLineColor],[rf.INK_OPACITY,Math.round(100*n_._defaultOpacity)]]}get propertiesToUpdate(){return[[rf.INK_THICKNESS,this.thickness||n_._defaultThickness],[rf.INK_COLOR,this.color||n_._defaultColor||fb._defaultLineColor],[rf.INK_OPACITY,Math.round(100*(this.opacity??n_._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(o(this,XC,VC).call(this),o(this,NC,DC).call(this)),this.isAttachedToDOM||(this.parent.add(this),o(this,TC,PC).call(this)),o(this,i_,A_).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,KE)&&(clearTimeout(t(this,KE)),A(this,KE,null)),null==(r=t(this,iC))||r.disconnect(),A(this,iC,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,eC)||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",t(this,qE),{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,qE)))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}commit(){t(this,eC)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),A(this,eC,!0),this.div.classList.add("disabled"),o(this,i_,A_).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,eC)||(this.setInForeground(),r.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),o(this,vC,mC).call(this,r.offsetX,r.offsetY))}canvasPointermove(r){r.preventDefault(),o(this,kC,wC).call(this,r.offsetX,r.offsetY)}canvasPointerup(r){r.preventDefault(),o(this,MC,GC).call(this,r)}canvasPointerleave(r){o(this,MC,GC).call(this,r)}get isResizable(){return!this.isEmpty()&&t(this,eC)}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,hC,bC).call(this);if(this.setAt(a,t,0,0),this.setDims(i,n),o(this,XC,VC).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,tC,!0),o(this,TC,PC).call(this),this.setDims(this.width*a,this.height*t),o(this,xC,SC).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return o(this,NC,DC).call(this),this.div}setDimensions(r,e){const a=Math.round(r),i=Math.round(e);if(t(this,AC)===a&&t(this,nC)===i)return;A(this,AC,a),A(this,nC,i),this.canvas.style.visibility="hidden";const[n,s]=this.parentDimensions;this.width=r/n,this.height=e/s,this.fixAndSetPosition(),t(this,eC)&&o(this,jC,OC).call(this,r,e),o(this,TC,PC).call(this),o(this,xC,SC).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(r,e,a){var t,i,n;if(r instanceof Pk)return null;const s=super.deserialize(r,e,a);s.thickness=r.thickness,s.color=sl.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,eC,!0),A(s,AC,Math.round(u)),A(s,nC,Math.round(c));const{paths:b,rect:g,rotation:p}=r;for(let{bezier:r}of b){r=o(t=n_,zC,$C).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,HC,QC).call(this,e);s.bezierPath2D.push(A)}const v=o(i=s,r_,e_).call(i);return A(s,UE,Math.max(fb.MIN_SIZE,v[2]-v[0])),A(s,QE,Math.max(fb.MIN_SIZE,v[3]-v[1])),o(n=s,jC,OC).call(n,u,c),s}serialize(){if(this.isEmpty())return null;const r=this.getRect(0,0),e=fb._colorManager.convert(this.ctx.strokeStyle);return{annotationType:Ks.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:o(this,qC,KC).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,r),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}};let o_=n_;var s_,f_,l_,u_,c_,d_,h_,b_,g_,p_,v_,m_,k_,w_,y_,E_,C_,__,B_,Z_,W_,I_,R_,F_,x_,S_,M_,G_,X_;QE=new WeakMap,UE=new WeakMap,JE=new WeakMap,zE=new WeakMap,$E=new WeakMap,qE=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 WeakMap,oC=new WeakMap,sC=new WeakSet,fC=function(r){const e=r=>{this.thickness=r,o(this,i_,A_).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:rf.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},lC=new WeakSet,uC=function(r){const e=r=>{this.color=r,o(this,xC,SC).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:rf.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},cC=new WeakSet,dC=function(r){const e=r=>{this.opacity=r,o(this,xC,SC).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:rf.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},hC=new WeakSet,bC=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]}},gC=new WeakSet,pC=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")}`},vC=new WeakSet,mC=function(r,e){const a=this._uiManager._signal;this.canvas.addEventListener("contextmenu",vu,{signal:a}),this.canvas.addEventListener("pointerleave",t(this,zE),{signal:a}),this.canvas.addEventListener("pointermove",t(this,JE),{signal:a}),this.canvas.addEventListener("pointerup",t(this,$E),{signal:a}),this.canvas.removeEventListener("pointerdown",t(this,qE)),this.isEditing=!0,t(this,tC)||(A(this,tC,!0),o(this,TC,PC).call(this),this.thickness||(this.thickness=n_._defaultThickness),this.color||(this.color=n_._defaultColor||fb._defaultLineColor),this.opacity??(this.opacity=n_._defaultOpacity)),this.currentPath.push([r,e]),A(this,aC,!1),o(this,gC,pC).call(this),A(this,oC,(()=>{o(this,BC,ZC).call(this),t(this,oC)&&window.requestAnimationFrame(t(this,oC))})),window.requestAnimationFrame(t(this,oC))},kC=new WeakSet,wC=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,rC);if(n.push([r,e]),A(this,aC,!0),n.length<=2)return s.moveTo(...n[0]),void s.lineTo(r,e);3===n.length&&(A(this,rC,s=new Path2D),s.moveTo(...n[0])),o(this,WC,IC).call(this,s,...n.at(-3),...n.at(-2),r,e)},yC=new WeakSet,EC=function(){if(0===this.currentPath.length)return;const r=this.currentPath.at(-1);t(this,rC).lineTo(...r)},CC=new WeakSet,_C=function(r,e){let a;if(A(this,oC,null),r=Math.min(Math.max(r,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),o(this,kC,wC).call(this,r,e),o(this,yC,EC).call(this),1!==this.currentPath.length)a=o(this,RC,FC).call(this);else{const t=[r,e];a=[[t,t.slice(),t.slice(),t]]}const i=t(this,rC),n=this.currentPath;this.currentPath=[],A(this,rC,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,XC,VC).call(this),o(this,NC,DC).call(this)),o(this,i_,A_).call(this))},mustExec:!0})},BC=new WeakSet,ZC=function(){if(!t(this,aC))return;A(this,aC,!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,rC)),i.restore()},WC=new WeakSet,IC=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)},RC=new WeakSet,FC=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},xC=new WeakSet,SC=function(){if(this.isEmpty())return void o(this,LC,YC).call(this);o(this,gC,pC).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,LC,YC).call(this);for(const r of this.bezierPath2D)e.stroke(r)},MC=new WeakSet,GC=function(r){this.canvas.removeEventListener("pointerleave",t(this,zE)),this.canvas.removeEventListener("pointermove",t(this,JE)),this.canvas.removeEventListener("pointerup",t(this,$E)),this.canvas.addEventListener("pointerdown",t(this,qE),{signal:this._uiManager._signal}),t(this,KE)&&clearTimeout(t(this,KE)),A(this,KE,setTimeout((()=>{A(this,KE,null),this.canvas.removeEventListener("contextmenu",vu)}),10)),o(this,CC,_C).call(this,r.offsetX,r.offsetY),this.addToAnnotationStorage(),this.setInBackground()},XC=new WeakSet,VC=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")},NC=new WeakSet,DC=function(){A(this,iC,new ResizeObserver((r=>{const e=r[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}))),t(this,iC).observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{var r;null==(r=t(this,iC))||r.disconnect(),A(this,iC,null)}),{once:!0})},TC=new WeakSet,PC=function(){if(!t(this,tC))return;const[r,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*r),this.canvas.height=Math.ceil(this.height*e),o(this,LC,YC).call(this)},jC=new WeakSet,OC=function(r,e){const a=o(this,a_,t_).call(this),i=(r-a)/t(this,UE),A=(e-a)/t(this,QE);this.scaleFactor=Math.min(i,A)},LC=new WeakSet,YC=function(){const r=o(this,a_,t_).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+r,this.translationY*this.scaleFactor+r)},HC=new WeakSet,QC=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},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]+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},zC=new WeakSet,$C=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},qC=new WeakSet,KC=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=n_,UC,JC).call(i,a,t,this.rotation),points:o(A=n_,UC,JC).call(A,s,t,this.rotation)})}return n},r_=new WeakSet,e_=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=sl.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]},a_=new WeakSet,t_=function(){return t(this,eC)?Math.ceil(this.thickness*this.parentScale):0},i_=new WeakSet,A_=function(r=!1){if(this.isEmpty())return;if(!t(this,eC))return void o(this,xC,SC).call(this);const e=o(this,r_,e_).call(this),a=o(this,a_,t_).call(this);A(this,UE,Math.max(fb.MIN_SIZE,e[2]-e[0])),A(this,QE,Math.max(fb.MIN_SIZE,e[3]-e[1]));const i=Math.ceil(a+t(this,UE)*this.scaleFactor),n=Math.ceil(a+t(this,QE)*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,TC,PC).call(this),o(this,xC,SC).call(this),A(this,AC,i),A(this,nC,n),this.setDims(i,n);const c=r?a/this.scaleFactor/2:0;this.translate(l-this.translationX-c,u-this.translationY-c)},i(o_,HC),i(o_,UC),i(o_,zC),e(o_,"_defaultColor",null),e(o_,"_defaultOpacity",1),e(o_,"_defaultThickness",1),e(o_,"_type","ink"),e(o_,"_editorType",Ks.INK);const V_=class extends fb{constructor(r){super({...r,name:"stampEditor"}),i(this,m_),i(this,w_),i(this,E_),i(this,__),i(this,Z_),i(this,I_),i(this,F_),i(this,S_),i(this,G_),i(this,s_,null),i(this,f_,null),i(this,l_,null),i(this,u_,null),i(this,c_,null),i(this,d_,""),i(this,h_,null),i(this,b_,null),i(this,g_,null),i(this,p_,!1),i(this,v_,!1),A(this,u_,r.bitmapUrl),A(this,c_,r.bitmapFile)}static initialize(r,e){fb.initialize(r,e)}static get supportedTypes(){return Lf(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((r=>`image/${r}`)))}static get supportedTypesStr(){return Lf(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(r){return this.supportedTypes.includes(r)}static paste(r,e){e.pasteEditor(Ks.STAMP,{bitmapFile:r.getAsFile()})}remove(){var r,e;t(this,f_)&&(A(this,s_,null),this._uiManager.imageManager.deleteId(t(this,f_)),null==(r=t(this,h_))||r.remove(),A(this,h_,null),null==(e=t(this,b_))||e.disconnect(),A(this,b_,null),t(this,g_)&&(clearTimeout(t(this,g_)),A(this,g_,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(t(this,f_)&&null===t(this,h_)&&o(this,E_,C_).call(this),this.isAttachedToDOM||this.parent.add(this))):t(this,f_)&&o(this,E_,C_).call(this)}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(t(this,l_)||t(this,s_)||t(this,u_)||t(this,c_)||t(this,f_))}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,s_)?o(this,__,B_).call(this):o(this,E_,C_).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,h_)}static deserialize(r,e,a){if(r instanceof Hk)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,f_,o):A(t,u_,n),A(t,p_,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:Ks.STAMP,bitmapId:t(this,f_),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:t(this,p_),structTreeParentId:this._structTreeParentId};if(r)return a.bitmapUrl=o(this,S_,M_).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,p_)?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(e.stamps.has(t(this,f_))){if(t(this,p_)){const r=e.stamps.get(t(this,f_));n>r.area&&(r.area=n,r.serialized.bitmap.close(),r.serialized.bitmap=o(this,S_,M_).call(this,!1))}}else e.stamps.set(t(this,f_),{area:n,serialized:a}),a.bitmap=o(this,S_,M_).call(this,!1);return a}};let N_=V_;var D_,T_,P_,j_,O_,L_,Y_,H_,Q_,U_,J_,z_,$_,q_,K_,rB,eB,aB,tB,iB,AB,nB,oB,sB;s_=new WeakMap,f_=new WeakMap,l_=new WeakMap,u_=new WeakMap,c_=new WeakMap,d_=new WeakMap,h_=new WeakMap,b_=new WeakMap,g_=new WeakMap,p_=new WeakMap,v_=new WeakMap,m_=new WeakSet,k_=function(r,e=!1){r?(A(this,s_,r.bitmap),e||(A(this,f_,r.id),A(this,p_,r.isSvg)),r.file&&A(this,d_,r.file.name),o(this,__,B_).call(this)):this.remove()},w_=new WeakSet,y_=function(){A(this,l_,null),this._uiManager.enableWaiting(!1),t(this,h_)&&this.div.focus()},E_=new WeakSet,C_=function(){if(t(this,f_))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(t(this,f_)).then((r=>o(this,m_,k_).call(this,r,!0))).finally((()=>o(this,w_,y_).call(this)));if(t(this,u_)){const r=t(this,u_);return A(this,u_,null),this._uiManager.enableWaiting(!0),void A(this,l_,this._uiManager.imageManager.getFromUrl(r).then((r=>o(this,m_,k_).call(this,r))).finally((()=>o(this,w_,y_).call(this))))}if(t(this,c_)){const r=t(this,c_);return A(this,c_,null),this._uiManager.enableWaiting(!0),void A(this,l_,this._uiManager.imageManager.getFromFile(r).then((r=>o(this,m_,k_).call(this,r))).finally((()=>o(this,w_,y_).call(this))))}const r=document.createElement("input");r.type="file",r.accept=V_.supportedTypesStr;const e=this._uiManager._signal;A(this,l_,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,m_,k_).call(this,e)}else this.remove();a()}),{signal:e}),r.addEventListener("cancel",(()=>{this.remove(),a()}),{signal:e})})).finally((()=>o(this,w_,y_).call(this)))),r.click()},__=new WeakSet,B_=function(){const{div:r}=this;let{width:e,height:a}=t(this,s_);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,h_,document.createElement("canvas"));r.append(u),r.hidden=!1,o(this,F_,x_).call(this,e,a),o(this,G_,X_).call(this),t(this,v_)||(this.parent.addUndoableEditor(this),A(this,v_,!0)),this._reportTelemetry({action:"inserted_image"}),t(this,d_)&&u.setAttribute("aria-label",t(this,d_))},Z_=new WeakSet,W_=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,g_)&&clearTimeout(t(this,g_)),A(this,g_,setTimeout((()=>{A(this,g_,null),o(this,F_,x_).call(this,r,e)}),200))},I_=new WeakSet,R_=function(r,e){const{width:a,height:i}=t(this,s_);let A=a,n=i,o=t(this,s_);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},F_=new WeakSet,x_=function(r,e){r=Math.ceil(r),e=Math.ceil(e);const a=t(this,h_);if(!a||a.width===r&&a.height===e)return;a.width=r,a.height=e;const i=t(this,p_)?t(this,s_):o(this,I_,R_).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)},S_=new WeakSet,M_=function(r){if(r){if(t(this,p_)){const r=this._uiManager.imageManager.getSvgUrl(t(this,f_));if(r)return r}const r=document.createElement("canvas");return({width:r.width,height:r.height}=t(this,s_)),r.getContext("2d").drawImage(t(this,s_),0,0),r.toDataURL()}if(t(this,p_)){const[r,e]=this.pageDimensions,a=Math.round(this.width*r*Fl.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*Fl.PDF_TO_CSS_UNITS),A=new OffscreenCanvas(a,i);return A.getContext("2d").drawImage(t(this,s_),0,0,t(this,s_).width,t(this,s_).height,0,0,a,i),A.transferToImageBitmap()}return structuredClone(t(this,s_))},G_=new WeakSet,X_=function(){this._uiManager._signal&&(A(this,b_,new ResizeObserver((r=>{const e=r[0].contentRect;e.width&&e.height&&o(this,Z_,W_).call(this,e.width,e.height)}))),t(this,b_).observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{var r;null==(r=t(this,b_))||r.disconnect(),A(this,b_,null)}),{once:!0}))},e(N_,"_type","stamp"),e(N_,"_editorType",Ks.STAMP);const fB=class{constructor({uiManager:r,pageIndex:e,div:a,accessibilityManager:n,annotationLayer:o,drawLayer:s,textLayer:f,viewport:l,l10n:u}){i(this,K_),i(this,eB),i(this,tB),i(this,AB),i(this,oB),i(this,D_,void 0),i(this,T_,!1),i(this,P_,null),i(this,j_,null),i(this,O_,null),i(this,L_,null),i(this,Y_,null),i(this,H_,new Map),i(this,Q_,!1),i(this,U_,!1),i(this,J_,!1),i(this,z_,null),i(this,$_,void 0);const c=[...t(fB,q_).values()];if(!fB._initialized){fB._initialized=!0;for(const e of c)e.initialize(u,r)}r.registerEditorTypes(c),A(this,$_,r),this.pageIndex=e,this.div=a,A(this,D_,n),A(this,P_,o),this.viewport=l,A(this,z_,f),this.drawLayer=s,t(this,$_).addLayer(this)}get isEmpty(){return 0===t(this,H_).size}get isInvisible(){return this.isEmpty&&t(this,$_).getMode()===Ks.NONE}updateToolbar(r){t(this,$_).updateToolbar(r)}updateMode(r=t(this,$_).getMode()){switch(o(this,oB,sB).call(this),r){case Ks.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Ks.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case Ks.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(fB,q_).values())e.toggle(`${a._type}Editing`,r===a._editorType);this.div.hidden=!1}hasTextLayer(r){var e;return r===(null==(e=t(this,z_))?void 0:e.div)}addInkEditorIfNeeded(r){if(t(this,$_).getMode()===Ks.INK){if(!r)for(const r of t(this,H_).values())if(r.isEmpty())return void r.setInBackground();this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(r){t(this,$_).setEditingState(r)}addCommands(r){t(this,$_).addCommands(r)}togglePointerEvents(r=!1){this.div.classList.toggle("disabled",!r)}toggleAnnotationLayerPointerEvents(r=!1){var e;null==(e=t(this,P_))||e.div.classList.toggle("disabled",!r)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const r=new Set;for(const e of t(this,H_).values())e.enableEditing(),e.show(!0),e.annotationElementId&&(t(this,$_).removeChangedExistingAnnotation(e),r.add(e.annotationElementId));if(!t(this,P_))return;const e=t(this,P_).getEditableAnnotations();for(const a of e){if(a.hide(),t(this,$_).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,J_,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,a=new Map;for(const i of t(this,H_).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,P_)){const r=t(this,P_).getEditableAnnotations();for(const i of r){const{id:r}=i.data;if(t(this,$_).isDeletedAnnotationElement(r))continue;let A=a.get(r);A?(A.resetAnnotationElement(i),A.show(!1),i.show()):(A=e.get(r),A&&(t(this,$_).addChangedExistingAnnotation(A),A.renderAnnotationElement(i),A.show(!1)),i.show())}}o(this,oB,sB).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const r of t(fB,q_).values())i.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),A(this,J_,!1)}getEditableAnnotation(r){var e;return(null==(e=t(this,P_))?void 0:e.getEditableAnnotation(r))||null}setActiveEditor(r){t(this,$_).getActive()!==r&&t(this,$_).setActiveEditor(r)}enableTextSelection(){var r;this.div.tabIndex=-1,null!=(r=t(this,z_))&&r.div&&!t(this,L_)&&(A(this,L_,o(this,K_,rB).bind(this)),t(this,z_).div.addEventListener("pointerdown",t(this,L_),{signal:t(this,$_)._signal}),t(this,z_).div.classList.add("highlighting"))}disableTextSelection(){var r;this.div.tabIndex=0,null!=(r=t(this,z_))&&r.div&&t(this,L_)&&(t(this,z_).div.removeEventListener("pointerdown",t(this,L_)),A(this,L_,null),t(this,z_).div.classList.remove("highlighting"))}enableClick(){if(t(this,O_))return;const r=t(this,$_)._signal;A(this,O_,this.pointerdown.bind(this)),A(this,j_,this.pointerup.bind(this)),this.div.addEventListener("pointerdown",t(this,O_),{signal:r}),this.div.addEventListener("pointerup",t(this,j_),{signal:r})}disableClick(){t(this,O_)&&(this.div.removeEventListener("pointerdown",t(this,O_)),this.div.removeEventListener("pointerup",t(this,j_)),A(this,O_,null),A(this,j_,null))}attach(r){t(this,H_).set(r.id,r);const{annotationElementId:e}=r;e&&t(this,$_).isDeletedAnnotationElement(e)&&t(this,$_).removeDeletedAnnotationElement(r)}detach(r){var e;t(this,H_).delete(r.id),null==(e=t(this,D_))||e.removePointerInTextLayer(r.contentDiv),!t(this,J_)&&r.annotationElementId&&t(this,$_).addDeletedAnnotationElement(r)}remove(r){this.detach(r),t(this,$_).removeEditor(r),r.div.remove(),r.isAttachedToDOM=!1,t(this,U_)||this.addInkEditorIfNeeded(!1)}changeParent(r){var e;r.parent!==this&&(r.parent&&r.annotationElementId&&(t(this,$_).addDeletedAnnotationElement(r.annotationElementId),fb.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,$_).addEditor(r),this.attach(r),!r.isAttachedToDOM){const e=r.render();this.div.append(e),r.isAttachedToDOM=!0}r.fixAndSetPosition(),r.onceAdded(),t(this,$_).addToAnnotationStorage(r),r._reportTelemetry(r.telemetryInitialData)}}moveEditorInDOM(r){var e;if(!r.isAttachedToDOM)return;const{activeElement:a}=document;r.div.contains(a)&&!t(this,Y_)&&(r._focusEventsAllowed=!1,A(this,Y_,setTimeout((()=>{A(this,Y_,null),r.div.contains(document.activeElement)?r._focusEventsAllowed=!0:(r.div.addEventListener("focusin",(()=>{r._focusEventsAllowed=!0}),{once:!0,signal:t(this,$_)._signal}),a.focus())}),0))),r._structTreeParentId=null==(e=t(this,D_))?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,$_).getId()}get _signal(){return t(this,$_)._signal}canCreateNewEmptyEditor(){var r;return null==(r=t(this,eB,aB))?void 0:r.canCreateNewEmptyEditor()}pasteEditor(r,e){t(this,$_).updateToolbar(r),t(this,$_).updateMode(r);const{offsetX:a,offsetY:i}=o(this,AB,nB).call(this),A=this.getNextId(),n=o(this,tB,iB).call(this,{parent:this,id:A,x:a,y:i,uiManager:t(this,$_),isCentered:!0,...e});n&&this.add(n)}deserialize(r){var e;return(null==(e=t(fB,q_).get(r.annotationType??r.annotationEditorType))?void 0:e.deserialize(r,this,t(this,$_)))||null}createAndAddNewEditor(r,e,a={}){const i=this.getNextId(),A=o(this,tB,iB).call(this,{parent:this,id:i,x:r.offsetX,y:r.offsetY,uiManager:t(this,$_),isCentered:e,...a});return A&&this.add(A),A}addNewEditor(){this.createAndAddNewEditor(o(this,AB,nB).call(this),!0)}setSelected(r){t(this,$_).setSelected(r)}toggleSelected(r){t(this,$_).toggleSelected(r)}isSelected(r){return t(this,$_).isSelected(r)}unselect(r){t(this,$_).unselect(r)}pointerup(r){const{isMac:e}=al.platform;if(!(0!==r.button||r.ctrlKey&&e)&&r.target===this.div&&t(this,Q_)){if(A(this,Q_,!1),!t(this,T_))return void A(this,T_,!0);if(t(this,$_).getMode()===Ks.STAMP)return void t(this,$_).unselectAll();this.createAndAddNewEditor(r,!1)}}pointerdown(r){if(t(this,$_).getMode()===Ks.HIGHLIGHT&&this.enableTextSelection(),t(this,Q_))return void A(this,Q_,!1);const{isMac:e}=al.platform;if(0!==r.button||r.ctrlKey&&e||r.target!==this.div)return;A(this,Q_,!0);const a=t(this,$_).getActive();A(this,T_,!a||a.isEmpty())}findNewParent(r,e,a){const i=t(this,$_).findParent(e,a);return null!==i&&i!==this&&(i.changeParent(r),!0)}destroy(){var r,e;(null==(r=t(this,$_).getActive())?void 0:r.parent)===this&&(t(this,$_).commitOrRemove(),t(this,$_).setActiveEditor(null)),t(this,Y_)&&(clearTimeout(t(this,Y_)),A(this,Y_,null));for(const r of t(this,H_).values())null==(e=t(this,D_))||e.removePointerInTextLayer(r.contentDiv),r.setParent(null),r.isAttachedToDOM=!1,r.div.remove();this.div=null,t(this,H_).clear(),t(this,$_).removeLayer(this)}render({viewport:r}){this.viewport=r,Bu(this.div,r);for(const r of t(this,$_).getEditors(this.pageIndex))this.add(r),r.rebuild();this.updateMode()}update({viewport:r}){t(this,$_).commitOrRemove(),o(this,oB,sB).call(this);const e=this.viewport.rotation,a=r.rotation;if(this.viewport=r,Bu(this.div,{rotation:a}),e!==a)for(const r of t(this,H_).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,$_).viewParameters.realScale}};let lB=fB;var uB,cB,dB,hB,bB,gB,pB,vB,mB,kB;D_=new WeakMap,T_=new WeakMap,P_=new WeakMap,j_=new WeakMap,O_=new WeakMap,L_=new WeakMap,Y_=new WeakMap,H_=new WeakMap,Q_=new WeakMap,U_=new WeakMap,J_=new WeakMap,z_=new WeakMap,$_=new WeakMap,q_=new WeakMap,K_=new WeakSet,rB=function(r){if(t(this,$_).unselectAll(),r.target===t(this,z_).div){const{isMac:e}=al.platform;if(0!==r.button||r.ctrlKey&&e)return;t(this,$_).showAllEditors("highlight",!0,!0),t(this,z_).div.classList.add("free"),HE.startHighlighting(this,"ltr"===t(this,$_).direction,r),t(this,z_).div.addEventListener("pointerup",(()=>{t(this,z_).div.classList.remove("free")}),{once:!0,signal:t(this,$_)._signal}),r.preventDefault()}},eB=new WeakSet,aB=function(){return t(fB,q_).get(t(this,$_).getMode())},tB=new WeakSet,iB=function(r){const e=t(this,eB,aB);return e?new e.prototype.constructor(r):null},AB=new WeakSet,nB=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}},oB=new WeakSet,sB=function(){A(this,U_,!0);for(const r of t(this,H_).values())r.isEmpty()&&r.remove();A(this,U_,!1)},e(lB,"_initialized",!1),i(lB,q_,new Map([_w,o_,N_,HE].map((r=>[r._editorType,r]))));const wB=class{constructor({pageIndex:r}){i(this,pB),i(this,mB),i(this,uB,null),i(this,cB,0),i(this,dB,new Map),i(this,hB,new Map),this.pageIndex=r}setParent(r){if(t(this,uB)){if(t(this,uB)!==r){if(t(this,dB).size>0)for(const e of t(this,dB).values())e.remove(),r.append(e);A(this,uB,r)}}else A(this,uB,r)}static get _svgFactory(){return Lf(this,"_svgFactory",new fu)}highlight(r,e,a,i=!1){const A=n(this,cB)._++,s=o(this,pB,vB).call(this,r.box);s.classList.add("highlight"),r.free&&s.classList.add("free");const f=wB._svgFactory.createElement("defs");s.append(f);const l=wB._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,hB).set(A,l);const c=o(this,mB,kB).call(this,f,u),d=wB._svgFactory.createElement("use");return s.append(d),s.setAttribute("fill",e),s.setAttribute("fill-opacity",a),d.setAttribute("href",`#${u}`),t(this,dB).set(A,s),{id:A,clipPathId:`url(#${c})`}}highlightOutline(r){const e=n(this,cB)._++,a=o(this,pB,vB).call(this,r.box);a.classList.add("highlightOutline");const i=wB._svgFactory.createElement("defs");a.append(i);const A=wB._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=wB._svgFactory.createElement("mask");i.append(r),f=`mask_p${this.pageIndex}_${e}`,r.setAttribute("id",f),r.setAttribute("maskUnits","objectBoundingBox");const t=wB._svgFactory.createElement("rect");r.append(t),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("fill","white");const A=wB._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=wB._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,dB).set(e,a),e}finalizeLine(r,e){const a=t(this,hB).get(r);t(this,hB).delete(r),this.updateBox(r,e.box),a.setAttribute("d",e.toSVGPath())}updateLine(r,e){t(this,dB).get(r).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(r){this.remove(r),t(this,hB).delete(r)}updatePath(r,e){t(this,hB).get(r).setAttribute("d",e.toSVGPath())}updateBox(r,e){var a;o(a=wB,bB,gB).call(a,t(this,dB).get(r),e)}show(r,e){t(this,dB).get(r).classList.toggle("hidden",!e)}rotate(r,e){t(this,dB).get(r).setAttribute("data-main-rotation",e)}changeColor(r,e){t(this,dB).get(r).setAttribute("fill",e)}changeOpacity(r,e){t(this,dB).get(r).setAttribute("fill-opacity",e)}addClass(r,e){t(this,dB).get(r).classList.add(e)}removeClass(r,e){t(this,dB).get(r).classList.remove(e)}remove(r){null!==t(this,uB)&&(t(this,dB).get(r).remove(),t(this,dB).delete(r))}destroy(){A(this,uB,null);for(const r of t(this,dB).values())r.remove();t(this,dB).clear()}};let yB=wB;uB=new WeakMap,cB=new WeakMap,dB=new WeakMap,hB=new WeakMap,bB=new WeakSet,gB=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+"%"},pB=new WeakSet,vB=function(r){var e;const a=wB._svgFactory.create(1,1,!0);return t(this,uB).append(a),a.setAttribute("aria-hidden",!0),o(e=wB,bB,gB).call(e,a,r),a},mB=new WeakSet,kB=function(r,e){const a=wB._svgFactory.createElement("clipPath");r.append(a);const t=`clip_${e}`;a.setAttribute("id",t),a.setAttribute("clipPathUnits","objectBoundingBox");const i=wB._svgFactory.createElement("use");return a.append(i),i.setAttribute("href",`#${e}`),i.classList.add("clip"),t},i(yB,bB);var EB=Ts.AbortException,CB=Ts.AnnotationEditorLayer,_B=Ts.AnnotationEditorParamsType,BB=Ts.AnnotationEditorType,ZB=Ts.AnnotationEditorUIManager,WB=Ts.AnnotationLayer,IB=Ts.AnnotationMode,RB=Ts.CMapCompressionType,FB=Ts.ColorPicker,xB=Ts.DOMSVGFactory,SB=Ts.DrawLayer,MB=Ts.FeatureTest,GB=Ts.GlobalWorkerOptions,XB=Ts.ImageKind,VB=Ts.InvalidPDFException,NB=Ts.MissingPDFException,DB=Ts.OPS,TB=Ts.Outliner,PB=Ts.PDFDataRangeTransport,jB=Ts.PDFDateString,OB=Ts.PDFWorker,LB=Ts.PasswordResponses,YB=Ts.PermissionFlag,HB=Ts.PixelsPerInch,QB=Ts.RenderingCancelledException,UB=Ts.TextLayer,JB=Ts.UnexpectedResponseException,zB=Ts.Util,$B=Ts.VerbosityLevel,qB=Ts.XfaLayer,KB=Ts.build,rZ=Ts.createValidAbsoluteUrl,eZ=Ts.fetchData,aZ=Ts.getDocument,tZ=Ts.getFilenameFromUrl,iZ=Ts.getPdfFilenameFromUrl,AZ=Ts.getXfaPageViewport,nZ=Ts.isDataScheme,oZ=Ts.isPdfFile,sZ=Ts.noContextMenu,fZ=Ts.normalizeUnicode,lZ=Ts.renderTextLayer,uZ=Ts.setLayerDimensions,cZ=Ts.shadow,dZ=Ts.updateTextLayer,hZ=Ts.version;const bZ=Object.freeze(Object.defineProperty({__proto__:null,AbortException:EB,AnnotationEditorLayer:CB,AnnotationEditorParamsType:_B,AnnotationEditorType:BB,AnnotationEditorUIManager:ZB,AnnotationLayer:WB,AnnotationMode:IB,CMapCompressionType:RB,ColorPicker:FB,DOMSVGFactory:xB,DrawLayer:SB,FeatureTest:MB,GlobalWorkerOptions:GB,ImageKind:XB,InvalidPDFException:VB,MissingPDFException:NB,OPS:DB,Outliner:TB,PDFDataRangeTransport:PB,PDFDateString:jB,PDFWorker:OB,PasswordResponses:LB,PermissionFlag:YB,PixelsPerInch:HB,RenderingCancelledException:QB,TextLayer:UB,UnexpectedResponseException:JB,Util:zB,VerbosityLevel:$B,XfaLayer:qB,build:KB,createValidAbsoluteUrl:rZ,fetchData:eZ,getDocument:aZ,getFilenameFromUrl:tZ,getPdfFilenameFromUrl:iZ,getXfaPageViewport:AZ,isDataScheme:nZ,isPdfFile:oZ,noContextMenu:sZ,normalizeUnicode:fZ,renderTextLayer:lZ,setLayerDimensions:uZ,shadow:cZ,updateTextLayer:dZ,version:hZ},Symbol.toStringTag,{value:"Module"}));var gZ=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))},pZ=gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ(gZ([],["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 vZ(r,e){var a={};return pZ.forEach((function(t){var i=r[t];i&&(a[t]=e?function(r){return i(r,e(t))}:i)})),a}function mZ(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 kZ(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=kZ(r[e]))&&(t&&(t+=" "),t+=a)}else for(a in r)r[a]&&(t&&(t+=" "),t+=a);return t}function wZ(){for(var r,e,a=0,t="",i=arguments.length;a<i;a++)(r=arguments[a])&&(e=kZ(r))&&(t&&(t+=" "),t+=e);return t}var yZ="production"===process.env.NODE_ENV,EZ="Invariant failed";function CZ(r,e){if(!r){if(yZ)throw new Error(EZ);var a="function"==typeof e?e():e,t=a?"".concat(EZ,": ").concat(a):EZ;throw new Error(t)}}var _Z=function(){};if("production"!==process.env.NODE_ENV){var BZ=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{}};_Z=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||BZ.apply(null,[e].concat(a))}}const ZZ=C(_Z);var WZ=Object.prototype.hasOwnProperty;function IZ(r,e,a){for(a of r.keys())if(RZ(a,e))return a}function RZ(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--&&RZ(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=IZ(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=IZ(e,i))||!RZ(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(WZ.call(r,a)&&++t&&!WZ.call(e,a)||!(a in e)||!RZ(r[a],e[a]))return!1;return Object.keys(e).length===t}}return r!=r&&e!=e}const FZ=h(null);function xZ({children:r,type:e}){return R.jsx("div",{className:`react-pdf__message react-pdf__message--${e}`,children:r})}class SZ{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 CZ(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(r){CZ(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=r}get rotation(){return 0}set rotation(r){}goToDestination(r){return new Promise((e=>{CZ(this.pdfDocument,"PDF document not loaded."),CZ(r,"Destination is not specified."),"string"==typeof r?this.pdfDocument.getDestination(r).then(e):Array.isArray(r)?e(r):r.then(e)})).then((r=>{CZ(Array.isArray(r),`"${r}" is not a valid destination array.`);const e=r[0];new Promise((r=>{CZ(this.pdfDocument,"PDF document not loaded."),e instanceof Object?this.pdfDocument.getPageIndex(e).then((e=>{r(e)})).catch((()=>{CZ(!1,`"${e}" is not a valid page reference.`)})):"number"==typeof e?r(e):CZ(!1,`"${e}" is not a valid destination reference.`)})).then((e=>{const a=e+1;CZ(this.pdfViewer,"PDF viewer is not initialized."),CZ(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;CZ(this.pdfViewer,"PDF viewer is not initialized."),CZ(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 MZ={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},GZ=typeof document<"u",XZ=GZ&&"file:"===window.location.protocol;function VZ(r){return function(r){return typeof r<"u"}(r)&&null!==r}function NZ(r){return function(r){return"string"==typeof r}(r)&&/^data:/.test(r)}function DZ(r){CZ(NZ(r),"Invalid data URI.");const[e="",a=""]=r.split(",");return-1!==e.split(";").indexOf("base64")?atob(a):unescape(a)}function TZ(){return GZ&&window.devicePixelRatio||1}const PZ="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function jZ(){ZZ(!XZ,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${PZ}`)}function OZ(r){null!=r&&r.cancel&&r.cancel()}function LZ(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 YZ(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 HZ(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 QZ(){return g(HZ,{value:void 0,error:void 0})}var UZ=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())}))},JZ=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:zZ}=bZ,$Z=(r,e)=>{switch(e){case MZ.NEED_PASSWORD:r(prompt("Enter the password to open this PDF file."));break;case MZ.INCORRECT_PASSWORD:r(prompt("Invalid password. Please try again."));break}};function qZ(r){return"object"==typeof r&&null!==r&&("data"in r||"range"in r||"url"in r)}const KZ=b((function(r,e){var{children:a,className:t,error:i="Failed to load PDF file.",externalLinkRel:A,externalLinkTarget:n,file:o,inputRef:s,imageResourcesPath:u,loading:c="Loading PDF…",noData:d="No PDF file specified.",onItemClick:h,onLoadError:b,onLoadProgress:g,onLoadSuccess:k,onPassword:w=$Z,onSourceError:y,onSourceSuccess:E,options:C,renderMode:_,rotate:B}=r,Z=JZ(r,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[W,I]=QZ(),{value:F,error:x}=W,[S,M]=QZ(),{value:G,error:X}=S,V=l(new SZ),N=l([]),D=l(void 0),T=l(void 0);o&&o!==D.current&&qZ(o)&&(ZZ(!RZ(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),C&&C!==T.current&&(ZZ(!RZ(C,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=C);const P=l({scrollPageIntoView:r=>{const{dest:e,pageNumber:a,pageIndex:t=a-1}=r;if(h)return void h({dest:e,pageIndex:t,pageNumber:a});const i=N.current[t];i?i.scrollIntoView():ZZ(!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>.`)}});v(e,(()=>({linkService:V,pages:N,viewer:P})),[]),p((function(){I({type:"RESET"})}),[o,I]);const j=m((()=>UZ(this,void 0,void 0,(function*(){if(!o)return null;if("string"==typeof o)return NZ(o)?{data:DZ(o)}:(jZ(),{url:o});if(o instanceof zZ)return{range:o};if(o instanceof ArrayBuffer)return{data:o};if(GZ&&function(r){return CZ(GZ,"isBlob can only be used in a browser environment"),r instanceof Blob}(o))return{data:yield YZ(o)};if(CZ("object"==typeof o,"Invalid parameter in file, need either Uint8Array, string or a parameter object"),CZ(qZ(o),"Invalid parameter object: need either .data, .range or .url"),"url"in o&&"string"==typeof o.url){if(NZ(o.url)){const{url:r}=o,e=JZ(o,["url"]),a=DZ(r);return Object.assign({data:a},e)}jZ()}return o}))),[o]);p((()=>{const r=mZ(j());return r.promise.then((r=>{I({type:"RESOLVE",value:r})})).catch((r=>{I({type:"REJECT",error:r})})),()=>{OZ(r)}}),[j,I]),p((()=>{if(!(typeof F>"u")){if(!1===F)return void(x&&(ZZ(!1,x.toString()),y&&y(x)));E&&E()}}),[F]),p((function(){M({type:"RESET"})}),[M,F]),p((function(){if(!F)return;const r=Object.assign(Object.assign({},F),C),e=aZ(r);g&&(e.onProgress=g),w&&(e.onPassword=w);const a=e;return a.promise.then((r=>{M({type:"RESOLVE",value:r})})).catch((r=>{a.destroyed||M({type:"REJECT",error:r})})),()=>{a.destroy()}}),[C,M,F]),p((()=>{if(!(typeof G>"u")){if(!1===G)return void(X&&(ZZ(!1,X.toString()),b&&b(X)));G&&(k&&k(G),N.current=new Array(G.numPages),V.current.setDocument(G))}}),[G]),p((function(){V.current.setViewer(P.current),V.current.setExternalLinkRel(A),V.current.setExternalLinkTarget(n)}),[A,n]);const O=m(((r,e)=>{N.current[r]=e}),[]),L=m((r=>{delete N.current[r]}),[]),Y=f((()=>({imageResourcesPath:u,linkService:V.current,onItemClick:h,pdf:G,registerPage:O,renderMode:_,rotate:B,unregisterPage:L})),[u,h,G,O,_,B,L]),H=f((()=>vZ(Z,(()=>G))),[Z,G]);return R.jsx("div",Object.assign({className:wZ("react-pdf__Document",t),ref:s,style:{"--scale-factor":"1"}},H,{children:o?null==G?R.jsx(xZ,{type:"loading",children:"function"==typeof c?c():c}):!1===G?R.jsx(xZ,{type:"error",children:"function"==typeof i?i():i}):R.jsx(FZ.Provider,{value:Y,children:a}):R.jsx(xZ,{type:"no-data",children:"function"==typeof d?d():d})}))})),rW=KZ;function eW(){return d(FZ)}function aW(){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 tW=h(null),iW={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},AW=/^H(\d+)$/;function nW(r){return"children"in r}function oW(r){return!!nW(r)&&(1===r.children.length&&0 in r.children&&"id"in r.children[0])}function sW(r){const e={};if(nW(r)){const{role:a}=r,t=a.match(AW);if(t)e.role="heading",e["aria-level"]=Number(t[1]);else if(function(r){return r in iW}(a)){const r=iW[a];r&&(e.role=r)}}return e}function fW(r){const e={};if(nW(r)){if(void 0!==r.alt&&(e["aria-label"]=r.alt),void 0!==r.lang&&(e.lang=r.lang),oW(r)){const[a]=r.children;if(a){const r=fW(a);return Object.assign(Object.assign({},e),r)}}}else"id"in r&&(e["aria-owns"]=r.id);return e}function lW(r){return r?Object.assign(Object.assign({},sW(r)),fW(r)):null}function uW({className:r,node:e}){const a=f((()=>lW(e)),[e]),t=f((()=>!nW(e)||oW(e)?null:e.children.map(((r,e)=>R.jsx(uW,{node:r},e)))),[e]);return R.jsx("span",Object.assign({className:r},a,{children:t}))}function cW(){return d(tW)}function dW(){const r=cW();CZ(r,"Unable to find Page context.");const{onGetStructTreeError:e,onGetStructTreeSuccess:a}=r,[t,i]=QZ(),{value:A,error:n}=t,{customTextRenderer:o,page:s}=r;return p((function(){i({type:"RESET"})}),[i,s]),p((function(){if(o||!s)return;const r=mZ(s.getStructTree()),e=r;return r.promise.then((r=>{i({type:"RESOLVE",value:r})})).catch((r=>{i({type:"REJECT",error:r})})),()=>OZ(e)}),[o,s,i]),p((()=>{if(void 0!==A){if(!1===A)return void(n&&(ZZ(!1,n.toString()),e&&e(n)));A&&a&&a(A)}}),[A]),A?R.jsx(uW,{className:"react-pdf__Page__structTree structTree",node:A}):null}const hW=IB;function bW(r){const e=cW();CZ(e,"Unable to find Page context.");const a=Object.assign(Object.assign({},e),r),{_className:t,canvasBackground:i,devicePixelRatio:A=TZ(),onRenderError:n,onRenderSuccess:o,page:s,renderForms:u,renderTextLayer:c,rotate:d,scale:h}=a,{canvasRef:b}=r;CZ(s,"Attempted to render page canvas, but no page was specified.");const g=l(null);function v(r){(function(r){return"RenderingCancelledException"===r.name})(r)||(ZZ(!1,r.toString()),n&&n(r))}const k=f((()=>s.getViewport({scale:h*A,rotation:d})),[A,s,d,h]),w=f((()=>s.getViewport({scale:h,rotation:d})),[s,d,h]);p((function(){if(!s)return;s.cleanup();const{current:r}=g;if(!r)return;r.width=k.width,r.height=k.height,r.style.width=`${Math.floor(w.width)}px`,r.style.height=`${Math.floor(w.height)}px`,r.style.visibility="hidden";const e={annotationMode:u?hW.ENABLE_FORMS:hW.ENABLE,canvasContext:r.getContext("2d",{alpha:!1}),viewport:k};i&&(e.background=i);const a=s.render(e),t=a;return a.promise.then((()=>{r.style.visibility="",s&&o&&o(LZ(s,h))})).catch(v),()=>OZ(t)}),[i,s,u,k,w]);const y=m((()=>{const{current:r}=g;r&&(r.width=0,r.height=0)}),[]);return p((()=>y),[y]),R.jsx("canvas",{className:`${t}__canvas`,dir:"ltr",ref:aW(b,g),style:{display:"block",userSelect:"none"},children:c?R.jsx(dW,{}):null})}function gW(){const r=cW();CZ(r,"Unable to find Page context.");const{customTextRenderer:e,onGetTextError:a,onGetTextSuccess:t,onRenderTextLayerError:i,onRenderTextLayerSuccess:A,page:n,pageIndex:o,pageNumber:s,rotate:u,scale:c}=r;CZ(n,"Attempted to load page text content, but no page was specified.");const[d,h]=QZ(),{value:b,error:g}=d,v=l(null),k=l(void 0);ZZ(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"),p((function(){h({type:"RESET"})}),[n,h]),p((function(){if(!n)return;const r=mZ(n.getTextContent()),e=r;return r.promise.then((r=>{h({type:"RESOLVE",value:r})})).catch((r=>{h({type:"REJECT",error:r})})),()=>OZ(e)}),[n,h]),p((()=>{if(void 0!==b){if(!1===b)return void(g&&(ZZ(!1,g.toString()),a&&a(g)));b&&t&&t(b)}}),[b]);const y=m((()=>{A&&A()}),[A]),E=m((r=>{ZZ(!1,r.toString()),i&&i(r)}),[i]);const C=f((()=>n.getViewport({scale:c,rotation:u})),[n,u,c]);return w((function(){if(!n||!b)return;const{current:r}=v;if(!r)return;r.innerHTML="";const a=n.streamTextContent({includeMarkedContent:!0}),t=new UB({container:r,textContentSource:a,viewport:C}),i=t;return t.render().then((()=>{const a=document.createElement("div");a.className="endOfContent",r.append(a),k.current=a;const t=r.querySelectorAll('[role="presentation"]');if(e){let r=0;b.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:s,itemIndex:i},a));A.innerHTML=n,r+=a.str&&a.hasEOL?2:1}))}y()})).catch(E),()=>OZ(i)}),[e,E,y,n,o,s,b,C]),R.jsx("div",{className:wZ("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){const r=k.current;r&&r.classList.remove("active")},onMouseDown:function(){const r=k.current;r&&r.classList.add("active")},ref:v})}function pW(){const r=eW(),e=cW();CZ(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:s,page:u,pdf:c,renderForms:d,rotate:h,scale:b=1}=a;CZ(c,"Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."),CZ(u,"Attempted to load page annotations, but no page was specified."),CZ(i,"Attempted to load page annotations, but no linkService was specified.");const[g,v]=QZ(),{value:m,error:k}=g,w=l(null);ZZ(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"),p((function(){v({type:"RESET"})}),[v,u]),p((function(){if(!u)return;const r=mZ(u.getAnnotations()),e=r;return r.promise.then((r=>{v({type:"RESOLVE",value:r})})).catch((r=>{v({type:"REJECT",error:r})})),()=>{OZ(e)}}),[v,u]),p((()=>{if(void 0!==m){if(!1===m)return void(k&&(ZZ(!1,k.toString()),A&&A(k)));m&&n&&n(m)}}),[m]);const y=f((()=>u.getViewport({scale:b,rotation:h})),[u,h,b]);return p((function(){if(!(c&&u&&i&&m))return;const{current:r}=w;if(!r)return;const e=y.clone({dontFlip:!0}),a={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:r,l10n:null,page:u,viewport:e},A={annotations:m,annotationStorage:c.annotationStorage,div:r,imageResourcesPath:t,linkService:i,page:u,renderForms:d,viewport:e};r.innerHTML="";try{new WB(a).render(A),s&&s()}catch(r){ZZ(!1,`${n=r}`),o&&o(n)}var n;return()=>{}}),[m,t,i,u,c,d,y]),R.jsx("div",{className:wZ("react-pdf__Page__annotations","annotationLayer"),ref:w})}var vW=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 mW=1;function kW(r){const e=eW(),a=Object.assign(Object.assign({},e),r),{_className:t="react-pdf__Page",_enableRegisterUnregisterPage:i=!0,canvasBackground:A,canvasRef:n,children:o,className:s,customRenderer:u,customTextRenderer:c,devicePixelRatio:d,error:h="Failed to load the page.",height:b,inputRef:g,loading:v="Loading page…",noData:m="No page specified.",onGetAnnotationsError:k,onGetAnnotationsSuccess:w,onGetStructTreeError:y,onGetStructTreeSuccess:E,onGetTextError:C,onGetTextSuccess:_,onLoadError:B,onLoadSuccess:Z,onRenderAnnotationLayerError:W,onRenderAnnotationLayerSuccess:I,onRenderError:F,onRenderSuccess:x,onRenderTextLayerError:S,onRenderTextLayerSuccess:M,pageIndex:G,pageNumber:X,pdf:V,registerPage:N,renderAnnotationLayer:D=!0,renderForms:T=!1,renderMode:P="canvas",renderTextLayer:j=!0,rotate:O,scale:L=mW,unregisterPage:Y,width:H}=a,Q=vW(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"]),[U,J]=QZ(),{value:z,error:$}=U,q=l(null);CZ(V,"Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.");const K=VZ(X)?X-1:G??null,rr=X??(VZ(G)?G+1:null),er=O??(z?z.rotate:null),ar=f((()=>{if(!z)return null;let r=1;const e=L??mW;if(H||b){const e=z.getViewport({scale:1,rotation:er});H?r=H/e.width:b&&(r=b/e.height)}return e*r}),[b,z,er,L,H]);p((function(){return()=>{VZ(K)&&i&&Y&&Y(K)}}),[i,V,K,Y]),p((function(){J({type:"RESET"})}),[J,V,K]),p((function(){if(!V||!rr)return;const r=mZ(V.getPage(rr)),e=r;return r.promise.then((r=>{J({type:"RESOLVE",value:r})})).catch((r=>{J({type:"REJECT",error:r})})),()=>OZ(e)}),[J,V,rr]),p((()=>{if(void 0!==z){if(!1===z)return void($&&(ZZ(!1,$.toString()),B&&B($)));!function(){if(Z){if(!z||!ar)return;Z(LZ(z,ar))}if(i&&N){if(!VZ(K)||!q.current)return;N(K,q.current)}}()}}),[z,ar]);const tr=f((()=>z&&VZ(K)&&rr&&VZ(er)&&VZ(ar)?{_className:t,canvasBackground:A,customTextRenderer:c,devicePixelRatio:d,onGetAnnotationsError:k,onGetAnnotationsSuccess:w,onGetStructTreeError:y,onGetStructTreeSuccess:E,onGetTextError:C,onGetTextSuccess:_,onRenderAnnotationLayerError:W,onRenderAnnotationLayerSuccess:I,onRenderError:F,onRenderSuccess:x,onRenderTextLayerError:S,onRenderTextLayerSuccess:M,page:z,pageIndex:K,pageNumber:rr,renderForms:T,renderTextLayer:j,rotate:er,scale:ar}:null),[t,A,c,d,k,w,y,E,C,_,W,I,F,x,S,M,z,K,rr,T,j,er,ar]),ir=f((()=>vZ(Q,(()=>z&&(ar?LZ(z,ar):void 0)))),[Q,z,ar]),Ar=`${K}@${ar}/${er}`;function nr(){switch(P){case"custom":return CZ(u,'renderMode was set to "custom", but no customRenderer was passed.'),R.jsx(u,{},`${Ar}_custom`);case"none":return null;default:return R.jsx(bW,{canvasRef:n},`${Ar}_canvas`)}}return R.jsx("div",Object.assign({className:wZ(t,s),"data-page-number":rr,ref:aW(g,q),style:{"--scale-factor":`${ar}`,backgroundColor:A||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},ir,{children:rr?null===V||null==z?R.jsx(xZ,{type:"loading",children:"function"==typeof v?v():v}):!1===V||!1===z?R.jsx(xZ,{type:"error",children:"function"==typeof h?h():h}):R.jsxs(tW.Provider,{value:tr,children:[nr(),j?R.jsx(gW,{},`${Ar}_text`):null,D?R.jsx(pW,{},`${Ar}_annotations`):null,o]}):R.jsx(xZ,{type:"no-data",children:"function"==typeof m?m():m})}))}ZZ(!XZ,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${PZ}`),GB.workerSrc="pdf.worker.mjs";const wW="SET_ZOOM_LEVEL",yW=r=>({type:wW,value:r}),EW="SET_PDF_PAGINATED",CW="SET_NUM_PAGES",_W=r=>({type:CW,value:r}),BW="SET_CURRENT_PAGE",ZW=r=>({type:BW,value:r}),WW={defaultZoomLevel:1,zoomLevel:1,zoomJump:.1,paginated:!0,numPages:0,currentPage:1,disablePageTags:!1},IW=(r=WW,e)=>{switch(e.type){case wW:{const{value:a}=e;return{...r,zoomLevel:a}}case EW:{const{value:a}=e;return{...r,paginated:a}}case CW:{const{value:a}=e;return{...r,numPages:a}}case BW:{const{value:a}=e;return{...r,currentPage:a}}default:return r}},RW=h({state:WW,dispatch:()=>null}),FW=({children:r,mainState:e})=>{var a,t,i,A,n,o,s,f;const[l,u]=g(IW,{...WW,defaultZoomLevel:(null==(t=null==(a=e.config)?void 0:a.pdfZoom)?void 0:t.defaultZoom)??WW.defaultZoomLevel,zoomLevel:(null==(A=null==(i=e.config)?void 0:i.pdfZoom)?void 0:A.defaultZoom)??WW.zoomLevel,zoomJump:(null==(o=null==(n=e.config)?void 0:n.pdfZoom)?void 0:o.zoomJump)??WW.zoomJump,paginated:(null==(s=e.config)||!s.pdfVerticalScrollByDefault)&&WW.paginated,disablePageTags:(null==(f=e.config)?void 0:f.disablePageTags)||!1,mainState:e});return R.jsx(RW.Provider,{value:{state:l,dispatch:u},children:r})},xW=({pageNum:r})=>{const{state:{mainState:e,paginated:a,zoomLevel:t,numPages:i,currentPage:A,disablePageTags:n}}=d(RW),{t:o}=as(),s=(null==e?void 0:e.rendererRect)||null,f=r??A;return R.jsxs(SW,{id:"pdf-page-wrapper",$lastPage:f>=i,children:[!a&&!n&&R.jsx(MW,{id:"pdf-page-info",children:o("pdfPluginPageNumber",{currentPage:f,allPagesCount:i})}),R.jsx(kW,{pageNumber:f||A,scale:t,height:((null==s?void 0:s.height)??100)-100,width:((null==s?void 0:s.width)??100)-100,loading:o("pdfPluginLoading")})]})},SW=no.div`
|
|
173
173
|
margin-bottom: ${r=>r.$lastPage?"20px":void 0};
|
|
174
174
|
`,MW=no.div`
|
|
175
175
|
padding: 0 0 10px 10px;
|
|
@@ -184,6 +184,8 @@ var r=Object.defineProperty,e=(e,a,t)=>(((e,a,t)=>{a in e?r(e,a,{enumerable:!0,c
|
|
|
184
184
|
display: flex;
|
|
185
185
|
flex-direction: column;
|
|
186
186
|
margin: 0 auto;
|
|
187
|
+
overflow-x: auto;
|
|
188
|
+
width: 100%;
|
|
187
189
|
`,NW=r=>R.jsx(TW,{...r,reverse:!0}),DW=r=>R.jsx(TW,{...r}),TW=r=>{const{color:e,size:a,reverse:t}=r;return R.jsx("svg",{width:a||"100%",height:a||"100%",style:{transform:""+(t?"rotate(180deg)":"")},viewBox:"0 0 12 12",version:"1.1",children:R.jsx("g",{id:"Icons",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:R.jsx("g",{id:"Rounded",transform:"translate(-548.000000, -1000.000000)",children:R.jsx("g",{id:"AV",transform:"translate(100.000000, 852.000000)",children:R.jsx("g",{id:"-Round-/-AV-/-skip_next",transform:"translate(442.000000, 142.000000)",children:R.jsxs("g",{children:[R.jsx("rect",{id:"Rectangle-Copy-52",x:"0",y:"0",width:"24",height:"24"}),R.jsx("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"})]})})})})})})},PW=r=>{const{color:e,size:a,reverse:t}=r;return R.jsxs("svg",{width:a||"100%",height:a||"100%",style:{transform:""+(t?"rotate(180deg)":"")},id:"Layer_1",viewBox:"0 0 24 24",children:[R.jsx("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"}),R.jsx("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"})]})},jW=r=>R.jsx(LW,{...r}),OW=r=>R.jsx(LW,{...r,reverse:!0}),LW=r=>{const{color:e,size:a,reverse:t}=r;return R.jsx("svg",{width:a||"100%",height:a||"100%",viewBox:"0 0 32 32",version:"1.1",children:R.jsx("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:R.jsx("g",{id:"search-plus-icon",fill:e||"#aaa",children:R.jsx("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"})})})})},YW=r=>{const{color:e,size:a}=r;return R.jsx("svg",{width:a||"100%",height:a||"100%",viewBox:"0 0 24 24",children:R.jsx("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"})})},HW=r=>{const{color:e,size:a,reverse:t}=r;return R.jsx("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:R.jsx("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"})})},QW=({color:r,size:e,reverse:a})=>R.jsx("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:R.jsx("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"})}),UW=()=>{const{state:{currentPage:r,numPages:e},dispatch:a}=d(RW),{t:t}=as();return R.jsxs(JW,{id:"pdf-pagination",children:[R.jsx(zW,{id:"pdf-pagination-prev",onClick:()=>a(ZW(r-1)),disabled:1===r,children:R.jsx(NW,{color:"#000",size:"50%"})}),R.jsx(qW,{id:"pdf-pagination-info",children:t("pdfPluginPageNumber",{currentPage:r,allPagesCount:e})}),R.jsx($W,{id:"pdf-pagination-next",onClick:()=>a(ZW(r+1)),disabled:r>=e,children:R.jsx(DW,{color:"#000",size:"50%"})})]})},JW=no.div`
|
|
188
190
|
display: flex;
|
|
189
191
|
align-items: center;
|