@qaecy/cue-ui 0.0.66 → 0.0.67

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/198.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[198],{60198(Sn,ye,V){V.d(ye,{PDFViewer:()=>Dd});var Bt={};V.r(Bt),V.d(Bt,{AbortException:()=>Zo,AnnotationEditorLayer:()=>Jo,AnnotationEditorParamsType:()=>tl,AnnotationEditorType:()=>Es,AnnotationEditorUIManager:()=>el,AnnotationLayer:()=>il,AnnotationMode:()=>nl,ColorPicker:()=>sl,DOMSVGFactory:()=>rl,DrawLayer:()=>al,FeatureTest:()=>ol,GlobalWorkerOptions:()=>xs,ImageKind:()=>ll,InvalidPDFException:()=>hl,MissingPDFException:()=>cl,OPS:()=>dl,OutputScale:()=>ul,PDFDataRangeTransport:()=>fl,PDFDateString:()=>pl,PDFWorker:()=>gl,PasswordResponses:()=>ml,PermissionFlag:()=>bl,PixelsPerInch:()=>_l,RenderingCancelledException:()=>vl,TextLayer:()=>Al,TouchManager:()=>wl,UnexpectedResponseException:()=>yl,Util:()=>El,VerbosityLevel:()=>Ss,XfaLayer:()=>xl,build:()=>Sl,createValidAbsoluteUrl:()=>Pl,fetchData:()=>Cl,getDocument:()=>Ps,getFilenameFromUrl:()=>Tl,getPdfFilenameFromUrl:()=>Ml,getXfaPageViewport:()=>Ll,isDataScheme:()=>Rl,isPdfFile:()=>Il,noContextMenu:()=>kl,normalizeUnicode:()=>Dl,setLayerDimensions:()=>Ol,shadow:()=>Nl,stopEvent:()=>Fl,version:()=>fi});var ee={};V.r(ee),V.d(ee,{AnnotationLayerBuilder:()=>$c,DownloadManager:()=>Xc,EventBus:()=>Yc,FindState:()=>qc,GenericL10n:()=>wr,LinkTarget:()=>Ae,PDFFindController:()=>yr,PDFHistory:()=>Kc,PDFLinkService:()=>Er,PDFPageView:()=>Qc,PDFScriptingManager:()=>Zc,PDFSinglePageViewer:()=>xr,PDFViewer:()=>Sr,ProgressBar:()=>Jc,RenderingStates:()=>td,ScrollMode:()=>ed,SimpleLinkService:()=>id,SpreadMode:()=>nd,StructTreeLayerBuilder:()=>sd,TextLayerBuilder:()=>rd,XfaLayerBuilder:()=>ad,parseQueryString:()=>od});var x=V(10467),T=V(85802),b=V(35547),X=V(17705),ut=V(32271),Xe=V(58750),kt=V(24226),Wt=V(31397),ce=V(47441),bt=V(98071),ie=V(6450);const Dt=["addListener","removeListener"],Ye=["addEventListener","removeEventListener"],Hr=["on","off"];function Z(o,t,e,i){if((0,bt.T)(e)&&(i=e,e=void 0),i)return Z(o,t,e).pipe((0,ie.I)(i));const[n,s]=function Wr(o){return(0,bt.T)(o.addEventListener)&&(0,bt.T)(o.removeEventListener)}(o)?Ye.map(r=>a=>o[r](t,a,e)):function zr(o){return(0,bt.T)(o.addListener)&&(0,bt.T)(o.removeListener)}(o)?Dt.map(Pn(o,t)):function Ur(o){return(0,bt.T)(o.on)&&(0,bt.T)(o.off)}(o)?Hr.map(Pn(o,t)):[];if(!n&&(0,ce.X)(o))return(0,Wt.Z)(r=>Z(r,t,e))((0,Xe.Tg)(o));if(!n)throw new TypeError("Invalid event target");return new kt.c(r=>{const a=(...l)=>r.next(1<l.length?l:l[0]);return n(a),()=>s(a)})}function Pn(o,t){return e=>i=>o[e](t,i)}var Gr=V(21413),Cn=V(86648),J=V(56977),$r=V(70152),Xr=V(5964),Ee={d:(o,t)=>{for(var e in t)Ee.o(t,e)&&!Ee.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:t[e]})},o:(o,t)=>Object.prototype.hasOwnProperty.call(o,t)},B=globalThis.pdfjsLib={};Ee.d(B,{AbortException:()=>Zt,AnnotationEditorLayer:()=>Qo,AnnotationEditorParamsType:()=>G,AnnotationEditorType:()=>U,AnnotationEditorUIManager:()=>Le,AnnotationLayer:()=>Go,AnnotationMode:()=>Kt,ColorPicker:()=>Mt,DOMSVGFactory:()=>Yi,DrawLayer:()=>At,FeatureTest:()=>_t,GlobalWorkerOptions:()=>ke,ImageKind:()=>Ke,InvalidPDFException:()=>Ti,MissingPDFException:()=>Se,OPS:()=>Ot,OutputScale:()=>Ni,PDFDataRangeTransport:()=>ds,PDFDateString:()=>kn,PDFWorker:()=>ht,PasswordResponses:()=>Qr,PermissionFlag:()=>Kr,PixelsPerInch:()=>ue,RenderingCancelledException:()=>ki,TextLayer:()=>vt,TouchManager:()=>ri,UnexpectedResponseException:()=>ti,Util:()=>N,VerbosityLevel:()=>Qe,XfaLayer:()=>gs,build:()=>So,createValidAbsoluteUrl:()=>ea,fetchData:()=>ii,getDocument:()=>mo,getFilenameFromUrl:()=>da,getPdfFilenameFromUrl:()=>ua,getXfaPageViewport:()=>fa,isDataScheme:()=>ni,isPdfFile:()=>Di,noContextMenu:()=>Nt,normalizeUnicode:()=>la,setLayerDimensions:()=>ne,shadow:()=>W,stopEvent:()=>Pt,version:()=>xo});const ft=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Tn=[1,0,0,1,0,0],Pi=[.001,0,0,.001,0,0],Kt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},U={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},G={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Kr={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ke={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Qe={ERRORS:0,WARNINGS:1,INFOS:5},Ot={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},Qr={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Ze=Qe.WARNINGS;function Jr(){return Ze}function Je(o){Ze>=Qe.INFOS&&console.log(`Info: ${o}`)}function z(o){Ze>=Qe.WARNINGS&&console.log(`Warning: ${o}`)}function Y(o){throw new Error(o)}function nt(o,t){o||Y(t)}function ea(o,t=null,e=null){if(!o)return null;try{if(e&&"string"==typeof o&&(e.addDefaultProtocol&&o.startsWith("www.")&&o.match(/\./g)?.length>=2&&(o=`http://${o}`),e.tryConvertEncoding))try{o=function oa(o){return decodeURIComponent(escape(o))}(o)}catch{}const i=t?new URL(o,t):new URL(o);if(function ta(o){switch(o?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch{}return null}function W(o,t,e,i=!1){return Object.defineProperty(o,t,{value:e,enumerable:!i,configurable:!0,writable:!1}),e}const Qt=function(){function t(e,i){this.message=e,this.name=i}return t.prototype=new Error,t.constructor=t,t}();class Mn extends Qt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Ci extends Qt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Ti extends Qt{constructor(t){super(t,"InvalidPDFException")}}class Se extends Qt{constructor(t){super(t,"MissingPDFException")}}class ti extends Qt{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class ia extends Qt{constructor(t){super(t,"FormatError")}}class Zt extends Qt{constructor(t){super(t,"AbortException")}}function Ln(o){("object"!=typeof o||void 0===o?.length)&&Y("Invalid argument for bytesToString");const t=o.length,e=8192;if(t<e)return String.fromCharCode.apply(null,o);const i=[];for(let n=0;n<t;n+=e){const s=Math.min(n+e,t),r=o.subarray(n,s);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function de(o){"string"!=typeof o&&Y("Invalid argument for stringToBytes");const t=o.length,e=new Uint8Array(t);for(let i=0;i<t;++i)e[i]=255&o.charCodeAt(i);return e}function Mi(o){const t=Object.create(null);for(const[e,i]of o)t[e]=i;return t}class _t{static get isLittleEndian(){return W(this,"isLittleEndian",function sa(){const o=new Uint8Array(4);return o[0]=1,1===new Uint32Array(o.buffer,0,1)[0]}())}static get isEvalSupported(){return W(this,"isEvalSupported",function ra(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return W(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return W(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&"string"==typeof navigator?.platform?W(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):W(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return W(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const ei=Array.from(Array(256).keys(),o=>o.toString(16).padStart(2,"0"));class N{static makeHexColor(t,e,i){return`#${ei[t]}${ei[e]}${ei[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){const i=this.applyTransform(t,e),n=this.applyTransform(t.slice(2,4),e),s=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],n[0],s[0],r[0]),Math.min(i[1],n[1],s[1],r[1]),Math.max(i[0],n[0],s[0],r[0]),Math.max(i[1],n[1],s[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(i+r)/2,l=Math.sqrt((i+r)**2-4*(i*r-(t[2]*e[0]+t[3]*e[2])*(t[0]*e[1]+t[1]*e[3])))/2,c=a-l||1;return[Math.sqrt(a+l||1),Math.sqrt(c)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>n)return null;const s=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return s>r?null:[i,s,n,r]}static#t(t,e,i,n,s,r,a,l,h,c){if(h<=0||h>=1)return;const d=1-h,u=h*h,f=u*h,p=d*(d*(d*t+3*h*e)+3*u*i)+f*n,g=d*(d*(d*s+3*h*r)+3*u*a)+f*l;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,i,n,s,r,a,l,h,c,d,u){if(Math.abs(h)<1e-12)return void(Math.abs(c)>=1e-12&&this.#t(t,e,i,n,s,r,a,l,-d/c,u));const f=c**2-4*d*h;if(f<0)return;const p=Math.sqrt(f),g=2*h;this.#t(t,e,i,n,s,r,a,l,(-c+p)/g,u),this.#t(t,e,i,n,s,r,a,l,(-c-p)/g,u)}static bezierBoundingBox(t,e,i,n,s,r,a,l,h){return h?(h[0]=Math.min(h[0],t,a),h[1]=Math.min(h[1],e,l),h[2]=Math.max(h[2],t,a),h[3]=Math.max(h[3],e,l)):h=[Math.min(t,a),Math.min(e,l),Math.max(t,a),Math.max(e,l)],this.#e(t,i,s,a,e,n,r,l,3*(3*(i-s)-t+a),6*(t-2*i+s),3*(i-t),h),this.#e(t,i,s,a,e,n,r,l,3*(3*(n-r)-e+l),6*(e-2*n+r),3*(n-e),h),h}}let Li=null,Rn=null;function la(o){return Li||(Li=/([\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,Rn=new Map([["\ufb05","\u017ft"]])),o.replaceAll(Li,(t,e,i)=>e?e.normalize("NFKC"):Rn.get(i))}const Ri="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(o,...t){return new Promise(e=>{e(o(...t))})});const Gt="http://www.w3.org/2000/svg";class ue{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}function ii(o){return Ii.apply(this,arguments)}function Ii(){return(Ii=(0,x.A)(function*(o,t="text"){if(Ce(o,document.baseURI)){const e=yield fetch(o);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,i)=>{const n=new XMLHttpRequest;n.open("GET",o,!0),n.responseType=t,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE){if(200===n.status||0===n.status){switch(t){case"arraybuffer":case"blob":case"json":return void e(n.response)}return void e(n.responseText)}i(new Error(n.statusText))}},n.send(null)})})).apply(this,arguments)}class Pe{constructor({viewBox:t,userUnit:e,scale:i,rotation:n,offsetX:s=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=n,this.offsetX=s,this.offsetY=r,i*=e;const l=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,d,u,f,p,g,_,m;switch((n%=360)<0&&(n+=360),n){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f),0===c?(p=Math.abs(h-t[1])*i+s,g=Math.abs(l-t[0])*i+r,_=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(l-t[0])*i+s,g=Math.abs(h-t[1])*i+r,_=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[c*i,d*i,u*i,f*i,p-c*i*l-u*i*h,g-d*i*l-f*i*h],this.width=_,this.height=m}get rawDims(){const{userUnit:t,viewBox:e}=this,i=e.map(n=>n*t);return W(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:n=this.offsetY,dontFlip:s=!1}={}){return new Pe({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:s})}convertToViewportPoint(t,e){return N.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=N.applyTransform([t[0],t[1]],this.transform),i=N.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return N.applyInverseTransform([t,e],this.transform)}}class ki extends Qt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function ni(o){const t=o.length;let e=0;for(;e<t&&""===o[e].trim();)e++;return"data:"===o.substring(e,e+5).toLowerCase()}function Di(o){return"string"==typeof o&&/\.pdf$/i.test(o)}function da(o){return[o]=o.split(/[#?]/,1),o.substring(o.lastIndexOf("/")+1)}function ua(o,t="document.pdf"){if("string"!=typeof o)return t;if(ni(o))return z('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(o);let s=i.exec(n[1])||i.exec(n[2])||i.exec(n[3]);if(s&&(s=s[0],s.includes("%")))try{s=i.exec(decodeURIComponent(s))[0]}catch{}return s||t}class In{started=Object.create(null);times=[];time(t){t in this.started&&z(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||z(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:i}of this.times)e=Math.max(i.length,e);for(const{name:i,start:n,end:s}of this.times)t.push(`${i.padEnd(e)} ${s-n}ms\n`);return t.join("")}}function Ce(o,t){try{const{protocol:e}=t?new URL(o,t):new URL(o);return"http:"===e||"https:"===e}catch{return!1}}function Nt(o){o.preventDefault()}function Pt(o){o.preventDefault(),o.stopPropagation()}class kn{static#t;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.exec(t);if(!e)return null;const i=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let s=parseInt(e[3],10);s=s>=1&&s<=31?s:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===h?(r+=c,a+=d):"+"===h&&(r-=c,a-=d),new Date(Date.UTC(i,n,s,r,a,l))}}function fa(o,{scale:t=1,rotation:e=0}){const{width:i,height:n}=o.attributes.style,s=[0,0,parseInt(i),parseInt(n)];return new Pe({viewBox:s,userUnit:1,scale:t,rotation:e})}function Oi(o){if(o.startsWith("#")){const t=parseInt(o.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return o.startsWith("rgb(")?o.slice(4,-1).split(",").map(t=>parseInt(t)):o.startsWith("rgba(")?o.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(z(`Not a valid color format: "${o}"`),[0,0,0])}function q(o){const{a:t,b:e,c:i,d:n,e:s,f:r}=o.getTransform();return[t,e,i,n,s,r]}function Vt(o){const{a:t,b:e,c:i,d:n,e:s,f:r}=o.getTransform().invertSelf();return[t,e,i,n,s,r]}function ne(o,t,e=!1,i=!0){if(t instanceof Pe){const{pageWidth:n,pageHeight:s}=t.rawDims,{style:r}=o,a=_t.isCSSRoundSupported,l=`var(--scale-factor) * ${n}px`,h=`var(--scale-factor) * ${s}px`,c=a?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,d=a?`round(down, ${h}, var(--scale-round-y, 1px))`:`calc(${h})`;e&&t.rotation%180!=0?(r.width=d,r.height=c):(r.width=c,r.height=d)}i&&o.setAttribute("data-main-rotation",t.rotation)}class Ni{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}class Te{#t=null;#e=null;#i;#n=null;#r=null;static#s=null;constructor(t){this.#i=t,Te.#s||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#i._uiManager._signal;t.addEventListener("contextmenu",Nt,{signal:e}),t.addEventListener("pointerdown",Te.#a,{signal:e});const i=this.#n=document.createElement("div");i.className="buttons",t.append(i);const n=this.#i.toolbarPosition;if(n){const{style:s}=t,r="ltr"===this.#i._uiManager.direction?1-n[0]:n[0];s.insetInlineEnd=100*r+"%",s.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return this.#u(),t}get div(){return this.#t}static#a(t){t.stopPropagation()}#l(t){this.#i._focusEventsAllowed=!1,Pt(t)}#c(t){this.#i._focusEventsAllowed=!0,Pt(t)}#h(t){const e=this.#i._uiManager._signal;t.addEventListener("focusin",this.#l.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Nt,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#r?.shown()}#u(){const{editorType:t,_uiManager:e}=this.#i,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",Te.#s[t]),this.#h(i),i.addEventListener("click",n=>{e.delete()},{signal:e._signal}),this.#n.append(i)}get#d(){const t=document.createElement("div");return t.className="divider",t}addAltText(t){var e=this;return(0,x.A)(function*(){const i=yield t.render();e.#h(i),e.#n.prepend(i,e.#d),e.#r=t})()}addColorPicker(t){this.#e=t;const e=t.renderButton();this.#h(e),this.#n.prepend(e,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class ga{#t=null;#e=null;#i;constructor(t){this.#i=t}#n(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Nt,{signal:this.#i._signal});const e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#s(),t}#r(t,e){let i=0,n=0;for(const s of t){const r=s.y+s.height;if(r<i)continue;const a=s.x+(e?s.width:0);r>i?(n=a,i=r):e?a>n&&(n=a):a<n&&(n=a)}return[e?1-n:n,i]}show(t,e,i){const[n,s]=this.#r(e,i),{style:r}=this.#e||=this.#n();t.append(this.#e),r.insetInlineEnd=100*n+"%",r.top=`calc(${100*s}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#s(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#i._signal;t.addEventListener("contextmenu",Nt,{signal:i}),t.addEventListener("click",()=>{this.#i.highlightSelection("floating_button")},{signal:i}),this.#t.append(t)}}function si(o,t,e){for(const i of e)t.addEventListener(i,o[i].bind(o))}class ma{#t=0;get id(){return"pdfjs_internal_editor_"+this.#t++}}class Fi{#t=function ha(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const o=new Uint8Array(32);return crypto.getRandomValues(o),Ln(o)}();#e=0;#i=null;static get _isSVGFittingCanvas(){const i=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),n=new Image;return n.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>',W(this,"_isSVGFittingCanvas",n.decode().then(()=>(i.drawImage(n,0,0,1,1,0,0,1,3),0===new Uint32Array(i.getImageData(0,0,1,1).data.buffer)[0])))}#n(t,e){var i=this;return(0,x.A)(function*(){i.#i||=new Map;let n=i.#i.get(t);if(null===n)return null;if(n?.bitmap)return n.refCounter+=1,n;try{let s;if(n||={bitmap:null,id:`image_${i.#t}_${i.#e++}`,refCounter:0,isSvg:!1},"string"==typeof e?(n.url=e,s=yield ii(e,"blob")):e instanceof File?s=n.file=e:e instanceof Blob&&(s=e),"image/svg+xml"===s.type){const r=Fi._isSVGFittingCanvas,a=new FileReader,l=new Image,h=new Promise((c,d)=>{l.onload=()=>{n.bitmap=l,n.isSvg=!0,c()},a.onload=(0,x.A)(function*(){const u=n.svgUrl=a.result;l.src=(yield r)?`${u}#svgView(preserveAspectRatio(none))`:u}),l.onerror=a.onerror=d});a.readAsDataURL(s),yield h}else n.bitmap=yield createImageBitmap(s);n.refCounter=1}catch(s){z(s),n=null}return i.#i.set(t,n),n&&i.#i.set(n.id,n),n})()}getFromFile(t){var e=this;return(0,x.A)(function*(){const{lastModified:i,name:n,size:s,type:r}=t;return e.#n(`${i}_${n}_${s}_${r}`,t)})()}getFromUrl(t){var e=this;return(0,x.A)(function*(){return e.#n(t,t)})()}getFromBlob(t,e){var i=this;return(0,x.A)(function*(){const n=yield e;return i.#n(t,n)})()}getFromId(t){var e=this;return(0,x.A)(function*(){e.#i||=new Map;const i=e.#i.get(t);if(!i)return null;if(i.bitmap)return i.refCounter+=1,i;if(i.file)return e.getFromFile(i.file);if(i.blobPromise){const{blobPromise:n}=i;return delete i.blobPromise,e.getFromBlob(i.id,n)}return e.getFromUrl(i.url)})()}getFromCanvas(t,e){this.#i||=new Map;let i=this.#i.get(t);if(i?.bitmap)return i.refCounter+=1,i;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),i={bitmap:n.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#i.set(t,i),this.#i.set(i.id,i),i}getSvgUrl(t){const e=this.#i.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#i||=new Map;const e=this.#i.get(t);if(!e||(e.refCounter-=1,0!==e.refCounter))return;const{bitmap:i}=e;if(!e.url&&!e.file){const n=new OffscreenCanvas(i.width,i.height);n.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=n.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class ba{#t=[];#e=!1;#i;#n=-1;constructor(t=128){this.#i=t}add({cmd:t,undo:e,post:i,mustExec:n,type:s=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(n&&t(),this.#e)return;const l={cmd:t,undo:e,post:i,type:s};if(-1===this.#n)return this.#t.length>0&&(this.#t.length=0),this.#n=0,void this.#t.push(l);if(r&&this.#t[this.#n].type===s)return a&&(l.undo=this.#t[this.#n].undo),void(this.#t[this.#n]=l);const h=this.#n+1;h===this.#i?this.#t.splice(0,1):(this.#n=h,h<this.#t.length&&this.#t.splice(h)),this.#t.push(l)}undo(){if(-1===this.#n)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1,this.#n-=1}redo(){if(this.#n<this.#t.length-1){this.#n+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return-1!==this.#n}hasSomethingToRedo(){return this.#n<this.#t.length-1}cleanType(t){if(-1!==this.#n){for(let e=this.#n;e>=0;e--)if(this.#t[e].type!==t)return this.#t.splice(e+1,this.#n-e),void(this.#n=e);this.#t.length=0,this.#n=-1}}destroy(){this.#t=null}}class Me{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=_t.platform;for(const[i,n,s={}]of t)for(const r of i){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:n,options:s}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:n,options:s}),this.allKeys.add(r.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#t(e));if(!i)return;const{callback:n,options:{bubbles:s=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(n.bind(t,...r,e)(),s||Pt(e))}}class Bi{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function pa(o){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of o.keys()){t.style.color=e;const i=window.getComputedStyle(t).color;o.set(e,Oi(i))}t.remove()}(t),W(this,"_colors",t)}convert(t){const e=Oi(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[i,n]of this._colors)if(n.every((s,r)=>s===e[r]))return Bi._colorsMapping.get(i);return e}getHexCode(t){const e=this._colors.get(t);return e?N.makeHexColor(...e):t}}let Le=(()=>{class o{#t=new AbortController;#e=null;#i=new Map;#n=new Map;#r=null;#s=null;#a=null;#l=new ba;#c=null;#h=null;#u=0;#d=new Set;#f=null;#o=null;#p=new Set;_editorUndoBar=null;#m=!1;#g=!1;#b=!1;#_=null;#v=null;#A=null;#y=null;#x=!1;#S=null;#M=new ma;#E=!1;#T=!1;#P=null;#R=null;#I=null;#O=null;#C=U.NONE;#w=new Set;#N=null;#k=null;#j=null;#U={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#V=[0,0];#F=null;#B=null;#W=null;#L=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=o.prototype,i=a=>a.#B.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&a.hasSomethingToControl(),n=(a,{target:l})=>{if(l instanceof HTMLInputElement){const{type:h}=l;return"text"!==h&&"number"!==h}return!0},s=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return W(this,"_keyboardManager",new Me([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],e.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:n}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:n}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(a,{target:l})=>!(l instanceof HTMLButtonElement)&&a.#B.contains(l)&&!a.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(a,{target:l})=>!(l instanceof HTMLButtonElement)&&a.#B.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-s,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[s,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-s],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,s],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:i}]]))}constructor(e,i,n,s,r,a,l,h,c,d,u,f,p){const g=this._signal=this.#t.signal;this.#B=e,this.#W=i,this.#r=n,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:g}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:g}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:g}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:g}),s._on("setpreference",this.onSetPreference.bind(this),{signal:g}),s._on("switchannotationeditorparams",_=>this.updateParams(_.type,_.value),{signal:g}),this.#et(),this.#rt(),this.#Y(),this.#s=r.annotationStorage,this.#_=r.filterFactory,this.#k=a,this.#y=l||null,this.#m=h,this.#g=c,this.#b=d,this.#O=u||null,this.viewParameters={realScale:ue.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=f||null,this._supportsPinchToZoom=!1!==p}destroy(){this.#L?.resolve(),this.#L=null,this.#t?.abort(),this.#t=null,this._signal=null;for(const e of this.#n.values())e.destroy();this.#n.clear(),this.#i.clear(),this.#p.clear(),this.#e=null,this.#w.clear(),this.#l.destroy(),this.#r?.destroy(),this.#S?.hide(),this.#S=null,this.#v&&(clearTimeout(this.#v),this.#v=null),this.#F&&(clearTimeout(this.#F),this.#F=null),this._editorUndoBar?.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#O}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return W(this,"hcmFilter",this.#k?this.#_.addHCMFilter(this.#k.foreground,this.#k.background):"none")}get direction(){return W(this,"direction",getComputedStyle(this.#B).direction)}get highlightColors(){return W(this,"highlightColors",this.#y?new Map(this.#y.split(",").map(e=>e.split("=").map(i=>i.trim()))):null)}get highlightColorNames(){return W(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#h=e}setMainHighlightColorPicker(e){this.#I=e}editAltText(e,i=!1){this.#r?.editAltText(this,e,i)}switchToMode(e,i){this._eventBus.on("annotationeditormodechanged",i,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,i){this._eventBus.dispatch("setpreference",{source:this,name:e,value:i})}onSetPreference({name:e,value:i}){"enableNewAltTextWhenAddingImage"===e&&(this.#b=i)}onPageChanging({pageNumber:e}){this.#u=e-1}focusMainContainer(){this.#B.focus()}findParent(e,i){for(const n of this.#n.values()){const{x:s,y:r,width:a,height:l}=n.div.getBoundingClientRect();if(e>=s&&e<=s+a&&i>=r&&i<=r+l)return n}return null}disableUserSelect(e=!1){this.#W.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#p.add(e)}removeShouldRescale(e){this.#p.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*ue.PDF_TO_CSS_UNITS;for(const i of this.#p)i.onScaleChanging();this.#h?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#H({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#X(e){const{currentLayer:i}=this;if(i.hasTextLayer(e))return i;for(const n of this.#n.values())if(n.hasTextLayer(e))return n;return null}highlightSelection(e=""){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:a}=i,l=i.toString(),c=this.#H(i).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;i.empty();const u=this.#X(c),f=this.#C===U.NONE,p=()=>{u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:d,anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:a,text:l}),f&&this.showAllEditors("highlight",!0,!0)};f?this.switchToMode(U.HIGHLIGHT,p):p()}#J(){const e=document.getSelection();if(!e||e.isCollapsed)return;const n=this.#H(e).closest(".textLayer"),s=this.getSelectionBoxes(n);s&&(this.#S||=new ga(this),this.#S.show(n,s,"ltr"===this.direction))}addToAnnotationStorage(e){!e.isEmpty()&&this.#s&&!this.#s.has(e.id)&&this.#s.setValue(e.id,e)}#tt(){const e=document.getSelection();if(!e||e.isCollapsed)return void(this.#N&&(this.#S?.hide(),this.#N=null,this.#D({hasSelectedText:!1})));const{anchorNode:i}=e;if(i===this.#N)return;const s=this.#H(e).closest(".textLayer");if(s){if(this.#S?.hide(),this.#N=i,this.#D({hasSelectedText:!0}),(this.#C===U.HIGHLIGHT||this.#C===U.NONE)&&(this.#C===U.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#x=this.isShiftKeyDown,!this.isShiftKeyDown)){const r=this.#C===U.HIGHLIGHT?this.#X(s):null;r?.toggleDrawing();const a=new AbortController,l=this.combinedSignal(a),h=c=>{"pointerup"===c.type&&0!==c.button||(a.abort(),r?.toggleDrawing(!0),"pointerup"===c.type&&this.#$("main_toolbar"))};window.addEventListener("pointerup",h,{signal:l}),window.addEventListener("blur",h,{signal:l})}}else this.#N&&(this.#S?.hide(),this.#N=null,this.#D({hasSelectedText:!1}))}#$(e=""){this.#C===U.HIGHLIGHT?this.highlightSelection(e):this.#m&&this.#J()}#et(){document.addEventListener("selectionchange",this.#tt.bind(this),{signal:this._signal})}#it(){if(this.#A)return;this.#A=new AbortController;const e=this.combinedSignal(this.#A);window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})}#nt(){this.#A?.abort(),this.#A=null}blur(){if(this.isShiftKeyDown=!1,this.#x&&(this.#x=!1,this.#$("main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const i of this.#w)if(i.div.contains(e)){this.#R=[i,e],i._focusEventsAllowed=!1;break}}focus(){if(!this.#R)return;const[e,i]=this.#R;this.#R=null,i.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),i.focus()}#Y(){if(this.#P)return;this.#P=new AbortController;const e=this.combinedSignal(this.#P);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#st(){this.#P?.abort(),this.#P=null}#q(){if(this.#c)return;this.#c=new AbortController;const e=this.combinedSignal(this.#c);document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})}#K(){this.#c?.abort(),this.#c=null}#rt(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#Y(),this.#q()}removeEditListeners(){this.#st(),this.#K()}dragOver(e){for(const{type:i}of e.dataTransfer.items)for(const n of this.#o)if(n.isHandlingMimeForPasting(i))return e.dataTransfer.dropEffect="copy",void e.preventDefault()}drop(e){for(const i of e.dataTransfer.items)for(const n of this.#o)if(n.isHandlingMimeForPasting(i.type))return n.paste(i,this.currentLayer),void e.preventDefault()}copy(e){if(e.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const i=[];for(const n of this.#w){const s=n.serialize(!0);s&&i.push(s)}0!==i.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(i))}cut(e){this.copy(e),this.delete()}paste(e){var i=this;return(0,x.A)(function*(){e.preventDefault();const{clipboardData:n}=e;for(const a of n.items)for(const l of i.#o)if(l.isHandlingMimeForPasting(a.type))return void l.paste(a,i.currentLayer);let s=n.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(a){return void z(`paste: "${a.message}".`)}if(!Array.isArray(s))return;i.unselectAll();const r=i.currentLayer;try{const a=[];for(const c of s){const d=yield r.deserialize(c);if(!d)return;a.push(d)}const l=()=>{for(const c of a)i.#Q(c);i.#Z(a)};i.addCommands({cmd:l,undo:()=>{for(const c of a)c.remove()},mustExec:!0})}catch(a){z(`paste: "${a.message}".`)}})()}keydown(e){!this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!0),this.#C!==U.NONE&&!this.isEditorHandlingKeyboard&&o._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!1,this.#x&&(this.#x=!1,this.#$("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#D(e){Object.entries(e).some(([n,s])=>this.#U[n]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#U,e)}),this.#C===U.HIGHLIGHT&&!1===e.hasSelectedEditor&&this.#z([[G.HIGHLIGHT_FREE,!0]]))}#z(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#it(),this.#q(),this.#D({isEditing:this.#C!==U.NONE,isEmpty:this.#G(),hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:this.#l.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#nt(),this.#K(),this.#D({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#o){this.#o=e;for(const i of this.#o)this.#z(i.defaultPropertiesToUpdate)}}getId(){return this.#M.id}get currentLayer(){return this.#n.get(this.#u)}getLayer(e){return this.#n.get(e)}get currentPageIndex(){return this.#u}addLayer(e){this.#n.set(e.pageIndex,e),this.#E?e.enable():e.disable()}removeLayer(e){this.#n.delete(e.pageIndex)}updateMode(e){var i=this;return(0,x.A)(function*(n,s=null,r=!1){if(i.#C!==n&&(!i.#L||(yield i.#L.promise,i.#L))){if(i.#L=Promise.withResolvers(),i.#C=n,n===U.NONE)return i.setEditingState(!1),i.#ot(),i._editorUndoBar?.hide(),void i.#L.resolve();i.setEditingState(!0),yield i.#at(),i.unselectAll();for(const a of i.#n.values())a.updateMode(n);if(!s)return r&&i.addNewEditorFromKeyboard(),void i.#L.resolve();for(const a of i.#i.values())a.annotationElementId===s?(i.setSelected(a),a.enterInEditMode()):a.unselect();i.#L.resolve()}}).apply(this,arguments)}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,i){if(this.#o){switch(e){case G.CREATE:return void this.currentLayer.addNewEditor();case G.HIGHLIGHT_DEFAULT_COLOR:this.#I?.updateColor(i);break;case G.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#j||=new Map).set(e,i),this.showAllEditors("highlight",i)}for(const n of this.#w)n.updateParams(e,i);for(const n of this.#o)n.updateDefaultParams(e,i)}}showAllEditors(e,i,n=!1){for(const r of this.#i.values())r.editorType===e&&r.show(i);(this.#j?.get(G.HIGHLIGHT_SHOW_ALL)??!0)!==i&&this.#z([[G.HIGHLIGHT_SHOW_ALL,i]])}enableWaiting(e=!1){if(this.#T!==e){this.#T=e;for(const i of this.#n.values())e?i.disableClick():i.enableClick(),i.div.classList.toggle("waiting",e)}}#at(){var e=this;return(0,x.A)(function*(){if(!e.#E){e.#E=!0;const i=[];for(const n of e.#n.values())i.push(n.enable());yield Promise.all(i);for(const n of e.#i.values())n.enable()}})()}#ot(){if(this.unselectAll(),this.#E){this.#E=!1;for(const e of this.#n.values())e.disable();for(const e of this.#i.values())e.disable()}}getEditors(e){const i=[];for(const n of this.#i.values())n.pageIndex===e&&i.push(n);return i}getEditor(e){return this.#i.get(e)}addEditor(e){this.#i.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.focusMainContainer(),this.#v=null},0)),this.#i.delete(e.id),this.unselect(e),(!e.annotationElementId||!this.#d.has(e.annotationElementId))&&this.#s?.remove(e.id)}addDeletedAnnotationElement(e){this.#d.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#d.has(e)}removeDeletedAnnotationElement(e){this.#d.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#Q(e){const i=this.#n.get(e.pageIndex);i?i.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#e!==e&&(this.#e=e,e&&this.#z(e.propertiesToUpdate))}get#lt(){let e=null;for(e of this.#w);return e}updateUI(e){this.#lt===e&&this.#z(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#z(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#w.has(e))return this.#w.delete(e),e.unselect(),void this.#D({hasSelectedEditor:this.hasSelection});this.#w.add(e),e.select(),this.#z(e.propertiesToUpdate),this.#D({hasSelectedEditor:!0})}setSelected(e){this.#h?.commitOrRemove();for(const i of this.#w)i!==e&&i.unselect();this.#w.clear(),this.#w.add(e),e.select(),this.#z(e.propertiesToUpdate),this.#D({hasSelectedEditor:!0})}isSelected(e){return this.#w.has(e)}get firstSelectedEditor(){return this.#w.values().next().value}unselect(e){e.unselect(),this.#w.delete(e),this.#D({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#w.size}get isEnterHandled(){return 1===this.#w.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#l.undo(),this.#D({hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#G()}),this._editorUndoBar?.hide()}redo(){this.#l.redo(),this.#D({hasSomethingToUndo:!0,hasSomethingToRedo:this.#l.hasSomethingToRedo(),isEmpty:this.#G()})}addCommands(e){this.#l.add(e),this.#D({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#G()})}cleanUndoStack(e){this.#l.cleanType(e)}#G(){if(0===this.#i.size)return!0;if(1===this.#i.size)for(const e of this.#i.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const i=e?[e]:[...this.#w],s=()=>{for(const r of i)this.#Q(r)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(s,1===i.length?i[0].editorType:i.length);for(const r of i)r.remove()},undo:s,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#Z(e){for(const i of this.#w)i.unselect();this.#w.clear();for(const i of e)i.isEmpty()||(this.#w.add(i),i.select());this.#D({hasSelectedEditor:this.hasSelection})}selectAll(){for(const e of this.#w)e.commit();this.#Z(this.#i.values())}unselectAll(){if((!this.#e||(this.#e.commitOrRemove(),this.#C===U.NONE))&&!this.#h?.commitOrRemove()&&this.hasSelection){for(const e of this.#w)e.unselect();this.#w.clear(),this.#D({hasSelectedEditor:!1})}}translateSelectedEditors(e,i,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#V[0]+=e,this.#V[1]+=i;const[s,r]=this.#V,a=[...this.#w];this.#F&&clearTimeout(this.#F),this.#F=setTimeout(()=>{this.#F=null,this.#V[0]=this.#V[1]=0,this.addCommands({cmd:()=>{for(const h of a)this.#i.has(h.id)&&h.translateInPage(s,r)},undo:()=>{for(const h of a)this.#i.has(h.id)&&h.translateInPage(-s,-r)},mustExec:!1})},1e3);for(const h of a)h.translateInPage(e,i)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(const e of this.#w)this.#f.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);const e=this.#f;this.#f=null;let i=!1;for(const[{x:s,y:r,pageIndex:a},l]of e)l.newX=s,l.newY=r,l.newPageIndex=a,i||=s!==l.savedX||r!==l.savedY||a!==l.savedPageIndex;if(!i)return!1;const n=(s,r,a,l)=>{if(this.#i.has(s.id)){const h=this.#n.get(l);h?s._setParentAndPosition(h,r,a):(s.pageIndex=l,s.x=r,s.y=a)}};return this.addCommands({cmd:()=>{for(const[s,{newX:r,newY:a,newPageIndex:l}]of e)n(s,r,a,l)},undo:()=>{for(const[s,{savedX:r,savedY:a,savedPageIndex:l}]of e)n(s,r,a,l)},mustExec:!0}),!0}dragSelectedEditors(e,i){if(this.#f)for(const n of this.#f.keys())n.drag(e,i)}rebuild(e){if(null===e.parent){const i=this.getLayer(e.pageIndex);i?(i.changeParent(e),i.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#w.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#e===e}getActive(){return this.#e}getMode(){return this.#C}get imageManager(){return W(this,"imageManager",new Fi)}getSelectionBoxes(e){if(!e)return null;const i=document.getSelection();for(let c=0,d=i.rangeCount;c<d;c++)if(!e.contains(i.getRangeAt(c).commonAncestorContainer))return null;const{x:n,y:s,width:r,height:a}=e.getBoundingClientRect();let l;switch(e.getAttribute("data-main-rotation")){case"90":l=(c,d,u,f)=>({x:(d-s)/a,y:1-(c+u-n)/r,width:f/a,height:u/r});break;case"180":l=(c,d,u,f)=>({x:1-(c+u-n)/r,y:1-(d+f-s)/a,width:u/r,height:f/a});break;case"270":l=(c,d,u,f)=>({x:1-(d+f-s)/a,y:(c-n)/r,width:f/a,height:u/r});break;default:l=(c,d,u,f)=>({x:(c-n)/r,y:(d-s)/a,width:u/r,height:f/a})}const h=[];for(let c=0,d=i.rangeCount;c<d;c++){const u=i.getRangeAt(c);if(!u.collapsed)for(const{x:f,y:p,width:g,height:_}of u.getClientRects())0===g||0===_||h.push(l(f,p,g,_))}return 0===h.length?null:h}addChangedExistingAnnotation({annotationElementId:e,id:i}){(this.#a||=new Map).set(e,i)}removeChangedExistingAnnotation({annotationElementId:e}){this.#a?.delete(e)}renderAnnotationElement(e){const i=this.#a?.get(e.data.id);if(!i)return;const n=this.#s.getRawValue(i);n&&(this.#C===U.NONE&&!n.hasBeenModified||n.renderAnnotationElement(e))}}return o})(),Dn=(()=>{class o{#t=null;#e=!1;#i=null;#n=null;#r=null;#s=null;#a=!1;#l=null;#c=null;#h=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(e){this.#c=e,this.#d=e._uiManager.useNewAltTextFlow,o.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(e){o._l10n??=e}render(){var e=this;return(0,x.A)(function*(){const i=e.#i=document.createElement("button");i.className="altText",i.tabIndex="0";const n=e.#n=document.createElement("span");i.append(n),e.#d?(i.classList.add("new"),i.setAttribute("data-l10n-id",o.#f.missing),n.setAttribute("data-l10n-id",o.#f["missing-label"])):(i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=e.#c._uiManager._signal;i.addEventListener("contextmenu",Nt,{signal:s}),i.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:s});const r=a=>{a.preventDefault(),e.#c._uiManager.editAltText(e.#c),e.#d&&e.#c._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:e.#o}})};return i.addEventListener("click",r,{capture:!0,signal:s}),i.addEventListener("keydown",a=>{a.target===i&&"Enter"===a.key&&(e.#a=!0,r(a))},{signal:s}),yield e.#p(),i})()}get#o(){return(this.#t?"added":null===this.#t&&this.guessedText&&"review")||"missing"}finish(){this.#i&&(this.#i.focus({focusVisible:this.#a}),this.#a=!1)}isEmpty(){return this.#d?null===this.#t:!this.#t&&!this.#e}hasData(){return this.#d?null!==this.#t||!!this.#h:this.isEmpty()}get guessedText(){return this.#h}setGuessedText(e){var i=this;return(0,x.A)(function*(){null===i.#t&&(i.#h=e,i.#u=yield o._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}),i.#p())})()}toggleAltTextBadge(e=!1){if(!this.#d||this.#t)return this.#l?.remove(),void(this.#l=null);if(!this.#l){const i=this.#l=document.createElement("div");i.className="noAltTextBadge",this.#c.div.append(i)}this.#l.classList.toggle("hidden",!e)}serialize(e){let i=this.#t;return!e&&this.#h===i&&(i=this.#u),{altText:i,decorative:this.#e,guessedText:this.#h,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:e,decorative:i,guessedText:n,textWithDisclaimer:s,cancel:r=!1}){n&&(this.#h=n,this.#u=s),(this.#t!==e||this.#e!==i)&&(r||(this.#t=e,this.#e=i),this.#p())}toggle(e=!1){this.#i&&(!e&&this.#s&&(clearTimeout(this.#s),this.#s=null),this.#i.disabled=!e)}shown(){this.#c._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#o}})}destroy(){this.#i?.remove(),this.#i=null,this.#n=null,this.#r=null,this.#l?.remove(),this.#l=null}#p(){var e=this;return(0,x.A)(function*(){const i=e.#i;if(!i)return;if(e.#d){if(i.classList.toggle("done",!!e.#t),i.setAttribute("data-l10n-id",o.#f[e.#o]),e.#n?.setAttribute("data-l10n-id",o.#f[`${e.#o}-label`]),!e.#t)return void e.#r?.remove()}else{if(!e.#t&&!e.#e)return i.classList.remove("done"),void e.#r?.remove();i.classList.add("done"),i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=e.#r;if(!n){e.#r=n=document.createElement("span"),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${e.#c.id}`;const r=100,a=e.#c._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(e.#s),e.#s=null},{once:!0}),i.addEventListener("mouseenter",()=>{e.#s=setTimeout(()=>{e.#s=null,e.#r.classList.add("show"),e.#c._reportTelemetry({action:"alt_text_tooltip"})},r)},{signal:a}),i.addEventListener("mouseleave",()=>{e.#s&&(clearTimeout(e.#s),e.#s=null),e.#r?.classList.remove("show")},{signal:a})}e.#e?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=e.#t),n.parentNode||i.append(n),e.#c.getImageForAltText()?.setAttribute("aria-describedby",n.id)})()}}return o})();class ri{#t;#e=!1;#i=null;#n;#r;#s;#a;#l;#c=null;#h;#u=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:n=null,onPinching:s=null,onPinchEnd:r=null,signal:a}){this.#t=t,this.#i=i,this.#n=e,this.#r=n,this.#s=s,this.#a=r,this.#h=new AbortController,this.#l=AbortSignal.any([a,this.#h.signal]),t.addEventListener("touchstart",this.#d.bind(this),{passive:!1,signal:this.#l})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return W(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#d(t){if(this.#n?.()||t.touches.length<2)return;if(!this.#u){this.#u=new AbortController;const n=AbortSignal.any([this.#l,this.#u.signal]),s=this.#t,r={signal:n,passive:!1};s.addEventListener("touchmove",this.#f.bind(this),r),s.addEventListener("touchend",this.#o.bind(this),r),s.addEventListener("touchcancel",this.#o.bind(this),r),this.#r?.()}if(Pt(t),2!==t.touches.length||this.#i?.())return void(this.#c=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#c={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#f(t){if(!this.#c||2!==t.touches.length)return;let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:n,screenY:s}=e,{screenX:r,screenY:a}=i,l=this.#c,{touch0X:h,touch0Y:c,touch1X:d,touch1Y:u}=l,f=d-h,p=u-c,m=Math.hypot(r-n,a-s)||1,A=Math.hypot(f,p)||1;if(!this.#e&&Math.abs(A-m)<=ri.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=s,l.touch1X=r,l.touch1Y=a,t.preventDefault(),!this.#e)return void(this.#e=!0);const v=[(n+r)/2,(s+a)/2];this.#s?.(v,A,m)}#o(t){this.#u.abort(),this.#u=null,this.#a?.(),this.#c&&(t.preventDefault(),this.#c=null,this.#e=!1)}destroy(){this.#h?.abort(),this.#h=null}}class F{#t=null;#e=null;#i=null;#n=!1;#r=null;#s="";#a=!1;#l=null;#c=null;#h=null;#u=null;#d="";#f=!1;#o=null;#p=!1;#m=!1;#g=!1;#b=null;#_=0;#v=0;#A=null;#y=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#x=!1;#S=F._zIndex++;static _borderLineWidth=-1;static _colorManager=new Bi;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=F.prototype._resizeWithKeyboard,e=Le.TRANSLATE_SMALL,i=Le.TRANSLATE_BIG;return W(this,"_resizerKeyboardManager",new Me([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],F.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:n,pageX:s,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,n],this.pageTranslation=[s,r];const[a,l]=this.parentDimensions;this.x=t.x/a,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return W(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new _a({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(F._l10n??=t,F._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==F._borderLineWidth)return;const i=getComputedStyle(document.documentElement);F._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Y("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#x}set _isDraggable(t){this.#x=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#S}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#H(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,n){const[s,r]=this.parentDimensions;[i,n]=this.screenToPageTranslation(i,n),this.x=(t+i)/s,this.y=(e+n)/r,this.fixAndSetPosition()}#M([t,e],i,n){[i,n]=this.screenToPageTranslation(i,n),this.x+=i/t,this.y+=n/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#M(this.parentDimensions,t,e)}translateInPage(t,e){this.#o||=[this.x,this.y,this.width,this.height],this.#M(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#o||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[n,s]}=this;if(this.x+=t/n,this.y+=e/s,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[l,h]=this.getBaseTranslation();r+=l,a+=h;const{style:c}=i;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#o&&(this.#o[0]!==this.x||this.#o[1]!==this.y)}get _hasBeenResized(){return!!this.#o&&(this.#o[2]!==this.width||this.#o[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=F,n=i/t,s=i/e;switch(this.rotation){case 90:return[-n,s];case 180:return[n,s];case 270:return[n,-s];default:return[-n,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,n]}=this;let{x:s,y:r,width:a,height:l}=this;if(a*=i,l*=n,s*=i,r*=n,this._mustFixPosition)switch(t){case 0:s=Math.max(0,Math.min(i-a,s)),r=Math.max(0,Math.min(n-l,r));break;case 90:s=Math.max(0,Math.min(i-l,s)),r=Math.min(n,Math.max(a,r));break;case 180:s=Math.min(i,Math.max(a,s)),r=Math.min(n,Math.max(l,r));break;case 270:s=Math.min(i,Math.max(l,s)),r=Math.max(0,Math.min(n-a,r))}this.x=s/=i,this.y=r/=n;const[h,c]=this.getBaseTranslation();s+=h,r+=c,e.left=`${(100*s).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#E(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return F.#E(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return F.#E(t,e,360-this.parentRotation)}#T(t){switch(t){case 90:{const[e,i]=this.pageDimensions;return[0,-e/i,i/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,i]=this.pageDimensions;return[0,e/i,-i/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,n]=this.parentDimensions,{style:s}=this.div;s.width=`${(100*t/i).toFixed(2)}%`,this.#a||(s.height=`${(100*e/n).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,n=i.endsWith("%"),s=!this.#a&&e.endsWith("%");if(n&&s)return;const[r,a]=this.parentDimensions;n||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),!this.#a&&!s&&(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#P(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const n=document.createElement("div");this.#l.append(n),n.classList.add("resizer",i),n.setAttribute("data-resizer-name",i),n.addEventListener("pointerdown",this.#R.bind(this,i),{signal:e}),n.addEventListener("contextmenu",Nt,{signal:e}),n.tabIndex=-1}this.div.prepend(this.#l)}#R(t,e){e.preventDefault();const{isMac:i}=_t.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#i?.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,this.#c=[e.screenX,e.screenY];const s=new AbortController,r=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#C.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Pt,{passive:!1,signal:r}),window.addEventListener("contextmenu",Nt,{signal:r}),this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const a=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{s.abort(),this.parent.togglePointerEvents(!0),this.#i?.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=a,this.div.style.cursor=l,this.#O()};window.addEventListener("pointerup",h,{signal:r}),window.addEventListener("blur",h,{signal:r})}#I(t,e,i,n){this.width=i,this.height=n,this.x=t,this.y=e;const[s,r]=this.parentDimensions;this.setDims(s*i,r*n),this.fixAndSetPosition(),this._onResized()}_onResized(){}#O(){if(!this.#h)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:n}=this.#h;this.#h=null;const s=this.x,r=this.y,a=this.width,l=this.height;s===t&&r===e&&a===i&&l===n||this.addCommands({cmd:this.#I.bind(this,s,r,a,l),undo:this.#I.bind(this,t,e,i,n),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#C(t,e){const[i,n]=this.parentDimensions,s=this.x,r=this.y,a=this.width,l=this.height,h=F.MIN_SIZE/i,c=F.MIN_SIZE/n,d=this.#T(this.rotation),u=(D,O)=>[d[0]*D+d[2]*O,d[1]*D+d[3]*O],f=this.#T(360-this.rotation);let g,_,m=!1,A=!1;switch(t){case"topLeft":m=!0,g=(D,O)=>[0,0],_=(D,O)=>[D,O];break;case"topMiddle":g=(D,O)=>[D/2,0],_=(D,O)=>[D/2,O];break;case"topRight":m=!0,g=(D,O)=>[D,0],_=(D,O)=>[0,O];break;case"middleRight":A=!0,g=(D,O)=>[D,O/2],_=(D,O)=>[0,O/2];break;case"bottomRight":m=!0,g=(D,O)=>[D,O],_=(D,O)=>[0,0];break;case"bottomMiddle":g=(D,O)=>[D/2,O],_=(D,O)=>[D/2,0];break;case"bottomLeft":m=!0,g=(D,O)=>[0,O],_=(D,O)=>[D,0];break;case"middleLeft":A=!0,g=(D,O)=>[0,O/2],_=(D,O)=>[D,O/2]}const v=g(a,l),w=_(a,l);let E=u(...w);const C=F._round(s+E[0]),M=F._round(r+E[1]);let P,R,L=1,y=1;if(e.fromKeyboard)({deltaX:P,deltaY:R}=e);else{const{screenX:D,screenY:O}=e,[xt,Lt]=this.#c;[P,R]=this.screenToPageTranslation(D-xt,O-Lt),this.#c[0]=D,this.#c[1]=O}if([P,R]=[f[0]*(D=P/i)+f[2]*(O=R/n),f[1]*D+f[3]*O],m){const D=Math.hypot(a,l);L=y=Math.max(Math.min(Math.hypot(w[0]-v[0]-P,w[1]-v[1]-R)/D,1/a,1/l),h/a,c/l)}else A?L=Math.max(h,Math.min(1,Math.abs(w[0]-v[0]-P)))/a:y=Math.max(c,Math.min(1,Math.abs(w[1]-v[1]-R)))/l;var D,O;const I=F._round(a*L),j=F._round(l*y);E=u(..._(I,j));const H=C-E[0],ct=M-E[1];this.#o||=[this.x,this.y,this.width,this.height],this.width=I,this.height=j,this.x=H,this.y=ct,this.setDims(i*I,n*j),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#i?.finish()}addEditToolbar(){var t=this;return(0,x.A)(function*(){return t._editToolbar||t.#m||(t._editToolbar=new Te(t),t.div.append(t._editToolbar.render()),t.#i&&(yield t._editToolbar.addAltText(t.#i))),t._editToolbar})()}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#i?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}addAltTextButton(){var t=this;return(0,x.A)(function*(){t.#i||(Dn.initialize(F._l10n),t.#i=new Dn(t),t.#t&&(t.#i.data=t.#t,t.#t=null),yield t.addEditToolbar())})()}get altTextData(){return this.#i?.data}set altTextData(t){this.#i&&(this.#i.data=t)}get guessedAltText(){return this.#i?.guessedText}setGuessedAltText(t){var e=this;return(0,x.A)(function*(){yield e.#i?.setGuessedText(t)})()}serializeAltText(t){return this.#i?.serialize(t)}hasAltText(){return!!this.#i&&!this.#i.isEmpty()}hasAltTextData(){return this.#i?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#n?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#V();const[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),si(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#y||=new ri({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#w.bind(this),onPinching:this.#N.bind(this),onPinchEnd:this.#k.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#w(){this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#i?.toggle(!1),this.parent.togglePointerEvents(!1)}#N(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const r=this.#T(this.rotation),a=(C,M)=>[r[0]*C+r[2]*M,r[1]*C+r[3]*M],[l,h]=this.parentDimensions,c=this.x,d=this.y,u=this.width,f=this.height,p=F.MIN_SIZE/l,g=F.MIN_SIZE/h;s=Math.max(Math.min(s,1/u,1/f),p/u,g/f);const _=F._round(u*s),m=F._round(f*s);if(_===u&&m===f)return;this.#o||=[c,d,u,f];const A=a(u/2,f/2),v=F._round(c+A[0]),w=F._round(d+A[1]),E=a(_/2,m/2);this.x=v-E[0],this.y=w-E[1],this.width=_,this.height=m,this.setDims(l*_,h*m),this.fixAndSetPosition(),this._onResizing()}#k(){this.#i?.toggle(!0),this.parent.togglePointerEvents(!0),this.#O()}pointerdown(t){const{isMac:e}=_t.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#f=!0,this._isDraggable?this.#U(t):this.#j(t))}get isSelected(){return this._uiManager.isSelected(this)}#j(t){const{isMac:e}=_t.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#U(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const n=new AbortController,s=this._uiManager.combinedSignal(n),r={capture:!0,passive:!1,signal:s},a=h=>{n.abort(),this.#r=null,this.#f=!1,this._uiManager.endDragSession()||this.#j(h),i&&this._onStopDragging()};e&&(this.#_=t.clientX,this.#v=t.clientY,this.#r=t.pointerId,this.#s=t.pointerType,window.addEventListener("pointermove",h=>{i||(i=!0,this._onStartDragging());const{clientX:c,clientY:d,pointerId:u}=h;if(u!==this.#r)return void Pt(h);const[f,p]=this.screenToPageTranslation(c-this.#_,d-this.#v);this.#_=c,this.#v=d,this._uiManager.dragSelectedEditors(f,p)},r),window.addEventListener("touchmove",Pt,r),window.addEventListener("pointerdown",h=>{h.pointerType===this.#s&&(this.#y||h.isPrimary)&&a(h),Pt(h)},r));const l=h=>{this.#r&&this.#r!==h.pointerId?Pt(h):a(h)};window.addEventListener("pointerup",l,{signal:s}),window.addEventListener("blur",l,{signal:s})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const n=this.parentScale,[s,r]=this.pageDimensions,[a,l]=this.pageTranslation,h=t/n,c=e/n,d=this.x*s,u=this.y*r,f=this.width*s,p=this.height*r;switch(i){case 0:return[d+h+a,r-u-c-p+l,d+h+f+a,r-u-c+l];case 90:return[d+c+a,r-u+h+l,d+c+p+a,r-u+h+f+l];case 180:return[d-h-f+a,r-u+c+l,d-h+a,r-u+c+p+l];case 270:return[d-c-p+a,r-u-h-f+l,d-c+a,r-u-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,n,s,r]=t,a=s-i,l=r-n;switch(this.rotation){case 0:return[i,e-r,a,l];case 90:return[i,e-n,l,a];case 180:return[s,e-n,a,l];case 270:return[s,e-r,l,a];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:n}=this.getClientDimensions(),{innerHeight:s,innerWidth:r}=window;return e<r&&n>0&&t<s&&i>0}#V(){if(this.#u||!this.div)return;this.#u=new AbortController;const t=this._uiManager.combinedSignal(this.#u);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#V()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){Y("An editor must be serializable")}static deserialize(t,e,i){var n=this;return(0,x.A)(function*(){const s=new n.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#t=t.accessibilityData;const[r,a]=s.pageDimensions,[l,h,c,d]=s.getRectInCurrentCoords(t.rect,a);return s.x=l/r,s.y=h/a,s.width=c/r,s.height=d/a,s})()}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#u?.abort(),this.#u=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#H(),this.removeEditToolbar(),this.#A){for(const t of this.#A.values())clearTimeout(t);this.#A=null}this.parent=null,this.#y?.destroy(),this.#y=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#P(),this.#l.classList.remove("hidden"),si(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#h={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#l.children;if(!this.#e){this.#e=Array.from(e);const r=this.#F.bind(this),a=this.#B.bind(this),l=this._uiManager._signal;for(const h of this.#e){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",r,{signal:l}),h.addEventListener("blur",a,{signal:l}),h.addEventListener("focus",this.#W.bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",F._l10nResizer[c])}}const i=this.#e[0];let n=0;for(const r of e){if(r===i)break;n++}const s=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(s!==n){if(s<n)for(let a=0;a<n-s;a++)this.#l.append(this.#l.firstChild);else if(s>n)for(let a=0;a<s-n;a++)this.#l.firstChild.before(this.#l.lastChild);let r=0;for(const a of e){const h=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",F._l10nResizer[h])}}this.#L(0),this.#g=!0,this.#l.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#F(t){F._resizerKeyboardManager.exec(this,t)}#B(t){this.#g&&t.relatedTarget?.parentNode!==this.#l&&this.#H()}#W(t){this.#d=this.#g?t:""}#L(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#g&&this.#C(this.#d,{deltaX:t,deltaY:e,fromKeyboard:!0})}#H(){this.#g=!1,this.#L(-1),this.#O()}_stopResizingWithKeyboard(){this.#H(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#i?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}unselect(){this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#i?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#a=!0;const i=t/e,{style:n}=this.div;n.aspectRatio=i,n.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#A||=new Map;const{action:i}=t;let n=this.#A.get(i);return n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(t),this.#A.delete(i),0===this.#A.size&&(this.#A=null)},F._telemetryTimeout),void this.#A.set(i,n)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#n=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#n=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const i=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),i.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class _a extends F{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const On=3285377520,Tt=4294901760,jt=65535;class Nn{constructor(t){this.h1=t?4294967295&t:On,this.h2=t?4294967295&t:On}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let g=0,_=t.length;g<_;g++){const m=t.charCodeAt(g);m<=255?e[i++]=m:(e[i++]=m>>>8,e[i++]=255&m)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const n=i>>2,s=i-4*n,r=new Uint32Array(e.buffer,0,n);let a=0,l=0,h=this.h1,c=this.h2;const d=3432918353,u=461845907,f=d&jt,p=u&jt;for(let g=0;g<n;g++)1&g?(a=r[g],a=a*d&Tt|a*f&jt,a=a<<15|a>>>17,a=a*u&Tt|a*p&jt,h^=a,h=h<<13|h>>>19,h=5*h+3864292196):(l=r[g],l=l*d&Tt|l*f&jt,l=l<<15|l>>>17,l=l*u&Tt|l*p&jt,c^=l,c=c<<13|c>>>19,c=5*c+3864292196);switch(a=0,s){case 3:a^=e[4*n+2]<<16;case 2:a^=e[4*n+1]<<8;case 1:a^=e[4*n],a=a*d&Tt|a*f&jt,a=a<<15|a>>>17,a=a*u&Tt|a*p&jt,1&n?h^=a:c^=a}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Tt|36045*t&jt,e=4283543511*e&Tt|(2950163797*(e<<16|t>>>16)&Tt)>>>16,t^=e>>>1,t=444984403*t&Tt|60499*t&jt,e=3301882366*e&Tt|(3120437893*(e<<16|t>>>16)&Tt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Vi=Object.freeze({map:null,hash:"",transfer:void 0});class ji{#t=!1;#e=null;#i=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#i.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#i.get(t)}remove(t){if(this.#i.delete(t),0===this.#i.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const e of this.#i.values())if(e instanceof F)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#i.get(t);let n=!1;if(void 0!==i)for(const[s,r]of Object.entries(e))i[s]!==r&&(n=!0,i[s]=r);else n=!0,this.#i.set(t,e);n&&this.#n(),e instanceof F&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#i.has(t)}getAll(){return this.#i.size>0?Mi(this.#i):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#i.size}#n(){this.#t||(this.#t=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Fn(this)}get serializable(){if(0===this.#i.size)return Vi;const t=new Map,e=new Nn,i=[],n=Object.create(null);let s=!1;for(const[r,a]of this.#i){const l=a instanceof F?a.serialize(!1,n):a;l&&(t.set(r,l),e.update(`${r}:${JSON.stringify(l)}`),s||=!!l.bitmap)}if(s)for(const r of t.values())r.bitmap&&i.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Vi}get editorStats(){let t=null;const e=new Map;for(const i of this.#i.values()){if(!(i instanceof F))continue;const n=i.telemetryFinalData;if(!n)continue;const{type:s}=n;e.has(s)||e.set(s,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const r=t[s]||=new Map;for(const[a,l]of Object.entries(n)){if("type"===a)continue;let h=r.get(a);h||(h=new Map,r.set(a,h));const c=h.get(l)??0;h.set(l,c+1)}}for(const[i,n]of e)t[i]=n.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;const t=[];for(const e of this.#i.values())!(e instanceof F)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}}class Fn extends ji{#t;constructor(t){super();const{map:e,hash:i,transfer:n}=t.serializable,s=structuredClone(e,n?{transfer:n}:null);this.#t={map:s,hash:i,transfer:n}}get print(){Y("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return W(this,"modifiedIds",{ids:new Set,hash:""})}}class va{#t=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(t){var e=this;return(0,x.A)(function*({systemFontInfo:i,_inspectFont:n}){if(i&&!e.#t.has(i.loadedName)){if(nt(!e.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),e.isFontLoadingAPISupported){const{loadedName:s,src:r,style:a}=i,l=new FontFace(s,r,a);e.addNativeFontFace(l);try{yield l.load(),e.#t.add(s),n?.(i)}catch{z(`Cannot load system font: ${i.baseFontName}, installing it could help to improve PDF rendering.`),e.removeNativeFontFace(l)}return}Y("Not implemented: loadSystemFont without the Font Loading API.")}}).apply(this,arguments)}bind(t){var e=this;return(0,x.A)(function*(){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void(yield e.loadSystemFont(t));if(e.isFontLoadingAPISupported){const n=t.createNativeFontFace();if(n){e.addNativeFontFace(n);try{yield n.loaded}catch(s){throw z(`Failed to load font '${n.family}': '${s}'.`),t.disableFontFace=!0,s}}return}const i=t.createFontFaceRule();if(i){if(e.insertRule(i),e.isSyncFontLoadingSupported)return;yield new Promise(n=>{const s=e._queueLoadingCallback(n);e._prepareFontLoadEvent(t,s)})}})()}get isFontLoadingAPISupported(){return W(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(ft||typeof navigator<"u"&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),W(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:i}=this,n={done:!1,complete:function e(){for(nt(!n.done,"completeRequest() cannot be called twice."),n.done=!0;i.length>0&&i[0].done;){const s=i.shift();setTimeout(s.callback,0)}},callback:t};return i.push(n),n}get _loadTestFont(){return W(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(w,E){return w.charCodeAt(E)<<24|w.charCodeAt(E+1)<<16|w.charCodeAt(E+2)<<8|255&w.charCodeAt(E+3)}function n(w,E,C,M){return w.substring(0,E)+M+w.substring(E+C)}let s,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const l=a.getContext("2d");let h=0;const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=n(u,976,d.length,d);const g=1482184792;let _=i(u,16);for(s=0,r=d.length-3;s<r;s+=4)_=_-g+i(d,s)|0;s<d.length&&(_=_-g+i(d+"XXX",s)|0),u=n(u,16,4,function na(o){return String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,255&o)}(_));const m=`url(data:font/opentype;base64,${btoa(u)});`;this.insertRule(`@font-face {font-family:"${d}";src:${m}}`);const v=this._document.createElement("div");v.style.visibility="hidden",v.style.width=v.style.height="10px",v.style.position="absolute",v.style.top=v.style.left="0px";for(const w of[t.loadedName,d]){const E=this._document.createElement("span");E.textContent="Hi",E.style.fontFamily=w,v.append(E)}this._document.body.append(v),function c(w,E){if(++h>30)return z("Load test font never loaded."),void E();l.font="30px "+w,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0?E():setTimeout(c.bind(null,w,E))}(d,()=>{v.remove(),e.complete()})}}class Aa{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:n=null}){this.compiledGlyphs=Object.create(null);for(const s in t)this[s]=t[s];this.disableFontFace=!0===e,this.fontExtraProperties=!0===i,this._inspectFont=n}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${function ca(o){return Uint8Array.prototype.toBase64?o.toBase64():btoa(Ln(o))}(this.data)});`;let e;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let n;try{n=t.get(i)}catch(r){z(`getPathGenerator - ignoring character: "${r}".`)}const s=new Path2D(n||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=s}}function Bn(){}function wt(o){if(o instanceof Zt||o instanceof Ti||o instanceof Se||o instanceof Mn||o instanceof ti||o instanceof Ci)return o;switch(o instanceof Error||"object"==typeof o&&null!==o||Y('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),o.name){case"AbortException":return new Zt(o.message);case"InvalidPDFException":return new Ti(o.message);case"MissingPDFException":return new Se(o.message);case"PasswordException":return new Mn(o.message,o.code);case"UnexpectedResponseException":return new ti(o.message,o.status);case"UnknownErrorException":return new Ci(o.message,o.details)}return new Ci(o.message,o.toString())}class Re{#t=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#n(t);if(t.callback){const i=t.callbackId,n=this.callbackCapabilities[i];if(!n)throw new Error(`Cannot resolve callback ${i}`);if(delete this.callbackCapabilities[i],1===t.callback)n.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");n.reject(wt(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,n=t.sourceName,s=this.comObj;return void Promise.try(e,t.data).then(function(r){s.postMessage({sourceName:i,targetName:n,callback:1,callbackId:t.callbackId,data:r})},function(r){s.postMessage({sourceName:i,targetName:n,callback:2,callbackId:t.callbackId,reason:wt(r)})})}t.streamId?this.#i(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const n=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[n]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},i)}catch(r){s.reject(r)}return s.promise}sendWithStream(t,e,i,n){const s=this.streamId++,r=this.sourceName,a=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[s]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:r,targetName:a,action:t,streamId:s,data:e,desiredSize:h.desiredSize},n),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[s].pullCall=c,l.postMessage({sourceName:r,targetName:a,stream:6,streamId:s,desiredSize:h.desiredSize}),c.promise},cancel:h=>{nt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[s].cancelCall=c,this.streamControllers[s].isClosed=!0,l.postMessage({sourceName:r,targetName:a,stream:1,streamId:s,reason:wt(h)}),c.promise}},i)}#i(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,s=this.comObj,r=this,a=this.actionHandler[t.action],l={enqueue(h,c=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),s.postMessage({sourceName:i,targetName:n,stream:4,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:3,streamId:e}),delete r.streamSinks[e])},error(h){nt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:5,streamId:e,reason:wt(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,Promise.try(a,t.data,l).then(function(){s.postMessage({sourceName:i,targetName:n,stream:8,streamId:e,success:!0})},function(h){s.postMessage({sourceName:i,targetName:n,stream:8,streamId:e,reason:wt(h)})})}#n(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,s=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case 8:t.success?r.startCall.resolve():r.startCall.reject(wt(t.reason));break;case 7:t.success?r.pullCall.resolve():r.pullCall.reject(wt(t.reason));break;case 6:if(!a){s.postMessage({sourceName:i,targetName:n,stream:7,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Bn).then(function(){s.postMessage({sourceName:i,targetName:n,stream:7,streamId:e,success:!0})},function(h){s.postMessage({sourceName:i,targetName:n,stream:7,streamId:e,reason:wt(h)})});break;case 4:if(nt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case 3:if(nt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#r(r,e);break;case 5:nt(r,"error should have stream controller"),r.controller.error(wt(t.reason)),this.#r(r,e);break;case 2:t.success?r.cancelCall.resolve():r.cancelCall.reject(wt(t.reason)),this.#r(r,e);break;case 1:if(!a)break;const l=wt(t.reason);Promise.try(a.onCancel||Bn,l).then(function(){s.postMessage({sourceName:i,targetName:n,stream:2,streamId:e,success:!0})},function(h){s.postMessage({sourceName:i,targetName:n,stream:2,streamId:e,reason:wt(h)})}),a.sinkCapability.reject(l),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}#r(t,e){var i=this;return(0,x.A)(function*(){yield Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete i.streamControllers[e]})()}destroy(){this.#t?.abort(),this.#t=null}}class Vn{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Y("Abstract method `_createCanvas` called.")}}class jn{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}fetch(t){var e=this;return(0,x.A)(function*({name:i}){if(!e.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!i)throw new Error("CMap name must be specified.");const n=e.baseUrl+i+(e.isCompressed?".bcmap":"");return e._fetch(n).then(s=>({cMapData:s,isCompressed:e.isCompressed})).catch(s=>{throw new Error(`Unable to load ${e.isCompressed?"binary ":""}CMap at: ${n}`)})}).apply(this,arguments)}_fetch(t){return(0,x.A)(function*(){Y("Abstract method `_fetch` called.")})()}}class Hn extends jn{_fetch(t){var e=this;return(0,x.A)(function*(){const i=yield ii(t,e.isCompressed?"arraybuffer":"text");return i instanceof ArrayBuffer?new Uint8Array(i):de(i)})()}}class zn{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,n,s){return"none"}destroy(t=!1){}}class Un{constructor({baseUrl:t=null}){this.baseUrl=t}fetch(t){var e=this;return(0,x.A)(function*({filename:i}){if(!e.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!i)throw new Error("Font filename must be specified.");const n=`${e.baseUrl}${i}`;return e._fetch(n).catch(s=>{throw new Error(`Unable to load font data at: ${n}`)})}).apply(this,arguments)}_fetch(t){return(0,x.A)(function*(){Y("Abstract method `_fetch` called.")})()}}class Wn extends Un{_fetch(t){return(0,x.A)(function*(){const e=yield ii(t,"arraybuffer");return new Uint8Array(e)})()}}function Gn(o){return Hi.apply(this,arguments)}function Hi(){return(Hi=(0,x.A)(function*(o){const e=yield process.getBuiltinModule("fs").promises.readFile(o);return new Uint8Array(e)})).apply(this,arguments)}ft&&z("Please use the `legacy` build in Node.js environments.");function zi(o,t){if(!t)return;const e=t[2]-t[0],i=t[3]-t[1],n=new Path2D;n.rect(t[0],t[1],e,i),o.clip(n)}class Ui{getPattern(){Y("Abstract method `getPattern` called.")}}class Ca extends Ui{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const i of this._colorStops)e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,n){let s;if("Stroke"===n||"Fill"===n){const r=e.current.getClippedPathBoundingBox(n,q(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,l=Math.ceil(r[3]-r[1])||1,h=e.cachedCanvases.getCanvas("pattern",a,l),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),i=N.transform(i,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),zi(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),s=t.createPattern(h.canvas,"no-repeat");const d=new DOMMatrix(i);s.setTransform(d)}else zi(t,this._bbox),s=this._createGradient(t);return s}}function Wi(o,t,e,i,n,s,r,a){const l=t.coords,h=t.colors,c=o.data,d=4*o.width;let u;l[e+1]>l[i+1]&&(u=e,e=i,i=u,u=s,s=r,r=u),l[i+1]>l[n+1]&&(u=i,i=n,n=u,u=r,r=a,a=u),l[e+1]>l[i+1]&&(u=e,e=i,i=u,u=s,s=r,r=u);const f=(l[e]+t.offsetX)*t.scaleX,p=(l[e+1]+t.offsetY)*t.scaleY,g=(l[i]+t.offsetX)*t.scaleX,_=(l[i+1]+t.offsetY)*t.scaleY,m=(l[n]+t.offsetX)*t.scaleX,A=(l[n+1]+t.offsetY)*t.scaleY;if(p>=A)return;const v=h[s],w=h[s+1],E=h[s+2],C=h[r],M=h[r+1],L=h[r+2],y=h[a],P=h[a+1],R=h[a+2],I=Math.round(p),j=Math.round(A);let H,ct,D,O,xt,Lt,he,Rt;for(let dt=I;dt<=j;dt++){if(dt<_){const K=dt<p?0:(p-dt)/(p-_);H=f-(f-g)*K,ct=v-(v-C)*K,D=w-(w-M)*K,O=E-(E-L)*K}else{let K;K=dt>A?1:_===A?0:(_-dt)/(_-A),H=g-(g-m)*K,ct=C-(C-y)*K,D=M-(M-P)*K,O=L-(L-R)*K}let at;at=dt<p?0:dt>A?1:(p-dt)/(p-A),xt=f-(f-m)*at,Lt=v-(v-y)*at,he=w-(w-P)*at,Rt=E-(E-R)*at;const we=Math.round(Math.min(H,xt)),$e=Math.round(Math.max(H,xt));let It=d*dt+4*we;for(let K=we;K<=$e;K++)at=(H-K)/(H-xt),at<0?at=0:at>1&&(at=1),c[It++]=ct-(ct-Lt)*at|0,c[It++]=D-(D-he)*at|0,c[It++]=O-(O-Rt)*at|0,c[It++]=255}}function Ta(o,t,e){const i=t.coords,n=t.colors;let s,r;switch(t.type){case"lattice":const a=t.verticesPerRow,l=Math.floor(i.length/a)-1,h=a-1;for(s=0;s<l;s++){let c=s*a;for(let d=0;d<h;d++,c++)Wi(o,e,i[c],i[c+1],i[c+a],n[c],n[c+1],n[c+a]),Wi(o,e,i[c+a+1],i[c+1],i[c+a],n[c+a+1],n[c+1],n[c+a])}break;case"triangles":for(s=0,r=i.length;s<r;s+=3)Wi(o,e,i[s],i[s+1],i[s+2],n[s],n[s+1],n[s+2]);break;default:throw new Error("illegal figure")}}class Ma extends Ui{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){const a=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),u=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3),f=h/d,p=c/u,g={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-l,scaleX:1/f,scaleY:1/p},A=i.getCanvas("mesh",d+4,u+4),v=A.context,w=v.createImageData(d,u);if(e){const C=w.data;for(let M=0,L=C.length;M<L;M+=4)C[M]=e[0],C[M+1]=e[1],C[M+2]=e[2],C[M+3]=255}for(const C of this._figures)Ta(w,C,g);return v.putImageData(w,2,2),{canvas:A.canvas,offsetX:a-2*f,offsetY:l-2*p,scaleX:f,scaleY:p}}getPattern(t,e,i,n){let s;if(zi(t,this._bbox),"Shading"===n)s=N.singularValueDecompose2dScale(q(t));else if(s=N.singularValueDecompose2dScale(e.baseTransform),this.matrix){const a=N.singularValueDecompose2dScale(this.matrix);s=[s[0]*a[0],s[1]*a[1]]}const r=this._createMeshCanvas(s,"Shading"===n?null:this._background,e.cachedCanvases);return"Shading"!==n&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class La extends Ui{getPattern(){return"hotpink"}}let Ia=(()=>{class o{static MAX_PATTERN_SIZE=3e3;constructor(e,i,n,s,r){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=i,this.ctx=n,this.canvasGraphicsFactory=s,this.baseTransform=r}createPatternCanvas(e){const{bbox:i,operatorList:n,paintType:s,tilingType:r,color:a,canvasGraphicsFactory:l}=this;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),Je("TilingType: "+r);const d=i[0],u=i[1],f=i[2],p=i[3],g=f-d,_=p-u,m=N.singularValueDecompose2dScale(this.matrix),A=N.singularValueDecompose2dScale(this.baseTransform),v=m[0]*A[0],w=m[1]*A[1];let E=g,C=_,M=!1,L=!1;const y=Math.ceil(h*v),P=Math.ceil(c*w);y>=Math.ceil(g*v)?E=h:M=!0,P>=Math.ceil(_*w)?C=c:L=!0;const j=this.getSizeAndScale(E,this.ctx.canvas.width,v),H=this.getSizeAndScale(C,this.ctx.canvas.height,w),ct=e.cachedCanvases.getCanvas("pattern",j.size,H.size),D=ct.context,O=l.createCanvasGraphics(D);if(O.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(O,s,a),D.translate(-j.scale*d,-H.scale*u),O.transform(j.scale,0,0,H.scale,0,0),D.save(),this.clipBbox(O,d,u,f,p),O.baseTransform=q(O.ctx),O.executeOperatorList(n),O.endDrawing(),D.restore(),M||L){const xt=ct.canvas;M&&(E=h),L&&(C=c);const Lt=this.getSizeAndScale(E,this.ctx.canvas.width,v),he=this.getSizeAndScale(C,this.ctx.canvas.height,w),Rt=Lt.size,dt=he.size,at=e.cachedCanvases.getCanvas("pattern-workaround",Rt,dt),we=at.context,$e=M?Math.floor(g/h):0,It=L?Math.floor(_/c):0;for(let K=0;K<=$e;K++)for(let Ut=0;Ut<=It;Ut++)we.drawImage(xt,Rt*K,dt*Ut,Rt,dt,0,0,Rt,dt);return{canvas:at.canvas,scaleX:Lt.scale,scaleY:he.scale,offsetX:d,offsetY:u}}return{canvas:ct.canvas,scaleX:j.scale,scaleY:H.scale,offsetX:d,offsetY:u}}getSizeAndScale(e,i,n){const s=Math.max(o.MAX_PATTERN_SIZE,i);let r=Math.ceil(e*n);return r>=s?r=s:n=r/e,{scale:n,size:r}}clipBbox(e,i,n,s,r){e.ctx.rect(i,n,s-i,r-n),e.current.updateRectMinMax(q(e.ctx),[i,n,s,r]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,i,n){const s=e.ctx,r=e.current;switch(i){case 1:const a=this.ctx;s.fillStyle=a.fillStyle,s.strokeStyle=a.strokeStyle,r.fillColor=a.fillStyle,r.strokeColor=a.strokeStyle;break;case 2:const l=N.makeHexColor(n[0],n[1],n[2]);s.fillStyle=l,s.strokeStyle=l,r.fillColor=l,r.strokeColor=l;break;default:throw new ia(`Unsupported paint type: ${i}`)}}getPattern(e,i,n,s){let r=n;"Shading"!==s&&(r=N.transform(r,i.baseTransform),this.matrix&&(r=N.transform(r,this.matrix)));const a=this.createPatternCanvas(i);let l=new DOMMatrix(r);l=l.translate(a.offsetX,a.offsetY),l=l.scale(1/a.scaleX,1/a.scaleY);const h=e.createPattern(a.canvas,"repeat");return h.setTransform(l),h}}return o})();function Xn({src:o,srcPos:t=0,dest:e,width:i,height:n,nonBlackColor:s=4294967295,inverseDecode:r=!1}){const a=_t.isLittleEndian?4278190080:255,[l,h]=r?[s,a]:[a,s],c=i>>3,d=7&i,u=o.length;e=new Uint32Array(e.buffer);let f=0;for(let p=0;p<n;p++){for(const _=t+c;t<_;t++){const m=t<u?o[t]:255;e[f++]=128&m?h:l,e[f++]=64&m?h:l,e[f++]=32&m?h:l,e[f++]=16&m?h:l,e[f++]=8&m?h:l,e[f++]=4&m?h:l,e[f++]=2&m?h:l,e[f++]=1&m?h:l}if(0===d)continue;const g=t<u?o[t++]:255;for(let _=0;_<d;_++)e[f++]=g&1<<7-_?h:l}return{srcPos:t,destPos:f}}class Na{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let n;return void 0!==this.cache[t]?(n=this.cache[t],this.canvasFactory.reset(n,e,i)):(n=this.canvasFactory.create(e,i),this.cache[t]=n),n}delete(t){delete this.cache[t]}clear(){for(const t in this.cache)this.canvasFactory.destroy(this.cache[t]),delete this.cache[t]}}function oi(o,t,e,i,n,s,r,a,l,h){const[c,d,u,f,p,g]=q(o);if(0===d&&0===u){const v=Math.round(r*c+p),E=Math.round(a*f+g),M=Math.abs(Math.round((r+l)*c+p)-v)||1,y=Math.abs(Math.round((a+h)*f+g)-E)||1;return o.setTransform(Math.sign(c),0,0,Math.sign(f),v,E),o.drawImage(t,e,i,n,s,0,0,M,y),o.setTransform(c,d,u,f,p,g),[M,y]}if(0===c&&0===f){const v=Math.round(a*u+p),E=Math.round(r*d+g),M=Math.abs(Math.round((a+h)*u+p)-v)||1,y=Math.abs(Math.round((r+l)*d+g)-E)||1;return o.setTransform(0,Math.sign(d),Math.sign(u),0,v,E),o.drawImage(t,e,i,n,s,0,0,y,M),o.setTransform(c,d,u,f,p,g),[y,M]}return o.drawImage(t,e,i,n,s,r,a,l,h),[Math.hypot(c,d)*l,Math.hypot(u,f)*h]}class Zn{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Tn,this.textMatrixScale=1,this.fontMatrix=Pi,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=0,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=N.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){const i=N.applyTransform(e,t),n=N.applyTransform(e.slice(2),t),s=N.applyTransform([e[0],e[3]],t),r=N.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],n[0],s[0],r[0]),this.minY=Math.min(this.minY,i[1],n[1],s[1],r[1]),this.maxX=Math.max(this.maxX,i[0],n[0],s[0],r[0]),this.maxY=Math.max(this.maxY,i[1],n[1],s[1],r[1])}updateScalingPathMinMax(t,e){N.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,n,s,r,a,l,h,c){const d=N.bezierBoundingBox(e,i,n,s,r,a,l,h,c);c||this.updateRectMinMax(t,d)}getPathBoundingBox(t="Fill",e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if("Stroke"===t){e||Y("Stroke bounding box must include transform.");const n=N.singularValueDecompose2dScale(e),s=n[0]*this.lineWidth/2,r=n[1]*this.lineWidth/2;i[0]-=s,i[1]-=r,i[2]+=s,i[3]+=r}return i}updateClipFromPath(){const t=N.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t="Fill",e=null){return N.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Jn(o,t){if(t instanceof ImageData)return void o.putImageData(t,0,0);const e=t.height,i=t.width,n=e%16,s=(e-n)/16,r=0===n?s:s+1,a=o.createImageData(i,16);let h,l=0;const c=t.data,d=a.data;let u,f,p,g;if(t.kind===Ke.GRAYSCALE_1BPP){const _=c.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),A=m.length,v=i+7>>3,w=4294967295,E=_t.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(p=u<s?16:n,h=0,f=0;f<p;f++){const C=_-l;let M=0;const L=C>v?i:8*C-7,y=-8&L;let P=0,R=0;for(;M<y;M+=8)R=c[l++],m[h++]=128&R?w:E,m[h++]=64&R?w:E,m[h++]=32&R?w:E,m[h++]=16&R?w:E,m[h++]=8&R?w:E,m[h++]=4&R?w:E,m[h++]=2&R?w:E,m[h++]=1&R?w:E;for(;M<L;M++)0===P&&(R=c[l++],P=128),m[h++]=R&P?w:E,P>>=1}for(;h<A;)m[h++]=0;o.putImageData(a,0,16*u)}}else if(t.kind===Ke.RGBA_32BPP){for(f=0,g=16*i*4,u=0;u<s;u++)d.set(c.subarray(l,l+g)),l+=g,o.putImageData(a,0,f),f+=16;u<r&&(g=i*n*4,d.set(c.subarray(l,l+g)),o.putImageData(a,0,f))}else{if(t.kind!==Ke.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(p=16,g=i*p,u=0;u<r;u++){for(u>=s&&(p=n,g=i*p),h=0,f=g;f--;)d[h++]=c[l++],d[h++]=c[l++],d[h++]=c[l++],d[h++]=255;o.putImageData(a,0,16*u)}}}function ts(o,t){if(t.bitmap)return void o.drawImage(t.bitmap,0,0);const e=t.height,i=t.width,n=e%16,s=(e-n)/16,r=0===n?s:s+1,a=o.createImageData(i,16);let l=0;const h=t.data,c=a.data;for(let d=0;d<r;d++){const u=d<s?16:n;({srcPos:l}=Xn({src:h,srcPos:l,dest:c,width:i,height:u,nonBlackColor:0})),o.putImageData(a,0,16*d)}}function Ie(o,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const i of e)void 0!==o[i]&&(t[i]=o[i]);void 0!==o.setLineDash&&(t.setLineDash(o.getLineDash()),t.lineDashOffset=o.lineDashOffset)}function li(o){if(o.strokeStyle=o.fillStyle="#000000",o.fillRule="nonzero",o.globalAlpha=1,o.lineWidth=1,o.lineCap="butt",o.lineJoin="miter",o.miterLimit=10,o.globalCompositeOperation="source-over",o.font="10px sans-serif",void 0!==o.setLineDash&&(o.setLineDash([]),o.lineDashOffset=0),!ft){const{filter:t}=o;"none"!==t&&""!==t&&(o.filter="none")}}function es(o,t){if(t)return!0;const e=N.singularValueDecompose2dScale(o);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const i=Math.fround((globalThis.devicePixelRatio||1)*ue.PDF_TO_CSS_UNITS);return e[0]<=i&&e[1]<=i}const Ba=["butt","round","square"],Va=["miter","round","bevel"],ja={},is={};class fe{constructor(t,e,i,n,s,{optionalContentConfig:r,markedContentStack:a=null},l,h){this.ctx=t,this.current=new Zn(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=i,this.canvasFactory=n,this.filterFactory=s,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=a||[],this.optionalContentConfig=r,this.cachedCanvases=new Na(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:n=null}){const s=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,s,r),this.ctx.fillStyle=a,i){const l=this.cachedCanvases.getCanvas("transparent",s,r);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...q(this.compositeCtx))}this.ctx.save(),li(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=q(this.ctx)}executeOperatorList(t,e,i,n){const s=t.argsArray,r=t.fnArray;let a=e||0;const l=s.length;if(l===a)return a;const h=l-a>10&&"function"==typeof i,c=h?Date.now()+15:0;let d=0;const u=this.commonObjs,f=this.objs;let p;for(;;){if(void 0!==n&&a===n.nextBreakPoint)return n.breakIt(a,i),a;if(p=r[a],p!==Ot.dependency)this[p].apply(this,s[a]);else for(const g of s[a]){const _=g.startsWith("g_")?u:f;if(!_.has(g))return _.get(g,i),a}if(a++,a===l)return a;if(h&&++d>10){if(Date.now()>c)return i(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,n=t.height??t.displayHeight;let c,d,s=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=i,l=n,h="prescale1";for(;s>2&&a>1||r>2&&l>1;){let u=a,f=l;s>2&&a>1&&(u=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),s/=a/u),r>2&&l>1&&(f=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,r/=l/f),c=this.cachedCanvases.getCanvas(h,u,f),d=c.context,d.clearRect(0,0,u,f),d.drawImage(t,0,0,a,l,0,0,u,f),t=c.canvas,a=u,l=f,h="prescale1"===h?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:l}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:n}=t,s=this.current.fillColor,r=this.current.patternFill,a=q(e);let l,h,c,d;if((t.bitmap||t.data)&&t.count>1){const L=t.bitmap||t.data.buffer;h=JSON.stringify(r?a:[a.slice(0,4),s]),l=this._cachedBitmapsMap.get(L),l||(l=new Map,this._cachedBitmapsMap.set(L,l));const y=l.get(h);if(y&&!r)return{canvas:y,offsetX:Math.round(Math.min(a[0],a[2])+a[4]),offsetY:Math.round(Math.min(a[1],a[3])+a[5])};c=y}c||(d=this.cachedCanvases.getCanvas("maskCanvas",i,n),ts(d.context,t));let u=N.transform(a,[1/i,0,0,-1/n,0,0]);u=N.transform(u,[1,0,0,1,0,-n]);const[f,p,g,_]=N.getAxialAlignedBoundingBox([0,0,i,n],u),m=Math.round(g-f)||1,A=Math.round(_-p)||1,v=this.cachedCanvases.getCanvas("fillCanvas",m,A),w=v.context,E=f,C=p;w.translate(-E,-C),w.transform(...u),c||(c=this._scaleImage(d.canvas,Vt(w)),c=c.img,l&&r&&l.set(h,c)),w.imageSmoothingEnabled=es(q(w),t.interpolate),oi(w,c,0,0,c.width,c.height,0,0,i,n),w.globalCompositeOperation="source-in";const M=N.transform(Vt(w),[1,0,0,1,-E,-C]);return w.fillStyle=r?s.getPattern(e,this,M,"Fill"):s,w.fillRect(0,0,i,n),l&&!r&&(this.cachedCanvases.delete("fillCanvas"),l.set(h,v.canvas)),{canvas:v.canvas,offsetX:Math.round(E),offsetY:Math.round(C)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Ba[t]}setLineJoin(t){this.ctx.lineJoin=Va[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const n=this.cachedCanvases.getCanvas("smaskGroupAt"+this.groupLevel,this.ctx.canvas.width,this.ctx.canvas.height);this.suspendedCtx=this.ctx,this.ctx=n.context;const s=this.ctx;s.setTransform(...q(this.suspendedCtx)),Ie(this.suspendedCtx,s),function Oa(o,t){if(o._removeMirroring)throw new Error("Context is already forwarding operations.");o.__originalSave=o.save,o.__originalRestore=o.restore,o.__originalRotate=o.rotate,o.__originalScale=o.scale,o.__originalTranslate=o.translate,o.__originalTransform=o.transform,o.__originalSetTransform=o.setTransform,o.__originalResetTransform=o.resetTransform,o.__originalClip=o.clip,o.__originalMoveTo=o.moveTo,o.__originalLineTo=o.lineTo,o.__originalBezierCurveTo=o.bezierCurveTo,o.__originalRect=o.rect,o.__originalClosePath=o.closePath,o.__originalBeginPath=o.beginPath,o._removeMirroring=()=>{o.save=o.__originalSave,o.restore=o.__originalRestore,o.rotate=o.__originalRotate,o.scale=o.__originalScale,o.translate=o.__originalTranslate,o.transform=o.__originalTransform,o.setTransform=o.__originalSetTransform,o.resetTransform=o.__originalResetTransform,o.clip=o.__originalClip,o.moveTo=o.__originalMoveTo,o.lineTo=o.__originalLineTo,o.bezierCurveTo=o.__originalBezierCurveTo,o.rect=o.__originalRect,o.closePath=o.__originalClosePath,o.beginPath=o.__originalBeginPath,delete o._removeMirroring},o.save=function(){t.save(),this.__originalSave()},o.restore=function(){t.restore(),this.__originalRestore()},o.translate=function(i,n){t.translate(i,n),this.__originalTranslate(i,n)},o.scale=function(i,n){t.scale(i,n),this.__originalScale(i,n)},o.transform=function(i,n,s,r,a,l){t.transform(i,n,s,r,a,l),this.__originalTransform(i,n,s,r,a,l)},o.setTransform=function(i,n,s,r,a,l){t.setTransform(i,n,s,r,a,l),this.__originalSetTransform(i,n,s,r,a,l)},o.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},o.rotate=function(i){t.rotate(i),this.__originalRotate(i)},o.clip=function(i){t.clip(i),this.__originalClip(i)},o.moveTo=function(e,i){t.moveTo(e,i),this.__originalMoveTo(e,i)},o.lineTo=function(e,i){t.lineTo(e,i),this.__originalLineTo(e,i)},o.bezierCurveTo=function(e,i,n,s,r,a){t.bezierCurveTo(e,i,n,s,r,a),this.__originalBezierCurveTo(e,i,n,s,r,a)},o.rect=function(e,i,n,s){t.rect(e,i,n,s),this.__originalRect(e,i,n,s)},o.closePath=function(){t.closePath(),this.__originalClosePath()},o.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(s,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(),Ie(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){this.current.activeSMask&&(t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height],this.composeSMask(this.suspendedCtx,this.current.activeSMask,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,i,n){const s=n[0],r=n[1],a=n[2]-s,l=n[3]-r;0===a||0===l||(this.genericComposeSMask(e.context,i,a,l,e.subtype,e.backdrop,e.transferMap,s,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,n,s,r,a,l,h,c,d){let u=t.canvas,f=l-c,p=h-d;if(r){const _=N.makeHexColor(...r);if(f<0||p<0||f+i>u.width||p+n>u.height){const m=this.cachedCanvases.getCanvas("maskExtension",i,n),A=m.context;A.drawImage(u,-f,-p),A.globalCompositeOperation="destination-atop",A.fillStyle=_,A.fillRect(0,0,i,n),A.globalCompositeOperation="source-over",u=m.canvas,f=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const m=new Path2D;m.rect(f,p,i,n),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=_,t.fillRect(f,p,i,n),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===s&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===s&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(l,h,i,n),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(u,f,p,i,n,l,h,i,n),e.restore()}save(){this.inSMaskMode?(Ie(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Ie(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,n,s,r){this.ctx.transform(t,e,i,n,s,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const n=this.ctx,s=this.current;let l,h,r=s.x,a=s.y;const c=q(n),d=0===c[0]&&0===c[3]||0===c[1]&&0===c[2],u=d?i.slice(0):null;for(let f=0,p=0,g=t.length;f<g;f++)switch(0|t[f]){case Ot.rectangle:r=e[p++],a=e[p++];const _=e[p++],m=e[p++],A=r+_,v=a+m;n.moveTo(r,a),0===_||0===m?n.lineTo(A,v):(n.lineTo(A,a),n.lineTo(A,v),n.lineTo(r,v)),d||s.updateRectMinMax(c,[r,a,A,v]),n.closePath();break;case Ot.moveTo:r=e[p++],a=e[p++],n.moveTo(r,a),d||s.updatePathMinMax(c,r,a);break;case Ot.lineTo:r=e[p++],a=e[p++],n.lineTo(r,a),d||s.updatePathMinMax(c,r,a);break;case Ot.curveTo:l=r,h=a,r=e[p+4],a=e[p+5],n.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],r,a),s.updateCurvePathMinMax(c,l,h,e[p],e[p+1],e[p+2],e[p+3],r,a,u),p+=6;break;case Ot.curveTo2:l=r,h=a,n.bezierCurveTo(r,a,e[p],e[p+1],e[p+2],e[p+3]),s.updateCurvePathMinMax(c,l,h,r,a,e[p],e[p+1],e[p+2],e[p+3],u),r=e[p+2],a=e[p+3],p+=4;break;case Ot.curveTo3:l=r,h=a,r=e[p+2],a=e[p+3],n.bezierCurveTo(e[p],e[p+1],r,a,r,a),s.updateCurvePathMinMax(c,l,h,e[p],e[p+1],r,a,r,a,u),p+=4;break;case Ot.closePath:n.closePath()}d&&s.updateScalingPathMinMax(c,u),s.setCurrentPoint(r,a)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,Vt(e),"Stroke"),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,i=this.current.fillColor;let s=!1;this.current.patternFill&&(e.save(),e.fillStyle=i.getPattern(e,this,Vt(e),"Fill"),s=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),s&&e.restore(),t&&this.consumePath(r)}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=ja}eoClip(){this.pendingClip=is}beginText(){this.current.textMatrix=Tn,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return void e.beginPath();const i=new Path2D,n=e.getTransform().invertSelf();for(const{transform:s,x:r,y:a,fontSize:l,path:h}of t)i.addPath(h,new DOMMatrix(s).preMultiplySelf(n).translate(r,a).scale(l,-l));e.clip(i),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),n=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(n.fontMatrix=i.fontMatrix||Pi,(0===n.fontMatrix[0]||0===n.fontMatrix[3])&&z("Invalid font matrix for font "+t),e<0?(e=-e,n.fontDirection=-1):n.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const s=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${s}", ${i.fallbackName}`;let a="normal";i.black?a="900":i.bold&&(a="bold");const l=i.italic?"italic":"normal";let h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font=`${l} ${a} ${h}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,n,s,r){this.current.textMatrix=[t,e,i,n,s,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#i(t,e,i){const n=new Path2D;return n.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),n}paintChar(t,e,i,n,s){const r=this.ctx,a=this.current,l=a.font,h=a.textRenderingMode,c=a.fontSize/a.fontSizeScale,d=3&h,u=!!(4&h),f=a.patternFill&&!l.missingFile,p=a.patternStroke&&!l.missingFile;let g;if((l.disableFontFace||u||f||p)&&(g=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||f||p){if(r.save(),r.translate(e,i),r.scale(c,-c),0===d||2===d)if(n){const _=r.getTransform();r.setTransform(...n),r.fill(this.#i(g,_,n))}else r.fill(g);if(1===d||2===d)if(s){const _=r.getTransform();r.setTransform(...s),r.stroke(this.#i(g,_,s))}else r.lineWidth/=c,r.stroke(g);r.restore()}else(0===d||2===d)&&r.fillText(t,e,i),(1===d||2===d)&&r.strokeText(t,e,i);u&&(this.pendingTextPaths||=[]).push({transform:q(r),x:e,y:i,fontSize:c,path:g})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let n=3;n<e.length;n+=4)if(e[n]>0&&e[n]<255){i=!0;break}return W(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const n=e.fontSize;if(0===n)return;const s=this.ctx,r=e.fontSizeScale,a=e.charSpacing,l=e.wordSpacing,h=e.fontDirection,c=e.textHScale*h,d=t.length,u=i.vertical,f=u?1:-1,p=i.defaultVMetrics,g=n*e.fontMatrix[0],_=0===e.textRenderingMode&&!i.disableFontFace&&!e.patternFill;let m,A;if(s.save(),s.transform(...e.textMatrix),s.translate(e.x,e.y+e.textRise),s.scale(c,h>0?-1:1),e.patternFill){s.save();const M=e.fillColor.getPattern(s,this,Vt(s),"Fill");m=q(s),s.restore(),s.fillStyle=M}if(e.patternStroke){s.save();const M=e.strokeColor.getPattern(s,this,Vt(s),"Stroke");A=q(s),s.restore(),s.strokeStyle=M}let v=e.lineWidth;const w=e.textMatrixScale;if(0===w||0===v){const M=3&e.textRenderingMode;(1===M||2===M)&&(v=this.getSinglePixelWidth())}else v/=w;if(1!==r&&(s.scale(r,r),v/=r),s.lineWidth=v,i.isInvalidPDFjsFont){const M=[];let L=0;for(const y of t)M.push(y.unicode),L+=y.width;return s.fillText(M.join(""),0,0),e.x+=L*g*c,s.restore(),void this.compose()}let C,E=0;for(C=0;C<d;++C){const M=t[C];if("number"==typeof M){E+=f*M*n/1e3;continue}let L=!1;const y=(M.isSpace?l:0)+a,P=M.fontChar,R=M.accent;let I,j,H=M.width;if(u){const D=M.vmetric||p,O=-(M.vmetric?D[1]:.5*H)*g;H=D?-D[0]:H,I=O/r,j=(E+D[2]*g)/r}else I=E/r,j=0;if(i.remeasure&&H>0){const D=1e3*s.measureText(P).width/n*r;if(H<D&&this.isFontSubpixelAAEnabled){const O=H/D;L=!0,s.save(),s.scale(O,1),I/=O}else H!==D&&(I+=(H-D)/2e3*n/r)}this.contentVisible&&(M.isInFont||i.missingFile)&&(_&&!R?s.fillText(P,I,j):(this.paintChar(P,I,j,m,A),R&&this.paintChar(R.fontChar,I+n*R.offset.x/r,j-n*R.offset.y/r,m,A))),E+=u?H*g-y*h:H*g+y*h,L&&s.restore()}u?e.y-=E:e.x+=E*c,s.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,n=i.font,s=i.fontSize,r=i.fontDirection,a=n.vertical?1:-1,l=i.charSpacing,h=i.wordSpacing,c=i.textHScale*r,d=i.fontMatrix||Pi,u=t.length;let p,g,_,m;if(3!==i.textRenderingMode&&0!==s){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(c,r),p=0;p<u;++p){if(g=t[p],"number"==typeof g){m=a*g*s/1e3,this.ctx.translate(m,0),i.x+=m*c;continue}const A=(g.isSpace?h:0)+l,v=n.charProcOperatorList[g.operatorListId];v?(this.contentVisible&&(this.processingType3=g,this.save(),e.scale(s,s),e.transform(...d),this.executeOperatorList(v),this.restore()),_=N.applyTransform([g.width,0],d)[0]*s+A,e.translate(_,0),i.x+=_*c):z(`Type3 character "${g.operatorListId}" is not available.`)}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,n,s,r){this.ctx.rect(i,n,s-i,r-n),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=t[1],n=this.baseTransform||q(this.ctx);e=new Ia(t,i,this.ctx,{createCanvasGraphics:r=>new fe(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},n)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=N.makeHexColor(t,e,i),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,i){this.ctx.fillStyle=this.current.fillColor=N.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function Ra(o){switch(o[0]){case"RadialAxial":return new Ca(o);case"Mesh":return new Ma(o);case"Dummy":return new La}throw new Error(`Unknown IR type: ${o[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,Vt(e),"Shading");const n=Vt(e);if(n){const{width:s,height:r}=e.canvas,[a,l,h,c]=N.getAxialAlignedBoundingBox([0,0,s,r],n);this.ctx.fillRect(a,l,h-a,c-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Y("Should not call beginInlineImage")}beginImageData(){Y("Should not call beginImageData")}paintFormXObjectBegin(t,e){this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=q(this.ctx),e)&&(this.ctx.rect(e[0],e[1],e[2]-e[0],e[3]-e[1]),this.current.updateRectMinMax(q(this.ctx),e),this.clip(),this.endPath())}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||Je("TODO: Support non-isolated groups."),t.knockout&&z("Knockout groups not supported.");const i=q(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let n=N.getAxialAlignedBoundingBox(t.bbox,q(e));n=N.intersect(n,[0,0,e.canvas.width,e.canvas.height])||[0,0,0,0];const r=Math.floor(n[0]),a=Math.floor(n[1]),l=Math.max(Math.ceil(n[2])-r,1),h=Math.max(Math.ceil(n[3])-a,1);this.current.startNewPathAndClipBox([0,0,l,h]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(c,l,h),u=d.context;u.translate(-r,-a),u.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:u,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),Ie(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const n=q(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...n);const s=N.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],n);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotation(t,e,i,n,s){if(this.#t(),li(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],a=e[3]-e[1];if(s&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=r,e[3]=a;const[l,h]=N.singularValueDecompose2dScale(q(this.ctx)),{viewportScale:c}=this,d=Math.ceil(r*this.outputScaleX*c),u=Math.ceil(a*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:f,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,f),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(l,0,0,-h,0,a*h),li(this.ctx)}else li(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new Zn(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...n)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,n=this.processingType3;if(n&&(void 0===n.compiled&&(n.compiled=function Fa(o){const{width:t,height:e}=o;if(t>1e3||e>1e3)return null;const n=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),s=t+1;let a,l,h,r=new Uint8Array(s*(e+1));const c=t+7&-8;let d=new Uint8Array(c*e),u=0;for(const m of o.data){let A=128;for(;A>0;)d[u++]=m&A?0:255,A>>=1}let f=0;for(u=0,0!==d[u]&&(r[0]=1,++f),l=1;l<t;l++)d[u]!==d[u+1]&&(r[l]=d[u]?2:1,++f),u++;for(0!==d[u]&&(r[l]=2,++f),a=1;a<e;a++){u=a*c,h=a*s,d[u-c]!==d[u]&&(r[h]=d[u]?1:8,++f);let m=(d[u]?4:0)+(d[u-c]?8:0);for(l=1;l<t;l++)m=(m>>2)+(d[u+1]?4:0)+(d[u-c+1]?8:0),n[m]&&(r[h+l]=n[m],++f),u++;if(d[u-c]!==d[u]&&(r[h+l]=d[u]?2:4,++f),f>1e3)return null}for(u=c*(e-1),h=a*s,0!==d[u]&&(r[h]=8,++f),l=1;l<t;l++)d[u]!==d[u+1]&&(r[h+l]=d[u]?4:8,++f),u++;if(0!==d[u]&&(r[h+l]=4,++f),f>1e3)return null;const p=new Int32Array([0,s,-1,0,-s,0,0,0,1]),g=new Path2D;for(a=0;f&&a<=e;a++){let m=a*s;const A=m+t;for(;m<A&&!r[m];)m++;if(m===A)continue;g.moveTo(m%s,a);const v=m;let w=r[m];do{const E=p[w];do{m+=E}while(!r[m]);const C=r[m];5!==C&&10!==C?(w=C,r[m]=0):(w=C&51*w>>4,r[m]&=w>>2|w<<2),g.lineTo(m%s,m/s|0),r[m]||--f}while(v!==m);--a}return d=null,r=null,function(m){m.save(),m.scale(1/t,-1/e),m.translate(0,-e),m.fill(g),m.beginPath(),m.restore()}}(t)),n.compiled))return void n.compiled(i);const s=this._createMaskCanvas(t),r=s.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,s.offsetX,s.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,n=0,s,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const l=q(a);a.transform(e,i,n,s,0,0);const h=this._createMaskCanvas(t);a.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]);for(let c=0,d=r.length;c<d;c+=2){const u=N.transform(l,[e,i,n,s,r[c],r[c+1]]),[f,p]=N.applyTransform([0,0],u);a.drawImage(h.canvas,f,p)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,n=this.current.patternFill;for(const s of t){const{data:r,width:a,height:l,transform:h}=s,c=this.cachedCanvases.getCanvas("maskCanvas",a,l),d=c.context;d.save(),ts(d,this.getObject(r,s)),d.globalCompositeOperation="source-in",d.fillStyle=n?i.getPattern(d,this,Vt(e),"Fill"):i,d.fillRect(0,0,a,l),d.restore(),e.save(),e.transform(...h),e.scale(1,-1),oi(e,c.canvas,0,0,a,l,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):z("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,n){if(!this.contentVisible)return;const s=this.getObject(t);if(!s)return void z("Dependent image isn't ready yet");const r=s.width,a=s.height,l=[];for(let h=0,c=n.length;h<c;h+=2)l.push({transform:[e,0,0,i,n[h],n[h+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(s,l)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:n}=t,s=this.cachedCanvases.getCanvas("inlineImage",i,n),r=s.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",s.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,n=this.ctx;if(this.save(),!ft){const{filter:a}=n;"none"!==a&&""!==a&&(n.filter="none")}let s;if(n.scale(1/e,-1/i),t.bitmap)s=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)s=t;else{const l=this.cachedCanvases.getCanvas("inlineImage",e,i).context;Jn(l,t),s=this.applyTransferMapsToCanvas(l)}const r=this._scaleImage(s,Vt(n));n.imageSmoothingEnabled=es(q(n),t.interpolate),oi(n,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let n;if(t.bitmap)n=t.bitmap;else{const l=this.cachedCanvases.getCanvas("inlineImage",t.width,t.height).context;Jn(l,t),n=this.applyTransferMapsToCanvas(l)}for(const s of e)i.save(),i.transform(...s.transform),i.scale(1,-1),oi(i,n,s.x,s.y,s.w,s.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){this.markedContentStack.push("OC"===t?{visible:this.optionalContentConfig.isVisible(e)}:{visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const i=this.ctx;this.pendingClip&&(e||(this.pendingClip===is?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=q(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:n,d:s}=this.ctx.getTransform();let r,a;if(0===i&&0===n){const l=Math.abs(e),h=Math.abs(s);if(l===h)if(0===t)r=a=1/l;else{const c=l*t;r=a=c<1?1/c:1}else if(0===t)r=1/l,a=1/h;else{const c=l*t,d=h*t;r=c<1?1/c:1,a=d<1?1/d:1}}else{const l=Math.abs(e*s-i*n),h=Math.hypot(e,i),c=Math.hypot(n,s);if(0===t)r=c/l,a=h/l;else{const d=t*l;r=c>d?c/d:1,a=h>d?h/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:i}=this.current,[n,s]=this.getScaleForStroking();if(e.lineWidth=i||1,1===n&&1===s)return void e.stroke();const r=e.getLineDash();if(t&&e.save(),e.scale(n,s),r.length>0){const a=Math.max(n,s);e.setLineDash(r.map(l=>l/a)),e.lineDashOffset/=a}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const o in Ot)void 0!==fe.prototype[o]&&(fe.prototype[Ot[o]]=fe.prototype[o]);class ke{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#e=t}}class Ha{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}getAll(){return Mi(this.#t)}has(t){return this.#t.has(t)}}const pe=Symbol("INTERNAL");class za{#t=!1;#e=!1;#i=!1;#n=!0;constructor(t,{name:e,intent:i,usage:n,rbGroups:s}){this.#t=!!(2&t),this.#e=!!(4&t),this.name=e,this.intent=i,this.usage=n,this.rbGroups=s}get visible(){if(this.#i)return this.#n;if(!this.#n)return!1;const{print:t,view:e}=this.usage;return this.#t?"OFF"!==e?.viewState:!this.#e||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==pe&&Y("Internal method `_setVisible` called."),this.#i=i,this.#n=e}}class Ua{#t=null;#e=new Map;#i=null;#n=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#n=t.order;for(const i of t.groups)this.#e.set(i.id,new za(e,i));if("OFF"===t.baseState)for(const i of this.#e.values())i._setVisible(pe,!1);for(const i of t.on)this.#e.get(i)._setVisible(pe,!0);for(const i of t.off)this.#e.get(i)._setVisible(pe,!1);this.#i=this.getHash()}}#r(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let n=1;n<e;n++){const s=t[n];let r;if(Array.isArray(s))r=this.#r(s);else{if(!this.#e.has(s))return z(`Optional content group not found: ${s}`),!0;r=this.#e.get(s).visible}switch(i){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return"And"===i}isVisible(t){if(0===this.#e.size)return!0;if(!t)return Je("Optional content group not defined."),!0;if("OCG"===t.type)return this.#e.has(t.id)?this.#e.get(t.id).visible:(z(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#r(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return z(`Unknown optional content policy ${t.policy}.`),!0}return z(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const n=this.#e.get(t);if(n){if(i&&e&&n.rbGroups.length)for(const s of n.rbGroups)for(const r of s)r!==t&&this.#e.get(r)?._setVisible(pe,!1,!0);n._setVisible(pe,!!e,!0),this.#t=null}else z(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const n of t){switch(n){case"ON":case"OFF":case"Toggle":i=n;continue}const s=this.#e.get(n);if(s)switch(i){case"ON":this.setVisibility(n,!0,e);break;case"OFF":this.setVisibility(n,!1,e);break;case"Toggle":this.setVisibility(n,!s.visible,e)}}this.#t=null}get hasInitialVisibility(){return null===this.#i||this.getHash()===this.#i}getOrder(){return this.#e.size?this.#n?this.#n.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?Mi(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(null!==this.#t)return this.#t;const t=new Nn;for(const[e,i]of this.#e)t.update(`${e}:${i.visible}`);return this.#t=t.hexdigest()}}class Wa{constructor(t,{disableRange:e=!1,disableStream:i=!1}){nt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:n,initialData:s,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,s?.length>0){const l=s instanceof Uint8Array&&s.byteLength===s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=n,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,h)=>{this._onReceiveData({begin:l,chunk:h})}),t.addProgressListener((l,h)=>{this._onProgress({loaded:l,total:h})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i):nt(this._rangeReaders.some(function(s){return s._begin===t&&(s._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){nt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Ga(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new $a(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Ga{constructor(t,e,i=!1,n=null){this._stream=t,this._done=i||!1,this._filename=Di(n)?n:null,this._queuedChunks=e||[],this._loaded=0;for(const s of this._queuedChunks)this._loaded+=s.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){var t=this;return(0,x.A)(function*(){if(t._queuedChunks.length>0)return{value:t._queuedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return t._requests.push(e),e.promise})()}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class $a{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){var t=this;return(0,x.A)(function*(){if(t._queuedChunk){const i=t._queuedChunk;return t._queuedChunk=null,{value:i,done:!1}}if(t._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return t._requests.push(e),e.promise})()}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ns(o,t){const e=new Headers;if(!o||!t||"object"!=typeof t)return e;for(const i in t){const n=t[i];void 0!==n&&e.append(i,n)}return e}function hi(o){try{return new URL(o).origin}catch{}return null}function ss({responseHeaders:o,isHttp:t,rangeChunkSize:e,disableRange:i}){const n={allowRangeRequests:!1,suggestedLength:void 0},s=parseInt(o.get("Content-Length"),10);return!Number.isInteger(s)||(n.suggestedLength=s,s<=2*e)||i||!t||"bytes"!==o.get("Accept-Ranges")||"identity"!==(o.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function rs(o){const t=o.get("Content-Disposition");if(t){let e=function Xa(o){let t=!0,e=i("filename\\*","i").exec(o);if(e){e=e[1];let c=a(e);return c=unescape(c),c=l(c),c=h(c),s(c)}if(e=function r(c){const d=[];let u;const f=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(u=f.exec(c));){let[,g,_,m]=u;if(g=parseInt(g,10),g in d){if(0===g)break}else d[g]=[_,m]}const p=[];for(let g=0;g<d.length&&g in d;++g){let[_,m]=d[g];m=a(m),_&&(m=unescape(m),0===g&&(m=l(m))),p.push(m)}return p.join("")}(o),e)return s(h(e));if(e=i("filename","i").exec(o),e){e=e[1];let c=a(e);return c=h(c),s(c)}function i(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function n(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(c,{fatal:!0}),f=de(d);d=u.decode(f),t=!1}catch{}}return d}function s(c){return t&&/[\x80-\xff]/.test(c)&&(c=n("utf-8",c),t&&(c=n("iso-8859-1",c))),c}function a(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let u=0;u<d.length;++u){const f=d[u].indexOf('"');-1!==f&&(d[u]=d[u].slice(0,f),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function l(c){const d=c.indexOf("'");return-1===d?c:n(c.slice(0,d),c.slice(d+1).replace(/^[^']*'/,""))}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,f,p){if("q"===f||"Q"===f)return n(u,p=(p=p.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(g,_){return String.fromCharCode(parseInt(_,16))}));try{p=atob(p)}catch{}return n(u,p)})}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Di(e))return e}return null}function ci(o,t){return 404===o||0===o&&t.startsWith("file:")?new Se('Missing PDF "'+t+'".'):new ti(`Unexpected server response (${o}) while retrieving PDF "${t}".`,o)}function as(o){return 200===o||206===o}function os(o,t,e){return{method:"GET",headers:o,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function ls(o){return o instanceof Uint8Array?o.buffer:o instanceof ArrayBuffer?o:(z(`getArrayBuffer - unexpected data format: ${o}`),new Uint8Array(o).buffer)}class hs{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=ns(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Ya(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new qa(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ya{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),n=e.url;fetch(n,os(i,this._withCredentials,this._abortController)).then(s=>{if(t._responseOrigin=hi(s.url),!as(s.status))throw ci(s.status,n);this._reader=s.body.getReader(),this._headersCapability.resolve();const r=s.headers,{allowRangeRequests:a,suggestedLength:l}=ss({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=l||this._contentLength,this._filename=rs(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Zt("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return(0,x.A)(function*(){yield t._headersCapability.promise;const{value:e,done:i}=yield t._reader.read();return i?{value:e,done:i}:(t._loaded+=e.byteLength,t.onProgress?.({loaded:t._loaded,total:t._contentLength}),{value:ls(e),done:!1})})()}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class qa{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const n=t.source;this._withCredentials=n.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!n.disableStream,this._abortController=new AbortController;const s=new Headers(t.headers);s.append("Range",`bytes=${e}-${i-1}`);const r=n.url;fetch(r,os(s,this._withCredentials,this._abortController)).then(a=>{const l=hi(a.url);if(l!==t._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${t._responseOrigin}".`);if(!as(a.status))throw ci(a.status,r);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return(0,x.A)(function*(){yield t._readCapability.promise;const{value:e,done:i}=yield t._reader.read();return i?{value:e,done:i}:(t._loaded+=e.byteLength,t.onProgress?.({loaded:t._loaded}),{value:ls(e),done:!1})})()}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Qa{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=ns(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,n=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[s,r]of this.headers)e.setRequestHeader(s,r);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),n.expectedStatus=206):n.expectedStatus=200,e.responseType="arraybuffer",nt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),n.onHeadersReceived=t.onHeadersReceived,n.onDone=t.onDone,n.onError=t.onError,n.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const n=i.xhr;if(n.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==n.readyState||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===n.status&&this.isHttp)return void i.onError(n.status);const s=n.status||200;if((200!==s||206!==i.expectedStatus)&&s!==i.expectedStatus)return void i.onError(n.status);const a=function Ka(o){const t=o.response;return"string"!=typeof t?t:de(t).buffer}(n);if(206===s){const l=n.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);h?i.onDone({begin:parseInt(h[1],10),chunk:a}):(z('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone({begin:0,chunk:a}):i.onError(n.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Za{constructor(t){this._source=t,this._manager=new Qa(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return nt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Ja(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new to(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ja{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=hi(e.responseURL);const i=e.getAllResponseHeaders(),n=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(a=>{const[l,...h]=a.split(": ");return[l,h.join(": ")]}):[]),{allowRangeRequests:s,suggestedLength:r}=ss({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});s&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=rs(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=ci(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}read(){var t=this;return(0,x.A)(function*(){if(yield t._headersCapability.promise,t._storedError)throw t._storedError;if(t._cachedChunks.length>0)return{value:t._cachedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return t._requests.push(e),e.promise})()}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class to{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=hi(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=ci(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}read(){var t=this;return(0,x.A)(function*(){if(t._storedError)throw t._storedError;if(null!==t._queuedChunk){const i=t._queuedChunk;return t._queuedChunk=null,{value:i,done:!1}}if(t._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return t._requests.push(e),e.promise})()}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const eo=/^[a-z][a-z0-9\-+.]+:/i;class no{constructor(t){this.source=t,this.url=function io(o){if(eo.test(o))return new URL(o);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(o))}(t.url),nt("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return nt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new so(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new ro(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class so{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then(n=>{this._contentLength=n.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},n=>{"ENOENT"===n.code&&(n=new Se(`Missing PDF "${this._url}".`)),this._storedError=n,this._headersCapability.reject(n)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return(0,x.A)(function*(){if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;const e=t._readableStream.read();return null===e?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=e.length,t.onProgress?.({loaded:t._loaded,total:t._contentLength}),{value:new Uint8Array(e).buffer,done:!1})})()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Zt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class ro{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!t.source.disableStream;const s=process.getBuiltinModule("fs");this._setReadableStream(s.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return(0,x.A)(function*(){if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;const e=t._readableStream.read();return null===e?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=e.length,t.onProgress?.({loaded:t._loaded}),{value:new Uint8Array(e).buffer,done:!1})})()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}class vt{#t=Promise.withResolvers();#e=null;#i=!1;#n=!!globalThis.FontInspector?.enabled;#r=null;#s=null;#a=0;#l=0;#c=null;#h=null;#u=0;#d=0;#f=Object.create(null);#o=[];#p=null;#m=[];#g=new WeakMap;#b=null;static#_=new Map;static#v=new Map;static#A=new WeakMap;static#y=null;static#x=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#p=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#p=new ReadableStream({start(l){l.enqueue(t),l.close()}})}this.#e=this.#h=e,this.#d=i.scale*(globalThis.devicePixelRatio||1),this.#u=i.rotation,this.#s={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:s,pageX:r,pageY:a}=i.rawDims;this.#b=[1,0,0,-1,-r,a+s],this.#l=n,this.#a=s,vt.#R(),ne(e,i),this.#t.promise.finally(()=>{vt.#x.delete(this),this.#s=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=_t.platform;return W(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{this.#c.read().then(({value:e,done:i})=>{i?this.#t.resolve():(this.#r??=e.lang,Object.assign(this.#f,e.styles),this.#S(e.items),t())},this.#t.reject)};return this.#c=this.#p.getReader(),vt.#x.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*(globalThis.devicePixelRatio||1),n=t.rotation;if(n!==this.#u&&(e?.(),this.#u=n,ne(this.#h,{rotation:n})),i!==this.#d){e?.(),this.#d=i;const s={div:null,properties:null,ctx:vt.#T(this.#r)};for(const r of this.#m)s.properties=this.#g.get(r),s.div=r,this.#E(s)}}cancel(){const t=new Zt("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#o}#S(t){if(this.#i)return;this.#s.ctx??=vt.#T(this.#r);const e=this.#m,i=this.#o;for(const n of t){if(e.length>1e5)return z("Ignoring additional textDivs for performance reasons."),void(this.#i=!0);if(void 0!==n.str)i.push(n.str),this.#M(n);else if("beginMarkedContentProps"===n.type||"beginMarkedContent"===n.type){const s=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),null!==n.id&&this.#e.setAttribute("id",`${n.id}`),s.append(this.#e)}else"endMarkedContent"===n.type&&(this.#e=this.#e.parentNode)}}#M(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#m.push(e);const n=N.transform(this.#b,t.transform);let s=Math.atan2(n[1],n[0]);const r=this.#f[t.fontName];r.vertical&&(s+=Math.PI/2);let a=this.#n&&r.fontSubstitution||r.fontFamily;a=vt.fontFamilyMap.get(a)||a;const l=Math.hypot(n[2],n[3]),h=l*vt.#I(a,this.#r);let c,d;0===s?(c=n[4],d=n[5]-h):(c=n[4]+h*Math.sin(s),d=n[5]-h*Math.cos(s));const u="calc(var(--scale-factor)*",f=e.style;this.#e===this.#h?(f.left=`${(100*c/this.#l).toFixed(2)}%`,f.top=`${(100*d/this.#a).toFixed(2)}%`):(f.left=`${u}${c.toFixed(2)}px)`,f.top=`${u}${d.toFixed(2)}px)`),f.fontSize=`${u}${(vt.#y*l).toFixed(2)}px)`,f.fontFamily=a,i.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#n&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),0!==s&&(i.angle=s*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const g=Math.abs(t.transform[0]),_=Math.abs(t.transform[3]);g!==_&&Math.max(g,_)/Math.min(g,_)>1.5&&(p=!0)}if(p&&(i.canvasWidth=r.vertical?t.height:t.width),this.#g.set(e,i),this.#s.div=e,this.#s.properties=i,this.#E(this.#s),i.hasText&&this.#e.append(e),i.hasEOL){const g=document.createElement("br");g.setAttribute("role","presentation"),this.#e.append(g)}}#E(t){const{div:e,properties:i,ctx:n}=t,{style:s}=e;let r="";if(vt.#y>1&&(r=`scale(${1/vt.#y})`),0!==i.canvasWidth&&i.hasText){const{fontFamily:a}=s,{canvasWidth:l,fontSize:h}=i;vt.#P(n,h*this.#d,a);const{width:c}=n.measureText(e.textContent);c>0&&(r=`scaleX(${l*this.#d/c}) ${r}`)}0!==i.angle&&(r=`rotate(${i.angle}deg) ${r}`),r.length>0&&(s.transform=r)}static cleanup(){if(!(this.#x.size>0)){this.#_.clear();for(const{canvas:t}of this.#v.values())t.remove();this.#v.clear()}}static#T(t=null){let e=this.#v.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#v.set(t,e),this.#A.set(e,{size:0,family:""})}return e}static#P(t,e,i){const n=this.#A.get(t);e===n.size&&i===n.family||(t.font=`${e}px ${i}`,n.size=e,n.family=i)}static#R(){if(null!==this.#y)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#y=t.getBoundingClientRect().height,t.remove()}static#I(t,e){const i=this.#_.get(t);if(i)return i;const n=this.#T(e);n.canvas.width=n.canvas.height=30,this.#P(n,30,t);const s=n.measureText("");let r=s.fontBoundingBoxAscent,a=Math.abs(s.fontBoundingBoxDescent);if(r){const c=r/(r+a);return this.#_.set(t,c),n.canvas.width=n.canvas.height=0,c}n.strokeStyle="red",n.clearRect(0,0,30,30),n.strokeText("g",0,0);let l=n.getImageData(0,0,30,30).data;a=0;for(let c=l.length-1-3;c>=0;c-=4)if(l[c]>0){a=Math.ceil(c/4/30);break}n.clearRect(0,0,30,30),n.strokeText("A",0,30),l=n.getImageData(0,0,30,30).data,r=0;for(let c=0,d=l.length;c<d;c+=4)if(l[c]>0){r=30-Math.floor(c/4/30);break}n.canvas.width=n.canvas.height=0;const h=r?r/(r+a):.8;return this.#_.set(t,h),h}}class De{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function n(s){if(!s)return;let r=null;const a=s.name;if("#text"===a)r=s.value;else{if(!De.shouldBuildText(a))return;s?.attributes?.textContent?r=s.attributes.textContent:s.value&&(r=s.value)}if(null!==r&&e.push({str:r}),s.children)for(const l of s.children)n(l)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const uo=ft?class xa extends Vn{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("file:///Users/admin/dev/ui-components/node_modules/pdfjs-dist/build/pdf.mjs")("@napi-rs/canvas").createCanvas(t,e)}}:class wa extends Vn{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}},fo=ft?class Sa extends jn{_fetch(t){return(0,x.A)(function*(){return Gn(t)})()}}:Hn,po=ft?class Ea extends zn{}:class ya extends zn{#t;#e;#i;#n;#r;#s;#a=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#n=t,this.#r=e}get#l(){return this.#e||=new Map}get#c(){return this.#s||=new Map}get#h(){if(!this.#i){const t=this.#r.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#r.createElementNS(Gt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#i=this.#r.createElementNS(Gt,"defs"),t.append(i),i.append(this.#i),this.#r.body.append(t)}return this.#i}#u(t){if(1===t.length){const l=t[0],h=new Array(256);for(let d=0;d<256;d++)h[d]=l[d]/255;const c=h.join(",");return[c,c,c]}const[e,i,n]=t,s=new Array(256),r=new Array(256),a=new Array(256);for(let l=0;l<256;l++)s[l]=e[l]/255,r[l]=i[l]/255,a[l]=n[l]/255;return[s.join(","),r.join(","),a.join(",")]}#d(t){if(void 0===this.#t){this.#t="";const e=this.#r.URL;e!==this.#r.baseURI&&(ni(e)?z('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=e.split("#",1)[0])}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#l.get(t);if(e)return e;const[i,n,s]=this.#u(t),r=1===t.length?i:`${i}${n}${s}`;if(e=this.#l.get(r),e)return this.#l.set(t,e),e;const a=`g_${this.#n}_transfer_map_${this.#a++}`,l=this.#d(a);this.#l.set(t,l),this.#l.set(r,l);const h=this.#p(a);return this.#g(i,n,s,h),l}addHCMFilter(t,e){const i=`${t}-${e}`,n="base";let s=this.#c.get(n);if(s?.key===i||(s?(s.filter?.remove(),s.key=i,s.url="none",s.filter=null):(s={key:i,url:"none",filter:null},this.#c.set(n,s)),!t||!e))return s.url;const r=this.#_(t);t=N.makeHexColor(...r);const a=this.#_(e);if(e=N.makeHexColor(...a),this.#h.style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.url;const l=new Array(256);for(let f=0;f<=255;f++){const p=f/255;l[f]=p<=.03928?p/12.92:((p+.055)/1.055)**2.4}const h=l.join(","),c=`g_${this.#n}_hcm_filter`,d=s.filter=this.#p(c);this.#g(h,h,h,d),this.#o(d);const u=(f,p)=>{const g=r[f]/255,_=a[f]/255,m=new Array(p+1);for(let A=0;A<=p;A++)m[A]=g+A/p*(_-g);return m.join(",")};return this.#g(u(0,5),u(1,5),u(2,5),d),s.url=this.#d(c),s.url}addAlphaFilter(t){let e=this.#l.get(t);if(e)return e;const[i]=this.#u([t]),n=`alpha_${i}`;if(e=this.#l.get(n),e)return this.#l.set(t,e),e;const s=`g_${this.#n}_alpha_map_${this.#a++}`,r=this.#d(s);this.#l.set(t,r),this.#l.set(n,r);const a=this.#p(s);return this.#b(i,a),r}addLuminosityFilter(t){let i,n,e=this.#l.get(t||"luminosity");if(e)return e;if(t?([i]=this.#u([t]),n=`luminosity_${i}`):n="luminosity",e=this.#l.get(n),e)return this.#l.set(t,e),e;const s=`g_${this.#n}_luminosity_map_${this.#a++}`,r=this.#d(s);this.#l.set(t,r),this.#l.set(n,r);const a=this.#p(s);return this.#f(a),t&&this.#b(i,a),r}addHighlightHCMFilter(t,e,i,n,s){const r=`${e}-${i}-${n}-${s}`;let a=this.#c.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#c.set(t,a)),!e||!i))return a.url;const[l,h]=[e,i].map(this.#_.bind(this));let c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[u,f]=[n,s].map(this.#_.bind(this));d<c&&([c,d,u,f]=[d,c,f,u]),this.#h.style.color="";const p=(m,A,v)=>{const w=new Array(256),E=(d-c)/v,C=m/255,M=(A-m)/(255*v);let L=0;for(let y=0;y<=v;y++){const P=Math.round(c+y*E),R=C+y*M;for(let I=L;I<=P;I++)w[I]=R;L=P+1}for(let y=L;y<256;y++)w[y]=w[L-1];return w.join(",")},g=`g_${this.#n}_hcm_${t}_filter`,_=a.filter=this.#p(g);return this.#o(_),this.#g(p(u[0],f[0],5),p(u[1],f[1],5),p(u[2],f[2],5),_),a.url=this.#d(g),a.url}destroy(t=!1){t&&this.#s?.size||(this.#i?.parentNode.parentNode.remove(),this.#i=null,this.#e?.clear(),this.#e=null,this.#s?.clear(),this.#s=null,this.#a=0)}#f(t){const e=this.#r.createElementNS(Gt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#o(t){const e=this.#r.createElementNS(Gt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#p(t){const e=this.#r.createElementNS(Gt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#h.append(e),e}#m(t,e,i){const n=this.#r.createElementNS(Gt,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),t.append(n)}#g(t,e,i,n){const s=this.#r.createElementNS(Gt,"feComponentTransfer");n.append(s),this.#m(s,"feFuncR",t),this.#m(s,"feFuncG",e),this.#m(s,"feFuncB",i)}#b(t,e){const i=this.#r.createElementNS(Gt,"feComponentTransfer");e.append(i),this.#m(i,"feFuncA",t)}#_(t){return this.#h.style.color=t,Oi(getComputedStyle(this.#h).getPropertyValue("color"))}},go=ft?class Pa extends Un{_fetch(t){return(0,x.A)(function*(){return Gn(t)})()}}:Wn;function mo(o={}){"string"==typeof o||o instanceof URL?o={url:o}:(o instanceof ArrayBuffer||ArrayBuffer.isView(o))&&(o={data:o});const t=new Xi,{docId:e}=t,i=o.url?function bo(o){if(o instanceof URL)return o.href;try{return new URL(o,window.location).href}catch{if(ft&&"string"==typeof o)return o}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(o.url):null,n=o.data?function _o(o){if(ft&&typeof Buffer<"u"&&o instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(o instanceof Uint8Array&&o.byteLength===o.buffer.byteLength)return o;if("string"==typeof o)return de(o);if(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||"object"==typeof o&&!isNaN(o?.length))return new Uint8Array(o);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(o.data):null,s=o.httpHeaders||null,r=!0===o.withCredentials,a=o.password??null,l=o.range instanceof ds?o.range:null,h=Number.isInteger(o.rangeChunkSize)&&o.rangeChunkSize>0?o.rangeChunkSize:65536;let c=o.worker instanceof ht?o.worker:null;const d=o.verbosity,u="string"!=typeof o.docBaseUrl||ni(o.docBaseUrl)?null:o.docBaseUrl,f="string"==typeof o.cMapUrl?o.cMapUrl:null,p=!1!==o.cMapPacked,g=o.CMapReaderFactory||fo,_="string"==typeof o.standardFontDataUrl?o.standardFontDataUrl:null,m=o.StandardFontDataFactory||go,A=!0!==o.stopAtErrors,v=Number.isInteger(o.maxImageSize)&&o.maxImageSize>-1?o.maxImageSize:-1,w=!1!==o.isEvalSupported,E="boolean"==typeof o.isOffscreenCanvasSupported?o.isOffscreenCanvasSupported:!ft,C="boolean"==typeof o.isImageDecoderSupported?o.isImageDecoderSupported:!ft&&(_t.platform.isFirefox||!globalThis.chrome),M=Number.isInteger(o.canvasMaxAreaInBytes)?o.canvasMaxAreaInBytes:-1,L="boolean"==typeof o.disableFontFace?o.disableFontFace:ft,y=!0===o.fontExtraProperties,P=!0===o.enableXfa,R=o.ownerDocument||globalThis.document,I=!0===o.disableRange,j=!0===o.disableStream,H=!0===o.disableAutoFetch,ct=!0===o.pdfBug,D=o.CanvasFactory||uo,O=o.FilterFactory||po,xt=!0===o.enableHWA,Lt=l?l.length:o.length??NaN,he="boolean"==typeof o.useSystemFonts?o.useSystemFonts:!ft&&!L,Rt="boolean"==typeof o.useWorkerFetch?o.useWorkerFetch:g===Hn&&m===Wn&&f&&_&&Ce(f,document.baseURI)&&Ce(_,document.baseURI);!function Zr(o){Number.isInteger(o)&&(Ze=o)}(d);const at={canvasFactory:new D({ownerDocument:R,enableHWA:xt}),filterFactory:new O({docId:e,ownerDocument:R}),cMapReaderFactory:Rt?null:new g({baseUrl:f,isCompressed:p}),standardFontDataFactory:Rt?null:new m({baseUrl:_})};if(!c){const It={verbosity:d,port:ke.workerPort};c=It.port?ht.fromPort(It):new ht(It),t._worker=c}const we={docId:e,apiVersion:"4.10.38",data:n,password:a,disableAutoFetch:H,rangeChunkSize:h,length:Lt,docBaseUrl:u,enableXfa:P,evaluatorOptions:{maxImageSize:v,disableFontFace:L,ignoreErrors:A,isEvalSupported:w,isOffscreenCanvasSupported:E,isImageDecoderSupported:C,canvasMaxAreaInBytes:M,fontExtraProperties:y,useSystemFonts:he,cMapUrl:Rt?f:null,standardFontDataUrl:Rt?_:null}},$e={disableFontFace:L,fontExtraProperties:y,ownerDocument:R,pdfBug:ct,styleElement:null,loadingParams:{disableAutoFetch:H,enableXfa:P}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const It=c.messageHandler.sendWithPromise("GetDocRequest",we,n?[n.buffer]:null);let K;if(l)K=new Wa(l,{disableRange:I,disableStream:j});else if(!n){if(!i)throw new Error("getDocument - no `url` parameter provided.");let Ut;if(ft)if(Ce(i)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");Ut=hs}else Ut=no;else Ut=Ce(i)?hs:Za;K=new Ut({url:i,length:Lt,httpHeaders:s,withCredentials:r,rangeChunkSize:h,disableRange:I,disableStream:j})}return It.then(Ut=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const jr=new Re(e,Ut,c.port),Od=new yo(jr,t,K,$e,at);t._transport=Od,jr.send("Ready",null)})}).catch(t._capability.reject),t}function cs(o){return"object"==typeof o&&Number.isInteger(o?.num)&&o.num>=0&&Number.isInteger(o?.gen)&&o.gen>=0}class Xi{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Xi.#t++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){var t=this;return(0,x.A)(function*(){t.destroyed=!0;try{t._worker?.port&&(t._worker._pendingDestroy=!0),yield t._transport?.destroy()}catch(e){throw t._worker?.port&&delete t._worker._pendingDestroy,e}t._transport=null,t._worker?.destroy(),t._worker=null})()}}class ds{constructor(t,e,i=!1,n=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=n,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const i of this._progressListeners)i(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Y("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class vo{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return W(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Ao{#t=null;#e=!1;constructor(t,e,i,n=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=n?new In:null,this._pdfBug=n,this.commonObjs=i.commonObjs,this.objs=new us,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:t,rotation:e=this.rotate,offsetX:i=0,offsetY:n=0,dontFlip:s=!1}={}){return new Pe({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:s})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return W(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){var t=this;return(0,x.A)(function*(){return t._transport._htmlForXfa?.children[t._pageIndex]||null})()}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:n=Kt.ENABLE,transform:s=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:d=!1}){this._stats?.time("Overall");const u=this._transport.getRenderingIntent(i,n,c,d),{renderingIntent:f,cacheKey:p}=u;this.#e=!1,this.#n(),a||=this._transport.getOptionalContentConfig(f);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const _=!!(4&f);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));const m=w=>{g.renderTasks.delete(A),(this._maybeCleanupAfterRender||_)&&(this.#e=!0),this.#i(!_),w?(A.capability.reject(w),this._abortOperatorList({intentState:g,reason:w instanceof Error?w:new Error(w)})):A.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},A=new ge({callback:m,params:{canvasContext:t,viewport:e,transform:s,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:h});(g.renderTasks||=new Set).add(A);const v=A.task;return Promise.all([g.displayReadyCapability.promise,a]).then(([w,E])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(E.renderingIntent&f))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");A.initializeGraphics({transparency:w,optionalContentConfig:E}),A.operatorListChanged()}}).catch(m),v}getOperatorList({intent:t="display",annotationMode:e=Kt.ENABLE,printAnnotationStorage:i=null,isEditing:n=!1}={}){const r=this._transport.getRenderingIntent(t,e,i,n,!0);let l,a=this._intentStates.get(r.cacheKey);return a||(a=Object.create(null),this._intentStates.set(r.cacheKey,a)),a.opListReadCapability||(l=Object.create(null),l.operatorListChanged=function s(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(l))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(l),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:n=>n.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>De.textContent(i));const e=this.streamTextContent(t);return new Promise(function(i,n){const r=e.getReader(),a={items:[],styles:Object.create(null),lang:null};!function s(){r.read().then(function({value:l,done:h}){h?i(a):(a.lang??=l.lang,Object.assign(a.styles,l.styles),a.items.push(...l.items),s())},n)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#e=!1,this.#n(),Promise.all(t)}cleanup(t=!1){this.#e=!0;const e=this.#i(!1);return t&&e&&(this._stats&&=new In),e}#i(t=!1){if(this.#n(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#i(!1)},5e3),!1;for(const{renderTasks:e,operatorList:i}of this._intentStates.values())if(e.size>0||!i.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#n(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,n=t.length;i<n;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const i of e.renderTasks)i.operatorListChanged();t.lastChunk&&this.#i(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:n}){const{map:s,transfer:r}=i,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:s,modifiedIds:n},r).getReader(),h=this._intentStates.get(e);h.streamReader=l;const c=()=>{l.read().then(({value:d,done:u})=>{u?h.streamReader=null:this._transport.destroyed||(this._renderPageChunk(d,h),c())},d=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const u of h.renderTasks)u.operatorListChanged();this.#i(!0)}if(h.displayReadyCapability)h.displayReadyCapability.reject(d);else{if(!h.opListReadCapability)throw d;h.opListReadCapability.reject(d)}}})};c()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof ki){let n=100;return e.extraDelay>0&&e.extraDelay<1e3&&(n+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},n))}}if(t.streamReader.cancel(new Zt(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[n,s]of this._intentStates)if(s===t){this._intentStates.delete(n);break}this.cleanup()}}}get stats(){return this._stats}}class wo{#t=new Map;#e=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const[n]of this.#t)n.call(this,i)})}addEventListener(t,e,i=null){let n=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted)return void z("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);n=()=>s.removeEventListener("abort",r),s.addEventListener("abort",r)}this.#t.set(e,n)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}class ht{static#t=0;static#e=!1;static#i;static{ft&&(this.#e=!0,ke.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(i=new URL(t),!i.origin||"null"===i.origin)return!1}catch{return!1}const n=new URL(e,i);return i.origin===n.origin},this._createCDNWrapper=t=>URL.createObjectURL(new Blob([`await import("${t}");`],{type:"text/javascript"}))}constructor({name:t=null,port:e=null,verbosity:i=Jr()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(ht.#i?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(ht.#i||=new WeakMap).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return this._readyCapability.promise}#n(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Re("main","worker",t),this._messageHandler.on("ready",function(){}),this.#n()}_initialize(){if(ht.#e||ht.#r)return void this._setupFakeWorker();let{workerSrc:t}=ht;try{ht._isSameOrigin(window.location.href,t)||(t=ht._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new Re("main","worker",e),n=()=>{s.abort(),i.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},s=new AbortController;e.addEventListener("error",()=>{this._webWorker||n()},{signal:s.signal}),i.on("test",a=>{s.abort(),!this.destroyed&&a?(this._messageHandler=i,this._port=e,this._webWorker=e,this.#n()):n()}),i.on("ready",a=>{if(s.abort(),this.destroyed)n();else try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;i.send("test",a,[a.buffer])};return void r()}catch{Je("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){ht.#e||(z("Setting up fake worker."),ht.#e=!0),ht._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new wo;this._port=e;const i="fake"+ht.#t++,n=new Re(i+"_worker",i,e);t.setup(n,e),this._messageHandler=new Re(i,i+"_worker",e),this.#n()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,ht.#i?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#i?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new ht(t)}static get workerSrc(){if(ke.workerSrc)return ke.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#r(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){var t=this;return W(this,"_setupFakeWorkerGlobal",function(){var i=(0,x.A)(function*(){return t.#r?t.#r:(yield import(t.workerSrc)).WorkerMessageHandler});return function(){return i.apply(this,arguments)}}()())}}class yo{#t=new Map;#e=new Map;#i=new Map;#n=new Map;#r=null;constructor(t,e,i,n,s){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new us,this.fontLoader=new va({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=s.canvasFactory,this.filterFactory=s.filterFactory,this.cMapReaderFactory=s.cMapReaderFactory,this.standardFontDataFactory=s.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#s(t,e=null){const i=this.#t.get(t);if(i)return i;const n=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,n),n}get annotationStorage(){return W(this,"annotationStorage",new ji)}getRenderingIntent(t,e=Kt.ENABLE,i=null,n=!1,s=!1){let r=2,a=Vi;switch(t){case"any":r=1;break;case"display":break;case"print":r=4;break;default:z(`getRenderingIntent - invalid intent: ${t}`)}const l=4&r&&i instanceof Fn?i:this.annotationStorage;switch(e){case Kt.DISABLE:r+=64;break;case Kt.ENABLE:break;case Kt.ENABLE_FORMS:r+=16;break;case Kt.ENABLE_STORAGE:r+=32,a=l.serializable;break;default:z(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(r+=128),s&&(r+=256);const{ids:h,hash:c}=l.modifiedIds;return{renderingIntent:r,cacheKey:[r,a.hash,c].join("_"),annotationStorageSerializable:a,modifiedIds:h}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#r?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of this.#e.values())t.push(i._destroy());this.#e.clear(),this.#i.clear(),this.#n.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),vt.cleanup(),this._networkStream?.cancelAllRequests(new Zt("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){var t=this;const{messageHandler:e,loadingTask:i}=this;e.on("GetReader",(n,s)=>{nt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},s.onPull=()=>{this._fullReader.read().then(function({value:r,done:a}){a?s.close():(nt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(r),1,[r]))}).catch(r=>{s.error(r)})},s.onCancel=r=>{this._fullReader.cancel(r),s.ready.catch(a=>{if(!this.destroyed)throw a})}}),e.on("ReaderHeadersReady",function(){var n=(0,x.A)(function*(s){yield t._fullReader.headersReady;const{isStreamingSupported:r,isRangeSupported:a,contentLength:l}=t._fullReader;return(!r||!a)&&(t._lastProgress&&i.onProgress?.(t._lastProgress),t._fullReader.onProgress=h=>{i.onProgress?.({loaded:h.loaded,total:h.total})}),{isStreamingSupported:r,isRangeSupported:a,contentLength:l}});return function(s){return n.apply(this,arguments)}}()),e.on("GetRangeReader",(n,s)=>{nt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(n.begin,n.end);r?(s.onPull=()=>{r.read().then(function({value:a,done:l}){l?s.close():(nt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(a),1,[a]))}).catch(a=>{s.error(a)})},s.onCancel=a=>{r.cancel(a),s.ready.catch(l=>{if(!this.destroyed)throw l})}):s.close()}),e.on("GetDoc",({pdfInfo:n})=>{this._numPages=n.numPages,this._htmlForXfa=n.htmlForXfa,delete n.htmlForXfa,i._capability.resolve(new vo(n,this))}),e.on("DocException",n=>{i._capability.reject(wt(n))}),e.on("PasswordRequest",n=>{this.#r=Promise.withResolvers();try{if(!i.onPassword)throw wt(n);i.onPassword(r=>{r instanceof Error?this.#r.reject(r):this.#r.resolve({password:r})},n.code)}catch(s){this.#r.reject(s)}return this.#r.promise}),e.on("DataLoaded",n=>{i.onProgress?.({loaded:n.length,total:n.length}),this.downloadInfoCapability.resolve(n)}),e.on("StartRenderPage",n=>{this.destroyed||this.#e.get(n.pageIndex)._startRenderPage(n.transparency,n.cacheKey)}),e.on("commonobj",([n,s,r])=>{if(this.destroyed||this.commonObjs.has(n))return null;switch(s){case"Font":const{disableFontFace:a,fontExtraProperties:l,pdfBug:h}=this._params;if("error"in r){const f=r.error;z(`Error during font loading: ${f}`),this.commonObjs.resolve(n,f);break}const c=h&&globalThis.FontInspector?.enabled?(f,p)=>globalThis.FontInspector.fontAdded(f,p):null,d=new Aa(r,{disableFontFace:a,fontExtraProperties:l,inspectFont:c});this.fontLoader.bind(d).catch(()=>e.sendWithPromise("FontFallback",{id:n})).finally(()=>{!l&&d.data&&(d.data=null),this.commonObjs.resolve(n,d)});break;case"CopyLocalImage":const{imageRef:u}=r;nt(u,"The imageRef must be defined.");for(const f of this.#e.values())for(const[,p]of f.objs)if(p?.ref===u)return p.dataLen?(this.commonObjs.resolve(n,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,r);break;default:throw new Error(`Got unknown common object type ${s}`)}return null}),e.on("obj",([n,s,r,a])=>{if(this.destroyed)return;const l=this.#e.get(s);if(!l.objs.has(n)){if(0===l._intentStates.size)return void a?.bitmap?.close();switch(r){case"Image":l.objs.resolve(n,a),a?.dataLen>1e7&&(l._maybeCleanupAfterRender=!0);break;case"Pattern":l.objs.resolve(n,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),e.on("DocProgress",n=>{this.destroyed||i.onProgress?.({loaded:n.loaded,total:n.total})}),e.on("FetchBuiltInCMap",function(){var n=(0,x.A)(function*(s){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return t.cMapReaderFactory.fetch(s)});return function(s){return n.apply(this,arguments)}}()),e.on("FetchStandardFontData",function(){var n=(0,x.A)(function*(s){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return t.standardFontDataFactory.fetch(s)});return function(s){return n.apply(this,arguments)}}())}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&z("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#i.get(e);if(i)return i;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(s=>{if(this.destroyed)throw new Error("Transport destroyed");s.refStr&&this.#n.set(s.refStr,t);const r=new Ao(e,s,this,this._params.pdfBug);return this.#e.set(e,r),r});return this.#i.set(e,n),n}getPageIndex(t){return cs(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#s("GetFieldObjects")}hasJSActions(){return this.#s("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#s("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#s("GetOptionalContentConfig").then(e=>new Ua(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then(n=>({info:n[0],metadata:n[1]?new Ha(n[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(){var t=this;return(0,x.A)(function*(e=!1){if(!t.destroyed){yield t.messageHandler.sendWithPromise("Cleanup",null);for(const i of t.#e.values())if(!i.cleanup())throw new Error(`startCleanup: Page ${i.pageNumber} is currently rendering.`);t.commonObjs.clear(),e||t.fontLoader.clear(),t.#t.clear(),t.filterFactory.destroy(!0),vt.cleanup()}}).apply(this,arguments)}cachedPageNumber(t){return cs(t)?this.#n.get(0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`)??null:null}}const Oe=Symbol("INITIAL_DATA");class us{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:Oe}}get(t,e=null){if(e){const n=this.#e(t);return n.promise.then(()=>e(n.data)),null}const i=this.#t[t];if(!i||i.data===Oe)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#t[t];return!!e&&e.data!==Oe}delete(t){const e=this.#t[t];return!(!e||e.data===Oe||(delete this.#t[t],0))}resolve(t,e=null){const i=this.#e(t);i.data=e,i.resolve()}clear(){for(const t in this.#t){const{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:e}=this.#t[t];e!==Oe&&(yield[t,e])}}}class Eo{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}}class ge{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:n,annotationCanvasMap:s,operatorList:r,pageIndex:a,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=n,this.annotationCanvasMap=s,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Eo(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(ge.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ge.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:i,viewport:n,transform:s,background:r}=this.params;this.gfx=new fe(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:s,viewport:n,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),ge.#e.delete(this._canvas),this.callback(t||new ki(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){var t=this;return(0,x.A)(function*(){t.cancelled||(t.operatorListIdx=t.gfx.executeOperatorList(t.operatorList,t.operatorListIdx,t._continueBound,t.stepper),t.operatorListIdx===t.operatorList.argsArray.length&&(t.running=!1,t.operatorList.lastChunk&&(t.gfx.endDrawing(),ge.#e.delete(t._canvas),t.callback())))})()}}const xo="4.10.38",So="f9bea397f";function fs(o){return Math.floor(255*Math.max(0,Math.min(1,o))).toString(16).padStart(2,"0")}function Ne(o){return Math.max(0,Math.min(255,255*o))}class ps{static CMYK_G([t,e,i,n]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+n)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=Ne(t),t,t]}static G_HTML([t]){const e=fs(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Ne)}static RGB_HTML(t){return`#${t.map(fs).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,i+n),1-Math.min(1,e+n)]}static CMYK_rgb([t,e,i,n]){return[Ne(1-Math.min(1,t+n)),Ne(1-Math.min(1,i+n)),Ne(1-Math.min(1,e+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const n=1-t,s=1-e,r=1-i;return["CMYK",n,s,r,Math.min(n,s,r)]}}class Po{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),i||(n.setAttribute("width",`${t}px`),n.setAttribute("height",`${e}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${t} ${e}`),n}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Y("Abstract method `_createSVG` called.")}}class Yi extends Po{_createSVG(t){return document.createElementNS(Gt,t)}}class gs{static setupStorage(t,e,i,n,s){const r=n.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===s)break;t.addEventListener("input",a=>{n.setValue(e,{value:a.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===s)break;t.addEventListener("change",a=>{n.setValue(e,{value:a.target.getAttribute(a.target.checked?"xfaOn":"xfaOff")})})}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===s)break;t.addEventListener("input",a=>{n.setValue(e,{value:a.target.value})})}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const a of i.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const l=a.target.options;n.setValue(e,{value:-1===l.selectedIndex?"":l[l.selectedIndex].value})})}}static setAttributes({html:t,element:e,storage:i=null,intent:n,linkService:s}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${n}`);for(const[l,h]of Object.entries(r))if(null!=h)switch(l){case"class":h.length&&t.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!a||"href"!==l&&"newWindow"!==l)&&t.setAttribute(l,h)}a&&s.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,n=t.xfaHtml,s=t.intent||"display",r=document.createElement(n.name);n.attributes&&this.setAttributes({html:r,element:n,intent:s,linkService:i});const a="richText"!==s,l=t.div;if(l.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=d}a&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(0===n.children.length){if(n.value){const d=document.createTextNode(n.value);r.append(d),a&&De.shouldBuildText(n.name)&&h.push(d)}return{textDivs:h}}const c=[[n,-1,r]];for(;c.length>0;){const[d,u,f]=c.at(-1);if(u+1===d.children.length){c.pop();continue}const p=d.children[++c.at(-1)[1]];if(null===p)continue;const{name:g}=p;if("#text"===g){const m=document.createTextNode(p.value);h.push(m),f.append(m);continue}const _=p?.attributes?.xmlns?document.createElementNS(p.attributes.xmlns,g):document.createElement(g);if(f.append(_),p.attributes&&this.setAttributes({html:_,element:p,storage:e,intent:s,linkService:i}),p.children?.length>0)c.push([p,-1,_]);else if(p.value){const m=document.createTextNode(p.value);a&&De.shouldBuildText(g)&&h.push(m),_.append(m)}}for(const d of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Fe=1e3,se=new WeakSet;function Jt(o){return{width:o[2]-o[0],height:o[3]-o[1]}}class To{static create(t){switch(t.data.annotationType){case 2:return new ms(t);case 1:return new Mo(t);case 20:switch(t.data.fieldType){case"Tx":return new Lo(t);case"Btn":return t.data.radioButton?new bs(t):t.data.checkBox?new Io(t):new ko(t);case"Ch":return new Do(t);case"Sig":return new Ro(t)}return new re(t);case 16:return new qi(t);case 3:return new _s(t);case 4:return new No(t);case 5:return new Fo(t);case 6:return new Bo(t);case 8:return new vs(t);case 14:return new jo(t);case 15:return new Ki(t);case 7:return new Vo(t);case 9:return new As(t);case 10:return new Ho(t);case 11:return new zo(t);case 12:return new Uo(t);case 13:return new ws(t);case 17:return new Wo(t);default:return new et(t)}}}class et{#t=null;#e=!1;#i=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:n=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),n&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return et._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#n(e),this.#i?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#n(this.#t.rect),this.#i?.popup.resetEdited(),this.#t=null)}#n(t){const{container:{style:e},data:{rect:i,rotation:n},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:r,pageX:a,pageY:l}}}}=this;i?.splice(0,4,...t);const{width:h,height:c}=Jt(t);e.left=100*(t[0]-a)/s+"%",e.top=100*(r-t[3]+l)/r+"%",0===n?(e.width=100*h/s+"%",e.height=100*c/r+"%"):this.setRotation(n)}_createContainer(t){const{data:e,parent:{page:i,viewport:n}}=this,s=document.createElement("section");s.setAttribute("data-annotation-id",e.id),this instanceof re||(s.tabIndex=Fe);const{style:r}=s;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(s.title=e.alternativeText),e.noRotate&&s.classList.add("norotate"),!e.rect||this instanceof qi){const{rotation:g}=e;return!e.hasOwnCanvas&&0!==g&&this.setRotation(g,s),s}const{width:a,height:l}=Jt(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const g=e.borderStyle.horizontalCornerRadius,_=e.borderStyle.verticalCornerRadius;switch(g>0||_>0?r.borderRadius=`calc(${g}px * var(--scale-factor)) / calc(${_}px * var(--scale-factor))`:this instanceof bs&&(r.borderRadius=`calc(${a}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`),e.borderStyle.style){case 1:r.borderStyle="solid";break;case 2:r.borderStyle="dashed";break;case 3:z("Unimplemented border style: beveled");break;case 4:z("Unimplemented border style: inset");break;case 5:r.borderBottomStyle="solid"}const m=e.borderColor||null;m?(this.#e=!0,r.borderColor=N.makeHexColor(0|m[0],0|m[1],0|m[2])):r.borderWidth=0}const h=N.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:f}=n.rawDims;r.left=100*(h[0]-u)/c+"%",r.top=100*(h[1]-f)/d+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=100*a/c+"%",r.height=100*l/d+"%"):this.setRotation(p,s),s}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:n}=this.parent.viewport.rawDims,{width:s,height:r}=Jt(this.data.rect);let a,l;t%180==0?(a=100*s/i,l=100*r/n):(a=100*r/i,l=100*s/n),e.style.width=`${a}%`,e.style.height=`${l}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,i,n)=>{const s=n.detail[e],r=s[0],a=s.slice(1);n.target.style[i]=ps[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[i]:ps[`${r}_rgb`](a)})};return W(this,"_commonActions",{display:e=>{const{display:i}=e.detail,n=i%2==1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:1===i||2===i})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:i}=e.detail;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:i,noView:i})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const i=e.detail.rotation;this.setRotation(i),this.annotationStorage.setValue(this.data.id,{rotation:i})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const n of Object.keys(e.detail))(t[n]||i[n])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[n,s]of Object.entries(e)){const r=i[n];r&&(r({detail:{[n]:s},target:t}),delete e[n])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,n,s]=this.data.rect.map(g=>Math.fround(g));if(8===t.length){const[g,_,m,A]=t.subarray(2,6);if(n===g&&s===_&&e===m&&i===A)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:g,borderWidth:_}=r;r.borderWidth=0,a=["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="${g}" stroke-width="${_}">`],this.container.classList.add("hasBorder")}const l=n-e,h=s-i,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const u=c.createElement("defs");d.append(u);const f=c.createElement("clipPath"),p=`clippath_${this.data.id}`;f.setAttribute("id",p),f.setAttribute("clipPathUnits","objectBoundingBox"),u.append(f);for(let g=2,_=t.length;g<_;g+=8){const m=t[g],A=t[g+1],v=t[g+2],w=t[g+3],E=c.createElement("rect"),C=(v-e)/l,M=(s-A)/h,L=(m-v)/l,y=(A-w)/h;E.setAttribute("x",C),E.setAttribute("y",M),E.setAttribute("width",L),E.setAttribute("height",y),f.append(E),a?.push(`<rect vector-effect="non-scaling-stroke" x="${C}" y="${M}" width="${L}" height="${y}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#i=new qi({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){Y("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:s,id:r,exportValues:a}of n){if(-1===s||r===e)continue;const l="string"==typeof a?a:null,h=document.querySelector(`[data-element-id="${r}"]`);!h||se.has(h)?i.push({id:r,exportValue:l,domElement:h}):z(`_getElementsByName - element not allowed: ${r}`)}return i}for(const n of document.getElementsByName(t)){const{exportValue:s}=n,r=n.getAttribute("data-element-id");r!==e&&se.has(n)&&i.push({id:r,exportValue:s,domElement:n})}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class ms extends et{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let n=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(i,t.action),n=!0):t.attachment?(this.#e(i,t.attachment,t.attachmentDest),n=!0):t.setOCGState?(this.#i(i,t.setOCGState),n=!0):t.dest?(this._bindLink(i,t.dest),n=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),n=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(i),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#t()}#i(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(e.actions)){const s=i.get(n);s&&(t[s]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:n}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects)return z('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:n,refs:s,include:r}=e,a=[];if(0!==n.length||0!==s.length){const c=new Set(s);for(const d of n){const u=this._fieldObjects[d]||[];for(const{id:f}of u)c.add(f)}for(const d of Object.values(this._fieldObjects))for(const u of d)c.has(u.id)===r&&a.push(u)}else for(const c of Object.values(this._fieldObjects))a.push(...c);const l=this.annotationStorage,h=[];for(const c of a){const{id:d}=c;switch(h.push(d),c.type){case"text":case"combobox":case"listbox":l.setValue(d,{value:c.defaultValue||""});break;case"checkbox":case"radiobutton":l.setValue(d,{value:c.defaultValue===c.exportValues});break;default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);u&&(se.has(u)?u.dispatchEvent(new Event("resetform")):z(`_bindResetFormAction - element not allowed: ${d}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class Mo extends et{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class re extends et{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return _t.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,n,s){i.includes("mouse")?t.addEventListener(i,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(i,r=>{if("blur"===i){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(r)}})})}_setEventListeners(t,e,i,n){for(const[s,r]of i)("Action"===r||this.data.actions?.[r])&&(("Focus"===r||"Blur"===r)&&(e||={focused:!1}),this._setEventListener(t,e,s,r,n),"Focus"!==r||this.data.actions?.Blur?"Blur"===r&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":N.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const{fontColor:i}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,s=t.style;let r;const l=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-2),c=Math.round(h/(1.35*n))||1;r=Math.min(n,l(h/c/1.35))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(n,l(h/1.35))}s.fontSize=`calc(${r}px * var(--scale-factor))`,s.color=N.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(s.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Lo extends re{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,n){const s=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),s.setValue(r.id,{[n]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const n=t.getValue(e,{value:this.data.fieldValue});let s=n.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&s.length>r&&(s=s.slice(0,r));let a=n.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const l={userValue:s,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??s,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",a??s),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),se.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Fe,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",c=>{t.setValue(e,{value:c.target.value}),this.setPropertyOnSiblings(i,"value",c.target.value,"value"),l.formattedValue=null}),i.addEventListener("resetform",c=>{i.value=l.userValue=this.data.defaultFieldValue??"",l.formattedValue=null});let h=c=>{const{formattedValue:d}=l;null!=d&&(c.target.value=d),c.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",d=>{if(l.focused)return;const{target:u}=d;l.userValue&&(u.value=l.userValue),l.lastCommittedValue=u.value,l.commitKey=1,this.data.actions?.Focus||(l.focused=!0)}),i.addEventListener("updatefromsandbox",d=>{this.showElementAndHideCanvas(d.target),this._dispatchEventFromSandbox({value(f){l.userValue=f.detail.value??"",t.setValue(e,{value:l.userValue.toString()}),f.target.value=l.userValue},formattedValue(f){const{formattedValue:p}=f.detail;l.formattedValue=p,null!=p&&f.target!==document.activeElement&&(f.target.value=p),t.setValue(e,{formattedValue:p})},selRange(f){f.target.setSelectionRange(...f.detail.selRange)},charLimit:f=>{const{charLimit:p}=f.detail,{target:g}=f;if(0===p)return void g.removeAttribute("maxLength");g.setAttribute("maxLength",p);let _=l.userValue;!_||_.length<=p||(_=_.slice(0,p),g.value=l.userValue=_,t.setValue(e,{value:_}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:1,selStart:g.selectionStart,selEnd:g.selectionEnd}}))}},d)}),i.addEventListener("keydown",d=>{l.commitKey=1;let u=-1;if("Escape"===d.key?u=0:"Enter"!==d.key||this.data.multiLine?"Tab"===d.key&&(l.commitKey=3):u=2,-1===u)return;const{value:f}=d.target;l.lastCommittedValue!==f&&(l.lastCommittedValue=f,l.userValue=f,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:f,willCommit:!0,commitKey:u,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}))});const c=h;h=null,i.addEventListener("blur",d=>{if(!l.focused||!d.relatedTarget)return;this.data.actions?.Blur||(l.focused=!1);const{value:u}=d.target;l.userValue=u,l.lastCommittedValue!==u&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:u,willCommit:!0,commitKey:l.commitKey,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}),c(d)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",d=>{l.lastCommittedValue=null;const{data:u,target:f}=d,{value:p,selectionStart:g,selectionEnd:_}=f;let m=g,A=_;switch(d.inputType){case"deleteWordBackward":{const v=p.substring(0,g).match(/\w*[^\w]*$/);v&&(m-=v[0].length);break}case"deleteWordForward":{const v=p.substring(g).match(/^[^\w]*\w*/);v&&(A+=v[0].length);break}case"deleteContentBackward":g===_&&(m-=1);break;case"deleteContentForward":g===_&&(A+=1)}d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:p,change:u||"",willCommit:!1,selStart:m,selEnd:A}})}),this._setEventListeners(i,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],d=>d.target.value)}if(h&&i.addEventListener("blur",h),this.data.comb){const d=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${d}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 Ro extends re{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Io extends re{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof n&&(n="Off"!==n,t.setValue(i,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const s=document.createElement("input");return se.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="checkbox",s.name=e.fieldName,n&&s.setAttribute("checked",!0),s.setAttribute("exportValue",e.exportValue),s.tabIndex=Fe,s.addEventListener("change",r=>{const{name:a,checked:l}=r.target;for(const h of this._getElementsByName(a,i)){const c=l&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(i,{value:l})}),s.addEventListener("resetform",r=>{r.target.checked=(e.defaultFieldValue||"Off")===e.exportValue}),this.enableScripting&&this.hasJSActions&&(s.addEventListener("updatefromsandbox",r=>{this._dispatchEventFromSandbox({value(l){l.target.checked="Off"!==l.detail.value,t.setValue(i,{value:l.target.checked})}},r)}),this._setEventListeners(s,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(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class bs extends re{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof n&&(n=n!==e.buttonValue,t.setValue(i,{value:n})),n)for(const r of this._getElementsByName(e.fieldName,i))t.setValue(r.id,{value:!1});const s=document.createElement("input");if(se.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="radio",s.name=e.fieldName,n&&s.setAttribute("checked",!0),s.tabIndex=Fe,s.addEventListener("change",r=>{const{name:a,checked:l}=r.target;for(const h of this._getElementsByName(a,i))t.setValue(h.id,{value:!1});t.setValue(i,{value:l})}),s.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=null!=a&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;s.addEventListener("updatefromsandbox",a=>{this._dispatchEventFromSandbox({value:h=>{const c=r===h.detail.value;for(const d of this._getElementsByName(h.target.name)){const u=c&&d.id===i;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}},a)}),this._setEventListeners(s,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class ko extends ms{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({},i)})),t}}class Do extends re{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");se.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=Fe;let s=this.data.combo&&this.data.options.length>0;this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue;for(const u of n.options)u.selected=u.value===d});for(const c of this.data.options){const d=document.createElement("option");d.textContent=c.displayValue,d.value=c.exportValue,i.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),s=!1),n.append(d)}let r=null;if(s){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),n.prepend(c),r=()=>{c.remove(),n.removeEventListener("input",r),r=null},n.addEventListener("input",r)}const a=c=>{const d=c?"value":"textContent",{options:u,multiple:f}=n;return f?Array.prototype.filter.call(u,p=>p.selected).map(p=>p[d]):-1===u.selectedIndex?null:u[u.selectedIndex][d]};let l=a(!1);const h=c=>Array.prototype.map.call(c.target.options,u=>({displayValue:u.textContent,exportValue:u.value}));return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",c=>{this._dispatchEventFromSandbox({value(u){r?.();const f=u.detail.value,p=new Set(Array.isArray(f)?f:[f]);for(const g of n.options)g.selected=p.has(g.value);t.setValue(e,{value:a(!0)}),l=a(!1)},multipleSelection(u){n.multiple=!0},remove(u){const f=n.options,p=u.detail.remove;f[p].selected=!1,n.remove(p),f.length>0&&-1===Array.prototype.findIndex.call(f,_=>_.selected)&&(f[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),l=a(!1)},clear(u){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]}),l=a(!1)},insert(u){const{index:f,displayValue:p,exportValue:g}=u.detail.insert,_=n.children[f],m=document.createElement("option");m.textContent=p,m.value=g,_?_.before(m):n.append(m),t.setValue(e,{value:a(!0),items:h(u)}),l=a(!1)},items(u){const{items:f}=u.detail;for(;0!==n.length;)n.remove(0);for(const p of f){const{displayValue:g,exportValue:_}=p,m=document.createElement("option");m.textContent=g,m.value=_,n.append(m)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),l=a(!1)},indices(u){const f=new Set(u.detail.indices);for(const p of u.target.options)p.selected=f.has(p.index);t.setValue(e,{value:a(!0)}),l=a(!1)},editable(u){u.target.disabled=!u.detail.editable}},c)}),n.addEventListener("input",c=>{const d=a(!0),u=a(!1);t.setValue(e,{value:d}),c.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):n.addEventListener("input",function(c){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class qi extends et{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:et._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Oo({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 i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(i=>`${Ri}${i}`).join(",")),this.container}}class Oo{#t=this.#S.bind(this);#e=this.#P.bind(this);#i=this.#T.bind(this);#n=this.#E.bind(this);#r=null;#s=null;#a=null;#l=null;#c=null;#h=null;#u=null;#d=!1;#f=null;#o=null;#p=null;#m=null;#g=null;#b=null;#_=!1;constructor({container:t,color:e,elements:i,titleObj:n,modificationDate:s,contentsObj:r,richText:a,parent:l,rect:h,parentRect:c,open:d}){this.#s=t,this.#g=n,this.#a=r,this.#m=a,this.#h=l,this.#r=e,this.#p=h,this.#u=c,this.#c=i,this.#l=kn.toDateObject(s),this.trigger=i.flatMap(u=>u.getElementsToTriggerPopup());for(const u of this.trigger)u.addEventListener("click",this.#n),u.addEventListener("mouseenter",this.#i),u.addEventListener("mouseleave",this.#e),u.classList.add("popupTriggerArea");for(const u of i)u.container?.addEventListener("keydown",this.#t);this.#s.hidden=!0,d&&this.#E()}render(){if(this.#f)return;const t=this.#f=document.createElement("div");if(t.className="popup",this.#r){const s=t.style.outlineColor=N.makeHexColor(...this.#r);t.style.backgroundColor=CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?`color-mix(in srgb, ${s} 30%, white)`:N.makeHexColor(...this.#r.map(a=>Math.floor(.7*(255-a)+a)))}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#g),t.append(e),this.#l){const s=document.createElement("span");s.classList.add("popupDate"),s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#l.valueOf()})),e.append(s)}const n=this.#v;if(n)gs.render({xfaHtml:n,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const s=this._formatContents(this.#a);t.append(s)}this.#s.append(t)}get#v(){const t=this.#m,e=this.#a;return t?.str&&(!e?.str||e.str===t.str)&&this.#m.html||null}get#A(){return this.#v?.attributes?.style?.fontSize||0}get#y(){return this.#v?.attributes?.style?.color||null}#x(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:this.#y,fontSize:this.#A?`calc(${this.#A}px * var(--scale-factor))`:""}};for(const s of t.split("\n"))e.push({name:"span",value:s,attributes:n});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const n=t.split(/(?:\r\n?|\n)/);for(let s=0,r=n.length;s<r;++s)i.append(document.createTextNode(n[s])),s<r-1&&i.append(document.createElement("br"));return i}#S(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#d)&&this.#E()}updateEdited({rect:t,popupContent:e}){this.#b||={contentsObj:this.#a,richText:this.#m},t&&(this.#o=null),e&&(this.#m=this.#x(e),this.#a=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#b&&(({contentsObj:this.#a,richText:this.#m}=this.#b),this.#b=null,this.#f?.remove(),this.#f=null,this.#o=null)}#M(){if(null!==this.#o)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:n,pageY:s}}}=this.#h;let r=!!this.#u,a=r?this.#u:this.#p;for(const p of this.#c)if(!a||null!==N.intersect(p.data.rect,a)){a=p.data.rect,r=!0;break}const l=N.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]);this.#o=[100*(l[0]+(r?a[2]-a[0]+5:0)-n)/e,100*(l[1]-s)/i];const{style:f}=this.#s;f.left=`${this.#o[0]}%`,f.top=`${this.#o[1]}%`}#E(){this.#d=!this.#d,this.#d?(this.#T(),this.#s.addEventListener("click",this.#n),this.#s.addEventListener("keydown",this.#t)):(this.#P(),this.#s.removeEventListener("click",this.#n),this.#s.removeEventListener("keydown",this.#t))}#T(){this.#f||this.render(),this.isVisible?this.#d&&this.#s.classList.add("focused"):(this.#M(),this.#s.hidden=!1,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)+1e3)}#P(){this.#s.classList.remove("focused"),!this.#d&&this.isVisible&&(this.#s.hidden=!0,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)-1e3)}forceHide(){this.#_=this.isVisible,this.#_&&(this.#s.hidden=!0)}maybeShow(){this.#_&&(this.#f||this.#T(),this.#_=!1,this.#s.hidden=!1)}get isVisible(){return!1===this.#s.hidden}}class _s extends et{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=U.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class No extends et{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=Jt(t.rect),n=this.svgFactory.create(e,i,!0),s=this.#t=this.svgFactory.createElement("svg:line");return s.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),s.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),s.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),s.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),s.setAttribute("stroke-width",t.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),n.append(s),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Fo extends et{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=Jt(t.rect),n=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",s/2),r.setAttribute("y",s/2),r.setAttribute("width",e-s),r.setAttribute("height",i-s),r.setAttribute("stroke-width",s||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),n.append(r),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Bo extends et{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=Jt(t.rect),n=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-s/2),r.setAttribute("ry",i/2-s/2),r.setAttribute("stroke-width",s||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),n.append(r),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class vs extends et{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:n}}=this;if(!e)return this.container;const{width:s,height:r}=Jt(t),a=this.svgFactory.create(s,r,!0);let l=[];for(let c=0,d=e.length;c<d;c+=2)l.push(`${e[c]-t[0]},${t[3]-e[c+1]}`);l=l.join(" ");const h=this.#t=this.svgFactory.createElement(this.svgElementName);return h.setAttribute("points",l),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),a.append(h),this.container.append(a),!n&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Vo extends vs{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class jo extends et{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Ki extends et{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?U.HIGHLIGHT:U.INK}#i(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:n,popupRef:s}}=this,{transform:r,width:a,height:l}=this.#i(e,t),h=this.svgFactory.create(a,l,!0),c=this.#t=this.svgFactory.createElement("svg:g");h.append(c),c.setAttribute("stroke-width",n.width||1),c.setAttribute("stroke-linecap","round"),c.setAttribute("stroke-linejoin","round"),c.setAttribute("stroke-miterlimit",10),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),c.setAttribute("transform",r);for(let d=0,u=i.length;d<u;d++){const f=this.svgFactory.createElement(this.svgElementName);this.#e.push(f),f.setAttribute("points",i[d].join(",")),c.append(f)}return!s&&this.hasPopupData&&this._createPopup(),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:n}=t,s=this.#t;if(e>=0&&s.setAttribute("stroke-width",e||1),i)for(let r=0,a=this.#e.length;r<a;r++)this.#e[r].setAttribute("points",i[r].join(","));if(n){const{transform:r,width:a,height:l}=this.#i(this.data.rotation,n);s.parentElement.setAttribute("viewBox",`0 0 ${a} ${l}`),s.setAttribute("transform",r)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class As extends et{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=U.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Ho extends et{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class zo extends et{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Uo extends et{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class ws extends et{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=U.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Wo extends et{#t=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#e.bind(this)),this.#t=i;const{isMac:n}=_t.platform;return t.addEventListener("keydown",s=>{"Enter"===s.key&&(n?s.metaKey:s.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class Go{#t=null;#e=null;#i=new Map;#n=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:n,page:s,viewport:r,structTreeLayer:a}){this.div=t,this.#t=e,this.#e=i,this.#n=a||null,this.page=s,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=n}hasEditableAnnotations(){return this.#i.size>0}#r(t,e){var i=this;return(0,x.A)(function*(){const n=t.firstChild||t,s=n.id=`${Ri}${e}`,r=yield i.#n?.getAriaAttributes(s);if(r)for(const[a,l]of r)n.setAttribute(a,l);i.div.append(t),i.#t?.moveElementInDOM(i.div,t,n,!1)})()}render(t){var e=this;return(0,x.A)(function*(){const{annotations:i}=t,n=e.div;ne(n,e.viewport);const s=new Map,r={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Yi,annotationStorage:t.annotationStorage||new ji,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:e,elements:null};for(const a of i){if(a.noHTML)continue;const l=16===a.annotationType;if(l){const d=s.get(a.id);if(!d)continue;r.elements=d}else{const{width:d,height:u}=Jt(a.rect);if(d<=0||u<=0)continue}r.data=a;const h=To.create(r);if(!h.isRenderable)continue;if(!l&&a.popupRef){const d=s.get(a.popupRef);d?d.push(h):s.set(a.popupRef,[h])}const c=h.render();a.hidden&&(c.style.visibility="hidden"),yield e.#r(c,a.id),h._isEditable&&(e.#i.set(h.data.id,h),e._annotationEditorUIManager?.renderAnnotationElement(h))}e.#s()})()}update({viewport:t}){const e=this.div;this.viewport=t,ne(e,{rotation:t.rotation}),this.#s(),e.hidden=!1}#s(){if(!this.#e)return;const t=this.div;for(const[e,i]of this.#e){const n=t.querySelector(`[data-annotation-id="${e}"]`);if(!n)continue;i.className="annotationContent";const{firstChild:s}=n;s?"CANVAS"===s.nodeName?s.replaceWith(i):s.classList.contains("annotationContent")?s.after(i):s.before(i):n.append(i)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#i.values())}getEditableAnnotation(t){return this.#i.get(t)}}const di=/\r\n?|\n/g;class lt extends F{#t;#e="";#i=`${this.id}-editor`;#n=null;#r;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=lt.prototype,e=s=>s.isEmpty(),i=Le.TRANSLATE_SMALL,n=Le.TRANSLATE_BIG;return W(this,"_keyboardManager",new Me([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}]]))}static _type="freetext";static _editorType=U.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#t=t.color||lt._defaultColor||F._defaultLineColor,this.#r=t.fontSize||lt._defaultFontSize}static initialize(t,e){F.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case G.FREETEXT_SIZE:lt._defaultFontSize=e;break;case G.FREETEXT_COLOR:lt._defaultColor=e}}updateParams(t,e){switch(t){case G.FREETEXT_SIZE:this.#s(e);break;case G.FREETEXT_COLOR:this.#a(e)}}static get defaultPropertiesToUpdate(){return[[G.FREETEXT_SIZE,lt._defaultFontSize],[G.FREETEXT_COLOR,lt._defaultColor||F._defaultLineColor]]}get propertiesToUpdate(){return[[G.FREETEXT_SIZE,this.#r],[G.FREETEXT_COLOR,this.#t]]}#s(t){const e=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-this.#r)*this.parentScale),this.#r=n,this.#c()},i=this.#r;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#a(t){const e=n=>{this.#t=this.editorDiv.style.color=n},i=this.#t;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-lt._internalPadding*t,-(lt._internalPadding+this.#r)*t]}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(U.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#n=new AbortController;const t=this._uiManager.combinedSignal(this.#n);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#i),this._isDraggable=!0,this.#n?.abort(),this.#n=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#l(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(lt.#h(i)),e=i);return t.join("\n")}#c(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:n,div:s}=this,r=s.style.display,a=s.classList.contains("hidden");s.classList.remove("hidden"),s.style.display="hidden",n.div.append(this.div),i=s.getBoundingClientRect(),s.remove(),s.style.display=r,s.classList.toggle("hidden",a)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#e,e=this.#e=this.#l().trimEnd();if(t===e)return;const i=n=>{this.#e=n,n?(this.#u(),this._uiManager.rebuild(this),this.#c()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#c()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){lt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#i),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#r}px * var(--scale-factor))`,i.color=this.#t,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),si(this,this.div,["dblclick","keydown"]),this.width){const[n,s]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this._initialData;let[a,l]=this.getInitialTranslation();[a,l]=this.pageTranslationToScreen(a,l);const[h,c]=this.pageDimensions,[d,u]=this.pageTranslation;let f,p;switch(this.rotation){case 0:f=t+(r[0]-d)/h,p=e+this.height-(r[1]-u)/c;break;case 90:f=t+(r[0]-d)/h,p=e-(r[1]-u)/c,[a,l]=[l,-a];break;case 180:f=t-this.width+(r[0]-d)/h,p=e-(r[1]-u)/c,[a,l]=[-a,-l];break;case 270:f=t+(r[0]-d-this.height*c)/h,p=e+(r[1]-u-this.width*h)/c,[a,l]=[-l,a]}this.setAt(f*n,p*s,a,l)}else this.setAt(t*n,e*s,this.width*n,this.height*s);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#h(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(di,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const n=lt.#f(e.getData("text")||"").replaceAll(di,"\n");if(!n)return;const s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize(),s.deleteFromDocument();const r=s.getRangeAt(0);if(!n.includes("\n"))return r.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),void s.collapseToStart();const{startContainer:a,startOffset:l}=r,h=[],c=[];if(a.nodeType===Node.TEXT_NODE){const f=a.parentElement;if(c.push(a.nodeValue.slice(l).replaceAll(di,"")),f!==this.editorDiv){let p=h;for(const g of this.editorDiv.childNodes)g!==f?p.push(lt.#h(g)):p=c}h.push(a.nodeValue.slice(0,l).replaceAll(di,""))}else if(a===this.editorDiv){let f=h,p=0;for(const g of this.editorDiv.childNodes)p++===l&&(f=c),f.push(lt.#h(g))}this.#e=`${h.join("\n")}${n}${c.join("\n")}`,this.#u();const d=new Range;let u=h.reduce((f,p)=>f+p.length,0);for(const{firstChild:f}of this.editorDiv.childNodes)if(f.nodeType===Node.TEXT_NODE){const p=f.nodeValue.length;if(u<=p){d.setStart(f,u),d.setEnd(f,u);break}u-=p}s.removeAllRanges(),s.addRange(d)}#u(){if(this.editorDiv.replaceChildren(),this.#e)for(const t of this.#e.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#d(){return this.#e.replaceAll("\xa0"," ")}static#f(t){return t.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}static deserialize(t,e,i){var n=()=>super.deserialize,s=this;return(0,x.A)(function*(){let r=null;if(t instanceof _s){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:c,rotation:d,id:u,popupRef:f},textContent:p,textPosition:g,parent:{page:{pageNumber:_}}}=t;if(!p||0===p.length)return null;r=t={annotationType:U.FREETEXT,color:Array.from(h),fontSize:l,value:p.join("\n"),position:g,pageIndex:_-1,rect:c.slice(0),rotation:d,id:u,deleted:!1,popupRef:f}}const a=yield n().call(s,t,e,i);return a.#r=t.fontSize,a.#t=N.makeHexColor(...t.color),a.#e=lt.#f(t.value),a.annotationElementId=t.id||null,a._initialData=r,a})()}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=lt._internalPadding*this.parentScale,i=this.getRect(e,e),n=F._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#t),s={annotationType:U.FREETEXT,color:n,fontSize:this.#r,value:this.#d(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?s:this.annotationElementId&&!this.#o(s)?null:(s.id=this.annotationElementId,s)}#o(t){const{value:e,fontSize:i,color:n,pageIndex:s}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((r,a)=>r!==n[a])||t.pageIndex!==s}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#r}px * var(--scale-factor))`,i.color=this.#t,e.replaceChildren();for(const s of this.#e.split("\n")){const r=document.createElement("div");r.append(s?document.createTextNode(s):document.createElement("br")),e.append(r)}const n=lt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(n,n),popupContent:this.#e}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}let k=(()=>class o{static PRECISION=1e-4;toSVGPath(){Y("Abstract method `toSVGPath` must be implemented.")}get box(){Y("Abstract getter `box` must be implemented.")}serialize(e,i){Y("Abstract method `serialize` must be implemented.")}static _rescale(e,i,n,s,r,a){a||=new Float32Array(e.length);for(let l=0,h=e.length;l<h;l+=2)a[l]=i+e[l]*s,a[l+1]=n+e[l+1]*r;return a}static _rescaleAndSwap(e,i,n,s,r,a){a||=new Float32Array(e.length);for(let l=0,h=e.length;l<h;l+=2)a[l]=i+e[l+1]*s,a[l+1]=n+e[l]*r;return a}static _translate(e,i,n,s){s||=new Float32Array(e.length);for(let r=0,a=e.length;r<a;r+=2)s[r]=i+e[r],s[r+1]=n+e[r+1];return s}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,i,n,s,r){switch(r){case 90:return[1-i/n,e/s];case 180:return[1-e/n,1-i/s];case 270:return[i/n,1-e/s];default:return[e/n,i/s]}}static _normalizePagePoint(e,i,n){switch(n){case 90:return[1-i,e];case 180:return[1-e,1-i];case 270:return[i,1-e];default:return[e,i]}}static createBezierPoints(e,i,n,s,r,a){return[(e+5*n)/6,(i+5*s)/6,(5*n+r)/6,(5*s+a)/6,(n+r)/2,(s+a)/2]}})();class ae{#t;#e=[];#i;#n;#r=[];#s=new Float32Array(18);#a;#l;#c;#h;#u;#d;#f=[];static#o=8;static#p=2;static#m=ae.#o+ae.#p;constructor({x:t,y:e},i,n,s,r,a=0){this.#t=i,this.#d=s*n,this.#n=r,this.#s.set([NaN,NaN,NaN,NaN,t,e],6),this.#i=a,this.#h=ae.#o*n,this.#c=ae.#m*n,this.#u=n,this.#f.push(t,e)}isEmpty(){return isNaN(this.#s[8])}#g(){const t=this.#s.subarray(4,6),e=this.#s.subarray(16,18),[i,n,s,r]=this.#t;return[(this.#a+(t[0]-e[0])/2-i)/s,(this.#l+(t[1]-e[1])/2-n)/r,(this.#a+(e[0]-t[0])/2-i)/s,(this.#l+(e[1]-t[1])/2-n)/r]}add({x:t,y:e}){this.#a=t,this.#l=e;const[i,n,s,r]=this.#t;let[a,l,h,c]=this.#s.subarray(8,12);const d=t-h,u=e-c,f=Math.hypot(d,u);if(f<this.#c)return!1;const p=f-this.#h,g=p/f,_=g*d,m=g*u;let A=a,v=l;a=h,l=c,h+=_,c+=m,this.#f?.push(t,e);const C=-m/p*this.#d,M=_/p*this.#d;return this.#s.set(this.#s.subarray(2,8),0),this.#s.set([h+C,c+M],4),this.#s.set(this.#s.subarray(14,18),12),this.#s.set([h-C,c-M],16),isNaN(this.#s[6])?(0===this.#r.length&&(this.#s.set([a+C,l+M],2),this.#r.push(NaN,NaN,NaN,NaN,(a+C-i)/s,(l+M-n)/r),this.#s.set([a-C,l-M],14),this.#e.push(NaN,NaN,NaN,NaN,(a-C-i)/s,(l-M-n)/r)),this.#s.set([A,v,a,l,h,c],6),!this.isEmpty()):(this.#s.set([A,v,a,l,h,c],6),Math.abs(Math.atan2(v-l,A-a)-Math.atan2(m,_))<Math.PI/2?([a,l,h,c]=this.#s.subarray(2,6),this.#r.push(NaN,NaN,NaN,NaN,((a+h)/2-i)/s,((l+c)/2-n)/r),[a,l,A,v]=this.#s.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((A+a)/2-i)/s,((v+l)/2-n)/r),!0):([A,v,a,l,h,c]=this.#s.subarray(0,6),this.#r.push(((A+5*a)/6-i)/s,((v+5*l)/6-n)/r,((5*a+h)/6-i)/s,((5*l+c)/6-n)/r,((a+h)/2-i)/s,((l+c)/2-n)/r),[h,c,a,l,A,v]=this.#s.subarray(12,18),this.#e.push(((A+5*a)/6-i)/s,((v+5*l)/6-n)/r,((5*a+h)/6-i)/s,((5*l+c)/6-n)/r,((a+h)/2-i)/s,((l+c)/2-n)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#r,e=this.#e;if(isNaN(this.#s[6])&&!this.isEmpty())return this.#b();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let n=6;n<t.length;n+=6)isNaN(t[n])?i.push(`L${t[n+4]} ${t[n+5]}`):i.push(`C${t[n]} ${t[n+1]} ${t[n+2]} ${t[n+3]} ${t[n+4]} ${t[n+5]}`);this.#v(i);for(let n=e.length-6;n>=6;n-=6)isNaN(e[n])?i.push(`L${e[n+4]} ${e[n+5]}`):i.push(`C${e[n]} ${e[n+1]} ${e[n+2]} ${e[n+3]} ${e[n+4]} ${e[n+5]}`);return this.#_(i),i.join(" ")}#b(){const[t,e,i,n]=this.#t,[s,r,a,l]=this.#g();return`M${(this.#s[2]-t)/i} ${(this.#s[3]-e)/n} L${(this.#s[4]-t)/i} ${(this.#s[5]-e)/n} L${s} ${r} L${a} ${l} L${(this.#s[16]-t)/i} ${(this.#s[17]-e)/n} L${(this.#s[14]-t)/i} ${(this.#s[15]-e)/n} Z`}#_(t){const e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#v(t){const[e,i,n,s]=this.#t,r=this.#s.subarray(4,6),a=this.#s.subarray(16,18),[l,h,c,d]=this.#g();t.push(`L${(r[0]-e)/n} ${(r[1]-i)/s} L${l} ${h} L${c} ${d} L${(a[0]-e)/n} ${(a[1]-i)/s}`)}newFreeDrawOutline(t,e,i,n,s,r){return new ys(t,e,i,n,s,r)}getOutlines(){const t=this.#r,e=this.#e,i=this.#s,[n,s,r,a]=this.#t,l=new Float32Array((this.#f?.length??0)+2);for(let d=0,u=l.length-2;d<u;d+=2)l[d]=(this.#f[d]-n)/r,l[d+1]=(this.#f[d+1]-s)/a;if(l[l.length-2]=(this.#a-n)/r,l[l.length-1]=(this.#l-s)/a,isNaN(i[6])&&!this.isEmpty())return this.#A(l);const h=new Float32Array(this.#r.length+24+this.#e.length);let c=t.length;for(let d=0;d<c;d+=2)isNaN(t[d])?h[d]=h[d+1]=NaN:(h[d]=t[d],h[d+1]=t[d+1]);c=this.#x(h,c);for(let d=e.length-6;d>=6;d-=6)for(let u=0;u<6;u+=2)isNaN(e[d+u])?(h[c]=h[c+1]=NaN,c+=2):(h[c]=e[d+u],h[c+1]=e[d+u+1],c+=2);return this.#y(h,c),this.newFreeDrawOutline(h,l,this.#t,this.#u,this.#i,this.#n)}#A(t){const e=this.#s,[i,n,s,r]=this.#t,[a,l,h,c]=this.#g(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/s,(e[3]-n)/r,NaN,NaN,NaN,NaN,(e[4]-i)/s,(e[5]-n)/r,NaN,NaN,NaN,NaN,a,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-i)/s,(e[17]-n)/r,NaN,NaN,NaN,NaN,(e[14]-i)/s,(e[15]-n)/r],0),this.newFreeDrawOutline(d,t,this.#t,this.#u,this.#i,this.#n)}#y(t,e){const i=this.#e;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#x(t,e){const i=this.#s.subarray(4,6),n=this.#s.subarray(16,18),[s,r,a,l]=this.#t,[h,c,d,u]=this.#g();return t.set([NaN,NaN,NaN,NaN,(i[0]-s)/a,(i[1]-r)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(n[0]-s)/a,(n[1]-r)/l],e),e+24}}class ys extends k{#t;#e=new Float32Array(4);#i;#n;#r;#s;#a;constructor(t,e,i,n,s,r){super(),this.#a=t,this.#r=e,this.#t=i,this.#s=n,this.#i=s,this.#n=r,this.lastPoint=[NaN,NaN],this.#l(r);const[a,l,h,c]=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/h,t[d+1]=(t[d+1]-l)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/h,e[d+1]=(e[d+1]-l)/c}toSVGPath(){const t=[`M${this.#a[4]} ${this.#a[5]}`];for(let e=6,i=this.#a.length;e<i;e+=6)isNaN(this.#a[e])?t.push(`L${this.#a[e+4]} ${this.#a[e+5]}`):t.push(`C${this.#a[e]} ${this.#a[e+1]} ${this.#a[e+2]} ${this.#a[e+3]} ${this.#a[e+4]} ${this.#a[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,n],s){const r=i-t,a=n-e;let l,h;switch(s){case 0:l=k._rescale(this.#a,t,n,r,-a),h=k._rescale(this.#r,t,n,r,-a);break;case 90:l=k._rescaleAndSwap(this.#a,t,e,r,a),h=k._rescaleAndSwap(this.#r,t,e,r,a);break;case 180:l=k._rescale(this.#a,i,e,-r,a),h=k._rescale(this.#r,i,e,-r,a);break;case 270:l=k._rescaleAndSwap(this.#a,i,n,-r,-a),h=k._rescaleAndSwap(this.#r,i,n,-r,-a)}return{outline:Array.from(l),points:[Array.from(h)]}}#l(t){const e=this.#a;let i=e[4],n=e[5],s=i,r=n,a=i,l=n,h=i,c=n;const d=t?Math.max:Math.min;for(let f=6,p=e.length;f<p;f+=6){if(isNaN(e[f]))s=Math.min(s,e[f+4]),r=Math.min(r,e[f+5]),a=Math.max(a,e[f+4]),l=Math.max(l,e[f+5]),c<e[f+5]?(h=e[f+4],c=e[f+5]):c===e[f+5]&&(h=d(h,e[f+4]));else{const g=N.bezierBoundingBox(i,n,...e.slice(f,f+6));s=Math.min(s,g[0]),r=Math.min(r,g[1]),a=Math.max(a,g[2]),l=Math.max(l,g[3]),c<g[3]?(h=g[2],c=g[3]):c===g[3]&&(h=d(h,g[2]))}i=e[f+4],n=e[f+5]}const u=this.#e;u[0]=s-this.#i,u[1]=r-this.#i,u[2]=a-s+2*this.#i,u[3]=l-r+2*this.#i,this.lastPoint=[h,c]}get box(){return this.#e}newOutliner(t,e,i,n,s,r=0){return new ae(t,e,i,n,s,r)}getNewOutline(t,e){const[i,n,s,r]=this.#e,[a,l,h,c]=this.#t,d=s*h,u=r*c,f=i*h+a,p=n*c+l,g=this.newOutliner({x:this.#r[0]*d+f,y:this.#r[1]*u+p},this.#t,this.#s,t,this.#n,e??this.#i);for(let _=2;_<this.#r.length;_+=2)g.add({x:this.#r[_]*d+f,y:this.#r[_+1]*u+p});return g.getOutlines()}}class Qi{#t;#e;#i=[];#n=[];constructor(t,e=0,i=0,n=!0){let s=1/0,r=-1/0,a=1/0,l=-1/0;const c=1e-4;for(const{x:m,y:A,width:v,height:w}of t){const E=Math.floor((m-e)/c)*c,C=Math.ceil((m+v+e)/c)*c,M=Math.floor((A-e)/c)*c,L=Math.ceil((A+w+e)/c)*c;this.#i.push([E,M,L,!0],[C,M,L,!1]),s=Math.min(s,E),r=Math.max(r,C),a=Math.min(a,M),l=Math.max(l,L)}const d=r-s+2*i,u=l-a+2*i,f=s-i,p=a-i,g=this.#i.at(n?-1:-2),_=[g[0],g[2]];for(const m of this.#i){const[A,v,w]=m;m[0]=(A-f)/d,m[1]=(v-p)/u,m[2]=(w-p)/u}this.#t=new Float32Array([f,p,d,u]),this.#e=_}getOutlines(){this.#i.sort((e,i)=>e[0]-i[0]||e[1]-i[1]||e[2]-i[2]);const t=[];for(const e of this.#i)e[3]?(t.push(...this.#c(e)),this.#a(e)):(this.#l(e),t.push(...this.#c(e)));return this.#r(t)}#r(t){const e=[],i=new Set;for(const r of t){const[a,l,h]=r;e.push([a,l,r],[a,h,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const l=e[r][2],h=e[r+1][2];l.push(h),h.push(l),i.add(l),i.add(h)}const n=[];let s;for(;i.size>0;){const r=i.values().next().value;let[a,l,h,c,d]=r;i.delete(r);let u=a,f=l;for(s=[a,h],n.push(s);;){let p;if(i.has(c))p=c;else{if(!i.has(d))break;p=d}i.delete(p),[a,l,h,c,d]=p,u!==a&&(s.push(u,f,a,f===l?l:h),u=a),f=f===l?h:l}s.push(u,f)}return new $o(n,this.#t,this.#e)}#s(t){const e=this.#n;let i=0,n=e.length-1;for(;i<=n;){const s=i+n>>1,r=e[s][0];if(r===t)return s;r<t?i=s+1:n=s-1}return n+1}#a([,t,e]){const i=this.#s(t);this.#n.splice(i,0,[t,e])}#l([,t,e]){const i=this.#s(t);for(let n=i;n<this.#n.length;n++){const[s,r]=this.#n[n];if(s!==t)break;if(s===t&&r===e)return void this.#n.splice(n,1)}for(let n=i-1;n>=0;n--){const[s,r]=this.#n[n];if(s!==t)break;if(s===t&&r===e)return void this.#n.splice(n,1)}}#c(t){const[e,i,n]=t,s=[[e,i,n]],r=this.#s(n);for(let a=0;a<r;a++){const[l,h]=this.#n[a];for(let c=0,d=s.length;c<d;c++){const[,u,f]=s[c];if(!(h<=u||f<=l)){if(u>=l){if(f>h)s[c][1]=h;else{if(1===d)return[];s.splice(c,1),c--,d--}continue}s[c][2]=l,f>h&&s.push([e,h,f])}}}return s}}class $o extends k{#t;#e;constructor(t,e,i){super(),this.#e=t,this.#t=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#e){let[i,n]=e;t.push(`M${i} ${n}`);for(let s=2;s<e.length;s+=2){const r=e[s],a=e[s+1];r===i?(t.push(`V${a}`),n=a):a===n&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,n],s){const r=[],a=i-t,l=n-e;for(const h of this.#e){const c=new Array(h.length);for(let d=0;d<h.length;d+=2)c[d]=t+h[d]*a,c[d+1]=n-h[d+1]*l;r.push(c)}return r}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}}class Zi extends ae{newFreeDrawOutline(t,e,i,n,s,r){return new Xo(t,e,i,n,s,r)}}class Xo extends ys{newOutliner(t,e,i,n,s,r=0){return new Zi(t,e,i,n,s,r)}}class Mt{#t=null;#e=null;#i;#n=null;#r=!1;#s=!1;#a=null;#l;#c=null;#h=null;#u;static#d=null;static get _keyboardManager(){return W(this,"_keyboardManager",new Me([[["Escape","mac+Escape"],Mt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Mt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Mt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Mt.prototype._moveToPrevious],[["Home","mac+Home"],Mt.prototype._moveToBeginning],[["End","mac+End"],Mt.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#s=!1,this.#u=G.HIGHLIGHT_COLOR,this.#a=t):(this.#s=!0,this.#u=G.HIGHLIGHT_DEFAULT_COLOR),this.#h=t?._uiManager||e,this.#l=this.#h._eventBus,this.#i=t?.color||this.#h?.highlightColors.values().next().value||"#FFFF98",Mt.#d||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#h._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});const i=this.#e=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#i,t.append(i),t}renderMainDropdown(){const t=this.#n=this.#f();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#f(){const t=document.createElement("div"),e=this.#h._signal;t.addEventListener("contextmenu",Nt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[i,n]of this.#h.highlightColors){const s=document.createElement("button");s.tabIndex="0",s.role="option",s.setAttribute("data-color",n),s.title=i,s.setAttribute("data-l10n-id",Mt.#d[i]);const r=document.createElement("span");s.append(r),r.className="swatch",r.style.backgroundColor=n,s.setAttribute("aria-selected",n===this.#i),s.addEventListener("click",this.#o.bind(this,n),{signal:e}),t.append(s)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#o(t,e){e.stopPropagation(),this.#l.dispatch("switchannotationeditorparams",{source:this,type:this.#u,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#t)return void this.#m(t);const e=t.target.getAttribute("data-color");e&&this.#o(e,t)}_moveToNext(t){this.#b?t.target!==this.#t?t.target.nextSibling?.focus():this.#n.firstChild?.focus():this.#m(t)}_moveToPrevious(t){t.target!==this.#n?.firstChild&&t.target!==this.#t?(this.#b||this.#m(t),t.target.previousSibling?.focus()):this.#b&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#b?this.#n.firstChild?.focus():this.#m(t)}_moveToEnd(t){this.#b?this.#n.lastChild?.focus():this.#m(t)}#p(t){Mt._keyboardManager.exec(this,t)}#m(t){if(this.#b)return void this.hideDropdown();if(this.#r=0===t.detail,this.#c||(this.#c=new AbortController,window.addEventListener("pointerdown",this.#g.bind(this),{signal:this.#h.combinedSignal(this.#c)})),this.#n)return void this.#n.classList.remove("hidden");const e=this.#n=this.#f();this.#t.append(e)}#g(t){this.#n?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#n?.classList.add("hidden"),this.#c?.abort(),this.#c=null}get#b(){return this.#n&&!this.#n.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#s){if(!this.#b)return void this.#a?.unselect();this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#r})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#n)return;const e=this.#h.highlightColors.values();for(const i of this.#n.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#n?.remove(),this.#n=null}}class it extends F{#t=null;#e=0;#i;#n=null;#r=null;#s=null;#a=null;#l=0;#c=null;#h=null;#u=null;#d=!1;#f=null;#o;#p=null;#m="";#g;#b="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=U.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=it.prototype;return W(this,"_keyboardManager",new Me([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||it._defaultColor,this.#g=t.thickness||it._defaultThickness,this.#o=t.opacity||it._defaultOpacity,this.#i=t.boxes||null,this.#b=t.methodOfCreation||"",this.#m=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#d=!0,this.#v(t),this.#M()):this.#i&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#a=t.focusNode,this.#l=t.focusOffset,this.#_(),this.#M(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#d?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#b}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#_(){const t=new Qi(this.#i,.001);this.#h=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#h.box;const e=new Qi(this.#i,.0025,.001,"ltr"===this._uiManager.direction);this.#s=e.getOutlines();const{lastPoint:i}=this.#s;this.#f=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#v({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#h=t,this.#s=t.getNewOutline(this.#g/2+1.5,.0025),e>=0)this.#u=e,this.#n=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#s.box,path:{d:this.#s.toSVGPath()}},!0);else if(this.parent){const c=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:it.#E(this.#h.box,(c-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:it.#E(this.#s.box,c),path:{d:this.#s.toSVGPath()}})}const[s,r,a,l]=t.box;switch(this.rotation){case 0:this.x=s,this.y=r,this.width=a,this.height=l;break;case 90:{const[c,d]=this.parentDimensions;this.x=r,this.y=1-s,this.width=a*d/c,this.height=l*c/d;break}case 180:this.x=1-s,this.y=1-r,this.width=a,this.height=l;break;case 270:{const[c,d]=this.parentDimensions;this.x=1-r,this.y=s,this.width=a*d/c,this.height=l*c/d;break}}const{lastPoint:h}=this.#s;this.#f=[(h[0]-s)/a,(h[1]-r)/l]}static initialize(t,e){F.initialize(t,e),it._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case G.HIGHLIGHT_DEFAULT_COLOR:it._defaultColor=e;break;case G.HIGHLIGHT_THICKNESS:it._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#f}updateParams(t,e){switch(t){case G.HIGHLIGHT_COLOR:this.#A(e);break;case G.HIGHLIGHT_THICKNESS:this.#y(e)}}static get defaultPropertiesToUpdate(){return[[G.HIGHLIGHT_DEFAULT_COLOR,it._defaultColor],[G.HIGHLIGHT_THICKNESS,it._defaultThickness]]}get propertiesToUpdate(){return[[G.HIGHLIGHT_COLOR,this.color||it._defaultColor],[G.HIGHLIGHT_THICKNESS,this.#g||it._defaultThickness],[G.HIGHLIGHT_FREE,this.#d]]}#A(t){const e=(s,r)=>{this.color=s,this.#o=r,this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:s,"fill-opacity":r}}),this.#r?.updateColor(s)},i=this.color,n=this.#o;this.addCommands({cmd:e.bind(this,t,it._defaultOpacity),undo:e.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#y(t){const e=this.#g,i=n=>{this.#g=n,this.#x(n)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:G.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}addEditToolbar(){var t=()=>super.addEditToolbar,e=this;return(0,x.A)(function*(){const i=yield t().call(e);return i?(e._uiManager.highlightColors&&(e.#r=new Mt({editor:e}),i.addColorPicker(e.#r)),i):null})()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#R())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#R())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#S(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#M(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#S():t&&(this.#M(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#x(t){if(!this.#d)return;this.#v({highlightOutlines:this.#h.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#S(){null===this.#u||!this.parent||(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#p),this.#p=null)}#M(t=this.parent){null===this.#u&&(({id:this.#u,clipPathId:this.#n}=t.drawLayer.draw({bbox:this.#h.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#o},rootClass:{highlight:!0,free:this.#d},path:{d:this.#h.toSVGPath()}},!1,!0)),this.#p=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#s.box,path:{d:this.#s.toSVGPath()}},this.#d),this.#c&&(this.#c.style.clipPath=this.#n))}static#E([t,e,i,n],s){switch(s){case 90:return[1-e-n,t,n,i];case 180:return[1-t-i,1-e-n,i,n];case 270:return[e,1-t-i,n,i]}return[t,e,i,n]}rotate(t){const{drawLayer:e}=this.parent;let i;i=this.#d?it.#E(this.#h.box,t=(t-this.rotation+360)%360):it.#E([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#u,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#p,{bbox:it.#E(this.#s.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#m&&(t.setAttribute("aria-label",this.#m),t.setAttribute("role","mark")),this.#d?t.classList.add("free"):this.div.addEventListener("keydown",this.#T.bind(this),{signal:this._uiManager._signal});const e=this.#c=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#n;const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),si(this,this.#c,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#T(t){it._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#P(!0);break;case 1:case 3:this.#P(!1)}}#P(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#a,this.#l)}select(){super.select(),this.#p&&this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#p&&(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),this.#d||this.#P(!1))}get _mustFixPosition(){return!this.#d}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!t}}))}#R(){return this.#d?this.rotation:0}#I(){if(this.#d)return null;const[t,e]=this.pageDimensions,[i,n]=this.pageTranslation,s=this.#i,r=new Float32Array(8*s.length);let a=0;for(const{x:l,y:h,width:c,height:d}of s){const u=l*t+i,f=(1-h)*e+n;r[a]=r[a+4]=u,r[a+1]=r[a+3]=f,r[a+2]=r[a+6]=u+c*t,r[a+5]=r[a+7]=f-d*e,a+=8}return r}#O(t){return this.#h.serialize(t,this.#R())}static startHighlighting(t,e,{target:i,x:n,y:s}){const{x:r,y:a,width:l,height:h}=i.getBoundingClientRect(),c=new AbortController,d=t.combinedSignal(c),u=f=>{c.abort(),this.#w(t,f)};window.addEventListener("blur",u,{signal:d}),window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("pointerdown",Pt,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Nt,{signal:d}),i.addEventListener("pointermove",this.#C.bind(this,t),{signal:d}),this._freeHighlight=new Zi({x:n,y:s},[r,a,l,h],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#C(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#w(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static deserialize(t,e,i){var n=()=>super.deserialize,s=this;return(0,x.A)(function*(){let r=null;if(t instanceof As){const{data:{quadPoints:_,rect:m,rotation:A,id:v,color:w,opacity:E,popupRef:C},parent:{page:{pageNumber:M}}}=t;r=t={annotationType:U.HIGHLIGHT,color:Array.from(w),opacity:E,quadPoints:_,boxes:null,pageIndex:M-1,rect:m.slice(0),rotation:A,id:v,deleted:!1,popupRef:C}}else if(t instanceof Ki){const{data:{inkLists:_,rect:m,rotation:A,id:v,color:w,borderStyle:{rawWidth:E},popupRef:C},parent:{page:{pageNumber:M}}}=t;r=t={annotationType:U.HIGHLIGHT,color:Array.from(w),thickness:E,inkLists:_,boxes:null,pageIndex:M-1,rect:m.slice(0),rotation:A,id:v,deleted:!1,popupRef:C}}const{color:a,quadPoints:l,inkLists:h,opacity:c}=t,d=yield n().call(s,t,e,i);d.color=N.makeHexColor(...a),d.#o=c||1,h&&(d.#g=t.thickness),d.annotationElementId=t.id||null,d._initialData=r;const[u,f]=d.pageDimensions,[p,g]=d.pageTranslation;if(l){const _=d.#i=[];for(let m=0;m<l.length;m+=8)_.push({x:(l[m]-p)/u,y:1-(l[m+1]-g)/f,width:(l[m+2]-l[m])/u,height:(l[m+1]-l[m+5])/f});d.#_(),d.#M(),d.rotate(d.rotation)}else if(h){d.#d=!0;const _=h[0],m={x:_[0]-p,y:f-(_[1]-g)},A=new Zi(m,[0,0,u,f],1,d.#g/2,!0,.001);for(let E=0,C=_.length;E<C;E+=2)m.x=_[E]-p,m.y=f-(_[E+1]-g),A.add(m);const{id:v,clipPathId:w}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:A.toSVGPath()}},!0,!0);d.#v({highlightOutlines:A.getOutlines(),highlightId:v,clipPathId:w}),d.#M()}return d})()}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=F._colorManager.convert(this.color),n={annotationType:U.HIGHLIGHT,color:i,opacity:this.#o,thickness:this.#g,quadPoints:this.#I(),outlines:this.#O(e),pageIndex:this.pageIndex,rect:e,rotation:this.#R(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#N(n)?null:(n.id=this.annotationElementId,n)}#N(t){const{color:e}=this._initialData;return t.color.some((i,n)=>i!==e[n])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Yo{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){const t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){Y("Not implemented")}}let qo=(()=>{class o extends F{#t=null;#e;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#i=null;static#n=null;static#r=null;static#s=NaN;static#a=null;static#l=null;static#c=NaN;static _INNER_MARGIN=3;constructor(e){super(e),this.#e=e.mustBeCommitted||!1,e.drawOutlines&&(this.#h(e),this.#f())}#h({drawOutlines:e,drawId:i,drawingOptions:n}){this.#t=e,this._drawingOptions||=n,i>=0?(this._drawId=i,this.parent.drawLayer.finalizeDraw(i,e.defaultProperties)):this._drawId=this.#u(e,this.parent),this.#m(e.box)}#u(e,i){const{id:n}=i.drawLayer.draw(o._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(e,i){const n=new Set(Object.keys(e));for(const[s,r]of Object.entries(i))n.has(s)?Object.assign(e[s],r):e[s]=r;return e}static getDefaultDrawingOptions(e){Y("Not implemented")}static get typesMap(){Y("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,i){const n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,i),this._currentParent&&(o.#i.updateProperty(n,i),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,i){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,i)}static get defaultPropertiesToUpdate(){const e=[],i=this._defaultDrawingOptions;for(const[n,s]of this.typesMap)e.push([n,i[s]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:i}=this;for(const[n,s]of this.constructor.typesMap)e.push([n,i[s]]);return e}_updateProperty(e,i,n){const s=this._drawingOptions,r=s[i],a=l=>{s.updateProperty(i,l);const h=this.#t.updateProperty(i,l);h&&this.#m(h),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#p()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#p()),{bbox:this.#g()}))}_onTranslating(e,i){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(e,i)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this.#d(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#f(),this.#m(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let i=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),this.#d()):e&&(this._uiManager.addShouldRescale(this),this.#f(e),i=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),i&&this.select()}#d(){null===this._drawId||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(e=this.parent){if(null===this._drawId||this.parent!==e){if(null!==this._drawId)return void this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);this._drawingOptions.updateAll(),this._drawId=this.#u(this.#t,e)}}#o([e,i,n,s]){const{parentDimensions:[r,a],rotation:l}=this;switch(l){case 90:return[i,1-e,n*(a/r),s*(r/a)];case 180:return[1-e,1-i,n,s];case 270:return[1-i,e,n*(a/r),s*(r/a)];default:return[e,i,n,s]}}#p(){const{x:e,y:i,width:n,height:s,parentDimensions:[r,a],rotation:l}=this;switch(l){case 90:return[1-i,e,n*(r/a),s*(a/r)];case 180:return[1-e,1-i,n,s];case 270:return[i,1-e,n*(r/a),s*(a/r)];default:return[e,i,n,s]}}#m(e){if([this.x,this.y,this.width,this.height]=this.#o(e),this.div){this.fixAndSetPosition();const[i,n]=this.parentDimensions;this.setDims(this.width*i,this.height*n)}this._onResized()}#g(){const{x:e,y:i,width:n,height:s,rotation:r,parentRotation:a,parentDimensions:[l,h]}=this;switch((4*r+a)/90){case 1:return[1-i-s,e,s,n];case 2:return[1-e-n,1-i-s,n,s];case 3:return[i,1-e-n,s,n];case 4:return[e,i-n*(l/h),s*(h/l),n*(l/h)];case 5:return[1-i,e,n*(l/h),s*(h/l)];case 6:return[1-e-s*(h/l),1-i,s*(h/l),n*(l/h)];case 7:return[i-n*(l/h),1-e-s*(h/l),n*(l/h),s*(h/l)];case 8:return[e-n,i-s,n,s];case 9:return[1-i,e-n,s,n];case 10:return[1-e,1-i,n,s];case 11:return[i-s,1-e,s,n];case 12:return[e-s*(h/l),i,s*(h/l),n*(l/h)];case 13:return[1-i-n*(l/h),e-s*(h/l),n*(l/h),s*(h/l)];case 14:return[1-e,1-i-n*(l/h),s*(h/l),n*(l/h)];case 15:return[i,1-e,n*(l/h),s*(h/l)];default:return[e,i,n,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,o._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#m(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const e=super.render();e.classList.add("draw");const i=document.createElement("div");e.append(i),i.setAttribute("aria-hidden","true"),i.className="internal";const[n,s]=this.parentDimensions;return this.setDims(this.width*n,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,i,n,s,r){Y("Not implemented")}static startDrawing(e,i,n,s){const{target:r,offsetX:a,offsetY:l,pointerId:h,pointerType:c}=s;if(o.#a&&o.#a!==c)return;const{viewport:{rotation:d}}=e,{width:u,height:f}=r.getBoundingClientRect(),p=o.#n=new AbortController,g=e.combinedSignal(p);o.#s||=h,o.#a??=c,window.addEventListener("pointerup",_=>{o.#s===_.pointerId?this._endDraw(_):o.#l?.delete(_.pointerId)},{signal:g}),window.addEventListener("pointercancel",_=>{o.#s===_.pointerId?this._currentParent.endDrawingSession():o.#l?.delete(_.pointerId)},{signal:g}),window.addEventListener("pointerdown",_=>{o.#a===_.pointerType&&((o.#l||=new Set).add(_.pointerId),o.#i.isCancellable()&&(o.#i.removeLastElement(),o.#i.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",Nt,{signal:g}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),r.addEventListener("touchmove",_=>{_.timeStamp===o.#c&&Pt(_)},{signal:g}),e.toggleDrawing(),i._editorUndoBar?.hide(),o.#i?e.drawLayer.updateProperties(this._currentDrawId,o.#i.startNew(a,l,u,f,d)):(i.updateUIForDefaultProperties(this),o.#i=this.createDrawerInstance(a,l,u,f,d),o.#r=this.getDefaultDrawingOptions(),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(o.#r.toSVGProperties(),o.#i.defaultSVGProperties),!0,!1)))}static _drawMove(e){if(o.#c=-1,!o.#i)return;const{offsetX:i,offsetY:n,pointerId:s}=e;if(o.#s===s){if(o.#l?.size>=1)return void this._endDraw(e);this._currentParent.drawLayer.updateProperties(this._currentDrawId,o.#i.add(i,n)),o.#c=e.timeStamp,Pt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,o.#i=null,o.#r=null,o.#a=null,o.#c=NaN),o.#n&&(o.#n.abort(),o.#n=null,o.#s=NaN,o.#l=null)}static _endDraw(e){const i=this._currentParent;if(i){if(i.toggleDrawing(!0),this._cleanup(!1),e&&i.drawLayer.updateProperties(this._currentDrawId,o.#i.end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const n=o.#i,s=this._currentDrawId,r=n.getLastElement();return void i.addCommands({cmd:()=>{i.drawLayer.updateProperties(s,n.setLastElement(r))},undo:()=>{i.drawLayer.updateProperties(s,n.removeLastElement())},mustExec:!1,type:G.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(e){const i=this._currentParent;if(!i)return null;if(i.toggleDrawing(!0),i.cleanUndoStack(G.DRAW_STEP),!o.#i.isEmpty()){const{pageDimensions:[n,s],scale:r}=i,a=i.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:o.#i.getOutlines(n*r,s*r,r,this._INNER_MARGIN),drawingOptions:o.#r,mustBeCommitted:!e});return this._cleanup(!0),a}return i.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,i,n,s,r,a){Y("Not implemented")}static deserialize(e,i,n){var s=()=>super.deserialize,r=this;return(0,x.A)(function*(){const{rawDims:{pageWidth:a,pageHeight:l,pageX:h,pageY:c}}=i.viewport,d=r.deserializeDraw(h,c,a,l,r._INNER_MARGIN,e),u=yield s().call(r,e,i,n);return u.createDrawingOptions(e),u.#h({drawOutlines:d}),u.#f(),u.onScaleChanging(),u.rotate(),u})()}serializeDraw(e){const[i,n]=this.pageTranslation,[s,r]=this.pageDimensions;return this.#t.serialize([i,n,s,r],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}return o})();class Ko{#t=new Float64Array(6);#e;#i;#n;#r;#s;#a="";#l=0;#c=new ui;#h;#u;constructor(t,e,i,n,s,r){this.#h=i,this.#u=n,this.#n=s,this.#r=r,[t,e]=this.#d(t,e);const a=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#s=[t,e],this.#i=[{line:a,points:this.#s}],this.#t.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#r=e)}#d(t,e){return k._normalizePoint(t,e,this.#h,this.#u,this.#n)}isEmpty(){return!this.#i||0===this.#i.length}isCancellable(){return this.#s.length<=10}add(t,e){[t,e]=this.#d(t,e);const[i,n,s,r]=this.#t.subarray(2,6);return Math.hypot(this.#h*(t-s),this.#u*(e-r))<=2?null:(this.#s.push(t,e),isNaN(i)?(this.#t.set([s,r,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([i,n,s,r,t,e],0),this.#e.push(...k.createBezierPoints(i,n,s,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){return this.add(t,e)||(2===this.#s.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,n,s){this.#h=i,this.#u=n,this.#n=s,[t,e]=this.#d(t,e);const r=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#s=[t,e];const a=this.#i.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#i.push({line:r,points:this.#s}),this.#t.set(r,0),this.#l=0,this.toSVGPath(),null}getLastElement(){return this.#i.at(-1)}setLastElement(t){return this.#i?(this.#i.push(t),this.#e=t.line,this.#s=t.points,this.#l=0,{path:{d:this.toSVGPath()}}):this.#c.setLastElement(t)}removeLastElement(){if(!this.#i)return this.#c.removeLastElement();this.#i.pop(),this.#a="";for(let t=0,e=this.#i.length;t<e;t++){const{line:i,points:n}=this.#i[t];this.#e=i,this.#s=n,this.#l=0,this.toSVGPath()}return{path:{d:this.#a}}}toSVGPath(){const t=k.svgRound(this.#e[4]),e=k.svgRound(this.#e[5]);if(2===this.#s.length)return this.#a=`${this.#a} M ${t} ${e} Z`,this.#a;if(this.#s.length<=6){const n=this.#a.lastIndexOf("M");this.#a=`${this.#a.slice(0,n)} M ${t} ${e}`,this.#l=6}if(4===this.#s.length){const n=k.svgRound(this.#e[10]),s=k.svgRound(this.#e[11]);return this.#a=`${this.#a} L ${n} ${s}`,this.#l=12,this.#a}const i=[];0===this.#l&&(i.push(`M ${t} ${e}`),this.#l=6);for(let n=this.#l,s=this.#e.length;n<s;n+=6){const[r,a,l,h,c,d]=this.#e.slice(n,n+6).map(k.svgRound);i.push(`C${r} ${a} ${l} ${h} ${c} ${d}`)}return this.#a+=i.join(" "),this.#l=this.#e.length,this.#a}getOutlines(t,e,i,n){const s=this.#i.at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),this.#c.build(this.#i,t,e,i,this.#n,this.#r,n),this.#t=null,this.#e=null,this.#i=null,this.#a=null,this.#c}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class ui extends k{#t;#e=0;#i;#n;#r;#s;#a;#l;#c;build(t,e,i,n,s,r,a){this.#r=e,this.#s=i,this.#a=n,this.#l=s,this.#c=r,this.#i=a??0,this.#n=t,this.#d()}setLastElement(t){return this.#n.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#n.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#n)if(t.push(`M${k.svgRound(e[4])} ${k.svgRound(e[5])}`),6!==e.length)if(12!==e.length)for(let i=6,n=e.length;i<n;i+=6){const[s,r,a,l,h,c]=e.subarray(i,i+6).map(k.svgRound);t.push(`C${s} ${r} ${a} ${l} ${h} ${c}`)}else t.push(`L${k.svgRound(e[10])} ${k.svgRound(e[11])}`);else t.push("Z");return t.join("")}serialize([t,e,i,n],s){const r=[],a=[],[l,h,c,d]=this.#u();let u,f,p,g,_,m,A,v,w;switch(this.#l){case 0:w=k._rescale,u=t,f=e+n,p=i,g=-n,_=t+l*i,m=e+(1-h-d)*n,A=t+(l+c)*i,v=e+(1-h)*n;break;case 90:w=k._rescaleAndSwap,u=t,f=e,p=i,g=n,_=t+h*i,m=e+l*n,A=t+(h+d)*i,v=e+(l+c)*n;break;case 180:w=k._rescale,u=t+i,f=e,p=-i,g=n,_=t+(1-l-c)*i,m=e+h*n,A=t+(1-l)*i,v=e+(h+d)*n;break;case 270:w=k._rescaleAndSwap,u=t+i,f=e+n,p=-i,g=-n,_=t+(1-h-d)*i,m=e+(1-l-c)*n,A=t+(1-h)*i,v=e+(1-l)*n}for(const{line:E,points:C}of this.#n)r.push(w(E,u,f,p,g,s?new Array(E.length):null)),a.push(w(C,u,f,p,g,s?new Array(C.length):null));return{lines:r,points:a,rect:[_,m,A,v]}}static deserialize(t,e,i,n,s,{paths:{lines:r,points:a},rotation:l,thickness:h}){const c=[];let d,u,f,p,g;switch(l){case 0:g=k._rescale,d=-t/i,u=e/n+1,f=1/i,p=-1/n;break;case 90:g=k._rescaleAndSwap,d=-e/n,u=-t/i,f=1/n,p=1/i;break;case 180:g=k._rescale,d=t/i+1,u=-e/n,f=-1/i,p=1/n;break;case 270:g=k._rescaleAndSwap,d=e/n+1,u=t/i+1,f=-1/n,p=-1/i}if(!r){r=[];for(const m of a){const A=m.length;if(2===A){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1]]));continue}if(4===A){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1],NaN,NaN,NaN,NaN,m[2],m[3]]));continue}const v=new Float32Array(3*(A-2));r.push(v);let[w,E,C,M]=m.subarray(0,4);v.set([NaN,NaN,NaN,NaN,w,E],0);for(let L=4;L<A;L+=2){const y=m[L],P=m[L+1];v.set(k.createBezierPoints(w,E,C,M,y,P),3*(L-2)),[w,E,C,M]=[C,M,y,P]}}}for(let m=0,A=r.length;m<A;m++)c.push({line:g(r[m].map(v=>v??NaN),d,u,f,p),points:g(a[m].map(v=>v??NaN),d,u,f,p)});const _=new ui;return _.build(c,i,n,1,l,h,s),_}#h(t=this.#c){const e=this.#i+t/2*this.#a;return this.#l%180==0?[e/this.#r,e/this.#s]:[e/this.#s,e/this.#r]}#u(){const[t,e,i,n]=this.#t,[s,r]=this.#h(0);return[t+s,e+r,i-2*s,n-2*r]}#d(){const t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:n}of this.#n){if(n.length<=12){for(let a=4,l=n.length;a<l;a+=6){const[h,c]=n.subarray(a,a+2);t[0]=Math.min(t[0],h),t[1]=Math.min(t[1],c),t[2]=Math.max(t[2],h),t[3]=Math.max(t[3],c)}continue}let s=n[4],r=n[5];for(let a=6,l=n.length;a<l;a+=6){const[h,c,d,u,f,p]=n.subarray(a,a+6);N.bezierBoundingBox(s,r,h,c,d,u,f,p,t),s=f,r=p}}const[e,i]=this.#h();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return"stroke-width"===t?this.#f(e):null}#f(t){const[e,i]=this.#h();this.#c=t;const[n,s]=this.#h(),[r,a]=[n-e,s-i],l=this.#t;return l[0]-=r,l[1]-=a,l[2]+=2*r,l[3]+=2*a,l}updateParentDimensions([t,e],i){const[n,s]=this.#h();this.#r=t,this.#s=e,this.#a=i;const[r,a]=this.#h(),l=r-n,h=a-s,c=this.#t;return c[0]-=l,c[1]-=h,c[2]+=2*l,c[3]+=2*h,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(k.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${k.svgRound(t)} ${k.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#t;let i=0,n=0,s=0,r=0,a=0,l=0;switch(this.#e){case 90:n=e/t,s=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,l=e;break;case 270:n=-e/t,s=t/e,l=e;break;default:return""}return`matrix(${i} ${n} ${s} ${r} ${k.svgRound(a)} ${k.svgRound(l)})`}getPathResizingSVGProperties([t,e,i,n]){const[s,r]=this.#h(),[a,l,h,c]=this.#t;if(Math.abs(h-s)<=k.PRECISION||Math.abs(c-r)<=k.PRECISION){const g=t+i/2-(a+h/2),_=e+n/2-(l+c/2);return{path:{"transform-origin":`${k.svgRound(t)} ${k.svgRound(e)}`,transform:`${this.rotationTransform} translate(${g} ${_})`}}}const d=(i-2*s)/(h-2*s),u=(n-2*r)/(c-2*r),f=h/i,p=c/n;return{path:{"transform-origin":`${k.svgRound(a)} ${k.svgRound(l)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${k.svgRound(s)} ${k.svgRound(r)}) scale(${d} ${u}) translate(${k.svgRound(-s)} ${k.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,n]){const[s,r]=this.#h(),a=this.#t,[l,h,c,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=n,Math.abs(c-s)<=k.PRECISION||Math.abs(d-r)<=k.PRECISION){const _=t+i/2-(l+c/2),m=e+n/2-(h+d/2);for(const{line:A,points:v}of this.#n)k._translate(A,_,m,A),k._translate(v,_,m,v);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${k.svgRound(t)} ${k.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(i-2*s)/(c-2*s),f=(n-2*r)/(d-2*r),p=-u*(l+s)+t+s,g=-f*(h+r)+e+r;if(1!==u||1!==f||0!==p||0!==g)for(const{line:_,points:m}of this.#n)k._rescale(_,p,g,u,f,_),k._rescale(m,p,g,u,f,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${k.svgRound(t)} ${k.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[n,s]=i,r=this.#t,a=t-r[0],l=e-r[1];if(this.#r===n&&this.#s===s)for(const{line:h,points:c}of this.#n)k._translate(h,a,l,h),k._translate(c,a,l,c);else{const h=this.#r/n,c=this.#s/s;this.#r=n,this.#s=s;for(const{line:d,points:u}of this.#n)k._rescale(d,a,l,h,c,d),k._rescale(u,a,l,h,c,u);r[2]*=h,r[3]*=c}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${k.svgRound(t)} ${k.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${k.svgRound(t[0])} ${k.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Ji extends Yo{#t;constructor(t){super(),this.#t=t,super.updateProperties({fill:"none",stroke:F._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this.#t.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Ji(this.#t);return t.updateAll(this),t}}class tn extends qo{static _type="ink";static _editorType=U.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){F.initialize(t,e),this._defaultDrawingOptions=new Ji(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return W(this,"typesMap",new Map([[G.INK_THICKNESS,"stroke-width"],[G.INK_COLOR,"stroke"],[G.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,n,s){return new Ko(t,e,i,n,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,n,s,r){return ui.deserialize(t,e,i,n,s,r)}static deserialize(t,e,i){var n=()=>super.deserialize,s=this;return(0,x.A)(function*(){let r=null;if(t instanceof Ki){const{data:{inkLists:l,rect:h,rotation:c,id:d,color:u,opacity:f,borderStyle:{rawWidth:p},popupRef:g},parent:{page:{pageNumber:_}}}=t;r=t={annotationType:U.INK,color:Array.from(u),thickness:p,opacity:f,paths:{points:l},boxes:null,pageIndex:_-1,rect:h.slice(0),rotation:c,id:d,deleted:!1,popupRef:g}}const a=yield n().call(s,t,e,i);return a.annotationElementId=t.id||null,a._initialData=r,a})()}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=tn.getDefaultDrawingOptions({stroke:N.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:n}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":r,"stroke-width":a}}=this,l={annotationType:U.INK,color:F._colorManager.convert(s),opacity:r,thickness:a,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?l:this.annotationElementId&&!this.#t(l)?null:(l.id=this.annotationElementId,l)}#t(t){const{color:e,thickness:i,opacity:n,pageIndex:s}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==i||t.opacity!==n||t.pageIndex!==s}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class en extends F{#t=null;#e=null;#i=null;#n=null;#r=null;#s="";#a=null;#l=null;#c=!1;#h=!1;static _type="stamp";static _editorType=U.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#n=t.bitmapUrl,this.#r=t.bitmapFile}static initialize(t,e){F.initialize(t,e)}static get supportedTypes(){return W(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return W(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(U.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#u(t,e=!1){t?(this.#t=t.bitmap,e||(this.#e=t.id,this.#c=t.isSvg),t.file&&(this.#s=t.file.name),this.#o()):this.remove()}#d(){if(this.#i=null,this._uiManager.enableWaiting(!1),this.#a){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}mlGuessAltText(){var t=this;return(0,x.A)(function*(e=null,i=!0){if(t.hasAltTextData())return null;const{mlManager:n}=t._uiManager;if(!n)throw new Error("No ML.");if(!(yield n.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");const{data:s,width:r,height:a}=e||t.copyCanvas(null,null,!0).imageData,l=yield n.guess({name:"altText",request:{data:s,width:r,height:a,channels:s.length/(r*a)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return yield t.setGuessedAltText(h),i&&!t.hasAltTextData()&&(t.altTextData={alt:h,decorative:!1}),h}).apply(this,arguments)}#f(){var t=this;if(this.#e)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#e).then(n=>this.#u(n,!0)).finally(()=>this.#d());if(this.#n){const n=this.#n;return this.#n=null,this._uiManager.enableWaiting(!0),void(this.#i=this._uiManager.imageManager.getFromUrl(n).then(s=>this.#u(s)).finally(()=>this.#d()))}if(this.#r){const n=this.#r;return this.#r=null,this._uiManager.enableWaiting(!0),void(this.#i=this._uiManager.imageManager.getFromFile(n).then(s=>this.#u(s)).finally(()=>this.#d()))}const e=document.createElement("input");e.type="file",e.accept=en.supportedTypesStr;const i=this._uiManager._signal;this.#i=new Promise(n=>{e.addEventListener("change",(0,x.A)(function*(){if(e.files&&0!==e.files.length){t._uiManager.enableWaiting(!0);const s=yield t._uiManager.imageManager.getFromFile(e.files[0]);t._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:t._uiManager.useNewAltTextFlow}}),t.#u(s)}else t.remove();n()}),{signal:i}),e.addEventListener("cancel",()=>{this.remove(),n()},{signal:i})}).finally(()=>this.#d()),e.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#a?.remove(),this.#a=null,this.#l&&(clearTimeout(this.#l),this.#l=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#e&&null===this.#a&&this.#f(),this.isAttachedToDOM||this.parent.add(this))):this.#e&&this.#f()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#i||this.#t||this.#n||this.#r||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#t?this.#o():this.#f(),this.width&&!this.annotationElementId){const[i,n]=this.parentDimensions;this.setAt(t*i,e*n,this.width*i,this.height*n)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#l&&clearTimeout(this.#l),this.#l=setTimeout(()=>{this.#l=null,this.#m()},200))}#o(){const{div:t}=this;let{width:e,height:i}=this.#t;const[n,s]=this.pageDimensions,r=.75;if(this.width)e=this.width*n,i=this.height*s;else if(e>r*n||i>r*s){const c=Math.min(r*n/e,r*s/i);e*=c,i*=c}const[a,l]=this.parentDimensions;this.setDims(e*a/n,i*l/s),this._uiManager.enableWaiting(!1);const h=this.#a=document.createElement("canvas");h.setAttribute("role","img"),this.addContainer(h),this.width=e/n,this.height=i/s,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#m(),this.#h||(this.parent.addUndoableEditor(this),this.#h=!0),this._reportTelemetry({action:"inserted_image"}),this.#s&&h.setAttribute("aria-label",this.#s)}copyCanvas(t,e,i=!1){t||(t=224);const{width:n,height:s}=this.#t,r=new Ni;let a=this.#t,l=n,h=s,c=null;if(e){if(n>e||s>e){const C=Math.min(e/n,e/s);l=Math.floor(n*C),h=Math.floor(s*C)}c=document.createElement("canvas");const u=c.width=Math.ceil(l*r.sx),f=c.height=Math.ceil(h*r.sy);this.#c||(a=this.#p(u,f));const p=c.getContext("2d");p.filter=this._uiManager.hcmFilter;let g="white",_="#cfcfd8";"none"!==this._uiManager.hcmFilter?_="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(g="#8f8f9d",_="#42414d");const m=15,A=m*r.sx,v=m*r.sy,w=new OffscreenCanvas(2*A,2*v),E=w.getContext("2d");E.fillStyle=g,E.fillRect(0,0,2*A,2*v),E.fillStyle=_,E.fillRect(0,0,A,v),E.fillRect(A,v,A,v),p.fillStyle=p.createPattern(w,"repeat"),p.fillRect(0,0,u,f),p.drawImage(a,0,0,a.width,a.height,0,0,u,f)}let d=null;if(i){let u,f;if(r.symmetric&&a.width<t&&a.height<t)u=a.width,f=a.height;else if(a=this.#t,n>t||s>t){const _=Math.min(t/n,t/s);u=Math.floor(n*_),f=Math.floor(s*_),this.#c||(a=this.#p(u,f))}const g=new OffscreenCanvas(u,f).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,u,f),d={width:u,height:f,data:g.getImageData(0,0,u,f).data}}return{canvas:c,width:l,height:h,imageData:d}}#p(t,e){const{width:i,height:n}=this.#t;let s=i,r=n,a=this.#t;for(;s>2*t||r>2*e;){const l=s,h=r;s>2*t&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const c=new OffscreenCanvas(s,r);c.getContext("2d").drawImage(a,0,0,l,h,0,0,s,r),a=c.transferToImageBitmap()}return a}#m(){const[t,e]=this.parentDimensions,{width:i,height:n}=this,s=new Ni,r=Math.ceil(i*t*s.sx),a=Math.ceil(n*e*s.sy),l=this.#a;if(!l||l.width===r&&l.height===a)return;l.width=r,l.height=a;const h=this.#c?this.#t:this.#p(r,a),c=l.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(h,0,0,h.width,h.height,0,0,r,a)}getImageForAltText(){return this.#a}#g(t){if(t){if(this.#c){const n=this._uiManager.imageManager.getSvgUrl(this.#e);if(n)return n}const e=document.createElement("canvas");return({width:e.width,height:e.height}=this.#t),e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#c){const[e,i]=this.pageDimensions,n=Math.round(this.width*e*ue.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*ue.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(n,s);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,n,s),r.transferToImageBitmap()}return structuredClone(this.#t)}static deserialize(t,e,i){var n=()=>super.deserialize,s=this;return(0,x.A)(function*(){let r=null;if(t instanceof ws){const{data:{rect:_,rotation:m,id:A,structParent:v,popupRef:w},container:E,parent:{page:{pageNumber:C}}}=t,M=E.querySelector("canvas"),L=i.imageManager.getFromCanvas(E.id,M);M.remove();const y=(yield e._structTree.getAriaAttributes(`${Ri}${A}`))?.get("aria-label")||"";r=t={annotationType:U.STAMP,bitmapId:L.id,bitmap:L.bitmap,pageIndex:C-1,rect:_.slice(0),rotation:m,id:A,deleted:!1,accessibilityData:{decorative:!1,altText:y},isSvg:!1,structParent:v,popupRef:w}}const a=yield n().call(s,t,e,i),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:d,isSvg:u,accessibilityData:f}=t;d&&i.imageManager.isValidId(d)?(a.#e=d,h&&(a.#t=h)):a.#n=c,a.#c=u;const[p,g]=a.pageDimensions;return a.width=(l[2]-l[0])/p,a.height=(l[3]-l[1])/g,a.annotationElementId=t.id||null,f&&(a.altTextData=f),a._initialData=r,a.#h=!!r,a})()}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:U.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#c,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#g(!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:n,altText:s}=this.serializeAltText(!1);if(!n&&s&&(i.accessibilityData={type:"Figure",alt:s}),this.annotationElementId){const a=this.#b(i);if(a.isSame)return null;a.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const r=this.#c?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#e)){if(this.#c){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#g(!1))}}else e.stamps.set(this.#e,{area:r,serialized:i}),i.bitmap=this.#g(!1);return i}#b(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,n=t.pageIndex===e,s=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&n&&s,isSameAltText:s}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}let Qo=(()=>{class o{#t;#e=!1;#i=null;#n=null;#r=null;#s=new Map;#a=!1;#l=!1;#c=!1;#h=null;#u=null;#d=null;#f=null;#o;static _initialized=!1;static#p=new Map([lt,tn,en,it].map(e=>[e._editorType,e]));constructor({uiManager:e,pageIndex:i,div:n,structTreeLayer:s,accessibilityManager:r,annotationLayer:a,drawLayer:l,textLayer:h,viewport:c,l10n:d}){const u=[...o.#p.values()];if(!o._initialized){o._initialized=!0;for(const f of u)f.initialize(d,e)}e.registerEditorTypes(u),this.#o=e,this.pageIndex=i,this.div=n,this.#t=r,this.#i=a,this.viewport=c,this.#d=h,this.drawLayer=l,this._structTree=s,this.#o.addLayer(this)}get isEmpty(){return 0===this.#s.size}get isInvisible(){return this.isEmpty&&this.#o.getMode()===U.NONE}updateToolbar(e){this.#o.updateToolbar(e)}updateMode(e=this.#o.getMode()){switch(this.#v(),e){case U.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case U.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case U.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:i}=this.div;for(const n of o.#p.values())i.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){return e===this.#d?.div}setEditingState(e){this.#o.setEditingState(e)}addCommands(e){this.#o.addCommands(e)}cleanUndoStack(e){this.#o.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#i?.div.classList.toggle("disabled",!e)}enable(){var e=this;return(0,x.A)(function*(){e.#c=!0,e.div.tabIndex=0,e.togglePointerEvents(!0);const i=new Set;for(const s of e.#s.values())s.enableEditing(),s.show(!0),s.annotationElementId&&(e.#o.removeChangedExistingAnnotation(s),i.add(s.annotationElementId));if(!e.#i)return void(e.#c=!1);const n=e.#i.getEditableAnnotations();for(const s of n){if(s.hide(),e.#o.isDeletedAnnotationElement(s.data.id)||i.has(s.data.id))continue;const r=yield e.deserialize(s);r&&(e.addOrRebuild(r),r.enableEditing())}e.#c=!1})()}disable(){this.#l=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,i=new Map;for(const s of this.#s.values())if(s.disableEditing(),s.annotationElementId){if(null!==s.serialize()){e.set(s.annotationElementId,s);continue}i.set(s.annotationElementId,s),this.getEditableAnnotation(s.annotationElementId)?.show(),s.remove()}if(this.#i){const s=this.#i.getEditableAnnotations();for(const r of s){const{id:a}=r.data;if(this.#o.isDeletedAnnotationElement(a))continue;let l=i.get(a);l?(l.resetAnnotationElement(r),l.show(!1),r.show()):(l=e.get(a),l&&(this.#o.addChangedExistingAnnotation(l),l.renderAnnotationElement(r)&&l.show(!1)),r.show())}}this.#v(),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const s of o.#p.values())n.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#l=!1}getEditableAnnotation(e){return this.#i?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#o.getActive()!==e&&this.#o.setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;const e=this.#o.combinedSignal(this.#f);this.#d.div.addEventListener("pointerdown",this.#m.bind(this),{signal:e}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#d.div.classList.remove("highlighting"))}#m(e){this.#o.unselectAll();const{target:i}=e;if(i===this.#d.div||("img"===i.getAttribute("role")||i.classList.contains("endOfContent"))&&this.#d.div.contains(i)){const{isMac:n}=_t.platform;if(0!==e.button||e.ctrlKey&&n)return;this.#o.showAllEditors("highlight",!0,!0),this.#d.div.classList.add("free"),this.toggleDrawing(),it.startHighlighting(this,"ltr"===this.#o.direction,{target:this.#d.div,x:e.x,y:e.y}),this.#d.div.addEventListener("pointerup",()=>{this.#d.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#o._signal}),e.preventDefault()}}enableClick(){if(this.#n)return;this.#n=new AbortController;const e=this.#o.combinedSignal(this.#n);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const i=this.pointerup.bind(this);this.div.addEventListener("pointerup",i,{signal:e}),this.div.addEventListener("pointercancel",i,{signal:e})}disableClick(){this.#n?.abort(),this.#n=null}attach(e){this.#s.set(e.id,e);const{annotationElementId:i}=e;i&&this.#o.isDeletedAnnotationElement(i)&&this.#o.removeDeletedAnnotationElement(e)}detach(e){this.#s.delete(e.id),this.#t?.removePointerInTextLayer(e.contentDiv),!this.#l&&e.annotationElementId&&this.#o.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#o.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){e.parent!==this&&(e.parent&&e.annotationElementId&&(this.#o.addDeletedAnnotationElement(e.annotationElementId),F.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(e.parent!==this||!e.isAttachedToDOM){if(this.changeParent(e),this.#o.addEditor(e),this.attach(e),!e.isAttachedToDOM){const i=e.render();this.div.append(i),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!this.#c),this.#o.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const{activeElement:i}=document;e.div.contains(i)&&!this.#r&&(e._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#o._signal}),i.focus())},0)),e._structTreeParentId=this.#t?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return this.#o.getId()}get#g(){return o.#p.get(this.#o.getMode())}combinedSignal(e){return this.#o.combinedSignal(e)}#b(e){const i=this.#g;return i?new i.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(e,i){this.#o.updateToolbar(e),this.#o.updateMode(e);const{offsetX:n,offsetY:s}=this.#_(),r=this.getNextId(),a=this.#b({parent:this,id:r,x:n,y:s,uiManager:this.#o,isCentered:!0,...i});a&&this.add(a)}deserialize(e){var i=this;return(0,x.A)(function*(){return(yield o.#p.get(e.annotationType??e.annotationEditorType)?.deserialize(e,i,i.#o))||null})()}createAndAddNewEditor(e,i,n={}){const s=this.getNextId(),r=this.#b({parent:this,id:s,x:e.offsetX,y:e.offsetY,uiManager:this.#o,isCentered:i,...n});return r&&this.add(r),r}#_(){const{x:e,y:i,width:n,height:s}=this.div.getBoundingClientRect(),r=Math.max(0,e),a=Math.max(0,i),c=(r+Math.min(window.innerWidth,e+n))/2-e,d=(a+Math.min(window.innerHeight,i+s))/2-i,[u,f]=this.viewport.rotation%180==0?[c,d]:[d,c];return{offsetX:u,offsetY:f}}addNewEditor(){this.createAndAddNewEditor(this.#_(),!0)}setSelected(e){this.#o.setSelected(e)}toggleSelected(e){this.#o.toggleSelected(e)}unselect(e){this.#o.unselect(e)}pointerup(e){const{isMac:i}=_t.platform;if(!(0!==e.button||e.ctrlKey&&i)&&e.target===this.div&&this.#a&&(this.#a=!1,!this.#g?.isDrawer||!this.#g.supportMultipleDrawings)){if(!this.#e)return void(this.#e=!0);if(this.#o.getMode()===U.STAMP)return void this.#o.unselectAll();this.createAndAddNewEditor(e,!1)}}pointerdown(e){if(this.#o.getMode()===U.HIGHLIGHT&&this.enableTextSelection(),this.#a)return void(this.#a=!1);const{isMac:i}=_t.platform;if(0!==e.button||e.ctrlKey&&i||e.target!==this.div)return;if(this.#a=!0,this.#g?.isDrawer)return void this.startDrawingSession(e);const n=this.#o.getActive();this.#e=!n||n.isEmpty()}startDrawingSession(e){if(this.div.focus(),this.#h)return void this.#g.startDrawing(this,this.#o,!1,e);this.#o.setCurrentDrawingSession(this),this.#h=new AbortController;const i=this.#o.combinedSignal(this.#h);this.div.addEventListener("blur",({relatedTarget:n})=>{n&&!this.div.contains(n)&&(this.#u=null,this.commitOrRemove())},{signal:i}),this.#g.startDrawing(this,this.#o,!1,e)}pause(e){if(e){const{activeElement:i}=document;return void(this.div.contains(i)&&(this.#u=i))}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(e=!1){return this.#h?(this.#o.setCurrentDrawingSession(null),this.#h.abort(),this.#h=null,this.#u=null,this.#g.endDrawing(e)):null}findNewParent(e,i,n){const s=this.#o.findParent(i,n);return null!==s&&s!==this&&(s.changeParent(e),!0)}commitOrRemove(){return!!this.#h&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#h&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#o.getActive()?.parent===this&&(this.#o.commitOrRemove(),this.#o.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(const e of this.#s.values())this.#t?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#s.clear(),this.#o.removeLayer(this)}#v(){for(const e of this.#s.values())e.isEmpty()&&e.remove()}render({viewport:e}){this.viewport=e,ne(this.div,e);for(const i of this.#o.getEditors(this.pageIndex))this.add(i),i.rebuild();this.updateMode()}update({viewport:e}){this.#o.commitOrRemove(),this.#v();const i=this.viewport.rotation,n=e.rotation;if(this.viewport=e,ne(this.div,{rotation:n}),i!==n)for(const s of this.#s.values())s.rotate(n)}get pageDimensions(){const{pageWidth:e,pageHeight:i}=this.viewport.rawDims;return[e,i]}get scale(){return this.#o.viewParameters.realScale}}return o})();class At{#t=null;#e=0;#i=new Map;#n=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#t){if(this.#t!==t){if(this.#i.size>0)for(const e of this.#i.values())e.remove(),t.append(e);this.#t=t}}else this.#t=t}static get _svgFactory(){return W(this,"_svgFactory",new Yi)}static#r(t,[e,i,n,s]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*n+"%",r.height=100*s+"%"}#s(){const t=At._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#a(t,e){const i=At._svgFactory.createElement("clipPath");t.append(i);const n=`clip_${e}`;i.setAttribute("id",n),i.setAttribute("clipPathUnits","objectBoundingBox");const s=At._svgFactory.createElement("use");return i.append(s),s.setAttribute("href",`#${e}`),s.classList.add("clip"),n}#l(t,e){for(const[i,n]of Object.entries(e))null===n?t.removeAttribute(i):t.setAttribute(i,n)}draw(t,e=!1,i=!1){const n=this.#e++,s=this.#s(),r=At._svgFactory.createElement("defs");s.append(r);const a=At._svgFactory.createElement("path");r.append(a);const l=`path_p${this.pageIndex}_${n}`;a.setAttribute("id",l),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#n.set(n,a);const h=i?this.#a(r,l):null,c=At._svgFactory.createElement("use");return s.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(s,t),this.#i.set(n,s),{id:n,clipPathId:`url(#${h})`}}drawOutline(t,e){const i=this.#e++,n=this.#s(),s=At._svgFactory.createElement("defs");n.append(s);const r=At._svgFactory.createElement("path");s.append(r);const a=`path_p${this.pageIndex}_${i}`;let l;if(r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke"),e){const d=At._svgFactory.createElement("mask");s.append(d),l=`mask_p${this.pageIndex}_${i}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const u=At._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=At._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const h=At._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${a}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return n.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(n,t),this.#i.set(i,n),i}finalizeDraw(t,e){this.#n.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:n,rootClass:s,path:r}=e,a="number"==typeof t?this.#i.get(t):t;if(a){if(i&&this.#l(a,i),n&&At.#r(a,n),s){const{classList:l}=a;for(const[h,c]of Object.entries(s))l.toggle(h,c)}r&&this.#l(a.firstChild.firstChild,r)}}updateParent(t,e){if(e===this)return;const i=this.#i.get(t);i&&(e.#t.append(i),this.#i.delete(t),e.#i.set(t,i))}remove(t){this.#n.delete(t),null!==this.#t&&(this.#i.get(t).remove(),this.#i.delete(t))}destroy(){this.#t=null;for(const t of this.#i.values())t.remove();this.#i.clear(),this.#n.clear()}}globalThis.pdfjsTestingUtils={HighlightOutliner:Qi};var Zo=B.AbortException,Jo=B.AnnotationEditorLayer,tl=B.AnnotationEditorParamsType,Es=B.AnnotationEditorType,el=B.AnnotationEditorUIManager,il=B.AnnotationLayer,nl=B.AnnotationMode,sl=B.ColorPicker,rl=B.DOMSVGFactory,al=B.DrawLayer,ol=B.FeatureTest,xs=B.GlobalWorkerOptions,ll=B.ImageKind,hl=B.InvalidPDFException,cl=B.MissingPDFException,dl=B.OPS,ul=B.OutputScale,fl=B.PDFDataRangeTransport,pl=B.PDFDateString,gl=B.PDFWorker,ml=B.PasswordResponses,bl=B.PermissionFlag,_l=B.PixelsPerInch,vl=B.RenderingCancelledException,Al=B.TextLayer,wl=B.TouchManager,yl=B.UnexpectedResponseException,El=B.Util,Ss=B.VerbosityLevel,xl=B.XfaLayer,Sl=B.build,Pl=B.createValidAbsoluteUrl,Cl=B.fetchData,Ps=B.getDocument,Tl=B.getFilenameFromUrl,Ml=B.getPdfFilenameFromUrl,Ll=B.getXfaPageViewport,Rl=B.isDataScheme,Il=B.isPdfFile,kl=B.noContextMenu,Dl=B.normalizeUnicode,Ol=B.setLayerDimensions,Nl=B.shadow,Fl=B.stopEvent,fi=B.version,Cs=V(56218),Ts=V(10600),Bl=V(19495),Be={d:(o,t)=>{for(var e in t)Be.o(t,e)&&!Be.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:t[e]})},o:(o,t)=>Object.prototype.hasOwnProperty.call(o,t)},Q=globalThis.pdfjsViewer={};Be.d(Q,{AnnotationLayerBuilder:()=>$s,DownloadManager:()=>Dh,EventBus:()=>un,FindState:()=>te,GenericL10n:()=>qt,LinkTarget:()=>oe,PDFFindController:()=>Ah,PDFHistory:()=>Tc,PDFLinkService:()=>_i,PDFPageView:()=>br,PDFScriptingManager:()=>Hc,PDFSinglePageViewer:()=>Gc,PDFViewer:()=>Ar,ProgressBar:()=>Ql,RenderingStates:()=>tt,ScrollMode:()=>$,SimpleLinkService:()=>on,SpreadMode:()=>mt,StructTreeLayerBuilder:()=>gr,TextLayerBuilder:()=>ve,XfaLayerBuilder:()=>mr,parseQueryString:()=>pi});const tt={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},$={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},mt={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function ks(o,t,e=!1){let i=o.offsetParent;if(!i)return void console.error("offsetParent is not set -- cannot scroll");let n=o.offsetTop+o.clientTop,s=o.offsetLeft+o.clientLeft;for(;i.clientHeight===i.scrollHeight&&i.clientWidth===i.scrollWidth||e&&(i.classList.contains("markedContent")||"hidden"===getComputedStyle(i).overflow);)if(n+=i.offsetTop,s+=i.offsetLeft,i=i.offsetParent,!i)return;t&&(void 0!==t.top&&(n+=t.top),void 0!==t.left&&(s+=t.left,i.scrollLeft=s)),i.scrollTop=n}function pi(o){const t=new Map;for(const[e,i]of new URLSearchParams(o))t.set(e.toLowerCase(),i);return t}const Ds=/[\x00-\x1F]/g;function Ve(o,t=!1){return Ds.test(o)?t?o.replaceAll(Ds,e=>"\0"===e?"":" "):o.replaceAll("\0",""):o}function je(o,t,e=0){let i=e,n=o.length-1;if(n<0||!t(o[n]))return o.length;if(t(o[i]))return i;for(;i<n;){const s=i+n>>1;t(o[s])?n=s:i=s+1}return i}function Os(o){if(Math.floor(o)===o)return[o,1];const t=1/o;if(t>8)return[1,8];if(Math.floor(t)===t)return[1,t];const i=o>1?t:o;let l,n=0,s=1,r=1,a=1;for(;;){const h=n+r,c=s+a;if(c>8)break;i<=h/c?(r=h,a=c):(n=h,s=c)}return l=i-n/s<r/a-i?i===o?[n,s]:[s,n]:i===o?[r,a]:[a,r],l}function gi(o,t){return o-o%t}function Ns(o){return Number.isInteger(o)&&o%90==0}function Fs(o){return o.width<=o.height}new Promise(function(o){window.requestAnimationFrame(o)});const ql=document.documentElement.style;class Ql{#t=null;#e=null;#i=0;#n=null;#r=!0;constructor(t){this.#t=t.classList,this.#n=t.style}get percent(){return this.#i}set percent(t){this.#i=function Kl(o,t,e){return Math.min(Math.max(o,t),e)}(t,0,100),isNaN(t)?this.#t.add("indeterminate"):(this.#t.remove("indeterminate"),this.#n.setProperty("--progressBar-percent",`${this.#i}%`))}setWidth(t){if(!t)return;const i=t.parentNode.offsetWidth-t.offsetWidth;i>0&&this.#n.setProperty("--progressBar-end-offset",`${i}px`)}setDisableAutoFetch(t=5e3){100===this.#i||isNaN(this.#i)||(this.#e&&clearTimeout(this.#e),this.show(),this.#e=setTimeout(()=>{this.#e=null,this.hide()},t))}hide(){this.#r&&(this.#r=!1,this.#t.add("hidden"))}show(){this.#r||(this.#r=!0,this.#t.remove("hidden"))}}const mi=function(){const o=document.createElement("div");return o.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)","calc(1320px)"===o.style.width?Math.fround:t=>t}();function bi(o){return function Jl(o){return o<11904}(o)?function th(o){return!(65408&o)}(o)?function nh(o){return 32===o||9===o||13===o||10===o}(o)?0:function eh(o){return o>=97&&o<=122||o>=65&&o<=90}(o)||function ih(o){return o>=48&&o<=57}(o)||95===o?1:2:function lh(o){return 3584==(65408&o)}(o)?7:160===o?0:1:function sh(o){return o>=13312&&o<=40959||o>=63744&&o<=64255}(o)?3:function rh(o){return o>=12448&&o<=12543}(o)?4:function ah(o){return o>=12352&&o<=12447}(o)?5:function oh(o){return o>=65376&&o<=65439}(o)?6:1}let Bs;const te={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},Vs={"\u2010":"-","\u2018":"'","\u2019":"'","\u201a":"'","\u201b":"'","\u201c":'"',"\u201d":'"',"\u201e":'"',"\u201f":'"',"\xbc":"1/4","\xbd":"1/2","\xbe":"3/4"},js=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]);let Hs;const fh=new RegExp("\\p{M}+","gu"),ph=new RegExp("([.*+?^${}()|[\\]\\\\])|(\\p{P})|(\\s+)|(\\p{M})|(\\p{L})","gu"),gh=new RegExp("([^\\p{M}])\\p{M}*$","u"),mh=new RegExp("^\\p{M}*([^\\p{M}])","u"),bh=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,zs=new Map,Us=new Map;let sn=null,rn=null;function an(o){const t=[];let e,i;for(;null!==(e=bh.exec(o));){let{index:g}=e;for(const _ of e[0]){let m=zs.get(_);m||(m=_.normalize("NFD").length,zs.set(_,m)),t.push([m,g++])}}if(0===t.length&&sn)i=sn;else if(t.length>0&&rn)i=rn;else{const w=`([${Object.keys(Vs).join("")}])|([${function hh(){return Bs||="\xa0\xa8\xaa\xaf\xb2-\xb5\xb8-\xba\xbc-\xbe\u0132-\u0133\u013f-\u0140\u0149\u017f\u01c4-\u01cc\u01f1-\u01f3\u02b0-\u02b8\u02d8-\u02dd\u02e0-\u02e4\u0374\u037a\u037e\u0384-\u0385\u0387\u03d0-\u03d6\u03f0-\u03f2\u03f4-\u03f5\u03f9\u0587\u0675-\u0678\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e33\u0eb3\u0edc-\u0edd\u0f0c\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u10fc\u1d2c-\u1d2e\u1d30-\u1d3a\u1d3c-\u1d4d\u1d4f-\u1d6a\u1d78\u1d9b-\u1dbf\u1e9a-\u1e9b\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbd-\u1fc1\u1fc9\u1fcb\u1fcd-\u1fcf\u1fd3\u1fdb\u1fdd-\u1fdf\u1fe3\u1feb\u1fed-\u1fef\u1ff9\u1ffb\u1ffd-\u1ffe\u2000-\u200a\u2011\u2017\u2024-\u2026\u202f\u2033-\u2034\u2036-\u2037\u203c\u203e\u2047-\u2049\u2057\u205f\u2070-\u2071\u2074-\u208e\u2090-\u209c\u20a8\u2100-\u2103\u2105-\u2107\u2109-\u2113\u2115-\u2116\u2119-\u211d\u2120-\u2122\u2124\u2126\u2128\u212a-\u212d\u212f-\u2131\u2133-\u2139\u213b-\u2140\u2145-\u2149\u2150-\u217f\u2189\u222c-\u222d\u222f-\u2230\u2329-\u232a\u2460-\u24ea\u2a0c\u2a74-\u2a76\u2adc\u2c7c-\u2c7d\u2d6f\u2e9f\u2ef3\u2f00-\u2fd5\u3000\u3036\u3038-\u303a\u309b-\u309c\u309f\u30ff\u3131-\u318e\u3192-\u319f\u3200-\u321e\u3220-\u3247\u3250-\u327e\u3280-\u33ff\ua69c-\ua69d\ua770\ua7f2-\ua7f4\ua7f8-\ua7f9\uab5c-\uab5f\uab69\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfc\ufe10-\ufe19\ufe30-\ufe44\ufe47-\ufe52\ufe54-\ufe66\ufe68-\ufe6b\ufe70-\ufe72\ufe74\ufe76-\ufefc\uff01-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc\uffe0-\uffe6",Bs}()}])|((?:\u3099|\u309a)\\n)|(\\p{M}+(?:-\\n)?)|(\\p{Ll}-\\n\\p{Lu})|(\\S-\\n)|((?:\\p{Ideographic}|[\u3040-\u30ff])\\n)|(\\n)`;i=0===t.length?sn=new RegExp(w+"|(\\u0000)","gum"):rn=new RegExp(w+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const n=[];for(;null!==(e=fh.exec(o));)n.push([e[0].length,e.index]);let s=o.normalize("NFD");const r=[0,0];let a=0,l=0,h=0,c=0,d=0,u=!1;s=s.replace(i,(g,_,m,A,v,w,E,C,M,L,y)=>{if(y-=c,_){const P=Vs[_],R=P.length;for(let I=1;I<R;I++)r.push(y-h+I,h-I);return h-=R-1,P}if(m){let P=Us.get(m);P||(P=m.normalize("NFKC"),Us.set(m,P));const R=P.length;for(let I=1;I<R;I++)r.push(y-h+I,h-I);return h-=R-1,P}if(A)return u=!0,y+d===n[a]?.[1]?++a:(r.push(y-1-h+1,h-1),h-=1,c+=1),r.push(y-h+1,h),c+=1,d+=1,A.charAt(0);if(v){const P=v.endsWith("\n"),R=P?v.length-2:v.length;u=!0;let I=R;y+d===n[a]?.[1]&&(I-=n[a][0],++a);for(let j=1;j<=I;j++)r.push(y-1-h+j,h-j);return h-=I,c+=I,P?(r.push((y+=R-1)-h+1,1+h),h+=1,c+=1,d+=1,v.slice(0,R)):v}if(w)return c+=1,d+=1,w.replace("\n","");if(E)return r.push(y-h+(E.length-2),1+h),h+=1,c+=1,d+=1,E.slice(0,-2);if(C)return r.push(y-h+(C.length-1),h),c+=1,d+=1,C.slice(0,-1);if(M)return r.push(y-h+1,h-1),h-=1,c+=1,d+=1," ";if(y+d===t[l]?.[1]){const P=t[l][0]-1;++l;for(let R=1;R<=P;R++)r.push(y-(h-R),h-R);h-=P,c+=P}return L}),r.push(s.length,h);const f=new Uint32Array(r.length>>1),p=new Int32Array(r.length>>1);for(let g=0,_=r.length;g<_;g+=2)f[g>>1]=r[g],p[g>>1]=r[g+1];return[s,[f,p],u]}class Ah{#t=null;#e=!0;#i=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#e=i,this.onIsPageVisible=null,this.#r(),e._on("find",this.#n.bind(this)),e._on("findbarclose",this.#_.bind(this))}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#t}setDocument(t){this._pdfDocument&&this.#r(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#n(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#t||this.#a(t))&&(this._dirtyMatch=!0),this.#t=t,"highlightallchange"!==i&&this.#y(te.PENDING),this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#u();const n=!this._highlightMatches,s=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#o():"again"===i?(this.#o(),n&&this.#t.highlightAll&&this.#f()):"highlightallchange"===i?(s?this.#o():this._highlightMatches=!0,this.#f()):this.#o():this._findTimeout=setTimeout(()=>{this.#o(),this._findTimeout=null},250)})}scrollMatchIntoView({element:t=null,selectedLeft:e=0,pageIndex:i=-1,matchIndex:n=-1}){this._scrollMatches&&t&&-1!==n&&n===this._selected.matchIdx&&-1!==i&&i===this._selected.pageIdx&&(this._scrollMatches=!1,ks(t,{top:-50,left:e+-400},!0))}#r(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#i=0,this.#t=null,this._selected={pageIdx:-1,matchIdx:-1},this._offset={pageIdx:null,matchIdx:null,wrapped:!1},this._extractTextPromises=[],this._pageContents=[],this._pageDiffs=[],this._hasDiacritics=[],this._matchesCountTotal=0,this._pagesToSearch=null,this._pendingFindMatches=new Set,this._resumePageIdx=null,this._dirtyMatch=!1,clearTimeout(this._findTimeout),this._findTimeout=null,this._firstPageCapability=Promise.withResolvers()}get#s(){const{query:t}=this.#t;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=an(t)),this._normalizedQuery):(t||[]).filter(e=>!!e).map(e=>an(e)[0])}#a(t){const e=t.query,i=this.#t.query,n=typeof e;if(n!==typeof i)return!0;if("string"===n){if(e!==i)return!0}else if(JSON.stringify(e)!==JSON.stringify(i))return!0;switch(t.type){case"again":const r=this._selected.pageIdx+1,a=this._linkService;return r>=1&&r<=a.pagesCount&&r!==a.page&&!(this.onIsPageVisible?.(r)??1);case"highlightallchange":return!1}return!0}#l(t,e,i){let n=t.slice(0,e).match(gh);if(n){const s=t.charCodeAt(e),r=n[1].charCodeAt(0);if(bi(s)===bi(r))return!1}if(n=t.slice(e+i).match(mh),n){const s=t.charCodeAt(e+i-1),r=n[1].charCodeAt(0);if(bi(s)===bi(r))return!1}return!0}#c(t,e){const{matchDiacritics:i}=this.#t;let n=!1;return(t=t.replaceAll(ph,(r,a,l,h,c,d)=>a?`[ ]*\\${a}[ ]*`:l?`[ ]*${l}[ ]*`:h?"[ ]+":i?c||d:c?js.has(c.charCodeAt(0))?c:"":e?(n=!0,`${d}\\p{M}*`):d)).endsWith("[ ]*")&&(t=t.slice(0,t.length-4)),i&&e&&(Hs||=String.fromCharCode(...js),n=!0,t=`${t}(?=[${Hs}]|[^\\p{M}]|$)`),[n,t]}#h(t){const e=this.#s;if(0===e.length)return;const n=this.match(e,this._pageContents[t],t),s=this._pageMatches[t]=[],r=this._pageMatchesLength[t]=[],a=this._pageDiffs[t];n?.forEach(({index:h,length:c})=>{const[d,u]=function vh(o,t,e){if(!o)return[t,e];const[i,n]=o,s=t,r=t+e-1;let a=je(i,u=>u>=s);i[a]>s&&--a;let l=je(i,u=>u>=r,a);i[l]>r&&--l;const h=s+n[a];return[h,r+n[l]+1-h]}(a,h,c);u&&(s.push(d),r.push(u))}),this.#t.highlightAll&&this.#d(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#m());const l=s.length;this._matchesCountTotal+=l,this.#e?l>0&&this.#A():++this.#i===this._linkService.pagesCount&&this.#A()}match(t,e,i){const n=this._hasDiacritics[i];let s=!1;if("string"==typeof t?[s,t]=this.#c(t,n):t=t.sort().reverse().map(d=>{const[u,f]=this.#c(d,n);return s||=u,`(${f})`}).join("|"),!t)return;const{caseSensitive:r,entireWord:a}=this.#t;t=new RegExp(t,`g${s?"u":""}${r?"":"i"}`);const h=[];let c;for(;null!==(c=t.exec(e));)a&&!this.#l(e,c.index,c[0].length)||h.push({index:c.index,length:c[0].length});return h}#u(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0};for(let i=0,n=this._linkService.pagesCount;i<n;i++){const{promise:s,resolve:r}=Promise.withResolvers();this._extractTextPromises[i]=s,t=t.then(()=>this._pdfDocument.getPage(i+1).then(a=>a.getTextContent(e)).then(a=>{const l=[];for(const h of a.items)l.push(h.str),h.hasEOL&&l.push("\n");[this._pageContents[i],this._pageDiffs[i],this._hasDiacritics[i]]=an(l.join("")),r()},a=>{console.error(`Unable to get text content for page ${i+1}`,a),this._pageContents[i]="",this._pageDiffs[i]=null,this._hasDiacritics[i]=!1,r()}))}}#d(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#f(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#o(){const t=this.#t.findPrevious,e=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=e,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#i=0,this._matchesCountTotal=0,this.#f();for(let r=0;r<i;r++)this._pendingFindMatches.has(r)||(this._pendingFindMatches.add(r),this._extractTextPromises[r].then(()=>{this._pendingFindMatches.delete(r),this.#h(r)}))}if(0===this.#s.length)return void this.#y(te.FOUND);if(this._resumePageIdx)return;const s=this._offset;if(this._pagesToSearch=i,null!==s.matchIdx){if(!t&&s.matchIdx+1<this._pageMatches[s.pageIdx].length||t&&s.matchIdx>0)return s.matchIdx=t?s.matchIdx-1:s.matchIdx+1,void this.#b(!0);this.#g(t)}this.#m()}#p(t){const e=this._offset,i=t.length,n=this.#t.findPrevious;return i?(e.matchIdx=n?i-1:0,this.#b(!0),!0):(this.#g(n),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#b(!1),!0))}#m(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let t=null;do{const e=this._offset.pageIdx;if(t=this._pageMatches[e],!t){this._resumePageIdx=e;break}}while(!this.#p(t))}#g(t){const e=this._offset,i=this._linkService.pagesCount;e.pageIdx=t?e.pageIdx-1:e.pageIdx+1,e.matchIdx=null,this._pagesToSearch--,(e.pageIdx>=i||e.pageIdx<0)&&(e.pageIdx=t?i-1:0,e.wrapped=!0)}#b(t=!1){let e=te.NOT_FOUND;const i=this._offset.wrapped;if(this._offset.wrapped=!1,t){const n=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx,this._selected.matchIdx=this._offset.matchIdx,e=i?te.WRAPPED:te.FOUND,-1!==n&&n!==this._selected.pageIdx&&this.#d(n)}this.#y(e,this.#t.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#d(this._selected.pageIdx))}#_(t){const e=this._pdfDocument;this._firstPageCapability.promise.then(()=>{!this._pdfDocument||e&&this._pdfDocument!==e||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#y(te.FOUND),this._highlightMatches=!1,this.#f())})}#v(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,n=this._matchesCountTotal;if(-1!==e){for(let s=0;s<t;s++)i+=this._pageMatches[s]?.length||0;i+=e+1}return(i<1||i>n)&&(i=n=0),{current:i,total:n}}#A(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#v()})}#y(t,e=!1){!this.#e&&(this.#i!==this._linkService.pagesCount||t===te.PENDING)||this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#t?.entireWord??null,matchesCount:this.#v(),rawQuery:this.#t?.query??null})}}const oe={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class _i{externalLinkEnabled=!0;constructor({eventBus:t,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:n=!1}={}){this.eventBus=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=n,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(t,e=null){this.baseUrl=e,this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setHistory(t){this.pdfHistory=t}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(t){this.pdfDocument&&(this.pdfViewer.currentPageNumber=t)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(t){this.pdfDocument&&(this.pdfViewer.pagesRotation=t)}get isInPresentationMode(){return!!this.pdfDocument&&this.pdfViewer.isInPresentationMode}goToDestination(t){var e=this;return(0,x.A)(function*(){if(!e.pdfDocument)return;let i,n,s;if("string"==typeof t?(i=t,n=yield e.pdfDocument.getDestination(t)):(i=null,n=yield t),!Array.isArray(n))return void console.error(`goToDestination: "${n}" is not a valid destination array, for dest="${t}".`);const[r]=n;if(r&&"object"==typeof r){if(s=e.pdfDocument.cachedPageNumber(r),!s)try{s=(yield e.pdfDocument.getPageIndex(r))+1}catch{return void console.error(`goToDestination: "${r}" is not a valid page reference, for dest="${t}".`)}}else Number.isInteger(r)&&(s=r+1);!s||s<1||s>e.pagesCount?console.error(`goToDestination: "${s}" is not a valid page number, for dest="${t}".`):(e.pdfHistory&&(e.pdfHistory.pushCurrentPosition(),e.pdfHistory.push({namedDest:i,explicitDest:n,pageNumber:s})),e.pdfViewer.scrollPageIntoView({pageNumber:s,destArray:n,ignoreDestinationZoom:e._ignoreDestinationZoom}))})()}goToPage(t){if(!this.pdfDocument)return;const e="string"==typeof t&&this.pdfViewer.pageLabelToPageNumber(t)||0|t;Number.isInteger(e)&&e>0&&e<=this.pagesCount?(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(e)),this.pdfViewer.scrollPageIntoView({pageNumber:e})):console.error(`PDFLinkService.goToPage: "${t}" is not a valid page.`)}addLinkAttributes(t,e,i=!1){if(!e||"string"!=typeof e)throw new Error('A valid "url" parameter must provided.');const n=i?oe.BLANK:this.externalLinkTarget,s=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let r="";switch(n){case oe.NONE:break;case oe.SELF:r="_self";break;case oe.BLANK:r="_blank";break;case oe.PARENT:r="_parent";break;case oe.TOP:r="_top"}t.target=r,t.rel="string"==typeof s?s:"noopener noreferrer nofollow"}getDestinationHash(t){if("string"==typeof t){if(t.length>0)return this.getAnchorUrl("#"+escape(t))}else if(Array.isArray(t)){const e=JSON.stringify(t);if(e.length>0)return this.getAnchorUrl("#"+escape(e))}return this.getAnchorUrl("")}getAnchorUrl(t){return this.baseUrl?this.baseUrl+t:t}setHash(t){if(!this.pdfDocument)return;let e,i;if(t.includes("=")){const n=pi(t);if(n.has("search")){const s=n.get("search").replaceAll('"',""),r="true"===n.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:r?s:s.match(/\S+/g)})}if(n.has("page")&&(e=0|n.get("page")||1),n.has("zoom")){const s=n.get("zoom").split(","),r=s[0],a=parseFloat(r);r.includes("Fit")?"Fit"===r||"FitB"===r?i=[null,{name:r}]:"FitH"===r||"FitBH"===r||"FitV"===r||"FitBV"===r?i=[null,{name:r},s.length>1?0|s[1]:null]:"FitR"===r?5!==s.length?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:r},0|s[1],0|s[2],0|s[3],0|s[4]]:console.error(`PDFLinkService.setHash: "${r}" is not a valid zoom value.`):i=[null,{name:"XYZ"},s.length>1?0|s[1]:null,s.length>2?0|s[2]:null,a?a/100:r]}return i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),n.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:n.get("pagemode")}),void(n.has("nameddest")&&this.goToDestination(n.get("nameddest")))}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||_i.#t(i)?this.goToDestination(i):console.error(`PDFLinkService.setHash: "${unescape(t)}" is not a valid destination.`)}executeNamedAction(t){if(this.pdfDocument){switch(t){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:t})}}executeSetOCGState(t){var e=this;return(0,x.A)(function*(){if(!e.pdfDocument)return;const i=e.pdfDocument,n=yield e.pdfViewer.optionalContentConfigPromise;i===e.pdfDocument&&(n.setOCGState(t),e.pdfViewer.optionalContentConfigPromise=Promise.resolve(n))})()}static#t(t){if(!Array.isArray(t)||t.length<2)return!1;const[e,i,...n]=t;if(("object"!=typeof e||!Number.isInteger(e?.num)||!Number.isInteger(e?.gen))&&!Number.isInteger(e)||"object"!=typeof i||"string"!=typeof i?.name)return!1;const s=n.length;let r=!0;switch(i.name){case"XYZ":if(s<2||s>3)return!1;break;case"Fit":case"FitB":return 0===s;case"FitH":case"FitBH":case"FitV":case"FitBV":if(s>1)return!1;break;case"FitR":if(4!==s)return!1;r=!1;break;default:return!1}for(const a of n)if(!("number"==typeof a||r&&null===a))return!1;return!0}}class on extends _i{setDocument(t,e=null){}}const{AbortException:yh,AnnotationEditorLayer:Eh,AnnotationEditorType:Ct,AnnotationEditorUIManager:xh,AnnotationLayer:Sh,AnnotationMode:$t,createValidAbsoluteUrl:Ph,DrawLayer:Ch,fetchData:Ws,getPdfFilenameFromUrl:Th,isPdfFile:Mh,normalizeUnicode:Lh,OutputScale:Rh,PermissionFlag:vi,PixelsPerInch:Xt,RenderingCancelledException:ln,setLayerDimensions:Ih,shadow:Ai,stopEvent:hn,TextLayer:kh,version:Gs,XfaLayer:cn}=globalThis.pdfjsLib;class $s{#t=null;#e=null;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:n=null,imageResourcesPath:s="",renderForms:r=!0,enableScripting:a=!1,hasJSActionsPromise:l=null,fieldObjectsPromise:h=null,annotationCanvasMap:c=null,accessibilityManager:d=null,annotationEditorUIManager:u=null,onAppend:f=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=s,this.renderForms=r,this.annotationStorage=n,this.enableScripting=a,this._hasJSActionsPromise=l||Promise.resolve(!1),this._fieldObjectsPromise=h||Promise.resolve(null),this._annotationCanvasMap=c,this._accessibilityManager=d,this._annotationEditorUIManager=u,this.#t=f,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}render(t,e){var i=this;return(0,x.A)(function*(n,s,r="display"){if(i.div){if(i._cancelled||!i.annotationLayer)return;return void i.annotationLayer.update({viewport:n.clone({dontFlip:!0})})}const[a,l,h]=yield Promise.all([i.pdfPage.getAnnotations({intent:r}),i._hasJSActionsPromise,i._fieldObjectsPromise]);if(i._cancelled)return;const c=i.div=document.createElement("div");c.className="annotationLayer",i.#t?.(c),0!==a.length?(i.annotationLayer=new Sh({div:c,accessibilityManager:i._accessibilityManager,annotationCanvasMap:i._annotationCanvasMap,annotationEditorUIManager:i._annotationEditorUIManager,page:i.pdfPage,viewport:n.clone({dontFlip:!0}),structTreeLayer:s?.structTreeLayer||null}),yield i.annotationLayer.render({annotations:a,imageResourcesPath:i.imageResourcesPath,renderForms:i.renderForms,linkService:i.linkService,downloadManager:i.downloadManager,annotationStorage:i.annotationStorage,enableScripting:i.enableScripting,hasJSActions:l,fieldObjects:h}),i.linkService.isInPresentationMode&&i.#i(3),i.#e||(i.#e=new AbortController,i._eventBus?._on("presentationmodechanged",d=>{i.#i(d.state)},{signal:i.#e.signal}))):i.hide()}).apply(this,arguments)}cancel(){this._cancelled=!0,this.#e?.abort(),this.#e=null}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}#i(t){if(!this.div)return;let e=!1;switch(t){case 3:e=!0;break;case 1:break;default:return}for(const i of this.div.childNodes)i.hasAttribute("data-internal-link")||(i.inert=e)}}function Xs(o,t){const e=document.createElement("a");if(!e.click)throw new Error('DownloadManager: "a.click()" is not supported.');e.href=o,e.target="_parent","download"in e&&(e.download=t),(document.body||document.documentElement).append(e),e.click(),e.remove()}class Dh{#t=new WeakMap;downloadData(t,e,i){Xs(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const s=Mh(e)?"application/pdf":"";return this.downloadData(t,e,s),!1}download(t,e,i){let n;if(t)n=URL.createObjectURL(new Blob([t],{type:"application/pdf"}));else{if(!Ph(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);n=e+"#pdfjs.action=download"}Xs(n,i)}}function dn(){return(dn=(0,x.A)(function*({target:o,name:t,delay:e=0}){if("object"!=typeof o||!t||"string"!=typeof t||!(Number.isInteger(e)&&e>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:i,resolve:n}=Promise.withResolvers(),s=new AbortController;function r(h){s.abort(),clearTimeout(l),n(h)}o[o instanceof un?"_on":"addEventListener"](t,r.bind(null,"event"),{signal:s.signal});const l=setTimeout(r.bind(null,"timeout"),e);return i})).apply(this,arguments)}class un{#t=Object.create(null);on(t,e,i=null){this._on(t,e,{external:!0,once:i?.once,signal:i?.signal})}off(t,e,i=null){this._off(t,e)}dispatch(t,e){const i=this.#t[t];if(!i||0===i.length)return;let n;for(const{listener:s,external:r,once:a}of i.slice(0))a&&this._off(t,s),r?(n||=[]).push(s):s(e);if(n){for(const s of n)s(e);n=null}}_on(t,e,i=null){let n=null;if(i?.signal instanceof AbortSignal){const{signal:r}=i;if(r.aborted)return void console.error("Cannot use an `aborted` signal.");const a=()=>this._off(t,e);n=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}(this.#t[t]||=[]).push({listener:e,external:!0===i?.external,once:!0===i?.once,rmAbort:n})}_off(t,e,i=null){const n=this.#t[t];if(n)for(let s=0,r=n.length;s<r;s++){const a=n[s];if(a.listener===e)return a.rmAbort?.(),void n.splice(s,1)}}}class wi{constructor(t){this.value=t}valueOf(){return this.value}}class rt extends wi{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class Yt extends wi{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),this.value.toString(10)}}}class He extends wi{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),new Date(this.value).toISOString()}}}function Bh(o,t,e){return e===t||e instanceof Yt&&t instanceof Yt&&e.value===t.value||t instanceof Yt&&"string"==typeof e&&e===o.memoizeIntlObject(Intl.PluralRules,t.opts).select(t.value)}function Ks(o,t,e){return t[e]?_e(o,t[e].value):(o.reportError(new RangeError("No default")),new rt)}function fn(o,t){const e=[],i=Object.create(null);for(const n of t)"narg"===n.type?i[n.name]=ze(o,n.value):e.push(ze(o,n));return{positional:e,named:i}}function ze(o,t){switch(t.type){case"str":return t.value;case"num":return new Yt(t.value,{minimumFractionDigits:t.precision});case"var":return function Vh(o,{name:t}){let e;if(o.params){if(!Object.prototype.hasOwnProperty.call(o.params,t))return new rt(`$${t}`);e=o.params[t]}else{if(!o.args||!Object.prototype.hasOwnProperty.call(o.args,t))return o.reportError(new ReferenceError(`Unknown variable: $${t}`)),new rt(`$${t}`);e=o.args[t]}if(e instanceof wi)return e;switch(typeof e){case"string":return e;case"number":return new Yt(e);case"object":if(e instanceof Date)return new He(e.getTime());default:return o.reportError(new TypeError(`Variable type not supported: $${t}, ${typeof e}`)),new rt(`$${t}`)}}(o,t);case"mesg":return function jh(o,{name:t,attr:e}){const i=o.bundle._messages.get(t);if(!i)return o.reportError(new ReferenceError(`Unknown message: ${t}`)),new rt(t);if(e){const n=i.attributes[e];return n?_e(o,n):(o.reportError(new ReferenceError(`Unknown attribute: ${e}`)),new rt(`${t}.${e}`))}return i.value?_e(o,i.value):(o.reportError(new ReferenceError(`No value: ${t}`)),new rt(t))}(o,t);case"term":return function Hh(o,{name:t,attr:e,args:i}){const n=`-${t}`,s=o.bundle._terms.get(n);if(!s)return o.reportError(new ReferenceError(`Unknown term: ${n}`)),new rt(n);if(e){const a=s.attributes[e];if(a){o.params=fn(o,i).named;const l=_e(o,a);return o.params=null,l}return o.reportError(new ReferenceError(`Unknown attribute: ${e}`)),new rt(`${n}.${e}`)}o.params=fn(o,i).named;const r=_e(o,s.value);return o.params=null,r}(o,t);case"func":return function zh(o,{name:t,args:e}){let i=o.bundle._functions[t];if(!i)return o.reportError(new ReferenceError(`Unknown function: ${t}()`)),new rt(`${t}()`);if("function"!=typeof i)return o.reportError(new TypeError(`Function ${t}() is not callable`)),new rt(`${t}()`);try{let n=fn(o,e);return i(n.positional,n.named)}catch(n){return o.reportError(n),new rt(`${t}()`)}}(o,t);case"select":return function Uh(o,{selector:t,variants:e,star:i}){let n=ze(o,t);if(n instanceof rt)return Ks(o,e,i);for(const s of e)if(Bh(o,n,ze(o,s.key)))return _e(o,s.value);return Ks(o,e,i)}(o,t);default:return new rt}}function Qs(o,t){if(o.dirty.has(t))return o.reportError(new RangeError("Cyclic reference")),new rt;o.dirty.add(t);const e=[],i=o.bundle._useIsolating&&t.length>1;for(const n of t)if("string"!=typeof n){if(o.placeables++,o.placeables>100)throw o.dirty.delete(t),new RangeError(`Too many placeables expanded: ${o.placeables}, max allowed is 100`);i&&e.push("\u2068"),e.push(ze(o,n).toString(o)),i&&e.push("\u2069")}else e.push(o.bundle._transform(n));return o.dirty.delete(t),e.join("")}function _e(o,t){return"string"==typeof t?o.bundle._transform(t):Qs(o,t)}class Wh{constructor(t,e,i){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=t,this.errors=e,this.args=i}reportError(t){if(!(this.errors&&t instanceof Error))throw t;this.errors.push(t)}memoizeIntlObject(t,e){let i=this.bundle._intls.get(t);i||(i={},this.bundle._intls.set(t,i));let n=JSON.stringify(e);return i[n]||(i[n]=new t(this.bundle.locales,e)),i[n]}}function yi(o,t){const e=Object.create(null);for(const[i,n]of Object.entries(o))t.includes(i)&&(e[i]=n.valueOf());return e}const Zs=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Gh(o,t){let e=o[0];if(e instanceof rt)return new rt(`NUMBER(${e.valueOf()})`);if(e instanceof Yt)return new Yt(e.valueOf(),{...e.opts,...yi(t,Zs)});if(e instanceof He)return new Yt(e.valueOf(),{...yi(t,Zs)});throw new TypeError("Invalid argument to NUMBER")}const Js=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function $h(o,t){let e=o[0];if(e instanceof rt)return new rt(`DATETIME(${e.valueOf()})`);if(e instanceof He)return new He(e.valueOf(),{...e.opts,...yi(t,Js)});if(e instanceof Yt)return new He(e.valueOf(),{...yi(t,Js)});throw new TypeError("Invalid argument to DATETIME")}const tr=new Map;class Yh{constructor(t,{functions:e,useIsolating:i=!0,transform:n=s=>s}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:Gh,DATETIME:$h,...e},this._useIsolating=i,this._transform=n,this._intls=function Xh(o){const t=Array.isArray(o)?o.join(" "):o;let e=tr.get(t);return void 0===e&&(e=new Map,tr.set(t,e)),e}(t)}hasMessage(t){return this._messages.has(t)}getMessage(t){return this._messages.get(t)}addResource(t,{allowOverrides:e=!1}={}){const i=[];for(let n=0;n<t.body.length;n++){let s=t.body[n];if(s.id.startsWith("-")){if(!1===e&&this._terms.has(s.id)){i.push(new Error(`Attempt to override an existing term: "${s.id}"`));continue}this._terms.set(s.id,s)}else{if(!1===e&&this._messages.has(s.id)){i.push(new Error(`Attempt to override an existing message: "${s.id}"`));continue}this._messages.set(s.id,s)}}return i}formatPattern(t,e=null,i=null){if("string"==typeof t)return this._transform(t);let n=new Wh(this,i,e);try{return Qs(n,t).toString(n)}catch(s){if(n.errors&&s instanceof Error)return n.errors.push(s),(new rt).toString(n);throw s}}}const pn=/^(-?[a-zA-Z][\w-]*) *= */gm,er=/\.([a-zA-Z][\w-]*) *= */y,qh=/\*?\[/y,gn=/(-?[0-9]+(?:\.([0-9]+))?)/y,Kh=/([a-zA-Z][\w-]*)/y,ir=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Qh=/^[A-Z][A-Z0-9_-]*$/,Ei=/([^{}\n\r]+)/y,Zh=/([^\\"\n\r]*)/y,nr=/\\([\\"])/y,sr=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,Jh=/^\n+/,rr=/ +$/,tc=/ *\r?\n/g,ec=/( *)$/,ic=/{\s*/y,ar=/\s*}/y,nc=/\[\s*/y,sc=/\s*] */y,rc=/\s*\(\s*/y,ac=/\s*->\s*/y,oc=/\s*:\s*/y,lc=/\s*,?\s*/y,hc=/\s+/y;class cc{constructor(t){this.body=[],pn.lastIndex=0;let e=0;for(;;){let y=pn.exec(t);if(null===y)break;e=pn.lastIndex;try{this.body.push(l(y[1]))}catch(P){if(P instanceof SyntaxError)continue;throw P}}function i(y){return y.lastIndex=e,y.test(t)}function n(y,P){if(t[e]===y)return e++,!0;if(P)throw new P(`Expected ${y}`);return!1}function s(y,P){if(i(y))return e=y.lastIndex,!0;if(P)throw new P(`Expected ${y.toString()}`);return!1}function r(y){y.lastIndex=e;let P=y.exec(t);if(null===P)throw new SyntaxError(`Expected ${y.toString()}`);return e=y.lastIndex,P}function a(y){return r(y)[1]}function l(y){let P=c(),R=function h(){let y=Object.create(null);for(;i(er);){let P=a(er),R=c();if(null===R)throw new SyntaxError("Expected attribute value");y[P]=R}return y}();if(null===P&&0===Object.keys(R).length)throw new SyntaxError("Expected message value or attributes");return{id:y,value:P,attributes:R}}function c(){let y;if(i(Ei)&&(y=a(Ei)),"{"===t[e]||"}"===t[e])return d(y?[y]:[],1/0);let P=C();return P?y?d([y,P],P.length):(P.value=M(P.value,Jh),d([P],P.length)):y?M(y,rr):null}function d(y=[],P){for(;;){if(i(Ei)){y.push(a(Ei));continue}if("{"===t[e]){y.push(u());continue}if("}"===t[e])throw new SyntaxError("Unbalanced closing brace");let H=C();if(!H)break;y.push(H),P=Math.min(P,H.length)}let R=y.length-1,I=y[R];"string"==typeof I&&(y[R]=M(I,rr));let j=[];for(let H of y)H instanceof or&&(H=H.value.slice(0,H.value.length-P)),H&&j.push(H);return j}function u(){s(ic,SyntaxError);let y=f();if(s(ar))return y;if(s(ac)){let P=function _(){let R,y=[],P=0;for(;i(qh);){n("*")&&(R=P);let I=m(),j=c();if(null===j)throw new SyntaxError("Expected variant value");y[P++]={key:I,value:j}}if(0===P)return null;if(void 0===R)throw new SyntaxError("Expected default variant");return{variants:y,star:R}}();return s(ar,SyntaxError),{type:"select",selector:y,...P}}throw new SyntaxError("Unclosed placeable")}function f(){if("{"===t[e])return u();if(i(ir)){let[,y,P,R=null]=r(ir);if("$"===y)return{type:"var",name:P};if(s(rc)){let I=function p(){let y=[];for(;;){switch(t[e]){case")":return e++,y;case void 0:throw new SyntaxError("Unclosed argument list")}y.push(g()),s(lc)}}();if("-"===y)return{type:"term",name:P,attr:R,args:I};if(Qh.test(P))return{type:"func",name:P,args:I};throw new SyntaxError("Function names must be all upper-case")}return"-"===y?{type:"term",name:P,attr:R,args:[]}:{type:"mesg",name:P,attr:R}}return A()}function g(){let y=f();return"mesg"!==y.type?y:s(oc)?{type:"narg",name:y.name,value:A()}:y}function m(){let y;return s(nc,SyntaxError),y=i(gn)?v():{type:"str",value:a(Kh)},s(sc,SyntaxError),y}function A(){if(i(gn))return v();if('"'===t[e])return function w(){n('"',SyntaxError);let y="";for(;;){if(y+=a(Zh),"\\"!==t[e]){if(n('"'))return{type:"str",value:y};throw new SyntaxError("Unclosed string literal")}y+=E()}}();throw new SyntaxError("Invalid expression")}function v(){let[,y,P=""]=r(gn),R=P.length;return{type:"num",value:parseFloat(y),precision:R}}function E(){if(i(nr))return a(nr);if(i(sr)){let[,y,P]=r(sr),R=parseInt(y||P,16);return R<=55295||57344<=R?String.fromCodePoint(R):"\ufffd"}throw new SyntaxError("Unknown escape sequence")}function C(){let y=e;switch(s(hc),t[e]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return L(t.slice(y,e))}return" "===t[e-1]&&L(t.slice(y,e))}function M(y,P){return y.replace(P,"")}function L(y){let P=y.replace(tc,"\n"),R=ec.exec(y)[1].length;return new or(P,R)}}}class or{constructor(t,e){this.value=t,this.length=e}}const dc=/<|&#?\w+;/,uc={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},fc={"http://www.w3.org/1999/xhtml":{global:["title","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function pc(o,t){const{value:e}=t;if("string"==typeof e)if("title"===o.localName&&"http://www.w3.org/1999/xhtml"===o.namespaceURI)o.textContent=e;else if(dc.test(e)){const i=o.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");i.innerHTML=e,function gc(o,t){for(const e of o.childNodes)if(e.nodeType!==e.TEXT_NODE){if(e.hasAttribute("data-l10n-name")){const i=bc(t,e);o.replaceChild(i,e);continue}if(vc(e)){const i=_c(e);o.replaceChild(i,e);continue}console.warn(`An element of forbidden type "${e.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`),o.replaceChild(mn(e),e)}t.textContent="",t.appendChild(o)}(i.content,o)}else o.textContent=e;lr(t,o)}function mc(o,t){if(!o)return!1;for(let e of o)if(e.name===t)return!0;return!1}function lr(o,t){const e=t.hasAttribute("data-l10n-attrs")?t.getAttribute("data-l10n-attrs").split(",").map(i=>i.trim()):null;for(const i of Array.from(t.attributes))hr(i.name,t,e)&&!mc(o.attributes,i.name)&&t.removeAttribute(i.name);if(o.attributes)for(const i of Array.from(o.attributes))hr(i.name,t,e)&&t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}function bc(o,t){const e=t.getAttribute("data-l10n-name"),i=o.querySelector(`[data-l10n-name="${e}"]`);return i?i.localName!==t.localName?(console.warn(`An element named "${e}" was found in the translation but its type ${t.localName} didn't match the element found in the source (${i.localName}).`),mn(t)):(o.removeChild(i),cr(t,i.cloneNode(!1))):(console.warn(`An element named "${e}" wasn't found in the source.`),mn(t))}function _c(o){const t=o.ownerDocument.createElement(o.localName);return cr(o,t)}function mn(o){return o.ownerDocument.createTextNode(o.textContent)}function vc(o){const t=uc[o.namespaceURI];return t&&t.includes(o.localName)}function hr(o,t,e=null){if(e&&e.includes(o))return!0;const i=fc[t.namespaceURI];if(!i)return!1;const n=o.toLowerCase(),s=t.localName;if(i.global.includes(n))return!0;if(!i[s])return!1;if(i[s].includes(n))return!0;if("http://www.w3.org/1999/xhtml"===t.namespaceURI&&"input"===s&&"value"===n){const r=t.type.toLowerCase();if("submit"===r||"button"===r||"reset"===r)return!0}return!1}function cr(o,t){return t.textContent=o.textContent,lr(o,t),t}class dr extends Array{static from(t){return t instanceof this?t:new this(t)}}Symbol;class Ac extends dr{constructor(t){if(super(),Symbol.asyncIterator in Object(t))this.iterator=t[Symbol.asyncIterator]();else{if(!(Symbol.iterator in Object(t)))throw new TypeError("Argument must implement the iteration protocol.");this.iterator=t[Symbol.iterator]()}}[Symbol.asyncIterator](){const t=this;let e=0;return{next:()=>(0,x.A)(function*(){return t.length<=e&&t.push(t.iterator.next()),t[e++]})()}}touchNext(){var t=this;return(0,x.A)(function*(e=1){let i=0;for(;i++<e;){const n=t[t.length-1];if(n&&(yield n).done)break;t.push(t.iterator.next())}return t[t.length-1]}).apply(this,arguments)}}class wc{constructor(t=[],e){this.resourceIds=t,this.generateBundles=e,this.onChange(!0)}addResourceIds(t,e=!1){return this.resourceIds.push(...t),this.onChange(e),this.resourceIds.length}removeResourceIds(t){return this.resourceIds=this.resourceIds.filter(e=>!t.includes(e)),this.onChange(),this.resourceIds.length}formatWithFallback(t,e){var i=this;return(0,x.A)(function*(){const n=[];let s=!1;var l,r=!1,a=!1;try{for(var c,h=(0,Bl.A)(i.bundles);r=!(c=yield h.next()).done;r=!1){const d=c.value;{s=!0;const u=xc(e,d,t,n);if(0===u.size)break;if(typeof console<"u"){const f=d.locales[0],p=Array.from(u).join(", ");console.warn(`[fluent] Missing translations in ${f}: ${p}`)}}}}catch(d){a=!0,l=d}finally{try{r&&null!=h.return&&(yield h.return())}finally{if(a)throw l}}return!s&&typeof console<"u"&&console.warn(`[fluent] Request for keys failed because no resource bundles got generated.\n keys: ${JSON.stringify(t)}.\n resourceIds: ${JSON.stringify(i.resourceIds)}.`),n})()}formatMessages(t){return this.formatWithFallback(t,Ec)}formatValues(t){return this.formatWithFallback(t,yc)}formatValue(t,e){var i=this;return(0,x.A)(function*(){const[n]=yield i.formatValues([{id:t,args:e}]);return n})()}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=Ac.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function yc(o,t,e,i){return e.value?o.formatPattern(e.value,i,t):null}function Ec(o,t,e,i){const n={value:null,attributes:null};e.value&&(n.value=o.formatPattern(e.value,i,t));let s=Object.keys(e.attributes);if(s.length>0){n.attributes=new Array(s.length);for(let[r,a]of s.entries()){let l=o.formatPattern(e.attributes[a],i,t);n.attributes[r]={name:a,value:l}}}return n}function xc(o,t,e,i){const n=[],s=new Set;return e.forEach(({id:r,args:a},l)=>{if(void 0!==i[l])return;let h=t.getMessage(r);if(h){if(n.length=0,i[l]=o(t,n,h,a),n.length>0&&typeof console<"u"){const c=t.locales[0],d=n.join(", ");console.warn(`[fluent][resolver] errors in ${c}/${r}: ${d}.`)}}else s.add(r)}),s}const le="data-l10n-id",Ue="data-l10n-args",Sc=`[${le}]`;class Pc extends wc{constructor(t,e){super(t,e),this.roots=new Set,this.pendingrAF=null,this.pendingElements=new Set,this.windowElement=null,this.mutationObserver=null,this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[le,Ue]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(le,e),i?t.setAttribute(Ue,JSON.stringify(i)):t.removeAttribute(Ue),t}getAttributes(t){return{id:t.getAttribute(le),args:JSON.parse(t.getAttribute(Ue)||null)}}connectRoot(t){for(const e of this.roots)if(e===t||e.contains(t)||t.contains(e))throw new Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==t.ownerDocument.defaultView)throw new Error("Cannot connect a root:\n DOMLocalization already has a root from a different window.")}else this.windowElement=t.ownerDocument.defaultView,this.mutationObserver=new this.windowElement.MutationObserver(e=>this.translateMutations(e));this.roots.add(t),this.mutationObserver.observe(t,this.observerConfig)}disconnectRoot(t){return this.roots.delete(t),this.pauseObserving(),0===this.roots.size?(this.mutationObserver=null,this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF),this.windowElement=null,this.pendingrAF=null,this.pendingElements.clear(),!0):(this.resumeObserving(),!1)}translateRoots(){const t=Array.from(this.roots);return Promise.all(t.map(e=>this.translateFragment(e)))}pauseObserving(){this.mutationObserver&&(this.translateMutations(this.mutationObserver.takeRecords()),this.mutationObserver.disconnect())}resumeObserving(){if(this.mutationObserver)for(const t of this.roots)this.mutationObserver.observe(t,this.observerConfig)}translateMutations(t){for(const e of t)switch(e.type){case"attributes":e.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(e.target);break;case"childList":for(const i of e.addedNodes)if(i.nodeType===i.ELEMENT_NODE)if(i.childElementCount)for(const n of this.getTranslatables(i))this.pendingElements.add(n);else i.hasAttribute(le)&&this.pendingElements.add(i)}this.pendingElements.size>0&&null===this.pendingrAF&&(this.pendingrAF=this.windowElement.requestAnimationFrame(()=>{this.translateElements(Array.from(this.pendingElements)),this.pendingElements.clear(),this.pendingrAF=null}))}translateFragment(t){return this.translateElements(this.getTranslatables(t))}translateElements(t){var e=this;return(0,x.A)(function*(){if(!t.length)return;const i=t.map(e.getKeysForElement),n=yield e.formatMessages(i);return e.applyTranslations(t,n)})()}applyTranslations(t,e){this.pauseObserving();for(let i=0;i<t.length;i++)void 0!==e[i]&&pc(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(Sc));return"function"==typeof t.hasAttribute&&t.hasAttribute(le)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(le),args:JSON.parse(t.getAttribute(Ue)||null)}}}class xi{#t;#e;#i;#n;constructor({lang:t,isRTL:e},i=null){this.#i=xi.#r(t),this.#n=i,this.#t=e??xi.#s(this.#i)?"rtl":"ltr"}_setL10n(t){this.#n=t}getLanguage(){return this.#i}getDirection(){return this.#t}get(t){var e=this;return(0,x.A)(function*(i,n=null,s){return Array.isArray(i)?(i=i.map(l=>({id:l})),(yield e.#n.formatMessages(i)).map(l=>l.value)):(yield e.#n.formatMessages([{id:i,args:n}]))[0]?.value||s}).apply(this,arguments)}translate(t){var e=this;return(0,x.A)(function*(){(e.#e||=new Set).add(t);try{e.#n.connectRoot(t),yield e.#n.translateRoots()}catch{}})()}translateOnce(t){var e=this;return(0,x.A)(function*(){try{yield e.#n.translateElements([t])}catch(i){console.error("translateOnce:",i)}})()}destroy(){var t=this;return(0,x.A)(function*(){if(t.#e){for(const e of t.#e)t.#n.disconnectRoot(e);t.#e.clear(),t.#e=null}t.#n.pauseObserving()})()}pause(){this.#n.pauseObserving()}resume(){this.#n.resumeObserving()}static#r(t){return{en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"}[t=t?.toLowerCase()||"en-us"]||t}static#s(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function ur(o,t){const e=new cc(t),i=new Yh(o),n=i.addResource(e);return n.length&&console.error("L10n errors",n),i}class qt extends xi{constructor(t){super({lang:t});const e=t?qt.#t.bind(qt,"en-us",this.getLanguage()):qt.#n.bind(qt,this.getLanguage());this._setL10n(new Pc([],e))}static#t(t,e){var i=this;return(0,Ts.A)(function*(){const{baseURL:n,paths:s}=yield(0,Cs.A)(i.#i()),r=[e];if(t!==e){const a=e.split("-",1)[0];a!==e&&r.push(a),r.push(t)}for(const a of r){const l=yield(0,Cs.A)(i.#e(a,n,s));l?yield l:"en-us"===a&&(yield i.#r(a))}})()}static#e(t,e,i){return(0,x.A)(function*(){const n=i[t];if(!n)return null;const s=new URL(n,e),r=yield Ws(s,"text");return ur(t,r)})()}static#i(){return(0,x.A)(function*(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=yield Ws(t,"json");return{baseURL:t.replace(/[^/]*$/,"")||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}})()}static#n(t){var e=this;return(0,Ts.A)(function*(){yield e.#r(t)})()}static#r(t){return(0,x.A)(function*(){return ur(t,'pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties\u2026\npdfjs-document-properties-button-label = Document Properties\u2026\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } \xd7 { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } \xd7 { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing\u2026\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document\u2026\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing\u2026\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can\u2019t see the image or when it doesn\u2019t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, \u201cA young man sits down at a table to eat a meal\u201d\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner \u2014 resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle \u2014 resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner \u2014 resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right \u2014 resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner \u2014 resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle \u2014 resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner \u2014 resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left \u2014 resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here\u2026\npdfjs-editor-new-alt-text-description = Short description for people who can\u2019t see the image or when the image doesn\u2019t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn\u2019t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can\u2019t see the image or when the image doesn\u2019t load.\npdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)\npdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.\npdfjs-editor-alt-text-settings-delete-model-button = Delete\npdfjs-editor-alt-text-settings-download-model-button = Download\npdfjs-editor-alt-text-settings-downloading-model-button = Downloading\u2026\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close')})()}}function _n(){return document.location.hash}class Tc{#t=null;constructor({linkService:t,eventBus:e}){this.linkService=t,this.eventBus=e,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus._on("pagesinit",()=>{this._isPagesLoaded=!1,this.eventBus._on("pagesloaded",i=>{this._isPagesLoaded=!!i.pagesCount},{once:!0})})}initialize({fingerprint:t,resetHistory:e=!1,updateUrl:i=!1}){if(!t||"string"!=typeof t)return void console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');this._initialized&&this.reset();const n=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=!0===i,this._initialized=!0,this.#u();const s=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=_n(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#r(s,!0)||e){const{hash:a,page:l,rotation:h}=this.#a(!0);return!a||n||e?void this.#e(null,!0):void this.#e({hash:a,page:l,rotation:h},!0)}const r=s.destination;this.#s(r,s.uid,!0),void 0!==r.rotation&&(this._initialRotation=r.rotation),r.dest?(this._initialBookmark=JSON.stringify(r.dest),this._destination.page=null):r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){this._initialized&&(this.#h(),this._initialized=!1,this.#d()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:t=null,explicitDest:e,pageNumber:i}){if(!this._initialized)return;if(t&&"string"!=typeof t)return void console.error(`PDFHistory.push: "${t}" is not a valid namedDest parameter.`);if(!Array.isArray(e))return void console.error(`PDFHistory.push: "${e}" is not a valid explicitDest parameter.`);if(!this.#n(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const n=t||JSON.stringify(e);if(!n)return;let s=!1;if(this._destination&&(function Mc(o,t){return"string"==typeof o&&"string"==typeof t&&(o===t||pi(o).get("nameddest")===t)}(this._destination.hash,n)||function Lc(o,t){function e(i,n){if(typeof i!=typeof n||Array.isArray(i)||Array.isArray(n))return!1;if(null!==i&&"object"==typeof i&&null!==n){if(Object.keys(i).length!==Object.keys(n).length)return!1;for(const s in i)if(!e(i[s],n[s]))return!1;return!0}return i===n||Number.isNaN(i)&&Number.isNaN(n)}if(!Array.isArray(o)||!Array.isArray(t)||o.length!==t.length)return!1;for(let i=0,n=o.length;i<n;i++)if(!e(o[i],t[i]))return!1;return!0}(this._destination.dest,e))){if(this._destination.page)return;s=!0}this._popStateInProgress&&!s||(this.#e({dest:e,hash:n,page:i,rotation:this.linkService.rotation},s),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1})))}pushPage(t){if(this._initialized){if(!this.#n(t))return void console.error(`PDFHistory.pushPage: "${t}" is not a valid page number.`);this._destination?.page!==t&&(this._popStateInProgress||(this.#e({dest:null,hash:`page=${t}`,page:t,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1}))))}}pushCurrentPosition(){!this._initialized||this._popStateInProgress||this.#i()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#r(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#r(t)&&t.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}#e(t,e=!1){const i=e||!this._destination,n={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};let s;if(this.#s(t,n.uid),this._updateUrl&&t?.hash){const r=document.location.href.split("#",1)[0];r.startsWith("file://")||(s=`${r}#${t.hash}`)}i?window.history.replaceState(n,"",s):window.history.pushState(n,"",s)}#i(t=!1){if(!this._position)return;let e=this._position;if(t&&(e=Object.assign(Object.create(null),this._position),e.temporary=!0),!this._destination)return void this.#e(e);if(this._destination.temporary)return void this.#e(e,!0);if(this._destination.hash===e.hash||!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=e.first&&this._destination.page<=e.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}this.#e(e,i)}#n(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#r(t,e=!1){if(!t)return!1;if(t.fingerprint!==this._fingerprint){if(!e)return!1;{if("string"!=typeof t.fingerprint||t.fingerprint.length!==this._fingerprint.length)return!1;const[i]=performance.getEntriesByType("navigation");if("reload"!==i?.type)return!1}}return!(!Number.isInteger(t.uid)||t.uid<0||null===t.destination||"object"!=typeof t.destination)}#s(t,e,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&t?.temporary&&delete t.temporary,this._destination=t,this._uid=e,this._maxUid=Math.max(this._maxUid,e),this._numPositionUpdates=0}#a(t=!1){const e=unescape(_n()).substring(1),i=pi(e),n=i.get("nameddest")||"";let s=0|i.get("page");return(!this.#n(s)||t&&n.length>0)&&(s=null),{hash:e,page:s,rotation:this.linkService.rotation}}#l({location:t}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation},!this._popStateInProgress&&(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout(()=>{this._popStateInProgress||this.#i(!0),this._updateViewareaTimeout=null},1e3))}#c({state:t}){const e=_n(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:s,page:r,rotation:a}=this.#a();return void this.#e({hash:s,page:r,rotation:a},!0)}if(!this.#r(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,function Oh(o){return dn.apply(this,arguments)}({target:window,name:"hashchange",delay:1e3}).then(()=>{this._blockHashChange--}));const n=t.destination;this.#s(n,t.uid,!0),Ns(n.rotation)&&(this.linkService.rotation=n.rotation),n.dest?this.linkService.goToDestination(n.dest):n.hash?this.linkService.setHash(n.hash):n.page&&(this.linkService.page=n.page),Promise.resolve().then(()=>{this._popStateInProgress=!1})}#h(){(!this._destination||this._destination.temporary)&&this.#i()}#u(){if(this.#t)return;this.#t=new AbortController;const{signal:t}=this.#t;this.eventBus._on("updateviewarea",this.#l.bind(this),{signal:t}),window.addEventListener("popstate",this.#c.bind(this),{signal:t}),window.addEventListener("pagehide",this.#h.bind(this),{signal:t})}#d(){this.#t?.abort(),this.#t=null}}class Rc{#t=null;#e=null;#i=null;#n=null;#r=null;#s;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new qt,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#s=t.uiManager,this.#t=t.annotationLayer||null,this.#r=t.textLayer||null,this.#e=t.drawLayer||null,this.#i=t.onAppend||null,this.#n=t.structTreeLayer||null}render(t){var e=this;return(0,x.A)(function*(i,n="display"){if("display"!==n||e._cancelled)return;const s=i.clone({dontFlip:!0});if(e.div)return e.annotationEditorLayer.update({viewport:s}),void e.show();const r=e.div=document.createElement("div");r.className="annotationEditorLayer",r.hidden=!0,r.dir=e.#s.direction,e.#i?.(r),e.annotationEditorLayer=new Eh({uiManager:e.#s,div:r,structTreeLayer:e.#n,accessibilityManager:e.accessibilityManager,pageIndex:e.pdfPage.pageNumber-1,l10n:e.l10n,viewport:s,annotationLayer:e.#t,textLayer:e.#r,drawLayer:e.#e}),e.annotationEditorLayer.render({viewport:s,div:r,annotations:null,intent:n}),e.show()}).apply(this,arguments)}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){!this.div||this.annotationEditorLayer.isInvisible||(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var vn=new Map;const o=navigator.userAgent||"",t=navigator.platform||"",e=navigator.maxTouchPoints||1,i=/Android/.test(o);(/\b(iPad|iPhone|iPod)(?=;)/.test(o)||"MacIntel"===t&&e>1||i)&&vn.set("maxCanvasPixels",5242880),i&&vn.set("useSystemFonts",!1)}const An={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},zt={allowedGlobalEvents:{value:null,kind:1},canvasMaxAreaInBytes:{value:-1,kind:5},isInAutomation:{value:!1,kind:1},localeProperties:{value:{lang:navigator.language||"en-US"},kind:1},nimbusDataStr:{value:"",kind:1},supportsCaretBrowsingMode:{value:!1,kind:1},supportsDocumentFonts:{value:!0,kind:1},supportsIntegratedFind:{value:!1,kind:1},supportsMouseWheelZoomCtrlKey:{value:!0,kind:1},supportsMouseWheelZoomMetaKey:{value:!0,kind:1},supportsPinchToZoom:{value:!0,kind:1},toolbarDensity:{value:0,kind:17},altTextLearnMoreUrl:{value:"",kind:130},annotationEditorMode:{value:0,kind:130},annotationMode:{value:2,kind:130},cursorToolOnLoad:{value:0,kind:130},debuggerSrc:{value:"./debugger.mjs",kind:2},defaultZoomDelay:{value:400,kind:130},defaultZoomValue:{value:"",kind:130},disableHistory:{value:!1,kind:2},disablePageLabels:{value:!1,kind:130},enableAltText:{value:!1,kind:130},enableAltTextModelDownload:{value:!0,kind:146},enableGuessAltText:{value:!0,kind:146},enableHighlightFloatingButton:{value:!1,kind:130},enableNewAltTextWhenAddingImage:{value:!0,kind:130},enablePermissions:{value:!1,kind:130},enablePrintAutoRotate:{value:!0,kind:130},enableScripting:{value:!0,kind:130},enableUpdatedAddImage:{value:!1,kind:130},externalLinkRel:{value:"noopener noreferrer nofollow",kind:2},externalLinkTarget:{value:0,kind:130},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:130},historyUpdateUrl:{value:!1,kind:130},ignoreDestinationZoom:{value:!1,kind:130},imageResourcesPath:{value:"./images/",kind:2},maxCanvasPixels:{value:2**25,kind:2},forcePageColors:{value:!1,kind:130},pageColorsBackground:{value:"Canvas",kind:130},pageColorsForeground:{value:"CanvasText",kind:130},pdfBugEnabled:{value:!1,kind:130},printResolution:{value:150,kind:2},sidebarViewOnLoad:{value:-1,kind:130},scrollModeOnLoad:{value:-1,kind:130},spreadModeOnLoad:{value:-1,kind:130},textLayerMode:{value:1,kind:130},viewOnLoad:{value:0,kind:130},cMapPacked:{value:!0,kind:4},cMapUrl:{value:"../web/cmaps/",kind:4},disableAutoFetch:{value:!1,kind:132},disableFontFace:{value:!1,kind:132},disableRange:{value:!1,kind:132},disableStream:{value:!1,kind:132},docBaseUrl:{value:"",kind:4},enableHWA:{value:!0,kind:134},enableXfa:{value:!0,kind:132},fontExtraProperties:{value:!1,kind:4},isEvalSupported:{value:!0,kind:4},isOffscreenCanvasSupported:{value:!0,kind:4},maxImageSize:{value:-1,kind:4},pdfBug:{value:!1,kind:4},standardFontDataUrl:{value:"../web/standard_fonts/",kind:4},useSystemFonts:{value:void 0,kind:4,type:An.BOOLEAN+An.UNDEFINED},verbosity:{value:1,kind:4},workerPort:{value:null,kind:8},workerSrc:{value:"../build/pdf.worker.mjs",kind:8},defaultUrl:{value:"compressed.tracemonkey-pldi-09.pdf",kind:2},sandboxBundleSrc:{value:"../build/pdf.sandbox.mjs",kind:2},viewerCssTheme:{value:0,kind:130},enableFakeMLManager:{value:!0,kind:2},disablePreferences:{value:!1,kind:2}};class Ic{static eventBus;static#t=new Map;static{for(const t in zt)this.#t.set(t,zt[t].value);for(const[t,e]of vn)this.#t.set(t,e);this._hasInvokedSet=!1,this._checkDisablePreferences=()=>!!this.get("disablePreferences")||(this._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.'),!1)}static get(t){return this.#t.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const n in zt){const s=zt[n];t&&!(t&s.kind)||(i[n]=e?s.value:this.#t.get(n))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){let i;this._hasInvokedSet||=!0;for(const n in t){const s=zt[n],r=t[n];if(!s||!(typeof r==typeof s.value||An[(typeof r).toUpperCase()]&s.type))continue;const{kind:a}=s;e&&!(1&a||128&a)||(this.eventBus&&16&a&&(i||=new Map).set(n,r),this.#t.set(n,r))}if(i)for(const[n,s]of i)this.eventBus.dispatch(n.toLowerCase(),{source:this,value:s})}}class kc{#t=null;constructor(t){this.pageIndex=t.pageIndex}render(){var t=this;return(0,x.A)(function*(e="display"){"display"!==e||t.#t||t._cancelled||(t.#t=new Ch({pageIndex:t.pageIndex}))}).apply(this,arguments)}cancel(){this._cancelled=!0,this.#t&&(this.#t.destroy(),this.#t=null)}setParent(t){this.#t?.setParent(t)}getDrawLayer(){return this.#t}}const pr={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},Dc=/^H(\d+)$/;class gr{#t;#e=null;#i;#n=new Map;#r;#s=null;constructor(t,e){this.#t=t.getStructTree(),this.#r=e}render(){var t=this;return(0,x.A)(function*(){if(t.#i)return t.#i;const{promise:e,resolve:i,reject:n}=Promise.withResolvers();t.#i=e;try{t.#e=t.#c(yield t.#t)}catch(s){n(s)}return t.#t=null,t.#e?.classList.add("structTree"),i(t.#e),e})()}getAriaAttributes(t){var e=this;return(0,x.A)(function*(){try{return yield e.render(),e.#n.get(t)}catch{}return null})()}hide(){this.#e&&!this.#e.hidden&&(this.#e.hidden=!0)}show(){this.#e?.hidden&&(this.#e.hidden=!1)}#a(t,e){const{alt:i,id:n,lang:s}=t;if(void 0!==i){let r=!1;const a=Ve(i);for(const l of t.children)if("annotation"===l.type){let h=this.#n.get(l.id);h||(h=new Map,this.#n.set(l.id,h)),h.set("aria-label",a),r=!0}r||e.setAttribute("aria-label",a)}void 0!==n&&e.setAttribute("aria-owns",n),void 0!==s&&e.setAttribute("lang",Ve(s,!0))}#l(t,e){const{alt:i,bbox:n,children:s}=t,r=s?.[0];if(!this.#r||!i||!n||"content"!==r?.type)return!1;const{id:a}=r;if(!a)return!1;e.setAttribute("aria-owns",a);const l=document.createElement("span");(this.#s||=new Map).set(a,l),l.setAttribute("role","img"),l.setAttribute("aria-label",Ve(i));const{pageHeight:h,pageX:c,pageY:d}=this.#r,u="calc(var(--scale-factor)*",{style:f}=l;return f.width=`${u}${n[2]-n[0]}px)`,f.height=`${u}${n[3]-n[1]}px)`,f.left=`${u}${n[0]-c}px)`,f.top=`${u}${h-n[3]+d}px)`,!0}addElementsToTextLayer(){if(this.#s){for(const[t,e]of this.#s)document.getElementById(t)?.append(e);this.#s.clear(),this.#s=null}}#c(t){if(!t)return null;const e=document.createElement("span");if("role"in t){const{role:i}=t,n=i.match(Dc);if(n?(e.setAttribute("role","heading"),e.setAttribute("aria-level",n[1])):pr[i]&&e.setAttribute("role",pr[i]),"Figure"===i&&this.#l(t,e))return e}if(this.#a(t,e),t.children)if(1===t.children.length&&"id"in t.children[0])this.#a(t.children[0],e);else for(const i of t.children)e.append(this.#c(i));return e}}class We{#t=!1;#e=null;#i=new Map;#n=new Map;setTextMapping(t){this.#e=t}static#r(t,e){const i=t.getBoundingClientRect(),n=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===n.width&&0===n.height)return-1;const a=i.y+i.height/2,c=n.y+n.height/2;return a<=n.y&&c>=i.y+i.height?-1:c<=i.y&&a>=n.y+n.height?1:i.x+i.width/2-(n.x+n.width/2)}enable(){if(this.#t)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#e)throw new Error("Text divs and strings have not been set.");if(this.#t=!0,this.#e=this.#e.slice(),this.#e.sort(We.#r),this.#i.size>0){const t=this.#e;for(const[e,i]of this.#i)document.getElementById(e)?this.#s(e,t[i]):this.#i.delete(e)}for(const[t,e]of this.#n)this.addPointerInTextLayer(t,e);this.#n.clear()}disable(){this.#t&&(this.#n.clear(),this.#e=null,this.#t=!1)}removePointerInTextLayer(t){if(!this.#t)return void this.#n.delete(t);const e=this.#e;if(!e||0===e.length)return;const{id:i}=t,n=this.#i.get(i);if(void 0===n)return;const s=e[n];this.#i.delete(i);let r=s.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter(a=>a!==i).join(" "),r?s.setAttribute("aria-owns",r):(s.removeAttribute("aria-owns"),s.setAttribute("role","presentation")))}#s(t,e){const i=e.getAttribute("aria-owns");i?.includes(t)||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")}addPointerInTextLayer(t,e){const{id:i}=t;if(!i)return null;if(!this.#t)return this.#n.set(t,e),null;e&&this.removePointerInTextLayer(t);const n=this.#e;if(!n||0===n.length)return null;const s=je(n,h=>We.#r(t,h)<0),r=Math.max(0,s-1),a=n[r];this.#s(i,a),this.#i.set(i,r);const l=a.parentNode;return l?.classList.contains("markedContent")?l.id:null}moveElementInDOM(t,e,i,n){const s=this.addPointerInTextLayer(i,n);if(!t.hasChildNodes())return t.append(e),s;const r=Array.from(t.childNodes).filter(h=>h!==e);if(0===r.length)return s;const a=i||e,l=je(r,h=>We.#r(a,h)<0);return 0===l?r[0].before(e):r[l-1].after(e),s}}class Oc{#t=null;constructor({findController:t,eventBus:e,pageIndex:i}){this.findController=t,this.matches=[],this.eventBus=e,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(t,e){this.textDivs=t,this.textContentItemsStr=e}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(this.enabled)throw new Error("TextHighlighter is already enabled.");this.enabled=!0,this.#t||(this.#t=new AbortController,this.eventBus._on("updatetextlayermatches",t=>{(t.pageIndex===this.pageIdx||-1===t.pageIndex)&&this._updateMatches()},{signal:this.#t.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#t?.abort(),this.#t=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let n=0,s=0;const r=i.length-1,a=[];for(let l=0,h=t.length;l<h;l++){let c=t[l];for(;n!==r&&c>=s+i[n].length;)s+=i[n].length,n++;n===i.length&&console.error("Could not find a matching mapping");const d={begin:{divIdx:n,offset:c-s}};for(c+=e[l];n!==r&&c>s+i[n].length;)s+=i[n].length,n++;d.end={divIdx:n,offset:c-s},a.push(d)}return a}_renderMatches(t){if(0===t.length)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:n,textDivs:s}=this,r=i===e.selected.pageIdx,a=e.selected.matchIdx;let h=null;function d(m,A){const v=m.divIdx;return s[v].textContent="",u(v,0,m.offset,A)}function u(m,A,v,w){let E=s[m];if(E.nodeType===Node.TEXT_NODE){const L=document.createElement("span");E.before(L),L.append(E),s[m]=L,E=L}const C=n[m].substring(A,v),M=document.createTextNode(C);if(w){const L=document.createElement("span");if(L.className=`${w} appended`,L.append(M),E.append(L),w.includes("selected")){const{left:y}=L.getClientRects()[0];return y-E.getBoundingClientRect().left}return 0}return E.append(M),0}let f=a,p=f+1;if(e.state.highlightAll)f=0,p=t.length;else if(!r)return;let g=-1,_=-1;for(let m=f;m<p;m++){const A=t[m],v=A.begin;if(v.divIdx===g&&v.offset===_)continue;g=v.divIdx,_=v.offset;const w=A.end,E=r&&m===a,C=E?" selected":"";let M=0;if(h&&v.divIdx===h.divIdx?u(h.divIdx,h.offset,v.offset):(null!==h&&u(h.divIdx,h.offset,void 0),d(v)),v.divIdx===w.divIdx)M=u(v.divIdx,v.offset,w.offset,"highlight"+C);else{M=u(v.divIdx,v.offset,void 0,"highlight begin"+C);for(let L=v.divIdx+1,y=w.divIdx;L<y;L++)s[L].className="highlight middle"+C;d(w,"highlight end"+C)}h=w,E&&e.scrollMatchIntoView({element:s[v.divIdx],selectedLeft:M,pageIndex:i,matchIndex:a})}h&&u(h.divIdx,h.offset,void 0)}_updateMatches(t=!1){if(!this.enabled&&!t)return;const{findController:e,matches:i,pageIdx:n}=this,{textContentItemsStr:s,textDivs:r}=this;let a=-1;for(const c of i){for(let u=Math.max(a,c.begin.divIdx),f=c.end.divIdx;u<=f;u++){const p=r[u];p.textContent=s[u],p.className=""}a=c.end.divIdx+1}e?.highlightMatches&&!t&&(this.matches=this._convertMatches(e.pageMatches[n]||null,e.pageMatchesLength[n]||null),this._renderMatches(this.matches))}}class ve{#t=!1;#e=null;#i=!1;#n=null;static#r=new Map;static#s=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:n=!1,onAppend:s=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#t=!0===n,this.#e=s,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}render(t){var e=this;return(0,x.A)(function*(i,n=null){if(e.#i&&e.#n)return e.#n.update({viewport:i,onBefore:e.hide.bind(e)}),void e.show();e.cancel(),e.#n=new kh({textContentSource:e.pdfPage.streamTextContent(n||{includeMarkedContent:!0,disableNormalization:!0}),container:e.div,viewport:i});const{textDivs:s,textContentItemsStr:r}=e.#n;e.highlighter?.setTextMapping(s,r),e.accessibilityManager?.setTextMapping(s),yield e.#n.render(),e.#i=!0;const a=document.createElement("div");a.className="endOfContent",e.div.append(a),e.#a(a),e.#e?.(e.div),e.highlighter?.enable(),e.accessibilityManager?.enable()}).apply(this,arguments)}hide(){!this.div.hidden&&this.#i&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#i&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#n?.cancel(),this.#n=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),ve.#l(this.div)}#a(t){const{div:e}=this;e.addEventListener("mousedown",()=>{e.classList.add("selecting")}),e.addEventListener("copy",i=>{if(!this.#t){const n=document.getSelection();i.clipboardData.setData("text/plain",Ve(Lh(n.toString())))}hn(i)}),ve.#r.set(e,t),ve.#c()}static#l(t){this.#r.delete(t),0===this.#r.size&&(this.#s?.abort(),this.#s=null)}static#c(){if(this.#s)return;this.#s=new AbortController;const{signal:t}=this.#s,e=(r,a)=>{a.append(r),r.style.width="",r.style.height="",a.classList.remove("selecting")};let i=!1;var n,s;document.addEventListener("pointerdown",()=>{i=!0},{signal:t}),document.addEventListener("pointerup",()=>{i=!1,this.#r.forEach(e)},{signal:t}),window.addEventListener("blur",()=>{i=!1,this.#r.forEach(e)},{signal:t}),document.addEventListener("keyup",()=>{i||this.#r.forEach(e)},{signal:t}),document.addEventListener("selectionchange",()=>{const r=document.getSelection();if(0===r.rangeCount)return void this.#r.forEach(e);const a=new Set;for(let f=0;f<r.rangeCount;f++){const p=r.getRangeAt(f);for(const g of this.#r.keys())!a.has(g)&&p.intersectsNode(g)&&a.add(g)}for(const[f,p]of this.#r)a.has(f)?f.classList.add("selecting"):e(p,f);if(n??="none"===getComputedStyle(this.#r.values().next().value).getPropertyValue("-moz-user-select"),n)return;const l=r.getRangeAt(0),h=s&&(0===l.compareBoundaryPoints(Range.END_TO_END,s)||0===l.compareBoundaryPoints(Range.START_TO_END,s));let c=h?l.startContainer:l.endContainer;c.nodeType===Node.TEXT_NODE&&(c=c.parentNode);const d=c.parentElement?.closest(".textLayer"),u=this.#r.get(d);u&&(u.style.width=d.style.width,u.style.height=d.style.height,c.parentElement.insertBefore(u,h?c:c.nextSibling)),s=l.cloneRange()},{signal:t})}}class mr{constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:n=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=n,this.div=null,this._cancelled=!1}render(t){var e=this;return(0,x.A)(function*(i,n="display"){if("print"===n){const a={viewport:i.clone({dontFlip:!0}),div:e.div,xfaHtml:e.xfaHtml,annotationStorage:e.annotationStorage,linkService:e.linkService,intent:n};return e.div=document.createElement("div"),a.div=e.div,cn.render(a)}const s=yield e.pdfPage.getXfa();if(e._cancelled||!s)return{textDivs:[]};const r={viewport:i.clone({dontFlip:!0}),div:e.div,xfaHtml:s,annotationStorage:e.annotationStorage,linkService:e.linkService,intent:n};return e.div?cn.update(r):(e.div=document.createElement("div"),r.div=e.div,cn.render(r))}).apply(this,arguments)}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const Nc={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new on}},Fc=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class br{#t=$t.ENABLE_FORMS;#e=null;#i=!1;#n=!1;#r=!1;#s=null;#a=null;#l=null;#c=null;#h=1;#u=1;#d=null;#f=tt.INITIAL;#o=1;#p={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#m=[null,null,null,null];constructor(t){const e=t.container,i=t.defaultViewport;this.id=t.id,this.renderingId="page"+this.id,this.#s=t.layerProperties||Nc,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=t.scale||1,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=t.optionalContentConfigPromise||null,this.#o=t.textLayerMode??1,this.#t=t.annotationMode??$t.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.maxCanvasPixels=t.maxCanvasPixels??Ic.get("maxCanvasPixels"),this.pageColors=t.pageColors||null,this.#i=t.enableHWA||!1,this.eventBus=t.eventBus,this.renderingQueue=t.renderingQueue,this.l10n=t.l10n,this.l10n||=new qt,this.renderTask=null,this.resume=null,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null;const n=document.createElement("div");if(n.className="page",n.setAttribute("data-page-number",this.id),n.setAttribute("role","region"),n.setAttribute("data-l10n-id","pdfjs-page-landmark"),n.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=n,this.#b(),e?.append(n),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*Xt.PDF_TO_CSS_UNITS),this.pageColors?.background&&e?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:s}=t;s&&s.then(r=>{s===this._optionalContentConfigPromise&&(this.#p.initialOptionalContent=r.hasInitialVisibility)}),t.l10n||this.l10n.translate(this.div)}}#g(t,e){const i=Fc.get(e),n=this.#m[i];if(this.#m[i]=t,n)n.replaceWith(t);else{for(let s=i-1;s>=0;s--){const r=this.#m[s];if(r)return void r.after(t)}this.div.prepend(t)}}get renderingState(){return this.#f}set renderingState(t){if(t!==this.#f)switch(this.#f=t,this.#a&&(clearTimeout(this.#a),this.#a=null),t){case tt.PAUSED:this.div.classList.remove("loading");break;case tt.RUNNING:this.div.classList.add("loadingIcon"),this.#a=setTimeout(()=>{this.div.classList.add("loading"),this.#a=null},0);break;case tt.INITIAL:case tt.FINISHED:this.div.classList.remove("loadingIcon","loading")}}#b(){const{viewport:t}=this;if(this.pdfPage){if(this.#c===t.rotation)return;this.#c=t.rotation}Ih(this.div,t,!0,!1)}setPdfPage(t){this._isStandalone&&("CanvasText"===this.pageColors?.foreground||"Canvas"===this.pageColors?.background)&&(this._container?.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=t,this.pdfPageRotate=t.rotate,this.viewport=t.getViewport({scale:this.scale*Xt.PDF_TO_CSS_UNITS,rotation:(this.rotation+this.pdfPageRotate)%360}),this.#b(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return Ai(this,"_textHighlighter",new Oc({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#s.findController}))}#_(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}#v(){var t=this;return(0,x.A)(function*(){let e=null;try{yield t.annotationLayer.render(t.viewport,{structTreeLayer:t.structTreeLayer},"display")}catch(i){console.error("#renderAnnotationLayer:",i),e=i}finally{t.#_("annotationlayerrendered",e)}})()}#A(){var t=this;return(0,x.A)(function*(){let e=null;try{yield t.annotationEditorLayer.render(t.viewport,"display")}catch(i){console.error("#renderAnnotationEditorLayer:",i),e=i}finally{t.#_("annotationeditorlayerrendered",e)}})()}#y(){var t=this;return(0,x.A)(function*(){try{yield t.drawLayer.render("display")}catch(e){console.error("#renderDrawLayer:",e)}})()}#x(){var t=this;return(0,x.A)(function*(){let e=null;try{const i=yield t.xfaLayer.render(t.viewport,"display");i?.textDivs&&t._textHighlighter&&t.#E(i.textDivs)}catch(i){console.error("#renderXfaLayer:",i),e=i}finally{t.xfaLayer?.div&&(t.l10n.pause(),t.#g(t.xfaLayer.div,"xfaLayer"),t.l10n.resume()),t.#_("xfalayerrendered",e)}})()}#S(){var t=this;return(0,x.A)(function*(){if(!t.textLayer)return;let e=null;try{yield t.textLayer.render(t.viewport)}catch(i){if(i instanceof yh)return;console.error("#renderTextLayer:",i),e=i}t.#_("textlayerrendered",e),t.#M()})()}#M(){var t=this;return(0,x.A)(function*(){if(!t.textLayer)return;const e=yield t.structTreeLayer?.render();e&&(t.l10n.pause(),t.structTreeLayer?.addElementsToTextLayer(),t.canvas&&e.parentNode!==t.canvas&&t.canvas.append(e),t.l10n.resume()),t.structTreeLayer?.show()})()}#E(t){var e=this;return(0,x.A)(function*(){const i=yield e.pdfPage.getTextContent(),n=[];for(const s of i.items)n.push(s.str);e._textHighlighter.setTextMapping(t,n),e._textHighlighter.enable()})()}#T(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#l=null)}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:n=!1,keepCanvasWrapper:s=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:n}),this.renderingState=tt.INITIAL;const r=this.div,a=r.childNodes,l=t&&this.annotationLayer?.div||null,h=e&&this.annotationEditorLayer?.div||null,c=i&&this.xfaLayer?.div||null,d=n&&this.textLayer?.div||null,u=s&&this.#e||null;for(let f=a.length-1;f>=0;f--){const p=a[f];switch(p){case l:case h:case c:case d:case u:continue}p.remove();const g=this.#m.indexOf(p);g>=0&&(this.#m[g]=null)}r.removeAttribute("data-loaded"),l&&this.annotationLayer.hide(),h&&this.annotationEditorLayer.hide(),c&&this.xfaLayer.hide(),d&&this.textLayer.hide(),this.structTreeLayer?.hide(),!s&&this.#e&&(this.#e=null,this.#T())}toggleEditingMode(t){this.hasEditableAnnotations()&&(this.#r=t,this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0}))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:n=-1}){if(this.scale=t||this.scale,"number"==typeof e&&(this.rotation=e),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then(r=>{i===this._optionalContentConfigPromise&&(this.#p.initialOptionalContent=r.hasInitialVisibility)})),this.#p.directDrawing=!0,this.viewport=this.viewport.clone({scale:this.scale*Xt.PDF_TO_CSS_UNITS,rotation:(this.rotation+this.pdfPageRotate)%360}),this.#b(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let r=!1;if(this.#n)if(0===this.maxCanvasPixels)r=!0;else if(this.maxCanvasPixels>0){const{width:l,height:h}=this.viewport,{sx:c,sy:d}=this.outputScale;r=(Math.floor(l)*c|0)*(Math.floor(h)*d|0)>this.maxCanvasPixels}const a=n>=0&&n<1e3;if(a||r){if(a&&!r&&this.renderingState!==tt.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:n}),this.renderingState=tt.FINISHED,this.#p.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!a,hideTextLayer:a}),a)return;return void this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#d})}}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:n=!1,cancelExtraDelay:s=0}={}){this.renderTask&&(this.renderTask.cancel(s),this.renderTask=null),this.resume=null,this.textLayer&&(!n||!this.textLayer.div)&&(this.textLayer.cancel(),this.textLayer=null),this.annotationLayer&&(!t||!this.annotationLayer.div)&&(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),this.annotationEditorLayer&&(!e||!this.annotationEditorLayer.div)&&(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),this.xfaLayer&&(!i||!this.xfaLayer.div)&&(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:n=!1,hideTextLayer:s=!1}){const{canvas:r}=this;if(!r)return;const a=this.#l;if(this.viewport!==a){const l=(360+this.viewport.rotation-a.rotation)%360;if(90===l||270===l){const{width:h,height:c}=this.viewport;r.style.transform=`rotate(${l}deg) scale(${c/h},${h/c})`}else r.style.transform=0===l?"":`rotate(${l}deg)`}t&&this.annotationLayer&&this.#v(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#y(),this.#A()),i&&this.xfaLayer&&this.#x(),this.textLayer&&(s?(this.textLayer.hide(),this.structTreeLayer?.hide()):n&&this.#S())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}#P(t){var e=this;return(0,x.A)(function*(i,n=null){if(i===e.renderTask&&(e.renderTask=null),n instanceof ln)e.#d=null;else if(e.#d=n,e.renderingState=tt.FINISHED,e.#p.regularAnnotations=!i.separateAnnots,e.eventBus.dispatch("pagerendered",{source:e,pageNumber:e.id,cssTransform:!1,timestamp:performance.now(),error:e.#d}),n)throw n}).apply(this,arguments)}draw(){var t=this;return(0,x.A)(function*(){t.renderingState!==tt.INITIAL&&(console.error("Must be in new state before drawing"),t.reset());const{div:e,l10n:i,pageColors:n,pdfPage:s,viewport:r}=t;if(!s)throw t.renderingState=tt.FINISHED,new Error("pdfPage is not loaded");t.renderingState=tt.RUNNING;let a=t.#e;if(a||(a=t.#e=document.createElement("div"),a.classList.add("canvasWrapper"),t.#g(a,"canvasWrapper")),!t.textLayer&&0!==t.#o&&!s.isPureXfa&&(t._accessibilityManager||=new We,t.textLayer=new ve({pdfPage:s,highlighter:t._textHighlighter,accessibilityManager:t._accessibilityManager,enablePermissions:2===t.#o,onAppend:I=>{t.l10n.pause(),t.#g(I,"textLayer"),t.l10n.resume()}})),!t.annotationLayer&&t.#t!==$t.DISABLE){const{annotationStorage:I,annotationEditorUIManager:j,downloadManager:H,enableScripting:ct,fieldObjectsPromise:D,hasJSActionsPromise:O,linkService:xt}=t.#s;t._annotationCanvasMap||=new Map,t.annotationLayer=new $s({pdfPage:s,annotationStorage:I,imageResourcesPath:t.imageResourcesPath,renderForms:t.#t===$t.ENABLE_FORMS,linkService:xt,downloadManager:H,enableScripting:ct,hasJSActionsPromise:O,fieldObjectsPromise:D,annotationCanvasMap:t._annotationCanvasMap,accessibilityManager:t._accessibilityManager,annotationEditorUIManager:j,onAppend:Lt=>{t.#g(Lt,"annotationLayer")}})}const{width:h,height:c}=r,d=document.createElement("canvas");d.setAttribute("role","presentation");const f=t.canvas,p=!(f||n?.background&&n?.foreground);t.canvas=d,t.#l=r;let g=I=>{if(p)return a.prepend(d),void(g=null);I&&(f?(f.replaceWith(d),f.width=f.height=0):a.prepend(d),g=null)};const _=d.getContext("2d",{alpha:!1,willReadFrequently:!t.#i}),m=t.outputScale=new Rh;if(0===t.maxCanvasPixels){const I=1/t.scale;m.sx*=I,m.sy*=I,t.#n=!0}else if(t.maxCanvasPixels>0){const j=Math.sqrt(t.maxCanvasPixels/(h*c));m.sx>j||m.sy>j?(m.sx=j,m.sy=j,t.#n=!0):t.#n=!1}const A=Os(m.sx),v=Os(m.sy),w=d.width=gi(mi(h*m.sx),A[0]),E=d.height=gi(mi(c*m.sy),v[0]),C=gi(mi(h),A[1]),M=gi(mi(c),v[1]);m.sx=w/C,m.sy=E/M,t.#h!==A[1]&&(e.style.setProperty("--scale-round-x",`${A[1]}px`),t.#h=A[1]),t.#u!==v[1]&&(e.style.setProperty("--scale-round-y",`${v[1]}px`),t.#u=v[1]);const y={canvasContext:_,transform:m.scaled?[m.sx,0,0,m.sy,0,0]:null,viewport:r,annotationMode:t.#t,optionalContentConfigPromise:t._optionalContentConfigPromise,annotationCanvasMap:t._annotationCanvasMap,pageColors:n,isEditing:t.#r},P=t.renderTask=s.render(y);P.onContinue=I=>{if(g?.(!1),t.renderingQueue&&!t.renderingQueue.isHighestPriority(t))return t.renderingState=tt.PAUSED,void(t.resume=()=>{t.renderingState=tt.RUNNING,I()});I()};const R=P.promise.then((0,x.A)(function*(){g?.(!0),yield t.#P(P),t.structTreeLayer||=new gr(s,r.rawDims),t.#S(),t.annotationLayer&&(yield t.#v());const{annotationEditorUIManager:I}=t.#s;I&&(t.drawLayer||=new kc({pageIndex:t.id}),yield t.#y(),t.drawLayer.setParent(a),t.annotationEditorLayer||=new Rc({uiManager:I,pdfPage:s,l10n:i,structTreeLayer:t.structTreeLayer,accessibilityManager:t._accessibilityManager,annotationLayer:t.annotationLayer?.annotationLayer,textLayer:t.textLayer,drawLayer:t.drawLayer.getDrawLayer(),onAppend:j=>{t.#g(j,"annotationEditorLayer")}}),t.#A())}),I=>(I instanceof ln?(f?.remove(),t.#T()):g?.(!0),t.#P(P,I)));if(s.isPureXfa){if(!t.xfaLayer){const{annotationStorage:I,linkService:j}=t.#s;t.xfaLayer=new mr({pdfPage:s,annotationStorage:I,linkService:j})}t.#x()}return e.setAttribute("data-loaded",!0),t.eventBus.dispatch("pagerender",{source:t,pageNumber:t.id}),R})()}setPageLabel(t){this.pageLabel="string"==typeof t?t:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:t,initialOptionalContent:e,regularAnnotations:i}=this.#p;return t&&e&&i?this.canvas:null}}function wn(){return(wn=(0,x.A)(function*(o){const e="".split("#",1)[0];let{info:i,metadata:n,contentDispositionFilename:s,contentLength:r}=yield o.getMetadata();if(!r){const{length:a}=yield o.getDownloadInfo();r=a}return{...i,baseURL:e,filesize:r,filename:s||Th(""),metadata:n?.getRaw(),authors:n?.get("dc:creator"),numPages:o.numPages,URL:""}})).apply(this,arguments)}class Vc{constructor(t){this._ready=new Promise((e,i)=>{import(t).then(s=>{e(s.QuickJSSandbox())}).catch(i)})}createSandbox(t){var e=this;return(0,x.A)(function*(){(yield e._ready).create(t)})()}dispatchEventInSandbox(t){var e=this;return(0,x.A)(function*(){const i=yield e._ready;setTimeout(()=>i.dispatchEvent(t),0)})()}destroySandbox(){var t=this;return(0,x.A)(function*(){(yield t._ready).nukeSandbox()})()}}class jc{#t=null;#e=null;#i=null;#n=null;#r=null;#s=null;#a=null;#l=null;#c=!1;#h=null;#u=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#r=t,this.#s=e,this.#i=i}setViewer(t){this.#l=t}setDocument(t){var e=this;return(0,x.A)(function*(){if(e.#a&&(yield e.#m()),e.#a=t,!t)return;const[i,n,s]=yield Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!i&&!s)return void(yield e.#m());if(t!==e.#a)return;try{e.#h=e.#p()}catch(l){return console.error("setDocument:",l),void(yield e.#m())}const r=e.#r;e.#n=new AbortController;const{signal:a}=e.#n;r._on("updatefromsandbox",l=>{l?.source===window&&e.#d(l.detail)},{signal:a}),r._on("dispatcheventinsandbox",l=>{e.#h?.dispatchEventInSandbox(l.detail)},{signal:a}),r._on("pagechanging",({pageNumber:l,previous:h})=>{l!==h&&(e.#o(h),e.#f(l))},{signal:a}),r._on("pagerendered",({pageNumber:l})=>{e._pageOpenPending.has(l)&&l===e.#l.currentPageNumber&&e.#f(l)},{signal:a}),r._on("pagesdestroy",(0,x.A)(function*(){yield e.#o(e.#l.currentPageNumber),yield e.#h?.dispatchEventInSandbox({id:"doc",name:"WillClose"}),e.#t?.resolve()}),{signal:a});try{const l=yield e.#i(t);if(t!==e.#a)return;yield e.#h.createSandbox({objects:i,calculationOrder:n,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...l,actions:s}}),r.dispatch("sandboxcreated",{source:e})}catch(l){return console.error("setDocument:",l),void(yield e.#m())}yield e.#h?.dispatchEventInSandbox({id:"doc",name:"Open"}),yield e.#f(e.#l.currentPageNumber,!0),Promise.resolve().then(()=>{t===e.#a&&(e.#c=!0)})})()}dispatchWillSave(){var t=this;return(0,x.A)(function*(){return t.#h?.dispatchEventInSandbox({id:"doc",name:"WillSave"})})()}dispatchDidSave(){var t=this;return(0,x.A)(function*(){return t.#h?.dispatchEventInSandbox({id:"doc",name:"DidSave"})})()}dispatchWillPrint(){var t=this;return(0,x.A)(function*(){if(t.#h){yield t.#u?.promise,t.#u=Promise.withResolvers();try{yield t.#h.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(e){throw t.#u.resolve(),t.#u=null,e}yield t.#u.promise}})()}dispatchDidPrint(){var t=this;return(0,x.A)(function*(){return t.#h?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})})()}get destroyPromise(){return this.#e?.promise||null}get ready(){return this.#c}get _pageOpenPending(){return Ai(this,"_pageOpenPending",new Set)}get _visitedPages(){return Ai(this,"_visitedPages",new Map)}#d(t){var e=this;return(0,x.A)(function*(){const i=e.#l,n=i.isInPresentationMode||i.isChangingPresentationMode,{id:s,siblings:r,command:a,value:l}=t;if(!s){switch(a){case"clear":console.clear();break;case"error":console.error(l);break;case"layout":if(!n){const c=function Zl(o){let t=$.VERTICAL,e=mt.NONE;switch(o){case"SinglePage":t=$.PAGE;break;case"OneColumn":break;case"TwoPageLeft":t=$.PAGE;case"TwoColumnLeft":e=mt.ODD;break;case"TwoPageRight":t=$.PAGE;case"TwoColumnRight":e=mt.EVEN}return{scrollMode:t,spreadMode:e}}(l);i.spreadMode=c.spreadMode}break;case"page-num":i.currentPageNumber=l+1;break;case"print":yield i.pagesPromise,e.#r.dispatch("print",{source:e});break;case"println":console.log(l);break;case"zoom":n||(i.currentScaleValue=l);break;case"SaveAs":e.#r.dispatch("download",{source:e});break;case"FirstPage":i.currentPageNumber=1;break;case"LastPage":i.currentPageNumber=i.pagesCount;break;case"NextPage":i.nextPage();break;case"PrevPage":i.previousPage();break;case"ZoomViewIn":n||i.increaseScale();break;case"ZoomViewOut":n||i.decreaseScale();break;case"WillPrintFinished":e.#u?.resolve(),e.#u=null}return}if(n&&t.focus)return;delete t.id,delete t.siblings;const h=r?[s,...r]:[s];for(const c of h){const d=document.querySelector(`[data-element-id="${c}"]`);d?d.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):e.#a?.annotationStorage.setValue(c,t)}})()}#f(t){var e=this;return(0,x.A)(function*(i,n=!1){const s=e.#a,r=e._visitedPages;if(n&&(e.#t=Promise.withResolvers()),!e.#t)return;const a=e.#l.getPageView(i-1);if(a?.renderingState!==tt.FINISHED)return void e._pageOpenPending.add(i);e._pageOpenPending.delete(i);const l=(0,x.A)(function*(){const h=yield r.has(i)?null:a.pdfPage?.getJSActions();s===e.#a&&(yield e.#h?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:i,actions:h}))})();r.set(i,l)}).apply(this,arguments)}#o(t){var e=this;return(0,x.A)(function*(){const i=e.#a,n=e._visitedPages;if(!e.#t||e._pageOpenPending.has(t))return;const s=n.get(t);s&&(n.set(t,null),yield s,i===e.#a&&(yield e.#h?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))})()}#p(){if(this.#e=Promise.withResolvers(),this.#h)throw new Error("#initScripting: Scripting already exists.");return this.#s.createScripting()}#m(){var t=this;return(0,x.A)(function*(){if(!t.#h)return t.#a=null,void t.#e?.resolve();t.#t&&(yield Promise.race([t.#t.promise,new Promise(e=>{setTimeout(e,1e3)})]).catch(()=>{}),t.#t=null),t.#a=null;try{yield t.#h.destroySandbox()}catch{}t.#u?.reject(new Error("Scripting destroyed.")),t.#u=null,t.#n?.abort(),t.#n=null,t._pageOpenPending.clear(),t._visitedPages.clear(),t.#h=null,t.#c=!1,t.#e?.resolve()})()}}class Hc extends jc{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})}),t.externalServices||={createScripting:()=>new Vc(t.sandboxBundleSrc)},t.docProperties||=e=>function Bc(o){return wn.apply(this,arguments)}(e),super(t)}}class Uc{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1,Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),!this.pdfViewer.forceRendering(t)&&(this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4)))}getHighestPriority(t,e,i,n=!1){const s=t.views,r=s.length;if(0===r)return null;for(let d=0;d<r;d++){const u=s[d].view;if(!this.isViewFinished(u))return u}const a=t.first.id,l=t.last.id;if(l-a+1>r){const d=t.ids;for(let u=1,f=l-a;u<f;u++){const p=i?a+u:l-u;if(d.has(p))continue;const g=e[p-1];if(!this.isViewFinished(g))return g}}let h=i?l:a-2,c=e[h];return c&&!this.isViewFinished(c)||n&&(h+=i?1:-1,c=e[h],c&&!this.isViewFinished(c))?c:null}isViewFinished(t){return t.renderingState===tt.FINISHED}renderView(t){switch(t.renderingState){case tt.FINISHED:return!1;case tt.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case tt.RUNNING:this.highestPriorityPage=t.renderingId;break;case tt.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(e=>{e instanceof ln||console.error("renderView:",e)})}return!0}}function vr(o){return Object.values(Ct).includes(o)&&o!==Ct.DISABLE}class Wc{#t=new Set;#e=0;constructor(t){this.#e=t}push(t){const e=this.#t;e.has(t)&&e.delete(t),e.add(t),e.size>this.#e&&this.#i()}resize(t,e=null){this.#e=t;const i=this.#t;if(e){const n=i.size;let s=1;for(const r of i)if(e.has(r.id)&&(i.delete(r),i.add(r)),++s>n)break}for(;i.size>this.#e;)this.#i()}has(t){return this.#t.has(t)}[Symbol.iterator](){return this.#t.keys()}#i(){const t=this.#t.keys().next().value;t?.destroy(),this.#t.delete(t)}}class Ar{#t=null;#e=null;#i=null;#n=Ct.NONE;#r=null;#s=$t.ENABLE_FORMS;#a=null;#l=null;#c=!1;#h=!1;#u=!1;#d=!1;#f=!1;#o=null;#p=null;#m=null;#g=null;#b=!1;#_=null;#v=!1;#A=0;#y=new ResizeObserver(this.#W.bind(this));#x=null;#S=null;#M=!0;#E=1;constructor(t){const e="4.10.38";if(Gs!==e)throw new Error(`The API version "${Gs}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,"DIV"!==this.container?.tagName||"DIV"!==this.viewer?.tagName)throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.");this.#y.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new on,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#e=t.altTextManager||null,this.#l=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=n=>this._getVisiblePages().ids.has(n)),this._scriptingManager=t.scriptingManager||null,this.#E=t.textLayerMode??1,this.#s=t.annotationMode??$t.ENABLE_FORMS,this.#n=t.annotationEditorMode??Ct.NONE,this.#i=t.annotationEditorHighlightColors||null,this.#h=!0===t.enableHighlightFloatingButton,this.#d=!0===t.enableUpdatedAddImage,this.#f=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.l10n=t.l10n,this.l10n||=new qt,this.#u=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#p=t.mlManager||null,this.#c=t.enableHWA||!1,this.#M=!1!==t.supportsPinchToZoom,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new Uc,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",()=>{this.#y.disconnect(),this.#y=null},{once:!0}),this.scroll=function Ul(o,t,e){const i=function(r){s||(s=window.requestAnimationFrame(function(){s=null;const l=o.scrollLeft,h=n.lastX;l!==h&&(n.right=l>h),n.lastX=l;const c=o.scrollTop,d=n.lastY;c!==d&&(n.down=c>d),n.lastY=c,t(n)}))},n={right:!0,down:!0,lastX:o.scrollLeft,lastY:o.scrollTop,_eventHandler:i};let s=null;return o.addEventListener("scroll",i,{useCapture:!0,signal:e}),e?.addEventListener("abort",()=>window.cancelAnimationFrame(s),{once:!0}),n}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=0,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#B(),this.eventBus._on("thumbnailrendered",({pageNumber:n,pdfPage:s})=>{this.#t.has(this._pages[n-1])||s?.cleanup()}),t.l10n||this.l10n.translate(this.container)}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#t)}get pageViewsReady(){return this._pages.every(t=>t?.pdfPage)}get renderForms(){return this.#s===$t.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(t){if(!Number.isInteger(t))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#j(),!0;if(!(0<t&&t<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,pageLabel:this._pageLabels?.[t-1]??null,previous:i}),e&&this.#j(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(t){if(!this.pdfDocument)return;let e=0|t;if(this._pageLabels){const i=this._pageLabels.indexOf(t);i>=0&&(e=i+1)}this._setCurrentPageNumber(e,!0)||console.error(`currentPageLabel: "${t}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(t){if(isNaN(t))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#k(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#k(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Ns(t))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument||((t%=360)<0&&(t+=360),this._pagesRotation===t))return;this._pagesRotation=t;const e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#k(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:t,pageNumber:e}),this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){const t=this;return Ai(this,"_layerProperties",{get annotationEditorUIManager(){return t.#r},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableScripting(){return!!t._scriptingManager},get fieldObjectsPromise(){return t.pdfDocument?.getFieldObjects()},get findController(){return t.findController},get hasJSActionsPromise(){return t.pdfDocument?.hasJSActions()},get linkService(){return t.linkService}})}#T(t){const e={annotationEditorMode:this.#n,annotationMode:this.#s,textLayerMode:this.#E};return t&&(!t.includes(vi.COPY)&&1===this.#E&&(e.textLayerMode=2),t.includes(vi.MODIFY_CONTENTS)||(e.annotationEditorMode=Ct.DISABLE),!t.includes(vi.MODIFY_ANNOTATIONS)&&!t.includes(vi.FILL_INTERACTIVE_FORMS)&&this.#s===$t.ENABLE_FORMS&&(e.annotationMode=$t.ENABLE)),e}#P(t){var e=this;return(0,x.A)(function*(){if("hidden"===document.visibilityState||!e.container.offsetParent||0===e._getVisiblePages().views.length)return;const i=Promise.withResolvers(),n=new AbortController;document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&i.resolve()},{signal:"function"==typeof AbortSignal.any?AbortSignal.any([t,n.signal]):t}),yield Promise.race([e._onePageRenderedCapability.promise,i.promise]),n.abort()})()}getAllText(){var t=this;return(0,x.A)(function*(){const e=[],i=[];for(let n=1,s=t.pdfDocument.numPages;n<=s;++n){if(t.#v)return null;i.length=0;const r=yield t.pdfDocument.getPage(n),{items:a}=yield r.getTextContent();for(const l of a)l.str&&i.push(l.str),l.hasEOL&&i.push("\n");e.push(Ve(i.join("")))}return e.join("\n")})()}#R(t,e){const i=document.getSelection(),{focusNode:n,anchorNode:s}=i;if(s&&n&&i.containsNode(this.#_)){if(this.#b||2===t)return void hn(e);this.#b=!0;const{classList:r}=this.viewer;r.add("copyAll");const a=new AbortController;window.addEventListener("keydown",l=>this.#v="Escape"===l.key,{signal:a.signal}),this.getAllText().then(function(){var l=(0,x.A)(function*(h){null!==h&&(yield navigator.clipboard.writeText(h))});return function(h){return l.apply(this,arguments)}}()).catch(l=>{console.warn(`Something goes wrong when extracting the text: ${l.message}`)}).finally(()=>{this.#b=!1,this.#v=!1,a.abort(),r.remove("copyAll")}),hn(e)}}setDocument(t){var e=this;if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#r?.destroy(),this.#r=null),this.pdfDocument=t,!t)return;const i=t.numPages,n=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),r=this.#u?t.getPermissions():Promise.resolve(),{eventBus:a,pageColors:l,viewer:h}=this;this.#o=new AbortController;const{signal:c}=this.#o;if(i>1e4){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const f=this._scrollMode=$.PAGE;a.dispatch("scrollmodechanged",{source:this,mode:f})}this._pagesCapability.promise.then(()=>{a.dispatch("pagesloaded",{source:this,pagesCount:i})},()=>{}),a._on("pagerender",f=>{const p=this._pages[f.pageNumber-1];p&&this.#t.push(p)},{signal:c});const u=f=>{f.cssTransform||(this._onePageRenderedCapability.resolve({timestamp:f.timestamp}),a._off("pagerendered",u))};a._on("pagerendered",u,{signal:c}),Promise.all([n,r]).then(([f,p])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(f),this._optionalContentConfigPromise=s;const{annotationEditorMode:g,annotationMode:_,textLayerMode:m}=this.#T(p);if(0!==m){const E=this.#_=document.createElement("div");E.id="hiddenCopyElement",h.before(E)}if("function"==typeof AbortSignal.any&&g!==Ct.DISABLE){const E=g;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):vr(E)?(this.#r=new xh(this.container,h,this.#e,a,t,l,this.#i,this.#h,this.#d,this.#f,this.#p,this.#l,this.#M),a.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#r}),E!==Ct.NONE&&(E===Ct.STAMP&&this.#p?.loadModel("altText"),this.#r.updateMode(E))):console.error(`Invalid AnnotationEditor mode: ${E}`)}const A=this._scrollMode===$.PAGE?null:h,v=this.currentScale,w=f.getViewport({scale:v*Xt.PDF_TO_CSS_UNITS});h.style.setProperty("--scale-factor",w.scale),l?.background&&h.style.setProperty("--page-bg-color",l.background),("CanvasText"===l?.foreground||"Canvas"===l?.background)&&(h.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),h.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText")));for(let E=1;E<=i;++E){const C=new br({container:A,eventBus:a,id:E,scale:v,defaultViewport:w.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:m,annotationMode:_,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,pageColors:l,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#c});this._pages.push(C)}this._pages[0]?.setPdfPage(f),this._scrollMode===$.PAGE?this.#I():this._spreadMode!==mt.NONE&&this._updateSpreadMode(),this.#P(c).then((0,x.A)(function*(){if(t!==e.pdfDocument)return;if(e.findController?.setDocument(t),e._scriptingManager?.setDocument(t),e.#_&&document.addEventListener("copy",e.#R.bind(e,m),{signal:c}),e.#r&&a.dispatch("annotationeditormodechanged",{source:e,mode:e.#n}),t.loadingParams.disableAutoFetch||i>5e3)return void e._pagesCapability.resolve();let E=i-1;if(E<=0)e._pagesCapability.resolve();else for(let C=2;C<=i;++C){const M=t.getPage(C).then(L=>{const y=e._pages[C-1];y.pdfPage||y.setPdfPage(L),0===--E&&e._pagesCapability.resolve()},L=>{console.error(`Unable to get page ${C} to initialize viewer`,L),0===--E&&e._pagesCapability.resolve()});C%250==0&&(yield M)}})),a.dispatch("pagesinit",{source:this}),t.getMetadata().then(({info:E})=>{t===this.pdfDocument&&E.Language&&(h.lang=E.Language)}),this.defaultRenderingQueue&&this.update()}).catch(f=>{console.error("Unable to initialize viewer",f),this._pagesCapability.reject(f)})}setPageLabels(t){if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let e=0,i=this._pages.length;e<i;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#t=new Wc(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=$.VERTICAL,this._previousScrollMode=$.UNKNOWN,this._spreadMode=mt.NONE,this.#x={previousPageNumber:1,scrollDown:!0,pages:[]},this.#o?.abort(),this.#o=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#_?.remove(),this.#_=null,this.#L()}#I(){if(this._scrollMode!==$.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#x,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==mt.NONE||this.isInPresentationMode){const n=new Set,s=this._spreadMode-1;-1===s?n.add(t-1):t%2!==s?(n.add(t-1),n.add(t)):(n.add(t-2),n.add(t-1));const r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){const a=document.createElement("div");a.className="dummyPage",r.append(a)}for(const a of n){const l=this._pages[a];l&&(r.append(l.div),e.pages.push(l))}i.append(r)}else{const n=this._pages[t-1];i.append(n.div),e.pages.push(n)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){0!==this.pagesCount&&this.update()}#O(t,e=null){const{div:i,id:n}=t;if(this._currentPageNumber!==n&&this._setCurrentPageNumber(n),this._scrollMode===$.PAGE&&(this.#I(),this.update()),!e&&!this.isInPresentationMode){const s=i.offsetLeft+i.clientLeft,r=s+i.clientWidth,{scrollLeft:a,clientWidth:l}=this.container;(this._scrollMode===$.HORIZONTAL||s<a||r>a+l)&&(e={left:0,top:0})}ks(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#C(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#w(t,e,{noScroll:i=!1,preset:n=!1,drawingDelay:s=-1,origin:r=null}){if(this._currentScaleValue=e.toString(),this.#C(t))return void(n&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*Xt.PDF_TO_CSS_UNITS);const a=s>=0&&s<1e3;this.refresh(!0,{scale:t,drawingDelay:a?s:-1}),a&&(this.#S=setTimeout(()=>{this.#S=null,this.refresh()},s));const l=this._currentScale;if(this._currentScale=t,!i){let c,h=this._currentPageNumber;if(this._location&&!(this.isInPresentationMode||this.isChangingPresentationMode)&&(h=this._location.pageNumber,c=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:h,destArray:c,allowNegativeOffset:!0}),Array.isArray(r)){const d=t/l-1,[u,f]=this.containerTopLeft;this.container.scrollLeft+=(r[0]-f)*d,this.container.scrollTop+=(r[1]-u)*d}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:n?e:void 0}),this.defaultRenderingQueue&&this.update()}get#N(){return this._spreadMode!==mt.NONE&&this._scrollMode!==$.HORIZONTAL?2:1}#k(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#w(i,t,e);else{const n=this._pages[this._currentPageNumber-1];if(!n)return;let s=40,r=5;this.isInPresentationMode?(s=r=4,this._spreadMode!==mt.NONE&&(s*=2)):this.removePageBorders?s=r=0:this._scrollMode===$.HORIZONTAL&&([s,r]=[r,s]);const a=(this.container.clientWidth-s)/n.width*n.scale/this.#N,l=(this.container.clientHeight-r)/n.height*n.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=l;break;case"page-fit":i=Math.min(a,l);break;case"auto":const h=Fs(n)?a:Math.min(l,a);i=Math.min(1.25,h);break;default:return void console.error(`#setScale: "${t}" is an unknown zoom value.`)}e.preset=!0,this.#w(i,t,e)}}#j(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#k(this._currentScaleValue,{noScroll:!0}),this.#O(t)}pageLabelToPageNumber(t){if(!this._pageLabels)return null;const e=this._pageLabels.indexOf(t);return e<0?null:e+1}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:n=!1}){if(!this.pdfDocument)return;const s=Number.isInteger(t)&&this._pages[t-1];if(!s)return void console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let c,d,r=0,a=0,l=0,h=0;const u=s.rotation%180!=0,f=(u?s.height:s.width)/s.scale/Xt.PDF_TO_CSS_UNITS,p=(u?s.width:s.height)/s.scale/Xt.PDF_TO_CSS_UNITS;let g=0;switch(e[1].name){case"XYZ":r=e[2],a=e[3],g=e[4],r=null!==r?r:0,a=null!==a?a:p;break;case"Fit":case"FitB":g="page-fit";break;case"FitH":case"FitBH":a=e[2],g="page-width",null===a&&this._location?(r=this._location.left,a=this._location.top):("number"!=typeof a||a<0)&&(a=p);break;case"FitV":case"FitBV":r=e[2],l=f,h=p,g="page-height";break;case"FitR":r=e[2],a=e[3],l=e[4]-r,h=e[5]-a;let v=40,w=5;this.removePageBorders&&(v=w=0),c=(this.container.clientWidth-v)/l/Xt.PDF_TO_CSS_UNITS,d=(this.container.clientHeight-w)/h/Xt.PDF_TO_CSS_UNITS,g=Math.min(Math.abs(c),Math.abs(d));break;default:return void console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`)}if(n||(g&&g!==this._currentScale?this.currentScaleValue=g:0===this._currentScale&&(this.currentScaleValue="auto")),"page-fit"===g&&!e[4])return void this.#O(s);const _=[s.viewport.convertToViewportPoint(r,a),s.viewport.convertToViewportPoint(r+l,a+h)];let m=Math.min(_[0][0],_[1][0]),A=Math.min(_[0][1],_[1][1]);i||(m=Math.max(m,0),A=Math.max(A,0)),this.#O(s,{left:m,top:A})}_updateLocation(t){const e=this._currentScale,i=this._currentScaleValue,n=parseFloat(i)===e?Math.round(1e4*e)/100:i,s=t.id,a=this.container,l=this._pages[s-1].getPagePoint(a.scrollLeft-t.x,a.scrollTop-t.y),h=Math.round(l[0]),c=Math.round(l[1]);let d=`#page=${s}`;this.isInPresentationMode||(d+=`&zoom=${n},${h},${c}`),this._location={pageNumber:s,scale:n,top:c,left:h,rotation:this._pagesRotation,pdfOpenParams:d}}update(){const t=this._getVisiblePages(),e=t.views,i=e.length;if(0===i)return;const n=Math.max(10,2*i+1);this.#t.resize(n,t.ids),this.renderingQueue.renderHighestPriority(t);const s=this._spreadMode===mt.NONE&&(this._scrollMode===$.PAGE||this._scrollMode===$.VERTICAL),r=this._currentPageNumber;let a=!1;for(const l of e){if(l.percent<100)break;if(l.id===r&&s){a=!0;break}}this._setCurrentPageNumber(a?r:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#U(){const t=this._getVisiblePages(),e=[],{ids:i,views:n}=t;for(const s of n){const{view:r}=s;r.hasEditableAnnotations()?e.push(s):i.delete(r.id)}return 0===e.length?null:(this.renderingQueue.renderHighestPriority({first:e[0],last:e.at(-1),views:e,ids:i}),i)}containsElement(t){return this.container.contains(t)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return 3===this.presentationModeState}get isChangingPresentationMode(){return 2===this.presentationModeState}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const t=this._scrollMode===$.PAGE?this.#x.pages:this._pages,e=this._scrollMode===$.HORIZONTAL;return function Gl({scrollEl:o,views:t,sortByVisibility:e=!1,horizontal:i=!1,rtl:n=!1}){const s=o.scrollTop,r=s+o.clientHeight,a=o.scrollLeft,l=a+o.clientWidth,d=[],u=new Set,f=t.length;let p=je(t,i?function c(A){const v=A.div,w=v.offsetLeft+v.clientLeft;return n?w<l:w+v.clientWidth>a}:function h(A){const v=A.div;return v.offsetTop+v.clientTop+v.clientHeight>s});p>0&&p<f&&!i&&(p=function Wl(o,t,e){if(o<2)return o;let i=t[o].div,n=i.offsetTop+i.clientTop;n>=e&&(i=t[o-1].div,n=i.offsetTop+i.clientTop);for(let s=o-2;s>=0&&(i=t[s].div,!(i.offsetTop+i.clientTop+i.clientHeight<=n));--s)o=s;return o}(p,t,s));let g=i?l:-1;for(let A=p;A<f;A++){const v=t[A],w=v.div,E=w.offsetLeft+w.clientLeft,C=w.offsetTop+w.clientTop,M=w.clientWidth,L=w.clientHeight,y=E+M,P=C+L;if(-1===g)P>=r&&(g=P);else if((i?E:C)>g)break;if(P<=s||C>=r||y<=a||E>=l)continue;const R=Math.max(0,s-C)+Math.max(0,P-r),H=(M-(Math.max(0,a-E)+Math.max(0,y-l)))/M;d.push({id:v.id,x:E,y:C,view:v,percent:(L-R)/L*H*100|0,widthPercent:100*H|0}),u.add(v.id)}const _=d[0],m=d.at(-1);return e&&d.sort(function(A,v){const w=A.percent-v.percent;return Math.abs(w)>.001?-w:A.id-v.id}),{first:_,last:m,views:d,ids:u}}({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:e&&this._isContainerRtl})}cleanup(){for(const t of this._pages)t.renderingState!==tt.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}#V(t){var e=this;return(0,x.A)(function*(){if(t.pdfPage)return t.pdfPage;try{const i=yield e.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(i),i}catch(i){return console.error("Unable to get page for page view",i),null}})()}#F(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case $.PAGE:return this.#x.scrollDown;case $.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#F(e),s=this.renderingQueue.getHighestPriority(e,this._pages,i,this._spreadMode!==mt.NONE&&this._scrollMode!==$.HORIZONTAL);return!!s&&(this.#V(s).then(()=>{this.renderingQueue.renderView(s)}),!0)}get hasEqualPageSizes(){const t=this._pages[0];for(let e=1,i=this._pages.length;e<i;++e){const n=this._pages[e];if(n.width!==t.width||n.height!==t.height)return!1}return!0}getPagesOverview(){let t;return this._pages.map(e=>{const i=e.pdfPage.getViewport({scale:1}),n=Fs(i);if(void 0===t)t=n;else if(this.enablePrintAutoRotate&&n!==t)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}})}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error("optionalContentConfigPromise: Not initialized yet."),this.pdfDocument.getOptionalContentConfig({intent:"display"})):Promise.resolve(null)}set optionalContentConfigPromise(t){if(!(t instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${t}`);this.pdfDocument&&this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=t,this.refresh(!1,{optionalContentConfigPromise:t}),this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:t}))}get scrollMode(){return this._scrollMode}set scrollMode(t){if(this._scrollMode!==t){if(!function Xl(o){return Number.isInteger(o)&&Object.values($).includes(o)&&o!==$.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>1e4||(this._previousScrollMode=this._scrollMode,this._scrollMode=t,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:t}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(t=null){const e=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",e===$.HORIZONTAL),i.classList.toggle("scrollWrapped",e===$.WRAPPED),this.pdfDocument&&t&&(e===$.PAGE?this.#I():this._previousScrollMode===$.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#k(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(t){if(this._spreadMode!==t){if(!function Yl(o){return Number.isInteger(o)&&Object.values(mt).includes(o)&&o!==mt.UNKNOWN}(t))throw new Error(`Invalid spread mode: ${t}`);this._spreadMode=t,this.eventBus.dispatch("spreadmodechanged",{source:this,mode:t}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(t=null){if(!this.pdfDocument)return;const e=this.viewer,i=this._pages;if(this._scrollMode===$.PAGE)this.#I();else if(e.textContent="",this._spreadMode===mt.NONE)for(const n of this._pages)e.append(n.div);else{const n=this._spreadMode-1;let s=null;for(let r=0,a=i.length;r<a;++r)null===s?(s=document.createElement("div"),s.className="spread",e.append(s)):r%2===n&&(s=s.cloneNode(!1),e.append(s)),s.append(i[r].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#k(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case $.WRAPPED:{const{views:i}=this._getVisiblePages(),n=new Map;for(const{id:s,y:r,percent:a,widthPercent:l}of i){if(0===a||l<100)continue;let h=n.get(r);h||n.set(r,h||=[]),h.push(s)}for(const s of n.values()){const r=s.indexOf(t);if(-1===r)continue;const a=s.length;if(1===a)break;if(e)for(let l=r-1,h=0;l>=h;l--){const d=s[l+1]-1;if(s[l]<d)return t-d}else for(let l=r+1,h=a;l<h;l++){const d=s[l-1]+1;if(s[l]>d)return d-t}if(e){const l=s[0];if(l<t)return t-l+1}else{const l=s[a-1];if(l>t)return l-t+1}break}break}case $.HORIZONTAL:break;case $.PAGE:case $.VERTICAL:{if(this._spreadMode===mt.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:n}=this._getVisiblePages(),s=e?t-1:t+1;for(const{id:r,percent:a,widthPercent:l}of n)if(r===s){if(a>0&&100===l)return 2;break}break}}return 1}nextPage(){const t=this._currentPageNumber,e=this.pagesCount;if(t>=e)return!1;const i=this._getPageAdvance(t,!1)||1;return this.currentPageNumber=Math.min(t+i,e),!0}previousPage(){const t=this._currentPageNumber;if(t<=1)return!1;const e=this._getPageAdvance(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:n}){if(null===i&&null===e)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let s=this._currentScale;if(e>0&&1!==e)s=Math.round(s*e*100)/100;else if(i){const r=i>0?1.1:1/1.1,a=i>0?Math.ceil:Math.floor;i=Math.abs(i);do{s=a(10*(s*r).toFixed(2))/10}while(--i>0)}s=Math.max(.1,Math.min(10,s)),this.#k(s,{noScroll:!1,drawingDelay:t,origin:n})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#B(t=this.container.clientHeight){t!==this.#A&&(this.#A=t,ql.setProperty("--viewer-container-height",`${t}px`))}#W(t){for(const e of t)if(e.target===this.container){this.#B(Math.floor(e.borderBoxSize[0].blockSize)),this.#a=null;break}}get containerTopLeft(){return this.#a||=[this.container.offsetTop,this.container.offsetLeft]}#L(){this.#m?.abort(),this.#m=null,null!==this.#g&&(clearTimeout(this.#g),this.#g=null)}get annotationEditorMode(){return this.#r?this.#n:Ct.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(!this.#r)throw new Error("The AnnotationEditor is not enabled.");if(this.#n===t)return;if(!vr(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;t===Ct.STAMP&&this.#p?.loadModel("altText");const{eventBus:n}=this,s=()=>{this.#L(),this.#n=t,this.#r.updateMode(t,e,i),n.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===Ct.NONE||this.#n===Ct.NONE){const r=t!==Ct.NONE;r||this.pdfDocument.annotationStorage.resetModifiedIds();for(const l of this._pages)l.toggleEditingMode(r);const a=this.#U();if(r&&a){this.#L(),this.#m=new AbortController;const l=AbortSignal.any([this.#o.signal,this.#m.signal]);return void n._on("pagerendered",({pageNumber:h})=>{a.delete(h),0===a.size&&(this.#g=setTimeout(s,0))},{signal:l})}}s()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const i of this._pages)i.update(e);null!==this.#S&&(clearTimeout(this.#S),this.#S=null),t||this.update()}}}class Gc extends Ar{_resetView(){super._resetView(),this._scrollMode=$.PAGE,this._spreadMode=mt.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var $c=Q.AnnotationLayerBuilder,Xc=Q.DownloadManager,Yc=Q.EventBus,qc=Q.FindState,wr=Q.GenericL10n,Ae=Q.LinkTarget,yr=Q.PDFFindController,Kc=Q.PDFHistory,Er=Q.PDFLinkService,Qc=Q.PDFPageView,Zc=Q.PDFScriptingManager,xr=Q.PDFSinglePageViewer,Sr=Q.PDFViewer,Jc=Q.ProgressBar,td=Q.RenderingStates,ed=Q.ScrollMode,id=Q.SimpleLinkService,nd=Q.SpreadMode,sd=Q.StructTreeLayerBuilder,rd=Q.TextLayerBuilder,ad=Q.XfaLayerBuilder,od=Q.parseQueryString;const ld=["pdfViewerContainer"];function yn(o,t,e){o[t]=e}function Ge(){return typeof window>"u"}Ge()||yn(Bt,"verbosity",Ss.INFOS),typeof Promise.withResolvers>"u"&&window&&(window.Promise.withResolvers=()=>{let o,t;return{promise:new Promise((i,n)=>{o=i,t=n}),resolve:o,reject:t}});var En=function(o){return o[o.DISABLED=0]="DISABLED",o[o.ENABLED=1]="ENABLED",o[o.ENHANCED=2]="ENHANCED",o}(En||{});let dd=(()=>{class o{element;ngZone;static CSS_UNITS=96/72;static BORDER_WIDTH=9;pdfViewerContainer;eventBus;pdfLinkService;pdfFindController;pdfViewer;isVisible=!1;_cMapsUrl=`https://unpkg.com/pdfjs-dist@${fi}/cmaps/`;_imageResourcesPath=`https://unpkg.com/pdfjs-dist@${fi}/web/images/`;_renderText=!0;_renderTextMode=En.ENABLED;_stickToPage=!1;_originalSize=!0;_pdf;_page=1;_zoom=1;_zoomScale="page-width";_rotation=0;_showAll=!0;_canAutoResize=!0;_fitToPage=!1;_externalLinkTarget="blank";_showBorders=!1;lastLoaded;_latestScrolledPage;pageScrollTimeout=null;isInitialized=!1;loadingTask;destroy$=new Gr.B;afterLoadComplete=new T.bkB;pageRendered=new T.bkB;pageInitialized=new T.bkB;textLayerRendered=new T.bkB;onError=new T.bkB;onProgress=new T.bkB;pageChange=new T.bkB(!0);src;set cMapsUrl(e){this._cMapsUrl=e}set page(e){const i=e=parseInt(e,10)||1;this._pdf&&(e=this.getValidPageNumber(e)),this._page=e,i!==e&&this.pageChange.emit(e)}set renderText(e){this._renderText=e}set renderTextMode(e){this._renderTextMode=e}set originalSize(e){this._originalSize=e}set showAll(e){this._showAll=e}set stickToPage(e){this._stickToPage=e}set zoom(e){e<=0||(this._zoom=e)}get zoom(){return this._zoom}set zoomScale(e){this._zoomScale=e}get zoomScale(){return this._zoomScale}set rotation(e){"number"==typeof e&&e%90==0?this._rotation=e:console.warn("Invalid pages rotation angle.")}set externalLinkTarget(e){this._externalLinkTarget=e}set autoresize(e){this._canAutoResize=!!e}set fitToPage(e){this._fitToPage=!!e}set showBorders(e){this._showBorders=!!e}static getLinkTarget(e){switch(e){case"blank":return Ae.BLANK;case"none":return Ae.NONE;case"self":return Ae.SELF;case"parent":return Ae.PARENT;case"top":return Ae.TOP}return null}constructor(e,i){if(this.element=e,this.ngZone=i,Ge())return;let n;const s=fi;n=window[`pdfWorkerSrc${s}`]||(window.hasOwnProperty("pdfWorkerSrc")&&"string"==typeof window.pdfWorkerSrc&&window.pdfWorkerSrc?window.pdfWorkerSrc:`https://cdn.jsdelivr.net/npm/pdfjs-dist@${s}/legacy/build/pdf.worker.min.mjs`),yn(xs,"workerSrc",n)}ngAfterViewChecked(){if(this.isInitialized)return;const e=this.pdfViewerContainer.nativeElement.offsetParent;!0!==this.isVisible||null!=e?!1===this.isVisible&&null!=e&&(this.isVisible=!0,setTimeout(()=>{this.initialize(),this.ngOnChanges({src:this.src})})):this.isVisible=!1}ngOnInit(){this.initialize(),this.setupResizeListener()}ngOnDestroy(){this.clear(),this.destroy$.next(),this.loadingTask=null}ngOnChanges(e){if(!Ge()&&this.isVisible)if("src"in e)this.loadPDF();else if(this._pdf){if(("renderText"in e||"showAll"in e)&&(this.setupViewer(),this.resetPdfDocument()),"page"in e){const{page:i}=e;if(i.currentValue===this._latestScrolledPage)return;this.pdfViewer.scrollPageIntoView({pageNumber:this._page})}this.update()}}updateSize(){(0,Cn.H)(this._pdf.getPage(this.pdfViewer.currentPageNumber)).pipe((0,J.Q)(this.destroy$)).subscribe({next:e=>{const i=this._rotation+e.rotate,n=e.getViewport({scale:this._zoom,rotation:i}).width*o.CSS_UNITS;let s=this._zoom,r=!0;if(!this._originalSize||this._fitToPage&&n>this.pdfViewerContainer.nativeElement.clientWidth){const a=e.getViewport({scale:1,rotation:i});s=this.getScale(a.width,a.height),r=!this._stickToPage}this.pdfViewer.currentScale=s,r&&this.pdfViewer.scrollPageIntoView({pageNumber:e.pageNumber,ignoreDestinationZoom:!0})}})}clear(){this.loadingTask&&!this.loadingTask.destroyed&&this.loadingTask.destroy(),this._pdf&&(this._latestScrolledPage=0,this._pdf.destroy(),this._pdf=void 0),this.pdfViewer&&this.pdfViewer.setDocument(null),this.pdfLinkService&&this.pdfLinkService.setDocument(null,null),this.pdfFindController&&this.pdfFindController.setDocument(null)}getPDFLinkServiceConfig(){const e=o.getLinkTarget(this._externalLinkTarget);return e?{externalLinkTarget:e}:{}}initEventBus(){this.eventBus=function hd(o,t){const e=new o.EventBus;return function cd(o,t){Z(o,"documentload").pipe((0,J.Q)(t)).subscribe(()=>{const e=document.createEvent("CustomEvent");e.initCustomEvent("documentload",!0,!0,{}),window.dispatchEvent(e)}),Z(o,"pagerendered").pipe((0,J.Q)(t)).subscribe(({pageNumber:e,cssTransform:i,source:n})=>{const s=document.createEvent("CustomEvent");s.initCustomEvent("pagerendered",!0,!0,{pageNumber:e,cssTransform:i}),n.div.dispatchEvent(s)}),Z(o,"textlayerrendered").pipe((0,J.Q)(t)).subscribe(({pageNumber:e,source:i})=>{const n=document.createEvent("CustomEvent");n.initCustomEvent("textlayerrendered",!0,!0,{pageNumber:e}),i.textLayerDiv?.dispatchEvent(n)}),Z(o,"pagechanging").pipe((0,J.Q)(t)).subscribe(({pageNumber:e,source:i})=>{const n=document.createEvent("UIEvents");n.initEvent("pagechanging",!0,!0),n.pageNumber=e,i.container.dispatchEvent(n)}),Z(o,"pagesinit").pipe((0,J.Q)(t)).subscribe(({source:e})=>{const i=document.createEvent("CustomEvent");i.initCustomEvent("pagesinit",!0,!0,null),e.container.dispatchEvent(i)}),Z(o,"pagesloaded").pipe((0,J.Q)(t)).subscribe(({pagesCount:e,source:i})=>{const n=document.createEvent("CustomEvent");n.initCustomEvent("pagesloaded",!0,!0,{pagesCount:e}),i.container.dispatchEvent(n)}),Z(o,"scalechange").pipe((0,J.Q)(t)).subscribe(({scale:e,presetValue:i,source:n})=>{const s=document.createEvent("UIEvents");s.initEvent("scalechange",!0,!0),s.scale=e,s.presetValue=i,n.container.dispatchEvent(s)}),Z(o,"updateviewarea").pipe((0,J.Q)(t)).subscribe(({location:e,source:i})=>{const n=document.createEvent("UIEvents");n.initEvent("updateviewarea",!0,!0),n.location=e,i.container.dispatchEvent(n)}),Z(o,"find").pipe((0,J.Q)(t)).subscribe(({source:e,type:i,query:n,phraseSearch:s,caseSensitive:r,highlightAll:a,findPrevious:l})=>{if(e===window)return;const h=document.createEvent("CustomEvent");h.initCustomEvent("find"+i,!0,!0,{query:n,phraseSearch:s,caseSensitive:r,highlightAll:a,findPrevious:l}),window.dispatchEvent(h)}),Z(o,"attachmentsloaded").pipe((0,J.Q)(t)).subscribe(({attachmentsCount:e,source:i})=>{const n=document.createEvent("CustomEvent");n.initCustomEvent("attachmentsloaded",!0,!0,{attachmentsCount:e}),i.container.dispatchEvent(n)}),Z(o,"sidebarviewchanged").pipe((0,J.Q)(t)).subscribe(({view:e,source:i})=>{const n=document.createEvent("CustomEvent");n.initCustomEvent("sidebarviewchanged",!0,!0,{view:e}),i.outerContainer.dispatchEvent(n)}),Z(o,"pagemode").pipe((0,J.Q)(t)).subscribe(({mode:e,source:i})=>{const n=document.createEvent("CustomEvent");n.initCustomEvent("pagemode",!0,!0,{mode:e}),i.pdfViewer.container.dispatchEvent(n)}),Z(o,"namedaction").pipe((0,J.Q)(t)).subscribe(({action:e,source:i})=>{const n=document.createEvent("CustomEvent");n.initCustomEvent("namedaction",!0,!0,{action:e}),i.pdfViewer.container.dispatchEvent(n)}),Z(o,"presentationmodechanged").pipe((0,J.Q)(t)).subscribe(({active:e,switchInProgress:i})=>{const n=document.createEvent("CustomEvent");n.initCustomEvent("presentationmodechanged",!0,!0,{active:e,switchInProgress:i}),window.dispatchEvent(n)}),Z(o,"outlineloaded").pipe((0,J.Q)(t)).subscribe(({outlineCount:e,source:i})=>{const n=document.createEvent("CustomEvent");n.initCustomEvent("outlineloaded",!0,!0,{outlineCount:e}),i.container.dispatchEvent(n)})}(e,t),e}(ee,this.destroy$),Z(this.eventBus,"pagerendered").pipe((0,J.Q)(this.destroy$)).subscribe(e=>{this.pageRendered.emit(e)}),Z(this.eventBus,"pagesinit").pipe((0,J.Q)(this.destroy$)).subscribe(e=>{this.pageInitialized.emit(e)}),Z(this.eventBus,"pagechanging").pipe((0,J.Q)(this.destroy$)).subscribe(({pageNumber:e})=>{this.pageScrollTimeout&&clearTimeout(this.pageScrollTimeout),this.pageScrollTimeout=window.setTimeout(()=>{this._latestScrolledPage=e,this.pageChange.emit(e)},100)}),Z(this.eventBus,"textlayerrendered").pipe((0,J.Q)(this.destroy$)).subscribe(e=>{this.textLayerRendered.emit(e)})}initPDFServices(){this.pdfLinkService=new Er({eventBus:this.eventBus,...this.getPDFLinkServiceConfig()}),this.pdfFindController=new yr({eventBus:this.eventBus,linkService:this.pdfLinkService})}getPDFOptions(){return{eventBus:this.eventBus,container:this.element.nativeElement.querySelector("div"),removePageBorders:!this._showBorders,linkService:this.pdfLinkService,textLayerMode:this._renderText?this._renderTextMode:En.DISABLED,findController:this.pdfFindController,l10n:new wr("en"),imageResourcesPath:this._imageResourcesPath,annotationEditorMode:Es.DISABLE}}setupViewer(){this.pdfViewer&&this.pdfViewer.setDocument(null),yn(Bt,"disableTextLayer",!this._renderText),this.initPDFServices(),this.pdfViewer=this._showAll?new Sr(this.getPDFOptions()):new xr(this.getPDFOptions()),this.pdfLinkService.setViewer(this.pdfViewer),this.pdfViewer._currentPageNumber=this._page}getValidPageNumber(e){return e<1?1:e>this._pdf.numPages?this._pdf.numPages:e}getDocumentParams(){const e=typeof this.src;if(!this._cMapsUrl)return this.src;const i={cMapUrl:this._cMapsUrl,cMapPacked:!0,enableXfa:!0,isEvalSupported:!1};return"string"===e?i.url=this.src:"object"===e&&(void 0!==this.src.byteLength?i.data=this.src:Object.assign(i,this.src)),i}loadPDF(){if(!this.src)return;if(this.lastLoaded===this.src)return void this.update();this.clear(),this.setupViewer(),this.loadingTask=Ps(this.getDocumentParams()),this.loadingTask.onProgress=i=>{this.onProgress.emit(i)};const e=this.src;(0,Cn.H)(this.loadingTask.promise).pipe((0,J.Q)(this.destroy$)).subscribe({next:i=>{this._pdf=i,this.lastLoaded=e,this.afterLoadComplete.emit(i),this.resetPdfDocument(),this.update()},error:i=>{this.lastLoaded=null,this.onError.emit(i)}})}update(){this.page=this._page,this.render()}render(){if(this._page=this.getValidPageNumber(this._page),(0!==this._rotation||this.pdfViewer.pagesRotation!==this._rotation)&&this.pdfViewer.firstPagePromise?.then(()=>this.pdfViewer.pagesRotation=this._rotation),this._stickToPage&&setTimeout(()=>{this.pdfViewer.currentPageNumber=this._page}),this.pdfViewer._pages?.length)this.updateSize();else{const e=this.pageInitialized.subscribe(()=>{this.updateSize(),e.unsubscribe()})}}getScale(e,i){const n=this._showBorders?2*o.BORDER_WIDTH:0,s=this.pdfViewerContainer.nativeElement.clientWidth-n,r=this.pdfViewerContainer.nativeElement.clientHeight-n;if(0===r||0===i||0===s||0===e)return 1;let a=1;switch(this._zoomScale){case"page-fit":a=Math.min(r/i,s/e);break;case"page-height":a=r/i;break;default:a=s/e}return this._zoom*a/o.CSS_UNITS}resetPdfDocument(){this.pdfLinkService.setDocument(this._pdf,null),this.pdfFindController.setDocument(this._pdf),this.pdfViewer.setDocument(this._pdf)}initialize(){Ge()||!this.isVisible||(this.isInitialized=!0,this.initEventBus(),this.setupViewer())}setupResizeListener(){Ge()||this.ngZone.runOutsideAngular(()=>{Z(window,"resize").pipe((0,$r.B)(100),(0,Xr.p)(()=>this._canAutoResize&&!!this._pdf),(0,J.Q)(this.destroy$)).subscribe(()=>{this.updateSize()})})}static \u0275fac=function(i){return new(i||o)(b.rXU(b.aKT),b.rXU(T.SKi))};static \u0275cmp=b.VBU({type:o,selectors:[["pdf-viewer"]],viewQuery:function(i,n){if(1&i&&b.GBs(ld,5),2&i){let s;b.mGM(s=b.lsd())&&(n.pdfViewerContainer=s.first)}},inputs:{src:"src",cMapsUrl:[0,"c-maps-url","cMapsUrl"],page:"page",renderText:[0,"render-text","renderText"],renderTextMode:[0,"render-text-mode","renderTextMode"],originalSize:[0,"original-size","originalSize"],showAll:[0,"show-all","showAll"],stickToPage:[0,"stick-to-page","stickToPage"],zoom:"zoom",zoomScale:[0,"zoom-scale","zoomScale"],rotation:"rotation",externalLinkTarget:[0,"external-link-target","externalLinkTarget"],autoresize:"autoresize",fitToPage:[0,"fit-to-page","fitToPage"],showBorders:[0,"show-borders","showBorders"]},outputs:{afterLoadComplete:"after-load-complete",pageRendered:"page-rendered",pageInitialized:"pages-initialized",textLayerRendered:"text-layer-rendered",onError:"error",onProgress:"on-progress",pageChange:"pageChange"},standalone:!1,features:[b.OA$],decls:3,vars:0,consts:[["pdfViewerContainer",""],[1,"ng2-pdf-viewer-container"],[1,"pdfViewer"]],template:function(i,n){1&i&&(b.j41(0,"div",1,0),b.nrm(2,"div",2),b.k0s())},styles:['.ng2-pdf-viewer-container[_ngcontent-%COMP%]{overflow-x:auto;position:absolute;height:100%;width:100%;-webkit-overflow-scrolling:touch}[_nghost-%COMP%]{display:block;position:relative}[_nghost-%COMP%] {--pdfViewer-padding-bottom: 0;--page-margin: 1px auto -8px;--page-border: 9px solid transparent;--spreadHorizontalWrapped-margin-LR: -3.5px;--viewer-container-height: 0;--annotation-unfocused-field-background: url("data:image/svg+xml;charset=UTF-8,<svg width=\'1px\' height=\'1px\' xmlns=\'http://www.w3.org/2000/svg\'><rect width=\'100%\' height=\'100%\' style=\'fill:rgba(0, 54, 255, 0.13);\'/></svg>");--xfa-unfocused-field-background: var( --annotation-unfocused-field-background );--page-border-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAA1ElEQVQ4jbWUWw6EIAxFy2NFs/8NzR4UJhpqLsdi5mOmSSMUOfYWqv3S0gMr4XlYH/64gZa/gN3ANYA7KAXALt4ktoQ5MI9YxqaG8bWmsIysMuT6piSQCa4whZThCu8CM4zP9YJaKci9jicPq3NcBWYoPMGUlhG7ivtkB+gVyFY75wXghOvh8t5mto1Mdim6e+MBqH6XsY+YAwjpq3vGF7weTWQptLEDVCZvPTMl5JZZsdh47FHW6qFMyvLYqjcnmdFfY9Xk/KDOlzCusX2mi/ofM7MPkzBcSp4Q1/wAAAAASUVORK5CYII=) 9 9 repeat;--scale-factor: 1;--focus-outline: solid 2px blue;--hover-outline: dashed 2px blue;--freetext-line-height: 1.35;--freetext-padding: 2px;--editorInk-editing-cursor: pointer}@media screen and (forced-colors: active){[_nghost-%COMP%] {--pdfViewer-padding-bottom: 9px;--page-margin: 8px auto -1px;--page-border: 1px solid CanvasText;--page-border-image: none;--spreadHorizontalWrapped-margin-LR: 3.5px}}@media (forced-colors: active){[_nghost-%COMP%] {--focus-outline: solid 3px ButtonText;--hover-outline: dashed 3px ButtonText}}[_nghost-%COMP%] .textLayer{position:absolute;text-align:initial;inset:0;overflow:hidden;opacity:.2;line-height:1;-webkit-text-size-adjust:none;text-size-adjust:none;forced-color-adjust:none;transform-origin:0 0}[_nghost-%COMP%] .textLayer span, [_nghost-%COMP%] .textLayer br{color:transparent;position:absolute;white-space:pre;cursor:text;transform-origin:0% 0%}[_nghost-%COMP%] .textLayer span.markedContent{top:0;height:0}[_nghost-%COMP%] .textLayer .highlight{margin:-1px;padding:1px;background-color:#b400aa;border-radius:4px}[_nghost-%COMP%] .textLayer .highlight.appended{position:initial}[_nghost-%COMP%] .textLayer .highlight.begin{border-radius:4px 0 0 4px}[_nghost-%COMP%] .textLayer .highlight.end{border-radius:0 4px 4px 0}[_nghost-%COMP%] .textLayer .highlight.middle{border-radius:0}[_nghost-%COMP%] .textLayer .highlight.selected{background-color:#006400}[_nghost-%COMP%] .textLayer ::selection{background:rgb(0,0,255)}[_nghost-%COMP%] .textLayer br::selection{background:transparent}[_nghost-%COMP%] .textLayer .endOfContent{display:block;position:absolute;inset:100% 0 0;z-index:-1;cursor:default;-webkit-user-select:none;user-select:none}[_nghost-%COMP%] .textLayer .endOfContent.active{top:0}@media (forced-colors: active){[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation input:required, [_nghost-%COMP%] .annotationLayer .textWidgetAnnotation textarea:required, [_nghost-%COMP%] .annotationLayer .choiceWidgetAnnotation select:required, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input:required, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton input:required{outline:1.5px solid selectedItem}}[_nghost-%COMP%] .annotationLayer{position:absolute;top:0;left:0;pointer-events:none;transform-origin:0 0}[_nghost-%COMP%] .annotationLayer section{position:absolute;text-align:initial;pointer-events:auto;box-sizing:border-box;transform-origin:0 0}[_nghost-%COMP%] .annotationLayer .linkAnnotation>a, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.pushButton>a{position:absolute;font-size:1em;top:0;left:0;width:100%;height:100%}[_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.pushButton>canvas{width:100%;height:100%}[_nghost-%COMP%] .annotationLayer .linkAnnotation>a:hover, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.pushButton>a:hover{opacity:.2;background:rgb(255,255,0);box-shadow:0 2px 10px #ff0}[_nghost-%COMP%] .annotationLayer .textAnnotation img{position:absolute;cursor:pointer;width:100%;height:100%}[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation input, [_nghost-%COMP%] .annotationLayer .textWidgetAnnotation textarea, [_nghost-%COMP%] .annotationLayer .choiceWidgetAnnotation select, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton input{background-image:var(--annotation-unfocused-field-background);border:1px solid transparent;box-sizing:border-box;font:calc(9px * var(--scale-factor)) sans-serif;height:100%;margin:0;vertical-align:top;width:100%}[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation input:required, [_nghost-%COMP%] .annotationLayer .textWidgetAnnotation textarea:required, [_nghost-%COMP%] .annotationLayer .choiceWidgetAnnotation select:required, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input:required, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton input:required{outline:1.5px solid red}[_nghost-%COMP%] .annotationLayer .choiceWidgetAnnotation select option{padding:0}[_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton input{border-radius:50%}[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation textarea{resize:none}[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation input[disabled], [_nghost-%COMP%] .annotationLayer .textWidgetAnnotation textarea[disabled], [_nghost-%COMP%] .annotationLayer .choiceWidgetAnnotation select[disabled], [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input[disabled], [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton input[disabled]{background:none;border:1px solid transparent;cursor:not-allowed}[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation input:hover, [_nghost-%COMP%] .annotationLayer .textWidgetAnnotation textarea:hover, [_nghost-%COMP%] .annotationLayer .choiceWidgetAnnotation select:hover, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input:hover, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton input:hover{border:1px solid rgb(0,0,0)}[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation input:focus, [_nghost-%COMP%] .annotationLayer .textWidgetAnnotation textarea:focus, [_nghost-%COMP%] .annotationLayer .choiceWidgetAnnotation select:focus{background:none;border:1px solid transparent}[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation input :focus, [_nghost-%COMP%] .annotationLayer .textWidgetAnnotation textarea :focus, [_nghost-%COMP%] .annotationLayer .choiceWidgetAnnotation select :focus, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox :focus, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton :focus{background-image:none;background-color:transparent;outline:auto}[_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{background-color:CanvasText;content:"";display:block;position:absolute}[_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{height:80%;left:45%;width:1px}[_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{transform:rotate(45deg)}[_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{transform:rotate(-45deg)}[_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{border-radius:50%;height:50%;left:30%;top:20%;width:50%}[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation input.comb{font-family:monospace;padding-left:2px;padding-right:0}[_nghost-%COMP%] .annotationLayer .textWidgetAnnotation input.comb:focus{width:103%}[_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.checkBox input, [_nghost-%COMP%] .annotationLayer .buttonWidgetAnnotation.radioButton input{-webkit-appearance:none;appearance:none}[_nghost-%COMP%] .annotationLayer .popupTriggerArea{height:100%;width:100%}[_nghost-%COMP%] .annotationLayer .popupWrapper{position:absolute;font-size:calc(9px * var(--scale-factor));width:100%;min-width:calc(180px * var(--scale-factor));pointer-events:none}[_nghost-%COMP%] .annotationLayer .popup{position:absolute;max-width:calc(180px * var(--scale-factor));background-color:#ff9;box-shadow:0 calc(2px * var(--scale-factor)) calc(5px * var(--scale-factor)) #888;border-radius:calc(2px * var(--scale-factor));padding:calc(6px * var(--scale-factor));margin-left:calc(5px * var(--scale-factor));cursor:pointer;font:message-box;white-space:normal;word-wrap:break-word;pointer-events:auto}[_nghost-%COMP%] .annotationLayer .popup>*{font-size:calc(9px * var(--scale-factor))}[_nghost-%COMP%] .annotationLayer .popup h1{display:inline-block}[_nghost-%COMP%] .annotationLayer .popupDate{display:inline-block;margin-left:calc(5px * var(--scale-factor))}[_nghost-%COMP%] .annotationLayer .popupContent{border-top:1px solid rgb(51,51,51);margin-top:calc(2px * var(--scale-factor));padding-top:calc(2px * var(--scale-factor))}[_nghost-%COMP%] .annotationLayer .richText>*{white-space:pre-wrap;font-size:calc(9px * var(--scale-factor))}[_nghost-%COMP%] .annotationLayer .highlightAnnotation, [_nghost-%COMP%] .annotationLayer .underlineAnnotation, [_nghost-%COMP%] .annotationLayer .squigglyAnnotation, [_nghost-%COMP%] .annotationLayer .strikeoutAnnotation, [_nghost-%COMP%] .annotationLayer .freeTextAnnotation, [_nghost-%COMP%] .annotationLayer .lineAnnotation svg line, [_nghost-%COMP%] .annotationLayer .squareAnnotation svg rect, [_nghost-%COMP%] .annotationLayer .circleAnnotation svg ellipse, [_nghost-%COMP%] .annotationLayer .polylineAnnotation svg polyline, [_nghost-%COMP%] .annotationLayer .polygonAnnotation svg polygon, [_nghost-%COMP%] .annotationLayer .caretAnnotation, [_nghost-%COMP%] .annotationLayer .inkAnnotation svg polyline, [_nghost-%COMP%] .annotationLayer .stampAnnotation, [_nghost-%COMP%] .annotationLayer .fileAttachmentAnnotation{cursor:pointer}[_nghost-%COMP%] .annotationLayer section svg{position:absolute;width:100%;height:100%}[_nghost-%COMP%] .annotationLayer .annotationTextContent{position:absolute;width:100%;height:100%;opacity:0;color:transparent;-webkit-user-select:none;user-select:none;pointer-events:none}[_nghost-%COMP%] .annotationLayer .annotationTextContent span{width:100%;display:inline-block}@media (forced-colors: active){[_nghost-%COMP%] .xfaLayer *:required{outline:1.5px solid selectedItem}}[_nghost-%COMP%] .xfaLayer .highlight{margin:-1px;padding:1px;background-color:#efcbed;border-radius:4px}[_nghost-%COMP%] .xfaLayer .highlight.appended{position:initial}[_nghost-%COMP%] .xfaLayer .highlight.begin{border-radius:4px 0 0 4px}[_nghost-%COMP%] .xfaLayer .highlight.end{border-radius:0 4px 4px 0}[_nghost-%COMP%] .xfaLayer .highlight.middle{border-radius:0}[_nghost-%COMP%] .xfaLayer .highlight.selected{background-color:#cbdfcb}[_nghost-%COMP%] .xfaLayer ::selection{background:rgb(0,0,255)}[_nghost-%COMP%] .xfaPage{overflow:hidden;position:relative}[_nghost-%COMP%] .xfaContentarea{position:absolute}[_nghost-%COMP%] .xfaPrintOnly{display:none}[_nghost-%COMP%] .xfaLayer{position:absolute;text-align:initial;top:0;left:0;transform-origin:0 0;line-height:1.2}[_nghost-%COMP%] .xfaLayer *{color:inherit;font:inherit;font-style:inherit;font-weight:inherit;font-kerning:inherit;letter-spacing:-.01px;text-align:inherit;text-decoration:inherit;box-sizing:border-box;background-color:transparent;padding:0;margin:0;pointer-events:auto;line-height:inherit}[_nghost-%COMP%] .xfaLayer *:required{outline:1.5px solid red}[_nghost-%COMP%] .xfaLayer div{pointer-events:none}[_nghost-%COMP%] .xfaLayer svg{pointer-events:none}[_nghost-%COMP%] .xfaLayer svg *{pointer-events:none}[_nghost-%COMP%] .xfaLayer a{color:#00f}[_nghost-%COMP%] .xfaRich li{margin-left:3em}[_nghost-%COMP%] .xfaFont{color:#000;font-weight:400;font-kerning:none;font-size:10px;font-style:normal;letter-spacing:0;text-decoration:none;vertical-align:0}[_nghost-%COMP%] .xfaCaption{overflow:hidden;flex:0 0 auto}[_nghost-%COMP%] .xfaCaptionForCheckButton{overflow:hidden;flex:1 1 auto}[_nghost-%COMP%] .xfaLabel{height:100%;width:100%}[_nghost-%COMP%] .xfaLeft{display:flex;flex-direction:row;align-items:center}[_nghost-%COMP%] .xfaRight{display:flex;flex-direction:row-reverse;align-items:center}[_nghost-%COMP%] .xfaLeft>.xfaCaption, [_nghost-%COMP%] .xfaLeft>.xfaCaptionForCheckButton, [_nghost-%COMP%] .xfaRight>.xfaCaption, [_nghost-%COMP%] .xfaRight>.xfaCaptionForCheckButton{max-height:100%}[_nghost-%COMP%] .xfaTop{display:flex;flex-direction:column;align-items:flex-start}[_nghost-%COMP%] .xfaBottom{display:flex;flex-direction:column-reverse;align-items:flex-start}[_nghost-%COMP%] .xfaTop>.xfaCaption, [_nghost-%COMP%] .xfaTop>.xfaCaptionForCheckButton, [_nghost-%COMP%] .xfaBottom>.xfaCaption, [_nghost-%COMP%] .xfaBottom>.xfaCaptionForCheckButton{width:100%}[_nghost-%COMP%] .xfaBorder{background-color:transparent;position:absolute;pointer-events:none}[_nghost-%COMP%] .xfaWrapped{width:100%;height:100%}[_nghost-%COMP%] .xfaTextfield:focus, [_nghost-%COMP%] .xfaSelect:focus{background-image:none;background-color:transparent;outline:auto;outline-offset:-1px}[_nghost-%COMP%] .xfaCheckbox:focus, [_nghost-%COMP%] .xfaRadio:focus{outline:auto}[_nghost-%COMP%] .xfaTextfield, [_nghost-%COMP%] .xfaSelect{height:100%;width:100%;flex:1 1 auto;border:none;resize:none;background-image:var(--xfa-unfocused-field-background)}[_nghost-%COMP%] .xfaTop>.xfaTextfield, [_nghost-%COMP%] .xfaTop>.xfaSelect, [_nghost-%COMP%] .xfaBottom>.xfaTextfield, [_nghost-%COMP%] .xfaBottom>.xfaSelect{flex:0 1 auto}[_nghost-%COMP%] .xfaButton{cursor:pointer;width:100%;height:100%;border:none;text-align:center}[_nghost-%COMP%] .xfaLink{width:100%;height:100%;position:absolute;top:0;left:0}[_nghost-%COMP%] .xfaCheckbox, [_nghost-%COMP%] .xfaRadio{width:100%;height:100%;flex:0 0 auto;border:none}[_nghost-%COMP%] .xfaRich{white-space:pre-wrap;width:100%;height:100%}[_nghost-%COMP%] .xfaImage{object-position:left top;object-fit:contain;width:100%;height:100%}[_nghost-%COMP%] .xfaLrTb, [_nghost-%COMP%] .xfaRlTb, [_nghost-%COMP%] .xfaTb{display:flex;flex-direction:column;align-items:stretch}[_nghost-%COMP%] .xfaLr{display:flex;flex-direction:row;align-items:stretch}[_nghost-%COMP%] .xfaRl{display:flex;flex-direction:row-reverse;align-items:stretch}[_nghost-%COMP%] .xfaTb>div{justify-content:left}[_nghost-%COMP%] .xfaPosition{position:relative}[_nghost-%COMP%] .xfaArea{position:relative}[_nghost-%COMP%] .xfaValignMiddle{display:flex;align-items:center}[_nghost-%COMP%] .xfaTable{display:flex;flex-direction:column;align-items:stretch}[_nghost-%COMP%] .xfaTable .xfaRow{display:flex;flex-direction:row;align-items:stretch}[_nghost-%COMP%] .xfaTable .xfaRlRow{display:flex;flex-direction:row-reverse;align-items:stretch;flex:1}[_nghost-%COMP%] .xfaTable .xfaRlRow>div{flex:1}[_nghost-%COMP%] .xfaNonInteractive input, [_nghost-%COMP%] .xfaNonInteractive textarea, [_nghost-%COMP%] .xfaDisabled input, [_nghost-%COMP%] .xfaDisabled textarea, [_nghost-%COMP%] .xfaReadOnly input, [_nghost-%COMP%] .xfaReadOnly textarea{background:initial}@media print{[_nghost-%COMP%] .xfaTextfield, [_nghost-%COMP%] .xfaSelect{background:transparent}[_nghost-%COMP%] .xfaSelect{-webkit-appearance:none;appearance:none;text-indent:1px;text-overflow:""}}[_nghost-%COMP%] [data-editor-rotation="90"]{transform:rotate(90deg)}[_nghost-%COMP%] [data-editor-rotation="180"]{transform:rotate(180deg)}[_nghost-%COMP%] [data-editor-rotation="270"]{transform:rotate(270deg)}[_nghost-%COMP%] .annotationEditorLayer{background:transparent;position:absolute;top:0;left:0;font-size:calc(100px * var(--scale-factor));transform-origin:0 0}[_nghost-%COMP%] .annotationEditorLayer .selectedEditor{outline:var(--focus-outline);resize:none}[_nghost-%COMP%] .annotationEditorLayer .freeTextEditor{position:absolute;background:transparent;border-radius:3px;padding:calc(var(--freetext-padding) * var(--scale-factor));resize:none;width:auto;height:auto;z-index:1;transform-origin:0 0;touch-action:none}[_nghost-%COMP%] .annotationEditorLayer .freeTextEditor .internal{background:transparent;border:none;top:0;left:0;overflow:visible;white-space:nowrap;resize:none;font:10px sans-serif;line-height:var(--freetext-line-height)}[_nghost-%COMP%] .annotationEditorLayer .freeTextEditor .overlay{position:absolute;display:none;background:transparent;top:0;left:0;width:100%;height:100%}[_nghost-%COMP%] .annotationEditorLayer .freeTextEditor .overlay.enabled{display:block}[_nghost-%COMP%] .annotationEditorLayer .freeTextEditor .internal:empty:before{content:attr(default-content);color:gray}[_nghost-%COMP%] .annotationEditorLayer .freeTextEditor .internal:focus{outline:none}[_nghost-%COMP%] .annotationEditorLayer .inkEditor.disabled{resize:none}[_nghost-%COMP%] .annotationEditorLayer .inkEditor.disabled.selectedEditor{resize:horizontal}[_nghost-%COMP%] .annotationEditorLayer .freeTextEditor:hover:not(.selectedEditor), [_nghost-%COMP%] .annotationEditorLayer .inkEditor:hover:not(.selectedEditor){outline:var(--hover-outline)}[_nghost-%COMP%] .annotationEditorLayer .inkEditor{position:absolute;background:transparent;border-radius:3px;overflow:auto;width:100%;height:100%;z-index:1;transform-origin:0 0;cursor:auto}[_nghost-%COMP%] .annotationEditorLayer .inkEditor.editing{resize:none;cursor:var(--editorInk-editing-cursor),pointer}[_nghost-%COMP%] .annotationEditorLayer .inkEditor .inkEditorCanvas{position:absolute;top:0;left:0;width:100%;height:100%;touch-action:none}[_nghost-%COMP%] [data-main-rotation="90"]{transform:rotate(90deg) translateY(-100%)}[_nghost-%COMP%] [data-main-rotation="180"]{transform:rotate(180deg) translate(-100%,-100%)}[_nghost-%COMP%] [data-main-rotation="270"]{transform:rotate(270deg) translate(-100%)}[_nghost-%COMP%] .pdfViewer{padding-bottom:var(--pdfViewer-padding-bottom)}[_nghost-%COMP%] .pdfViewer .canvasWrapper{overflow:hidden}[_nghost-%COMP%] .pdfViewer .canvasWrapper canvas{width:100%}[_nghost-%COMP%] .pdfViewer .page{direction:ltr;width:816px;height:1056px;margin:var(--page-margin);position:relative;overflow:visible;border:var(--page-border);border-image:var(--page-border-image);background-clip:content-box;background-color:#fff}[_nghost-%COMP%] .pdfViewer .dummyPage{position:relative;width:0;height:var(--viewer-container-height)}[_nghost-%COMP%] .pdfViewer.removePageBorders .page{margin:0 auto 10px;border:none}[_nghost-%COMP%] .pdfViewer.singlePageView{display:inline-block}[_nghost-%COMP%] .pdfViewer.singlePageView .page{margin:0;border:none}[_nghost-%COMP%] .pdfViewer.scrollHorizontal, [_nghost-%COMP%] .pdfViewer.scrollWrapped, [_nghost-%COMP%] .spread{margin-left:3.5px;margin-right:3.5px;text-align:center}[_nghost-%COMP%] .pdfViewer.scrollHorizontal, [_nghost-%COMP%] .spread{white-space:nowrap}[_nghost-%COMP%] .pdfViewer.removePageBorders, [_nghost-%COMP%] .pdfViewer.scrollHorizontal .spread, [_nghost-%COMP%] .pdfViewer.scrollWrapped .spread{margin-left:0;margin-right:0}[_nghost-%COMP%] .spread .page, [_nghost-%COMP%] .spread .dummyPage, [_nghost-%COMP%] .pdfViewer.scrollHorizontal .page, [_nghost-%COMP%] .pdfViewer.scrollWrapped .page, [_nghost-%COMP%] .pdfViewer.scrollHorizontal .spread, [_nghost-%COMP%] .pdfViewer.scrollWrapped .spread{display:inline-block;vertical-align:middle}[_nghost-%COMP%] .spread .page, [_nghost-%COMP%] .pdfViewer.scrollHorizontal .page, [_nghost-%COMP%] .pdfViewer.scrollWrapped .page{margin-left:var(--spreadHorizontalWrapped-margin-LR);margin-right:var(--spreadHorizontalWrapped-margin-LR)}[_nghost-%COMP%] .pdfViewer.removePageBorders .spread .page, [_nghost-%COMP%] .pdfViewer.removePageBorders.scrollHorizontal .page, [_nghost-%COMP%] .pdfViewer.removePageBorders.scrollWrapped .page{margin-left:5px;margin-right:5px}[_nghost-%COMP%] .pdfViewer .page canvas{margin:0;display:block}[_nghost-%COMP%] .pdfViewer .page canvas[hidden]{display:none}[_nghost-%COMP%] .pdfViewer .page .loadingIcon{position:absolute;display:block;inset:0;background:url(data:image/gif;base64,R0lGODlhGAAYAPQQAM7Ozvr6+uDg4LCwsOjo6I6OjsjIyJycnNjY2KioqMDAwPLy8nZ2doaGhri4uGhoaP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/ilPcHRpbWl6ZWQgd2l0aCBodHRwczovL2V6Z2lmLmNvbS9vcHRpbWl6ZQAh+QQJBwAQACwAAAAAGAAYAAAFmiAkjiTkOGVaBgjZNGSgkgKjjM8zLoI8iy+BKCdiCX8iBeMAhEEIPRXLxViYUE9CbCQoFAzFhHY3zkaT3oPvBz1zE4UBsr1eWZH4vAowOBwGAHk8AoQLfH6Agm0Ed3qOAXWOIgQKiWyFJQgDgJEpdG+WEACNEFNFmKVlVzJQk6qdkwqBoi1mebJ3ALNGeIZHtGSwNDS1RZKueCEAIfkECQcAEAAsAAAAABgAGAAABZcgJI4kpChlWgYCWRQkEKgjURgjw4zOg9CjVwuiEyEeO6CxkBC9nA+HiuUqLEyoBZI0Mx4SAFFgQCDZuguBoGv6Dtg0gvpqdhxQQDkBzuUr/4A1JwMKP39pc2mDhYCIc4GQYn6QCwCMeY91l0p6dBAEJ0OfcFRimZ91Mwt0alxxAIZyRmuAsKxDLKKvZbM1tJxmvGKRpn8hACH5BAkHABAALAAAAAAYABgAAAWhICSOJGQYZVoGAnkcJBKoI3EAY1GMCtPSosSBINKJBIwGkHdwBGGQA0OhYpEGQxNqkYzNIITBACEKKBaxxNfBeOCO4vMy0Hg8nDHFeCktkKtfNAtoS4UqAicKBj9zBAKPC4iKi4aRkISGmWWBmjUIAIyHkCUEAKCVo2WmREecVqoCgZhgP4NHrGWCj7e3szSpuxAsoVWxnp6cVV4kyZW+KSEAIfkECQcAEAAsAAAAABgAGAAABZkgJI4kBABlWgYEOQykEKgjMSDjcYxG0dKi108nEhQKQN4rCIMkCgbawjWYnSCLY2yGVSgEooBhWqsGGwxc0RtNBgoMhmJ1QgETjANYFeBKyUmBKQQIdT9JDmgPDQ6EhoKJD4sOgpWWgiwChyqEBH5hmptSoSOZgJ4kLKWkYTF7C2SaqaM/hEWygay4mYG8t6uffFuzl1iANCEAIfkECQcAEAAsAAAAABgAGAAABZ0gJI4khCBlmhKkopBCoI6LIozDMAIHO4uuBVBnOiR+I4FrCDwAZsKdQnaCLIwwmRUA8JmioprWUCjcwlwUMnAoG0qL03k2KCS8cC0UjOzDCQKBfHQFDAwFU4CCfgqFhy9+kZJWgzSKSAcPZn+BfQENDw8OljGWJAFeDoZPYTBnC1GdSXqnsoBolSulX2GyP6hgvnG0KrS3NJNhuSQhACH5BAkHABAALAAAAAAYABgAAAWaICSOJCQIZZoupGGQRKCOC0CMijIiwz2LABtQZxoMfjQhxAXszWQ7gOwECRhh0MCJJRJARTUoIHFAgbfI6uBwAJS01J/i4PClVYHvfV8lbLlIBmwFbQt+aGmChG18jXeGT4dICQxlb4g/AQUMDER9XjR6BAdiDQwINDBmkAsPDVh4cX4imw53iLKuaVqAcUsPqEiidkt6j4AzIQAh+QQJBwAQACwAAAAAGAAYAAAFmSAkjiREEGWaBiSCtCoZCMsIAKOg1LEo0KKbaKFQ9EYLoOkFuQlirNxzCQkUW9GZ0hQd4nyDAWr4G/esYSbyZFYZwu3jqiuvr8u8I2BwOAwASXh1e31/doeHC3klWnElfAlTd46MfQUGk2stCVEGBQWSdCciDg5VDAVYKoEiDQ0iBwxGcj9RDw8+qHIzebc2DJJQJK6qiKVyIQAh+QQJBwAQACwAAAAAGAAYAAAFmSAkjiS0LGWaBiRBtCoZCKgoCCMB1DF0sz6cCQDo5W62l28XAyZFpyECBv3lnCbhUqHMIo0Qg4Jbmn1jRCa4iV27TzfXGjEecOFWMN1OdvvfPGUuXSoKBw6EXokrAwcHRVU0UAeEBANAAAmUI1gNDyhjJgUHLW0iDg8FIqOnBQZrDA9TELE2rEYIDw4jta2LMpCrqld/YQpgIQAh+QQJBwAQACwAAAAAGAAYAAAFmyAkjiS0LGWaBiRBkKw6BgIqCsJcyyMe4yJajhcEml5H26o1PN2QQd3uFiv2AADlAgflIbDdZLgkABOJgep5LfWty4p4zeU+w+XsvJWXliEKDwdEBgMKYQ4PDw1qK3EDCCMAiQ5BCV0LCj+FSDQkgCgGBiYHAy2MIgoMghAHqw4HAGsNDEMFBTekdgwKI7aRB2MwkL2rVHoQoWchACH5BAkHABAALAAAAAAYABgAAAWWICSOJLQsZZoGJEGQrDoGAioKwlzLIx7jIlqOFwSaXkfbqjU83ZBB3e4WK0qrCxyU55peid0qcUwuixyNx6PhILsAcAJazXYj4lvz2MkLiFsHDAlEcABKZwwMBX8pBgoKQxAIigpBA1sLBj+PSDQkB4uSACYDlTMyBgWDEKVnl2QFBUigN61gBQYjtLV5JZ4jtlR6omMhACH5BAkHABAALAAAAAAYABgAAAWaICSOJLQsZZoGJEGQrDoGAioKwlzLIx7jIlqOFwSaXkdbidYanm7I4AjwYDh6saJuJ3JUG1mZi9srPA7EcRimJLrfJYWZUVC8TziXnEG3u/E+cIJaPAFrPQl1aQAIbRAGBZGHJQiMUQKRBkEKbQsAPZaEXQcslSYKmjMyAAdXj34ACkNEiUgDA5t+PAQHn6Ogjkuzry2DNwhuIQAh+QQFBwAQACwAAAAAGAAYAAAFnCAkjiS0LGVaBgBJEGSguo8zCsK4CPIsMg+ECCcKEH0ix6MwhJl4KiOp8UCdmrEbo6EoHpxF8A6aBBZ6vhf5dmAkkGr0CoWs21WGQ2FvsI9xC3l7B311fy93iWGKJQQOhHCAJQB6A3IqcWwJLU90i2FkUiMKlhBELEI6MwgDXRAGhQgAYD6tTqRFAJxpA6mvrqazSKJJhUWMpjlIIQA7) center no-repeat}[_nghost-%COMP%] .pdfViewer .page .loadingIcon.notVisible{background:none}[_nghost-%COMP%] .pdfViewer.enablePermissions .textLayer span{-webkit-user-select:none!important;user-select:none!important;cursor:not-allowed}[_nghost-%COMP%] .pdfPresentationMode .pdfViewer{padding-bottom:0}[_nghost-%COMP%] .pdfPresentationMode .spread{margin:0}[_nghost-%COMP%] .pdfPresentationMode .pdfViewer .page{margin:0 auto;border:2px solid transparent}']})}return o})(),ud=(()=>{class o{static \u0275fac=function(i){return new(i||o)};static \u0275mod=b.$C({type:o});static \u0275inj=T.G2t({})}return o})();var Pr=V(35381),Cr=V(65187),fd=V(42245),pd=V(70063),Tr=V(85971),Mr=V(13319),Lr=V(77089),Rr=V(59352);let Ir=(()=>{class o{getPdfViewerContainer(e){return e.closest("cue-pdf-viewer")?.querySelector(".ng2-pdf-viewer-container")}maintainCenterPosition(e,i,n){const s=this.getPdfViewerContainer(e);if(!s)return{...i,zoom:n(i.zoom)};const r=i.zoom,a=n(r);if(r===a)return i;const c={x:(s.scrollLeft+s.clientWidth/2)*(a/r)-s.clientWidth/2,y:(s.scrollTop+s.clientHeight/2)*(a/r)-s.clientHeight/2};return setTimeout(()=>{s.scrollLeft=Math.max(0,c.x),s.scrollTop=Math.max(0,c.y)},50),{...i,zoom:a,panOffset:c}}zoomAtPoint(e,i,n,s,r){const a=this.getPdfViewerContainer(e);if(!a)return{...i,zoom:n};const l=i.zoom;if(l===n)return i;const h=n/l,u={x:(a.scrollLeft+s)*h-s,y:(a.scrollTop+r)*h-r};return setTimeout(()=>{a.scrollLeft=Math.max(0,u.x),a.scrollTop=Math.max(0,u.y)},50),{...i,zoom:n,panOffset:u}}zoomIn(e,i){return this.maintainCenterPosition(e,i,n=>n+.25)}zoomOut(e,i){return this.maintainCenterPosition(e,i,n=>Math.max(i.minZoom,n-.25))}zoomFit(e,i){return this.maintainCenterPosition(e,i,()=>1)}setPanMode(e,i,n){const s=this.getPdfViewerContainer(e);return s&&(s.style.cursor=n?"grab":"default"),{...i,panMode:n}}startPan(e,i){const n=this.getPdfViewerContainer(e);return n?(i.preventDefault(),n.style.cursor="grabbing",{startX:i.clientX,startY:i.clientY,startScrollX:n.scrollLeft,startScrollY:n.scrollTop}):null}panMove(e,i,n){const s=this.getPdfViewerContainer(e);if(!s)return;i.preventDefault();const a=i.clientY-n.startY;s.scrollLeft=n.startScrollX-(i.clientX-n.startX),s.scrollTop=n.startScrollY-a}endPan(e,i){const n=this.getPdfViewerContainer(e);return n&&(n.style.cursor=i.panMode?"grab":"default"),{...i,panOffset:{x:n?.scrollLeft||0,y:n?.scrollTop||0}}}static \u0275fac=function(i){return new(i||o)};static \u0275prov=T.jDH({token:o,factory:o.\u0275fac,providedIn:"root"})}return o})();var kr=V(76149);function gd(o,t){if(1&o){const e=b.RV6();b.j41(0,"cue-flexcontainer",3)(1,"cue-typography",7),b.EFF(2),b.nI1(3,"transloco"),b.k0s(),b.j41(4,"cue-select",8),b.mxI("valueChange",function(n){T.eBV(e);const s=b.XpG();return b.DH7(s.page,n)||(s.page=n),T.Njj(n)}),b.k0s()()}if(2&o){const e=b.XpG();b.R7$(2),b.JRh(b.bMT(3,5,"components.pdfViewer.labelPage")),b.R7$(2),b.R50("value",e.page),b.Y8G("menuPosition",e.selectMenuPositions())("options",e.pageOptions())("underline",!1)}}function md(o,t){if(1&o){const e=b.RV6();b.j41(0,"cue-flexcontainer",3)(1,"cue-button",9),b.nI1(2,"transloco"),b.bIt("click",function(){T.eBV(e);const n=b.XpG();return T.Njj(n.handleZoomOut())}),b.nrm(3,"cue-button-icon",10),b.k0s(),b.j41(4,"cue-button",9),b.nI1(5,"transloco"),b.bIt("click",function(){T.eBV(e);const n=b.XpG();return T.Njj(n.handleZoomIn())}),b.nrm(6,"cue-button-icon",11),b.k0s(),b.j41(7,"cue-button",12),b.nI1(8,"transloco"),b.bIt("click",function(){T.eBV(e);const n=b.XpG();return T.Njj(n.handleZoomFit())}),b.nrm(9,"cue-button-icon",13),b.k0s()()}if(2&o){const e=b.XpG();b.AVh("border-left",!e.pageSelectHidden()&&e.options().displayZoom),b.R7$(),b.Y8G("cueTooltip",b.bMT(2,6,"components.pdfViewer.tooltipZoomOut")),b.R7$(3),b.Y8G("cueTooltip",b.bMT(5,8,"components.pdfViewer.tooltipZoomIn")),b.R7$(3),b.Y8G("disabled",1===e.settings().zoom)("cueTooltip",b.bMT(8,10,"components.pdfViewer.tooltipZoomFit"))}}function bd(o,t){if(1&o){const e=b.RV6();b.j41(0,"cue-button",14),b.nI1(1,"transloco"),b.bIt("click",function(){T.eBV(e);const n=b.XpG();return T.Njj(n.handleRotate())}),b.nrm(2,"cue-button-icon",15),b.k0s()}if(2&o){const e=b.XpG();b.AVh("border-left",e.options().displayZoom&&e.options().displayRotate),b.Y8G("cueTooltip",b.bMT(1,3,"components.pdfViewer.tooltipRotate"))}}function _d(o,t){if(1&o){const e=b.RV6();b.j41(0,"cue-button",16),b.nI1(1,"transloco"),b.mxI("selectedChange",function(n){T.eBV(e);const s=b.XpG();return b.DH7(s.panMode,n)||(s.panMode=n),T.Njj(n)}),b.nrm(2,"cue-button-icon",17),b.k0s()}if(2&o){const e=b.XpG();b.AVh("border-left",e.options().displayRotate&&e.options().displayPan),b.Y8G("cueTooltip",b.bMT(1,5,"components.pdfViewer.tooltipPan")),b.R50("selected",e.panMode),b.Y8G("toggleButton",!0)}}let vd=(()=>{class o{elementRef=(0,T.WQX)(b.aKT);panZoomService=(0,T.WQX)(Ir);options=(0,X.hFB)(new kr.g);settings=X.geq.required();numPages=(0,X.hFB)(1);page=(0,X.geq)("1");panMode=(0,X.geq)(!1);constructor(){(0,T.QZP)(()=>{const e=this.panMode();this.settings.update(i=>i.panMode!==e?this.panZoomService.setPanMode(this.elementRef.nativeElement,i,e):i)})}pageOptions=(0,ut.EW)(()=>Array.from({length:this.numPages()},(e,i)=>(i+1).toString()));pageSelectHidden=(0,ut.EW)(()=>{const e=this.options().displayPageSelect;return!!(this.options().hidePageSelectOnSinglePageDocument&&this.numPages()<2)||!e});selectMenuPositions=(0,ut.EW)(()=>"top"===this.options().position?"bottomright":"topright");handleZoomIn(){this.settings.update(e=>this.panZoomService.zoomIn(this.elementRef.nativeElement,e))}handleZoomOut(){this.settings.update(e=>this.panZoomService.zoomOut(this.elementRef.nativeElement,e))}handleZoomFit(){this.settings.update(e=>this.panZoomService.zoomFit(this.elementRef.nativeElement,e))}handleRotate(){this.settings.update(e=>(e.rotation+=90,e))}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=b.VBU({type:o,selectors:[["cue-pdf-toolbar"]],inputs:{options:[1,"options"],settings:[1,"settings"],numPages:[1,"numPages"],page:[1,"page"],panMode:[1,"panMode"]},outputs:{settings:"settingsChange",page:"pageChange",panMode:"panModeChange"},decls:7,vars:5,consts:[["justify","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["align","center","gap","s",3,"border-left"],["size","xs","variant","ghost",3,"cueTooltip","border-left"],["size","xs","variant","tertiary",3,"cueTooltip","border-left","selected","toggleButton"],["size","s"],["size","xs","placeholder","Select",3,"valueChange","value","menuPosition","options","underline"],["size","xs","variant","tertiary",3,"click","cueTooltip"],["icon","zoom-out"],["icon","zoom-in"],["size","xs","variant","tertiary",3,"click","disabled","cueTooltip"],["icon","zoom-fit"],["size","xs","variant","ghost",3,"click","cueTooltip"],["icon","rotate-2d"],["size","xs","variant","tertiary",3,"selectedChange","cueTooltip","selected","toggleButton"],["icon","move-click"]],template:function(i,n){1&i&&(b.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),b.nVh(3,gd,5,7,"cue-flexcontainer",3),b.nVh(4,md,10,12,"cue-flexcontainer",4),b.nVh(5,bd,3,5,"cue-button",5),b.nVh(6,_d,3,7,"cue-button",6),b.k0s()()()),2&i&&(b.R7$(),b.Y8G("padded",!1),b.R7$(2),b.vxM(n.options().displayPageSelect&&!n.pageSelectHidden()?3:-1),b.R7$(),b.vxM(n.options().displayZoom?4:-1),b.R7$(),b.vxM(n.options().displayRotate?5:-1),b.R7$(),b.vxM(n.options().displayPan?6:-1))},dependencies:[Pr.FlexContainer,Cr.Card,fd.Typography,pd.Select,Tr.Button,Mr.ButtonIcon,Lr.d,Rr.Kj],styles:[".container[_ngcontent-%COMP%]{width:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return o})();var Ad=V(97851),wd=V(49769),yd=V(2036),Ed=V(73191);let Nr=(()=>{class o{_panZoomService;_hostEl;_settings;_minZoom;_startDistance=0;_startZoom=1;_touchStart=null;_touchMove=null;_touchEnd=null;_wheel=null;_virtualScroll={x:0,y:0};_lastPinchTime=0;pendingScroll=null;init(e,i,n,s){this._panZoomService=e,this._hostEl=i,this._settings=n,this._minZoom=s}attach(){const e=this._getContainer();!e||this._touchStart||(e.style.touchAction="none",this._touchStart=i=>{2===i.touches.length&&(i.preventDefault(),this._startDistance=o._dist(i.touches[0],i.touches[1]),this._startZoom=this._settings().zoom)},this._touchMove=i=>{if(2!==i.touches.length||0===this._startDistance)return;i.preventDefault();const n=o._dist(i.touches[0],i.touches[1])/this._startDistance,s=e.getBoundingClientRect();this._applyTransform(n,(i.touches[0].clientX+i.touches[1].clientX)/2-s.left,(i.touches[0].clientY+i.touches[1].clientY)/2-s.top)},this._touchEnd=i=>{if(i.touches.length>=2||0===this._startDistance)return;const s=this._hostEl.querySelector("pdf-viewer")?.style.transform.match(/scale\(([\d.]+)\)/),r=s?parseFloat(s[1]):1,a=Math.min(5,Math.max(this._minZoom(),this._startZoom*r));this._clearTransform(),this._settings.update(l=>this._panZoomService.zoomAtPoint(this._hostEl,l,a,e.clientWidth/2,e.clientHeight/2)),this._startDistance=0},this._wheel=i=>{if(!i.ctrlKey)return;i.preventDefault(),i.stopPropagation();const n=Date.now();n-this._lastPinchTime>300&&(this._virtualScroll={x:e.scrollLeft,y:e.scrollTop}),this._lastPinchTime=n;const s=this._settings().zoom,r=Math.min(5,Math.max(this._minZoom(),s*(1-.003*i.deltaY)));if(r===s)return;const a=e.getBoundingClientRect(),l=i.clientX-a.left,h=i.clientY-a.top,c=r/s;this._virtualScroll={x:Math.max(0,(this._virtualScroll.x+l)*c-l),y:Math.max(0,(this._virtualScroll.y+h)*c-h)},this.pendingScroll={...this._virtualScroll},this._settings.update(d=>({...d,zoom:r}))},e.addEventListener("touchstart",this._touchStart,{passive:!1}),e.addEventListener("touchmove",this._touchMove,{passive:!1}),e.addEventListener("touchend",this._touchEnd,{passive:!1}),e.addEventListener("wheel",this._wheel,{passive:!1,capture:!0}))}detach(){const e=this._getContainer();e&&(e.style.touchAction=""),this._touchStart&&(e?.removeEventListener("touchstart",this._touchStart),this._touchStart=null),this._touchMove&&(e?.removeEventListener("touchmove",this._touchMove),this._touchMove=null),this._touchEnd&&(e?.removeEventListener("touchend",this._touchEnd),this._touchEnd=null),this._wheel&&(e?.removeEventListener("wheel",this._wheel,{capture:!0}),this._wheel=null)}applyPendingScroll(){if(!this.pendingScroll)return;const e=this.pendingScroll;this.pendingScroll=null;const i=this._getContainer();i&&(i.scrollLeft=e.x,i.scrollTop=e.y)}handleDrawOverlayPinch(e){const i=this._getContainer();if(!i)return;const n=Date.now();n-this._lastPinchTime>300&&(this._virtualScroll={x:i.scrollLeft,y:i.scrollTop}),this._lastPinchTime=n;const s=this._settings().zoom,r=Math.min(5,Math.max(this._minZoom(),s*(1-.003*e.deltaY)));if(r===s)return;const a=i.getBoundingClientRect(),l=e.clientX-a.left,h=e.clientY-a.top,c=r/s;this._virtualScroll={x:Math.max(0,(this._virtualScroll.x+l)*c-l),y:Math.max(0,(this._virtualScroll.y+h)*c-h)},this.pendingScroll={...this._virtualScroll},this._settings.update(d=>({...d,zoom:r}))}handleOverlayTouchStart(e){2!==e.touches.length||!this._getContainer()||(this._startDistance=o._dist(e.touches[0],e.touches[1]),this._startZoom=this._settings().zoom)}handleOverlayTouchMove(e){if(2!==e.touches.length||0===this._startDistance)return;const i=this._getContainer();if(!i)return;const n=o._dist(e.touches[0],e.touches[1])/this._startDistance,s=i.getBoundingClientRect();this._applyTransform(n,(e.touches[0].clientX+e.touches[1].clientX)/2-s.left,(e.touches[0].clientY+e.touches[1].clientY)/2-s.top)}handleOverlayTouchEnd(e){if(e.touches.length>=2||0===this._startDistance)return;const i=this._getContainer();if(!i)return;const s=this._hostEl.querySelector("pdf-viewer")?.style.transform.match(/scale\(([\d.]+)\)/),r=s?parseFloat(s[1]):1,a=Math.min(5,Math.max(this._minZoom(),this._startZoom*r));this._clearTransform(),this._settings.update(l=>this._panZoomService.zoomAtPoint(this._hostEl,l,a,i.clientWidth/2,i.clientHeight/2)),this._startDistance=0}_getContainer(){return this._hostEl?.querySelector(".ng2-pdf-viewer-container")}static _dist(e,i){const n=i.clientX-e.clientX,s=i.clientY-e.clientY;return Math.sqrt(n*n+s*s)}_applyTransform(e,i,n){const s=this._hostEl.querySelector("pdf-viewer");s&&(s.style.transformOrigin=`${i}px ${n}px`,s.style.transform=`scale(${e})`)}_clearTransform(){const e=this._hostEl.querySelector("pdf-viewer");e&&(e.style.transform="",e.style.transformOrigin="")}static \u0275fac=function(i){return new(i||o)};static \u0275prov=T.jDH({token:o,factory:o.\u0275fac})}return o})(),Fr=(()=>{class o{_hostEl;canvasRect=(0,T.vPA)(null);_scrollListener=null;_canvasResizeObserver=null;init(e){this._hostEl=e}updateCanvasRect(){const e=this._hostEl?.querySelector(".container"),i=this._hostEl?.querySelector("pdf-viewer canvas");if(!e||!i)return void this.canvasRect.set(null);const n=e.getBoundingClientRect(),s=i.getBoundingClientRect();this.canvasRect.set({left:s.left-n.left,top:s.top-n.top,width:s.width,height:s.height})}attachCanvasResizeObserver(){if(this._canvasResizeObserver)return;const e=this._hostEl?.querySelector("pdf-viewer canvas");e&&(this._canvasResizeObserver=new ResizeObserver(()=>this.updateCanvasRect()),this._canvasResizeObserver.observe(e))}detachCanvasResizeObserver(){this._canvasResizeObserver?.disconnect(),this._canvasResizeObserver=null}attachScrollListener(){const e=this._hostEl?.querySelector(".ng2-pdf-viewer-container");!e||this._scrollListener||(this._scrollListener=()=>this.updateCanvasRect(),e.addEventListener("scroll",this._scrollListener,{passive:!0}))}detachScrollListener(){this._scrollListener&&(this._hostEl?.querySelector(".ng2-pdf-viewer-container")?.removeEventListener("scroll",this._scrollListener),this._scrollListener=null)}destroy(){this.detachScrollListener(),this.detachCanvasResizeObserver(),this.canvasRect.set(null)}static \u0275fac=function(i){return new(i||o)};static \u0275prov=T.jDH({token:o,factory:o.\u0275fac})}return o})();const Br="cue-search-highlight";let Vr=(()=>{class o{_hostEl;_searchService;_currentPage;_searchResults;pdfDoc=(0,T.vPA)(null);searchTerm=(0,T.vPA)("");allMatches=(0,T.vPA)([]);currentPageHighlights=(0,ut.EW)(()=>{const e=this._currentPage?.()??1;return this.allMatches().filter(i=>i.page===e).map(i=>{const n=i.xywhStr.replace("percent:","").split(",").map(h=>parseFloat(h.trim()));if(4!==n.length||n.some(isNaN))return null;const[s,r,a,l]=n;return{x:s,y:r,width:a,height:l}}).filter(Boolean)});_scheduleTimer=null;_canvasResizeObserver=null;init(e){this._hostEl=e.hostEl,this._searchService=e.searchService,this._currentPage=e.currentPage,this._searchResults=e.searchResults}attachCanvasResizeObserver(){if(this._canvasResizeObserver)return;const e=this._hostEl.querySelector("pdf-viewer canvas");e&&(this._canvasResizeObserver=new ResizeObserver(()=>this.scheduleRender()),this._canvasResizeObserver.observe(e))}detachCanvasResizeObserver(){this._canvasResizeObserver?.disconnect(),this._canvasResizeObserver=null}destroy(){this.detachCanvasResizeObserver(),this._scheduleTimer&&clearTimeout(this._scheduleTimer)}runSearch(){var e=this;return(0,x.A)(function*(){const i=e.pdfDoc(),n=e.searchTerm();if(e.allMatches.set([]),!i||!n?.trim())return e.clearHighlights(),void e._searchResults.emit([]);const s=yield e._searchService.searchAll(i,n);e.allMatches.set(s),e._searchResults.emit(s),e.renderHighlights()})()}scheduleRender(e=-1){this._scheduleTimer&&clearTimeout(this._scheduleTimer),this._scheduleTimer=setTimeout(()=>this.renderHighlights(e),50)}renderHighlights(e=-1){this.clearHighlights();const i=this.currentPageHighlights();if(0===i.length)return;const n=this._hostEl.querySelector("pdf-viewer .page"),s=this._hostEl.querySelector("pdf-viewer canvas");if(!n||!s)return;const r=s.clientWidth,a=s.clientHeight,l=n.getBoundingClientRect(),h=s.getBoundingClientRect(),c=h.left-l.left,d=h.top-l.top,u=this._currentPage?.()??1,f=this.allMatches(),p=e>=0?f.slice(0,e).filter(_=>_.page===u).length:-1,g=e>=0&&f[e]?.page===u;for(let _=0;_<i.length;_++){const m=i[_],A=g&&_===p,v=document.createElement("div");v.className=Br+(A?" cue-search-active":""),v.style.cssText=`\n position: absolute;\n left: ${c+m.x/100*r}px;\n top: ${d+m.y/100*a}px;\n width: ${m.width/100*r}px;\n height: ${m.height/100*a}px;\n background-color: ${A?"rgba(30, 120, 255, 0.30)":"rgba(255, 200, 0, 0.35)"};\n border: ${A?"2px solid rgba(30, 120, 255, 0.90)":"1.5px solid rgba(255, 160, 0, 0.85)"};\n border-radius: 2px;\n box-sizing: border-box;\n pointer-events: none;\n z-index: 4;\n ${A?"":"animation: cue-highlight-pulse 2s ease-in-out infinite;"}\n `,n.appendChild(v),A&&v.scrollIntoView({block:"center",behavior:"smooth"})}o._ensureStyles()}clearHighlights(){this._hostEl?.querySelectorAll(`.${Br}`).forEach(e=>e.remove())}static _stylesInjected=!1;static _ensureStyles(){if(o._stylesInjected)return;o._stylesInjected=!0;const e=document.createElement("style");e.textContent="\n @keyframes cue-highlight-pulse {\n 0%, 100% { background-color: rgba(255, 200, 0, 0.40); }\n 50% { background-color: rgba(255, 200, 0, 0.62); }\n }\n ",document.head.appendChild(e)}static \u0275fac=function(i){return new(i||o)};static \u0275prov=T.jDH({token:o,factory:o.\u0275fac})}return o})();var xn=V(78560),Sd=V(45600);const Pd=["searchBarInput"],Cd=o=>({count:o});function Td(o,t){if(1&o){const e=b.RV6();b.j41(0,"div",5),b.bIt("wheel",function(n){T.eBV(e);const s=b.XpG();return T.Njj(s.onDrawOverlayWheel(n))})("touchstart",function(n){T.eBV(e);const s=b.XpG();return T.Njj(s.onOverlayTouchStart(n))})("touchmove",function(n){T.eBV(e);const s=b.XpG();return T.Njj(s.onOverlayTouchMove(n))})("touchend",function(n){T.eBV(e);const s=b.XpG();return T.Njj(s.onOverlayTouchEnd(n))}),b.j41(1,"cue-image-viewer",6),b.mxI("drawingArtefactsChange",function(n){T.eBV(e);const s=b.XpG();return b.DH7(s.drawingArtefacts,n)||(s.drawingArtefacts=n),T.Njj(n)}),b.bIt("artefactDrawn",function(n){T.eBV(e);const s=b.XpG();return T.Njj(s.artefactDrawn.emit(n))})("artefactRemoved",function(n){T.eBV(e);const s=b.XpG();return T.Njj(s.artefactRemoved.emit(n))})("artefactSelected",function(n){T.eBV(e);const s=b.XpG();return T.Njj(s.artefactSelected.emit(n))})("artefactEdited",function(n){T.eBV(e);const s=b.XpG();return T.Njj(s.artefactEdited.emit(n))}),b.k0s()()}if(2&o){const e=t,i=b.XpG();b.xc7("left",e.left,"px")("top",e.top,"px")("width",e.width,"px")("height",e.height,"px"),b.AVh("draw-active",i.isEditOrDrawModeActive()),b.R7$(),b.Y8G("src",i._drawerSrc())("panDisabled",!0)("zoomDisabled",!0)("drawMode",i._drawMode())("drawnArtefactDef",i.drawnArtefactDef())("contextMenuItems",i.contextMenuItems()),b.R50("drawingArtefacts",i.drawingArtefacts),b.Y8G("toolbarOptions",i._drawerToolbar)}}function Md(o,t){if(1&o){const e=b.RV6();b.j41(0,"cue-pdf-toolbar",8),b.mxI("pageChange",function(n){T.eBV(e),b.XpG(2);const s=b.r8f(1);return b.DH7(s.page,n)||(s.page=n),T.Njj(n)})("settingsChange",function(n){T.eBV(e);const s=b.XpG(2);return b.DH7(s.settings,n)||(s.settings=n),T.Njj(n)})("panModeChange",function(n){T.eBV(e);const s=b.XpG(2);return b.DH7(s.panMode,n)||(s.panMode=n),T.Njj(n)}),b.k0s()}if(2&o){const e=b.XpG(),i=b.XpG(),n=b.r8f(1);b.Aen(i.toolbarStyle()),b.Y8G("options",e),b.R50("page",n.page)("settings",i.settings),b.Y8G("numPages",i.numPages()),b.R50("panMode",i.panMode)}}function Ld(o,t){1&o&&b.nVh(0,Md,1,7,"cue-pdf-toolbar",7),2&o&&b.vxM(t.hidden?-1:0)}function Rd(o,t){if(1&o&&(b.j41(0,"span",18),b.nI1(1,"transloco"),b.EFF(2," \xa0\u25cf "),b.k0s()),2&o){const e=b.XpG(3);b.Y8G("cueTooltip",b.i5U(1,1,"components.pdfViewer.searchOtherPages",b.eq3(4,Cd,e._otherPageMatchCount())))}}function Id(o,t){if(1&o&&(b.j41(0,"span",12),b.EFF(1),b.nVh(2,Rd,3,6,"span",18),b.k0s()),2&o){const e=b.XpG(2);b.R7$(),b.Lme(" ",e._searchMatchIndex()+1,"\u2009/\u2009",e._allMatchCount()," "),b.R7$(),b.vxM(e._otherPageMatchCount()>0?2:-1)}}function kd(o,t){if(1&o){const e=b.RV6();b.j41(0,"cue-card",9),b.bIt("keydown.escape",function(){T.eBV(e);const n=b.XpG();return T.Njj(n._closeSearch())}),b.j41(1,"cue-flexcontainer",10)(2,"input",11,0),b.nI1(4,"transloco"),b.bIt("input",function(n){T.eBV(e);const s=b.XpG();return T.Njj(s._onSearchInput(n.target.value))})("keydown.enter",function(){T.eBV(e);const n=b.XpG();return T.Njj(n._searchNext())})("keydown.escape",function(){T.eBV(e);const n=b.XpG();return T.Njj(n._closeSearch())}),b.k0s(),b.nVh(5,Id,3,3,"span",12),b.j41(6,"cue-button",13),b.nI1(7,"transloco"),b.bIt("click",function(){T.eBV(e);const n=b.XpG();return T.Njj(n._searchPrev())}),b.nrm(8,"cue-button-icon",14),b.k0s(),b.j41(9,"cue-button",13),b.nI1(10,"transloco"),b.bIt("click",function(){T.eBV(e);const n=b.XpG();return T.Njj(n._searchNext())}),b.nrm(11,"cue-button-icon",15),b.k0s(),b.j41(12,"cue-button",16),b.nI1(13,"transloco"),b.bIt("click",function(){T.eBV(e);const n=b.XpG();return T.Njj(n._closeSearch())}),b.nrm(14,"cue-button-icon",17),b.k0s()()()}if(2&o){const e=b.XpG();b.R7$(2),b.Y8G("value",e._searchValue())("placeholder",b.bMT(4,8,"components.pdfViewer.searchPlaceholder")),b.R7$(3),b.vxM(e._searchValue()?5:-1),b.R7$(),b.Y8G("disabled",0===e._allMatchCount())("cueTooltip",b.bMT(7,10,"components.pdfViewer.searchPrev")),b.R7$(3),b.Y8G("disabled",0===e._allMatchCount())("cueTooltip",b.bMT(10,12,"components.pdfViewer.searchNext")),b.R7$(3),b.Y8G("cueTooltip",b.bMT(13,14,"components.pdfViewer.searchClose"))}}let Dd=(()=>{class o{elementRef=(0,T.WQX)(b.aKT);panZoomSvc=(0,T.WQX)(Ir);searchSvc=(0,T.WQX)(Ed.g);drawing=(0,T.WQX)(Fr);pinch=(0,T.WQX)(Nr);highlight=(0,T.WQX)(Vr);src=(0,X.hFB)("");settings=(0,X.geq)(new kr._);panMode=(0,X.geq)(!1);drawMode=(0,X.hFB)("none");contextMenuItems=(0,X.hFB)([]);drawnArtefactDef=(0,X.hFB)({allowRemove:!0,color:"rgba(0, 120, 255, 0.8)"});searchTerm=(0,X.hFB)("");searchResults=(0,X.CGW)();pdfLoaded=(0,X.CGW)();drawingArtefacts=(0,X.geq)((0,yd.x)());artefactDrawn=(0,X.CGW)();artefactRemoved=(0,X.CGW)();artefactSelected=(0,X.CGW)();artefactEdited=(0,X.CGW)();_imageViewer=(0,X.ebz)(xn.ImageViewer);_searchBarInput=(0,X.ebz)("searchBarInput");activateEditForBbox(e){const i=this._imageViewer();i&&i.editService.startEditArtefact("bbox",e)}numPages=(0,T.vPA)(1);loading=(0,T.vPA)(!0);minZoom=(0,T.vPA)(.1);_searchOpen=(0,T.vPA)(!1);_searchValue=(0,T.vPA)("");_searchMatchIndex=(0,T.vPA)(0);_allMatchCount=(0,ut.EW)(()=>this.highlight.allMatches().length);_otherPageMatchCount=(0,ut.EW)(()=>{const e=Number(this.settings().page)||1;return this.highlight.allMatches().filter(i=>i.page!==e).length});_onKeydown(e){(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),e.stopPropagation(),this._searchOpen.set(!0),setTimeout(()=>this._searchBarInput()?.nativeElement?.focus()))}_onSearchInput(e){this._searchMatchIndex.set(0),this.highlight.searchTerm.set(e),this.highlight.runSearch()}_searchNext(){const e=this._allMatchCount();if(0===e)return;const i=(this._searchMatchIndex()+1)%e;this._searchMatchIndex.set(i),this._jumpToMatch(i)}_searchPrev(){const e=this._allMatchCount();if(0===e)return;const i=(this._searchMatchIndex()-1+e)%e;this._searchMatchIndex.set(i),this._jumpToMatch(i)}_jumpToMatch(e){const i=this.highlight.allMatches()[e];if(!i)return;const n=String(i.page);this.settings().page!==n?this.settings.update(s=>({...s,page:n})):this.highlight.renderHighlights(e)}_closeSearch(){this._searchOpen.set(!1),this._searchValue.set(""),this._searchMatchIndex.set(0),this.highlight.searchTerm.set(""),this.highlight.clearHighlights()}_srcEffect=(0,T.QZP)(()=>{console.log("[PDFViewer] src changed:",this.src()?.substring(0,100))});isPanning=(0,T.vPA)(!1);panStart=(0,T.vPA)(null);isMiddlePanning=(0,T.vPA)(!1);middlePanStart=(0,T.vPA)(null);_midMoveListener=this._onMiddlePanMove.bind(this);_midUpListener=this._onMiddlePanUp.bind(this);isDrawModeActive=(0,ut.EW)(()=>"none"!==this._drawMode());isEditOrDrawModeActive=(0,ut.EW)(()=>this.isDrawModeActive()||this.settings().editMode||null!==this._imageViewer()?.editService.editingArtefact());_lastScrolledBbox=null;_drawMode=(0,ut.EW)(()=>{const e=this.settings().drawMode||this.drawMode();return"xywh"===e||"polygon"===e||"circle"===e?e:"none"});_drawerSrc=(0,ut.EW)(()=>{const e=this.drawing.canvasRect();return e?`data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="${2*Math.round(e.width/2)}" height="${2*Math.round(e.height/2)}"/>`:""});_drawerToolbar=Object.assign(new Sd.g,{hidden:!0});currentPageNum=(0,ut.EW)(()=>Number(this.settings().page)||1);constructor(){const e=this.elementRef.nativeElement;this.pinch.init(this.panZoomSvc,e,this.settings,this.minZoom),this.drawing.init(e),this.highlight.init({hostEl:e,searchService:this.searchSvc,currentPage:this.currentPageNum,searchResults:this.searchResults}),(0,T.QZP)(()=>{this.settings.update(i=>this.panZoomSvc.setPanMode(e,i,this.panMode()))}),(0,T.QZP)(()=>{this.highlight.pdfDoc();const n=this.searchTerm();this.highlight.searchTerm.set(n),this.highlight.runSearch()}),(0,T.QZP)(()=>{0===this.highlight.currentPageHighlights().length&&this.highlight.clearHighlights(),this.highlight.scheduleRender(this._searchMatchIndex())}),(0,T.QZP)(()=>{const i=this.settings().drawingArtefacts;this.drawingArtefacts.set(i)}),(0,T.QZP)(()=>{const i=this._imageViewer(),n=this.settings().editMode,s=this.drawingArtefacts();!i||!n||0===s.xywhs.length||queueMicrotask(()=>this.activateEditForBbox(0))}),(0,T.QZP)(()=>{const i=this.drawingArtefacts(),n=this.drawing.canvasRect(),s=i.xywhs[0];s?n&&this._lastScrolledBbox!==s.xywhStr&&(this._lastScrolledBbox=s.xywhStr,this.scrollToBbox(s)):this._lastScrolledBbox=null})}ngOnDestroy(){this.pinch.detach(),this.drawing.destroy(),this.highlight.destroy(),this._stopMiddlePan()}onPdfLoaded(e){var i=this;return(0,x.A)(function*(){console.log("[PDFViewer] onPdfLoaded \u2014 pages:",e.numPages),i.numPages.set(e.numPages),i.loading.set(!1),i.highlight.pdfDoc.set(e),i.pdfLoaded.emit(e)})()}onPageRendered(){this.drawing.detachScrollListener(),this.drawing.attachScrollListener(),this.drawing.detachCanvasResizeObserver(),this.drawing.attachCanvasResizeObserver(),this.highlight.detachCanvasResizeObserver(),this.highlight.attachCanvasResizeObserver(),this._updateMinZoom(),this.highlight.renderHighlights(),this.pinch.attach(),this.pinch.applyPendingScroll(),requestAnimationFrame(()=>this.drawing.updateCanvasRect())}toolbarStyle(){const e=this.settings().toolbarOptions;return`left:${e.margin};right:${e.margin};${"top"===e.position?"top":"bottom"}:${e.margin}`}_overlayPinching=!1;onOverlayTouchStart(e){e.touches.length>=2&&(e.preventDefault(),this._overlayPinching=!0,this.pinch.handleOverlayTouchStart(e))}onOverlayTouchMove(e){(this._overlayPinching||e.touches.length>=2)&&(e.preventDefault(),this._overlayPinching=!0,this.pinch.handleOverlayTouchMove(e))}onOverlayTouchEnd(e){this._overlayPinching&&(this.pinch.handleOverlayTouchEnd(e),e.touches.length<2&&(this._overlayPinching=!1))}onMouseDown(e){if(1===e.button){e.preventDefault();const n=this.panZoomSvc.startPan(this.elementRef.nativeElement,e);return void(n&&(this.isMiddlePanning.set(!0),this.middlePanStart.set(n),window.addEventListener("mousemove",this._midMoveListener),window.addEventListener("mouseup",this._midUpListener)))}if(!this.panMode()||0!==e.button)return;const i=this.panZoomSvc.startPan(this.elementRef.nativeElement,e);i&&(this.isPanning.set(!0),this.panStart.set(i))}onMouseMove(e){!this.isPanning()||!this.panStart()||this.panZoomSvc.panMove(this.elementRef.nativeElement,e,this.panStart())}onMouseUp(){this.isPanning()&&(this.settings.update(e=>this.panZoomSvc.endPan(this.elementRef.nativeElement,e)),this.isPanning.set(!1),this.panStart.set(null))}_onMiddlePanMove(e){!this.isMiddlePanning()||!this.middlePanStart()||this.panZoomSvc.panMove(this.elementRef.nativeElement,e,this.middlePanStart())}_onMiddlePanUp(e){1===e.button&&this._stopMiddlePan()}_stopMiddlePan(){window.removeEventListener("mousemove",this._midMoveListener),window.removeEventListener("mouseup",this._midUpListener),this.isMiddlePanning()&&(this.settings.update(e=>this.panZoomSvc.endPan(this.elementRef.nativeElement,e)),this.isMiddlePanning.set(!1),this.middlePanStart.set(null))}onDrawOverlayWheel(e){const i=this.elementRef.nativeElement.querySelector(".ng2-pdf-viewer-container");i&&(e.preventDefault(),e.ctrlKey?this.pinch.handleDrawOverlayPinch(e):(i.scrollTop+=e.deltaY,i.scrollLeft+=e.deltaX))}scrollToBbox(e){const i=this.elementRef.nativeElement.querySelector(".ng2-pdf-viewer-container"),n=this.elementRef.nativeElement.querySelector(".container"),s=this.drawing.canvasRect();if(!i||!n||!s)return;const a=e.xywhStr.replace("percent:","").split(",").map(Number);if(a.length<4||a.some(isNaN))return;const[,l,,h]=a,c=n.getBoundingClientRect(),d=i.getBoundingClientRect();i.scrollBy({top:c.top+s.top+l/100*s.height+h/100*s.height/2-(d.top+d.height/2),behavior:"smooth"})}_updateMinZoom(){const e=this.elementRef.nativeElement.querySelector(".ng2-pdf-viewer-container");if(!e)return;const i=e.querySelector("canvas");if(!i)return;const n=this.settings().zoom;if(n<=0)return;const s=i.offsetWidth/n,r=i.offsetHeight/n;if(s<=0||r<=0)return;const a=Math.min(e.clientWidth/s,e.clientHeight/r),l=Math.max(.05,a);this.minZoom.set(l),this.settings.update(h=>({...h,minZoom:l}))}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=b.VBU({type:o,selectors:[["cue-pdf-viewer"]],viewQuery:function(i,n){1&i&&b.wEZ(n._imageViewer,xn.ImageViewer,5)(n._searchBarInput,Pd,5),2&i&&b.NyB(2)},inputs:{src:[1,"src"],settings:[1,"settings"],panMode:[1,"panMode"],drawMode:[1,"drawMode"],contextMenuItems:[1,"contextMenuItems"],drawnArtefactDef:[1,"drawnArtefactDef"],searchTerm:[1,"searchTerm"],drawingArtefacts:[1,"drawingArtefacts"]},outputs:{settings:"settingsChange",panMode:"panModeChange",searchResults:"searchResults",pdfLoaded:"pdfLoaded",drawingArtefacts:"drawingArtefactsChange",artefactDrawn:"artefactDrawn",artefactRemoved:"artefactRemoved",artefactSelected:"artefactSelected",artefactEdited:"artefactEdited"},features:[b.Jv_([Nr,Fr,Vr])],decls:6,vars:26,consts:[["searchBarInput",""],["direction","column","align","center","justify","center","tabindex","-1",1,"container",3,"mousedown","mousemove","mouseup","mouseleave","keydown","cueLogoLoader"],[2,"width","100%","height","100%",3,"after-load-complete","page-rendered","src","page","render-text","render-text-mode","original-size","stick-to-page","zoom","rotation","external-link-target","autoresize","fit-to-page","show-borders","show-all"],[1,"drawing-overlay",3,"draw-active","left","top","width","height"],["variant","default",1,"pdf-search-card"],[1,"drawing-overlay",3,"wheel","touchstart","touchmove","touchend"],["fitMode","contain",2,"width","100%","height","100%",3,"drawingArtefactsChange","artefactDrawn","artefactRemoved","artefactSelected","artefactEdited","src","panDisabled","zoomDisabled","drawMode","drawnArtefactDef","contextMenuItems","drawingArtefacts","toolbarOptions"],[3,"style","options","page","settings","numPages","panMode"],[3,"pageChange","settingsChange","panModeChange","options","page","settings","numPages","panMode"],["variant","default",1,"pdf-search-card",3,"keydown.escape"],["align","center","gap","s"],["type","text",1,"pdf-search-input",3,"input","keydown.enter","keydown.escape","value","placeholder"],[1,"pdf-search-count"],["size","xs","variant","tertiary",3,"click","disabled","cueTooltip"],["icon","arrow-up"],["icon","arrow-down"],["size","xs","variant","tertiary",3,"click","cueTooltip"],["icon","close"],[1,"pdf-search-other",3,"cueTooltip"]],template:function(i,n){if(1&i&&(b.j41(0,"cue-flexcontainer",1),b.bIt("mousedown",function(r){return n.onMouseDown(r)})("mousemove",function(r){return n.onMouseMove(r)})("mouseup",function(){return n.onMouseUp()})("mouseleave",function(){return n.onMouseUp()})("keydown",function(r){return n._onKeydown(r)}),b.SS7(1),b.j41(2,"pdf-viewer",2),b.bIt("after-load-complete",function(r){return n.onPdfLoaded(r)})("page-rendered",function(){return n.onPageRendered()}),b.k0s(),b.nVh(3,Td,2,18,"div",3),b.nVh(4,Ld,1,1),b.nVh(5,kd,15,16,"cue-card",4),b.k0s()),2&i){let s,r;b.AVh("pan-mode",n.panMode())("draw-mode",n.isDrawModeActive())("edit-mode",n.isEditOrDrawModeActive())("middle-panning",n.isMiddlePanning()),b.Y8G("cueLogoLoader",n.loading()),b.R7$();const a=b.bH3(n.settings());b.R7$(),b.Y8G("src",n.src())("page",a.page)("render-text",a.renderText)("render-text-mode",a.renderTextMode)("original-size",a.originalSize)("stick-to-page",a.stickToPage)("zoom",a.zoom)("rotation",a.rotation)("external-link-target",a.externalLinkTarget)("autoresize",a.autoresize)("fit-to-page",a.fitToPage)("show-borders",a.showBorders)("show-all",!1),b.R7$(),b.vxM((s=n.drawing.canvasRect())?3:-1,s),b.R7$(),b.vxM((r=a.toolbarOptions)?4:-1,r),b.R7$(),b.vxM(n._searchOpen()?5:-1)}},dependencies:[ud,dd,vd,Pr.FlexContainer,wd.MD,xn.ImageViewer,Ad.k,Cr.Card,Tr.Button,Mr.ButtonIcon,Lr.d,Rr.Kj],styles:["[_nghost-%COMP%]{display:contents}.container[_ngcontent-%COMP%]{width:100%;height:100%;position:relative}.container.pan-mode[_ngcontent-%COMP%]{cursor:grab;-webkit-user-select:none;user-select:none}.container.pan-mode[_ngcontent-%COMP%]:active{cursor:grabbing}.container.draw-mode[_ngcontent-%COMP%]{cursor:crosshair;-webkit-user-select:none;user-select:none}.container.edit-mode[_ngcontent-%COMP%]{cursor:move;-webkit-user-select:none;user-select:none}.container.middle-panning[_ngcontent-%COMP%], .container.middle-panning[_ngcontent-%COMP%] .drawing-overlay[_ngcontent-%COMP%]{cursor:grabbing!important;-webkit-user-select:none;user-select:none}cue-pdf-toolbar[_ngcontent-%COMP%]{position:absolute;z-index:10}.pdf-search-card[_ngcontent-%COMP%]{position:absolute;top:8px;right:8px;z-index:20}.pdf-search-input[_ngcontent-%COMP%]{border:none;outline:none;background:transparent;color:var(--cue-main-foreground);font-size:.875rem;min-width:180px;font-family:var(--cue-font-family)}.pdf-search-count[_ngcontent-%COMP%]{font-size:.75rem;white-space:nowrap;opacity:.6}.pdf-search-other[_ngcontent-%COMP%]{cursor:help;color:var(--cue-color-blue)}.drawing-overlay[_ngcontent-%COMP%]{position:absolute;z-index:5;background:transparent;pointer-events:none}.drawing-overlay.draw-active[_ngcontent-%COMP%]{pointer-events:auto}.drawing-overlay[_ngcontent-%COMP%] .container, .drawing-overlay[_ngcontent-%COMP%] cue-pan-zoom, .drawing-overlay[_ngcontent-%COMP%] .image-container{background:transparent!important}.drawing-overlay[_ngcontent-%COMP%] img{opacity:0!important}"],changeDetection:0})}return o})()},27106(Sn,ye,V){function Bt(ee,x){this.v=ee,this.k=x}V.d(ye,{A:()=>Bt})},10600(Sn,ye,V){V.d(ye,{A:()=>ee});var Bt=V(27106);function ee(T){return function(){return new x(T.apply(this,arguments))}}function x(T){var b,X;function ut(kt,Wt){try{var ce=T[kt](Wt),bt=ce.value,ie=bt instanceof Bt.A;Promise.resolve(ie?bt.v:bt).then(function(Dt){if(ie){var Ye="return"===kt&&bt.k?kt:"next";if(!bt.k||Dt.done)return ut(Ye,Dt);Dt=T[Ye](Dt).value}Xe(!!ce.done,Dt)},function(Dt){ut("throw",Dt)})}catch(Dt){Xe(2,Dt)}}function Xe(kt,Wt){2===kt?b.reject(Wt):b.resolve({value:Wt,done:kt}),(b=b.next)?ut(b.key,b.arg):X=null}this._invoke=function(kt,Wt){return new Promise(function(ce,bt){var ie={key:kt,arg:Wt,resolve:ce,reject:bt,next:null};X?X=X.next=ie:(b=X=ie,ut(kt,Wt))})},"function"!=typeof T.return&&(this.return=void 0)}x.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},x.prototype.next=function(T){return this._invoke("next",T)},x.prototype.throw=function(T){return this._invoke("throw",T)},x.prototype.return=function(T){return this._invoke("return",T)}}}]);