UNPKG

svelte-pdfz

Version:

svelte-pdf provides a component for rendering PDF documents using PDF.js

38 lines 336 kB
import{s as Ls,c as Ri,u as Pi,g as Mi,a as Li,r as jt,y as Zs,f as Ii,z as Nt,A as Tn,n as Gt,t as xn,e as je}from"../chunks/scheduler.DkWk2TK-.js";import{S as Is,i as Ds,e as X,s as bt,c as Y,d as z,g as C,h as vt,o as y,j as tt,k as L,y as it,t as V,q as oe,a as st,n as le,z as kn,A as Rn,B as ge,C as Tt,b as Mt,D as xt,f as Lt,l as Fs,E as Js,u as qt,v as $t,w as Xt,x as Yt}from"../chunks/index.Bn0-CRlt.js";import{_ as Ve}from"../chunks/preload-helper.Dch09mLN.js";const Pn=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var Le={};Le.d=(l,t)=>{for(var e in t)Le.o(t,e)&&!Le.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})};Le.o=(l,t)=>Object.prototype.hasOwnProperty.call(l,t);var D=globalThis.pdfjsLib={};Le.d(D,{AbortException:()=>Ae,AnnotationEditorLayer:()=>ee,AnnotationEditorParamsType:()=>N,AnnotationEditorType:()=>W,AnnotationEditorUIManager:()=>ce,AnnotationLayer:()=>ka,AnnotationMode:()=>he,CMapCompressionType:()=>As,ColorPicker:()=>Wt,DOMSVGFactory:()=>Hs,DrawLayer:()=>wt,FeatureTest:()=>It,GlobalWorkerOptions:()=>Ie,ImageKind:()=>Ye,InvalidPDFException:()=>Fi,MissingPDFException:()=>ve,OPS:()=>Ut,Outliner:()=>xs,PDFDataRangeTransport:()=>Zi,PDFDateString:()=>Ui,PDFWorker:()=>zt,PasswordResponses:()=>Dn,PermissionFlag:()=>In,PixelsPerInch:()=>Ce,RenderingCancelledException:()=>Bs,TextLayer:()=>Pt,UnexpectedResponseException:()=>es,Util:()=>R,VerbosityLevel:()=>Ze,XfaLayer:()=>tn,build:()=>la,createValidAbsoluteUrl:()=>Hn,fetchData:()=>os,getDocument:()=>Jr,getFilenameFromUrl:()=>Xn,getPdfFilenameFromUrl:()=>Yn,getXfaPageViewport:()=>Kn,isDataScheme:()=>zs,isPdfFile:()=>Us,noContextMenu:()=>Dt,normalizeUnicode:()=>Wn,renderTextLayer:()=>Wr,setLayerDimensions:()=>me,shadow:()=>K,updateTextLayer:()=>Gr,version:()=>oa});const Et=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Di=[1,0,0,1,0,0],vs=[.001,0,0,.001,0,0],Mn=1e7,ds=1.35,Bt={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},he={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Ln="pdfjs_internal_editor_",W={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},N={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},In={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},yt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Ye={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ft={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},xe={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Ze={ERRORS:0,WARNINGS:1,INFOS:5},As={NONE:0,BINARY:1},Ut={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},Dn={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Je=Ze.WARNINGS;function Fn(l){Number.isInteger(l)&&(Je=l)}function Nn(){return Je}function ts(l){Je>=Ze.INFOS&&console.log(`Info: ${l}`)}function j(l){Je>=Ze.WARNINGS&&console.log(`Warning: ${l}`)}function nt(l){throw new Error(l)}function gt(l,t){l||nt(t)}function On(l){switch(l?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Hn(l,t=null,e=null){if(!l)return null;try{if(e&&typeof l=="string"&&(e.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),e.tryConvertEncoding))try{l=Vn(l)}catch{}const s=t?new URL(l,t):new URL(l);if(On(s))return s}catch{}return null}function K(l,t,e,s=!1){return Object.defineProperty(l,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const de=function(){function t(e,s){this.constructor===t&&nt("Cannot initialize BaseException."),this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class _s extends de{constructor(t,e){super(t,"PasswordException"),this.code=e}}class ys extends de{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Fi extends de{constructor(t){super(t,"InvalidPDFException")}}class ve extends de{constructor(t){super(t,"MissingPDFException")}}class es extends de{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Bn extends de{constructor(t){super(t,"FormatError")}}class Ae extends de{constructor(t){super(t,"AbortException")}}function Ni(l){(typeof l!="object"||l?.length===void 0)&&nt("Invalid argument for bytesToString");const t=l.length,e=8192;if(t<e)return String.fromCharCode.apply(null,l);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=l.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function ss(l){typeof l!="string"&&nt("Invalid argument for stringToBytes");const t=l.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=l.charCodeAt(s)&255;return e}function zn(l){return String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255)}function Ns(l){const t=Object.create(null);for(const[e,s]of l)t[e]=s;return t}function Un(){const l=new Uint8Array(4);return l[0]=1,new Uint32Array(l.buffer,0,1)[0]===1}function jn(){try{return new Function(""),!0}catch{return!1}}class It{static get isLittleEndian(){return K(this,"isLittleEndian",Un())}static get isEvalSupported(){return K(this,"isEvalSupported",jn())}static get isOffscreenCanvasSupported(){return K(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?K(this,"platform",{isMac:navigator.platform.includes("Mac")}):K(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return K(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const us=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0"));class R{static makeHexColor(t,e,s){return`#${us[t]}${us[e]}${us[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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){const s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2],i=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,n]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[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]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(s+r)/2,o=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,h=a+o||1,c=a-o||1;return[Math.sqrt(h),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 s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const n=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 n>r?null:[s,n,i,r]}static#t(t,e,s,i,n,r,a,o,h,c){if(h<=0||h>=1)return;const d=1-h,u=h*h,p=u*h,f=d*(d*(d*t+3*h*e)+3*u*s)+p*i,g=d*(d*(d*n+3*h*r)+3*u*a)+p*o;c[0]=Math.min(c[0],f),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],f),c[3]=Math.max(c[3],g)}static#e(t,e,s,i,n,r,a,o,h,c,d,u){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/c,u);return}const p=c**2-4*d*h;if(p<0)return;const f=Math.sqrt(p),g=2*h;this.#t(t,e,s,i,n,r,a,o,(-c+f)/g,u),this.#t(t,e,s,i,n,r,a,o,(-c-f)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,h){return h?(h[0]=Math.min(h[0],t,a),h[1]=Math.min(h[1],e,o),h[2]=Math.max(h[2],t,a),h[3]=Math.max(h[3],e,o)):h=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),h),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),h),h}}function Vn(l){return decodeURIComponent(escape(l))}let fs=null,ti=null;function Wn(l){return fs||(fs=/([\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,ti=new Map([["ſt","ſt"]])),l.replaceAll(fs,(t,e,s)=>e?e.normalize("NFKC"):ti.get(s))}function Gn(){if(typeof crypto<"u"&&typeof crypto?.randomUUID=="function")return crypto.randomUUID();const l=new Uint8Array(32);if(typeof crypto<"u"&&typeof crypto?.getRandomValues=="function")crypto.getRandomValues(l);else for(let t=0;t<32;t++)l[t]=Math.floor(Math.random()*255);return Ni(l)}const Oi="pdfjs_internal_id_",Zt={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};class is{constructor(){this.constructor===is&&nt("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class ns{#t=!1;constructor({enableHWA:t=!1}={}){this.constructor===ns&&nt("Cannot initialize BaseCanvasFactory."),this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}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){nt("Abstract method `_createCanvas` called.")}}class rs{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===rs&&nt("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":""),s=this.isCompressed?As.BINARY:As.NONE;return this._fetchData(e,s).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}_fetchData(t,e){nt("Abstract method `_fetchData` called.")}}class as{constructor({baseUrl:t=null}){this.constructor===as&&nt("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetchData(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}_fetchData(t){nt("Abstract method `_fetchData` called.")}}class Os{constructor(){this.constructor===Os&&nt("Cannot initialize BaseSVGFactory.")}create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){nt("Abstract method `_createSVG` called.")}}const te="http://www.w3.org/2000/svg";class Ce{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class qn extends is{#t;#e;#s;#n;#o;#i=0;constructor({docId:t,ownerDocument:e=globalThis.document}={}){super(),this.#s=t,this.#n=e}get#r(){return this.#t||=new Map}get#l(){return this.#o||=new Map}get#c(){if(!this.#e){const t=this.#n.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 s=this.#n.createElementNS(te,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#e=this.#n.createElementNS(te,"defs"),t.append(s),s.append(this.#e),this.#n.body.append(t)}return this.#e}#d(t){if(t.length===1){const o=t[0],h=new Array(256);for(let d=0;d<256;d++)h[d]=o[d]/255;const c=h.join(",");return[c,c,c]}const[e,s,i]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=s[o]/255,a[o]=i[o]/255;return[n.join(","),r.join(","),a.join(",")]}addFilter(t){if(!t)return"none";let e=this.#r.get(t);if(e)return e;const[s,i,n]=this.#d(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#r.get(r),e)return this.#r.set(t,e),e;const a=`g_${this.#s}_transfer_map_${this.#i++}`,o=`url(#${a})`;this.#r.set(t,o),this.#r.set(r,o);const h=this.#a(a);return this.#m(s,i,n,h),o}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let n=this.#l.get(i);if(n?.key===s||(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},this.#l.set(i,n)),!t||!e))return n.url;const r=this.#v(t);t=R.makeHexColor(...r);const a=this.#v(e);if(e=R.makeHexColor(...a),this.#c.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return n.url;const o=new Array(256);for(let p=0;p<=255;p++){const f=p/255;o[p]=f<=.03928?f/12.92:((f+.055)/1.055)**2.4}const h=o.join(","),c=`g_${this.#s}_hcm_filter`,d=n.filter=this.#a(c);this.#m(h,h,h,d),this.#h(d);const u=(p,f)=>{const g=r[p]/255,b=a[p]/255,m=new Array(f+1);for(let v=0;v<=f;v++)m[v]=g+v/f*(b-g);return m.join(",")};return this.#m(u(0,5),u(1,5),u(2,5),d),n.url=`url(#${c})`,n.url}addAlphaFilter(t){let e=this.#r.get(t);if(e)return e;const[s]=this.#d([t]),i=`alpha_${s}`;if(e=this.#r.get(i),e)return this.#r.set(t,e),e;const n=`g_${this.#s}_alpha_map_${this.#i++}`,r=`url(#${n})`;this.#r.set(t,r),this.#r.set(i,r);const a=this.#a(n);return this.#u(s,a),r}addLuminosityFilter(t){let e=this.#r.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#d([t]),i=`luminosity_${s}`):i="luminosity",e=this.#r.get(i),e)return this.#r.set(t,e),e;const n=`g_${this.#s}_luminosity_map_${this.#i++}`,r=`url(#${n})`;this.#r.set(t,r),this.#r.set(i,r);const a=this.#a(n);return this.#f(a),t&&this.#u(s,a),r}addHighlightHCMFilter(t,e,s,i,n){const r=`${e}-${s}-${i}-${n}`;let a=this.#l.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.#l.set(t,a)),!e||!s))return a.url;const[o,h]=[e,s].map(this.#v.bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[u,p]=[i,n].map(this.#v.bind(this));d<c&&([c,d,u,p]=[d,c,p,u]),this.#c.style.color="";const f=(m,v,_)=>{const A=new Array(256),E=(d-c)/_,w=m/255,S=(v-m)/(255*_);let T=0;for(let k=0;k<=_;k++){const O=Math.round(c+k*E),M=w+k*S;for(let G=T;G<=O;G++)A[G]=M;T=O+1}for(let k=T;k<256;k++)A[k]=A[T-1];return A.join(",")},g=`g_${this.#s}_hcm_${t}_filter`,b=a.filter=this.#a(g);return this.#h(b),this.#m(f(u[0],p[0],5),f(u[1],p[1],5),f(u[2],p[2],5),b),a.url=`url(#${g})`,a.url}destroy(t=!1){t&&this.#l.size!==0||(this.#e&&(this.#e.parentNode.parentNode.remove(),this.#e=null),this.#t&&(this.#t.clear(),this.#t=null),this.#i=0)}#f(t){const e=this.#n.createElementNS(te,"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)}#h(t){const e=this.#n.createElementNS(te,"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)}#a(t){const e=this.#n.createElementNS(te,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#p(t,e,s){const i=this.#n.createElementNS(te,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#m(t,e,s,i){const n=this.#n.createElementNS(te,"feComponentTransfer");i.append(n),this.#p(n,"feFuncR",t),this.#p(n,"feFuncG",e),this.#p(n,"feFuncB",s)}#u(t,e){const s=this.#n.createElementNS(te,"feComponentTransfer");e.append(s),this.#p(s,"feFuncA",t)}#v(t){return this.#c.style.color=t,js(getComputedStyle(this.#c).getPropertyValue("color"))}}class $n extends ns{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}={}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}async function os(l,t="text"){if(Pe(l,document.baseURI)){const e=await fetch(l);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,s)=>{const i=new XMLHttpRequest;i.open("GET",l,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class Hi extends rs{_fetchData(t,e){return os(t,this.isCompressed?"arraybuffer":"text").then(s=>({cMapData:s instanceof ArrayBuffer?new Uint8Array(s):ss(s),compressionType:e}))}}class Bi extends as{_fetchData(t){return os(t,"arraybuffer").then(e=>new Uint8Array(e))}}class Hs extends Os{_createSVG(t){return document.createElementNS(te,t)}}class Fe{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const a=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let h,c,d,u;switch(s%=360,s<0&&(s+=360),s){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u);let p,f,g,b;h===0?(p=Math.abs(o-t[1])*e+i,f=Math.abs(a-t[0])*e+n,g=(t[3]-t[1])*e,b=(t[2]-t[0])*e):(p=Math.abs(a-t[0])*e+i,f=Math.abs(o-t[1])*e+n,g=(t[2]-t[0])*e,b=(t[3]-t[1])*e),this.transform=[h*e,c*e,d*e,u*e,p-h*e*a-d*e*o,f-c*e*a-u*e*o],this.width=g,this.height=b}get rawDims(){const{viewBox:t}=this;return K(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new Fe({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return R.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=R.applyTransform([t[0],t[1]],this.transform),s=R.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return R.applyInverseTransform([t,e],this.transform)}}class Bs extends de{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function zs(l){const t=l.length;let e=0;for(;e<t&&l[e].trim()==="";)e++;return l.substring(e,e+5).toLowerCase()==="data:"}function Us(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function Xn(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function Yn(l,t="document.pdf"){if(typeof l!="string")return t;if(zs(l))return j('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(l);let n=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(n&&(n=n[0],n.includes("%")))try{n=s.exec(decodeURIComponent(n))[0]}catch{}return n||t}class ei{started=Object.create(null);times=[];time(t){t in this.started&&j(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||j(`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:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
`);return t.join("")}}function Pe(l,t){try{const{protocol:e}=t?new URL(l,t):new URL(l);return e==="http:"||e==="https:"}catch{return!1}}function Dt(l){l.preventDefault()}function zi(l){console.log("Deprecated API usage: "+l)}let si;class Ui{static toDateObject(t){if(!t||typeof t!="string")return null;si||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=si.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n: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 o=parseInt(e[6],10);o=o>=0&&o<=59?o: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(s,i,n,r,a,o))}}function Kn(l,{scale:t=1,rotation:e=0}){const{width:s,height:i}=l.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new Fe({viewBox:n,scale:t,rotation:e})}function js(l){if(l.startsWith("#")){const t=parseInt(l.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(j(`Not a valid color format: "${l}"`),[0,0,0])}function Qn(l){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of l.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;l.set(e,js(s))}t.remove()}function ht(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform();return[t,e,s,i,n,r]}function Jt(l){const{a:t,b:e,c:s,d:i,e:n,f:r}=l.getTransform().invertSelf();return[t,e,s,i,n,r]}function me(l,t,e=!1,s=!0){if(t instanceof Fe){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=l,a=It.isCSSRoundSupported,o=`var(--scale-factor) * ${i}px`,h=`var(--scale-factor) * ${n}px`,c=a?`round(${o}, 1px)`:`calc(${o})`,d=a?`round(${h}, 1px)`:`calc(${h})`;!e||t.rotation%180===0?(r.width=c,r.height=d):(r.width=d,r.height=c)}s&&l.setAttribute("data-main-rotation",t.rotation)}class Vs{#t=null;#e=null;#s;#n=null;constructor(t){this.#s=t}render(){const t=this.#t=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;t.addEventListener("contextmenu",Dt,{signal:e}),t.addEventListener("pointerdown",Vs.#o,{signal:e});const s=this.#n=document.createElement("div");s.className="buttons",t.append(s);const i=this.#s.toolbarPosition;if(i){const{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#c(),t}static#o(t){t.stopPropagation()}#i(t){this.#s._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#r(t){this.#s._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#l(t){const e=this.#s._uiManager._signal;t.addEventListener("focusin",this.#i.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#r.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Dt,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden")}#c(){const t=document.createElement("button");t.className="delete",t.tabIndex=0,t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#s.editorType}-button`),this.#l(t),t.addEventListener("click",e=>{this.#s._uiManager.delete()},{signal:this.#s._uiManager._signal}),this.#n.append(t)}get#d(){const t=document.createElement("div");return t.className="divider",t}addAltTextButton(t){this.#l(t),this.#n.prepend(t,this.#d)}addColorPicker(t){this.#e=t;const e=t.renderButton();this.#l(e),this.#n.prepend(e,this.#d)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class Zn{#t=null;#e=null;#s;constructor(t){this.#s=t}#n(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Dt,{signal:this.#s._signal});const e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#i(),t}#o(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#o(e,s),{style:r}=this.#e||=this.#n();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#i(){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 s=this.#s._signal;t.addEventListener("contextmenu",Dt,{signal:s}),t.addEventListener("click",()=>{this.#s.highlightSelection("floating_button")},{signal:s}),this.#t.append(t)}}function Ke(l,t,e){for(const s of e)t.addEventListener(s,l[s].bind(l))}function Jn(l){return Math.round(Math.min(255,Math.max(1,255*l))).toString(16).padStart(2,"0")}class tr{#t=0;get id(){return`${Ln}${this.#t++}`}}class Ws{#t=Gn();#e=0;#s=null;static get _isSVGFittingCanvas(){const t='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>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return K(this,"_isSVGFittingCanvas",n)}async#n(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await os(e,"blob")):i=s.file=e,i.type==="image/svg+xml"){const n=Ws._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((h,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,h()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#n(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#n(t,t)}async getFromId(t){this.#s||=new Map;const e=this.#s.get(t);return e?e.bitmap?(e.refCounter+=1,e):e.file?this.getFromFile(e.file):this.getFromUrl(e.url):null}getSvgUrl(t){const e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);e&&(e.refCounter-=1,e.refCounter===0&&(e.bitmap=null))}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class er{#t=[];#e=!1;#s;#n=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:n};if(this.#n===-1){this.#t.length>0&&(this.#t.length=0),this.#n=0,this.#t.push(o);return}if(r&&this.#t[this.#n].type===n){a&&(o.undo=this.#t[this.#n].undo),this.#t[this.#n]=o;return}const h=this.#n+1;h===this.#s?this.#t.splice(0,1):(this.#n=h,h<this.#t.length&&this.#t.splice(h)),this.#t.push(o)}undo(){if(this.#n===-1)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 this.#n!==-1}hasSomethingToRedo(){return this.#n<this.#t.length-1}destroy(){this.#t=null}}class Ne{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=It.platform;for(const[s,i,n={}]of t)for(const r of s){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:i,options:n}),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 s=this.callbacks.get(this.#t(e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||(e.stopPropagation(),e.preventDefault()))}}class Gs{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Qn(t),K(this,"_colors",t)}convert(t){const e=js(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return Gs._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?R.makeHexColor(...e):t}}class ce{#t=new AbortController;#e=null;#s=new Map;#n=new Map;#o=null;#i=null;#r=null;#l=new er;#c=0;#d=new Set;#f=null;#h=null;#a=new Set;#p=!1;#m=null;#u=null;#v=null;#g=!1;#A=null;#y=new tr;#E=!1;#C=!1;#T=null;#P=null;#S=null;#_=W.NONE;#b=new Set;#w=null;#x=null;#k=null;#L=this.blur.bind(this);#M=this.focus.bind(this);#F=this.copy.bind(this);#I=this.cut.bind(this);#N=this.paste.bind(this);#D=this.keydown.bind(this);#W=this.keyup.bind(this);#G=this.onEditingAction.bind(this);#j=this.onPageChanging.bind(this);#z=this.onScaleChanging.bind(this);#O=this.onRotationChanging.bind(this);#Y={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#V=[0,0];#H=null;#U=null;#K=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=ce.prototype,e=r=>r.#U.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return K(this,"_keyboardManager",new Ne([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#U.contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#U.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,h){this._signal=this.#t.signal,this.#U=t,this.#K=e,this.#o=s,this._eventBus=i,this._eventBus._on("editingaction",this.#G),this._eventBus._on("pagechanging",this.#j),this._eventBus._on("scalechanging",this.#z),this._eventBus._on("rotationchanging",this.#O),this.#nt(),this.#lt(),this.#Q(),this.#i=n.annotationStorage,this.#m=n.filterFactory,this.#x=r,this.#v=a||null,this.#p=o,this.#S=h||null,this.viewParameters={realScale:Ce.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#t?.abort(),this.#t=null,this._signal=null,this._eventBus._off("editingaction",this.#G),this._eventBus._off("pagechanging",this.#j),this._eventBus._off("scalechanging",this.#z),this._eventBus._off("rotationchanging",this.#O);for(const t of this.#n.values())t.destroy();this.#n.clear(),this.#s.clear(),this.#a.clear(),this.#e=null,this.#b.clear(),this.#l.destroy(),this.#o?.destroy(),this.#A?.hide(),this.#A=null,this.#u&&(clearTimeout(this.#u),this.#u=null),this.#H&&(clearTimeout(this.#H),this.#H=null)}async mlGuess(t){return this.#S?.guess(t)||null}get hasMLManager(){return!!this.#S}get hcmFilter(){return K(this,"hcmFilter",this.#x?this.#m.addHCMFilter(this.#x.foreground,this.#x.background):"none")}get direction(){return K(this,"direction",getComputedStyle(this.#U).direction)}get highlightColors(){return K(this,"highlightColors",this.#v?new Map(this.#v.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return K(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){this.#P=t}editAltText(t){this.#o?.editAltText(this,t)}onPageChanging({pageNumber:t}){this.#c=t-1}focusMainContainer(){this.#U.focus()}findParent(t,e){for(const s of this.#n.values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#K.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#a.add(t)}removeShouldRescale(t){this.#a.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Ce.PDF_TO_CSS_UNITS;for(const e of this.#a)e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#$({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=e,a=e.toString(),h=this.#$(e).closest(".textLayer"),c=this.getSelectionBoxes(h);if(c){e.empty(),this.#_===W.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:W.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0));for(const d of this.#n.values())if(d.hasTextLayer(h)){d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a});break}}}#st(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=this.#$(t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#A||=new Zn(this),this.#A.show(s,i,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#i&&!this.#i.has(t.id)&&this.#i.setValue(t.id,t)}#it(){const t=document.getSelection();if(!t||t.isCollapsed){this.#w&&(this.#A?.hide(),this.#w=null,this.#R({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#w)return;if(!this.#$(t).closest(".textLayer")){this.#w&&(this.#A?.hide(),this.#w=null,this.#R({hasSelectedText:!1}));return}if(this.#A?.hide(),this.#w=e,this.#R({hasSelectedText:!0}),!(this.#_!==W.HIGHLIGHT&&this.#_!==W.NONE)&&(this.#_===W.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#g=this.isShiftKeyDown,!this.isShiftKeyDown)){const n=this._signal,r=a=>{a.type==="pointerup"&&a.button!==0||(window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),a.type==="pointerup"&&this.#X("main_toolbar"))};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}}#X(t=""){this.#_===W.HIGHLIGHT?this.highlightSelection(t):this.#p&&this.#st()}#nt(){document.addEventListener("selectionchange",this.#it.bind(this),{signal:this._signal})}#rt(){const t=this._signal;window.addEventListener("focus",this.#M,{signal:t}),window.addEventListener("blur",this.#L,{signal:t})}#at(){window.removeEventListener("focus",this.#M),window.removeEventListener("blur",this.#L)}blur(){if(this.isShiftKeyDown=!1,this.#g&&(this.#g=!1,this.#X("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#b)if(e.div.contains(t)){this.#T=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#T)return;const[t,e]=this.#T;this.#T=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Q(){const t=this._signal;window.addEventListener("keydown",this.#D,{signal:t}),window.addEventListener("keyup",this.#W,{signal:t})}#ot(){window.removeEventListener("keydown",this.#D),window.removeEventListener("keyup",this.#W)}#Z(){const t=this._signal;document.addEventListener("copy",this.#F,{signal:t}),document.addEventListener("cut",this.#I,{signal:t}),document.addEventListener("paste",this.#N,{signal:t})}#J(){document.removeEventListener("copy",this.#F),document.removeEventListener("cut",this.#I),document.removeEventListener("paste",this.#N)}#lt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Q(),this.#Z()}removeEditListeners(){this.#ot(),this.#J()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#h)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#h)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#b){const i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of this.#h)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){j(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const o of s){const h=i.deserialize(o);if(!h)return;n.push(h)}const r=()=>{for(const o of n)this.#tt(o);this.#et(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){j(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#_!==W.NONE&&!this.isEditorHandlingKeyboard&&ce._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#g&&(this.#g=!1,this.#X("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}#R(t){Object.entries(t).some(([s,i])=>this.#Y[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#Y,t)}),this.#_===W.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#B([[N.HIGHLIGHT_FREE,!0]]))}#B(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#rt(),this.#Z(),this.#R({isEditing:this.#_!==W.NONE,isEmpty:this.#q(),hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:this.#l.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#at(),this.#J(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#h){this.#h=t;for(const e of this.#h)this.#B(e.defaultPropertiesToUpdate)}}getId(){return this.#y.id}get currentLayer(){return this.#n.get(this.#c)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#c}addLayer(t){this.#n.set(t.pageIndex,t),this.#E?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(this.#_!==t){if(this.#_=t,t===W.NONE){this.setEditingState(!1),this.#ct();return}this.setEditingState(!0),this.#ht(),this.unselectAll();for(const i of this.#n.values())i.updateMode(t);if(!e&&s){this.addNewEditorFromKeyboard();return}if(e){for(const i of this.#s.values())if(i.annotationElementId===e){this.setSelected(i),i.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#_&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#h){switch(t){case N.CREATE:this.currentLayer.addNewEditor();return;case N.HIGHLIGHT_DEFAULT_COLOR:this.#P?.updateColor(e);break;case N.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#k||=new Map).set(t,e),this.showAllEditors("highlight",e);break}for(const s of this.#b)s.updateParams(t,e);for(const s of this.#h)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const n of this.#s.values())n.editorType===t&&n.show(e);(this.#k?.get(N.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#B([[N.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#C!==t){this.#C=t;for(const e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}#ht(){if(!this.#E){this.#E=!0;for(const t of this.#n.values())t.enable();for(const t of this.#s.values())t.enable()}}#ct(){if(this.unselectAll(),this.#E){this.#E=!1;for(const t of this.#n.values())t.disable();for(const t of this.#s.values())t.disable()}}getEditors(t){const e=[];for(const s of this.#s.values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#u&&clearTimeout(this.#u),this.#u=setTimeout(()=>{this.focusMainContainer(),this.#u=null},0)),this.#s.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#d.has(t.annotationElementId))&&this.#i?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tt(t){const e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#B(t.propertiesToUpdate))}get#dt(){let t=null;for(t of this.#b);return t}updateUI(t){this.#dt===t&&this.#B(t.propertiesToUpdate)}toggleSelected(t){if(this.#b.has(t)){this.#b.delete(t),t.unselect(),this.#R({hasSelectedEditor:this.hasSelection});return}this.#b.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){for(const e of this.#b)e!==t&&e.unselect();this.#b.clear(),this.#b.add(t),t.select(),this.#B(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#b.has(t)}get firstSelectedEditor(){return this.#b.values().next().value}unselect(t){t.unselect(),this.#b.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#b.size!==0}get isEnterHandled(){return this.#b.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#l.undo(),this.#R({hasSomethingToUndo:this.#l.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#q()})}redo(){this.#l.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#l.hasSomethingToRedo(),isEmpty:this.#q()})}addCommands(t){this.#l.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#q()})}#q(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const t of this.#s.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...this.#b],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)this.#tt(i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#et(t){for(const e of this.#b)e.unselect();this.#b.clear();for(const e of t)e.isEmpty()||(this.#b.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#b)t.commit();this.#et(this.#s.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#_!==W.NONE))&&this.hasSelection){for(const t of this.#b)t.unselect();this.#b.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#V[0]+=t,this.#V[1]+=e;const[i,n]=this.#V,r=[...this.#b],a=1e3;this.#H&&clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#H=null,this.#V[0]=this.#V[1]=0,this.addCommands({cmd:()=>{for(const o of r)this.#s.has(o.id)&&o.translateInPage(i,n)},undo:()=>{for(const o of r)this.#s.has(o.id)&&o.translateInPage(-i,-n)},mustExec:!1})},a);for(const o of r)o.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(const t of this.#b)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);const t=this.#f;this.#f=null;let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const s=(i,n,r,a)=>{if(this.#s.has(i.id)){const o=this.#n.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(const s of this.#f.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#b.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#_}get imageManager(){return K(this,"imageManager",new Ws)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(h,c,d,u)=>({x:(c-i)/r,y:1-(h+d-s)/n,width:u/r,height:d/n});break;case"180":a=(h,c,d,u)=>({x:1-(h+d-s)/n,y:1-(c+u-i)/r,width:d/n,height:u/r});break;case"270":a=(h,c,d,u)=>({x:1-(c+u-i)/r,y:(h-s)/n,width:u/r,height:d/n});break;default:a=(h,c,d,u)=>({x:(h-s)/n,y:(c-i)/r,width:d/n,height:u/r});break}const o=[];for(let h=0,c=e.rangeCount;h<c;h++){const d=e.getRangeAt(h);if(!d.collapsed)for(const{x:u,y:p,width:f,height:g}of d.getClientRects())f===0||g===0||o.push(a(u,p,f,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#r||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#r?.delete(t)}renderAnnotationElement(t){const e=this.#r?.get(t.data.id);if(!e)return;const s=this.#i.getRawValue(e);s&&(this.#_===W.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}}class fe{#t="";#e=!1;#s=null;#n=null;#o=null;#i=!1;#r=null;static _l10nPromise=null;constructor(t){this.#r=t}static initialize(t){fe._l10nPromise||=t}async render(){const t=this.#s=document.createElement("button");t.className="altText";const e=await fe._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e,t.setAttribute("aria-label",e),t.tabIndex="0";const s=this.#r._uiManager._signal;t.addEventListener("contextmenu",Dt,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),this.#r._uiManager.editAltText(this.#r)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#i=!0,i(n))},{signal:s}),await this.#l(),t}finish(){this.#s&&(this.#s.focus({focusVisible:this.#i}),this.#i=!1)}isEmpty(){return!this.#t&&!this.#e}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e}){this.#t===t&&this.#e===e||(this.#t=t,this.#e=e,this.#l())}toggle(t=!1){this.#s&&(!t&&this.#o&&(clearTimeout(this.#o),this.#o=null),this.#s.disabled=!t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null}async#l(){const t=this.#s;if(!t)return;if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),fe._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(i=>{t.setAttribute("aria-label",i)});let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip");const i=e.id=`alt-text-tooltip-${this.#r.id}`;t.setAttribute("aria-describedby",i);const n=100,r=this.#r._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#o),this.#o=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#o=setTimeout(()=>{this.#o=null,this.#n.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:r}),t.addEventListener("mouseleave",()=>{this.#o&&(clearTimeout(this.#o),this.#o=null),this.#n?.classList.remove("show")},{signal:r})}e.innerText=this.#e?await fe._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#t,e.parentNode||t.append(e),this.#r.getImageForAltText()?.setAttribute("aria-describedby",e.id)}}class F{#t=null;#e=null;#s=null;#n=!1;#o=!1;#i=null;#r=null;#l=this.focusin.bind(this);#c=this.focusout.bind(this);#d=null;#f="";#h=!1;#a=null;#p=!1;#m=!1;#u=!1;#v=null;#g=0;#A=0;#y=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#E=!1;#C=F._zIndex++;static _borderLineWidth=-1;static _colorManager=new Gs;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=F.prototype._resizeWithKeyboard,e=ce.TRANSLATE_SMALL,s=ce.TRANSLATE_BIG;return K(this,"_resizerKeyboardManager",new Ne([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],F.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===F&&nt("Cannot initialize AnnotationEditor."),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:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return K(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new sr({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,s){if(F._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(n=>[n,t.get(n.replaceAll(/([A-Z])/g,r=>`-${r.toLowerCase()}`))])),s?.strings)for(const n of s.strings)F._l10nPromise.set(n,t.get(n));if(F._borderLineWidth!==-1)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){nt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=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/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}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.#C}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#D(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#h?this.#h=!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,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}#T([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()}translate(t,e){this.#T(this.parentDimensions,t,e)}translateInPage(t,e){this.#a||=[this.x,this.y],this.#T(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#a||=[this.x,this.y];const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:h,y:c}=this.div.getBoundingClientRect();this.parent.findNewParent(this,h,c)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:r}=this;const[a,o]=this.getBaseTranslation();n+=a,r+=o,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#a&&(this.#a[0]!==this.x||this.#a[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=F,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:n,width:r,height:a}=this;if(r*=e,a*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-r,i)),n=Math.max(0,Math.min(s-a,n));break;case 90:i=Math.max(0,Math.min(e-a,i)),n=Math.min(s,Math.max(r,n));break;case 180:i=Math.min(e,Math.max(r,i)),n=Math.min(s,Math.max(a,n));break;case 270:i=Math.min(e,Math.max(a,i)),n=Math.max(0,Math.min(s-r,n));break}this.x=i/=e,this.y=n/=s;const[o,h]=this.getBaseTranslation();i+=o,n+=h;const{style:c}=this.div;c.left=`${(100*i).toFixed(2)}%`,c.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#P(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return F.#P(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return F.#P(t,e,360-this.parentRotation)}#S(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/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,s]}=this,i=e*t,n=s*t;return It.isCSSRoundSupported?[Math.round(i),Math.round(n)]:[i,n]}setDims(t,e){const[s,i]=this.parentDimensions;this.div.style.width=`${(100*t/s).toFixed(2)}%`,this.#o||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!this.#o&&e.endsWith("%");if(i&&n)return;const[r,a]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),!this.#o&&!n&&(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#_(){if(this.#i)return;this.#i=document.createElement("div"),this.#i.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 s of t){const i=document.createElement("div");this.#i.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#b.bind(this,s),{signal:e}),i.addEventListener("contextmenu",Dt,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#i)}#b(t,e){e.preventDefault();const{isMac:s}=It.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const i=this.#x.bind(this,t),n=this._isDraggable;this._isDraggable=!1;const r=this._uiManager._signal,a={passive:!0,capture:!0,signal:r};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,a),window.addEventListener("contextmenu",Dt,{signal:r});const o=this.x,h=this.y,c=this.width,d=this.height,u=this.parent.div.style.cursor,p=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const f=()=>{this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=n,window.removeEventListener("pointerup",f),window.removeEventListener("blur",f),window.removeEventListener("pointermove",i,a),window.removeEventListener("contextmenu",Dt),this.parent.div.style.cursor=u,this.div.style.cursor=p,this.#w(o,h,c,d)};window.addEventListener("pointerup",f,{signal:r}),window.addEventListener("blur",f,{signal:r})}#w(t,e,s,i){const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:()=>{this.width=a,this.height=o,this.x=n,this.y=r;const[h,c]=this.parentDimensions;this.setDims(h*a,c*o),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[h,c]=this.parentDimensions;this.setDims(h*s,c*i),this.fixAndSetPosition()},mustExec:!0})}#x(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,h=F.MIN_SIZE/s,c=F.MIN_SIZE/i,d=P=>Math.round(P*1e4)/1e4,u=this.#S(this.rotation),p=(P,I)=>[u[0]*P+u[2]*I,u[1]*P+u[3]*I],f=this.#S(360-this.rotation),g=(P,I)=>[f[0]*P+f[2]*I,f[1]*P+f[3]*I];let b,m,v=!1,_=!1;switch(t){case"topLeft":v=!0,b=(P,I)=>[0,0],m=(P,I)=>[P,I];break;case"topMiddle":b=(P,I)=>[P/2,0],m=(P,I)=>[P/2,I];break;case"topRight":v=!0,b=(P,I)=>[P,0],m=(P,I)=>[0,I];break;case"middleRight":_=!0,b=(P,I)=>[P,I/2],m=(P,I)=>[0,I/2];break;case"bottomRight":v=!0,b=(P,I)=>[P,I],m=(P,I)=>[0,0];break;case"bottomMiddle":b=(P,I)=>[P/2,I],m=(P,I)=>[P/2,0];break;case"bottomLeft":v=!0,b=(P,I)=>[0,I],m=(P,I)=>[P,0];break;case"middleLeft":_=!0,b=(P,I)=>[0,I/2],m=(P,I)=>[P,I/2];break}const A=b(a,o),E=m(a,o);let w=p(...E);const S=d(n+w[0]),T=d(r+w[1]);let k=1,O=1,[M,G]=this.screenToPageTranslation(e.movementX,e.movementY);if([M,G]=g(M/s,G/i),v){const P=Math.hypot(a,o);k=O=Math.max(Math.min(Math.hypot(E[0]-A[0]-M,E[1]-A[1]-G)/P,1/a,1/o),h/a,c/o)}else _?k=Math.max(h,Math.min(1,Math.abs(E[0]-A[0]-M)))/a:O=Math.max(c,Math.min(1,Math.abs(E[1]-A[1]-G)))/o;const ot=d(a*k),lt=d(o*O);w=p(...m(ot,lt));const rt=S-w[0],J=T-w[1];this.width=ot,this.height=lt,this.x=rt,this.y=J,this.setDims(s*ot,i*lt),this.fixAndSetPosition()}altTextFinish(){this.#s?.finish()}async addEditToolbar(){return this.#d||this.#m?this.#d:(this.#d=new Vs(this),this.div.append(this.#d.render()),this.#s&&this.#d.addAltTextButton(await this.#s.render()),this.#d)}removeEditToolbar(){this.#d&&(this.#d.remove(),this.#d=null,this.#s?.destroy())}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#s||(fe.initialize(F._l10nPromise),this.#s=new fe(this),this.#t&&(this.#s.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}hasAltText(){return!this.#s?.isEmpty()}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#n?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground();const t=this._uiManager._signal;this.div.addEventListener("focusin",this.#l,{signal:t}),this.div.addEventListener("focusout",this.#c,{signal:t});const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*s/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),Ke(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=It.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#h=!0,this._isDraggable){this.#L(t);return}this.#k(t)}#k(t){const{isMac:e}=It.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#L(t){const e=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let s,i;const n=this._uiManager._signal;e&&(this.div.classList.add("moving"),s={passive:!0,capture:!0,signal:n},this.#g=t.clientX,this.#A=t.clientY,i=a=>{const{clientX:o,clientY:h}=a,[c,d]=this.screenToPageTranslation(o-this.#g,h-this.#A);this.#g=o,this.#A=h,this._uiManager.dragSelectedEditors(c,d)},window.addEventListener("pointermove",i,s));const r=()=>{window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),e&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",i,s)),this.#h=!1,this._uiManager.endDragSession()||this.#k(t)};window.addEventListener("pointerup",r,{signal:n}),window.addEventListener("blur",r,{signal:n})}moveInDOM(){this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,h=t/i,c=e/i,d=this.x*n,u=this.y*r,p=this.width*n,f=this.height*r;switch(s){case 0:return[d+h+a,r-u-c-f+o,d+h+p+a,r-u-c+o];case 90:return[d+c+a,r-u+h+o,d+c+f+a,r-u+h+p+o];case 180:return[d-h-p+a,r-u+c+o,d-h+a,r-u+c+f+o];case 270:return[d-c-f+a,r-u-h-p+o,d-c+a,r-u-h+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#u}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){const t=this._uiManager._signal;this.div?.addEventListener("focusin",this.#l,{signal:t}),this.div?.addEventListener("focusout",this.#c,{signal:t})}rotate(t){}serialize(t=!1,e=null){nt("An editor must be serializable")}static deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,i.#t=t.accessibilityData;const[n,r]=i.pageDimensions,[a,o,h,c]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=h/n,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.div.removeEventListener("focusin",this.#l),this.div.removeEventListener("focusout",this.#c),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#v&&(clearTimeout(this.#v),this.#v=null),this.#D(),this.removeEditToolbar(),this.#y){for(const t of this.#y.values())clearTimeout(t);this.#y=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#_(),this.#i.classList.remove("hidden"),Ke(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#r={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#i.children;if(!this.#e){this.#e=Array.from(e);const r=this.#M.bind(this),a=this.#F.bind(this),o=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:o}),h.addEventListener("blur",a,{signal:o}),h.addEventListener("focus",this.#I.bind(this,c),{signal:o}),F._l10nPromise.get(`pdfjs-editor-resizer-label-${c}`).then(d=>h.setAttribute("aria-label",d))}}const s=this.#e[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#i.append(this.#i.firstChild);else if(n>i)for(let a=0;a<n-i;a++)this.#i.firstChild.before(this.#i.lastChild);let r=0;for(const a of e){const h=this.#e[r++].getAttribute("data-resizer-name");F._l10nPromise.get(`pdfjs-editor-resizer-label-${h}`).then(c=>a.setAttribute("aria-label",c))}}this.#N(0),this.#u=!0,this.#i.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#M(t){F._resizerKeyboardManager.exec(this,t)}#F(t){this.#u&&t.relatedTarget?.parentNode!==this.#i&&this.#D()}#I(t){this.#f=this.#u?t:""}#N(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#u&&this.#x(this.#f,{movementX:t,movementY:e})}#D(){if(this.#u=!1,this.#N(-1),this.#r){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#r;this.#w(t,e,s,i),this.#r=null}}_stopResizingWithKeyboard(){this.#D(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this.#d){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#d?.show()});return}this.#d?.show()}unselect(){this.#i?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#d?.hide()}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.#o=!0;const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.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.#y||=new Map;const{action:s}=t;let i=this.#y.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#y.delete(s),this.#y.size===0&&(this.#y=null)},F._telemetryTimeout),this.#y.set(s,i);return}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)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;e.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class sr extends F{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}const ii=3285377520,Ht=4294901760,Vt=65535;class ji{constructor(t){this.h1=t?t&4294967295:ii,this.h2=t?t&4294967295:ii}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,b=t.length;g<b;g++){const m=t.charCodeAt(g);m<=255?e[s++]=m:(e[s++]=m>>>8,e[s++]=m&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i);let a=0,o=0,h=this.h1,c=this.h2;const d=3432918353,u=461845907,p=d&Vt,f=u&Vt;for(let g=0;g<i;g++)g&1?(a=r[g],a=a*d&Ht|a*p&Vt,a=a<<15|a>>>17,a=a*u&Ht|a*f&Vt,h^=a,h=h<<13|h>>>19,h=h*5+3864292196):(o=r[g],o=o*d&Ht|o*p&Vt,o=o<<15|o>>>17,o=o*u&Ht|o*f&Vt,c^=o,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&Ht|a*p&Vt,a=a<<15|a>>>17,a=a*u&Ht|a*f&Vt,i&1?h^=a:c^=a}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Ht|t*36045&Vt,e=e*4283543511&Ht|((e<<16|t>>>16)*2950163797&Ht)>>>16,t^=e>>>1,t=t*444984403&Ht|t*60499&Vt,e=e*3301882366&Ht|((e<<16|t>>>16)*3120437893&Ht)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ws=Object.freeze({map:null,hash:"",transfer:void 0});class qs{#t=!1;#e=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=this.#e.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#e.get(t)}remove(t){if(this.#e.delete(t),this.#e.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of this.#e.values())if(e instanceof F)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#e.get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#e.set(t,e);i&&this.#s(),e instanceof F&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#e.has(t)}getAll(){return this.#e.size>0?Ns(this.#e):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return this.#e.size}#s(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Vi(this)}get serializable(){if(this.#e.size===0)return ws;const t=new Map,e=new ji,s=[],i=Object.create(null);let n=!1;for(const[r,a]of this.#e){const o=a instanceof F?a.serialize(!1,i):a;o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:ws}get editorStats(){let t=null;const e=new Map;for(const s of this.#e.values()){if(!(s instanceof F))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[a,o]of Object.entries(i)){if(a==="type")continue;let h=r.get(a);h||(h=new Map,r.set(a,h));const c=h.get(o)??0;h.set(o,c+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}}class Vi extends qs{#t;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);this.#t={map:n,hash:s,transfer:i}}get print(){nt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}}class ir{#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)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(gt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),this.#t.add(s),e?.(t)}catch{j(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}nt("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw j(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return K(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(Et||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),K(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(gt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return K(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(A,E){return A.charCodeAt(E)<<24|A.charCodeAt(E+1)<<16|A.charCodeAt(E+2)<<8|A.charCodeAt(E+3)&255}function i(A,E,w,S){const T=A.substring(0,E),k=A.substring(E+w);return T+S+k}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let h=0;function c(A,E){if(++h>30){j("Load test font never loaded."),E();return}if(o.font="30px "+A,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0){E();return}setTimeout(c.bind(null,A,E))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=i(u,976,d.length,d);const f=16,g=1482184792;let b=s(u,f);for(n=0,r=d.length-3;n<r;n+=4)b=b-g+s(d,n)|0;n<d.length&&(b=b-g+s(d+"XXX",n)|0),u=i(u,f,4,zn(b));const m=`url(data:font/opentype;base64,${btoa(u)});`,v=`@font-face {font-family:"${d}";src:${m}}`;this.insertRule(v);const _=this._document.createElement("div");_.style.visibility="hidden",_.style.width=_.style.height="10px",_.style.position="absolute",_.style.top=_.style.left="0px";for(const A of[t.loadedName,d]){const E=this._document.createElement("span");E.textContent="Hi",E.style.fontFamily=A,_.append(E)}this._document.body.append(_),c(d,()=>{_.remove(),e.complete()})}}class nr{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=e===!0,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{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)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=Ni(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}return this._inspectFont?.(this,e),s}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(n){j(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,r){};const i=[];for(let n=0,r=s.length;n<r;)switch(s[n++]){case Zt.BEZIER_CURVE_TO:{const[a,o,h,c,d,u]=s.slice(n,n+6);i.push(p=>p.bezierCurveTo(a,o,h,c,d,u)),n+=6}break;case Zt.MOVE_TO:{const[a,o]=s.slice(n,n+2);i.push(h=>h.moveTo(a,o)),n+=2}break;case Zt.LINE_TO:{const[a,o]=s.slice(n,n+2);i.push(h=>h.lineTo(a,o)),n+=2}break;case Zt.QUADRATIC_CURVE_TO:{const[a,o,h,c]=s.slice(n,n+4);i.push(d=>d.quadraticCurveTo(a,o,h,c)),n+=4}break;case Zt.RESTORE:i.push(a=>a.restore());break;case Zt.SAVE:i.push(a=>a.save());break;case Zt.SCALE:gt(i.length===2,"Scale command is only valid at the third position.");break;case Zt.TRANSFORM:{const[a,o,h,c,d,u]=s.slice(n,n+6);i.push(p=>p.transform(a,o,h,c,d,u)),n+=6}break;case Zt.TRANSLATE:{const[a,o]=s.slice(n,n+2);i.push(h=>h.translate(a,o)),n+=2}break}return this.compiledGlyphs[e]=function(r,a){i[0](r),i[1](r),r.scale(a,-a);for(let o=2,h=i.length;o<h;o++)i[o](r)}}}if(Et){var Es=Promise.withResolvers(),Ss=null;(async()=>{const t=await Ve(()=>import("../chunks/__vite-browser-external.BIHI7g3E.js"),[],import.meta.url),e=await Ve(()=>import("../chunks/__vite-browser-external.BIHI7g3E.js"),[],import.meta.url),s=await Ve(()=>import("../chunks/__vite-browser-external.BIHI7g3E.js"),[],import.meta.url),i=await Ve(()=>import("../chunks/__vite-browser-external.BIHI7g3E.js"),[],import.meta.url);let n,r;return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:n,path2d:r}))})().then(t=>{Ss=t,Es.resolve()},t=>{j(`loadPackages: ${t}`),Ss=new Map,Es.resolve()})}class Kt{static get promise(){return Es.promise}static get(t){return Ss?.get(t)}}const Wi=function(l){return Kt.get("fs").promises.readFile(l).then(e=>new Uint8Array(e))};class rr extends is{}class ar extends ns{_createCanvas(t,e){return Kt.get("canvas").createCanvas(t,e)}}class or extends rs{_fetchData(t,e){return Wi(t).then(s=>({cMapData:s,compressionType:e}))}}class lr extends as{_fetchData(t){return Wi(t)}}const Ct={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Cs(l,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),l.clip(i)}class Oe{constructor(){this.constructor===Oe&&nt("Cannot initialize BaseShadingPattern.")}getPattern(){nt("Abstract method `getPattern` called.")}}class hr extends Oe{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===Ct.STROKE||i===Ct.FILL){const r=e.current.getClippedPathBoundingBox(i,ht(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,h=e.cachedCanvases.getCanvas("pattern",a,o,!0),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]),s=R.transform(s,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Cs(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(h.canvas,"no-repeat");const d=new DOMMatrix(s);n.setTransform(d)}else Cs(t,this._bbox),n=this._createGradient(t);return n}}function ps(l,t,e,s,i,n,r,a){const o=t.coords,h=t.colors,c=l.data,d=l.width*4;let u;o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u),o[s+1]>o[i+1]&&(u=s,s=i,i=u,u=r,r=a,a=u),o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=n,n=r,r=u);const p=(o[e]+t.offsetX)*t.scaleX,f=(o[e+1]+t.offsetY)*t.scaleY,g=(o[s]+t.offsetX)*t.scaleX,b=(o[s+1]+t.offsetY)*t.scaleY,m=(o[i]+t.offsetX)*t.scaleX,v=(o[i+1]+t.offsetY)*t.scaleY;if(f>=v)return;const _=h[n],A=h[n+1],E=h[n+2],w=h[r],S=h[r+1],T=h[r+2],k=h[a],O=h[a+1],M=h[a+2],G=Math.round(f),ot=Math.round(v);let lt,rt,J,P,I,St,At,Ot;for(let et=G;et<=ot;et++){if(et<b){const H=et<f?0:(f-et)/(f-b);lt=p-(p-g)*H,rt=_-(_-w)*H,J=A-(A-S)*H,P=E-(E-T)*H}else{let H;et>v?H=1:b===v?H=0:H=(b-et)/(b-v),lt=g-(g-m)*H,rt=w-(w-k)*H,J=S-(S-O)*H,P=T-(T-M)*H}let B;et<f?B=0:et>v?B=1:B=(f-et)/(f-v),I=p-(p-m)*B,St=_-(_-k)*B,At=A-(A-O)*B,Ot=E-(E-M)*B;const at=Math.round(Math.min(lt,I)),Z=Math.round(Math.max(lt,I));let Q=d*et+at*4;for(let H=at;H<=Z;H++)B=(lt-H)/(lt-I),B<0?B=0:B>1&&(B=1),c[Q++]=rt-(rt-St)*B|0,c[Q++]=J-(J-At)*B|0,c[Q++]=P-(P-Ot)*B|0,c[Q++]=255}}function cr(l,t,e){const s=t.coords,i=t.colors;let n,r;switch(t.type){case"lattice":const a=t.verticesPerRow,o=Math.floor(s.length/a)-1,h=a-1;for(n=0;n<o;n++){let c=n*a;for(let d=0;d<h;d++,c++)ps(l,e,s[c],s[c+1],s[c+a],i[c],i[c+1],i[c+a]),ps(l,e,s[c+a+1],s[c+1],s[c+a],i[c+a+1],i[c+1],i[c+a])}break;case"triangles":for(n=0,r=s.length;n<r;n+=3)ps(l,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}class dr extends Oe{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,s){const a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,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),p=h/d,f=c/u,g={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/p,scaleY:1/f},b=d+2*2,m=u+2*2,v=s.getCanvas("mesh",b,m,!1),_=v.context,A=_.createImageData(d,u);if(e){const w=A.data;for(let S=0,T=w.length;S<T;S+=4)w[S]=e[0],w[S+1]=e[1],w[S+2]=e[2],w[S+3]=255}for(const w of this._figures)cr(A,w,g);return _.putImageData(A,2,2),{canvas:v.canvas,offsetX:a-2*p,offsetY:o-2*f,scaleX:p,scaleY:f}}getPattern(t,e,s,i){Cs(t,this._bbox);let n;if(i===Ct.SHADING)n=R.singularValueDecompose2dScale(ht(t));else if(n=R.singularValueDecompose2dScale(e.baseTransform),this.matrix){const a=R.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}const r=this._createMeshCanvas(n,i===Ct.SHADING?null:this._background,e.cachedCanvases);return i!==Ct.SHADING&&(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 ur extends Oe{getPattern(){return"hotpink"}}function fr(l){switch(l[0]){case"RadialAxial":return new hr(l);case"Mesh":return new dr(l);case"Dummy":return new ur}throw new Error(`Unknown IR type: ${l[0]}`)}const ni={COLORED:1,UNCOLORED:2};class $s{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,i=this.xstep,n=this.ystep,r=this.paintType,a=this.tilingType,o=this.color,h=this.canvasGraphicsFactory;ts("TilingType: "+a);const c=s[0],d=s[1],u=s[2],p=s[3],f=R.singularValueDecompose2dScale(this.matrix),g=R.singularValueDecompose2dScale(this.baseTransform),b=[f[0]*g[0],f[1]*g[1]],m=this.getSizeAndScale(i,this.ctx.canvas.width,b[0]),v=this.getSizeAndScale(n,this.ctx.canvas.height,b[1]),_=t.cachedCanvases.getCanvas("pattern",m.size,v.size,!0),A=_.context,E=h.createCanvasGraphics(A);E.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(E,r,o);let w=c,S=d,T=u,k=p;return c<0&&(w=0,T+=Math.abs(c)),d<0&&(S=0,k+=Math.abs(d)),A.translate(-(m.scale*w),-(v.scale*S)),E.transform(m.scale,0,0,v.scale,0,0),A.save(),this.clipBbox(E,w,S,T,k),E.baseTransform=ht(E.ctx),E.executeOperatorList(e),E.endDrawing(),{canvas:_.canvas,scaleX:m.scale,scaleY:v.scale,offsetX:w,offsetY:S}}getSizeAndScale(t,e,s){t=Math.abs(t);const i=Math.max($s.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const r=i-e,a=n-s;t.ctx.rect(e,s,r,a),t.current.updateRectMinMax(ht(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case ni.COLORED:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case ni.UNCOLORED:const a=R.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new Bn(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==Ct.SHADING&&(n=R.transform(n,e.baseTransform),this.matrix&&(n=R.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function pr({src:l,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=It.isLittleEndian?4278190080:255,[o,h]=r?[n,a]:[a,n],c=s>>3,d=s&7,u=l.length;e=new Uint32Array(e.buffer);let p=0;for(let f=0;f<i;f++){for(const b=t+c;t<b;t++){const m=t<u?l[t]:255;e[p++]=m&128?h:o,e[p++]=m&64?h:o,e[p++]=m&32?h:o,e[p++]=m&16?h:o,e[p++]=m&8?h:o,e[p++]=m&4?h:o,e[p++]=m&2?h:o,e[p++]=m&1?h:o}if(d===0)continue;const g=t<u?l[t++]:255;for(let b=0;b<d;b++)e[p++]=g&1<<7-b?h:o}return{srcPos:t,destPos:p}}const ri=16,ai=100,gr=15,oi=10,li=1e3,Rt=16;function mr(l,t){if(l._removeMirroring)throw new Error("Context is already forwarding operations.");l.__originalSave=l.save,l.__originalRestore=l.restore,l.__originalRotate=l.rotate,l.__originalScale=l.scale,l.__originalTranslate=l.translate,l.__originalTransform=l.transform,l.__originalSetTransform=l.setTransform,l.__originalResetTransform=l.resetTransform,l.__originalClip=l.clip,l.__originalMoveTo=l.moveTo,l.__originalLineTo=l.lineTo,l.__originalBezierCurveTo=l.bezierCurveTo,l.__originalRect=l.rect,l.__originalClosePath=l.closePath,l.__originalBeginPath=l.beginPath,l._removeMirroring=()=>{l.save=l.__originalSave,l.restore=l.__originalRestore,l.rotate=l.__originalRotate,l.scale=l.__originalScale,l.translate=l.__originalTranslate,l.transform=l.__originalTransform,l.setTransform=l.__originalSetTransform,l.resetTransform=l.__originalResetTransform,l.clip=l.__originalClip,l.moveTo=l.__originalMoveTo,l.lineTo=l.__originalLineTo,l.bezierCurveTo=l.__originalBezierCurveTo,l.rect=l.__originalRect,l.closePath=l.__originalClosePath,l.beginPath=l.__originalBeginPath,delete l._removeMirroring},l.save=function(){t.save(),this.__originalSave()},l.restore=function(){t.restore(),this.__originalRestore()},l.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},l.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},l.transform=function(s,i,n,r,a,o){t.transform(s,i,n,r,a,o),this.__originalTransform(s,i,n,r,a,o)},l.setTransform=function(s,i,n,r,a,o){t.setTransform(s,i,n,r,a,o),this.__originalSetTransform(s,i,n,r,a,o)},l.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},l.rotate=function(s){t.rotate(s),this.__originalRotate(s)},l.clip=function(s){t.clip(s),this.__originalClip(s)},l.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},l.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},l.bezierCurveTo=function(e,s,i,n,r,a){t.bezierCurveTo(e,s,i,n,r,a),this.__originalBezierCurveTo(e,s,i,n,r,a)},l.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},l.closePath=function(){t.closePath(),this.__originalClosePath()},l.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class br{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function We(l,t,e,s,i,n,r,a,o,h){const[c,d,u,p,f,g]=ht(l);if(d===0&&u===0){const v=r*c+f,_=Math.round(v),A=a*p+g,E=Math.round(A),w=(r+o)*c+f,S=Math.abs(Math.round(w)-_)||1,T=(a+h)*p+g,k=Math.abs(Math.round(T)-E)||1;return l.setTransform(Math.sign(c),0,0,Math.sign(p),_,E),l.drawImage(t,e,s,i,n,0,0,S,k),l.setTransform(c,d,u,p,f,g),[S,k]}if(c===0&&p===0){const v=a*u+f,_=Math.round(v),A=r*d+g,E=Math.round(A),w=(a+h)*u+f,S=Math.abs(Math.round(w)-_)||1,T=(r+o)*d+g,k=Math.abs(Math.round(T)-E)||1;return l.setTransform(0,Math.sign(d),Math.sign(u),0,_,E),l.drawImage(t,e,s,i,n,0,0,k,S),l.setTransform(c,d,u,p,f,g),[k,S]}l.drawImage(t,e,s,i,n,r,a,o,h);const b=Math.hypot(c,d),m=Math.hypot(u,p);return[b*o,m*h]}function vr(l){const{width:t,height:e}=l;if(t>li||e>li)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let r=new Uint8Array(n*(e+1)),a,o,h;const c=t+7&-8;let d=new Uint8Array(c*e),u=0;for(const m of l.data){let v=128;for(;v>0;)d[u++]=m&v?0:255,v>>=1}let p=0;for(u=0,d[u]!==0&&(r[0]=1,++p),o=1;o<t;o++)d[u]!==d[u+1]&&(r[o]=d[u]?2:1,++p),u++;for(d[u]!==0&&(r[o]=2,++p),a=1;a<e;a++){u=a*c,h=a*n,d[u-c]!==d[u]&&(r[h]=d[u]?1:8,++p);let m=(d[u]?4:0)+(d[u-c]?8:0);for(o=1;o<t;o++)m=(m>>2)+(d[u+1]?4:0)+(d[u-c+1]?8:0),i[m]&&(r[h+o]=i[m],++p),u++;if(d[u-c]!==d[u]&&(r[h+o]=d[u]?2:4,++p),p>s)return null}for(u=c*(e-1),h=a*n,d[u]!==0&&(r[h]=8,++p),o=1;o<t;o++)d[u]!==d[u+1]&&(r[h+o]=d[u]?4:8,++p),u++;if(d[u]!==0&&(r[h+o]=4,++p),p>s)return null;const f=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;p&&a<=e;a++){let m=a*n;const v=m+t;for(;m<v&&!r[m];)m++;if(m===v)continue;g.moveTo(m%n,a);const _=m;let A=r[m];do{const E=f[A];do m+=E;while(!r[m]);const w=r[m];w!==5&&w!==10?(A=w,r[m]=0):(A=w&51*A>>4,r[m]&=A>>2|A<<2),g.lineTo(m%n,m/n|0),r[m]||--p}while(_!==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()}}class hi{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Di,this.textMatrixScale=1,this.fontMatrix=vs,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=yt.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,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,s){[e,s]=R.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=R.applyTransform(e,t),i=R.applyTransform(e.slice(2),t),n=R.applyTransform([e[0],e[3]],t),r=R.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(t,e){R.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,s,i,n,r,a,o,h,c){const d=R.bezierBoundingBox(e,s,i,n,r,a,o,h,c);c||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Ct.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Ct.STROKE){e||nt("Stroke bounding box must include transform.");const i=R.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=R.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=Ct.FILL,e=null){return R.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function ci(l,t){if(typeof ImageData<"u"&&t instanceof ImageData){l.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%Rt,n=(e-i)/Rt,r=i===0?n:n+1,a=l.createImageData(s,Rt);let o=0,h;const c=t.data,d=a.data;let u,p,f,g;if(t.kind===Ye.GRAYSCALE_1BPP){const b=c.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),v=m.length,_=s+7>>3,A=4294967295,E=It.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(f=u<n?Rt:i,h=0,p=0;p<f;p++){const w=b-o;let S=0;const T=w>_?s:w*8-7,k=T&-8;let O=0,M=0;for(;S<k;S+=8)M=c[o++],m[h++]=M&128?A:E,m[h++]=M&64?A:E,m[h++]=M&32?A:E,m[h++]=M&16?A:E,m[h++]=M&8?A:E,m[h++]=M&4?A:E,m[h++]=M&2?A:E,m[h++]=M&1?A:E;for(;S<T;S++)O===0&&(M=c[o++],O=128),m[h++]=M&O?A:E,O>>=1}for(;h<v;)m[h++]=0;l.putImageData(a,0,u*Rt)}}else if(t.kind===Ye.RGBA_32BPP){for(p=0,g=s*Rt*4,u=0;u<n;u++)d.set(c.subarray(o,o+g)),o+=g,l.putImageData(a,0,p),p+=Rt;u<r&&(g=s*i*4,d.set(c.subarray(o,o+g)),l.putImageData(a,0,p))}else if(t.kind===Ye.RGB_24BPP)for(f=Rt,g=s*f,u=0;u<r;u++){for(u>=n&&(f=i,g=s*f),h=0,p=g;p--;)d[h++]=c[o++],d[h++]=c[o++],d[h++]=c[o++],d[h++]=255;l.putImageData(a,0,u*Rt)}else throw new Error(`bad image kind: ${t.kind}`)}function di(l,t){if(t.bitmap){l.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%Rt,n=(e-i)/Rt,r=i===0?n:n+1,a=l.createImageData(s,Rt);let o=0;const h=t.data,c=a.data;for(let d=0;d<r;d++){const u=d<n?Rt:i;({srcPos:o}=pr({src:h,srcPos:o,dest:c,width:s,height:u,nonBlackColor:0})),l.putImageData(a,0,d*Rt)}}function ke(l,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)l[s]!==void 0&&(t[s]=l[s]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function Ge(l){if(l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0),!Et){const{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}}function ui(l,t){if(t)return!0;const e=R.singularValueDecompose2dScale(l);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Ce.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const Ar=["butt","round","square"],_r=["miter","round","bevel"],yr={},fi={};class Se{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,h){this.ctx=t,this.current=new hi(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=s,this.canvasFactory=i,this.filterFactory=n,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 br(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,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 typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){const o=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=o.canvas,this.ctx=o.context,this.ctx.save(),this.ctx.transform(...ht(this.compositeCtx))}this.ctx.save(),Ge(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=ht(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const h=o-a>oi&&typeof s=="function",c=h?Date.now()+gr:0;let d=0;const u=this.commonObjs,p=this.objs;let f;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(f=r[a],f!==Ut.dependency)this[f].apply(this,n[a]);else for(const g of n[a]){const b=g.startsWith("g_")?u:p;if(!b.has(g))return b.get(g,s),a}if(a++,a===o)return a;if(h&&++d>oi){if(Date.now()>c)return s(),a;d=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}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(t!=="none"){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 s=t.width,i=t.height;let n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=s,o=i,h="prescale1",c,d;for(;n>2&&a>1||r>2&&o>1;){let u=a,p=o;n>2&&a>1&&(u=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/u),r>2&&o>1&&(p=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,r/=o/p),c=this.cachedCanvases.getCanvas(h,u,p),d=c.context,d.clearRect(0,0,u,p),d.drawImage(t,0,0,a,o,0,0,u,p),t=c.canvas,a=u,o=p,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:o}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,r=this.current.patternFill,a=ht(e);let o,h,c,d;if((t.bitmap||t.data)&&t.count>1){const T=t.bitmap||t.data.buffer;h=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(T),o||(o=new Map,this._cachedBitmapsMap.set(T,o));const k=o.get(h);if(k&&!r){const O=Math.round(Math.min(a[0],a[2])+a[4]),M=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:k,offsetX:O,offsetY:M}}c=k}c||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),di(d.context,t));let u=R.transform(a,[1/s,0,0,-1/i,0,0]);u=R.transform(u,[1,0,0,1,0,-i]);const[p,f,g,b]=R.getAxialAlignedBoundingBox([0,0,s,i],u),m=Math.round(g-p)||1,v=Math.round(b-f)||1,_=this.cachedCanvases.getCanvas("fillCanvas",m,v),A=_.context,E=p,w=f;A.translate(-E,-w),A.transform(...u),c||(c=this._scaleImage(d.canvas,Jt(A)),c=c.img,o&&r&&o.set(h,c)),A.imageSmoothingEnabled=ui(ht(A),t.interpolate),We(A,c,0,0,c.width,c.height,0,0,s,i),A.globalCompositeOperation="source-in";const S=R.transform(Jt(A),[1,0,0,1,-E,-w]);return A.fillStyle=r?n.getPattern(e,this,S,Ct.FILL):n,A.fillRect(0,0,s,i),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(h,_.canvas)),{canvas:_.canvas,offsetX:Math.round(E),offsetY:Math.round(w)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Ar[t]}setLineJoin(t){this.ctx.lineJoin=_r[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...ht(this.suspendedCtx)),ke(this.suspendedCtx,n),mr(n,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(),ke(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){const n=i[0],r=i[1],a=i[2]-n,o=i[3]-r;a===0||o===0||(this.genericComposeSMask(e.context,s,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,r,a,o,h,c,d){let u=t.canvas,p=o-c,f=h-d;if(r){if(p<0||f<0||p+s>u.width||f+i>u.height){const b=this.cachedCanvases.getCanvas("maskExtension",s,i),m=b.context;m.drawImage(u,-p,-f),r.some(v=>v!==0)&&(m.globalCompositeOperation="destination-atop",m.fillStyle=R.makeHexColor(...r),m.fillRect(0,0,s,i),m.globalCompositeOperation="source-over"),u=b.canvas,p=f=0}else if(r.some(b=>b!==0)){t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const b=new Path2D;b.rect(p,f,s,i),t.clip(b),t.globalCompositeOperation="destination-atop",t.fillStyle=R.makeHexColor(...r),t.fillRect(p,f,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,h,s,i),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(u,p,f,s,i,o,h,s,i),e.restore()}save(){this.inSMaskMode?(ke(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),ke(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let r=n.x,a=n.y,o,h;const c=ht(i),d=c[0]===0&&c[3]===0||c[1]===0&&c[2]===0,u=d?s.slice(0):null;for(let p=0,f=0,g=t.length;p<g;p++)switch(t[p]|0){case Ut.rectangle:r=e[f++],a=e[f++];const b=e[f++],m=e[f++],v=r+b,_=a+m;i.moveTo(r,a),b===0||m===0?i.lineTo(v,_):(i.lineTo(v,a),i.lineTo(v,_),i.lineTo(r,_)),d||n.updateRectMinMax(c,[r,a,v,_]),i.closePath();break;case Ut.moveTo:r=e[f++],a=e[f++],i.moveTo(r,a),d||n.updatePathMinMax(c,r,a);break;case Ut.lineTo:r=e[f++],a=e[f++],i.lineTo(r,a),d||n.updatePathMinMax(c,r,a);break;case Ut.curveTo:o=r,h=a,r=e[f+4],a=e[f+5],i.bezierCurveTo(e[f],e[f+1],e[f+2],e[f+3],r,a),n.updateCurvePathMinMax(c,o,h,e[f],e[f+1],e[f+2],e[f+3],r,a,u),f+=6;break;case Ut.curveTo2:o=r,h=a,i.bezierCurveTo(r,a,e[f],e[f+1],e[f+2],e[f+3]),n.updateCurvePathMinMax(c,o,h,r,a,e[f],e[f+1],e[f+2],e[f+3],u),r=e[f+2],a=e[f+3],f+=4;break;case Ut.curveTo3:o=r,h=a,r=e[f+2],a=e[f+3],i.bezierCurveTo(e[f],e[f+1],r,a,r,a),n.updateCurvePathMinMax(c,o,h,e[f],e[f+1],r,a,r,a,u),f+=4;break;case Ut.closePath:i.closePath();break}d&&n.updateScalingPathMinMax(c,u),n.setCurrentPoint(r,a)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&s?.getPattern?(e.save(),e.strokeStyle=s.getPattern(e,this,Jt(e),Ct.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,s=this.current.fillColor,i=this.current.patternFill;let n=!1;i&&(e.save(),e.fillStyle=s.getPattern(e,this,Jt(e),Ct.FILL),n=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&r!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&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=yr}eoClip(){this.pendingClip=fi}beginText(){this.current.textMatrix=Di,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(t===void 0){e.beginPath();return}e.save(),e.beginPath();for(const s of t)e.setTransform(...s.transform),e.translate(s.x,s.y),s.addToPath(e,s.fontSize);e.restore(),e.clip(),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 s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||vs,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&j("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const n=s.loadedName||"sans-serif",r=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`;let a="normal";s.black?a="900":s.bold&&(a="bold");const o=s.italic?"italic":"normal";let h=e;e<ri?h=ri:e>ai&&(h=ai),this.current.fontSizeScale=e/h,this.ctx.font=`${o} ${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,s,i,n,r){this.current.textMatrix=[t,e,s,i,n,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)}paintChar(t,e,s,i){const n=this.ctx,r=this.current,a=r.font,o=r.textRenderingMode,h=r.fontSize/r.fontSizeScale,c=o&yt.FILL_STROKE_MASK,d=!!(o&yt.ADD_TO_PATH_FLAG),u=r.patternFill&&!a.missingFile;let p;(a.disableFontFace||d||u)&&(p=a.getPathGenerator(this.commonObjs,t)),a.disableFontFace||u?(n.save(),n.translate(e,s),n.beginPath(),p(n,h),i&&n.setTransform(...i),(c===yt.FILL||c===yt.FILL_STROKE)&&n.fill(),(c===yt.STROKE||c===yt.FILL_STROKE)&&n.stroke(),n.restore()):((c===yt.FILL||c===yt.FILL_STROKE)&&n.fillText(t,e,s),(c===yt.STROKE||c===yt.FILL_STROKE)&&n.strokeText(t,e,s)),d&&(this.pendingTextPaths||=[]).push({transform:ht(n),x:e,y:s,fontSize:h,addToPath:p})}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 s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return K(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,h=e.fontDirection,c=e.textHScale*h,d=t.length,u=s.vertical,p=u?1:-1,f=s.defaultVMetrics,g=i*e.fontMatrix[0],b=e.textRenderingMode===yt.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),h>0?n.scale(c,-1):n.scale(c,1);let m;if(e.patternFill){n.save();const w=e.fillColor.getPattern(n,this,Jt(n),Ct.FILL);m=ht(n),n.restore(),n.fillStyle=w}let v=e.lineWidth;const _=e.textMatrixScale;if(_===0||v===0){const w=e.textRenderingMode&yt.FILL_STROKE_MASK;(w===yt.STROKE||w===yt.FILL_STROKE)&&(v=this.getSinglePixelWidth())}else v/=_;if(r!==1&&(n.scale(r,r),v/=r),n.lineWidth=v,s.isInvalidPDFjsFont){const w=[];let S=0;for(const T of t)w.push(T.unicode),S+=T.width;n.fillText(w.join(""),0,0),e.x+=S*g*c,n.restore(),this.compose();return}let A=0,E;for(E=0;E<d;++E){const w=t[E];if(typeof w=="number"){A+=p*w*i/1e3;continue}let S=!1;const T=(w.isSpace?o:0)+a,k=w.fontChar,O=w.accent;let M,G,ot=w.width;if(u){const rt=w.vmetric||f,J=-(w.vmetric?rt[1]:ot*.5)*g,P=rt[2]*g;ot=rt?-rt[0]:ot,M=J/r,G=(A+P)/r}else M=A/r,G=0;if(s.remeasure&&ot>0){const rt=n.measureText(k).width*1e3/i*r;if(ot<rt&&this.isFontSubpixelAAEnabled){const J=ot/rt;S=!0,n.save(),n.scale(J,1),M/=J}else ot!==rt&&(M+=(ot-rt)/2e3*i/r)}if(this.contentVisible&&(w.isInFont||s.missingFile)){if(b&&!O)n.fillText(k,M,G);else if(this.paintChar(k,M,G,m),O){const rt=M+i*O.offset.x/r,J=G-i*O.offset.y/r;this.paintChar(O.fontChar,rt,J,m)}}const lt=u?ot*g-T*h:ot*g+T*h;A+=lt,S&&n.restore()}u?e.y-=A:e.x+=A*c,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,r=s.fontDirection,a=i.vertical?1:-1,o=s.charSpacing,h=s.wordSpacing,c=s.textHScale*r,d=s.fontMatrix||vs,u=t.length,p=s.textRenderingMode===yt.INVISIBLE;let f,g,b,m;if(!(p||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(c,r),f=0;f<u;++f){if(g=t[f],typeof g=="number"){m=a*g*n/1e3,this.ctx.translate(m,0),s.x+=m*c;continue}const v=(g.isSpace?h:0)+o,_=i.charProcOperatorList[g.operatorListId];if(!_){j(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(_),this.restore()),b=R.applyTransform([g.width,0],d)[0]*n+v,e.translate(b,0),s.x+=b*c}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||ht(this.ctx),n={createCanvasGraphics:r=>new Se(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new $s(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const i=R.makeHexColor(t,e,s);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(t,e,s){const i=R.makeHexColor(t,e,s);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=fr(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Jt(e),Ct.SHADING);const i=Jt(e);if(i){const{width:n,height:r}=e.canvas,[a,o,h,c]=R.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,o,h-a,c-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){nt("Should not call beginInlineImage")}beginImageData(){nt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=ht(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(ht(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||ts("TODO: Support non-isolated groups."),t.knockout&&j("Knockout groups not supported.");const s=ht(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=R.getAxialAlignedBoundingBox(t.bbox,ht(e));const n=[0,0,e.canvas.width,e.canvas.height];i=R.intersect(i,n)||[0,0,0,0];const r=Math.floor(i[0]),a=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-r,1),h=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,h]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(c,o,h),u=d.context;u.translate(-r,-a),u.transform(...s),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()),ke(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,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=ht(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=R.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(this.#t(),Ge(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(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=r,e[3]=a;const[o,h]=R.singularValueDecompose2dScale(ht(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:p,context:f}=this.annotationCanvas;this.annotationCanvasMap.set(t,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(o,0,0,-h,0,a*h),Ge(this.ctx)}else Ge(this.ctx),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.endPath()}this.current=new hi(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}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),t.count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=vr(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=ht(a);a.transform(e,s,i,n,0,0);const h=this._createMaskCanvas(t);a.setTransform(1,0,0,1,h.offsetX-o[4],h.offsetY-o[5]);for(let c=0,d=r.length;c<d;c+=2){const u=R.transform(o,[e,s,i,n,r[c],r[c+1]]),[p,f]=R.applyTransform([0,0],u);a.drawImage(h.canvas,p,f)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:r,width:a,height:o,transform:h}=n,c=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=c.context;d.save();const u=this.getObject(r,n);di(d,u),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,Jt(e),Ct.FILL):s,d.fillRect(0,0,a,o),d.restore(),e.save(),e.transform(...h),e.scale(1,-1),We(e,c.canvas,0,0,a,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){j("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n){j("Dependent image isn't ready yet");return}const r=n.width,a=n.height,o=[];for(let h=0,c=i.length;h<c;h+=2)o.push({transform:[e,0,0,s,i[h],i[h+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!Et){const{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}i.scale(1/e,-1/s);let n;if(t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const o=this.cachedCanvases.getCanvas("inlineImage",e,s).context;ci(o,t),n=this.applyTransferMapsToCanvas(o)}const r=this._scaleImage(n,Jt(i));i.imageSmoothingEnabled=ui(ht(i),t.interpolate),We(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,r=t.height,o=this.cachedCanvases.getCanvas("inlineImage",n,r).context;ci(o,t),i=this.applyTransferMapsToCanvas(o)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),We(s,i,n.x,n.y,n.w,n.h,0,-1,1,1),s.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){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===fi?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=ht(this.ctx);if(t[1]===0&&t[2]===0)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]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let r,a;if(s===0&&i===0){const o=Math.abs(e),h=Math.abs(n);if(o===h)if(t===0)r=a=1/o;else{const c=o*t;r=a=c<1?1/c:1}else if(t===0)r=1/o,a=1/h;else{const c=o*t,d=h*t;r=c<1?1/c:1,a=d<1?1/d:1}}else{const o=Math.abs(e*n-s*i),h=Math.hypot(e,s),c=Math.hypot(i,n);if(t===0)r=c/o,a=h/o;else{const d=t*o;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:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}const r=e.getLineDash();if(t&&e.save(),e.scale(i,n),r.length>0){const a=Math.max(i,n);e.setLineDash(r.map(o=>o/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 l in Ut)Se.prototype[l]!==void 0&&(Se.prototype[Ut[l]]=Se.prototype[l]);class Ie{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}const qe={UNKNOWN:0,DATA:1,ERROR:2},dt={UNKNOWN:0,CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Ft(l){switch(l instanceof Error||typeof l=="object"&&l!==null||nt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new Ae(l.message);case"MissingPDFException":return new ve(l.message);case"PasswordException":return new _s(l.message,l.code);case"UnexpectedResponseException":return new es(l.message,l.status);case"UnknownErrorException":return new ys(l.message,l.details);default:return new ys(l.message,l.toString())}}class Me{constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=i=>{const n=i.data;if(n.targetName!==this.sourceName)return;if(n.stream){this.#e(n);return}if(n.callback){const a=n.callbackId,o=this.callbackCapabilities[a];if(!o)throw new Error(`Cannot resolve callback ${a}`);if(delete this.callbackCapabilities[a],n.callback===qe.DATA)o.resolve(n.data);else if(n.callback===qe.ERROR)o.reject(Ft(n.reason));else throw new Error("Unexpected callback case");return}const r=this.actionHandler[n.action];if(!r)throw new Error(`Unknown action from worker: ${n.action}`);if(n.callbackId){const a=this.sourceName,o=n.sourceName;new Promise(function(h){h(r(n.data))}).then(function(h){s.postMessage({sourceName:a,targetName:o,callback:qe.DATA,callbackId:n.callbackId,data:h})},function(h){s.postMessage({sourceName:a,targetName:o,callback:qe.ERROR,callbackId:n.callbackId,reason:Ft(h)})});return}if(n.streamId){this.#t(n);return}r(n.data)},s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[n]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:dt.PULL,streamId:n,desiredSize:h.desiredSize}),c.promise},cancel:h=>{gt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:dt.CANCEL,streamId:n,reason:Ft(h)}),c.promise}},s)}#t(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={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),n.postMessage({sourceName:s,targetName:i,stream:dt.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:dt.CLOSE,streamId:e}),delete r.streamSinks[e])},error(h){gt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:dt.ERROR,streamId:e,reason:Ft(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise(function(h){h(a(t.data,o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:dt.START_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:dt.START_COMPLETE,streamId:e,reason:Ft(h)})})}#e(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case dt.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(Ft(t.reason));break;case dt.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(Ft(t.reason));break;case dt.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:dt.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,new Promise(function(o){o(a.onPull?.())}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:dt.PULL_COMPLETE,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:dt.PULL_COMPLETE,streamId:e,reason:Ft(o)})});break;case dt.ENQUEUE:if(gt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case dt.CLOSE:if(gt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#s(r,e);break;case dt.ERROR:gt(r,"error should have stream controller"),r.controller.error(Ft(t.reason)),this.#s(r,e);break;case dt.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(Ft(t.reason)),this.#s(r,e);break;case dt.CANCEL:if(!a)break;new Promise(function(o){o(a.onCancel?.(Ft(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:dt.CANCEL_COMPLETE,streamId:e,success:!0})},function(o){n.postMessage({sourceName:s,targetName:i,stream:dt.CANCEL_COMPLETE,streamId:e,reason:Ft(o)})}),a.sinkCapability.reject(Ft(t.reason)),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#s(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class wr{#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 Ns(this.#t)}has(t){return this.#t.has(t)}}const ae=Symbol("INTERNAL");class Er{#t=!1;#e=!1;#s=!1;#n=!0;constructor(t,{name:e,intent:s,usage:i}){this.#t=!!(t&Bt.DISPLAY),this.#e=!!(t&Bt.PRINT),this.name=e,this.intent=s,this.usage=i}get visible(){if(this.#s)return this.#n;if(!this.#n)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==ae&&nt("Internal method `_setVisible` called."),this.#s=s,this.#n=e}}class Sr{#t=null;#e=new Map;#s=null;#n=null;constructor(t,e=Bt.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#n=t.order;for(const s of t.groups)this.#e.set(s.id,new Er(e,s));if(t.baseState==="OFF")for(const s of this.#e.values())s._setVisible(ae,!1);for(const s of t.on)this.#e.get(s)._setVisible(ae,!0);for(const s of t.off)this.#e.get(s)._setVisible(ae,!1);this.#s=this.getHash()}}#o(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let r;if(Array.isArray(n))r=this.#o(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return j(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return ts("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(j(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#o(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return j(`Unknown optional content policy ${t.policy}.`),!0}return j(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0){const s=this.#e.get(t);if(!s){j(`Optional content group not found: ${t}`);return}s._setVisible(ae,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=this.#e.get(i);if(n)switch(s){case"ON":n._setVisible(ae,!0);break;case"OFF":n._setVisible(ae,!1);break;case"Toggle":n._setVisible(ae,!n.visible);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){return this.#e.size?this.#n?this.#n.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?Ns(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new ji;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}}class Cr{constructor(t,{disableRange:e=!1,disableStream:s=!1}){gt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const o=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(o)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((o,h)=>{this._onReceiveData({begin:o,chunk:h})}),t.addProgressListener((o,h)=>{this._onProgress({loaded:o,total:h})}),t.addProgressiveReadListener(o=>{this._onReceiveData({chunk:o})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(s),!0)});gt(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?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(){gt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Tr(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new xr(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Tr{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Us(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.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}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class xr{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function kr(l){let t=!0,e=s("filename\\*","i").exec(l);if(e){e=e[1];let c=a(e);return c=unescape(c),c=o(c),c=h(c),n(c)}if(e=r(l),e){const c=h(e);return n(c)}if(e=s("filename","i").exec(l),e){e=e[1];let c=a(e);return c=h(c),n(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(c,{fatal:!0}),p=ss(d);d=u.decode(p),t=!1}catch{}}return d}function n(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function r(c){const d=[];let u;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=p.exec(c))!==null;){let[,g,b,m]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[b,m]}const f=[];for(let g=0;g<d.length&&g in d;++g){let[b,m]=d[g];m=a(m),b&&(m=unescape(m),g===0&&(m=o(m))),f.push(m)}return f.join("")}function a(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let u=0;u<d.length;++u){const p=d[u].indexOf('"');p!==-1&&(d[u]=d[u].slice(0,p),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function o(c){const d=c.indexOf("'");if(d===-1)return c;const u=c.slice(0,d),f=c.slice(d+1).replace(/^[^']*'/,"");return i(u,f)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,p,f){if(p==="q"||p==="Q")return f=f.replaceAll("_"," "),f=f.replaceAll(/=([0-9a-fA-F]{2})/g,function(g,b){return String.fromCharCode(parseInt(b,16))}),i(u,f);try{f=atob(f)}catch{}return i(u,f)})}return""}function Xs({getResponseHeader:l,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(l("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||l("Accept-Ranges")!=="bytes"||(l("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Ys(l){const t=l("Content-Disposition");if(t){let e=kr(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Us(e))return e}return null}function ls(l,t){return l===404||l===0&&t.startsWith("file:")?new ve('Missing PDF "'+t+'".'):new es(`Unexpected server response (${l}) while retrieving PDF "${t}".`,l)}function Gi(l){return l===200||l===206}function qi(l,t,e){return{method:"GET",headers:l,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function $i(l){const t=new Headers;for(const e in l){const s=l[e];s!==void 0&&t.append(e,s)}return t}function Xi(l){return l instanceof Uint8Array?l.buffer:l instanceof ArrayBuffer?l:(j(`getArrayBuffer - unexpected data format: ${l}`),new Uint8Array(l).buffer)}class pi{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return gt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Rr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Pr(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Rr{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,this._headers=$i(this._stream.httpHeaders);const s=e.url;fetch(s,qi(this._headers,this._withCredentials,this._abortController)).then(i=>{if(!Gi(i.status))throw ls(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const n=o=>i.headers.get(o),{allowRangeRequests:r,suggestedLength:a}=Xs({getResponseHeader:n,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=a||this._contentLength,this._filename=Ys(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ae("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Xi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Pr{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=$i(this._stream.httpHeaders),this._headers.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,qi(this._headers,this._withCredentials,this._abortController)).then(r=>{if(!Gi(r.status))throw ls(r.status,n);this._readCapability.resolve(),this._reader=r.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Xi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const gs=200,ms=206;function Mr(l){const t=l.response;return typeof t!="string"?t:ss(t).buffer}class Lr{constructor(t,e={}){this.url=t,this.isHttp=/^https?:/i.test(t),this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null),this.withCredentials=e.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const n in this.httpHeaders){const r=this.httpHeaders[n];r!==void 0&&e.setRequestHeader(n,r)}return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=ms):i.expectedStatus=gs,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError?.(i.status);return}const n=i.status||gs;if(!(n===gs&&s.expectedStatus===ms)&&n!==s.expectedStatus){s.onError?.(i.status);return}const a=Mr(i);if(n===ms){const o=i.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(o);s.onDone({begin:parseInt(h[1],10),chunk:a})}else a?s.onDone({begin:0,chunk:a}):s.onError?.(i.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 Ir{constructor(t){this._source=t,this._manager=new Lr(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials}),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 gt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Dr(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Fr(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Dr{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),this._headersReceivedCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),s=r=>e.getResponseHeader(r),{allowRangeRequests:i,suggestedLength:n}=Xs({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Ys(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersReceivedCapability.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=ls(t,this._url),this._headersReceivedCapability.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._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersReceivedCapability.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 Fr{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_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 s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=ls(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}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Yi=/^file:\/\/\/[a-zA-Z]:\//;function Nr(l){const t=Kt.get("url"),e=t.parse(l);return e.protocol==="file:"||e.host?e:/^[a-z]:[/\\]/i.test(l)?t.parse(`file:///${l}`):(e.host||(e.protocol="file:"),e)}class Or{constructor(t){this.source=t,this.url=Nr(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return gt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new zr(this):new Hr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new Ur(this,t,e):new Br(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ki{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()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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 Ae("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Qi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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)}}function Qe(l,t){return{protocol:l.protocol,auth:l.auth,host:l.hostname,port:l.port,path:l.path,method:"GET",headers:t}}class Hr extends Ki{constructor(t){super(t);const e=s=>{if(s.statusCode===404){const a=new ve(`Missing PDF "${this._url}".`);this._storedError=a,this._headersCapability.reject(a);return}this._headersCapability.resolve(),this._setReadableStream(s);const i=a=>this._readableStream.headers[a.toLowerCase()],{allowRangeRequests:n,suggestedLength:r}=Xs({getResponseHeader:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Ys(i)};if(this._request=null,this._url.protocol==="http:"){const s=Kt.get("http");this._request=s.request(Qe(this._url,t.httpHeaders),e)}else{const s=Kt.get("https");this._request=s.request(Qe(this._url,t.httpHeaders),e)}this._request.on("error",s=>{this._storedError=s,this._headersCapability.reject(s)}),this._request.end()}}class Br extends Qi{constructor(t,e,s){super(t),this._httpHeaders={};for(const n in t.httpHeaders){const r=t.httpHeaders[n];r!==void 0&&(this._httpHeaders[n]=r)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const i=n=>{if(n.statusCode===404){const r=new ve(`Missing PDF "${this._url}".`);this._storedError=r;return}this._setReadableStream(n)};if(this._request=null,this._url.protocol==="http:"){const n=Kt.get("http");this._request=n.request(Qe(this._url,this._httpHeaders),i)}else{const n=Kt.get("https");this._request=n.request(Qe(this._url,this._httpHeaders),i)}this._request.on("error",n=>{this._storedError=n}),this._request.end()}}class zr extends Ki{constructor(t){super(t);let e=decodeURIComponent(this._url.path);Yi.test(this._url.href)&&(e=e.replace(/^\//,""));const s=Kt.get("fs");s.promises.lstat(e).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(e)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new ve(`Missing PDF "${e}".`)),this._storedError=i,this._headersCapability.reject(i)})}}class Ur extends Qi{constructor(t,e,s){super(t);let i=decodeURIComponent(this._url.path);Yi.test(this._url.href)&&(i=i.replace(/^\//,""));const n=Kt.get("fs");this._setReadableStream(n.createReadStream(i,{start:e,end:s-1}))}}const jr=1e5,kt=30,Vr=.8;class Pt{#t=Promise.withResolvers();#e=null;#s=!1;#n=!!globalThis.FontInspector?.enabled;#o=null;#i=null;#r=0;#l=0;#c=null;#d=null;#f=0;#h=0;#a=Object.create(null);#p=[];#m=null;#u=[];#v=new WeakMap;#g=null;static#A=new Map;static#y=new Map;static#E=null;static#C=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#m=t;else if(typeof t=="object")this.#m=new ReadableStream({start(o){o.enqueue(t),o.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#d=e,this.#h=s.scale*(globalThis.devicePixelRatio||1),this.#f=s.rotation,this.#i={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;this.#g=[1,0,0,-1,-r,a+n],this.#l=i,this.#r=n,Pt.#b(),me(e,s),this.#t.promise.catch(()=>{}).then(()=>{Pt.#C.delete(this),this.#i=null,this.#a=null})}render(){const t=()=>{this.#c.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#o??=e.lang,Object.assign(this.#a,e.styles),this.#T(e.items),t()},this.#t.reject)};return this.#c=this.#m.getReader(),Pt.#C.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#f&&(e?.(),this.#f=i,me(this.#d,{rotation:i})),s!==this.#h){e?.(),this.#h=s;const n={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:Pt.#_(this.#o)};for(const r of this.#u)n.properties=this.#v.get(r),n.div=r,this.#S(n)}}cancel(){const t=new Ae("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#u}get textContentItemsStr(){return this.#p}#T(t){if(this.#s)return;this.#i.ctx??=Pt.#_(this.#o);const e=this.#u,s=this.#p;for(const i of t){if(e.length>jr){j("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id!==null&&this.#e.setAttribute("id",`${i.id}`),n.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(i.str),this.#P(i)}}#P(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#u.push(e);const i=R.transform(this.#g,t.transform);let n=Math.atan2(i[1],i[0]);const r=this.#a[t.fontName];r.vertical&&(n+=Math.PI/2);const a=this.#n&&r.fontSubstitution||r.fontFamily,o=Math.hypot(i[2],i[3]),h=o*Pt.#w(a,this.#o);let c,d;n===0?(c=i[4],d=i[5]-h):(c=i[4]+h*Math.sin(n),d=i[5]-h*Math.cos(n));const u="calc(var(--scale-factor)*",p=e.style;this.#e===this.#d?(p.left=`${(100*c/this.#l).toFixed(2)}%`,p.top=`${(100*d/this.#r).toFixed(2)}%`):(p.left=`${u}${c.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(Pt.#E*o).toFixed(2)}px)`,p.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#n&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const g=Math.abs(t.transform[0]),b=Math.abs(t.transform[3]);g!==b&&Math.max(g,b)/Math.min(g,b)>1.5&&(f=!0)}if(f&&(s.canvasWidth=r.vertical?t.height:t.width),this.#v.set(e,s),this.#i.div=e,this.#i.properties=s,this.#S(this.#i),s.hasText&&this.#e.append(e),s.hasEOL){const g=document.createElement("br");g.setAttribute("role","presentation"),this.#e.append(g)}}#S(t){const{div:e,properties:s,ctx:i,prevFontSize:n,prevFontFamily:r}=t,{style:a}=e;let o="";if(Pt.#E>1&&(o=`scale(${1/Pt.#E})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:h}=a,{canvasWidth:c,fontSize:d}=s;(n!==d||r!==h)&&(i.font=`${d*this.#h}px ${h}`,t.prevFontSize=d,t.prevFontFamily=h);const{width:u}=i.measureText(e.textContent);u>0&&(o=`scaleX(${c*this.#h/u}) ${o}`)}s.angle!==0&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#C.size>0)){this.#A.clear();for(const{canvas:t}of this.#y.values())t.remove();this.#y.clear()}}static#_(t=null){let e=this.#y.get(t||="");if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#y.set(t,e)}return e}static#b(){if(this.#E!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.textContent="X",document.body.append(t),this.#E=t.getBoundingClientRect().height,t.remove()}static#w(t,e){const s=this.#A.get(t);if(s)return s;const i=this.#_(e),n=i.font;i.canvas.width=i.canvas.height=kt,i.font=`${kt}px ${t}`;const r=i.measureText("");let a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);if(a){const d=a/(a+o);return this.#A.set(t,d),i.canvas.width=i.canvas.height=0,i.font=n,d}i.strokeStyle="red",i.clearRect(0,0,kt,kt),i.strokeText("g",0,0);let h=i.getImageData(0,0,kt,kt).data;o=0;for(let d=h.length-1-3;d>=0;d-=4)if(h[d]>0){o=Math.ceil(d/4/kt);break}i.clearRect(0,0,kt,kt),i.strokeText("A",0,kt),h=i.getImageData(0,0,kt,kt).data,a=0;for(let d=0,u=h.length;d<u;d+=4)if(h[d]>0){a=kt-Math.floor(d/4/kt);break}i.canvas.width=i.canvas.height=0,i.font=n;const c=a?a/(a+o):Vr;return this.#A.set(t,c),c}}function Wr(){zi("`renderTextLayer`, please use `TextLayer` instead.");const{textContentSource:l,container:t,viewport:e,...s}=arguments[0],i=Object.keys(s);i.length>0&&j("Ignoring `renderTextLayer` parameters: "+i.join(", "));const n=new Pt({textContentSource:l,container:t,viewport:e}),{textDivs:r,textContentItemsStr:a}=n;return{promise:n.render(),textDivs:r,textContentItemsStr:a}}function Gr(){zi("`updateTextLayer`, please use `TextLayer` instead.")}class De{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(De.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const qr=65536,$r=100,Xr=5e3,Yr=Et?ar:$n,Kr=Et?or:Hi,Qr=Et?rr:qn,Zr=Et?lr:Bi;function Jr(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});const t=new Ks,{docId:e}=t,s=l.url?ta(l.url):null,i=l.data?ea(l.data):null,n=l.httpHeaders||null,r=l.withCredentials===!0,a=l.password??null,o=l.range instanceof Zi?l.range:null,h=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:qr;let c=l.worker instanceof zt?l.worker:null;const d=l.verbosity,u=typeof l.docBaseUrl=="string"&&!zs(l.docBaseUrl)?l.docBaseUrl:null,p=typeof l.cMapUrl=="string"?l.cMapUrl:null,f=l.cMapPacked!==!1,g=l.CMapReaderFactory||Kr,b=typeof l.standardFontDataUrl=="string"?l.standardFontDataUrl:null,m=l.StandardFontDataFactory||Zr,v=l.stopAtErrors!==!0,_=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,A=l.isEvalSupported!==!1,E=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!Et,w=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,S=typeof l.disableFontFace=="boolean"?l.disableFontFace:Et,T=l.fontExtraProperties===!0,k=l.enableXfa===!0,O=l.ownerDocument||globalThis.document,M=l.disableRange===!0,G=l.disableStream===!0,ot=l.disableAutoFetch===!0,lt=l.pdfBug===!0,rt=l.enableHWA===!0,J=o?o.length:l.length??NaN,P=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!Et&&!S,I=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:g===Hi&&m===Bi&&p&&b&&Pe(p,document.baseURI)&&Pe(b,document.baseURI),St=l.canvasFactory||new Yr({ownerDocument:O,enableHWA:rt}),At=l.filterFactory||new Qr({docId:e,ownerDocument:O}),Ot=null;Fn(d);const et={canvasFactory:St,filterFactory:At};if(I||(et.cMapReaderFactory=new g({baseUrl:p,isCompressed:f}),et.standardFontDataFactory=new m({baseUrl:b})),!c){const Z={verbosity:d,port:Ie.workerPort};c=Z.port?zt.fromPort(Z):new zt(Z),t._worker=c}const B={docId:e,apiVersion:"4.4.168",data:i,password:a,disableAutoFetch:ot,rangeChunkSize:h,length:J,docBaseUrl:u,enableXfa:k,evaluatorOptions:{maxImageSize:_,disableFontFace:S,ignoreErrors:v,isEvalSupported:A,isOffscreenCanvasSupported:E,canvasMaxAreaInBytes:w,fontExtraProperties:T,useSystemFonts:P,cMapUrl:I?p:null,standardFontDataUrl:I?b:null}},at={disableFontFace:S,fontExtraProperties:T,ownerDocument:O,pdfBug:lt,styleElement:Ot,loadingParams:{disableAutoFetch:ot,enableXfa:k}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const Z=c.messageHandler.sendWithPromise("GetDocRequest",B,i?[i.buffer]:null);let Q;if(o)Q=new Cr(o,{disableRange:M,disableStream:G});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");Q=(q=>Et?function(){return typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype}()&&Pe(q.url)?new pi(q):new Or(q):Pe(q.url)?new pi(q):new Ir(q))({url:s,length:J,httpHeaders:n,withCredentials:r,rangeChunkSize:h,disableRange:M,disableStream:G})}return Z.then(H=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const q=new Me(e,H,c.port),U=new ra(q,t,Q,at,et);t._transport=U,q.send("Ready",null)})}).catch(t._capability.reject),t}function ta(l){if(l instanceof URL)return l.href;try{return new URL(l,window.location).href}catch{if(Et&&typeof l=="string")return l}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function ea(l){if(Et&&typeof Buffer<"u"&&l instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(l instanceof Uint8Array&&l.byteLength===l.buffer.byteLength)return l;if(typeof l=="string")return ss(l);if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)||typeof l=="object"&&!isNaN(l?.length))return new Uint8Array(l);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function gi(l){return typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0}class Ks{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Ks.#t++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}class Zi{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,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 s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(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){nt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class sa{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return K(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 ia{#t=null;#e=!1;constructor(t,e,s,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new ei:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Ji,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:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new Fe({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}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 K(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=he.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:h=null,printAnnotationStorage:c=null}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(s,i,c),{renderingIntent:u,cacheKey:p}=d;this.#e=!1,this.#n(),a||=this._transport.getOptionalContentConfig(u);let f=this._intentStates.get(p);f||(f=Object.create(null),this._intentStates.set(p,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const g=!!(u&Bt.PRINT);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const b=_=>{f.renderTasks.delete(m),(this._maybeCleanupAfterRender||g)&&(this.#e=!0),this.#s(!g),_?(m.capability.reject(_),this._abortOperatorList({intentState:f,reason:_ instanceof Error?_:new Error(_)})):m.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},m=new Ee({callback:b,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:f.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!g,pdfBug:this._pdfBug,pageColors:h});(f.renderTasks||=new Set).add(m);const v=m.task;return Promise.all([f.displayReadyCapability.promise,a]).then(([_,A])=>{if(this.destroyed){b();return}if(this._stats?.time("Rendering"),!(A.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");m.initializeGraphics({transparency:_,optionalContentConfig:A}),m.operatorListChanged()}).catch(b),v}getOperatorList({intent:t="display",annotationMode:e=he.ENABLE,printAnnotationStorage:s=null}={}){function i(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))}const n=this._transport.getRenderingIntent(t,e,s,!0);let r=this._intentStates.get(n.cacheKey);r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r));let a;return r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=i,r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>De.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){r.read().then(function({value:o,done:h}){if(h){s(a);return}a.lang??=o.lang,Object.assign(a.styles,o.styles),a.items.push(...o.items),n()},i)}const r=e.getReader(),a={items:[],styles:Object.create(null),lang:null};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 s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#e=!1,this.#n(),Promise.all(t)}cleanup(t=!1){this.#e=!0;const e=this.#s(!1);return t&&e&&(this._stats&&=new ei),e}#s(t=!1){if(this.#n(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#s(!1)},Xr),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.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 s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#s(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s}){const{map:i,transfer:n}=s,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i},n).getReader(),o=this._intentStates.get(e);o.streamReader=a;const h=()=>{a.read().then(({value:c,done:d})=>{if(d){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(c,o),h())},c=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const d of o.renderTasks)d.operatorListChanged();this.#s(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(c);else if(o.opListReadCapability)o.opListReadCapability.reject(c);else throw c}})};h()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Bs){let i=$r;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new Ae(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}class na{#t=new Set;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const i of this.#t)i.call(this,s)})}addEventListener(t,e){this.#t.add(e)}removeEventListener(t,e){this.#t.delete(e)}terminate(){this.#t.clear()}}const se={isWorkerDisabled:!1,fakeWorkerId:0};Et&&(se.isWorkerDisabled=!0,Ie.workerSrc||="./pdf.worker.mjs"),se.isSameOrigin=function(l,t){let e;try{if(e=new URL(l),!e.origin||e.origin==="null")return!1}catch{return!1}const s=new URL(t,e);return e.origin===s.origin},se.createCDNWrapper=function(l){const t=`await import("${l}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};class zt{static#t;constructor({name:t=null,port:e=null,verbosity:s=Nn()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(zt.#t?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(zt.#t||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return Et?Promise.all([Kt.promise,this._readyCapability.promise]):this._readyCapability.promise}#e(){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 Me("main","worker",t),this._messageHandler.on("ready",function(){}),this.#e()}_initialize(){if(se.isWorkerDisabled||zt.#s){this._setupFakeWorker();return}let{workerSrc:t}=zt;try{se.isSameOrigin(window.location.href,t)||(t=se.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Me("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{if(n.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,this.#e()}),s.on("ready",a=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{ts("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){se.isWorkerDisabled||(j("Setting up fake worker."),se.isWorkerDisabled=!0),zt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new na;this._port=e;const s=`fake${se.fakeWorkerId++}`,i=new Me(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new Me(s,s+"_worker",e),this.#e()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),zt.#t?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#t?.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 zt(t)}static get workerSrc(){if(Ie.workerSrc)return Ie.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#s(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return K(this,"_setupFakeWorkerGlobal",(async()=>this.#s?this.#s:(await import(this.workerSrc)).WorkerMessageHandler)())}}class ra{#t=new Map;#e=new Map;#s=new Map;#n=new Map;#o=null;constructor(t,e,s,i,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Ji,this.fontLoader=new ir({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#i(t,e=null){const s=this.#t.get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,i),i}get annotationStorage(){return K(this,"annotationStorage",new qs)}getRenderingIntent(t,e=he.ENABLE,s=null,i=!1){let n=Bt.DISPLAY,r=ws;switch(t){case"any":n=Bt.ANY;break;case"display":break;case"print":n=Bt.PRINT;break;default:j(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case he.DISABLE:n+=Bt.ANNOTATIONS_DISABLE;break;case he.ENABLE:break;case he.ENABLE_FORMS:n+=Bt.ANNOTATIONS_FORMS;break;case he.ENABLE_STORAGE:n+=Bt.ANNOTATIONS_STORAGE,r=(n&Bt.PRINT&&s instanceof Vi?s:this.annotationStorage).serializable;break;default:j(`getRenderingIntent - invalid annotationMode: ${e}`)}return i&&(n+=Bt.OPLIST),{renderingIntent:n,cacheKey:`${n}_${r.hash}`,annotationStorageSerializable:r}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#o?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#s.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(),Pt.cleanup(),this._networkStream?.cancelAllRequests(new Ae("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{gt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){i.close();return}gt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",s=>{const i=Promise.withResolvers(),n=this._fullReader;return n.headersReady.then(()=>{(!n.isStreamingSupported||!n.isRangeSupported)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),n.onProgress=r=>{e.onProgress?.({loaded:r.loaded,total:r.total})}),i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})},i.reject),i.promise}),t.on("GetRangeReader",(s,i)=>{gt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}gt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new sa(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new _s(s.message,s.code);break;case"InvalidPDFException":i=new Fi(s.message);break;case"MissingPDFException":i=new ve(s.message);break;case"UnexpectedResponseException":i=new es(s.message,s.status);break;case"UnknownErrorException":i=new ys(s.message,s.details);break;default:nt("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(this.#o=Promise.withResolvers(),e.onPassword){const i=n=>{n instanceof Error?this.#o.reject(n):this.#o.resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){this.#o.reject(n)}}else this.#o.reject(new _s(s.message,s.code));return this.#o.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:r,fontExtraProperties:a,pdfBug:o}=this._params;if("error"in n){const u=n.error;j(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}const h=o&&globalThis.FontInspector?.enabled?(u,p)=>globalThis.FontInspector.fontAdded(u,p):null,c=new nr(n,{disableFontFace:r,inspectFont:h});this.fontLoader.bind(c).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!a&&c.data&&(c.data=null),this.commonObjs.resolve(s,c)});break;case"CopyLocalImage":const{imageRef:d}=n;gt(d,"The imageRef must be defined.");for(const u of this.#e.values())for(const[,p]of u.objs)if(p?.ref===d)return p.dataLen?(this.commonObjs.resolve(s,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;const a=this.#e.get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":a.objs.resolve(s,r),r?.dataLen>Mn&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(s):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),t.on("FetchStandardFontData",s=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(s):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&j("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,s=this.#s.get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#n.set(n.refStr,t);const r=new ia(e,n,this,this._params.pdfBug);return this.#e.set(e,r),r});return this.#s.set(e,i),i}getPageIndex(t){return gi(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.#i("GetFieldObjects")}hasJSActions(){return this.#i("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?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.#i("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.#i("GetOptionalContentConfig").then(e=>new Sr(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>({info:i[0],metadata:i[1]?new wr(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Pt.cleanup()}}cachedPageNumber(t){if(!gi(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#n.get(e)??null}}const $e=Symbol("INITIAL_DATA");class Ji{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:$e}}get(t,e=null){if(e){const i=this.#e(t);return i.promise.then(()=>e(i.data)),null}const s=this.#t[t];if(!s||s.data===$e)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#t[t];return!!e&&e.data!==$e}resolve(t,e=null){const s=this.#e(t);s.data=e,s.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!==$e&&(yield[t,e])}}}class aa{#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 Ee{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=h,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new aa(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(Ee.#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.");Ee.#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:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new Se(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,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),Ee.#e.delete(this._canvas),this.callback(t||new Bs(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_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)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Ee.#e.delete(this._canvas),this.callback())))}}const oa="4.4.168",la="19fbc8998";function mi(l){return Math.floor(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}function Re(l){return Math.max(0,Math.min(255,255*l))}class bi{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}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=Re(t),[t,t,t]}static G_HTML([t]){const e=mi(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Re)}static RGB_HTML(t){return`#${t.map(mi).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Re(1-Math.min(1,t+i)),Re(1-Math.min(1,s+i)),Re(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}}class tn{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,h=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[o,h]of Object.entries(r))if(h!=null)switch(o){case"class":h.length&&t.setAttribute(o,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||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,h)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const d=document.createTextNode(i.value);r.append(d),a&&De.shouldBuildText(i.name)&&h.push(d)}return{textDivs:h}}const c=[[i,-1,r]];for(;c.length>0;){const[d,u,p]=c.at(-1);if(u+1===d.children.length){c.pop();continue}const f=d.children[++c.at(-1)[1]];if(f===null)continue;const{name:g}=f;if(g==="#text"){const m=document.createTextNode(f.value);h.push(m),p.append(m);continue}const b=f?.attributes?.xmlns?document.createElementNS(f.attributes.xmlns,g):document.createElement(g);if(p.append(b),f.attributes&&this.setAttributes({html:b,element:f,storage:e,intent:n,linkService:s}),f.children?.length>0)c.push([f,-1,b]);else if(f.value){const m=document.createTextNode(f.value);a&&De.shouldBuildText(g)&&h.push(m),b.append(m)}}for(const d of o.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 He=1e3,ha=9,be=new WeakSet;function ie(l){return{width:l[2]-l[0],height:l[3]-l[1]}}class ca{static create(t){switch(t.data.annotationType){case ft.LINK:return new en(t);case ft.TEXT:return new da(t);case ft.WIDGET:switch(t.data.fieldType){case"Tx":return new ua(t);case"Btn":return t.data.radioButton?new sn(t):t.data.checkBox?new pa(t):new ga(t);case"Ch":return new ma(t);case"Sig":return new fa(t)}return new _e(t);case ft.POPUP:return new Ts(t);case ft.FREETEXT:return new nn(t);case ft.LINE:return new va(t);case ft.SQUARE:return new Aa(t);case ft.CIRCLE:return new _a(t);case ft.POLYLINE:return new rn(t);case ft.CARET:return new wa(t);case ft.INK:return new an(t);case ft.POLYGON:return new ya(t);case ft.HIGHLIGHT:return new Ea(t);case ft.UNDERLINE:return new Sa(t);case ft.SQUIGGLY:return new Ca(t);case ft.STRIKEOUT:return new Ta(t);case ft.STAMP:return new on(t);case ft.FILEATTACHMENT:return new xa(t);default:return new ct(t)}}}class ct{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!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(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get hasPopupData(){return ct._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.#s?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#n(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null)}#n(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t);const{width:h,height:c}=ie(t);e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,i===0?(e.width=`${100*h/n}%`,e.height=`${100*c/r}%`):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof _e||(n.tabIndex=He);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.popupRef&&n.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Ts){const{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,n),n}const{width:a,height:o}=ie(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const g=e.borderStyle.horizontalCornerRadius,b=e.borderStyle.verticalCornerRadius;if(g>0||b>0){const v=`calc(${g}px * var(--scale-factor)) / calc(${b}px * var(--scale-factor))`;r.borderRadius=v}else if(this instanceof sn){const v=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=v}switch(e.borderStyle.style){case xe.SOLID:r.borderStyle="solid";break;case xe.DASHED:r.borderStyle="dashed";break;case xe.BEVELED:j("Unimplemented border style: beveled");break;case xe.INSET:j("Unimplemented border style: inset");break;case xe.UNDERLINE:r.borderBottomStyle="solid";break}const m=e.borderColor||null;m?(this.#e=!0,r.borderColor=R.makeHexColor(m[0]|0,m[1]|0,m[2]|0)):r.borderWidth=0}const h=R.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:p}=i.rawDims;r.left=`${100*(h[0]-u)/c}%`,r.top=`${100*(h[1]-p)/d}%`;const{rotation:f}=e;return e.hasOwnCanvas||f===0?(r.width=`${100*a/c}%`,r.height=`${100*o/d}%`):this.setRotation(f,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=ie(this.data.rect);let a,o;t%180===0?(a=100*n/s,o=100*r/i):(a=100*r/s,o=100*n/i),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=bi[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:bi[`${r}_rgb`](a)})};return K(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},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 s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const r=s[i];if(r){const a={detail:{[i]:n},target:t};r(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(g=>Math.fround(g));if(t.length===8){const[g,b,m,v]=t.subarray(2,6);if(i===g&&n===b&&e===m&&s===v)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:g,borderWidth:b}=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="${b}">`],this.container.classList.add("hasBorder")}const o=i-e,h=n-s,{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 p=c.createElement("clipPath"),f=`clippath_${this.data.id}`;p.setAttribute("id",f),p.setAttribute("clipPathUnits","objectBoundingBox"),u.append(p);for(let g=2,b=t.length;g<b;g+=8){const m=t[g],v=t[g+1],_=t[g+2],A=t[g+3],E=c.createElement("rect"),w=(_-e)/o,S=(n-v)/h,T=(m-_)/o,k=(v-A)/h;E.setAttribute("x",w),E.setAttribute("y",S),E.setAttribute("width",T),E.setAttribute("height",k),p.append(E),a?.push(`<rect vector-effect="non-scaling-stroke" x="${w}" y="${S}" width="${T}" height="${k}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${f})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const s=this.#s=new Ts({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(s.render())}render(){nt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:r,exportValues:a}of i){if(n===-1||r===e)continue;const o=typeof a=="string"?a:null,h=document.querySelector(`[data-element-id="${r}"]`);if(h&&!be.has(h)){j(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:o,domElement:h})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==e&&be.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}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")}get _isEditable(){return!1}_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 en extends ct{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,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action),i=!0):t.attachment?(this.#e(s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#s(s,t.setOCGState),i=!0):t.dest?(this._bindLink(s,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(s),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,s=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#s(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 s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){j('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();const{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){const c=new Set(n);for(const d of i){const u=this._fieldObjects[d]||[];for(const{id:p}of u)c.add(p)}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 o=this.annotationStorage,h=[];for(const c of a){const{id:d}=c;switch(h.push(d),c.type){case"text":{const p=c.defaultValue||"";o.setValue(d,{value:p});break}case"checkbox":case"radiobutton":{const p=c.defaultValue===c.exportValues;o.setValue(d,{value:p});break}case"combobox":case"listbox":{const p=c.defaultValue||"";o.setValue(d,{value:p});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!be.has(u)){j(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class da extends ct{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 _e extends ct{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return It.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}})})}_setEventListeners(t,e,s,i){for(const[n,r]of s)(r==="Action"||this.data.actions?.[r])&&((r==="Focus"||r==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,n,r,i),r==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):r==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":R.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||ha,n=t.style;let r;const a=2,o=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-a),c=Math.round(h/(ds*i))||1,d=h/c;r=Math.min(i,o(d/ds))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(i,o(h/ds))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=R.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class ua extends _e{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let n=i.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=i.formattedValue||this.data.textContent?.join(`
`)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=a??n,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",a??n),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),be.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=He,this._setRequired(s,this.data.required),r&&(s.maxLength=r),s.addEventListener("input",c=>{t.setValue(e,{value:c.target.value}),this.setPropertyOnSiblings(s,"value",c.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue??"";s.value=o.userValue=d,o.formattedValue=null});let h=c=>{const{formattedValue:d}=o;d!=null&&(c.target.value=d),c.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",d=>{if(o.focused)return;const{target:u}=d;o.userValue&&(u.value=o.userValue),o.lastCommittedValue=u.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),s.addEventListener("updatefromsandbox",d=>{this.showElementAndHideCanvas(d.target);const u={value(p){o.userValue=p.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),p.target.value=o.userValue},formattedValue(p){const{formattedValue:f}=p.detail;o.formattedValue=f,f!=null&&p.target!==document.activeElement&&(p.target.value=f),t.setValue(e,{formattedValue:f})},selRange(p){p.target.setSelectionRange(...p.detail.selRange)},charLimit:p=>{const{charLimit:f}=p.detail,{target:g}=p;if(f===0){g.removeAttribute("maxLength");return}g.setAttribute("maxLength",f);let b=o.userValue;!b||b.length<=f||(b=b.slice(0,f),g.value=o.userValue=b,t.setValue(e,{value:b}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:1,selStart:g.selectionStart,selEnd:g.selectionEnd}}))}};this._dispatchEventFromSandbox(u,d)}),s.addEventListener("keydown",d=>{o.commitKey=1;let u=-1;if(d.key==="Escape"?u=0:d.key==="Enter"&&!this.data.multiLine?u=2:d.key==="Tab"&&(o.commitKey=3),u===-1)return;const{value:p}=d.target;o.lastCommittedValue!==p&&(o.lastCommittedValue=p,o.userValue=p,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:p,willCommit:!0,commitKey:u,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}))});const c=h;h=null,s.addEventListener("blur",d=>{if(!o.focused||!d.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:u}=d.target;o.userValue=u,o.lastCommittedValue!==u&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:u,willCommit:!0,commitKey:o.commitKey,selStart:d.target.selectionStart,selEnd:d.target.selectionEnd}}),c(d)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",d=>{o.lastCommittedValue=null;const{data:u,target:p}=d,{value:f,selectionStart:g,selectionEnd:b}=p;let m=g,v=b;switch(d.inputType){case"deleteWordBackward":{const _=f.substring(0,g).match(/\w*[^\w]*$/);_&&(m-=_[0].length);break}case"deleteWordForward":{const _=f.substring(g).match(/^[^\w]*\w*/);_&&(v+=_[0].length);break}case"deleteContentBackward":g===b&&(m-=1);break;case"deleteContentForward":g===b&&(v+=1);break}d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:f,change:u||"",willCommit:!1,selStart:m,selEnd:v}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],d=>d.target.value)}if(h&&s.addEventListener("blur",h),this.data.comb){const d=(this.data.rect[2]-this.data.rect[0])/r;s.classList.add("comb"),s.style.letterSpacing=`calc(${d}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class fa extends _e{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class pa extends _e{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return be.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=He,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const h of this._getElementsByName(a,s)){const c=o&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{const a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,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(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class sn extends _e{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(be.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=He,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const h of this._getElementsByName(a,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{const o={value:h=>{const c=r===h.detail.value;for(const d of this._getElementsByName(h.target.name)){const u=c&&d.id===s;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,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(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class ga extends en{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",s=>{this._dispatchEventFromSandbox({},s)})),t}}class ma extends _e{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");be.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=He;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue;for(const u of i.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,s.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),n=!1),i.append(d)}let r=null;if(n){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),r=()=>{c.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}const a=c=>{const d=c?"value":"textContent",{options:u,multiple:p}=i;return p?Array.prototype.filter.call(u,f=>f.selected).map(f=>f[d]):u.selectedIndex===-1?null:u[u.selectedIndex][d]};let o=a(!1);const h=c=>{const d=c.target.options;return Array.prototype.map.call(d,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{const d={value(u){r?.();const p=u.detail.value,f=new Set(Array.isArray(p)?p:[p]);for(const g of i.options)g.selected=f.has(g.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(u){i.multiple=!0},remove(u){const p=i.options,f=u.detail.remove;p[f].selected=!1,i.remove(f),p.length>0&&Array.prototype.findIndex.call(p,b=>b.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},clear(u){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(u){const{index:p,displayValue:f,exportValue:g}=u.detail.insert,b=i.children[p],m=document.createElement("option");m.textContent=f,m.value=g,b?b.before(m):i.append(m),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},items(u){const{items:p}=u.detail;for(;i.length!==0;)i.remove(0);for(const f of p){const{displayValue:g,exportValue:b}=f,m=document.createElement("option");m.textContent=g,m.value=b,i.append(m)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},indices(u){const p=new Set(u.detail.indices);for(const f of u.target.options)f.selected=p.has(f.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,c)}),i.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:o,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,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)):i.addEventListener("input",function(c){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Ts extends ct{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:ct._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new ba({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 s of this.elements)s.popup=t,e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${Oi}${s}`).join(",")),this.container}}class ba{#t=this.#P.bind(this);#e=this.#w.bind(this);#s=this.#b.bind(this);#n=this.#_.bind(this);#o=null;#i=null;#r=null;#l=null;#c=null;#d=null;#f=null;#h=!1;#a=null;#p=null;#m=null;#u=null;#v=null;#g=null;#A=!1;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:h,parentRect:c,open:d}){this.#i=t,this.#v=i,this.#r=r,this.#u=a,this.#d=o,this.#o=e,this.#m=h,this.#f=c,this.#c=s,this.#l=Ui.toDateObject(n),this.trigger=s.flatMap(u=>u.getElementsToTriggerPopup());for(const u of this.trigger)u.addEventListener("click",this.#n),u.addEventListener("mouseenter",this.#s),u.addEventListener("mouseleave",this.#e),u.classList.add("popupTriggerArea");for(const u of s)u.container?.addEventListener("keydown",this.#t);this.#i.hidden=!0,d&&this.#_()}render(){if(this.#a)return;const t=this.#a=document.createElement("div");if(t.className="popup",this.#o){const n=t.style.outlineColor=R.makeHexColor(...this.#o);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=R.makeHexColor(...this.#o.map(a=>Math.floor(.7*(255-a)+a)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=this.#v,t.append(e),this.#l){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),n.setAttribute("data-l10n-args",JSON.stringify({date:this.#l.toLocaleDateString(),time:this.#l.toLocaleTimeString()})),e.append(n)}const i=this.#y;if(i)tn.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(this.#r);t.append(n)}this.#i.append(t)}get#y(){const t=this.#u,e=this.#r;return t?.str&&(!e?.str||e.str===t.str)&&this.#u.html||null}get#E(){return this.#y?.attributes?.style?.fontSize||0}get#C(){return this.#y?.attributes?.style?.color||null}#T(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#C,fontSize:this.#E?`calc(${this.#E}px * var(--scale-factor))`:""}};for(const n of t.split(`
`))e.push({name:"span",value:n,attributes:i});return s}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let n=0,r=i.length;n<r;++n){const a=i[n];s.append(document.createTextNode(a)),n<r-1&&s.append(document.createElement("br"))}return s}#P(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#h)&&this.#_()}updateEdited({rect:t,popupContent:e}){this.#g||={contentsObj:this.#r,richText:this.#u},t&&(this.#p=null),e&&(this.#u=this.#T(e),this.#r=null),this.#a?.remove(),this.#a=null}resetEdited(){this.#g&&({contentsObj:this.#r,richText:this.#u}=this.#g,this.#g=null,this.#a?.remove(),this.#a=null,this.#p=null)}#S(){if(this.#p!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#d;let r=!!this.#f,a=r?this.#f:this.#m;for(const f of this.#c)if(!a||R.intersect(f.data.rect,a)!==null){a=f.data.rect,r=!0;break}const o=R.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),c=r?a[2]-a[0]+5:0,d=o[0]+c,u=o[1];this.#p=[100*(d-i)/e,100*(u-n)/s];const{style:p}=this.#i;p.left=`${this.#p[0]}%`,p.top=`${this.#p[1]}%`}#_(){this.#h=!this.#h,this.#h?(this.#b(),this.#i.addEventListener("click",this.#n),this.#i.addEventListener("keydown",this.#t)):(this.#w(),this.#i.removeEventListener("click",this.#n),this.#i.removeEventListener("keydown",this.#t))}#b(){this.#a||this.render(),this.isVisible?this.#h&&this.#i.classList.add("focused"):(this.#S(),this.#i.hidden=!1,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)+1e3)}#w(){this.#i.classList.remove("focused"),!(this.#h||!this.isVisible)&&(this.#i.hidden=!0,this.#i.style.zIndex=parseInt(this.#i.style.zIndex)-1e3)}forceHide(){this.#A=this.isVisible,this.#A&&(this.#i.hidden=!0)}maybeShow(){this.#A&&(this.#a||this.#b(),this.#A=!1,this.#i.hidden=!1)}get isVisible(){return this.#i.hidden===!1}}class nn extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=W.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 s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}get _isEditable(){return this.data.hasOwnCanvas}}class va extends ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:s}=ie(t.rect),i=this.svgFactory.create(e,s,!0),n=this.#t=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Aa extends ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:s}=ie(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",s-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class _a extends ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:s}=ie(t.rect),i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",s/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class rn extends ct{#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:s,popupRef:i}}=this;if(!e)return this.container;const{width:n,height:r}=ie(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let c=0,d=e.length;c<d;c+=2){const u=e[c]-t[0],p=t[3]-e[c+1];o.push(`${u},${p}`)}o=o.join(" ");const h=this.#t=this.svgFactory.createElement(this.svgElementName);return h.setAttribute("points",o),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),a.append(h),this.container.append(a),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ya extends rn{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class wa extends ct{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 an extends ct{#t=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=W.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,inkLists:e,borderStyle:s,popupRef:i}}=this,{width:n,height:r}=ie(t),a=this.svgFactory.create(n,r,!0);for(const o of e){let h=[];for(let d=0,u=o.length;d<u;d+=2){const p=o[d]-t[0],f=t[3]-o[d+1];h.push(`${p},${f}`)}h=h.join(" ");const c=this.svgFactory.createElement(this.svgElementName);this.#t.push(c),c.setAttribute("points",h),c.setAttribute("stroke-width",s.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),!i&&this.hasPopupData&&this._createPopup(),a.append(c)}return this.container.append(a),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ea extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class Sa extends ct{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 Ca extends ct{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 Ta extends ct{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 on extends ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class xa extends ct{#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 s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;const{isMac:i}=It.platform;return t.addEventListener("keydown",n=>{n.key==="Enter"&&(i?n.metaKey:n.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class ka{#t=null;#e=null;#s=new Map;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r}){this.div=t,this.#t=e,this.#e=s,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=i}#n(t,e){const s=t.firstChild||t;s.id=`${Oi}${e}`,this.div.append(t),this.#t?.moveElementInDOM(this.div,t,s,!1)}async render(t){const{annotations:e}=t,s=this.div;me(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Hs,annotationStorage:t.annotationStorage||new qs,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const r of e){if(r.noHTML)continue;const a=r.annotationType===ft.POPUP;if(a){const c=i.get(r.id);if(!c)continue;n.elements=c}else{const{width:c,height:d}=ie(r.rect);if(c<=0||d<=0)continue}n.data=r;const o=ca.create(n);if(!o.isRenderable)continue;if(!a&&r.popupRef){const c=i.get(r.popupRef);c?c.push(o):i.set(r.popupRef,[o])}const h=o.render();r.hidden&&(h.style.visibility="hidden"),this.#n(h,r.id),o.annotationEditorType>0&&(this.#s.set(o.data.id,o),this._annotationEditorUIManager?.renderAnnotationElement(o))}this.#o()}update({viewport:t}){const e=this.div;this.viewport=t,me(e,{rotation:t.rotation}),this.#o(),e.hidden=!1}#o(){if(!this.#e)return;const t=this.div;for(const[e,s]of this.#e){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#s.values())}getEditableAnnotation(t){return this.#s.get(t)}}const Xe=/\r\n?|\n/g;class pt extends F{#t=this.editorDivBlur.bind(this);#e=this.editorDivFocus.bind(this);#s=this.editorDivInput.bind(this);#n=this.editorDivKeydown.bind(this);#o=this.editorDivPaste.bind(this);#i;#r="";#l=`${this.id}-editor`;#c;#d=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=pt.prototype,e=n=>n.isEmpty(),s=ce.TRANSLATE_SMALL,i=ce.TRANSLATE_BIG;return K(this,"_keyboardManager",new Ne([[["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:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=W.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#i=t.color||pt._defaultColor||F._defaultLineColor,this.#c=t.fontSize||pt._defaultFontSize}static initialize(t,e){F.initialize(t,e,{strings:["pdfjs-free-text-default-content"]});const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case N.FREETEXT_SIZE:pt._defaultFontSize=e;break;case N.FREETEXT_COLOR:pt._defaultColor=e;break}}updateParams(t,e){switch(t){case N.FREETEXT_SIZE:this.#f(e);break;case N.FREETEXT_COLOR:this.#h(e);break}}static get defaultPropertiesToUpdate(){return[[N.FREETEXT_SIZE,pt._defaultFontSize],[N.FREETEXT_COLOR,pt._defaultColor||F._defaultLineColor]]}get propertiesToUpdate(){return[[N.FREETEXT_SIZE,this.#c],[N.FREETEXT_COLOR,this.#i]]}#f(t){const e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--scale-factor))`,this.translate(0,-(i-this.#c)*this.parentScale),this.#c=i,this.#p()},s=this.#c;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#h(t){const e=i=>{this.#i=this.editorDiv.style.color=i},s=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-pt._internalPadding*t,-(pt._internalPadding+this.#c)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(W.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");const t=this._uiManager._signal;this.editorDiv.addEventListener("keydown",this.#n,{signal:t}),this.editorDiv.addEventListener("focus",this.#e,{signal:t}),this.editorDiv.addEventListener("blur",this.#t,{signal:t}),this.editorDiv.addEventListener("input",this.#s,{signal:t}),this.editorDiv.addEventListener("paste",this.#o,{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.#l),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#n),this.editorDiv.removeEventListener("focus",this.#e),this.editorDiv.removeEventListener("blur",this.#t),this.editorDiv.removeEventListener("input",this.#s),this.editorDiv.removeEventListener("paste",this.#o),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(){this.width||(this.enableEditMode(),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()}#a(){const t=[];this.editorDiv.normalize();for(const e of this.editorDiv.childNodes)t.push(pt.#m(e));return t.join(`
`)}#p(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:i,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",i.div.append(this.div),s=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#r,e=this.#r=this.#a().trimEnd();if(t===e)return;const s=i=>{if(this.#r=i,!i){this.remove();return}this.#u(),this._uiManager.rebuild(this),this.#p()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#p()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){pt._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.#l),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),F._l10nPromise.get("pdfjs-free-text-default-content").then(i=>this.editorDiv?.setAttribute("default-content",i)),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#c}px * var(--scale-factor))`,s.color=this.#i,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Ke(this,this.div,["dblclick","keydown"]),this.width){const[i,n]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this.#d;let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[h,c]=this.pageDimensions,[d,u]=this.pageTranslation;let p,f;switch(this.rotation){case 0:p=t+(r[0]-d)/h,f=e+this.height-(r[1]-u)/c;break;case 90:p=t+(r[0]-d)/h,f=e-(r[1]-u)/c,[a,o]=[o,-a];break;case 180:p=t-this.width+(r[0]-d)/h,f=e-(r[1]-u)/c,[a,o]=[-a,-o];break;case 270:p=t+(r[0]-d-this.height*c)/h,f=e+(r[1]-u-this.width*h)/c,[a,o]=[-o,a];break}this.setAt(p*i,f*n,a,o)}else this.setAt(t*i,e*n,this.width*i,this.height*n);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#m(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Xe,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();const i=pt.#g(e.getData("text")||"").replaceAll(Xe,`
`);if(!i)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!i.includes(`
`)){r.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),n.collapseToStart();return}const{startContainer:a,startOffset:o}=r,h=[],c=[];if(a.nodeType===Node.TEXT_NODE){const p=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll(Xe,"")),p!==this.editorDiv){let f=h;for(const g of this.editorDiv.childNodes){if(g===p){f=c;continue}f.push(pt.#m(g))}}h.push(a.nodeValue.slice(0,o).replaceAll(Xe,""))}else if(a===this.editorDiv){let p=h,f=0;for(const g of this.editorDiv.childNodes)f++===o&&(p=c),p.push(pt.#m(g))}this.#r=`${h.join(`
`)}${i}${c.join(`
`)}`,this.#u();const d=new Range;let u=h.reduce((p,f)=>p+f.length,0);for(const{firstChild:p}of this.editorDiv.childNodes)if(p.nodeType===Node.TEXT_NODE){const f=p.nodeValue.length;if(u<=f){d.setStart(p,u),d.setEnd(p,u);break}u-=f}n.removeAllRanges(),n.addRange(d)}#u(){if(this.editorDiv.replaceChildren(),!!this.#r)for(const t of this.#r.split(`
`)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#v(){return this.#r.replaceAll(" "," ")}static#g(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static deserialize(t,e,s){let i=null;if(t instanceof nn){const{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:h,id:c},textContent:d,textPosition:u,parent:{page:{pageNumber:p}}}=t;if(!d||d.length===0)return null;i=t={annotationType:W.FREETEXT,color:Array.from(a),fontSize:r,value:d.join(`
`),position:u,pageIndex:p-1,rect:o.slice(0),rotation:h,id:c,deleted:!1}}const n=super.deserialize(t,e,s);return n.#c=t.fontSize,n.#i=R.makeHexColor(...t.color),n.#r=pt.#g(t.value),n.annotationElementId=t.id||null,n.#d=i,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=pt._internalPadding*this.parentScale,s=this.getRect(e,e),i=F._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#i),n={annotationType:W.FREETEXT,color:i,fontSize:this.#c,value:this.#v(),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#A(n)?null:(n.id=this.annotationElementId,n)}#A(t){const{value:e,fontSize:s,color:i,pageIndex:n}=this.#d;return this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((r,a)=>r!==i[a])||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:s}=e;s.fontSize=`calc(${this.#c}px * var(--scale-factor))`,s.color=this.#i,e.replaceChildren();for(const n of this.#r.split(`
`)){const r=document.createElement("div");r.append(n?document.createTextNode(n):document.createElement("br")),e.append(r)}const i=pt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:this.#r}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class xs{#t;#e=[];#s=[];constructor(t,e=0,s=0,i=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const c=10**-4;for(const{x:m,y:v,width:_,height:A}of t){const E=Math.floor((m-e)/c)*c,w=Math.ceil((m+_+e)/c)*c,S=Math.floor((v-e)/c)*c,T=Math.ceil((v+A+e)/c)*c,k=[E,S,T,!0],O=[w,S,T,!1];this.#e.push(k,O),n=Math.min(n,E),r=Math.max(r,w),a=Math.min(a,S),o=Math.max(o,T)}const d=r-n+2*s,u=o-a+2*s,p=n-s,f=a-s,g=this.#e.at(i?-1:-2),b=[g[0],g[2]];for(const m of this.#e){const[v,_,A]=m;m[0]=(v-p)/d,m[1]=(_-f)/u,m[2]=(A-f)/u}this.#t={x:p,y:f,width:d,height:u,lastPoint:b}}getOutlines(){this.#e.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#e)e[3]?(t.push(...this.#l(e)),this.#i(e)):(this.#r(e),t.push(...this.#l(e)));return this.#n(t)}#n(t){const e=[],s=new Set;for(const r of t){const[a,o,h]=r;e.push([a,o,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 o=e[r][2],h=e[r+1][2];o.push(h),h.push(o),s.add(o),s.add(h)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[a,o,h,c,d]=r;s.delete(r);let u=a,p=o;for(n=[a,h],i.push(n);;){let f;if(s.has(c))f=c;else if(s.has(d))f=d;else break;s.delete(f),[a,o,h,c,d]=f,u!==a&&(n.push(u,p,a,p===o?o:h),u=a),p=p===o?h:o}n.push(u,p)}return new Ra(i,this.#t)}#o(t){const e=this.#s;let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1}#i([,t,e]){const s=this.#o(t);this.#s.splice(s,0,[t,e])}#r([,t,e]){const s=this.#o(t);for(let i=s;i<this.#s.length;i++){const[n,r]=this.#s[i];if(n!==t)break;if(n===t&&r===e){this.#s.splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,r]=this.#s[i];if(n!==t)break;if(n===t&&r===e){this.#s.splice(i,1);return}}}#l(t){const[e,s,i]=t,n=[[e,s,i]],r=this.#o(i);for(let a=0;a<r;a++){const[o,h]=this.#s[a];for(let c=0,d=n.length;c<d;c++){const[,u,p]=n[c];if(!(h<=u||p<=o)){if(u>=o){if(p>h)n[c][1]=h;else{if(d===1)return[];n.splice(c,1),c--,d--}continue}n[c][2]=o,p>h&&n.push([e,h,p])}}}return n}}class ln{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(t,e){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof ks}}class Ra extends ln{#t;#e;constructor(t,e){super(),this.#e=t,this.#t=e}toSVGPath(){const t=[];for(const e of this.#e){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===s?(t.push(`V${a}`),i=a):a===i&&(t.push(`H${r}`),s=r)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){const r=[],a=s-t,o=i-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]=i-h[d+1]*o;r.push(c)}return r}get box(){return this.#t}}class pe{#t;#e=[];#s;#n;#o=[];#i=new Float64Array(18);#r;#l;#c;#d;#f;#h;#a=[];static#p=8;static#m=2;static#u=pe.#p+pe.#m;constructor({x:t,y:e},s,i,n,r,a=0){this.#t=s,this.#h=n*i,this.#n=r,this.#i.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#d=pe.#p*i,this.#c=pe.#u*i,this.#f=i,this.#a.push(t,e)}get free(){return!0}isEmpty(){return isNaN(this.#i[8])}#v(){const t=this.#i.subarray(4,6),e=this.#i.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#r+(t[0]-e[0])/2-s)/n,(this.#l+(t[1]-e[1])/2-i)/r,(this.#r+(e[0]-t[0])/2-s)/n,(this.#l+(e[1]-t[1])/2-i)/r]}add({x:t,y:e}){this.#r=t,this.#l=e;const[s,i,n,r]=this.#t;let[a,o,h,c]=this.#i.subarray(8,12);const d=t-h,u=e-c,p=Math.hypot(d,u);if(p<this.#c)return!1;const f=p-this.#d,g=f/p,b=g*d,m=g*u;let v=a,_=o;a=h,o=c,h+=b,c+=m,this.#a?.push(t,e);const A=-m/f,E=b/f,w=A*this.#h,S=E*this.#h;return this.#i.set(this.#i.subarray(2,8),0),this.#i.set([h+w,c+S],4),this.#i.set(this.#i.subarray(14,18),12),this.#i.set([h-w,c-S],16),isNaN(this.#i[6])?(this.#o.length===0&&(this.#i.set([a+w,o+S],2),this.#o.push(NaN,NaN,NaN,NaN,(a+w-s)/n,(o+S-i)/r),this.#i.set([a-w,o-S],14),this.#e.push(NaN,NaN,NaN,NaN,(a-w-s)/n,(o-S-i)/r)),this.#i.set([v,_,a,o,h,c],6),!this.isEmpty()):(this.#i.set([v,_,a,o,h,c],6),Math.abs(Math.atan2(_-o,v-a)-Math.atan2(m,b))<Math.PI/2?([a,o,h,c]=this.#i.subarray(2,6),this.#o.push(NaN,NaN,NaN,NaN,((a+h)/2-s)/n,((o+c)/2-i)/r),[a,o,v,_]=this.#i.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((v+a)/2-s)/n,((_+o)/2-i)/r),!0):([v,_,a,o,h,c]=this.#i.subarray(0,6),this.#o.push(((v+5*a)/6-s)/n,((_+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),[h,c,a,o,v,_]=this.#i.subarray(12,18),this.#e.push(((v+5*a)/6-s)/n,((_+5*o)/6-i)/r,((5*a+h)/6-s)/n,((5*o+c)/6-i)/r,((a+h)/2-s)/n,((o+c)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#o,e=this.#e,s=this.#i.subarray(4,6),i=this.#i.subarray(16,18),[n,r,a,o]=this.#t,[h,c,d,u]=this.#v();if(isNaN(this.#i[6])&&!this.isEmpty())return`M${(this.#i[2]-n)/a} ${(this.#i[3]-r)/o} L${(this.#i[4]-n)/a} ${(this.#i[5]-r)/o} L${h} ${c} L${d} ${u} L${(this.#i[16]-n)/a} ${(this.#i[17]-r)/o} L${(this.#i[14]-n)/a} ${(this.#i[15]-r)/o} Z`;const p=[];p.push(`M${t[4]} ${t[5]}`);for(let f=6;f<t.length;f+=6)isNaN(t[f])?p.push(`L${t[f+4]} ${t[f+5]}`):p.push(`C${t[f]} ${t[f+1]} ${t[f+2]} ${t[f+3]} ${t[f+4]} ${t[f+5]}`);p.push(`L${(s[0]-n)/a} ${(s[1]-r)/o} L${h} ${c} L${d} ${u} L${(i[0]-n)/a} ${(i[1]-r)/o}`);for(let f=e.length-6;f>=6;f-=6)isNaN(e[f])?p.push(`L${e[f+4]} ${e[f+5]}`):p.push(`C${e[f]} ${e[f+1]} ${e[f+2]} ${e[f+3]} ${e[f+4]} ${e[f+5]}`);return p.push(`L${e[4]} ${e[5]} Z`),p.join(" ")}getOutlines(){const t=this.#o,e=this.#e,s=this.#i,i=s.subarray(4,6),n=s.subarray(16,18),[r,a,o,h]=this.#t,c=new Float64Array((this.#a?.length??0)+2);for(let m=0,v=c.length-2;m<v;m+=2)c[m]=(this.#a[m]-r)/o,c[m+1]=(this.#a[m+1]-a)/h;c[c.length-2]=(this.#r-r)/o,c[c.length-1]=(this.#l-a)/h;const[d,u,p,f]=this.#v();if(isNaN(s[6])&&!this.isEmpty()){const m=new Float64Array(36);return m.set([NaN,NaN,NaN,NaN,(s[2]-r)/o,(s[3]-a)/h,NaN,NaN,NaN,NaN,(s[4]-r)/o,(s[5]-a)/h,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,p,f,NaN,NaN,NaN,NaN,(s[16]-r)/o,(s[17]-a)/h,NaN,NaN,NaN,NaN,(s[14]-r)/o,(s[15]-a)/h],0),new ks(m,c,this.#t,this.#f,this.#s,this.#n)}const g=new Float64Array(this.#o.length+24+this.#e.length);let b=t.length;for(let m=0;m<b;m+=2){if(isNaN(t[m])){g[m]=g[m+1]=NaN;continue}g[m]=t[m],g[m+1]=t[m+1]}g.set([NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/h,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,p,f,NaN,NaN,NaN,NaN,(n[0]-r)/o,(n[1]-a)/h],b),b+=24;for(let m=e.length-6;m>=6;m-=6)for(let v=0;v<6;v+=2){if(isNaN(e[m+v])){g[b]=g[b+1]=NaN,b+=2;continue}g[b]=e[m+v],g[b+1]=e[m+v+1],b+=2}return g.set([NaN,NaN,NaN,NaN,e[4],e[5]],b),new ks(g,c,this.#t,this.#f,this.#s,this.#n)}}class ks extends ln{#t;#e=null;#s;#n;#o;#i;#r;constructor(t,e,s,i,n,r){super(),this.#r=t,this.#o=e,this.#t=s,this.#i=i,this.#s=n,this.#n=r,this.#d(r);const{x:a,y:o,width:h,height: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]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/h,e[d+1]=(e[d+1]-o)/c}toSVGPath(){const t=[`M${this.#r[4]} ${this.#r[5]}`];for(let e=6,s=this.#r.length;e<s;e+=6){if(isNaN(this.#r[e])){t.push(`L${this.#r[e+4]} ${this.#r[e+5]}`);continue}t.push(`C${this.#r[e]} ${this.#r[e+1]} ${this.#r[e+2]} ${this.#r[e+3]} ${this.#r[e+4]} ${this.#r[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){const r=s-t,a=i-e;let o,h;switch(n){case 0:o=this.#l(this.#r,t,i,r,-a),h=this.#l(this.#o,t,i,r,-a);break;case 90:o=this.#c(this.#r,t,e,r,a),h=this.#c(this.#o,t,e,r,a);break;case 180:o=this.#l(this.#r,s,e,-r,a),h=this.#l(this.#o,s,e,-r,a);break;case 270:o=this.#c(this.#r,s,i,-r,-a),h=this.#c(this.#o,s,i,-r,-a);break}return{outline:Array.from(o),points:[Array.from(h)]}}#l(t,e,s,i,n){const r=new Float64Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}#c(t,e,s,i,n){const r=new Float64Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}#d(t){const e=this.#r;let s=e[4],i=e[5],n=s,r=i,a=s,o=i,h=s,c=i;const d=t?Math.max:Math.min;for(let b=6,m=e.length;b<m;b+=6){if(isNaN(e[b]))n=Math.min(n,e[b+4]),r=Math.min(r,e[b+5]),a=Math.max(a,e[b+4]),o=Math.max(o,e[b+5]),c<e[b+5]?(h=e[b+4],c=e[b+5]):c===e[b+5]&&(h=d(h,e[b+4]));else{const v=R.bezierBoundingBox(s,i,...e.slice(b,b+6));n=Math.min(n,v[0]),r=Math.min(r,v[1]),a=Math.max(a,v[2]),o=Math.max(o,v[3]),c<v[3]?(h=v[2],c=v[3]):c===v[3]&&(h=d(h,v[2]))}s=e[b+4],i=e[b+5]}const u=n-this.#s,p=r-this.#s,f=a-n+2*this.#s,g=o-r+2*this.#s;this.#e={x:u,y:p,width:f,height:g,lastPoint:[h,c]}}get box(){return this.#e}getNewOutline(t,e){const{x:s,y:i,width:n,height:r}=this.#e,[a,o,h,c]=this.#t,d=n*h,u=r*c,p=s*h+a,f=i*c+o,g=new pe({x:this.#o[0]*d+p,y:this.#o[1]*u+f},this.#t,this.#i,t,this.#n,e??this.#s);for(let b=2;b<this.#o.length;b+=2)g.add({x:this.#o[b]*d+p,y:this.#o[b+1]*u+f});return g.getOutlines()}}class Wt{#t=this.#m.bind(this);#e=this.#v.bind(this);#s=null;#n=null;#o;#i=null;#r=!1;#l=!1;#c=null;#d;#f=null;#h;static get _keyboardManager(){return K(this,"_keyboardManager",new Ne([[["Escape","mac+Escape"],Wt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Wt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Wt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Wt.prototype._moveToPrevious],[["Home","mac+Home"],Wt.prototype._moveToBeginning],[["End","mac+End"],Wt.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#l=!1,this.#h=N.HIGHLIGHT_COLOR,this.#c=t):(this.#l=!0,this.#h=N.HIGHLIGHT_DEFAULT_COLOR),this.#f=t?._uiManager||e,this.#d=this.#f._eventBus,this.#o=t?.color||this.#f?.highlightColors.values().next().value||"#FFFF98"}renderButton(){const t=this.#s=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.#f._signal;t.addEventListener("click",this.#u.bind(this),{signal:e}),t.addEventListener("keydown",this.#t,{signal:e});const s=this.#n=document.createElement("span");return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=this.#o,t.append(s),t}renderMainDropdown(){const t=this.#i=this.#a();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#a(){const t=document.createElement("div"),e=this.#f._signal;t.addEventListener("contextmenu",Dt,{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[s,i]of this.#f.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${s}`);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.setAttribute("aria-selected",i===this.#o),n.addEventListener("click",this.#p.bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#t,{signal:e}),t}#p(t,e){e.stopPropagation(),this.#d.dispatch("switchannotationeditorparams",{source:this,type:this.#h,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#s){this.#u(t);return}const e=t.target.getAttribute("data-color");e&&this.#p(e,t)}_moveToNext(t){if(!this.#g){this.#u(t);return}if(t.target===this.#s){this.#i.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#i?.firstChild||t.target===this.#s){this.#g&&this._hideDropdownFromKeyboard();return}this.#g||this.#u(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#g){this.#u(t);return}this.#i.firstChild?.focus()}_moveToEnd(t){if(!this.#g){this.#u(t);return}this.#i.lastChild?.focus()}#m(t){Wt._keyboardManager.exec(this,t)}#u(t){if(this.#g){this.hideDropdown();return}if(this.#r=t.detail===0,window.addEventListener("pointerdown",this.#e,{signal:this.#f._signal}),this.#i){this.#i.classList.remove("hidden");return}const e=this.#i=this.#a();this.#s.append(e)}#v(t){this.#i?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),window.removeEventListener("pointerdown",this.#e)}get#g(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#l){if(!this.#g){this.#c?.unselect();return}this.hideDropdown(),this.#s.focus({preventScroll:!0,focusVisible:this.#r})}}updateColor(t){if(this.#n&&(this.#n.style.backgroundColor=t),!this.#i)return;const e=this.#f.highlightColors.values();for(const s of this.#i.children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#s?.remove(),this.#s=null,this.#n=null,this.#i?.remove(),this.#i=null}}class ut extends F{#t=null;#e=0;#s;#n=null;#o=null;#i=null;#r=null;#l=0;#c=null;#d=null;#f=null;#h=!1;#a=this.#w.bind(this);#p=null;#m;#u=null;#v="";#g;#A="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _l10nPromise;static _type="highlight";static _editorType=W.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=ut.prototype;return K(this,"_keyboardManager",new Ne([[["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||ut._defaultColor,this.#g=t.thickness||ut._defaultThickness,this.#m=t.opacity||ut._defaultOpacity,this.#s=t.boxes||null,this.#A=t.methodOfCreation||"",this.#v=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#h=!0,this.#E(t),this.#_()):(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#r=t.focusNode,this.#l=t.focusOffset,this.#y(),this.#_(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#h?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#A}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#y(){const t=new xs(this.#s,.001);this.#d=t.getOutlines(),{x:this.x,y:this.y,width:this.width,height:this.height}=this.#d.box;const e=new xs(this.#s,.0025,.001,this._uiManager.direction==="ltr");this.#i=e.getOutlines();const{lastPoint:s}=this.#i.box;this.#p=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#E({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#d=t;const i=1.5;if(this.#i=t.getNewOutline(this.#g/2+i,.0025),e>=0)this.#f=e,this.#n=s,this.parent.drawLayer.finalizeLine(e,t),this.#u=this.parent.drawLayer.highlightOutline(this.#i);else if(this.parent){const c=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#f,t),this.parent.drawLayer.updateBox(this.#f,ut.#b(this.#d.box,(c-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#u,this.#i),this.parent.drawLayer.updateBox(this.#u,ut.#b(this.#i.box,c))}const{x:n,y:r,width:a,height:o}=t.box;switch(this.rotation){case 0:this.x=n,this.y=r,this.width=a,this.height=o;break;case 90:{const[c,d]=this.parentDimensions;this.x=r,this.y=1-n,this.width=a*d/c,this.height=o*c/d;break}case 180:this.x=1-n,this.y=1-r,this.width=a,this.height=o;break;case 270:{const[c,d]=this.parentDimensions;this.x=1-r,this.y=n,this.width=a*d/c,this.height=o*c/d;break}}const{lastPoint:h}=this.#i.box;this.#p=[(h[0]-n)/a,(h[1]-r)/o]}static initialize(t,e){F.initialize(t,e),ut._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case N.HIGHLIGHT_DEFAULT_COLOR:ut._defaultColor=e;break;case N.HIGHLIGHT_THICKNESS:ut._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#p}updateParams(t,e){switch(t){case N.HIGHLIGHT_COLOR:this.#C(e);break;case N.HIGHLIGHT_THICKNESS:this.#T(e);break}}static get defaultPropertiesToUpdate(){return[[N.HIGHLIGHT_DEFAULT_COLOR,ut._defaultColor],[N.HIGHLIGHT_THICKNESS,ut._defaultThickness]]}get propertiesToUpdate(){return[[N.HIGHLIGHT_COLOR,this.color||ut._defaultColor],[N.HIGHLIGHT_THICKNESS,this.#g||ut._defaultThickness],[N.HIGHLIGHT_FREE,this.#h]]}#C(t){const e=i=>{this.color=i,this.parent?.drawLayer.changeColor(this.#f,i),this.#o?.updateColor(i)},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#T(t){const e=this.#g,s=i=>{this.#g=i,this.#P(i)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#o=new Wt({editor:this}),t.addColorPicker(this.#o)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#k())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#k())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#S(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#_(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#S():t&&(this.#_(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#P(t){if(!this.#h)return;this.#E({highlightOutlines:this.#d.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}#S(){this.#f===null||!this.parent||(this.parent.drawLayer.remove(this.#f),this.#f=null,this.parent.drawLayer.remove(this.#u),this.#u=null)}#_(t=this.parent){this.#f===null&&({id:this.#f,clipPathId:this.#n}=t.drawLayer.highlight(this.#d,this.color,this.#m),this.#u=t.drawLayer.highlightOutline(this.#i),this.#c&&(this.#c.style.clipPath=this.#n))}static#b({x:t,y:e,width:s,height:i},n){switch(n){case 90:return{x:1-e-i,y:t,width:i,height:s};case 180:return{x:1-t-s,y:1-e-i,width:s,height:i};case 270:return{x:e,y:1-t-s,width:i,height:s}}return{x:t,y:e,width:s,height:i}}rotate(t){const{drawLayer:e}=this.parent;let s;this.#h?(t=(t-this.rotation+360)%360,s=ut.#b(this.#d.box,t)):s=ut.#b(this,t),e.rotate(this.#f,t),e.rotate(this.#u,t),e.updateBox(this.#f,s),e.updateBox(this.#u,ut.#b(this.#i.box,t))}render(){if(this.div)return this.div;const t=super.render();this.#v&&(t.setAttribute("aria-label",this.#v),t.setAttribute("role","mark")),this.#h?t.classList.add("free"):this.div.addEventListener("keydown",this.#a,{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[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),Ke(this,this.#c,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.parent.drawLayer.addClass(this.#u,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#u,"hovered")}#w(t){ut._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#x(!0);break;case 1:case 3:this.#x(!1);break}}#x(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#r,this.#l)}select(){super.select(),this.#u&&(this.parent?.drawLayer.removeClass(this.#u,"hovered"),this.parent?.drawLayer.addClass(this.#u,"selected"))}unselect(){super.unselect(),this.#u&&(this.parent?.drawLayer.removeClass(this.#u,"selected"),this.#h||this.#x(!1))}get _mustFixPosition(){return!this.#h}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(this.#f,t),this.parent.drawLayer.show(this.#u,t))}#k(){return this.#h?this.rotation:0}#L(){if(this.#h)return null;const[t,e]=this.pageDimensions,s=this.#s,i=new Float32Array(s.length*8);let n=0;for(const{x:r,y:a,width:o,height:h}of s){const c=r*t,d=(1-a-h)*e;i[n]=i[n+4]=c,i[n+1]=i[n+3]=d,i[n+2]=i[n+6]=c+o*t,i[n+5]=i[n+7]=d+h*e,n+=8}return i}#M(t){return this.#d.serialize(t,this.#k())}static startHighlighting(t,e,{target:s,x:i,y:n}){const{x:r,y:a,width:o,height:h}=s.getBoundingClientRect(),c=g=>{this.#F(t,g)},d=t._signal,u={capture:!0,passive:!1,signal:d},p=g=>{g.preventDefault(),g.stopPropagation()},f=g=>{s.removeEventListener("pointermove",c),window.removeEventListener("blur",f),window.removeEventListener("pointerup",f),window.removeEventListener("pointerdown",p,u),window.removeEventListener("contextmenu",Dt),this.#I(t,g)};window.addEventListener("blur",f,{signal:d}),window.addEventListener("pointerup",f,{signal:d}),window.addEventListener("pointerdown",p,u),window.addEventListener("contextmenu",Dt,{signal:d}),s.addEventListener("pointermove",c,{signal:d}),this._freeHighlight=new pe({x:i,y:n},[r,a,o,h],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static#F(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#I(t,e){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(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,s){const i=super.deserialize(t,e,s),{rect:[n,r,a,o],color:h,quadPoints:c}=t;i.color=R.makeHexColor(...h),i.#m=t.opacity;const[d,u]=i.pageDimensions;i.width=(a-n)/d,i.height=(o-r)/u;const p=i.#s=[];for(let f=0;f<c.length;f+=8)p.push({x:(c[4]-a)/d,y:(o-(1-c[f+5]))/u,width:(c[f+2]-c[f])/d,height:(c[f+5]-c[f+1])/u});return i.#y(),i}serialize(t=!1){if(this.isEmpty()||t)return null;const e=this.getRect(0,0),s=F._colorManager.convert(this.color);return{annotationType:W.HIGHLIGHT,color:s,opacity:this.#m,thickness:this.#g,quadPoints:this.#L(),outlines:this.#M(e),pageIndex:this.pageIndex,rect:e,rotation:this.#k(),structTreeParentId:this._structTreeParentId}}static canCreateNewEmptyEditor(){return!1}}class _t extends F{#t=0;#e=0;#s=this.canvasPointermove.bind(this);#n=this.canvasPointerleave.bind(this);#o=this.canvasPointerup.bind(this);#i=this.canvasPointerdown.bind(this);#r=null;#l=new Path2D;#c=!1;#d=!1;#f=!1;#h=null;#a=0;#p=0;#m=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=W.INK;constructor(t){super({...t,name:"inkEditor"}),this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,e){F.initialize(t,e)}static updateDefaultParams(t,e){switch(t){case N.INK_THICKNESS:_t._defaultThickness=e;break;case N.INK_COLOR:_t._defaultColor=e;break;case N.INK_OPACITY:_t._defaultOpacity=e/100;break}}updateParams(t,e){switch(t){case N.INK_THICKNESS:this.#u(e);break;case N.INK_COLOR:this.#v(e);break;case N.INK_OPACITY:this.#g(e);break}}static get defaultPropertiesToUpdate(){return[[N.INK_THICKNESS,_t._defaultThickness],[N.INK_COLOR,_t._defaultColor||F._defaultLineColor],[N.INK_OPACITY,Math.round(_t._defaultOpacity*100)]]}get propertiesToUpdate(){return[[N.INK_THICKNESS,this.thickness||_t._defaultThickness],[N.INK_COLOR,this.color||_t._defaultColor||F._defaultLineColor],[N.INK_OPACITY,Math.round(100*(this.opacity??_t._defaultOpacity))]]}#u(t){const e=i=>{this.thickness=i,this.#O()},s=this.thickness;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#v(t){const e=i=>{this.color=i,this.#w()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#g(t){const e=i=>{this.opacity=i,this.#w()};t/=100;const s=this.opacity;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(this.#k(),this.#L()),this.isAttachedToDOM||(this.parent.add(this),this.#M()),this.#O()))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#r&&(clearTimeout(this.#r),this.#r=null),this.#h?.disconnect(),this.#h=null,super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&t===null&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,e]=this.parentDimensions,s=this.width*t,i=this.height*e;this.setDimensions(s,i)}enableEditMode(){this.#c||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#i,{signal:this._uiManager._signal}))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",this.#i))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}#A(){const{parentRotation:t,parentDimensions:[e,s]}=this;switch(t){case 90:return[0,s,s,e];case 180:return[e,s,e,s];case 270:return[e,0,s,e];default:return[0,0,e,s]}}#y(){const{ctx:t,color:e,opacity:s,thickness:i,parentScale:n,scaleFactor:r}=this;t.lineWidth=i*n/r,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${e}${Jn(s)}`}#E(t,e){const s=this._uiManager._signal;this.canvas.addEventListener("contextmenu",Dt,{signal:s}),this.canvas.addEventListener("pointerleave",this.#n,{signal:s}),this.canvas.addEventListener("pointermove",this.#s,{signal:s}),this.canvas.addEventListener("pointerup",this.#o,{signal:s}),this.canvas.removeEventListener("pointerdown",this.#i),this.isEditing=!0,this.#f||(this.#f=!0,this.#M(),this.thickness||=_t._defaultThickness,this.color||=_t._defaultColor||F._defaultLineColor,this.opacity??=_t._defaultOpacity),this.currentPath.push([t,e]),this.#d=!1,this.#y(),this.#m=()=>{this.#S(),this.#m&&window.requestAnimationFrame(this.#m)},window.requestAnimationFrame(this.#m)}#C(t,e){const[s,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===s&&e===i)return;const n=this.currentPath;let r=this.#l;if(n.push([t,e]),this.#d=!0,n.length<=2){r.moveTo(...n[0]),r.lineTo(t,e);return}n.length===3&&(this.#l=r=new Path2D,r.moveTo(...n[0])),this.#_(r,...n.at(-3),...n.at(-2),t,e)}#T(){if(this.currentPath.length===0)return;const t=this.currentPath.at(-1);this.#l.lineTo(...t)}#P(t,e){this.#m=null,t=Math.min(Math.max(t,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),this.#C(t,e),this.#T();let s;if(this.currentPath.length!==1)s=this.#b();else{const o=[t,e];s=[[o,o.slice(),o.slice(),o]]}const i=this.#l,n=this.currentPath;this.currentPath=[],this.#l=new Path2D;const r=()=>{this.allRawPaths.push(n),this.paths.push(s),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},a=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(this.#k(),this.#L()),this.#O())};this.addCommands({cmd:r,undo:a,mustExec:!0})}#S(){if(!this.#d)return;this.#d=!1;const t=Math.ceil(this.thickness*this.parentScale),e=this.currentPath.slice(-3),s=e.map(r=>r[0]),i=e.map(r=>r[1]);Math.min(...s)-t,Math.max(...s)+t,Math.min(...i)-t,Math.max(...i)+t;const{ctx:n}=this;n.save(),n.clearRect(0,0,this.canvas.width,this.canvas.height);for(const r of this.bezierPath2D)n.stroke(r);n.stroke(this.#l),n.restore()}#_(t,e,s,i,n,r,a){const o=(e+i)/2,h=(s+n)/2,c=(i+r)/2,d=(n+a)/2;t.bezierCurveTo(o+2*(i-o)/3,h+2*(n-h)/3,c+2*(i-c)/3,d+2*(n-d)/3,c,d)}#b(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const e=[];let s,[i,n]=t[0];for(s=1;s<t.length-2;s++){const[u,p]=t[s],[f,g]=t[s+1],b=(u+f)/2,m=(p+g)/2,v=[i+2*(u-i)/3,n+2*(p-n)/3],_=[b+2*(u-b)/3,m+2*(p-m)/3];e.push([[i,n],v,_,[b,m]]),[i,n]=[b,m]}const[r,a]=t[s],[o,h]=t[s+1],c=[i+2*(r-i)/3,n+2*(a-n)/3],d=[o+2*(r-o)/3,h+2*(a-h)/3];return e.push([[i,n],c,d,[o,h]]),e}#w(){if(this.isEmpty()){this.#I();return}this.#y();const{canvas:t,ctx:e}=this;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height),this.#I();for(const s of this.bezierPath2D)e.stroke(s)}commit(){this.#c||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),this.#c=!0,this.div.classList.add("disabled"),this.#O(!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}canvasPointerdown(t){t.button!==0||!this.isInEditMode()||this.#c||(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),this.#E(t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),this.#C(t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),this.#x(t)}canvasPointerleave(t){this.#x(t)}#x(t){this.canvas.removeEventListener("pointerleave",this.#n),this.canvas.removeEventListener("pointermove",this.#s),this.canvas.removeEventListener("pointerup",this.#o),this.canvas.addEventListener("pointerdown",this.#i,{signal:this._uiManager._signal}),this.#r&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.canvas.removeEventListener("contextmenu",Dt)},10),this.#P(t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#k(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#L(){this.#h=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}),this.#h.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#h?.disconnect(),this.#h=null},{once:!0})}get isResizable(){return!this.isEmpty()&&this.#c}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[s,i,n,r]=this.#A();if(this.setAt(s,i,0,0),this.setDims(n,r),this.#k(),this.width){const[a,o]=this.parentDimensions;this.setAspectRatio(this.width*a,this.height*o),this.setAt(t*a,e*o,this.width*a,this.height*o),this.#f=!0,this.#M(),this.setDims(this.width*a,this.height*o),this.#w(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#L(),this.div}#M(){if(!this.#f)return;const[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*e),this.#I()}setDimensions(t,e){const s=Math.round(t),i=Math.round(e);if(this.#a===s&&this.#p===i)return;this.#a=s,this.#p=i,this.canvas.style.visibility="hidden";const[n,r]=this.parentDimensions;this.width=t/n,this.height=e/r,this.fixAndSetPosition(),this.#c&&this.#F(t,e),this.#M(),this.#w(),this.canvas.style.visibility="visible",this.fixDims()}#F(t,e){const s=this.#z(),i=(t-s)/this.#e,n=(e-s)/this.#t;this.scaleFactor=Math.min(i,n)}#I(){const t=this.#z()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static#N(t){const e=new Path2D;for(let s=0,i=t.length;s<i;s++){const[n,r,a,o]=t[s];s===0&&e.moveTo(...n),e.bezierCurveTo(r[0],r[1],a[0],a[1],o[0],o[1])}return e}static#D(t,e,s){const[i,n,r,a]=e;switch(s){case 0:for(let o=0,h=t.length;o<h;o+=2)t[o]+=i,t[o+1]=a-t[o+1];break;case 90:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=t[o+1]+i,t[o+1]=c+n}break;case 180:for(let o=0,h=t.length;o<h;o+=2)t[o]=r-t[o],t[o+1]+=n;break;case 270:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=r-t[o+1],t[o+1]=a-c}break;default:throw new Error("Invalid rotation")}return t}static#W(t,e,s){const[i,n,r,a]=e;switch(s){case 0:for(let o=0,h=t.length;o<h;o+=2)t[o]-=i,t[o+1]=a-t[o+1];break;case 90:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=t[o+1]-n,t[o+1]=c-i}break;case 180:for(let o=0,h=t.length;o<h;o+=2)t[o]=r-t[o],t[o+1]-=n;break;case 270:for(let o=0,h=t.length;o<h;o+=2){const c=t[o];t[o]=a-t[o+1],t[o+1]=r-c}break;default:throw new Error("Invalid rotation")}return t}#G(t,e,s,i){const n=[],r=this.thickness/2,a=t*e+r,o=t*s+r;for(const h of this.paths){const c=[],d=[];for(let u=0,p=h.length;u<p;u++){const[f,g,b,m]=h[u];if(f[0]===m[0]&&f[1]===m[1]&&p===1){const O=t*f[0]+a,M=t*f[1]+o;c.push(O,M),d.push(O,M);break}const v=t*f[0]+a,_=t*f[1]+o,A=t*g[0]+a,E=t*g[1]+o,w=t*b[0]+a,S=t*b[1]+o,T=t*m[0]+a,k=t*m[1]+o;u===0&&(c.push(v,_),d.push(v,_)),c.push(A,E,w,S,T,k),d.push(A,E),u===p-1&&d.push(T,k)}n.push({bezier:_t.#D(c,i,this.rotation),points:_t.#D(d,i,this.rotation)})}return n}#j(){let t=1/0,e=-1/0,s=1/0,i=-1/0;for(const n of this.paths)for(const[r,a,o,h]of n){const c=R.bezierBoundingBox(...r,...a,...o,...h);t=Math.min(t,c[0]),s=Math.min(s,c[1]),e=Math.max(e,c[2]),i=Math.max(i,c[3])}return[t,s,e,i]}#z(){return this.#c?Math.ceil(this.thickness*this.parentScale):0}#O(t=!1){if(this.isEmpty())return;if(!this.#c){this.#w();return}const e=this.#j(),s=this.#z();this.#e=Math.max(F.MIN_SIZE,e[2]-e[0]),this.#t=Math.max(F.MIN_SIZE,e[3]-e[1]);const i=Math.ceil(s+this.#e*this.scaleFactor),n=Math.ceil(s+this.#t*this.scaleFactor),[r,a]=this.parentDimensions;this.width=i/r,this.height=n/a,this.setAspectRatio(i,n);const o=this.translationX,h=this.translationY;this.translationX=-e[0],this.translationY=-e[1],this.#M(),this.#w(),this.#a=i,this.#p=n,this.setDims(i,n);const c=t?s/this.scaleFactor/2:0;this.translate(o-this.translationX-c,h-this.translationY-c)}static deserialize(t,e,s){if(t instanceof an)return null;const i=super.deserialize(t,e,s);i.thickness=t.thickness,i.color=R.makeHexColor(...t.color),i.opacity=t.opacity;const[n,r]=i.pageDimensions,a=i.width*n,o=i.height*r,h=i.parentScale,c=t.thickness/2;i.#c=!0,i.#a=Math.round(a),i.#p=Math.round(o);const{paths:d,rect:u,rotation:p}=t;for(let{bezier:g}of d){g=_t.#W(g,u,p);const b=[];i.paths.push(b);let m=h*(g[0]-c),v=h*(g[1]-c);for(let A=2,E=g.length;A<E;A+=6){const w=h*(g[A]-c),S=h*(g[A+1]-c),T=h*(g[A+2]-c),k=h*(g[A+3]-c),O=h*(g[A+4]-c),M=h*(g[A+5]-c);b.push([[m,v],[w,S],[T,k],[O,M]]),m=O,v=M}const _=this.#N(b);i.bezierPath2D.push(_)}const f=i.#j();return i.#e=Math.max(F.MIN_SIZE,f[2]-f[0]),i.#t=Math.max(F.MIN_SIZE,f[3]-f[1]),i.#F(a,o),i}serialize(){if(this.isEmpty())return null;const t=this.getRect(0,0),e=F._colorManager.convert(this.ctx.strokeStyle);return{annotationType:W.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:this.#G(this.scaleFactor/this.parentScale,this.translationX,this.translationY,t),pageIndex:this.pageIndex,rect:t,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}class Qs extends F{#t=null;#e=null;#s=null;#n=null;#o=null;#i="";#r=null;#l=null;#c=null;#d=!1;#f=!1;static _type="stamp";static _editorType=W.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#n=t.bitmapUrl,this.#o=t.bitmapFile}static initialize(t,e){F.initialize(t,e)}static get supportedTypes(){return K(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return K(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(W.STAMP,{bitmapFile:t.getAsFile()})}#h(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#d=t.isSvg),t.file&&(this.#i=t.file.name),this.#m()}#a(){this.#s=null,this._uiManager.enableWaiting(!1),this.#r&&this.div.focus()}#p(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#h(s,!0)).finally(()=>this.#a());return}if(this.#n){const s=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#h(i)).finally(()=>this.#a());return}if(this.#o){const s=this.#o;this.#o=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then(i=>this.#h(i)).finally(()=>this.#a());return}const t=document.createElement("input");t.type="file",t.accept=Qs.supportedTypesStr;const e=this._uiManager._signal;this.#s=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(t.files[0]);this.#h(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#a()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#r?.remove(),this.#r=null,this.#l?.disconnect(),this.#l=null,this.#c&&(clearTimeout(this.#c),this.#c=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#p();return}super.rebuild(),this.div!==null&&(this.#e&&this.#r===null&&this.#p(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#n||this.#o||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.addAltTextButton(),this.#t?this.#m():this.#p(),this.width){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i)}return this.div}#m(){const{div:t}=this;let{width:e,height:s}=this.#t;const[i,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>r*i||s>r*n){const c=Math.min(r*i/e,r*n/s);e*=c,s*=c}const[a,o]=this.parentDimensions;this.setDims(e*a/i,s*o/n),this._uiManager.enableWaiting(!1);const h=this.#r=document.createElement("canvas");t.append(h),t.hidden=!1,this.#g(e,s),this.#y(),this.#f||(this.parent.addUndoableEditor(this),this.#f=!0),this._reportTelemetry({action:"inserted_image"}),this.#i&&h.setAttribute("aria-label",this.#i)}#u(t,e){const[s,i]=this.parentDimensions;this.width=t/s,this.height=e/i,this.setDims(t,e),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this.#c!==null&&clearTimeout(this.#c);const n=200;this.#c=setTimeout(()=>{this.#c=null,this.#g(t,e)},n)}#v(t,e){const{width:s,height:i}=this.#t;let n=s,r=i,a=this.#t;for(;n>2*t||r>2*e;){const o=n,h=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const c=new OffscreenCanvas(n,r);c.getContext("2d").drawImage(a,0,0,o,h,0,0,n,r),a=c.transferToImageBitmap()}return a}#g(t,e){t=Math.ceil(t),e=Math.ceil(e);const s=this.#r;if(!s||s.width===t&&s.height===e)return;s.width=t,s.height=e;const i=this.#d?this.#t:this.#v(t,e);if(this._uiManager.hasMLManager&&!this.hasAltText()){const a=new OffscreenCanvas(t,e).getContext("2d");a.drawImage(i,0,0,i.width,i.height,0,0,t,e),this._uiManager.mlGuess({service:"image-to-text",request:{data:a.getImageData(0,0,t,e).data,width:t,height:e,channels:4}}).then(o=>{const h=o?.output||"";this.parent&&h&&!this.hasAltText()&&(this.altTextData={altText:h,decorative:!1})})}const n=s.getContext("2d");n.filter=this._uiManager.hcmFilter,n.drawImage(i,0,0,i.width,i.height,0,0,t,e)}getImageForAltText(){return this.#r}#A(t){if(t){if(this.#d){const i=this._uiManager.imageManager.getSvgUrl(this.#e);if(i)return i}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.#d){const[e,s]=this.pageDimensions,i=Math.round(this.width*e*Ce.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*Ce.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,n),r.transferToImageBitmap()}return structuredClone(this.#t)}#y(){this._uiManager._signal&&(this.#l=new ResizeObserver(t=>{const e=t[0].contentRect;e.width&&e.height&&this.#u(e.width,e.height)}),this.#l.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#l?.disconnect(),this.#l=null},{once:!0}))}static deserialize(t,e,s){if(t instanceof on)return null;const i=super.deserialize(t,e,s),{rect:n,bitmapUrl:r,bitmapId:a,isSvg:o,accessibilityData:h}=t;a&&s.imageManager.isValidId(a)?i.#e=a:i.#n=r,i.#d=o;const[c,d]=i.pageDimensions;return i.width=(n[2]-n[0])/c,i.height=(n[3]-n[1])/d,h&&(i.altTextData=h),i}serialize(t=!1,e=null){if(this.isEmpty())return null;const s={annotationType:W.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#d,structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=this.#A(!0),s.accessibilityData=this.altTextData,s;const{decorative:i,altText:n}=this.altTextData;if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),e===null)return s;e.stamps||=new Map;const r=this.#d?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#A(!1);else if(this.#d){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#A(!1))}return s}}class ee{#t;#e=!1;#s=null;#n=null;#o=null;#i=null;#r=null;#l=new Map;#c=!1;#d=!1;#f=!1;#h=null;#a;static _initialized=!1;static#p=new Map([pt,_t,Qs,ut].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,accessibilityManager:i,annotationLayer:n,drawLayer:r,textLayer:a,viewport:o,l10n:h}){const c=[...ee.#p.values()];if(!ee._initialized){ee._initialized=!0;for(const d of c)d.initialize(h,t)}t.registerEditorTypes(c),this.#a=t,this.pageIndex=e,this.div=s,this.#t=i,this.#s=n,this.viewport=o,this.#h=a,this.drawLayer=r,this.#a.addLayer(this)}get isEmpty(){return this.#l.size===0}get isInvisible(){return this.isEmpty&&this.#a.getMode()===W.NONE}updateToolbar(t){this.#a.updateToolbar(t)}updateMode(t=this.#a.getMode()){switch(this.#A(),t){case W.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case W.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case W.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of ee.#p.values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#h?.div}addInkEditorIfNeeded(t){if(this.#a.getMode()!==W.INK)return;if(!t){for(const s of this.#l.values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){this.#a.setEditingState(t)}addCommands(t){this.#a.addCommands(t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.div.classList.toggle("disabled",!t)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of this.#l.values())s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#a.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!this.#s)return;const e=this.#s.getEditableAnnotations();for(const s of e){if(s.hide(),this.#a.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){this.#f=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#l.values())if(i.disableEditing(),!!i.annotationElementId){if(i.serialize()!==null){t.set(i.annotationElementId,i);continue}else e.set(i.annotationElementId,i);this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()}if(this.#s){const i=this.#s.getEditableAnnotations();for(const n of i){const{id:r}=n.data;if(this.#a.isDeletedAnnotationElement(r))continue;let a=e.get(r);if(a){a.resetAnnotationElement(n),a.show(!1),n.show();continue}a=t.get(r),a&&(this.#a.addChangedExistingAnnotation(a),a.renderAnnotationElement(n),a.show(!1)),n.show()}}this.#A(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const i of ee.#p.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#f=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#a.getActive()!==t&&this.#a.setActiveEditor(t)}enableTextSelection(){this.div.tabIndex=-1,this.#h?.div&&!this.#i&&(this.#i=this.#m.bind(this),this.#h.div.addEventListener("pointerdown",this.#i,{signal:this.#a._signal}),this.#h.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#h?.div&&this.#i&&(this.#h.div.removeEventListener("pointerdown",this.#i),this.#i=null,this.#h.div.classList.remove("highlighting"))}#m(t){if(this.#a.unselectAll(),t.target===this.#h.div){const{isMac:e}=It.platform;if(t.button!==0||t.ctrlKey&&e)return;this.#a.showAllEditors("highlight",!0,!0),this.#h.div.classList.add("free"),ut.startHighlighting(this,this.#a.direction==="ltr",t),this.#h.div.addEventListener("pointerup",()=>{this.#h.div.classList.remove("free")},{once:!0,signal:this.#a._signal}),t.preventDefault()}}enableClick(){if(this.#o)return;const t=this.#a._signal;this.#o=this.pointerdown.bind(this),this.#n=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#o,{signal:t}),this.div.addEventListener("pointerup",this.#n,{signal:t})}disableClick(){this.#o&&(this.div.removeEventListener("pointerdown",this.#o),this.div.removeEventListener("pointerup",this.#n),this.#o=null,this.#n=null)}attach(t){this.#l.set(t.id,t);const{annotationElementId:e}=t;e&&this.#a.isDeletedAnnotationElement(e)&&this.#a.removeDeletedAnnotationElement(t)}detach(t){this.#l.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#f&&t.annotationElementId&&this.#a.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#a.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,this.#d||this.addInkEditorIfNeeded(!1)}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#a.addDeletedAnnotationElement(t.annotationElementId),F.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),this.#a.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#a.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#r&&(t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#a._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return this.#a.getId()}get#u(){return ee.#p.get(this.#a.getMode())}get _signal(){return this.#a._signal}#v(t){const e=this.#u;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#u?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#a.updateToolbar(t),this.#a.updateMode(t);const{offsetX:s,offsetY:i}=this.#g(),n=this.getNextId(),r=this.#v({parent:this,id:n,x:s,y:i,uiManager:this.#a,isCentered:!0,...e});r&&this.add(r)}deserialize(t){return ee.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#a)||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=this.#v({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#a,isCentered:e,...s});return n&&this.add(n),n}#g(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),h=(n+a)/2-t,c=(r+o)/2-e,[d,u]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:u}}addNewEditor(){this.createAndAddNewEditor(this.#g(),!0)}setSelected(t){this.#a.setSelected(t)}toggleSelected(t){this.#a.toggleSelected(t)}isSelected(t){return this.#a.isSelected(t)}unselect(t){this.#a.unselect(t)}pointerup(t){const{isMac:e}=It.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&this.#c){if(this.#c=!1,!this.#e){this.#e=!0;return}if(this.#a.getMode()===W.STAMP){this.#a.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#a.getMode()===W.HIGHLIGHT&&this.enableTextSelection(),this.#c){this.#c=!1;return}const{isMac:e}=It.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;this.#c=!0;const s=this.#a.getActive();this.#e=!s||s.isEmpty()}findNewParent(t,e,s){const i=this.#a.findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){this.#a.getActive()?.parent===this&&(this.#a.commitOrRemove(),this.#a.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(const t of this.#l.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#l.clear(),this.#a.removeLayer(this)}#A(){this.#d=!0;for(const t of this.#l.values())t.isEmpty()&&t.remove();this.#d=!1}render({viewport:t}){this.viewport=t,me(this.div,t);for(const e of this.#a.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#a.commitOrRemove(),this.#A();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,me(this.div,{rotation:s}),e!==s)for(const i of this.#l.values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#a.viewParameters.realScale}}class wt{#t=null;#e=0;#s=new Map;#n=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#s.size>0)for(const e of this.#s.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return K(this,"_svgFactory",new Hs)}static#o(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`}#i(t){const e=wt._svgFactory.create(1,1,!0);return this.#t.append(e),e.setAttribute("aria-hidden",!0),wt.#o(e,t),e}#r(t,e){const s=wt._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=wt._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}highlight(t,e,s,i=!1){const n=this.#e++,r=this.#i(t.box);r.classList.add("highlight"),t.free&&r.classList.add("free");const a=wt._svgFactory.createElement("defs");r.append(a);const o=wt._svgFactory.createElement("path");a.append(o);const h=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",h),o.setAttribute("d",t.toSVGPath()),i&&this.#n.set(n,o);const c=this.#r(a,h),d=wt._svgFactory.createElement("use");return r.append(d),r.setAttribute("fill",e),r.setAttribute("fill-opacity",s),d.setAttribute("href",`#${h}`),this.#s.set(n,r),{id:n,clipPathId:`url(#${c})`}}highlightOutline(t){const e=this.#e++,s=this.#i(t.box);s.classList.add("highlightOutline");const i=wt._svgFactory.createElement("defs");s.append(i);const n=wt._svgFactory.createElement("path");i.append(n);const r=`path_p${this.pageIndex}_${e}`;n.setAttribute("id",r),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke");let a;if(t.free){s.classList.add("free");const c=wt._svgFactory.createElement("mask");i.append(c),a=`mask_p${this.pageIndex}_${e}`,c.setAttribute("id",a),c.setAttribute("maskUnits","objectBoundingBox");const d=wt._svgFactory.createElement("rect");c.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");const u=wt._svgFactory.createElement("use");c.append(u),u.setAttribute("href",`#${r}`),u.setAttribute("stroke","none"),u.setAttribute("fill","black"),u.setAttribute("fill-rule","nonzero"),u.classList.add("mask")}const o=wt._svgFactory.createElement("use");s.append(o),o.setAttribute("href",`#${r}`),a&&o.setAttribute("mask",`url(#${a})`);const h=o.cloneNode();return s.append(h),o.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.#s.set(e,s),e}finalizeLine(t,e){const s=this.#n.get(t);this.#n.delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#s.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t),this.#n.delete(t)}updatePath(t,e){this.#n.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){wt.#o(this.#s.get(t),e)}show(t,e){this.#s.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#s.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#s.get(t).setAttribute("fill",e)}changeOpacity(t,e){this.#s.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#s.get(t).classList.add(e)}removeClass(t,e){this.#s.get(t).classList.remove(e)}remove(t){this.#t!==null&&(this.#s.get(t).remove(),this.#s.delete(t))}destroy(){this.#t=null;for(const t of this.#s.values())t.remove();this.#s.clear()}}D.AbortException;D.AnnotationEditorLayer;D.AnnotationEditorParamsType;D.AnnotationEditorType;D.AnnotationEditorUIManager;D.AnnotationLayer;D.AnnotationMode;D.CMapCompressionType;D.ColorPicker;D.DOMSVGFactory;D.DrawLayer;D.FeatureTest;var Pa=D.GlobalWorkerOptions;D.ImageKind;D.InvalidPDFException;D.MissingPDFException;D.OPS;D.Outliner;D.PDFDataRangeTransport;D.PDFDateString;D.PDFWorker;D.PasswordResponses;D.PermissionFlag;D.PixelsPerInch;D.RenderingCancelledException;D.TextLayer;D.UnexpectedResponseException;D.Util;D.VerbosityLevel;D.XfaLayer;D.build;D.createValidAbsoluteUrl;D.fetchData;var Ma=D.getDocument;D.getFilenameFromUrl;D.getPdfFilenameFromUrl;D.getXfaPageViewport;D.isDataScheme;D.isPdfFile;D.noContextMenu;D.normalizeUnicode;D.renderTextLayer;D.setLayerDimensions;D.shadow;D.updateTextLayer;D.version;const La=""+new URL("../workers/pdf.worker-6GyNUiLx.js",import.meta.url).href,Ia=l=>{let t;t||(t=document.createElement("iframe"),document.body.appendChild(t),t.style.display="none",t.onload=function(){setTimeout(function(){t.focus(),t.contentWindow.print()},1)}),t.src=l},Da=l=>{let e=l.split(" ").length;if(e>0)return Math.ceil(e/200)},Fa=(l,t)=>new Promise(function(e,s){t.getPage(l).then(function(i){i.getTextContent().then(function(n){for(var r=n.items,a="",o=0;o<r.length;o++){var h=r[o];a+=h.str+" "}e(a)})})}),Na=async({fileUrl:l,data:t,name:e="download.pdf"})=>{const s=document.createElement("a");s.download=e,s.rel="noopener",l||(l=`data:application/pdf;base64,${btoa(t)}`);let i=await fetch(l).then(r=>r.blob());(!i||!(i instanceof Blob))&&console.log("Invalid blob object passed to URL.createObjectURL()"),typeof URL.createObjectURL>"u"&&console.log("Your browser does not support URL.createObjectURL()");const n=URL.createObjectURL(i);s.href=n,s.click(),URL.revokeObjectURL(s.href)};function Oa(l){const t=l-1;return t*t*t+1}function vi(l,{delay:t=0,duration:e=400,easing:s=Oa,start:i=0,opacity:n=0}={}){const r=getComputedStyle(l),a=+r.opacity,o=r.transform==="none"?"":r.transform,h=1-i,c=a*(1-n);return{delay:t,duration:e,easing:s,css:(d,u)=>`
			transform: ${o} scale(${1-h*u});
			opacity: ${a-c*u}
		`}}class Ha{constructor(t,e){this.defaults=typeof t=="function"?t(e):t,this.classes=this.defaults}flush(){return this.classes=this.defaults,this}extend(...t){return this}get(){return this.classes}replace(t,e=!0){return e&&t&&(this.classes=Object.keys(t).reduce((s,i)=>s.replace(new RegExp(i,"g"),t[i]),this.classes)),this}remove(t,e=!0){return e&&t&&(this.classes=t.split(" ").reduce((s,i)=>s.replace(new RegExp(i,"g"),""),this.classes)),this}add(t,e=!0,s){if(!e||!t)return this;switch(typeof t){case"string":default:return this.classes+=` ${t} `,this;case"function":return this.classes+=` ${t(s||this.classes)} `,this}}}const Ba=l=>({}),Ai=l=>({});function _i(l){let t,e,s,i,n;const r=l[8].default,a=Ri(r,l,l[7],null);return{c(){t=X("div"),a&&a.c(),this.h()},l(o){t=Y(o,"DIV",{class:!0});var h=z(t);a&&a.l(h),h.forEach(C),this.h()},h(){y(t,"class",e=Zs(l[1])+" svelte-10lk5cm")},m(o,h){tt(o,t,h),a&&a.m(t,null),n=!0},p(o,h){a&&a.p&&(!n||h&128)&&Pi(a,r,o,o[7],n?Li(r,o[7],h,null):Mi(o[7]),null),(!n||h&2&&e!==(e=Zs(o[1])+" svelte-10lk5cm"))&&y(t,"class",e)},i(o){n||(V(a,o),o&&Ii(()=>{n&&(i&&i.end(1),s=kn(t,vi,{duration:150}),s.start())}),n=!0)},o(o){st(a,o),s&&s.invalidate(),o&&(i=Rn(t,vi,{duration:150,delay:100})),n=!1},d(o){o&&C(t),a&&a.d(o),o&&i&&i.end()}}}function za(l){let t,e,s,i,n,r;const a=l[8].activator,o=Ri(a,l,l[7],Ai);let h=l[0]&&_i(l);return{c(){t=X("div"),e=X("div"),o&&o.c(),s=bt(),h&&h.c(),this.h()},l(c){t=Y(c,"DIV",{class:!0});var d=z(t);e=Y(d,"DIV",{role:!0});var u=z(e);o&&o.l(u),u.forEach(C),s=vt(d),h&&h.l(d),d.forEach(C),this.h()},h(){y(e,"role","note"),y(t,"class","activator svelte-10lk5cm")},m(c,d){tt(c,t,d),L(t,e),o&&o.m(e,null),L(t,s),h&&h.m(t,null),i=!0,n||(r=[it(e,"mouseenter",yi(l[2],100)),it(e,"mouseleave",yi(l[3],100)),it(e,"mouseenter",l[9]),it(e,"mouseleave",l[10]),it(e,"focus",l[11]),it(e,"blur",l[12])],n=!0)},p(c,[d]){o&&o.p&&(!i||d&128)&&Pi(o,a,c,c[7],i?Li(a,c[7],d,Ba):Mi(c[7]),Ai),c[0]?h?(h.p(c,d),d&1&&V(h,1)):(h=_i(c),h.c(),V(h,1),h.m(t,null)):h&&(oe(),st(h,1,1,()=>{h=null}),le())},i(c){i||(V(o,c),V(h),i=!0)},o(c){st(o,c),st(h),i=!1},d(c){c&&C(t),o&&o.d(c),h&&h.d(),n=!1,jt(r)}}}const bs="tooltip";function yi(l,t,e){let s;return function(){let i=this,n=arguments,r=function(){s=null,l.apply(i,n)};clearTimeout(s),s=setTimeout(r,t)}}function Ua(l,t,e){let s,{$$slots:i={},$$scope:n}=t,{class:r=""}=t,{classes:a=bs}=t,{show:o=!1}=t,{timeout:h=null}=t;const c=new Ha(a,bs);function d(){o||(e(0,o=!0),h&&e(4,h=setTimeout(()=>{e(0,o=!1)},h)))}function u(){o&&(e(0,o=!1),clearTimeout(h))}function p(m){Nt.call(this,l,m)}function f(m){Nt.call(this,l,m)}function g(m){Nt.call(this,l,m)}function b(m){Nt.call(this,l,m)}return l.$$set=m=>{"class"in m&&e(5,r=m.class),"classes"in m&&e(6,a=m.classes),"show"in m&&e(0,o=m.show),"timeout"in m&&e(4,h=m.timeout),"$$scope"in m&&e(7,n=m.$$scope)},l.$$.update=()=>{l.$$.dirty&96&&e(1,s=c.flush().add(a,!0,bs).add(r).get())},[o,s,d,u,h,r,a,n,i,p,f,g,b]}class ne extends Is{constructor(t){super(),Ds(this,t,Ua,za,Ls,{class:5,classes:6,show:0,timeout:4})}}const{window:Rs}=Pn;function ja(l){let t,e,s;return{c(){t=X("div"),e=X("canvas"),this.h()},l(i){t=Y(i,"DIV",{class:!0});var n=z(t);e=Y(n,"CANVAS",{}),z(e).forEach(C),n.forEach(C),this.h()},h(){y(t,"class",s=l[6]===!0?"viewer":"null")},m(i,n){tt(i,t,n),L(t,e),l[55](e)},p(i,n){n[0]&64&&s!==(s=i[6]===!0?"viewer":"null")&&y(t,"class",s)},i:Gt,o:Gt,d(i){i&&C(t),l[55](null)}}}function Va(l){let t,e,s=l[5].includes("navigation"),i,n=l[5].includes("zoom"),r,a=l[5].includes("print"),o,h=l[5].includes("rotate"),c,d=l[5].includes("download"),u,p=l[5].includes("autoflip"),f,g,b,m,v,_,A,E,w,S,T,k,O,M,G,ot,lt,rt,J,P,I,St,At,Ot,et,B=s&&wi(l),at=n&&Ei(l),Z=a&&Si(l),Q=h&&Ci(l),H=d&&Ti(l),q=p&&xi(l);return{c(){t=X("div"),e=X("div"),B&&B.c(),i=bt(),at&&at.c(),r=bt(),Z&&Z.c(),o=bt(),Q&&Q.c(),c=bt(),H&&H.c(),u=bt(),q&&q.c(),f=bt(),g=X("span"),b=Tt("svg"),m=Tt("path"),v=bt(),_=X("span"),A=Mt(l[11]),E=Mt(" min read"),S=bt(),T=X("span"),k=Tt("svg"),O=Tt("path"),M=bt(),G=X("div"),ot=Mt(`Page :
              `),lt=X("span"),rt=Mt(`
              /
              `),J=X("span"),I=bt(),St=X("div"),At=X("canvas"),this.h()},l(U){t=Y(U,"DIV",{class:!0});var $=z(t);e=Y($,"DIV",{class:!0});var mt=z(e);B&&B.l(mt),i=vt(mt),at&&at.l(mt),r=vt(mt),Z&&Z.l(mt),o=vt(mt),Q&&Q.l(mt),c=vt(mt),H&&H.l(mt),u=vt(mt),q&&q.l(mt),f=vt(mt),g=Y(mt,"SPAN",{class:!0,style:!0});var ye=z(g);b=xt(ye,"svg",{class:!0,xmlns:!0,viewBox:!0});var Be=z(b);m=xt(Be,"path",{d:!0}),z(m).forEach(C),Be.forEach(C),v=vt(ye),_=Y(ye,"SPAN",{class:!0});var Te=z(_);A=Lt(Te,l[11]),E=Lt(Te," min read"),Te.forEach(C),ye.forEach(C),S=vt(mt),T=Y(mt,"SPAN",{class:!0,style:!0});var we=z(T);k=xt(we,"svg",{class:!0,xmlns:!0,viewBox:!0});var ze=z(k);O=xt(ze,"path",{d:!0}),z(O).forEach(C),ze.forEach(C),M=vt(we),G=Y(we,"DIV",{class:!0});var ue=z(G);ot=Lt(ue,`Page :
              `),lt=Y(ue,"SPAN",{}),z(lt).forEach(C),rt=Lt(ue,`
              /
              `),J=Y(ue,"SPAN",{}),z(J).forEach(C),ue.forEach(C),we.forEach(C),mt.forEach(C),I=vt($),St=Y($,"DIV",{class:!0});var Ue=z(St);At=Y(Ue,"CANVAS",{width:!0,height:!0}),z(At).forEach(C),Ue.forEach(C),$.forEach(C),this.h()},h(){y(m,"d",`M16.32 7.1A8 8 0 1 1 9 4.06V2h2v2.06c1.46.18 2.8.76 3.9
                1.62l1.46-1.46 1.42 1.42-1.46 1.45zM10 18a6 6 0 1 0 0-12 6 6 0 0
                0 0 12zM7 0h6v2H7V0zm5.12 8.46l1.42 1.42L10 13.4 8.59
                12l3.53-3.54z`),y(b,"class","icon"),y(b,"xmlns","http://www.w3.org/2000/svg"),y(b,"viewBox","0 0 20 20"),y(_,"class","text"),y(g,"class","page-info"),y(g,"style",w=l[5].includes("timeInfo")?"":"display: none;"),y(O,"d",`M16 2h4v15a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V0h16v2zm0 2v13a1 1 0
                0 0 1 1 1 1 0 0 0 1-1V4h-2zM2 2v15a1 1 0 0 0 1 1h11.17a2.98 2.98
                0 0 1-.17-1V2H2zm2 8h8v2H4v-2zm0 4h8v2H4v-2zM4 4h8v4H4V4z`),y(k,"class","icon"),y(k,"xmlns","http://www.w3.org/2000/svg"),y(k,"viewBox","0 0 20 20"),y(G,"class","text"),y(T,"class","page-info"),y(T,"style",P=l[5].includes("pageInfo")?"":"display: none;"),y(e,"class","line"),y(At,"width",l[17]),y(At,"height",l[18]),y(St,"class",Ot=l[6]===!0?"viewer":"null"),y(t,"class","control-start")},m(U,$){tt(U,t,$),L(t,e),B&&B.m(e,null),L(e,i),at&&at.m(e,null),L(e,r),Z&&Z.m(e,null),L(e,o),Q&&Q.m(e,null),L(e,c),H&&H.m(e,null),L(e,u),q&&q.m(e,null),L(e,f),L(e,g),L(g,b),L(b,m),L(g,v),L(g,_),L(_,A),L(_,E),L(e,S),L(e,T),L(T,k),L(k,O),L(T,M),L(T,G),L(G,ot),L(G,lt),l[52](lt),L(G,rt),L(G,J),l[53](J),L(t,I),L(t,St),L(St,At),l[54](At),et=!0},p(U,$){$[0]&32&&(s=U[5].includes("navigation")),s?B?(B.p(U,$),$[0]&32&&V(B,1)):(B=wi(U),B.c(),V(B,1),B.m(e,i)):B&&(oe(),st(B,1,1,()=>{B=null}),le()),$[0]&32&&(n=U[5].includes("zoom")),n?at?(at.p(U,$),$[0]&32&&V(at,1)):(at=Ei(U),at.c(),V(at,1),at.m(e,r)):at&&(oe(),st(at,1,1,()=>{at=null}),le()),$[0]&32&&(a=U[5].includes("print")),a?Z?(Z.p(U,$),$[0]&32&&V(Z,1)):(Z=Si(U),Z.c(),V(Z,1),Z.m(e,o)):Z&&(oe(),st(Z,1,1,()=>{Z=null}),le()),$[0]&32&&(h=U[5].includes("rotate")),h?Q?(Q.p(U,$),$[0]&32&&V(Q,1)):(Q=Ci(U),Q.c(),V(Q,1),Q.m(e,c)):Q&&(oe(),st(Q,1,1,()=>{Q=null}),le()),$[0]&32&&(d=U[5].includes("download")),d?H?(H.p(U,$),$[0]&32&&V(H,1)):(H=Ti(U),H.c(),V(H,1),H.m(e,u)):H&&(oe(),st(H,1,1,()=>{H=null}),le()),$[0]&32&&(p=U[5].includes("autoflip")),p?q?(q.p(U,$),$[0]&32&&V(q,1)):(q=xi(U),q.c(),V(q,1),q.m(e,f)):q&&(oe(),st(q,1,1,()=>{q=null}),le()),(!et||$[0]&2048)&&Fs(A,U[11]),(!et||$[0]&32&&w!==(w=U[5].includes("timeInfo")?"":"display: none;"))&&y(g,"style",w),(!et||$[0]&32&&P!==(P=U[5].includes("pageInfo")?"":"display: none;"))&&y(T,"style",P),(!et||$[0]&131072)&&y(At,"width",U[17]),(!et||$[0]&262144)&&y(At,"height",U[18]),(!et||$[0]&64&&Ot!==(Ot=U[6]===!0?"viewer":"null"))&&y(St,"class",Ot)},i(U){et||(V(B),V(at),V(Z),V(Q),V(H),V(q),et=!0)},o(U){st(B),st(at),st(Z),st(Q),st(H),st(q),et=!1},d(U){U&&C(t),B&&B.d(),at&&at.d(),Z&&Z.d(),Q&&Q.d(),H&&H.d(),q&&q.d(),l[52](null),l[53](null),l[54](null)}}}function Wa(l){let t,e,s="This document requires a password to open:",i,n,r,a,o,h,c,d,u="Submit",p,f;return{c(){t=X("div"),e=X("p"),e.textContent=s,i=bt(),n=X("p"),r=Mt(l[16]),a=bt(),o=X("div"),h=X("input"),c=bt(),d=X("button"),d.textContent=u,this.h()},l(g){t=Y(g,"DIV",{class:!0});var b=z(t);e=Y(b,"P",{"data-svelte-h":!0}),ge(e)!=="svelte-1d6vq7g"&&(e.textContent=s),i=vt(b),n=Y(b,"P",{class:!0});var m=z(n);r=Lt(m,l[16]),m.forEach(C),a=vt(b),o=Y(b,"DIV",{class:!0});var v=z(o);h=Y(v,"INPUT",{type:!0,class:!0}),c=vt(v),d=Y(v,"BUTTON",{class:!0,"data-svelte-h":!0}),ge(d)!=="svelte-pjp04f"&&(d.textContent=u),v.forEach(C),b.forEach(C),this.h()},h(){y(n,"class","password-message"),y(h,"type","password"),y(h,"class","password-input"),y(d,"class","password-button"),y(o,"class","password-container"),y(t,"class","password-viewer")},m(g,b){tt(g,t,b),L(t,e),L(t,i),L(t,n),L(n,r),L(t,a),L(t,o),L(o,h),Js(h,l[14]),L(o,c),L(o,d),p||(f=[it(h,"input",l[42]),it(d,"click",l[26])],p=!0)},p(g,b){b[0]&65536&&Fs(r,g[16]),b[0]&16384&&h.value!==g[14]&&Js(h,g[14])},i:Gt,o:Gt,d(g){g&&C(t),p=!1,jt(f)}}}function wi(l){let t,e,s,i;return t=new ne({props:{$$slots:{activator:[qa],default:[Ga]},$$scope:{ctx:l}}}),s=new ne({props:{$$slots:{activator:[Xa],default:[$a]},$$scope:{ctx:l}}}),{c(){qt(t.$$.fragment),e=bt(),qt(s.$$.fragment)},l(n){$t(t.$$.fragment,n),e=vt(n),$t(s.$$.fragment,n)},m(n,r){Xt(t,n,r),tt(n,e,r),Xt(s,n,r),i=!0},p(n,r){const a={};r[0]&1|r[2]&128&&(a.$$scope={dirty:r,ctx:n}),t.$set(a);const o={};r[0]&5|r[2]&128&&(o.$$scope={dirty:r,ctx:n}),s.$set(o)},i(n){i||(V(t.$$.fragment,n),V(s.$$.fragment,n),i=!0)},o(n){st(t.$$.fragment,n),st(s.$$.fragment,n),i=!1},d(n){n&&C(e),Yt(t,n),Yt(s,n)}}}function Ga(l){let t;return{c(){t=Mt("Previous")},l(e){t=Lt(e,"Previous")},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function qa(l){let t,e,s,i,n,r;return{c(){t=X("span"),e=Tt("svg"),s=Tt("polygon"),this.h()},l(a){t=Y(a,"SPAN",{role:!0,tabindex:!0,slot:!0,class:!0});var o=z(t);e=xt(o,"svg",{class:!0,xmlns:!0,viewBox:!0});var h=z(e);s=xt(h,"polygon",{points:!0}),z(s).forEach(C),h.forEach(C),o.forEach(C),this.h()},h(){y(s,"points",`3.828 9 9.899 2.929 8.485 1.515 0 10 .707 10.707 8.485
                  18.485 9.899 17.071 3.828 11 20 11 20 9 3.828 9`),y(e,"class","icon"),y(e,"xmlns","http://www.w3.org/2000/svg"),y(e,"viewBox","0 0 20 20"),y(t,"role","button"),y(t,"tabindex","0"),y(t,"slot","activator"),y(t,"class",i="button-control "+(l[0]<=1?"disabled":null))},m(a,o){tt(a,t,o),L(t,e),L(e,s),n||(r=[it(t,"click",l[43]),it(t,"keydown",l[40])],n=!0)},p(a,o){o[0]&1&&i!==(i="button-control "+(a[0]<=1?"disabled":null))&&y(t,"class",i)},d(a){a&&C(t),n=!1,jt(r)}}}function $a(l){let t;return{c(){t=Mt("Next")},l(e){t=Lt(e,"Next")},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function Xa(l){let t,e,s,i,n,r;return{c(){t=X("span"),e=Tt("svg"),s=Tt("polygon"),this.h()},l(a){t=Y(a,"SPAN",{role:!0,tabindex:!0,slot:!0,class:!0});var o=z(t);e=xt(o,"svg",{class:!0,xmlns:!0,viewBox:!0});var h=z(e);s=xt(h,"polygon",{points:!0}),z(s).forEach(C),h.forEach(C),o.forEach(C),this.h()},h(){y(s,"points",`16.172 9 10.101 2.929 11.515 1.515 20 10 19.293 10.707
                  11.515 18.485 10.101 17.071 16.172 11 0 11 0 9`),y(e,"class","icon"),y(e,"xmlns","http://www.w3.org/2000/svg"),y(e,"viewBox","0 0 20 20"),y(t,"role","button"),y(t,"tabindex","0"),y(t,"slot","activator"),y(t,"class",i="button-control "+(l[0]>=l[2]?"disabled":null))},m(a,o){tt(a,t,o),L(t,e),L(e,s),n||(r=[it(t,"click",l[44]),it(t,"keydown",l[39])],n=!0)},p(a,o){o[0]&5&&i!==(i="button-control "+(a[0]>=a[2]?"disabled":null))&&y(t,"class",i)},d(a){a&&C(t),n=!1,jt(r)}}}function Ei(l){let t,e,s,i;return t=new ne({props:{$$slots:{activator:[Ka],default:[Ya]},$$scope:{ctx:l}}}),s=new ne({props:{$$slots:{activator:[Za],default:[Qa]},$$scope:{ctx:l}}}),{c(){qt(t.$$.fragment),e=bt(),qt(s.$$.fragment)},l(n){$t(t.$$.fragment,n),e=vt(n),$t(s.$$.fragment,n)},m(n,r){Xt(t,n,r),tt(n,e,r),Xt(s,n,r),i=!0},p(n,r){const a={};r[0]&2|r[2]&128&&(a.$$scope={dirty:r,ctx:n}),t.$set(a);const o={};r[0]&2|r[2]&128&&(o.$$scope={dirty:r,ctx:n}),s.$set(o)},i(n){i||(V(t.$$.fragment,n),V(s.$$.fragment,n),i=!0)},o(n){st(t.$$.fragment,n),st(s.$$.fragment,n),i=!1},d(n){n&&C(e),Yt(t,n),Yt(s,n)}}}function Ya(l){let t;return{c(){t=Mt("Zoom In")},l(e){t=Lt(e,"Zoom In")},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function Ka(l){let t,e,s,i,n,r;return{c(){t=X("span"),e=Tt("svg"),s=Tt("path"),this.h()},l(a){t=Y(a,"SPAN",{role:!0,tabindex:!0,slot:!0,class:!0});var o=z(t);e=xt(o,"svg",{class:!0,xmlns:!0,viewBox:!0});var h=z(e);s=xt(h,"path",{"fill-rule":!0,d:!0}),z(s).forEach(C),h.forEach(C),o.forEach(C),this.h()},h(){y(s,"fill-rule","evenodd"),y(s,"d",`M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42
                  1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12zM7
                  7V5h2v2h2v2H9v2H7V9H5V7h2z`),y(e,"class","icon"),y(e,"xmlns","http://www.w3.org/2000/svg"),y(e,"viewBox","0 0 20 20"),y(t,"role","button"),y(t,"tabindex","0"),y(t,"slot","activator"),y(t,"class",i="button-control "+(l[1]>=Ms?"disabled":null))},m(a,o){tt(a,t,o),L(t,e),L(e,s),n||(r=[it(t,"click",l[45]),it(t,"keydown",l[38])],n=!0)},p(a,o){o[0]&2&&i!==(i="button-control "+(a[1]>=Ms?"disabled":null))&&y(t,"class",i)},d(a){a&&C(t),n=!1,jt(r)}}}function Qa(l){let t;return{c(){t=Mt("Zoom Out")},l(e){t=Lt(e,"Zoom Out")},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function Za(l){let t,e,s,i,n,r;return{c(){t=X("span"),e=Tt("svg"),s=Tt("path"),this.h()},l(a){t=Y(a,"SPAN",{role:!0,tabindex:!0,slot:!0,class:!0});var o=z(t);e=xt(o,"svg",{class:!0,xmlns:!0,viewBox:!0});var h=z(e);s=xt(h,"path",{"fill-rule":!0,d:!0}),z(s).forEach(C),h.forEach(C),o.forEach(C),this.h()},h(){y(s,"fill-rule","evenodd"),y(s,"d",`M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42
                  1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12zM5
                  7h6v2H5V7z`),y(e,"class","icon"),y(e,"xmlns","http://www.w3.org/2000/svg"),y(e,"viewBox","0 0 20 20"),y(t,"role","button"),y(t,"tabindex","0"),y(t,"slot","activator"),y(t,"class",i="button-control "+(l[1]<=Ps?"disabled":null))},m(a,o){tt(a,t,o),L(t,e),L(e,s),n||(r=[it(t,"click",l[46]),it(t,"keydown",l[37])],n=!0)},p(a,o){o[0]&2&&i!==(i="button-control "+(a[1]<=Ps?"disabled":null))&&y(t,"class",i)},d(a){a&&C(t),n=!1,jt(r)}}}function Si(l){let t,e;return t=new ne({props:{$$slots:{activator:[to],default:[Ja]},$$scope:{ctx:l}}}),{c(){qt(t.$$.fragment)},l(s){$t(t.$$.fragment,s)},m(s,i){Xt(t,s,i),e=!0},p(s,i){const n={};i[0]&8|i[2]&128&&(n.$$scope={dirty:i,ctx:s}),t.$set(n)},i(s){e||(V(t.$$.fragment,s),e=!0)},o(s){st(t.$$.fragment,s),e=!1},d(s){Yt(t,s)}}}function Ja(l){let t;return{c(){t=Mt("Print")},l(e){t=Lt(e,"Print")},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function to(l){let t,e=`<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M4 16H0V6h20v10h-4v4H4v-4zm2-4v6h8v-6H6zM4 0h12v5H4V0zM2
                  8v2h2V8H2zm4 0v2h2V8H6z"></path></svg>`,s,i;return{c(){t=X("span"),t.innerHTML=e,this.h()},l(n){t=Y(n,"SPAN",{role:!0,tabindex:!0,slot:!0,class:!0,"data-svelte-h":!0}),ge(t)!=="svelte-19y611v"&&(t.innerHTML=e),this.h()},h(){y(t,"role","button"),y(t,"tabindex","0"),y(t,"slot","activator"),y(t,"class","button-control")},m(n,r){tt(n,t,r),s||(i=[it(t,"click",l[47]),it(t,"keydown",l[36])],s=!0)},p:Gt,d(n){n&&C(t),s=!1,jt(i)}}}function Ci(l){let t,e,s,i;return t=new ne({props:{$$slots:{activator:[so],default:[eo]},$$scope:{ctx:l}}}),s=new ne({props:{$$slots:{activator:[no],default:[io]},$$scope:{ctx:l}}}),{c(){qt(t.$$.fragment),e=bt(),qt(s.$$.fragment)},l(n){$t(t.$$.fragment,n),e=vt(n),$t(s.$$.fragment,n)},m(n,r){Xt(t,n,r),tt(n,e,r),Xt(s,n,r),i=!0},p(n,r){const a={};r[2]&128&&(a.$$scope={dirty:r,ctx:n}),t.$set(a);const o={};r[2]&128&&(o.$$scope={dirty:r,ctx:n}),s.$set(o)},i(n){i||(V(t.$$.fragment,n),V(s.$$.fragment,n),i=!0)},o(n){st(t.$$.fragment,n),st(s.$$.fragment,n),i=!1},d(n){n&&C(e),Yt(t,n),Yt(s,n)}}}function eo(l){let t;return{c(){t=Mt("Anti-Clockwise")},l(e){t=Lt(e,"Anti-Clockwise")},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function so(l){let t,e=`<svg class="icon rot-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M14.66 15.66A8 8 0 1 1 17 10h-2a6 6 0 1 0-1.76 4.24l1.42
                  1.42zM12 10h8l-4 4-4-4z"></path></svg>`,s,i;return{c(){t=X("span"),t.innerHTML=e,this.h()},l(n){t=Y(n,"SPAN",{role:!0,tabindex:!0,slot:!0,class:!0,"data-svelte-h":!0}),ge(t)!=="svelte-tk6nke"&&(t.innerHTML=e),this.h()},h(){y(t,"role","button"),y(t,"tabindex","0"),y(t,"slot","activator"),y(t,"class","button-control")},m(n,r){tt(n,t,r),s||(i=[it(t,"click",l[48]),it(t,"keydown",l[35])],s=!0)},p:Gt,d(n){n&&C(t),s=!1,jt(i)}}}function io(l){let t;return{c(){t=Mt("Clockwise")},l(e){t=Lt(e,"Clockwise")},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function no(l){let t,e=`<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M14.66 15.66A8 8 0 1 1 17 10h-2a6 6 0 1 0-1.76 4.24l1.42
                  1.42zM12 10h8l-4 4-4-4z"></path></svg>`,s,i;return{c(){t=X("span"),t.innerHTML=e,this.h()},l(n){t=Y(n,"SPAN",{role:!0,tabindex:!0,slot:!0,class:!0,"data-svelte-h":!0}),ge(t)!=="svelte-10vh4p"&&(t.innerHTML=e),this.h()},h(){y(t,"role","button"),y(t,"tabindex","0"),y(t,"slot","activator"),y(t,"class","button-control")},m(n,r){tt(n,t,r),s||(i=[it(t,"click",l[49]),it(t,"keydown",l[34])],s=!0)},p:Gt,d(n){n&&C(t),s=!1,jt(i)}}}function Ti(l){let t,e;return t=new ne({props:{$$slots:{activator:[ao],default:[ro]},$$scope:{ctx:l}}}),{c(){qt(t.$$.fragment)},l(s){$t(t.$$.fragment,s)},m(s,i){Xt(t,s,i),e=!0},p(s,i){const n={};i[0]&24|i[2]&128&&(n.$$scope={dirty:i,ctx:s}),t.$set(n)},i(s){e||(V(t.$$.fragment,s),e=!0)},o(s){st(t.$$.fragment,s),e=!1},d(s){Yt(t,s)}}}function ro(l){let t;return{c(){t=Mt("Download")},l(e){t=Lt(e,"Download")},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function ao(l){let t,e='<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M13 8V2H7v6H2l8 8 8-8h-5zM0 18h20v2H0v-2z"></path></svg>',s,i;return{c(){t=X("span"),t.innerHTML=e,this.h()},l(n){t=Y(n,"SPAN",{role:!0,tabindex:!0,slot:!0,class:!0,"data-svelte-h":!0}),ge(t)!=="svelte-1sz9e7n"&&(t.innerHTML=e),this.h()},h(){y(t,"role","button"),y(t,"tabindex","0"),y(t,"slot","activator"),y(t,"class","button-control")},m(n,r){tt(n,t,r),s||(i=[it(t,"click",l[50]),it(t,"keydown",l[33])],s=!0)},p:Gt,d(n){n&&C(t),s=!1,jt(i)}}}function xi(l){let t,e;return t=new ne({props:{$$slots:{activator:[co],default:[oo]},$$scope:{ctx:l}}}),{c(){qt(t.$$.fragment)},l(s){$t(t.$$.fragment,s)},m(s,i){Xt(t,s,i),e=!0},p(s,i){const n={};i[0]&12288|i[2]&128&&(n.$$scope={dirty:i,ctx:s}),t.$set(n)},i(s){e||(V(t.$$.fragment,s),e=!0)},o(s){st(t.$$.fragment,s),e=!1},d(s){Yt(t,s)}}}function oo(l){let t=(l[12]===!0?l[13]:"Auto Turn Page")+"",e;return{c(){e=Mt(t)},l(s){e=Lt(s,t)},m(s,i){tt(s,e,i)},p(s,i){i[0]&12288&&t!==(t=(s[12]===!0?s[13]:"Auto Turn Page")+"")&&Fs(e,t)},d(s){s&&C(e)}}}function lo(l){let t;return{c(){t=Tt("path"),this.h()},l(e){t=xt(e,"path",{d:!0}),z(t).forEach(C),this.h()},h(){y(t,"d",`M9.896,3.838L0.792,1.562v14.794l9.104,2.276L19,16.356V1.562L9.896,3.838z
                    M9.327,17.332L1.93,15.219V3.27 l7.397,1.585V17.332z
                    M17.862,15.219l-7.397,2.113V4.855l7.397-1.585V15.219z`)},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function ho(l){let t;return{c(){t=Tt("path"),this.h()},l(e){t=xt(e,"path",{d:!0}),z(t).forEach(C),this.h()},h(){y(t,"d","M4 18h12V6h-4V2H4v16zm-2 1V0h12l4 4v16H2v-1z")},m(e,s){tt(e,t,s)},d(e){e&&C(t)}}}function co(l){let t,e,s,i;function n(o,h){return o[12]===!0?ho:lo}let r=n(l),a=r(l);return{c(){t=X("span"),e=Tt("svg"),a.c(),this.h()},l(o){t=Y(o,"SPAN",{role:!0,tabindex:!0,slot:!0,class:!0});var h=z(t);e=xt(h,"svg",{class:!0,xmlns:!0,viewBox:!0});var c=z(e);a.l(c),c.forEach(C),h.forEach(C),this.h()},h(){y(e,"class","icon"),y(e,"xmlns","http://www.w3.org/2000/svg"),y(e,"viewBox","0 0 20 20"),y(t,"role","button"),y(t,"tabindex","0"),y(t,"slot","activator"),y(t,"class","page-info button-control")},m(o,h){tt(o,t,h),L(t,e),a.m(e,null),s||(i=[it(t,"click",l[51]),it(t,"keydown",l[32])],s=!0)},p(o,h){r!==(r=n(o))&&(a.d(1),a=r(o),a&&(a.c(),a.m(e,null)))},d(o){o&&C(t),a.d(),s=!1,jt(i)}}}function ki(l){let t,e='<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M7 10v8h6v-8h5l-8-8-8 8h5z"></path></svg>',s,i;return{c(){t=X("button"),t.innerHTML=e,this.h()},l(n){t=Y(n,"BUTTON",{id:!0,"data-svelte-h":!0}),ge(t)!=="svelte-doxth2"&&(t.innerHTML=e),this.h()},h(){y(t,"id","topBtn")},m(n,r){tt(n,t,r),s||(i=it(t,"click",l[56]),s=!0)},p:Gt,d(n){n&&C(t),s=!1,i()}}}function uo(l){let t,e,s,i,n,r,a,o,h;Ii(l[41]);const c=[Wa,Va,ja],d=[];function u(f,g){return f[15]===!0?0:f[5].length?1:2}s=u(l),i=d[s]=c[s](l);let p=l[7]&&ki(l);return{c(){t=X("div"),e=X("div"),i.c(),r=bt(),p&&p.c(),this.h()},l(f){t=Y(f,"DIV",{class:!0});var g=z(t);e=Y(g,"DIV",{class:!0});var b=z(e);i.l(b),b.forEach(C),r=vt(g),p&&p.l(g),g.forEach(C),this.h()},h(){y(e,"class",n=l[6]===!0?"control":"null"),y(t,"class","parent")},m(f,g){tt(f,t,g),L(t,e),d[s].m(e,null),L(t,r),p&&p.m(t,null),a=!0,o||(h=it(Rs,"resize",l[41]),o=!0)},p(f,g){let b=s;s=u(f),s===b?d[s].p(f,g):(oe(),st(d[b],1,1,()=>{d[b]=null}),le(),i=d[s],i?i.p(f,g):(i=d[s]=c[s](f),i.c()),V(i,1),i.m(e,null)),(!a||g[0]&64&&n!==(n=f[6]===!0?"control":"null"))&&y(e,"class",n),f[7]?p?p.p(f,g):(p=ki(f),p.c(),p.m(t,null)):p&&(p.d(1),p=null)},i(f){a||(V(i),a=!0)},o(f){st(i),a=!1},d(f){f&&C(t),d[s].d(),p&&p.d(),o=!1,h()}}}const Ps=1,Ms=2.3;function fo(l,t,e){let{url:s}=t,{data:i}=t,{scale:n=1.8}=t,{pageNum:r=1}=t,{flipTime:a=120}=t,{showButtons:o=["navigation","zoom","print","rotate","download","autoflip","timeInfo","pageInfo"]}=t,{showBorder:h=!0}=t,{totalPage:c=0}=t,{downloadFileName:d=""}=t,{showTopButton:u=!0}=t;Pa.workerSrc=La;let p,f=0,g=0,b=null,m=!1,v=null,_=0,A="",E=0,w=!1,S,T,k=a,O=[],M="",G=!1,ot="",lt=!1;const rt=x=>{m=!0,b.getPage(x).then(function(re){let Qt=re.getViewport({scale:n,rotation:_});const hs=p.getContext("2d");e(8,p.height=Qt.height,p),e(8,p.width=Qt.width,p);let Cn={canvasContext:hs,viewport:Qt};re.render(Cn).promise.then(function(){if(m=!1,v!==null){if(r<b.totalPage)O[r]=p,e(0,r++,r),b.getPage(r).then(rt);else for(let cs=1;cs<O.length;cs++)p.appendChild(O[cs]);v=null}})}),o.length&&e(9,f.textContent=x,f)},J=x=>{m?v=x:rt(x)},P=()=>{r<=1||(e(0,r--,r),J(r))},I=()=>{r>=b.numPages||(e(0,r++,r),J(r))},St=()=>{n<=Ms&&(e(1,n=n+.1),J(r))},At=()=>{n>=Ps&&(e(1,n=n-.1),J(r))},Ot=x=>{Ia(x)},et=()=>{_=_+90,J(r)},B=()=>{_=_-90,J(r)},at=()=>{Z()},Z=async()=>{Ma({...s&&{url:s},...i&&{data:i},...M&&{password:M}}).promise.then(async function(re){if(b=re,e(15,G=!1),await xn(),o.length&&e(10,g.textContent=b.numPages,g),e(2,c=b.numPages),o.length)for(let Qt=1;Qt<=c;Qt++)Fa(Qt,b).then(function(hs){A=A.concat(hs),e(11,E=Da(A))});e(31,lt=!0)}).catch(function(re){e(15,G=!0),e(16,ot=re.message)})};Z();const Q=()=>{e(12,w=!w),w===!1&&(clearInterval(S),clearInterval(T)),w===!0&&r<=c&&(T=setInterval(()=>{e(13,k=k-1)},1e3),S=setInterval(()=>{e(13,k=a),I()},a*1e3))},H=({url:x,data:re})=>{let Qt=d||x&&x.substring(x.lastIndexOf("/")+1);Na({fileURL:x,data:re,name:Qt})};Tn(()=>{clearInterval(S),clearInterval(T)});let q,U;function $(x){Nt.call(this,l,x)}function mt(x){Nt.call(this,l,x)}function ye(x){Nt.call(this,l,x)}function Be(x){Nt.call(this,l,x)}function Te(x){Nt.call(this,l,x)}function we(x){Nt.call(this,l,x)}function ze(x){Nt.call(this,l,x)}function ue(x){Nt.call(this,l,x)}function Ue(x){Nt.call(this,l,x)}function hn(){e(17,q=Rs.innerWidth),e(18,U=Rs.innerHeight)}function cn(){M=this.value,e(14,M)}const dn=()=>P(),un=()=>I(),fn=()=>St(),pn=()=>At(),gn=()=>Ot(s),mn=()=>B(),bn=()=>et(),vn=()=>H({url:s,data:i}),An=()=>Q();function _n(x){je[x?"unshift":"push"](()=>{f=x,e(9,f)})}function yn(x){je[x?"unshift":"push"](()=>{g=x,e(10,g)})}function wn(x){je[x?"unshift":"push"](()=>{p=x,e(8,p)})}function En(x){je[x?"unshift":"push"](()=>{p=x,e(8,p)})}const Sn=()=>window.scrollTo(0,0);return l.$$set=x=>{"url"in x&&e(3,s=x.url),"data"in x&&e(4,i=x.data),"scale"in x&&e(1,n=x.scale),"pageNum"in x&&e(0,r=x.pageNum),"flipTime"in x&&e(29,a=x.flipTime),"showButtons"in x&&e(5,o=x.showButtons),"showBorder"in x&&e(6,h=x.showBorder),"totalPage"in x&&e(2,c=x.totalPage),"downloadFileName"in x&&e(30,d=x.downloadFileName),"showTopButton"in x&&e(7,u=x.showTopButton)},l.$$.update=()=>{l.$$.dirty[0]&1|l.$$.dirty[1]&1&&lt&&J(r)},[r,n,c,s,i,o,h,u,p,f,g,E,w,k,M,G,ot,q,U,P,I,St,At,Ot,et,B,at,Q,H,a,d,lt,$,mt,ye,Be,Te,we,ze,ue,Ue,hn,cn,dn,un,fn,pn,gn,mn,bn,vn,An,_n,yn,wn,En,Sn]}class po extends Is{constructor(t){super(),Ds(this,t,fo,uo,Ls,{url:3,data:4,scale:1,pageNum:0,flipTime:29,showButtons:5,showBorder:6,totalPage:2,downloadFileName:30,showTopButton:7},null,[-1,-1,-1])}}function go(l){let t,e;return t=new po({props:{url:"https://raw.githubusercontent.com/vinodnimbalkar/svelte-pdf/369db2f9edbf5ab8c87184193e1404340729bb3a/public/sample.pdf"}}),{c(){qt(t.$$.fragment)},l(s){$t(t.$$.fragment,s)},m(s,i){Xt(t,s,i),e=!0},p:Gt,i(s){e||(V(t.$$.fragment,s),e=!0)},o(s){st(t.$$.fragment,s),e=!1},d(s){Yt(t,s)}}}class _o extends Is{constructor(t){super(),Ds(this,t,null,go,Ls,{})}}export{_o as component};