revise 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +962 -0
- package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
- package/FONT-LICENSE-KATEX.txt +95 -0
- package/FONT-LICENSE-LIBERATION.txt +102 -0
- package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
- package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
- package/FONT-LICENSE-NOTO.txt +94 -0
- package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
- package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
- package/LICENSE +41 -21
- package/README.md +39 -1
- package/THIRD-PARTY-NOTICES.md +3376 -0
- package/assets/historyMaterializeWorker-CoAX9ZAi.js +3 -0
- package/backend.d.ts +133 -0
- package/backend.js +1 -0
- package/chunks/AgentPageRenderer-C0n4EnuW.js +1 -0
- package/chunks/AgentPageRenderer-DURfmiu0.js +1 -0
- package/chunks/AttachmentDocumentImporter-DSic_6At.js +1 -0
- package/chunks/AttachmentDocumentImporter-dNMtkxrv.js +1 -0
- package/chunks/BidiText-B4Hzrjg9.js +1 -0
- package/chunks/ColorParserFull-BKH72fK8.js +1 -0
- package/chunks/DocumentStylesheet-byN5dtC6.js +1 -0
- package/chunks/DocxConverter-B7P52lw7.js +11 -0
- package/chunks/DocxConverter-COV6CjUM.js +11 -0
- package/chunks/DocxConverter-Cq_zCEJC.js +11 -0
- package/chunks/DocxGraft-CJ12C9WP.js +1 -0
- package/chunks/DocxGraft-CQpvFcYb.js +1 -0
- package/chunks/DocxGraft-DcmFuUkd.js +1 -0
- package/chunks/FileImporter-DVnYOJHp.js +1 -0
- package/chunks/FileImporter-q9mCch0J.js +1 -0
- package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +1 -0
- package/chunks/HtmlConverter-JvRlkQM3.js +61 -0
- package/chunks/ListNumbering-Qlu6AuRZ.js +1 -0
- package/chunks/MarkdownConverter-B-tPY7X3.js +17 -0
- package/chunks/MathRenderer-B0Y1h1JU.js +33 -0
- package/chunks/OdtConverter-Br81BSoJ.js +1 -0
- package/chunks/OdtConverter-CQjh0vlo.js +1 -0
- package/chunks/OdtConverter-DYHnR4E8.js +1 -0
- package/chunks/PdfConverter-D26rXumc.js +21 -0
- package/chunks/PdfConverter-DGZpUSVf.js +21 -0
- package/chunks/PdfConverter-DZzVP0-B.js +21 -0
- package/chunks/PdfImportService-CBD8TL1k.js +2 -0
- package/chunks/PdfImportService-D6uUKGMf.js +2 -0
- package/chunks/RtfConverter-BQGge3K-.js +14 -0
- package/chunks/RtfConverter-CMfZ4olw.js +14 -0
- package/chunks/RtfConverter-oIwzoqCD.js +14 -0
- package/chunks/TableBorders-BLkZYt1k.js +1 -0
- package/chunks/TableGrid-DVWaRZv0.js +1 -0
- package/chunks/TextFileDecoder--rsVs3NR.js +2 -0
- package/chunks/TxtConverter-C1lp6dBS.js +11 -0
- package/chunks/__vite-browser-external-l0sNRNKZ.js +0 -0
- package/chunks/_commonjsHelpers-DaMA6jEr.js +1 -0
- package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -0
- package/chunks/_revise-sdk-lazy-harfbuzz-X8gnYTZL.js +1 -0
- package/chunks/ar-kgSWdrXF.js +8 -0
- package/chunks/backend-Cq-khfdG.js +1 -0
- package/chunks/base64-CfDUyGi8.js +36 -0
- package/chunks/browser-module-6b2Fq-5C.js +3 -0
- package/chunks/browser-module-CFmqfGkE.js +3 -0
- package/chunks/browser-module-CkO57IPL.js +3 -0
- package/chunks/bundle.min-DRpfgV69.js +8 -0
- package/chunks/capture-DU3MC7tb.js +1 -0
- package/chunks/carrier-WgcRSu7a.js +1 -0
- package/chunks/de-C2QTHrqo.js +8 -0
- package/chunks/es-BKboUn4q.js +8 -0
- package/chunks/footnoteFlatten-CW-DUcgK.js +1 -0
- package/chunks/graftExport-CVg7PO2A.js +2 -0
- package/chunks/html2canvas.esm-CntiHiYW.js +5 -0
- package/chunks/index-BWdRWxoH.js +24 -0
- package/chunks/index-CLw_BlSL.js +353 -0
- package/chunks/index-F-kHIwWT.js +353 -0
- package/chunks/index.es-CI0QPo8w.js +5 -0
- package/chunks/index.es-DOqegDGr.js +5 -0
- package/chunks/index.es-tXDO0RMv.js +5 -0
- package/chunks/jspdf.es.min-CzYti8jo.js +77 -0
- package/chunks/jspdf.es.min-DU74zN8b.js +77 -0
- package/chunks/jspdf.es.min-ejWOGhkJ.js +77 -0
- package/chunks/jszip.min-CPW0h1Kx.js +2 -0
- package/chunks/katex-DWj8TvwO.js +261 -0
- package/chunks/pdf-BLWDCiFF.js +12 -0
- package/chunks/persistInlineDocumentImages-DQj2iaqg.js +1 -0
- package/chunks/pseudoLocale-CdBtPHRi.js +1 -0
- package/chunks/pseudoLocale-DEVWLkGC.js +1 -0
- package/chunks/purify.es-BwLardii.js +2 -0
- package/chunks/serverDocumentSession-DZrYbdpk.js +42 -0
- package/chunks/tree-sitter-D6zWWUMP.js +4 -0
- package/chunks/wasmInline.generated-CBYFkdSM.js +1 -0
- package/chunks/web-tree-sitter-BXGZGnNj.js +1 -0
- package/full.js +1 -0
- package/index.d.ts +929 -0
- package/index.js +1 -0
- package/package.json +93 -26
- package/root.d.ts +5 -0
- package/root.js +2 -0
- package/serverToolContract.d.ts +373 -0
- package/serverToolInputs.generated.d.ts +229 -0
- package/style.css +1 -0
- package/.npmignore +0 -4
- package/.travis.yml +0 -16
- package/revise.js +0 -16
- package/t/cover +0 -18
- package/t/revise/comparator.t.js +0 -31
- package/t/revise/extractor.t.js +0 -29
- package/t/test +0 -20
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var cf=Object.defineProperty,nu=r=>{throw TypeError(r)},df=(r,t,e)=>t in r?cf(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,C=(r,t,e)=>df(r,typeof t!="symbol"?t+"":t,e),cc=(r,t,e)=>t.has(r)||nu("Cannot "+e),n=(r,t,e)=>(cc(r,t,"read from private field"),e?e.call(r):t.get(r)),f=(r,t,e)=>t.has(r)?nu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),p=(r,t,e,s)=>(cc(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e),m=(r,t,e)=>(cc(r,t,"access private method"),e),Zt=(r,t,e,s)=>({set _(i){p(r,t,i,e)},get _(){return n(r,t,s)}});const Xt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),dc=[.001,0,0,.001,0,0],uc=1.35,oe={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},cs={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},uf="pdfjs_internal_editor_",$={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101},j={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},au={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Bt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},$a={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},dt={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},Sn={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Ga={ERRORS:0,WARNINGS:1,INFOS:5},za={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},Wo={moveTo:0,lineTo:1,curveTo:2,closePath:3},ru={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Bo=Ga.WARNINGS;function pf(r){Number.isInteger(r)&&(Bo=r)}function gf(){return Bo}function Ho(r){Bo>=Ga.INFOS&&`${r}`}function G(r){Bo>=Ga.WARNINGS&&`${r}`}function Y(r){throw new Error(r)}function ft(r,t){r||Y(t)}function ff(r){switch(r?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function pc(r,t=null,e=null){if(!r)return null;if(e&&typeof r=="string"&&(e.addDefaultProtocol&&r.startsWith("www.")&&r.match(/\./g)?.length>=2&&(r=`http://${r}`),e.tryConvertEncoding))try{r=vf(r)}catch{}const s=t?URL.parse(r,t):URL.parse(r);return ff(s)?s:null}function gc(r,t,e=!1){const s=URL.parse(r);return s?(s.hash=t,s.href):e&&pc(r,"http://example.com")?r.split("#",1)[0]+`${t?`#${t}`:""}`:""}function z(r,t,e,s=!1){return Object.defineProperty(r,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Mi=function(){function r(t,e){this.message=t,this.name=e}return r.prototype=new Error,r.constructor=r,r}();class ou extends Mi{constructor(t,e){super(t,"PasswordException"),this.code=e}}class fc extends Mi{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class $o extends Mi{constructor(t){super(t,"InvalidPDFException")}}class Ua extends Mi{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class mf extends Mi{constructor(t){super(t,"FormatError")}}class ds extends Mi{constructor(t){super(t,"AbortException")}}function hu(r){(typeof r!="object"||r?.length===void 0)&&Y("Invalid argument for bytesToString");const t=r.length,e=8192;if(t<e)return String.fromCharCode.apply(null,r);const s=[];for(let i=0;i<t;i+=e){const a=Math.min(i+e,t),o=r.subarray(i,a);s.push(String.fromCharCode.apply(null,o))}return s.join("")}function ja(r){typeof r!="string"&&Y("Invalid argument for stringToBytes");const t=r.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=r.charCodeAt(s)&255;return e}function wf(r){return String.fromCharCode(r>>24&255,r>>16&255,r>>8&255,r&255)}function bf(){const r=new Uint8Array(4);return r[0]=1,new Uint32Array(r.buffer,0,1)[0]===1}function Af(){try{return new Function(""),!0}catch{return!1}}class Mt{static get isLittleEndian(){return z(this,"isLittleEndian",bf())}static get isEvalSupported(){return z(this,"isEvalSupported",Af())}static get isOffscreenCanvasSupported(){return z(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return z(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return z(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return z(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const mc=Array.from(Array(256).keys(),r=>r.toString(16).padStart(2,"0"));var ki,Go,wc;class L{static makeHexColor(t,e,s){return`#${mc[t]}${mc[e]}${mc[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,s=0){const i=t[s],a=t[s+1];t[s]=i*e[0]+a*e[2]+e[4],t[s+1]=i*e[1]+a*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],a=e[1],o=e[2],h=e[3],l=e[4],d=e[5];for(let c=0;c<6;c+=2){const u=t[s+c],g=t[s+c+1];t[s+c]=u*i+g*o+l,t[s+c+1]=u*a+g*h+d}}static applyInverseTransform(t,e){const s=t[0],i=t[1],a=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/a,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/a}static axialAlignedBoundingBox(t,e,s){const i=e[0],a=e[1],o=e[2],h=e[3],l=e[4],d=e[5],c=t[0],u=t[1],g=t[2],w=t[3];let b=i*c+l,A=b,v=i*g+l,y=v,S=h*u+d,_=S,x=h*w+d,E=x;if(a!==0||o!==0){const M=a*c,k=a*g,T=o*u,R=o*w;b+=T,y+=T,v+=R,A+=R,S+=M,E+=M,x+=k,_+=k}s[0]=Math.min(s[0],b,v,A,y),s[1]=Math.min(s[1],S,x,_,E),s[2]=Math.max(s[2],b,v,A,y),s[3]=Math.max(s[3],S,x,_,E)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const s=t[0],i=t[1],a=t[2],o=t[3],h=s**2+i**2,l=s*a+i*o,d=a**2+o**2,c=(h+d)/2,u=Math.sqrt(c**2-(h*d-l**2));e[0]=Math.sqrt(c+u||1),e[1]=Math.sqrt(c-u||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const 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 a=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),o=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return a>o?null:[s,a,i,o]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,a){a[0]=Math.min(a[0],t,s),a[1]=Math.min(a[1],e,i),a[2]=Math.max(a[2],t,s),a[3]=Math.max(a[3],e,i)}static bezierBoundingBox(t,e,s,i,a,o,h,l,d){d[0]=Math.min(d[0],t,h),d[1]=Math.min(d[1],e,l),d[2]=Math.max(d[2],t,h),d[3]=Math.max(d[3],e,l),m(this,ki,wc).call(this,t,s,a,h,e,i,o,l,3*(-t+3*(s-a)+h),6*(t-2*s+a),3*(s-t),d),m(this,ki,wc).call(this,t,s,a,h,e,i,o,l,3*(-e+3*(i-o)+l),6*(e-2*i+o),3*(i-e),d)}}ki=new WeakSet,Go=function(r,t,e,s,i,a,o,h,l,d){if(l<=0||l>=1)return;const c=1-l,u=l*l,g=u*l,w=c*(c*(c*r+3*l*t)+3*u*e)+g*s,b=c*(c*(c*i+3*l*a)+3*u*o)+g*h;d[0]=Math.min(d[0],w),d[1]=Math.min(d[1],b),d[2]=Math.max(d[2],w),d[3]=Math.max(d[3],b)},wc=function(r,t,e,s,i,a,o,h,l,d,c,u){if(Math.abs(l)<1e-12){Math.abs(d)>=1e-12&&m(this,ki,Go).call(this,r,t,e,s,i,a,o,h,-c/d,u);return}const g=d**2-4*c*l;if(g<0)return;const w=Math.sqrt(g),b=2*l;m(this,ki,Go).call(this,r,t,e,s,i,a,o,h,(-d+w)/b,u),m(this,ki,Go).call(this,r,t,e,s,i,a,o,h,(-d-w)/b,u)},f(L,ki);function vf(r){return decodeURIComponent(escape(r))}let bc=null,lu=null;function cu(r){return bc||(bc=/([\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,lu=new Map([["ſt","ſt"]])),r.replaceAll(bc,(t,e,s)=>e?e.normalize("NFKC"):lu.get(s))}function Ac(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const r=new Uint8Array(32);return crypto.getRandomValues(r),hu(r)}const vc="pdfjs_internal_id_";function yf(r,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...a]=e;if(!r(s)&&!Number.isInteger(s)||!t(i))return!1;const o=a.length;let h=!0;switch(i.name){case"XYZ":if(o<2||o>3)return!1;break;case"Fit":case"FitB":return o===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(o>1)return!1;break;case"FitR":if(o!==4)return!1;h=!1;break;default:return!1}for(const l of a)if(!(typeof l=="number"||h&&l===null))return!1;return!0}function Ht(r,t,e){return Math.min(Math.max(r,t),e)}function du(r){return Uint8Array.prototype.toBase64?r.toBase64():btoa(hu(r))}function _f(r){return Uint8Array.fromBase64?Uint8Array.fromBase64(r):ja(atob(r))}typeof Promise.try!="function"&&(Promise.try=function(r,...t){return new Promise(e=>{e(r(...t))})}),typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(r){return r.reduce((t,e)=>t+e,0)});const us="http://www.w3.org/2000/svg",xn=class{};C(xn,"CSS",96),C(xn,"PDF",72),C(xn,"PDF_TO_CSS_UNITS",xn.CSS/xn.PDF);let Ci=xn;async function En(r,t="text"){if(qa(r,document.baseURI)){const e=await fetch(r);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",r,!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 Fo{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:a=0,offsetY:o=0,dontFlip:h=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=a,this.offsetY=o,s*=e;const l=(t[2]+t[0])/2,d=(t[3]+t[1])/2;let c,u,g,w;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,u=0,g=0,w=1;break;case 90:c=0,u=1,g=1,w=0;break;case 270:c=0,u=-1,g=-1,w=0;break;case 0:c=1,u=0,g=0,w=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}h&&(g=-g,w=-w);let b,A,v,y;c===0?(b=Math.abs(d-t[1])*s+a,A=Math.abs(l-t[0])*s+o,v=(t[3]-t[1])*s,y=(t[2]-t[0])*s):(b=Math.abs(l-t[0])*s+a,A=Math.abs(d-t[1])*s+o,v=(t[2]-t[0])*s,y=(t[3]-t[1])*s),this.transform=[c*s,u*s,g*s,w*s,b-c*s*l-g*s*d,A-u*s*l-w*s*d],this.width=v,this.height=y}get rawDims(){const t=this.viewBox;return z(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:a=!1}={}){return new Fo({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:a})}convertToViewportPoint(t,e){const s=[t,e];return L.applyTransform(s,this.transform),s}convertToViewportRectangle(t){const e=[t[0],t[1]];L.applyTransform(e,this.transform);const s=[t[2],t[3]];return L.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];return L.applyInverseTransform(s,this.transform),s}}class zo extends Mi{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Va(r){const t=r.length;let e=0;for(;e<t&&r[e].trim()==="";)e++;return r.substring(e,e+5).toLowerCase()==="data:"}function Uo(r){return typeof r=="string"&&/\.pdf$/i.test(r)}function uu(r){return[r]=r.split(/[#?]/,1),r.substring(r.lastIndexOf("/")+1)}function pu(r,t="document.pdf"){if(typeof r!="string")return t;if(Va(r))return G('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(r);let a=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(a&&(a=a[0],a.includes("%")))try{a=s.exec(decodeURIComponent(a))[0]}catch{}return a||t}class gu{constructor(){C(this,"started",Object.create(null)),C(this,"times",[])}time(t){t in this.started&&G(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||G(`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:a}of this.times)t.push(`${s.padEnd(e)} ${a-i}ms
|
|
2
|
+
`);return t.join("")}}function qa(r,t){const e=t?URL.parse(r,t):URL.parse(r);return e?.protocol==="http:"||e?.protocol==="https:"}function me(r){r.preventDefault()}function ut(r){r.preventDefault(),r.stopPropagation()}function Sf(r){""+r}var Xa;class jo{static toDateObject(t){if(!t||typeof t!="string")return null;n(this,Xa)||p(this,Xa,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,Xa).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 a=parseInt(e[3],10);a=a>=1&&a<=31?a:1;let o=parseInt(e[4],10);o=o>=0&&o<=23?o:0;let h=parseInt(e[5],10);h=h>=0&&h<=59?h:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const d=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,d==="-"?(o+=c,h+=u):d==="+"&&(o-=c,h-=u),new Date(Date.UTC(s,i,a,o,h,l))}}Xa=new WeakMap,f(jo,Xa);function fu(r,{scale:t=1,rotation:e=0}){const{width:s,height:i}=r.attributes.style,a=[0,0,parseInt(s),parseInt(i)];return new Fo({viewBox:a,userUnit:1,scale:t,rotation:e})}function yc(r){if(r.startsWith("#")){const t=parseInt(r.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return r.startsWith("rgb(")?r.slice(4,-1).split(",").map(t=>parseInt(t)):r.startsWith("rgba(")?r.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(G(`Not a valid color format: "${r}"`),[0,0,0])}function xf(r){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of r.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;r.set(e,yc(s))}t.remove()}function rt(r){const{a:t,b:e,c:s,d:i,e:a,f:o}=r.getTransform();return[t,e,s,i,a,o]}function ze(r){const{a:t,b:e,c:s,d:i,e:a,f:o}=r.getTransform().invertSelf();return[t,e,s,i,a,o]}function Bs(r,t,e=!1,s=!0){if(t instanceof Fo){const{pageWidth:i,pageHeight:a}=t.rawDims,{style:o}=r,h=Mt.isCSSRoundSupported,l=`var(--total-scale-factor) * ${i}px`,d=`var(--total-scale-factor) * ${a}px`,c=h?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,u=h?`round(down, ${d}, var(--scale-round-y))`:`calc(${d})`;!e||t.rotation%180===0?(o.width=c,o.height=u):(o.width=u,o.height=c)}s&&r.setAttribute("data-main-rotation",t.rotation)}class Ge{constructor(){const{pixelRatio:t}=Ge;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,a=-1){let o=1/0,h=1/0,l=1/0;s=Ge.capPixels(s,a),s>0&&(o=Math.sqrt(s/(t*e))),i!==-1&&(h=i/t,l=i/e);const d=Math.min(o,h,l);return this.sx>d||this.sy>d?(this.sx=d,this.sy=d,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const Vo=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];var Ti,Mn,De,Ri,qo,Ka,Ya,_c,mu,we,wu,bu,Qa,Au,Xo;const Ko=class rc{constructor(t){f(this,we),f(this,Ti,null),f(this,Mn,null),f(this,De),f(this,Ri,null),f(this,qo,null),f(this,Ka,null),p(this,De,t),n(rc,Ya)||p(rc,Ya,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const t=p(this,Ti,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,De)._uiManager._signal;t.addEventListener("contextmenu",me,{signal:e}),t.addEventListener("pointerdown",m(rc,_c,mu),{signal:e});const s=p(this,Ri,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,De).toolbarPosition;if(i){const{style:a}=t,o=n(this,De)._uiManager.direction==="ltr"?1-i[0]:i[0];a.insetInlineEnd=`${100*o}%`,a.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return m(this,we,Au).call(this),t}get div(){return n(this,Ti)}hide(){n(this,Ti).classList.add("hidden"),n(this,Mn)?.hideDropdown()}show(){n(this,Ti).classList.remove("hidden"),n(this,qo)?.shown()}async addAltText(t){const e=await t.render();m(this,we,Qa).call(this,e),n(this,Ri).prepend(e,n(this,we,Xo)),p(this,qo,t)}addColorPicker(t){p(this,Mn,t);const e=t.renderButton();m(this,we,Qa).call(this,e),n(this,Ri).prepend(e,n(this,we,Xo))}async addEditSignatureButton(t){const e=p(this,Ka,await t.renderEditButton(n(this,De)));m(this,we,Qa).call(this,e),n(this,Ri).prepend(e,n(this,we,Xo))}updateEditSignatureButton(t){n(this,Ka)&&(n(this,Ka).title=t)}remove(){n(this,Ti).remove(),n(this,Mn)?.destroy(),p(this,Mn,null)}};Ti=new WeakMap,Mn=new WeakMap,De=new WeakMap,Ri=new WeakMap,qo=new WeakMap,Ka=new WeakMap,Ya=new WeakMap,_c=new WeakSet,mu=function(r){r.stopPropagation()},we=new WeakSet,wu=function(r){n(this,De)._focusEventsAllowed=!1,ut(r)},bu=function(r){n(this,De)._focusEventsAllowed=!0,ut(r)},Qa=function(r){const t=n(this,De)._uiManager._signal;r.addEventListener("focusin",m(this,we,wu).bind(this),{capture:!0,signal:t}),r.addEventListener("focusout",m(this,we,bu).bind(this),{capture:!0,signal:t}),r.addEventListener("contextmenu",me,{signal:t})},Au=function(){const{editorType:r,_uiManager:t}=n(this,De),e=document.createElement("button");e.className="delete",e.tabIndex=0,e.setAttribute("data-l10n-id",n(Ko,Ya)[r]),m(this,we,Qa).call(this,e),e.addEventListener("click",s=>{t.delete()},{signal:t._signal}),n(this,Ri).append(e)},Xo=function(){const r=document.createElement("div");return r.className="divider",r},f(Ko,_c),f(Ko,Ya,null);let Ef=Ko;var Yo,Pi,kn,Ja,vu,yu,_u;class Mf{constructor(t){f(this,Ja),f(this,Yo,null),f(this,Pi,null),f(this,kn),p(this,kn,t)}show(t,e,s){const[i,a]=m(this,Ja,yu).call(this,e,s),{style:o}=n(this,Pi)||p(this,Pi,m(this,Ja,vu).call(this));t.append(n(this,Pi)),o.insetInlineEnd=`${100*i}%`,o.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,Pi).remove()}}Yo=new WeakMap,Pi=new WeakMap,kn=new WeakMap,Ja=new WeakSet,vu=function(){const r=p(this,Pi,document.createElement("div"));r.className="editToolbar",r.setAttribute("role","toolbar"),r.addEventListener("contextmenu",me,{signal:n(this,kn)._signal});const t=p(this,Yo,document.createElement("div"));return t.className="buttons",r.append(t),m(this,Ja,_u).call(this),r},yu=function(r,t){let e=0,s=0;for(const i of r){const a=i.y+i.height;if(a<e)continue;const o=i.x+(t?i.width:0);if(a>e){s=o,e=a;continue}t?o>s&&(s=o):o<s&&(s=o)}return[t?1-s:s,e]},_u=function(){const r=document.createElement("button");r.className="highlightButton",r.tabIndex=0,r.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const t=document.createElement("span");r.append(t),t.className="visuallyHidden",t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const e=n(this,kn)._signal;r.addEventListener("contextmenu",me,{signal:e}),r.addEventListener("click",()=>{n(this,kn).highlightSelection("floating_button")},{signal:e}),n(this,Yo).append(r)};function Su(r,t,e){for(const s of e)t.addEventListener(s,r[s].bind(r))}var Sc;class kf{constructor(){f(this,Sc,0)}get id(){return`${uf}${Zt(this,Sc)._++}`}}Sc=new WeakMap;var Za,Qo,At,tr,Jo;const xu=class{constructor(){f(this,tr),f(this,Za,Ac()),f(this,Qo,0),f(this,At,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>',e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),s=new Image;s.src=t;const i=s.decode().then(()=>(e.drawImage(s,0,0,1,1,0,0,1,3),new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]===0));return z(this,"_isSVGFittingCanvas",i)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:a}=t;return m(this,tr,Jo).call(this,`${e}_${s}_${i}_${a}`,t)}async getFromUrl(t){return m(this,tr,Jo).call(this,t,t)}async getFromBlob(t,e){const s=await e;return m(this,tr,Jo).call(this,t,s)}async getFromId(t){n(this,At)||p(this,At,new Map);const e=n(this,At).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){n(this,At)||p(this,At,new Map);let s=n(this,At).get(t);if(s?.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${n(this,Za)}_${Zt(this,Qo)._++}`,refCounter:1,isSvg:!1},n(this,At).set(t,s),n(this,At).set(s.id,s),s}getSvgUrl(t){const e=n(this,At).get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){n(this,At)||p(this,At,new Map);const e=n(this,At).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,Za)}_`)}};Za=new WeakMap,Qo=new WeakMap,At=new WeakMap,tr=new WeakSet,Jo=async function(r,t){n(this,At)||p(this,At,new Map);let e=n(this,At).get(r);if(e===null)return null;if(e?.bitmap)return e.refCounter+=1,e;try{e||(e={bitmap:null,id:`image_${n(this,Za)}_${Zt(this,Qo)._++}`,refCounter:0,isSvg:!1});let s;if(typeof t=="string"?(e.url=t,s=await En(t,"blob")):t instanceof File?s=e.file=t:t instanceof Blob&&(s=t),s.type==="image/svg+xml"){const i=xu._isSVGFittingCanvas,a=new FileReader,o=new Image,h=new Promise((l,d)=>{o.onload=()=>{e.bitmap=o,e.isSvg=!0,l()},a.onload=async()=>{const c=e.svgUrl=a.result;o.src=await i?`${c}#svgView(preserveAspectRatio(none))`:c},o.onerror=a.onerror=d});a.readAsDataURL(s),await h}else e.bitmap=await createImageBitmap(s);e.refCounter=1}catch(s){G(s),e=null}return n(this,At).set(r,e),e&&n(this,At).set(e.id,e),e};let Cf=xu;var mt,Ii,Zo,it;class Tf{constructor(t=128){f(this,mt,[]),f(this,Ii,!1),f(this,Zo),f(this,it,-1),p(this,Zo,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:a=NaN,overwriteIfSameType:o=!1,keepUndo:h=!1}){if(i&&t(),n(this,Ii))return;const l={cmd:t,undo:e,post:s,type:a};if(n(this,it)===-1){n(this,mt).length>0&&(n(this,mt).length=0),p(this,it,0),n(this,mt).push(l);return}if(o&&n(this,mt)[n(this,it)].type===a){h&&(l.undo=n(this,mt)[n(this,it)].undo),n(this,mt)[n(this,it)]=l;return}const d=n(this,it)+1;d===n(this,Zo)?n(this,mt).splice(0,1):(p(this,it,d),d<n(this,mt).length&&n(this,mt).splice(d)),n(this,mt).push(l)}undo(){if(n(this,it)===-1)return;p(this,Ii,!0);const{undo:t,post:e}=n(this,mt)[n(this,it)];t(),e?.(),p(this,Ii,!1),p(this,it,n(this,it)-1)}redo(){if(n(this,it)<n(this,mt).length-1){p(this,it,n(this,it)+1),p(this,Ii,!0);const{cmd:t,post:e}=n(this,mt)[n(this,it)];t(),e?.(),p(this,Ii,!1)}}hasSomethingToUndo(){return n(this,it)!==-1}hasSomethingToRedo(){return n(this,it)<n(this,mt).length-1}cleanType(t){if(n(this,it)!==-1){for(let e=n(this,it);e>=0;e--)if(n(this,mt)[e].type!==t){n(this,mt).splice(e+1,n(this,it)-e),p(this,it,e);return}n(this,mt).length=0,p(this,it,-1)}}destroy(){p(this,mt,null)}}mt=new WeakMap,Ii=new WeakMap,Zo=new WeakMap,it=new WeakMap;var xc,Eu;class er{constructor(t){f(this,xc),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Mt.platform;for(const[s,i,a={}]of t)for(const o of s){const h=o.startsWith("mac+");e&&h?(this.callbacks.set(o.slice(4),{callback:i,options:a}),this.allKeys.add(o.split("+").at(-1))):!e&&!h&&(this.callbacks.set(o,{callback:i,options:a}),this.allKeys.add(o.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(m(this,xc,Eu).call(this,e));if(!s)return;const{callback:i,options:{bubbles:a=!1,args:o=[],checker:h=null}}=s;h&&!h(t,e)||(i.bind(t,...o,e)(),a||ut(e))}}xc=new WeakSet,Eu=function(r){r.altKey&&this.buffer.push("alt"),r.ctrlKey&&this.buffer.push("ctrl"),r.metaKey&&this.buffer.push("meta"),r.shiftKey&&this.buffer.push("shift"),this.buffer.push(r.key);const t=this.buffer.join("+");return this.buffer.length=0,t};const Mu=class Zg{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return xf(t),z(this,"_colors",t)}convert(t){const e=yc(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((a,o)=>a===e[o]))return Zg._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?L.makeHexColor(...e):t}};C(Mu,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Rf=Mu;var sr,be,kt,$t,ir,Hs,Cn,Ne,Li,Di,nr,Tn,ps,Ue,Rn,th,eh,ar,sh,gs,Ni,rr,Fi,je,Ec,Oi,ih,Wi,Pn,In,$s,nh,Tt,Q,Gs,Bi,Ln,or,ah,Hi,fs,zs,rh,Fe,N,oh,Mc,ku,Cu,hh,Tu,Ru,Pu,kc,Iu,Cc,Tc,Lu,Kt,ms,Du,Nu,Rc,Fu,hr,Pc;const Ic=class Zd{constructor(t,e,s,i,a,o,h,l,d,c,u,g,w,b){f(this,N),f(this,sr,new AbortController),f(this,be,null),f(this,kt,new Map),f(this,$t,new Map),f(this,ir,null),f(this,Hs,null),f(this,Cn,null),f(this,Ne,new Tf),f(this,Li,null),f(this,Di,null),f(this,nr,0),f(this,Tn,new Set),f(this,ps,null),f(this,Ue,null),f(this,Rn,new Set),C(this,"_editorUndoBar",null),f(this,th,!1),f(this,eh,!1),f(this,ar,!1),f(this,sh,null),f(this,gs,null),f(this,Ni,null),f(this,rr,null),f(this,Fi,!1),f(this,je,null),f(this,Ec,new kf),f(this,Oi,!1),f(this,ih,!1),f(this,Wi,null),f(this,Pn,null),f(this,In,null),f(this,$s,null),f(this,nh,null),f(this,Tt,$.NONE),f(this,Q,new Set),f(this,Gs,null),f(this,Bi,null),f(this,Ln,null),f(this,or,null),f(this,ah,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),f(this,Hi,[0,0]),f(this,fs,null),f(this,zs,null),f(this,rh,null),f(this,Fe,null);const A=this._signal=n(this,sr).signal;p(this,zs,t),p(this,rh,e),p(this,ir,s),p(this,Bi,i),this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:A}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:A}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:A}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:A}),a._on("setpreference",this.onSetPreference.bind(this),{signal:A}),a._on("switchannotationeditorparams",v=>this.updateParams(v.type,v.value),{signal:A}),m(this,N,Tu).call(this),m(this,N,Lu).call(this),m(this,N,kc).call(this),p(this,Hs,o.annotationStorage),p(this,sh,o.filterFactory),p(this,Ln,h),p(this,rr,l||null),p(this,th,d),p(this,eh,c),p(this,ar,u),p(this,nh,g||null),this.viewParameters={realScale:Ci.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=w||null,this._supportsPinchToZoom=b!==!1}static get _keyboardManager(){const t=Zd.prototype,e=o=>n(o,zs).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&o.hasSomethingToControl(),s=(o,{target:h})=>{if(h instanceof HTMLInputElement){const{type:l}=h;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return z(this,"_keyboardManager",new er([[["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:(o,{target:h})=>!(h instanceof HTMLButtonElement)&&n(o,zs).contains(h)&&!o.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(o,{target:h})=>!(h instanceof HTMLButtonElement)&&n(o,zs).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:[-a,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:e}]]))}destroy(){n(this,Fe)?.resolve(),p(this,Fe,null),n(this,sr)?.abort(),p(this,sr,null),this._signal=null;for(const t of n(this,$t).values())t.destroy();n(this,$t).clear(),n(this,kt).clear(),n(this,Rn).clear(),n(this,$s)?.clear(),p(this,be,null),n(this,Q).clear(),n(this,Ne).destroy(),n(this,ir)?.destroy(),n(this,Bi)?.destroy(),n(this,je)?.hide(),p(this,je,null),n(this,In)?.destroy(),p(this,In,null),n(this,gs)&&(clearTimeout(n(this,gs)),p(this,gs,null)),n(this,fs)&&(clearTimeout(n(this,fs)),p(this,fs,null)),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,nh)}get useNewAltTextFlow(){return n(this,eh)}get useNewAltTextWhenAddingImage(){return n(this,ar)}get hcmFilter(){return z(this,"hcmFilter",n(this,Ln)?n(this,sh).addHCMFilter(n(this,Ln).foreground,n(this,Ln).background):"none")}get direction(){return z(this,"direction",getComputedStyle(n(this,zs)).direction)}get highlightColors(){return z(this,"highlightColors",n(this,rr)?new Map(n(this,rr).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return z(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),p(this,Di,t)}setMainHighlightColorPicker(t){p(this,In,t)}editAltText(t,e=!1){n(this,ir)?.editAltText(this,t,e)}getSignature(t){n(this,Bi)?.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,Bi)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,ar,e);break}}onPageChanging({pageNumber:t}){p(this,nr,t-1)}focusMainContainer(){n(this,zs).focus()}findParent(t,e){for(const s of n(this,$t).values()){const{x:i,y:a,width:o,height:h}=s.div.getBoundingClientRect();if(t>=i&&t<=i+o&&e>=a&&e<=a+h)return s}return null}disableUserSelect(t=!1){n(this,rh).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,Rn).add(t)}removeShouldRescale(t){n(this,Rn).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Ci.PDF_TO_CSS_UNITS;for(const e of n(this,Rn))e.onScaleChanging();n(this,Di)?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:a,focusOffset:o}=e,h=e.toString(),l=m(this,N,oh).call(this,e).closest(".textLayer"),d=this.getSelectionBoxes(l);if(!d)return;e.empty();const c=m(this,N,Mc).call(this,l),u=n(this,Tt)===$.NONE,g=()=>{c?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:s,anchorOffset:i,focusNode:a,focusOffset:o,text:h}),u&&this.showAllEditors("highlight",!0,!0)};if(u){this.switchToMode($.HIGHLIGHT,g);return}g()}addToAnnotationStorage(t){!t.isEmpty()&&n(this,Hs)&&!n(this,Hs).has(t.id)&&n(this,Hs).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,n(this,Fi)&&(p(this,Fi,!1),m(this,N,hh).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,Q))if(e.div.contains(t)){p(this,Pn,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,Pn))return;const[t,e]=n(this,Pn);p(this,Pn,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){m(this,N,kc).call(this),m(this,N,Cc).call(this)}removeEditListeners(){m(this,N,Iu).call(this),m(this,N,Tc).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,Ue))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of n(this,Ue))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),n(this,be)?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of n(this,Q)){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()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const a of e.items)for(const o of n(this,Ue))if(o.isHandlingMimeForPasting(a.type)){o.paste(a,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(a){G(`paste: "${a.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const a=[];for(const l of s){const d=await i.deserialize(l);if(!d)return;a.push(d)}const o=()=>{for(const l of a)m(this,N,Rc).call(this,l);m(this,N,Pc).call(this,a)},h=()=>{for(const l of a)l.remove()};this.addCommands({cmd:o,undo:h,mustExec:!0})}catch(a){G(`paste: "${a.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,Tt)!==$.NONE&&!this.isEditorHandlingKeyboard&&Zd._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Fi)&&(p(this,Fi,!1),m(this,N,hh).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}setEditingState(t){t?(m(this,N,Ru).call(this),m(this,N,Cc).call(this),m(this,N,Kt).call(this,{isEditing:n(this,Tt)!==$.NONE,isEmpty:m(this,N,hr).call(this),hasSomethingToUndo:n(this,Ne).hasSomethingToUndo(),hasSomethingToRedo:n(this,Ne).hasSomethingToRedo(),hasSelectedEditor:!1})):(m(this,N,Pu).call(this),m(this,N,Tc).call(this),m(this,N,Kt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,Ue)){p(this,Ue,t);for(const e of n(this,Ue))m(this,N,ms).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,Ec).id}get currentLayer(){return n(this,$t).get(n(this,nr))}getLayer(t){return n(this,$t).get(t)}get currentPageIndex(){return n(this,nr)}addLayer(t){n(this,$t).set(t.pageIndex,t),n(this,Oi)?t.enable():t.disable()}removeLayer(t){n(this,$t).delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(n(this,Tt)!==t&&!(n(this,Fe)&&(await n(this,Fe).promise,!n(this,Fe)))){if(p(this,Fe,Promise.withResolvers()),n(this,Di)?.commitOrRemove(),p(this,Tt,t),t===$.NONE){this.setEditingState(!1),m(this,N,Nu).call(this),this._editorUndoBar?.hide(),n(this,Fe).resolve();return}t===$.SIGNATURE&&await n(this,Bi)?.loadSignatures(),this.setEditingState(!0),await m(this,N,Du).call(this),this.unselectAll();for(const i of n(this,$t).values())i.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),n(this,Fe).resolve();return}for(const i of n(this,kt).values())i.annotationElementId===e||i.id===e?(this.setSelected(i),i.enterInEditMode()):i.unselect();n(this,Fe).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,Tt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,Ue)){switch(t){case j.CREATE:this.currentLayer.addNewEditor(e);return;case j.HIGHLIGHT_DEFAULT_COLOR:n(this,In)?.updateColor(e);break;case j.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,or)||p(this,or,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const s of n(this,Q))s.updateParams(t,e);for(const s of n(this,Ue))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const i of n(this,kt).values())i.editorType===t&&i.show(e);(n(this,or)?.get(j.HIGHLIGHT_SHOW_ALL)??!0)!==e&&m(this,N,ms).call(this,[[j.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,ih)!==t){p(this,ih,t);for(const e of n(this,$t).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of n(this,kt).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return n(this,kt).get(t)}addEditor(t){n(this,kt).set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(n(this,gs)&&clearTimeout(n(this,gs)),p(this,gs,setTimeout(()=>{this.focusMainContainer(),p(this,gs,null)},0))),n(this,kt).delete(t.id),t.annotationElementId&&n(this,$s)?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!n(this,Tn).has(t.annotationElementId))&&n(this,Hs)?.remove(t.id)}addDeletedAnnotationElement(t){n(this,Tn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,Tn).has(t)}removeDeletedAnnotationElement(t){n(this,Tn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,be)!==t&&(p(this,be,t),t&&m(this,N,ms).call(this,t.propertiesToUpdate))}updateUI(t){n(this,N,Fu)===t&&m(this,N,ms).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){m(this,N,ms).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,Q).has(t)){n(this,Q).delete(t),t.unselect(),m(this,N,Kt).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,Q).add(t),t.select(),m(this,N,ms).call(this,t.propertiesToUpdate),m(this,N,Kt).call(this,{hasSelectedEditor:!0})}setSelected(t){n(this,Di)?.commitOrRemove();for(const e of n(this,Q))e!==t&&e.unselect();n(this,Q).clear(),n(this,Q).add(t),t.select(),m(this,N,ms).call(this,t.propertiesToUpdate),m(this,N,Kt).call(this,{hasSelectedEditor:!0})}isSelected(t){return n(this,Q).has(t)}get firstSelectedEditor(){return n(this,Q).values().next().value}unselect(t){t.unselect(),n(this,Q).delete(t),m(this,N,Kt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,Q).size!==0}get isEnterHandled(){return n(this,Q).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){n(this,Ne).undo(),m(this,N,Kt).call(this,{hasSomethingToUndo:n(this,Ne).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:m(this,N,hr).call(this)}),this._editorUndoBar?.hide()}redo(){n(this,Ne).redo(),m(this,N,Kt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,Ne).hasSomethingToRedo(),isEmpty:m(this,N,hr).call(this)})}addCommands(t){n(this,Ne).add(t),m(this,N,Kt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:m(this,N,hr).call(this)})}cleanUndoStack(t){n(this,Ne).cleanType(t)}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...n(this,Q)],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(const a of e)a.remove()},i=()=>{for(const a of e)m(this,N,Rc).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){n(this,be)?.commitOrRemove()}hasSomethingToControl(){return n(this,be)||this.hasSelection}selectAll(){for(const t of n(this,Q))t.commit();m(this,N,Pc).call(this,n(this,kt).values())}unselectAll(){if(!(n(this,be)&&(n(this,be).commitOrRemove(),n(this,Tt)!==$.NONE))&&!n(this,Di)?.commitOrRemove()&&this.hasSelection){for(const t of n(this,Q))t.unselect();n(this,Q).clear(),m(this,N,Kt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,Hi)[0]+=t,n(this,Hi)[1]+=e;const[i,a]=n(this,Hi),o=[...n(this,Q)];n(this,fs)&&clearTimeout(n(this,fs)),p(this,fs,setTimeout(()=>{p(this,fs,null),n(this,Hi)[0]=n(this,Hi)[1]=0,this.addCommands({cmd:()=>{for(const l of o)n(this,kt).has(l.id)&&(l.translateInPage(i,a),l.translationDone())},undo:()=>{for(const l of o)n(this,kt).has(l.id)&&(l.translateInPage(-i,-a),l.translationDone())},mustExec:!1})},1e3));for(const l of o)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,ps,new Map);for(const t of n(this,Q))n(this,ps).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,ps))return!1;this.disableUserSelect(!1);const t=n(this,ps);p(this,ps,null);let e=!1;for(const[{x:i,y:a,pageIndex:o},h]of t)h.newX=i,h.newY=a,h.newPageIndex=o,e||(e=i!==h.savedX||a!==h.savedY||o!==h.savedPageIndex);if(!e)return!1;const s=(i,a,o,h)=>{if(n(this,kt).has(i.id)){const l=n(this,$t).get(h);l?i._setParentAndPosition(l,a,o):(i.pageIndex=h,i.x=a,i.y=o)}};return this.addCommands({cmd:()=>{for(const[i,{newX:a,newY:o,newPageIndex:h}]of t)s(i,a,o,h)},undo:()=>{for(const[i,{savedX:a,savedY:o,savedPageIndex:h}]of t)s(i,a,o,h)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,ps))for(const s of n(this,ps).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()||n(this,Q).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,be)===t}getActive(){return n(this,be)}getMode(){return n(this,Tt)}get imageManager(){return z(this,"imageManager",new Cf)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let d=0,c=e.rangeCount;d<c;d++)if(!t.contains(e.getRangeAt(d).commonAncestorContainer))return null;const{x:s,y:i,width:a,height:o}=t.getBoundingClientRect();let h;switch(t.getAttribute("data-main-rotation")){case"90":h=(d,c,u,g)=>({x:(c-i)/o,y:1-(d+u-s)/a,width:g/o,height:u/a});break;case"180":h=(d,c,u,g)=>({x:1-(d+u-s)/a,y:1-(c+g-i)/o,width:u/a,height:g/o});break;case"270":h=(d,c,u,g)=>({x:1-(c+g-i)/o,y:(d-s)/a,width:g/o,height:u/a});break;default:h=(d,c,u,g)=>({x:(d-s)/a,y:(c-i)/o,width:u/a,height:g/o});break}const l=[];for(let d=0,c=e.rangeCount;d<c;d++){const u=e.getRangeAt(d);if(!u.collapsed)for(const{x:g,y:w,width:b,height:A}of u.getClientRects())b===0||A===0||l.push(h(g,w,b,A))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,Cn)||p(this,Cn,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){n(this,Cn)?.delete(t)}renderAnnotationElement(t){const e=n(this,Cn)?.get(t.data.id);if(!e)return;const s=n(this,Hs).getRawValue(e);s&&(n(this,Tt)===$.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){const i=n(this,$s)?.get(t);i&&(i.setCanvas(e,s),n(this,$s).delete(t))}addMissingCanvas(t,e){(n(this,$s)||p(this,$s,new Map)).set(t,e)}};sr=new WeakMap,be=new WeakMap,kt=new WeakMap,$t=new WeakMap,ir=new WeakMap,Hs=new WeakMap,Cn=new WeakMap,Ne=new WeakMap,Li=new WeakMap,Di=new WeakMap,nr=new WeakMap,Tn=new WeakMap,ps=new WeakMap,Ue=new WeakMap,Rn=new WeakMap,th=new WeakMap,eh=new WeakMap,ar=new WeakMap,sh=new WeakMap,gs=new WeakMap,Ni=new WeakMap,rr=new WeakMap,Fi=new WeakMap,je=new WeakMap,Ec=new WeakMap,Oi=new WeakMap,ih=new WeakMap,Wi=new WeakMap,Pn=new WeakMap,In=new WeakMap,$s=new WeakMap,nh=new WeakMap,Tt=new WeakMap,Q=new WeakMap,Gs=new WeakMap,Bi=new WeakMap,Ln=new WeakMap,or=new WeakMap,ah=new WeakMap,Hi=new WeakMap,fs=new WeakMap,zs=new WeakMap,rh=new WeakMap,Fe=new WeakMap,N=new WeakSet,oh=function({anchorNode:r}){return r.nodeType===Node.TEXT_NODE?r.parentElement:r},Mc=function(r){const{currentLayer:t}=this;if(t.hasTextLayer(r))return t;for(const e of n(this,$t).values())if(e.hasTextLayer(r))return e;return null},ku=function(){const r=document.getSelection();if(!r||r.isCollapsed)return;const t=m(this,N,oh).call(this,r).closest(".textLayer"),e=this.getSelectionBoxes(t);e&&(n(this,je)||p(this,je,new Mf(this)),n(this,je).show(t,e,this.direction==="ltr"))},Cu=function(){const r=document.getSelection();if(!r||r.isCollapsed){n(this,Gs)&&(n(this,je)?.hide(),p(this,Gs,null),m(this,N,Kt).call(this,{hasSelectedText:!1}));return}const{anchorNode:t}=r;if(t===n(this,Gs))return;const e=m(this,N,oh).call(this,r).closest(".textLayer");if(!e){n(this,Gs)&&(n(this,je)?.hide(),p(this,Gs,null),m(this,N,Kt).call(this,{hasSelectedText:!1}));return}if(n(this,je)?.hide(),p(this,Gs,t),m(this,N,Kt).call(this,{hasSelectedText:!0}),!(n(this,Tt)!==$.HIGHLIGHT&&n(this,Tt)!==$.NONE)&&(n(this,Tt)===$.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,Fi,this.isShiftKeyDown),!this.isShiftKeyDown)){const s=n(this,Tt)===$.HIGHLIGHT?m(this,N,Mc).call(this,e):null;s?.toggleDrawing();const i=new AbortController,a=this.combinedSignal(i),o=h=>{h.type==="pointerup"&&h.button!==0||(i.abort(),s?.toggleDrawing(!0),h.type==="pointerup"&&m(this,N,hh).call(this,"main_toolbar"))};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}},hh=function(r=""){n(this,Tt)===$.HIGHLIGHT?this.highlightSelection(r):n(this,th)&&m(this,N,ku).call(this)},Tu=function(){document.addEventListener("selectionchange",m(this,N,Cu).bind(this),{signal:this._signal})},Ru=function(){if(n(this,Ni))return;p(this,Ni,new AbortController);const r=this.combinedSignal(n(this,Ni));window.addEventListener("focus",this.focus.bind(this),{signal:r}),window.addEventListener("blur",this.blur.bind(this),{signal:r})},Pu=function(){n(this,Ni)?.abort(),p(this,Ni,null)},kc=function(){if(n(this,Wi))return;p(this,Wi,new AbortController);const r=this.combinedSignal(n(this,Wi));window.addEventListener("keydown",this.keydown.bind(this),{signal:r}),window.addEventListener("keyup",this.keyup.bind(this),{signal:r})},Iu=function(){n(this,Wi)?.abort(),p(this,Wi,null)},Cc=function(){if(n(this,Li))return;p(this,Li,new AbortController);const r=this.combinedSignal(n(this,Li));document.addEventListener("copy",this.copy.bind(this),{signal:r}),document.addEventListener("cut",this.cut.bind(this),{signal:r}),document.addEventListener("paste",this.paste.bind(this),{signal:r})},Tc=function(){n(this,Li)?.abort(),p(this,Li,null)},Lu=function(){const r=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:r}),document.addEventListener("drop",this.drop.bind(this),{signal:r})},Kt=function(r){Object.entries(r).some(([t,e])=>n(this,ah)[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(n(this,ah),r)}),n(this,Tt)===$.HIGHLIGHT&&r.hasSelectedEditor===!1&&m(this,N,ms).call(this,[[j.HIGHLIGHT_FREE,!0]]))},ms=function(r){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:r})},Du=async function(){if(!n(this,Oi)){p(this,Oi,!0);const r=[];for(const t of n(this,$t).values())r.push(t.enable());await Promise.all(r);for(const t of n(this,kt).values())t.enable()}},Nu=function(){if(this.unselectAll(),n(this,Oi)){p(this,Oi,!1);for(const r of n(this,$t).values())r.disable();for(const r of n(this,kt).values())r.disable()}},Rc=function(r){const t=n(this,$t).get(r.pageIndex);t?t.addOrRebuild(r):(this.addEditor(r),this.addToAnnotationStorage(r))},Fu=function(){let r=null;for(r of n(this,Q));return r},hr=function(){if(n(this,kt).size===0)return!0;if(n(this,kt).size===1)for(const r of n(this,kt).values())return r.isEmpty();return!1},Pc=function(r){for(const t of n(this,Q))t.unselect();n(this,Q).clear();for(const t of r)t.isEmpty()||(n(this,Q).add(t),t.select());m(this,N,Kt).call(this,{hasSelectedEditor:this.hasSelection})},C(Ic,"TRANSLATE_SMALL",1),C(Ic,"TRANSLATE_BIG",10);let Dn=Ic;var Rt,ws,Ve,lr,bs,Ae,cr,As,he,Us,Nn,vs,js,ys,dr,lh;const ur=class Si{constructor(t){f(this,ys),f(this,Rt,null),f(this,ws,!1),f(this,Ve,null),f(this,lr,null),f(this,bs,null),f(this,Ae,null),f(this,cr,!1),f(this,As,null),f(this,he,null),f(this,Us,null),f(this,Nn,null),f(this,vs,!1),p(this,he,t),p(this,vs,t._uiManager.useNewAltTextFlow),n(Si,js)||p(Si,js,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){Si._l10n??(Si._l10n=t)}async render(){const t=p(this,Ve,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,lr,document.createElement("span"));t.append(e),n(this,vs)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(Si,js).missing),e.setAttribute("data-l10n-id",n(Si,js)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=n(this,he)._uiManager._signal;t.addEventListener("contextmenu",me,{signal:s}),t.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:s});const i=a=>{a.preventDefault(),n(this,he)._uiManager.editAltText(n(this,he)),n(this,vs)&&n(this,he)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,ys,dr)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",a=>{a.target===t&&a.key==="Enter"&&(p(this,cr,!0),i(a))},{signal:s}),await m(this,ys,lh).call(this),t}finish(){n(this,Ve)&&(n(this,Ve).focus({focusVisible:n(this,cr)}),p(this,cr,!1))}isEmpty(){return n(this,vs)?n(this,Rt)===null:!n(this,Rt)&&!n(this,ws)}hasData(){return n(this,vs)?n(this,Rt)!==null||!!n(this,Us):this.isEmpty()}get guessedText(){return n(this,Us)}async setGuessedText(t){n(this,Rt)===null&&(p(this,Us,t),p(this,Nn,await Si._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),m(this,ys,lh).call(this))}toggleAltTextBadge(t=!1){if(!n(this,vs)||n(this,Rt)){n(this,As)?.remove(),p(this,As,null);return}if(!n(this,As)){const e=p(this,As,document.createElement("div"));e.className="noAltTextBadge",n(this,he).div.append(e)}n(this,As).classList.toggle("hidden",!t)}serialize(t){let e=n(this,Rt);return!t&&n(this,Us)===e&&(e=n(this,Nn)),{altText:e,decorative:n(this,ws),guessedText:n(this,Us),textWithDisclaimer:n(this,Nn)}}get data(){return{altText:n(this,Rt),decorative:n(this,ws)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:a=!1}){s&&(p(this,Us,s),p(this,Nn,i)),!(n(this,Rt)===t&&n(this,ws)===e)&&(a||(p(this,Rt,t),p(this,ws,e)),m(this,ys,lh).call(this))}toggle(t=!1){n(this,Ve)&&(!t&&n(this,Ae)&&(clearTimeout(n(this,Ae)),p(this,Ae,null)),n(this,Ve).disabled=!t)}shown(){n(this,he)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,ys,dr)}})}destroy(){n(this,Ve)?.remove(),p(this,Ve,null),p(this,lr,null),p(this,bs,null),n(this,As)?.remove(),p(this,As,null)}};Rt=new WeakMap,ws=new WeakMap,Ve=new WeakMap,lr=new WeakMap,bs=new WeakMap,Ae=new WeakMap,cr=new WeakMap,As=new WeakMap,he=new WeakMap,Us=new WeakMap,Nn=new WeakMap,vs=new WeakMap,js=new WeakMap,ys=new WeakSet,dr=function(){return n(this,Rt)&&"added"||n(this,Rt)===null&&this.guessedText&&"review"||"missing"},lh=async function(){const r=n(this,Ve);if(!r)return;if(n(this,vs)){if(r.classList.toggle("done",!!n(this,Rt)),r.setAttribute("data-l10n-id",n(ur,js)[n(this,ys,dr)]),n(this,lr)?.setAttribute("data-l10n-id",n(ur,js)[`${n(this,ys,dr)}-label`]),!n(this,Rt)){n(this,bs)?.remove();return}}else{if(!n(this,Rt)&&!n(this,ws)){r.classList.remove("done"),n(this,bs)?.remove();return}r.classList.add("done"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=n(this,bs);if(!t){p(this,bs,t=document.createElement("span")),t.className="tooltip",t.setAttribute("role","tooltip"),t.id=`alt-text-tooltip-${n(this,he).id}`;const e=100,s=n(this,he)._uiManager._signal;s.addEventListener("abort",()=>{clearTimeout(n(this,Ae)),p(this,Ae,null)},{once:!0}),r.addEventListener("mouseenter",()=>{p(this,Ae,setTimeout(()=>{p(this,Ae,null),n(this,bs).classList.add("show"),n(this,he)._reportTelemetry({action:"alt_text_tooltip"})},e))},{signal:s}),r.addEventListener("mouseleave",()=>{n(this,Ae)&&(clearTimeout(n(this,Ae)),p(this,Ae,null)),n(this,bs)?.classList.remove("show")},{signal:s})}n(this,ws)?t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(t.removeAttribute("data-l10n-id"),t.textContent=n(this,Rt)),t.parentNode||r.append(t),n(this,he).getElementForAltText()?.setAttribute("aria-describedby",t.id)},f(ur,js,null),C(ur,"_l10n",null);let Ou=ur;var pr,Fn,ch,dh,uh,ph,gh,Vs,On,qs,Wn,Xs,gr,Wu,Bu,Hu;const $u=class{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:a=null,onPinchEnd:o=null,signal:h}){f(this,gr),f(this,pr),f(this,Fn,!1),f(this,ch,null),f(this,dh),f(this,uh),f(this,ph),f(this,gh),f(this,Vs,null),f(this,On),f(this,qs,null),f(this,Wn),f(this,Xs,null),p(this,pr,t),p(this,ch,s),p(this,dh,e),p(this,uh,i),p(this,ph,a),p(this,gh,o),p(this,Wn,new AbortController),p(this,On,AbortSignal.any([h,n(this,Wn).signal])),t.addEventListener("touchstart",m(this,gr,Wu).bind(this),{passive:!1,signal:n(this,On)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ge.pixelRatio}destroy(){n(this,Wn)?.abort(),p(this,Wn,null),n(this,Vs)?.abort(),p(this,Vs,null)}};pr=new WeakMap,Fn=new WeakMap,ch=new WeakMap,dh=new WeakMap,uh=new WeakMap,ph=new WeakMap,gh=new WeakMap,Vs=new WeakMap,On=new WeakMap,qs=new WeakMap,Wn=new WeakMap,Xs=new WeakMap,gr=new WeakSet,Wu=function(r){var t,e,s;if((t=n(this,dh))!=null&&t.call(this))return;if(r.touches.length===1){if(n(this,Vs))return;const o=p(this,Vs,new AbortController),h=AbortSignal.any([n(this,On),o.signal]),l=n(this,pr),d={capture:!0,signal:h,passive:!1},c=u=>{u.pointerType==="touch"&&(n(this,Vs)?.abort(),p(this,Vs,null))};l.addEventListener("pointerdown",u=>{u.pointerType==="touch"&&(ut(u),c(u))},d),l.addEventListener("pointerup",c,d),l.addEventListener("pointercancel",c,d);return}if(!n(this,Xs)){p(this,Xs,new AbortController);const o=AbortSignal.any([n(this,On),n(this,Xs).signal]),h=n(this,pr),l={signal:o,capture:!1,passive:!1};h.addEventListener("touchmove",m(this,gr,Bu).bind(this),l);const d=m(this,gr,Hu).bind(this);h.addEventListener("touchend",d,l),h.addEventListener("touchcancel",d,l),l.capture=!0,h.addEventListener("pointerdown",ut,l),h.addEventListener("pointermove",ut,l),h.addEventListener("pointercancel",ut,l),h.addEventListener("pointerup",ut,l),(e=n(this,uh))==null||e.call(this)}if(ut(r),r.touches.length!==2||(s=n(this,ch))!=null&&s.call(this)){p(this,qs,null);return}let[i,a]=r.touches;i.identifier>a.identifier&&([i,a]=[a,i]),p(this,qs,{touch0X:i.screenX,touch0Y:i.screenY,touch1X:a.screenX,touch1Y:a.screenY})},Bu=function(r){var t;if(!n(this,qs)||r.touches.length!==2)return;ut(r);let[e,s]=r.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:a}=e,{screenX:o,screenY:h}=s,l=n(this,qs),{touch0X:d,touch0Y:c,touch1X:u,touch1Y:g}=l,w=u-d,b=g-c,A=o-i,v=h-a,y=Math.hypot(A,v)||1,S=Math.hypot(w,b)||1;if(!n(this,Fn)&&Math.abs(S-y)<=$u.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=a,l.touch1X=o,l.touch1Y=h,!n(this,Fn)){p(this,Fn,!0);return}const _=[(i+o)/2,(a+h)/2];(t=n(this,ph))==null||t.call(this,_,S,y)},Hu=function(r){var t;r.touches.length>=2||(n(this,Xs)&&(n(this,Xs).abort(),p(this,Xs,null),(t=n(this,gh))==null||t.call(this)),n(this,qs)&&(ut(r),p(this,qs,null),p(this,Fn,!1)))};let Lc=$u;var Bn,qe,nt,fr,$i,fh,Hn,Gt,$n,Ks,Gi,mh,Gn,zt,wh,zn,Ys,_s,mr,wr,ve,zi,bh,Dc,V,Nc,Ah,Fc,vh,Gu,zu,Oc,yh,Wc,Uu,ju,Vu,Bc,qu,Hc,Xu,Ku,Yu,$c,br;const pt=class Ot{constructor(t){f(this,V),f(this,Bn,null),f(this,qe,null),f(this,nt,null),f(this,fr,!1),f(this,$i,null),f(this,fh,""),f(this,Hn,!1),f(this,Gt,null),f(this,$n,null),f(this,Ks,null),f(this,Gi,null),f(this,mh,""),f(this,Gn,!1),f(this,zt,null),f(this,wh,!1),f(this,zn,!1),f(this,Ys,!1),f(this,_s,null),f(this,mr,0),f(this,wr,0),f(this,ve,null),f(this,zi,null),C(this,"isSelected",!1),C(this,"_isCopy",!1),C(this,"_editToolbar",null),C(this,"_initialOptions",Object.create(null)),C(this,"_initialData",null),C(this,"_isVisible",!0),C(this,"_uiManager",null),C(this,"_focusEventsAllowed",!0),f(this,bh,!1),f(this,Dc,Ot._zIndex++),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:a,pageY:o}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[a,o];const[h,l]=this.parentDimensions;this.x=t.x/h,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=Ot.prototype._resizeWithKeyboard,e=Dn.TRANSLATE_SMALL,s=Dn.TRANSLATE_BIG;return z(this,"_resizerKeyboardManager",new er([[["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"],Ot.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return z(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Pf({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(Ot._l10n??(Ot._l10n=t),Ot._l10nResizer||(Ot._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),Ot._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);Ot._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Y("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,bh)}set _isDraggable(t){p(this,bh,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=n(this,Dc)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):m(this,V,br).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,Gn)?p(this,Gn,!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[a,o]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/a,this.y=(e+i)/o,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){m(this,V,Nc).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,zt)||p(this,zt,[this.x,this.y,this.width,this.height]),m(this,V,Nc).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,zt)||p(this,zt,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,a]}=this;if(this.x+=t/i,this.y+=e/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:u,y:g}=this.div.getBoundingClientRect();this.parent.findNewParent(this,u,g)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:o,y:h}=this;const[l,d]=this.getBaseTranslation();o+=l,h+=d;const{style:c}=s;c.left=`${(100*o).toFixed(2)}%`,c.top=`${(100*h).toFixed(2)}%`,this._onTranslating(o,h),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,zt)&&(n(this,zt)[0]!==this.x||n(this,zt)[1]!==this.y)}get _hasBeenResized(){return!!n(this,zt)&&(n(this,zt)[2]!==this.width||n(this,zt)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=Ot,i=s/t,a=s/e;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:a,y:o,width:h,height:l}=this;if(h*=s,l*=i,a*=s,o*=i,this._mustFixPosition)switch(t){case 0:a=Ht(a,0,s-h),o=Ht(o,0,i-l);break;case 90:a=Ht(a,0,s-l),o=Ht(o,h,i);break;case 180:a=Ht(a,h,s),o=Ht(o,l,i);break;case 270:a=Ht(a,l,s),o=Ht(o,0,i-h);break}this.x=a/=s,this.y=o/=i;const[d,c]=this.getBaseTranslation();a+=d,o+=c,e.left=`${(100*a).toFixed(2)}%`,e.top=`${(100*o).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return m(s=Ot,Ah,Fc).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return m(s=Ot,Ah,Fc).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(t,e){const[s,i]=this.parentDimensions,{style:a}=this.div;a.width=`${(100*t/s).toFixed(2)}%`,n(this,Hn)||(a.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),a=!n(this,Hn)&&e.endsWith("%");if(i&&a)return;const[o,h]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/o).toFixed(2)}%`),!n(this,Hn)&&!a&&(t.height=`${(100*parseFloat(e)/h).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){n(this,nt)?.finish()}async addEditToolbar(){return this._editToolbar||n(this,zn)?this._editToolbar:(this._editToolbar=new Ef(this),this.div.append(this._editToolbar.render()),n(this,nt)&&await this._editToolbar.addAltText(n(this,nt)),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,n(this,nt)?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){n(this,nt)||(Ou.initialize(Ot._l10n),p(this,nt,new Ou(this)),n(this,Bn)&&(n(this,nt).data=n(this,Bn),p(this,Bn,null)),await this.addEditToolbar())}get altTextData(){return n(this,nt)?.data}set altTextData(t){n(this,nt)&&(n(this,nt).data=t)}get guessedAltText(){return n(this,nt)?.guessedText}async setGuessedAltText(t){await n(this,nt)?.setGuessedText(t)}serializeAltText(t){return n(this,nt)?.serialize(t)}hasAltText(){return!!n(this,nt)&&!n(this,nt).isEmpty()}hasAltTextData(){return n(this,nt)?.hasData()??!1}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=n(this,fr)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),m(this,V,Hc).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,a]=this.getInitialTranslation();return this.translate(i,a),Su(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,zi)||p(this,zi,new Lc({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:m(this,V,Uu).bind(this),onPinching:m(this,V,ju).bind(this),onPinchEnd:m(this,V,Vu).bind(this),signal:this._uiManager._signal}))),this._uiManager._editorUndoBar?.hide(),t}pointerdown(t){const{isMac:e}=Mt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,Gn,!0),this._isDraggable){m(this,V,qu).call(this,t);return}m(this,V,Bc).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,_s)&&clearTimeout(n(this,_s)),p(this,_s,setTimeout(()=>{p(this,_s,null),this.parent?.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[a,o]=this.pageDimensions,[h,l]=this.pageTranslation,d=t/i,c=e/i,u=this.x*a,g=this.y*o,w=this.width*a,b=this.height*o;switch(s){case 0:return[u+d+h,o-g-c-b+l,u+d+w+h,o-g-c+l];case 90:return[u+c+h,o-g+d+l,u+c+b+h,o-g+d+w+l];case 180:return[u-d-w+h,o-g+c+l,u-d+h,o-g+c+b+l];case 270:return[u-c-b+h,o-g-d-w+l,u-c+h,o-g-d+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,a,o]=t,h=a-s,l=o-i;switch(this.rotation){case 0:return[s,e-o,h,l];case 90:return[s,e-i,l,h];case 180:return[a,e-i,h,l];case 270:return[a,e-o,l,h];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),p(this,zn,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,zn,!1),!0):!1}isInEditMode(){return n(this,zn)}shouldGetKeyboardEvents(){return n(this,Ys)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:a,innerWidth:o}=window;return e<o&&i>0&&t<a&&s>0}rebuild(){m(this,V,Hc).call(this)}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){Y("An editor must be serializable")}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,p(i,Bn,t.accessibilityData),i._isCopy=t.isCopy||!1;const[a,o]=i.pageDimensions,[h,l,d,c]=i.getRectInCurrentCoords(t.rect,o);return i.x=h/a,i.y=l/o,i.width=d/a,i.height=c/o,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(n(this,Gi)?.abort(),p(this,Gi,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),n(this,_s)&&(clearTimeout(n(this,_s)),p(this,_s,null)),m(this,V,br).call(this),this.removeEditToolbar(),n(this,ve)){for(const t of n(this,ve).values())clearTimeout(t);p(this,ve,null)}this.parent=null,n(this,zi)?.destroy(),p(this,zi,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(m(this,V,Gu).call(this),n(this,Gt).classList.remove("hidden"))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,Ks,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,Gt).children;if(!n(this,qe)){p(this,qe,Array.from(e));const o=m(this,V,Xu).bind(this),h=m(this,V,Ku).bind(this),l=this._uiManager._signal;for(const d of n(this,qe)){const c=d.getAttribute("data-resizer-name");d.setAttribute("role","spinbutton"),d.addEventListener("keydown",o,{signal:l}),d.addEventListener("blur",h,{signal:l}),d.addEventListener("focus",m(this,V,Yu).bind(this,c),{signal:l}),d.setAttribute("data-l10n-id",Ot._l10nResizer[c])}}const s=n(this,qe)[0];let i=0;for(const o of e){if(o===s)break;i++}const a=(360-this.rotation+this.parentRotation)%360/90*(n(this,qe).length/4);if(a!==i){if(a<i)for(let h=0;h<i-a;h++)n(this,Gt).append(n(this,Gt).firstChild);else if(a>i)for(let h=0;h<a-i;h++)n(this,Gt).firstChild.before(n(this,Gt).lastChild);let o=0;for(const h of e){const l=n(this,qe)[o++].getAttribute("data-resizer-name");h.setAttribute("data-l10n-id",Ot._l10nResizer[l])}}m(this,V,$c).call(this,0),p(this,Ys,!0),n(this,Gt).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,Ys)&&m(this,V,Wc).call(this,n(this,mh),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){m(this,V,br).call(this),this.div.focus()}select(){if(!(this.isSelected&&this._editToolbar)){if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),n(this,nt)?.toggleAltTextBadge(!1)}}unselect(){this.isSelected&&(this.isSelected=!1,n(this,Gt)?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),n(this,nt)?.toggleAltTextBadge(!0))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return n(this,wh)}set isEditing(t){p(this,wh,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){p(this,Hn,!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){n(this,ve)||p(this,ve,new Map);const{action:s}=t;let i=n(this,ve).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,ve).delete(s),n(this,ve).size===0&&p(this,ve,null)},Ot._telemetryTimeout),n(this,ve).set(s,i);return}t.type||(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),p(this,fr,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,fr,!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()}};Bn=new WeakMap,qe=new WeakMap,nt=new WeakMap,fr=new WeakMap,$i=new WeakMap,fh=new WeakMap,Hn=new WeakMap,Gt=new WeakMap,$n=new WeakMap,Ks=new WeakMap,Gi=new WeakMap,mh=new WeakMap,Gn=new WeakMap,zt=new WeakMap,wh=new WeakMap,zn=new WeakMap,Ys=new WeakMap,_s=new WeakMap,mr=new WeakMap,wr=new WeakMap,ve=new WeakMap,zi=new WeakMap,bh=new WeakMap,Dc=new WeakMap,V=new WeakSet,Nc=function([r,t],e,s){[e,s]=this.screenToPageTranslation(e,s),this.x+=e/r,this.y+=s/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Ah=new WeakSet,Fc=function(r,t,e){switch(e){case 90:return[t,-r];case 180:return[-r,-t];case 270:return[-t,r];default:return[r,t]}},vh=function(r){switch(r){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}},Gu=function(){if(n(this,Gt))return;p(this,Gt,document.createElement("div")),n(this,Gt).classList.add("resizers");const r=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const e of r){const s=document.createElement("div");n(this,Gt).append(s),s.classList.add("resizer",e),s.setAttribute("data-resizer-name",e),s.addEventListener("pointerdown",m(this,V,zu).bind(this,e),{signal:t}),s.addEventListener("contextmenu",me,{signal:t}),s.tabIndex=-1}this.div.prepend(n(this,Gt))},zu=function(r,t){t.preventDefault();const{isMac:e}=Mt.platform;if(t.button!==0||t.ctrlKey&&e)return;n(this,nt)?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,p(this,$n,[t.screenX,t.screenY]);const i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",m(this,V,Wc).bind(this,r),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",ut,{passive:!1,signal:a}),window.addEventListener("contextmenu",me,{signal:a}),p(this,Ks,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,h=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const l=()=>{i.abort(),this.parent.togglePointerEvents(!0),n(this,nt)?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=o,this.div.style.cursor=h,m(this,V,yh).call(this)};window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})},Oc=function(r,t,e,s){this.width=e,this.height=s,this.x=r,this.y=t;const[i,a]=this.parentDimensions;this.setDims(i*e,a*s),this.fixAndSetPosition(),this._onResized()},yh=function(){if(!n(this,Ks))return;const{savedX:r,savedY:t,savedWidth:e,savedHeight:s}=n(this,Ks);p(this,Ks,null);const i=this.x,a=this.y,o=this.width,h=this.height;i===r&&a===t&&o===e&&h===s||this.addCommands({cmd:m(this,V,Oc).bind(this,i,a,o,h),undo:m(this,V,Oc).bind(this,r,t,e,s),mustExec:!0})},Wc=function(r,t){const[e,s]=this.parentDimensions,i=this.x,a=this.y,o=this.width,h=this.height,l=pt.MIN_SIZE/e,d=pt.MIN_SIZE/s,c=m(this,V,vh).call(this,this.rotation),u=(O,I)=>[c[0]*O+c[2]*I,c[1]*O+c[3]*I],g=m(this,V,vh).call(this,360-this.rotation),w=(O,I)=>[g[0]*O+g[2]*I,g[1]*O+g[3]*I];let b,A,v=!1,y=!1;switch(r){case"topLeft":v=!0,b=(O,I)=>[0,0],A=(O,I)=>[O,I];break;case"topMiddle":b=(O,I)=>[O/2,0],A=(O,I)=>[O/2,I];break;case"topRight":v=!0,b=(O,I)=>[O,0],A=(O,I)=>[0,I];break;case"middleRight":y=!0,b=(O,I)=>[O,I/2],A=(O,I)=>[0,I/2];break;case"bottomRight":v=!0,b=(O,I)=>[O,I],A=(O,I)=>[0,0];break;case"bottomMiddle":b=(O,I)=>[O/2,I],A=(O,I)=>[O/2,0];break;case"bottomLeft":v=!0,b=(O,I)=>[0,I],A=(O,I)=>[O,0];break;case"middleLeft":y=!0,b=(O,I)=>[0,I/2],A=(O,I)=>[O,I/2];break}const S=b(o,h),_=A(o,h);let x=u(..._);const E=pt._round(i+x[0]),M=pt._round(a+x[1]);let k=1,T=1,R,B;if(t.fromKeyboard)({deltaX:R,deltaY:B}=t);else{const{screenX:O,screenY:I}=t,[tt,fe]=n(this,$n);[R,B]=this.screenToPageTranslation(O-tt,I-fe),n(this,$n)[0]=O,n(this,$n)[1]=I}if([R,B]=w(R/e,B/s),v){const O=Math.hypot(o,h);k=T=Math.max(Math.min(Math.hypot(_[0]-S[0]-R,_[1]-S[1]-B)/O,1/o,1/h),l/o,d/h)}else y?k=Ht(Math.abs(_[0]-S[0]-R),l,1)/o:T=Ht(Math.abs(_[1]-S[1]-B),d,1)/h;const H=pt._round(o*k),q=pt._round(h*T);x=u(...A(H,q));const Z=E-x[0],K=M-x[1];n(this,zt)||p(this,zt,[this.x,this.y,this.width,this.height]),this.width=H,this.height=q,this.x=Z,this.y=K,this.setDims(e*H,s*q),this.fixAndSetPosition(),this._onResizing()},Uu=function(){p(this,Ks,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),n(this,nt)?.toggle(!1),this.parent.togglePointerEvents(!1)},ju=function(r,t,e){let s=.7*(e/t)+1-.7;if(s===1)return;const i=m(this,V,vh).call(this,this.rotation),a=(x,E)=>[i[0]*x+i[2]*E,i[1]*x+i[3]*E],[o,h]=this.parentDimensions,l=this.x,d=this.y,c=this.width,u=this.height,g=pt.MIN_SIZE/o,w=pt.MIN_SIZE/h;s=Math.max(Math.min(s,1/c,1/u),g/c,w/u);const b=pt._round(c*s),A=pt._round(u*s);if(b===c&&A===u)return;n(this,zt)||p(this,zt,[l,d,c,u]);const v=a(c/2,u/2),y=pt._round(l+v[0]),S=pt._round(d+v[1]),_=a(b/2,A/2);this.x=y-_[0],this.y=S-_[1],this.width=b,this.height=A,this.setDims(o*b,h*A),this.fixAndSetPosition(),this._onResizing()},Vu=function(){n(this,nt)?.toggle(!0),this.parent.togglePointerEvents(!0),m(this,V,yh).call(this)},Bc=function(r){const{isMac:t}=Mt.platform;r.ctrlKey&&!t||r.shiftKey||r.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)},qu=function(r){const{isSelected:t}=this;this._uiManager.setUpDragSession();let e=!1;const s=new AbortController,i=this._uiManager.combinedSignal(s),a={capture:!0,passive:!1,signal:i},o=l=>{s.abort(),p(this,$i,null),p(this,Gn,!1),this._uiManager.endDragSession()||m(this,V,Bc).call(this,l),e&&this._onStopDragging()};t&&(p(this,mr,r.clientX),p(this,wr,r.clientY),p(this,$i,r.pointerId),p(this,fh,r.pointerType),window.addEventListener("pointermove",l=>{e||(e=!0,this._onStartDragging());const{clientX:d,clientY:c,pointerId:u}=l;if(u!==n(this,$i)){ut(l);return}const[g,w]=this.screenToPageTranslation(d-n(this,mr),c-n(this,wr));p(this,mr,d),p(this,wr,c),this._uiManager.dragSelectedEditors(g,w)},a),window.addEventListener("touchmove",ut,a),window.addEventListener("pointerdown",l=>{l.pointerType===n(this,fh)&&(n(this,zi)||l.isPrimary)&&o(l),ut(l)},a));const h=l=>{if(!n(this,$i)||n(this,$i)===l.pointerId){o(l);return}ut(l)};window.addEventListener("pointerup",h,{signal:i}),window.addEventListener("blur",h,{signal:i})},Hc=function(){if(n(this,Gi)||!this.div)return;p(this,Gi,new AbortController);const r=this._uiManager.combinedSignal(n(this,Gi));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:r}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:r})},Xu=function(r){pt._resizerKeyboardManager.exec(this,r)},Ku=function(r){n(this,Ys)&&r.relatedTarget?.parentNode!==n(this,Gt)&&m(this,V,br).call(this)},Yu=function(r){p(this,mh,n(this,Ys)?r:"")},$c=function(r){if(n(this,qe))for(const t of n(this,qe))t.tabIndex=r},br=function(){p(this,Ys,!1),m(this,V,$c).call(this,-1),m(this,V,yh).call(this)},f(pt,Ah),C(pt,"_l10n",null),C(pt,"_l10nResizer",null),C(pt,"_borderLineWidth",-1),C(pt,"_colorManager",new Rf),C(pt,"_zIndex",1),C(pt,"_telemetryTimeout",1e3);let at=pt;class Pf extends at{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Qu=3285377520,ye=4294901760,Xe=65535;class Ju{constructor(t){this.h1=t?t&4294967295:Qu,this.h2=t?t&4294967295:Qu}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let A=0,v=t.length;A<v;A++){const y=t.charCodeAt(A);y<=255?e[s++]=y:(e[s++]=y>>>8,e[s++]=y&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,a=s-i*4,o=new Uint32Array(e.buffer,0,i);let h=0,l=0,d=this.h1,c=this.h2;const u=3432918353,g=461845907,w=u&Xe,b=g&Xe;for(let A=0;A<i;A++)A&1?(h=o[A],h=h*u&ye|h*w&Xe,h=h<<15|h>>>17,h=h*g&ye|h*b&Xe,d^=h,d=d<<13|d>>>19,d=d*5+3864292196):(l=o[A],l=l*u&ye|l*w&Xe,l=l<<15|l>>>17,l=l*g&ye|l*b&Xe,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(h=0,a){case 3:h^=e[i*4+2]<<16;case 2:h^=e[i*4+1]<<8;case 1:h^=e[i*4],h=h*u&ye|h*w&Xe,h=h<<15|h>>>17,h=h*g&ye|h*b&Xe,i&1?d^=h:c^=h}this.h1=d,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&ye|t*36045&Xe,e=e*4283543511&ye|((e<<16|t>>>16)*2950163797&ye)>>>16,t^=e>>>1,t=t*444984403&ye|t*60499&Xe,e=e*3301882366&ye|((e<<16|t>>>16)*3120437893&ye)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Gc=Object.freeze({map:null,hash:"",transfer:void 0});var Un,jn,Ut,zc,Zu;class Uc{constructor(){f(this,zc),f(this,Un,!1),f(this,jn,null),f(this,Ut,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=n(this,Ut).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,Ut).get(t)}remove(t){if(n(this,Ut).delete(t),n(this,Ut).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of n(this,Ut).values())if(e instanceof at)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=n(this,Ut).get(t);let i=!1;if(s!==void 0)for(const[a,o]of Object.entries(e))s[a]!==o&&(i=!0,s[a]=o);else i=!0,n(this,Ut).set(t,e);i&&m(this,zc,Zu).call(this),e instanceof at&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return n(this,Ut).has(t)}get size(){return n(this,Ut).size}resetModified(){n(this,Un)&&(p(this,Un,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new tp(this)}get serializable(){if(n(this,Ut).size===0)return Gc;const t=new Map,e=new Ju,s=[],i=Object.create(null);let a=!1;for(const[o,h]of n(this,Ut)){const l=h instanceof at?h.serialize(!1,i):h;l&&(t.set(o,l),e.update(`${o}:${JSON.stringify(l)}`),a||(a=!!l.bitmap))}if(a)for(const o of t.values())o.bitmap&&s.push(o.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Gc}get editorStats(){let t=null;const e=new Map;for(const s of n(this,Ut).values()){if(!(s instanceof at))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:a}=i;e.has(a)||e.set(a,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const o=t[a]||(t[a]=new Map);for(const[h,l]of Object.entries(i)){if(h==="type")continue;let d=o.get(h);d||(d=new Map,o.set(h,d));const c=d.get(l)??0;d.set(l,c+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){p(this,jn,null)}get modifiedIds(){if(n(this,jn))return n(this,jn);const t=[];for(const e of n(this,Ut).values())!(e instanceof at)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return p(this,jn,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return n(this,Ut).entries()}}Un=new WeakMap,jn=new WeakMap,Ut=new WeakMap,zc=new WeakSet,Zu=function(){n(this,Un)||(p(this,Un,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var _h;class tp extends Uc{constructor(t){super(),f(this,_h);const{map:e,hash:s,transfer:i}=t.serializable,a=structuredClone(e,i?{transfer:i}:null);p(this,_h,{map:a,hash:s,transfer:i})}get print(){Y("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,_h)}get modifiedIds(){return z(this,"modifiedIds",{ids:new Set,hash:""})}}_h=new WeakMap;var Ar;class If{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){f(this,Ar,new Set),this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),n(this,Ar).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,Ar).has(t.loadedName))){if(ft(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:a,style:o}=t,h=new FontFace(i,a,o);this.addNativeFontFace(h);try{await h.load(),n(this,Ar).add(i),s?.(t)}catch{G(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(h)}return}Y("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 G(`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 z(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return z(this,"isSyncFontLoadingSupported",Xt||Mt.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(ft(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const a=s.shift();setTimeout(a.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 z(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(_,x){return _.charCodeAt(x)<<24|_.charCodeAt(x+1)<<16|_.charCodeAt(x+2)<<8|_.charCodeAt(x+3)&255}function i(_,x,E,M){const k=_.substring(0,x),T=_.substring(x+E);return k+M+T}let a,o;const h=this._document.createElement("canvas");h.width=1,h.height=1;const l=h.getContext("2d");let d=0;function c(_,x){if(++d>30){G("Load test font never loaded."),x();return}if(l.font="30px "+_,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){x();return}setTimeout(c.bind(null,_,x))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let g=this._loadTestFont;g=i(g,976,u.length,u);const w=16,b=1482184792;let A=s(g,w);for(a=0,o=u.length-3;a<o;a+=4)A=A-b+s(u,a)|0;a<u.length&&(A=A-b+s(u+"XXX",a)|0),g=i(g,w,4,wf(A));const v=`url(data:font/opentype;base64,${btoa(g)});`,y=`@font-face {font-family:"${u}";src:${v}}`;this.insertRule(y);const S=this._document.createElement("div");S.style.visibility="hidden",S.style.width=S.style.height="10px",S.style.position="absolute",S.style.top=S.style.left="0px";for(const _ of[t.loadedName,u]){const x=this._document.createElement("span");x.textContent="Hi",x.style.fontFamily=_,S.append(x)}this._document.body.append(S),c(u,()=>{S.remove(),e.complete()})}}Ar=new WeakMap;class Lf{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const s in t)this[s]=t[s];this._inspectFont=e}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=`url(data:${this.mimetype};base64,${du(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(o){G(`getPathGenerator - ignoring character: "${o}".`)}const a=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=a}}function Df(r){if(r instanceof URL)return r.href;if(typeof r=="string"){if(Xt)return r;const t=URL.parse(r,window.location);if(t)return t.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Nf(r){if(Xt&&typeof Buffer<"u"&&r instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength)return r;if(typeof r=="string")return ja(r);if(r instanceof ArrayBuffer||ArrayBuffer.isView(r)||typeof r=="object"&&!isNaN(r?.length))return new Uint8Array(r);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Sh(r){if(typeof r!="string")return null;if(r.endsWith("/"))return r;throw new Error(`Invalid factory url: "${r}" must include trailing slash.`)}const jc=r=>typeof r=="object"&&Number.isInteger(r?.num)&&r.num>=0&&Number.isInteger(r?.gen)&&r.gen>=0,Ff=r=>typeof r=="object"&&typeof r?.name=="string",ep=yf.bind(null,jc,Ff);var Qs,Vc;class Of{constructor(){f(this,Qs,new Map),f(this,Vc,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,Vc).then(()=>{for(const[i]of n(this,Qs))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){const{signal:a}=s;if(a.aborted){G("LoopbackPort - cannot use an `aborted` signal.");return}const o=()=>this.removeEventListener(t,e);i=()=>a.removeEventListener("abort",o),a.addEventListener("abort",o)}n(this,Qs).set(e,i)}removeEventListener(t,e){n(this,Qs).get(e)?.(),n(this,Qs).delete(e)}terminate(){for(const[,t]of n(this,Qs))t?.();n(this,Qs).clear()}}Qs=new WeakMap,Vc=new WeakMap;const xh={DATA:1,ERROR:2},wt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function sp(){}function te(r){if(r instanceof ds||r instanceof $o||r instanceof ou||r instanceof Ua||r instanceof fc)return r;switch(r instanceof Error||typeof r=="object"&&r!==null||Y('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),r.name){case"AbortException":return new ds(r.message);case"InvalidPDFException":return new $o(r.message);case"PasswordException":return new ou(r.message,r.code);case"ResponseException":return new Ua(r.message,r.status,r.missing);case"UnknownErrorException":return new fc(r.message,r.details)}return new fc(r.message,r.toString())}var vr,Js,ip,np,ap,Eh;class yr{constructor(t,e,s){f(this,Js),f(this,vr,new AbortController),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),s.addEventListener("message",m(this,Js,ip).bind(this),{signal:n(this,vr).signal})}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++,a=Promise.withResolvers();this.callbackCapabilities[i]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(o){a.reject(o)}return a.promise}sendWithStream(t,e,s,i){const a=this.streamId++,o=this.sourceName,h=this.targetName,l=this.comObj;return new ReadableStream({start:d=>{const c=Promise.withResolvers();return this.streamControllers[a]={controller:d,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:o,targetName:h,action:t,streamId:a,data:e,desiredSize:d.desiredSize},i),c.promise},pull:d=>{const c=Promise.withResolvers();return this.streamControllers[a].pullCall=c,l.postMessage({sourceName:o,targetName:h,stream:wt.PULL,streamId:a,desiredSize:d.desiredSize}),c.promise},cancel:d=>{ft(d instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[a].cancelCall=c,this.streamControllers[a].isClosed=!0,l.postMessage({sourceName:o,targetName:h,stream:wt.CANCEL,streamId:a,reason:te(d)}),c.promise}},s)}destroy(){n(this,vr)?.abort(),p(this,vr,null)}}vr=new WeakMap,Js=new WeakSet,ip=function({data:r}){if(r.targetName!==this.sourceName)return;if(r.stream){m(this,Js,ap).call(this,r);return}if(r.callback){const e=r.callbackId,s=this.callbackCapabilities[e];if(!s)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],r.callback===xh.DATA)s.resolve(r.data);else if(r.callback===xh.ERROR)s.reject(te(r.reason));else throw new Error("Unexpected callback case");return}const t=this.actionHandler[r.action];if(!t)throw new Error(`Unknown action from worker: ${r.action}`);if(r.callbackId){const e=this.sourceName,s=r.sourceName,i=this.comObj;Promise.try(t,r.data).then(function(a){i.postMessage({sourceName:e,targetName:s,callback:xh.DATA,callbackId:r.callbackId,data:a})},function(a){i.postMessage({sourceName:e,targetName:s,callback:xh.ERROR,callbackId:r.callbackId,reason:te(a)})});return}if(r.streamId){m(this,Js,np).call(this,r);return}t(r.data)},np=function(r){const t=r.streamId,e=this.sourceName,s=r.sourceName,i=this.comObj,a=this,o=this.actionHandler[r.action],h={enqueue(l,d=1,c){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=d,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:e,targetName:s,stream:wt.ENQUEUE,streamId:t,chunk:l},c)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:e,targetName:s,stream:wt.CLOSE,streamId:t}),delete a.streamSinks[t])},error(l){ft(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:e,targetName:s,stream:wt.ERROR,streamId:t,reason:te(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:r.desiredSize,ready:null};h.sinkCapability.resolve(),h.ready=h.sinkCapability.promise,this.streamSinks[t]=h,Promise.try(o,r.data,h).then(function(){i.postMessage({sourceName:e,targetName:s,stream:wt.START_COMPLETE,streamId:t,success:!0})},function(l){i.postMessage({sourceName:e,targetName:s,stream:wt.START_COMPLETE,streamId:t,reason:te(l)})})},ap=function(r){const t=r.streamId,e=this.sourceName,s=r.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(r.stream){case wt.START_COMPLETE:r.success?a.startCall.resolve():a.startCall.reject(te(r.reason));break;case wt.PULL_COMPLETE:r.success?a.pullCall.resolve():a.pullCall.reject(te(r.reason));break;case wt.PULL:if(!o){i.postMessage({sourceName:e,targetName:s,stream:wt.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&r.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=r.desiredSize,Promise.try(o.onPull||sp).then(function(){i.postMessage({sourceName:e,targetName:s,stream:wt.PULL_COMPLETE,streamId:t,success:!0})},function(l){i.postMessage({sourceName:e,targetName:s,stream:wt.PULL_COMPLETE,streamId:t,reason:te(l)})});break;case wt.ENQUEUE:if(ft(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(r.chunk);break;case wt.CLOSE:if(ft(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),m(this,Js,Eh).call(this,a,t);break;case wt.ERROR:ft(a,"error should have stream controller"),a.controller.error(te(r.reason)),m(this,Js,Eh).call(this,a,t);break;case wt.CANCEL_COMPLETE:r.success?a.cancelCall.resolve():a.cancelCall.reject(te(r.reason)),m(this,Js,Eh).call(this,a,t);break;case wt.CANCEL:if(!o)break;const h=te(r.reason);Promise.try(o.onCancel||sp,h).then(function(){i.postMessage({sourceName:e,targetName:s,stream:wt.CANCEL_COMPLETE,streamId:t,success:!0})},function(l){i.postMessage({sourceName:e,targetName:s,stream:wt.CANCEL_COMPLETE,streamId:t,reason:te(l)})}),o.sinkCapability.reject(h),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}},Eh=async function(r,t){await Promise.allSettled([r.startCall?.promise,r.pullCall?.promise,r.cancelCall?.promise]),delete this.streamControllers[t]};var Mh;class rp{constructor({enableHWA:t=!1}){f(this,Mh,!1),p(this,Mh,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:!n(this,Mh)})}}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){Y("Abstract method `_createCanvas` called.")}}Mh=new WeakMap;class Wf extends rp{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}}class op{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){Y("Abstract method `_fetch` called.")}}class hp extends op{async _fetch(t){const e=await En(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):ja(e)}}class lp{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,a){return"none"}destroy(t=!1){}}var Vn,qn,Zs,ti,Yt,Ui,Xn,F,jt,_r,Kn,kh,Yn,cp,qc,Qn,Sr,xr,Xc,Er;class Bf extends lp{constructor({docId:t,ownerDocument:e=globalThis.document}){super(),f(this,F),f(this,Vn),f(this,qn),f(this,Zs),f(this,ti),f(this,Yt),f(this,Ui),f(this,Xn,0),p(this,ti,t),p(this,Yt,e)}addFilter(t){if(!t)return"none";let e=n(this,F,jt).get(t);if(e)return e;const[s,i,a]=m(this,F,kh).call(this,t),o=t.length===1?s:`${s}${i}${a}`;if(e=n(this,F,jt).get(o),e)return n(this,F,jt).set(t,e),e;const h=`g_${n(this,ti)}_transfer_map_${Zt(this,Xn)._++}`,l=m(this,F,Yn).call(this,h);n(this,F,jt).set(t,l),n(this,F,jt).set(o,l);const d=m(this,F,Qn).call(this,h);return m(this,F,xr).call(this,s,i,a,d),l}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let a=n(this,F,_r).get(i);if(a?.key===s||(a?(a.filter?.remove(),a.key=s,a.url="none",a.filter=null):(a={key:s,url:"none",filter:null},n(this,F,_r).set(i,a)),!t||!e))return a.url;const o=m(this,F,Er).call(this,t);t=L.makeHexColor(...o);const h=m(this,F,Er).call(this,e);if(e=L.makeHexColor(...h),n(this,F,Kn).style.color="",t==="#000000"&&e==="#ffffff"||t===e)return a.url;const l=new Array(256);for(let w=0;w<=255;w++){const b=w/255;l[w]=b<=.03928?b/12.92:((b+.055)/1.055)**2.4}const d=l.join(","),c=`g_${n(this,ti)}_hcm_filter`,u=a.filter=m(this,F,Qn).call(this,c);m(this,F,xr).call(this,d,d,d,u),m(this,F,qc).call(this,u);const g=(w,b)=>{const A=o[w]/255,v=h[w]/255,y=new Array(b+1);for(let S=0;S<=b;S++)y[S]=A+S/b*(v-A);return y.join(",")};return m(this,F,xr).call(this,g(0,5),g(1,5),g(2,5),u),a.url=m(this,F,Yn).call(this,c),a.url}addAlphaFilter(t){let e=n(this,F,jt).get(t);if(e)return e;const[s]=m(this,F,kh).call(this,[t]),i=`alpha_${s}`;if(e=n(this,F,jt).get(i),e)return n(this,F,jt).set(t,e),e;const a=`g_${n(this,ti)}_alpha_map_${Zt(this,Xn)._++}`,o=m(this,F,Yn).call(this,a);n(this,F,jt).set(t,o),n(this,F,jt).set(i,o);const h=m(this,F,Qn).call(this,a);return m(this,F,Xc).call(this,s,h),o}addLuminosityFilter(t){let e=n(this,F,jt).get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=m(this,F,kh).call(this,[t]),i=`luminosity_${s}`):i="luminosity",e=n(this,F,jt).get(i),e)return n(this,F,jt).set(t,e),e;const a=`g_${n(this,ti)}_luminosity_map_${Zt(this,Xn)._++}`,o=m(this,F,Yn).call(this,a);n(this,F,jt).set(t,o),n(this,F,jt).set(i,o);const h=m(this,F,Qn).call(this,a);return m(this,F,cp).call(this,h),t&&m(this,F,Xc).call(this,s,h),o}addHighlightHCMFilter(t,e,s,i,a){const o=`${e}-${s}-${i}-${a}`;let h=n(this,F,_r).get(t);if(h?.key===o||(h?(h.filter?.remove(),h.key=o,h.url="none",h.filter=null):(h={key:o,url:"none",filter:null},n(this,F,_r).set(t,h)),!e||!s))return h.url;const[l,d]=[e,s].map(m(this,F,Er).bind(this));let c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),u=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[g,w]=[i,a].map(m(this,F,Er).bind(this));u<c&&([c,u,g,w]=[u,c,w,g]),n(this,F,Kn).style.color="";const b=(y,S,_)=>{const x=new Array(256),E=(u-c)/_,M=y/255,k=(S-y)/(255*_);let T=0;for(let R=0;R<=_;R++){const B=Math.round(c+R*E),H=M+R*k;for(let q=T;q<=B;q++)x[q]=H;T=B+1}for(let R=T;R<256;R++)x[R]=x[T-1];return x.join(",")},A=`g_${n(this,ti)}_hcm_${t}_filter`,v=h.filter=m(this,F,Qn).call(this,A);return m(this,F,qc).call(this,v),m(this,F,xr).call(this,b(g[0],w[0],5),b(g[1],w[1],5),b(g[2],w[2],5),v),h.url=m(this,F,Yn).call(this,A),h.url}destroy(t=!1){t&&n(this,Ui)?.size||(n(this,Zs)?.parentNode.parentNode.remove(),p(this,Zs,null),n(this,qn)?.clear(),p(this,qn,null),n(this,Ui)?.clear(),p(this,Ui,null),p(this,Xn,0))}}Vn=new WeakMap,qn=new WeakMap,Zs=new WeakMap,ti=new WeakMap,Yt=new WeakMap,Ui=new WeakMap,Xn=new WeakMap,F=new WeakSet,jt=function(){return n(this,qn)||p(this,qn,new Map)},_r=function(){return n(this,Ui)||p(this,Ui,new Map)},Kn=function(){if(!n(this,Zs)){const r=n(this,Yt).createElement("div"),{style:t}=r;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;const e=n(this,Yt).createElementNS(us,"svg");e.setAttribute("width",0),e.setAttribute("height",0),p(this,Zs,n(this,Yt).createElementNS(us,"defs")),r.append(e),e.append(n(this,Zs)),n(this,Yt).body.append(r)}return n(this,Zs)},kh=function(r){if(r.length===1){const h=r[0],l=new Array(256);for(let c=0;c<256;c++)l[c]=h[c]/255;const d=l.join(",");return[d,d,d]}const[t,e,s]=r,i=new Array(256),a=new Array(256),o=new Array(256);for(let h=0;h<256;h++)i[h]=t[h]/255,a[h]=e[h]/255,o[h]=s[h]/255;return[i.join(","),a.join(","),o.join(",")]},Yn=function(r){if(n(this,Vn)===void 0){p(this,Vn,"");const t=n(this,Yt).URL;t!==n(this,Yt).baseURI&&(Va(t)?G('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,Vn,gc(t,"")))}return`url(${n(this,Vn)}#${r})`},cp=function(r){const t=n(this,Yt).createElementNS(us,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),r.append(t)},qc=function(r){const t=n(this,Yt).createElementNS(us,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),r.append(t)},Qn=function(r){const t=n(this,Yt).createElementNS(us,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",r),n(this,F,Kn).append(t),t},Sr=function(r,t,e){const s=n(this,Yt).createElementNS(us,t);s.setAttribute("type","discrete"),s.setAttribute("tableValues",e),r.append(s)},xr=function(r,t,e,s){const i=n(this,Yt).createElementNS(us,"feComponentTransfer");s.append(i),m(this,F,Sr).call(this,i,"feFuncR",r),m(this,F,Sr).call(this,i,"feFuncG",t),m(this,F,Sr).call(this,i,"feFuncB",e)},Xc=function(r,t){const e=n(this,Yt).createElementNS(us,"feComponentTransfer");t.append(e),m(this,F,Sr).call(this,e,"feFuncA",r)},Er=function(r){return n(this,F,Kn).style.color=r,yc(getComputedStyle(n(this,F,Kn)).getPropertyValue("color"))};class dp{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){Y("Abstract method `_fetch` called.")}}class up extends dp{async _fetch(t){const e=await En(t,"arraybuffer");return new Uint8Array(e)}}class pp{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){Y("Abstract method `_fetch` called.")}}class gp extends pp{async _fetch(t){const e=await En(t,"arraybuffer");return new Uint8Array(e)}}Xt&&G("Please use the `legacy` build in Node.js environments.");async function Kc(r){const t=await process.getBuiltinModule("fs").promises.readFile(r);return new Uint8Array(t)}class Hf extends lp{}class $f extends rp{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Gf extends op{async _fetch(t){return Kc(t)}}class zf extends dp{async _fetch(t){return Kc(t)}}class Uf extends pp{async _fetch(t){return Kc(t)}}const Pt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Yc(r,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),r.clip(i)}class Qc{isModifyingCurrentTransform(){return!1}getPattern(){Y("Abstract method `getPattern` called.")}}class jf extends Qc{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 a;if(i===Pt.STROKE||i===Pt.FILL){const o=e.current.getClippedPathBoundingBox(i,rt(t))||[0,0,0,0],h=Math.ceil(o[2]-o[0])||1,l=Math.ceil(o[3]-o[1])||1,d=e.cachedCanvases.getCanvas("pattern",h,l),c=d.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(-o[0],-o[1]),s=L.transform(s,[1,0,0,1,o[0],o[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Yc(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),a=t.createPattern(d.canvas,"no-repeat");const u=new DOMMatrix(s);a.setTransform(u)}else Yc(t,this._bbox),a=this._createGradient(t);return a}}function Jc(r,t,e,s,i,a,o,h){const l=t.coords,d=t.colors,c=r.data,u=r.width*4;let g;l[e+1]>l[s+1]&&(g=e,e=s,s=g,g=a,a=o,o=g),l[s+1]>l[i+1]&&(g=s,s=i,i=g,g=o,o=h,h=g),l[e+1]>l[s+1]&&(g=e,e=s,s=g,g=a,a=o,o=g);const w=(l[e]+t.offsetX)*t.scaleX,b=(l[e+1]+t.offsetY)*t.scaleY,A=(l[s]+t.offsetX)*t.scaleX,v=(l[s+1]+t.offsetY)*t.scaleY,y=(l[i]+t.offsetX)*t.scaleX,S=(l[i+1]+t.offsetY)*t.scaleY;if(b>=S)return;const _=d[a],x=d[a+1],E=d[a+2],M=d[o],k=d[o+1],T=d[o+2],R=d[h],B=d[h+1],H=d[h+2],q=Math.round(b),Z=Math.round(S);let K,O,I,tt,fe,xi,Ei,ls;for(let Et=q;Et<=Z;Et++){if(Et<v){const ht=Et<b?0:(b-Et)/(b-v);K=w-(w-A)*ht,O=_-(_-M)*ht,I=x-(x-k)*ht,tt=E-(E-T)*ht}else{let ht;Et>S?ht=1:v===S?ht=0:ht=(v-Et)/(v-S),K=A-(A-y)*ht,O=M-(M-R)*ht,I=k-(k-B)*ht,tt=T-(T-H)*ht}let ct;Et<b?ct=0:Et>S?ct=1:ct=(b-Et)/(b-S),fe=w-(w-y)*ct,xi=_-(_-R)*ct,Ei=x-(x-B)*ct,ls=E-(E-H)*ct;const _n=Math.round(Math.min(K,fe)),Os=Math.round(Math.max(K,fe));let Ws=u*Et+_n*4;for(let ht=_n;ht<=Os;ht++)ct=(K-ht)/(K-fe),ct<0?ct=0:ct>1&&(ct=1),c[Ws++]=O-(O-xi)*ct|0,c[Ws++]=I-(I-Ei)*ct|0,c[Ws++]=tt-(tt-ls)*ct|0,c[Ws++]=255}}function Vf(r,t,e){const s=t.coords,i=t.colors;let a,o;switch(t.type){case"lattice":const h=t.verticesPerRow,l=Math.floor(s.length/h)-1,d=h-1;for(a=0;a<l;a++){let c=a*h;for(let u=0;u<d;u++,c++)Jc(r,e,s[c],s[c+1],s[c+h],i[c],i[c+1],i[c+h]),Jc(r,e,s[c+h+1],s[c+1],s[c+h],i[c+h+1],i[c+1],i[c+h])}break;case"triangles":for(a=0,o=s.length;a<o;a+=3)Jc(r,e,s[a],s[a+1],s[a+2],i[a],i[a+1],i[a+2]);break;default:throw new Error("illegal figure")}}class qf extends Qc{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),a=Math.floor(this._bounds[1]),o=Math.ceil(this._bounds[2])-i,h=Math.ceil(this._bounds[3])-a,l=Math.min(Math.ceil(Math.abs(o*t[0]*1.1)),3e3),d=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3e3),c=o/l,u=h/d,g={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-a,scaleX:1/c,scaleY:1/u},w=l+2*2,b=d+2*2,A=s.getCanvas("mesh",w,b),v=A.context,y=v.createImageData(l,d);if(e){const S=y.data;for(let _=0,x=S.length;_<x;_+=4)S[_]=e[0],S[_+1]=e[1],S[_+2]=e[2],S[_+3]=255}for(const S of this._figures)Vf(y,S,g);return v.putImageData(y,2,2),{canvas:A.canvas,offsetX:i-2*c,offsetY:a-2*u,scaleX:c,scaleY:u}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){Yc(t,this._bbox);const a=new Float32Array(2);if(i===Pt.SHADING)L.singularValueDecompose2dScale(rt(t),a);else if(this.matrix){L.singularValueDecompose2dScale(this.matrix,a);const[h,l]=a;L.singularValueDecompose2dScale(e.baseTransform,a),a[0]*=h,a[1]*=l}else L.singularValueDecompose2dScale(e.baseTransform,a);const o=this._createMeshCanvas(a,i===Pt.SHADING?null:this._background,e.cachedCanvases);return i!==Pt.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(o.offsetX,o.offsetY),t.scale(o.scaleX,o.scaleY),t.createPattern(o.canvas,"no-repeat")}}class Xf extends Qc{getPattern(){return"hotpink"}}function Kf(r){switch(r[0]){case"RadialAxial":return new jf(r);case"Mesh":return new qf(r);case"Dummy":return new Xf}throw new Error(`Unknown IR type: ${r[0]}`)}const fp={COLORED:1,UNCOLORED:2},mp=class tf{constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i}createPatternCanvas(t){const{bbox:e,operatorList:s,paintType:i,tilingType:a,color:o,canvasGraphicsFactory:h}=this;let{xstep:l,ystep:d}=this;l=Math.abs(l),d=Math.abs(d),Ho("TilingType: "+a);const c=e[0],u=e[1],g=e[2],w=e[3],b=g-c,A=w-u,v=new Float32Array(2);L.singularValueDecompose2dScale(this.matrix,v);const[y,S]=v;L.singularValueDecompose2dScale(this.baseTransform,v);const _=y*v[0],x=S*v[1];let E=b,M=A,k=!1,T=!1;const R=Math.ceil(l*_),B=Math.ceil(d*x),H=Math.ceil(b*_),q=Math.ceil(A*x);R>=H?E=l:k=!0,B>=q?M=d:T=!0;const Z=this.getSizeAndScale(E,this.ctx.canvas.width,_),K=this.getSizeAndScale(M,this.ctx.canvas.height,x),O=t.cachedCanvases.getCanvas("pattern",Z.size,K.size),I=O.context,tt=h.createCanvasGraphics(I);if(tt.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(tt,i,o),I.translate(-Z.scale*c,-K.scale*u),tt.transform(Z.scale,0,0,K.scale,0,0),I.save(),this.clipBbox(tt,c,u,g,w),tt.baseTransform=rt(tt.ctx),tt.executeOperatorList(s),tt.endDrawing(),I.restore(),k||T){const fe=O.canvas;k&&(E=l),T&&(M=d);const xi=this.getSizeAndScale(E,this.ctx.canvas.width,_),Ei=this.getSizeAndScale(M,this.ctx.canvas.height,x),ls=xi.size,Et=Ei.size,ct=t.cachedCanvases.getCanvas("pattern-workaround",ls,Et),_n=ct.context,Os=k?Math.floor(b/l):0,Ws=T?Math.floor(A/d):0;for(let ht=0;ht<=Os;ht++)for(let Ha=0;Ha<=Ws;Ha++)_n.drawImage(fe,ls*ht,Et*Ha,ls,Et,0,0,ls,Et);return{canvas:ct.canvas,scaleX:xi.scale,scaleY:Ei.scale,offsetX:c,offsetY:u}}return{canvas:O.canvas,scaleX:Z.scale,scaleY:K.scale,offsetX:c,offsetY:u}}getSizeAndScale(t,e,s){const i=Math.max(tf.MAX_PATTERN_SIZE,e);let a=Math.ceil(t*s);return a>=i?a=i:s=a/t,{scale:s,size:a}}clipBbox(t,e,s,i,a){const o=i-e,h=a-s;t.ctx.rect(e,s,o,h),L.axialAlignedBoundingBox([e,s,i,a],rt(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,a=t.current;switch(e){case fp.COLORED:const{fillStyle:o,strokeStyle:h}=this.ctx;i.fillStyle=a.fillColor=o,i.strokeStyle=a.strokeColor=h;break;case fp.UNCOLORED:i.fillStyle=i.strokeStyle=s,a.fillColor=a.strokeColor=s;break;default:throw new mf(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i){let a=s;i!==Pt.SHADING&&(a=L.transform(a,e.baseTransform),this.matrix&&(a=L.transform(a,this.matrix)));const o=this.createPatternCanvas(e);let h=new DOMMatrix(a);h=h.translate(o.offsetX,o.offsetY),h=h.scale(1/o.scaleX,1/o.scaleY);const l=t.createPattern(o.canvas,"repeat");return l.setTransform(h),l}};C(mp,"MAX_PATTERN_SIZE",3e3);let Yf=mp;function Qf({src:r,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){const h=Mt.isLittleEndian?4278190080:255,[l,d]=o?[a,h]:[h,a],c=s>>3,u=s&7,g=r.length;e=new Uint32Array(e.buffer);let w=0;for(let b=0;b<i;b++){for(const v=t+c;t<v;t++){const y=t<g?r[t]:255;e[w++]=y&128?d:l,e[w++]=y&64?d:l,e[w++]=y&32?d:l,e[w++]=y&16?d:l,e[w++]=y&8?d:l,e[w++]=y&4?d:l,e[w++]=y&2?d:l,e[w++]=y&1?d:l}if(u===0)continue;const A=t<g?r[t++]:255;for(let v=0;v<u;v++)e[w++]=A&1<<7-v?d:l}return{srcPos:t,destPos:w}}const wp=16,bp=100,Jf=15,Ap=10,ee=16,Zc=new DOMMatrix,le=new Float32Array(2),Jn=new Float32Array([1/0,1/0,-1/0,-1/0]);function Zf(r,t){if(r._removeMirroring)throw new Error("Context is already forwarding operations.");r.__originalSave=r.save,r.__originalRestore=r.restore,r.__originalRotate=r.rotate,r.__originalScale=r.scale,r.__originalTranslate=r.translate,r.__originalTransform=r.transform,r.__originalSetTransform=r.setTransform,r.__originalResetTransform=r.resetTransform,r.__originalClip=r.clip,r.__originalMoveTo=r.moveTo,r.__originalLineTo=r.lineTo,r.__originalBezierCurveTo=r.bezierCurveTo,r.__originalRect=r.rect,r.__originalClosePath=r.closePath,r.__originalBeginPath=r.beginPath,r._removeMirroring=()=>{r.save=r.__originalSave,r.restore=r.__originalRestore,r.rotate=r.__originalRotate,r.scale=r.__originalScale,r.translate=r.__originalTranslate,r.transform=r.__originalTransform,r.setTransform=r.__originalSetTransform,r.resetTransform=r.__originalResetTransform,r.clip=r.__originalClip,r.moveTo=r.__originalMoveTo,r.lineTo=r.__originalLineTo,r.bezierCurveTo=r.__originalBezierCurveTo,r.rect=r.__originalRect,r.closePath=r.__originalClosePath,r.beginPath=r.__originalBeginPath,delete r._removeMirroring},r.save=function(){t.save(),this.__originalSave()},r.restore=function(){t.restore(),this.__originalRestore()},r.translate=function(e,s){t.translate(e,s),this.__originalTranslate(e,s)},r.scale=function(e,s){t.scale(e,s),this.__originalScale(e,s)},r.transform=function(e,s,i,a,o,h){t.transform(e,s,i,a,o,h),this.__originalTransform(e,s,i,a,o,h)},r.setTransform=function(e,s,i,a,o,h){t.setTransform(e,s,i,a,o,h),this.__originalSetTransform(e,s,i,a,o,h)},r.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},r.rotate=function(e){t.rotate(e),this.__originalRotate(e)},r.clip=function(e){t.clip(e),this.__originalClip(e)},r.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},r.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},r.bezierCurveTo=function(e,s,i,a,o,h){t.bezierCurveTo(e,s,i,a,o,h),this.__originalBezierCurveTo(e,s,i,a,o,h)},r.rect=function(e,s,i,a){t.rect(e,s,i,a),this.__originalRect(e,s,i,a)},r.closePath=function(){t.closePath(),this.__originalClosePath()},r.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class tm{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 Ch(r,t,e,s,i,a,o,h,l,d){const[c,u,g,w,b,A]=rt(r);if(u===0&&g===0){const S=o*c+b,_=Math.round(S),x=h*w+A,E=Math.round(x),M=(o+l)*c+b,k=Math.abs(Math.round(M)-_)||1,T=(h+d)*w+A,R=Math.abs(Math.round(T)-E)||1;return r.setTransform(Math.sign(c),0,0,Math.sign(w),_,E),r.drawImage(t,e,s,i,a,0,0,k,R),r.setTransform(c,u,g,w,b,A),[k,R]}if(c===0&&w===0){const S=h*g+b,_=Math.round(S),x=o*u+A,E=Math.round(x),M=(h+d)*g+b,k=Math.abs(Math.round(M)-_)||1,T=(o+l)*u+A,R=Math.abs(Math.round(T)-E)||1;return r.setTransform(0,Math.sign(u),Math.sign(g),0,_,E),r.drawImage(t,e,s,i,a,0,0,R,k),r.setTransform(c,u,g,w,b,A),[R,k]}r.drawImage(t,e,s,i,a,o,h,l,d);const v=Math.hypot(c,u),y=Math.hypot(g,w);return[v*l,y*d]}class vp{constructor(t,e){C(this,"alphaIsShape",!1),C(this,"fontSize",0),C(this,"fontSizeScale",1),C(this,"textMatrix",null),C(this,"textMatrixScale",1),C(this,"fontMatrix",dc),C(this,"leading",0),C(this,"x",0),C(this,"y",0),C(this,"lineX",0),C(this,"lineY",0),C(this,"charSpacing",0),C(this,"wordSpacing",0),C(this,"textHScale",1),C(this,"textRenderingMode",Bt.FILL),C(this,"textRise",0),C(this,"fillColor","#000000"),C(this,"strokeColor","#000000"),C(this,"patternFill",!1),C(this,"patternStroke",!1),C(this,"fillAlpha",1),C(this,"strokeAlpha",1),C(this,"lineWidth",1),C(this,"activeSMask",null),C(this,"transferMaps","none"),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=Jn.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=Pt.FILL,e=null){const s=this.minMax.slice();if(t===Pt.STROKE){e||Y("Stroke bounding box must include transform."),L.singularValueDecompose2dScale(e,le);const i=le[0]*this.lineWidth/2,a=le[1]*this.lineWidth/2;s[0]-=i,s[1]-=a,s[2]+=i,s[3]+=a}return s}updateClipFromPath(){const t=L.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(Jn,0)}getClippedPathBoundingBox(t=Pt.FILL,e=null){return L.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function yp(r,t){if(t instanceof ImageData){r.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%ee,a=(e-i)/ee,o=i===0?a:a+1,h=r.createImageData(s,ee);let l=0,d;const c=t.data,u=h.data;let g,w,b,A;if(t.kind===$a.GRAYSCALE_1BPP){const v=c.byteLength,y=new Uint32Array(u.buffer,0,u.byteLength>>2),S=y.length,_=s+7>>3,x=4294967295,E=Mt.isLittleEndian?4278190080:255;for(g=0;g<o;g++){for(b=g<a?ee:i,d=0,w=0;w<b;w++){const M=v-l;let k=0;const T=M>_?s:M*8-7,R=T&-8;let B=0,H=0;for(;k<R;k+=8)H=c[l++],y[d++]=H&128?x:E,y[d++]=H&64?x:E,y[d++]=H&32?x:E,y[d++]=H&16?x:E,y[d++]=H&8?x:E,y[d++]=H&4?x:E,y[d++]=H&2?x:E,y[d++]=H&1?x:E;for(;k<T;k++)B===0&&(H=c[l++],B=128),y[d++]=H&B?x:E,B>>=1}for(;d<S;)y[d++]=0;r.putImageData(h,0,g*ee)}}else if(t.kind===$a.RGBA_32BPP){for(w=0,A=s*ee*4,g=0;g<a;g++)u.set(c.subarray(l,l+A)),l+=A,r.putImageData(h,0,w),w+=ee;g<o&&(A=s*i*4,u.set(c.subarray(l,l+A)),r.putImageData(h,0,w))}else if(t.kind===$a.RGB_24BPP)for(b=ee,A=s*b,g=0;g<o;g++){for(g>=a&&(b=i,A=s*b),d=0,w=A;w--;)u[d++]=c[l++],u[d++]=c[l++],u[d++]=c[l++],u[d++]=255;r.putImageData(h,0,g*ee)}else throw new Error(`bad image kind: ${t.kind}`)}function _p(r,t){if(t.bitmap){r.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%ee,a=(e-i)/ee,o=i===0?a:a+1,h=r.createImageData(s,ee);let l=0;const d=t.data,c=h.data;for(let u=0;u<o;u++){const g=u<a?ee:i;({srcPos:l}=Qf({src:d,srcPos:l,dest:c,width:s,height:g,nonBlackColor:0})),r.putImageData(h,0,u*ee)}}function Mr(r,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)r[s]!==void 0&&(t[s]=r[s]);r.setLineDash!==void 0&&(t.setLineDash(r.getLineDash()),t.lineDashOffset=r.lineDashOffset)}function Th(r){r.strokeStyle=r.fillStyle="#000000",r.fillRule="nonzero",r.globalAlpha=1,r.lineWidth=1,r.lineCap="butt",r.lineJoin="miter",r.miterLimit=10,r.globalCompositeOperation="source-over",r.font="10px sans-serif",r.setLineDash!==void 0&&(r.setLineDash([]),r.lineDashOffset=0);const{filter:t}=r;t!=="none"&&t!==""&&(r.filter="none")}function Sp(r,t){if(t)return!0;L.singularValueDecompose2dScale(r,le);const e=Math.fround(Ge.pixelRatio*Ci.PDF_TO_CSS_UNITS);return le[0]<=e&&le[1]<=e}const em=["butt","round","square"],sm=["miter","round","bevel"],im={},xp={};var ei,td,ed,sd;const nm=class ef{constructor(t,e,s,i,a,{optionalContentConfig:o,markedContentStack:h=null},l,d){f(this,ei),this.ctx=t,this.current=new vp(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=a,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=h||[],this.optionalContentConfig=o,this.cachedCanvases=new tm(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=d,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 a=this.ctx.canvas.width,o=this.ctx.canvas.height,h=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,a,o),this.ctx.fillStyle=h,s){const l=this.cachedCanvases.getCanvas("transparent",a,o);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...rt(this.compositeCtx))}this.ctx.save(),Th(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=rt(this.ctx)}executeOperatorList(t,e,s,i){const a=t.argsArray,o=t.fnArray;let h=e||0;const l=a.length;if(l===h)return h;const d=l-h>Ap&&typeof s=="function",c=d?Date.now()+Jf:0;let u=0;const g=this.commonObjs,w=this.objs;let b;for(;;){if(i!==void 0&&h===i.nextBreakPoint)return i.breakIt(h,s),h;if(b=o[h],b!==za.dependency)this[b].apply(this,a[h]);else for(const A of a[h]){const v=A.startsWith("g_")?g:w;if(!v.has(A))return v.get(A,s),h}if(h++,h===l)return h;if(d&&++u>Ap){if(Date.now()>c)return s(),h;u=0}}}endDrawing(){m(this,ei,td).call(this),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(),m(this,ei,ed).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),h=s,l=i,d="prescale1",c,u;for(;a>2&&h>1||o>2&&l>1;){let g=h,w=l;a>2&&h>1&&(g=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h/2),a/=h/g),o>2&&l>1&&(w=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,o/=l/w),c=this.cachedCanvases.getCanvas(d,g,w),u=c.context,u.clearRect(0,0,g,w),u.drawImage(t,0,0,h,l,0,0,g,w),t=c.canvas,h=g,l=w,d=d==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:h,paintHeight:l}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,a=this.current.fillColor,o=this.current.patternFill,h=rt(e);let l,d,c,u;if((t.bitmap||t.data)&&t.count>1){const R=t.bitmap||t.data.buffer;d=JSON.stringify(o?h:[h.slice(0,4),a]),l=this._cachedBitmapsMap.get(R),l||(l=new Map,this._cachedBitmapsMap.set(R,l));const B=l.get(d);if(B&&!o){const H=Math.round(Math.min(h[0],h[2])+h[4]),q=Math.round(Math.min(h[1],h[3])+h[5]);return{canvas:B,offsetX:H,offsetY:q}}c=B}c||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),_p(u.context,t));let g=L.transform(h,[1/s,0,0,-1/i,0,0]);g=L.transform(g,[1,0,0,1,0,-i]);const w=Jn.slice();L.axialAlignedBoundingBox([0,0,s,i],g,w);const[b,A,v,y]=w,S=Math.round(v-b)||1,_=Math.round(y-A)||1,x=this.cachedCanvases.getCanvas("fillCanvas",S,_),E=x.context,M=b,k=A;E.translate(-M,-k),E.transform(...g),c||(c=this._scaleImage(u.canvas,ze(E)),c=c.img,l&&o&&l.set(d,c)),E.imageSmoothingEnabled=Sp(rt(E),t.interpolate),Ch(E,c,0,0,c.width,c.height,0,0,s,i),E.globalCompositeOperation="source-in";const T=L.transform(ze(E),[1,0,0,1,-M,-k]);return E.fillStyle=o?a.getPattern(e,this,T,Pt.FILL):a,E.fillRect(0,0,s,i),l&&!o&&(this.cachedCanvases.delete("fillCanvas"),l.set(d,x.canvas)),{canvas:x.canvas,offsetX:Math.round(M),offsetY:Math.round(k)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=em[t]}setLineJoin(t){this.ctx.lineJoin=sm[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.ctx.globalAlpha=this.current.fillAlpha=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;const a=this.ctx=i.context;a.setTransform(this.suspendedCtx.getTransform()),Mr(this.suspendedCtx,a),Zf(a,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Mr(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 a=i[0],o=i[1],h=i[2]-a,l=i[3]-o;h===0||l===0||(this.genericComposeSMask(e.context,s,h,l,e.subtype,e.backdrop,e.transferMap,a,o,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,a,o,h,l,d,c,u){let g=t.canvas,w=l-c,b=d-u;if(o)if(w<0||b<0||w+s>g.width||b+i>g.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),y=v.context;y.drawImage(g,-w,-b),y.globalCompositeOperation="destination-atop",y.fillStyle=o,y.fillRect(0,0,s,i),y.globalCompositeOperation="source-over",g=v.canvas,w=b=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(w,b,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=o,t.fillRect(w,b,s,i),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),a==="Alpha"&&h?e.filter=this.filterFactory.addAlphaFilter(h):a==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(h));const A=new Path2D;A.rect(l,d,s,i),e.clip(A),e.globalCompositeOperation="destination-in",e.drawImage(g,w,b,s,i,l,d,s,i),e.restore()}save(){this.inSMaskMode&&Mr(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){if(this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Mr(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,a,o){this.ctx.transform(t,e,s,i,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){let[i]=e;if(!s){i||(i=e[0]=new Path2D),this[t](i);return}if(!(i instanceof Path2D)){const a=e[0]=new Path2D;for(let o=0,h=i.length;o<h;)switch(i[o++]){case Wo.moveTo:a.moveTo(i[o++],i[o++]);break;case Wo.lineTo:a.lineTo(i[o++],i[o++]);break;case Wo.curveTo:a.bezierCurveTo(i[o++],i[o++],i[o++],i[o++],i[o++],i[o++]);break;case Wo.closePath:a.closePath();break;default:G(`Unrecognized drawing path operator: ${i[o-1]}`);break}i=a}L.axialAlignedBoundingBox(s,rt(this.ctx),this.current.minMax),this[t](i)}closePath(){this.ctx.closePath()}stroke(t,e=!0){const s=this.ctx,i=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof i=="object"&&i?.getPattern){const a=i.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=i.getPattern(s,this,ze(s),Pt.STROKE),a){const o=new Path2D;o.addPath(t,s.getTransform().invertSelf().multiplySelf(a)),t=o}this.rescaleAndStroke(t,!1),s.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(Pt.STROKE,rt(this.ctx))),s.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,e=!0){const s=this.ctx,i=this.current.fillColor,a=this.current.patternFill;let o=!1;if(a){const l=i.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.fillStyle=i.getPattern(s,this,ze(s),Pt.FILL),l){const d=new Path2D;d.addPath(t,s.getTransform().invertSelf().multiplySelf(l)),t=d}o=!0}const h=this.current.getClippedPathBoundingBox();this.contentVisible&&h!==null&&(this.pendingEOFill?(s.fill(t,"evenodd"),this.pendingEOFill=!1):s.fill(t)),o&&s.restore(),e&&this.consumePath(t,h)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=im}eoClip(){this.pendingClip=xp}beginText(){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t===void 0)return;const s=new Path2D,i=e.getTransform().invertSelf();for(const{transform:a,x:o,y:h,fontSize:l,path:d}of t)s.addPath(d,new DOMMatrix(a).preMultiplySelf(i).translate(o,h).scale(l,-l));e.clip(s),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||dc,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&G("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 a=s.loadedName||"sans-serif",o=s.systemFontInfo?.css||`"${a}", ${s.fallbackName}`;let h="normal";s.black?h="900":s.bold&&(h="bold");const l=s.italic?"italic":"normal";let d=e;e<wp?d=wp:e>bp&&(d=bp),this.current.fontSizeScale=e/d,this.ctx.font=`${l} ${h} ${d}px ${o}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t){const{current:e}=this;e.textMatrix=t,e.textMatrixScale=Math.hypot(t[0],t[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i,a){const o=this.ctx,h=this.current,l=h.font,d=h.textRenderingMode,c=h.fontSize/h.fontSizeScale,u=d&Bt.FILL_STROKE_MASK,g=!!(d&Bt.ADD_TO_PATH_FLAG),w=h.patternFill&&!l.missingFile,b=h.patternStroke&&!l.missingFile;let A;if((l.disableFontFace||g||w||b)&&(A=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||w||b){o.save(),o.translate(e,s),o.scale(c,-c);let v;if((u===Bt.FILL||u===Bt.FILL_STROKE)&&(i?(v=o.getTransform(),o.setTransform(...i),o.fill(m(this,ei,sd).call(this,A,v,i))):o.fill(A)),u===Bt.STROKE||u===Bt.FILL_STROKE)if(a){v||(v=o.getTransform()),o.setTransform(...a);const{a:y,b:S,c:_,d:x}=v,E=L.inverseTransform(a),M=L.transform([y,S,_,x,0,0],E);L.singularValueDecompose2dScale(M,le),o.lineWidth*=Math.max(le[0],le[1])/c,o.stroke(m(this,ei,sd).call(this,A,v,a))}else o.lineWidth/=c,o.stroke(A);o.restore()}else(u===Bt.FILL||u===Bt.FILL_STROKE)&&o.fillText(t,e,s),(u===Bt.STROKE||u===Bt.FILL_STROKE)&&o.strokeText(t,e,s);g&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:rt(o),x:e,y:s,fontSize:c,path:A})}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 z(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 a=this.ctx,o=e.fontSizeScale,h=e.charSpacing,l=e.wordSpacing,d=e.fontDirection,c=e.textHScale*d,u=t.length,g=s.vertical,w=g?1:-1,b=s.defaultVMetrics,A=i*e.fontMatrix[0],v=e.textRenderingMode===Bt.FILL&&!s.disableFontFace&&!e.patternFill;a.save(),e.textMatrix&&a.transform(...e.textMatrix),a.translate(e.x,e.y+e.textRise),d>0?a.scale(c,-1):a.scale(c,1);let y,S;if(e.patternFill){a.save();const k=e.fillColor.getPattern(a,this,ze(a),Pt.FILL);y=rt(a),a.restore(),a.fillStyle=k}if(e.patternStroke){a.save();const k=e.strokeColor.getPattern(a,this,ze(a),Pt.STROKE);S=rt(a),a.restore(),a.strokeStyle=k}let _=e.lineWidth;const x=e.textMatrixScale;if(x===0||_===0){const k=e.textRenderingMode&Bt.FILL_STROKE_MASK;(k===Bt.STROKE||k===Bt.FILL_STROKE)&&(_=this.getSinglePixelWidth())}else _/=x;if(o!==1&&(a.scale(o,o),_/=o),a.lineWidth=_,s.isInvalidPDFjsFont){const k=[];let T=0;for(const R of t)k.push(R.unicode),T+=R.width;a.fillText(k.join(""),0,0),e.x+=T*A*c,a.restore(),this.compose();return}let E=0,M;for(M=0;M<u;++M){const k=t[M];if(typeof k=="number"){E+=w*k*i/1e3;continue}let T=!1;const R=(k.isSpace?l:0)+h,B=k.fontChar,H=k.accent;let q,Z,K=k.width;if(g){const I=k.vmetric||b,tt=-(k.vmetric?I[1]:K*.5)*A,fe=I[2]*A;K=I?-I[0]:K,q=tt/o,Z=(E+fe)/o}else q=E/o,Z=0;if(s.remeasure&&K>0){const I=a.measureText(B).width*1e3/i*o;if(K<I&&this.isFontSubpixelAAEnabled){const tt=K/I;T=!0,a.save(),a.scale(tt,1),q/=tt}else K!==I&&(q+=(K-I)/2e3*i/o)}if(this.contentVisible&&(k.isInFont||s.missingFile)){if(v&&!H)a.fillText(B,q,Z);else if(this.paintChar(B,q,Z,y,S),H){const I=q+i*H.offset.x/o,tt=Z-i*H.offset.y/o;this.paintChar(H.fontChar,I,tt,y,S)}}const O=g?K*A-R*d:K*A+R*d;E+=O,T&&a.restore()}g?e.y-=E:e.x+=E*c,a.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,a=s.fontSize,o=s.fontDirection,h=i.vertical?1:-1,l=s.charSpacing,d=s.wordSpacing,c=s.textHScale*o,u=s.fontMatrix||dc,g=t.length,w=s.textRenderingMode===Bt.INVISIBLE;let b,A,v,y;if(!(w||a===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),s.textMatrix&&e.transform(...s.textMatrix),e.translate(s.x,s.y+s.textRise),e.scale(c,o),b=0;b<g;++b){if(A=t[b],typeof A=="number"){y=h*A*a/1e3,this.ctx.translate(y,0),s.x+=y*c;continue}const S=(A.isSpace?d:0)+l,_=i.charProcOperatorList[A.operatorListId];_?this.contentVisible&&(this.save(),e.scale(a,a),e.transform(...u),this.executeOperatorList(_),this.restore()):G(`Type3 character "${A.operatorListId}" is not available.`);const x=[A.width,0];L.applyTransform(x,u),v=x[0]*a+S,e.translate(v,0),s.x+=v*c}e.restore()}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,a,o){const h=new Path2D;h.rect(s,i,a-s,o-i),this.ctx.clip(h),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=this.baseTransform||rt(this.ctx),i={createCanvasGraphics:a=>new ef(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Yf(t,this.ctx,i,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t){this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t){this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=Kf(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,ze(e),Pt.SHADING);const i=ze(e);if(i){const{width:a,height:o}=e.canvas,h=Jn.slice();L.axialAlignedBoundingBox([0,0,a,o],i,h);const[l,d,c,u]=h;this.ctx.fillRect(l,d,c-l,u-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Y("Should not call beginInlineImage")}beginImageData(){Y("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=rt(this.ctx),e)){L.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[s,i,a,o]=e,h=new Path2D;h.rect(s,i,a-s,o-i),this.ctx.clip(h),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||Ho("TODO: Support non-isolated groups."),t.knockout&&G("Knockout groups not supported.");const s=rt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=Jn.slice();L.axialAlignedBoundingBox(t.bbox,rt(e),i);const a=[0,0,e.canvas.width,e.canvas.height];i=L.intersect(i,a)||[0,0,0,0];const o=Math.floor(i[0]),h=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-o,1),d=Math.max(Math.ceil(i[3])-h,1);this.current.startNewPathAndClipBox([0,0,l,d]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(c,l,d),g=u.context;g.translate(-o,-h),g.transform(...s);let w=new Path2D;const[b,A,v,y]=t.bbox;if(w.rect(b,A,v-b,y-A),t.matrix){const S=new Path2D;S.addPath(w,new DOMMatrix(t.matrix)),w=S}g.clip(w),t.smask?this.smaskStack.push({canvas:u.canvas,context:g,offsetX:o,offsetY:h,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(o,h),e.save()),Mr(e,g),this.ctx=g,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=rt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const a=Jn.slice();L.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i,a),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(t,e,s,i,a){if(m(this,ei,td).call(this),Th(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const o=e[2]-e[0],h=e[3]-e[1];if(a&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=o,e[3]=h,L.singularValueDecompose2dScale(rt(this.ctx),le);const{viewportScale:l}=this,d=Math.ceil(o*this.outputScaleX*l),c=Math.ceil(h*this.outputScaleY*l);this.annotationCanvas=this.canvasFactory.create(d,c);const{canvas:u,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(t,u),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.save(),this.ctx.setTransform(le[0],0,0,-le[1],0,h*le[1]),Th(this.ctx)}else{Th(this.ctx),this.endPath();const l=new Path2D;l.rect(e[0],e[1],o,h),this.ctx.clip(l)}}this.current=new vp(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),m(this,ei,ed).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;t=this.getObject(t.data,t),t.count=e;const s=this.ctx,i=this._createMaskCanvas(t),a=i.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,i.offsetX,i.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,a,o){if(!this.contentVisible)return;t=this.getObject(t.data,t);const h=this.ctx;h.save();const l=rt(h);h.transform(e,s,i,a,0,0);const d=this._createMaskCanvas(t);h.setTransform(1,0,0,1,d.offsetX-l[4],d.offsetY-l[5]);for(let c=0,u=o.length;c<u;c+=2){const g=L.transform(l,[e,s,i,a,o[c],o[c+1]]);h.drawImage(d.canvas,g[4],g[5])}h.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const a of t){const{data:o,width:h,height:l,transform:d}=a,c=this.cachedCanvases.getCanvas("maskCanvas",h,l),u=c.context;u.save();const g=this.getObject(o,a);_p(u,g),u.globalCompositeOperation="source-in",u.fillStyle=i?s.getPattern(u,this,ze(e),Pt.FILL):s,u.fillRect(0,0,h,l),u.restore(),e.save(),e.transform(...d),e.scale(1,-1),Ch(e,c.canvas,0,0,h,l,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){G("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const a=this.getObject(t);if(!a){G("Dependent image isn't ready yet");return}const o=a.width,h=a.height,l=[];for(let d=0,c=i.length;d<c;d+=2)l.push({transform:[e,0,0,s,i[d],i[d+1]],x:0,y:0,w:o,h});this.paintInlineImageXObjectGroup(a,l)}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,a=this.cachedCanvases.getCanvas("inlineImage",s,i),o=a.context;return o.filter=this.current.transferMaps,o.drawImage(e,0,0),o.filter="none",a.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;this.save();const{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none"),i.scale(1/e,-1/s);let o;if(t.bitmap)o=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)o=t;else{const l=this.cachedCanvases.getCanvas("inlineImage",e,s).context;yp(l,t),o=this.applyTransferMapsToCanvas(l)}const h=this._scaleImage(o,ze(i));i.imageSmoothingEnabled=Sp(rt(i),t.interpolate),Ch(i,h.img,0,0,h.paintWidth,h.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 a=t.width,o=t.height,h=this.cachedCanvases.getCanvas("inlineImage",a,o).context;yp(h,t),i=this.applyTransferMapsToCanvas(h)}for(const a of e)s.save(),s.transform(...a.transform),s.scale(1,-1),Ch(s,i,a.x,a.y,a.w,a.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,e){const s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const i=this.ctx;this.pendingClip&&(s||(this.pendingClip===xp?i.clip(t,"evenodd"):i.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=rt(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:a}=this.ctx.getTransform();let o,h;if(s===0&&i===0){const l=Math.abs(e),d=Math.abs(a);if(l===d)if(t===0)o=h=1/l;else{const c=l*t;o=h=c<1?1/c:1}else if(t===0)o=1/l,h=1/d;else{const c=l*t,u=d*t;o=c<1?1/c:1,h=u<1?1/u:1}}else{const l=Math.abs(e*a-s*i),d=Math.hypot(e,s),c=Math.hypot(i,a);if(t===0)o=c/l,h=d/l;else{const u=t*l;o=c>u?c/u:1,h=d>u?d/u:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=h}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[a,o]=this.getScaleForStroking();if(a===o){s.lineWidth=(i||1)*a,s.stroke(t);return}const h=s.getLineDash();e&&s.save(),s.scale(a,o),Zc.a=1/a,Zc.d=1/o;const l=new Path2D;if(l.addPath(t,Zc),h.length>0){const d=Math.max(a,o);s.setLineDash(h.map(c=>c/d)),s.lineDashOffset/=d}s.lineWidth=i||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};ei=new WeakSet,td=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},ed=function(){if(this.pageColors){const r=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(r!=="none"){const t=this.ctx.filter;this.ctx.filter=r,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}},sd=function(r,t,e){const s=new Path2D;return s.addPath(r,new DOMMatrix(e).invertSelf().multiplySelf(t)),s};let Rh=nm;for(const r in za)Rh.prototype[r]!==void 0&&(Rh.prototype[za[r]]=Rh.prototype[r]);var Ph,Ih;class Ss{static get workerPort(){return n(this,Ph)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Ph,t)}static get workerSrc(){return n(this,Ih)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,Ih,t)}}Ph=new WeakMap,Ih=new WeakMap,f(Ss,Ph,null),f(Ss,Ih,"");var kr,Lh;class am{constructor({parsedData:t,rawData:e}){f(this,kr),f(this,Lh),p(this,kr,t),p(this,Lh,e)}getRaw(){return n(this,Lh)}get(t){return n(this,kr).get(t)??null}[Symbol.iterator](){return n(this,kr).entries()}}kr=new WeakMap,Lh=new WeakMap;const Zn=Symbol("INTERNAL");var Dh,Nh,Fh,Cr;class rm{constructor(t,{name:e,intent:s,usage:i,rbGroups:a}){f(this,Dh,!1),f(this,Nh,!1),f(this,Fh,!1),f(this,Cr,!0),p(this,Dh,!!(t&oe.DISPLAY)),p(this,Nh,!!(t&oe.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=a}get visible(){if(n(this,Fh))return n(this,Cr);if(!n(this,Cr))return!1;const{print:t,view:e}=this.usage;return n(this,Dh)?e?.viewState!=="OFF":n(this,Nh)?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Zn&&Y("Internal method `_setVisible` called."),p(this,Fh,s),p(this,Cr,e)}}Dh=new WeakMap,Nh=new WeakMap,Fh=new WeakMap,Cr=new WeakMap;var ji,J,Tr,Rr,Oh,id;class om{constructor(t,e=oe.DISPLAY){if(f(this,Oh),f(this,ji,null),f(this,J,new Map),f(this,Tr,null),f(this,Rr,null),this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,Rr,t.order);for(const s of t.groups)n(this,J).set(s.id,new rm(e,s));if(t.baseState==="OFF")for(const s of n(this,J).values())s._setVisible(Zn,!1);for(const s of t.on)n(this,J).get(s)._setVisible(Zn,!0);for(const s of t.off)n(this,J).get(s)._setVisible(Zn,!1);p(this,Tr,this.getHash())}}isVisible(t){if(n(this,J).size===0)return!0;if(!t)return Ho("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,J).has(t.id)?n(this,J).get(t.id).visible:(G(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return m(this,Oh,id).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,J).has(e))return G(`Optional content group not found: ${e}`),!0;if(n(this,J).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,J).has(e))return G(`Optional content group not found: ${e}`),!0;if(!n(this,J).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,J).has(e))return G(`Optional content group not found: ${e}`),!0;if(!n(this,J).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,J).has(e))return G(`Optional content group not found: ${e}`),!0;if(n(this,J).get(e).visible)return!1}return!0}return G(`Unknown optional content policy ${t.policy}.`),!0}return G(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){const i=n(this,J).get(t);if(!i){G(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&n(this,J).get(o)?._setVisible(Zn,!1,!0);i._setVisible(Zn,!!e,!0),p(this,ji,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 a=n(this,J).get(i);if(a)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!a.visible,e);break}}p(this,ji,null)}get hasInitialVisibility(){return n(this,Tr)===null||this.getHash()===n(this,Tr)}getOrder(){return n(this,J).size?n(this,Rr)?n(this,Rr).slice():[...n(this,J).keys()]:null}getGroup(t){return n(this,J).get(t)||null}getHash(){if(n(this,ji)!==null)return n(this,ji);const t=new Ju;for(const[e,s]of n(this,J))t.update(`${e}:${s.visible}`);return p(this,ji,t.hexdigest())}[Symbol.iterator](){return n(this,J).entries()}}ji=new WeakMap,J=new WeakMap,Tr=new WeakMap,Rr=new WeakMap,Oh=new WeakSet,id=function(r){const t=r.length;if(t<2)return!0;const e=r[0];for(let s=1;s<t;s++){const i=r[s];let a;if(Array.isArray(i))a=m(this,Oh,id).call(this,i);else if(n(this,J).has(i))a=n(this,J).get(i).visible;else return G(`Optional content group not found: ${i}`),!0;switch(e){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return e==="And"};class hm{constructor(t,{disableRange:e=!1,disableStream:s=!1}){ft(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:a,progressiveDone:o,contentDispositionFilename:h}=t;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=h,a?.length>0){const l=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,d)=>{this._onReceiveData({begin:l,chunk:d})}),t.addProgressListener((l,d)=>{this._onProgress({loaded:l,total:d})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),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(a){return a._begin!==t?!1:(a._enqueue(s),!0)});ft(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(){ft(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new lm(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new cm(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 lm{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Uo(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const a of this._queuedChunks)this._loaded+=a.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 cm{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 e of this._requests)e.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 dm(r){let t=!0,e=s("filename\\*","i").exec(r);if(e){e=e[1];let c=h(e);return c=unescape(c),c=l(c),c=d(c),a(c)}if(e=o(r),e){const c=d(e);return a(c)}if(e=s("filename","i").exec(r),e){e=e[1];let c=h(e);return c=d(c),a(c)}function s(c,u){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(c,u){if(c){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const g=new TextDecoder(c,{fatal:!0}),w=ja(u);u=g.decode(w),t=!1}catch{}}return u}function a(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function o(c){const u=[];let g;const w=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(g=w.exec(c))!==null;){let[,A,v,y]=g;if(A=parseInt(A,10),A in u){if(A===0)break;continue}u[A]=[v,y]}const b=[];for(let A=0;A<u.length&&A in u;++A){let[v,y]=u[A];y=h(y),v&&(y=unescape(y),A===0&&(y=l(y))),b.push(y)}return b.join("")}function h(c){if(c.startsWith('"')){const u=c.slice(1).split('\\"');for(let g=0;g<u.length;++g){const w=u[g].indexOf('"');w!==-1&&(u[g]=u[g].slice(0,w),u.length=g+1),u[g]=u[g].replaceAll(/\\(.)/g,"$1")}c=u.join('"')}return c}function l(c){const u=c.indexOf("'");if(u===-1)return c;const g=c.slice(0,u),w=c.slice(u+1).replace(/^[^']*'/,"");return i(g,w)}function d(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(u,g,w,b){if(w==="q"||w==="Q")return b=b.replaceAll("_"," "),b=b.replaceAll(/=([0-9a-fA-F]{2})/g,function(A,v){return String.fromCharCode(parseInt(v,16))}),i(g,b);try{b=atob(b)}catch{}return i(g,b)})}return""}function Ep(r,t){const e=new Headers;if(!r||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function Wh(r){return URL.parse(r)?.origin??null}function Mp({responseHeaders:r,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(r.get("Content-Length"),10);return!Number.isInteger(a)||(i.suggestedLength=a,a<=2*e)||s||!t||r.get("Accept-Ranges")!=="bytes"||(r.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function kp(r){const t=r.get("Content-Disposition");if(t){let e=dm(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Uo(e))return e}return null}function Pr(r,t){return new Ua(`Unexpected server response (${r}) while retrieving PDF "${t}".`,r,r===404||r===0&&t.startsWith("file:"))}function Cp(r){return r===200||r===206}function Tp(r,t,e){return{method:"GET",headers:r,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Rp(r){return r instanceof Uint8Array?r.buffer:r instanceof ArrayBuffer?r:(G(`getArrayBuffer - unexpected data format: ${r}`),new Uint8Array(r).buffer)}class um{constructor(t){C(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Ep(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ft(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new pm(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new gm(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 pm{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const s=new Headers(t.headers),i=e.url;fetch(i,Tp(s,this._withCredentials,this._abortController)).then(a=>{if(t._responseOrigin=Wh(a.url),!Cp(a.status))throw Pr(a.status,i);this._reader=a.body.getReader(),this._headersCapability.resolve();const o=a.headers,{allowRangeRequests:h,suggestedLength:l}=Mp({responseHeaders:o,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=h,this._contentLength=l||this._contentLength,this._filename=kp(o),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ds("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:Rp(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class gm{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;const a=new Headers(t.headers);a.append("Range",`bytes=${e}-${s-1}`);const o=i.url;fetch(o,Tp(a,this._withCredentials,this._abortController)).then(h=>{const l=Wh(h.url);if(l!==t._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${t._responseOrigin}".`);if(!Cp(h.status))throw Pr(h.status,o);this._readCapability.resolve(),this._reader=h.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:Rp(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const nd=200,ad=206;function fm(r){const t=r.response;return typeof t!="string"?t:ja(t).buffer}class mm{constructor({url:t,httpHeaders:e,withCredentials:s}){C(this,"_responseOrigin",null),this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Ep(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}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[a,o]of this.headers)e.setRequestHeader(a,o);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=ad):i.expectedStatus=nd,e.responseType="arraybuffer",ft(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{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 a=i.status||nd;if(!(a===nd&&s.expectedStatus===ad)&&a!==s.expectedStatus){s.onError(i.status);return}const o=fm(i);if(a===ad){const h=i.getResponseHeader("Content-Range"),l=/bytes (\d+)-(\d+)\/(\d+)/.exec(h);l?s.onDone({begin:parseInt(l[1],10),chunk:o}):(G('Missing or invalid "Content-Range" header.'),s.onError(0))}else o?s.onDone({begin:0,chunk:o}):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 wm{constructor(t){this._source=t,this._manager=new mm(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return ft(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new bm(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Am(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 bm{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Wh(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(h=>{const[l,...d]=h.split(": ");return[l,d.join(": ")]}):[]),{allowRangeRequests:a,suggestedLength:o}=Mp({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});a&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=kp(i),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Pr(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Am{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Wh(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=Pr(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 vm=/^[a-z][a-z0-9\-+.]+:/i;function ym(r){if(vm.test(r))return new URL(r);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(r))}class _m{constructor(t){this.source=t,this.url=ym(t.url),ft(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ft(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Sm(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new xm(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 Sm{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=Pr(0,this._url.href)),this._storedError=i,this._headersCapability.reject(i)})}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 ds("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class xm{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const i=t.source;this._isStreamingSupported=!i.disableStream;const a=process.getBuiltinModule("fs");this._setReadableStream(a.createReadStream(this._url,{start:e,end:s-1}))}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)}}const Ir=Symbol("INITIAL_DATA");var _e,Bh,rd;class Pp{constructor(){f(this,Bh),f(this,_e,Object.create(null))}get(t,e=null){if(e){const i=m(this,Bh,rd).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=n(this,_e)[t];if(!s||s.data===Ir)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,_e)[t];return!!e&&e.data!==Ir}delete(t){const e=n(this,_e)[t];return!e||e.data===Ir?!1:(delete n(this,_e)[t],!0)}resolve(t,e=null){const s=m(this,Bh,rd).call(this,t);s.data=e,s.resolve()}clear(){for(const t in n(this,_e)){const{data:e}=n(this,_e)[t];e?.bitmap?.close()}p(this,_e,Object.create(null))}*[Symbol.iterator](){for(const t in n(this,_e)){const{data:e}=n(this,_e)[t];e!==Ir&&(yield[t,e])}}}_e=new WeakMap,Bh=new WeakSet,rd=function(r){var t;return(t=n(this,_e))[r]||(t[r]={...Promise.withResolvers(),data:Ir})};const Em=1e5,Ip=30;var Vi,ce,Hh,$h,qi,si,Gh,zh,ta,Lr,Dr,Xi,Nr,Uh,Fr,ea,jh,Vh,Or,sa,qh,Ki,Wr,ia,Lp,Dp,od,xs,Xh,hd,Np,Fp;const se=class Lo{constructor({textContentSource:t,container:e,viewport:s}){f(this,ia),f(this,Vi,Promise.withResolvers()),f(this,ce,null),f(this,Hh,!1),f(this,$h,!!globalThis.FontInspector?.enabled),f(this,qi,null),f(this,si,null),f(this,Gh,0),f(this,zh,0),f(this,ta,null),f(this,Lr,null),f(this,Dr,0),f(this,Xi,0),f(this,Nr,Object.create(null)),f(this,Uh,[]),f(this,Fr,null),f(this,ea,[]),f(this,jh,new WeakMap),f(this,Vh,null);var i;if(t instanceof ReadableStream)p(this,Fr,t);else if(typeof t=="object")p(this,Fr,new ReadableStream({start(d){d.enqueue(t),d.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,ce,p(this,Lr,e)),p(this,Xi,s.scale*Ge.pixelRatio),p(this,Dr,s.rotation),p(this,si,{div:null,properties:null,ctx:null});const{pageWidth:a,pageHeight:o,pageX:h,pageY:l}=s.rawDims;p(this,Vh,[1,0,0,-1,-h,l+o]),p(this,zh,a),p(this,Gh,o),m(i=Lo,xs,Np).call(i),Bs(e,s),n(this,Vi).promise.finally(()=>{n(Lo,Wr).delete(this),p(this,si,null),p(this,Nr,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Mt.platform;return z(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{n(this,ta).read().then(({value:e,done:s})=>{if(s){n(this,Vi).resolve();return}n(this,qi)??p(this,qi,e.lang),Object.assign(n(this,Nr),e.styles),m(this,ia,Lp).call(this,e.items),t()},n(this,Vi).reject)};return p(this,ta,n(this,Fr).getReader()),n(Lo,Wr).add(this),t(),n(this,Vi).promise}update({viewport:t,onBefore:e=null}){var s;const i=t.scale*Ge.pixelRatio,a=t.rotation;if(a!==n(this,Dr)&&(e?.(),p(this,Dr,a),Bs(n(this,Lr),{rotation:a})),i!==n(this,Xi)){e?.(),p(this,Xi,i);const o={div:null,properties:null,ctx:m(s=Lo,xs,Xh).call(s,n(this,qi))};for(const h of n(this,ea))o.properties=n(this,jh).get(h),o.div=h,m(this,ia,od).call(this,o)}}cancel(){const t=new ds("TextLayer task cancelled.");n(this,ta)?.cancel(t).catch(()=>{}),p(this,ta,null),n(this,Vi).reject(t)}get textDivs(){return n(this,ea)}get textContentItemsStr(){return n(this,Uh)}static cleanup(){if(!(n(this,Wr).size>0)){n(this,Or).clear();for(const{canvas:t}of n(this,sa).values())t.remove();n(this,sa).clear()}}};Vi=new WeakMap,ce=new WeakMap,Hh=new WeakMap,$h=new WeakMap,qi=new WeakMap,si=new WeakMap,Gh=new WeakMap,zh=new WeakMap,ta=new WeakMap,Lr=new WeakMap,Dr=new WeakMap,Xi=new WeakMap,Nr=new WeakMap,Uh=new WeakMap,Fr=new WeakMap,ea=new WeakMap,jh=new WeakMap,Vh=new WeakMap,Or=new WeakMap,sa=new WeakMap,qh=new WeakMap,Ki=new WeakMap,Wr=new WeakMap,ia=new WeakSet,Lp=function(r){var t,e;if(n(this,Hh))return;(e=n(this,si)).ctx??(e.ctx=m(t=se,xs,Xh).call(t,n(this,qi)));const s=n(this,ea),i=n(this,Uh);for(const a of r){if(s.length>Em){G("Ignoring additional textDivs for performance reasons."),p(this,Hh,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,ce);p(this,ce,document.createElement("span")),n(this,ce).classList.add("markedContent"),a.id!==null&&n(this,ce).setAttribute("id",`${a.id}`),o.append(n(this,ce))}else a.type==="endMarkedContent"&&p(this,ce,n(this,ce).parentNode);continue}i.push(a.str),m(this,ia,Dp).call(this,a)}},Dp=function(r){var t;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:r.str!=="",hasEOL:r.hasEOL,fontSize:0};n(this,ea).push(e);const i=L.transform(n(this,Vh),r.transform);let a=Math.atan2(i[1],i[0]);const o=n(this,Nr)[r.fontName];o.vertical&&(a+=Math.PI/2);let h=n(this,$h)&&o.fontSubstitution||o.fontFamily;h=se.fontFamilyMap.get(h)||h;const l=Math.hypot(i[2],i[3]),d=l*m(t=se,xs,Fp).call(t,h,o,n(this,qi));let c,u;a===0?(c=i[4],u=i[5]-d):(c=i[4]+d*Math.sin(a),u=i[5]-d*Math.cos(a));const g="calc(var(--total-scale-factor) *",w=e.style;n(this,ce)===n(this,Lr)?(w.left=`${(100*c/n(this,zh)).toFixed(2)}%`,w.top=`${(100*u/n(this,Gh)).toFixed(2)}%`):(w.left=`${g}${c.toFixed(2)}px)`,w.top=`${g}${u.toFixed(2)}px)`),w.fontSize=`${g}${(n(se,Ki)*l).toFixed(2)}px)`,w.fontFamily=h,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=r.str,e.dir=r.dir,n(this,$h)&&(e.dataset.fontName=o.fontSubstitutionLoadedName||r.fontName),a!==0&&(s.angle=a*(180/Math.PI));let b=!1;if(r.str.length>1)b=!0;else if(r.str!==" "&&r.transform[0]!==r.transform[3]){const A=Math.abs(r.transform[0]),v=Math.abs(r.transform[3]);A!==v&&Math.max(A,v)/Math.min(A,v)>1.5&&(b=!0)}if(b&&(s.canvasWidth=o.vertical?r.height:r.width),n(this,jh).set(e,s),n(this,si).div=e,n(this,si).properties=s,m(this,ia,od).call(this,n(this,si)),s.hasText&&n(this,ce).append(e),s.hasEOL){const A=document.createElement("br");A.setAttribute("role","presentation"),n(this,ce).append(A)}},od=function(r){var t;const{div:e,properties:s,ctx:i}=r,{style:a}=e;let o="";if(n(se,Ki)>1&&(o=`scale(${1/n(se,Ki)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:h}=a,{canvasWidth:l,fontSize:d}=s;m(t=se,xs,hd).call(t,i,d*n(this,Xi),h);const{width:c}=i.measureText(e.textContent);c>0&&(o=`scaleX(${l*n(this,Xi)/c}) ${o}`)}s.angle!==0&&(o=`rotate(${s.angle}deg) ${o}`),o.length>0&&(a.transform=o)},xs=new WeakSet,Xh=function(r=null){let t=n(this,sa).get(r||(r=""));if(!t){const e=document.createElement("canvas");e.className="hiddenCanvasElement",e.lang=r,document.body.append(e),t=e.getContext("2d",{alpha:!1,willReadFrequently:!0}),n(this,sa).set(r,t),n(this,qh).set(t,{size:0,family:""})}return t},hd=function(r,t,e){const s=n(this,qh).get(r);t===s.size&&e===s.family||(r.font=`${t}px ${e}`,s.size=t,s.family=e)},Np=function(){if(n(this,Ki)!==null)return;const r=document.createElement("div");r.style.opacity=0,r.style.lineHeight=1,r.style.fontSize="1px",r.style.position="absolute",r.textContent="X",document.body.append(r),p(this,Ki,r.getBoundingClientRect().height),r.remove()},Fp=function(r,t,e){const s=n(this,Or).get(r);if(s)return s;const i=m(this,xs,Xh).call(this,e);i.canvas.width=i.canvas.height=Ip,m(this,xs,hd).call(this,i,Ip,r);const a=i.measureText(""),o=a.fontBoundingBoxAscent,h=Math.abs(a.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let l=.8;return o?l=o/(o+h):(Mt.platform.isFirefox&&G("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),t.ascent?l=t.ascent:t.descent&&(l=1+t.descent)),n(this,Or).set(r,l),l},f(se,xs),f(se,Or,new Map),f(se,sa,new Map),f(se,qh,new WeakMap),f(se,Ki,null),f(se,Wr,new Set);let Kh=se;class Oo{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(a){if(!a)return;let o=null;const h=a.name;if(h==="#text")o=a.value;else if(Oo.shouldBuildText(h))a?.attributes?.textContent?o=a.attributes.textContent:a.value&&(o=a.value);else return;if(o!==null&&e.push({str:o}),!!a.children)for(const l of a.children)i(l)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const Mm=100;function Op(r={}){typeof r=="string"||r instanceof URL?r={url:r}:(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});const t=new km,{docId:e}=t,s=r.url?Df(r.url):null,i=r.data?Nf(r.data):null,a=r.httpHeaders||null,o=r.withCredentials===!0,h=r.password??null,l=r.range instanceof cd?r.range:null,d=Number.isInteger(r.rangeChunkSize)&&r.rangeChunkSize>0?r.rangeChunkSize:2**16;let c=r.worker instanceof sl?r.worker:null;const u=r.verbosity,g=typeof r.docBaseUrl=="string"&&!Va(r.docBaseUrl)?r.docBaseUrl:null,w=Sh(r.cMapUrl),b=r.cMapPacked!==!1,A=r.CMapReaderFactory||(Xt?Gf:hp),v=Sh(r.iccUrl),y=Sh(r.standardFontDataUrl),S=r.StandardFontDataFactory||(Xt?zf:up),_=Sh(r.wasmUrl),x=r.WasmFactory||(Xt?Uf:gp),E=r.stopAtErrors!==!0,M=Number.isInteger(r.maxImageSize)&&r.maxImageSize>-1?r.maxImageSize:-1,k=r.isEvalSupported!==!1,T=typeof r.isOffscreenCanvasSupported=="boolean"?r.isOffscreenCanvasSupported:!Xt,R=typeof r.isImageDecoderSupported=="boolean"?r.isImageDecoderSupported:!Xt&&(Mt.platform.isFirefox||!globalThis.chrome),B=Number.isInteger(r.canvasMaxAreaInBytes)?r.canvasMaxAreaInBytes:-1,H=typeof r.disableFontFace=="boolean"?r.disableFontFace:Xt,q=r.fontExtraProperties===!0,Z=r.enableXfa===!0,K=r.ownerDocument||globalThis.document,O=r.disableRange===!0,I=r.disableStream===!0,tt=r.disableAutoFetch===!0,fe=r.pdfBug===!0,xi=r.CanvasFactory||(Xt?$f:Wf),Ei=r.FilterFactory||(Xt?Hf:Bf),ls=r.enableHWA===!0,Et=r.useWasm!==!1,ct=l?l.length:r.length??NaN,_n=typeof r.useSystemFonts=="boolean"?r.useSystemFonts:!Xt&&!H,Os=typeof r.useWorkerFetch=="boolean"?r.useWorkerFetch:!!(A===hp&&S===up&&x===gp&&w&&y&&_&&qa(w,document.baseURI)&&qa(y,document.baseURI)&&qa(_,document.baseURI)),Ws=null;pf(u);const ht={canvasFactory:new xi({ownerDocument:K,enableHWA:ls}),filterFactory:new Ei({docId:e,ownerDocument:K}),cMapReaderFactory:Os?null:new A({baseUrl:w,isCompressed:b}),standardFontDataFactory:Os?null:new S({baseUrl:y}),wasmFactory:Os?null:new x({baseUrl:_})};c||(c=sl.create({verbosity:u,port:Ss.workerPort}),t._worker=c);const Ha={docId:e,apiVersion:"5.3.31",data:i,password:h,disableAutoFetch:tt,rangeChunkSize:d,length:ct,docBaseUrl:g,enableXfa:Z,evaluatorOptions:{maxImageSize:M,disableFontFace:H,ignoreErrors:E,isEvalSupported:k,isOffscreenCanvasSupported:T,isImageDecoderSupported:R,canvasMaxAreaInBytes:B,fontExtraProperties:q,useSystemFonts:_n,useWasm:Et,useWorkerFetch:Os,cMapUrl:w,iccUrl:v,standardFontDataUrl:y,wasmUrl:_}},of={ownerDocument:K,pdfBug:fe,styleElement:Ws,loadingParams:{disableAutoFetch:tt,enableXfa:Z}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const hf=c.messageHandler.sendWithPromise("GetDocRequest",Ha,i?[i.buffer]:null);let hc;if(l)hc=new hm(l,{disableRange:O,disableStream:I});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");const lc=qa(s)?um:Xt?_m:wm;hc=new lc({url:s,length:ct,httpHeaders:a,withCredentials:o,rangeChunkSize:d,disableRange:O,disableStream:I})}return hf.then(lc=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const iu=new yr(e,lc,c.port),lf=new Rm(iu,t,hc,of,ht);t._transport=lf,iu.send("Ready",null)})}).catch(t._capability.reject),t}var ld;const Wp=class sf{constructor(){C(this,"_capability",Promise.withResolvers()),C(this,"_transport",null),C(this,"_worker",null),C(this,"docId",`d${Zt(sf,ld)._++}`),C(this,"destroyed",!1),C(this,"onPassword",null),C(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?.destroy(),this._worker=null}async getData(){return this._transport.getData()}};ld=new WeakMap,f(Wp,ld,0);let km=Wp;var na,Yh,Qh,Jh,Zh;class cd{constructor(t,e,s=!1,i=null){f(this,na,Promise.withResolvers()),f(this,Yh,[]),f(this,Qh,[]),f(this,Jh,[]),f(this,Zh,[]),this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}addRangeListener(t){n(this,Zh).push(t)}addProgressListener(t){n(this,Jh).push(t)}addProgressiveReadListener(t){n(this,Qh).push(t)}addProgressiveDoneListener(t){n(this,Yh).push(t)}onDataRange(t,e){for(const s of n(this,Zh))s(t,e)}onDataProgress(t,e){n(this,na).promise.then(()=>{for(const s of n(this,Jh))s(t,e)})}onDataProgressiveRead(t){n(this,na).promise.then(()=>{for(const e of n(this,Qh))e(t)})}onDataProgressiveDone(){n(this,na).promise.then(()=>{for(const t of n(this,Yh))t()})}transportReady(){n(this,na).resolve()}requestDataRange(t,e){Y("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}na=new WeakMap,Yh=new WeakMap,Qh=new WeakMap,Jh=new WeakMap,Zh=new WeakMap;class Cm{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return z(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()}}var ii,aa,Br;class Tm{constructor(t,e,s,i=!1){f(this,aa),f(this,ii,!1),this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new gu:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Pp,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:a=!1}={}){return new Fo({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:a})}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 z(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=cs.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:h=null,annotationCanvasMap:l=null,pageColors:d=null,printAnnotationStorage:c=null,isEditing:u=!1}){this._stats?.time("Overall");const g=this._transport.getRenderingIntent(s,i,c,u),{renderingIntent:w,cacheKey:b}=g;p(this,ii,!1),h||(h=this._transport.getOptionalContentConfig(w));let A=this._intentStates.get(b);A||(A=Object.create(null),this._intentStates.set(b,A)),A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const v=!!(w&oe.PRINT);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(g));const y=x=>{A.renderTasks.delete(S),v&&p(this,ii,!0),m(this,aa,Br).call(this),x?(S.capability.reject(x),this._abortOperatorList({intentState:A,reason:x instanceof Error?x:new Error(x)})):S.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},S=new Im({callback:y,params:{canvasContext:t,viewport:e,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:d});(A.renderTasks||(A.renderTasks=new Set)).add(S);const _=S.task;return Promise.all([A.displayReadyCapability.promise,h]).then(([x,E])=>{if(this.destroyed){y();return}if(this._stats?.time("Rendering"),!(E.renderingIntent&w))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");S.initializeGraphics({transparency:x,optionalContentConfig:E}),S.operatorListChanged()}).catch(y),_}getOperatorList({intent:t="display",annotationMode:e=cs.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){function a(){h.operatorList.lastChunk&&(h.opListReadCapability.resolve(h.operatorList),h.renderTasks.delete(l))}const o=this._transport.getRenderingIntent(t,e,s,i,!0);let h=this._intentStates.get(o.cacheKey);h||(h=Object.create(null),this._intentStates.set(o.cacheKey,h));let l;return h.opListReadCapability||(l=Object.create(null),l.operatorListChanged=a,h.opListReadCapability=Promise.withResolvers(),(h.renderTasks||(h.renderTasks=new Set)).add(l),h.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(o)),h.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(s){return s.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Oo.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function a(){o.read().then(function({value:l,done:d}){if(d){s(h);return}h.lang??(h.lang=l.lang),Object.assign(h.styles,l.styles),h.items.push(...l.items),a()},i)}const o=e.getReader(),h={items:[],styles:Object.create(null),lang:null};a()})}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(),p(this,ii,!1),Promise.all(t)}cleanup(t=!1){p(this,ii,!0);const e=m(this,aa,Br).call(this);return t&&e&&this._stats&&(this._stats=new gu),e}_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&&m(this,aa,Br).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:a,transfer:o}=s,h=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:a,modifiedIds:i},o).getReader(),l=this._intentStates.get(e);l.streamReader=h;const d=()=>{h.read().then(({value:c,done:u})=>{if(u){l.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(c,l),d())},c=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const u of l.renderTasks)u.operatorListChanged();m(this,aa,Br).call(this)}if(l.displayReadyCapability)l.displayReadyCapability.reject(c);else if(l.opListReadCapability)l.opListReadCapability.reject(c);else throw c}})};d()}_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 zo){let i=Mm;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 ds(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,a]of this._intentStates)if(a===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}ii=new WeakMap,aa=new WeakSet,Br=function(){if(!n(this,ii)||this.destroyed)return!1;for(const{renderTasks:r,operatorList:t}of this._intentStates.values())if(r.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),p(this,ii,!1),!0};var Yi,Ke,ni,ra,dd,oa,ha,Oe,tl,Bp,Hp,Hr,$r,el;const vt=class Do{constructor({name:t=null,port:e=null,verbosity:s=gf()}={}){if(f(this,Oe),f(this,Yi,Promise.withResolvers()),f(this,Ke,null),f(this,ni,null),f(this,ra,null),this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(Do,ha).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(Do,ha).set(e,this),m(this,Oe,Bp).call(this,e)}else m(this,Oe,Hp).call(this)}get promise(){return n(this,Yi).promise}get port(){return n(this,ni)}get messageHandler(){return n(this,Ke)}destroy(){this.destroyed=!0,n(this,ra)?.terminate(),p(this,ra,null),n(Do,ha).delete(n(this,ni)),p(this,ni,null),n(this,Ke)?.destroy(),p(this,Ke,null)}static create(t){const e=n(this,ha).get(t?.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Do(t)}static get workerSrc(){if(Ss.workerSrc)return Ss.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return z(this,"_setupFakeWorkerGlobal",(async()=>n(this,$r,el)?n(this,$r,el):(await import(this.workerSrc)).WorkerMessageHandler)())}};Yi=new WeakMap,Ke=new WeakMap,ni=new WeakMap,ra=new WeakMap,dd=new WeakMap,oa=new WeakMap,ha=new WeakMap,Oe=new WeakSet,tl=function(){n(this,Yi).resolve(),n(this,Ke).send("configure",{verbosity:this.verbosity})},Bp=function(r){p(this,ni,r),p(this,Ke,new yr("main","worker",r)),n(this,Ke).on("ready",()=>{}),m(this,Oe,tl).call(this)},Hp=function(){if(n(vt,oa)||n(vt,$r,el)){m(this,Oe,Hr).call(this);return}let{workerSrc:r}=vt;try{vt._isSameOrigin(window.location,r)||(r=vt._createCDNWrapper(new URL(r,window.location).href));const t=new Worker(r,{type:"module"}),e=new yr("main","worker",t),s=()=>{i.abort(),e.destroy(),t.terminate(),this.destroyed?n(this,Yi).reject(new Error("Worker was destroyed")):m(this,Oe,Hr).call(this)},i=new AbortController;t.addEventListener("error",()=>{n(this,ra)||s()},{signal:i.signal}),e.on("test",o=>{if(i.abort(),this.destroyed||!o){s();return}p(this,Ke,e),p(this,ni,t),p(this,ra,t),m(this,Oe,tl).call(this)}),e.on("ready",o=>{if(i.abort(),this.destroyed){s();return}try{a()}catch{m(this,Oe,Hr).call(this)}});const a=()=>{const o=new Uint8Array;e.send("test",o,[o.buffer])};a();return}catch{Ho("The worker has been disabled.")}m(this,Oe,Hr).call(this)},Hr=function(){n(vt,oa)||(G("Setting up fake worker."),p(vt,oa,!0)),vt._setupFakeWorkerGlobal.then(r=>{if(this.destroyed){n(this,Yi).reject(new Error("Worker was destroyed"));return}const t=new Of;p(this,ni,t);const e=`fake${Zt(vt,dd)._++}`,s=new yr(e+"_worker",e,t);r.setup(s,t),p(this,Ke,new yr(e,e+"_worker",t)),m(this,Oe,tl).call(this)}).catch(r=>{n(this,Yi).reject(new Error(`Setting up fake worker failed: "${r.message}".`))})},$r=new WeakSet,el=function(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}},f(vt,$r),f(vt,dd,0),f(vt,oa,!1),f(vt,ha,new WeakMap),Xt&&(p(vt,oa,!0),Ss.workerSrc||(Ss.workerSrc="./pdf.worker.mjs")),vt._isSameOrigin=(r,t)=>{const e=URL.parse(r);if(!e?.origin||e.origin==="null")return!1;const s=new URL(t,e);return e.origin===s.origin},vt._createCDNWrapper=r=>{const t=`await import("${r}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))},vt.fromPort=r=>{if(Sf("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!r?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return vt.create(r)};let sl=vt;var ai,Es,Gr,zr,ri,la,Ur;class Rm{constructor(t,e,s,i,a){f(this,la),f(this,ai,new Map),f(this,Es,new Map),f(this,Gr,new Map),f(this,zr,new Map),f(this,ri,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Pp,this.fontLoader=new If({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.wasmFactory=a.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return z(this,"annotationStorage",new Uc)}getRenderingIntent(t,e=cs.ENABLE,s=null,i=!1,a=!1){let o=oe.DISPLAY,h=Gc;switch(t){case"any":o=oe.ANY;break;case"display":break;case"print":o=oe.PRINT;break;default:G(`getRenderingIntent - invalid intent: ${t}`)}const l=o&oe.PRINT&&s instanceof tp?s:this.annotationStorage;switch(e){case cs.DISABLE:o+=oe.ANNOTATIONS_DISABLE;break;case cs.ENABLE:break;case cs.ENABLE_FORMS:o+=oe.ANNOTATIONS_FORMS;break;case cs.ENABLE_STORAGE:o+=oe.ANNOTATIONS_STORAGE,h=l.serializable;break;default:G(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(o+=oe.IS_EDITING),a&&(o+=oe.OPLIST);const{ids:d,hash:c}=l.modifiedIds,u=[o,h.hash,c];return{renderingIntent:o,cacheKey:u.join("_"),annotationStorageSerializable:h,modifiedIds:d}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),n(this,ri)?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of n(this,Es).values())t.push(s._destroy());n(this,Es).clear(),n(this,Gr).clear(),n(this,zr).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(),n(this,ai).clear(),this.filterFactory.destroy(),Kh.cleanup(),this._networkStream?.cancelAllRequests(new ds("Worker was terminated.")),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)=>{ft(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=a=>{this._lastProgress={loaded:a.loaded,total:a.total}},i.onPull=()=>{this._fullReader.read().then(function({value:a,done:o}){if(o){i.close();return}ft(a instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{this._fullReader.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("ReaderHeadersReady",async s=>{await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:a,contentLength:o}=this._fullReader;return(!i||!a)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=h=>{e.onProgress?.({loaded:h.loaded,total:h.total})}),{isStreamingSupported:i,isRangeSupported:a,contentLength:o}}),t.on("GetRangeReader",(s,i)=>{ft(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const a=this._networkStream.getRangeReader(s.begin,s.end);if(!a){i.close();return}i.onPull=()=>{a.read().then(function({value:o,done:h}){if(h){i.close();return}ft(o instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{i.error(o)})},i.onCancel=o=>{a.cancel(o),i.ready.catch(h=>{if(!this.destroyed)throw h})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new Cm(s,this))}),t.on("DocException",s=>{e._capability.reject(te(s))}),t.on("PasswordRequest",s=>{p(this,ri,Promise.withResolvers());try{if(!e.onPassword)throw te(s);const i=a=>{a instanceof Error?n(this,ri).reject(a):n(this,ri).resolve({password:a})};e.onPassword(i,s.code)}catch(i){n(this,ri).reject(i)}return n(this,ri).promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{this.destroyed||n(this,Es).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,a])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in a){const d=a.error;G(`Error during font loading: ${d}`),this.commonObjs.resolve(s,d);break}const o=this._params.pdfBug&&globalThis.FontInspector?.enabled?(d,c)=>globalThis.FontInspector.fontAdded(d,c):null,h=new Lf(a,o);this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!h.fontExtraProperties&&h.data&&(h.data=null),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:l}=a;ft(l,"The imageRef must be defined.");for(const d of n(this,Es).values())for(const[,c]of d.objs)if(c?.ref===l)return c.dataLen?(this.commonObjs.resolve(s,structuredClone(c)),c.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,a);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,a,o])=>{if(this.destroyed)return;const h=n(this,Es).get(i);if(!h.objs.has(s)){if(h._intentStates.size===0){o?.bitmap?.close();return}switch(a){case"Image":case"Pattern":h.objs.resolve(s,o);break;default:throw new Error(`Got unknown object type ${a}`)}}}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");const i=this[s.type];if(!i)throw new Error(`${s.type} not initialized, see the \`useWorkerFetch\` parameter.`);return i.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&G("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=n(this,Gr).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&n(this,zr).set(a.refStr,t);const o=new Tm(e,a,this,this._params.pdfBug);return n(this,Es).set(e,o),o});return n(this,Gr).set(e,i),i}getPageIndex(t){return jc(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 m(this,la,Ur).call(this,"GetFieldObjects")}hasJSActions(){return m(this,la,Ur).call(this,"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 m(this,la,Ur).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return m(this,la,Ur).call(this,"GetOptionalContentConfig").then(e=>new om(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=n(this,ai).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>({info:i[0],metadata:i[1]?new am(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return n(this,ai).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 n(this,Es).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,ai).clear(),this.filterFactory.destroy(!0),Kh.cleanup()}}cachedPageNumber(t){if(!jc(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return n(this,zr).get(e)??null}}ai=new WeakMap,Es=new WeakMap,Gr=new WeakMap,zr=new WeakMap,ri=new WeakMap,la=new WeakSet,Ur=function(r,t=null){const e=n(this,ai).get(r);if(e)return e;const s=this.messageHandler.sendWithPromise(r,t);return n(this,ai).set(r,s),s};var Qi;class Pm{constructor(t){f(this,Qi,null),C(this,"onContinue",null),C(this,"onError",null),p(this,Qi,t)}get promise(){return n(this,Qi).capability.promise}cancel(t=0){n(this,Qi).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=n(this,Qi).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=n(this,Qi);return t.form||t.canvas&&e?.size>0}}Qi=new WeakMap;var Ji,ca;const $p=class No{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:a,operatorList:o,pageIndex:h,canvasFactory:l,filterFactory:d,useRequestAnimationFrame:c=!1,pdfBug:u=!1,pageColors:g=null}){f(this,Ji,null),this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=h,this.canvasFactory=l,this.filterFactory=d,this._pdfBug=u,this.pageColors=g,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 Pm(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(n(No,ca).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.");n(No,ca).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:a,background:o}=this.params;this.gfx=new Rh(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:i,transparency:t,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),n(this,Ji)&&(window.cancelAnimationFrame(n(this,Ji)),p(this,Ji,null)),n(No,ca).delete(this._canvas),t||(t=new zo(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||(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?p(this,Ji,window.requestAnimationFrame(()=>{p(this,Ji,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(),n(No,ca).delete(this._canvas),this.callback())))}};Ji=new WeakMap,ca=new WeakMap,f($p,ca,new WeakSet);let Im=$p;const Gp="5.3.31",zp="47ad820d9";function Up(r){return Math.floor(Math.max(0,Math.min(1,r))*255).toString(16).padStart(2,"0")}function jr(r){return Math.max(0,Math.min(255,255*r))}class jp{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=jr(t),[t,t,t]}static G_HTML([t]){const e=Up(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(jr)}static RGB_HTML(t){return`#${t.map(Up).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[jr(1-Math.min(1,t+i)),jr(1-Math.min(1,s+i)),jr(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,a=1-e,o=1-s,h=Math.min(i,a,o);return["CMYK",i,a,o,h]}}class Lm{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){Y("Abstract method `_createSVG` called.")}}class Vr extends Lm{_createSVG(t){return document.createElementNS(us,t)}}class ud{static setupStorage(t,e,s,i,a){const o=i.getValue(e,{value:null});switch(s.name){case"textarea":if(o.value!==null&&(t.textContent=o.value),a==="print")break;t.addEventListener("input",h=>{i.setValue(e,{value:h.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(o.value===s.attributes.xfaOn?t.setAttribute("checked",!0):o.value===s.attributes.xfaOff&&t.removeAttribute("checked"),a==="print")break;t.addEventListener("change",h=>{i.setValue(e,{value:h.target.checked?h.target.getAttribute("xfaOn"):h.target.getAttribute("xfaOff")})})}else{if(o.value!==null&&t.setAttribute("value",o.value),a==="print")break;t.addEventListener("input",h=>{i.setValue(e,{value:h.target.value})})}break;case"select":if(o.value!==null){t.setAttribute("value",o.value);for(const h of s.children)h.attributes.value===o.value?h.attributes.selected=!0:h.attributes.hasOwnProperty("selected")&&delete h.attributes.selected}t.addEventListener("input",h=>{const l=h.target.options,d=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:d})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:a}){const{attributes:o}=e,h=t instanceof HTMLAnchorElement;o.type==="radio"&&(o.name=`${o.name}-${i}`);for(const[l,d]of Object.entries(o))if(d!=null)switch(l){case"class":d.length&&t.setAttribute(l,d.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",d);break;case"style":Object.assign(t.style,d);break;case"textContent":t.textContent=d;break;default:(!h||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,d)}h&&a.addLinkAttributes(t,o.href,o.newWindow),s&&o.dataId&&this.setupStorage(t,o.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,a=t.intent||"display",o=document.createElement(i.name);i.attributes&&this.setAttributes({html:o,element:i,intent:a,linkService:s});const h=a!=="richText",l=t.div;if(l.append(o),t.viewport){const u=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=u}h&&l.setAttribute("class","xfaLayer xfaFont");const d=[];if(i.children.length===0){if(i.value){const u=document.createTextNode(i.value);o.append(u),h&&Oo.shouldBuildText(i.name)&&d.push(u)}return{textDivs:d}}const c=[[i,-1,o]];for(;c.length>0;){const[u,g,w]=c.at(-1);if(g+1===u.children.length){c.pop();continue}const b=u.children[++c.at(-1)[1]];if(b===null)continue;const{name:A}=b;if(A==="#text"){const y=document.createTextNode(b.value);d.push(y),w.append(y);continue}const v=b?.attributes?.xmlns?document.createElementNS(b.attributes.xmlns,A):document.createElement(A);if(w.append(v),b.attributes&&this.setAttributes({html:v,element:b,storage:e,intent:a,linkService:s}),b.children?.length>0)c.push([b,-1,v]);else if(b.value){const y=document.createTextNode(b.value);h&&Oo.shouldBuildText(A)&&d.push(y),v.append(y)}}for(const u of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))u.setAttribute("readOnly",!0);return{textDivs:d}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const qr=1e3,Dm=9,Zi=new WeakSet;class Vp{static create(t){switch(t.data.annotationType){case dt.LINK:return new Kp(t);case dt.TEXT:return new Fm(t);case dt.WIDGET:switch(t.data.fieldType){case"Tx":return new Om(t);case"Btn":return t.data.radioButton?new Yp(t):t.data.checkBox?new Bm(t):new Hm(t);case"Ch":return new $m(t);case"Sig":return new Wm(t)}return new sn(t);case dt.POPUP:return new gd(t);case dt.FREETEXT:return new eg(t);case dt.LINE:return new zm(t);case dt.SQUARE:return new Um(t);case dt.CIRCLE:return new jm(t);case dt.POLYLINE:return new sg(t);case dt.CARET:return new qm(t);case dt.INK:return new vd(t);case dt.POLYGON:return new Vm(t);case dt.HIGHLIGHT:return new ig(t);case dt.UNDERLINE:return new Xm(t);case dt.SQUIGGLY:return new Km(t);case dt.STRIKEOUT:return new Ym(t);case dt.STAMP:return new ng(t);case dt.FILEATTACHMENT:return new Qm(t);default:return new yt(t)}}}var tn,Xr,Kr,il,pd;const Nm=class nf{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){f(this,il),f(this,tn,null),f(this,Xr,!1),f(this,Kr,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t?.str||e?.str||s?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return nf._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;n(this,tn)||p(this,tn,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&m(this,il,pd).call(this,e),n(this,Kr)?.popup.updateEdited(t)}resetEdited(){n(this,tn)&&(m(this,il,pd).call(this,n(this,tn).rect),n(this,Kr)?.popup.resetEdited(),p(this,tn,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id),this instanceof sn||(a.tabIndex=qr);const{style:o}=a;if(o.zIndex=this.parent.zIndex++,e.alternativeText&&(a.title=e.alternativeText),e.noRotate&&a.classList.add("norotate"),!e.rect||this instanceof gd){const{rotation:A}=e;return!e.hasOwnCanvas&&A!==0&&this.setRotation(A,a),a}const{width:h,height:l}=this;if(!t&&e.borderStyle.width>0){o.borderWidth=`${e.borderStyle.width}px`;const A=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(A>0||v>0){const S=`calc(${A}px * var(--total-scale-factor)) / calc(${v}px * var(--total-scale-factor))`;o.borderRadius=S}else if(this instanceof Yp){const S=`calc(${h}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;o.borderRadius=S}switch(e.borderStyle.style){case Sn.SOLID:o.borderStyle="solid";break;case Sn.DASHED:o.borderStyle="dashed";break;case Sn.BEVELED:G("Unimplemented border style: beveled");break;case Sn.INSET:G("Unimplemented border style: inset");break;case Sn.UNDERLINE:o.borderBottomStyle="solid";break}const y=e.borderColor||null;y?(p(this,Xr,!0),o.borderColor=L.makeHexColor(y[0]|0,y[1]|0,y[2]|0)):o.borderWidth=0}const d=L.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:u,pageX:g,pageY:w}=i.rawDims;o.left=`${100*(d[0]-g)/c}%`,o.top=`${100*(d[1]-w)/u}%`;const{rotation:b}=e;return e.hasOwnCanvas||b===0?(o.width=`${100*h/c}%`,o.height=`${100*l/u}%`):this.setRotation(b,a),a}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:a,height:o}=this;t%180!==0&&([a,o]=[o,a]),e.style.width=`${100*a/s}%`,e.style.height=`${100*o/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const a=i.detail[e],o=a[0],h=a.slice(1);i.target.style[s]=jp[`${o}_HTML`](h),this.annotationStorage.setValue(this.data.id,{[s]:jp[`${o}_rgb`](h)})};return z(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,a]of Object.entries(e)){const o=s[i];if(o){const h={detail:{[i]:a},target:t};o(h),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,a]=this.data.rect.map(A=>Math.fround(A));if(t.length===8){const[A,v,y,S]=t.subarray(2,6);if(i===A&&a===v&&e===y&&s===S)return}const{style:o}=this.container;let h;if(n(this,Xr)){const{borderColor:A,borderWidth:v}=o;o.borderWidth=0,h=["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="${A}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const l=i-e,d=a-s,{svgFactory:c}=this,u=c.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const g=c.createElement("defs");u.append(g);const w=c.createElement("clipPath"),b=`clippath_${this.data.id}`;w.setAttribute("id",b),w.setAttribute("clipPathUnits","objectBoundingBox"),g.append(w);for(let A=2,v=t.length;A<v;A+=8){const y=t[A],S=t[A+1],_=t[A+2],x=t[A+3],E=c.createElement("rect"),M=(_-e)/l,k=(a-S)/d,T=(y-_)/l,R=(S-x)/d;E.setAttribute("x",M),E.setAttribute("y",k),E.setAttribute("width",T),E.setAttribute("height",R),w.append(E),h?.push(`<rect vector-effect="non-scaling-stroke" x="${M}" y="${k}" width="${T}" height="${R}"/>`)}n(this,Xr)&&(h.push("</g></svg>')"),o.backgroundImage=h.join("")),this.container.append(u),this.container.style.clipPath=`url(#${b})`}_createPopup(){const{data:t}=this,e=p(this,Kr,new gd({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){Y("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:a,id:o,exportValues:h}of i){if(a===-1||o===e)continue;const l=typeof h=="string"?h:null,d=document.querySelector(`[data-element-id="${o}"]`);if(d&&!Zi.has(d)){G(`_getElementsByName - element not allowed: ${o}`);continue}s.push({id:o,exportValue:l,domElement:d})}return s}for(const i of document.getElementsByName(t)){const{exportValue:a}=i,o=i.getAttribute("data-element-id");o!==e&&Zi.has(i)&&s.push({id:o,exportValue:a,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")}_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})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};tn=new WeakMap,Xr=new WeakMap,Kr=new WeakMap,il=new WeakSet,pd=function(r){const{container:{style:t},data:{rect:e,rotation:s},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:h}}}}=this;e?.splice(0,4,...r),t.left=`${100*(r[0]-o)/i}%`,t.top=`${100*(a-r[3]+h)/a}%`,s===0?(t.width=`${100*(r[2]-r[0])/i}%`,t.height=`${100*(r[3]-r[1])/a}%`):this.setRotation(s)};let yt=Nm;var Ye,en,qp,Xp;class Kp extends yt{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),f(this,Ye),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?(m(this,Ye,qp).call(this,s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(m(this,Ye,Xp).call(this,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}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&m(this,Ye,en).call(this)}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),m(this,Ye,en).call(this)}_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 a=s.get(i);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),m(this,Ye,en).call(this)}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),m(this,Ye,en).call(this),!this._fieldObjects){G('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();const{fields:i,refs:a,include:o}=e,h=[];if(i.length!==0||a.length!==0){const c=new Set(a);for(const u of i){const g=this._fieldObjects[u]||[];for(const{id:w}of g)c.add(w)}for(const u of Object.values(this._fieldObjects))for(const g of u)c.has(g.id)===o&&h.push(g)}else for(const c of Object.values(this._fieldObjects))h.push(...c);const l=this.annotationStorage,d=[];for(const c of h){const{id:u}=c;switch(d.push(u),c.type){case"text":{const w=c.defaultValue||"";l.setValue(u,{value:w});break}case"checkbox":case"radiobutton":{const w=c.defaultValue===c.exportValues;l.setValue(u,{value:w});break}case"combobox":case"listbox":{const w=c.defaultValue||"";l.setValue(u,{value:w});break}default:continue}const g=document.querySelector(`[data-element-id="${u}"]`);if(g){if(!Zi.has(g)){G(`_bindResetFormAction - element not allowed: ${u}`);continue}}else continue;g.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:d,name:"ResetForm"}}),!1}}}Ye=new WeakSet,en=function(){this.container.setAttribute("data-internal-link","")},qp=function(r,t,e=null){r.href=this.linkService.getAnchorUrl(""),t.description&&(r.title=t.description),r.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,e),!1),m(this,Ye,en).call(this)},Xp=function(r,t){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeSetOCGState(t),!1),m(this,Ye,en).call(this)};class Fm extends yt{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 sn extends yt{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Mt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,a){s.includes("mouse")?t.addEventListener(s,o=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:a(o),shift:o.shiftKey,modifier:this._getKeyModifier(o)}})}):t.addEventListener(s,o=>{if(s==="blur"){if(!e.focused||!o.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}a&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:a(o)}})})}_setEventListeners(t,e,s,i){for(const[a,o]of s)(o==="Action"||this.data.actions?.[o])&&((o==="Focus"||o==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,a,o,i),o==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):o==="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":L.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Dm,a=t.style;let o;const h=2,l=d=>Math.round(10*d)/10;if(this.data.multiLine){const d=Math.abs(this.data.rect[3]-this.data.rect[1]-h),c=Math.round(d/(uc*i))||1,u=d/c;o=Math.min(i,l(u/uc))}else{const d=Math.abs(this.data.rect[3]-this.data.rect[1]-h);o=Math.min(i,l(d/uc))}a.fontSize=`calc(${o}px * var(--total-scale-factor))`,a.color=L.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(a.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Om extends sn{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 a=this.annotationStorage;for(const o of this._getElementsByName(t.name,t.id))o.domElement&&(o.domElement[e]=s),a.setValue(o.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 a=i.value||"";const o=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;o&&a.length>o&&(a=a.slice(0,o));let h=i.formattedValue||this.data.textContent?.join(`
|
|
3
|
+
`)||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const l={userValue:a,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=h??a,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",h??a),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Zi.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=qr,this._setRequired(s,this.data.required),o&&(s.maxLength=o),s.addEventListener("input",c=>{t.setValue(e,{value:c.target.value}),this.setPropertyOnSiblings(s,"value",c.target.value,"value"),l.formattedValue=null}),s.addEventListener("resetform",c=>{const u=this.data.defaultFieldValue??"";s.value=l.userValue=u,l.formattedValue=null});let d=c=>{const{formattedValue:u}=l;u!=null&&(c.target.value=u),c.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",u=>{if(l.focused)return;const{target:g}=u;l.userValue&&(g.value=l.userValue),l.lastCommittedValue=g.value,l.commitKey=1,this.data.actions?.Focus||(l.focused=!0)}),s.addEventListener("updatefromsandbox",u=>{this.showElementAndHideCanvas(u.target);const g={value(w){l.userValue=w.detail.value??"",t.setValue(e,{value:l.userValue.toString()}),w.target.value=l.userValue},formattedValue(w){const{formattedValue:b}=w.detail;l.formattedValue=b,b!=null&&w.target!==document.activeElement&&(w.target.value=b),t.setValue(e,{formattedValue:b})},selRange(w){w.target.setSelectionRange(...w.detail.selRange)},charLimit:w=>{const{charLimit:b}=w.detail,{target:A}=w;if(b===0){A.removeAttribute("maxLength");return}A.setAttribute("maxLength",b);let v=l.userValue;!v||v.length<=b||(v=v.slice(0,b),A.value=l.userValue=v,t.setValue(e,{value:v}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:1,selStart:A.selectionStart,selEnd:A.selectionEnd}}))}};this._dispatchEventFromSandbox(g,u)}),s.addEventListener("keydown",u=>{l.commitKey=1;let g=-1;if(u.key==="Escape"?g=0:u.key==="Enter"&&!this.data.multiLine?g=2:u.key==="Tab"&&(l.commitKey=3),g===-1)return;const{value:w}=u.target;l.lastCommittedValue!==w&&(l.lastCommittedValue=w,l.userValue=w,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,willCommit:!0,commitKey:g,selStart:u.target.selectionStart,selEnd:u.target.selectionEnd}}))});const c=d;d=null,s.addEventListener("blur",u=>{if(!l.focused||!u.relatedTarget)return;this.data.actions?.Blur||(l.focused=!1);const{value:g}=u.target;l.userValue=g,l.lastCommittedValue!==g&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:g,willCommit:!0,commitKey:l.commitKey,selStart:u.target.selectionStart,selEnd:u.target.selectionEnd}}),c(u)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",u=>{l.lastCommittedValue=null;const{data:g,target:w}=u,{value:b,selectionStart:A,selectionEnd:v}=w;let y=A,S=v;switch(u.inputType){case"deleteWordBackward":{const _=b.substring(0,A).match(/\w*[^\w]*$/);_&&(y-=_[0].length);break}case"deleteWordForward":{const _=b.substring(A).match(/^[^\w]*\w*/);_&&(S+=_[0].length);break}case"deleteContentBackward":A===v&&(y-=1);break;case"deleteContentForward":A===v&&(S+=1);break}u.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,change:g||"",willCommit:!1,selStart:y,selEnd:S}})}),this._setEventListeners(s,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],u=>u.target.value)}if(d&&s.addEventListener("blur",d),this.data.comb){const c=(this.data.rect[2]-this.data.rect[0])/o;s.classList.add("comb"),s.style.letterSpacing=`calc(${c}px * var(--total-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 Wm extends sn{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Bm extends sn{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 a=document.createElement("input");return Zi.add(a),a.setAttribute("data-element-id",s),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=e.fieldName,i&&a.setAttribute("checked",!0),a.setAttribute("exportValue",e.exportValue),a.tabIndex=qr,a.addEventListener("change",o=>{const{name:h,checked:l}=o.target;for(const d of this._getElementsByName(h,s)){const c=l&&d.exportValue===e.exportValue;d.domElement&&(d.domElement.checked=c),t.setValue(d.id,{value:c})}t.setValue(s,{value:l})}),a.addEventListener("resetform",o=>{const h=e.defaultFieldValue||"Off";o.target.checked=h===e.exportValue}),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",o=>{const h={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(h,o)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Yp extends sn{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 o of this._getElementsByName(e.fieldName,s))t.setValue(o.id,{value:!1});const a=document.createElement("input");if(Zi.add(a),a.setAttribute("data-element-id",s),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,i&&a.setAttribute("checked",!0),a.tabIndex=qr,a.addEventListener("change",o=>{const{name:h,checked:l}=o.target;for(const d of this._getElementsByName(h,s))t.setValue(d.id,{value:!1});t.setValue(s,{value:l})}),a.addEventListener("resetform",o=>{const h=e.defaultFieldValue;o.target.checked=h!=null&&h===e.buttonValue}),this.enableScripting&&this.hasJSActions){const o=e.buttonValue;a.addEventListener("updatefromsandbox",h=>{const l={value:d=>{const c=o===d.detail.value;for(const u of this._getElementsByName(d.target.name)){const g=c&&u.id===s;u.domElement&&(u.domElement.checked=g),t.setValue(u.id,{value:g})}}};this._dispatchEventFromSandbox(l,h)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],h=>h.target.checked)}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Hm extends Kp{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 $m extends sn{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");Zi.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=qr;let a=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 u=this.data.defaultFieldValue;for(const g of i.options)g.selected=g.value===u});for(const c of this.data.options){const u=document.createElement("option");u.textContent=c.displayValue,u.value=c.exportValue,s.value.includes(c.exportValue)&&(u.setAttribute("selected",!0),a=!1),i.append(u)}let o=null;if(a){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),o=()=>{c.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const h=c=>{const u=c?"value":"textContent",{options:g,multiple:w}=i;return w?Array.prototype.filter.call(g,b=>b.selected).map(b=>b[u]):g.selectedIndex===-1?null:g[g.selectedIndex][u]};let l=h(!1);const d=c=>{const u=c.target.options;return Array.prototype.map.call(u,g=>({displayValue:g.textContent,exportValue:g.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{const u={value(g){o?.();const w=g.detail.value,b=new Set(Array.isArray(w)?w:[w]);for(const A of i.options)A.selected=b.has(A.value);t.setValue(e,{value:h(!0)}),l=h(!1)},multipleSelection(g){i.multiple=!0},remove(g){const w=i.options,b=g.detail.remove;w[b].selected=!1,i.remove(b),w.length>0&&Array.prototype.findIndex.call(w,A=>A.selected)===-1&&(w[0].selected=!0),t.setValue(e,{value:h(!0),items:d(g)}),l=h(!1)},clear(g){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=h(!1)},insert(g){const{index:w,displayValue:b,exportValue:A}=g.detail.insert,v=i.children[w],y=document.createElement("option");y.textContent=b,y.value=A,v?v.before(y):i.append(y),t.setValue(e,{value:h(!0),items:d(g)}),l=h(!1)},items(g){const{items:w}=g.detail;for(;i.length!==0;)i.remove(0);for(const b of w){const{displayValue:A,exportValue:v}=b,y=document.createElement("option");y.textContent=A,y.value=v,i.append(y)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:h(!0),items:d(g)}),l=h(!1)},indices(g){const w=new Set(g.detail.indices);for(const b of g.target.options)b.selected=w.has(b.index);t.setValue(e,{value:h(!0)}),l=h(!1)},editable(g){g.target.disabled=!g.detail.editable}};this._dispatchEventFromSandbox(u,c)}),i.addEventListener("input",c=>{const u=h(!0),g=h(!1);t.setValue(e,{value:u}),c.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:g,changeEx:u,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:h(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class gd extends yt{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:yt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Gm({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,s.container.ariaHasPopup="dialog",e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${vc}${s}`).join(",")),this.container}}var Yr,fd,md,Qr,Jr,gt,oi,Zr,nl,al,to,hi,Qe,li,rl,ci,ol,nn,da,_t,hl,wd,Qp,Jp,Zp,tg,ll,cl,bd;class Gm{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:a,contentsObj:o,richText:h,parent:l,rect:d,parentRect:c,open:u}){f(this,_t),f(this,Yr,m(this,_t,Zp).bind(this)),f(this,fd,m(this,_t,bd).bind(this)),f(this,md,m(this,_t,cl).bind(this)),f(this,Qr,m(this,_t,ll).bind(this)),f(this,Jr,null),f(this,gt,null),f(this,oi,null),f(this,Zr,null),f(this,nl,null),f(this,al,null),f(this,to,null),f(this,hi,!1),f(this,Qe,null),f(this,li,null),f(this,rl,null),f(this,ci,null),f(this,ol,null),f(this,nn,null),f(this,da,!1),p(this,gt,t),p(this,ol,i),p(this,oi,o),p(this,ci,h),p(this,al,l),p(this,Jr,e),p(this,rl,d),p(this,to,c),p(this,nl,s),p(this,Zr,jo.toDateObject(a)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",n(this,Qr)),g.addEventListener("mouseenter",n(this,md)),g.addEventListener("mouseleave",n(this,fd)),g.classList.add("popupTriggerArea");for(const g of s)g.container?.addEventListener("keydown",n(this,Yr));n(this,gt).hidden=!0,u&&m(this,_t,ll).call(this)}render(){if(n(this,Qe))return;const t=p(this,Qe,document.createElement("div"));if(t.className="popup",n(this,Jr)){const a=t.style.outlineColor=L.makeHexColor(...n(this,Jr));t.style.backgroundColor=`color-mix(in srgb, ${a} 30%, white)`}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=n(this,ol),t.append(e),n(this,Zr)){const a=document.createElement("span");a.classList.add("popupDate"),a.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),a.setAttribute("data-l10n-args",JSON.stringify({dateObj:n(this,Zr).valueOf()})),e.append(a)}const i=n(this,_t,hl);if(i)ud.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const a=this._formatContents(n(this,oi));t.append(a)}n(this,gt).append(t)}_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 a=0,o=i.length;a<o;++a){const h=i[a];s.append(document.createTextNode(h)),a<o-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:t,popupContent:e}){n(this,nn)||p(this,nn,{contentsObj:n(this,oi),richText:n(this,ci)}),t&&p(this,li,null),e&&(p(this,ci,m(this,_t,Jp).call(this,e)),p(this,oi,null)),n(this,Qe)?.remove(),p(this,Qe,null)}resetEdited(){n(this,nn)&&({contentsObj:Zt(this,oi)._,richText:Zt(this,ci)._}=n(this,nn),p(this,nn,null),n(this,Qe)?.remove(),p(this,Qe,null),p(this,li,null))}forceHide(){p(this,da,this.isVisible),n(this,da)&&(n(this,gt).hidden=!0)}maybeShow(){n(this,da)&&(n(this,Qe)||m(this,_t,cl).call(this),p(this,da,!1),n(this,gt).hidden=!1)}get isVisible(){return n(this,gt).hidden===!1}}Yr=new WeakMap,fd=new WeakMap,md=new WeakMap,Qr=new WeakMap,Jr=new WeakMap,gt=new WeakMap,oi=new WeakMap,Zr=new WeakMap,nl=new WeakMap,al=new WeakMap,to=new WeakMap,hi=new WeakMap,Qe=new WeakMap,li=new WeakMap,rl=new WeakMap,ci=new WeakMap,ol=new WeakMap,nn=new WeakMap,da=new WeakMap,_t=new WeakSet,hl=function(){const r=n(this,ci),t=n(this,oi);return r?.str&&(!t?.str||t.str===r.str)&&n(this,ci).html||null},wd=function(){return n(this,_t,hl)?.attributes?.style?.fontSize||0},Qp=function(){return n(this,_t,hl)?.attributes?.style?.color||null},Jp=function(r){const t=[],e={str:r,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},s={style:{color:n(this,_t,Qp),fontSize:n(this,_t,wd)?`calc(${n(this,_t,wd)}px * var(--total-scale-factor))`:""}};for(const i of r.split(`
|
|
4
|
+
`))t.push({name:"span",value:i,attributes:s});return e},Zp=function(r){r.altKey||r.shiftKey||r.ctrlKey||r.metaKey||(r.key==="Enter"||r.key==="Escape"&&n(this,hi))&&m(this,_t,ll).call(this)},tg=function(){if(n(this,li)!==null)return;const{page:{view:r},viewport:{rawDims:{pageWidth:t,pageHeight:e,pageX:s,pageY:i}}}=n(this,al);let a=!!n(this,to),o=a?n(this,to):n(this,rl);for(const g of n(this,nl))if(!o||L.intersect(g.data.rect,o)!==null){o=g.data.rect,a=!0;break}const h=L.normalizeRect([o[0],r[3]-o[1]+r[1],o[2],r[3]-o[3]+r[1]]),l=a?o[2]-o[0]+5:0,d=h[0]+l,c=h[1];p(this,li,[100*(d-s)/t,100*(c-i)/e]);const{style:u}=n(this,gt);u.left=`${n(this,li)[0]}%`,u.top=`${n(this,li)[1]}%`},ll=function(){p(this,hi,!n(this,hi)),n(this,hi)?(m(this,_t,cl).call(this),n(this,gt).addEventListener("click",n(this,Qr)),n(this,gt).addEventListener("keydown",n(this,Yr))):(m(this,_t,bd).call(this),n(this,gt).removeEventListener("click",n(this,Qr)),n(this,gt).removeEventListener("keydown",n(this,Yr)))},cl=function(){n(this,Qe)||this.render(),this.isVisible?n(this,hi)&&n(this,gt).classList.add("focused"):(m(this,_t,tg).call(this),n(this,gt).hidden=!1,n(this,gt).style.zIndex=parseInt(n(this,gt).style.zIndex)+1e3)},bd=function(){n(this,gt).classList.remove("focused"),!(n(this,hi)||!this.isVisible)&&(n(this,gt).hidden=!0,n(this,gt).style.zIndex=parseInt(n(this,gt).style.zIndex)-1e3)};class eg extends yt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=$.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}}var dl;class zm extends yt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),f(this,dl,null)}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),a=p(this,dl,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),a.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),a.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),a.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),a.setAttribute("stroke-width",t.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,dl)}addHighlightArea(){this.container.classList.add("highlightArea")}}dl=new WeakMap;var ul;class Um extends yt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),f(this,ul,null)}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),a=t.borderStyle.width,o=p(this,ul,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",e-a),o.setAttribute("height",s-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,ul)}addHighlightArea(){this.container.classList.add("highlightArea")}}ul=new WeakMap;var pl;class jm extends yt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),f(this,pl,null)}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),a=t.borderStyle.width,o=p(this,pl,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",e/2),o.setAttribute("cy",s/2),o.setAttribute("rx",e/2-a/2),o.setAttribute("ry",s/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,pl)}addHighlightArea(){this.container.classList.add("highlightArea")}}pl=new WeakMap;var gl;class sg extends yt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),f(this,gl,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:s,popupRef:i},width:a,height:o}=this;if(!e)return this.container;const h=this.svgFactory.create(a,o,!0);let l=[];for(let c=0,u=e.length;c<u;c+=2){const g=e[c]-t[0],w=t[3]-e[c+1];l.push(`${g},${w}`)}l=l.join(" ");const d=p(this,gl,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",l),d.setAttribute("stroke-width",s.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),h.append(d),this.container.append(h),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,gl)}addHighlightArea(){this.container.classList.add("highlightArea")}}gl=new WeakMap;class Vm extends sg{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class qm extends yt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var fl,ua,ml,Ad;class vd extends yt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),f(this,ml),f(this,fl,null),f(this,ua,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?$.HIGHLIGHT:$.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:a}}=this,{transform:o,width:h,height:l}=m(this,ml,Ad).call(this,e,t),d=this.svgFactory.create(h,l,!0),c=p(this,fl,this.svgFactory.createElement("svg:g"));d.append(c),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke-linecap","round"),c.setAttribute("stroke-linejoin","round"),c.setAttribute("stroke-miterlimit",10),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),c.setAttribute("transform",o);for(let u=0,g=s.length;u<g;u++){const w=this.svgFactory.createElement(this.svgElementName);n(this,ua).push(w),w.setAttribute("points",s[u].join(",")),c.append(w)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(d),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:s,rect:i}=t,a=n(this,fl);if(e>=0&&a.setAttribute("stroke-width",e||1),s)for(let o=0,h=n(this,ua).length;o<h;o++)n(this,ua)[o].setAttribute("points",s[o].join(","));if(i){const{transform:o,width:h,height:l}=m(this,ml,Ad).call(this,this.data.rotation,i);a.parentElement.setAttribute("viewBox",`0 0 ${h} ${l}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return n(this,ua)}addHighlightArea(){this.container.classList.add("highlightArea")}}fl=new WeakMap,ua=new WeakMap,ml=new WeakSet,Ad=function(r,t){switch(r){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}};class ig extends yt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=$.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Xm extends yt{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 Km extends yt{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 Ym extends yt{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 ng extends yt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=$.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var wl,bl,yd;class Qm extends yt{constructor(t){super(t,{isRenderable:!0}),f(this,bl),f(this,wl,null);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",m(this,bl,yd).bind(this)),p(this,wl,s);const{isMac:i}=Mt.platform;return t.addEventListener("keydown",a=>{a.key==="Enter"&&(i?a.metaKey:a.ctrlKey)&&m(this,bl,yd).call(this)}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return n(this,wl)}addHighlightArea(){this.container.classList.add("highlightArea")}}wl=new WeakMap,bl=new WeakSet,yd=function(){this.downloadManager?.openOrDownloadData(this.content,this.filename)};var Al,pa,an,vl,ga,_d,Sd;const Jm=class af{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:a,viewport:o,structTreeLayer:h}){f(this,ga),f(this,Al,null),f(this,pa,null),f(this,an,new Map),f(this,vl,null),this.div=t,p(this,Al,e),p(this,pa,s),p(this,vl,h||null),this.page=a,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return n(this,an).size>0}async render(t){const{annotations:e}=t,s=this.div;Bs(s,this.viewport);const i=new Map,a={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Vr,annotationStorage:t.annotationStorage||new Uc,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const o of e){if(o.noHTML)continue;const h=o.annotationType===dt.POPUP;if(h){const c=i.get(o.id);if(!c)continue;a.elements=c}else if(o.rect[2]===o.rect[0]||o.rect[3]===o.rect[1])continue;a.data=o;const l=Vp.create(a);if(!l.isRenderable)continue;if(!h&&o.popupRef){const c=i.get(o.popupRef);c?c.push(l):i.set(o.popupRef,[l])}const d=l.render();o.hidden&&(d.style.visibility="hidden"),await m(this,ga,_d).call(this,d,o.id),l._isEditable&&(n(this,an).set(l.data.id,l),this._annotationEditorUIManager?.renderAnnotationElement(l))}m(this,ga,Sd).call(this)}async addLinkAnnotations(t,e){const s={data:null,layer:this.div,linkService:e,svgFactory:new Vr,parent:this};for(const i of t){i.borderStyle||(i.borderStyle=af._defaultBorderStyle),s.data=i;const a=Vp.create(s);if(!a.isRenderable)continue;const o=a.render();await m(this,ga,_d).call(this,o,i.id)}}update({viewport:t}){const e=this.div;this.viewport=t,Bs(e,{rotation:t.rotation}),m(this,ga,Sd).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(n(this,an).values())}getEditableAnnotation(t){return n(this,an).get(t)}static get _defaultBorderStyle(){return z(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Sn.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};Al=new WeakMap,pa=new WeakMap,an=new WeakMap,vl=new WeakMap,ga=new WeakSet,_d=async function(r,t){const e=r.firstChild||r,s=e.id=`${vc}${t}`,i=await n(this,vl)?.getAriaAttributes(s);if(i)for(const[a,o]of i)e.setAttribute(a,o);this.div.append(r),n(this,Al)?.moveElementInDOM(this.div,r,e,!1)},Sd=function(){if(!n(this,pa))return;const r=this.div;for(const[t,e]of n(this,pa)){const s=r.querySelector(`[data-annotation-id="${t}"]`);if(!s)continue;e.className="annotationContent";const{firstChild:i}=s;i?i.nodeName==="CANVAS"?i.replaceWith(e):i.classList.contains("annotationContent")?i.after(e):i.before(e):s.append(e);const a=n(this,an).get(t);a&&(a._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(t,s.id,e),a._hasNoCanvas=!1):a.canvas=e)}n(this,pa).clear()};let ag=Jm;const yl=/\r\n?|\n/g;var Je,Se,_l,fa,xe,de,rg,og,hg,Sl,rn,xl,El,lg,xd,cg;const Ms=class Wt extends at{constructor(t){super({...t,name:"freeTextEditor"}),f(this,de),f(this,Je),f(this,Se,""),f(this,_l,`${this.id}-editor`),f(this,fa,null),f(this,xe),p(this,Je,t.color||Wt._defaultColor||at._defaultLineColor),p(this,xe,t.fontSize||Wt._defaultFontSize)}static get _keyboardManager(){const t=Wt.prototype,e=a=>a.isEmpty(),s=Dn.TRANSLATE_SMALL,i=Dn.TRANSLATE_BIG;return z(this,"_keyboardManager",new er([[["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 initialize(t,e){at.initialize(t,e);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case j.FREETEXT_SIZE:Wt._defaultFontSize=e;break;case j.FREETEXT_COLOR:Wt._defaultColor=e;break}}updateParams(t,e){switch(t){case j.FREETEXT_SIZE:m(this,de,rg).call(this,e);break;case j.FREETEXT_COLOR:m(this,de,og).call(this,e);break}}static get defaultPropertiesToUpdate(){return[[j.FREETEXT_SIZE,Wt._defaultFontSize],[j.FREETEXT_COLOR,Wt._defaultColor||at._defaultLineColor]]}get propertiesToUpdate(){return[[j.FREETEXT_SIZE,n(this,xe)],[j.FREETEXT_COLOR,n(this,Je)]]}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Wt._internalPadding*t,-(Wt._internalPadding+n(this,xe))*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,fa,new AbortController);const t=this._uiManager.combinedSignal(n(this,fa));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",n(this,_l)),this._isDraggable=!0,n(this,fa)?.abort(),p(this,fa,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=n(this,Se),e=p(this,Se,m(this,de,hg).call(this).trimEnd());if(t===e)return;const s=i=>{if(p(this,Se,i),!i){this.remove();return}m(this,de,El).call(this),this._uiManager.rebuild(this),m(this,de,Sl).call(this)};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),m(this,de,Sl).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Wt._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)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",n(this,_l)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${n(this,xe)}px * var(--total-scale-factor))`,s.color=n(this,Je),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[h,l]=this.getInitialTranslation();[h,l]=this.pageTranslationToScreen(h,l);const[d,c]=this.pageDimensions,[u,g]=this.pageTranslation;let w,b;switch(this.rotation){case 0:w=t+(o[0]-u)/d,b=e+this.height-(o[1]-g)/c;break;case 90:w=t+(o[0]-u)/d,b=e-(o[1]-g)/c,[h,l]=[l,-h];break;case 180:w=t-this.width+(o[0]-u)/d,b=e-(o[1]-g)/c,[h,l]=[-h,-l];break;case 270:w=t+(o[0]-u-this.height*c)/d,b=e+(o[1]-g-this.width*d)/c,[h,l]=[-l,h];break}this.setAt(w*i,b*a,h,l)}else this._moveAfterPaste(t,e);m(this,de,El).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){var e,s,i;const a=t.clipboardData||window.clipboardData,{types:o}=a;if(o.length===1&&o[0]==="text/plain")return;t.preventDefault();const h=m(e=Wt,rn,xd).call(e,a.getData("text")||"").replaceAll(yl,`
|
|
5
|
+
`);if(!h)return;const l=window.getSelection();if(!l.rangeCount)return;this.editorDiv.normalize(),l.deleteFromDocument();const d=l.getRangeAt(0);if(!h.includes(`
|
|
6
|
+
`)){d.insertNode(document.createTextNode(h)),this.editorDiv.normalize(),l.collapseToStart();return}const{startContainer:c,startOffset:u}=d,g=[],w=[];if(c.nodeType===Node.TEXT_NODE){const v=c.parentElement;if(w.push(c.nodeValue.slice(u).replaceAll(yl,"")),v!==this.editorDiv){let y=g;for(const S of this.editorDiv.childNodes){if(S===v){y=w;continue}y.push(m(s=Wt,rn,xl).call(s,S))}}g.push(c.nodeValue.slice(0,u).replaceAll(yl,""))}else if(c===this.editorDiv){let v=g,y=0;for(const S of this.editorDiv.childNodes)y++===u&&(v=w),v.push(m(i=Wt,rn,xl).call(i,S))}p(this,Se,`${g.join(`
|
|
7
|
+
`)}${h}${w.join(`
|
|
8
|
+
`)}`),m(this,de,El).call(this);const b=new Range;let A=Math.sumPrecise(g.map(v=>v.length));for(const{firstChild:v}of this.editorDiv.childNodes)if(v.nodeType===Node.TEXT_NODE){const y=v.nodeValue.length;if(A<=y){b.setStart(v,A),b.setEnd(v,A);break}A-=y}l.removeAllRanges(),l.addRange(b)}get contentDiv(){return this.editorDiv}static async deserialize(t,e,s){var i;let a=null;if(t instanceof eg){const{data:{defaultAppearanceData:{fontSize:h,fontColor:l},rect:d,rotation:c,id:u,popupRef:g},textContent:w,textPosition:b,parent:{page:{pageNumber:A}}}=t;if(!w||w.length===0)return null;a=t={annotationType:$.FREETEXT,color:Array.from(l),fontSize:h,value:w.join(`
|
|
9
|
+
`),position:b,pageIndex:A-1,rect:d.slice(0),rotation:c,id:u,deleted:!1,popupRef:g}}const o=await super.deserialize(t,e,s);return p(o,xe,t.fontSize),p(o,Je,L.makeHexColor(...t.color)),p(o,Se,m(i=Wt,rn,xd).call(i,t.value)),o.annotationElementId=t.id||null,o._initialData=a,o}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=Wt._internalPadding*this.parentScale,s=this.getRect(e,e),i=at._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:n(this,Je)),a={annotationType:$.FREETEXT,color:i,fontSize:n(this,xe),value:m(this,de,lg).call(this),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(a.isCopy=!0,a):this.annotationElementId&&!m(this,de,cg).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:s}=e;s.fontSize=`calc(${n(this,xe)}px * var(--total-scale-factor))`,s.color=n(this,Je),e.replaceChildren();for(const a of n(this,Se).split(`
|
|
10
|
+
`)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),e.append(o)}const i=Wt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:n(this,Se)}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};Je=new WeakMap,Se=new WeakMap,_l=new WeakMap,fa=new WeakMap,xe=new WeakMap,de=new WeakSet,rg=function(r){const t=s=>{this.editorDiv.style.fontSize=`calc(${s}px * var(--total-scale-factor))`,this.translate(0,-(s-n(this,xe))*this.parentScale),p(this,xe,s),m(this,de,Sl).call(this)},e=n(this,xe);this.addCommands({cmd:t.bind(this,r),undo:t.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},og=function(r){const t=s=>{p(this,Je,this.editorDiv.style.color=s)},e=n(this,Je);this.addCommands({cmd:t.bind(this,r),undo:t.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},hg=function(){var r;const t=[];this.editorDiv.normalize();let e=null;for(const s of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR"||(t.push(m(r=Ms,rn,xl).call(r,s)),e=s);return t.join(`
|
|
11
|
+
`)},Sl=function(){const[r,t]=this.parentDimensions;let e;if(this.isAttachedToDOM)e=this.div.getBoundingClientRect();else{const{currentLayer:s,div:i}=this,a=i.style.display,o=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",s.div.append(this.div),e=i.getBoundingClientRect(),i.remove(),i.style.display=a,i.classList.toggle("hidden",o)}this.rotation%180===this.parentRotation%180?(this.width=e.width/r,this.height=e.height/t):(this.width=e.height/r,this.height=e.width/t),this.fixAndSetPosition()},rn=new WeakSet,xl=function(r){return(r.nodeType===Node.TEXT_NODE?r.nodeValue:r.innerText).replaceAll(yl,"")},El=function(){if(this.editorDiv.replaceChildren(),!!n(this,Se))for(const r of n(this,Se).split(`
|
|
12
|
+
`)){const t=document.createElement("div");t.append(r?document.createTextNode(r):document.createElement("br")),this.editorDiv.append(t)}},lg=function(){return n(this,Se).replaceAll(" "," ")},xd=function(r){return r.replaceAll(" "," ")},cg=function(r){const{value:t,fontSize:e,color:s,pageIndex:i}=this._initialData;return this._hasBeenMoved||r.value!==t||r.fontSize!==e||r.color.some((a,o)=>a!==s[o])||r.pageIndex!==i},f(Ms,rn),C(Ms,"_freeTextDefaultContent",""),C(Ms,"_internalPadding",0),C(Ms,"_defaultColor",null),C(Ms,"_defaultFontSize",10),C(Ms,"_type","freetext"),C(Ms,"_editorType",$.FREETEXT);let Zm=Ms;class P{toSVGPath(){Y("Abstract method `toSVGPath` must be implemented.")}get box(){Y("Abstract getter `box` must be implemented.")}serialize(t,e){Y("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,a,o){o||(o=new Float32Array(t.length));for(let h=0,l=t.length;h<l;h+=2)o[h]=e+t[h]*i,o[h+1]=s+t[h+1]*a;return o}static _rescaleAndSwap(t,e,s,i,a,o){o||(o=new Float32Array(t.length));for(let h=0,l=t.length;h<l;h+=2)o[h]=e+t[h+1]*i,o[h+1]=s+t[h]*a;return o}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let a=0,o=t.length;a<o;a+=2)i[a]=e+t[a],i[a+1]=s+t[a+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,a){switch(a){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,i,a,o){return[(t+5*s)/6,(e+5*i)/6,(5*s+a)/6,(5*i+o)/6,(s+a)/2,(i+o)/2]}}C(P,"PRECISION",1e-4);var Ee,Ze,eo,so,ks,U,ma,wa,Ml,kl,io,no,on,Cl,Ed,Md,Me,ao,dg,ug,pg,gg,fg,mg;const ba=class tu{constructor({x:t,y:e},s,i,a,o,h=0){f(this,Me),f(this,Ee),f(this,Ze,[]),f(this,eo),f(this,so),f(this,ks,[]),f(this,U,new Float32Array(18)),f(this,ma),f(this,wa),f(this,Ml),f(this,kl),f(this,io),f(this,no),f(this,on,[]),p(this,Ee,s),p(this,no,a*i),p(this,so,o),n(this,U).set([NaN,NaN,NaN,NaN,t,e],6),p(this,eo,h),p(this,kl,n(tu,Cl)*i),p(this,Ml,n(tu,Md)*i),p(this,io,i),n(this,on).push(t,e)}isEmpty(){return isNaN(n(this,U)[8])}add({x:t,y:e}){p(this,ma,t),p(this,wa,e);const[s,i,a,o]=n(this,Ee);let[h,l,d,c]=n(this,U).subarray(8,12);const u=t-d,g=e-c,w=Math.hypot(u,g);if(w<n(this,Ml))return!1;const b=w-n(this,kl),A=b/w,v=A*u,y=A*g;let S=h,_=l;h=d,l=c,d+=v,c+=y,n(this,on)?.push(t,e);const x=-y/b,E=v/b,M=x*n(this,no),k=E*n(this,no);return n(this,U).set(n(this,U).subarray(2,8),0),n(this,U).set([d+M,c+k],4),n(this,U).set(n(this,U).subarray(14,18),12),n(this,U).set([d-M,c-k],16),isNaN(n(this,U)[6])?(n(this,ks).length===0&&(n(this,U).set([h+M,l+k],2),n(this,ks).push(NaN,NaN,NaN,NaN,(h+M-s)/a,(l+k-i)/o),n(this,U).set([h-M,l-k],14),n(this,Ze).push(NaN,NaN,NaN,NaN,(h-M-s)/a,(l-k-i)/o)),n(this,U).set([S,_,h,l,d,c],6),!this.isEmpty()):(n(this,U).set([S,_,h,l,d,c],6),Math.abs(Math.atan2(_-l,S-h)-Math.atan2(y,v))<Math.PI/2?([h,l,d,c]=n(this,U).subarray(2,6),n(this,ks).push(NaN,NaN,NaN,NaN,((h+d)/2-s)/a,((l+c)/2-i)/o),[h,l,S,_]=n(this,U).subarray(14,18),n(this,Ze).push(NaN,NaN,NaN,NaN,((S+h)/2-s)/a,((_+l)/2-i)/o),!0):([S,_,h,l,d,c]=n(this,U).subarray(0,6),n(this,ks).push(((S+5*h)/6-s)/a,((_+5*l)/6-i)/o,((5*h+d)/6-s)/a,((5*l+c)/6-i)/o,((h+d)/2-s)/a,((l+c)/2-i)/o),[d,c,h,l,S,_]=n(this,U).subarray(12,18),n(this,Ze).push(((S+5*h)/6-s)/a,((_+5*l)/6-i)/o,((5*h+d)/6-s)/a,((5*l+c)/6-i)/o,((h+d)/2-s)/a,((l+c)/2-i)/o),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,ks),e=n(this,Ze);if(isNaN(n(this,U)[6])&&!this.isEmpty())return m(this,Me,dg).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);m(this,Me,pg).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return m(this,Me,ug).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,a,o){return new Ag(t,e,s,i,a,o)}getOutlines(){const t=n(this,ks),e=n(this,Ze),s=n(this,U),[i,a,o,h]=n(this,Ee),l=new Float32Array((n(this,on)?.length??0)+2);for(let u=0,g=l.length-2;u<g;u+=2)l[u]=(n(this,on)[u]-i)/o,l[u+1]=(n(this,on)[u+1]-a)/h;if(l[l.length-2]=(n(this,ma)-i)/o,l[l.length-1]=(n(this,wa)-a)/h,isNaN(s[6])&&!this.isEmpty())return m(this,Me,gg).call(this,l);const d=new Float32Array(n(this,ks).length+24+n(this,Ze).length);let c=t.length;for(let u=0;u<c;u+=2){if(isNaN(t[u])){d[u]=d[u+1]=NaN;continue}d[u]=t[u],d[u+1]=t[u+1]}c=m(this,Me,mg).call(this,d,c);for(let u=e.length-6;u>=6;u-=6)for(let g=0;g<6;g+=2){if(isNaN(e[u+g])){d[c]=d[c+1]=NaN,c+=2;continue}d[c]=e[u+g],d[c+1]=e[u+g+1],c+=2}return m(this,Me,fg).call(this,d,c),this.newFreeDrawOutline(d,l,n(this,Ee),n(this,io),n(this,eo),n(this,so))}};Ee=new WeakMap,Ze=new WeakMap,eo=new WeakMap,so=new WeakMap,ks=new WeakMap,U=new WeakMap,ma=new WeakMap,wa=new WeakMap,Ml=new WeakMap,kl=new WeakMap,io=new WeakMap,no=new WeakMap,on=new WeakMap,Cl=new WeakMap,Ed=new WeakMap,Md=new WeakMap,Me=new WeakSet,ao=function(){const r=n(this,U).subarray(4,6),t=n(this,U).subarray(16,18),[e,s,i,a]=n(this,Ee);return[(n(this,ma)+(r[0]-t[0])/2-e)/i,(n(this,wa)+(r[1]-t[1])/2-s)/a,(n(this,ma)+(t[0]-r[0])/2-e)/i,(n(this,wa)+(t[1]-r[1])/2-s)/a]},dg=function(){const[r,t,e,s]=n(this,Ee),[i,a,o,h]=m(this,Me,ao).call(this);return`M${(n(this,U)[2]-r)/e} ${(n(this,U)[3]-t)/s} L${(n(this,U)[4]-r)/e} ${(n(this,U)[5]-t)/s} L${i} ${a} L${o} ${h} L${(n(this,U)[16]-r)/e} ${(n(this,U)[17]-t)/s} L${(n(this,U)[14]-r)/e} ${(n(this,U)[15]-t)/s} Z`},ug=function(r){const t=n(this,Ze);r.push(`L${t[4]} ${t[5]} Z`)},pg=function(r){const[t,e,s,i]=n(this,Ee),a=n(this,U).subarray(4,6),o=n(this,U).subarray(16,18),[h,l,d,c]=m(this,Me,ao).call(this);r.push(`L${(a[0]-t)/s} ${(a[1]-e)/i} L${h} ${l} L${d} ${c} L${(o[0]-t)/s} ${(o[1]-e)/i}`)},gg=function(r){const t=n(this,U),[e,s,i,a]=n(this,Ee),[o,h,l,d]=m(this,Me,ao).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(t[2]-e)/i,(t[3]-s)/a,NaN,NaN,NaN,NaN,(t[4]-e)/i,(t[5]-s)/a,NaN,NaN,NaN,NaN,o,h,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,(t[16]-e)/i,(t[17]-s)/a,NaN,NaN,NaN,NaN,(t[14]-e)/i,(t[15]-s)/a],0),this.newFreeDrawOutline(c,r,n(this,Ee),n(this,io),n(this,eo),n(this,so))},fg=function(r,t){const e=n(this,Ze);return r.set([NaN,NaN,NaN,NaN,e[4],e[5]],t),t+=6},mg=function(r,t){const e=n(this,U).subarray(4,6),s=n(this,U).subarray(16,18),[i,a,o,h]=n(this,Ee),[l,d,c,u]=m(this,Me,ao).call(this);return r.set([NaN,NaN,NaN,NaN,(e[0]-i)/o,(e[1]-a)/h,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,(s[0]-i)/o,(s[1]-a)/h],t),t+=24},f(ba,Cl,8),f(ba,Ed,2),f(ba,Md,n(ba,Cl)+n(ba,Ed));let wg=ba;var ro,Aa,di,Tl,ke,Rl,bt,kd,bg;class Ag extends P{constructor(t,e,s,i,a,o){super(),f(this,kd),f(this,ro),f(this,Aa,new Float32Array(4)),f(this,di),f(this,Tl),f(this,ke),f(this,Rl),f(this,bt),p(this,bt,t),p(this,ke,e),p(this,ro,s),p(this,Rl,i),p(this,di,a),p(this,Tl,o),this.lastPoint=[NaN,NaN],m(this,kd,bg).call(this,o);const[h,l,d,c]=n(this,Aa);for(let u=0,g=t.length;u<g;u+=2)t[u]=(t[u]-h)/d,t[u+1]=(t[u+1]-l)/c;for(let u=0,g=e.length;u<g;u+=2)e[u]=(e[u]-h)/d,e[u+1]=(e[u+1]-l)/c}toSVGPath(){const t=[`M${n(this,bt)[4]} ${n(this,bt)[5]}`];for(let e=6,s=n(this,bt).length;e<s;e+=6){if(isNaN(n(this,bt)[e])){t.push(`L${n(this,bt)[e+4]} ${n(this,bt)[e+5]}`);continue}t.push(`C${n(this,bt)[e]} ${n(this,bt)[e+1]} ${n(this,bt)[e+2]} ${n(this,bt)[e+3]} ${n(this,bt)[e+4]} ${n(this,bt)[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],a){const o=s-t,h=i-e;let l,d;switch(a){case 0:l=P._rescale(n(this,bt),t,i,o,-h),d=P._rescale(n(this,ke),t,i,o,-h);break;case 90:l=P._rescaleAndSwap(n(this,bt),t,e,o,h),d=P._rescaleAndSwap(n(this,ke),t,e,o,h);break;case 180:l=P._rescale(n(this,bt),s,e,-o,h),d=P._rescale(n(this,ke),s,e,-o,h);break;case 270:l=P._rescaleAndSwap(n(this,bt),s,i,-o,-h),d=P._rescaleAndSwap(n(this,ke),s,i,-o,-h);break}return{outline:Array.from(l),points:[Array.from(d)]}}get box(){return n(this,Aa)}newOutliner(t,e,s,i,a,o=0){return new wg(t,e,s,i,a,o)}getNewOutline(t,e){const[s,i,a,o]=n(this,Aa),[h,l,d,c]=n(this,ro),u=a*d,g=o*c,w=s*d+h,b=i*c+l,A=this.newOutliner({x:n(this,ke)[0]*u+w,y:n(this,ke)[1]*g+b},n(this,ro),n(this,Rl),t,n(this,Tl),e??n(this,di));for(let v=2;v<n(this,ke).length;v+=2)A.add({x:n(this,ke)[v]*u+w,y:n(this,ke)[v+1]*g+b});return A.getOutlines()}}ro=new WeakMap,Aa=new WeakMap,di=new WeakMap,Tl=new WeakMap,ke=new WeakMap,Rl=new WeakMap,bt=new WeakMap,kd=new WeakSet,bg=function(r){const t=n(this,bt);let e=t[4],s=t[5];const i=[e,s,e,s];let a=e,o=s;const h=r?Math.max:Math.min;for(let d=6,c=t.length;d<c;d+=6){const u=t[d+4],g=t[d+5];if(isNaN(t[d]))L.pointBoundingBox(u,g,i),o<g?(a=u,o=g):o===g&&(a=h(a,u));else{const w=[1/0,1/0,-1/0,-1/0];L.bezierBoundingBox(e,s,...t.slice(d,d+6),w),L.rectBoundingBox(...w,i),o<w[3]?(a=w[2],o=w[3]):o===w[3]&&(a=h(a,w[2]))}e=u,s=g}const l=n(this,Aa);l[0]=i[0]-n(this,di),l[1]=i[1]-n(this,di),l[2]=i[2]-i[0]+2*n(this,di),l[3]=i[3]-i[1]+2*n(this,di),this.lastPoint=[a,o]};var Pl,Il,hn,ts,es,vg,Ll,yg,_g,Cd;class Td{constructor(t,e=0,s=0,i=!0){f(this,es),f(this,Pl),f(this,Il),f(this,hn,[]),f(this,ts,[]);const a=[1/0,1/0,-1/0,-1/0],o=10**-4;for(const{x:w,y:b,width:A,height:v}of t){const y=Math.floor((w-e)/o)*o,S=Math.ceil((w+A+e)/o)*o,_=Math.floor((b-e)/o)*o,x=Math.ceil((b+v+e)/o)*o,E=[y,_,x,!0],M=[S,_,x,!1];n(this,hn).push(E,M),L.rectBoundingBox(y,_,S,x,a)}const h=a[2]-a[0]+2*s,l=a[3]-a[1]+2*s,d=a[0]-s,c=a[1]-s,u=n(this,hn).at(i?-1:-2),g=[u[0],u[2]];for(const w of n(this,hn)){const[b,A,v]=w;w[0]=(b-d)/h,w[1]=(A-c)/l,w[2]=(v-c)/l}p(this,Pl,new Float32Array([d,c,h,l])),p(this,Il,g)}getOutlines(){n(this,hn).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,hn))e[3]?(t.push(...m(this,es,Cd).call(this,e)),m(this,es,yg).call(this,e)):(m(this,es,_g).call(this,e),t.push(...m(this,es,Cd).call(this,e)));return m(this,es,vg).call(this,t)}}Pl=new WeakMap,Il=new WeakMap,hn=new WeakMap,ts=new WeakMap,es=new WeakSet,vg=function(r){const t=[],e=new Set;for(const a of r){const[o,h,l]=a;t.push([o,h,a],[o,l,a])}t.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=t.length;a<o;a+=2){const h=t[a][2],l=t[a+1][2];h.push(l),l.push(h),e.add(h),e.add(l)}const s=[];let i;for(;e.size>0;){const a=e.values().next().value;let[o,h,l,d,c]=a;e.delete(a);let u=o,g=h;for(i=[o,l],s.push(i);;){let w;if(e.has(d))w=d;else if(e.has(c))w=c;else break;e.delete(w),[o,h,l,d,c]=w,u!==o&&(i.push(u,g,o,g===h?h:l),u=o),g=g===h?l:h}i.push(u,g)}return new tw(s,n(this,Pl),n(this,Il))},Ll=function(r){const t=n(this,ts);let e=0,s=t.length-1;for(;e<=s;){const i=e+s>>1,a=t[i][0];if(a===r)return i;a<r?e=i+1:s=i-1}return s+1},yg=function([,r,t]){const e=m(this,es,Ll).call(this,r);n(this,ts).splice(e,0,[r,t])},_g=function([,r,t]){const e=m(this,es,Ll).call(this,r);for(let s=e;s<n(this,ts).length;s++){const[i,a]=n(this,ts)[s];if(i!==r)break;if(i===r&&a===t){n(this,ts).splice(s,1);return}}for(let s=e-1;s>=0;s--){const[i,a]=n(this,ts)[s];if(i!==r)break;if(i===r&&a===t){n(this,ts).splice(s,1);return}}},Cd=function(r){const[t,e,s]=r,i=[[t,e,s]],a=m(this,es,Ll).call(this,s);for(let o=0;o<a;o++){const[h,l]=n(this,ts)[o];for(let d=0,c=i.length;d<c;d++){const[,u,g]=i[d];if(!(l<=u||g<=h)){if(u>=h){if(g>l)i[d][1]=l;else{if(c===1)return[];i.splice(d,1),d--,c--}continue}i[d][2]=h,g>l&&i.push([t,l,g])}}}return i};var Dl,oo;class tw extends P{constructor(t,e,s){super(),f(this,Dl),f(this,oo),p(this,oo,t),p(this,Dl,e),this.lastPoint=s}toSVGPath(){const t=[];for(const e of n(this,oo)){let[s,i]=e;t.push(`M${s} ${i}`);for(let a=2;a<e.length;a+=2){const o=e[a],h=e[a+1];o===s?(t.push(`V${h}`),i=h):h===i&&(t.push(`H${o}`),s=o)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],a){const o=[],h=s-t,l=i-e;for(const d of n(this,oo)){const c=new Array(d.length);for(let u=0;u<d.length;u+=2)c[u]=t+d[u]*h,c[u+1]=i-d[u+1]*l;o.push(c)}return o}get box(){return n(this,Dl)}get classNamesForOutlining(){return["highlightOutline"]}}Dl=new WeakMap,oo=new WeakMap;class Rd extends wg{newFreeDrawOutline(t,e,s,i,a,o){return new ew(t,e,s,i,a,o)}}class ew extends Ag{newOutliner(t,e,s,i,a,o=0){return new Rd(t,e,s,i,a,o)}}var ss,va,ho,Ct,Nl,lo,Fl,Ol,ln,is,co,uo,lt,Pd,Id,Ld,cn,Sg,ui;const Wl=class Ns{constructor({editor:t=null,uiManager:e=null}){f(this,lt),f(this,ss,null),f(this,va,null),f(this,ho),f(this,Ct,null),f(this,Nl,!1),f(this,lo,!1),f(this,Fl,null),f(this,Ol),f(this,ln,null),f(this,is,null),f(this,co),t?(p(this,lo,!1),p(this,co,j.HIGHLIGHT_COLOR),p(this,Fl,t)):(p(this,lo,!0),p(this,co,j.HIGHLIGHT_DEFAULT_COLOR)),p(this,is,t?._uiManager||e),p(this,Ol,n(this,is)._eventBus),p(this,ho,t?.color||n(this,is)?.highlightColors.values().next().value||"#FFFF98"),n(Ns,uo)||p(Ns,uo,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return z(this,"_keyboardManager",new er([[["Escape","mac+Escape"],Ns.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Ns.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Ns.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Ns.prototype._moveToPrevious],[["Home","mac+Home"],Ns.prototype._moveToBeginning],[["End","mac+End"],Ns.prototype._moveToEnd]]))}renderButton(){const t=p(this,ss,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=n(this,is)._signal;t.addEventListener("click",m(this,lt,cn).bind(this),{signal:e}),t.addEventListener("keydown",m(this,lt,Ld).bind(this),{signal:e});const s=p(this,va,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=n(this,ho),t.append(s),t}renderMainDropdown(){const t=p(this,Ct,m(this,lt,Pd).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===n(this,ss)){m(this,lt,cn).call(this,t);return}const e=t.target.getAttribute("data-color");e&&m(this,lt,Id).call(this,e,t)}_moveToNext(t){if(!n(this,lt,ui)){m(this,lt,cn).call(this,t);return}if(t.target===n(this,ss)){n(this,Ct).firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===n(this,Ct)?.firstChild||t.target===n(this,ss)){n(this,lt,ui)&&this._hideDropdownFromKeyboard();return}n(this,lt,ui)||m(this,lt,cn).call(this,t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!n(this,lt,ui)){m(this,lt,cn).call(this,t);return}n(this,Ct).firstChild?.focus()}_moveToEnd(t){if(!n(this,lt,ui)){m(this,lt,cn).call(this,t);return}n(this,Ct).lastChild?.focus()}hideDropdown(){n(this,Ct)?.classList.add("hidden"),n(this,ln)?.abort(),p(this,ln,null)}_hideDropdownFromKeyboard(){if(!n(this,lo)){if(!n(this,lt,ui)){n(this,Fl)?.unselect();return}this.hideDropdown(),n(this,ss).focus({preventScroll:!0,focusVisible:n(this,Nl)})}}updateColor(t){if(n(this,va)&&(n(this,va).style.backgroundColor=t),!n(this,Ct))return;const e=n(this,is).highlightColors.values();for(const s of n(this,Ct).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){n(this,ss)?.remove(),p(this,ss,null),p(this,va,null),n(this,Ct)?.remove(),p(this,Ct,null)}};ss=new WeakMap,va=new WeakMap,ho=new WeakMap,Ct=new WeakMap,Nl=new WeakMap,lo=new WeakMap,Fl=new WeakMap,Ol=new WeakMap,ln=new WeakMap,is=new WeakMap,co=new WeakMap,uo=new WeakMap,lt=new WeakSet,Pd=function(){const r=document.createElement("div"),t=n(this,is)._signal;r.addEventListener("contextmenu",me,{signal:t}),r.className="dropdown",r.role="listbox",r.setAttribute("aria-multiselectable",!1),r.setAttribute("aria-orientation","vertical"),r.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[e,s]of n(this,is).highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",s),i.title=e,i.setAttribute("data-l10n-id",n(Wl,uo)[e]);const a=document.createElement("span");i.append(a),a.className="swatch",a.style.backgroundColor=s,i.setAttribute("aria-selected",s===n(this,ho)),i.addEventListener("click",m(this,lt,Id).bind(this,s),{signal:t}),r.append(i)}return r.addEventListener("keydown",m(this,lt,Ld).bind(this),{signal:t}),r},Id=function(r,t){t.stopPropagation(),n(this,Ol).dispatch("switchannotationeditorparams",{source:this,type:n(this,co),value:r})},Ld=function(r){Wl._keyboardManager.exec(this,r)},cn=function(r){if(n(this,lt,ui)){this.hideDropdown();return}if(p(this,Nl,r.detail===0),n(this,ln)||(p(this,ln,new AbortController),window.addEventListener("pointerdown",m(this,lt,Sg).bind(this),{signal:n(this,is).combinedSignal(n(this,ln))})),n(this,Ct)){n(this,Ct).classList.remove("hidden");return}const t=p(this,Ct,m(this,lt,Pd).call(this));n(this,ss).append(t)},Sg=function(r){n(this,Ct)?.contains(r.target)||this.hideDropdown()},ui=function(){return n(this,Ct)&&!n(this,Ct).classList.contains("hidden")},f(Wl,uo,null);let Dd=Wl;var po,Bl,pi,ya,go,ue,Hl,$l,_a,We,Ce,Vt,fo,gi,Qt,mo,Be,Gl,X,Nd,zl,xg,Eg,Mg,Fd,dn,Cs,Sa,kg,Ul,wo,Cg,Tg,Rg,Pg,Ig;const ie=class qt extends at{constructor(t){super({...t,name:"highlightEditor"}),f(this,X),f(this,po,null),f(this,Bl,0),f(this,pi),f(this,ya,null),f(this,go,null),f(this,ue,null),f(this,Hl,null),f(this,$l,0),f(this,_a,null),f(this,We,null),f(this,Ce,null),f(this,Vt,!1),f(this,fo,null),f(this,gi),f(this,Qt,null),f(this,mo,""),f(this,Be),f(this,Gl,""),this.color=t.color||qt._defaultColor,p(this,Be,t.thickness||qt._defaultThickness),p(this,gi,t.opacity||qt._defaultOpacity),p(this,pi,t.boxes||null),p(this,Gl,t.methodOfCreation||""),p(this,mo,t.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(p(this,Vt,!0),m(this,X,zl).call(this,t),m(this,X,dn).call(this)):n(this,pi)&&(p(this,po,t.anchorNode),p(this,Bl,t.anchorOffset),p(this,Hl,t.focusNode),p(this,$l,t.focusOffset),m(this,X,Nd).call(this),m(this,X,dn).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const t=qt.prototype;return z(this,"_keyboardManager",new er([[["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]}]]))}get telemetryInitialData(){return{action:"added",type:n(this,Vt)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:n(this,Be),methodOfCreation:n(this,Gl)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,e){at.initialize(t,e),qt._defaultColor||(qt._defaultColor=e.highlightColors?.values().next().value||"#fff066")}static updateDefaultParams(t,e){switch(t){case j.HIGHLIGHT_DEFAULT_COLOR:qt._defaultColor=e;break;case j.HIGHLIGHT_THICKNESS:qt._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return n(this,fo)}updateParams(t,e){switch(t){case j.HIGHLIGHT_COLOR:m(this,X,xg).call(this,e);break;case j.HIGHLIGHT_THICKNESS:m(this,X,Eg).call(this,e);break}}static get defaultPropertiesToUpdate(){return[[j.HIGHLIGHT_DEFAULT_COLOR,qt._defaultColor],[j.HIGHLIGHT_THICKNESS,qt._defaultThickness]]}get propertiesToUpdate(){return[[j.HIGHLIGHT_COLOR,this.color||qt._defaultColor],[j.HIGHLIGHT_THICKNESS,n(this,Be)||qt._defaultThickness],[j.HIGHLIGHT_FREE,n(this,Vt)]]}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(p(this,go,new Dd({editor:this})),t.addColorPicker(n(this,go))),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(m(this,X,wo).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,m(this,X,wo).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){m(this,X,Fd).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,X,dn).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?m(this,X,Fd).call(this):t&&(m(this,X,dn).call(this,t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}rotate(t){var e,s,i;const{drawLayer:a}=this.parent;let o;n(this,Vt)?(t=(t-this.rotation+360)%360,o=m(e=qt,Cs,Sa).call(e,n(this,We).box,t)):o=m(s=qt,Cs,Sa).call(s,[this.x,this.y,this.width,this.height],t),a.updateProperties(n(this,Ce),{bbox:o,root:{"data-main-rotation":t}}),a.updateProperties(n(this,Qt),{bbox:m(i=qt,Cs,Sa).call(i,n(this,ue).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();n(this,mo)&&(t.setAttribute("aria-label",n(this,mo)),t.setAttribute("role","mark")),n(this,Vt)?t.classList.add("free"):this.div.addEventListener("keydown",m(this,X,kg).bind(this),{signal:this._uiManager._signal});const e=p(this,_a,document.createElement("div"));t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=n(this,ya);const[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),Su(this,n(this,_a),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(n(this,Qt),{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(n(this,Qt),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:m(this,X,Ul).call(this,!0);break;case 1:case 3:m(this,X,Ul).call(this,!1);break}}select(){super.select(),n(this,Qt)&&this.parent?.drawLayer.updateProperties(n(this,Qt),{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),n(this,Qt)&&(this.parent?.drawLayer.updateProperties(n(this,Qt),{rootClass:{selected:!1}}),n(this,Vt)||m(this,X,Ul).call(this,!1))}get _mustFixPosition(){return!n(this,Vt)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(n(this,Ce),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(n(this,Qt),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,{target:s,x:i,y:a}){const{x:o,y:h,width:l,height:d}=s.getBoundingClientRect(),c=new AbortController,u=t.combinedSignal(c),g=w=>{c.abort(),m(this,Cs,Pg).call(this,t,w)};window.addEventListener("blur",g,{signal:u}),window.addEventListener("pointerup",g,{signal:u}),window.addEventListener("pointerdown",ut,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",me,{signal:u}),s.addEventListener("pointermove",m(this,Cs,Rg).bind(this,t),{signal:u}),this._freeHighlight=new Rd({x:i,y:a},[o,h,l,d],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(t,e,s){var i,a,o,h;let l=null;if(t instanceof ig){const{data:{quadPoints:S,rect:_,rotation:x,id:E,color:M,opacity:k,popupRef:T},parent:{page:{pageNumber:R}}}=t;l=t={annotationType:$.HIGHLIGHT,color:Array.from(M),opacity:k,quadPoints:S,boxes:null,pageIndex:R-1,rect:_.slice(0),rotation:x,id:E,deleted:!1,popupRef:T}}else if(t instanceof vd){const{data:{inkLists:S,rect:_,rotation:x,id:E,color:M,borderStyle:{rawWidth:k},popupRef:T},parent:{page:{pageNumber:R}}}=t;l=t={annotationType:$.HIGHLIGHT,color:Array.from(M),thickness:k,inkLists:S,boxes:null,pageIndex:R-1,rect:_.slice(0),rotation:x,id:E,deleted:!1,popupRef:T}}const{color:d,quadPoints:c,inkLists:u,opacity:g}=t,w=await super.deserialize(t,e,s);w.color=L.makeHexColor(...d),p(w,gi,g||1),u&&p(w,Be,t.thickness),w.annotationElementId=t.id||null,w._initialData=l;const[b,A]=w.pageDimensions,[v,y]=w.pageTranslation;if(c){const S=p(w,pi,[]);for(let _=0;_<c.length;_+=8)S.push({x:(c[_]-v)/b,y:1-(c[_+1]-y)/A,width:(c[_+2]-c[_])/b,height:(c[_+1]-c[_+5])/A});m(i=w,X,Nd).call(i),m(a=w,X,dn).call(a),w.rotate(w.rotation)}else if(u){p(w,Vt,!0);const S=u[0],_={x:S[0]-v,y:A-(S[1]-y)},x=new Rd(_,[0,0,b,A],1,n(w,Be)/2,!0,.001);for(let k=0,T=S.length;k<T;k+=2)_.x=S[k]-v,_.y=A-(S[k+1]-y),x.add(_);const{id:E,clipPathId:M}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:w.color,"fill-opacity":w._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:x.toSVGPath()}},!0,!0);m(o=w,X,zl).call(o,{highlightOutlines:x.getOutlines(),highlightId:E,clipPathId:M}),m(h=w,X,dn).call(h),w.rotate(w.parentRotation)}return w}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),s=at._colorManager.convert(this.color),i={annotationType:$.HIGHLIGHT,color:s,opacity:n(this,gi),thickness:n(this,Be),quadPoints:m(this,X,Cg).call(this),outlines:m(this,X,Tg).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:m(this,X,wo).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!m(this,X,Ig).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};po=new WeakMap,Bl=new WeakMap,pi=new WeakMap,ya=new WeakMap,go=new WeakMap,ue=new WeakMap,Hl=new WeakMap,$l=new WeakMap,_a=new WeakMap,We=new WeakMap,Ce=new WeakMap,Vt=new WeakMap,fo=new WeakMap,gi=new WeakMap,Qt=new WeakMap,mo=new WeakMap,Be=new WeakMap,Gl=new WeakMap,X=new WeakSet,Nd=function(){const r=new Td(n(this,pi),.001);p(this,We,r.getOutlines()),[this.x,this.y,this.width,this.height]=n(this,We).box;const t=new Td(n(this,pi),.0025,.001,this._uiManager.direction==="ltr");p(this,ue,t.getOutlines());const{lastPoint:e}=n(this,ue);p(this,fo,[(e[0]-this.x)/this.width,(e[1]-this.y)/this.height])},zl=function({highlightOutlines:r,highlightId:t,clipPathId:e}){var s,i;if(p(this,We,r),p(this,ue,r.getNewOutline(n(this,Be)/2+1.5,.0025)),t>=0)p(this,Ce,t),p(this,ya,e),this.parent.drawLayer.finalizeDraw(t,{bbox:r.box,path:{d:r.toSVGPath()}}),p(this,Qt,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,ue).box,path:{d:n(this,ue).toSVGPath()}},!0));else if(this.parent){const c=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,Ce),{bbox:m(s=ie,Cs,Sa).call(s,n(this,We).box,(c-this.rotation+360)%360),path:{d:r.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,Qt),{bbox:m(i=ie,Cs,Sa).call(i,n(this,ue).box,c),path:{d:n(this,ue).toSVGPath()}})}const[a,o,h,l]=r.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=h,this.height=l;break;case 90:{const[c,u]=this.parentDimensions;this.x=o,this.y=1-a,this.width=h*u/c,this.height=l*c/u;break}case 180:this.x=1-a,this.y=1-o,this.width=h,this.height=l;break;case 270:{const[c,u]=this.parentDimensions;this.x=1-o,this.y=a,this.width=h*u/c,this.height=l*c/u;break}}const{lastPoint:d}=n(this,ue);p(this,fo,[(d[0]-a)/h,(d[1]-o)/l])},xg=function(r){const t=(i,a)=>{this.color=i,p(this,gi,a),this.parent?.drawLayer.updateProperties(n(this,Ce),{root:{fill:i,"fill-opacity":a}}),n(this,go)?.updateColor(i)},e=this.color,s=n(this,gi);this.addCommands({cmd:t.bind(this,r,ie._defaultOpacity),undo:t.bind(this,e,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(r)},!0)},Eg=function(r){const t=n(this,Be),e=s=>{p(this,Be,s),m(this,X,Mg).call(this,s)};this.addCommands({cmd:e.bind(this,r),undo:e.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:j.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:r},!0)},Mg=function(r){if(!n(this,Vt))return;m(this,X,zl).call(this,{highlightOutlines:n(this,We).getNewOutline(r/2)}),this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)},Fd=function(){n(this,Ce)===null||!this.parent||(this.parent.drawLayer.remove(n(this,Ce)),p(this,Ce,null),this.parent.drawLayer.remove(n(this,Qt)),p(this,Qt,null))},dn=function(r=this.parent){n(this,Ce)===null&&({id:Zt(this,Ce)._,clipPathId:Zt(this,ya)._}=r.drawLayer.draw({bbox:n(this,We).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":n(this,gi)},rootClass:{highlight:!0,free:n(this,Vt)},path:{d:n(this,We).toSVGPath()}},!1,!0),p(this,Qt,r.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,Vt)},bbox:n(this,ue).box,path:{d:n(this,ue).toSVGPath()}},n(this,Vt))),n(this,_a)&&(n(this,_a).style.clipPath=n(this,ya)))},Cs=new WeakSet,Sa=function([r,t,e,s],i){switch(i){case 90:return[1-t-s,r,s,e];case 180:return[1-r-e,1-t-s,e,s];case 270:return[t,1-r-e,s,e]}return[r,t,e,s]},kg=function(r){ie._keyboardManager.exec(this,r)},Ul=function(r){if(!n(this,po))return;const t=window.getSelection();r?t.setPosition(n(this,po),n(this,Bl)):t.setPosition(n(this,Hl),n(this,$l))},wo=function(){return n(this,Vt)?this.rotation:0},Cg=function(){if(n(this,Vt))return null;const[r,t]=this.pageDimensions,[e,s]=this.pageTranslation,i=n(this,pi),a=new Float32Array(i.length*8);let o=0;for(const{x:h,y:l,width:d,height:c}of i){const u=h*r+e,g=(1-l)*t+s;a[o]=a[o+4]=u,a[o+1]=a[o+3]=g,a[o+2]=a[o+6]=u+d*r,a[o+5]=a[o+7]=g-c*t,o+=8}return a},Tg=function(r){return n(this,We).serialize(r,m(this,X,wo).call(this))},Rg=function(r,t){this._freeHighlight.add(t)&&r.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Pg=function(r,t){this._freeHighlight.isEmpty()?r.drawLayer.remove(this._freeHighlightId):r.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Ig=function(r){const{color:t}=this._initialData;return r.color.some((e,s)=>e!==t[s])},f(ie,Cs),C(ie,"_defaultColor",null),C(ie,"_defaultOpacity",1),C(ie,"_defaultThickness",12),C(ie,"_type","highlight"),C(ie,"_editorType",$.HIGHLIGHT),C(ie,"_freeHighlightId",-1),C(ie,"_freeHighlight",null),C(ie,"_freeHighlightClipId","");let Lg=ie;var xa;class Dg{constructor(){f(this,xa,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,xa)[t]=e}toSVGProperties(){const t=n(this,xa);return p(this,xa,Object.create(null)),{root:t}}reset(){p(this,xa,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Y("Not implemented")}}xa=new WeakMap;var Te,bo,It,Ea,Ma,fi,mi,wi,ka,et,Od,Wd,Bd,Ao,Ng,jl,vo,Ca;const Re=class W extends at{constructor(t){super(t),f(this,et),f(this,Te,null),f(this,bo),C(this,"_drawId",null),p(this,bo,t.mustBeCommitted||!1),this._addOutlines(t)}_addOutlines(t){t.drawOutlines&&(m(this,et,Od).call(this,t),m(this,et,Ao).call(this))}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[i,a]of Object.entries(e))s.has(i)?Object.assign(t[i],a):t[i]=a;return t}static getDefaultDrawingOptions(t){Y("Not implemented")}static get typesMap(){Y("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&(n(W,It).updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){const i=this._drawingOptions,a=i[e],o=h=>{i.updateProperty(e,h);const l=n(this,Te).updateProperty(e,h);l&&m(this,et,vo).call(this,l),this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties())};this.addCommands({cmd:o.bind(this,s),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,W._mergeSVGProperties(n(this,Te).getPathResizingSVGProperties(m(this,et,jl).call(this)),{bbox:m(this,et,Ca).call(this)}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,W._mergeSVGProperties(n(this,Te).getPathResizedSVGProperties(m(this,et,jl).call(this)),{bbox:m(this,et,Ca).call(this)}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:m(this,et,Ca).call(this)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,W._mergeSVGProperties(n(this,Te).getPathTranslatedSVGProperties(m(this,et,jl).call(this),this.parentDimensions),{bbox:m(this,et,Ca).call(this)}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,bo)&&(p(this,bo,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){m(this,et,Bd).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,et,Ao).call(this),m(this,et,vo).call(this,n(this,Te).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),m(this,et,Bd).call(this)):t&&(this._uiManager.addShouldRescale(this),m(this,et,Ao).call(this,t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,W._mergeSVGProperties({bbox:m(this,et,Ca).call(this)},n(this,Te).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&m(this,et,vo).call(this,n(this,Te).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const s=super.render();s.classList.add("draw");const i=document.createElement("div");s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal";const[a,o]=this.parentDimensions;return this.setDims(this.width*a,this.height*o),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),s}static createDrawerInstance(t,e,s,i,a){Y("Not implemented")}static startDrawing(t,e,s,i){const{target:a,offsetX:o,offsetY:h,pointerId:l,pointerType:d}=i;if(n(W,mi)&&n(W,mi)!==d)return;const{viewport:{rotation:c}}=t,{width:u,height:g}=a.getBoundingClientRect(),w=p(W,Ea,new AbortController),b=t.combinedSignal(w);if(n(W,fi)||p(W,fi,l),n(W,mi)??p(W,mi,d),window.addEventListener("pointerup",A=>{n(W,fi)===A.pointerId?this._endDraw(A):n(W,wi)?.delete(A.pointerId)},{signal:b}),window.addEventListener("pointercancel",A=>{n(W,fi)===A.pointerId?this._currentParent.endDrawingSession():n(W,wi)?.delete(A.pointerId)},{signal:b}),window.addEventListener("pointerdown",A=>{n(W,mi)===A.pointerType&&((n(W,wi)||p(W,wi,new Set)).add(A.pointerId),n(W,It).isCancellable()&&(n(W,It).removeLastElement(),n(W,It).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:b}),window.addEventListener("contextmenu",me,{signal:b}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:b}),a.addEventListener("touchmove",A=>{A.timeStamp===n(W,ka)&&ut(A)},{signal:b}),t.toggleDrawing(),e._editorUndoBar?.hide(),n(W,It)){t.drawLayer.updateProperties(this._currentDrawId,n(W,It).startNew(o,h,u,g,c));return}e.updateUIForDefaultProperties(this),p(W,It,this.createDrawerInstance(o,h,u,g,c)),p(W,Ma,this.getDefaultDrawingOptions()),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(n(W,Ma).toSVGProperties(),n(W,It).defaultSVGProperties),!0,!1)}static _drawMove(t){if(p(W,ka,-1),!n(W,It))return;const{offsetX:e,offsetY:s,pointerId:i}=t;if(n(W,fi)===i){if(n(W,wi)?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(W,It).add(e,s)),p(W,ka,t.timeStamp),ut(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,p(W,It,null),p(W,Ma,null),p(W,mi,null),p(W,ka,NaN)),n(W,Ea)&&(n(W,Ea).abort(),p(W,Ea,null),p(W,fi,NaN),p(W,wi,null))}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,n(W,It).end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const s=n(W,It),i=this._currentDrawId,a=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,s.setLastElement(a))},undo:()=>{e.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:j.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(j.DRAW_STEP),!n(W,It).isEmpty()){const{pageDimensions:[s,i],scale:a}=e,o=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(W,It).getOutlines(s*a,i*a,a,this._INNER_MARGIN),drawingOptions:n(W,Ma),mustBeCommitted:!t});return this._cleanup(!0),o}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,a,o){Y("Not implemented")}static async deserialize(t,e,s){var i,a;const{rawDims:{pageWidth:o,pageHeight:h,pageX:l,pageY:d}}=e.viewport,c=this.deserializeDraw(l,d,o,h,this._INNER_MARGIN,t),u=await super.deserialize(t,e,s);return u.createDrawingOptions(t),m(i=u,et,Od).call(i,{drawOutlines:c}),m(a=u,et,Ao).call(a),u.onScaleChanging(),u.rotate(),u}serializeDraw(t){const[e,s]=this.pageTranslation,[i,a]=this.pageDimensions;return n(this,Te).serialize([e,s,i,a],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Te=new WeakMap,bo=new WeakMap,It=new WeakMap,Ea=new WeakMap,Ma=new WeakMap,fi=new WeakMap,mi=new WeakMap,wi=new WeakMap,ka=new WeakMap,et=new WeakSet,Od=function({drawOutlines:r,drawId:t,drawingOptions:e}){p(this,Te,r),this._drawingOptions||(this._drawingOptions=e),t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,r.defaultProperties)):this._drawId=m(this,et,Wd).call(this,r,this.parent),m(this,et,vo).call(this,r.box)},Wd=function(r,t){const{id:e}=t.drawLayer.draw(Re._mergeSVGProperties(this._drawingOptions.toSVGProperties(),r.defaultSVGProperties),!1,!1);return e},Bd=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Ao=function(r=this.parent){if(!(this._drawId!==null&&this.parent===r)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,r.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=m(this,et,Wd).call(this,n(this,Te),r)}},Ng=function([r,t,e,s]){const{parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[t,1-r,e*(a/i),s*(i/a)];case 180:return[1-r,1-t,e,s];case 270:return[1-t,r,e*(a/i),s*(i/a)];default:return[r,t,e,s]}},jl=function(){const{x:r,y:t,width:e,height:s,parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[1-t,r,e*(i/a),s*(a/i)];case 180:return[1-r,1-t,e,s];case 270:return[t,1-r,e*(i/a),s*(a/i)];default:return[r,t,e,s]}},vo=function(r){if([this.x,this.y,this.width,this.height]=m(this,et,Ng).call(this,r),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()},Ca=function(){const{x:r,y:t,width:e,height:s,rotation:i,parentRotation:a,parentDimensions:[o,h]}=this;switch((i*4+a)/90){case 1:return[1-t-s,r,s,e];case 2:return[1-r-e,1-t-s,e,s];case 3:return[t,1-r-e,s,e];case 4:return[r,t-e*(o/h),s*(h/o),e*(o/h)];case 5:return[1-t,r,e*(o/h),s*(h/o)];case 6:return[1-r-s*(h/o),1-t,s*(h/o),e*(o/h)];case 7:return[t-e*(o/h),1-r-s*(h/o),e*(o/h),s*(h/o)];case 8:return[r-e,t-s,e,s];case 9:return[1-t,r-e,s,e];case 10:return[1-r,1-t,e,s];case 11:return[t-s,1-r,s,e];case 12:return[r-s*(h/o),t,s*(h/o),e*(o/h)];case 13:return[1-t-e*(o/h),r-s*(h/o),e*(o/h),s*(h/o)];case 14:return[1-r,1-t-e*(o/h),s*(h/o),e*(o/h)];case 15:return[t,1-r,e*(o/h),s*(h/o)];default:return[r,t,e,s]}},C(Re,"_currentDrawId",-1),C(Re,"_currentParent",null),f(Re,It,null),f(Re,Ea,null),f(Re,Ma,null),f(Re,fi,NaN),f(Re,mi,null),f(Re,wi,null),f(Re,ka,NaN),C(Re,"_INNER_MARGIN",3);let Fg=Re;var Ts,Lt,Dt,Ta,yo,ne,Nt,He,Ra,Pa,Ia,_o,Vl;class sw{constructor(t,e,s,i,a,o){f(this,_o),f(this,Ts,new Float64Array(6)),f(this,Lt),f(this,Dt),f(this,Ta),f(this,yo),f(this,ne),f(this,Nt,""),f(this,He,0),f(this,Ra,new Eo),f(this,Pa),f(this,Ia),p(this,Pa,s),p(this,Ia,i),p(this,Ta,a),p(this,yo,o),[t,e]=m(this,_o,Vl).call(this,t,e);const h=p(this,Lt,[NaN,NaN,NaN,NaN,t,e]);p(this,ne,[t,e]),p(this,Dt,[{line:h,points:n(this,ne)}]),n(this,Ts).set(h,0)}updateProperty(t,e){t==="stroke-width"&&p(this,yo,e)}isEmpty(){return!n(this,Dt)||n(this,Dt).length===0}isCancellable(){return n(this,ne).length<=10}add(t,e){[t,e]=m(this,_o,Vl).call(this,t,e);const[s,i,a,o]=n(this,Ts).subarray(2,6),h=t-a,l=e-o;return Math.hypot(n(this,Pa)*h,n(this,Ia)*l)<=2?null:(n(this,ne).push(t,e),isNaN(s)?(n(this,Ts).set([a,o,t,e],2),n(this,Lt).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,Ts)[0])&&n(this,Lt).splice(6,6),n(this,Ts).set([s,i,a,o,t,e],0),n(this,Lt).push(...P.createBezierPoints(s,i,a,o,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){return this.add(t,e)||(n(this,ne).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,a){p(this,Pa,s),p(this,Ia,i),p(this,Ta,a),[t,e]=m(this,_o,Vl).call(this,t,e);const o=p(this,Lt,[NaN,NaN,NaN,NaN,t,e]);p(this,ne,[t,e]);const h=n(this,Dt).at(-1);return h&&(h.line=new Float32Array(h.line),h.points=new Float32Array(h.points)),n(this,Dt).push({line:o,points:n(this,ne)}),n(this,Ts).set(o,0),p(this,He,0),this.toSVGPath(),null}getLastElement(){return n(this,Dt).at(-1)}setLastElement(t){return n(this,Dt)?(n(this,Dt).push(t),p(this,Lt,t.line),p(this,ne,t.points),p(this,He,0),{path:{d:this.toSVGPath()}}):n(this,Ra).setLastElement(t)}removeLastElement(){if(!n(this,Dt))return n(this,Ra).removeLastElement();n(this,Dt).pop(),p(this,Nt,"");for(let t=0,e=n(this,Dt).length;t<e;t++){const{line:s,points:i}=n(this,Dt)[t];p(this,Lt,s),p(this,ne,i),p(this,He,0),this.toSVGPath()}return{path:{d:n(this,Nt)}}}toSVGPath(){const t=P.svgRound(n(this,Lt)[4]),e=P.svgRound(n(this,Lt)[5]);if(n(this,ne).length===2)return p(this,Nt,`${n(this,Nt)} M ${t} ${e} Z`),n(this,Nt);if(n(this,ne).length<=6){const i=n(this,Nt).lastIndexOf("M");p(this,Nt,`${n(this,Nt).slice(0,i)} M ${t} ${e}`),p(this,He,6)}if(n(this,ne).length===4){const i=P.svgRound(n(this,Lt)[10]),a=P.svgRound(n(this,Lt)[11]);return p(this,Nt,`${n(this,Nt)} L ${i} ${a}`),p(this,He,12),n(this,Nt)}const s=[];n(this,He)===0&&(s.push(`M ${t} ${e}`),p(this,He,6));for(let i=n(this,He),a=n(this,Lt).length;i<a;i+=6){const[o,h,l,d,c,u]=n(this,Lt).slice(i,i+6).map(P.svgRound);s.push(`C${o} ${h} ${l} ${d} ${c} ${u}`)}return p(this,Nt,n(this,Nt)+s.join(" ")),p(this,He,n(this,Lt).length),n(this,Nt)}getOutlines(t,e,s,i){const a=n(this,Dt).at(-1);return a.line=new Float32Array(a.line),a.points=new Float32Array(a.points),n(this,Ra).build(n(this,Dt),t,e,s,n(this,Ta),n(this,yo),i),p(this,Ts,null),p(this,Lt,null),p(this,Dt,null),p(this,Nt,null),n(this,Ra)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Ts=new WeakMap,Lt=new WeakMap,Dt=new WeakMap,Ta=new WeakMap,yo=new WeakMap,ne=new WeakMap,Nt=new WeakMap,He=new WeakMap,Ra=new WeakMap,Pa=new WeakMap,Ia=new WeakMap,_o=new WeakSet,Vl=function(r,t){return P._normalizePoint(r,t,n(this,Pa),n(this,Ia),n(this,Ta))};var ae,ql,Xl,Pe,Rs,Ps,So,xo,La,pe,Is,Og,Wg,Bg;class Eo extends P{constructor(){super(...arguments),f(this,pe),f(this,ae),f(this,ql,0),f(this,Xl),f(this,Pe),f(this,Rs),f(this,Ps),f(this,So),f(this,xo),f(this,La)}build(t,e,s,i,a,o,h){p(this,Rs,e),p(this,Ps,s),p(this,So,i),p(this,xo,a),p(this,La,o),p(this,Xl,h??0),p(this,Pe,t),m(this,pe,Wg).call(this)}get thickness(){return n(this,La)}setLastElement(t){return n(this,Pe).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,Pe).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of n(this,Pe)){if(t.push(`M${P.svgRound(e[4])} ${P.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${P.svgRound(e[10])} ${P.svgRound(e[11])}`);continue}for(let s=6,i=e.length;s<i;s+=6){const[a,o,h,l,d,c]=e.subarray(s,s+6).map(P.svgRound);t.push(`C${a} ${o} ${h} ${l} ${d} ${c}`)}}return t.join("")}serialize([t,e,s,i],a){const o=[],h=[],[l,d,c,u]=m(this,pe,Og).call(this);let g,w,b,A,v,y,S,_,x;switch(n(this,xo)){case 0:x=P._rescale,g=t,w=e+i,b=s,A=-i,v=t+l*s,y=e+(1-d-u)*i,S=t+(l+c)*s,_=e+(1-d)*i;break;case 90:x=P._rescaleAndSwap,g=t,w=e,b=s,A=i,v=t+d*s,y=e+l*i,S=t+(d+u)*s,_=e+(l+c)*i;break;case 180:x=P._rescale,g=t+s,w=e,b=-s,A=i,v=t+(1-l-c)*s,y=e+d*i,S=t+(1-l)*s,_=e+(d+u)*i;break;case 270:x=P._rescaleAndSwap,g=t+s,w=e+i,b=-s,A=-i,v=t+(1-d-u)*s,y=e+(1-l-c)*i,S=t+(1-d)*s,_=e+(1-l)*i;break}for(const{line:E,points:M}of n(this,Pe))o.push(x(E,g,w,b,A,a?new Array(E.length):null)),h.push(x(M,g,w,b,A,a?new Array(M.length):null));return{lines:o,points:h,rect:[v,y,S,_]}}static deserialize(t,e,s,i,a,{paths:{lines:o,points:h},rotation:l,thickness:d}){const c=[];let u,g,w,b,A;switch(l){case 0:A=P._rescale,u=-t/s,g=e/i+1,w=1/s,b=-1/i;break;case 90:A=P._rescaleAndSwap,u=-e/i,g=-t/s,w=1/i,b=1/s;break;case 180:A=P._rescale,u=t/s+1,g=-e/i,w=-1/s,b=1/i;break;case 270:A=P._rescaleAndSwap,u=e/i+1,g=t/s+1,w=-1/i,b=-1/s;break}if(!o){o=[];for(const y of h){const S=y.length;if(S===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,y[0],y[1]]));continue}if(S===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,y[0],y[1],NaN,NaN,NaN,NaN,y[2],y[3]]));continue}const _=new Float32Array(3*(S-2));o.push(_);let[x,E,M,k]=y.subarray(0,4);_.set([NaN,NaN,NaN,NaN,x,E],0);for(let T=4;T<S;T+=2){const R=y[T],B=y[T+1];_.set(P.createBezierPoints(x,E,M,k,R,B),(T-2)*3),[x,E,M,k]=[M,k,R,B]}}}for(let y=0,S=o.length;y<S;y++)c.push({line:A(o[y].map(_=>_??NaN),u,g,w,b),points:A(h[y].map(_=>_??NaN),u,g,w,b)});const v=new this.prototype.constructor;return v.build(c,s,i,1,l,d,a),v}get box(){return n(this,ae)}updateProperty(t,e){return t==="stroke-width"?m(this,pe,Bg).call(this,e):null}updateParentDimensions([t,e],s){const[i,a]=m(this,pe,Is).call(this);p(this,Rs,t),p(this,Ps,e),p(this,So,s);const[o,h]=m(this,pe,Is).call(this),l=o-i,d=h-a,c=n(this,ae);return c[0]-=l,c[1]-=d,c[2]+=2*l,c[3]+=2*d,c}updateRotation(t){return p(this,ql,t),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,ae).map(P.svgRound).join(" ")}get defaultProperties(){const[t,e]=n(this,ae);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=n(this,ae);let s=0,i=0,a=0,o=0,h=0,l=0;switch(n(this,ql)){case 90:i=e/t,a=-t/e,h=t;break;case 180:s=-1,o=-1,h=t,l=e;break;case 270:i=-e/t,a=t/e,l=e;break;default:return""}return`matrix(${s} ${i} ${a} ${o} ${P.svgRound(h)} ${P.svgRound(l)})`}getPathResizingSVGProperties([t,e,s,i]){const[a,o]=m(this,pe,Is).call(this),[h,l,d,c]=n(this,ae);if(Math.abs(d-a)<=P.PRECISION||Math.abs(c-o)<=P.PRECISION){const A=t+s/2-(h+d/2),v=e+i/2-(l+c/2);return{path:{"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`,transform:`${this.rotationTransform} translate(${A} ${v})`}}}const u=(s-2*a)/(d-2*a),g=(i-2*o)/(c-2*o),w=d/s,b=c/i;return{path:{"transform-origin":`${P.svgRound(h)} ${P.svgRound(l)}`,transform:`${this.rotationTransform} scale(${w} ${b}) translate(${P.svgRound(a)} ${P.svgRound(o)}) scale(${u} ${g}) translate(${P.svgRound(-a)} ${P.svgRound(-o)})`}}}getPathResizedSVGProperties([t,e,s,i]){const[a,o]=m(this,pe,Is).call(this),h=n(this,ae),[l,d,c,u]=h;if(h[0]=t,h[1]=e,h[2]=s,h[3]=i,Math.abs(c-a)<=P.PRECISION||Math.abs(u-o)<=P.PRECISION){const v=t+s/2-(l+c/2),y=e+i/2-(d+u/2);for(const{line:S,points:_}of n(this,Pe))P._translate(S,v,y,S),P._translate(_,v,y,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(s-2*a)/(c-2*a),w=(i-2*o)/(u-2*o),b=-g*(l+a)+t+a,A=-w*(d+o)+e+o;if(g!==1||w!==1||b!==0||A!==0)for(const{line:v,points:y}of n(this,Pe))P._rescale(v,b,A,g,w,v),P._rescale(y,b,A,g,w,y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){const[i,a]=s,o=n(this,ae),h=t-o[0],l=e-o[1];if(n(this,Rs)===i&&n(this,Ps)===a)for(const{line:d,points:c}of n(this,Pe))P._translate(d,h,l,d),P._translate(c,h,l,c);else{const d=n(this,Rs)/i,c=n(this,Ps)/a;p(this,Rs,i),p(this,Ps,a);for(const{line:u,points:g}of n(this,Pe))P._rescale(u,h,l,d,c,u),P._rescale(g,h,l,d,c,g);o[2]*=d,o[3]*=c}return o[0]=t,o[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${P.svgRound(t)} ${P.svgRound(e)}`}}}get defaultSVGProperties(){const t=n(this,ae);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${P.svgRound(t[0])} ${P.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}ae=new WeakMap,ql=new WeakMap,Xl=new WeakMap,Pe=new WeakMap,Rs=new WeakMap,Ps=new WeakMap,So=new WeakMap,xo=new WeakMap,La=new WeakMap,pe=new WeakSet,Is=function(r=n(this,La)){const t=n(this,Xl)+r/2*n(this,So);return n(this,xo)%180===0?[t/n(this,Rs),t/n(this,Ps)]:[t/n(this,Ps),t/n(this,Rs)]},Og=function(){const[r,t,e,s]=n(this,ae),[i,a]=m(this,pe,Is).call(this,0);return[r+i,t+a,e-2*i,s-2*a]},Wg=function(){const r=p(this,ae,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:s}of n(this,Pe)){if(s.length<=12){for(let o=4,h=s.length;o<h;o+=6)L.pointBoundingBox(s[o],s[o+1],r);continue}let i=s[4],a=s[5];for(let o=6,h=s.length;o<h;o+=6){const[l,d,c,u,g,w]=s.subarray(o,o+6);L.bezierBoundingBox(i,a,l,d,c,u,g,w,r),i=g,a=w}}const[t,e]=m(this,pe,Is).call(this);r[0]=Ht(r[0]-t,0,1),r[1]=Ht(r[1]-e,0,1),r[2]=Ht(r[2]+t,0,1),r[3]=Ht(r[3]+e,0,1),r[2]-=r[0],r[3]-=r[1]},Bg=function(r){const[t,e]=m(this,pe,Is).call(this);p(this,La,r);const[s,i]=m(this,pe,Is).call(this),[a,o]=[s-t,i-e],h=n(this,ae);return h[0]-=a,h[1]-=o,h[2]+=2*a,h[3]+=2*o,h};class oc extends Dg{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:at._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new oc(this._viewParameters);return t.updateAll(this),t}}var Hd,Hg;const Kl=class rf extends Fg{constructor(t){super({...t,name:"inkEditor"}),f(this,Hd),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){at.initialize(t,e),this._defaultDrawingOptions=new oc(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return z(this,"typesMap",new Map([[j.INK_THICKNESS,"stroke-width"],[j.INK_COLOR,"stroke"],[j.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,i,a){return new sw(t,e,s,i,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,a,o){return Eo.deserialize(t,e,s,i,a,o)}static async deserialize(t,e,s){let i=null;if(t instanceof vd){const{data:{inkLists:o,rect:h,rotation:l,id:d,color:c,opacity:u,borderStyle:{rawWidth:g},popupRef:w},parent:{page:{pageNumber:b}}}=t;i=t={annotationType:$.INK,color:Array.from(c),thickness:g,opacity:u,paths:{points:o},boxes:null,pageIndex:b-1,rect:h.slice(0),rotation:l,id:d,deleted:!1,popupRef:w}}const a=await super.deserialize(t,e,s);return a.annotationElementId=t.id||null,a._initialData=i,a}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=rf.getDefaultDrawingOptions({stroke:L.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:s,rect:i}=this.serializeDraw(t),{_drawingOptions:{stroke:a,"stroke-opacity":o,"stroke-width":h}}=this,l={annotationType:$.INK,color:at._colorManager.convert(a),opacity:o,thickness:h,paths:{lines:e,points:s},pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(l.isCopy=!0,l):this.annotationElementId&&!m(this,Hd,Hg).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(t){const{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e}),null}};Hd=new WeakSet,Hg=function(r){const{color:t,thickness:e,opacity:s,pageIndex:i}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||r.color.some((a,o)=>a!==t[o])||r.thickness!==e||r.opacity!==s||r.pageIndex!==i},C(Kl,"_type","ink"),C(Kl,"_editorType",$.INK),C(Kl,"_defaultDrawingOptions",null);let iw=Kl;class $d extends Eo{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Yl=8,Mo=3;var Da,St,Gd,ns,$g,Gg,zd,Ql,zg,Ug,jg,Ud,jd,Vg;class as{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},a,o,h,l){let d=new OffscreenCanvas(1,1),c=d.getContext("2d",{alpha:!1});const u=200,g=c.font=`${s} ${i} ${u}px ${e}`,{actualBoundingBoxLeft:w,actualBoundingBoxRight:b,actualBoundingBoxAscent:A,actualBoundingBoxDescent:v,fontBoundingBoxAscent:y,fontBoundingBoxDescent:S,width:_}=c.measureText(t),x=1.5,E=Math.ceil(Math.max(Math.abs(w)+Math.abs(b)||0,_)*x),M=Math.ceil(Math.max(Math.abs(A)+Math.abs(v)||u,Math.abs(y)+Math.abs(S)||u)*x);d=new OffscreenCanvas(E,M),c=d.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=g,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,E,M),c.fillStyle="black",c.fillText(t,E*(x-1)/2,M*(3-x)/2);const k=m(this,St,Ud).call(this,c.getImageData(0,0,E,M).data),T=m(this,St,jg).call(this,k),R=m(this,St,jd).call(this,T),B=m(this,St,zd).call(this,k,E,M,R);return this.processDrawnLines({lines:{curves:B,width:E,height:M},pageWidth:a,pageHeight:o,rotation:h,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,a){const[o,h,l]=m(this,St,Vg).call(this,t),[d,c]=m(this,St,Ug).call(this,o,h,l,Math.hypot(h,l)*n(this,Da).sigmaSFactor,n(this,Da).sigmaR,n(this,Da).kernelSize),u=m(this,St,jd).call(this,c),g=m(this,St,zd).call(this,d,h,l,u);return this.processDrawnLines({lines:{curves:g,width:h,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:a,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:a,mustSmooth:o,areContours:h}){i%180!==0&&([e,s]=[s,e]);const{curves:l,width:d,height:c}=t,u=t.thickness??0,g=[],w=Math.min(e/d,s/c),b=w/e,A=w/s,v=[];for(const{points:S}of l){const _=o?m(this,St,zg).call(this,S):S;if(!_)continue;v.push(_);const x=_.length,E=new Float32Array(x),M=new Float32Array(3*(x===2?2:x-2));if(g.push({line:M,points:E}),x===2){E[0]=_[0]*b,E[1]=_[1]*A,M.set([NaN,NaN,NaN,NaN,E[0],E[1]],0);continue}let[k,T,R,B]=_;k*=b,T*=A,R*=b,B*=A,E.set([k,T,R,B],0),M.set([NaN,NaN,NaN,NaN,k,T],0);for(let H=4;H<x;H+=2){const q=E[H]=_[H]*b,Z=E[H+1]=_[H+1]*A;M.set(P.createBezierPoints(k,T,R,B,q,Z),(H-2)*3),[k,T,R,B]=[R,B,q,Z]}}if(g.length===0)return null;const y=h?new $d:new Eo;return y.build(g,e,s,1,i,h?0:u,a),{outline:y,newCurves:v,areContours:h,thickness:u,width:d,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:a}){let o=1/0,h=-1/0,l=0;for(const _ of t){l+=_.length;for(let x=2,E=_.length;x<E;x++){const M=_[x]-_[x-2];o=Math.min(o,M),h=Math.max(h,M)}}let d;o>=-128&&h<=127?d=Int8Array:o>=-32768&&h<=32767?d=Int16Array:d=Int32Array;const c=t.length,u=Yl+Mo*c,g=new Uint32Array(u);let w=0;g[w++]=u*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*d.BYTES_PER_ELEMENT,g[w++]=0,g[w++]=i,g[w++]=a,g[w++]=e?0:1,g[w++]=Math.max(0,Math.floor(s??0)),g[w++]=c,g[w++]=d.BYTES_PER_ELEMENT;for(const _ of t)g[w++]=_.length-2,g[w++]=_[0],g[w++]=_[1];const b=new CompressionStream("deflate-raw"),A=b.writable.getWriter();await A.ready,A.write(g);const v=d.prototype.constructor;for(const _ of t){const x=new v(_.length-2);for(let E=2,M=_.length;E<M;E++)x[E-2]=_[E]-_[E-2];A.write(x)}A.close();const y=await new Response(b.readable).arrayBuffer(),S=new Uint8Array(y);return du(S)}static async decompressSignature(t){try{const e=_f(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),a=i.getWriter();await a.ready,a.write(e).then(async()=>{await a.ready,await a.close()}).catch(()=>{});let o=null,h=0;for await(const _ of s)o||(o=new Uint8Array(new Uint32Array(_.buffer,0,4)[0])),o.set(_,h),h+=_.length;const l=new Uint32Array(o.buffer,0,o.length>>2),d=l[1];if(d!==0)throw new Error(`Invalid version: ${d}`);const c=l[2],u=l[3],g=l[4]===0,w=l[5],b=l[6],A=l[7],v=[],y=(Yl+Mo*b)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(A){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(o.buffer,y);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(o.buffer,y);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(o.buffer,y);break}h=0;for(let _=0;_<b;_++){const x=l[Mo*_+Yl],E=new Float32Array(x+2);v.push(E);for(let M=0;M<Mo-1;M++)E[M]=l[Mo*_+Yl+M+1];for(let M=0;M<x;M++)E[M+2]=E[M]+S[h++]}return{areContours:g,thickness:w,outlines:v,width:c,height:u}}catch(e){return G(`decompressSignature: ${e}`),null}}}Da=new WeakMap,St=new WeakSet,Gd=function(r,t,e,s){return e-=r,s-=t,e===0?s>0?0:4:e===1?s+6:2-s},ns=new WeakMap,$g=function(r,t,e,s,i,a,o){const h=m(this,St,Gd).call(this,e,s,i,a);for(let l=0;l<8;l++){const d=(-l+h-o+16)%8,c=n(this,ns)[2*d],u=n(this,ns)[2*d+1];if(r[(e+c)*t+(s+u)]!==0)return d}return-1},Gg=function(r,t,e,s,i,a,o){const h=m(this,St,Gd).call(this,e,s,i,a);for(let l=0;l<8;l++){const d=(l+h+o+16)%8,c=n(this,ns)[2*d],u=n(this,ns)[2*d+1];if(r[(e+c)*t+(s+u)]!==0)return d}return-1},zd=function(r,t,e,s){const i=r.length,a=new Int32Array(i);for(let d=0;d<i;d++)a[d]=r[d]<=s?1:0;for(let d=1;d<e-1;d++)a[d*t]=a[d*t+t-1]=0;for(let d=0;d<t;d++)a[d]=a[t*e-1-d]=0;let o=1,h;const l=[];for(let d=1;d<e-1;d++){h=1;for(let c=1;c<t-1;c++){const u=d*t+c,g=a[u];if(g===0)continue;let w=d,b=c;if(g===1&&a[u-1]===0)o+=1,b-=1;else if(g>=1&&a[u+1]===0)o+=1,b+=1,g>1&&(h=g);else{g!==1&&(h=Math.abs(g));continue}const A=[c,d],v=b===c+1,y={isHole:v,points:A,id:o,parent:0};l.push(y);let S;for(const B of l)if(B.id===h){S=B;break}S?S.isHole?y.parent=v?S.parent:h:y.parent=v?h:S.parent:y.parent=v?h:0;const _=m(this,St,$g).call(this,a,t,d,c,w,b,0);if(_===-1){a[u]=-o,a[u]!==1&&(h=Math.abs(a[u]));continue}let x=n(this,ns)[2*_],E=n(this,ns)[2*_+1];const M=d+x,k=c+E;w=M,b=k;let T=d,R=c;for(;;){const B=m(this,St,Gg).call(this,a,t,T,R,w,b,1);x=n(this,ns)[2*B],E=n(this,ns)[2*B+1];const H=T+x,q=R+E;A.push(q,H);const Z=T*t+R;if(a[Z+1]===0?a[Z]=-o:a[Z]===1&&(a[Z]=o),H===d&&q===c&&T===M&&R===k){a[u]!==1&&(h=Math.abs(a[u]));break}else w=T,b=R,T=H,R=q}}}return l},Ql=function(r,t,e,s){if(e-t<=4){for(let M=t;M<e-2;M+=2)s.push(r[M],r[M+1]);return}const i=r[t],a=r[t+1],o=r[e-4]-i,h=r[e-3]-a,l=Math.hypot(o,h),d=o/l,c=h/l,u=d*a-c*i,g=h/o,w=1/l,b=Math.atan(g),A=Math.cos(b),v=Math.sin(b),y=w*(Math.abs(A)+Math.abs(v)),S=w*(1-y+y**2),_=Math.max(Math.atan(Math.abs(v+A)*S),Math.atan(Math.abs(v-A)*S));let x=0,E=t;for(let M=t+2;M<e-2;M+=2){const k=Math.abs(u-d*r[M+1]+c*r[M]);k>x&&(E=M,x=k)}x>(l*_)**2?(m(this,St,Ql).call(this,r,t,E+2,s),m(this,St,Ql).call(this,r,E,e,s)):s.push(i,a)},zg=function(r){const t=[],e=r.length;return m(this,St,Ql).call(this,r,0,e,t),t.push(r[e-2],r[e-1]),t.length<=4?null:t},Ug=function(r,t,e,s,i,a){const o=new Float32Array(a**2),h=-2*s**2,l=a>>1;for(let b=0;b<a;b++){const A=(b-l)**2;for(let v=0;v<a;v++)o[b*a+v]=Math.exp((A+(v-l)**2)/h)}const d=new Float32Array(256),c=-2*i**2;for(let b=0;b<256;b++)d[b]=Math.exp(b**2/c);const u=r.length,g=new Uint8Array(u),w=new Uint32Array(256);for(let b=0;b<e;b++)for(let A=0;A<t;A++){const v=b*t+A,y=r[v];let S=0,_=0;for(let E=0;E<a;E++){const M=b+E-l;if(!(M<0||M>=e))for(let k=0;k<a;k++){const T=A+k-l;if(T<0||T>=t)continue;const R=r[M*t+T],B=o[E*a+k]*d[Math.abs(R-y)];S+=R*B,_+=B}}const x=g[v]=Math.round(S/_);w[x]++}return[g,w]},jg=function(r){const t=new Uint32Array(256);for(const e of r)t[e]++;return t},Ud=function(r){const t=r.length,e=new Uint8ClampedArray(t>>2);let s=-1/0,i=1/0;for(let o=0,h=e.length;o<h;o++){if(r[(o<<2)+3]===0){s=e[o]=255;continue}const l=e[o]=r[o<<2];l>s&&(s=l),l<i&&(i=l)}const a=255/(s-i);for(let o=0;o<t;o++)e[o]=(e[o]-i)*a;return e},jd=function(r){let t,e=-1/0,s=-1/0;const i=r.findIndex(h=>h!==0);let a=i,o=i;for(t=i;t<256;t++){const h=r[t];h>e&&(t-a>s&&(s=t-a,o=t-1),e=h,a=t)}for(t=o-1;t>=0&&!(r[t]>r[t+1]);t--);return t},Vg=function(r){const t=r,{width:e,height:s}=r,{maxDim:i}=n(this,Da);let a=e,o=s;if(e>i||s>i){let d=e,c=s,u=Math.log2(Math.max(e,s)/i);const g=Math.floor(u);u=u===g?g-1:g;for(let b=0;b<u;b++){a=Math.ceil(d/2),o=Math.ceil(c/2);const A=new OffscreenCanvas(a,o);A.getContext("2d").drawImage(r,0,0,d,c,0,0,a,o),d=a,c=o,r!==t&&r.close(),r=A.transferToImageBitmap()}const w=Math.min(i/a,i/o);a=Math.round(a*w),o=Math.round(o*w)}const h=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});h.filter="grayscale(1)",h.drawImage(r,0,0,r.width,r.height,0,0,a,o);const l=h.getImageData(0,0,a,o).data;return[m(this,St,Ud).call(this,l),a,o]},f(as,St),f(as,Da,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),f(as,ns,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class eu extends Dg{constructor(){super(),super.updateProperties({fill:at._defaultLineColor,"stroke-width":0})}clone(){const t=new eu;return t.updateAll(this),t}}class su extends oc{constructor(t){super(t),super.updateProperties({stroke:at._defaultLineColor,"stroke-width":1})}clone(){const t=new su(this._viewParameters);return t.updateAll(this),t}}var un,Ie,pn,gn;const Jl=class Fs extends Fg{constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),f(this,un,!1),f(this,Ie,null),f(this,pn,null),f(this,gn,null),this._willKeepAspectRatio=!0,p(this,pn,t.signatureData||null),p(this,Ie,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){at.initialize(t,e),this._defaultDrawingOptions=new eu,this._defaultDrawnSignatureOptions=new su(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return z(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,Ie)}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(n(this,pn)){const{lines:i,mustSmooth:a,areContours:o,description:h,uuid:l,heightInPage:d}=n(this,pn),{rawDims:{pageWidth:c,pageHeight:u},rotation:g}=this.parent.viewport,w=as.processDrawnLines({lines:i,pageWidth:c,pageHeight:u,rotation:g,innerMargin:Fs._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(w,d,h,l)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);return s&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){p(this,gn,t),this.addEditToolbar()}getUuid(){return n(this,gn)}get description(){return n(this,Ie)}set description(t){p(this,Ie,t),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)})}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:s,width:i,height:a}=n(this,pn),o=Math.max(i,a),h=as.processDrawnLines({lines:{curves:t.map(l=>({points:l})),thickness:s,width:i,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:h.outline}}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.signatureManager&&n(this,Ie)!==null&&(await t.addEditSignatureButton(this._uiManager.signatureManager,n(this,gn),n(this,Ie)),t.show()),t):null}addSignature(t,e,s,i){const{x:a,y:o}=this,{outline:h}=p(this,pn,t);p(this,un,h instanceof $d),p(this,Ie,s),this.div.setAttribute("data-l10n-args",JSON.stringify({description:s}));let l;n(this,un)?l=Fs.getDefaultDrawingOptions():(l=Fs._defaultDrawnSignatureOptions.clone(),l.updateProperties({"stroke-width":h.thickness})),this._addOutlines({drawOutlines:h,drawingOptions:l});const[d,c]=this.parentDimensions,[,u]=this.pageDimensions;let g=e/u;g=g>=1?.5:g,this.width*=g/this.height,this.width>=1&&(g*=.9/this.width,this.width=.9),this.height=g,this.setDims(d*this.width,c*this.height),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return as.process(t,e,s,i,Fs._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:a}=this.parent.viewport;return as.extractContoursFromText(t,e,s,i,a,Fs._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return as.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:Fs._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Fs.getDefaultDrawingOptions():(this._drawingOptions=Fs._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:s,rect:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":a}}=this,o={annotationType:$.SIGNATURE,isSignature:!0,areContours:n(this,un),color:[0,0,0],thickness:n(this,un)?0:a,pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(o.paths={lines:e,points:s},o.uuid=n(this,gn),o.isCopy=!0):o.lines=e,n(this,Ie)&&(o.accessibilityData={type:"Figure",alt:n(this,Ie)}),o}static deserializeDraw(t,e,s,i,a,o){return o.areContours?$d.deserialize(t,e,s,i,a,o):Eo.deserialize(t,e,s,i,a,o)}static async deserialize(t,e,s){const i=await super.deserialize(t,e,s);return p(i,un,t.areContours),p(i,Ie,t.accessibilityData?.alt||""),p(i,gn,t.uuid),i}};un=new WeakMap,Ie=new WeakMap,pn=new WeakMap,gn=new WeakMap,C(Jl,"_type","signature"),C(Jl,"_editorType",$.SIGNATURE),C(Jl,"_defaultDrawingOptions",null);let nw=Jl;var ot,Ft,fn,bi,mn,ko,Ai,Na,Ls,Le,Co,st,To,Ro,Zl,tc,ec,Vd,sc,qg;class qd extends at{constructor(t){super({...t,name:"stampEditor"}),f(this,st),f(this,ot,null),f(this,Ft,null),f(this,fn,null),f(this,bi,null),f(this,mn,null),f(this,ko,""),f(this,Ai,null),f(this,Na,!1),f(this,Ls,null),f(this,Le,!1),f(this,Co,!1),p(this,bi,t.bitmapUrl),p(this,mn,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){at.initialize(t,e)}static isHandlingMimeForPasting(t){return Vo.includes(t)}static paste(t,e){e.pasteEditor({mode:$.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:a,height:o}=t||this.copyCanvas(null,null,!0).imageData,h=await s.guess({name:"altText",request:{data:i,width:a,height:o,channels:i.length/(a*o)}});if(!h)throw new Error("No response from the AI service.");if(h.error)throw new Error("Error from the AI service.");if(h.cancel)return null;if(!h.output)throw new Error("No valid response from the AI service.");const l=h.output;return await this.setGuessedAltText(l),e&&!this.hasAltTextData()&&(this.altTextData={alt:l,decorative:!1}),l}remove(){n(this,Ft)&&(p(this,ot,null),this._uiManager.imageManager.deleteId(n(this,Ft)),n(this,Ai)?.remove(),p(this,Ai,null),n(this,Ls)&&(clearTimeout(n(this,Ls)),p(this,Ls,null))),super.remove()}rebuild(){if(!this.parent){n(this,Ft)&&m(this,st,Zl).call(this);return}super.rebuild(),this.div!==null&&(n(this,Ft)&&n(this,Ai)===null&&m(this,st,Zl).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(n(this,fn)||n(this,ot)||n(this,bi)||n(this,mn)||n(this,Ft)||n(this,Na))}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),n(this,Na)||(n(this,ot)?m(this,st,tc).call(this):m(this,st,Zl).call(this)),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(p(this,Ft,s),i&&p(this,ot,i),p(this,Na,!1),m(this,st,tc).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(n(this,Ls)!==null&&clearTimeout(n(this,Ls)),p(this,Ls,setTimeout(()=>{p(this,Ls,null),m(this,st,Vd).call(this)},200)))}copyCanvas(t,e,s=!1){t||(t=224);const{width:i,height:a}=n(this,ot),o=new Ge;let h=n(this,ot),l=i,d=a,c=null;if(e){if(i>e||a>e){const M=Math.min(e/i,e/a);l=Math.floor(i*M),d=Math.floor(a*M)}c=document.createElement("canvas");const g=c.width=Math.ceil(l*o.sx),w=c.height=Math.ceil(d*o.sy);n(this,Le)||(h=m(this,st,ec).call(this,g,w));const b=c.getContext("2d");b.filter=this._uiManager.hcmFilter;let A="white",v="#cfcfd8";this._uiManager.hcmFilter!=="none"?v="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(A="#8f8f9d",v="#42414d");const y=15,S=y*o.sx,_=y*o.sy,x=new OffscreenCanvas(S*2,_*2),E=x.getContext("2d");E.fillStyle=A,E.fillRect(0,0,S*2,_*2),E.fillStyle=v,E.fillRect(0,0,S,_),E.fillRect(S,_,S,_),b.fillStyle=b.createPattern(x,"repeat"),b.fillRect(0,0,g,w),b.drawImage(h,0,0,h.width,h.height,0,0,g,w)}let u=null;if(s){let g,w;if(o.symmetric&&h.width<t&&h.height<t)g=h.width,w=h.height;else if(h=n(this,ot),i>t||a>t){const A=Math.min(t/i,t/a);g=Math.floor(i*A),w=Math.floor(a*A),n(this,Le)||(h=m(this,st,ec).call(this,g,w))}const b=new OffscreenCanvas(g,w).getContext("2d",{willReadFrequently:!0});b.drawImage(h,0,0,h.width,h.height,0,0,g,w),u={width:g,height:w,data:b.getImageData(0,0,g,w).data}}return{canvas:c,width:l,height:d,imageData:u}}static async deserialize(t,e,s){let i=null,a=!1;if(t instanceof ng){const{data:{rect:A,rotation:v,id:y,structParent:S,popupRef:_},container:x,parent:{page:{pageNumber:E}},canvas:M}=t;let k,T;M?(delete t.canvas,{id:k,bitmap:T}=s.imageManager.getFromCanvas(x.id,M),M.remove()):(a=!0,t._hasNoCanvas=!0);const R=(await e._structTree.getAriaAttributes(`${vc}${y}`))?.get("aria-label")||"";i=t={annotationType:$.STAMP,bitmapId:k,bitmap:T,pageIndex:E-1,rect:A.slice(0),rotation:v,id:y,deleted:!1,accessibilityData:{decorative:!1,altText:R},isSvg:!1,structParent:S,popupRef:_}}const o=await super.deserialize(t,e,s),{rect:h,bitmap:l,bitmapUrl:d,bitmapId:c,isSvg:u,accessibilityData:g}=t;a?(s.addMissingCanvas(t.id,o),p(o,Na,!0)):c&&s.imageManager.isValidId(c)?(p(o,Ft,c),l&&p(o,ot,l)):p(o,bi,d),p(o,Le,u);const[w,b]=o.pageDimensions;return o.width=(h[2]-h[0])/w,o.height=(h[3]-h[1])/b,o.annotationElementId=t.id||null,g&&(o.altTextData=g),o._initialData=i,p(o,Co,!!i),o}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s={annotationType:$.STAMP,bitmapId:n(this,Ft),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:n(this,Le),structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=m(this,st,sc).call(this,!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;const{decorative:i,altText:a}=this.serializeAltText(!1);if(!i&&a&&(s.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const h=m(this,st,qg).call(this,s);if(h.isSame)return null;h.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1}if(s.id=this.annotationElementId,e===null)return s;e.stamps||(e.stamps=new Map);const o=n(this,Le)?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(n(this,Ft)))e.stamps.set(n(this,Ft),{area:o,serialized:s}),s.bitmap=m(this,st,sc).call(this,!1);else if(n(this,Le)){const h=e.stamps.get(n(this,Ft));o>h.area&&(h.area=o,h.serialized.bitmap.close(),h.serialized.bitmap=m(this,st,sc).call(this,!1))}return s}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}ot=new WeakMap,Ft=new WeakMap,fn=new WeakMap,bi=new WeakMap,mn=new WeakMap,ko=new WeakMap,Ai=new WeakMap,Na=new WeakMap,Ls=new WeakMap,Le=new WeakMap,Co=new WeakMap,st=new WeakSet,To=function(r,t=!1){if(!r){this.remove();return}p(this,ot,r.bitmap),t||(p(this,Ft,r.id),p(this,Le,r.isSvg)),r.file&&p(this,ko,r.file.name),m(this,st,tc).call(this)},Ro=function(){if(p(this,fn,null),this._uiManager.enableWaiting(!1),!!n(this,Ai)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,ot)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,ot)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Zl=function(){if(n(this,Ft)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,Ft)).then(e=>m(this,st,To).call(this,e,!0)).finally(()=>m(this,st,Ro).call(this));return}if(n(this,bi)){const e=n(this,bi);p(this,bi,null),this._uiManager.enableWaiting(!0),p(this,fn,this._uiManager.imageManager.getFromUrl(e).then(s=>m(this,st,To).call(this,s)).finally(()=>m(this,st,Ro).call(this)));return}if(n(this,mn)){const e=n(this,mn);p(this,mn,null),this._uiManager.enableWaiting(!0),p(this,fn,this._uiManager.imageManager.getFromFile(e).then(s=>m(this,st,To).call(this,s)).finally(()=>m(this,st,Ro).call(this)));return}const r=document.createElement("input");r.type="file",r.accept=Vo.join(",");const t=this._uiManager._signal;p(this,fn,new Promise(e=>{r.addEventListener("change",async()=>{if(!r.files||r.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const s=await this._uiManager.imageManager.getFromFile(r.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),m(this,st,To).call(this,s)}e()},{signal:t}),r.addEventListener("cancel",()=>{this.remove(),e()},{signal:t})}).finally(()=>m(this,st,Ro).call(this))),r.click()},tc=function(){const{div:r}=this;let{width:t,height:e}=n(this,ot);const[s,i]=this.pageDimensions,a=.75;if(this.width)t=this.width*s,e=this.height*i;else if(t>a*s||e>a*i){const d=Math.min(a*s/t,a*i/e);t*=d,e*=d}const[o,h]=this.parentDimensions;this.setDims(t*o/s,e*h/i),this._uiManager.enableWaiting(!1);const l=p(this,Ai,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=t/s,this.height=e/i,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(r.hidden=!1),m(this,st,Vd).call(this),n(this,Co)||(this.parent.addUndoableEditor(this),p(this,Co,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,ko)&&this.div.setAttribute("aria-description",n(this,ko))},ec=function(r,t){const{width:e,height:s}=n(this,ot);let i=e,a=s,o=n(this,ot);for(;i>2*r||a>2*t;){const h=i,l=a;i>2*r&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2)),a>2*t&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const d=new OffscreenCanvas(i,a);d.getContext("2d").drawImage(o,0,0,h,l,0,0,i,a),o=d.transferToImageBitmap()}return o},Vd=function(){const[r,t]=this.parentDimensions,{width:e,height:s}=this,i=new Ge,a=Math.ceil(e*r*i.sx),o=Math.ceil(s*t*i.sy),h=n(this,Ai);if(!h||h.width===a&&h.height===o)return;h.width=a,h.height=o;const l=n(this,Le)?n(this,ot):m(this,st,ec).call(this,a,o),d=h.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(l,0,0,l.width,l.height,0,0,a,o)},sc=function(r){if(r){if(n(this,Le)){const e=this._uiManager.imageManager.getSvgUrl(n(this,Ft));if(e)return e}const t=document.createElement("canvas");return{width:t.width,height:t.height}=n(this,ot),t.getContext("2d").drawImage(n(this,ot),0,0),t.toDataURL()}if(n(this,Le)){const[t,e]=this.pageDimensions,s=Math.round(this.width*t*Ci.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*Ci.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(s,i);return a.getContext("2d").drawImage(n(this,ot),0,0,n(this,ot).width,n(this,ot).height,0,0,s,i),a.transferToImageBitmap()}return structuredClone(n(this,ot))},qg=function(r){const{pageIndex:t,accessibilityData:{altText:e}}=this._initialData,s=r.pageIndex===t,i=(r.accessibilityData?.alt||"")===e;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&i,isSameAltText:i}},C(qd,"_type","stamp"),C(qd,"_editorType",$.STAMP);var Fa,Po,Ds,wn,vi,$e,bn,Io,Oa,rs,yi,Jt,_i,D,An,xt,Xg,os,Xd,Kd,ic;const nc=class yn{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:a,annotationLayer:o,drawLayer:h,textLayer:l,viewport:d,l10n:c}){f(this,xt),f(this,Fa),f(this,Po,!1),f(this,Ds,null),f(this,wn,null),f(this,vi,null),f(this,$e,new Map),f(this,bn,!1),f(this,Io,!1),f(this,Oa,!1),f(this,rs,null),f(this,yi,null),f(this,Jt,null),f(this,_i,null),f(this,D);const u=[...n(yn,An).values()];if(!yn._initialized){yn._initialized=!0;for(const g of u)g.initialize(c,t)}t.registerEditorTypes(u),p(this,D,t),this.pageIndex=e,this.div=s,p(this,Fa,a),p(this,Ds,o),this.viewport=d,p(this,Jt,l),this.drawLayer=h,this._structTree=i,n(this,D).addLayer(this)}get isEmpty(){return n(this,$e).size===0}get isInvisible(){return this.isEmpty&&n(this,D).getMode()===$.NONE}updateToolbar(t){n(this,D).updateToolbar(t)}updateMode(t=n(this,D).getMode()){switch(m(this,xt,ic).call(this),t){case $.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case $.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case $.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 n(yn,An).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===n(this,Jt)?.div}setEditingState(t){n(this,D).setEditingState(t)}addCommands(t){n(this,D).addCommands(t)}cleanUndoStack(t){n(this,D).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){n(this,Ds)?.div.classList.toggle("disabled",!t)}async enable(){p(this,Oa,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of n(this,$e).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(n(this,D).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!n(this,Ds)){p(this,Oa,!1);return}const e=n(this,Ds).getEditableAnnotations();for(const s of e){if(s.hide(),n(this,D).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}p(this,Oa,!1)}disable(){p(this,Io,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of n(this,$e).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(n(this,Ds)){const i=n(this,Ds).getEditableAnnotations();for(const a of i){const{id:o}=a.data;if(n(this,D).isDeletedAnnotationElement(o))continue;let h=e.get(o);if(h){h.resetAnnotationElement(a),h.show(!1),a.show();continue}h=t.get(o),h&&(n(this,D).addChangedExistingAnnotation(h),h.renderAnnotationElement(a)&&h.show(!1)),a.show()}}m(this,xt,ic).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const i of n(yn,An).values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,Io,!1)}getEditableAnnotation(t){return n(this,Ds)?.getEditableAnnotation(t)||null}setActiveEditor(t){n(this,D).getActive()!==t&&n(this,D).setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,n(this,Jt)?.div&&!n(this,_i)){p(this,_i,new AbortController);const t=n(this,D).combinedSignal(n(this,_i));n(this,Jt).div.addEventListener("pointerdown",m(this,xt,Xg).bind(this),{signal:t}),n(this,Jt).div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,n(this,Jt)?.div&&n(this,_i)&&(n(this,_i).abort(),p(this,_i,null),n(this,Jt).div.classList.remove("highlighting"))}enableClick(){if(n(this,wn))return;p(this,wn,new AbortController);const t=n(this,D).combinedSignal(n(this,wn));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){n(this,wn)?.abort(),p(this,wn,null)}attach(t){n(this,$e).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,D).isDeletedAnnotationElement(e)&&n(this,D).removeDeletedAnnotationElement(t)}detach(t){n(this,$e).delete(t.id),n(this,Fa)?.removePointerInTextLayer(t.contentDiv),!n(this,Io)&&t.annotationElementId&&n(this,D).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,D).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,D).addDeletedAnnotationElement(t.annotationElementId),at.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),n(this,D).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,Oa)),n(this,D).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,vi)&&(t._focusEventsAllowed=!1,p(this,vi,setTimeout(()=>{p(this,vi,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,D)._signal}),e.focus())},0))),t._structTreeParentId=n(this,Fa)?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return n(this,D).getId()}combinedSignal(t){return n(this,D).combinedSignal(t)}canCreateNewEmptyEditor(){return n(this,xt,os)?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,D).updateMode(t.mode);const{offsetX:s,offsetY:i}=m(this,xt,Kd).call(this),a=this.getNextId(),o=m(this,xt,Xd).call(this,{parent:this,id:a,x:s,y:i,uiManager:n(this,D),isCentered:!0,...e});o&&this.add(o)}async deserialize(t){return await n(yn,An).get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,n(this,D))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),a=m(this,xt,Xd).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,D),isCentered:e,...s});return a&&this.add(a),a}addNewEditor(t={}){this.createAndAddNewEditor(m(this,xt,Kd).call(this),!0,t)}setSelected(t){n(this,D).setSelected(t)}toggleSelected(t){n(this,D).toggleSelected(t)}unselect(t){n(this,D).unselect(t)}pointerup(t){const{isMac:e}=Mt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,bn)||(p(this,bn,!1),n(this,xt,os)?.isDrawer&&n(this,xt,os).supportMultipleDrawings))return;if(!n(this,Po)){p(this,Po,!0);return}const s=n(this,D).getMode();if(s===$.STAMP||s===$.SIGNATURE){n(this,D).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(n(this,D).getMode()===$.HIGHLIGHT&&this.enableTextSelection(),n(this,bn)){p(this,bn,!1);return}const{isMac:e}=Mt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,bn,!0),n(this,xt,os)?.isDrawer){this.startDrawingSession(t);return}const s=n(this,D).getActive();p(this,Po,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,rs)){n(this,xt,os).startDrawing(this,n(this,D),!1,t);return}n(this,D).setCurrentDrawingSession(this),p(this,rs,new AbortController);const e=n(this,D).combinedSignal(n(this,rs));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(p(this,yi,null),this.commitOrRemove())},{signal:e}),n(this,xt,os).startDrawing(this,n(this,D),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,yi,e);return}n(this,yi)&&setTimeout(()=>{n(this,yi)?.focus(),p(this,yi,null)},0)}endDrawingSession(t=!1){return n(this,rs)?(n(this,D).setCurrentDrawingSession(null),n(this,rs).abort(),p(this,rs,null),p(this,yi,null),n(this,xt,os).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,D).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,rs)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,rs)&&n(this,xt,os).onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),n(this,D).getActive()?.parent===this&&(n(this,D).commitOrRemove(),n(this,D).setActiveEditor(null)),n(this,vi)&&(clearTimeout(n(this,vi)),p(this,vi,null));for(const t of n(this,$e).values())n(this,Fa)?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,n(this,$e).clear(),n(this,D).removeLayer(this)}render({viewport:t}){this.viewport=t,Bs(this.div,t);for(const e of n(this,D).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){n(this,D).commitOrRemove(),m(this,xt,ic).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Bs(this.div,{rotation:s}),e!==s)for(const i of n(this,$e).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,D).viewParameters.realScale}};Fa=new WeakMap,Po=new WeakMap,Ds=new WeakMap,wn=new WeakMap,vi=new WeakMap,$e=new WeakMap,bn=new WeakMap,Io=new WeakMap,Oa=new WeakMap,rs=new WeakMap,yi=new WeakMap,Jt=new WeakMap,_i=new WeakMap,D=new WeakMap,An=new WeakMap,xt=new WeakSet,Xg=function(r){n(this,D).unselectAll();const{target:t}=r;if(t===n(this,Jt).div||(t.getAttribute("role")==="img"||t.classList.contains("endOfContent"))&&n(this,Jt).div.contains(t)){const{isMac:e}=Mt.platform;if(r.button!==0||r.ctrlKey&&e)return;n(this,D).showAllEditors("highlight",!0,!0),n(this,Jt).div.classList.add("free"),this.toggleDrawing(),Lg.startHighlighting(this,n(this,D).direction==="ltr",{target:n(this,Jt).div,x:r.x,y:r.y}),n(this,Jt).div.addEventListener("pointerup",()=>{n(this,Jt).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,D)._signal}),r.preventDefault()}},os=function(){return n(nc,An).get(n(this,D).getMode())},Xd=function(r){const t=n(this,xt,os);return t?new t.prototype.constructor(r):null},Kd=function(){const{x:r,y:t,width:e,height:s}=this.div.getBoundingClientRect(),i=Math.max(0,r),a=Math.max(0,t),o=Math.min(window.innerWidth,r+e),h=Math.min(window.innerHeight,t+s),l=(i+o)/2-r,d=(a+h)/2-t,[c,u]=this.viewport.rotation%180===0?[l,d]:[d,l];return{offsetX:c,offsetY:u}},ic=function(){for(const r of n(this,$e).values())r.isEmpty()&&r.remove()},C(nc,"_initialized",!1),f(nc,An,new Map([Zm,iw,qd,Lg,nw].map(r=>[r._editorType,r])));let Kg=nc;var hs,re,Wa,ac,Yd,Yg,vn,Qd,Qg,Jd;const Ba=class ge{constructor({pageIndex:t}){f(this,vn),f(this,hs,null),f(this,re,new Map),f(this,Wa,new Map),this.pageIndex=t}setParent(t){if(!n(this,hs)){p(this,hs,t);return}if(n(this,hs)!==t){if(n(this,re).size>0)for(const e of n(this,re).values())e.remove(),t.append(e);p(this,hs,t)}}static get _svgFactory(){return z(this,"_svgFactory",new Vr)}draw(t,e=!1,s=!1){const i=Zt(ge,ac)._++,a=m(this,vn,Qd).call(this),o=ge._svgFactory.createElement("defs");a.append(o);const h=ge._svgFactory.createElement("path");o.append(h);const l=`path_p${this.pageIndex}_${i}`;h.setAttribute("id",l),h.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,Wa).set(i,h);const d=s?m(this,vn,Qg).call(this,o,l):null,c=ge._svgFactory.createElement("use");return a.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(a,t),n(this,re).set(i,a),{id:i,clipPathId:`url(#${d})`}}drawOutline(t,e){const s=Zt(ge,ac)._++,i=m(this,vn,Qd).call(this),a=ge._svgFactory.createElement("defs");i.append(a);const o=ge._svgFactory.createElement("path");a.append(o);const h=`path_p${this.pageIndex}_${s}`;o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const u=ge._svgFactory.createElement("mask");a.append(u),l=`mask_p${this.pageIndex}_${s}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");const g=ge._svgFactory.createElement("rect");u.append(g),g.setAttribute("width","1"),g.setAttribute("height","1"),g.setAttribute("fill","white");const w=ge._svgFactory.createElement("use");u.append(w),w.setAttribute("href",`#${h}`),w.setAttribute("stroke","none"),w.setAttribute("fill","black"),w.setAttribute("fill-rule","nonzero"),w.classList.add("mask")}const d=ge._svgFactory.createElement("use");i.append(d),d.setAttribute("href",`#${h}`),l&&d.setAttribute("mask",`url(#${l})`);const c=d.cloneNode();return i.append(c),d.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,re).set(s,i),s}finalizeDraw(t,e){n(this,Wa).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var s;if(!e)return;const{root:i,bbox:a,rootClass:o,path:h}=e,l=typeof t=="number"?n(this,re).get(t):t;if(l){if(i&&m(this,vn,Jd).call(this,l,i),a&&m(s=ge,Yd,Yg).call(s,l,a),o){const{classList:d}=l;for(const[c,u]of Object.entries(o))d.toggle(c,u)}if(h){const d=l.firstChild.firstChild;m(this,vn,Jd).call(this,d,h)}}}updateParent(t,e){if(e===this)return;const s=n(this,re).get(t);s&&(n(e,hs).append(s),n(this,re).delete(t),n(e,re).set(t,s))}remove(t){n(this,Wa).delete(t),n(this,hs)!==null&&(n(this,re).get(t).remove(),n(this,re).delete(t))}destroy(){p(this,hs,null);for(const t of n(this,re).values())t.remove();n(this,re).clear(),n(this,Wa).clear()}};hs=new WeakMap,re=new WeakMap,Wa=new WeakMap,ac=new WeakMap,Yd=new WeakSet,Yg=function(r,[t,e,s,i]){const{style:a}=r;a.top=`${100*e}%`,a.left=`${100*t}%`,a.width=`${100*s}%`,a.height=`${100*i}%`},vn=new WeakSet,Qd=function(){const r=Ba._svgFactory.create(1,1,!0);return n(this,hs).append(r),r.setAttribute("aria-hidden",!0),r},Qg=function(r,t){const e=Ba._svgFactory.createElement("clipPath");r.append(e);const s=`clip_${t}`;e.setAttribute("id",s),e.setAttribute("clipPathUnits","objectBoundingBox");const i=Ba._svgFactory.createElement("use");return e.append(i),i.setAttribute("href",`#${t}`),i.classList.add("clip"),s},Jd=function(r,t){for(const[e,s]of Object.entries(t))s===null?r.removeAttribute(e):r.setAttribute(e,s)},f(Ba,Yd),f(Ba,ac,0);let Jg=Ba;globalThis._pdfjsTestingUtils={HighlightOutliner:Td},globalThis.pdfjsLib={AbortException:ds,AnnotationEditorLayer:Kg,AnnotationEditorParamsType:j,AnnotationEditorType:$,AnnotationEditorUIManager:Dn,AnnotationLayer:ag,AnnotationMode:cs,AnnotationType:dt,build:zp,ColorPicker:Dd,createValidAbsoluteUrl:pc,DOMSVGFactory:Vr,DrawLayer:Jg,FeatureTest:Mt,fetchData:En,getDocument:Op,getFilenameFromUrl:uu,getPdfFilenameFromUrl:pu,getUuid:Ac,getXfaPageViewport:fu,GlobalWorkerOptions:Ss,ImageKind:$a,InvalidPDFException:$o,isDataScheme:Va,isPdfFile:Uo,isValidExplicitDest:ep,MathClamp:Ht,noContextMenu:me,normalizeUnicode:cu,OPS:za,OutputScale:Ge,PasswordResponses:ru,PDFDataRangeTransport:cd,PDFDateString:jo,PDFWorker:sl,PermissionFlag:au,PixelsPerInch:Ci,RenderingCancelledException:zo,ResponseException:Ua,setLayerDimensions:Bs,shadow:z,SignatureExtractor:as,stopEvent:ut,SupportedImageMimeTypes:Vo,TextLayer:Kh,TouchManager:Lc,updateUrlHash:gc,Util:L,VerbosityLevel:Ga,version:Gp,XfaLayer:ud};export{ds as AbortException,Kg as AnnotationEditorLayer,j as AnnotationEditorParamsType,$ as AnnotationEditorType,Dn as AnnotationEditorUIManager,ag as AnnotationLayer,cs as AnnotationMode,dt as AnnotationType,Dd as ColorPicker,Vr as DOMSVGFactory,Jg as DrawLayer,Mt as FeatureTest,Ss as GlobalWorkerOptions,$a as ImageKind,$o as InvalidPDFException,Ht as MathClamp,za as OPS,Ge as OutputScale,cd as PDFDataRangeTransport,jo as PDFDateString,sl as PDFWorker,ru as PasswordResponses,au as PermissionFlag,Ci as PixelsPerInch,zo as RenderingCancelledException,Ua as ResponseException,as as SignatureExtractor,Vo as SupportedImageMimeTypes,Kh as TextLayer,Lc as TouchManager,L as Util,Ga as VerbosityLevel,ud as XfaLayer,zp as build,pc as createValidAbsoluteUrl,En as fetchData,Op as getDocument,uu as getFilenameFromUrl,pu as getPdfFilenameFromUrl,Ac as getUuid,fu as getXfaPageViewport,Va as isDataScheme,Uo as isPdfFile,ep as isValidExplicitDest,me as noContextMenu,cu as normalizeUnicode,Bs as setLayerDimensions,z as shadow,ut as stopEvent,gc as updateUrlHash,Gp as version};
|