legalesign-document-viewer 1.0.1 → 1.0.2

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.
@@ -1,4 +1,4 @@
1
- import{r as t,c as e,a as s,h as i,H as n}from"./p-CItPoq74.js";import{d as r}from"./p-WVWIAGo_.js";import{o,m as a,u as h,r as c,s as l,b as u,g as f,v as d,c as p,d as g,e as m}from"./p-ChvyHQhX.js";import{D as w,a as b,F as A}from"./p-04cXI5GQ.js";import{c as y,a as v,p as x,u as k,t as S,m as M,b as C,d as T,e as E,f as P}from"./p-CEM1EUk-.js";import{r as N,a as D,b as I}from"./p-xqZBqrca.js";import"./p-CwCWCxsI.js";
1
+ import{r as t,c as e,a as s,h as i,H as n}from"./p-CItPoq74.js";import{d as r}from"./p-WVWIAGo_.js";import{o,m as a,u as h,r as c,s as l,b as u,v as f,g as d,c as p,d as g,e as m}from"./p-ChvyHQhX.js";import{D as w,a as b,F as A}from"./p-04cXI5GQ.js";import{c as y,a as v,p as x,u as k,t as S,m as M,b as C,d as T,e as E,f as P}from"./p-CEM1EUk-.js";import{r as N,a as D,b as I}from"./p-xqZBqrca.js";import"./p-CwCWCxsI.js";
2
2
  /**
3
3
  * @licstart The following is the entire license notice for the
4
4
  * JavaScript code in this page
@@ -20,5 +20,5 @@ import{r as t,c as e,a as s,h as i,H as n}from"./p-CItPoq74.js";import{d as r}fr
20
20
  * @licend The above is the entire license notice for the
21
21
  * JavaScript code in this page
22
22
  */const R=typeof process==="object"&&process+""==="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser");const F=[.001,0,0,.001,0,0];const O=1.35;const $={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256};const _={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};const B="pdfjs_internal_editor_";const L={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102};const U={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_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41};const j={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};const z={TRIANGLES:1,LATTICE:2};const H={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};const W={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};const G={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};const V={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};const X={ERRORS:0,WARNINGS:1,INFOS:5};const q={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};const Y={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4};const J={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let K=X.WARNINGS;function Q(t){if(Number.isInteger(t)){K=t}}function Z(){return K}function tt(t){if(K>=X.INFOS){console.info(`Info: ${t}`)}}function et(t){if(K>=X.WARNINGS){console.warn(`Warning: ${t}`)}}function st(t){throw new Error(t)}function it(t,e){if(!t){st(e)}}function nt(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return true;default:return false}}function rt(t,e=null,s=null){if(!t){return null}if(s&&typeof t==="string"){if(s.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);if(e?.length>=2){t=`http://${t}`}}if(s.tryConvertEncoding){try{t=kt(t)}catch{}}}const i=e?URL.parse(t,e):URL.parse(t);return nt(i)?i:null}function ot(t,e,s=false){const i=URL.parse(t);if(i){i.hash=e;return i.href}if(s&&rt(t,"http://example.com")){return t.split("#",1)[0]+`${e?`#${e}`:""}`}return""}function at(t,e,s,i=false){Object.defineProperty(t,e,{value:s,enumerable:!i,configurable:true,writable:false});return s}const ht=function t(){function e(t,e){this.message=t;this.name=e}e.prototype=new Error;e.constructor=e;return e}();class ct extends ht{constructor(t,e){super(t,"PasswordException");this.code=e}}class lt extends ht{constructor(t,e){super(t,"UnknownErrorException");this.details=e}}class ut extends ht{constructor(t){super(t,"InvalidPDFException")}}class ft extends ht{constructor(t,e,s){super(t,"ResponseException");this.status=e;this.missing=s}}class dt extends ht{constructor(t){super(t,"FormatError")}}class pt extends ht{constructor(t){super(t,"AbortException")}}function gt(t){if(typeof t!=="object"||t?.length===undefined){st("Invalid argument for bytesToString")}const e=t.length;const s=8192;if(e<s){return String.fromCharCode.apply(null,t)}const i=[];for(let n=0;n<e;n+=s){const r=Math.min(n+s,e);const o=t.subarray(n,r);i.push(String.fromCharCode.apply(null,o))}return i.join("")}function mt(t){if(typeof t!=="string"){st("Invalid argument for stringToBytes")}const e=t.length;const s=new Uint8Array(e);for(let i=0;i<e;++i){s[i]=t.charCodeAt(i)&255}return s}function wt(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255)}function bt(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return e[0]===1}function At(){try{new Function("");return true}catch{return false}}class yt{static get isLittleEndian(){return at(this,"isLittleEndian",bt())}static get isEvalSupported(){return at(this,"isEvalSupported",At())}static get isOffscreenCanvasSupported(){return at(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas!=="undefined")}static get isImageDecoderSupported(){return at(this,"isImageDecoderSupported",typeof ImageDecoder!=="undefined")}static get isFloat16ArraySupported(){return at(this,"isFloat16ArraySupported",typeof Float16Array!=="undefined")}static get isSanitizerSupported(){return at(this,"isSanitizerSupported",typeof Sanitizer!=="undefined")}static get platform(){const{platform:t,userAgent:e}=navigator;return at(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 at(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const vt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class xt{static makeHexColor(t,e,s){return`#${vt[t]}${vt[e]}${vt[s]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let s;if(t[0]){if(t[0]<0){s=e[0];e[0]=e[2];e[2]=s}e[0]*=t[0];e[2]*=t[0];if(t[3]<0){s=e[1];e[1]=e[3];e[3]=s}e[1]*=t[3];e[3]*=t[3]}else{s=e[0];e[0]=e[1];e[1]=s;s=e[2];e[2]=e[3];e[3]=s;if(t[1]<0){s=e[1];e[1]=e[3];e[3]=s}e[1]*=t[1];e[3]*=t[1];if(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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const i=t[s];const n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4];t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0];const n=e[1];const r=e[2];const o=e[3];const a=e[4];const h=e[5];for(let e=0;e<6;e+=2){const c=t[s+e];const l=t[s+e+1];t[s+e]=c*i+l*r+a;t[s+e+1]=c*n+l*o+h}}static applyInverseTransform(t,e){const s=t[0];const i=t[1];const n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n;t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){const i=e[0];const n=e[1];const r=e[2];const o=e[3];const a=e[4];const h=e[5];const c=t[0];const l=t[1];const u=t[2];const f=t[3];let d=i*c+a;let p=d;let g=i*u+a;let m=g;let w=o*l+h;let b=w;let A=o*f+h;let y=A;if(n!==0||r!==0){const t=n*c;const e=n*u;const s=r*l;const i=r*f;d+=s;m+=s;g+=i;p+=i;w+=t;y+=t;A+=e;b+=e}s[0]=Math.min(s[0],d,g,p,m);s[1]=Math.min(s[1],w,A,b,y);s[2]=Math.max(s[2],d,g,p,m);s[3]=Math.max(s[3],w,A,b,y)}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];const i=t[1];const n=t[2];const r=t[3];const o=s**2+i**2;const a=s*n+i*r;const h=n**2+r**2;const c=(o+h)/2;const l=Math.sqrt(c**2-(o*h-a**2));e[0]=Math.sqrt(c+l||1);e[1]=Math.sqrt(c-l||1)}static normalizeRect(t){const e=t.slice(0);if(t[0]>t[2]){e[0]=t[2];e[2]=t[0]}if(t[1]>t[3]){e[1]=t[3];e[3]=t[1]}return e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2]));const i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i){return null}const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3]));const r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));if(n>r){return null}return[s,n,i,r]}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,n){n[0]=Math.min(n[0],t,s);n[1]=Math.min(n[1],e,i);n[2]=Math.max(n[2],t,s);n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,o,a,h,c){if(h<=0||h>=1){return}const l=1-h;const u=h*h;const f=u*h;const d=l*(l*(l*t+3*h*e)+3*u*s)+f*i;const p=l*(l*(l*n+3*h*r)+3*u*o)+f*a;c[0]=Math.min(c[0],d);c[1]=Math.min(c[1],p);c[2]=Math.max(c[2],d);c[3]=Math.max(c[3],p)}static#e(t,e,s,i,n,r,o,a,h,c,l,u){if(Math.abs(h)<1e-12){if(Math.abs(c)>=1e-12){this.#t(t,e,s,i,n,r,o,a,-l/c,u)}return}const f=c**2-4*l*h;if(f<0){return}const d=Math.sqrt(f);const p=2*h;this.#t(t,e,s,i,n,r,o,a,(-c+d)/p,u);this.#t(t,e,s,i,n,r,o,a,(-c-d)/p,u)}static bezierBoundingBox(t,e,s,i,n,r,o,a,h){h[0]=Math.min(h[0],t,o);h[1]=Math.min(h[1],e,a);h[2]=Math.max(h[2],t,o);h[3]=Math.max(h[3],e,a);this.#e(t,s,n,o,e,i,r,a,3*(-t+3*(s-n)+o),6*(t-2*s+n),3*(s-t),h);this.#e(t,s,n,o,e,i,r,a,3*(-e+3*(i-r)+a),6*(e-2*i+r),3*(i-e),h)}}function kt(t){return decodeURIComponent(escape(t))}let St=null;let Mt=null;function Ct(t){if(!St){St=/([\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;Mt=new Map([["ſt","ſt"]])}return t.replaceAll(St,((t,e,s)=>e?e.normalize("NFKC"):Mt.get(s)))}function Tt(){if(typeof crypto.randomUUID==="function"){return crypto.randomUUID()}const t=new Uint8Array(32);crypto.getRandomValues(t);return gt(t)}const Et="pdfjs_internal_id_";function Pt(t,e,s){if(!Array.isArray(s)||s.length<2){return false}const[i,n,...r]=s;if(!t(i)&&!Number.isInteger(i)){return false}if(!e(n)){return false}const o=r.length;let a=true;switch(n.name){case"XYZ":if(o<2||o>3){return false}break;case"Fit":case"FitB":return o===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(o>1){return false}break;case"FitR":if(o!==4){return false}a=false;break;default:return false}for(const t of r){if(typeof t==="number"||a&&t===null){continue}return false}return true}function Nt(t,e,s){return Math.min(Math.max(t,e),s)}function Dt(t){if(Uint8Array.prototype.toBase64){return t.toBase64()}return btoa(gt(t))}function It(t){if(Uint8Array.fromBase64){return Uint8Array.fromBase64(t)}return mt(atob(t))}if(typeof Promise.try!=="function"){Promise.try=function(t,...e){return new Promise((s=>{s(t(...e))}))}}if(typeof Math.sumPrecise!=="function"){Math.sumPrecise=function(t){return t.reduce(((t,e)=>t+e),0)}}class Rt{static textContent(t){const e=[];const s={items:e,styles:Object.create(null)};function i(t){if(!t){return}let s=null;const n=t.name;if(n==="#text"){s=t.value}else if(!Rt.shouldBuildText(n)){return}else if(t?.attributes?.textContent){s=t.attributes.textContent}else if(t.value){s=t.value}if(s!==null){e.push({str:s})}if(!t.children){return}for(const e of t.children){i(e)}}i(t);return s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class Ft{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null){t.textContent=r.value}if(n==="print"){break}t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}));break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn){t.setAttribute("checked",true)}else if(r.value===s.attributes.xfaOff){t.removeAttribute("checked")}if(n==="print"){break}t.addEventListener("change",(t=>{i.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(r.value!==null){t.setAttribute("value",r.value)}if(n==="print"){break}t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}))}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const t of s.children){if(t.attributes.value===r.value){t.attributes.selected=true}else if(t.attributes.hasOwnProperty("selected")){delete t.attributes.selected}}}t.addEventListener("input",(t=>{const s=t.target.options;const n=s.selectedIndex===-1?"":s[s.selectedIndex].value;i.setValue(e,{value:n})}));break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e;const o=t instanceof HTMLAnchorElement;if(r.type==="radio"){r.name=`${r.name}-${i}`}for(const[e,s]of Object.entries(r)){if(s===null||s===undefined){continue}switch(e){case"class":if(s.length){t.setAttribute(e,s.join(" "))}break;case"dataId":break;case"id":t.setAttribute("data-element-id",s);break;case"style":Object.assign(t.style,s);break;case"textContent":t.textContent=s;break;default:if(!o||e!=="href"&&e!=="newWindow"){t.setAttribute(e,s)}}}if(o){n.addLinkAttributes(t,r.href,r.newWindow)}if(s&&r.dataId){this.setupStorage(t,r.dataId,e,s)}}static render(t){const e=t.annotationStorage;const s=t.linkService;const i=t.xfaHtml;const n=t.intent||"display";const r=document.createElement(i.name);if(i.attributes){this.setAttributes({html:r,element:i,intent:n,linkService:s})}const o=n!=="richText";const a=t.div;a.append(r);if(t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;a.style.transform=e}if(o){a.setAttribute("class","xfaLayer xfaFont")}const h=[];if(i.children.length===0){if(i.value){const t=document.createTextNode(i.value);r.append(t);if(o&&Rt.shouldBuildText(i.name)){h.push(t)}}return{textDivs:h}}const c=[[i,-1,r]];while(c.length>0){const[t,i,r]=c.at(-1);if(i+1===t.children.length){c.pop();continue}const a=t.children[++c.at(-1)[1]];if(a===null){continue}const{name:l}=a;if(l==="#text"){const t=document.createTextNode(a.value);h.push(t);r.append(t);continue}const u=a?.attributes?.xmlns?document.createElementNS(a.attributes.xmlns,l):document.createElement(l);r.append(u);if(a.attributes){this.setAttributes({html:u,element:a,storage:e,intent:n,linkService:s})}if(a.children?.length>0){c.push([a,-1,u])}else if(a.value){const t=document.createTextNode(a.value);if(o&&Rt.shouldBuildText(l)){h.push(t)}u.append(t)}}for(const t of a.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea")){t.setAttribute("readOnly",true)}return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e;t.div.hidden=false}}const Ot="http://www.w3.org/2000/svg";class $t{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function _t(t,e="text"){if(Gt(t,document.baseURI)){const s=await fetch(t);if(!s.ok){throw new Error(s.statusText)}switch(e){case"arraybuffer":return s.arrayBuffer();case"blob":return s.blob();case"json":return s.json()}return s.text()}return new Promise(((s,i)=>{const n=new XMLHttpRequest;n.open("GET",t,true);n.responseType=e;n.onreadystatechange=()=>{if(n.readyState!==XMLHttpRequest.DONE){return}if(n.status===200||n.status===0){switch(e){case"arraybuffer":case"blob":case"json":s(n.response);return}s(n.responseText);return}i(new Error(n.statusText))};n.send(null)}))}class Bt{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:o=false}){this.viewBox=t;this.userUnit=e;this.scale=s;this.rotation=i;this.offsetX=n;this.offsetY=r;s*=e;const a=(t[2]+t[0])/2;const h=(t[3]+t[1])/2;let c,l,u,f;i%=360;if(i<0){i+=360}switch(i){case 180:c=-1;l=0;u=0;f=1;break;case 90:c=0;l=1;u=1;f=0;break;case 270:c=0;l=-1;u=-1;f=0;break;case 0:c=1;l=0;u=0;f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(o){u=-u;f=-f}let d,p;let g,m;if(c===0){d=Math.abs(h-t[1])*s+n;p=Math.abs(a-t[0])*s+r;g=(t[3]-t[1])*s;m=(t[2]-t[0])*s}else{d=Math.abs(a-t[0])*s+n;p=Math.abs(h-t[1])*s+r;g=(t[2]-t[0])*s;m=(t[3]-t[1])*s}this.transform=[c*s,l*s,u*s,f*s,d-c*s*a-u*s*h,p-l*s*a-f*s*h];this.width=g;this.height=m}get rawDims(){const t=this.viewBox;return at(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=false}={}){return new Bt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){const s=[t,e];xt.applyTransform(s,this.transform);return s}convertToViewportRectangle(t){const e=[t[0],t[1]];xt.applyTransform(e,this.transform);const s=[t[2],t[3]];xt.applyTransform(s,this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];xt.applyInverseTransform(s,this.transform);return s}}class Lt extends ht{constructor(t,e=0){super(t,"RenderingCancelledException");this.extraDelay=e}}function Ut(t){const e=t.length;let s=0;while(s<e&&t[s].trim()===""){s++}return t.substring(s,s+5).toLowerCase()==="data:"}function jt(t){return typeof t==="string"&&/\.pdf$/i.test(t)}function zt(t){[t]=t.split(/[#?]/,1);return t.substring(t.lastIndexOf("/")+1)}function Ht(t,e="document.pdf"){if(typeof t!=="string"){return e}if(Ut(t)){et('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');return e}const s=t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}};const i=s(t);if(!i){return e}const n=t=>{try{let e=decodeURIComponent(t);if(e.includes("/")){e=e.split("/").at(-1);if(e.test(/^\.pdf$/i)){return e}return t}return e}catch{return t}};const r=/\.pdf$/i;const o=i.pathname.split("/").at(-1);if(r.test(o)){return n(o)}if(i.searchParams.size>0){const t=Array.from(i.searchParams.values()).reverse();for(const e of t){if(r.test(e)){return n(e)}}const e=Array.from(i.searchParams.keys()).reverse();for(const t of e){if(r.test(t)){return n(t)}}}if(i.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;const e=t.exec(i.hash);if(e){return n(e[0])}}return e}class Wt{started=Object.create(null);times=[];time(t){if(t in this.started){et(`Timer is already running for ${t}`)}this.started[t]=Date.now()}timeEnd(t){if(!(t in this.started)){et(`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:t}of this.times){e=Math.max(t.length,e)}for(const{name:s,start:i,end:n}of this.times){t.push(`${s.padEnd(e)} ${n-i}ms\n`)}return t.join("")}}function Gt(t,e){const s=e?URL.parse(t,e):URL.parse(t);return s?.protocol==="http:"||s?.protocol==="https:"}function Vt(t){t.preventDefault()}function Xt(t){t.preventDefault();t.stopPropagation()}function qt(t){console.log("Deprecated API usage: "+t)}class Yt{static#s;static toDateObject(t){if(t instanceof Date){return t}if(!t||typeof t!=="string"){return null}this.#s||=new RegExp("^D:"+"(\\d{4})"+"(\\d{2})?"+"(\\d{2})?"+"(\\d{2})?"+"(\\d{2})?"+"(\\d{2})?"+"([Z|+|-])?"+"(\\d{2})?"+"'?"+"(\\d{2})?"+"'?");const e=this.#s.exec(t);if(!e){return null}const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let a=parseInt(e[6],10);a=a>=0&&a<=59?a:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let l=parseInt(e[9],10)||0;l=l>=0&&l<=59?l:0;if(h==="-"){r+=c;o+=l}else if(h==="+"){r-=c;o-=l}return new Date(Date.UTC(s,i,n,r,o,a))}}function Jt(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style;const r=[0,0,parseInt(i),parseInt(n)];return new Bt({viewBox:r,userUnit:1,scale:e,rotation:s})}function Kt(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}if(t.startsWith("rgb(")){return t.slice(4,-1).split(",").map((t=>parseInt(t)))}if(t.startsWith("rgba(")){return t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3)}et(`Not a valid color format: "${t}"`);return[0,0,0]}function Qt(t){const e=document.createElement("span");e.style.visibility="hidden";e.style.colorScheme="only light";document.body.append(e);for(const s of t.keys()){e.style.color=s;const i=window.getComputedStyle(e).color;t.set(s,Kt(i))}e.remove()}function Zt(t){const{a:e,b:s,c:i,d:n,e:r,f:o}=t.getTransform();return[e,s,i,n,r,o]}function te(t){const{a:e,b:s,c:i,d:n,e:r,f:o}=t.getTransform().invertSelf();return[e,s,i,n,r,o]}function ee(t,e,s=false,i=true){if(e instanceof Bt){const{pageWidth:i,pageHeight:n}=e.rawDims;const{style:r}=t;const o=yt.isCSSRoundSupported;const a=`var(--total-scale-factor) * ${i}px`,h=`var(--total-scale-factor) * ${n}px`;const c=o?`round(down, ${a}, var(--scale-round-x))`:`calc(${a})`,l=o?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;if(!s||e.rotation%180===0){r.width=c;r.height=l}else{r.width=l;r.height=c}}if(i){t.setAttribute("data-main-rotation",e.rotation)}}class se{constructor(){const{pixelRatio:t}=se;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,n=-1){let r=Infinity,o=Infinity,a=Infinity;s=se.capPixels(s,n);if(s>0){r=Math.sqrt(s/(t*e))}if(i!==-1){o=i/t;a=i/e}const h=Math.min(r,o,a);if(this.sx>h||this.sy>h){this.sx=h;this.sy=h;return true}return false}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 ie=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class ne{static get isDarkMode(){return at(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class re{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0";e.display="none";e.color="var(--comment-fg-color)";document.body.append(t);const{color:s}=window.getComputedStyle(t);t.remove();return at(this,"commentForegroundColor",Kt(s))}}function oe(t,e,s,i){i=Math.min(Math.max(i??1,0),1);const n=255*(1-i);t=Math.round(t*i+n);e=Math.round(e*i+n);s=Math.round(s*i+n);return[t,e,s]}function ae(t,e){const s=t[0]/255;const i=t[1]/255;const n=t[2]/255;const r=Math.max(s,i,n);const o=Math.min(s,i,n);const a=(r+o)/2;if(r===o){e[0]=e[1]=0}else{const t=r-o;e[1]=a<.5?t/(r+o):t/(2-r-o);switch(r){case s:e[0]=((i-n)/t+(i<n?6:0))*60;break;case i:e[0]=((n-s)/t+2)*60;break;case n:e[0]=((s-i)/t+4)*60;break}}e[2]=a}function he(t,e){const s=t[0];const i=t[1];const n=t[2];const r=(1-Math.abs(2*n-1))*i;const o=r*(1-Math.abs(s/60%2-1));const a=n-r/2;switch(Math.floor(s/60)){case 0:e[0]=r+a;e[1]=o+a;e[2]=a;break;case 1:e[0]=o+a;e[1]=r+a;e[2]=a;break;case 2:e[0]=a;e[1]=r+a;e[2]=o+a;break;case 3:e[0]=a;e[1]=o+a;e[2]=r+a;break;case 4:e[0]=o+a;e[1]=a;e[2]=r+a;break;case 5:case 6:e[0]=r+a;e[1]=a;e[2]=o+a;break}}function ce(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function le(t,e,s){he(t,s);s.map(ce);const i=.2126*s[0]+.7152*s[1]+.0722*s[2];he(e,s);s.map(ce);const n=.2126*s[0]+.7152*s[1]+.0722*s[2];return i>n?(i+.05)/(n+.05):(n+.05)/(i+.05)}const ue=new Map;function fe(t,e){const s=t[0]+t[1]*256+t[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776;let i=ue.get(s);if(i){return i}const n=new Float32Array(9);const r=n.subarray(0,3);const o=n.subarray(3,6);ae(t,o);const a=n.subarray(6,9);ae(e,a);const h=a[2]<.5;const c=h?12:4.5;o[2]=h?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]);if(le(o,a,r)<c){let t,e;if(h){t=o[2];e=1}else{t=0;e=o[2]}const s=.005;while(e-t>s){const s=o[2]=(t+e)/2;if(h===le(o,a,r)<c){t=s}else{e=s}}o[2]=h?e:t}he(o,r);i=xt.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255));ue.set(s,i);return i}function de({html:t,dir:e,className:s},i){const n=document.createDocumentFragment();if(typeof t==="string"){const s=document.createElement("p");s.dir=e||"auto";const i=t.split(/(?:\r\n?|\n)/);for(let t=0,e=i.length;t<e;++t){const n=i[t];s.append(document.createTextNode(n));if(t<e-1){s.append(document.createElement("br"))}}n.append(s)}else{Ft.render({xfaHtml:t,div:n,intent:"richText"})}n.firstElementChild.classList.add("richText",s);i.append(n)}function pe(t){const e=new Path2D;if(!t){return e}for(let s=0,i=t.length;s<i;){switch(t[s++]){case Y.moveTo:e.moveTo(t[s++],t[s++]);break;case Y.lineTo:e.lineTo(t[s++],t[s++]);break;case Y.curveTo:e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);break;case Y.quadraticCurveTo:e.quadraticCurveTo(t[s++],t[s++],t[s++],t[s++]);break;case Y.closePath:e.closePath();break;default:et(`Unrecognized drawing path operator: ${t[s-1]}`);break}}return e}class ge{#i=null;#n=null;#r;#o=null;#a=null;#h=null;#c=null;#l=null;static#u=null;constructor(t){this.#r=t;ge.#u||=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=this.#i=document.createElement("div");t.classList.add("editToolbar","hidden");t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;if(e instanceof AbortSignal&&!e.aborted){t.addEventListener("contextmenu",Vt,{signal:e});t.addEventListener("pointerdown",ge.#f,{signal:e})}const s=this.#o=document.createElement("div");s.className="buttons";t.append(s);const i=this.#r.toolbarPosition;if(i){const{style:e}=t;const s=this.#r._uiManager.direction==="ltr"?1-i[0]:i[0];e.insetInlineEnd=`${100*s}%`;e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#i}static#f(t){t.stopPropagation()}#d(t){this.#r._focusEventsAllowed=false;Xt(t)}#p(t){this.#r._focusEventsAllowed=true;Xt(t)}#g(t){const e=this.#r._uiManager._signal;if(!(e instanceof AbortSignal)||e.aborted){return false}t.addEventListener("focusin",this.#d.bind(this),{capture:true,signal:e});t.addEventListener("focusout",this.#p.bind(this),{capture:true,signal:e});t.addEventListener("contextmenu",Vt,{signal:e});return true}hide(){this.#i.classList.add("hidden");this.#n?.hideDropdown()}show(){this.#i.classList.remove("hidden");this.#a?.shown();this.#h?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#r;const s=document.createElement("button");s.classList.add("basic","deleteButton");s.tabIndex=0;s.setAttribute("data-l10n-id",ge.#u[t]);if(this.#g(s)){s.addEventListener("click",(t=>{e.delete()}),{signal:e._signal})}this.#o.append(s)}get#m(){const t=document.createElement("div");t.className="divider";return t}async addAltText(t){const e=await t.render();this.#g(e);this.#o.append(e,this.#m);this.#a=t}addComment(t,e=null){if(this.#h){return}const s=t.renderForToolbar();if(!s){return}this.#g(s);const i=this.#c=this.#m;if(!e){this.#o.append(s,i)}else{this.#o.insertBefore(s,e);this.#o.insertBefore(i,e)}this.#h=t;t.toolbar=this}addColorPicker(t){if(this.#n){return}this.#n=t;const e=t.renderButton();this.#g(e);this.#o.append(e,this.#m)}async addEditSignatureButton(t){const e=this.#l=await t.renderEditButton(this.#r);this.#g(e);this.#o.append(e,this.#m)}removeButton(t){switch(t){case"comment":this.#h?.removeToolbarCommentButton();this.#h=null;this.#c?.remove();this.#c=null;break}}async addButton(t,e){switch(t){case"colorPicker":if(e){this.addColorPicker(e)}break;case"altText":if(e){await this.addAltText(e)}break;case"editSignature":if(e){await this.addEditSignatureButton(e)}break;case"delete":this.addDeleteButton();break;case"comment":if(e){this.addComment(e)}break}}async addButtonBefore(t,e,s){if(!e&&t==="comment"){return}const i=this.#o.querySelector(s);if(!i){return}if(t==="comment"){this.addComment(e,i)}}updateEditSignatureButton(t){if(this.#l){this.#l.title=t}}remove(){this.#i.remove();this.#n?.destroy();this.#n=null}}class me{#o=null;#i=null;#w;constructor(t){this.#w=t}#b(){const t=this.#i=document.createElement("div");t.className="editToolbar";t.setAttribute("role","toolbar");const e=this.#w._signal;if(e instanceof AbortSignal&&!e.aborted){t.addEventListener("contextmenu",Vt,{signal:e})}const s=this.#o=document.createElement("div");s.className="buttons";t.append(s);if(this.#w.hasCommentManager()){this.#A("commentButton",`pdfjs-comment-floating-button`,"pdfjs-comment-floating-button-label",(()=>{this.#w.commentSelection("floating_button")}))}this.#A("highlightButton",`pdfjs-highlight-floating-button1`,"pdfjs-highlight-floating-button-label",(()=>{this.#w.highlightSelection("floating_button")}));return t}#y(t,e){let s=0;let i=0;for(const n of t){const t=n.y+n.height;if(t<s){continue}const r=n.x+(e?n.width:0);if(t>s){i=r;s=t;continue}if(e){if(r>i){i=r}}else if(r<i){i=r}}return[e?1-i:i,s]}show(t,e,s){const[i,n]=this.#y(e,s);const{style:r}=this.#i||=this.#b();t.append(this.#i);r.insetInlineEnd=`${100*i}%`;r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#i.remove()}#A(t,e,s,i){const n=document.createElement("button");n.classList.add("basic",t);n.tabIndex=0;n.setAttribute("data-l10n-id",e);const r=document.createElement("span");n.append(r);r.className="visuallyHidden";r.setAttribute("data-l10n-id",s);const o=this.#w._signal;if(o instanceof AbortSignal&&!o.aborted){n.addEventListener("contextmenu",Vt,{signal:o});n.addEventListener("click",i,{signal:o})}this.#o.append(n)}}function we(t,e,s){for(const i of s){e.addEventListener(i,t[i].bind(t))}}class be{static#v=NaN;static#x=null;static#k=NaN;static#S=null;static initializeAndAddPointerId(t){(be.#x||=new Set).add(t)}static setPointer(t,e){be.#v||=e;be.#S??=t}static setTimeStamp(t){be.#k=t}static isSamePointerId(t){return be.#v===t}static isSamePointerIdOrRemove(t){if(be.#v===t){return true}be.#x?.delete(t);return false}static isSamePointerType(t){return be.#S===t}static isInitializedAndDifferentPointerType(t){return be.#S!==null&&!be.isSamePointerType(t)}static isSameTimeStamp(t){return be.#k===t}static isUsingMultiplePointers(){return be.#x?.size>=1}static clearPointerType(){be.#S=null}static clearPointerIds(){be.#v=NaN;be.#x=null}static clearTimeStamp(){be.#k=NaN}}class Ae{#M=0;get id(){return`${B}${this.#M++}`}}class ye{#C=Tt();#M=0;#T=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>`;const e=new OffscreenCanvas(1,3);const s=e.getContext("2d",{willReadFrequently:true});const i=new Image;i.src=t;const n=i.decode().then((()=>{s.drawImage(i,0,0,1,1,0,0,1,3);return new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0}));return at(this,"_isSVGFittingCanvas",n)}async#E(t,e){this.#T||=new Map;let s=this.#T.get(t);if(s===null){return null}if(s?.bitmap){s.refCounter+=1;return s}try{s||={bitmap:null,id:`image_${this.#C}_${this.#M++}`,refCounter:0,isSvg:false};let t;if(typeof e==="string"){s.url=e;t=await _t(e,"blob")}else if(e instanceof File){t=s.file=e}else if(e instanceof Blob){t=e}if(t.type==="image/svg+xml"){const e=ye._isSVGFittingCanvas;const i=new FileReader;const n=new Image;const r=new Promise(((t,r)=>{n.onload=()=>{s.bitmap=n;s.isSvg=true;t()};i.onload=async()=>{const t=s.svgUrl=i.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t};n.onerror=i.onerror=r}));i.readAsDataURL(t);await r}else{s.bitmap=await createImageBitmap(t)}s.refCounter=1}catch(t){et(t);s=null}this.#T.set(t,s);if(s){this.#T.set(s.id,s)}return s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return this.#E(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#E(t,t)}async getFromBlob(t,e){const s=await e;return this.#E(t,s)}async getFromId(t){this.#T||=new Map;const e=this.#T.get(t);if(!e){return null}if(e.bitmap){e.refCounter+=1;return e}if(e.file){return this.getFromFile(e.file)}if(e.blobPromise){const{blobPromise:t}=e;delete e.blobPromise;return this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#T||=new Map;let s=this.#T.get(t);if(s?.bitmap){s.refCounter+=1;return s}const i=new OffscreenCanvas(e.width,e.height);const n=i.getContext("2d");n.drawImage(e,0,0);s={bitmap:i.transferToImageBitmap(),id:`image_${this.#C}_${this.#M++}`,refCounter:1,isSvg:false};this.#T.set(t,s);this.#T.set(s.id,s);return s}getSvgUrl(t){const e=this.#T.get(t);if(!e?.isSvg){return null}return e.svgUrl}deleteId(t){this.#T||=new Map;const e=this.#T.get(t);if(!e){return}e.refCounter-=1;if(e.refCounter!==0){return}const{bitmap:s}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(s.width,s.height);const i=t.getContext("bitmaprenderer");i.transferFromImageBitmap(s);e.blobPromise=t.convertToBlob()}s.close?.();e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#C}_`)}}class ve{#P=[];#N=false;#D;#I=-1;constructor(t=128){this.#D=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=false,keepUndo:o=false}){if(i){t()}if(this.#N){return}const a={cmd:t,undo:e,post:s,type:n};if(this.#I===-1){if(this.#P.length>0){this.#P.length=0}this.#I=0;this.#P.push(a);return}if(r&&this.#P[this.#I].type===n){if(o){a.undo=this.#P[this.#I].undo}this.#P[this.#I]=a;return}const h=this.#I+1;if(h===this.#D){this.#P.splice(0,1)}else{this.#I=h;if(h<this.#P.length){this.#P.splice(h)}}this.#P.push(a)}undo(){if(this.#I===-1){return}this.#N=true;const{undo:t,post:e}=this.#P[this.#I];t();e?.();this.#N=false;this.#I-=1}redo(){if(this.#I<this.#P.length-1){this.#I+=1;this.#N=true;const{cmd:t,post:e}=this.#P[this.#I];t();e?.();this.#N=false}}hasSomethingToUndo(){return this.#I!==-1}hasSomethingToRedo(){return this.#I<this.#P.length-1}cleanType(t){if(this.#I===-1){return}for(let e=this.#I;e>=0;e--){if(this.#P[e].type!==t){this.#P.splice(e+1,this.#I-e);this.#I=e;return}}this.#P.length=0;this.#I=-1}destroy(){this.#P=null}}class xe{constructor(t){this.buffer=[];this.callbacks=new Map;this.allKeys=new Set;const{isMac:e}=yt.platform;for(const[s,i,n={}]of t){for(const t of s){const s=t.startsWith("mac+");if(e&&s){this.callbacks.set(t.slice(4),{callback:i,options:n});this.allKeys.add(t.split("+").at(-1))}else if(!e&&!s){this.callbacks.set(t,{callback:i,options:n});this.allKeys.add(t.split("+").at(-1))}}}}#R(t){if(t.altKey){this.buffer.push("alt")}if(t.ctrlKey){this.buffer.push("ctrl")}if(t.metaKey){this.buffer.push("meta")}if(t.shiftKey){this.buffer.push("shift")}this.buffer.push(t.key);const e=this.buffer.join("+");this.buffer.length=0;return e}exec(t,e){if(!this.allKeys.has(e.key)){return}const s=this.callbacks.get(this.#R(e));if(!s){return}const{callback:i,options:{bubbles:n=false,args:r=[],checker:o=null}}=s;if(o&&!o(t,e)){return}i.bind(t,...r,e)();if(!n){Xt(e)}}}class ke{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);Qt(t);return at(this,"_colors",t)}convert(t){const e=Kt(t);if(!window.matchMedia("(forced-colors: active)").matches){return e}for(const[t,s]of this._colors){if(s.every(((t,s)=>t===e[s]))){return ke._colorsMapping.get(t)}}return e}getHexCode(t){const e=this._colors.get(t);if(!e){return t}return xt.makeHexColor(...e)}}class Se{#F=new AbortController;#O=null;#$=null;#_=new Map;#B=new Map;#L=null;#U=null;#j=null;#z=new ve;#H=null;#W=null;#G=null;#V=0;#X=new Set;#q=null;#Y=null;#J=new Set;_editorUndoBar=null;#K=false;#Q=false;#Z=false;#tt=null;#et=null;#st=null;#it=null;#nt=false;#rt=null;#ot=new Ae;#at=false;#ht=false;#ct=false;#lt=null;#ut=null;#ft=null;#dt=null;#pt=null;#gt=L.NONE;#mt=new Set;#wt=null;#bt=null;#At=null;#yt=null;#vt=null;#xt={isEditing:false,isEmpty:true,hasSomethingToUndo:false,hasSomethingToRedo:false,hasSelectedEditor:false,hasSelectedText:false};#kt=[0,0];#St=null;#Mt=null;#Ct=null;#Tt=null;#Et=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Se.prototype;const e=t=>t.#Mt.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&t.hasSomethingToControl();const s=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return t!=="text"&&t!=="number"}return true};const i=this.TRANSLATE_SMALL;const n=this.TRANSLATE_BIG;return at(this,"_keyboardManager",new xe([[["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:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#Mt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#Mt.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,o,a,h,c,l,u,f,d,p,g){const m=this._signal=this.#F.signal;this.#Mt=t;this.#Ct=e;this.#Tt=s;this.#L=i;this.#H=n;this.#bt=r;this.#vt=a;this._eventBus=o;o._on("editingaction",this.onEditingAction.bind(this),{signal:m});o._on("pagechanging",this.onPageChanging.bind(this),{signal:m});o._on("scalechanging",this.onScaleChanging.bind(this),{signal:m});o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m});o._on("setpreference",this.onSetPreference.bind(this),{signal:m});o._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:m});window.addEventListener("pointerdown",(()=>{this.#ht=true}),{capture:true,signal:m});window.addEventListener("pointerup",(()=>{this.#ht=false}),{capture:true,signal:m});this.#Pt();this.#Nt();this.#Dt();this.#U=a.annotationStorage;this.#tt=a.filterFactory;this.#At=h;this.#it=c||null;this.#K=l;this.#Q=u;this.#Z=f;this.#pt=d||null;this.viewParameters={realScale:$t.PDF_TO_CSS_UNITS,rotation:0};this.isShiftKeyDown=false;this._editorUndoBar=p||null;this._supportsPinchToZoom=g!==false;n?.setSidebarUiManager(this)}destroy(){this.#Et?.resolve();this.#Et=null;this.#F?.abort();this.#F=null;this._signal=null;for(const t of this.#B.values()){t.destroy()}this.#B.clear();this.#_.clear();this.#J.clear();this.#dt?.clear();this.#O=null;this.#mt.clear();this.#z.destroy();this.#L?.destroy();this.#H?.destroy();this.#bt?.destroy();this.#rt?.hide();this.#rt=null;this.#ft?.destroy();this.#ft=null;this.#$=null;if(this.#et){clearTimeout(this.#et);this.#et=null}if(this.#St){clearTimeout(this.#St);this.#St=null}this._editorUndoBar?.destroy();this.#vt=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#pt}get useNewAltTextFlow(){return this.#Q}get useNewAltTextWhenAddingImage(){return this.#Z}get hcmFilter(){return at(this,"hcmFilter",this.#At?this.#tt.addHCMFilter(this.#At.foreground,this.#At.background):"none")}get direction(){return at(this,"direction",getComputedStyle(this.#Mt).direction)}get _highlightColors(){return at(this,"_highlightColors",this.#it?new Map(this.#it.split(",").map((t=>{t=t.split("=").map((t=>t.trim()));t[1]=t[1].toUpperCase();return t}))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t){return at(this,"highlightColors",null)}const e=new Map;const s=!!this.#At;for(const[i,n]of t){const t=i.endsWith("_HCM");if(s&&t){e.set(i.replace("_HCM",""),n);continue}if(!s&&!t){e.set(i,n)}}return at(this,"highlightColors",e)}get highlightColorNames(){return at(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}getNonHCMColor(t){if(!this._highlightColors){return t}const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){if(t){this.unselectAll();this.disableUserSelect(true)}else{this.disableUserSelect(false)}this.#G=t}setMainHighlightColorPicker(t){this.#ft=t}editAltText(t,e=false){this.#L?.editAltText(this,t,e)}hasCommentManager(){return!!this.#H}editComment(t,e,s,i){this.#H?.showDialog(this,t,e,s,i)}selectComment(t,e){const s=this.#B.get(t);const i=s?.getEditorByUID(e);i?.toggleComment(true,true)}updateComment(t){this.#H?.updateComment(t.getData())}updatePopupColor(t){this.#H?.updatePopupColor(t)}removeComment(t){this.#H?.removeComments([t.uid])}toggleComment(t,e,s=undefined){this.#H?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#H?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#H?.dialogElement||null}async waitForEditorsRendered(t){if(this.#B.has(t-1)){return}const{resolve:e,promise:s}=Promise.withResolvers();const i=s=>{if(s.pageNumber===t){this._eventBus._off("editorsrendered",i);e()}};this._eventBus.on("editorsrendered",i);await s}getSignature(t){this.#bt?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#bt}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:true,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":this.#Z=e;break}}onPageChanging({pageNumber:t}){this.#V=t-1}focusMainContainer(){this.#Mt.focus()}findParent(t,e){for(const s of this.#B.values()){const{x:i,y:n,width:r,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+o){return s}}return null}disableUserSelect(t=false){this.#Ct.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#J.add(t)}removeShouldRescale(t){this.#J.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove();this.viewParameters.realScale=t*$t.PDF_TO_CSS_UNITS;for(const t of this.#J){t.onScaleChanging()}this.#G?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove();this.viewParameters.rotation=t}#It({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#Rt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t)){return e}for(const e of this.#B.values()){if(e.hasTextLayer(t)){return e}}return null}highlightSelection(t="",e=false){const s=document.getSelection();if(!s||s.isCollapsed){return}const{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:o}=s;const a=s.toString();const h=this.#It(s);const c=h.closest(".textLayer");const l=this.getSelectionBoxes(c);if(!l){return}s.empty();const u=this.#Rt(c);const f=this.#gt===L.NONE;const d=()=>{const s=u?.createAndAddNewEditor({x:0,y:0},false,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:o,text:a});if(f){this.showAllEditors("highlight",true,true)}if(e){s?.editComment()}};if(f){this.switchToMode(L.HIGHLIGHT,d);return}d()}commentSelection(t=""){this.highlightSelection(t,true)}#Ft(){const t=document.getSelection();if(!t||t.isCollapsed){return}const e=this.#It(t);const s=e.closest(".textLayer");const i=this.getSelectionBoxes(s);if(!i){return}this.#rt||=new me(this);this.#rt.show(s,i,this.direction==="ltr")}getAndRemoveDataFromAnnotationStorage(t){if(!this.#U){return null}const e=`${B}${t}`;const s=this.#U.getRawValue(e);if(s){this.#U.remove(e)}return s}addToAnnotationStorage(t){if(!t.isEmpty()&&this.#U&&!this.#U.has(t.id)){this.#U.setValue(t.id,t)}}a11yAlert(t,e=null){const s=this.#Tt;if(!s){return}s.setAttribute("data-l10n-id",t);if(e){s.setAttribute("data-l10n-args",JSON.stringify(e))}else{s.removeAttribute("data-l10n-args")}}#Ot(){const t=document.getSelection();if(!t||t.isCollapsed){if(this.#wt){this.#rt?.hide();this.#wt=null;this.#$t({hasSelectedText:false})}return}const{anchorNode:e}=t;if(e===this.#wt){return}const s=this.#It(t);const i=s.closest(".textLayer");if(!i){if(this.#wt){this.#rt?.hide();this.#wt=null;this.#$t({hasSelectedText:false})}return}this.#rt?.hide();this.#wt=e;this.#$t({hasSelectedText:true});if(this.#gt!==L.HIGHLIGHT&&this.#gt!==L.NONE){return}if(this.#gt===L.HIGHLIGHT){this.showAllEditors("highlight",true,true)}this.#nt=this.isShiftKeyDown;if(!this.isShiftKeyDown){const t=this.#gt===L.HIGHLIGHT?this.#Rt(i):null;t?.toggleDrawing();if(this.#ht){const e=new AbortController;const s=this.combinedSignal(e);const i=s=>{if(s.type==="pointerup"&&s.button!==0){return}e.abort();t?.toggleDrawing(true);if(s.type==="pointerup"){this.#_t("main_toolbar")}};window.addEventListener("pointerup",i,{signal:s});window.addEventListener("blur",i,{signal:s})}else{t?.toggleDrawing(true);this.#_t("main_toolbar")}}}#_t(t=""){if(this.#gt===L.HIGHLIGHT){this.highlightSelection(t)}else if(this.#K){this.#Ft()}}#Pt(){document.addEventListener("selectionchange",this.#Ot.bind(this),{signal:this._signal})}#Bt(){if(this.#st){return}this.#st=new AbortController;const t=this.combinedSignal(this.#st);window.addEventListener("focus",this.focus.bind(this),{signal:t});window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Lt(){this.#st?.abort();this.#st=null}blur(){this.isShiftKeyDown=false;if(this.#nt){this.#nt=false;this.#_t("main_toolbar")}if(!this.hasSelection){return}const{activeElement:t}=document;for(const e of this.#mt){if(e.div.contains(t)){this.#ut=[e,t];e._focusEventsAllowed=false;break}}}focus(){if(!this.#ut){return}const[t,e]=this.#ut;this.#ut=null;e.addEventListener("focusin",(()=>{t._focusEventsAllowed=true}),{once:true,signal:this._signal});e.focus()}#Dt(){if(this.#lt){return}this.#lt=new AbortController;const t=this.combinedSignal(this.#lt);window.addEventListener("keydown",this.keydown.bind(this),{signal:t});window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Ut(){this.#lt?.abort();this.#lt=null}#jt(){if(this.#W){return}this.#W=new AbortController;const t=this.combinedSignal(this.#W);document.addEventListener("copy",this.copy.bind(this),{signal:t});document.addEventListener("cut",this.cut.bind(this),{signal:t});document.addEventListener("paste",this.paste.bind(this),{signal:t})}#zt(){this.#W?.abort();this.#W=null}#Nt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t});document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Dt();this.setEditingState(true)}removeEditListeners(){this.#Ut();this.setEditingState(false)}dragOver(t){for(const{type:e}of t.dataTransfer.items){for(const s of this.#Y){if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy";t.preventDefault();return}}}}drop(t){for(const e of t.dataTransfer.items){for(const s of this.#Y){if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer);t.preventDefault();return}}}}copy(t){t.preventDefault();this.#O?.commitOrRemove();if(!this.hasSelection){return}const e=[];for(const t of this.#mt){const s=t.serialize(true);if(s){e.push(s)}}if(e.length===0){return}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 t of e.items){for(const e of this.#Y){if(e.isHandlingMimeForPasting(t.type)){e.paste(t,this.currentLayer);return}}}let s=e.getData("application/pdfjs");if(!s){return}try{s=JSON.parse(s)}catch(t){et(`paste: "${t.message}".`);return}if(!Array.isArray(s)){return}this.unselectAll();const i=this.currentLayer;try{const t=[];for(const e of s){const s=await i.deserialize(e);if(!s){return}t.push(s)}const e=()=>{for(const e of t){this.#Ht(e)}this.#Wt(t)};const n=()=>{for(const e of t){e.remove()}};this.addCommands({cmd:e,undo:n,mustExec:true})}catch(t){et(`paste: "${t.message}".`)}}keydown(t){if(!this.isShiftKeyDown&&t.key==="Shift"){this.isShiftKeyDown=true}if(this.#gt!==L.NONE&&!this.isEditorHandlingKeyboard){Se._keyboardManager.exec(this,t)}}keyup(t){if(this.isShiftKeyDown&&t.key==="Shift"){this.isShiftKeyDown=false;if(this.#nt){this.#nt=false;this.#_t("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;case"commentSelection":this.commentSelection("context_menu");break}}#$t(t){const e=Object.entries(t).some((([t,e])=>this.#xt[t]!==e));if(e){this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#xt,t)});if(this.#gt===L.HIGHLIGHT&&t.hasSelectedEditor===false){this.#Gt([[U.HIGHLIGHT_FREE,true]])}}}#Gt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){if(t){this.#Bt();this.#jt();this.#$t({isEditing:this.#gt!==L.NONE,isEmpty:this.#Vt(),hasSomethingToUndo:this.#z.hasSomethingToUndo(),hasSomethingToRedo:this.#z.hasSomethingToRedo(),hasSelectedEditor:false})}else{this.#Lt();this.#zt();this.#$t({isEditing:false});this.disableUserSelect(false)}}registerEditorTypes(t){if(this.#Y){return}this.#Y=t;for(const t of this.#Y){this.#Gt(t.defaultPropertiesToUpdate)}}getId(){return this.#ot.id}get currentLayer(){return this.#B.get(this.#V)}getLayer(t){return this.#B.get(t)}get currentPageIndex(){return this.#V}addLayer(t){this.#B.set(t.pageIndex,t);if(this.#at){t.enable()}else{t.disable()}}removeLayer(t){this.#B.delete(t.pageIndex)}async updateMode(t,e=null,s=false,i=false,n=false){if(this.#gt===t){return}if(this.#Et){await this.#Et.promise;if(!this.#Et){return}}this.#Et=Promise.withResolvers();this.#G?.commitOrRemove();if(this.#gt===L.POPUP){this.#H?.hideSidebar()}this.#H?.destroyPopup();this.#gt=t;if(t===L.NONE){this.setEditingState(false);this.#Xt();for(const t of this.#_.values()){t.hideStandaloneCommentButton()}this._editorUndoBar?.hide();this.toggleComment(null);this.#Et.resolve();return}for(const t of this.#_.values()){t.addStandaloneCommentButton()}if(t===L.SIGNATURE){await(this.#bt?.loadSignatures())}this.setEditingState(true);await this.#qt();this.unselectAll();for(const e of this.#B.values()){e.updateMode(t)}if(t===L.POPUP){this.#$||=await this.#vt.getAnnotationsByType(new Set(this.#Y.map((t=>t._editorType))));const t=new Set;const e=[];for(const s of this.#_.values()){const{annotationElementId:i,hasComment:n,deleted:r}=s;if(i){t.add(i)}if(n&&!r){e.push(s.getData())}}for(const s of this.#$){const{id:i,popupRef:n,contentsObj:r}=s;if(n&&r?.str&&!t.has(i)&&!this.#X.has(i)){e.push(s)}}this.#H?.showSidebar(e)}if(!e){if(s){this.addNewEditorFromKeyboard()}this.#Et.resolve();return}for(const t of this.#_.values()){if(t.uid===e){this.setSelected(t);if(n){t.editComment()}else if(i){t.enterInEditMode()}else{t.focus()}}else{t.unselect()}}this.#Et.resolve()}addNewEditorFromKeyboard(){if(this.currentLayer.canCreateNewEmptyEditor()){this.currentLayer.addNewEditor()}}updateToolbar(t){if(t.mode===this.#gt){return}this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(!this.#Y){return}switch(t){case U.CREATE:this.currentLayer.addNewEditor(e);return;case U.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}});(this.#yt||=new Map).set(t,e);this.showAllEditors("highlight",e);break}if(this.hasSelection){for(const s of this.#mt){s.updateParams(t,e)}}else{for(const s of this.#Y){s.updateDefaultParams(t,e)}}}showAllEditors(t,e,s=false){for(const s of this.#_.values()){if(s.editorType===t){s.show(e)}}const i=this.#yt?.get(U.HIGHLIGHT_SHOW_ALL)??true;if(i!==e){this.#Gt([[U.HIGHLIGHT_SHOW_ALL,e]])}}enableWaiting(t=false){if(this.#ct===t){return}this.#ct=t;for(const e of this.#B.values()){if(t){e.disableClick()}else{e.enableClick()}e.div.classList.toggle("waiting",t)}}async#qt(){if(!this.#at){this.#at=true;const t=[];for(const e of this.#B.values()){t.push(e.enable())}await Promise.all(t);for(const t of this.#_.values()){t.enable()}}}#Xt(){this.unselectAll();if(this.#at){this.#at=false;for(const t of this.#B.values()){t.disable()}for(const t of this.#_.values()){t.disable()}}}*getEditors(t){for(const e of this.#_.values()){if(e.pageIndex===t){yield e}}}getEditor(t){return this.#_.get(t)}addEditor(t){this.#_.set(t.id,t)}removeEditor(t){if(t.div.contains(document.activeElement)){if(this.#et){clearTimeout(this.#et)}this.#et=setTimeout((()=>{this.focusMainContainer();this.#et=null}),0)}this.#_.delete(t.id);if(t.annotationElementId){this.#dt?.delete(t.annotationElementId)}this.unselect(t);if(!t.annotationElementId||!this.#X.has(t.annotationElementId)){this.#U?.remove(t.id)}}addDeletedAnnotationElement(t){this.#X.add(t.annotationElementId);this.addChangedExistingAnnotation(t);t.deleted=true}isDeletedAnnotationElement(t){return this.#X.has(t)}removeDeletedAnnotationElement(t){this.#X.delete(t.annotationElementId);this.removeChangedExistingAnnotation(t);t.deleted=false}#Ht(t){const e=this.#B.get(t.pageIndex);if(e){e.addOrRebuild(t)}else{this.addEditor(t);this.addToAnnotationStorage(t)}}setActiveEditor(t){if(this.#O===t){return}this.#O=t;if(t){this.#Gt(t.propertiesToUpdate)}}get#Yt(){let t=null;for(t of this.#mt){}return t}updateUI(t){if(this.#Yt===t){this.#Gt(t.propertiesToUpdate)}}updateUIForDefaultProperties(t){this.#Gt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#mt.has(t)){this.#mt.delete(t);t.unselect();this.#$t({hasSelectedEditor:this.hasSelection});return}this.#mt.add(t);t.select();this.#Gt(t.propertiesToUpdate);this.#$t({hasSelectedEditor:true})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid});this.#G?.commitOrRemove();for(const e of this.#mt){if(e!==t){e.unselect()}}this.#mt.clear();this.#mt.add(t);t.select();this.#Gt(t.propertiesToUpdate);this.#$t({hasSelectedEditor:true})}isSelected(t){return this.#mt.has(t)}get firstSelectedEditor(){return this.#mt.values().next().value}unselect(t){t.unselect();this.#mt.delete(t);this.#$t({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#mt.size!==0}get isEnterHandled(){return this.#mt.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#z.undo();this.#$t({hasSomethingToUndo:this.#z.hasSomethingToUndo(),hasSomethingToRedo:true,isEmpty:this.#Vt()});this._editorUndoBar?.hide()}redo(){this.#z.redo();this.#$t({hasSomethingToUndo:true,hasSomethingToRedo:this.#z.hasSomethingToRedo(),isEmpty:this.#Vt()})}addCommands(t){this.#z.add(t);this.#$t({hasSomethingToUndo:true,hasSomethingToRedo:false,isEmpty:this.#Vt()})}cleanUndoStack(t){this.#z.cleanType(t)}#Vt(){if(this.#_.size===0){return true}if(this.#_.size===1){for(const t of this.#_.values()){return t.isEmpty()}}return false}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(true);if(!this.hasSelection&&!t){return}const e=t?[t]:[...this.#mt];const s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(const t of e){t.remove()}};const i=()=>{for(const t of e){this.#Ht(t)}};this.addCommands({cmd:s,undo:i,mustExec:true})}commitOrRemove(){this.#O?.commitOrRemove()}hasSomethingToControl(){return this.#O||this.hasSelection}#Wt(t){for(const t of this.#mt){t.unselect()}this.#mt.clear();for(const e of t){if(e.isEmpty()){continue}this.#mt.add(e);e.select()}this.#$t({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#mt){t.commit()}this.#Wt(this.#_.values())}unselectAll(){if(this.#O){this.#O.commitOrRemove();if(this.#gt!==L.NONE){return}}if(this.#G?.commitOrRemove()){return}if(!this.hasSelection){return}for(const t of this.#mt){t.unselect()}this.#mt.clear();this.#$t({hasSelectedEditor:false})}translateSelectedEditors(t,e,s=false){if(!s){this.commitOrRemove()}if(!this.hasSelection){return}this.#kt[0]+=t;this.#kt[1]+=e;const[i,n]=this.#kt;const r=[...this.#mt];const o=1e3;if(this.#St){clearTimeout(this.#St)}this.#St=setTimeout((()=>{this.#St=null;this.#kt[0]=this.#kt[1]=0;this.addCommands({cmd:()=>{for(const t of r){if(this.#_.has(t.id)){t.translateInPage(i,n);t.translationDone()}}},undo:()=>{for(const t of r){if(this.#_.has(t.id)){t.translateInPage(-i,-n);t.translationDone()}}},mustExec:false})}),o);for(const s of r){s.translateInPage(t,e);s.translationDone()}}setUpDragSession(){if(!this.hasSelection){return}this.disableUserSelect(true);this.#q=new Map;for(const t of this.#mt){this.#q.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#q){return false}this.disableUserSelect(false);const t=this.#q;this.#q=null;let e=false;for(const[{x:s,y:i,pageIndex:n},r]of t){r.newX=s;r.newY=i;r.newPageIndex=n;e||=s!==r.savedX||i!==r.savedY||n!==r.savedPageIndex}if(!e){return false}const s=(t,e,s,i)=>{if(this.#_.has(t.id)){const n=this.#B.get(i);if(n){t._setParentAndPosition(n,e,s)}else{t.pageIndex=i;t.x=e;t.y=s}}};this.addCommands({cmd:()=>{for(const[e,{newX:i,newY:n,newPageIndex:r}]of t){s(e,i,n,r)}},undo:()=>{for(const[e,{savedX:i,savedY:n,savedPageIndex:r}]of t){s(e,i,n,r)}},mustExec:true});return true}dragSelectedEditors(t,e){if(!this.#q){return}for(const s of this.#q.keys()){s.drag(t,e)}}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);if(e){e.changeParent(t);e.addOrRebuild(t)}else{this.addEditor(t);this.addToAnnotationStorage(t);t.rebuild()}}else{t.parent.addOrRebuild(t)}}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#mt.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#O===t}getActive(){return this.#O}getMode(){return this.#gt}isEditingMode(){return this.#gt!==L.NONE}get imageManager(){return at(this,"imageManager",new ye)}getSelectionBoxes(t){if(!t){return null}const e=document.getSelection();for(let s=0,i=e.rangeCount;s<i;s++){if(!t.contains(e.getRangeAt(s).commonAncestorContainer)){return null}}const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(t,e,o,a)=>({x:(e-i)/r,y:1-(t+o-s)/n,width:a/r,height:o/n});break;case"180":o=(t,e,o,a)=>({x:1-(t+o-s)/n,y:1-(e+a-i)/r,width:o/n,height:a/r});break;case"270":o=(t,e,o,a)=>({x:1-(e+a-i)/r,y:(t-s)/n,width:a/r,height:o/n});break;default:o=(t,e,o,a)=>({x:(t-s)/n,y:(e-i)/r,width:o/n,height:a/r});break}const a=[];for(let t=0,s=e.rangeCount;t<s;t++){const s=e.getRangeAt(t);if(s.collapsed){continue}for(const{x:t,y:e,width:i,height:n}of s.getClientRects()){if(i===0||n===0){continue}a.push(o(t,e,i,n))}}return a.length===0?null:a}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#j||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#j?.delete(t)}renderAnnotationElement(t){const e=this.#j?.get(t.data.id);if(!e){return}const s=this.#U.getRawValue(e);if(!s){return}if(this.#gt===L.NONE&&!s.hasBeenModified){return}s.renderAnnotationElement(t)}setMissingCanvas(t,e,s){const i=this.#dt?.get(t);if(!i){return}i.setCanvas(e,s);this.#dt.delete(t)}addMissingCanvas(t,e){(this.#dt||=new Map).set(t,e)}}class Me{#a=null;#Jt=false;#Kt=null;#Qt=null;#Zt=null;#te=null;#ee=false;#se=null;#r=null;#ie=null;#ne=null;#re=false;static#oe=null;static _l10n=null;constructor(t){this.#r=t;this.#re=t._uiManager.useNewAltTextFlow;Me.#oe||=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){Me._l10n??=t}async render(){const t=this.#Kt=document.createElement("button");t.className="altText";t.tabIndex="0";const e=this.#Qt=document.createElement("span");t.append(e);if(this.#re){t.classList.add("new");t.setAttribute("data-l10n-id",Me.#oe.missing);e.setAttribute("data-l10n-id",Me.#oe["missing-label"])}else{t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button");e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label")}const s=this.#r._uiManager._signal;t.addEventListener("contextmenu",Vt,{signal:s});t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:s});const i=t=>{t.preventDefault();this.#r._uiManager.editAltText(this.#r);if(this.#re){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#ae}})}};t.addEventListener("click",i,{capture:true,signal:s});t.addEventListener("keydown",(e=>{if(e.target===t&&e.key==="Enter"){this.#ee=true;i(e)}}),{signal:s});await this.#he();return t}get#ae(){return this.#a&&"added"||this.#a===null&&this.guessedText&&"review"||"missing"}finish(){if(!this.#Kt){return}this.#Kt.focus({focusVisible:this.#ee});this.#ee=false}isEmpty(){if(this.#re){return this.#a===null}return!this.#a&&!this.#Jt}hasData(){if(this.#re){return this.#a!==null||!!this.#ie}return this.isEmpty()}get guessedText(){return this.#ie}async setGuessedText(t){if(this.#a!==null){return}this.#ie=t;this.#ne=await Me._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t});this.#he()}toggleAltTextBadge(t=false){if(!this.#re||this.#a){this.#se?.remove();this.#se=null;return}if(!this.#se){const t=this.#se=document.createElement("div");t.className="noAltTextBadge";this.#r.div.append(t)}this.#se.classList.toggle("hidden",!t)}serialize(t){let e=this.#a;if(!t&&this.#ie===e){e=this.#ne}return{altText:e,decorative:this.#Jt,guessedText:this.#ie,textWithDisclaimer:this.#ne}}get data(){return{altText:this.#a,decorative:this.#Jt}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=false}){if(s){this.#ie=s;this.#ne=i}if(this.#a===t&&this.#Jt===e){return}if(!n){this.#a=t;this.#Jt=e}this.#he()}toggle(t=false){if(!this.#Kt){return}if(!t&&this.#te){clearTimeout(this.#te);this.#te=null}this.#Kt.disabled=!t}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#ae}})}destroy(){this.#Kt?.remove();this.#Kt=null;this.#Qt=null;this.#Zt=null;this.#se?.remove();this.#se=null}async#he(){const t=this.#Kt;if(!t){return}if(this.#re){t.classList.toggle("done",!!this.#a);t.setAttribute("data-l10n-id",Me.#oe[this.#ae]);this.#Qt?.setAttribute("data-l10n-id",Me.#oe[`${this.#ae}-label`]);if(!this.#a){this.#Zt?.remove();return}}else{if(!this.#a&&!this.#Jt){t.classList.remove("done");this.#Zt?.remove();return}t.classList.add("done");t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Zt;if(!e){this.#Zt=e=document.createElement("span");e.className="tooltip";e.setAttribute("role","tooltip");e.id=`alt-text-tooltip-${this.#r.id}`;const s=100;const i=this.#r._uiManager._signal;i.addEventListener("abort",(()=>{clearTimeout(this.#te);this.#te=null}),{once:true});t.addEventListener("mouseenter",(()=>{this.#te=setTimeout((()=>{this.#te=null;this.#Zt.classList.add("show");this.#r._reportTelemetry({action:"alt_text_tooltip"})}),s)}),{signal:i});t.addEventListener("mouseleave",(()=>{if(this.#te){clearTimeout(this.#te);this.#te=null}this.#Zt?.classList.remove("show")}),{signal:i})}if(this.#Jt){e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip")}else{e.removeAttribute("data-l10n-id");e.textContent=this.#a}if(!e.parentNode){t.append(e)}const s=this.#r.getElementForAltText();s?.setAttribute("aria-describedby",e.id)}}class Ce{#ce=null;#le=null;#ue=false;#r=null;#fe=null;#de=null;#pe=null;#ge=null;#me=false;#we=null;constructor(t){this.#r=t}renderForToolbar(){const t=this.#le=document.createElement("button");t.className="comment";return this.#b(t,false)}renderForStandalone(){const t=this.#ce=document.createElement("button");t.className="annotationCommentButton";const e=this.#r.commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#r._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`;s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=this.#r.commentButtonColor;if(i){s.backgroundColor=i}}return this.#b(t,true)}focusButton(){setTimeout((()=>{(this.#ce??this.#le)?.focus()}),0)}onUpdatedColor(){if(!this.#ce){return}const t=this.#r.commentButtonColor;if(t){this.#ce.style.backgroundColor=t}this.#r._uiManager.updatePopupColor(this.#r)}get commentButtonWidth(){return(this.#ce?.getBoundingClientRect().width??0)/this.#r.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#we){return this.#we}if(!this.#ce){return null}const{x:t,y:e,height:s}=this.#ce.getBoundingClientRect();const{x:i,y:n,width:r,height:o}=this.#r.parent.boundingClientRect;return[(t-i)/r,(e+s-n)/o]}set commentPopupPositionInLayer(t){this.#we=t}hasDefaultPopupPosition(){return this.#we===null}removeStandaloneCommentButton(){this.#ce?.remove();this.#ce=null}removeToolbarCommentButton(){this.#le?.remove();this.#le=null}setCommentButtonStates({selected:t,hasPopup:e}){if(!this.#ce){return}this.#ce.classList.toggle("selected",t);this.#ce.ariaExpanded=e}#b(t,e){if(!this.#r._uiManager.hasCommentManager()){return null}t.tabIndex="0";t.ariaHasPopup="dialog";if(e){t.ariaControls="commentPopup";t.setAttribute("data-l10n-id","pdfjs-show-comment-button")}else{t.ariaControlsElements=[this.#r._uiManager.getCommentDialogElement()];t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button")}const s=this.#r._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted){return t}t.addEventListener("contextmenu",Vt,{signal:s});if(e){t.addEventListener("focusin",(t=>{this.#r._focusEventsAllowed=false;Xt(t)}),{capture:true,signal:s});t.addEventListener("focusout",(t=>{this.#r._focusEventsAllowed=true;Xt(t)}),{capture:true,signal:s})}t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:s});const i=e=>{e.preventDefault();if(t===this.#le){this.edit()}else{this.#r.toggleComment(true)}};t.addEventListener("click",i,{capture:true,signal:s});t.addEventListener("keydown",(e=>{if(e.target===t&&e.key==="Enter"){this.#ue=true;i(e)}}),{signal:s});t.addEventListener("pointerenter",(()=>{this.#r.toggleComment(false,true)}),{signal:s});t.addEventListener("pointerleave",(()=>{this.#r.toggleComment(false,false)}),{signal:s});return t}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e){[s,i]=e}else{[s,i]=this.#r.commentButtonPosition;const{width:t,height:e,x:n,y:r}=this.#r;s=n+s*t;i=r+i*e}const n=this.#r.parent.boundingClientRect;const{x:r,y:o,width:a,height:h}=n;this.#r._uiManager.editComment(this.#r,r+s*a,o+i*h,{...t,parentDimensions:n})}finish(){if(!this.#le){return}this.#le.focus({focusVisible:this.#ue});this.#ue=false}isDeleted(){return this.#me||this.#pe===""}isEmpty(){return this.#pe===null}hasBeenEdited(){return this.isDeleted()||this.#pe!==this.#fe}serialize(){return this.data}get data(){return{text:this.#pe,richText:this.#de,date:this.#ge,deleted:this.isDeleted()}}set data(t){if(t!==this.#pe){this.#de=null}if(t===null){this.#pe="";this.#me=true;return}this.#pe=t;this.#ge=new Date;this.#me=false}setInitialText(t,e=null){this.#fe=t;this.data=t;this.#ge=null;this.#de=e}shown(){}destroy(){this.#le?.remove();this.#le=null;this.#ce?.remove();this.#ce=null;this.#pe="";this.#de=null;this.#ge=null;this.#r=null;this.#ue=false;this.#me=false}}class Te{#Mt;#be=false;#Ae=null;#ye;#ve;#xe;#ke;#Se=null;#Me;#Ce=null;#Te;#Ee=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,signal:o}){this.#Mt=t;this.#Ae=s;this.#ye=e;this.#ve=i;this.#xe=n;this.#ke=r;this.#Te=new AbortController;this.#Me=AbortSignal.any([o,this.#Te.signal]);t.addEventListener("touchstart",this.#Pe.bind(this),{passive:false,signal:this.#Me})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/se.pixelRatio}#Pe(t){if(this.#ye?.()){return}if(t.touches.length===1){if(this.#Se){return}const t=this.#Se=new AbortController;const e=AbortSignal.any([this.#Me,t.signal]);const s=this.#Mt;const i={capture:true,signal:e,passive:false};const n=t=>{if(t.pointerType==="touch"){this.#Se?.abort();this.#Se=null}};s.addEventListener("pointerdown",(t=>{if(t.pointerType==="touch"){Xt(t);n(t)}}),i);s.addEventListener("pointerup",n,i);s.addEventListener("pointercancel",n,i);return}if(!this.#Ee){this.#Ee=new AbortController;const t=AbortSignal.any([this.#Me,this.#Ee.signal]);const e=this.#Mt;const s={signal:t,capture:false,passive:false};e.addEventListener("touchmove",this.#Ne.bind(this),s);const i=this.#De.bind(this);e.addEventListener("touchend",i,s);e.addEventListener("touchcancel",i,s);s.capture=true;e.addEventListener("pointerdown",Xt,s);e.addEventListener("pointermove",Xt,s);e.addEventListener("pointercancel",Xt,s);e.addEventListener("pointerup",Xt,s);this.#ve?.()}Xt(t);if(t.touches.length!==2||this.#Ae?.()){this.#Ce=null;return}let[e,s]=t.touches;if(e.identifier>s.identifier){[e,s]=[s,e]}this.#Ce={touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY}}#Ne(t){if(!this.#Ce||t.touches.length!==2){return}Xt(t);let[e,s]=t.touches;if(e.identifier>s.identifier){[e,s]=[s,e]}const{screenX:i,screenY:n}=e;const{screenX:r,screenY:o}=s;const a=this.#Ce;const{touch0X:h,touch0Y:c,touch1X:l,touch1Y:u}=a;const f=l-h;const d=u-c;const p=r-i;const g=o-n;const m=Math.hypot(p,g)||1;const w=Math.hypot(f,d)||1;if(!this.#be&&Math.abs(w-m)<=Te.MIN_TOUCH_DISTANCE_TO_PINCH){return}a.touch0X=i;a.touch0Y=n;a.touch1X=r;a.touch1Y=o;if(!this.#be){this.#be=true;return}const b=[(i+r)/2,(n+o)/2];this.#xe?.(b,w,m)}#De(t){if(t.touches.length>=2){return}if(this.#Ee){this.#Ee.abort();this.#Ee=null;this.#ke?.()}if(!this.#Ce){return}Xt(t);this.#Ce=null;this.#be=false}destroy(){this.#Te?.abort();this.#Te=null;this.#Se?.abort();this.#Se=null}}class Ee{#Ie=null;#Re=null;#a=null;#h=null;#ce=null;#Fe=false;#Oe=null;#$e="";#_e=null;#Be=null;#Le=null;#Ue=null;#je=null;#ze="";#He=false;#We=null;#Ge=false;#Ve=false;#Xe=false;#qe=null;#Ye=0;#Je=0;#Ke=null;#Qe=null;isSelected=false;_isCopy=false;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=true;_uiManager=null;_focusEventsAllowed=true;static _l10n=null;static _l10nResizer=null;#Ze=false;#ts=Ee._zIndex++;static _borderLineWidth=-1;static _colorManager=new ke;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=Ee.prototype._resizeWithKeyboard;const e=Se.TRANSLATE_SMALL;const s=Se.TRANSLATE_BIG;return at(this,"_resizerKeyboardManager",new xe([[["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"],Ee.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent;this.id=t.id;this.width=this.height=null;this.pageIndex=t.parent.pageIndex;this.name=t.name;this.div=null;this._uiManager=t.uiManager;this.annotationElementId=null;this._willKeepAspectRatio=false;this._initialOptions.isCentered=t.isCentered;this._structTreeParentId=null;this.annotationElementId=t.annotationElementId||null;this.creationDate=t.creationDate||new Date;this.modificationDate=t.modificationDate||null;this.canAddComment=true;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e;this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360;this.pageDimensions=[s,i];this.pageTranslation=[n,r];const[o,a]=this.parentDimensions;this.x=t.x/o;this.y=t.y/a;this.isAttachedToDOM=false;this.deleted=false}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return false}static get _defaultLineColor(){return at(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Pe({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId;e.deleted=true;e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){Ee._l10n??=t;Ee._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"});if(Ee._borderLineWidth!==-1){return}const s=getComputedStyle(document.documentElement);Ee._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return false}static paste(t,e){st("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#Ze}set _isDraggable(t){this.#Ze=t;this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return true}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2);this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2;this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2);this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2;this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#ts}setParent(t){if(t!==null){this.pageIndex=t.pageIndex;this.pageDimensions=t.pageDimensions}else{this.#es();this.#Ue?.remove();this.#Ue=null}this.parent=t}focusin(t){if(!this._focusEventsAllowed){return}if(!this.#He){this.parent.setSelected(this)}else{this.#He=false}}focusout(t){if(!this._focusEventsAllowed){return}if(!this.isAttachedToDOM){return}const e=t.relatedTarget;if(e?.closest(`#${this.id}`)){return}t.preventDefault();if(!this.parent?.isMultipleSelection){this.commitOrRemove()}}commitOrRemove(){if(this.isEmpty()){this.remove()}else{this.commit()}}commit(){if(!this.isInEditMode()){return}this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i);this.x=(t+s)/n;this.y=(e+i)/r;this.fixAndSetPosition()}_moveAfterPaste(t,e){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i);this._onTranslated()}#ss([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i);this.x+=s/t;this.y+=i/e;this._onTranslating(this.x,this.y);this.fixAndSetPosition()}translate(t,e){this.#ss(this.parentDimensions,t,e)}translateInPage(t,e){this.#We||=[this.x,this.y,this.width,this.height];this.#ss(this.pageDimensions,t,e);this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#We||=[this.x,this.y,this.width,this.height];const{div:s,parentDimensions:[i,n]}=this;this.x+=t/i;this.y+=e/n;if(this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();if(this.parent.findNewParent(this,t,e)){this.x-=Math.floor(this.x);this.y-=Math.floor(this.y)}}let{x:r,y:o}=this;const[a,h]=this.getBaseTranslation();r+=a;o+=h;const{style:c}=s;c.left=`${(100*r).toFixed(2)}%`;c.top=`${(100*o).toFixed(2)}%`;this._onTranslating(r,o);s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#We&&(this.#We[0]!==this.x||this.#We[1]!==this.y)}get _hasBeenResized(){return!!this.#We&&(this.#We[2]!==this.width||this.#We[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions;const{_borderLineWidth:s}=Ee;const i=s/t;const n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return true}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:n,y:r,width:o,height:a}=this;o*=s;a*=i;n*=s;r*=i;if(this._mustFixPosition){switch(t){case 0:n=Nt(n,0,s-o);r=Nt(r,0,i-a);break;case 90:n=Nt(n,0,s-a);r=Nt(r,o,i);break;case 180:n=Nt(n,o,s);r=Nt(r,a,i);break;case 270:n=Nt(n,a,s);r=Nt(r,0,i-o);break}}this.x=n/=s;this.y=r/=i;const[h,c]=this.getBaseTranslation();n+=h;r+=c;e.left=`${(100*n).toFixed(2)}%`;e.top=`${(100*r).toFixed(2)}%`;this.moveInDOM()}static#is(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return Ee.#is(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Ee.#is(t,e,360-this.parentRotation)}#ns(t){switch(t){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]}}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(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`;t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#rs(){if(this.#_e){return}this.#_e=document.createElement("div");this.#_e.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"];const e=this._uiManager._signal;for(const s of t){const t=document.createElement("div");this.#_e.append(t);t.classList.add("resizer",s);t.setAttribute("data-resizer-name",s);t.addEventListener("pointerdown",this.#os.bind(this,s),{signal:e});t.addEventListener("contextmenu",Vt,{signal:e});t.tabIndex=-1}this.div.prepend(this.#_e)}#os(t,e){e.preventDefault();const{isMac:s}=yt.platform;if(e.button!==0||e.ctrlKey&&s){return}this.#a?.toggle(false);const i=this._isDraggable;this._isDraggable=false;this.#Be=[e.screenX,e.screenY];const n=new AbortController;const r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(false);window.addEventListener("pointermove",this.#as.bind(this,t),{passive:true,capture:true,signal:r});window.addEventListener("touchmove",Xt,{passive:false,signal:r});window.addEventListener("contextmenu",Vt,{signal:r});this.#Le={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const o=this.parent.div.style.cursor;const a=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{n.abort();this.parent.togglePointerEvents(true);this.#a?.toggle(true);this._isDraggable=i;this.parent.div.style.cursor=o;this.div.style.cursor=a;this.#hs()};window.addEventListener("pointerup",h,{signal:r});window.addEventListener("blur",h,{signal:r})}#cs(t,e,s,i){this.width=s;this.height=i;this.x=t;this.y=e;this.setDims();this.fixAndSetPosition();this._onResized()}_onResized(){}#hs(){if(!this.#Le){return}const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#Le;this.#Le=null;const n=this.x;const r=this.y;const o=this.width;const a=this.height;if(n===t&&r===e&&o===s&&a===i){return}this.addCommands({cmd:this.#cs.bind(this,n,r,o,a),undo:this.#cs.bind(this,t,e,s,i),mustExec:true})}static _round(t){return Math.round(t*1e4)/1e4}#as(t,e){const[s,i]=this.parentDimensions;const n=this.x;const r=this.y;const o=this.width;const a=this.height;const h=Ee.MIN_SIZE/s;const c=Ee.MIN_SIZE/i;const l=this.#ns(this.rotation);const u=(t,e)=>[l[0]*t+l[2]*e,l[1]*t+l[3]*e];const f=this.#ns(360-this.rotation);const d=(t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e];let p;let g;let m=false;let w=false;switch(t){case"topLeft":m=true;p=(t,e)=>[0,0];g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0];g=(t,e)=>[t/2,e];break;case"topRight":m=true;p=(t,e)=>[t,0];g=(t,e)=>[0,e];break;case"middleRight":w=true;p=(t,e)=>[t,e/2];g=(t,e)=>[0,e/2];break;case"bottomRight":m=true;p=(t,e)=>[t,e];g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e];g=(t,e)=>[t/2,0];break;case"bottomLeft":m=true;p=(t,e)=>[0,e];g=(t,e)=>[t,0];break;case"middleLeft":w=true;p=(t,e)=>[0,e/2];g=(t,e)=>[t,e/2];break}const b=p(o,a);const A=g(o,a);let y=u(...A);const v=Ee._round(n+y[0]);const x=Ee._round(r+y[1]);let k=1;let S=1;let M,C;if(!e.fromKeyboard){const{screenX:t,screenY:s}=e;const[i,n]=this.#Be;[M,C]=this.screenToPageTranslation(t-i,s-n);this.#Be[0]=t;this.#Be[1]=s}else{({deltaX:M,deltaY:C}=e)}[M,C]=d(M/s,C/i);if(m){const t=Math.hypot(o,a);k=S=Math.max(Math.min(Math.hypot(A[0]-b[0]-M,A[1]-b[1]-C)/t,1/o,1/a),h/o,c/a)}else if(w){k=Nt(Math.abs(A[0]-b[0]-M),h,1)/o}else{S=Nt(Math.abs(A[1]-b[1]-C),c,1)/a}const T=Ee._round(o*k);const E=Ee._round(a*S);y=u(...g(T,E));const P=v-y[0];const N=x-y[1];this.#We||=[this.x,this.y,this.width,this.height];this.width=T;this.height=E;this.x=P;this.y=N;this.setDims();this.fixAndSetPosition();this._onResizing()}_onResizing(){}altTextFinish(){this.#a?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#Ve){return this._editToolbar}this._editToolbar=new ge(this);this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t){for(const[e,s]of t){await this._editToolbar.addButton(e,s)}}if(!this.hasComment){this._editToolbar.addButton("comment",this.addCommentButton())}this._editToolbar.addButton("delete");return this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove();this._editToolbar=null;this.#a?.destroy()}addContainer(t){const e=this._editToolbar?.div;if(e){e.before(t)}else{this.div.append(t)}}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){if(!this.#a){Me.initialize(Ee._l10n);this.#a=new Me(this);if(this.#Ie){this.#a.data=this.#Ie;this.#Ie=null}}return this.#a}get altTextData(){return this.#a?.data}set altTextData(t){if(!this.#a){return}this.#a.data=t}get guessedAltText(){return this.#a?.guessedText}async setGuessedAltText(t){await(this.#a?.setGuessedText(t))}serializeAltText(t){return this.#a?.serialize(t)}hasAltText(){return!!this.#a&&!this.#a.isEmpty()}hasAltTextData(){return this.#a?.hasData()??false}focusCommentButton(){this.#h?.focusButton()}addCommentButton(){return this.canAddComment?this.#h||=new Ce(this):null}addStandaloneCommentButton(){if(!this._uiManager.hasCommentManager()){return}if(this.#ce){if(this._uiManager.isEditingMode()){this.#ce.classList.remove("hidden")}return}if(!this.hasComment){return}this.#ce=this.#h.renderForStandalone();this.div.append(this.#ce)}removeStandaloneCommentButton(){this.#h.removeStandaloneCommentButton();this.#ce=null}hideStandaloneCommentButton(){this.#ce?.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:s,deleted:i}}=this.#h;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#h||=new Ce(this);this.#h.data=t;if(this.hasComment){this.removeCommentButtonFromToolbar();this.addStandaloneCommentButton();this._uiManager.updateComment(this)}else{this.addCommentButtonInToolbar();this.removeStandaloneCommentButton();this._uiManager.removeComment(this)}}setCommentData({comment:t,popupRef:e,richText:s}){if(!e){return}this.#h||=new Ce(this);this.#h.setInitialText(t,s);if(!this.annotationElementId){return}const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);if(i){this.updateFromAnnotationLayer(i)}}get hasEditedComment(){return this.#h?.hasBeenEdited()}get hasDeletedComment(){return this.#h?.isDeleted()}get hasComment(){return!!this.#h&&!this.#h.isEmpty()&&!this.#h.isDeleted()}async editComment(t){this.#h||=new Ce(this);this.#h.edit(t)}toggleComment(t,e=undefined){if(this.hasComment){this._uiManager.toggleComment(this,t,e)}}setSelectedCommentButton(t){this.#h.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const e=180;const s=100;const[,,,i]=t.rect;const[n]=this.pageDimensions;const[r]=this.pageTranslation;const o=r+n+1;const a=i-s;const h=o+e;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,a,h,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#h.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}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=this.#Fe?-1:0;t.setAttribute("role","application");if(this.defaultL10nId){t.setAttribute("data-l10n-id",this.defaultL10nId)}if(!this._isVisible){t.classList.add("hidden")}this.setInForeground();this.#ls();const[e,s]=this.parentDimensions;if(this.parentRotation%180!==0){t.style.maxWidth=`${(100*s/e).toFixed(2)}%`;t.style.maxHeight=`${(100*e/s).toFixed(2)}%`}const[i,n]=this.getInitialTranslation();this.translate(i,n);we(this,t,["keydown","pointerdown","dblclick"]);if(this.isResizable&&this._uiManager._supportsPinchToZoom){this.#Qe||=new Te({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#us.bind(this),onPinching:this.#fs.bind(this),onPinchEnd:this.#ds.bind(this),signal:this._uiManager._signal})}this.addStandaloneCommentButton();this._uiManager._editorUndoBar?.hide();return t}#us(){this.#Le={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};this.#a?.toggle(false);this.parent.togglePointerEvents(false)}#fs(t,e,s){const i=.7;let n=i*(s/e)+1-i;if(n===1){return}const r=this.#ns(this.rotation);const o=(t,e)=>[r[0]*t+r[2]*e,r[1]*t+r[3]*e];const[a,h]=this.parentDimensions;const c=this.x;const l=this.y;const u=this.width;const f=this.height;const d=Ee.MIN_SIZE/a;const p=Ee.MIN_SIZE/h;n=Math.max(Math.min(n,1/u,1/f),d/u,p/f);const g=Ee._round(u*n);const m=Ee._round(f*n);if(g===u&&m===f){return}this.#We||=[c,l,u,f];const w=o(u/2,f/2);const b=Ee._round(c+w[0]);const A=Ee._round(l+w[1]);const y=o(g/2,m/2);this.x=b-y[0];this.y=A-y[1];this.width=g;this.height=m;this.setDims();this.fixAndSetPosition();this._onResizing()}#ds(){this.#a?.toggle(true);this.parent.togglePointerEvents(true);this.#hs()}pointerdown(t){const{isMac:e}=yt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}this.#He=true;if(this._isDraggable){this.#ps(t);return}this.#gs(t)}#gs(t){const{isMac:e}=yt.platform;if(t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e){this.parent.toggleSelected(this)}else{this.parent.setSelected(this)}}#ps(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=false;const i=new AbortController;const n=this._uiManager.combinedSignal(i);const r={capture:true,passive:false,signal:n};const o=t=>{i.abort();this.#Oe=null;this.#He=false;if(!this._uiManager.endDragSession()){this.#gs(t)}if(s){this._onStopDragging()}};if(e){this.#Ye=t.clientX;this.#Je=t.clientY;this.#Oe=t.pointerId;this.#$e=t.pointerType;window.addEventListener("pointermove",(t=>{if(!s){s=true;this._uiManager.toggleComment(this,true,false);this._onStartDragging()}const{clientX:e,clientY:i,pointerId:n}=t;if(n!==this.#Oe){Xt(t);return}const[r,o]=this.screenToPageTranslation(e-this.#Ye,i-this.#Je);this.#Ye=e;this.#Je=i;this._uiManager.dragSelectedEditors(r,o)}),r);window.addEventListener("touchmove",Xt,r);window.addEventListener("pointerdown",(t=>{if(t.pointerType===this.#$e){if(this.#Qe||t.isPrimary){o(t)}}Xt(t)}),r)}const a=t=>{if(!this.#Oe||this.#Oe===t.pointerId){o(t);return}Xt(t)};window.addEventListener("pointerup",a,{signal:n});window.addEventListener("blur",a,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){if(this.#qe){clearTimeout(this.#qe)}this.#qe=setTimeout((()=>{this.#qe=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;const[n,r]=this.pageDimensions;const[o,a]=this.pageTranslation;const h=t/i;const c=e/i;const l=this.x*n;const u=this.y*r;const f=this.width*n;const d=this.height*r;switch(s){case 0:return[l+h+o,r-u-c-d+a,l+h+f+o,r-u-c+a];case 90:return[l+c+o,r-u+h+a,l+c+d+o,r-u+h+f+a];case 180:return[l-h-f+o,r-u+c+a,l-h+o,r-u+c+d+a];case 270:return[l-c-d+o,r-u-h-f+a,l-c+o,r-u-h+a];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t;const o=n-s;const a=r-i;switch(this.rotation){case 0:return[s,e-r,o,a];case 90:return[s,e-i,a,o];case 180:return[n,e-i,o,a];case 270:return[n,e-r,a,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&Ee._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#h?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:n,richText:r},uid:o,pageIndex:a,creationDate:h,modificationDate:c}=this;return{id:o,pageIndex:a,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:h,modificationDate:s||c,popupRef:!n,color:e,opacity:i}}onceAdded(t){}isEmpty(){return false}enableEditMode(){if(this.isInEditMode()){return false}this.parent.setEditingState(false);this.#Ve=true;return true}disableEditMode(){if(!this.isInEditMode()){return false}this.parent.setEditingState(true);this.#Ve=false;return true}isInEditMode(){return this.#Ve}shouldGetKeyboardEvents(){return this.#Xe}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions();const{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}#ls(){if(this.#je||!this.div){return}this.#je=new AbortController;const t=this._uiManager.combinedSignal(this.#je);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t});this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#ls()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:true,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=false,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation;i.#Ie=t.accessibilityData;i._isCopy=t.isCopy||false;const[n,r]=i.pageDimensions;const[o,a,h,c]=i.getRectInCurrentCoords(t.rect,r);i.x=o/n;i.y=a/r;i.width=h/n;i.height=c/r;return i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){this.#je?.abort();this.#je=null;if(!this.isEmpty()){this.commit()}if(this.parent){this.parent.remove(this)}else{this._uiManager.removeEditor(this)}this.hideCommentPopup();if(this.#qe){clearTimeout(this.#qe);this.#qe=null}this.#es();this.removeEditToolbar();if(this.#Ke){for(const t of this.#Ke.values()){clearTimeout(t)}this.#Ke=null}this.parent=null;this.#Qe?.destroy();this.#Qe=null;this.#Ue?.remove();this.#Ue=null}get isResizable(){return false}makeResizable(){if(this.isResizable){this.#rs();this.#_e.classList.remove("hidden")}}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this;const[s,i,n,r]=this.getPDFRect();return[Ee._round(s+(n-s)*t),Ee._round(i+(r-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#h.commentPopupPositionInLayer}set commentPopupPosition(t){this.#h.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#h.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#h.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#h?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter"){return}this._uiManager.setSelected(this);this.#Le={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#_e.children;if(!this.#Re){this.#Re=Array.from(e);const t=this.#ms.bind(this);const s=this.#ws.bind(this);const i=this._uiManager._signal;for(const e of this.#Re){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton");e.addEventListener("keydown",t,{signal:i});e.addEventListener("blur",s,{signal:i});e.addEventListener("focus",this.#bs.bind(this,n),{signal:i});e.setAttribute("data-l10n-id",Ee._l10nResizer[n])}}const s=this.#Re[0];let i=0;for(const t of e){if(t===s){break}i++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#Re.length/4);if(n!==i){if(n<i){for(let t=0;t<i-n;t++){this.#_e.append(this.#_e.firstElementChild)}}else if(n>i){for(let t=0;t<n-i;t++){this.#_e.firstElementChild.before(this.#_e.lastElementChild)}}let t=0;for(const s of e){const e=this.#Re[t++];const i=e.getAttribute("data-resizer-name");s.setAttribute("data-l10n-id",Ee._l10nResizer[i])}}this.#As(0);this.#Xe=true;this.#_e.firstElementChild.focus({focusVisible:true});t.preventDefault();t.stopImmediatePropagation()}#ms(t){Ee._resizerKeyboardManager.exec(this,t)}#ws(t){if(this.#Xe&&t.relatedTarget?.parentNode!==this.#_e){this.#es()}}#bs(t){this.#ze=this.#Xe?t:""}#As(t){if(!this.#Re){return}for(const e of this.#Re){e.tabIndex=t}}_resizeWithKeyboard(t,e){if(!this.#Xe){return}this.#as(this.#ze,{deltaX:t,deltaY:e,fromKeyboard:true})}#es(){this.#Xe=false;this.#As(-1);this.#hs()}_stopResizingWithKeyboard(){this.#es();this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}this.isSelected=true;this.makeResizable();this.div?.classList.add("selectedEditor");if(!this._editToolbar){this.addEditToolbar().then((()=>{if(this.div?.classList.contains("selectedEditor")){this._editToolbar?.show()}}));return}this._editToolbar?.show();this.#a?.toggleAltTextBadge(false)}focus(){if(this.div&&!this.div.contains(document.activeElement)){setTimeout((()=>this.div?.focus({preventScroll:true})),0)}}unselect(){if(!this.isSelected){return}this.isSelected=false;this.#_e?.classList.add("hidden");this.div?.classList.remove("selectedEditor");if(this.div?.contains(document.activeElement)){this._uiManager.currentLayer.div.focus({preventScroll:true})}this._editToolbar?.hide();this.#a?.toggleAltTextBadge(true);this.hideCommentPopup()}hideCommentPopup(){if(this.hasComment){this._uiManager.toggleComment(null)}}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return false}enterInEditMode(){if(!this.canChangeContent){return}this.enableEditMode();this.div.focus()}dblclick(t){if(t.target.nodeName==="BUTTON"){return}this.enterInEditMode();this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#Ge}set isEditing(t){this.#Ge=t;if(!this.parent){return}if(t){this.parent.setSelected(this);this.parent.setActiveEditor(this)}else{this.parent.setActiveEditor(null)}}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return true}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=false){if(e){this.#Ke||=new Map;const{action:e}=t;let s=this.#Ke.get(e);if(s){clearTimeout(s)}s=setTimeout((()=>{this._reportTelemetry(t);this.#Ke.delete(e);if(this.#Ke.size===0){this.#Ke=null}}),Ee._telemetryTimeout);this.#Ke.set(e,s);return}t.type||=this.editorType;this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t);this._isVisible=t}enable(){if(this.div){this.div.tabIndex=0}this.#Fe=false}disable(){if(this.div){this.div.tabIndex=-1}this.#Fe=true}updateFakeAnnotationElement(t){if(!this.#Ue&&!this.deleted){this.#Ue=t.addFakeAnnotation(this);return}if(this.deleted){this.#Ue.remove();this.#Ue=null;return}if(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized){this.#Ue.updateEdited({rect:this.getPDFRect(),popup:this.comment})}}renderAnnotationElement(t){if(this.deleted){t.hide();return null}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 t=e;e=document.createElement("div");e.classList.add("annotationContent",this.editorType);t.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;if(e?.nodeName==="DIV"&&e.classList.contains("annotationContent")){e.remove()}}}class Pe extends Ee{constructor(t){super(t);this.annotationElementId=t.annotationElementId;this.deleted=true}serialize(){return this.serializeDeleted()}}const Ne=3285377520;const De=4294901760;const Ie=65535;class Re{constructor(t){this.h1=t?t&4294967295:Ne;this.h2=t?t&4294967295:Ne}update(t){let e,s;if(typeof t==="string"){e=new Uint8Array(t.length*2);s=0;for(let i=0,n=t.length;i<n;i++){const n=t.charCodeAt(i);if(n<=255){e[s++]=n}else{e[s++]=n>>>8;e[s++]=n&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;const n=s-i*4;const r=new Uint32Array(e.buffer,0,i);let o=0,a=0;let h=this.h1,c=this.h2;const l=3432918353,u=461845907;const f=l&Ie,d=u&Ie;for(let t=0;t<i;t++){if(t&1){o=r[t];o=o*l&De|o*f&Ie;o=o<<15|o>>>17;o=o*u&De|o*d&Ie;h^=o;h=h<<13|h>>>19;h=h*5+3864292196}else{a=r[t];a=a*l&De|a*f&Ie;a=a<<15|a>>>17;a=a*u&De|a*d&Ie;c^=a;c=c<<13|c>>>19;c=c*5+3864292196}}o=0;switch(n){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4];o=o*l&De|o*f&Ie;o=o<<15|o>>>17;o=o*u&De|o*d&Ie;if(i&1){h^=o}else{c^=o}}this.h1=h;this.h2=c}hexdigest(){let t=this.h1,e=this.h2;t^=e>>>1;t=t*3981806797&De|t*36045&Ie;e=e*4283543511&De|((e<<16|t>>>16)*2950163797&De)>>>16;t^=e>>>1;t=t*444984403&De|t*60499&Ie;e=e*3301882366&De|((e<<16|t>>>16)*3120437893&De)>>>16;t^=e>>>1;return(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Fe=Object.freeze({map:null,hash:"",transfer:undefined});class Oe{#ys=false;#vs=null;#xs=null;#ks=new Map;constructor(){this.onSetModified=null;this.onResetModified=null;this.onAnnotationEditor=null}getValue(t,e){const s=this.#ks.get(t);if(s===undefined){return e}return Object.assign(e,s)}getRawValue(t){return this.#ks.get(t)}remove(t){const e=this.#ks.get(t);if(e===undefined){return}if(e instanceof Ee){this.#xs.delete(e.annotationElementId)}this.#ks.delete(t);if(this.#ks.size===0){this.resetModified()}if(typeof this.onAnnotationEditor==="function"){for(const t of this.#ks.values()){if(t instanceof Ee){return}}this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#ks.get(t);let i=false;if(s!==undefined){for(const[t,n]of Object.entries(e)){if(s[t]!==n){i=true;s[t]=n}}}else{i=true;this.#ks.set(t,e)}if(i){this.#Ss()}if(e instanceof Ee){(this.#xs||=new Map).set(e.annotationElementId,e);if(typeof this.onAnnotationEditor==="function"){this.onAnnotationEditor(e.constructor._type)}}}has(t){return this.#ks.has(t)}get size(){return this.#ks.size}#Ss(){if(!this.#ys){this.#ys=true;if(typeof this.onSetModified==="function"){this.onSetModified()}}}resetModified(){if(this.#ys){this.#ys=false;if(typeof this.onResetModified==="function"){this.onResetModified()}}}get print(){return new $e(this)}get serializable(){if(this.#ks.size===0){return Fe}const t=new Map,e=new Re,s=[];const i=Object.create(null);let n=false;for(const[s,r]of this.#ks){const o=r instanceof Ee?r.serialize(false,i):r;if(o){t.set(s,o);e.update(`${s}:${JSON.stringify(o)}`);n||=!!o.bitmap}}if(n){for(const e of t.values()){if(e.bitmap){s.push(e.bitmap)}}}return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Fe}get editorStats(){let t=null;const e=new Map;let s=0;let i=0;for(const n of this.#ks.values()){if(!(n instanceof Ee)){if(n.popup){if(n.popup.deleted){i+=1}else{s+=1}}continue}if(n.isCommentDeleted){i+=1}else if(n.hasEditedComment){s+=1}const r=n.telemetryFinalData;if(!r){continue}const{type:o}=r;if(!e.has(o)){e.set(o,Object.getPrototypeOf(n).constructor)}t||=Object.create(null);const a=t[o]||=new Map;for(const[t,e]of Object.entries(r)){if(t==="type"){continue}let s=a.get(t);if(!s){s=new Map;a.set(t,s)}const i=s.get(e)??0;s.set(e,i+1)}}if(i>0||s>0){t||=Object.create(null);t.comments={deleted:i,edited:s}}if(!t){return null}for(const[s,i]of e){t[s]=i.computeTelemetryFinalData(t[s])}return t}resetModifiedIds(){this.#vs=null}updateEditor(t,e){const s=this.#xs?.get(t);if(s){s.updateFromAnnotationLayer(e);return true}return false}getEditor(t){return this.#xs?.get(t)||null}get modifiedIds(){if(this.#vs){return this.#vs}const t=[];if(this.#xs){for(const e of this.#xs.values()){if(!e.serialize()){continue}t.push(e.annotationElementId)}}return this.#vs={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#ks.entries()}}class $e extends Oe{#Ms;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable;const n=structuredClone(e,i?{transfer:i}:null);this.#Ms={map:n,hash:s,transfer:i}}get print(){st("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Ms}get modifiedIds(){return at(this,"modifiedIds",{ids:new Set,hash:""})}}class _e{#Cs=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t;this.nativeFontFaces=new Set;this.styleElement=null;this.loadingRequests=[];this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t);this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t);this._document.fonts.delete(t)}insertRule(t){if(!this.styleElement){this.styleElement=this._document.createElement("style");this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)}const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces){this._document.fonts.delete(t)}this.nativeFontFaces.clear();this.#Cs.clear();if(this.styleElement){this.styleElement.remove();this.styleElement=null}}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!t||this.#Cs.has(t.loadedName)){return}it(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set.");if(this.isFontLoadingAPISupported){const{loadedName:e,src:i,style:n}=t;const r=new FontFace(e,i,n);this.addNativeFontFace(r);try{await r.load();this.#Cs.add(e);s?.(t)}catch{et(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`);this.removeNativeFontFace(r)}return}st("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo){return}t.attached=true;if(t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(s){et(`Failed to load font '${e.family}': '${s}'.`);t.disableFontFace=true;throw s}}return}const e=t.createFontFaceRule();if(e){this.insertRule(e);if(this.isSyncFontLoadingSupported){return}await new Promise((e=>{const s=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,s)}))}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return at(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return at(this,"isSyncFontLoadingSupported",R||yt.platform.isFirefox)}_queueLoadingCallback(t){function e(){it(!i.done,"completeRequest() cannot be called twice.");i.done=true;while(s.length>0&&s[0].done){const t=s.shift();setTimeout(t.callback,0)}}const{loadingRequests:s}=this;const i={done:false,complete:e,callback:t};s.push(i);return i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA"+"FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA"+"ALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgA"+"AAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1"+"AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD"+"6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACM"+"AooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4D"+"IP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAA"+"AAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUA"+"AQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgAB"+"AAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABY"+"AAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAA"+"AC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAA"+"AAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQAC"+"AQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3"+"Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTj"+"FQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return at(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3)&255}function i(t,e,s,i){const n=t.substring(0,e);const r=t.substring(e+s);return n+i+r}let n,r;const o=this._document.createElement("canvas");o.width=1;o.height=1;const a=o.getContext("2d");let h=0;function c(t,e){if(++h>30){et("Load test font never loaded.");e();return}a.font="30px "+t;a.fillText(".",0,20);const s=a.getImageData(0,0,1,1);if(s.data[3]>0){e();return}setTimeout(c.bind(null,t,e))}const l=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;const f=976;u=i(u,f,l.length,l);const d=16;const p=1482184792;let g=s(u,d);for(n=0,r=l.length-3;n<r;n+=4){g=g-p+s(l,n)|0}if(n<l.length){g=g-p+s(l+"XXX",n)|0}u=i(u,d,4,wt(g));const m=`url(data:font/opentype;base64,${btoa(u)});`;const w=`@font-face {font-family:"${l}";src:${m}}`;this.insertRule(w);const b=this._document.createElement("div");b.style.visibility="hidden";b.style.width=b.style.height="10px";b.style.position="absolute";b.style.top=b.style.left="0px";for(const e of[t.loadedName,l]){const t=this._document.createElement("span");t.textContent="Hi";t.style.fontFamily=e;b.append(t)}this._document.body.append(b);c(l,(()=>{b.remove();e.complete()}))}}class Be{#Ts;constructor(t,e=null,s,i){this.compiledGlyphs=Object.create(null);this.#Ts=t;this._inspectFont=e;if(s){Object.assign(this,s)}if(i){this.charProcOperatorList=i}}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};if(this.cssFontInfo.italicAngle){e.style=`oblique ${this.cssFontInfo.italicAngle}deg`}t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}this._inspectFont?.(this);return t}createFontFaceRule(){if(!this.data||this.disableFontFace){return null}const t=`url(data:${this.mimetype};base64,${Dt(this.data)});`;let e;if(!this.cssFontInfo){e=`@font-face {font-family:"${this.loadedName}";src:${t}}`}else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;if(this.cssFontInfo.italicAngle){s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`}e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}this._inspectFont?.(this,t);return e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==undefined){return this.compiledGlyphs[e]}const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(t){et(`getPathGenerator - ignoring character: "${t}".`)}const n=pe(i);if(!this.fontExtraProperties){t.delete(s)}return this.compiledGlyphs[e]=n}get black(){return this.#Ts.black}get bold(){return this.#Ts.bold}get disableFontFace(){return this.#Ts.disableFontFace??false}set disableFontFace(t){at(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#Ts.fontExtraProperties??false}get isInvalidPDFjsFont(){return this.#Ts.isInvalidPDFjsFont}get isType3Font(){return this.#Ts.isType3Font}get italic(){return this.#Ts.italic}get missingFile(){return this.#Ts.missingFile}get remeasure(){return this.#Ts.remeasure}get vertical(){return this.#Ts.vertical}get ascent(){return this.#Ts.ascent}get defaultWidth(){return this.#Ts.defaultWidth}get descent(){return this.#Ts.descent}get bbox(){return this.#Ts.bbox}set bbox(t){at(this,"bbox",t)}get fontMatrix(){return this.#Ts.fontMatrix}get fallbackName(){return this.#Ts.fallbackName}get loadedName(){return this.#Ts.loadedName}get mimetype(){return this.#Ts.mimetype}get name(){return this.#Ts.name}get data(){return this.#Ts.data}clearData(){this.#Ts.clearData()}get cssFontInfo(){return this.#Ts.cssFontInfo}get systemFontInfo(){return this.#Ts.systemFontInfo}get defaultVMetrics(){return this.#Ts.defaultVMetrics}}class Le{#Es;#Ps;#Ns;static strings=["fontFamily","fontWeight","italicAngle"];static write(t){const e=new TextEncoder;const s={};let i=0;for(const n of Le.strings){const r=e.encode(t[n]);s[n]=r;i+=4+r.length}const n=new ArrayBuffer(i);const r=new Uint8Array(n);const o=new DataView(n);let a=0;for(const t of Le.strings){const e=s[t];const i=e.length;o.setUint32(a,i);r.set(e,a+4);a+=4+i}it(a===n.byteLength,"CssFontInfo.write: Buffer overflow");return n}constructor(t){this.#Es=t;this.#Ps=new DataView(this.#Es);this.#Ns=new TextDecoder}#Ds(t){it(t<Le.strings.length,"Invalid string index");let e=0;for(let s=0;s<t;s++){e+=this.#Ps.getUint32(e)+4}const s=this.#Ps.getUint32(e);return this.#Ns.decode(new Uint8Array(this.#Es,e+4,s))}get fontFamily(){return this.#Ds(0)}get fontWeight(){return this.#Ds(1)}get italicAngle(){return this.#Ds(2)}}class Ue{#Es;#Ps;#Ns;static strings=["css","loadedName","baseFontName","src"];static write(t){const e=new TextEncoder;const s={};let i=0;for(const n of Ue.strings){const r=e.encode(t[n]);s[n]=r;i+=4+r.length}i+=4;let n,r,o=1+i;if(t.style){n=e.encode(t.style.style);r=e.encode(t.style.weight);o+=4+n.length+4+r.length}const a=new ArrayBuffer(o);const h=new Uint8Array(a);const c=new DataView(a);let l=0;c.setUint8(l++,t.guessFallback?1:0);c.setUint32(l,0);l+=4;i=0;for(const t of Ue.strings){const e=s[t];const n=e.length;i+=4+n;c.setUint32(l,n);h.set(e,l+4);l+=4+n}c.setUint32(l-i-4,i);if(t.style){c.setUint32(l,n.length);h.set(n,l+4);l+=4+n.length;c.setUint32(l,r.length);h.set(r,l+4);l+=4+r.length}it(l<=a.byteLength,"SubstitionInfo.write: Buffer overflow");return a.transferToFixedLength(l)}constructor(t){this.#Es=t;this.#Ps=new DataView(this.#Es);this.#Ns=new TextDecoder}get guessFallback(){return this.#Ps.getUint8(0)!==0}#Ds(t){it(t<Ue.strings.length,"Invalid string index");let e=5;for(let s=0;s<t;s++){e+=this.#Ps.getUint32(e)+4}const s=this.#Ps.getUint32(e);return this.#Ns.decode(new Uint8Array(this.#Es,e+4,s))}get css(){return this.#Ds(0)}get loadedName(){return this.#Ds(1)}get baseFontName(){return this.#Ds(2)}get src(){return this.#Ds(3)}get style(){let t=1;t+=4+this.#Ps.getUint32(t);const e=this.#Ps.getUint32(t);const s=this.#Ns.decode(new Uint8Array(this.#Es,t+4,e));t+=4+e;const i=this.#Ps.getUint32(t);const n=this.#Ns.decode(new Uint8Array(this.#Es,t+4,i));return{style:s,weight:n}}}class je{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static#Is=Math.ceil(this.bools.length*2/8);static#Rs=this.#Is+this.numbers.length*8;static#Fs=this.#Rs+1+2*4;static#Os=this.#Fs+1+8*6;static#$s=this.#Os+1+2*3;#Es;#Ns;#Ps;constructor({data:t,extra:e}){this.#Es=t;this.#Ns=new TextDecoder;this.#Ps=new DataView(this.#Es);if(e){Object.assign(this,e)}}#_s(t){it(t<je.bools.length,"Invalid boolean index");const e=Math.floor(t/4);const s=t*2%8;const i=this.#Ps.getUint8(e)>>s&3;return i===0?undefined:i===2}get black(){return this.#_s(0)}get bold(){return this.#_s(1)}get disableFontFace(){return this.#_s(2)}get fontExtraProperties(){return this.#_s(3)}get isInvalidPDFjsFont(){return this.#_s(4)}get isType3Font(){return this.#_s(5)}get italic(){return this.#_s(6)}get missingFile(){return this.#_s(7)}get remeasure(){return this.#_s(8)}get vertical(){return this.#_s(9)}#Bs(t){it(t<je.numbers.length,"Invalid number index");return this.#Ps.getFloat64(je.#Is+t*8)}get ascent(){return this.#Bs(0)}get defaultWidth(){return this.#Bs(1)}get descent(){return this.#Bs(2)}get bbox(){let t=je.#Rs;const e=this.#Ps.getUint8(t);if(e===0){return undefined}t+=1;const s=[];for(let e=0;e<4;e++){s.push(this.#Ps.getInt16(t,true));t+=2}return s}get fontMatrix(){let t=je.#Fs;const e=this.#Ps.getUint8(t);if(e===0){return undefined}t+=1;const s=[];for(let e=0;e<6;e++){s.push(this.#Ps.getFloat64(t,true));t+=8}return s}get defaultVMetrics(){let t=je.#Os;const e=this.#Ps.getUint8(t);if(e===0){return undefined}t+=1;const s=[];for(let e=0;e<3;e++){s.push(this.#Ps.getInt16(t,true));t+=2}return s}#Ds(t){it(t<je.strings.length,"Invalid string index");let e=je.#$s+4;for(let s=0;s<t;s++){e+=this.#Ps.getUint32(e)+4}const s=this.#Ps.getUint32(e);const i=new Uint8Array(s);i.set(new Uint8Array(this.#Es,e+4,s));return this.#Ns.decode(i)}get fallbackName(){return this.#Ds(0)}get loadedName(){return this.#Ds(1)}get mimetype(){return this.#Ds(2)}get name(){return this.#Ds(3)}get data(){let t=je.#$s;const e=this.#Ps.getUint32(t);t+=4+e;const s=this.#Ps.getUint32(t);t+=4+s;const i=this.#Ps.getUint32(t);t+=4+i;const n=this.#Ps.getUint32(t);if(n===0){return undefined}return new Uint8Array(this.#Es,t+4,n)}clearData(){let t=je.#$s;const e=this.#Ps.getUint32(t);t+=4+e;const s=this.#Ps.getUint32(t);t+=4+s;const i=this.#Ps.getUint32(t);t+=4+i;const n=this.#Ps.getUint32(t);const r=new Uint8Array(this.#Es,t+4,n);r.fill(0);this.#Ps.setUint32(t,0)}get cssFontInfo(){let t=je.#$s;const e=this.#Ps.getUint32(t);t+=4+e;const s=this.#Ps.getUint32(t);t+=4+s;const i=this.#Ps.getUint32(t);if(i===0){return null}const n=new Uint8Array(i);n.set(new Uint8Array(this.#Es,t+4,i));return new Le(n.buffer)}get systemFontInfo(){let t=je.#$s;const e=this.#Ps.getUint32(t);t+=4+e;const s=this.#Ps.getUint32(t);if(s===0){return null}const i=new Uint8Array(s);i.set(new Uint8Array(this.#Es,t+4,s));return new Ue(i.buffer)}static write(t){const e=t.systemFontInfo?Ue.write(t.systemFontInfo):null;const s=t.cssFontInfo?Le.write(t.cssFontInfo):null;const i=new TextEncoder;const n={};let r=0;for(const e of je.strings){n[e]=i.encode(t[e]);r+=4+n[e].length}const o=je.#$s+4+r+4+(e?e.byteLength:0)+4+(s?s.byteLength:0)+4+(t.data?t.data.length:0);const a=new ArrayBuffer(o);const h=new Uint8Array(a);const c=new DataView(a);let l=0;const u=je.bools.length;let f=0,d=0;for(let e=0;e<u;e++){const s=t[je.bools[e]];const i=s===undefined?0:s?2:1;f|=i<<d;d+=2;if(d===8||e===u-1){c.setUint8(l++,f);f=0;d=0}}it(l===je.#Is,"FontInfo.write: Boolean properties offset mismatch");for(const e of je.numbers){c.setFloat64(l,t[e]);l+=8}it(l===je.#Rs,"FontInfo.write: Number properties offset mismatch");if(t.bbox){c.setUint8(l++,4);for(const e of t.bbox){c.setInt16(l,e,true);l+=2}}else{c.setUint8(l++,0);l+=2*4}it(l===je.#Fs,"FontInfo.write: BBox properties offset mismatch");if(t.fontMatrix){c.setUint8(l++,6);for(const e of t.fontMatrix){c.setFloat64(l,e,true);l+=8}}else{c.setUint8(l++,0);l+=8*6}it(l===je.#Os,"FontInfo.write: FontMatrix properties offset mismatch");if(t.defaultVMetrics){c.setUint8(l++,1);for(const e of t.defaultVMetrics){c.setInt16(l,e,true);l+=2}}else{c.setUint8(l++,0);l+=3*2}it(l===je.#$s,"FontInfo.write: DefaultVMetrics properties offset mismatch");c.setUint32(je.#$s,0);l+=4;for(const t of je.strings){const e=n[t];const s=e.length;c.setUint32(l,s);h.set(e,l+4);l+=4+s}c.setUint32(je.#$s,l-je.#$s-4);if(!e){c.setUint32(l,0);l+=4}else{const t=e.byteLength;c.setUint32(l,t);it(l+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo");h.set(new Uint8Array(e),l+4);l+=4+t}if(!s){c.setUint32(l,0);l+=4}else{const t=s.byteLength;c.setUint32(l,t);it(l+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo");h.set(new Uint8Array(s),l+4);l+=4+t}if(t.data===undefined){c.setUint32(l,0);l+=4}else{c.setUint32(l,t.data.length);h.set(t.data,l+4);l+=4+t.data.length}it(l<=a.byteLength,"FontInfo.write: Buffer overflow");return a.transferToFixedLength(l)}}class ze{static#Ls=0;static#Us=1;static#js=2;static#zs=3;static#Hs=4;static#Ws=8;static#Gs=12;static#Vs=16;constructor(t){this.buffer=t;this.view=new DataView(t);this.data=new Uint8Array(t)}static write(t){let e,s=null,i=[],n=[],r=[],o=[],a=null,h=null;switch(t[0]){case"RadialAxial":e=t[1]==="axial"?1:2;s=t[2];r=t[3];if(e===1){i.push(...t[4],...t[5])}else{i.push(t[4][0],t[4][1],t[6],t[5][0],t[5][1],t[7])}break;case"Mesh":e=3;a=t[1];i=t[2];n=t[3];o=t[4]||[];s=t[6];h=t[7];break;default:throw new Error(`Unsupported pattern type: ${t[0]}`)}const c=Math.floor(i.length/2);const l=Math.floor(n.length/3);const u=r.length;const f=o.length;let d=0;for(const t of o){d+=1;d=Math.ceil(d/4)*4;d+=4+t.coords.length*4;d+=4+t.colors.length*4;if(t.verticesPerRow!==undefined){d+=4}}const p=20+c*8+l*3+u*8+(s?16:0)+(h?3:0)+d;const g=new ArrayBuffer(p);const m=new DataView(g);const w=new Uint8Array(g);m.setUint8(ze.#Ls,e);m.setUint8(ze.#Us,s?1:0);m.setUint8(ze.#js,h?1:0);m.setUint8(ze.#zs,a);m.setUint32(ze.#Hs,c,true);m.setUint32(ze.#Ws,l,true);m.setUint32(ze.#Gs,u,true);m.setUint32(ze.#Vs,f,true);let b=20;const A=new Float32Array(g,b,c*2);A.set(i);b+=c*8;w.set(n,b);b+=l*3;for(const[t,e]of r){m.setFloat32(b,t,true);b+=4;m.setUint32(b,parseInt(e.slice(1),16),true);b+=4}if(s){for(const t of s){m.setFloat32(b,t,true);b+=4}}if(h){w.set(h,b);b+=3}for(let t=0;t<o.length;t++){const e=o[t];m.setUint8(b,e.type);b+=1;b=Math.ceil(b/4)*4;m.setUint32(b,e.coords.length,true);b+=4;const s=new Int32Array(g,b,e.coords.length);s.set(e.coords);b+=e.coords.length*4;m.setUint32(b,e.colors.length,true);b+=4;const i=new Int32Array(g,b,e.colors.length);i.set(e.colors);b+=e.colors.length*4;if(e.verticesPerRow!==undefined){m.setUint32(b,e.verticesPerRow,true);b+=4}}return g}getIR(){const t=this.view;const e=this.data[ze.#Ls];const s=!!this.data[ze.#Us];const i=!!this.data[ze.#js];const n=t.getUint32(ze.#Hs,true);const r=t.getUint32(ze.#Ws,true);const o=t.getUint32(ze.#Gs,true);const a=t.getUint32(ze.#Vs,true);let h=20;const c=new Float32Array(this.buffer,h,n*2);h+=n*8;const l=new Uint8Array(this.buffer,h,r*3);h+=r*3;const u=[];for(let e=0;e<o;++e){const e=t.getFloat32(h,true);h+=4;const s=t.getUint32(h,true);h+=4;u.push([e,`#${s.toString(16).padStart(6,"0")}`])}let f=null;if(s){f=[];for(let e=0;e<4;++e){f.push(t.getFloat32(h,true));h+=4}}let d=null;if(i){d=new Uint8Array(this.buffer,h,3);h+=3}const p=[];for(let e=0;e<a;++e){const e=t.getUint8(h);h+=1;h=Math.ceil(h/4)*4;const s=t.getUint32(h,true);h+=4;const i=new Int32Array(this.buffer,h,s);h+=s*4;const n=t.getUint32(h,true);h+=4;const r=new Int32Array(this.buffer,h,n);h+=n*4;const o={type:e,coords:i,colors:r};if(e===z.LATTICE){o.verticesPerRow=t.getUint32(h,true);h+=4}p.push(o)}if(e===1){return["RadialAxial","axial",f,u,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null]}if(e===2){return["RadialAxial","radial",f,u,[c[0],c[1]],[c[3],c[4]],c[2],c[5]]}if(e===3){const t=this.data[ze.#zs];let e=null;if(c.length>0){let t=c[0],s=c[0];let i=c[1],n=c[1];for(let e=0;e<c.length;e+=2){const r=c[e],o=c[e+1];t=t>r?r:t;i=i>o?o:i;s=s<r?r:s;n=n<o?o:n}e=[t,i,s,n]}return["Mesh",t,c,l,p,e,f,d]}throw new Error(`Unsupported pattern kind: ${e}`)}}function He(t){if(t instanceof URL){return t.href}if(typeof t==="string"){if(R){return t}const e=URL.parse(t,window.location);if(e){return e.href}}throw new Error("Invalid PDF url data: "+"either string or URL-object is expected in the url property.")}function We(t){if(R&&typeof Buffer!=="undefined"&&t instanceof Buffer){throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.")}if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength){return t}if(typeof t==="string"){return mt(t)}if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t==="object"&&!isNaN(t?.length)){return new Uint8Array(t)}throw new Error("Invalid PDF binary data: either TypedArray, "+"string, or array-like object is expected in the data property.")}function Ge(t){if(typeof t!=="string"){return null}if(t.endsWith("/")){return t}throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const Ve=t=>typeof t==="object"&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0;const Xe=t=>typeof t==="object"&&typeof t?.name==="string";const qe=Pt.bind(null,Ve,Xe);class Ye{#Xs=new Map;#qs=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#qs.then((()=>{for(const[t]of this.#Xs){t.call(this,s)}}))}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){const{signal:n}=s;if(n.aborted){et("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r);n.addEventListener("abort",r)}this.#Xs.set(e,i)}removeEventListener(t,e){const s=this.#Xs.get(e);s?.();this.#Xs.delete(e)}terminate(){for(const[,t]of this.#Xs){t?.()}this.#Xs.clear()}}const Je={DATA:1,ERROR:2};const Ke={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Qe(){}function Ze(t){if(t instanceof pt||t instanceof ut||t instanceof ct||t instanceof ft||t instanceof lt){return t}if(!(t instanceof Error||typeof t==="object"&&t!==null)){st('wrapReason: Expected "reason" to be a (possibly cloned) Error.')}switch(t.name){case"AbortException":return new pt(t.message);case"InvalidPDFException":return new ut(t.message);case"PasswordException":return new ct(t.message,t.code);case"ResponseException":return new ft(t.message,t.status,t.missing);case"UnknownErrorException":return new lt(t.message,t.details)}return new lt(t.message,t.toString())}class ts{#Ys=new AbortController;constructor(t,e,s){this.sourceName=t;this.targetName=e;this.comObj=s;this.callbackId=1;this.streamId=1;this.streamSinks=Object.create(null);this.streamControllers=Object.create(null);this.callbackCapabilities=Object.create(null);this.actionHandler=Object.create(null);s.addEventListener("message",this.#Js.bind(this),{signal:this.#Ys.signal})}#Js({data:t}){if(t.targetName!==this.sourceName){return}if(t.stream){this.#Ks(t);return}if(t.callback){const e=t.callbackId;const s=this.callbackCapabilities[e];if(!s){throw new Error(`Cannot resolve callback ${e}`)}delete this.callbackCapabilities[e];if(t.callback===Je.DATA){s.resolve(t.data)}else if(t.callback===Je.ERROR){s.reject(Ze(t.reason))}else{throw new Error("Unexpected callback case")}return}const e=this.actionHandler[t.action];if(!e){throw new Error(`Unknown action from worker: ${t.action}`)}if(t.callbackId){const s=this.sourceName,i=t.sourceName,n=this.comObj;Promise.try(e,t.data).then((function(e){n.postMessage({sourceName:s,targetName:i,callback:Je.DATA,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:s,targetName:i,callback:Je.ERROR,callbackId:t.callbackId,reason:Ze(e)})}));return}if(t.streamId){this.#Qs(t);return}e(t.data)}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++;const n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,o=this.targetName,a=this.comObj;return new ReadableStream({start:s=>{const h=Promise.withResolvers();this.streamControllers[n]={controller:s,startCall:h,pullCall:null,cancelCall:null,isClosed:false};a.postMessage({sourceName:r,targetName:o,action:t,streamId:n,data:e,desiredSize:s.desiredSize},i);return h.promise},pull:t=>{const e=Promise.withResolvers();this.streamControllers[n].pullCall=e;a.postMessage({sourceName:r,targetName:o,stream:Ke.PULL,streamId:n,desiredSize:t.desiredSize});return e.promise},cancel:t=>{it(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();this.streamControllers[n].cancelCall=e;this.streamControllers[n].isClosed=true;a.postMessage({sourceName:r,targetName:o,stream:Ke.CANCEL,streamId:n,reason:Ze(t)});return e.promise}},s)}#Qs(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj;const r=this,o=this.actionHandler[t.action];const a={enqueue(t,r=1,o){if(this.isCancelled){return}const a=this.desiredSize;this.desiredSize-=r;if(a>0&&this.desiredSize<=0){this.sinkCapability=Promise.withResolvers();this.ready=this.sinkCapability.promise}n.postMessage({sourceName:s,targetName:i,stream:Ke.ENQUEUE,streamId:e,chunk:t},o)},close(){if(this.isCancelled){return}this.isCancelled=true;n.postMessage({sourceName:s,targetName:i,stream:Ke.CLOSE,streamId:e});delete r.streamSinks[e]},error(t){it(t instanceof Error,"error must have a valid reason");if(this.isCancelled){return}this.isCancelled=true;n.postMessage({sourceName:s,targetName:i,stream:Ke.ERROR,streamId:e,reason:Ze(t)})},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:false,desiredSize:t.desiredSize,ready:null};a.sinkCapability.resolve();a.ready=a.sinkCapability.promise;this.streamSinks[e]=a;Promise.try(o,t.data,a).then((function(){n.postMessage({sourceName:s,targetName:i,stream:Ke.START_COMPLETE,streamId:e,success:true})}),(function(t){n.postMessage({sourceName:s,targetName:i,stream:Ke.START_COMPLETE,streamId:e,reason:Ze(t)})}))}#Ks(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj;const r=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Ke.START_COMPLETE:if(t.success){r.startCall.resolve()}else{r.startCall.reject(Ze(t.reason))}break;case Ke.PULL_COMPLETE:if(t.success){r.pullCall.resolve()}else{r.pullCall.reject(Ze(t.reason))}break;case Ke.PULL:if(!o){n.postMessage({sourceName:s,targetName:i,stream:Ke.PULL_COMPLETE,streamId:e,success:true});break}if(o.desiredSize<=0&&t.desiredSize>0){o.sinkCapability.resolve()}o.desiredSize=t.desiredSize;Promise.try(o.onPull||Qe).then((function(){n.postMessage({sourceName:s,targetName:i,stream:Ke.PULL_COMPLETE,streamId:e,success:true})}),(function(t){n.postMessage({sourceName:s,targetName:i,stream:Ke.PULL_COMPLETE,streamId:e,reason:Ze(t)})}));break;case Ke.ENQUEUE:it(r,"enqueue should have stream controller");if(r.isClosed){break}r.controller.enqueue(t.chunk);break;case Ke.CLOSE:it(r,"close should have stream controller");if(r.isClosed){break}r.isClosed=true;r.controller.close();this.#Zs(r,e);break;case Ke.ERROR:it(r,"error should have stream controller");r.controller.error(Ze(t.reason));this.#Zs(r,e);break;case Ke.CANCEL_COMPLETE:if(t.success){r.cancelCall.resolve()}else{r.cancelCall.reject(Ze(t.reason))}this.#Zs(r,e);break;case Ke.CANCEL:if(!o){break}const a=Ze(t.reason);Promise.try(o.onCancel||Qe,a).then((function(){n.postMessage({sourceName:s,targetName:i,stream:Ke.CANCEL_COMPLETE,streamId:e,success:true})}),(function(t){n.postMessage({sourceName:s,targetName:i,stream:Ke.CANCEL_COMPLETE,streamId:e,reason:Ze(t)})}));o.sinkCapability.reject(a);o.isCancelled=true;delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#Zs(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]);delete this.streamControllers[e]}destroy(){this.#Ys?.abort();this.#Ys=null}}class es{#ti=false;constructor({enableHWA:t=false}){this.#ti=t}create(t,e){if(t<=0||e<=0){throw new Error("Invalid canvas size")}const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#ti})}}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){st("Abstract method `_createCanvas` called.")}}class ss extends es{constructor({ownerDocument:t=globalThis.document,enableHWA:e=false}){super({enableHWA:e});this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");s.width=t;s.height=e;return s}}class is{constructor({baseUrl:t=null,isCompressed:e=true}){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((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}async _fetch(t){st("Abstract method `_fetch` called.")}}class ns extends is{async _fetch(t){const e=await _t(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):mt(e)}}class rs{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=false){}}class os extends rs{#ei;#si;#ii;#ni;#ri;#oi;#M=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super();this.#ni=t;this.#ri=e}get#T(){return this.#si||=new Map}get#ai(){return this.#oi||=new Map}get#hi(){if(!this.#ii){const t=this.#ri.createElement("div");const{style:e}=t;e.visibility="hidden";e.contain="strict";e.width=e.height=0;e.position="absolute";e.top=e.left=0;e.zIndex=-1;const s=this.#ri.createElementNS(Ot,"svg");s.setAttribute("width",0);s.setAttribute("height",0);this.#ii=this.#ri.createElementNS(Ot,"defs");t.append(s);s.append(this.#ii);this.#ri.body.append(t)}return this.#ii}#ci(t){if(t.length===1){const e=t[0];const s=new Array(256);for(let t=0;t<256;t++){s[t]=e[t]/255}const i=s.join(",");return[i,i,i]}const[e,s,i]=t;const n=new Array(256);const r=new Array(256);const o=new Array(256);for(let t=0;t<256;t++){n[t]=e[t]/255;r[t]=s[t]/255;o[t]=i[t]/255}return[n.join(","),r.join(","),o.join(",")]}#li(t){if(this.#ei===undefined){this.#ei="";const t=this.#ri.URL;if(t!==this.#ri.baseURI){if(Ut(t)){et('#createUrl: ignore "data:"-URL for performance reasons.')}else{this.#ei=ot(t,"")}}}return`url(${this.#ei}#${t})`}addFilter(t){if(!t){return"none"}let e=this.#T.get(t);if(e){return e}const[s,i,n]=this.#ci(t);const r=t.length===1?s:`${s}${i}${n}`;e=this.#T.get(r);if(e){this.#T.set(t,e);return e}const o=`g_${this.#ni}_transfer_map_${this.#M++}`;const a=this.#li(o);this.#T.set(t,a);this.#T.set(r,a);const h=this.#ui(o);this.#fi(s,i,n,h);return a}addHCMFilter(t,e){const s=`${t}-${e}`;const i="base";let n=this.#ai.get(i);if(n?.key===s){return n.url}if(n){n.filter?.remove();n.key=s;n.url="none";n.filter=null}else{n={key:s,url:"none",filter:null};this.#ai.set(i,n)}if(!t||!e){return n.url}const r=this.#di(t);t=xt.makeHexColor(...r);const o=this.#di(e);e=xt.makeHexColor(...o);this.#hi.style.color="";if(t==="#000000"&&e==="#ffffff"||t===e){return n.url}const a=new Array(256);for(let t=0;t<=255;t++){const e=t/255;a[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const h=a.join(",");const c=`g_${this.#ni}_hcm_filter`;const l=n.filter=this.#ui(c);this.#fi(h,h,h,l);this.#pi(l);const u=(t,e)=>{const s=r[t]/255;const i=o[t]/255;const n=new Array(e+1);for(let t=0;t<=e;t++){n[t]=s+t/e*(i-s)}return n.join(",")};this.#fi(u(0,5),u(1,5),u(2,5),l);n.url=this.#li(c);return n.url}addAlphaFilter(t){let e=this.#T.get(t);if(e){return e}const[s]=this.#ci([t]);const i=`alpha_${s}`;e=this.#T.get(i);if(e){this.#T.set(t,e);return e}const n=`g_${this.#ni}_alpha_map_${this.#M++}`;const r=this.#li(n);this.#T.set(t,r);this.#T.set(i,r);const o=this.#ui(n);this.#gi(s,o);return r}addLuminosityFilter(t){let e=this.#T.get(t||"luminosity");if(e){return e}let s,i;if(t){[s]=this.#ci([t]);i=`luminosity_${s}`}else{i="luminosity"}e=this.#T.get(i);if(e){this.#T.set(t,e);return e}const n=`g_${this.#ni}_luminosity_map_${this.#M++}`;const r=this.#li(n);this.#T.set(t,r);this.#T.set(i,r);const o=this.#ui(n);this.#mi(o);if(t){this.#gi(s,o)}return r}addHighlightHCMFilter(t,e,s,i,n){const r=`${e}-${s}-${i}-${n}`;let o=this.#ai.get(t);if(o?.key===r){return o.url}if(o){o.filter?.remove();o.key=r;o.url="none";o.filter=null}else{o={key:r,url:"none",filter:null};this.#ai.set(t,o)}if(!e||!s){return o.url}const[a,h]=[e,s].map(this.#di.bind(this));let c=Math.round(.2126*a[0]+.7152*a[1]+.0722*a[2]);let l=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]);let[u,f]=[i,n].map(this.#di.bind(this));if(l<c){[c,l,u,f]=[l,c,f,u]}this.#hi.style.color="";const d=(t,e,s)=>{const i=new Array(256);const n=(l-c)/s;const r=t/255;const o=(e-t)/(255*s);let a=0;for(let t=0;t<=s;t++){const e=Math.round(c+t*n);const s=r+t*o;for(let t=a;t<=e;t++){i[t]=s}a=e+1}for(let t=a;t<256;t++){i[t]=i[a-1]}return i.join(",")};const p=`g_${this.#ni}_hcm_${t}_filter`;const g=o.filter=this.#ui(p);this.#pi(g);this.#fi(d(u[0],f[0],5),d(u[1],f[1],5),d(u[2],f[2],5),g);o.url=this.#li(p);return o.url}destroy(t=false){if(t&&this.#oi?.size){return}this.#ii?.parentNode.parentNode.remove();this.#ii=null;this.#si?.clear();this.#si=null;this.#oi?.clear();this.#oi=null;this.#M=0}#mi(t){const e=this.#ri.createElementNS(Ot,"feColorMatrix");e.setAttribute("type","matrix");e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0");t.append(e)}#pi(t){const e=this.#ri.createElementNS(Ot,"feColorMatrix");e.setAttribute("type","matrix");e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0");t.append(e)}#ui(t){const e=this.#ri.createElementNS(Ot,"filter");e.setAttribute("color-interpolation-filters","sRGB");e.setAttribute("id",t);this.#hi.append(e);return e}#wi(t,e,s){const i=this.#ri.createElementNS(Ot,e);i.setAttribute("type","discrete");i.setAttribute("tableValues",s);t.append(i)}#fi(t,e,s,i){const n=this.#ri.createElementNS(Ot,"feComponentTransfer");i.append(n);this.#wi(n,"feFuncR",t);this.#wi(n,"feFuncG",e);this.#wi(n,"feFuncB",s)}#gi(t,e){const s=this.#ri.createElementNS(Ot,"feComponentTransfer");e.append(s);this.#wi(s,"feFuncA",t)}#di(t){this.#hi.style.color=t;return Kt(getComputedStyle(this.#hi).getPropertyValue("color"))}}class as{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((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}async _fetch(t){st("Abstract method `_fetch` called.")}}class hs extends as{async _fetch(t){const e=await _t(t,"arraybuffer");return new Uint8Array(e)}}class cs{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((t=>{throw new Error(`Unable to load wasm data at: ${e}`)}))}async _fetch(t){st("Abstract method `_fetch` called.")}}class ls extends cs{async _fetch(t){const e=await _t(t,"arraybuffer");return new Uint8Array(e)}}if(R){et("Please use the `legacy` build in Node.js environments.")}async function us(t){const e=process.getBuiltinModule("fs");const s=await e.promises.readFile(t);return new Uint8Array(s)}class fs extends rs{}class ds extends es{_createCanvas(t,e){const s=process.getBuiltinModule("module").createRequire(import.meta.url);const i=s("@napi-rs/canvas");return i.createCanvas(t,e)}}class ps extends is{async _fetch(t){return us(t)}}class gs extends as{async _fetch(t){return us(t)}}class ms extends cs{async _fetch(t){return us(t)}}const ws="__forcedDependency";const{floor:bs,ceil:As}=Math;function ys(t,e,s,i,n,r){t[e*4+0]=Math.min(t[e*4+0],s);t[e*4+1]=Math.min(t[e*4+1],i);t[e*4+2]=Math.max(t[e*4+2],n);t[e*4+3]=Math.max(t[e*4+3],r)}const vs=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class xs{#bi;#Ai;constructor(t,e){this.#bi=t;this.#Ai=e}get length(){return this.#bi.length}isEmpty(t){return this.#bi[t]===vs}minX(t){return this.#Ai[t*4+0]/256}minY(t){return this.#Ai[t*4+1]/256}maxX(t){return(this.#Ai[t*4+2]+1)/256}maxY(t){return(this.#Ai[t*4+3]+1)/256}}const ks=(t,e)=>{if(!t){return undefined}let s=t.get(e);if(!s){s={dependencies:new Set,isRenderingOperation:false};t.set(e,s)}return s};class Ss{#yi={__proto__:null};#vi={__proto__:null,transform:[],moveText:[],sameLineText:[],[ws]:[]};#xi=new Map;#ki=[];#Si=[];#Mi=[[1,0,0,1,0,0]];#Ci=[-Infinity,-Infinity,Infinity,Infinity];#Ti=new Float64Array([Infinity,Infinity,-Infinity,-Infinity]);#Ei=-1;#Pi=new Set;#Ni=new Map;#Di=new Map;#Ii;#Ri;#Fi;#bi;#Oi;constructor(t,e,s=false){this.#Ii=t.width;this.#Ri=t.height;this.#$i(e);if(s){this.#Oi=new Map}}growOperationsCount(t){if(t>=this.#bi.length){this.#$i(t,this.#bi)}}#$i(t,e){const s=new ArrayBuffer(t*4);this.#Fi=new Uint8ClampedArray(s);this.#bi=new Uint32Array(s);if(e&&e.length>0){this.#bi.set(e);this.#bi.fill(vs,e.length)}else{this.#bi.fill(vs)}}save(t){this.#yi={__proto__:this.#yi};this.#vi={__proto__:this.#vi,transform:{__proto__:this.#vi.transform},moveText:{__proto__:this.#vi.moveText},sameLineText:{__proto__:this.#vi.sameLineText},[ws]:{__proto__:this.#vi[ws]}};this.#Ci={__proto__:this.#Ci};this.#ki.push(t);return this}restore(t){const e=Object.getPrototypeOf(this.#yi);if(e===null){return this}this.#yi=e;this.#vi=Object.getPrototypeOf(this.#vi);this.#Ci=Object.getPrototypeOf(this.#Ci);const s=this.#ki.pop();if(s!==undefined){ks(this.#Oi,t)?.dependencies.add(s);this.#bi[t]=this.#bi[s]}return this}recordOpenMarker(t){this.#ki.push(t);return this}getOpenMarker(){if(this.#ki.length===0){return null}return this.#ki.at(-1)}recordCloseMarker(t){const e=this.#ki.pop();if(e!==undefined){ks(this.#Oi,t)?.dependencies.add(e);this.#bi[t]=this.#bi[e]}return this}beginMarkedContent(t){this.#Si.push(t);return this}endMarkedContent(t){const e=this.#Si.pop();if(e!==undefined){ks(this.#Oi,t)?.dependencies.add(e);this.#bi[t]=this.#bi[e]}return this}pushBaseTransform(t){this.#Mi.push(xt.multiplyByDOMMatrix(this.#Mi.at(-1),t.getTransform()));return this}popBaseTransform(){if(this.#Mi.length>1){this.#Mi.pop()}return this}recordSimpleData(t,e){this.#yi[t]=e;return this}recordIncrementalData(t,e){this.#vi[t].push(e);return this}resetIncrementalData(t,e){this.#vi[t].length=0;return this}recordNamedData(t,e){this.#xi.set(t,e);return this}recordSimpleDataFromNamed(t,e,s){this.#yi[t]=this.#xi.get(e)??s}recordFutureForcedDependency(t,e){this.recordIncrementalData(ws,e);return this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t){if(e in this.#yi){this.recordFutureForcedDependency(e,this.#yi[e])}}return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#Pi){this.recordFutureForcedDependency(ws,t)}return this}resetBBox(t){if(this.#Ei!==t){this.#Ei=t;this.#Ti[0]=Infinity;this.#Ti[1]=Infinity;this.#Ti[2]=-Infinity;this.#Ti[3]=-Infinity}return this}recordClipBox(t,e,s,i,n,r){const o=xt.multiplyByDOMMatrix(this.#Mi.at(-1),e.getTransform());const a=[Infinity,Infinity,-Infinity,-Infinity];xt.axialAlignedBoundingBox([s,n,i,r],o,a);const h=xt.intersect(this.#Ci,a);if(h){this.#Ci[0]=h[0];this.#Ci[1]=h[1];this.#Ci[2]=h[2];this.#Ci[3]=h[3]}else{this.#Ci[0]=this.#Ci[1]=Infinity;this.#Ci[2]=this.#Ci[3]=-Infinity}return this}recordBBox(t,e,s,i,n,r){const o=this.#Ci;if(o[0]===Infinity){return this}const a=xt.multiplyByDOMMatrix(this.#Mi.at(-1),e.getTransform());if(o[0]===-Infinity){xt.axialAlignedBoundingBox([s,n,i,r],a,this.#Ti);return this}const h=[Infinity,Infinity,-Infinity,-Infinity];xt.axialAlignedBoundingBox([s,n,i,r],a,h);this.#Ti[0]=Math.min(this.#Ti[0],Math.max(h[0],o[0]));this.#Ti[1]=Math.min(this.#Ti[1],Math.max(h[1],o[1]));this.#Ti[2]=Math.max(this.#Ti[2],Math.min(h[2],o[2]));this.#Ti[3]=Math.max(this.#Ti[3],Math.min(h[3],o[3]));return this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,o){const a=s.bbox;let h;let c;if(a){h=a[2]!==a[0]&&a[3]!==a[1]&&this.#Di.get(s);if(h!==false){c=[0,0,0,0];xt.axialAlignedBoundingBox(a,s.fontMatrix,c);if(i!==1||n!==0||r!==0){xt.scaleMinMax([i,0,0,-i,n,r],c)}if(h){return this.recordBBox(t,e,c[0],c[2],c[1],c[3])}}}if(!o){return this.recordFullPageBBox(t)}const l=o();if(a&&c&&h===undefined){h=c[0]<=n-l.actualBoundingBoxLeft&&c[2]>=n+l.actualBoundingBoxRight&&c[1]<=r-l.actualBoundingBoxAscent&&c[3]>=r+l.actualBoundingBoxDescent;this.#Di.set(s,h);if(h){return this.recordBBox(t,e,c[0],c[2],c[1],c[3])}}return this.recordBBox(t,e,n-l.actualBoundingBoxLeft,n+l.actualBoundingBoxRight,r-l.actualBoundingBoxAscent,r+l.actualBoundingBoxDescent)}recordFullPageBBox(t){this.#Ti[0]=Math.max(0,this.#Ci[0]);this.#Ti[1]=Math.max(0,this.#Ci[1]);this.#Ti[2]=Math.min(this.#Ii,this.#Ci[2]);this.#Ti[3]=Math.min(this.#Ri,this.#Ci[3]);return this}getSimpleIndex(t){return this.#yi[t]}recordDependencies(t,e){const s=this.#Pi;const i=this.#yi;const n=this.#vi;for(const t of e){if(t in this.#yi){s.add(i[t])}else if(t in n){n[t].forEach(s.add,s)}}return this}recordNamedDependency(t,e){if(this.#xi.has(e)){this.#Pi.add(this.#xi.get(e))}return this}recordOperation(t,e=false){this.recordDependencies(t,[ws]);if(this.#Oi){const e=ks(this.#Oi,t);const{dependencies:s}=e;this.#Pi.forEach(s.add,s);this.#ki.forEach(s.add,s);this.#Si.forEach(s.add,s);s.delete(t);e.isRenderingOperation=true}if(this.#Ei===t){const s=bs(this.#Ti[0]*256/this.#Ii);const i=bs(this.#Ti[1]*256/this.#Ri);const n=As(this.#Ti[2]*256/this.#Ii);const r=As(this.#Ti[3]*256/this.#Ri);ys(this.#Fi,t,s,i,n,r);for(const e of this.#Pi){if(e!==t){ys(this.#Fi,e,s,i,n,r)}}for(const e of this.#ki){if(e!==t){ys(this.#Fi,e,s,i,n,r)}}for(const e of this.#Si){if(e!==t){ys(this.#Fi,e,s,i,n,r)}}if(!e){this.#Pi.clear();this.#Ei=-1}}return this}recordShowTextOperation(t,e=false){const s=Array.from(this.#Pi);this.recordOperation(t,e);this.recordIncrementalData("sameLineText",t);for(const t of s){this.recordIncrementalData("sameLineText",t)}return this}bboxToClipBoxDropOperation(t,e=false){if(this.#Ei===t){this.#Ei=-1;this.#Ci[0]=Math.max(this.#Ci[0],this.#Ti[0]);this.#Ci[1]=Math.max(this.#Ci[1],this.#Ti[1]);this.#Ci[2]=Math.min(this.#Ci[2],this.#Ti[2]);this.#Ci[3]=Math.min(this.#Ci[3],this.#Ti[3]);if(!e){this.#Pi.clear()}}return this}_takePendingDependencies(){const t=this.#Pi;this.#Pi=new Set;return t}_extractOperation(t){const e=this.#Ni.get(t);this.#Ni.delete(t);return e}_pushPendingDependencies(t){for(const e of t){this.#Pi.add(e)}}take(){this.#Di.clear();return new xs(this.#bi,this.#Fi)}takeDebugMetadata(){return this.#Oi}}class Ms{#_i;#Bi;#Li;#Ui=0;#ji=0;constructor(t,e,s){if(t instanceof Ms&&t.#Li===!!s){return t}this.#_i=t;this.#Bi=e;this.#Li=!!s}growOperationsCount(){throw new Error("Unreachable")}save(t){this.#ji++;this.#_i.save(this.#Bi);return this}restore(t){if(this.#ji>0){this.#_i.restore(this.#Bi);this.#ji--}return this}recordOpenMarker(t){this.#Ui++;return this}getOpenMarker(){return this.#Ui>0?this.#Bi:this.#_i.getOpenMarker()}recordCloseMarker(t){this.#Ui--;return this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){this.#_i.pushBaseTransform(t);return this}popBaseTransform(){this.#_i.popBaseTransform();return this}recordSimpleData(t,e){this.#_i.recordSimpleData(t,this.#Bi);return this}recordIncrementalData(t,e){this.#_i.recordIncrementalData(t,this.#Bi);return this}resetIncrementalData(t,e){this.#_i.resetIncrementalData(t,this.#Bi);return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){this.#_i.recordSimpleDataFromNamed(t,e,this.#Bi);return this}recordFutureForcedDependency(t,e){this.#_i.recordFutureForcedDependency(t,this.#Bi);return this}inheritSimpleDataAsFutureForcedDependencies(t){this.#_i.inheritSimpleDataAsFutureForcedDependencies(t);return this}inheritPendingDependenciesAsFutureForcedDependencies(){this.#_i.inheritPendingDependenciesAsFutureForcedDependencies();return this}resetBBox(t){if(!this.#Li){this.#_i.resetBBox(this.#Bi)}return this}recordClipBox(t,e,s,i,n,r){if(!this.#Li){this.#_i.recordClipBox(this.#Bi,e,s,i,n,r)}return this}recordBBox(t,e,s,i,n,r){if(!this.#Li){this.#_i.recordBBox(this.#Bi,e,s,i,n,r)}return this}recordCharacterBBox(t,e,s,i,n,r,o){if(!this.#Li){this.#_i.recordCharacterBBox(this.#Bi,e,s,i,n,r,o)}return this}recordFullPageBBox(t){if(!this.#Li){this.#_i.recordFullPageBBox(this.#Bi)}return this}getSimpleIndex(t){return this.#_i.getSimpleIndex(t)}recordDependencies(t,e){this.#_i.recordDependencies(this.#Bi,e);return this}recordNamedDependency(t,e){this.#_i.recordNamedDependency(this.#Bi,e);return this}recordOperation(t){this.#_i.recordOperation(this.#Bi,true);return this}recordShowTextOperation(t){this.#_i.recordShowTextOperation(this.#Bi,true);return this}bboxToClipBoxDropOperation(t){if(!this.#Li){this.#_i.bboxToClipBoxDropOperation(this.#Bi,true)}return this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const Cs={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};const Ts={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Es(t,e){if(!e){return}const s=e[2]-e[0];const i=e[3]-e[1];const n=new Path2D;n.rect(e[0],e[1],s,i);t.clip(n)}class Ps{isModifyingCurrentTransform(){return false}getPattern(){st("Abstract method `getPattern` called.")}}class Ns extends Ps{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;if(this._type==="axial"){e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1])}else if(this._type==="radial"){e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)}for(const t of this._colorStops){e.addColorStop(t[0],t[1])}return e}getPattern(t,e,s,i){let n;if(i===Ts.STROKE||i===Ts.FILL){const r=e.current.getClippedPathBoundingBox(i,Zt(t))||[0,0,0,0];const o=Math.ceil(r[2]-r[0])||1;const a=Math.ceil(r[3]-r[1])||1;const h=e.cachedCanvases.getCanvas("pattern",o,a);const c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height);c.beginPath();c.rect(0,0,c.canvas.width,c.canvas.height);c.translate(-r[0],-r[1]);s=xt.transform(s,[1,0,0,1,r[0],r[1]]);c.transform(...e.baseTransform);if(this.matrix){c.transform(...this.matrix)}Es(c,this._bbox);c.fillStyle=this._createGradient(c);c.fill();n=t.createPattern(h.canvas,"no-repeat");const l=new DOMMatrix(s);n.setTransform(l)}else{Es(t,this._bbox);n=this._createGradient(t)}return n}}function Ds(t,e,s,i,n,r,o,a){const h=e.coords,c=e.colors;const l=t.data,u=t.width*4;let f;if(h[s+1]>h[i+1]){f=s;s=i;i=f;f=r;r=o;o=f}if(h[i+1]>h[n+1]){f=i;i=n;n=f;f=o;o=a;a=f}if(h[s+1]>h[i+1]){f=s;s=i;i=f;f=r;r=o;o=f}const d=(h[s]+e.offsetX)*e.scaleX;const p=(h[s+1]+e.offsetY)*e.scaleY;const g=(h[i]+e.offsetX)*e.scaleX;const m=(h[i+1]+e.offsetY)*e.scaleY;const w=(h[n]+e.offsetX)*e.scaleX;const b=(h[n+1]+e.offsetY)*e.scaleY;if(p>=b){return}const A=c[r],y=c[r+1],v=c[r+2];const x=c[o],k=c[o+1],S=c[o+2];const M=c[a],C=c[a+1],T=c[a+2];const E=Math.round(p),P=Math.round(b);let N,D,I,R;let F,O,$,_;for(let t=E;t<=P;t++){if(t<m){const e=t<p?0:(p-t)/(p-m);N=d-(d-g)*e;D=A-(A-x)*e;I=y-(y-k)*e;R=v-(v-S)*e}else{let e;if(t>b){e=1}else if(m===b){e=0}else{e=(m-t)/(m-b)}N=g-(g-w)*e;D=x-(x-M)*e;I=k-(k-C)*e;R=S-(S-T)*e}let e;if(t<p){e=0}else if(t>b){e=1}else{e=(p-t)/(p-b)}F=d-(d-w)*e;O=A-(A-M)*e;$=y-(y-C)*e;_=v-(v-T)*e;const s=Math.round(Math.min(N,F));const i=Math.round(Math.max(N,F));let n=u*t+s*4;for(let t=s;t<=i;t++){e=(N-t)/(N-F);if(e<0){e=0}else if(e>1){e=1}l[n++]=D-(D-O)*e|0;l[n++]=I-(I-$)*e|0;l[n++]=R-(R-_)*e|0;l[n++]=255}}}function Is(t,e,s){const i=e.coords;const n=e.colors;let r,o;switch(e.type){case z.LATTICE:const a=e.verticesPerRow;const h=Math.floor(i.length/a)-1;const c=a-1;for(r=0;r<h;r++){let e=r*a;for(let r=0;r<c;r++,e++){Ds(t,s,i[e],i[e+1],i[e+a],n[e],n[e+1],n[e+a]);Ds(t,s,i[e+a+1],i[e+1],i[e+a],n[e+a+1],n[e+1],n[e+a])}}break;case z.TRIANGLES:for(r=0,o=i.length;r<o;r+=3){Ds(t,s,i[r],i[r+1],i[r+2],n[r],n[r+1],n[r+2])}break;default:throw new Error("illegal figure")}}class Rs extends Ps{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=1.1;const n=3e3;const r=2;const o=Math.floor(this._bounds[0]);const a=Math.floor(this._bounds[1]);const h=Math.ceil(this._bounds[2])-o;const c=Math.ceil(this._bounds[3])-a;const l=Math.min(Math.ceil(Math.abs(h*t[0]*i)),n);const u=Math.min(Math.ceil(Math.abs(c*t[1]*i)),n);const f=h/l;const d=c/u;const p={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-a,scaleX:1/f,scaleY:1/d};const g=l+r*2;const m=u+r*2;const w=s.getCanvas("mesh",g,m);const b=w.context;const A=b.createImageData(l,u);if(e){const t=A.data;for(let s=0,i=t.length;s<i;s+=4){t[s]=e[0];t[s+1]=e[1];t[s+2]=e[2];t[s+3]=255}}for(const t of this._figures){Is(A,t,p)}b.putImageData(A,r,r);const y=w.canvas;return{canvas:y,offsetX:o-r*f,offsetY:a-r*d,scaleX:f,scaleY:d}}isModifyingCurrentTransform(){return true}getPattern(t,e,s,i){Es(t,this._bbox);const n=new Float32Array(2);if(i===Ts.SHADING){xt.singularValueDecompose2dScale(Zt(t),n)}else if(this.matrix){xt.singularValueDecompose2dScale(this.matrix,n);const[t,s]=n;xt.singularValueDecompose2dScale(e.baseTransform,n);n[0]*=t;n[1]*=s}else{xt.singularValueDecompose2dScale(e.baseTransform,n)}const r=this._createMeshCanvas(n,i===Ts.SHADING?null:this._background,e.cachedCanvases);if(i!==Ts.SHADING){t.setTransform(...e.baseTransform);if(this.matrix){t.transform(...this.matrix)}}t.translate(r.offsetX,r.offsetY);t.scale(r.scaleX,r.scaleY);return t.createPattern(r.canvas,"no-repeat")}}class Fs extends Ps{getPattern(){return"hotpink"}}function Os(t){switch(t[0]){case"RadialAxial":return new Ns(t);case"Mesh":return new Rs(t);case"Dummy":return new Fs}throw new Error(`Unknown IR type: ${t[0]}`)}const $s={COLORED:1,UNCOLORED:2};class _s{static MAX_PATTERN_SIZE=3e3;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,e){const{bbox:s,operatorList:i,paintType:n,tilingType:r,color:o,canvasGraphicsFactory:a}=this;let{xstep:h,ystep:c}=this;h=Math.abs(h);c=Math.abs(c);tt("TilingType: "+r);const l=s[0],u=s[1],f=s[2],d=s[3];const p=f-l;const g=d-u;const m=new Float32Array(2);xt.singularValueDecompose2dScale(this.matrix,m);const[w,b]=m;xt.singularValueDecompose2dScale(this.baseTransform,m);const A=w*m[0];const y=b*m[1];let v=p,x=g,k=false,S=false;const M=Math.ceil(h*A);const C=Math.ceil(c*y);const T=Math.ceil(p*A);const E=Math.ceil(g*y);if(M>=T){v=h}else{k=true}if(C>=E){x=c}else{S=true}const P=this.getSizeAndScale(v,this.ctx.canvas.width,A);const N=this.getSizeAndScale(x,this.ctx.canvas.height,y);const D=t.cachedCanvases.getCanvas("pattern",P.size,N.size);const I=D.context;const R=a.createCanvasGraphics(I,e);R.groupLevel=t.groupLevel;this.setFillAndStrokeStyleToContext(R,n,o);I.translate(-P.scale*l,-N.scale*u);R.transform(0,P.scale,0,0,N.scale,0,0);I.save();R.dependencyTracker?.save();this.clipBbox(R,l,u,f,d);R.baseTransform=Zt(R.ctx);R.executeOperatorList(i);R.endDrawing();R.dependencyTracker?.restore();I.restore();if(k||S){const e=D.canvas;if(k){v=h}if(S){x=c}const s=this.getSizeAndScale(v,this.ctx.canvas.width,A);const i=this.getSizeAndScale(x,this.ctx.canvas.height,y);const n=s.size;const r=i.size;const o=t.cachedCanvases.getCanvas("pattern-workaround",n,r);const a=o.context;const f=k?Math.floor(p/h):0;const d=S?Math.floor(g/c):0;for(let t=0;t<=f;t++){for(let s=0;s<=d;s++){a.drawImage(e,n*t,r*s,n,r,0,0,n,r)}}return{canvas:o.canvas,scaleX:s.scale,scaleY:i.scale,offsetX:l,offsetY:u}}return{canvas:D.canvas,scaleX:P.scale,scaleY:N.scale,offsetX:l,offsetY:u}}getSizeAndScale(t,e,s){const i=Math.max(_s.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);if(n>=i){n=i}else{s=n/t}return{scale:s,size:n}}clipBbox(t,e,s,i,n){const r=i-e;const o=n-s;t.ctx.rect(e,s,r,o);xt.axialAlignedBoundingBox([e,s,i,n],Zt(t.ctx),t.current.minMax);t.clip();t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case $s.COLORED:const{fillStyle:t,strokeStyle:r}=this.ctx;i.fillStyle=n.fillColor=t;i.strokeStyle=n.strokeColor=r;break;case $s.UNCOLORED:i.fillStyle=i.strokeStyle=s;n.fillColor=n.strokeColor=s;break;default:throw new dt(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return false}getPattern(t,e,s,i,n){let r=s;if(i!==Ts.SHADING){r=xt.transform(r,e.baseTransform);if(this.matrix){r=xt.transform(r,this.matrix)}}const o=this.createPatternCanvas(e,n);let a=new DOMMatrix(r);a=a.translate(o.offsetX,o.offsetY);a=a.scale(1/o.scaleX,1/o.scaleY);const h=t.createPattern(o.canvas,"repeat");h.setTransform(a);return h}}function Bs({src:t,srcPos:e=0,dest:s,width:i,height:n,nonBlackColor:r=4294967295,inverseDecode:o=false}){const a=yt.isLittleEndian?4278190080:255;const[h,c]=o?[r,a]:[a,r];const l=i>>3;const u=i&7;const f=t.length;s=new Uint32Array(s.buffer);let d=0;for(let i=0;i<n;i++){for(const i=e+l;e<i;e++){const i=e<f?t[e]:255;s[d++]=i&128?c:h;s[d++]=i&64?c:h;s[d++]=i&32?c:h;s[d++]=i&16?c:h;s[d++]=i&8?c:h;s[d++]=i&4?c:h;s[d++]=i&2?c:h;s[d++]=i&1?c:h}if(u===0){continue}const i=e<f?t[e++]:255;for(let t=0;t<u;t++){s[d++]=i&1<<7-t?c:h}}return{srcPos:e,destPos:d}}const Ls=16;const Us=100;const js=15;const zs=10;const Hs=16;const Ws=new DOMMatrix;const Gs=new Float32Array(2);const Vs=new Float32Array([Infinity,Infinity,-Infinity,-Infinity]);function Xs(t,e){if(t._removeMirroring){throw new Error("Context is already forwarding operations.")}t.__originalSave=t.save;t.__originalRestore=t.restore;t.__originalRotate=t.rotate;t.__originalScale=t.scale;t.__originalTranslate=t.translate;t.__originalTransform=t.transform;t.__originalSetTransform=t.setTransform;t.__originalResetTransform=t.resetTransform;t.__originalClip=t.clip;t.__originalMoveTo=t.moveTo;t.__originalLineTo=t.lineTo;t.__originalBezierCurveTo=t.bezierCurveTo;t.__originalRect=t.rect;t.__originalClosePath=t.closePath;t.__originalBeginPath=t.beginPath;t._removeMirroring=()=>{t.save=t.__originalSave;t.restore=t.__originalRestore;t.rotate=t.__originalRotate;t.scale=t.__originalScale;t.translate=t.__originalTranslate;t.transform=t.__originalTransform;t.setTransform=t.__originalSetTransform;t.resetTransform=t.__originalResetTransform;t.clip=t.__originalClip;t.moveTo=t.__originalMoveTo;t.lineTo=t.__originalLineTo;t.bezierCurveTo=t.__originalBezierCurveTo;t.rect=t.__originalRect;t.closePath=t.__originalClosePath;t.beginPath=t.__originalBeginPath;delete t._removeMirroring};t.save=function(){e.save();this.__originalSave()};t.restore=function(){e.restore();this.__originalRestore()};t.translate=function(t,s){e.translate(t,s);this.__originalTranslate(t,s)};t.scale=function(t,s){e.scale(t,s);this.__originalScale(t,s)};t.transform=function(t,s,i,n,r,o){e.transform(t,s,i,n,r,o);this.__originalTransform(t,s,i,n,r,o)};t.setTransform=function(t,s,i,n,r,o){e.setTransform(t,s,i,n,r,o);this.__originalSetTransform(t,s,i,n,r,o)};t.resetTransform=function(){e.resetTransform();this.__originalResetTransform()};t.rotate=function(t){e.rotate(t);this.__originalRotate(t)};t.clip=function(t){e.clip(t);this.__originalClip(t)};t.moveTo=function(t,s){e.moveTo(t,s);this.__originalMoveTo(t,s)};t.lineTo=function(t,s){e.lineTo(t,s);this.__originalLineTo(t,s)};t.bezierCurveTo=function(t,s,i,n,r,o){e.bezierCurveTo(t,s,i,n,r,o);this.__originalBezierCurveTo(t,s,i,n,r,o)};t.rect=function(t,s,i,n){e.rect(t,s,i,n);this.__originalRect(t,s,i,n)};t.closePath=function(){e.closePath();this.__originalClosePath()};t.beginPath=function(){e.beginPath();this.__originalBeginPath()}}class qs{constructor(t){this.canvasFactory=t;this.cache=Object.create(null)}getCanvas(t,e,s){let i;if(this.cache[t]!==undefined){i=this.cache[t];this.canvasFactory.reset(i,e,s)}else{i=this.canvasFactory.create(e,s);this.cache[t]=i}return 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 Ys(t,e,s,i,n,r,o,a,h,c){const[l,u,f,d,p,g]=Zt(t);if(u===0&&f===0){const m=o*l+p;const w=Math.round(m);const b=a*d+g;const A=Math.round(b);const y=(o+h)*l+p;const v=Math.abs(Math.round(y)-w)||1;const x=(a+c)*d+g;const k=Math.abs(Math.round(x)-A)||1;t.setTransform(Math.sign(l),0,0,Math.sign(d),w,A);t.drawImage(e,s,i,n,r,0,0,v,k);t.setTransform(l,u,f,d,p,g);return[v,k]}if(l===0&&d===0){const m=a*f+p;const w=Math.round(m);const b=o*u+g;const A=Math.round(b);const y=(a+c)*f+p;const v=Math.abs(Math.round(y)-w)||1;const x=(o+h)*u+g;const k=Math.abs(Math.round(x)-A)||1;t.setTransform(0,Math.sign(u),Math.sign(f),0,w,A);t.drawImage(e,s,i,n,r,0,0,k,v);t.setTransform(l,u,f,d,p,g);return[k,v]}t.drawImage(e,s,i,n,r,o,a,h,c);const m=Math.hypot(l,u);const w=Math.hypot(f,d);return[m*h,w*c]}class Js{alphaIsShape=false;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=F;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=H.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=false;patternStroke=false;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e,s){s?.(this);this.clipBox=new Float32Array([0,0,t,e]);this.minMax=Vs.slice()}clone(){const t=Object.create(this);t.clipBox=this.clipBox.slice();t.minMax=this.minMax.slice();return t}getPathBoundingBox(t=Ts.FILL,e=null){const s=this.minMax.slice();if(t===Ts.STROKE){if(!e){st("Stroke bounding box must include transform.")}xt.singularValueDecompose2dScale(e,Gs);const t=Gs[0]*this.lineWidth/2;const i=Gs[1]*this.lineWidth/2;s[0]-=t;s[1]-=i;s[2]+=t;s[3]+=i}return s}updateClipFromPath(){const t=xt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===Infinity}startNewPathAndClipBox(t){this.clipBox.set(t,0);this.minMax.set(Vs,0)}getClippedPathBoundingBox(t=Ts.FILL,e=null){return xt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Ks(t,e){if(e instanceof ImageData){t.putImageData(e,0,0);return}const s=e.height,i=e.width;const n=s%Hs;const r=(s-n)/Hs;const o=n===0?r:r+1;const a=t.createImageData(i,Hs);let h=0,c;const l=e.data;const u=a.data;let f,d,p,g;if(e.kind===W.GRAYSCALE_1BPP){const e=l.byteLength;const s=new Uint32Array(u.buffer,0,u.byteLength>>2);const g=s.length;const m=i+7>>3;const w=4294967295;const b=yt.isLittleEndian?4278190080:255;for(f=0;f<o;f++){p=f<r?Hs:n;c=0;for(d=0;d<p;d++){const t=e-h;let n=0;const r=t>m?i:t*8-7;const o=r&-8;let a=0;let u=0;for(;n<o;n+=8){u=l[h++];s[c++]=u&128?w:b;s[c++]=u&64?w:b;s[c++]=u&32?w:b;s[c++]=u&16?w:b;s[c++]=u&8?w:b;s[c++]=u&4?w:b;s[c++]=u&2?w:b;s[c++]=u&1?w:b}for(;n<r;n++){if(a===0){u=l[h++];a=128}s[c++]=u&a?w:b;a>>=1}}while(c<g){s[c++]=0}t.putImageData(a,0,f*Hs)}}else if(e.kind===W.RGBA_32BPP){d=0;g=i*Hs*4;for(f=0;f<r;f++){u.set(l.subarray(h,h+g));h+=g;t.putImageData(a,0,d);d+=Hs}if(f<o){g=i*n*4;u.set(l.subarray(h,h+g));t.putImageData(a,0,d)}}else if(e.kind===W.RGB_24BPP){p=Hs;g=i*p;for(f=0;f<o;f++){if(f>=r){p=n;g=i*p}c=0;for(d=g;d--;){u[c++]=l[h++];u[c++]=l[h++];u[c++]=l[h++];u[c++]=255}t.putImageData(a,0,f*Hs)}}else{throw new Error(`bad image kind: ${e.kind}`)}}function Qs(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}const s=e.height,i=e.width;const n=s%Hs;const r=(s-n)/Hs;const o=n===0?r:r+1;const a=t.createImageData(i,Hs);let h=0;const c=e.data;const l=a.data;for(let e=0;e<o;e++){const s=e<r?Hs:n;({srcPos:h}=Bs({src:c,srcPos:h,dest:l,width:i,height:s,nonBlackColor:0}));t.putImageData(a,0,e*Hs)}}function Zs(t,e){const s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const i of s){if(t[i]!==undefined){e[i]=t[i]}}if(t.setLineDash!==undefined){e.setLineDash(t.getLineDash());e.lineDashOffset=t.lineDashOffset}}function ti(t){t.strokeStyle=t.fillStyle="#000000";t.fillRule="nonzero";t.globalAlpha=1;t.lineWidth=1;t.lineCap="butt";t.lineJoin="miter";t.miterLimit=10;t.globalCompositeOperation="source-over";t.font="10px sans-serif";if(t.setLineDash!==undefined){t.setLineDash([]);t.lineDashOffset=0}const{filter:e}=t;if(e!=="none"&&e!==""){t.filter="none"}}function ei(t,e){if(e){return true}xt.singularValueDecompose2dScale(t,Gs);const s=Math.fround(se.pixelRatio*$t.PDF_TO_CSS_UNITS);return Gs[0]<=s&&Gs[1]<=s}const si=["butt","round","square"];const ii=["miter","round","bevel"];const ni={};const ri={};class oi{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:o=null},a,h,c){this.ctx=t;this.current=new Js(this.ctx.canvas.width,this.ctx.canvas.height);this.stateStack=[];this.pendingClip=null;this.pendingEOFill=false;this.res=null;this.xobjs=null;this.commonObjs=e;this.objs=s;this.canvasFactory=i;this.filterFactory=n;this.groupStack=[];this.baseTransform=null;this.baseTransformStack=[];this.groupLevel=0;this.smaskStack=[];this.smaskCounter=0;this.tempSMask=null;this.suspendedCtx=null;this.contentVisible=true;this.markedContentStack=o||[];this.optionalContentConfig=r;this.cachedCanvases=new qs(this.canvasFactory);this.cachedPatterns=new Map;this.annotationCanvasMap=a;this.viewportScale=1;this.outputScaleX=1;this.outputScaleY=1;this.pageColors=h;this._cachedScaleForStroking=[-1,0];this._cachedGetSinglePixelWidth=null;this._cachedBitmapsMap=new Map;this.dependencyTracker=c??null}getObject(t,e,s=null){if(typeof e==="string"){this.dependencyTracker?.recordNamedDependency(t,e);return e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)}return s}beginDrawing({transform:t,viewport:e,transparency:s=false,background:i=null}){const n=this.ctx.canvas.width;const r=this.ctx.canvas.height;const o=this.ctx.fillStyle;this.ctx.fillStyle=i||"#ffffff";this.ctx.fillRect(0,0,n,r);this.ctx.fillStyle=o;if(s){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx;this.transparentCanvas=t.canvas;this.ctx=t.context;this.ctx.save();this.ctx.transform(...Zt(this.compositeCtx))}this.ctx.save();ti(this.ctx);if(t){this.ctx.transform(...t);this.outputScaleX=t[0];this.outputScaleY=t[0]}this.ctx.transform(...e.transform);this.viewportScale=e.scale;this.baseTransform=Zt(this.ctx)}executeOperatorList(t,e,s,i,n){const r=t.argsArray;const o=t.fnArray;let a=e||0;const h=r.length;if(h===a){return a}const c=h-a>zs&&typeof s==="function";const l=c?Date.now()+js:0;let u=0;const f=this.commonObjs;const d=this.objs;let p,g;while(true){if(i!==undefined&&a===i.nextBreakPoint){i.breakIt(a,s);return a}if(!n||n(a)){p=o[a];g=r[a]??null;if(p!==q.dependency){if(g===null){this[p](a)}else{this[p](a,...g)}}else{for(const t of g){this.dependencyTracker?.recordNamedData(t,a);const e=t.startsWith("g_")?f:d;if(!e.has(t)){e.get(t,s);return a}}}}a++;if(a===h){return a}if(c&&++u>zs){if(Date.now()>l){s();return a}u=0}}}#zi(){while(this.stateStack.length||this.inSMaskMode){this.restore()}this.current.activeSMask=null;this.ctx.restore();if(this.transparentCanvas){this.ctx=this.compositeCtx;this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.drawImage(this.transparentCanvas,0,0);this.ctx.restore();this.transparentCanvas=null}}endDrawing(){this.#zi();this.cachedCanvases.clear();this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values()){if(typeof HTMLCanvasElement!=="undefined"&&e instanceof HTMLCanvasElement){e.width=e.height=0}}t.clear()}this._cachedBitmapsMap.clear();this.#Hi()}#Hi(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t;this.ctx.drawImage(this.ctx.canvas,0,0);this.ctx.filter=e}}}_scaleImage(t,e){const s=t.width??t.displayWidth;const i=t.height??t.displayHeight;let n=Math.max(Math.hypot(e[0],e[1]),1);let r=Math.max(Math.hypot(e[2],e[3]),1);let o=s,a=i;let h="prescale1";let c,l;while(n>2&&o>1||r>2&&a>1){let e=o,s=a;if(n>2&&o>1){e=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2);n/=o/e}if(r>2&&a>1){s=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a)/2;r/=a/s}c=this.cachedCanvases.getCanvas(h,e,s);l=c.context;l.clearRect(0,0,e,s);l.drawImage(t,0,0,o,a,0,0,e,s);t=c.canvas;o=e;a=s;h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:a}}_createMaskCanvas(t,e){const s=this.ctx;const{width:i,height:n}=e;const r=this.current.fillColor;const o=this.current.patternFill;const a=Zt(s);let h,c,l,u;if((e.bitmap||e.data)&&e.count>1){const s=e.bitmap||e.data.buffer;c=JSON.stringify(o?a:[a.slice(0,4),r]);h=this._cachedBitmapsMap.get(s);if(!h){h=new Map;this._cachedBitmapsMap.set(s,h)}const i=h.get(c);if(i&&!o){const e=Math.round(Math.min(a[0],a[2])+a[4]);const s=Math.round(Math.min(a[1],a[3])+a[5]);this.dependencyTracker?.recordDependencies(t,Cs.transformAndFill);return{canvas:i,offsetX:e,offsetY:s}}l=i}if(!l){u=this.cachedCanvases.getCanvas("maskCanvas",i,n);Qs(u.context,e)}let f=xt.transform(a,[1/i,0,0,-1/n,0,0]);f=xt.transform(f,[1,0,0,1,0,-n]);const d=Vs.slice();xt.axialAlignedBoundingBox([0,0,i,n],f,d);const[p,g,m,w]=d;const b=Math.round(m-p)||1;const A=Math.round(w-g)||1;const y=this.cachedCanvases.getCanvas("fillCanvas",b,A);const v=y.context;const x=p;const k=g;v.translate(-x,-k);v.transform(...f);if(!l){l=this._scaleImage(u.canvas,te(v));l=l.img;if(h&&o){h.set(c,l)}}v.imageSmoothingEnabled=ei(Zt(v),e.interpolate);Ys(v,l,0,0,l.width,l.height,0,0,i,n);v.globalCompositeOperation="source-in";const S=xt.transform(te(v),[1,0,0,1,-x,-k]);v.fillStyle=o?r.getPattern(s,this,S,Ts.FILL,t):r;v.fillRect(0,0,i,n);if(h&&!o){this.cachedCanvases.delete("fillCanvas");h.set(c,y.canvas)}this.dependencyTracker?.recordDependencies(t,Cs.transformAndFill);return{canvas:y.canvas,offsetX:Math.round(x),offsetY:Math.round(k)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t);if(e!==this.current.lineWidth){this._cachedScaleForStroking[0]=-1}this.current.lineWidth=e;this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t);this.ctx.lineCap=si[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t);this.ctx.lineJoin=ii[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t);this.ctx.miterLimit=e}setDash(t,e,s){this.dependencyTracker?.recordSimpleData("dash",t);const i=this.ctx;if(i.setLineDash!==undefined){i.setLineDash(e);i.lineDashOffset=s}}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(const[s,i]of e){switch(s){case"LW":this.setLineWidth(t,i);break;case"LC":this.setLineCap(t,i);break;case"LJ":this.setLineJoin(t,i);break;case"ML":this.setMiterLimit(t,i);break;case"D":this.setDash(t,i[0],i[1]);break;case"RI":this.setRenderingIntent(t,i);break;case"FL":this.setFlatness(t,i);break;case"Font":this.setFont(t,i[0],i[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t);this.current.strokeAlpha=i;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t);this.ctx.globalAlpha=this.current.fillAlpha=i;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t);this.ctx.globalCompositeOperation=i;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t);this.current.activeSMask=i?this.tempSMask:null;this.tempSMask=null;this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t);this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i);break}}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;if(this.current.activeSMask&&!t){this.beginSMaskMode()}else if(!this.current.activeSMask&&t){this.endSMaskMode()}}beginSMaskMode(t){if(this.inSMaskMode){throw new Error("beginSMaskMode called while already in smask mode")}const e=this.ctx.canvas.width;const s=this.ctx.canvas.height;const i="smaskGroupAt"+this.groupLevel;const n=this.cachedCanvases.getCanvas(i,e,s);this.suspendedCtx=this.ctx;const r=this.ctx=n.context;r.setTransform(this.suspendedCtx.getTransform());Zs(this.suspendedCtx,r);Xs(r,this.suspendedCtx);this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode){throw new Error("endSMaskMode called while not in smask mode")}this.ctx._removeMirroring();Zs(this.ctx,this.suspendedCtx);this.ctx=this.suspendedCtx;this.suspendedCtx=null}compose(t){if(!this.current.activeSMask){return}if(!t){t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height]}else{t[0]=Math.floor(t[0]);t[1]=Math.floor(t[1]);t[2]=Math.ceil(t[2]);t[3]=Math.ceil(t[3])}const e=this.current.activeSMask;const s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t);this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height);this.ctx.restore()}composeSMask(t,e,s,i){const n=i[0];const r=i[1];const o=i[2]-n;const a=i[3]-r;if(o===0||a===0){return}this.genericComposeSMask(e.context,s,o,a,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY);t.save();t.globalAlpha=1;t.globalCompositeOperation="source-over";t.setTransform(1,0,0,1,0,0);t.drawImage(s.canvas,0,0);t.restore()}genericComposeSMask(t,e,s,i,n,r,o,a,h,c,l){let u=t.canvas;let f=a-c;let d=h-l;if(r){if(f<0||d<0||f+s>u.width||d+i>u.height){const t=this.cachedCanvases.getCanvas("maskExtension",s,i);const e=t.context;e.drawImage(u,-f,-d);e.globalCompositeOperation="destination-atop";e.fillStyle=r;e.fillRect(0,0,s,i);e.globalCompositeOperation="source-over";u=t.canvas;f=d=0}else{t.save();t.globalAlpha=1;t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(f,d,s,i);t.clip(e);t.globalCompositeOperation="destination-atop";t.fillStyle=r;t.fillRect(f,d,s,i);t.restore()}}e.save();e.globalAlpha=1;e.setTransform(1,0,0,1,0,0);if(n==="Alpha"&&o){e.filter=this.filterFactory.addAlphaFilter(o)}else if(n==="Luminosity"){e.filter=this.filterFactory.addLuminosityFilter(o)}const p=new Path2D;p.rect(a,h,s,i);e.clip(p);e.globalCompositeOperation="destination-in";e.drawImage(u,f,d,s,i,a,h,s,i);e.restore()}save(t){if(this.inSMaskMode){Zs(this.ctx,this.suspendedCtx)}this.ctx.save();const e=this.current;this.stateStack.push(e);this.current=e.clone();this.dependencyTracker?.save(t)}restore(t){this.dependencyTracker?.restore(t);if(this.stateStack.length===0){if(this.inSMaskMode){this.endSMaskMode()}return}this.current=this.stateStack.pop();this.ctx.restore();if(this.inSMaskMode){Zs(this.suspendedCtx,this.ctx)}this.checkSMaskState();this.pendingClip=null;this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,n,r,o){this.dependencyTracker?.recordIncrementalData("transform",t);this.ctx.transform(e,s,i,n,r,o);this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[n]=s;if(!i){n||=s[0]=new Path2D;this[e](t,n);return}if(this.dependencyTracker!==null){const s=e===q.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-s,i[2]+s,i[1]-s,i[3]+s).recordDependencies(t,["transform"])}if(!(n instanceof Path2D)){n=s[0]=pe(n)}xt.axialAlignedBoundingBox(i,Zt(this.ctx),this.current.minMax);this[e](t,n);this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=true){const i=this.ctx;const n=this.current.strokeColor;i.globalAlpha=this.current.strokeAlpha;if(this.contentVisible){if(typeof n==="object"&&n?.getPattern){const s=n.isModifyingCurrentTransform()?i.getTransform():null;i.save();i.strokeStyle=n.getPattern(i,this,te(i),Ts.STROKE,t);if(s){const t=new Path2D;t.addPath(e,i.getTransform().invertSelf().multiplySelf(s));e=t}this.rescaleAndStroke(e,false);i.restore()}else{this.rescaleAndStroke(e,true)}}this.dependencyTracker?.recordDependencies(t,Cs.stroke);if(s){this.consumePath(t,e,this.current.getClippedPathBoundingBox(Ts.STROKE,Zt(this.ctx)))}i.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=true){const i=this.ctx;const n=this.current.fillColor;const r=this.current.patternFill;let o=false;if(r){const s=n.isModifyingCurrentTransform()?i.getTransform():null;this.dependencyTracker?.save(t);i.save();i.fillStyle=n.getPattern(i,this,te(i),Ts.FILL,t);if(s){const t=new Path2D;t.addPath(e,i.getTransform().invertSelf().multiplySelf(s));e=t}o=true}const a=this.current.getClippedPathBoundingBox();if(this.contentVisible&&a!==null){if(this.pendingEOFill){i.fill(e,"evenodd");this.pendingEOFill=false}else{i.fill(e)}}this.dependencyTracker?.recordDependencies(t,Cs.fill);if(o){i.restore();this.dependencyTracker?.restore(t)}if(s){this.consumePath(t,e,a)}}eoFill(t,e){this.pendingEOFill=true;this.fill(t,e)}fillStroke(t,e){this.fill(t,e,false);this.stroke(t,e,false);this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=true;this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=true;this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e);this.dependencyTracker?.recordDependencies(t,Cs.rawFillPath).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t);this.pendingClip=ni}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t);this.pendingClip=ri}beginText(t){this.current.textMatrix=null;this.current.textMatrixScale=1;this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0;this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths;const s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:s}=this;if(e!==undefined){s.recordFutureForcedDependency("textClip",s.getOpenMarker()).recordFutureForcedDependency("textClip",t)}s.recordCloseMarker(t)}if(e!==undefined){const t=new Path2D;const i=s.getTransform().invertSelf();for(const{transform:s,x:n,y:r,fontSize:o,path:a}of e){if(!a){continue}t.addPath(a,new DOMMatrix(s).preMultiplySelf(i).translate(n,r).scale(o,-o))}s.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t);this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t);this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t);this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t);this.current.leading=-e}setFont(t,e,s){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const i=this.commonObjs.get(e);const n=this.current;if(!i){throw new Error(`Can't find font for ${e}`)}n.fontMatrix=i.fontMatrix||F;if(n.fontMatrix[0]===0||n.fontMatrix[3]===0){et("Invalid font matrix for font "+e)}if(s<0){s=-s;n.fontDirection=-1}else{n.fontDirection=1}this.current.font=i;this.current.fontSize=s;if(i.isType3Font){return}const r=i.loadedName||"sans-serif";const o=i.systemFontInfo?.css||`"${r}", ${i.fallbackName}`;let a="normal";if(i.black){a="900"}else if(i.bold){a="bold"}const h=i.italic?"italic":"normal";let c=s;if(s<Ls){c=Ls}else if(s>Us){c=Us}this.current.fontSizeScale=s/c;this.ctx.font=`${h} ${a} ${c}px ${o}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t);this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t);this.current.textRise=e}moveText(t,e,s){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t);this.current.x=this.current.lineX+=e;this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s);this.moveText(t,e,s)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e;s.textMatrixScale=Math.hypot(e[0],e[1]);s.x=s.lineX=0;s.y=s.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading);this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#Wi(t,e,s){const i=new Path2D;i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e));return i}paintChar(t,e,s,i,n,r){const o=this.ctx;const a=this.current;const h=a.font;const c=a.textRenderingMode;const l=a.fontSize/a.fontSizeScale;const u=c&H.FILL_STROKE_MASK;const f=!!(c&H.ADD_TO_PATH_FLAG);const d=a.patternFill&&!h.missingFile;const p=a.patternStroke&&!h.missingFile;let g;if((h.disableFontFace||f||d||p)&&!h.missingFile){g=h.getPathGenerator(this.commonObjs,e)}if(g&&(h.disableFontFace||d||p)){o.save();o.translate(s,i);o.scale(l,-l);this.dependencyTracker?.recordCharacterBBox(t,o,h);let e;if(u===H.FILL||u===H.FILL_STROKE){if(n){e=o.getTransform();o.setTransform(...n);const t=this.#Wi(g,e,n);o.fill(t)}else{o.fill(g)}}if(u===H.STROKE||u===H.FILL_STROKE){if(r){e||=o.getTransform();o.setTransform(...r);const{a:t,b:s,c:i,d:n}=e;const a=xt.inverseTransform(r);const h=xt.transform([t,s,i,n,0,0],a);xt.singularValueDecompose2dScale(h,Gs);o.lineWidth*=Math.max(Gs[0],Gs[1])/l;o.stroke(this.#Wi(g,e,r))}else{o.lineWidth/=l;o.stroke(g)}}o.restore()}else{if(u===H.FILL||u===H.FILL_STROKE){o.fillText(e,s,i);this.dependencyTracker?.recordCharacterBBox(t,o,h,l,s,i,(()=>o.measureText(e)))}if(u===H.STROKE||u===H.FILL_STROKE){if(this.dependencyTracker){this.dependencyTracker?.recordCharacterBBox(t,o,h,l,s,i,(()=>o.measureText(e))).recordDependencies(t,Cs.stroke)}o.strokeText(e,s,i)}}if(f){const e=this.pendingTextPaths||=[];e.push({transform:Zt(o),x:s,y:i,fontSize:l,path:g});this.dependencyTracker?.recordCharacterBBox(t,o,h,l,s,i)}}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=false;for(let t=3;t<e.length;t+=4){if(e[t]>0&&e[t]<255){s=true;break}}return at(this,"isFontSubpixelAAEnabled",s)}showText(t,e){if(this.dependencyTracker){this.dependencyTracker.recordDependencies(t,Cs.showText).resetBBox(t);if(this.current.textRenderingMode&H.ADD_TO_PATH_FLAG){this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies()}}const s=this.current;const i=s.font;if(i.isType3Font){this.showType3Text(t,e);this.dependencyTracker?.recordShowTextOperation(t);return undefined}const n=s.fontSize;if(n===0){this.dependencyTracker?.recordOperation(t);return undefined}const r=this.ctx;const o=s.fontSizeScale;const a=s.charSpacing;const h=s.wordSpacing;const c=s.fontDirection;const l=s.textHScale*c;const u=e.length;const f=i.vertical;const d=f?1:-1;const p=i.defaultVMetrics;const g=n*s.fontMatrix[0];const m=s.textRenderingMode===H.FILL&&!i.disableFontFace&&!s.patternFill;r.save();if(s.textMatrix){r.transform(...s.textMatrix)}r.translate(s.x,s.y+s.textRise);if(c>0){r.scale(l,-1)}else{r.scale(l,1)}let w,b;if(s.patternFill){r.save();const e=s.fillColor.getPattern(r,this,te(r),Ts.FILL,t);w=Zt(r);r.restore();r.fillStyle=e}if(s.patternStroke){r.save();const e=s.strokeColor.getPattern(r,this,te(r),Ts.STROKE,t);b=Zt(r);r.restore();r.strokeStyle=e}let A=s.lineWidth;const y=s.textMatrixScale;if(y===0||A===0){const t=s.textRenderingMode&H.FILL_STROKE_MASK;if(t===H.STROKE||t===H.FILL_STROKE){A=this.getSinglePixelWidth()}}else{A/=y}if(o!==1){r.scale(o,o);A/=o}r.lineWidth=A;if(i.isInvalidPDFjsFont){const i=[];let n=0;for(const t of e){i.push(t.unicode);n+=t.width}const o=i.join("");r.fillText(o,0,0);if(this.dependencyTracker!==null){const e=r.measureText(o);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=n*g*l;r.restore();this.compose();return undefined}let v=0,x;for(x=0;x<u;++x){const s=e[x];if(typeof s==="number"){v+=d*s*n/1e3;continue}let l=false;const u=(s.isSpace?h:0)+a;const A=s.fontChar;const y=s.accent;let k,S;let M=s.width;if(f){const t=s.vmetric||p;const e=-(s.vmetric?t[1]:M*.5)*g;const i=t[2]*g;M=t?-t[0]:M;k=e/o;S=(v+i)/o}else{k=v/o;S=0}let C;if(i.remeasure&&M>0){C=r.measureText(A);const t=C.width*1e3/n*o;if(M<t&&this.isFontSubpixelAAEnabled){const e=M/t;l=true;r.save();r.scale(e,1);k/=e}else if(M!==t){k+=(M-t)/2e3*n/o}}if(this.contentVisible&&(s.isInFont||i.missingFile)){if(m&&!y){r.fillText(A,k,S);this.dependencyTracker?.recordCharacterBBox(t,r,C?{bbox:null}:i,n/o,k,S,(()=>C??r.measureText(A)))}else{this.paintChar(t,A,k,S,w,b);if(y){const e=k+n*y.offset.x/o;const s=S-n*y.offset.y/o;this.paintChar(t,y.fontChar,e,s,w,b)}}}const T=f?M*g-u*c:M*g+u*c;v+=T;if(l){r.restore()}}if(f){s.y-=v}else{s.x+=v*l}r.restore();this.compose();this.dependencyTracker?.recordShowTextOperation(t);return undefined}showType3Text(t,e){const s=this.ctx;const i=this.current;const n=i.font;const r=i.fontSize;const o=i.fontDirection;const a=n.vertical?1:-1;const h=i.charSpacing;const c=i.wordSpacing;const l=i.textHScale*o;const u=i.fontMatrix||F;const f=e.length;const d=i.textRenderingMode===H.INVISIBLE;let p,g,m,w;if(d||r===0){return}this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null;s.save();if(i.textMatrix){s.transform(...i.textMatrix)}s.translate(i.x,i.y+i.textRise);s.scale(l,o);const b=this.dependencyTracker;this.dependencyTracker=b?new Ms(b,t):null;for(p=0;p<f;++p){g=e[p];if(typeof g==="number"){w=a*g*r/1e3;this.ctx.translate(w,0);i.x+=w*l;continue}const t=(g.isSpace?c:0)+h;const o=n.charProcOperatorList[g.operatorListId];if(!o){et(`Type3 character "${g.operatorListId}" is not available.`)}else if(this.contentVisible){this.save();s.scale(r,r);s.transform(...u);this.executeOperatorList(o);this.restore()}const f=[g.width,0];xt.applyTransform(f,u);m=f[0]*r+t;s.translate(m,0);i.x+=m*l}s.restore();if(b){this.dependencyTracker=b}}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,n,r,o){const a=new Path2D;a.rect(i,n,r-i,o-n);this.ctx.clip(a);this.dependencyTracker?.recordBBox(t,this.ctx,i,r,n,o).recordClipBox(t,this.ctx,i,r,n,o);this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const t=this.baseTransform||Zt(this.ctx);const i={createCanvasGraphics:(t,e)=>new oi(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},undefined,undefined,this.dependencyTracker?new Ms(this.dependencyTracker,e,true):null)};s=new _s(e,this.ctx,i,t)}else{s=this._getPattern(t,e[1],e[2])}return s}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t);this.current.strokeColor=this.getColorN_Pattern(t,e);this.current.patternStroke=true}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=true}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t);this.ctx.strokeStyle=this.current.strokeColor=e;this.current.patternStroke=false}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t);this.ctx.strokeStyle=this.current.strokeColor="transparent";this.current.patternStroke=false}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t);this.ctx.fillStyle=this.current.fillColor=e;this.current.patternFill=false}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t);this.ctx.fillStyle=this.current.fillColor="transparent";this.current.patternFill=false}_getPattern(t,e,s=null){let i;if(this.cachedPatterns.has(e)){i=this.cachedPatterns.get(e)}else{i=Os(this.getObject(t,e));this.cachedPatterns.set(e,i)}if(s){i.matrix=s}return i}shadingFill(t,e){if(!this.contentVisible){return}const s=this.ctx;this.save(t);const i=this._getPattern(t,e);s.fillStyle=i.getPattern(s,this,te(s),Ts.SHADING,t);const n=te(s);if(n){const{width:t,height:e}=s.canvas;const i=Vs.slice();xt.axialAlignedBoundingBox([0,0,t,e],n,i);const[r,o,a,h]=i;this.ctx.fillRect(r,o,a-r,h-o)}else{this.ctx.fillRect(-1e10,-1e10,2e10,2e10)}this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Cs.transform).recordDependencies(t,Cs.fill).recordOperation(t);this.compose(this.current.getClippedPathBoundingBox());this.restore(t)}beginInlineImage(){st("Should not call beginInlineImage")}beginImageData(){st("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){if(!this.contentVisible){return}this.save(t);this.baseTransformStack.push(this.baseTransform);if(e){this.transform(t,...e)}this.baseTransform=Zt(this.ctx);if(s){xt.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[e,i,n,r]=s;const o=new Path2D;o.rect(e,i,n-e,r-i);this.ctx.clip(o);this.dependencyTracker?.recordClipBox(t,this.ctx,e,n,i,r);this.endPath(t)}}paintFormXObjectEnd(t){if(!this.contentVisible){return}this.restore(t);this.baseTransform=this.baseTransformStack.pop()}beginGroup(t,e){if(!this.contentVisible){return}this.save(t);if(this.inSMaskMode){this.endSMaskMode();this.current.activeSMask=null}const s=this.ctx;if(!e.isolated){tt("TODO: Support non-isolated groups.")}if(e.knockout){et("Knockout groups not supported.")}const i=Zt(s);if(e.matrix){s.transform(...e.matrix)}if(!e.bbox){throw new Error("Bounding box is required.")}let n=Vs.slice();xt.axialAlignedBoundingBox(e.bbox,Zt(s),n);const r=[0,0,s.canvas.width,s.canvas.height];n=xt.intersect(n,r)||[0,0,0,0];const o=Math.floor(n[0]);const a=Math.floor(n[1]);const h=Math.max(Math.ceil(n[2])-o,1);const c=Math.max(Math.ceil(n[3])-a,1);this.current.startNewPathAndClipBox([0,0,h,c]);let l="groupAt"+this.groupLevel;if(e.smask){l+="_smask_"+this.smaskCounter++%2}const u=this.cachedCanvases.getCanvas(l,h,c);const f=u.context;f.translate(-o,-a);f.transform(...i);let d=new Path2D;const[p,g,m,w]=e.bbox;d.rect(p,g,m-p,w-g);if(e.matrix){const t=new Path2D;t.addPath(d,new DOMMatrix(e.matrix));d=t}f.clip(d);if(e.smask){this.smaskStack.push({canvas:u.canvas,context:f,offsetX:o,offsetY:a,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null})}if(!e.smask||this.dependencyTracker){s.setTransform(1,0,0,1,0,0);s.translate(o,a);s.save()}Zs(s,f);this.ctx=f;this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s);this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]);this.groupStack.push(s);this.groupLevel++}endGroup(t,e){if(!this.contentVisible){return}this.groupLevel--;const s=this.ctx;const i=this.groupStack.pop();this.ctx=i;this.ctx.imageSmoothingEnabled=false;this.dependencyTracker?.popBaseTransform();if(e.smask){this.tempSMask=this.smaskStack.pop();this.restore(t);if(this.dependencyTracker){this.ctx.restore()}}else{this.ctx.restore();const e=Zt(this.ctx);this.restore(t);this.ctx.save();this.ctx.setTransform(...e);const i=Vs.slice();xt.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],e,i);this.ctx.drawImage(s.canvas,0,0);this.ctx.restore();this.compose(i)}}beginAnnotation(t,e,s,i,n,r){this.#zi();ti(this.ctx);this.ctx.save();this.save(t);if(this.baseTransform){this.ctx.setTransform(...this.baseTransform)}if(s){const n=s[2]-s[0];const o=s[3]-s[1];if(r&&this.annotationCanvasMap){i=i.slice();i[4]-=s[0];i[5]-=s[1];s=s.slice();s[0]=s[1]=0;s[2]=n;s[3]=o;xt.singularValueDecompose2dScale(Zt(this.ctx),Gs);const{viewportScale:t}=this;const r=Math.ceil(n*this.outputScaleX*t);const a=Math.ceil(o*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(r,a);const{canvas:h,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(e,h);this.annotationCanvas.savedCtx=this.ctx;this.ctx=c;this.ctx.save();this.ctx.setTransform(Gs[0],0,0,-Gs[1],0,o*Gs[1]);ti(this.ctx)}else{ti(this.ctx);this.endPath(t);const e=new Path2D;e.rect(s[0],s[1],n,o);this.ctx.clip(e)}}this.current=new Js(this.ctx.canvas.width,this.ctx.canvas.height);this.transform(t,...i);this.transform(t,...n)}endAnnotation(t){if(this.annotationCanvas){this.ctx.restore();this.#Hi();this.ctx=this.annotationCanvas.savedCtx;delete this.annotationCanvas.savedCtx;delete this.annotationCanvas}}paintImageMaskXObject(t,e){if(!this.contentVisible){return}const s=e.count;e=this.getObject(t,e.data,e);e.count=s;const i=this.ctx;const n=this._createMaskCanvas(t,e);const r=n.canvas;i.save();i.setTransform(1,0,0,1,0,0);i.drawImage(r,n.offsetX,n.offsetY);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+r.width,n.offsetY,n.offsetY+r.height).recordOperation(t);i.restore();this.compose()}paintImageMaskXObjectRepeat(t,e,s,i=0,n=0,r,o){if(!this.contentVisible){return}e=this.getObject(t,e.data,e);const a=this.ctx;a.save();const h=Zt(a);a.transform(s,i,n,r,0,0);const c=this._createMaskCanvas(t,e);a.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]);this.dependencyTracker?.resetBBox(t);for(let e=0,l=o.length;e<l;e+=2){const l=xt.transform(h,[s,i,n,r,o[e],o[e+1]]);a.drawImage(c.canvas,l[4],l[5]);this.dependencyTracker?.recordBBox(t,this.ctx,l[4],l[4]+c.canvas.width,l[5],l[5]+c.canvas.height)}a.restore();this.compose();this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible){return}const s=this.ctx;const i=this.current.fillColor;const n=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Cs.transformAndFill);for(const r of e){const{data:e,width:o,height:a,transform:h}=r;const c=this.cachedCanvases.getCanvas("maskCanvas",o,a);const l=c.context;l.save();const u=this.getObject(t,e,r);Qs(l,u);l.globalCompositeOperation="source-in";l.fillStyle=n?i.getPattern(l,this,te(s),Ts.FILL,t):i;l.fillRect(0,0,o,a);l.restore();s.save();s.transform(...h);s.scale(1,-1);Ys(s,c.canvas,0,0,o,a,0,-1,1,1);this.dependencyTracker?.recordBBox(t,s,0,o,0,a);s.restore()}this.compose();this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible){return}const s=this.getObject(t,e);if(!s){et("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,n){if(!this.contentVisible){return}const r=this.getObject(t,e);if(!r){et("Dependent image isn't ready yet");return}const o=r.width;const a=r.height;const h=[];for(let t=0,e=n.length;t<e;t+=2){h.push({transform:[s,0,0,i,n[t],n[t+1]],x:0,y:0,w:o,h:a})}this.paintInlineImageXObjectGroup(t,r,h)}applyTransferMapsToCanvas(t){if(this.current.transferMaps!=="none"){t.filter=this.current.transferMaps;t.drawImage(t.canvas,0,0);t.filter="none"}return t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none"){return t.bitmap}const{bitmap:e,width:s,height:i}=t;const n=this.cachedCanvases.getCanvas("inlineImage",s,i);const r=n.context;r.filter=this.current.transferMaps;r.drawImage(e,0,0);r.filter="none";return n.canvas}paintInlineImageXObject(t,e){if(!this.contentVisible){return}const s=e.width;const i=e.height;const n=this.ctx;this.save(t);const{filter:r}=n;if(r!=="none"&&r!==""){n.filter="none"}n.scale(1/s,-1/i);let o;if(e.bitmap){o=this.applyTransferMapsToBitmap(e)}else if(typeof HTMLElement==="function"&&e instanceof HTMLElement||!e.data){o=e}else{const t=this.cachedCanvases.getCanvas("inlineImage",s,i);const n=t.context;Ks(n,e);o=this.applyTransferMapsToCanvas(n)}const a=this._scaleImage(o,te(n));n.imageSmoothingEnabled=ei(Zt(n),e.interpolate);this.dependencyTracker?.resetBBox(t).recordBBox(t,n,0,s,-i,0).recordDependencies(t,Cs.imageXObject).recordOperation(t);Ys(n,a.img,0,0,a.paintWidth,a.paintHeight,0,-i,s,i);this.compose();this.restore(t)}paintInlineImageXObjectGroup(t,e,s){if(!this.contentVisible){return}const i=this.ctx;let n;if(e.bitmap){n=e.bitmap}else{const t=e.width;const s=e.height;const i=this.cachedCanvases.getCanvas("inlineImage",t,s);const r=i.context;Ks(r,e);n=this.applyTransferMapsToCanvas(r)}this.dependencyTracker?.resetBBox(t);for(const e of s){i.save();i.transform(...e.transform);i.scale(1,-1);Ys(i,n,e.x,e.y,e.w,e.h,0,-1,1,1);this.dependencyTracker?.recordBBox(t,i,0,1,-1,0);i.restore()}this.dependencyTracker?.recordOperation(t);this.compose()}paintSolidColorImageMask(t){if(!this.contentVisible){return}this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Cs.fill).recordOperation(t);this.ctx.fillRect(0,0,1,1);this.compose()}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t);this.markedContentStack.push({visible:true})}beginMarkedContentProps(t,e,s){this.dependencyTracker?.beginMarkedContent(t);if(e==="OC"){this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)})}else{this.markedContentStack.push({visible:true})}this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t);this.markedContentStack.pop();this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){const i=this.current.isEmptyClip();if(this.pendingClip){this.current.updateClipFromPath()}if(!this.pendingClip){this.compose(s)}const n=this.ctx;if(this.pendingClip){if(!i){if(this.pendingClip===ri){n.clip(e,"evenodd")}else{n.clip(e)}}this.pendingClip=null;this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)}else{this.dependencyTracker?.recordOperation(t)}this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Zt(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]);const s=Math.hypot(t[0],t[2]);const 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;const{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let r,o;if(s===0&&i===0){const s=Math.abs(e);const i=Math.abs(n);if(s===i){if(t===0){r=o=1/s}else{const e=s*t;r=o=e<1?1/e:1}}else if(t===0){r=1/s;o=1/i}else{const e=s*t;const n=i*t;r=e<1?1/e:1;o=n<1?1/n:1}}else{const a=Math.abs(e*n-s*i);const h=Math.hypot(e,s);const c=Math.hypot(i,n);if(t===0){r=c/a;o=h/a}else{const e=t*a;r=c>e?c/e:1;o=h>e?h/e:1}}this._cachedScaleForStroking[0]=r;this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this;const[n,r]=this.getScaleForStroking();if(n===r){s.lineWidth=(i||1)*n;s.stroke(t);return}const o=s.getLineDash();if(e){s.save()}s.scale(n,r);Ws.a=1/n;Ws.d=1/r;const a=new Path2D;a.addPath(t,Ws);if(o.length>0){const t=Math.max(n,r);s.setLineDash(o.map((e=>e/t)));s.lineDashOffset/=t}s.lineWidth=i||1;s.stroke(a);if(e){s.restore()}}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--){if(!this.markedContentStack[t].visible){return false}}return true}}for(const t in q){if(oi.prototype[t]!==undefined){oi.prototype[q[t]]=oi.prototype[t]}}class ai{static#Gi=null;static#Vi="";static get workerPort(){return this.#Gi}static set workerPort(t){if(!(typeof Worker!=="undefined"&&t instanceof Worker)&&t!==null){throw new Error("Invalid `workerPort` type.")}this.#Gi=t}static get workerSrc(){return this.#Vi}static set workerSrc(t){if(typeof t!=="string"){throw new Error("Invalid `workerSrc` type.")}this.#Vi=t}}class hi{#Xi;#qi;constructor({parsedData:t,rawData:e}){this.#Xi=t;this.#qi=e}getRaw(){return this.#qi}get(t){return this.#Xi.get(t)??null}[Symbol.iterator](){return this.#Xi.entries()}}const ci=Symbol("INTERNAL");class li{#Yi=false;#Ji=false;#Ki=false;#Qi=true;constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){this.#Yi=!!(t&$.DISPLAY);this.#Ji=!!(t&$.PRINT);this.name=e;this.intent=s;this.usage=i;this.rbGroups=n}get visible(){if(this.#Ki){return this.#Qi}if(!this.#Qi){return false}const{print:t,view:e}=this.usage;if(this.#Yi){return e?.viewState!=="OFF"}else if(this.#Ji){return t?.printState!=="OFF"}return true}_setVisible(t,e,s=false){if(t!==ci){st("Internal method `_setVisible` called.")}this.#Ki=s;this.#Qi=e}}class ui{#Zi=null;#tn=new Map;#en=null;#sn=null;constructor(t,e=$.DISPLAY){this.renderingIntent=e;this.name=null;this.creator=null;if(t===null){return}this.name=t.name;this.creator=t.creator;this.#sn=t.order;for(const s of t.groups){this.#tn.set(s.id,new li(e,s))}if(t.baseState==="OFF"){for(const t of this.#tn.values()){t._setVisible(ci,false)}}for(const e of t.on){this.#tn.get(e)._setVisible(ci,true)}for(const e of t.off){this.#tn.get(e)._setVisible(ci,false)}this.#en=this.getHash()}#in(t){const e=t.length;if(e<2){return true}const s=t[0];for(let i=1;i<e;i++){const e=t[i];let n;if(Array.isArray(e)){n=this.#in(e)}else if(this.#tn.has(e)){n=this.#tn.get(e).visible}else{et(`Optional content group not found: ${e}`);return true}switch(s){case"And":if(!n){return false}break;case"Or":if(n){return true}break;case"Not":return!n;default:return true}}return s==="And"}isVisible(t){if(this.#tn.size===0){return true}if(!t){tt("Optional content group not defined.");return true}if(t.type==="OCG"){if(!this.#tn.has(t.id)){et(`Optional content group not found: ${t.id}`);return true}return this.#tn.get(t.id).visible}else if(t.type==="OCMD"){if(t.expression){return this.#in(t.expression)}if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#tn.has(e)){et(`Optional content group not found: ${e}`);return true}if(this.#tn.get(e).visible){return true}}return false}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#tn.has(e)){et(`Optional content group not found: ${e}`);return true}if(!this.#tn.get(e).visible){return false}}return true}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#tn.has(e)){et(`Optional content group not found: ${e}`);return true}if(!this.#tn.get(e).visible){return true}}return false}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#tn.has(e)){et(`Optional content group not found: ${e}`);return true}if(this.#tn.get(e).visible){return false}}return true}et(`Unknown optional content policy ${t.policy}.`);return true}et(`Unknown group type ${t.type}.`);return true}setVisibility(t,e=true,s=true){const i=this.#tn.get(t);if(!i){et(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length){for(const e of i.rbGroups){for(const s of e){if(s!==t){this.#tn.get(s)?._setVisible(ci,false,true)}}}}i._setVisible(ci,!!e,true);this.#Zi=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 t=this.#tn.get(i);if(!t){continue}switch(s){case"ON":this.setVisibility(i,true,e);break;case"OFF":this.setVisibility(i,false,e);break;case"Toggle":this.setVisibility(i,!t.visible,e);break}}this.#Zi=null}get hasInitialVisibility(){return this.#en===null||this.getHash()===this.#en}getOrder(){if(!this.#tn.size){return null}if(this.#sn){return this.#sn.slice()}return[...this.#tn.keys()]}getGroup(t){return this.#tn.get(t)||null}getHash(){if(this.#Zi!==null){return this.#Zi}const t=new Re;for(const[e,s]of this.#tn){t.update(`${e}:${s.visible}`)}return this.#Zi=t.hexdigest()}[Symbol.iterator](){return this.#tn.entries()}}class fi{constructor(t,{disableRange:e=false,disableStream:s=false}){it(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:o}=t;this._queuedChunks=[];this._progressiveDone=r;this._contentDispositionFilename=o;if(n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t;this._isStreamingSupported=!s;this._isRangeSupported=!e;this._contentLength=i;this._fullRequestReader=null;this._rangeReaders=[];t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})}));t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})}));t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})}));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===undefined){if(this._fullRequestReader){this._fullRequestReader._enqueue(s)}else{this._queuedChunks.push(s)}}else{const e=this._rangeReaders.some((function(e){if(e._begin!==t){return false}e._enqueue(s);return true}));it(e,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){if(t.total===undefined){this._rangeReaders[0]?.onProgress?.({loaded:t.loaded})}else{this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}}_onProgressiveDone(){this._fullRequestReader?.progressiveDone();this._progressiveDone=true}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);if(e>=0){this._rangeReaders.splice(e,1)}}getFullReader(){it(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;this._queuedChunks=null;return new di(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength){return null}const s=new pi(this,t,e);this._pdfDataRangeTransport.requestDataRange(t,e);this._rangeReaders.push(s);return s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0)){e.cancel(t)}this._pdfDataRangeTransport.abort()}}class di{constructor(t,e,s=false,i=null){this._stream=t;this._done=s||false;this._filename=jt(i)?i:null;this._queuedChunks=e||[];this._loaded=0;for(const t of this._queuedChunks){this._loaded+=t.byteLength}this._requests=[];this._headersReady=Promise.resolve();t._fullRequestReader=this;this.onProgress=null}_enqueue(t){if(this._done){return}if(this._requests.length>0){const e=this._requests.shift();e.resolve({value:t,done:false})}else{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){const t=this._queuedChunks.shift();return{value:t,done:false}}if(this._done){return{value:undefined,done:true}}const t=Promise.withResolvers();this._requests.push(t);return t.promise}cancel(t){this._done=true;for(const t of this._requests){t.resolve({value:undefined,done:true})}this._requests.length=0}progressiveDone(){if(this._done){return}this._done=true}}class pi{constructor(t,e,s){this._stream=t;this._begin=e;this._end=s;this._queuedChunk=null;this._requests=[];this._done=false;this.onProgress=null}_enqueue(t){if(this._done){return}if(this._requests.length===0){this._queuedChunk=t}else{const e=this._requests.shift();e.resolve({value:t,done:false});for(const t of this._requests){t.resolve({value:undefined,done:true})}this._requests.length=0}this._done=true;this._stream._removeRangeReader(this)}get isStreamingSupported(){return false}async read(){if(this._queuedChunk){const t=this._queuedChunk;this._queuedChunk=null;return{value:t,done:false}}if(this._done){return{value:undefined,done:true}}const t=Promise.withResolvers();this._requests.push(t);return t.promise}cancel(t){this._done=true;for(const t of this._requests){t.resolve({value:undefined,done:true})}this._requests.length=0;this._stream._removeRangeReader(this)}}function gi(t){let e=true;let s=i("filename\\*","i").exec(t);if(s){s=s[1];let t=a(s);t=unescape(t);t=h(t);t=c(t);return r(t)}s=o(t);if(s){const t=c(s);return r(t)}s=i("filename","i").exec(t);if(s){s=s[1];let t=a(s);t=c(t);return r(t)}function i(t,e){return new RegExp("(?:^|;)\\s*"+t+"\\s*=\\s*"+"("+'[^";\\s][^;\\s]*'+"|"+'"(?:[^"\\\\]|\\\\"?)+"?'+")",e)}function n(t,s){if(t){if(!/^[\x00-\xFF]+$/.test(s)){return s}try{const i=new TextDecoder(t,{fatal:true});const n=mt(s);s=i.decode(n);e=false}catch{}}return s}function r(t){if(e&&/[\x80-\xff]/.test(t)){t=n("utf-8",t);if(e){t=n("iso-8859-1",t)}}return t}function o(t){const e=[];let s;const n=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");while((s=n.exec(t))!==null){let[,t,i,n]=s;t=parseInt(t,10);if(t in e){if(t===0){break}continue}e[t]=[i,n]}const r=[];for(let t=0;t<e.length;++t){if(!(t in e)){break}let[s,i]=e[t];i=a(i);if(s){i=unescape(i);if(t===0){i=h(i)}}r.push(i)}return r.join("")}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const s=e[t].indexOf('"');if(s!==-1){e[t]=e[t].slice(0,s);e.length=t+1}e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function h(t){const e=t.indexOf("'");if(e===-1){return t}const s=t.slice(0,e);const i=t.slice(e+1);const r=i.replace(/^[^']*'/,"");return n(s,r)}function c(t){if(!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)){return t}return t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,s,i){if(s==="q"||s==="Q"){i=i.replaceAll("_"," ");i=i.replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))}));return n(e,i)}try{i=atob(i)}catch{}return n(e,i)}))}return""}function mi(t,e){const s=new Headers;if(!t||!e||typeof e!=="object"){return s}for(const t in e){const i=e[t];if(i!==undefined){s.append(t,i)}}return s}function wi(t){return URL.parse(t)?.origin??null}function bi({responseHeaders:t,isHttp:e,rangeChunkSize:s,disableRange:i}){const n={allowRangeRequests:false,suggestedLength:undefined};const r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r)){return n}n.suggestedLength=r;if(r<=2*s){return n}if(i||!e){return n}if(t.get("Accept-Ranges")!=="bytes"){return n}const o=t.get("Content-Encoding")||"identity";if(o!=="identity"){return n}n.allowRangeRequests=true;return n}function Ai(t){const e=t.get("Content-Disposition");if(e){let t=gi(e);if(t.includes("%")){try{t=decodeURIComponent(t)}catch{}}if(jt(t)){return t}}return null}function yi(t,e){return new ft(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,t===404||t===0&&e.startsWith("file:"))}function vi(t){return t===200||t===206}function xi(t,e,s){return{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function ki(t){if(t instanceof Uint8Array){return t.buffer}if(t instanceof ArrayBuffer){return t}et(`getArrayBuffer - unexpected data format: ${t}`);return new Uint8Array(t).buffer}class Si{_responseOrigin=null;constructor(t){this.source=t;this.isHttp=/^https?:/i.test(t.url);this.headers=mi(this.isHttp,t.httpHeaders);this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){it(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once.");this._fullRequestReader=new Mi(this);return this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength){return null}const s=new Ci(this,t,e);this._rangeRequestReaders.push(s);return s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0)){e.cancel(t)}}}class Mi{constructor(t){this._stream=t;this._reader=null;this._loaded=0;this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||false;this._contentLength=e.length;this._headersCapability=Promise.withResolvers();this._disableRange=e.disableRange||false;this._rangeChunkSize=e.rangeChunkSize;if(!this._rangeChunkSize&&!this._disableRange){this._disableRange=true}this._abortController=new AbortController;this._isStreamingSupported=!e.disableStream;this._isRangeSupported=!e.disableRange;const s=new Headers(t.headers);const i=e.url;fetch(i,xi(s,this._withCredentials,this._abortController)).then((e=>{t._responseOrigin=wi(e.url);if(!vi(e.status)){throw yi(e.status,i)}this._reader=e.body.getReader();this._headersCapability.resolve();const s=e.headers;const{allowRangeRequests:n,suggestedLength:r}=bi({responseHeaders:s,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n;this._contentLength=r||this._contentLength;this._filename=Ai(s);if(!this._isStreamingSupported&&this._isRangeSupported){this.cancel(new pt("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();if(e){return{value:t,done:e}}this._loaded+=t.byteLength;this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:ki(t),done:false}}cancel(t){this._reader?.cancel(t);this._abortController.abort()}}class Ci{constructor(t,e,s){this._stream=t;this._reader=null;this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||false;this._readCapability=Promise.withResolvers();this._isStreamingSupported=!i.disableStream;this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${s-1}`);const r=i.url;fetch(r,xi(n,this._withCredentials,this._abortController)).then((e=>{const s=wi(e.url);if(s!==t._responseOrigin){throw new Error(`Expected range response-origin "${s}" to match "${t._responseOrigin}".`)}if(!vi(e.status)){throw yi(e.status,r)}this._readCapability.resolve();this._reader=e.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();if(e){return{value:t,done:e}}this._loaded+=t.byteLength;this.onProgress?.({loaded:this._loaded});return{value:ki(t),done:false}}cancel(t){this._reader?.cancel(t);this._abortController.abort()}}const Ti=200;const Ei=206;function Pi(t){const e=t.response;if(typeof e!=="string"){return e}return mt(e).buffer}class Ni{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t;this.isHttp=/^https?:/i.test(t);this.headers=mi(this.isHttp,e);this.withCredentials=s||false;this.currXhrId=0;this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest;const s=this.currXhrId++;const i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url);e.withCredentials=this.withCredentials;for(const[t,s]of this.headers){e.setRequestHeader(t,s)}if(this.isHttp&&"begin"in t&&"end"in t){e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`);i.expectedStatus=Ei}else{i.expectedStatus=Ti}e.responseType="arraybuffer";it(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);return s}onProgress(t,e){const s=this.pendingRequests[t];if(!s){return}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}if(i.readyState!==4){return}if(!(t in this.pendingRequests)){return}delete this.pendingRequests[t];if(i.status===0&&this.isHttp){s.onError(i.status);return}const n=i.status||Ti;const r=n===Ti&&s.expectedStatus===Ei;if(!r&&n!==s.expectedStatus){s.onError(i.status);return}const o=Pi(i);if(n===Ei){const t=i.getResponseHeader("Content-Range");const e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);if(e){s.onDone({begin:parseInt(e[1],10),chunk:o})}else{et(`Missing or invalid "Content-Range" header.`);s.onError(0)}}else if(o){s.onDone({begin:0,chunk:o})}else{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 Di{constructor(t){this._source=t;this._manager=new Ni(t);this._rangeChunkSize=t.rangeChunkSize;this._fullRequestReader=null;this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);if(e>=0){this._rangeRequestReaders.splice(e,1)}}getFullReader(){it(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once.");this._fullRequestReader=new Ii(this._manager,this._source);return this._fullRequestReader}getRangeReader(t,e){const s=new Ri(this._manager,t,e);s.onClosed=this._onRangeRequestReaderClosed.bind(this);this._rangeRequestReaders.push(s);return s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0)){e.cancel(t)}}}class Ii{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||false;this._contentLength=e.length;this._rangeChunkSize=e.rangeChunkSize;if(!this._rangeChunkSize&&!this._disableRange){this._disableRange=true}this._isStreamingSupported=false;this._isRangeSupported=false;this._cachedChunks=[];this._requests=[];this._done=false;this._storedError=undefined;this._filename=null;this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId;const e=this._manager.getRequestXhr(t);this._manager._responseOrigin=wi(e.responseURL);const s=e.getAllResponseHeaders();const i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...s]=t.split(": ");return[e,s.join(": ")]})):[]);const{allowRangeRequests:n,suggestedLength:r}=bi({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});if(n){this._isRangeSupported=true}this._contentLength=r||this._contentLength;this._filename=Ai(i);if(this._isRangeSupported){this._manager.abortRequest(t)}this._headersCapability.resolve()}_onDone(t){if(t){if(this._requests.length>0){const e=this._requests.shift();e.resolve({value:t.chunk,done:false})}else{this._cachedChunks.push(t.chunk)}}this._done=true;if(this._cachedChunks.length>0){return}for(const t of this._requests){t.resolve({value:undefined,done:true})}this._requests.length=0}_onError(t){this._storedError=yi(t,this._url);this._headersCapability.reject(this._storedError);for(const t of this._requests){t.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(){await this._headersCapability.promise;if(this._storedError){throw this._storedError}if(this._cachedChunks.length>0){const t=this._cachedChunks.shift();return{value:t,done:false}}if(this._done){return{value:undefined,done:true}}const t=Promise.withResolvers();this._requests.push(t);return t.promise}cancel(t){this._done=true;this._headersCapability.reject(t);for(const t of this._requests){t.resolve({value:undefined,done:true})}this._requests.length=0;if(this._manager.isPendingRequest(this._fullRequestId)){this._manager.abortRequest(this._fullRequestId)}this._fullRequestReader=null}}class Ri{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=false;this._storedError=undefined;this.onProgress=null;this.onClosed=null}_onHeadersReceived(){const t=wi(this._manager.getRequestXhr(this._requestId)?.responseURL);if(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;if(this._requests.length>0){const t=this._requests.shift();t.resolve({value:e,done:false})}else{this._queuedChunk=e}this._done=true;for(const t of this._requests){t.resolve({value:undefined,done:true})}this._requests.length=0;this._close()}_onError(t){this._storedError??=yi(t,this._url);for(const t of this._requests){t.reject(this._storedError)}this._requests.length=0;this._queuedChunk=null}_onProgress(t){if(!this.isStreamingSupported){this.onProgress?.({loaded:t.loaded})}}get isStreamingSupported(){return false}async read(){if(this._storedError){throw this._storedError}if(this._queuedChunk!==null){const t=this._queuedChunk;this._queuedChunk=null;return{value:t,done:false}}if(this._done){return{value:undefined,done:true}}const t=Promise.withResolvers();this._requests.push(t);return t.promise}cancel(t){this._done=true;for(const t of this._requests){t.resolve({value:undefined,done:true})}this._requests.length=0;if(this._manager.isPendingRequest(this._requestId)){this._manager.abortRequest(this._requestId)}this._close()}}const Fi=/^[a-z][a-z0-9\-+.]+:/i;function Oi(t){if(Fi.test(t)){return new URL(t)}const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}class $i{constructor(t){this.source=t;this.url=Oi(t.url);it(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs.");this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){it(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once.");this._fullRequestReader=new _i(this);return this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength){return null}const s=new Bi(this,t,e);this._rangeRequestReaders.push(s);return s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0)){e.cancel(t)}}}class _i{constructor(t){this._url=t.url;this._done=false;this._storedError=null;this.onProgress=null;const e=t.source;this._contentLength=e.length;this._loaded=0;this._filename=null;this._disableRange=e.disableRange||false;this._rangeChunkSize=e.rangeChunkSize;if(!this._rangeChunkSize&&!this._disableRange){this._disableRange=true}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((t=>{this._contentLength=t.size;this._setReadableStream(s.createReadStream(this._url));this._headersCapability.resolve()}),(t=>{if(t.code==="ENOENT"){t=yi(0,this._url.href)}this._storedError=t;this._headersCapability.reject(t)}))}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._readCapability.promise;if(this._done){return{value:undefined,done:true}}if(this._storedError){throw this._storedError}const t=this._readableStream.read();if(t===null){this._readCapability=Promise.withResolvers();return this.read()}this._loaded+=t.length;this.onProgress?.({loaded:this._loaded,total:this._contentLength});const e=new Uint8Array(t).buffer;return{value:e,done:false}}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=true;this._readCapability.resolve()}));t.on("error",(t=>{this._error(t)}));if(!this._isStreamingSupported&&this._isRangeSupported){this._error(new pt("streaming is disabled"))}if(this._storedError){this._readableStream.destroy(this._storedError)}}}class Bi{constructor(t,e,s){this._url=t.url;this._done=false;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 n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;if(this._done){return{value:undefined,done:true}}if(this._storedError){throw this._storedError}const t=this._readableStream.read();if(t===null){this._readCapability=Promise.withResolvers();return this.read()}this._loaded+=t.length;this.onProgress?.({loaded:this._loaded});const e=new Uint8Array(t).buffer;return{value:e,done:false}}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=true;this._readCapability.resolve()}));t.on("error",(t=>{this._error(t)}));if(this._storedError){this._readableStream.destroy(this._storedError)}}}const Li=Symbol("INITIAL_DATA");class Ui{#nn=Object.create(null);#rn(t){return this.#nn[t]||={...Promise.withResolvers(),data:Li}}get(t,e=null){if(e){const s=this.#rn(t);s.promise.then((()=>e(s.data)));return null}const s=this.#nn[t];if(!s||s.data===Li){throw new Error(`Requesting object that isn't resolved yet ${t}.`)}return s.data}has(t){const e=this.#nn[t];return!!e&&e.data!==Li}delete(t){const e=this.#nn[t];if(!e||e.data===Li){return false}delete this.#nn[t];return true}resolve(t,e=null){const s=this.#rn(t);s.data=e;s.resolve()}clear(){for(const t in this.#nn){const{data:e}=this.#nn[t];e?.bitmap?.close()}this.#nn=Object.create(null)}*[Symbol.iterator](){for(const t in this.#nn){const{data:e}=this.#nn[t];if(e===Li){continue}yield[t,e]}}}const ji=1e5;const zi=30;class Hi{#on=Promise.withResolvers();#Mt=null;#an=false;#hn=!!globalThis.FontInspector?.enabled;#cn=null;#ln=null;#un=0;#fn=0;#dn=null;#pn=null;#gn=0;#mn=0;#wn=Object.create(null);#bn=[];#An=null;#yn=[];#vn=new WeakMap;#xn=null;static#kn=new Map;static#Sn=new Map;static#Mn=new WeakMap;static#Cn=null;static#Tn=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream){this.#An=t}else if(typeof t==="object"){this.#An=new ReadableStream({start(e){e.enqueue(t);e.close()}})}else{throw new Error('No "textContentSource" parameter specified.')}this.#Mt=this.#pn=e;this.#mn=s.scale*se.pixelRatio;this.#gn=s.rotation;this.#ln={div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:n,pageX:r,pageY:o}=s.rawDims;this.#xn=[1,0,0,-1,-r,o+n];this.#fn=i;this.#un=n;Hi.#En();ee(e,s);this.#on.promise.finally((()=>{Hi.#Tn.delete(this);this.#ln=null;this.#wn=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=yt.platform;return at(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{this.#dn.read().then((({value:e,done:s})=>{if(s){this.#on.resolve();return}this.#cn??=e.lang;Object.assign(this.#wn,e.styles);this.#Pn(e.items);t()}),this.#on.reject)};this.#dn=this.#An.getReader();Hi.#Tn.add(this);t();return this.#on.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*se.pixelRatio;const i=t.rotation;if(i!==this.#gn){e?.();this.#gn=i;ee(this.#pn,{rotation:i})}if(s!==this.#mn){e?.();this.#mn=s;const t={div:null,properties:null,ctx:Hi.#Nn(this.#cn)};for(const e of this.#yn){t.properties=this.#vn.get(e);t.div=e;this.#Dn(t)}}}cancel(){const t=new pt("TextLayer task cancelled.");this.#dn?.cancel(t).catch((()=>{}));this.#dn=null;this.#on.reject(t)}get textDivs(){return this.#yn}get textContentItemsStr(){return this.#bn}#Pn(t){if(this.#an){return}this.#ln.ctx??=Hi.#Nn(this.#cn);const e=this.#yn,s=this.#bn;for(const i of t){if(e.length>ji){et("Ignoring additional textDivs for performance reasons.");this.#an=true;return}if(i.str===undefined){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const t=this.#Mt;this.#Mt=document.createElement("span");this.#Mt.classList.add("markedContent");if(i.id){this.#Mt.setAttribute("id",`${i.id}`)}t.append(this.#Mt)}else if(i.type==="endMarkedContent"){this.#Mt=this.#Mt.parentNode}continue}s.push(i.str);this.#In(i)}}#In(t){const e=document.createElement("span");const s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#yn.push(e);const i=xt.transform(this.#xn,t.transform);let n=Math.atan2(i[1],i[0]);const r=this.#wn[t.fontName];if(r.vertical){n+=Math.PI/2}let o=this.#hn&&r.fontSubstitution||r.fontFamily;o=Hi.fontFamilyMap.get(o)||o;const a=Math.hypot(i[2],i[3]);const h=a*Hi.#Rn(o,r,this.#cn);let c,l;if(n===0){c=i[4];l=i[5]-h}else{c=i[4]+h*Math.sin(n);l=i[5]-h*Math.cos(n)}const u="calc(var(--total-scale-factor) *";const f=e.style;if(this.#Mt===this.#pn){f.left=`${(100*c/this.#fn).toFixed(2)}%`;f.top=`${(100*l/this.#un).toFixed(2)}%`}else{f.left=`${u}${c.toFixed(2)}px)`;f.top=`${u}${l.toFixed(2)}px)`}f.fontSize=`${u}${(Hi.#Cn*a).toFixed(2)}px)`;f.fontFamily=o;s.fontSize=a;e.setAttribute("role","presentation");e.textContent=t.str;e.dir=t.dir;if(this.#hn){e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName}if(n!==0){s.angle=n*(180/Math.PI)}let d=false;if(t.str.length>1){d=true}else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),s=Math.abs(t.transform[3]);if(e!==s&&Math.max(e,s)/Math.min(e,s)>1.5){d=true}}if(d){s.canvasWidth=r.vertical?t.height:t.width}this.#vn.set(e,s);this.#ln.div=e;this.#ln.properties=s;this.#Dn(this.#ln);if(s.hasText){this.#Mt.append(e)}if(s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation");this.#Mt.append(t)}}#Dn(t){const{div:e,properties:s,ctx:i}=t;const{style:n}=e;let r="";if(Hi.#Cn>1){r=`scale(${1/Hi.#Cn})`}if(s.canvasWidth!==0&&s.hasText){const{fontFamily:t}=n;const{canvasWidth:o,fontSize:a}=s;Hi.#Fn(i,a*this.#mn,t);const{width:h}=i.measureText(e.textContent);if(h>0){r=`scaleX(${o*this.#mn/h}) ${r}`}}if(s.angle!==0){r=`rotate(${s.angle}deg) ${r}`}if(r.length>0){n.transform=r}}static cleanup(){if(this.#Tn.size>0){return}this.#kn.clear();for(const{canvas:t}of this.#Sn.values()){t.remove()}this.#Sn.clear()}static#Nn(t=null){let e=this.#Sn.get(t||="");if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement";s.lang=t;document.body.append(s);e=s.getContext("2d",{alpha:false,willReadFrequently:true});this.#Sn.set(t,e);this.#Mn.set(e,{size:0,family:""})}return e}static#Fn(t,e,s){const i=this.#Mn.get(t);if(e===i.size&&s===i.family){return}t.font=`${e}px ${s}`;i.size=e;i.family=s}static#En(){if(this.#Cn!==null){return}const t=document.createElement("div");t.style.opacity=0;t.style.lineHeight=1;t.style.fontSize="1px";t.style.position="absolute";t.textContent="X";document.body.append(t);this.#Cn=t.getBoundingClientRect().height;t.remove()}static#Rn(t,e,s){const i=this.#kn.get(t);if(i){return i}const n=this.#Nn(s);n.canvas.width=n.canvas.height=zi;this.#Fn(n,zi,t);const r=n.measureText("");const o=r.fontBoundingBoxAscent;const a=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let h=.8;if(o){h=o/(o+a)}else{if(yt.platform.isFirefox){et("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference "+"in `about:config` to improve TextLayer rendering.")}if(e.ascent){h=e.ascent}else if(e.descent){h=1+e.descent}}this.#kn.set(t,h);return h}}const Wi=100;function Gi(t={}){if(typeof t==="string"||t instanceof URL){t={url:t}}else if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){t={data:t}}const e=new Vi;const{docId:s}=e;const i=t.url?He(t.url):null;const n=t.data?We(t.data):null;const r=t.httpHeaders||null;const o=t.withCredentials===true;const a=t.password??null;const h=t.range instanceof Xi?t.range:null;const c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:2**16;let l=t.worker instanceof Ji?t.worker:null;const u=t.verbosity;const f=typeof t.docBaseUrl==="string"&&!Ut(t.docBaseUrl)?t.docBaseUrl:null;const d=Ge(t.cMapUrl);const p=t.cMapPacked!==false;const g=t.CMapReaderFactory||(R?ps:ns);const m=Ge(t.iccUrl);const w=Ge(t.standardFontDataUrl);const b=t.StandardFontDataFactory||(R?gs:hs);const A=Ge(t.wasmUrl);const y=t.WasmFactory||(R?ms:ls);const v=t.stopAtErrors!==true;const x=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1;const k=t.isEvalSupported!==false;const S=typeof t.isOffscreenCanvasSupported==="boolean"?t.isOffscreenCanvasSupported:!R;const M=typeof t.isImageDecoderSupported==="boolean"?t.isImageDecoderSupported:!R&&(yt.platform.isFirefox||!globalThis.chrome);const C=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1;const T=typeof t.disableFontFace==="boolean"?t.disableFontFace:R;const E=t.fontExtraProperties===true;const P=t.enableXfa===true;const N=t.ownerDocument||globalThis.document;const D=t.disableRange===true;const I=t.disableStream===true;const F=t.disableAutoFetch===true;const O=t.pdfBug===true;const $=t.CanvasFactory||(R?ds:ss);const _=t.FilterFactory||(R?fs:os);const B=t.enableHWA===true;const L=t.useWasm!==false;const U=h?h.length:t.length??NaN;const j=typeof t.useSystemFonts==="boolean"?t.useSystemFonts:!R&&!T;const z=typeof t.useWorkerFetch==="boolean"?t.useWorkerFetch:!!(g===ns&&b===hs&&y===ls&&d&&w&&A&&Gt(d,document.baseURI)&&Gt(w,document.baseURI)&&Gt(A,document.baseURI));const H=null;Q(u);const W={canvasFactory:new $({ownerDocument:N,enableHWA:B}),filterFactory:new _({docId:s,ownerDocument:N}),cMapReaderFactory:z?null:new g({baseUrl:d,isCompressed:p}),standardFontDataFactory:z?null:new b({baseUrl:w}),wasmFactory:z?null:new y({baseUrl:A})};if(!l){l=Ji.create({verbosity:u,port:ai.workerPort});e._worker=l}const G={docId:s,apiVersion:"5.4.449",data:n,password:a,disableAutoFetch:F,rangeChunkSize:c,length:U,docBaseUrl:f,enableXfa:P,evaluatorOptions:{maxImageSize:x,disableFontFace:T,ignoreErrors:v,isEvalSupported:k,isOffscreenCanvasSupported:S,isImageDecoderSupported:M,canvasMaxAreaInBytes:C,fontExtraProperties:E,useSystemFonts:j,useWasm:L,useWorkerFetch:z,cMapUrl:d,iccUrl:m,standardFontDataUrl:w,wasmUrl:A}};const V={ownerDocument:N,pdfBug:O,styleElement:H,loadingParams:{disableAutoFetch:F,enableXfa:P}};l.promise.then((function(){if(e.destroyed){throw new Error("Loading aborted")}if(l.destroyed){throw new Error("Worker was destroyed")}const t=l.messageHandler.sendWithPromise("GetDocRequest",G,n?[n.buffer]:null);let a;if(h){a=new fi(h,{disableRange:D,disableStream:I})}else if(!n){if(!i){throw new Error("getDocument - no `url` parameter provided.")}const t=Gt(i)?Si:R?$i:Di;a=new t({url:i,length:U,httpHeaders:r,withCredentials:o,rangeChunkSize:c,disableRange:D,disableStream:I})}return t.then((t=>{if(e.destroyed){throw new Error("Loading aborted")}if(l.destroyed){throw new Error("Worker was destroyed")}const i=new ts(s,t,l.port);const n=new Ki(i,e,a,V,W,B);e._transport=n;i.send("Ready",null)}))})).catch(e._capability.reject);return e}class Vi{static#ni=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${Vi.#ni++}`;destroyed=false;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=true;try{if(this._worker?.port){this._worker._pendingDestroy=true}await(this._transport?.destroy())}catch(t){if(this._worker?.port){delete this._worker._pendingDestroy}throw t}this._transport=null;this._worker?.destroy();this._worker=null}async getData(){return this._transport.getData()}}class Xi{#on=Promise.withResolvers();#On=[];#$n=[];#_n=[];#Bn=[];constructor(t,e,s=false,i=null){this.length=t;this.initialData=e;this.progressiveDone=s;this.contentDispositionFilename=i}addRangeListener(t){this.#Bn.push(t)}addProgressListener(t){this.#_n.push(t)}addProgressiveReadListener(t){this.#$n.push(t)}addProgressiveDoneListener(t){this.#On.push(t)}onDataRange(t,e){for(const s of this.#Bn){s(t,e)}}onDataProgress(t,e){this.#on.promise.then((()=>{for(const s of this.#_n){s(t,e)}}))}onDataProgressiveRead(t){this.#on.promise.then((()=>{for(const e of this.#$n){e(t)}}))}onDataProgressiveDone(){this.#on.promise.then((()=>{for(const t of this.#On){t()}}))}transportReady(){this.#on.resolve()}requestDataRange(t,e){st("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class qi{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 at(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}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()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=false){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Yi{#Ln=false;constructor(t,e,s,i=false){this._pageIndex=t;this._pageInfo=e;this._transport=s;this._stats=i?new Wt:null;this._pdfBug=i;this.commonObjs=s.commonObjs;this.objs=new Ui;this._intentStates=new Map;this.destroyed=false;this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=false}={}){return new Bt({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return at(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:n=_.ENABLE,transform:r=null,background:o=null,optionalContentConfigPromise:a=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:l=null,isEditing:u=false,recordOperations:f=false,operationsFilter:d=null}){this._stats?.time("Overall");const p=this._transport.getRenderingIntent(i,n,l,u);const{renderingIntent:g,cacheKey:m}=p;this.#Ln=false;a||=this._transport.getOptionalContentConfig(g);let w=this._intentStates.get(m);if(!w){w=Object.create(null);this._intentStates.set(m,w)}if(w.streamReaderCancelTimeout){clearTimeout(w.streamReaderCancelTimeout);w.streamReaderCancelTimeout=null}const b=!!(g&$.PRINT);if(!w.displayReadyCapability){w.displayReadyCapability=Promise.withResolvers();w.operatorList={fnArray:[],argsArray:[],lastChunk:false,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(p)}const A=Boolean(this._pdfBug&&globalThis.StepperManager?.enabled);const y=!this.recordedBBoxes&&(f||A);const v=t=>{w.renderTasks.delete(x);if(y){const t=x.gfx?.dependencyTracker.take();if(t){if(x.stepper){x.stepper.setOperatorBBoxes(t,x.gfx.dependencyTracker.takeDebugMetadata())}if(f){this.recordedBBoxes=t}}}if(b){this.#Ln=true}this.#Un();if(t){x.capability.reject(t);this._abortOperatorList({intentState:w,reason:t instanceof Error?t:new Error(t)})}else{x.capability.resolve()}if(this._stats){this._stats.timeEnd("Rendering");this._stats.timeEnd("Overall");if(globalThis.Stats?.enabled){globalThis.Stats.add(this.pageNumber,this._stats)}}};const x=new Zi({callback:v,params:{canvas:e,canvasContext:t,dependencyTracker:y?new Ss(e,w.operatorList.length,A):null,viewport:s,transform:r,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:w.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:d});(w.renderTasks||=new Set).add(x);const k=x.task;Promise.all([w.displayReadyCapability.promise,a]).then((([t,e])=>{if(this.destroyed){v();return}this._stats?.time("Rendering");if(!(e.renderingIntent&g)){throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` "+"and `PDFDocumentProxy.getOptionalContentConfig` methods.")}x.initializeGraphics({transparency:t,optionalContentConfig:e});x.operatorListChanged()})).catch(v);return k}getOperatorList({intent:t="display",annotationMode:e=_.ENABLE,printAnnotationStorage:s=null,isEditing:i=false}={}){function n(){if(o.operatorList.lastChunk){o.opListReadCapability.resolve(o.operatorList);o.renderTasks.delete(a)}}const r=this._transport.getRenderingIntent(t,e,s,i,true);let o=this._intentStates.get(r.cacheKey);if(!o){o=Object.create(null);this._intentStates.set(r.cacheKey,o)}let a;if(!o.opListReadCapability){a=Object.create(null);a.operatorListChanged=n;o.opListReadCapability=Promise.withResolvers();(o.renderTasks||=new Set).add(a);o.operatorList={fnArray:[],argsArray:[],lastChunk:false,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(r)}return o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=false,disableNormalization:e=false}={}){const s=100;return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===true,disableNormalization:e===true},{highWaterMark:s,size(t){return t.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa){return this.getXfa().then((t=>Rt.textContent(t)))}const e=this.streamTextContent(t);return new Promise((function(t,s){function i(){n.read().then((function({value:e,done:s}){if(s){t(r);return}r.lang??=e.lang;Object.assign(r.styles,e.styles);r.items.push(...e.items);i()}),s)}const n=e.getReader();const r={items:[],styles:Object.create(null),lang:null};i()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=true;const t=[];for(const e of this._intentStates.values()){this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:true});if(e.opListReadCapability){continue}for(const s of e.renderTasks){t.push(s.completed);s.cancel()}}this.objs.clear();this.#Ln=false;return Promise.all(t)}cleanup(t=false){this.#Ln=true;const e=this.#Un();if(t&&e){this._stats&&=new Wt}return e}#Un(){if(!this.#Ln||this.destroyed){return false}for(const{renderTasks:t,operatorList:e}of this._intentStates.values()){if(t.size>0||!e.lastChunk){return false}}this._intentStates.clear();this.objs.clear();this.#Ln=false;return true}_startRenderPage(t,e){const s=this._intentStates.get(e);if(!s){return}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 t of e.renderTasks){t.operatorListChanged()}if(t.lastChunk){this.#Un()}}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:n,transfer:r}=s;const o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},r);const a=o.getReader();const h=this._intentStates.get(e);h.streamReader=a;const c=()=>{a.read().then((({value:t,done:e})=>{if(e){h.streamReader=null;return}if(this._transport.destroyed){return}this._renderPageChunk(t,h);c()}),(t=>{h.streamReader=null;if(this._transport.destroyed){return}if(h.operatorList){h.operatorList.lastChunk=true;for(const t of h.renderTasks){t.operatorListChanged()}this.#Un()}if(h.displayReadyCapability){h.displayReadyCapability.reject(t)}else if(h.opListReadCapability){h.opListReadCapability.reject(t)}else{throw t}}))};c()}_abortOperatorList({intentState:t,reason:e,force:s=false}){if(!t.streamReader){return}if(t.streamReaderCancelTimeout){clearTimeout(t.streamReaderCancelTimeout);t.streamReaderCancelTimeout=null}if(!s){if(t.renderTasks.size>0){return}if(e instanceof Lt){let s=Wi;if(e.extraDelay>0&&e.extraDelay<1e3){s+=e.extraDelay}t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null;this._abortOperatorList({intentState:t,reason:e,force:true})}),s);return}}t.streamReader.cancel(new pt(e.message)).catch((()=>{}));t.streamReader=null;if(this._transport.destroyed){return}for(const[e,s]of this._intentStates){if(s===t){this._intentStates.delete(e);break}}this.cleanup()}get stats(){return this._stats}}class Ji{#on=Promise.withResolvers();#jn=null;#Gi=null;#zn=null;static#Hn=0;static#Wn=false;static#Gn=new WeakMap;static{if(R){this.#Wn=true;ai.workerSrc||="./pdf.worker.mjs"}this._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!s?.origin||s.origin==="null"){return false}const i=new URL(e,s);return s.origin===i.origin};this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};this.fromPort=t=>{qt("`PDFWorker.fromPort` - please use `PDFWorker.create` instead.");if(!t?.port){throw new Error("PDFWorker.fromPort - invalid method signature.")}return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:s=Z()}={}){this.name=t;this.destroyed=false;this.verbosity=s;if(e){if(Ji.#Gn.has(e)){throw new Error("Cannot use more than one PDFWorker per port.")}Ji.#Gn.set(e,this);this.#Vn(e)}else{this.#Xn()}}get promise(){return this.#on.promise}#qn(){this.#on.resolve();this.#jn.send("configure",{verbosity:this.verbosity})}get port(){return this.#Gi}get messageHandler(){return this.#jn}#Vn(t){this.#Gi=t;this.#jn=new ts("main","worker",t);this.#jn.on("ready",(()=>{}));this.#qn()}#Xn(){if(Ji.#Wn||Ji.#Yn){this.#Jn();return}let{workerSrc:t}=Ji;try{if(!Ji._isSameOrigin(window.location,t)){t=Ji._createCDNWrapper(new URL(t,window.location).href)}const e=new Worker(t,{type:"module"});const s=new ts("main","worker",e);const i=()=>{n.abort();s.destroy();e.terminate();if(this.destroyed){this.#on.reject(new Error("Worker was destroyed"))}else{this.#Jn()}};const n=new AbortController;e.addEventListener("error",(()=>{if(!this.#zn){i()}}),{signal:n.signal});s.on("test",(t=>{n.abort();if(this.destroyed||!t){i();return}this.#jn=s;this.#Gi=e;this.#zn=e;this.#qn()}));s.on("ready",(t=>{n.abort();if(this.destroyed){i();return}try{r()}catch{this.#Jn()}}));const r=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};r();return}catch{tt("The worker has been disabled.")}this.#Jn()}#Jn(){if(!Ji.#Wn){et("Setting up fake worker.");Ji.#Wn=true}Ji._setupFakeWorkerGlobal.then((t=>{if(this.destroyed){this.#on.reject(new Error("Worker was destroyed"));return}const e=new Ye;this.#Gi=e;const s=`fake${Ji.#Hn++}`;const i=new ts(s+"_worker",s,e);t.setup(i,e);this.#jn=new ts(s,s+"_worker",e);this.#qn()})).catch((t=>{this.#on.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=true;this.#zn?.terminate();this.#zn=null;Ji.#Gn.delete(this.#Gi);this.#Gi=null;this.#jn?.destroy();this.#jn=null}static create(t){const e=this.#Gn.get(t?.port);if(e){if(e._pendingDestroy){throw new Error("PDFWorker.create - the worker is being destroyed.\n"+"Please remember to await `PDFDocumentLoadingTask.destroy()`-calls.")}return e}return new Ji(t)}static get workerSrc(){if(ai.workerSrc){return ai.workerSrc}throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Yn(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){const t=async()=>{if(this.#Yn){return this.#Yn}const t=await import(this.workerSrc);return t.WorkerMessageHandler};return at(this,"_setupFakeWorkerGlobal",t())}}class Ki{#Kn=new Map;#Qn=new Map;#Zn=new Map;#tr=new Map;#er=null;constructor(t,e,s,i,n,r){this.messageHandler=t;this.loadingTask=e;this.commonObjs=new Ui;this.fontLoader=new _e({ownerDocument:i.ownerDocument,styleElement:i.styleElement});this.loadingParams=i.loadingParams;this._params=i;this.canvasFactory=n.canvasFactory;this.filterFactory=n.filterFactory;this.cMapReaderFactory=n.cMapReaderFactory;this.standardFontDataFactory=n.standardFontDataFactory;this.wasmFactory=n.wasmFactory;this.destroyed=false;this.destroyCapability=null;this._networkStream=s;this._fullReader=null;this._lastProgress=null;this.downloadInfoCapability=Promise.withResolvers();this.enableHWA=r;this.setupMessageHandler()}#sr(t,e=null){const s=this.#Kn.get(t);if(s){return s}const i=this.messageHandler.sendWithPromise(t,e);this.#Kn.set(t,i);return i}get annotationStorage(){return at(this,"annotationStorage",new Oe)}getRenderingIntent(t,e=_.ENABLE,s=null,i=false,n=false){let r=$.DISPLAY;let o=Fe;switch(t){case"any":r=$.ANY;break;case"display":break;case"print":r=$.PRINT;break;default:et(`getRenderingIntent - invalid intent: ${t}`)}const a=r&$.PRINT&&s instanceof $e?s:this.annotationStorage;switch(e){case _.DISABLE:r+=$.ANNOTATIONS_DISABLE;break;case _.ENABLE:break;case _.ENABLE_FORMS:r+=$.ANNOTATIONS_FORMS;break;case _.ENABLE_STORAGE:r+=$.ANNOTATIONS_STORAGE;o=a.serializable;break;default:et(`getRenderingIntent - invalid annotationMode: ${e}`)}if(i){r+=$.IS_EDITING}if(n){r+=$.OPLIST}const{ids:h,hash:c}=a.modifiedIds;const l=[r,o.hash,c];return{renderingIntent:r,cacheKey:l.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){if(this.destroyCapability){return this.destroyCapability.promise}this.destroyed=true;this.destroyCapability=Promise.withResolvers();this.#er?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Qn.values()){t.push(e._destroy())}this.#Qn.clear();this.#Zn.clear();this.#tr.clear();if(this.hasOwnProperty("annotationStorage")){this.annotationStorage.resetModified()}const e=this.messageHandler.sendWithPromise("Terminate",null);t.push(e);Promise.all(t).then((()=>{this.commonObjs.clear();this.fontLoader.clear();this.#Kn.clear();this.filterFactory.destroy();Hi.cleanup();this._networkStream?.cancelAllRequests(new pt("Worker was terminated."));this.messageHandler?.destroy();this.messageHandler=null;this.destroyCapability.resolve()}),this.destroyCapability.reject);return this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{it(this._networkStream,"GetReader - no `IPDFStream` instance available.");this._fullReader=this._networkStream.getFullReader();this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}};e.onPull=()=>{this._fullReader.read().then((function({value:t,done:s}){if(s){e.close();return}it(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer.");e.enqueue(new Uint8Array(t),1,[t])})).catch((t=>{e.error(t)}))};e.onCancel=t=>{this._fullReader.cancel(t);e.ready.catch((t=>{if(this.destroyed){return}throw t}))}}));t.on("ReaderHeadersReady",(async t=>{await this._fullReader.headersReady;const{isStreamingSupported:s,isRangeSupported:i,contentLength:n}=this._fullReader;if(!s||!i){if(this._lastProgress){e.onProgress?.(this._lastProgress)}this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}}return{isStreamingSupported:s,isRangeSupported:i,contentLength:n}}));t.on("GetRangeReader",((t,e)=>{it(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const s=this._networkStream.getRangeReader(t.begin,t.end);if(!s){e.close();return}e.onPull=()=>{s.read().then((function({value:t,done:s}){if(s){e.close();return}it(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer.");e.enqueue(new Uint8Array(t),1,[t])})).catch((t=>{e.error(t)}))};e.onCancel=t=>{s.cancel(t);e.ready.catch((t=>{if(this.destroyed){return}throw t}))}}));t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages;this._htmlForXfa=t.htmlForXfa;delete t.htmlForXfa;e._capability.resolve(new qi(t,this))}));t.on("DocException",(t=>{e._capability.reject(Ze(t))}));t.on("PasswordRequest",(t=>{this.#er=Promise.withResolvers();try{if(!e.onPassword){throw Ze(t)}const s=t=>{if(t instanceof Error){this.#er.reject(t)}else{this.#er.resolve({password:t})}};e.onPassword(s,t.code)}catch(t){this.#er.reject(t)}return this.#er.promise}));t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length});this.downloadInfoCapability.resolve(t)}));t.on("StartRenderPage",(t=>{if(this.destroyed){return}const e=this.#Qn.get(t.pageIndex);e._startRenderPage(t.transparency,t.cacheKey)}));t.on("commonobj",(([e,s,i])=>{if(this.destroyed){return null}if(this.commonObjs.has(e)){return null}switch(s){case"Font":if("error"in i){const t=i.error;et(`Error during font loading: ${t}`);this.commonObjs.resolve(e,t);break}const n=new je(i);const r=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null;const o=new Be(n,r,i.extra,i.charProcOperatorList);this.fontLoader.bind(o).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{if(!o.fontExtraProperties&&o.data){o.clearData()}this.commonObjs.resolve(e,o)}));break;case"CopyLocalImage":const{imageRef:a}=i;it(a,"The imageRef must be defined.");for(const t of this.#Qn.values()){for(const[,s]of t.objs){if(s?.ref!==a){continue}if(!s.dataLen){return null}this.commonObjs.resolve(e,structuredClone(s));return s.dataLen}}break;case"FontPath":case"Image":this.commonObjs.resolve(e,i);break;case"Pattern":const h=new ze(i);this.commonObjs.resolve(e,h.getIR());break;default:throw new Error(`Got unknown common object type ${s}`)}return null}));t.on("obj",(([t,e,s,i])=>{if(this.destroyed){return}const n=this.#Qn.get(e);if(n.objs.has(t)){return}if(n._intentStates.size===0){i?.bitmap?.close();return}switch(s){case"Image":case"Pattern":n.objs.resolve(t,i);break;default:throw new Error(`Got unknown object type ${s}`)}}));t.on("DocProgress",(t=>{if(this.destroyed){return}e.onProgress?.({loaded:t.loaded,total:t.total})}));t.on("FetchBinaryData",(async t=>{if(this.destroyed){throw new Error("Worker was destroyed.")}const e=this[t.type];if(!e){throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`)}return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){if(this.annotationStorage.size<=0){et("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()}))}extractPages(t){return this.messageHandler.sendWithPromise("ExtractPages",{pageInfos:t})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages){return Promise.reject(new Error("Invalid page request."))}const e=t-1,s=this.#Zn.get(e);if(s){return s}const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((s=>{if(this.destroyed){throw new Error("Transport destroyed")}if(s.refStr){this.#tr.set(s.refStr,t)}const i=new Yi(e,s,this,this._params.pdfBug);this.#Qn.set(e,i);return i}));this.#Zn.set(e,i);return i}getPageIndex(t){if(!Ve(t)){return Promise.reject(new Error("Invalid pageIndex request."))}return this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen})}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#sr("GetFieldObjects")}hasJSActions(){return this.#sr("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){if(typeof t!=="string"){return Promise.reject(new Error("Invalid destination request."))}return 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)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#sr("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#sr("GetOptionalContentConfig").then((e=>new ui(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Kn.get(t);if(e){return e}const s=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new hi(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null,hasStructTree:t[2]})));this.#Kn.set(t,s);return s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=false){if(this.destroyed){return}await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Qn.values()){const e=t.cleanup();if(!e){throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}}this.commonObjs.clear();if(!t){this.fontLoader.clear()}this.#Kn.clear();this.filterFactory.destroy(true);Hi.cleanup()}cachedPageNumber(t){if(!Ve(t)){return null}const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#tr.get(e)??null}}class Qi{#ir=null;onContinue=null;onError=null;constructor(t){this.#ir=t}get promise(){return this.#ir.capability.promise}cancel(t=0){this.#ir.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#ir.operatorList;if(!t){return false}const{annotationCanvasMap:e}=this.#ir;return t.form||t.canvas&&e?.size>0}}class Zi{#nr=null;static#rr=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:o,canvasFactory:a,filterFactory:h,useRequestAnimationFrame:c=false,pdfBug:l=false,pageColors:u=null,enableHWA:f=false,operationsFilter:d=null}){this.callback=t;this.params=e;this.objs=s;this.commonObjs=i;this.annotationCanvasMap=n;this.operatorListIdx=null;this.operatorList=r;this._pageIndex=o;this.canvasFactory=a;this.filterFactory=h;this._pdfBug=l;this.pageColors=u;this.running=false;this.graphicsReadyCallback=null;this.graphicsReady=false;this._useRequestAnimationFrame=c===true&&typeof window!=="undefined";this.cancelled=false;this.capability=Promise.withResolvers();this.task=new Qi(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.canvas;this._canvasContext=e.canvas?null:e.canvasContext;this._enableHWA=f;this._dependencyTracker=e.dependencyTracker;this._operationsFilter=d}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=false,optionalContentConfig:e}){if(this.cancelled){return}if(this._canvas){if(Zi.#rr.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.")}Zi.#rr.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled){this.stepper=globalThis.StepperManager.create(this._pageIndex);this.stepper.init(this.operatorList);this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint()}const{viewport:s,transform:i,background:n,dependencyTracker:r}=this.params;const o=this._canvasContext||this._canvas.getContext("2d",{alpha:false,willReadFrequently:!this._enableHWA});this.gfx=new oi(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r);this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:n});this.operatorListIdx=0;this.graphicsReady=true;this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=false;this.cancelled=true;this.gfx?.endDrawing();if(this.#nr){window.cancelAnimationFrame(this.#nr);this.#nr=null}Zi.#rr.delete(this._canvas);t||=new Lt(`Rendering cancelled, page ${this._pageIndex+1}`,e);this.callback(t);this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length);this.stepper?.updateOperatorList(this.operatorList);if(this.running){return}this._continue()}_continue(){this.running=true;if(this.cancelled){return}if(this.task.onContinue){this.task.onContinue(this._scheduleNextBound)}else{this._scheduleNext()}}_scheduleNext(){if(this._useRequestAnimationFrame){this.#nr=window.requestAnimationFrame((()=>{this.#nr=null;this._nextBound().catch(this._cancelBound)}))}else{Promise.resolve().then(this._nextBound).catch(this._cancelBound)}}async _next(){if(this.cancelled){return}this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter);if(this.operatorListIdx===this.operatorList.argsArray.length){this.running=false;if(this.operatorList.lastChunk){this.gfx.endDrawing();Zi.#rr.delete(this._canvas);this.callback()}}}}const tn="5.4.449";const en="f44e5f0e6";class sn{#or=null;#ar=null;#hr;#cr=null;#lr=false;#ur=false;#r=null;#fr;#dr=null;#w=null;static#pr=null;static get _keyboardManager(){return at(this,"_keyboardManager",new xe([[["Escape","mac+Escape"],sn.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],sn.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],sn.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],sn.prototype._moveToPrevious],[["Home","mac+Home"],sn.prototype._moveToBeginning],[["End","mac+End"],sn.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){if(t){this.#ur=false;this.#r=t}else{this.#ur=true}this.#w=t?._uiManager||e;this.#fr=this.#w._eventBus;this.#hr=t?.color?.toUpperCase()||this.#w?.highlightColors.values().next().value||"#FFFF98";sn.#pr||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#or=document.createElement("button");t.className="colorPicker";t.tabIndex="0";t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button");t.ariaHasPopup="true";if(this.#r){t.ariaControls=`${this.#r.id}_colorpicker_dropdown`}const e=this.#w._signal;t.addEventListener("click",this.#gr.bind(this),{signal:e});t.addEventListener("keydown",this.#mr.bind(this),{signal:e});const s=this.#ar=document.createElement("span");s.className="swatch";s.ariaHidden="true";s.style.backgroundColor=this.#hr;t.append(s);return t}renderMainDropdown(){const t=this.#cr=this.#wr();t.ariaOrientation="horizontal";t.ariaLabelledBy="highlightColorPickerLabel";return t}#wr(){const t=document.createElement("div");const e=this.#w._signal;t.addEventListener("contextmenu",Vt,{signal:e});t.className="dropdown";t.role="listbox";t.ariaMultiSelectable="false";t.ariaOrientation="vertical";t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");if(this.#r){t.id=`${this.#r.id}_colorpicker_dropdown`}for(const[s,i]of this.#w.highlightColors){const n=document.createElement("button");n.tabIndex="0";n.role="option";n.setAttribute("data-color",i);n.title=s;n.setAttribute("data-l10n-id",sn.#pr[s]);const r=document.createElement("span");n.append(r);r.className="swatch";r.style.backgroundColor=i;n.ariaSelected=i===this.#hr;n.addEventListener("click",this.#br.bind(this,i),{signal:e});t.append(n)}t.addEventListener("keydown",this.#mr.bind(this),{signal:e});return t}#br(t,e){e.stopPropagation();this.#fr.dispatch("switchannotationeditorparams",{source:this,type:U.HIGHLIGHT_COLOR,value:t});this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#or){this.#gr(t);return}const e=t.target.getAttribute("data-color");if(!e){return}this.#br(e,t)}_moveToNext(t){if(!this.#Ar){this.#gr(t);return}if(t.target===this.#or){this.#cr.firstElementChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#cr?.firstElementChild||t.target===this.#or){if(this.#Ar){this._hideDropdownFromKeyboard()}return}if(!this.#Ar){this.#gr(t)}t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#Ar){this.#gr(t);return}this.#cr.firstElementChild?.focus()}_moveToEnd(t){if(!this.#Ar){this.#gr(t);return}this.#cr.lastElementChild?.focus()}#mr(t){sn._keyboardManager.exec(this,t)}#gr(t){if(this.#Ar){this.hideDropdown();return}this.#lr=t.detail===0;if(!this.#dr){this.#dr=new AbortController;window.addEventListener("pointerdown",this.#f.bind(this),{signal:this.#w.combinedSignal(this.#dr)})}this.#or.ariaExpanded="true";if(this.#cr){this.#cr.classList.remove("hidden");return}const e=this.#cr=this.#wr();this.#or.append(e)}#f(t){if(this.#cr?.contains(t.target)){return}this.hideDropdown()}hideDropdown(){this.#cr?.classList.add("hidden");this.#or.ariaExpanded="false";this.#dr?.abort();this.#dr=null}get#Ar(){return this.#cr&&!this.#cr.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(this.#ur){return}if(!this.#Ar){this.#r?.unselect();return}this.hideDropdown();this.#or.focus({preventScroll:true,focusVisible:this.#lr})}updateColor(t){if(this.#ar){this.#ar.style.backgroundColor=t}if(!this.#cr){return}const e=this.#w.highlightColors.values();for(const s of this.#cr.children){s.ariaSelected=e.next().value===t.toUpperCase()}}destroy(){this.#or?.remove();this.#or=null;this.#ar=null;this.#cr?.remove();this.#cr=null}}class nn{#yr=null;#r=null;#w=null;static#pr=null;constructor(t){this.#r=t;this.#w=t._uiManager;nn.#pr||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#yr){return this.#yr}const{editorType:t,colorType:e,color:s}=this.#r;const i=this.#yr=document.createElement("input");i.type="color";i.value=s||"#000000";i.className="basicColorPicker";i.tabIndex=0;i.setAttribute("data-l10n-id",nn.#pr[t]);i.addEventListener("input",(()=>{this.#w.updateParams(e,i.value)}),{signal:this.#w._signal});return i}update(t){if(!this.#yr){return}this.#yr.value=t}destroy(){this.#yr?.remove();this.#yr=null}hideDropdown(){}}function rn(t){return Math.floor(Math.max(0,Math.min(1,t))*255).toString(16).padStart(2,"0")}function on(t){return Math.max(0,Math.min(255,255*t))}class an{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]){t=on(t);return[t,t,t]}static G_HTML([t]){const e=rn(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(on)}static RGB_HTML(t){return`#${t.map(rn).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[on(1-Math.min(1,t+i)),on(1-Math.min(1,s+i)),on(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;const n=1-e;const r=1-s;const o=Math.min(i,n,r);return["CMYK",i,n,r,o]}}class hn{create(t,e,s=false){if(t<=0||e<=0){throw new Error("Invalid SVG dimensions")}const i=this._createSVG("svg:svg");i.setAttribute("version","1.1");if(!s){i.setAttribute("width",`${t}px`);i.setAttribute("height",`${e}px`)}i.setAttribute("preserveAspectRatio","none");i.setAttribute("viewBox",`0 0 ${t} ${e}`);return i}createElement(t){if(typeof t!=="string"){throw new Error("Invalid SVG element type")}return this._createSVG(t)}_createSVG(t){st("Abstract method `_createSVG` called.")}}class cn extends hn{_createSVG(t){return document.createElementNS(Ot,t)}}const ln=9;const un=new WeakSet;const fn=(new Date).getTimezoneOffset()*60*1e3;class dn{static create(t){const e=t.data.annotationType;switch(e){case G.LINK:return new mn(t);case G.TEXT:return new wn(t);case G.WIDGET:const e=t.data.fieldType;switch(e){case"Tx":return new An(t);case"Btn":if(t.data.radioButton){return new xn(t)}else if(t.data.checkBox){return new vn(t)}return new kn(t);case"Ch":return new Sn(t);case"Sig":return new yn(t)}return new bn(t);case G.POPUP:return new Mn(t);case G.FREETEXT:return new Tn(t);case G.LINE:return new En(t);case G.SQUARE:return new Pn(t);case G.CIRCLE:return new Nn(t);case G.POLYLINE:return new Dn(t);case G.CARET:return new Rn(t);case G.INK:return new Fn(t);case G.POLYGON:return new In(t);case G.HIGHLIGHT:return new On(t);case G.UNDERLINE:return new $n(t);case G.SQUIGGLY:return new _n(t);case G.STRIKEOUT:return new Bn(t);case G.STAMP:return new Ln(t);case G.FILEATTACHMENT:return new Un(t);default:return new pn(t)}}}class pn{#vr=null;#xr=false;#kr=null;constructor(t,{isRenderable:e=false,ignoreBorder:s=false,createQuadrilaterals:i=false}={}){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.enableComment=t.enableComment;this.enableScripting=t.enableScripting;this.hasJSActions=t.hasJSActions;this._fieldObjects=t.fieldObjects;this.parent=t.parent;this.hasOwnCommentButton=false;if(e){this.contentElement=this.container=this._createContainer(s)}if(i){this._createQuadrilaterals()}}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return pn._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this;const e=this.annotationStorage?.getEditor(t.id);if(e){return e.getData()}return t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t){return t.commentButtonPositionInPage}const{quadPoints:e,inkLists:s,rect:i}=this.data;let n=-Infinity;let r=-Infinity;if(e?.length>=8){for(let t=0;t<e.length;t+=8){if(e[t+1]>r){r=e[t+1];n=e[t+2]}else if(e[t+1]===r){n=Math.max(n,e[t+2])}}return[n,r]}if(s?.length>=1){for(const t of s){for(let e=0,s=t.length;e<s;e+=2){if(t[e+1]>r){r=t[e+1];n=t[e]}else if(t[e+1]===r){n=Math.max(n,t[e])}}}if(n!==Infinity){return[n,r]}}if(i){return[i[2],i[3]]}return null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}}=this.parent;t[1]=e[3]-t[1]+e[1];t[0]=100*(t[0]-n)/s;t[1]=100*(t[1]-r)/i;return t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${B}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this;const s={deleted:!t,contents:t||""};if(!this.annotationStorage.updateEditor(e.id,{popup:s})){this.annotationStorage.setValue(`${B}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:s,popupRef:e.popupRef,modificationDate:new Date})}if(!t){this.removePopup()}}removePopup(){(this.#kr?.popup||this.popup)?.remove();this.#kr=this.popup=null}updateEdited(t){if(!this.container){return}if(t.rect){this.#vr||={rect:this.data.rect.slice(0)}}const{rect:e,popup:s}=t;if(e){this.#Sr(e)}let i=this.#kr?.popup||this.popup;if(!i&&s?.text){this._createPopup(s);i=this.#kr.popup}if(!i){return}i.updateEdited(t);if(s?.deleted){i.remove();this.#kr=null;this.popup=null}}resetEdited(){if(!this.#vr){return}this.#Sr(this.#vr.rect);this.#kr?.popup.resetEdited();this.#vr=null}#Sr(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:o,pageY:a}}}}=this;s?.splice(0,4,...t);e.left=`${100*(t[0]-o)/n}%`;e.top=`${100*(r-t[3]+a)/r}%`;if(i===0){e.width=`${100*(t[2]-t[0])/n}%`;e.height=`${100*(t[3]-t[1])/r}%`}else{this.setRotation(i)}}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this;const n=document.createElement("section");n.setAttribute("data-annotation-id",e.id);if(!(this instanceof bn)&&!(this instanceof mn)){n.tabIndex=0}const{style:r}=n;r.zIndex=this.parent.zIndex;this.parent.zIndex+=2;if(e.alternativeText){n.title=e.alternativeText}if(e.noRotate){n.classList.add("norotate")}if(!e.rect||this instanceof Mn){const{rotation:t}=e;if(!e.hasOwnCanvas&&t!==0){this.setRotation(t,n)}return n}const{width:o,height:a}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius;const s=e.borderStyle.verticalCornerRadius;if(t>0||s>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${s}px * var(--total-scale-factor))`;r.borderRadius=e}else if(this instanceof xn){const t=`calc(${o}px * var(--total-scale-factor)) / calc(${a}px * var(--total-scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case V.SOLID:r.borderStyle="solid";break;case V.DASHED:r.borderStyle="dashed";break;case V.BEVELED:et("Unimplemented border style: beveled");break;case V.INSET:et("Unimplemented border style: inset");break;case V.UNDERLINE:r.borderBottomStyle="solid";break}const i=e.borderColor||null;if(i){this.#xr=true;r.borderColor=xt.makeHexColor(i[0]|0,i[1]|0,i[2]|0)}else{r.borderWidth=0}}const h=xt.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]]);const{pageWidth:c,pageHeight:l,pageX:u,pageY:f}=i.rawDims;r.left=`${100*(h[0]-u)/c}%`;r.top=`${100*(h[1]-f)/l}%`;const{rotation:d}=e;if(e.hasOwnCanvas||d===0){r.width=`${100*o/c}%`;r.height=`${100*a/l}%`}else{this.setRotation(d,n)}return n}setRotation(t,e=this.container){if(!this.data.rect){return}const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:n,height:r}=this;if(t%180!==0){[n,r]=[r,n]}e.style.width=`${100*n/s}%`;e.style.height=`${100*r/i}%`;e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,s)=>{const i=s.detail[t];const n=i[0];const r=i.slice(1);s.target.style[e]=an[`${n}_HTML`](r);this.annotationStorage.setValue(this.data.id,{[e]:an[`${n}_rgb`](r)})};return at(this,"_commonActions",{display:t=>{const{display:e}=t.detail;const s=e%2===1;this.container.style.visibility=s?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:e===1||e===2})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:false})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.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:t=>{const e=t.detail.rotation;this.setRotation(e);this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting){return}const e=this.annotationStorage.getRawValue(this.data.id);if(!e){return}const s=this._commonActions;for(const[i,n]of Object.entries(e)){const r=s[i];if(r){const s={detail:{[i]:n},target:t};r(s);delete e[i]}}}_createQuadrilaterals(){if(!this.container){return}const{quadPoints:t}=this.data;if(!t){return}const[e,s,i,n]=this.data.rect.map((t=>Math.fround(t)));if(t.length===8){const[r,o,a,h]=t.subarray(2,6);if(i===r&&n===o&&e===a&&s===h){return}}const{style:r}=this.container;let o;if(this.#xr){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0;o=["url('data:image/svg+xml;utf8,",`<svg xmlns="http://www.w3.org/2000/svg"`,` preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${t}" stroke-width="${e}">`];this.container.classList.add("hasBorder")}const a=i-e;const h=n-s;const{svgFactory:c}=this;const l=c.createElement("svg");l.classList.add("quadrilateralsContainer");l.setAttribute("width",0);l.setAttribute("height",0);l.role="none";const u=c.createElement("defs");l.append(u);const f=c.createElement("clipPath");const d=`clippath_${this.data.id}`;f.setAttribute("id",d);f.setAttribute("clipPathUnits","objectBoundingBox");u.append(f);for(let s=2,i=t.length;s<i;s+=8){const i=t[s];const r=t[s+1];const l=t[s+2];const u=t[s+3];const d=c.createElement("rect");const p=(l-e)/a;const g=(n-r)/h;const m=(i-l)/a;const w=(r-u)/h;d.setAttribute("x",p);d.setAttribute("y",g);d.setAttribute("width",m);d.setAttribute("height",w);f.append(d);o?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${g}" width="${m}" height="${w}"/>`)}if(this.#xr){o.push(`</g></svg>')`);r.backgroundImage=o.join("")}this.container.append(l);this.container.style.clipPath=`url(#${d})`}_createPopup(t=null){const{data:e}=this;let s,i;if(t){s={str:t.text};i=t.date}else{s=e.contentsObj;i=e.modificationDate}this.#kr=new Mn({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:true},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#kr||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#kr}render(){st("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i){for(const{page:t,id:n,exportValues:r}of i){if(t===-1){continue}if(n===e){continue}const i=typeof r==="string"?r:null;const o=document.querySelector(`[data-element-id="${n}"]`);if(o&&!un.has(o)){et(`_getElementsByName - element not allowed: ${n}`);continue}s.push({id:n,exportValue:i,domElement:o})}}return s}for(const i of document.getElementsByName(t)){const{exportValue:t}=i;const n=i.getAttribute("data-element-id");if(n===e){continue}if(!un.has(i)){continue}s.push({id:n,exportValue:t,domElement:i})}return s}show(){if(this.container){this.container.hidden=false}this.popup?.maybeShow()}hide(){if(this.container){this.container.hidden=true}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,mustEnterInEditMode:true})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class gn extends pn{constructor(t){super(t,{isRenderable:true,ignoreBorder:true});this.editor=t.editor}render(){this.container.className="editorAnnotation";return this.container}createOrUpdatePopup(){const{editor:t}=this;if(!t.hasComment){return}this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t;if(!t){this.removePopup()}}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id);this.container.remove();this.container=null;this.removePopup()}}class mn extends pn{constructor(t,e=null){super(t,{isRenderable:true,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:true});this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this;const s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=false;if(t.url){e.addLinkAttributes(s,t.url,t.newWindow);i=true}else if(t.action){this._bindNamedAction(s,t.action,t.overlaidText);i=true}else if(t.attachment){this.#Mr(s,t.attachment,t.overlaidText,t.attachmentDest);i=true}else if(t.setOCGState){this.#Cr(s,t.setOCGState,t.overlaidText);i=true}else if(t.dest){this._bindLink(s,t.dest,t.overlaidText);i=true}else{if(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions){this._bindJSAction(s,t);i=true}if(t.resetForm){this._bindResetFormAction(s,t.resetForm);i=true}else if(this.isTooltipOnly&&!i){this._bindLink(s,"");i=true}}this.container.classList.add("linkAnnotation");if(i){this.contentElement=s;this.container.append(s)}return this.container}#Tr(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,s=""){t.href=this.linkService.getDestinationHash(e);t.onclick=()=>{if(e){this.linkService.goToDestination(e)}return false};if(e||e===""){this.#Tr()}if(s){t.title=s}}_bindNamedAction(t,e,s=""){t.href=this.linkService.getAnchorUrl("");t.onclick=()=>{this.linkService.executeNamedAction(e);return false};if(s){t.title=s}this.#Tr()}#Mr(t,e,s="",i=null){t.href=this.linkService.getAnchorUrl("");if(e.description){t.title=e.description}else if(s){t.title=s}t.onclick=()=>{this.downloadManager?.openOrDownloadData(e.content,e.filename,i);return false};this.#Tr()}#Cr(t,e,s=""){t.href=this.linkService.getAnchorUrl("");t.onclick=()=>{this.linkService.executeSetOCGState(e);return false};if(s){t.title=s}this.#Tr()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);if(!n){continue}t[n]=()=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}});return false}}if(e.overlaidText){t.title=e.overlaidText}if(!t.onclick){t.onclick=()=>false}this.#Tr()}_bindResetFormAction(t,e){const s=t.onclick;if(!s){t.href=this.linkService.getAnchorUrl("")}this.#Tr();if(!this._fieldObjects){et(`_bindResetFormAction - "resetForm" action not supported, `+"ensure that the `fieldObjects` parameter is provided.");if(!s){t.onclick=()=>false}return}t.onclick=()=>{s?.();const{fields:t,refs:i,include:n}=e;const r=[];if(t.length!==0||i.length!==0){const e=new Set(i);for(const s of t){const t=this._fieldObjects[s]||[];for(const{id:s}of t){e.add(s)}}for(const t of Object.values(this._fieldObjects)){for(const s of t){if(e.has(s.id)===n){r.push(s)}}}}else{for(const t of Object.values(this._fieldObjects)){r.push(...t)}}const o=this.annotationStorage;const a=[];for(const t of r){const{id:e}=t;a.push(e);switch(t.type){case"text":{const s=t.defaultValue||"";o.setValue(e,{value:s});break}case"checkbox":case"radiobutton":{const s=t.defaultValue===t.exportValues;o.setValue(e,{value:s});break}case"combobox":case"listbox":{const s=t.defaultValue||"";o.setValue(e,{value:s});break}default:continue}const s=document.querySelector(`[data-element-id="${e}"]`);if(!s){continue}else if(!un.has(s)){et(`_bindResetFormAction - element not allowed: ${e}`);continue}s.dispatchEvent(new Event("resetform"))}if(this.enableScripting){this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:a,name:"ResetForm"}})}return false}}}class wn extends pn{constructor(t){super(t,{isRenderable:true})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");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}));if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}this.container.append(t);return this.container}}class bn extends pn{render(){return this.container}showElementAndHideCanvas(t){if(this.data.hasOwnCanvas){if(t.previousSibling?.nodeName==="CANVAS"){t.previousSibling.hidden=true}t.hidden=false}}_getKeyModifier(t){return yt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){if(s.includes("mouse")){t.addEventListener(s,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}))}else{t.addEventListener(s,(t=>{if(s==="blur"){if(!e.focused||!t.relatedTarget){return}e.focused=false}else if(s==="focus"){if(e.focused){return}e.focused=true}if(!n){return}this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(t)}})}))}}_setEventListeners(t,e,s,i){for(const[n,r]of s){if(r==="Action"||this.data.actions?.[r]){if(r==="Focus"||r==="Blur"){e||={focused:false}}this._setEventListener(t,e,n,r,i);if(r==="Focus"&&!this.data.actions?.Blur){this._setEventListener(t,e,"blur","Blur",null)}else if(r==="Blur"&&!this.data.actions?.Focus){this._setEventListener(t,e,"focus","Focus",null)}}}}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":xt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"];const{fontColor:s}=this.data.defaultAppearanceData;const i=this.data.defaultAppearanceData.fontSize||ln;const n=t.style;let r;const o=2;const a=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-o);const e=Math.round(t/(O*i))||1;const s=t/e;r=Math.min(i,a(s/O))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-o);r=Math.min(i,a(t/O))}n.fontSize=`calc(${r}px * var(--total-scale-factor))`;n.color=xt.makeHexColor(s[0],s[1],s[2]);if(this.data.textAlignment!==null){n.textAlign=e[this.data.textAlignment]}}_setRequired(t,e){if(e){t.setAttribute("required",true)}else{t.removeAttribute("required")}t.setAttribute("aria-required",e)}}class An extends bn{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id)){if(r.domElement){r.domElement[e]=s}n.setValue(r.id,{[i]:s})}}render(){const t=this.annotationStorage;const e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let n=i.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;if(r&&n.length>r){n=n.slice(0,r)}let o=i.formattedValue||this.data.textContent?.join("\n")||null;if(o&&this.data.comb){o=o.replaceAll(/\s+/g,"")}const a={userValue:n,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:false};if(this.data.multiLine){s=document.createElement("textarea");s.textContent=o??n;if(this.data.doNotScroll){s.style.overflowY="hidden"}}else{s=document.createElement("input");s.type=this.data.password?"password":"text";s.setAttribute("value",o??n);if(this.data.doNotScroll){s.style.overflowX="hidden"}}if(this.data.hasOwnCanvas){s.hidden=true}un.add(s);this.contentElement=s;s.setAttribute("data-element-id",e);s.disabled=this.data.readOnly;s.name=this.data.fieldName;s.tabIndex=0;const{datetimeFormat:h,datetimeType:c,timeStep:l}=this.data;const u=!!c&&this.enableScripting;if(h){s.title=h}this._setRequired(s,this.data.required);if(r){s.maxLength=r}s.addEventListener("input",(i=>{t.setValue(e,{value:i.target.value});this.setPropertyOnSiblings(s,"value",i.target.value,"value");a.formattedValue=null}));s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";s.value=a.userValue=e;a.formattedValue=null}));let f=t=>{const{formattedValue:e}=a;if(e!==null&&e!==undefined){t.target.value=e}t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",(t=>{if(a.focused){return}const{target:e}=t;if(u){e.type=c;if(l){e.step=l}}if(a.userValue){const t=a.userValue;if(u){if(c==="time"){const s=new Date(t);const i=[s.getHours(),s.getMinutes(),s.getSeconds()];e.value=i.map((t=>t.toString().padStart(2,"0"))).join(":")}else{e.value=new Date(t-fn).toISOString().split(c==="date"?"T":".",1)[0]}}else{e.value=t}}a.lastCommittedValue=e.value;a.commitKey=1;if(!this.data.actions?.Focus){a.focused=true}}));s.addEventListener("updatefromsandbox",(s=>{this.showElementAndHideCanvas(s.target);const i={value(s){a.userValue=s.detail.value??"";if(!u){t.setValue(e,{value:a.userValue.toString()})}s.target.value=a.userValue},formattedValue(s){const{formattedValue:i}=s.detail;a.formattedValue=i;if(i!==null&&i!==undefined&&s.target!==document.activeElement){s.target.value=i}const n={formattedValue:i};if(u){n.value=i}t.setValue(e,n)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:s=>{const{charLimit:i}=s.detail;const{target:n}=s;if(i===0){n.removeAttribute("maxLength");return}n.setAttribute("maxLength",i);let r=a.userValue;if(!r||r.length<=i){return}r=r.slice(0,i);n.value=a.userValue=r;t.setValue(e,{value:r});this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:true,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}})}};this._dispatchEventFromSandbox(i,s)}));s.addEventListener("keydown",(t=>{a.commitKey=1;let s=-1;if(t.key==="Escape"){s=0}else if(t.key==="Enter"&&!this.data.multiLine){s=2}else if(t.key==="Tab"){a.commitKey=3}if(s===-1){return}const{value:i}=t.target;if(a.lastCommittedValue===i){return}a.lastCommittedValue=i;a.userValue=i;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:true,commitKey:s,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}})}));const i=f;f=null;s.addEventListener("blur",(t=>{if(!a.focused||!t.relatedTarget){return}if(!this.data.actions?.Blur){a.focused=false}const{target:s}=t;let{value:n}=s;if(u){if(n&&c==="time"){const t=n.split(":").map((t=>parseInt(t,10)));n=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf();s.step=""}else{if(!n.includes("T")){n=`${n}T00:00`}n=new Date(n).valueOf()}s.type="text"}a.userValue=n;if(a.lastCommittedValue!==n){this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:true,commitKey:a.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}})}i(t)}));if(this.data.actions?.Keystroke){s.addEventListener("beforeinput",(t=>{a.lastCommittedValue=null;const{data:s,target:i}=t;const{value:n,selectionStart:r,selectionEnd:o}=i;let h=r,c=o;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,r).match(/\w*[^\w]*$/);if(t){h-=t[0].length}break}case"deleteWordForward":{const t=n.substring(r).match(/^[^\w]*\w*/);if(t){c+=t[0].length}break}case"deleteContentBackward":if(r===o){h-=1}break;case"deleteContentForward":if(r===o){c+=1}break}t.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:s||"",willCommit:false,selStart:h,selEnd:c}})}))}this._setEventListeners(s,a,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(f){s.addEventListener("blur",f)}if(this.data.comb){const t=this.data.rect[2]-this.data.rect[0];const e=t/r;s.classList.add("comb");s.style.letterSpacing=`calc(${e}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";if(this.data.hasOwnCanvas){s.hidden=true}}this._setTextStyle(s);this._setBackgroundColor(s);this._setDefaultPropertiesFromJS(s);this.container.append(s);return this.container}}class yn extends bn{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class vn extends bn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage;const e=this.data;const s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;if(typeof i==="string"){i=i!=="Off";t.setValue(s,{value:i})}this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");un.add(n);n.setAttribute("data-element-id",s);n.disabled=e.readOnly;this._setRequired(n,this.data.required);n.type="checkbox";n.name=e.fieldName;if(i){n.setAttribute("checked",true)}n.setAttribute("exportValue",e.exportValue);n.tabIndex=0;n.addEventListener("change",(i=>{const{name:n,checked:r}=i.target;for(const i of this._getElementsByName(n,s)){const s=r&&i.exportValue===e.exportValue;if(i.domElement){i.domElement.checked=s}t.setValue(i.id,{value:s})}t.setValue(s,{value:r})}));n.addEventListener("resetform",(t=>{const s=e.defaultFieldValue||"Off";t.target.checked=s===e.exportValue}));if(this.enableScripting&&this.hasJSActions){n.addEventListener("updatefromsandbox",(e=>{const i={value(e){e.target.checked=e.detail.value!=="Off";t.setValue(s,{value:e.target.checked})}};this._dispatchEventFromSandbox(i,e)}));this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}this._setBackgroundColor(n);this._setDefaultPropertiesFromJS(n);this.container.append(n);return this.container}}class xn extends bn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage;const e=this.data;const 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})}if(i){for(const i of this._getElementsByName(e.fieldName,s)){t.setValue(i.id,{value:false})}}const n=document.createElement("input");un.add(n);n.setAttribute("data-element-id",s);n.disabled=e.readOnly;this._setRequired(n,this.data.required);n.type="radio";n.name=e.fieldName;if(i){n.setAttribute("checked",true)}n.tabIndex=0;n.addEventListener("change",(e=>{const{name:i,checked:n}=e.target;for(const e of this._getElementsByName(i,s)){t.setValue(e.id,{value:false})}t.setValue(s,{value:n})}));n.addEventListener("resetform",(t=>{const s=e.defaultFieldValue;t.target.checked=s!==null&&s!==undefined&&s===e.buttonValue}));if(this.enableScripting&&this.hasJSActions){const i=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{const n={value:e=>{const n=i===e.detail.value;for(const i of this._getElementsByName(e.target.name)){const e=n&&i.id===s;if(i.domElement){i.domElement.checked=e}t.setValue(i.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)}));this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}this._setBackgroundColor(n);this._setDefaultPropertiesFromJS(n);this.container.append(n);return this.container}}class kn extends mn{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;if(this.enableScripting&&this.hasJSActions&&e){this._setDefaultPropertiesFromJS(e);e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))}return t}}class Sn extends bn{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage;const e=this.data.id;const s=t.getValue(e,{value:this.data.fieldValue});const i=document.createElement("select");un.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=0;let n=this.data.combo&&this.data.options.length>0;if(!this.data.combo){i.size=this.data.options.length;if(this.data.multiSelect){i.multiple=true}}i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of i.options){t.selected=t.value===e}}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue;e.value=t.exportValue;if(s.value.includes(t.exportValue)){e.setAttribute("selected",true);n=false}i.append(e)}let r=null;if(n){const t=document.createElement("option");t.value=" ";t.setAttribute("hidden",true);t.setAttribute("selected",true);i.prepend(t);r=()=>{t.remove();i.removeEventListener("input",r);r=null};i.addEventListener("input",r)}const o=t=>{const e=t?"value":"textContent";const{options:s,multiple:n}=i;if(!n){return s.selectedIndex===-1?null:s[s.selectedIndex][e]}return Array.prototype.filter.call(s,(t=>t.selected)).map((t=>t[e]))};let a=o(false);const h=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};if(this.enableScripting&&this.hasJSActions){i.addEventListener("updatefromsandbox",(s=>{const n={value(s){r?.();const n=s.detail.value;const h=new Set(Array.isArray(n)?n:[n]);for(const t of i.options){t.selected=h.has(t.value)}t.setValue(e,{value:o(true)});a=o(false)},multipleSelection(t){i.multiple=true},remove(s){const n=i.options;const r=s.detail.remove;n[r].selected=false;i.remove(r);if(n.length>0){const t=Array.prototype.findIndex.call(n,(t=>t.selected));if(t===-1){n[0].selected=true}}t.setValue(e,{value:o(true),items:h(s)});a=o(false)},clear(s){while(i.length!==0){i.remove(0)}t.setValue(e,{value:null,items:[]});a=o(false)},insert(s){const{index:n,displayValue:r,exportValue:c}=s.detail.insert;const l=i.children[n];const u=document.createElement("option");u.textContent=r;u.value=c;if(l){l.before(u)}else{i.append(u)}t.setValue(e,{value:o(true),items:h(s)});a=o(false)},items(s){const{items:n}=s.detail;while(i.length!==0){i.remove(0)}for(const t of n){const{displayValue:e,exportValue:s}=t;const n=document.createElement("option");n.textContent=e;n.value=s;i.append(n)}if(i.options.length>0){i.options[0].selected=true}t.setValue(e,{value:o(true),items:h(s)});a=o(false)},indices(s){const i=new Set(s.detail.indices);for(const t of s.target.options){t.selected=i.has(t.index)}t.setValue(e,{value:o(true)});a=o(false)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,s)}));i.addEventListener("input",(s=>{const i=o(true);const n=o(false);t.setValue(e,{value:i});s.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,change:n,changeEx:i,willCommit:false,commitKey:1,keyDown:false}})}));this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))}else{i.addEventListener("input",(function(s){t.setValue(e,{value:o(true)})}))}if(this.data.combo){this._setTextStyle(i)}this._setBackgroundColor(i);this._setDefaultPropertiesFromJS(i);this.container.append(i);return this.container}}class Mn extends pn{constructor(t){const{data:e,elements:s,parent:i}=t;const n=!!i._commentManager;super(t,{isRenderable:!n&&pn._hasPopupData(e)});this.elements=s;if(n&&pn._hasPopupData(e)){const t=this.popup=this.#Er();for(const e of s){e.popup=t}}else{this.popup=null}}#Er(){return new Cn({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})}render(){const{container:t}=this;t.classList.add("popupAnnotation");t.role="comment";const e=this.popup=this.#Er();const s=[];for(const t of this.elements){t.popup=e;t.container.ariaHasPopup="dialog";s.push(t.data.id);t.addHighlightArea()}this.container.setAttribute("aria-controls",s.map((t=>`${Et}${t}`)).join(","));return this.container}}class Cn{#H=null;#Pr=this.#mr.bind(this);#Nr=this.#Dr.bind(this);#Ir=this.#Rr.bind(this);#Fr=this.#Or.bind(this);#$r=null;#Mt=null;#_r=null;#Br=null;#Lr=null;#Ur=null;#jr=null;#zr=false;#Hr=null;#Wr=null;#I=null;#Gr=null;#Vr=null;#we=null;#Xr=null;#de=null;#qr=null;#vr=null;#Yr=false;#Jr=null;#Kr=null;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:o,parent:a,rect:h,parentRect:c,open:l,commentManager:u=null}){this.#Mt=t;this.#qr=i;this.#_r=r;this.#de=o;this.#Ur=a;this.#$r=e;this.#Xr=h;this.#jr=c;this.#Lr=s;this.#H=u;this.#Jr=s[0];this.#Br=Yt.toDateObject(n);this.trigger=s.flatMap((t=>t.getElementsToTriggerPopup()));if(!u){this.#Qr();this.#Mt.hidden=true;if(l){this.#Or()}}}#Qr(){if(this.#Wr){return}this.#Wr=new AbortController;const{signal:t}=this.#Wr;for(const e of this.trigger){e.addEventListener("click",this.#Fr,{signal:t});e.addEventListener("pointerenter",this.#Ir,{signal:t});e.addEventListener("pointerleave",this.#Nr,{signal:t});e.classList.add("popupTriggerArea")}for(const e of this.#Lr){e.container?.addEventListener("keydown",this.#Pr,{signal:t})}}#Zr(){const t=this.#Lr.find((t=>t.hasCommentButton));if(!t){return}this.#Vr=t._normalizePoint(t.commentButtonPosition)}renderCommentButton(){if(this.#Gr){if(!this.#Gr.parentNode){this.#Jr.container.after(this.#Gr)}return}if(!this.#Vr){this.#Zr()}if(!this.#Vr){return}const{signal:t}=this.#Wr=new AbortController;const e=this.#Jr.hasOwnCommentButton;const s=()=>{this.#H.toggleCommentPopup(this,true,undefined,!e)};const i=()=>{this.#H.toggleCommentPopup(this,false,true,!e)};const n=()=>{this.#H.toggleCommentPopup(this,false,false)};if(!e){const e=this.#Gr=document.createElement("button");e.className="annotationCommentButton";const r=this.#Jr.container;e.style.zIndex=r.style.zIndex+1;e.tabIndex=0;e.ariaHasPopup="dialog";e.ariaControls="commentPopup";e.setAttribute("data-l10n-id","pdfjs-show-comment-button");this.#to();this.#eo();e.addEventListener("keydown",this.#Pr,{signal:t});e.addEventListener("click",s,{signal:t});e.addEventListener("pointerenter",i,{signal:t});e.addEventListener("pointerleave",n,{signal:t});r.after(e)}else{this.#Gr=this.#Jr.container;for(const e of this.trigger){e.ariaHasPopup="dialog";e.ariaControls="commentPopup";e.addEventListener("keydown",this.#Pr,{signal:t});e.addEventListener("click",s,{signal:t});e.addEventListener("pointerenter",i,{signal:t});e.addEventListener("pointerleave",n,{signal:t});e.classList.add("popupTriggerArea")}}}#eo(){if(this.#Jr.extraPopupElement&&!this.#Jr.editor){return}if(!this.#Gr){this.renderCommentButton()}const[t,e]=this.#Vr;const{style:s}=this.#Gr;s.left=`calc(${t}%)`;s.top=`calc(${e}% - var(--comment-button-dim))`}#to(){if(this.#Jr.extraPopupElement){return}if(!this.#Gr){this.renderCommentButton()}this.#Gr.style.backgroundColor=this.commentButtonColor||""}get commentButtonColor(){const{color:t,opacity:e}=this.#Jr.commentData;if(!t){return null}return this.#Ur._commentManager.makeCommentColor(t,e)}focusCommentButton(){setTimeout((()=>{this.#Gr?.focus()}),0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}=this.#Jr.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}}get elementBeforePopup(){return this.#Gr}get comment(){this.#Kr||=this.#Jr.commentText;return this.#Kr}set comment(t){if(t===this.comment){return}this.#Jr.commentText=this.#Kr=t}focus(){this.#Jr.container?.focus()}get parentBoundingClientRect(){return this.#Jr.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){if(!this.#Gr){return}this.#Gr.classList.toggle("selected",t);this.#Gr.ariaExpanded=e}setSelectedCommentButton(t){this.#Gr.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#we){return this.#we}const{x:t,y:e,height:s}=this.#Gr.getBoundingClientRect();const{x:i,y:n,width:r,height:o}=this.#Jr.layer.getBoundingClientRect();return[(t-i)/r,(e+s-n)/o]}set commentPopupPosition(t){this.#we=t}hasDefaultPopupPosition(){return this.#we===null}get commentButtonPosition(){return this.#Vr}get commentButtonWidth(){return this.#Gr.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=this.#we||this.commentButtonPosition.map((t=>t/100));const i=this.parentBoundingClientRect;const{x:n,y:r,width:o,height:a}=i;this.#H.showDialog(null,this,n+e*o,r+s*a,{...t,parentDimensions:i})}render(){if(this.#Hr){return}const t=this.#Hr=document.createElement("div");t.className="popup";if(this.#$r){const e=t.style.outlineColor=xt.makeHexColor(...this.#$r);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");e.className="header";if(this.#qr?.str){const t=document.createElement("span");t.className="title";e.append(t);({dir:t.dir,str:t.textContent}=this.#qr)}t.append(e);if(this.#Br){const t=document.createElement("time");t.className="popupDate";t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string");t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#Br.valueOf()}));t.dateTime=this.#Br.toISOString();e.append(t)}de({html:this.#so||this.#_r.str,dir:this.#_r?.dir,className:"popupContent"},t);this.#Mt.append(t)}get#so(){const t=this.#de;const e=this.#_r;if(t?.str&&(!e?.str||e.str===t.str)){return this.#de.html||null}return null}get#io(){return this.#so?.attributes?.style?.fontSize||0}get#no(){return this.#so?.attributes?.style?.color||null}#ro(t){const e=[];const s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}};const i={style:{color:this.#no,fontSize:this.#io?`calc(${this.#io}px * var(--total-scale-factor))`:""}};for(const s of t.split("\n")){e.push({name:"span",value:s,attributes:i})}return s}#mr(t){if(t.altKey||t.shiftKey||t.ctrlKey||t.metaKey){return}if(t.key==="Enter"||t.key==="Escape"&&this.#zr){this.#Or()}}updateEdited({rect:t,popup:e,deleted:s}){if(this.#H){if(s){this.remove();this.#Kr=null}else if(e){if(e.deleted){this.remove()}else{this.#to();this.#Kr=e.text}}if(t){this.#Vr=null;this.#Zr();this.#eo()}return}if(s||e?.deleted){this.remove();return}this.#Qr();this.#vr||={contentsObj:this.#_r,richText:this.#de};if(t){this.#I=null}if(e&&e.text){this.#de=this.#ro(e.text);this.#Br=Yt.toDateObject(e.date);this.#_r=null}this.#Hr?.remove();this.#Hr=null}resetEdited(){if(!this.#vr){return}({contentsObj:this.#_r,richText:this.#de}=this.#vr);this.#vr=null;this.#Hr?.remove();this.#Hr=null;this.#I=null}remove(){this.#Wr?.abort();this.#Wr=null;this.#Hr?.remove();this.#Hr=null;this.#Yr=false;this.#zr=false;this.#Gr?.remove();this.#Gr=null;if(this.trigger){for(const t of this.trigger){t.classList.remove("popupTriggerArea")}}}#oo(){if(this.#I!==null){return}const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#Ur;let r=!!this.#jr;let o=r?this.#jr:this.#Xr;for(const t of this.#Lr){if(!o||xt.intersect(t.data.rect,o)!==null){o=t.data.rect;r=true;break}}const a=xt.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]);const h=5;const c=r?o[2]-o[0]+h:0;const l=a[0]+c;const u=a[1];this.#I=[100*(l-i)/e,100*(u-n)/s];const{style:f}=this.#Mt;f.left=`${this.#I[0]}%`;f.top=`${this.#I[1]}%`}#Or(){if(this.#H){this.#H.toggleCommentPopup(this,false);return}this.#zr=!this.#zr;if(this.#zr){this.#Rr();this.#Mt.addEventListener("click",this.#Fr);this.#Mt.addEventListener("keydown",this.#Pr)}else{this.#Dr();this.#Mt.removeEventListener("click",this.#Fr);this.#Mt.removeEventListener("keydown",this.#Pr)}}#Rr(){if(!this.#Hr){this.render()}if(!this.isVisible){this.#oo();this.#Mt.hidden=false;this.#Mt.style.zIndex=parseInt(this.#Mt.style.zIndex)+1e3}else if(this.#zr){this.#Mt.classList.add("focused")}}#Dr(){this.#Mt.classList.remove("focused");if(this.#zr||!this.isVisible){return}this.#Mt.hidden=true;this.#Mt.style.zIndex=parseInt(this.#Mt.style.zIndex)-1e3}forceHide(){this.#Yr=this.isVisible;if(!this.#Yr){return}this.#Mt.hidden=true}maybeShow(){if(this.#H){return}this.#Qr();if(!this.#Yr){return}if(!this.#Hr){this.#Rr()}this.#Yr=false;this.#Mt.hidden=false}get isVisible(){if(this.#H){return false}return this.#Mt.hidden===false}}class Tn extends pn{constructor(t){super(t,{isRenderable:true,ignoreBorder:true});this.textContent=t.data.textContent;this.textPosition=t.data.textPosition;this.annotationEditorType=L.FREETEXT}render(){this.container.classList.add("freeTextAnnotation");if(this.textContent){const t=this.contentElement=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)}if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}this._editOnDoubleClick();return this.container}}class En extends pn{#ao=null;constructor(t){super(t,{isRenderable:true,ignoreBorder:true})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:s}=this;const i=this.svgFactory.create(e,s,true);const n=this.#ao=this.svgFactory.createElement("svg:line");n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]);n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]);n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]);n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]);n.setAttribute("stroke-width",t.borderStyle.width||1);n.setAttribute("stroke","transparent");n.setAttribute("fill","transparent");i.append(n);this.container.append(i);if(!t.popupRef&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}return this.container}getElementsToTriggerPopup(){return this.#ao}addHighlightArea(){this.container.classList.add("highlightArea")}}class Pn extends pn{#ho=null;constructor(t){super(t,{isRenderable:true,ignoreBorder:true})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:s}=this;const i=this.svgFactory.create(e,s,true);const n=t.borderStyle.width;const r=this.#ho=this.svgFactory.createElement("svg:rect");r.setAttribute("x",n/2);r.setAttribute("y",n/2);r.setAttribute("width",e-n);r.setAttribute("height",s-n);r.setAttribute("stroke-width",n||1);r.setAttribute("stroke","transparent");r.setAttribute("fill","transparent");i.append(r);this.container.append(i);if(!t.popupRef&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}return this.container}getElementsToTriggerPopup(){return this.#ho}addHighlightArea(){this.container.classList.add("highlightArea")}}class Nn extends pn{#co=null;constructor(t){super(t,{isRenderable:true,ignoreBorder:true})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:s}=this;const i=this.svgFactory.create(e,s,true);const n=t.borderStyle.width;const r=this.#co=this.svgFactory.createElement("svg:ellipse");r.setAttribute("cx",e/2);r.setAttribute("cy",s/2);r.setAttribute("rx",e/2-n/2);r.setAttribute("ry",s/2-n/2);r.setAttribute("stroke-width",n||1);r.setAttribute("stroke","transparent");r.setAttribute("fill","transparent");i.append(r);this.container.append(i);if(!t.popupRef&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}return this.container}getElementsToTriggerPopup(){return this.#co}addHighlightArea(){this.container.classList.add("highlightArea")}}class Dn extends pn{#lo=null;constructor(t){super(t,{isRenderable:true,ignoreBorder:true});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:n,height:r}=this;if(!e){return this.container}const o=this.svgFactory.create(n,r,true);let a=[];for(let s=0,i=e.length;s<i;s+=2){const i=e[s]-t[0];const n=t[3]-e[s+1];a.push(`${i},${n}`)}a=a.join(" ");const h=this.#lo=this.svgFactory.createElement(this.svgElementName);h.setAttribute("points",a);h.setAttribute("stroke-width",s.width||1);h.setAttribute("stroke","transparent");h.setAttribute("fill","transparent");o.append(h);this.container.append(o);if(!i&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}return this.container}getElementsToTriggerPopup(){return this.#lo}addHighlightArea(){this.container.classList.add("highlightArea")}}class In extends Dn{constructor(t){super(t);this.containerClassName="polygonAnnotation";this.svgElementName="svg:polygon"}}class Rn extends pn{constructor(t){super(t,{isRenderable:true,ignoreBorder:true})}render(){this.container.classList.add("caretAnnotation");if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}return this.container}}class Fn extends pn{#uo=null;#fo=[];constructor(t){super(t,{isRenderable:true,ignoreBorder:true});this.containerClassName="inkAnnotation";this.svgElementName="svg:polyline";this.annotationEditorType=this.data.it==="InkHighlight"?L.HIGHLIGHT:L.INK}#do(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:n}}=this;const{transform:r,width:o,height:a}=this.#do(e,t);const h=this.svgFactory.create(o,a,true);const c=this.#uo=this.svgFactory.createElement("svg:g");h.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",r);for(let t=0,e=s.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#fo.push(e);e.setAttribute("points",s[t].join(","));c.append(e)}if(!n&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}this.container.append(h);this._editOnDoubleClick();return this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:s,rect:i}=t;const n=this.#uo;if(e>=0){n.setAttribute("stroke-width",e||1)}if(s){for(let t=0,e=this.#fo.length;t<e;t++){this.#fo[t].setAttribute("points",s[t].join(","))}}if(i){const{transform:t,width:e,height:s}=this.#do(this.data.rotation,i);const r=n.parentElement;r.setAttribute("viewBox",`0 0 ${e} ${s}`);n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#fo}addHighlightArea(){this.container.classList.add("highlightArea")}}class On extends pn{constructor(t){super(t,{isRenderable:true,ignoreBorder:true,createQuadrilaterals:true});this.annotationEditorType=L.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}this.container.classList.add("highlightAnnotation");this._editOnDoubleClick();if(t){const e=document.createElement("mark");e.classList.add("overlaidText");e.textContent=t;this.container.append(e)}return this.container}}class $n extends pn{constructor(t){super(t,{isRenderable:true,ignoreBorder:true,createQuadrilaterals:true})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}this.container.classList.add("underlineAnnotation");if(t){const e=document.createElement("u");e.classList.add("overlaidText");e.textContent=t;this.container.append(e)}return this.container}}class _n extends pn{constructor(t){super(t,{isRenderable:true,ignoreBorder:true,createQuadrilaterals:true})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}this.container.classList.add("squigglyAnnotation");if(t){const e=document.createElement("u");e.classList.add("overlaidText");e.textContent=t;this.container.append(e)}return this.container}}class Bn extends pn{constructor(t){super(t,{isRenderable:true,ignoreBorder:true,createQuadrilaterals:true})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}this.container.classList.add("strikeoutAnnotation");if(t){const e=document.createElement("s");e.classList.add("overlaidText");e.textContent=t;this.container.append(e)}return this.container}}class Ln extends pn{constructor(t){super(t,{isRenderable:true,ignoreBorder:true});this.annotationEditorType=L.STAMP}render(){this.container.classList.add("stampAnnotation");this.container.setAttribute("role","img");if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}this._editOnDoubleClick();return this.container}}class Un extends pn{#po=null;constructor(t){super(t,{isRenderable:true});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;if(e.hasAppearance||e.fillAlpha===0){s=document.createElement("div")}else{s=document.createElement("img");s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`;if(e.fillAlpha&&e.fillAlpha<1){s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`}}s.addEventListener("dblclick",this.#go.bind(this));this.#po=s;const{isMac:i}=yt.platform;t.addEventListener("keydown",(t=>{if(t.key==="Enter"&&(i?t.metaKey:t.ctrlKey)){this.#go()}}));if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=true;this._createPopup()}else{s.classList.add("popupTriggerArea")}t.append(s);return t}getElementsToTriggerPopup(){return this.#po}addHighlightArea(){this.container.classList.add("highlightArea")}#go(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class jn{#mo=null;#wo=null;#U=null;#bo=new Map;#Ao=null;#yo=null;#Lr=[];#vo=false;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r,structTreeLayer:o,commentManager:a,linkService:h,annotationStorage:c}){this.div=t;this.#mo=e;this.#wo=s;this.#Ao=o||null;this.#yo=h||null;this.#U=c||new Oe;this.page=n;this.viewport=r;this.zIndex=0;this._annotationEditorUIManager=i;this._commentManager=a||null}hasEditableAnnotations(){return this.#bo.size>0}async render(t){const{annotations:e}=t;const s=this.div;ee(s,this.viewport);const i=new Map;const n=[];const r={data:null,layer:s,linkService:this.#yo,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==false,svgFactory:new cn,annotationStorage:this.#U,enableComment:t.enableComment===true,enableScripting:t.enableScripting===true,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML){continue}const e=t.annotationType===G.POPUP;if(!e){if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1]){continue}}else{const e=i.get(t.id);if(!e){continue}if(!this._commentManager){n.push(t);continue}r.elements=e}r.data=t;const s=dn.create(r);if(!s.isRenderable){continue}if(!e){this.#Lr.push(s);if(t.popupRef){const e=i.get(t.popupRef);if(!e){i.set(t.popupRef,[s])}else{e.push(s)}}}const o=s.render();if(t.hidden){o.style.visibility="hidden"}if(s._isEditable){this.#bo.set(s.data.id,s);this._annotationEditorUIManager?.renderAnnotationElement(s)}}await this.#xo();for(const t of n){const e=r.elements=i.get(t.id);r.data=t;const s=dn.create(r);if(!s.isRenderable){continue}const n=s.render();s.contentElement.id=`${Et}${t.id}`;if(t.hidden){n.style.visibility="hidden"}e.at(-1).container.after(n)}this.#ko()}async#xo(){if(this.#Lr.length===0){return}this.div.replaceChildren();const t=[];if(!this.#vo){this.#vo=true;for(const{contentElement:e,data:{id:s}}of this.#Lr){const i=e.id=`${Et}${s}`;t.push(this.#Ao?.getAriaAttributes(i).then((t=>{if(t){for(const[s,i]of t){e.setAttribute(s,i)}}})))}}this.#Lr.sort((({data:{rect:[t,e,s,i]}},{data:{rect:[n,r,o,a]}})=>{if(t===s&&e===i){return 1}if(n===o&&r===a){return-1}const h=i;const c=e;const l=(e+i)/2;const u=a;const f=r;const d=(r+a)/2;if(l>=u&&d<=c){return-1}if(d>=h&&l<=f){return 1}const p=(t+s)/2;const g=(n+o)/2;return p-g}));const e=document.createDocumentFragment();for(const t of this.#Lr){e.append(t.container);if(this._commentManager){(t.extraPopupElement?.popup||t.popup)?.renderCommentButton()}else if(t.extraPopupElement){e.append(t.extraPopupElement.render())}}this.div.append(e);await Promise.all(t);if(this.#mo){for(const t of this.#Lr){this.#mo.addPointerInTextLayer(t.contentElement,false)}}}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:this.#yo,svgFactory:new cn,parent:this};for(const s of t){s.borderStyle||=jn._defaultBorderStyle;e.data=s;const t=dn.create(e);if(!t.isRenderable){continue}t.render();t.contentElement.id=`${Et}${s.id}`;this.#Lr.push(t)}await this.#xo()}update({viewport:t}){const e=this.div;this.viewport=t;ee(e,{rotation:t.rotation});this.#ko();e.hidden=false}#ko(){if(!this.#wo){return}const t=this.div;for(const[e,s]of this.#wo){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i){continue}s.className="annotationContent";const{firstChild:n}=i;if(!n){i.append(s)}else if(n.nodeName==="CANVAS"){n.replaceWith(s)}else if(!n.classList.contains("annotationContent")){n.before(s)}else{n.after(s)}const r=this.#bo.get(e);if(!r){continue}if(r._hasNoCanvas){this._annotationEditorUIManager?.setMissingCanvas(e,i.id,s);r._hasNoCanvas=false}else{r.canvas=s}}this.#wo.clear()}getEditableAnnotations(){return Array.from(this.#bo.values())}getEditableAnnotation(t){return this.#bo.get(t)}addFakeAnnotation(t){const{div:e}=this;const{id:s,rotation:i}=t;const n=new gn({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#yo,annotationStorage:this.#U});n.render();n.contentElement.id=`${Et}${s}`;n.createOrUpdatePopup();this.#Lr.push(n);return n}removeAnnotation(t){const e=this.#Lr.findIndex((e=>e.data.id===t));if(e<0){return}const[s]=this.#Lr.splice(e,1);this.#mo?.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length===0){return}for(const e of t){e.updateFakeAnnotationElement(this)}this.#xo()}togglePointerEvents(t=false){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return at(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:V.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const zn=/\r\n?|\n/g;class Hn extends Ee{#So="";#Mo=`${this.id}-editor`;#Co=null;#io;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Hn.prototype;const e=t=>t.isEmpty();const s=Se.TRANSLATE_SMALL;const i=Se.TRANSLATE_BIG;return at(this,"_keyboardManager",new xe([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:true}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=L.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"});this.color=t.color||Hn._defaultColor||Ee._defaultLineColor;this.#io=t.fontSize||Hn._defaultFontSize;if(!this.annotationElementId){this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}this.canAddComment=false}static initialize(t,e){Ee.initialize(t,e);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case U.FREETEXT_SIZE:Hn._defaultFontSize=e;break;case U.FREETEXT_COLOR:Hn._defaultColor=e;break}}updateParams(t,e){switch(t){case U.FREETEXT_SIZE:this.#To(e);break;case U.FREETEXT_COLOR:this.#to(e);break}}static get defaultPropertiesToUpdate(){return[[U.FREETEXT_SIZE,Hn._defaultFontSize],[U.FREETEXT_COLOR,Hn._defaultColor||Ee._defaultLineColor]]}get propertiesToUpdate(){return[[U.FREETEXT_SIZE,this.#io],[U.FREETEXT_COLOR,this.color]]}get toolbarButtons(){this._colorPicker||=new nn(this);return[["colorPicker",this._colorPicker]]}get colorType(){return U.FREETEXT_COLOR}#To(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`;this.translate(0,-(t-this.#io)*this.parentScale);this.#io=t;this.#Eo()};const s=this.#io;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:true,type:U.FREETEXT_SIZE,overwriteIfSameType:true,keepUndo:true})}onUpdatedColor(){this.editorDiv.style.color=this.color;this._colorPicker?.update(this.color);super.onUpdatedColor()}#to(t){const e=t=>{this.color=t;this.onUpdatedColor()};const s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:true,type:U.FREETEXT_COLOR,overwriteIfSameType:true,keepUndo:true})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,true)}getInitialTranslation(){const t=this.parentScale;return[-Hn._internalPadding*t,-(Hn._internalPadding+this.#io)*t]}rebuild(){if(!this.parent){return}super.rebuild();if(this.div===null){return}if(!this.isAttachedToDOM){this.parent.add(this)}}enableEditMode(){if(!super.enableEditMode()){return false}this.overlayDiv.classList.remove("enabled");this.editorDiv.contentEditable=true;this._isDraggable=false;this.div.removeAttribute("aria-activedescendant");this.#Co=new AbortController;const t=this._uiManager.combinedSignal(this.#Co);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});return true}disableEditMode(){if(!super.disableEditMode()){return false}this.overlayDiv.classList.add("enabled");this.editorDiv.contentEditable=false;this.div.setAttribute("aria-activedescendant",this.#Mo);this._isDraggable=true;this.#Co?.abort();this.#Co=null;this.div.focus({preventScroll:true});this.isEditing=false;this.parent.div.classList.add("freetextEditing");return true}focusin(t){if(!this._focusEventsAllowed){return}super.focusin(t);if(t.target!==this.editorDiv){this.editorDiv.focus()}}onceAdded(t){if(this.width){return}this.enableEditMode();if(t){this.editorDiv.focus()}if(this._initialOptions?.isCentered){this.center()}this._initialOptions=null}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=false;if(this.parent){this.parent.setEditingState(true);this.parent.div.classList.add("freetextEditing")}super.remove()}#Po(){const t=[];this.editorDiv.normalize();let e=null;for(const s of this.editorDiv.childNodes){if(e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR"){continue}t.push(Hn.#No(s));e=s}return t.join("\n")}#Eo(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM){s=this.div.getBoundingClientRect()}else{const{currentLayer:t,div:e}=this;const i=e.style.display;const n=e.classList.contains("hidden");e.classList.remove("hidden");e.style.display="hidden";t.div.append(this.div);s=e.getBoundingClientRect();e.remove();e.style.display=i;e.classList.toggle("hidden",n)}if(this.rotation%180===this.parentRotation%180){this.width=s.width/t;this.height=s.height/e}else{this.width=s.height/t;this.height=s.width/e}this.fixAndSetPosition()}commit(){if(!this.isInEditMode()){return}super.commit();this.disableEditMode();const t=this.#So;const e=this.#So=this.#Po().trimEnd();if(t===e){return}const s=t=>{this.#So=t;if(!t){this.remove();return}this.#Do();this._uiManager.rebuild(this);this.#Eo()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:false});this.#Eo()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode();this.editorDiv.focus()}keydown(t){if(t.target===this.div&&t.key==="Enter"){this.enterInEditMode();t.preventDefault()}}editorDivKeydown(t){Hn._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=true}editorDivBlur(t){this.isEditing=false}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",true)}get canChangeContent(){return true}render(){if(this.div){return this.div}let t,e;if(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",this.#Mo);this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2");this.editorDiv.setAttribute("data-l10n-attrs","default-content");this.enableEditing();this.editorDiv.contentEditable=true;const{style:s}=this.editorDiv;s.fontSize=`calc(${this.#io}px * var(--total-scale-factor))`;s.color=this.color;this.div.append(this.editorDiv);this.overlayDiv=document.createElement("div");this.overlayDiv.classList.add("overlay","enabled");this.div.append(this.overlayDiv);if(this._isCopy||this.annotationElementId){const[s,i]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,o]=this.getInitialTranslation();[r,o]=this.pageTranslationToScreen(r,o);const[a,h]=this.pageDimensions;const[c,l]=this.pageTranslation;let u,f;switch(this.rotation){case 0:u=t+(n[0]-c)/a;f=e+this.height-(n[1]-l)/h;break;case 90:u=t+(n[0]-c)/a;f=e-(n[1]-l)/h;[r,o]=[o,-r];break;case 180:u=t-this.width+(n[0]-c)/a;f=e-(n[1]-l)/h;[r,o]=[-r,-o];break;case 270:u=t+(n[0]-c-this.height*h)/a;f=e+(n[1]-l-this.width*a)/h;[r,o]=[-o,r];break}this.setAt(u*s,f*i,r,o)}else{this._moveAfterPaste(t,e)}this.#Do();this._isDraggable=true;this.editorDiv.contentEditable=false}else{this._isDraggable=false;this.editorDiv.contentEditable=true}return this.div}static#No(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(zn,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData;const{types:s}=e;if(s.length===1&&s[0]==="text/plain"){return}t.preventDefault();const i=Hn.#Io(e.getData("text")||"").replaceAll(zn,"\n");if(!i){return}const n=window.getSelection();if(!n.rangeCount){return}this.editorDiv.normalize();n.deleteFromDocument();const r=n.getRangeAt(0);if(!i.includes("\n")){r.insertNode(document.createTextNode(i));this.editorDiv.normalize();n.collapseToStart();return}const{startContainer:o,startOffset:a}=r;const h=[];const c=[];if(o.nodeType===Node.TEXT_NODE){const t=o.parentElement;c.push(o.nodeValue.slice(a).replaceAll(zn,""));if(t!==this.editorDiv){let e=h;for(const s of this.editorDiv.childNodes){if(s===t){e=c;continue}e.push(Hn.#No(s))}}h.push(o.nodeValue.slice(0,a).replaceAll(zn,""))}else if(o===this.editorDiv){let t=h;let e=0;for(const s of this.editorDiv.childNodes){if(e++===a){t=c}t.push(Hn.#No(s))}}this.#So=`${h.join("\n")}${i}${c.join("\n")}`;this.#Do();const l=new Range;let u=Math.sumPrecise(h.map((t=>t.length)));for(const{firstChild:t}of this.editorDiv.childNodes){if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(u<=e){l.setStart(t,u);l.setEnd(t,u);break}u-=e}}n.removeAllRanges();n.addRange(l)}#Do(){this.editorDiv.replaceChildren();if(!this.#So){return}for(const t of this.#So.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br"));this.editorDiv.append(e)}}#Ro(){return this.#So.replaceAll(" "," ")}static#Io(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=Hn._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,s){let i=null;if(t instanceof Tn){const{data:{defaultAppearanceData:{fontSize:e,fontColor:s},rect:n,rotation:r,id:o,popupRef:a,richText:h,contentsObj:c,creationDate:l,modificationDate:u},textContent:f,textPosition:d,parent:{page:{pageNumber:p}}}=t;if(!f||f.length===0){return null}i=t={annotationType:L.FREETEXT,color:Array.from(s),fontSize:e,value:f.join("\n"),position:d,pageIndex:p-1,rect:n.slice(0),rotation:r,annotationElementId:o,id:o,deleted:false,popupRef:a,comment:c?.str||null,richText:h,creationDate:l,modificationDate:u}}const n=await super.deserialize(t,e,s);n.#io=t.fontSize;n.color=xt.makeHexColor(...t.color);n.#So=Hn.#Io(t.value);n._initialData=i;if(t.comment){n.setCommentData(t)}return n}serialize(t=false){if(this.isEmpty()){return null}if(this.deleted){return this.serializeDeleted()}const e=Ee._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color);const s=Object.assign(super.serialize(t),{color:e,fontSize:this.#io,value:this.#Ro()});this.addComment(s);if(t){s.isCopy=true;return s}if(this.annotationElementId&&!this.#Fo(s)){return null}s.id=this.annotationElementId;return s}#Fo(t){const{value:e,fontSize:s,color:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some(((t,e)=>t!==i[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e){return null}const{style:s}=e;s.fontSize=`calc(${this.#io}px * var(--total-scale-factor))`;s.color=this.color;e.replaceChildren();for(const t of this.#So.split("\n")){const s=document.createElement("div");s.append(t?document.createTextNode(t):document.createElement("br"));e.append(s)}t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#So}});return e}resetAnnotationElement(t){super.resetAnnotationElement(t);t.resetEdited()}}class Wn{static PRECISION=1e-4;toSVGPath(){st("Abstract method `toSVGPath` must be implemented.")}get box(){st("Abstract getter `box` must be implemented.")}serialize(t,e){st("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let o=0,a=t.length;o<a;o+=2){r[o]=e+t[o]*i;r[o+1]=s+t[o+1]*n}return r}static _rescaleAndSwap(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let o=0,a=t.length;o<a;o+=2){r[o]=e+t[o+1]*i;r[o+1]=s+t[o]*n}return r}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2){i[n]=e+t[n];i[n+1]=s+t[n+1]}return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,n){switch(n){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,n,r){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+r)/6,(s+n)/2,(i+r)/2]}}class Gn{#Oo;#$o=[];#_o;#Bo;#Lo=[];#Uo=new Float32Array(18);#jo;#zo;#Ho;#Wo;#Go;#Vo;#Xo=[];static#qo=8;static#Yo=2;static#Jo=Gn.#qo+Gn.#Yo;constructor({x:t,y:e},s,i,n,r,o=0){this.#Oo=s;this.#Vo=n*i;this.#Bo=r;this.#Uo.set([NaN,NaN,NaN,NaN,t,e],6);this.#_o=o;this.#Wo=Gn.#qo*i;this.#Ho=Gn.#Jo*i;this.#Go=i;this.#Xo.push(t,e)}isEmpty(){return isNaN(this.#Uo[8])}#Ko(){const t=this.#Uo.subarray(4,6);const e=this.#Uo.subarray(16,18);const[s,i,n,r]=this.#Oo;return[(this.#jo+(t[0]-e[0])/2-s)/n,(this.#zo+(t[1]-e[1])/2-i)/r,(this.#jo+(e[0]-t[0])/2-s)/n,(this.#zo+(e[1]-t[1])/2-i)/r]}add({x:t,y:e}){this.#jo=t;this.#zo=e;const[s,i,n,r]=this.#Oo;let[o,a,h,c]=this.#Uo.subarray(8,12);const l=t-h;const u=e-c;const f=Math.hypot(l,u);if(f<this.#Ho){return false}const d=f-this.#Wo;const p=d/f;const g=p*l;const m=p*u;let w=o;let b=a;o=h;a=c;h+=g;c+=m;this.#Xo?.push(t,e);const A=-m/d;const y=g/d;const v=A*this.#Vo;const x=y*this.#Vo;this.#Uo.set(this.#Uo.subarray(2,8),0);this.#Uo.set([h+v,c+x],4);this.#Uo.set(this.#Uo.subarray(14,18),12);this.#Uo.set([h-v,c-x],16);if(isNaN(this.#Uo[6])){if(this.#Lo.length===0){this.#Uo.set([o+v,a+x],2);this.#Lo.push(NaN,NaN,NaN,NaN,(o+v-s)/n,(a+x-i)/r);this.#Uo.set([o-v,a-x],14);this.#$o.push(NaN,NaN,NaN,NaN,(o-v-s)/n,(a-x-i)/r)}this.#Uo.set([w,b,o,a,h,c],6);return!this.isEmpty()}this.#Uo.set([w,b,o,a,h,c],6);const k=Math.abs(Math.atan2(b-a,w-o)-Math.atan2(m,g));if(k<Math.PI/2){[o,a,h,c]=this.#Uo.subarray(2,6);this.#Lo.push(NaN,NaN,NaN,NaN,((o+h)/2-s)/n,((a+c)/2-i)/r);[o,a,w,b]=this.#Uo.subarray(14,18);this.#$o.push(NaN,NaN,NaN,NaN,((w+o)/2-s)/n,((b+a)/2-i)/r);return true}[w,b,o,a,h,c]=this.#Uo.subarray(0,6);this.#Lo.push(((w+5*o)/6-s)/n,((b+5*a)/6-i)/r,((5*o+h)/6-s)/n,((5*a+c)/6-i)/r,((o+h)/2-s)/n,((a+c)/2-i)/r);[h,c,o,a,w,b]=this.#Uo.subarray(12,18);this.#$o.push(((w+5*o)/6-s)/n,((b+5*a)/6-i)/r,((5*o+h)/6-s)/n,((5*a+c)/6-i)/r,((o+h)/2-s)/n,((a+c)/2-i)/r);return true}toSVGPath(){if(this.isEmpty()){return""}const t=this.#Lo;const e=this.#$o;if(isNaN(this.#Uo[6])&&!this.isEmpty()){return this.#Qo()}const s=[];s.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6){if(isNaN(t[e])){s.push(`L${t[e+4]} ${t[e+5]}`)}else{s.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`)}}this.#Zo(s);for(let t=e.length-6;t>=6;t-=6){if(isNaN(e[t])){s.push(`L${e[t+4]} ${e[t+5]}`)}else{s.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`)}}this.#ta(s);return s.join(" ")}#Qo(){const[t,e,s,i]=this.#Oo;const[n,r,o,a]=this.#Ko();return`M${(this.#Uo[2]-t)/s} ${(this.#Uo[3]-e)/i} L${(this.#Uo[4]-t)/s} ${(this.#Uo[5]-e)/i} L${n} ${r} L${o} ${a} L${(this.#Uo[16]-t)/s} ${(this.#Uo[17]-e)/i} L${(this.#Uo[14]-t)/s} ${(this.#Uo[15]-e)/i} Z`}#ta(t){const e=this.#$o;t.push(`L${e[4]} ${e[5]} Z`)}#Zo(t){const[e,s,i,n]=this.#Oo;const r=this.#Uo.subarray(4,6);const o=this.#Uo.subarray(16,18);const[a,h,c,l]=this.#Ko();t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${a} ${h} L${c} ${l} L${(o[0]-e)/i} ${(o[1]-s)/n}`)}newFreeDrawOutline(t,e,s,i,n,r){return new Vn(t,e,s,i,n,r)}getOutlines(){const t=this.#Lo;const e=this.#$o;const s=this.#Uo;const[i,n,r,o]=this.#Oo;const a=new Float32Array((this.#Xo?.length??0)+2);for(let t=0,e=a.length-2;t<e;t+=2){a[t]=(this.#Xo[t]-i)/r;a[t+1]=(this.#Xo[t+1]-n)/o}a[a.length-2]=(this.#jo-i)/r;a[a.length-1]=(this.#zo-n)/o;if(isNaN(s[6])&&!this.isEmpty()){return this.#ea(a)}const h=new Float32Array(this.#Lo.length+24+this.#$o.length);let c=t.length;for(let e=0;e<c;e+=2){if(isNaN(t[e])){h[e]=h[e+1]=NaN;continue}h[e]=t[e];h[e+1]=t[e+1]}c=this.#sa(h,c);for(let t=e.length-6;t>=6;t-=6){for(let s=0;s<6;s+=2){if(isNaN(e[t+s])){h[c]=h[c+1]=NaN;c+=2;continue}h[c]=e[t+s];h[c+1]=e[t+s+1];c+=2}}this.#ia(h,c);return this.newFreeDrawOutline(h,a,this.#Oo,this.#Go,this.#_o,this.#Bo)}#ea(t){const e=this.#Uo;const[s,i,n,r]=this.#Oo;const[o,a,h,c]=this.#Ko();const l=new Float32Array(36);l.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,o,a,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0);return this.newFreeDrawOutline(l,t,this.#Oo,this.#Go,this.#_o,this.#Bo)}#ia(t,e){const s=this.#$o;t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e);return e+=6}#sa(t,e){const s=this.#Uo.subarray(4,6);const i=this.#Uo.subarray(16,18);const[n,r,o,a]=this.#Oo;const[h,c,l,u]=this.#Ko();t.set([NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-r)/a,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,l,u,NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-r)/a],e);return e+=24}}class Vn extends Wn{#Oo;#na=new Float32Array(4);#_o;#Bo;#Xo;#Go;#ra;constructor(t,e,s,i,n,r){super();this.#ra=t;this.#Xo=e;this.#Oo=s;this.#Go=i;this.#_o=n;this.#Bo=r;this.firstPoint=[NaN,NaN];this.lastPoint=[NaN,NaN];this.#oa(r);const[o,a,h,c]=this.#na;for(let e=0,s=t.length;e<s;e+=2){t[e]=(t[e]-o)/h;t[e+1]=(t[e+1]-a)/c}for(let t=0,s=e.length;t<s;t+=2){e[t]=(e[t]-o)/h;e[t+1]=(e[t+1]-a)/c}}toSVGPath(){const t=[`M${this.#ra[4]} ${this.#ra[5]}`];for(let e=6,s=this.#ra.length;e<s;e+=6){if(isNaN(this.#ra[e])){t.push(`L${this.#ra[e+4]} ${this.#ra[e+5]}`);continue}t.push(`C${this.#ra[e]} ${this.#ra[e+1]} ${this.#ra[e+2]} ${this.#ra[e+3]} ${this.#ra[e+4]} ${this.#ra[e+5]}`)}t.push("Z");return t.join(" ")}serialize([t,e,s,i],n){const r=s-t;const o=i-e;let a;let h;switch(n){case 0:a=Wn._rescale(this.#ra,t,i,r,-o);h=Wn._rescale(this.#Xo,t,i,r,-o);break;case 90:a=Wn._rescaleAndSwap(this.#ra,t,e,r,o);h=Wn._rescaleAndSwap(this.#Xo,t,e,r,o);break;case 180:a=Wn._rescale(this.#ra,s,e,-r,o);h=Wn._rescale(this.#Xo,s,e,-r,o);break;case 270:a=Wn._rescaleAndSwap(this.#ra,s,i,-r,-o);h=Wn._rescaleAndSwap(this.#Xo,s,i,-r,-o);break}return{outline:Array.from(a),points:[Array.from(h)]}}#oa(t){const e=this.#ra;let s=e[4];let i=e[5];const n=[s,i,s,i];let r=s;let o=i;let a=s;let h=i;const c=t?Math.max:Math.min;const l=new Float32Array(4);for(let t=6,u=e.length;t<u;t+=6){const u=e[t+4],f=e[t+5];if(isNaN(e[t])){xt.pointBoundingBox(u,f,n);if(o>f){r=u;o=f}else if(o===f){r=c(r,u)}if(h<f){a=u;h=f}else if(h===f){a=c(a,u)}}else{l[0]=l[1]=Infinity;l[2]=l[3]=-Infinity;xt.bezierBoundingBox(s,i,...e.slice(t,t+6),l);xt.rectBoundingBox(l[0],l[1],l[2],l[3],n);if(o>l[1]){r=l[0];o=l[1]}else if(o===l[1]){r=c(r,l[0])}if(h<l[3]){a=l[2];h=l[3]}else if(h===l[3]){a=c(a,l[2])}}s=u;i=f}const u=this.#na;u[0]=n[0]-this.#_o;u[1]=n[1]-this.#_o;u[2]=n[2]-n[0]+2*this.#_o;u[3]=n[3]-n[1]+2*this.#_o;this.firstPoint=[r,o];this.lastPoint=[a,h]}get box(){return this.#na}newOutliner(t,e,s,i,n,r=0){return new Gn(t,e,s,i,n,r)}getNewOutline(t,e){const[s,i,n,r]=this.#na;const[o,a,h,c]=this.#Oo;const l=n*h;const u=r*c;const f=s*h+o;const d=i*c+a;const p=this.newOutliner({x:this.#Xo[0]*l+f,y:this.#Xo[1]*u+d},this.#Oo,this.#Go,t,this.#Bo,e??this.#_o);for(let t=2;t<this.#Xo.length;t+=2){p.add({x:this.#Xo[t]*l+f,y:this.#Xo[t+1]*u+d})}return p.getOutlines()}}class Xn{#Oo;#aa;#ha;#ca=[];#la=[];constructor(t,e=0,s=0,i=true){const n=[Infinity,Infinity,-Infinity,-Infinity];const r=10**-4;for(const{x:s,y:i,width:o,height:a}of t){const t=Math.floor((s-e)/r)*r;const h=Math.ceil((s+o+e)/r)*r;const c=Math.floor((i-e)/r)*r;const l=Math.ceil((i+a+e)/r)*r;const u=[t,c,l,true];const f=[h,c,l,false];this.#ca.push(u,f);xt.rectBoundingBox(t,c,h,l,n)}const o=n[2]-n[0]+2*s;const a=n[3]-n[1]+2*s;const h=n[0]-s;const c=n[1]-s;let l=i?-Infinity:Infinity;let u=Infinity;const f=this.#ca.at(i?-1:-2);const d=[f[0],f[2]];for(const t of this.#ca){const[e,s,n,r]=t;if(!r&&i){if(s<u){u=s;l=e}else if(s===u){l=Math.max(l,e)}}else if(r&&!i){if(s<u){u=s;l=e}else if(s===u){l=Math.min(l,e)}}t[0]=(e-h)/o;t[1]=(s-c)/a;t[2]=(n-c)/a}this.#Oo=new Float32Array([h,c,o,a]);this.#aa=[l,u];this.#ha=d}getOutlines(){this.#ca.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#ca){if(e[3]){t.push(...this.#ua(e));this.#fa(e)}else{this.#da(e);t.push(...this.#ua(e))}}return this.#pa(t)}#pa(t){const e=[];const s=new Set;for(const s of t){const[t,i,n]=s;e.push([t,i,s],[t,n,s])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,i=e.length;t<i;t+=2){const i=e[t][2];const n=e[t+1][2];i.push(n);n.push(i);s.add(i);s.add(n)}const i=[];let n;while(s.size>0){const t=s.values().next().value;let[e,r,o,a,h]=t;s.delete(t);let c=e;let l=r;n=[e,o];i.push(n);while(true){let t;if(s.has(a)){t=a}else if(s.has(h)){t=h}else{break}s.delete(t);[e,r,o,a,h]=t;if(c!==e){n.push(c,l,e,l===r?r:o);c=e}l=l===r?o:r}n.push(c,l)}return new qn(i,this.#Oo,this.#aa,this.#ha)}#ga(t){const e=this.#la;let s=0;let i=e.length-1;while(s<=i){const n=s+i>>1;const r=e[n][0];if(r===t){return n}if(r<t){s=n+1}else{i=n-1}}return i+1}#fa([,t,e]){const s=this.#ga(t);this.#la.splice(s,0,[t,e])}#da([,t,e]){const s=this.#ga(t);for(let i=s;i<this.#la.length;i++){const[s,n]=this.#la[i];if(s!==t){break}if(s===t&&n===e){this.#la.splice(i,1);return}}for(let i=s-1;i>=0;i--){const[s,n]=this.#la[i];if(s!==t){break}if(s===t&&n===e){this.#la.splice(i,1);return}}}#ua(t){const[e,s,i]=t;const n=[[e,s,i]];const r=this.#ga(i);for(let t=0;t<r;t++){const[s,i]=this.#la[t];for(let t=0,r=n.length;t<r;t++){const[,o,a]=n[t];if(i<=o||a<=s){continue}if(o>=s){if(a>i){n[t][1]=i}else{if(r===1){return[]}n.splice(t,1);t--;r--}continue}n[t][2]=s;if(a>i){n.push([e,i,a])}}}return n}}class qn extends Wn{#Oo;#ma;constructor(t,e,s,i){super();this.#ma=t;this.#Oo=e;this.firstPoint=s;this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#ma){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const r=e[n];const o=e[n+1];if(r===s){t.push(`V${o}`);i=o}else if(o===i){t.push(`H${r}`);s=r}}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){const r=[];const o=s-t;const a=i-e;for(const e of this.#ma){const s=new Array(e.length);for(let n=0;n<e.length;n+=2){s[n]=t+e[n]*o;s[n+1]=i-e[n+1]*a}r.push(s)}return r}get box(){return this.#Oo}get classNamesForOutlining(){return["highlightOutline"]}}class Yn extends Gn{newFreeDrawOutline(t,e,s,i,n,r){return new Jn(t,e,s,i,n,r)}}class Jn extends Vn{newOutliner(t,e,s,i,n,r=0){return new Yn(t,e,s,i,n,r)}}class Kn extends Ee{#wa=null;#ba=0;#Aa;#ya=null;#n=null;#va=null;#xa=null;#ka=0;#Sa=null;#Ma=null;#M=null;#Ca=false;#aa=null;#ha=null;#Ta=null;#pe="";#Vo;#Ea="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=L.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Kn.prototype;return at(this,"_keyboardManager",new xe([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"});this.color=t.color||Kn._defaultColor;this.#Vo=t.thickness||Kn._defaultThickness;this.opacity=t.opacity||Kn._defaultOpacity;this.#Aa=t.boxes||null;this.#Ea=t.methodOfCreation||"";this.#pe=t.text||"";this._isDraggable=false;this.defaultL10nId="pdfjs-editor-highlight-editor";if(t.highlightId>-1){this.#Ca=true;this.#Pa(t);this.#Na()}else if(this.#Aa){this.#wa=t.anchorNode;this.#ba=t.anchorOffset;this.#xa=t.focusNode;this.#ka=t.focusOffset;this.#Da();this.#Na();this.rotate(this.rotation)}if(!this.annotationElementId){this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}}get telemetryInitialData(){return{action:"added",type:this.#Ca?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#Vo,methodOfCreation:this.#Ea}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#Da(){const t=new Xn(this.#Aa,.001);this.#Ma=t.getOutlines();[this.x,this.y,this.width,this.height]=this.#Ma.box;const e=new Xn(this.#Aa,.0025,.001,this._uiManager.direction==="ltr");this.#va=e.getOutlines();const{firstPoint:s}=this.#Ma;this.#aa=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height];const{lastPoint:i}=this.#va;this.#ha=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Pa({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#Ma=t;const i=1.5;this.#va=t.getNewOutline(this.#Vo/2+i,.0025);if(e>=0){this.#M=e;this.#ya=s;this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}});this.#Ta=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:true,free:true},bbox:this.#va.box,path:{d:this.#va.toSVGPath()}},true)}else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#M,{bbox:Kn.#Ia(this.#Ma.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}});this.parent.drawLayer.updateProperties(this.#Ta,{bbox:Kn.#Ia(this.#va.box,e),path:{d:this.#va.toSVGPath()}})}const[n,r,o,a]=t.box;switch(this.rotation){case 0:this.x=n;this.y=r;this.width=o;this.height=a;break;case 90:{const[t,e]=this.parentDimensions;this.x=r;this.y=1-n;this.width=o*e/t;this.height=a*t/e;break}case 180:this.x=1-n;this.y=1-r;this.width=o;this.height=a;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-r;this.y=n;this.width=o*e/t;this.height=a*t/e;break}}const{firstPoint:h}=t;this.#aa=[(h[0]-n)/o,(h[1]-r)/a];const{lastPoint:c}=this.#va;this.#ha=[(c[0]-n)/o,(c[1]-r)/a]}static initialize(t,e){Ee.initialize(t,e);Kn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case U.HIGHLIGHT_COLOR:Kn._defaultColor=e;break;case U.HIGHLIGHT_THICKNESS:Kn._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#ha}get commentButtonPosition(){return this.#aa}updateParams(t,e){switch(t){case U.HIGHLIGHT_COLOR:this.#to(e);break;case U.HIGHLIGHT_THICKNESS:this.#Ra(e);break}}static get defaultPropertiesToUpdate(){return[[U.HIGHLIGHT_COLOR,Kn._defaultColor],[U.HIGHLIGHT_THICKNESS,Kn._defaultThickness]]}get propertiesToUpdate(){return[[U.HIGHLIGHT_COLOR,this.color||Kn._defaultColor],[U.HIGHLIGHT_THICKNESS,this.#Vo||Kn._defaultThickness],[U.HIGHLIGHT_FREE,this.#Ca]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#M,{root:{fill:this.color,"fill-opacity":this.opacity}});this.#n?.updateColor(this.color);super.onUpdatedColor()}#to(t){const e=(t,e)=>{this.color=t;this.opacity=e;this.onUpdatedColor()};const s=this.color;const i=this.opacity;this.addCommands({cmd:e.bind(this,t,Kn._defaultOpacity),undo:e.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:true,type:U.HIGHLIGHT_COLOR,overwriteIfSameType:true,keepUndo:true});this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},true)}#Ra(t){const e=this.#Vo;const s=t=>{this.#Vo=t;this.#Fa(t)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:true,type:U.INK_THICKNESS,overwriteIfSameType:true,keepUndo:true});this._reportTelemetry({action:"thickness_changed",thickness:t},true)}get toolbarButtons(){if(this._uiManager.highlightColors){const t=this.#n=new sn({editor:this});return[["colorPicker",t]]}return super.toolbarButtons}disableEditing(){super.disableEditing();this.div.classList.toggle("disabled",true)}enableEditing(){super.enableEditing();this.div.classList.toggle("disabled",false)}fixAndSetPosition(){return super.fixAndSetPosition(this.#Oa())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#Oa())}onceAdded(t){if(!this.annotationElementId){this.parent.addUndoableEditor(this)}if(t){this.div.focus()}}remove(){this.#$a();this._reportTelemetry({action:"deleted"});super.remove()}rebuild(){if(!this.parent){return}super.rebuild();if(this.div===null){return}this.#Na();if(!this.isAttachedToDOM){this.parent.add(this)}}setParent(t){let e=false;if(this.parent&&!t){this.#$a()}else if(t){this.#Na(t);e=!this.parent&&this.div?.classList.contains("selectedEditor")}super.setParent(t);this.show(this._isVisible);if(e){this.select()}}#Fa(t){if(!this.#Ca){return}this.#Pa({highlightOutlines:this.#Ma.getNewOutline(t/2)});this.fixAndSetPosition();this.setDims()}#$a(){if(this.#M===null||!this.parent){return}this.parent.drawLayer.remove(this.#M);this.#M=null;this.parent.drawLayer.remove(this.#Ta);this.#Ta=null}#Na(t=this.parent){if(this.#M!==null){return}({id:this.#M,clipPathId:this.#ya}=t.drawLayer.draw({bbox:this.#Ma.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:true,free:this.#Ca},path:{d:this.#Ma.toSVGPath()}},false,true));this.#Ta=t.drawLayer.drawOutline({rootClass:{highlightOutline:true,free:this.#Ca},bbox:this.#va.box,path:{d:this.#va.toSVGPath()}},this.#Ca);if(this.#Sa){this.#Sa.style.clipPath=this.#ya}}static#Ia([t,e,s,i],n){switch(n){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}rotate(t){const{drawLayer:e}=this.parent;let s;if(this.#Ca){t=(t-this.rotation+360)%360;s=Kn.#Ia(this.#Ma.box,t)}else{s=Kn.#Ia([this.x,this.y,this.width,this.height],t)}e.updateProperties(this.#M,{bbox:s,root:{"data-main-rotation":t}});e.updateProperties(this.#Ta,{bbox:Kn.#Ia(this.#va.box,t),root:{"data-main-rotation":t}})}render(){if(this.div){return this.div}const t=super.render();if(this.#pe){t.setAttribute("aria-label",this.#pe);t.setAttribute("role","mark")}if(this.#Ca){t.classList.add("free")}else{this.div.addEventListener("keydown",this.#_a.bind(this),{signal:this._uiManager._signal})}const e=this.#Sa=document.createElement("div");t.append(e);e.setAttribute("aria-hidden","true");e.className="internal";e.style.clipPath=this.#ya;this.setDims();we(this,this.#Sa,["pointerover","pointerleave"]);this.enableEditing();return t}pointerover(){if(!this.isSelected){this.parent?.drawLayer.updateProperties(this.#Ta,{rootClass:{hovered:true}})}}pointerleave(){if(!this.isSelected){this.parent?.drawLayer.updateProperties(this.#Ta,{rootClass:{hovered:false}})}}#_a(t){Kn._keyboardManager.exec(this,t)}_moveCaret(t){this.parent.unselect(this);switch(t){case 0:case 2:this.#Ba(true);break;case 1:case 3:this.#Ba(false);break}}#Ba(t){if(!this.#wa){return}const e=window.getSelection();if(t){e.setPosition(this.#wa,this.#ba)}else{e.setPosition(this.#xa,this.#ka)}}select(){super.select();if(!this.#Ta){return}this.parent?.drawLayer.updateProperties(this.#Ta,{rootClass:{hovered:false,selected:true}})}unselect(){super.unselect();if(!this.#Ta){return}this.parent?.drawLayer.updateProperties(this.#Ta,{rootClass:{selected:false}});if(!this.#Ca){this.#Ba(false)}}get _mustFixPosition(){return!this.#Ca}show(t=this._isVisible){super.show(t);if(this.parent){this.parent.drawLayer.updateProperties(this.#M,{rootClass:{hidden:!t}});this.parent.drawLayer.updateProperties(this.#Ta,{rootClass:{hidden:!t}})}}#Oa(){return this.#Ca?this.rotation:0}#La(){if(this.#Ca){return null}const[t,e]=this.pageDimensions;const[s,i]=this.pageTranslation;const n=this.#Aa;const r=new Float32Array(n.length*8);let o=0;for(const{x:a,y:h,width:c,height:l}of n){const n=a*t+s;const u=(1-h)*e+i;r[o]=r[o+4]=n;r[o+1]=r[o+3]=u;r[o+2]=r[o+6]=n+c*t;r[o+5]=r[o+7]=u-l*e;o+=8}return r}#Ua(t){return this.#Ma.serialize(t,this.#Oa())}static startHighlighting(t,e,{target:s,x:i,y:n}){const{x:r,y:o,width:a,height:h}=s.getBoundingClientRect();const c=new AbortController;const l=t.combinedSignal(c);const u=e=>{c.abort();this.#ja(t,e)};window.addEventListener("blur",u,{signal:l});window.addEventListener("pointerup",u,{signal:l});window.addEventListener("pointerdown",Xt,{capture:true,passive:false,signal:l});window.addEventListener("contextmenu",Vt,{signal:l});s.addEventListener("pointermove",this.#za.bind(this,t),{signal:l});this._freeHighlight=new Yn({x:i,y:n},[r,o,a,h],t.scale,this._defaultThickness/2,e,.001);({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:true,free:true},path:{d:this._freeHighlight.toSVGPath()}},true,true))}static#za(t,e){if(this._freeHighlight.add(e)){t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}}static#ja(t,e){if(!this._freeHighlight.isEmpty()){t.createAndAddNewEditor(e,false,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"})}else{t.drawLayer.remove(this._freeHighlightId)}this._freeHighlightId=-1;this._freeHighlight=null;this._freeHighlightClipId=""}static async deserialize(t,e,s){let i=null;if(t instanceof On){const{data:{quadPoints:e,rect:s,rotation:n,id:r,color:o,opacity:a,popupRef:h,richText:c,contentsObj:l,creationDate:u,modificationDate:f},parent:{page:{pageNumber:d}}}=t;i=t={annotationType:L.HIGHLIGHT,color:Array.from(o),opacity:a,quadPoints:e,boxes:null,pageIndex:d-1,rect:s.slice(0),rotation:n,annotationElementId:r,id:r,deleted:false,popupRef:h,richText:c,comment:l?.str||null,creationDate:u,modificationDate:f}}else if(t instanceof Fn){const{data:{inkLists:e,rect:s,rotation:n,id:r,color:o,borderStyle:{rawWidth:a},popupRef:h,richText:c,contentsObj:l,creationDate:u,modificationDate:f},parent:{page:{pageNumber:d}}}=t;i=t={annotationType:L.HIGHLIGHT,color:Array.from(o),thickness:a,inkLists:e,boxes:null,pageIndex:d-1,rect:s.slice(0),rotation:n,annotationElementId:r,id:r,deleted:false,popupRef:h,richText:c,comment:l?.str||null,creationDate:u,modificationDate:f}}const{color:n,quadPoints:r,inkLists:o,opacity:a}=t;const h=await super.deserialize(t,e,s);h.color=xt.makeHexColor(...n);h.opacity=a||1;if(o){h.#Vo=t.thickness}h._initialData=i;if(t.comment){h.setCommentData(t)}const[c,l]=h.pageDimensions;const[u,f]=h.pageTranslation;if(r){const t=h.#Aa=[];for(let e=0;e<r.length;e+=8){t.push({x:(r[e]-u)/c,y:1-(r[e+1]-f)/l,width:(r[e+2]-r[e])/c,height:(r[e+1]-r[e+5])/l})}h.#Da();h.#Na();h.rotate(h.rotation)}else if(o){h.#Ca=true;const t=o[0];const s={x:t[0]-u,y:l-(t[1]-f)};const i=new Yn(s,[0,0,c,l],1,h.#Vo/2,true,.001);for(let e=0,n=t.length;e<n;e+=2){s.x=t[e]-u;s.y=l-(t[e+1]-f);i.add(s)}const{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:true,free:true},path:{d:i.toSVGPath()}},true,true);h.#Pa({highlightOutlines:i.getOutlines(),highlightId:n,clipPathId:r});h.#Na();h.rotate(h.parentRotation)}return h}serialize(t=false){if(this.isEmpty()||t){return null}if(this.deleted){return this.serializeDeleted()}const e=Ee._colorManager.convert(this._uiManager.getNonHCMColor(this.color));const s=super.serialize(t);Object.assign(s,{color:e,opacity:this.opacity,thickness:this.#Vo,quadPoints:this.#La(),outlines:this.#Ua(s.rect)});this.addComment(s);if(this.annotationElementId&&!this.#Fo(s)){return null}s.id=this.annotationElementId;return s}#Fo(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some(((t,s)=>t!==e[s]))}renderAnnotationElement(t){if(this.deleted){t.hide();return null}t.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}static canCreateNewEmptyEditor(){return false}}class Qn{#Ha=Object.create(null);updateProperty(t,e){this[t]=e;this.updateSVGProperty(t,e)}updateProperties(t){if(!t){return}for(const[e,s]of Object.entries(t)){if(!e.startsWith("_")){this.updateProperty(e,s)}}}updateSVGProperty(t,e){this.#Ha[t]=e}toSVGProperties(){const t=this.#Ha;this.#Ha=Object.create(null);return{root:t}}reset(){this.#Ha=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){st("Not implemented")}}class Zn extends Ee{#Wa=null;#Ga;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#Va=null;static#Xa=null;static#qa=null;static _INNER_MARGIN=3;constructor(t){super(t);this.#Ga=t.mustBeCommitted||false;this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color);super.onUpdatedColor()}_addOutlines(t){if(t.drawOutlines){this.#Ya(t);this.#Na()}}#Ya({drawOutlines:t,drawId:e,drawingOptions:s}){this.#Wa=t;this._drawingOptions||=s;if(!this.annotationElementId){this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`)}if(e>=0){this._drawId=e;this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)}else{this._drawId=this.#Ja(t,this.parent)}this.#Ka(t.box)}#Ja(t,e){const{id:s}=e.drawLayer.draw(Zn._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),false,false);return s}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[i,n]of Object.entries(e)){if(s.has(i)){Object.assign(t[i],n)}else{t[i]=n}}return t}static getDefaultDrawingOptions(t){st("Not implemented")}static get typesMap(){st("Not implemented")}static get isDrawer(){return true}static get supportMultipleDrawings(){return false}static updateDefaultParams(t,e){const s=this.typesMap.get(t);if(s){this._defaultDrawingOptions.updateProperty(s,e)}if(this._currentParent){Zn.#Va.updateProperty(s,e);this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}updateParams(t,e){const s=this.constructor.typesMap.get(t);if(s){this._updateProperty(t,s,e)}}static get defaultPropertiesToUpdate(){const t=[];const e=this._defaultDrawingOptions;for(const[s,i]of this.typesMap){t.push([s,e[i]])}return t}get propertiesToUpdate(){const t=[];const{_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;const n=i[e];const r=s=>{i.updateProperty(e,s);const n=this.#Wa.updateProperty(e,s);if(n){this.#Ka(n)}this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties());if(t===this.colorType){this.onUpdatedColor()}};this.addCommands({cmd:r.bind(this,s),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:true,type:t,overwriteIfSameType:true,keepUndo:true})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Zn._mergeSVGProperties(this.#Wa.getPathResizingSVGProperties(this.#Qa()),{bbox:this.#Za()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Zn._mergeSVGProperties(this.#Wa.getPathResizedSVGProperties(this.#Qa()),{bbox:this.#Za()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Za()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Zn._mergeSVGProperties(this.#Wa.getPathTranslatedSVGProperties(this.#Qa(),this.parentDimensions),{bbox:this.#Za()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:true}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:false}})}commit(){super.commit();this.disableEditMode();this.disableEditing()}disableEditing(){super.disableEditing();this.div.classList.toggle("disabled",true)}enableEditing(){super.enableEditing();this.div.classList.toggle("disabled",false)}getBaseTranslation(){return[0,0]}get isResizable(){return true}onceAdded(t){if(!this.annotationElementId){this.parent.addUndoableEditor(this)}this._isDraggable=true;if(this.#Ga){this.#Ga=false;this.commit();this.parent.setSelected(this);if(t&&this.isOnScreen){this.div.focus()}}}remove(){this.#$a();super.remove()}rebuild(){if(!this.parent){return}super.rebuild();if(this.div===null){return}this.#Na();this.#Ka(this.#Wa.box);if(!this.isAttachedToDOM){this.parent.add(this)}}setParent(t){let e=false;if(this.parent&&!t){this._uiManager.removeShouldRescale(this);this.#$a()}else if(t){this._uiManager.addShouldRescale(this);this.#Na(t);e=!this.parent&&this.div?.classList.contains("selectedEditor")}super.setParent(t);if(e){this.select()}}#$a(){if(this._drawId===null||!this.parent){return}this.parent.drawLayer.remove(this._drawId);this._drawId=null;this._drawingOptions.reset()}#Na(t=this.parent){if(this._drawId!==null&&this.parent===t){return}if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll();this._drawId=this.#Ja(this.#Wa,t)}#th([t,e,s,i]){const{parentDimensions:[n,r],rotation:o}=this;switch(o){case 90:return[e,1-t,s*(r/n),i*(n/r)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(r/n),i*(n/r)];default:return[t,e,s,i]}}#Qa(){const{x:t,y:e,width:s,height:i,parentDimensions:[n,r],rotation:o}=this;switch(o){case 90:return[1-e,t,s*(n/r),i*(r/n)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(n/r),i*(r/n)];default:return[t,e,s,i]}}#Ka(t){[this.x,this.y,this.width,this.height]=this.#th(t);if(this.div){this.fixAndSetPosition();this.setDims()}this._onResized()}#Za(){const{x:t,y:e,width:s,height:i,rotation:n,parentRotation:r,parentDimensions:[o,a]}=this;switch((n*4+r)/90){case 1:return[1-e-i,t,i,s];case 2:return[1-t-s,1-e-i,s,i];case 3:return[e,1-t-s,i,s];case 4:return[t,e-s*(o/a),i*(a/o),s*(o/a)];case 5:return[1-e,t,s*(o/a),i*(a/o)];case 6:return[1-t-i*(a/o),1-e,i*(a/o),s*(o/a)];case 7:return[e-s*(o/a),1-t-i*(a/o),s*(o/a),i*(a/o)];case 8:return[t-s,e-i,s,i];case 9:return[1-e,t-s,i,s];case 10:return[1-t,1-e,s,i];case 11:return[e-i,1-t,i,s];case 12:return[t-i*(a/o),e,i*(a/o),s*(o/a)];case 13:return[1-e-s*(o/a),t-i*(a/o),s*(o/a),i*(a/o)];case 14:return[1-t,1-e-s*(o/a),i*(a/o),s*(o/a)];case 15:return[e,1-t,s*(o/a),i*(a/o)];default:return[t,e,s,i]}}rotate(){if(!this.parent){return}this.parent.drawLayer.updateProperties(this._drawId,Zn._mergeSVGProperties({bbox:this.#Za()},this.#Wa.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){if(!this.parent){return}this.#Ka(this.#Wa.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div){return this.div}let t,e;if(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";this.setDims();this._uiManager.addShouldRescale(this);this.disableEditing();if(this._isCopy){this._moveAfterPaste(t,e)}return s}static createDrawerInstance(t,e,s,i,n){st("Not implemented")}static startDrawing(t,e,s,i){const{target:n,offsetX:r,offsetY:o,pointerId:a,pointerType:h}=i;if(be.isInitializedAndDifferentPointerType(h)){return}const{viewport:{rotation:c}}=t;const{width:l,height:u}=n.getBoundingClientRect();const f=Zn.#Xa=new AbortController;const d=t.combinedSignal(f);be.setPointer(h,a);window.addEventListener("pointerup",(t=>{if(be.isSamePointerIdOrRemove(t.pointerId)){this._endDraw(t)}}),{signal:d});window.addEventListener("pointercancel",(t=>{if(be.isSamePointerIdOrRemove(t.pointerId)){this._currentParent.endDrawingSession()}}),{signal:d});window.addEventListener("pointerdown",(t=>{if(!be.isSamePointerType(t.pointerType)){return}be.initializeAndAddPointerId(t.pointerId);if(Zn.#Va.isCancellable()){Zn.#Va.removeLastElement();if(Zn.#Va.isEmpty()){this._currentParent.endDrawingSession(true)}else{this._endDraw(null)}}}),{capture:true,passive:false,signal:d});window.addEventListener("contextmenu",Vt,{signal:d});n.addEventListener("pointermove",this._drawMove.bind(this),{signal:d});n.addEventListener("touchmove",(t=>{if(be.isSameTimeStamp(t.timeStamp)){Xt(t)}}),{signal:d});t.toggleDrawing();e._editorUndoBar?.hide();if(Zn.#Va){t.drawLayer.updateProperties(this._currentDrawId,Zn.#Va.startNew(r,o,l,u,c));return}e.updateUIForDefaultProperties(this);Zn.#Va=this.createDrawerInstance(r,o,l,u,c);Zn.#qa=this.getDefaultDrawingOptions();this._currentParent=t;({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(Zn.#qa.toSVGProperties(),Zn.#Va.defaultSVGProperties),true,false))}static _drawMove(t){if(!Zn.#Va){return}const{offsetX:e,offsetY:s,pointerId:i}=t;if(!be.isSamePointerId(i)){return}if(be.isUsingMultiplePointers()){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,Zn.#Va.add(e,s));be.setTimeStamp(t.timeStamp);Xt(t)}static _cleanup(t){if(t){this._currentDrawId=-1;this._currentParent=null;Zn.#Va=null;Zn.#qa=null;be.clearPointerType();be.clearTimeStamp()}if(Zn.#Xa){Zn.#Xa.abort();Zn.#Xa=null;be.clearPointerIds()}}static _endDraw(t){const e=this._currentParent;if(!e){return}e.toggleDrawing(true);this._cleanup(false);if(t?.target===e.div){e.drawLayer.updateProperties(this._currentDrawId,Zn.#Va.end(t.offsetX,t.offsetY))}if(this.supportMultipleDrawings){const t=Zn.#Va;const s=this._currentDrawId;const i=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(s,t.setLastElement(i))},undo:()=>{e.drawLayer.updateProperties(s,t.removeLastElement())},mustExec:false,type:U.DRAW_STEP});return}this.endDrawing(false)}static endDrawing(t){const e=this._currentParent;if(!e){return null}e.toggleDrawing(true);e.cleanUndoStack(U.DRAW_STEP);if(!Zn.#Va.isEmpty()){const{pageDimensions:[s,i],scale:n}=e;const r=e.createAndAddNewEditor({offsetX:0,offsetY:0},false,{drawId:this._currentDrawId,drawOutlines:Zn.#Va.getOutlines(s*n,i*n,n,this._INNER_MARGIN),drawingOptions:Zn.#qa,mustBeCommitted:!t});this._cleanup(true);return r}e.drawLayer.remove(this._currentDrawId);this._cleanup(true);return null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,n,r){st("Not implemented")}static async deserialize(t,e,s){const{rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:o}}=e.viewport;const a=this.deserializeDraw(r,o,i,n,this._INNER_MARGIN,t);const h=await super.deserialize(t,e,s);h.createDrawingOptions(t);h.#Ya({drawOutlines:a});h.#Na();h.onScaleChanging();h.rotate();return h}serializeDraw(t){const[e,s]=this.pageTranslation;const[i,n]=this.pageDimensions;return this.#Wa.serialize([e,s,i,n],t)}renderAnnotationElement(t){t.updateEdited({rect:this.getPDFRect()});return null}static canCreateNewEmptyEditor(){return false}}class tr{#Uo=new Float64Array(6);#ao;#eh;#gn;#Vo;#Xo;#sh="";#ih=0;#ma=new er;#nh;#rh;constructor(t,e,s,i,n,r){this.#nh=s;this.#rh=i;this.#gn=n;this.#Vo=r;[t,e]=this.#oh(t,e);const o=this.#ao=[NaN,NaN,NaN,NaN,t,e];this.#Xo=[t,e];this.#eh=[{line:o,points:this.#Xo}];this.#Uo.set(o,0)}updateProperty(t,e){if(t==="stroke-width"){this.#Vo=e}}#oh(t,e){return Wn._normalizePoint(t,e,this.#nh,this.#rh,this.#gn)}isEmpty(){return!this.#eh||this.#eh.length===0}isCancellable(){return this.#Xo.length<=10}add(t,e){[t,e]=this.#oh(t,e);const[s,i,n,r]=this.#Uo.subarray(2,6);const o=t-n;const a=e-r;const h=Math.hypot(this.#nh*o,this.#rh*a);if(h<=2){return null}this.#Xo.push(t,e);if(isNaN(s)){this.#Uo.set([n,r,t,e],2);this.#ao.push(NaN,NaN,NaN,NaN,t,e);return{path:{d:this.toSVGPath()}}}if(isNaN(this.#Uo[0])){this.#ao.splice(6,6)}this.#Uo.set([s,i,n,r,t,e],0);this.#ao.push(...Wn.createBezierPoints(s,i,n,r,t,e));return{path:{d:this.toSVGPath()}}}end(t,e){const s=this.add(t,e);if(s){return s}if(this.#Xo.length===2){return{path:{d:this.toSVGPath()}}}return null}startNew(t,e,s,i,n){this.#nh=s;this.#rh=i;this.#gn=n;[t,e]=this.#oh(t,e);const r=this.#ao=[NaN,NaN,NaN,NaN,t,e];this.#Xo=[t,e];const o=this.#eh.at(-1);if(o){o.line=new Float32Array(o.line);o.points=new Float32Array(o.points)}this.#eh.push({line:r,points:this.#Xo});this.#Uo.set(r,0);this.#ih=0;this.toSVGPath();return null}getLastElement(){return this.#eh.at(-1)}setLastElement(t){if(!this.#eh){return this.#ma.setLastElement(t)}this.#eh.push(t);this.#ao=t.line;this.#Xo=t.points;this.#ih=0;return{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#eh){return this.#ma.removeLastElement()}this.#eh.pop();this.#sh="";for(let t=0,e=this.#eh.length;t<e;t++){const{line:e,points:s}=this.#eh[t];this.#ao=e;this.#Xo=s;this.#ih=0;this.toSVGPath()}return{path:{d:this.#sh}}}toSVGPath(){const t=Wn.svgRound(this.#ao[4]);const e=Wn.svgRound(this.#ao[5]);if(this.#Xo.length===2){this.#sh=`${this.#sh} M ${t} ${e} Z`;return this.#sh}if(this.#Xo.length<=6){const s=this.#sh.lastIndexOf("M");this.#sh=`${this.#sh.slice(0,s)} M ${t} ${e}`;this.#ih=6}if(this.#Xo.length===4){const t=Wn.svgRound(this.#ao[10]);const e=Wn.svgRound(this.#ao[11]);this.#sh=`${this.#sh} L ${t} ${e}`;this.#ih=12;return this.#sh}const s=[];if(this.#ih===0){s.push(`M ${t} ${e}`);this.#ih=6}for(let t=this.#ih,e=this.#ao.length;t<e;t+=6){const[e,i,n,r,o,a]=this.#ao.slice(t,t+6).map(Wn.svgRound);s.push(`C${e} ${i} ${n} ${r} ${o} ${a}`)}this.#sh+=s.join(" ");this.#ih=this.#ao.length;return this.#sh}getOutlines(t,e,s,i){const n=this.#eh.at(-1);n.line=new Float32Array(n.line);n.points=new Float32Array(n.points);this.#ma.build(this.#eh,t,e,s,this.#gn,this.#Vo,i);this.#Uo=null;this.#ao=null;this.#eh=null;this.#sh=null;return this.#ma}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:true},bbox:[0,0,1,1]}}}class er extends Wn{#na;#ah=0;#_o;#eh;#nh;#rh;#hh;#gn;#Vo;build(t,e,s,i,n,r,o){this.#nh=e;this.#rh=s;this.#hh=i;this.#gn=n;this.#Vo=r;this.#_o=o??0;this.#eh=t;this.#ch()}get thickness(){return this.#Vo}setLastElement(t){this.#eh.push(t);return{path:{d:this.toSVGPath()}}}removeLastElement(){this.#eh.pop();return{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#eh){t.push(`M${Wn.svgRound(e[4])} ${Wn.svgRound(e[5])}`);if(e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${Wn.svgRound(e[10])} ${Wn.svgRound(e[11])}`);continue}for(let s=6,i=e.length;s<i;s+=6){const[i,n,r,o,a,h]=e.subarray(s,s+6).map(Wn.svgRound);t.push(`C${i} ${n} ${r} ${o} ${a} ${h}`)}}return t.join("")}serialize([t,e,s,i],n){const r=[];const o=[];const[a,h,c,l]=this.#lh();let u,f,d,p,g,m,w,b,A;switch(this.#gn){case 0:A=Wn._rescale;u=t;f=e+i;d=s;p=-i;g=t+a*s;m=e+(1-h-l)*i;w=t+(a+c)*s;b=e+(1-h)*i;break;case 90:A=Wn._rescaleAndSwap;u=t;f=e;d=s;p=i;g=t+h*s;m=e+a*i;w=t+(h+l)*s;b=e+(a+c)*i;break;case 180:A=Wn._rescale;u=t+s;f=e;d=-s;p=i;g=t+(1-a-c)*s;m=e+h*i;w=t+(1-a)*s;b=e+(h+l)*i;break;case 270:A=Wn._rescaleAndSwap;u=t+s;f=e+i;d=-s;p=-i;g=t+(1-h-l)*s;m=e+(1-a-c)*i;w=t+(1-h)*s;b=e+(1-a)*i;break}for(const{line:t,points:e}of this.#eh){r.push(A(t,u,f,d,p,n?new Array(t.length):null));o.push(A(e,u,f,d,p,n?new Array(e.length):null))}return{lines:r,points:o,rect:[g,m,w,b]}}static deserialize(t,e,s,i,n,{paths:{lines:r,points:o},rotation:a,thickness:h}){const c=[];let l,u,f,d,p;switch(a){case 0:p=Wn._rescale;l=-t/s;u=e/i+1;f=1/s;d=-1/i;break;case 90:p=Wn._rescaleAndSwap;l=-e/i;u=-t/s;f=1/i;d=1/s;break;case 180:p=Wn._rescale;l=t/s+1;u=-e/i;f=-1/s;d=1/i;break;case 270:p=Wn._rescaleAndSwap;l=e/i+1;u=t/s+1;f=-1/i;d=-1/s;break}if(!r){r=[];for(const t of o){const e=t.length;if(e===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(e===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const s=new Float32Array(3*(e-2));r.push(s);let[i,n,o,a]=t.subarray(0,4);s.set([NaN,NaN,NaN,NaN,i,n],0);for(let r=4;r<e;r+=2){const e=t[r];const h=t[r+1];s.set(Wn.createBezierPoints(i,n,o,a,e,h),(r-2)*3);[i,n,o,a]=[o,a,e,h]}}}for(let t=0,e=r.length;t<e;t++){c.push({line:p(r[t].map((t=>t??NaN)),l,u,f,d),points:p(o[t].map((t=>t??NaN)),l,u,f,d)})}const g=new this.prototype.constructor;g.build(c,s,i,1,a,h,n);return g}#uh(t=this.#Vo){const e=this.#_o+t/2*this.#hh;return this.#gn%180===0?[e/this.#nh,e/this.#rh]:[e/this.#rh,e/this.#nh]}#lh(){const[t,e,s,i]=this.#na;const[n,r]=this.#uh(0);return[t+n,e+r,s-2*n,i-2*r]}#ch(){const t=this.#na=new Float32Array([Infinity,Infinity,-Infinity,-Infinity]);for(const{line:e}of this.#eh){if(e.length<=12){for(let s=4,i=e.length;s<i;s+=6){xt.pointBoundingBox(e[s],e[s+1],t)}continue}let s=e[4],i=e[5];for(let n=6,r=e.length;n<r;n+=6){const[r,o,a,h,c,l]=e.subarray(n,n+6);xt.bezierBoundingBox(s,i,r,o,a,h,c,l,t);s=c;i=l}}const[e,s]=this.#uh();t[0]=Nt(t[0]-e,0,1);t[1]=Nt(t[1]-s,0,1);t[2]=Nt(t[2]+e,0,1);t[3]=Nt(t[3]+s,0,1);t[2]-=t[0];t[3]-=t[1]}get box(){return this.#na}updateProperty(t,e){if(t==="stroke-width"){return this.#Ra(e)}return null}#Ra(t){const[e,s]=this.#uh();this.#Vo=t;const[i,n]=this.#uh();const[r,o]=[i-e,n-s];const a=this.#na;a[0]-=r;a[1]-=o;a[2]+=2*r;a[3]+=2*o;return a}updateParentDimensions([t,e],s){const[i,n]=this.#uh();this.#nh=t;this.#rh=e;this.#hh=s;const[r,o]=this.#uh();const a=r-i;const h=o-n;const c=this.#na;c[0]-=a;c[1]-=h;c[2]+=2*a;c[3]+=2*h;return c}updateRotation(t){this.#ah=t;return{path:{transform:this.rotationTransform}}}get viewBox(){return this.#na.map(Wn.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#na;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Wn.svgRound(t)} ${Wn.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#na;let s=0,i=0,n=0,r=0,o=0,a=0;switch(this.#ah){case 90:i=e/t;n=-t/e;o=t;break;case 180:s=-1;r=-1;o=t;a=e;break;case 270:i=-e/t;n=t/e;a=e;break;default:return""}return`matrix(${s} ${i} ${n} ${r} ${Wn.svgRound(o)} ${Wn.svgRound(a)})`}getPathResizingSVGProperties([t,e,s,i]){const[n,r]=this.#uh();const[o,a,h,c]=this.#na;if(Math.abs(h-n)<=Wn.PRECISION||Math.abs(c-r)<=Wn.PRECISION){const n=t+s/2-(o+h/2);const r=e+i/2-(a+c/2);return{path:{"transform-origin":`${Wn.svgRound(t)} ${Wn.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const l=(s-2*n)/(h-2*n);const u=(i-2*r)/(c-2*r);const f=h/s;const d=c/i;return{path:{"transform-origin":`${Wn.svgRound(o)} ${Wn.svgRound(a)}`,transform:`${this.rotationTransform} scale(${f} ${d}) `+`translate(${Wn.svgRound(n)} ${Wn.svgRound(r)}) scale(${l} ${u}) `+`translate(${Wn.svgRound(-n)} ${Wn.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,s,i]){const[n,r]=this.#uh();const o=this.#na;const[a,h,c,l]=o;o[0]=t;o[1]=e;o[2]=s;o[3]=i;if(Math.abs(c-n)<=Wn.PRECISION||Math.abs(l-r)<=Wn.PRECISION){const n=t+s/2-(a+c/2);const r=e+i/2-(h+l/2);for(const{line:t,points:e}of this.#eh){Wn._translate(t,n,r,t);Wn._translate(e,n,r,e)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Wn.svgRound(t)} ${Wn.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(s-2*n)/(c-2*n);const f=(i-2*r)/(l-2*r);const d=-u*(a+n)+t+n;const p=-f*(h+r)+e+r;if(u!==1||f!==1||d!==0||p!==0){for(const{line:t,points:e}of this.#eh){Wn._rescale(t,d,p,u,f,t);Wn._rescale(e,d,p,u,f,e)}}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Wn.svgRound(t)} ${Wn.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){const[i,n]=s;const r=this.#na;const o=t-r[0];const a=e-r[1];if(this.#nh===i&&this.#rh===n){for(const{line:t,points:e}of this.#eh){Wn._translate(t,o,a,t);Wn._translate(e,o,a,e)}}else{const t=this.#nh/i;const e=this.#rh/n;this.#nh=i;this.#rh=n;for(const{line:s,points:i}of this.#eh){Wn._rescale(s,o,a,t,e,s);Wn._rescale(i,o,a,t,e,i)}r[2]*=t;r[3]*=e}r[0]=t;r[1]=e;return{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Wn.svgRound(t)} ${Wn.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#na;return{root:{viewBox:this.viewBox},rootClass:{draw:true},path:{d:this.toSVGPath(),"transform-origin":`${Wn.svgRound(t[0])} ${Wn.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class sr extends Qn{constructor(t){super();this._viewParameters=t;super.updateProperties({fill:"none",stroke:Ee._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){if(t==="stroke-width"){e??=this["stroke-width"];e*=this._viewParameters.realScale}super.updateSVGProperty(t,e)}clone(){const t=new sr(this._viewParameters);t.updateAll(this);return t}}class ir extends Zn{static _type="ink";static _editorType=L.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"});this._willKeepAspectRatio=true;this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){Ee.initialize(t,e);this._defaultDrawingOptions=new sr(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();e.updateProperties(t);return e}static get supportMultipleDrawings(){return true}static get typesMap(){return at(this,"typesMap",new Map([[U.INK_THICKNESS,"stroke-width"],[U.INK_COLOR,"stroke"],[U.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,i,n){return new tr(t,e,s,i,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,n,r){return er.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=null;if(t instanceof Fn){const{data:{inkLists:e,rect:s,rotation:n,id:r,color:o,opacity:a,borderStyle:{rawWidth:h},popupRef:c,richText:l,contentsObj:u,creationDate:f,modificationDate:d},parent:{page:{pageNumber:p}}}=t;i=t={annotationType:L.INK,color:Array.from(o),thickness:h,opacity:a,paths:{points:e},boxes:null,pageIndex:p-1,rect:s.slice(0),rotation:n,annotationElementId:r,id:r,deleted:false,popupRef:c,richText:l,comment:u?.str||null,creationDate:f,modificationDate:d}}const n=await super.deserialize(t,e,s);n._initialData=i;if(t.comment){n.setCommentData(t)}return n}get toolbarButtons(){this._colorPicker||=new nn(this);return[["colorPicker",this._colorPicker]]}get colorType(){return U.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}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;if(!t){return}super.onScaleChangingWhenDrawing();this._defaultDrawingOptions.updateSVGProperty("stroke-width");t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=ir.getDefaultDrawingOptions({stroke:xt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=false){if(this.isEmpty()){return null}if(this.deleted){return this.serializeDeleted()}const{lines:e,points:s}=this.serializeDraw(t);const{_drawingOptions:{stroke:i,"stroke-opacity":n,"stroke-width":r}}=this;const o=Object.assign(super.serialize(t),{color:Ee._colorManager.convert(i),opacity:n,thickness:r,paths:{lines:e,points:s}});this.addComment(o);if(t){o.isCopy=true;return o}if(this.annotationElementId&&!this.#Fo(o)){return null}o.id=this.annotationElementId;return o}#Fo(t){const{color:e,thickness:s,opacity:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,s)=>t!==e[s]))||t.thickness!==s||t.opacity!==i||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted){t.hide();return null}const{points:e,rect:s}=this.serializeDraw(false);t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment});return null}}class nr extends er{toSVGPath(){let t=super.toSVGPath();if(!t.endsWith("Z")){t+="Z"}return t}}const rr=8;const or=3;class ar{static#fh={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#dh(t,e,s,i){s-=t;i-=e;if(s===0){return i>0?0:4}if(s===1){return i+6}return 2-i}static#ph=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#gh(t,e,s,i,n,r,o){const a=this.#dh(s,i,n,r);for(let n=0;n<8;n++){const r=(-n+a-o+16)%8;const h=this.#ph[2*r];const c=this.#ph[2*r+1];if(t[(s+h)*e+(i+c)]!==0){return r}}return-1}static#mh(t,e,s,i,n,r,o){const a=this.#dh(s,i,n,r);for(let n=0;n<8;n++){const r=(n+a+o+16)%8;const h=this.#ph[2*r];const c=this.#ph[2*r+1];if(t[(s+h)*e+(i+c)]!==0){return r}}return-1}static#wh(t,e,s,i){const n=t.length;const r=new Int32Array(n);for(let e=0;e<n;e++){r[e]=t[e]<=i?1:0}for(let t=1;t<s-1;t++){r[t*e]=r[t*e+e-1]=0}for(let t=0;t<e;t++){r[t]=r[e*s-1-t]=0}let o=1;let a;const h=[];for(let t=1;t<s-1;t++){a=1;for(let s=1;s<e-1;s++){const i=t*e+s;const n=r[i];if(n===0){continue}let c=t;let l=s;if(n===1&&r[i-1]===0){o+=1;l-=1}else if(n>=1&&r[i+1]===0){o+=1;l+=1;if(n>1){a=n}}else{if(n!==1){a=Math.abs(n)}continue}const u=[s,t];const f=l===s+1;const d={isHole:f,points:u,id:o,parent:0};h.push(d);let p;for(const t of h){if(t.id===a){p=t;break}}if(!p){d.parent=f?a:0}else if(p.isHole){d.parent=f?p.parent:a}else{d.parent=f?a:p.parent}const g=this.#gh(r,e,t,s,c,l,0);if(g===-1){r[i]=-o;if(r[i]!==1){a=Math.abs(r[i])}continue}let m=this.#ph[2*g];let w=this.#ph[2*g+1];const b=t+m;const A=s+w;c=b;l=A;let y=t;let v=s;while(true){const n=this.#mh(r,e,y,v,c,l,1);m=this.#ph[2*n];w=this.#ph[2*n+1];const h=y+m;const f=v+w;u.push(f,h);const d=y*e+v;if(r[d+1]===0){r[d]=-o}else if(r[d]===1){r[d]=o}if(h===t&&f===s&&y===b&&v===A){if(r[i]!==1){a=Math.abs(r[i])}break}else{c=y;l=v;y=h;v=f}}}}return h}static#bh(t,e,s,i){if(s-e<=4){for(let n=e;n<s-2;n+=2){i.push(t[n],t[n+1])}return}const n=t[e];const r=t[e+1];const o=t[s-4]-n;const a=t[s-3]-r;const h=Math.hypot(o,a);const c=o/h;const l=a/h;const u=c*r-l*n;const f=a/o;const d=1/h;const p=Math.atan(f);const g=Math.cos(p);const m=Math.sin(p);const w=d*(Math.abs(g)+Math.abs(m));const b=d*(1-w+w**2);const A=Math.max(Math.atan(Math.abs(m+g)*b),Math.atan(Math.abs(m-g)*b));let y=0;let v=e;for(let i=e+2;i<s-2;i+=2){const e=Math.abs(u-c*t[i+1]+l*t[i]);if(e>y){v=i;y=e}}if(y>(h*A)**2){this.#bh(t,e,v+2,i);this.#bh(t,v,s,i)}else{i.push(n,r)}}static#Ah(t){const e=[];const s=t.length;this.#bh(t,0,s,e);e.push(t[s-2],t[s-1]);return e.length<=4?null:e}static#yh(t,e,s,i,n,r){const o=new Float32Array(r**2);const a=-2*i**2;const h=r>>1;for(let t=0;t<r;t++){const e=(t-h)**2;for(let s=0;s<r;s++){o[t*r+s]=Math.exp((e+(s-h)**2)/a)}}const c=new Float32Array(256);const l=-2*n**2;for(let t=0;t<256;t++){c[t]=Math.exp(t**2/l)}const u=t.length;const f=new Uint8Array(u);const d=new Uint32Array(256);for(let i=0;i<s;i++){for(let n=0;n<e;n++){const a=i*e+n;const l=t[a];let u=0;let p=0;for(let a=0;a<r;a++){const f=i+a-h;if(f<0||f>=s){continue}for(let s=0;s<r;s++){const i=n+s-h;if(i<0||i>=e){continue}const d=t[f*e+i];const g=o[a*r+s]*c[Math.abs(d-l)];u+=d*g;p+=g}}const g=f[a]=Math.round(u/p);d[g]++}}return[f,d]}static#vh(t){const e=new Uint32Array(256);for(const s of t){e[s]++}return e}static#xh(t){const e=t.length;const s=new Uint8ClampedArray(e>>2);let i=-Infinity;let n=Infinity;for(let e=0,r=s.length;e<r;e++){const r=s[e]=t[e<<2];i=Math.max(i,r);n=Math.min(n,r)}const r=255/(i-n);for(let t=0,e=s.length;t<e;t++){s[t]=(s[t]-n)*r}return s}static#kh(t){let e;let s=-Infinity;let i=-Infinity;const n=t.findIndex((t=>t!==0));let r=n;let o=n;for(e=n;e<256;e++){const n=t[e];if(n>s){if(e-r>i){i=e-r;o=e-1}s=n;r=e}}for(e=o-1;e>=0;e--){if(t[e]>t[e+1]){break}}return e}static#Sh(t){const e=t;const{width:s,height:i}=t;const{maxDim:n}=this.#fh;let r=s;let o=i;if(s>n||i>n){let a=s;let h=i;let c=Math.log2(Math.max(s,i)/n);const l=Math.floor(c);c=c===l?l-1:l;for(let s=0;s<c;s++){r=Math.ceil(a/2);o=Math.ceil(h/2);const s=new OffscreenCanvas(r,o);const i=s.getContext("2d");i.drawImage(t,0,0,a,h,0,0,r,o);a=r;h=o;if(t!==e){t.close()}t=s.transferToImageBitmap()}const u=Math.min(n/r,n/o);r=Math.round(r*u);o=Math.round(o*u)}const a=new OffscreenCanvas(r,o);const h=a.getContext("2d",{willReadFrequently:true});h.fillStyle="white";h.fillRect(0,0,r,o);h.filter="grayscale(1)";h.drawImage(t,0,0,t.width,t.height,0,0,r,o);const c=h.getImageData(0,0,r,o).data;const l=this.#xh(c);return[l,r,o]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},n,r,o,a){let h=new OffscreenCanvas(1,1);let c=h.getContext("2d",{alpha:false});const l=200;const u=c.font=`${s} ${i} ${l}px ${e}`;const{actualBoundingBoxLeft:f,actualBoundingBoxRight:d,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:w,width:b}=c.measureText(t);const A=1.5;const y=Math.ceil(Math.max(Math.abs(f)+Math.abs(d)||0,b)*A);const v=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||l,Math.abs(m)+Math.abs(w)||l)*A);h=new OffscreenCanvas(y,v);c=h.getContext("2d",{alpha:true,willReadFrequently:true});c.font=u;c.filter="grayscale(1)";c.fillStyle="white";c.fillRect(0,0,y,v);c.fillStyle="black";c.fillText(t,y*(A-1)/2,v*(3-A)/2);const x=this.#xh(c.getImageData(0,0,y,v).data);const k=this.#vh(x);const S=this.#kh(k);const M=this.#wh(x,y,v,S);return this.processDrawnLines({lines:{curves:M,width:y,height:v},pageWidth:n,pageHeight:r,rotation:o,innerMargin:a,mustSmooth:true,areContours:true})}static process(t,e,s,i,n){const[r,o,a]=this.#Sh(t);const[h,c]=this.#yh(r,o,a,Math.hypot(o,a)*this.#fh.sigmaSFactor,this.#fh.sigmaR,this.#fh.kernelSize);const l=this.#kh(c);const u=this.#wh(h,o,a,l);return this.processDrawnLines({lines:{curves:u,width:o,height:a},pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:true,areContours:true})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:r,areContours:o}){if(i%180!==0){[e,s]=[s,e]}const{curves:a,width:h,height:c}=t;const l=t.thickness??0;const u=[];const f=Math.min(e/h,s/c);const d=f/e;const p=f/s;const g=[];for(const{points:t}of a){const e=r?this.#Ah(t):t;if(!e){continue}g.push(e);const s=e.length;const i=new Float32Array(s);const n=new Float32Array(3*(s===2?2:s-2));u.push({line:n,points:i});if(s===2){i[0]=e[0]*d;i[1]=e[1]*p;n.set([NaN,NaN,NaN,NaN,i[0],i[1]],0);continue}let[o,a,h,c]=e;o*=d;a*=p;h*=d;c*=p;i.set([o,a,h,c],0);n.set([NaN,NaN,NaN,NaN,o,a],0);for(let t=4;t<s;t+=2){const s=i[t]=e[t]*d;const r=i[t+1]=e[t+1]*p;n.set(Wn.createBezierPoints(o,a,h,c,s,r),(t-2)*3);[o,a,h,c]=[h,c,s,r]}}if(u.length===0){return null}const m=o?new nr:new er;m.build(u,e,s,1,i,o?0:l,n);return{outline:m,newCurves:g,areContours:o,thickness:l,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:n}){let r=Infinity;let o=-Infinity;let a=0;for(const e of t){a+=e.length;for(let t=2,s=e.length;t<s;t++){const s=e[t]-e[t-2];r=Math.min(r,s);o=Math.max(o,s)}}let h;if(r>=-128&&o<=127){h=Int8Array}else if(r>=-32768&&o<=32767){h=Int16Array}else{h=Int32Array}const c=t.length;const l=rr+or*c;const u=new Uint32Array(l);let f=0;u[f++]=l*Uint32Array.BYTES_PER_ELEMENT+(a-2*c)*h.BYTES_PER_ELEMENT;u[f++]=0;u[f++]=i;u[f++]=n;u[f++]=e?0:1;u[f++]=Math.max(0,Math.floor(s??0));u[f++]=c;u[f++]=h.BYTES_PER_ELEMENT;for(const e of t){u[f++]=e.length-2;u[f++]=e[0];u[f++]=e[1]}const d=new CompressionStream("deflate-raw");const p=d.writable.getWriter();await p.ready;p.write(u);const g=h.prototype.constructor;for(const e of t){const t=new g(e.length-2);for(let s=2,i=e.length;s<i;s++){t[s-2]=e[s]-e[s-2]}p.write(t)}p.close();const m=await new Response(d.readable).arrayBuffer();const w=new Uint8Array(m);return Dt(w)}static async decompressSignature(t){try{const e=It(t);const{readable:s,writable:i}=new DecompressionStream("deflate-raw");const n=i.getWriter();await n.ready;n.write(e).then((async()=>{await n.ready;await n.close()})).catch((()=>{}));let r=null;let o=0;for await(const t of s){r||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]);r.set(t,o);o+=t.length}const a=new Uint32Array(r.buffer,0,r.length>>2);const h=a[1];if(h!==0){throw new Error(`Invalid version: ${h}`)}const c=a[2];const l=a[3];const u=a[4]===0;const f=a[5];const d=a[6];const p=a[7];const g=[];const m=(rr+or*d)*Uint32Array.BYTES_PER_ELEMENT;let w;switch(p){case Int8Array.BYTES_PER_ELEMENT:w=new Int8Array(r.buffer,m);break;case Int16Array.BYTES_PER_ELEMENT:w=new Int16Array(r.buffer,m);break;case Int32Array.BYTES_PER_ELEMENT:w=new Int32Array(r.buffer,m);break}o=0;for(let t=0;t<d;t++){const e=a[or*t+rr];const s=new Float32Array(e+2);g.push(s);for(let e=0;e<or-1;e++){s[e]=a[or*t+rr+e+1]}for(let t=0;t<e;t++){s[t+2]=s[t]+w[o++]}}return{areContours:u,thickness:f,outlines:g,width:c,height:l}}catch(t){et(`decompressSignature: ${t}`);return null}}}class hr extends Qn{constructor(){super();super.updateProperties({fill:Ee._defaultLineColor,"stroke-width":0})}clone(){const t=new hr;t.updateAll(this);return t}}class cr extends sr{constructor(t){super(t);super.updateProperties({stroke:Ee._defaultLineColor,"stroke-width":1})}clone(){const t=new cr(this._viewParameters);t.updateAll(this);return t}}class lr extends Zn{#Mh=false;#Ch=null;#Th=null;#Eh=null;static _type="signature";static _editorType=L.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:true,name:"signatureEditor"});this._willKeepAspectRatio=true;this.#Th=t.signatureData||null;this.#Ch=null;this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){Ee.initialize(t,e);this._defaultDrawingOptions=new hr;this._defaultDrawnSignatureOptions=new cr(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();e.updateProperties(t);return e}static get supportMultipleDrawings(){return false}static get typesMap(){return at(this,"typesMap",new Map)}static get isDrawer(){return false}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#Ch}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(true)??0,hasNoAltText:e.get(false)??0}}get isResizable(){return true}onScaleChanging(){if(this._drawId===null){return}super.onScaleChanging()}render(){if(this.div){return this.div}let t,e;const{_isCopy:s}=this;if(s){this._isCopy=false;t=this.x;e=this.y}super.render();if(this._drawId===null){if(this.#Th){const{lines:t,mustSmooth:e,areContours:s,description:i,uuid:n,heightInPage:r}=this.#Th;const{rawDims:{pageWidth:o,pageHeight:a},rotation:h}=this.parent.viewport;const c=ar.processDrawnLines({lines:t,pageWidth:o,pageHeight:a,rotation:h,innerMargin:lr._INNER_MARGIN,mustSmooth:e,areContours:s});this.addSignature(c,r,i,n)}else{this.div.setAttribute("data-l10n-args",JSON.stringify({description:""}));this.div.hidden=true;this._uiManager.getSignature(this)}}else{this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#Ch||""}))}if(s){this._isCopy=true;this._moveAfterPaste(t,e)}return this.div}setUuid(t){this.#Eh=t;this.addEditToolbar()}getUuid(){return this.#Eh}get description(){return this.#Ch}set description(t){this.#Ch=t;if(!this.div){return}this.div.setAttribute("data-l10n-args",JSON.stringify({description:t}));super.addEditToolbar().then((e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:s,width:i,height:n}=this.#Th;const r=Math.max(i,n);const o=ar.processDrawnLines({lines:{curves:t.map((t=>({points:t}))),thickness:s,width:i,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:false,areContours:e});return{areContours:e,outline:o.outline}}get toolbarButtons(){if(this._uiManager.signatureManager){return[["editSignature",this._uiManager.signatureManager]]}return super.toolbarButtons}addSignature(t,e,s,i){const{x:n,y:r}=this;const{outline:o}=this.#Th=t;this.#Mh=o instanceof nr;this.description=s;let a;if(this.#Mh){a=lr.getDefaultDrawingOptions()}else{a=lr._defaultDrawnSignatureOptions.clone();a.updateProperties({"stroke-width":o.thickness})}this._addOutlines({drawOutlines:o,drawingOptions:a});const[,h]=this.pageDimensions;let c=e/h;c=c>=1?.5:c;this.width*=c/this.height;if(this.width>=1){c*=.9/this.width;this.width=.9}this.height=c;this.setDims();this.x=n;this.y=r;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=false}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return ar.process(t,e,s,i,lr._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return ar.extractContoursFromText(t,e,s,i,n,lr._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return ar.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:lr._INNER_MARGIN,mustSmooth:false,areContours:false})}createDrawingOptions({areContours:t,thickness:e}){if(t){this._drawingOptions=lr.getDefaultDrawingOptions()}else{this._drawingOptions=lr._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":e})}}serialize(t=false){if(this.isEmpty()){return null}const{lines:e,points:s}=this.serializeDraw(t);const{_drawingOptions:{"stroke-width":i}}=this;const n=Object.assign(super.serialize(t),{isSignature:true,areContours:this.#Mh,color:[0,0,0],thickness:this.#Mh?0:i});this.addComment(n);if(t){n.paths={lines:e,points:s};n.uuid=this.#Eh;n.isCopy=true}else{n.lines=e}if(this.#Ch){n.accessibilityData={type:"Figure",alt:this.#Ch}}return n}static deserializeDraw(t,e,s,i,n,r){if(r.areContours){return nr.deserialize(t,e,s,i,n,r)}return er.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){const i=await super.deserialize(t,e,s);i.#Mh=t.areContours;i.description=t.accessibilityData?.alt||"";i.#Eh=t.uuid;return i}}class ur extends Ee{#Ph=null;#Nh=null;#Dh=null;#Ih=null;#Rh=null;#Fh="";#Oh=null;#$h=false;#_h=null;#Bh=false;#Lh=false;static _type="stamp";static _editorType=L.STAMP;constructor(t){super({...t,name:"stampEditor"});this.#Ih=t.bitmapUrl;this.#Rh=t.bitmapFile;this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){Ee.initialize(t,e)}static isHandlingMimeForPasting(t){return ie.includes(t)}static paste(t,e){e.pasteEditor({mode:L.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){if(this._uiManager.useNewAltTextFlow){this.div.hidden=false}super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(true)??0,hasNoAltText:e.get(false)??0}}#Uh(t,e=false){if(!t){this.remove();return}this.#Ph=t.bitmap;if(!e){this.#Nh=t.id;this.#Bh=t.isSvg}if(t.file){this.#Fh=t.file.name}this.#jh()}#zh(){this.#Dh=null;this._uiManager.enableWaiting(false);if(!this.#Oh){return}if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ph){this.addEditToolbar().then((()=>{this._editToolbar.hide();this._uiManager.editAltText(this,true)}));return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ph){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:false,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}async mlGuessAltText(t=null,e=true){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:n,height:r}=t||this.copyCanvas(null,null,true).imageData;const o=await s.guess({name:"altText",request:{data:i,width:n,height:r,channels:i.length/(n*r)}});if(!o){throw new Error("No response from the AI service.")}if(o.error){throw new Error("Error from the AI service.")}if(o.cancel){return null}if(!o.output){throw new Error("No valid response from the AI service.")}const a=o.output;await this.setGuessedAltText(a);if(e&&!this.hasAltTextData()){this.altTextData={alt:a,decorative:false}}return a}#Hh(){if(this.#Nh){this._uiManager.enableWaiting(true);this._uiManager.imageManager.getFromId(this.#Nh).then((t=>this.#Uh(t,true))).finally((()=>this.#zh()));return}if(this.#Ih){const t=this.#Ih;this.#Ih=null;this._uiManager.enableWaiting(true);this.#Dh=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Uh(t))).finally((()=>this.#zh()));return}if(this.#Rh){const t=this.#Rh;this.#Rh=null;this._uiManager.enableWaiting(true);this.#Dh=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Uh(t))).finally((()=>this.#zh()));return}const t=document.createElement("input");t.type="file";t.accept=ie.join(",");const e=this._uiManager._signal;this.#Dh=new Promise((s=>{t.addEventListener("change",(async()=>{if(!t.files||t.files.length===0){this.remove()}else{this._uiManager.enableWaiting(true);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});this.#Uh(e)}s()}),{signal:e});t.addEventListener("cancel",(()=>{this.remove();s()}),{signal:e})})).finally((()=>this.#zh()));t.click()}remove(){if(this.#Nh){this.#Ph=null;this._uiManager.imageManager.deleteId(this.#Nh);this.#Oh?.remove();this.#Oh=null;if(this.#_h){clearTimeout(this.#_h);this.#_h=null}}super.remove()}rebuild(){if(!this.parent){if(this.#Nh){this.#Hh()}return}super.rebuild();if(this.div===null){return}if(this.#Nh&&this.#Oh===null){this.#Hh()}if(!this.isAttachedToDOM){this.parent.add(this)}}onceAdded(t){this._isDraggable=true;if(t){this.div.focus()}}isEmpty(){return!(this.#Dh||this.#Ph||this.#Ih||this.#Rh||this.#Nh||this.#$h)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return true}render(){if(this.div){return this.div}let t,e;if(this._isCopy){t=this.x;e=this.y}super.render();this.div.hidden=true;this.createAltText();if(!this.#$h){if(this.#Ph){this.#jh()}else{this.#Hh()}}if(this._isCopy){this._moveAfterPaste(t,e)}this._uiManager.addShouldRescale(this);return this.div}setCanvas(t,e){const{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove();if(s&&this._uiManager.imageManager.isValidId(s)){this.#Nh=s;if(i){this.#Ph=i}this.#$h=false;this.#jh()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent){return}if(this.#_h!==null){clearTimeout(this.#_h)}const t=200;this.#_h=setTimeout((()=>{this.#_h=null;this.#Wh()}),t)}#jh(){const{div:t}=this;let{width:e,height:s}=this.#Ph;const[i,n]=this.pageDimensions;const r=.75;if(this.width){e=this.width*i;s=this.height*n}else if(e>r*i||s>r*n){const t=Math.min(r*i/e,r*n/s);e*=t;s*=t}this._uiManager.enableWaiting(false);const o=this.#Oh=document.createElement("canvas");o.setAttribute("role","img");this.addContainer(o);this.width=e/i;this.height=s/n;this.setDims();if(this._initialOptions?.isCentered){this.center()}else{this.fixAndSetPosition()}this._initialOptions=null;if(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId){t.hidden=false}this.#Wh();if(!this.#Lh){this.parent.addUndoableEditor(this);this.#Lh=true}this._reportTelemetry({action:"inserted_image"});if(this.#Fh){this.div.setAttribute("aria-description",this.#Fh)}if(!this.annotationElementId){this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}}copyCanvas(t,e,s=false){if(!t){t=224}const{width:i,height:n}=this.#Ph;const r=new se;let o=this.#Ph;let a=i,h=n;let c=null;if(e){if(i>e||n>e){const t=Math.min(e/i,e/n);a=Math.floor(i*t);h=Math.floor(n*t)}c=document.createElement("canvas");const t=c.width=Math.ceil(a*r.sx);const s=c.height=Math.ceil(h*r.sy);if(!this.#Bh){o=this.#Gh(t,s)}const l=c.getContext("2d");l.filter=this._uiManager.hcmFilter;let u="white",f="#cfcfd8";if(this._uiManager.hcmFilter!=="none"){f="black"}else if(ne.isDarkMode){u="#8f8f9d";f="#42414d"}const d=15;const p=d*r.sx;const g=d*r.sy;const m=new OffscreenCanvas(p*2,g*2);const w=m.getContext("2d");w.fillStyle=u;w.fillRect(0,0,p*2,g*2);w.fillStyle=f;w.fillRect(0,0,p,g);w.fillRect(p,g,p,g);l.fillStyle=l.createPattern(m,"repeat");l.fillRect(0,0,t,s);l.drawImage(o,0,0,o.width,o.height,0,0,t,s)}let l=null;if(s){let e,s;if(r.symmetric&&o.width<t&&o.height<t){e=o.width;s=o.height}else{o=this.#Ph;if(i>t||n>t){const r=Math.min(t/i,t/n);e=Math.floor(i*r);s=Math.floor(n*r);if(!this.#Bh){o=this.#Gh(e,s)}}}const a=new OffscreenCanvas(e,s);const h=a.getContext("2d",{willReadFrequently:true});h.drawImage(o,0,0,o.width,o.height,0,0,e,s);l={width:e,height:s,data:h.getImageData(0,0,e,s).data}}return{canvas:c,width:a,height:h,imageData:l}}#Gh(t,e){const{width:s,height:i}=this.#Ph;let n=s;let r=i;let o=this.#Ph;while(n>2*t||r>2*e){const s=n;const i=r;if(n>2*t){n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)}if(r>2*e){r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)}const a=new OffscreenCanvas(n,r);const h=a.getContext("2d");h.drawImage(o,0,0,s,i,0,0,n,r);o=a.transferToImageBitmap()}return o}#Wh(){const[t,e]=this.parentDimensions;const{width:s,height:i}=this;const n=new se;const r=Math.ceil(s*t*n.sx);const o=Math.ceil(i*e*n.sy);const a=this.#Oh;if(!a||a.width===r&&a.height===o){return}a.width=r;a.height=o;const h=this.#Bh?this.#Ph:this.#Gh(r,o);const c=a.getContext("2d");c.filter=this._uiManager.hcmFilter;c.drawImage(h,0,0,h.width,h.height,0,0,r,o)}#Vh(t){if(t){if(this.#Bh){const t=this._uiManager.imageManager.getSvgUrl(this.#Nh);if(t){return t}}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#Ph);const e=t.getContext("2d");e.drawImage(this.#Ph,0,0);return t.toDataURL()}if(this.#Bh){const[t,e]=this.pageDimensions;const s=Math.round(this.width*t*$t.PDF_TO_CSS_UNITS);const i=Math.round(this.height*e*$t.PDF_TO_CSS_UNITS);const n=new OffscreenCanvas(s,i);const r=n.getContext("2d");r.drawImage(this.#Ph,0,0,this.#Ph.width,this.#Ph.height,0,0,s,i);return n.transferToImageBitmap()}return structuredClone(this.#Ph)}static async deserialize(t,e,s){let i=null;let n=false;if(t instanceof Ln){const{data:{rect:r,rotation:o,id:a,structParent:h,popupRef:c,richText:l,contentsObj:u,creationDate:f,modificationDate:d},container:p,parent:{page:{pageNumber:g}},canvas:m}=t;let w,b;if(m){delete t.canvas;({id:w,bitmap:b}=s.imageManager.getFromCanvas(p.id,m));m.remove()}else{n=true;t._hasNoCanvas=true}const A=(await e._structTree.getAriaAttributes(`${Et}${a}`))?.get("aria-label")||"";i=t={annotationType:L.STAMP,bitmapId:w,bitmap:b,pageIndex:g-1,rect:r.slice(0),rotation:o,annotationElementId:a,id:a,deleted:false,accessibilityData:{decorative:false,altText:A},isSvg:false,structParent:h,popupRef:c,richText:l,comment:u?.str||null,creationDate:f,modificationDate:d}}const r=await super.deserialize(t,e,s);const{rect:o,bitmap:a,bitmapUrl:h,bitmapId:c,isSvg:l,accessibilityData:u}=t;if(n){s.addMissingCanvas(t.id,r);r.#$h=true}else if(c&&s.imageManager.isValidId(c)){r.#Nh=c;if(a){r.#Ph=a}}else{r.#Ih=h}r.#Bh=l;const[f,d]=r.pageDimensions;r.width=(o[2]-o[0])/f;r.height=(o[3]-o[1])/d;if(u){r.altTextData=u}r._initialData=i;if(t.comment){r.setCommentData(t)}r.#Lh=!!i;return r}serialize(t=false,e=null){if(this.isEmpty()){return null}if(this.deleted){return this.serializeDeleted()}const s=Object.assign(super.serialize(t),{bitmapId:this.#Nh,isSvg:this.#Bh});this.addComment(s);if(t){s.bitmapUrl=this.#Vh(true);s.accessibilityData=this.serializeAltText(true);s.isCopy=true;return s}const{decorative:i,altText:n}=this.serializeAltText(false);if(!i&&n){s.accessibilityData={type:"Figure",alt:n}}if(this.annotationElementId){const t=this.#Fo(s);if(t.isSame){return null}if(t.isSameAltText){delete s.accessibilityData}else{s.accessibilityData.structParent=this._initialData.structParent??-1}s.id=this.annotationElementId;delete s.bitmapId;return s}if(e===null){return s}e.stamps||=new Map;const r=this.#Bh?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#Nh)){e.stamps.set(this.#Nh,{area:r,serialized:s});s.bitmap=this.#Vh(false)}else if(this.#Bh){const t=e.stamps.get(this.#Nh);if(r>t.area){t.area=r;t.serialized.bitmap.close();t.serialized.bitmap=this.#Vh(false)}}return s}#Fo(t){const{pageIndex:e,accessibilityData:{altText:s}}=this._initialData;const i=t.pageIndex===e;const n=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&n,isSameAltText:n}}renderAnnotationElement(t){if(this.deleted){t.hide();return null}t.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}}class fr{#mo;#Xh=false;#qh=null;#Yh=null;#Jh=null;#Kh=new Map;#Qh=false;#Zh=false;#tc=false;#ec=null;#sc=null;#ic=null;#nc=null;#rc=null;#oc=-1;#w;static _initialized=false;static#Y=new Map([Hn,ir,ur,Kn,lr].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:o,textLayer:a,viewport:h,l10n:c}){const l=[...fr.#Y.values()];if(!fr._initialized){fr._initialized=true;for(const e of l){e.initialize(c,t)}}t.registerEditorTypes(l);this.#w=t;this.pageIndex=e;this.div=s;this.#mo=n;this.#qh=r;this.viewport=h;this.#ic=a;this.drawLayer=o;this._structTree=i;this.#w.addLayer(this)}get isEmpty(){return this.#Kh.size===0}get isInvisible(){return this.isEmpty&&this.#w.getMode()===L.NONE}updateToolbar(t){this.#w.updateToolbar(t)}updateMode(t=this.#w.getMode()){this.#ac();switch(t){case L.NONE:this.div.classList.toggle("nonEditing",true);this.disableTextSelection();this.togglePointerEvents(false);this.toggleAnnotationLayerPointerEvents(true);this.disableClick();return;case L.INK:this.disableTextSelection();this.togglePointerEvents(true);this.enableClick();break;case L.HIGHLIGHT:this.enableTextSelection();this.togglePointerEvents(false);this.disableClick();break;default:this.disableTextSelection();this.togglePointerEvents(true);this.enableClick()}this.toggleAnnotationLayerPointerEvents(false);const{classList:e}=this.div;e.toggle("nonEditing",false);if(t===L.POPUP){e.toggle("commentEditing",true)}else{e.toggle("commentEditing",false);for(const s of fr.#Y.values()){e.toggle(`${s._type}Editing`,t===s._editorType)}}this.div.hidden=false}hasTextLayer(t){return t===this.#ic?.div}setEditingState(t){this.#w.setEditingState(t)}addCommands(t){this.#w.addCommands(t)}cleanUndoStack(t){this.#w.cleanUndoStack(t)}toggleDrawing(t=false){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=false){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=false){this.#qh?.togglePointerEvents(t)}get#hc(){return this.#Kh.size!==0?this.#Kh.values():this.#w.getEditors(this.pageIndex)}async enable(){this.#tc=true;this.div.tabIndex=0;this.togglePointerEvents(true);this.div.classList.toggle("nonEditing",false);this.#rc?.abort();this.#rc=null;const t=new Set;for(const e of this.#hc){e.enableEditing();e.show(true);if(e.annotationElementId){this.#w.removeChangedExistingAnnotation(e);t.add(e.annotationElementId)}}const e=this.#qh;if(e){for(const s of e.getEditableAnnotations()){s.hide();if(this.#w.isDeletedAnnotationElement(s.data.id)){continue}if(t.has(s.data.id)){continue}const e=await this.deserialize(s);if(!e){continue}this.addOrRebuild(e);e.enableEditing()}}this.#tc=false;this.#w._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){this.#Zh=true;this.div.tabIndex=-1;this.togglePointerEvents(false);this.div.classList.toggle("nonEditing",true);if(this.#ic&&!this.#rc){this.#rc=new AbortController;const t=this.#w.combinedSignal(this.#rc);this.#ic.div.addEventListener("pointerdown",(t=>{const e=500;const{clientX:s,clientY:i,timeStamp:n}=t;const r=this.#oc;if(n-r>e){this.#oc=n;return}this.#oc=-1;const{classList:o}=this.div;o.toggle("getElements",true);const a=document.elementsFromPoint(s,i);o.toggle("getElements",false);if(!this.div.contains(a[0])){return}let h;const c=new RegExp(`^${B}[0-9]+$`);for(const t of a){if(c.test(t.id)){h=t.id;break}}if(!h){return}const l=this.#Kh.get(h);if(l?.annotationElementId===null){t.stopPropagation();t.preventDefault();l.dblclick(t)}}),{signal:t,capture:true})}const t=this.#qh;const e=[];if(t){const s=new Map;const i=new Map;for(const t of this.#hc){t.disableEditing();if(!t.annotationElementId){e.push(t);continue}if(t.serialize()!==null){s.set(t.annotationElementId,t);continue}else{i.set(t.annotationElementId,t)}this.getEditableAnnotation(t.annotationElementId)?.show();t.remove()}const n=t.getEditableAnnotations();for(const t of n){const{id:e}=t.data;if(this.#w.isDeletedAnnotationElement(e)){t.updateEdited({deleted:true});continue}let n=i.get(e);if(n){n.resetAnnotationElement(t);n.show(false);t.show();continue}n=s.get(e);if(n){this.#w.addChangedExistingAnnotation(n);if(n.renderAnnotationElement(t)){n.show(false)}}t.show()}}this.#ac();if(this.isEmpty){this.div.hidden=true}const{classList:s}=this.div;for(const t of fr.#Y.values()){s.remove(`${t._type}Editing`)}this.disableTextSelection();this.toggleAnnotationLayerPointerEvents(true);t?.updateFakeAnnotations(e);this.#Zh=false}getEditableAnnotation(t){return this.#qh?.getEditableAnnotation(t)||null}setActiveEditor(t){const e=this.#w.getActive();if(e===t){return}this.#w.setActiveEditor(t)}enableTextSelection(){this.div.tabIndex=-1;if(this.#ic?.div&&!this.#nc){this.#nc=new AbortController;const t=this.#w.combinedSignal(this.#nc);this.#ic.div.addEventListener("pointerdown",this.#cc.bind(this),{signal:t});this.#ic.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0;if(this.#ic?.div&&this.#nc){this.#nc.abort();this.#nc=null;this.#ic.div.classList.remove("highlighting")}}#cc(t){this.#w.unselectAll();const{target:e}=t;if(e===this.#ic.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&this.#ic.div.contains(e)){const{isMac:e}=yt.platform;if(t.button!==0||t.ctrlKey&&e){return}this.#w.showAllEditors("highlight",true,true);this.#ic.div.classList.add("free");this.toggleDrawing();Kn.startHighlighting(this,this.#w.direction==="ltr",{target:this.#ic.div,x:t.x,y:t.y});this.#ic.div.addEventListener("pointerup",(()=>{this.#ic.div.classList.remove("free");this.toggleDrawing(true)}),{once:true,signal:this.#w._signal});t.preventDefault()}}enableClick(){if(this.#Yh){return}this.#Yh=new AbortController;const t=this.#w.combinedSignal(this.#Yh);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(){this.#Yh?.abort();this.#Yh=null}attach(t){this.#Kh.set(t.id,t);const{annotationElementId:e}=t;if(e&&this.#w.isDeletedAnnotationElement(e)){this.#w.removeDeletedAnnotationElement(t)}}detach(t){this.#Kh.delete(t.id);this.#mo?.removePointerInTextLayer(t.contentDiv);if(!this.#Zh&&t.annotationElementId){this.#w.addDeletedAnnotationElement(t)}}remove(t){this.detach(t);this.#w.removeEditor(t);t.div.remove();t.isAttachedToDOM=false}changeParent(t){if(t.parent===this){return}if(t.parent&&t.annotationElementId){this.#w.addDeletedAnnotationElement(t);Ee.deleteAnnotationElement(t);t.annotationElementId=null}this.attach(t);t.parent?.detach(t);t.setParent(this);if(t.div&&t.isAttachedToDOM){t.div.remove();this.div.append(t.div)}}add(t){if(t.parent===this&&t.isAttachedToDOM){return}this.changeParent(t);this.#w.addEditor(t);this.attach(t);if(!t.isAttachedToDOM){const e=t.render();this.div.append(e);t.isAttachedToDOM=true}t.fixAndSetPosition();t.onceAdded(!this.#tc);this.#w.addToAnnotationStorage(t);t._reportTelemetry(t.telemetryInitialData)}moveEditorInDOM(t){if(!t.isAttachedToDOM){return}const{activeElement:e}=document;if(t.div.contains(e)&&!this.#Jh){t._focusEventsAllowed=false;this.#Jh=setTimeout((()=>{this.#Jh=null;if(!t.div.contains(document.activeElement)){t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=true}),{once:true,signal:this.#w._signal});e.focus()}else{t._focusEventsAllowed=true}}),0)}t._structTreeParentId=this.#mo?.moveElementInDOM(this.div,t.div,t.contentDiv,true)}addOrRebuild(t){if(t.needsToBeRebuilt()){t.parent||=this;t.rebuild();t.show()}else{this.add(t)}}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t);const s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:false})}getEditorByUID(t){for(const e of this.#Kh.values()){if(e.uid===t){return e}}return null}getNextId(){return this.#w.getId()}get#lc(){return fr.#Y.get(this.#w.getMode())}combinedSignal(t){return this.#w.combinedSignal(t)}#uc(t){const e=this.#lc;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#lc?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t);await this.#w.updateMode(t.mode);const{offsetX:s,offsetY:i}=this.#fc();const n=this.getNextId();const r=this.#uc({parent:this,id:n,x:s,y:i,uiManager:this.#w,isCentered:true,...e});if(r){this.add(r)}}async deserialize(t){return await(fr.#Y.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#w))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId();const n=this.#uc({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#w,isCentered:e,...s});if(n){this.add(n)}return n}get boundingClientRect(){return this.div.getBoundingClientRect()}#fc(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect;const n=Math.max(0,t);const r=Math.max(0,e);const o=Math.min(window.innerWidth,t+s);const a=Math.min(window.innerHeight,e+i);const h=(n+o)/2-t;const c=(r+a)/2-e;const[l,u]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:l,offsetY:u}}addNewEditor(t={}){this.createAndAddNewEditor(this.#fc(),true,t)}setSelected(t){this.#w.setSelected(t)}toggleSelected(t){this.#w.toggleSelected(t)}unselect(t){this.#w.unselect(t)}pointerup(t){const{isMac:e}=yt.platform;if(t.button!==0||t.ctrlKey&&e){return}if(t.target!==this.div){return}if(!this.#Qh){return}this.#Qh=false;if(this.#lc?.isDrawer&&this.#lc.supportMultipleDrawings){return}if(!this.#Xh){this.#Xh=true;return}const s=this.#w.getMode();if(s===L.STAMP||s===L.SIGNATURE){this.#w.unselectAll();return}this.createAndAddNewEditor(t,false)}pointerdown(t){if(this.#w.getMode()===L.HIGHLIGHT){this.enableTextSelection()}if(this.#Qh){this.#Qh=false;return}const{isMac:e}=yt.platform;if(t.button!==0||t.ctrlKey&&e){return}if(t.target!==this.div){return}this.#Qh=true;if(this.#lc?.isDrawer){this.startDrawingSession(t);return}const s=this.#w.getActive();this.#Xh=!s||s.isEmpty()}startDrawingSession(t){this.div.focus({preventScroll:true});if(this.#ec){this.#lc.startDrawing(this,this.#w,false,t);return}this.#w.setCurrentDrawingSession(this);this.#ec=new AbortController;const e=this.#w.combinedSignal(this.#ec);this.div.addEventListener("blur",(({relatedTarget:t})=>{if(t&&!this.div.contains(t)){this.#sc=null;this.commitOrRemove()}}),{signal:e});this.#lc.startDrawing(this,this.#w,false,t)}pause(t){if(t){const{activeElement:t}=document;if(this.div.contains(t)){this.#sc=t}return}if(this.#sc){setTimeout((()=>{this.#sc?.focus();this.#sc=null}),0)}}endDrawingSession(t=false){if(!this.#ec){return null}this.#w.setCurrentDrawingSession(null);this.#ec.abort();this.#ec=null;this.#sc=null;return this.#lc.endDrawing(t)}findNewParent(t,e,s){const i=this.#w.findParent(e,s);if(i===null||i===this){return false}i.changeParent(t);return true}commitOrRemove(){if(this.#ec){this.endDrawingSession();return true}return false}onScaleChanging(){if(!this.#ec){return}this.#lc.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove();if(this.#w.getActive()?.parent===this){this.#w.commitOrRemove();this.#w.setActiveEditor(null)}if(this.#Jh){clearTimeout(this.#Jh);this.#Jh=null}for(const t of this.#Kh.values()){this.#mo?.removePointerInTextLayer(t.contentDiv);t.setParent(null);t.isAttachedToDOM=false;t.div.remove()}this.div=null;this.#Kh.clear();this.#w.removeLayer(this)}#ac(){for(const t of this.#Kh.values()){if(t.isEmpty()){t.remove()}}}render({viewport:t}){this.viewport=t;ee(this.div,t);for(const t of this.#w.getEditors(this.pageIndex)){this.add(t);t.rebuild()}this.updateMode()}update({viewport:t}){this.#w.commitOrRemove();this.#ac();const e=this.viewport.rotation;const s=t.rotation;this.viewport=t;ee(this.div,{rotation:s});if(e!==s){for(const t of this.#Kh.values()){t.rotate(s)}}}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#w.viewParameters.realScale}}class dr{#Ur=null;#dc=new Map;#pc=new Map;static#M=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#Ur){this.#Ur=t;return}if(this.#Ur!==t){if(this.#dc.size>0){for(const e of this.#dc.values()){e.remove();t.append(e)}}this.#Ur=t}}static get _svgFactory(){return at(this,"_svgFactory",new cn)}static#gc(t,[e,s,i,n]){const{style:r}=t;r.top=`${100*s}%`;r.left=`${100*e}%`;r.width=`${100*i}%`;r.height=`${100*n}%`}#mc(){const t=dr._svgFactory.create(1,1,true);this.#Ur.append(t);t.setAttribute("aria-hidden",true);return t}#wc(t,e){const s=dr._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i);s.setAttribute("clipPathUnits","objectBoundingBox");const n=dr._svgFactory.createElement("use");s.append(n);n.setAttribute("href",`#${e}`);n.classList.add("clip");return i}#bc(t,e){for(const[s,i]of Object.entries(e)){if(i===null){t.removeAttribute(s)}else{t.setAttribute(s,i)}}}draw(t,e=false,s=false){const i=dr.#M++;const n=this.#mc();const r=dr._svgFactory.createElement("defs");n.append(r);const o=dr._svgFactory.createElement("path");r.append(o);const a=`path_p${this.pageIndex}_${i}`;o.setAttribute("id",a);o.setAttribute("vector-effect","non-scaling-stroke");if(e){this.#pc.set(i,o)}const h=s?this.#wc(r,a):null;const c=dr._svgFactory.createElement("use");n.append(c);c.setAttribute("href",`#${a}`);this.updateProperties(n,t);this.#dc.set(i,n);return{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=dr.#M++;const i=this.#mc();const n=dr._svgFactory.createElement("defs");i.append(n);const r=dr._svgFactory.createElement("path");n.append(r);const o=`path_p${this.pageIndex}_${s}`;r.setAttribute("id",o);r.setAttribute("vector-effect","non-scaling-stroke");let a;if(e){const t=dr._svgFactory.createElement("mask");n.append(t);a=`mask_p${this.pageIndex}_${s}`;t.setAttribute("id",a);t.setAttribute("maskUnits","objectBoundingBox");const e=dr._svgFactory.createElement("rect");t.append(e);e.setAttribute("width","1");e.setAttribute("height","1");e.setAttribute("fill","white");const i=dr._svgFactory.createElement("use");t.append(i);i.setAttribute("href",`#${o}`);i.setAttribute("stroke","none");i.setAttribute("fill","black");i.setAttribute("fill-rule","nonzero");i.classList.add("mask")}const h=dr._svgFactory.createElement("use");i.append(h);h.setAttribute("href",`#${o}`);if(a){h.setAttribute("mask",`url(#${a})`)}const c=h.cloneNode();i.append(c);h.classList.add("mainOutline");c.classList.add("secondaryOutline");this.updateProperties(i,t);this.#dc.set(s,i);return s}finalizeDraw(t,e){this.#pc.delete(t);this.updateProperties(t,e)}updateProperties(t,e){if(!e){return}const{root:s,bbox:i,rootClass:n,path:r}=e;const o=typeof t==="number"?this.#dc.get(t):t;if(!o){return}if(s){this.#bc(o,s)}if(i){dr.#gc(o,i)}if(n){const{classList:t}=o;for(const[e,s]of Object.entries(n)){t.toggle(e,s)}}if(r){const t=o.firstElementChild;const e=t.firstElementChild;this.#bc(e,r)}}updateParent(t,e){if(e===this){return}const s=this.#dc.get(t);if(!s){return}e.#Ur.append(s);this.#dc.delete(t);e.#dc.set(t,s)}remove(t){this.#pc.delete(t);if(this.#Ur===null){return}this.#dc.get(t).remove();this.#dc.delete(t)}destroy(){this.#Ur=null;for(const t of this.#dc.values()){t.remove()}this.#dc.clear();this.#pc.clear()}}{globalThis._pdfjsTestingUtils={HighlightOutliner:Xn}}globalThis.pdfjsLib={AbortException:pt,AnnotationEditorLayer:fr,AnnotationEditorParamsType:U,AnnotationEditorType:L,AnnotationEditorUIManager:Se,AnnotationLayer:jn,AnnotationMode:_,AnnotationType:G,applyOpacity:oe,build:en,ColorPicker:sn,createValidAbsoluteUrl:rt,CSSConstants:re,DOMSVGFactory:cn,DrawLayer:dr,FeatureTest:yt,fetchData:_t,findContrastColor:fe,getDocument:Gi,getFilenameFromUrl:zt,getPdfFilenameFromUrl:Ht,getRGB:Kt,getUuid:Tt,getXfaPageViewport:Jt,GlobalWorkerOptions:ai,ImageKind:W,InvalidPDFException:ut,isDataScheme:Ut,isPdfFile:jt,isValidExplicitDest:qe,MathClamp:Nt,noContextMenu:Vt,normalizeUnicode:Ct,OPS:q,OutputScale:se,PasswordResponses:J,PDFDataRangeTransport:Xi,PDFDateString:Yt,PDFWorker:Ji,PermissionFlag:j,PixelsPerInch:$t,RenderingCancelledException:Lt,renderRichText:de,ResponseException:ft,setLayerDimensions:ee,shadow:at,SignatureExtractor:ar,stopEvent:Xt,SupportedImageMimeTypes:ie,TextLayer:Hi,TouchManager:Te,updateUrlHash:ot,Util:xt,VerbosityLevel:X,version:tn,XfaLayer:Ft};let pr=null;let gr=null;const mr=300;function wr(t){if(this.mode==="preview"||this._template?.locked){return}const e=t.ctrlKey||t.metaKey;if(e){if(t.key==="a"||t.key==="A"){t.preventDefault();br.bind(this)();return}if(t.key==="c"||t.key==="C"){t.preventDefault();y.bind(this)();return}if(t.key==="x"||t.key==="X"){t.preventDefault();v.bind(this)();return}if(t.key==="v"||t.key==="V"){t.preventDefault();x.bind(this)();return}if(t.key==="z"||t.key==="Z"){t.preventDefault();if(t.shiftKey){yr.bind(this)()}else{Ar.bind(this)()}return}if(t.key==="y"||t.key==="Y"){t.preventDefault();yr.bind(this)();return}}if(this.selected&&this.selected?.length>0){if(t.key==="ArrowDown"){t.preventDefault();vr.bind(this)((()=>t=>{const e={...t,top:t.top+1,ay:t.ay+1,by:t.by+1};return o(e)?t:e}))}else if(t.key==="ArrowUp"){t.preventDefault();vr.bind(this)((()=>t=>{const e={...t,top:t.top-1,ay:t.ay-1,by:t.top-1};return o(e)?t:e}))}else if(t.key==="ArrowRight"){t.preventDefault();vr.bind(this)((()=>t=>{const e={...t,left:t.left+1,ax:t.ax+1,bx:t.bx+1};return o(e)?t:e}))}else if(t.key==="ArrowLeft"){t.preventDefault();vr.bind(this)((()=>t=>{const e={...t,left:t.left-1,ax:t.ax-1,bx:t.bx-1};return o(e)?t:e}))}else if(t.key==="Delete"||t.key==="Backspace"){const t=Array.from(this.selected);this.mutate.emit(t.map((t=>({action:"delete",data:t.dataItem}))))}else if(!e&&(t.key==="d"||t.key==="D"||t.key==="keyD")){const t=Array.from(this.selected);const e=t.map((t=>{const e={...t.dataItem,id:btoa("ele"+crypto.randomUUID())};const s=t.dataItem.top+t.dataItem.height;if(s+t.dataItem.height<t.dataItem.pageDimensions.height){e.top=s}return{action:"create",data:e,select:"clear"}}));this.mutate.emit(e.map((t=>({action:"create",data:t.data}))))}else if(t.key==="Escape"){console.log("Clearing selection");this.selected=[];this.selectFields.emit([])}}}function br(){const t=Array.from(this.component.shadowRoot.querySelectorAll("ls-editor-field"));if(t.length===0)return;t.forEach((e=>{e.selected=true;e.multiSelected=t.length>1}));this.selected=t;this.selectFields.emit(t.map((t=>t.dataItem)));k.bind(this)()}function Ar(){const t=D();if(!t)return;this._skipHistory=true;this.mutate.emit(t)}function yr(){const t=N();if(!t)return;this._skipHistory=true;this.mutate.emit(t)}function vr(t){if(gr){clearTimeout(gr)}const e=t();this.selected.forEach((t=>{const s=e(t.dataItem);Object.assign(t.dataItem,s);a.bind(this)(t,s)}));k.bind(this)();pr=this.selected.map((t=>t.dataItem));gr=setTimeout((()=>{if(pr){const t=pr.map((t=>({action:"update",data:t})));this.mutate.emit(t);pr=null}gr=null}),mr)}var xr=typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};function kr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t["default"]:t}
23
- /*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors */var Sr;var Mr;function Cr(){if(Mr)return Sr;Mr=1;function t(t,e){return function s(){return t.apply(e,arguments)}}const{toString:e}=Object.prototype;const{getPrototypeOf:s}=Object;const{iterator:i,toStringTag:n}=Symbol;const r=(t=>s=>{const i=e.call(s);return t[i]||(t[i]=i.slice(8,-1).toLowerCase())})(Object.create(null));const o=t=>{t=t.toLowerCase();return e=>r(e)===t};const a=t=>e=>typeof e===t;const{isArray:h}=Array;const c=a("undefined");function l(t){return t!==null&&!c(t)&&t.constructor!==null&&!c(t.constructor)&&p(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const u=o("ArrayBuffer");function f(t){let e;if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){e=ArrayBuffer.isView(t)}else{e=t&&t.buffer&&u(t.buffer)}return e}const d=a("string");const p=a("function");const g=a("number");const m=t=>t!==null&&typeof t==="object";const w=t=>t===true||t===false;const b=t=>{if(r(t)!=="object"){return false}const e=s(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(n in t)&&!(i in t)};const A=t=>{if(!m(t)||l(t)){return false}try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch(t){return false}};const y=o("Date");const v=o("File");const x=o("Blob");const k=o("FileList");const S=t=>m(t)&&p(t.pipe);const M=t=>{let e;return t&&(typeof FormData==="function"&&t instanceof FormData||p(t.append)&&((e=r(t))==="formdata"||e==="object"&&p(t.toString)&&t.toString()==="[object FormData]"))};const C=o("URLSearchParams");const[T,E,P,N]=["ReadableStream","Request","Response","Headers"].map(o);const D=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function I(t,e,{allOwnKeys:s=false}={}){if(t===null||typeof t==="undefined"){return}let i;let n;if(typeof t!=="object"){t=[t]}if(h(t)){for(i=0,n=t.length;i<n;i++){e.call(null,t[i],i,t)}}else{if(l(t)){return}const n=s?Object.getOwnPropertyNames(t):Object.keys(t);const r=n.length;let o;for(i=0;i<r;i++){o=n[i];e.call(null,t[o],o,t)}}}function R(t,e){if(l(t)){return null}e=e.toLowerCase();const s=Object.keys(t);let i=s.length;let n;while(i-- >0){n=s[i];if(e===n.toLowerCase()){return n}}return null}const F=(()=>{if(typeof globalThis!=="undefined")return globalThis;return typeof self!=="undefined"?self:typeof window!=="undefined"?window:xr})();const O=t=>!c(t)&&t!==F;function $(){const{caseless:t,skipUndefined:e}=O(this)&&this||{};const s={};const i=(i,n)=>{const r=t&&R(s,n)||n;if(b(s[r])&&b(i)){s[r]=$(s[r],i)}else if(b(i)){s[r]=$({},i)}else if(h(i)){s[r]=i.slice()}else if(!e||!c(i)){s[r]=i}};for(let t=0,e=arguments.length;t<e;t++){arguments[t]&&I(arguments[t],i)}return s}const _=(e,s,i,{allOwnKeys:n}={})=>{I(s,((s,n)=>{if(i&&p(s)){e[n]=t(s,i)}else{e[n]=s}}),{allOwnKeys:n});return e};const B=t=>{if(t.charCodeAt(0)===65279){t=t.slice(1)}return t};const L=(t,e,s,i)=>{t.prototype=Object.create(e.prototype,i);t.prototype.constructor=t;Object.defineProperty(t,"super",{value:e.prototype});s&&Object.assign(t.prototype,s)};const U=(t,e,i,n)=>{let r;let o;let a;const h={};e=e||{};if(t==null)return e;do{r=Object.getOwnPropertyNames(t);o=r.length;while(o-- >0){a=r[o];if((!n||n(a,t,e))&&!h[a]){e[a]=t[a];h[a]=true}}t=i!==false&&s(t)}while(t&&(!i||i(t,e))&&t!==Object.prototype);return e};const j=(t,e,s)=>{t=String(t);if(s===undefined||s>t.length){s=t.length}s-=e.length;const i=t.indexOf(e,s);return i!==-1&&i===s};const z=t=>{if(!t)return null;if(h(t))return t;let e=t.length;if(!g(e))return null;const s=new Array(e);while(e-- >0){s[e]=t[e]}return s};const H=(t=>e=>t&&e instanceof t)(typeof Uint8Array!=="undefined"&&s(Uint8Array));const W=(t,e)=>{const s=t&&t[i];const n=s.call(t);let r;while((r=n.next())&&!r.done){const s=r.value;e.call(t,s[0],s[1])}};const G=(t,e)=>{let s;const i=[];while((s=t.exec(e))!==null){i.push(s)}return i};const V=o("HTMLFormElement");const X=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function t(e,s,i){return s.toUpperCase()+i}));const q=(({hasOwnProperty:t})=>(e,s)=>t.call(e,s))(Object.prototype);const Y=o("RegExp");const J=(t,e)=>{const s=Object.getOwnPropertyDescriptors(t);const i={};I(s,((s,n)=>{let r;if((r=e(s,n,t))!==false){i[n]=r||s}}));Object.defineProperties(t,i)};const K=t=>{J(t,((e,s)=>{if(p(t)&&["arguments","caller","callee"].indexOf(s)!==-1){return false}const i=t[s];if(!p(i))return;e.enumerable=false;if("writable"in e){e.writable=false;return}if(!e.set){e.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")}}}))};const Q=(t,e)=>{const s={};const i=t=>{t.forEach((t=>{s[t]=true}))};h(t)?i(t):i(String(t).split(e));return s};const Z=()=>{};const tt=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function et(t){return!!(t&&p(t.append)&&t[n]==="FormData"&&t[i])}const st=t=>{const e=new Array(10);const s=(t,i)=>{if(m(t)){if(e.indexOf(t)>=0){return}if(l(t)){return t}if(!("toJSON"in t)){e[i]=t;const n=h(t)?[]:{};I(t,((t,e)=>{const r=s(t,i+1);!c(r)&&(n[e]=r)}));e[i]=undefined;return n}}return t};return s(t,0)};const it=o("AsyncFunction");const nt=t=>t&&(m(t)||p(t))&&p(t.then)&&p(t.catch);const rt=((t,e)=>{if(t){return setImmediate}return e?((t,e)=>{F.addEventListener("message",(({source:s,data:i})=>{if(s===F&&i===t){e.length&&e.shift()()}}),false);return s=>{e.push(s);F.postMessage(t,"*")}})(`axios@${Math.random()}`,[]):t=>setTimeout(t)})(typeof setImmediate==="function",p(F.postMessage));const ot=typeof queueMicrotask!=="undefined"?queueMicrotask.bind(F):typeof process!=="undefined"&&process.nextTick||rt;const at=t=>t!=null&&p(t[i]);var ht={isArray:h,isArrayBuffer:u,isBuffer:l,isFormData:M,isArrayBufferView:f,isString:d,isNumber:g,isBoolean:w,isObject:m,isPlainObject:b,isEmptyObject:A,isReadableStream:T,isRequest:E,isResponse:P,isHeaders:N,isUndefined:c,isDate:y,isFile:v,isBlob:x,isRegExp:Y,isFunction:p,isStream:S,isURLSearchParams:C,isTypedArray:H,isFileList:k,forEach:I,merge:$,extend:_,trim:D,stripBOM:B,inherits:L,toFlatObject:U,kindOf:r,kindOfTest:o,endsWith:j,toArray:z,forEachEntry:W,matchAll:G,isHTMLForm:V,hasOwnProperty:q,hasOwnProp:q,reduceDescriptors:J,freezeMethods:K,toObjectSet:Q,toCamelCase:X,noop:Z,toFiniteNumber:tt,findKey:R,global:F,isContextDefined:O,isSpecCompliantForm:et,toJSONObject:st,isAsyncFn:it,isThenable:nt,setImmediate:rt,asap:ot,isIterable:at};function ct(t,e,s,i,n){Error.call(this);if(Error.captureStackTrace){Error.captureStackTrace(this,this.constructor)}else{this.stack=(new Error).stack}this.message=t;this.name="AxiosError";e&&(this.code=e);s&&(this.config=s);i&&(this.request=i);if(n){this.response=n;this.status=n.status?n.status:null}}ht.inherits(ct,Error,{toJSON:function t(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ht.toJSONObject(this.config),code:this.code,status:this.status}}});const lt=ct.prototype;const ut={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((t=>{ut[t]={value:t}}));Object.defineProperties(ct,ut);Object.defineProperty(lt,"isAxiosError",{value:true});ct.from=(t,e,s,i,n,r)=>{const o=Object.create(lt);ht.toFlatObject(t,o,(function t(e){return e!==Error.prototype}),(t=>t!=="isAxiosError"));const a=t&&t.message?t.message:"Error";const h=e==null&&t?t.code:e;ct.call(o,a,h,s,i,n);if(t&&o.cause==null){Object.defineProperty(o,"cause",{value:t,configurable:true})}o.name=t&&t.name||"Error";r&&Object.assign(o,r);return o};var ft=null;function dt(t){return ht.isPlainObject(t)||ht.isArray(t)}function pt(t){return ht.endsWith(t,"[]")?t.slice(0,-2):t}function gt(t,e,s){if(!t)return e;return t.concat(e).map((function t(e,i){e=pt(e);return!s&&i?"["+e+"]":e})).join(s?".":"")}function mt(t){return ht.isArray(t)&&!t.some(dt)}const wt=ht.toFlatObject(ht,{},null,(function t(e){return/^is[A-Z]/.test(e)}));function bt(t,e,s){if(!ht.isObject(t)){throw new TypeError("target must be an object")}e=e||new FormData;s=ht.toFlatObject(s,{metaTokens:true,dots:false,indexes:false},false,(function t(e,s){return!ht.isUndefined(s[e])}));const i=s.metaTokens;const n=s.visitor||l;const r=s.dots;const o=s.indexes;const a=s.Blob||typeof Blob!=="undefined"&&Blob;const h=a&&ht.isSpecCompliantForm(e);if(!ht.isFunction(n)){throw new TypeError("visitor must be a function")}function c(t){if(t===null)return"";if(ht.isDate(t)){return t.toISOString()}if(ht.isBoolean(t)){return t.toString()}if(!h&&ht.isBlob(t)){throw new ct("Blob is not supported. Use a Buffer instead.")}if(ht.isArrayBuffer(t)||ht.isTypedArray(t)){return h&&typeof Blob==="function"?new Blob([t]):Buffer.from(t)}return t}function l(t,s,n){let a=t;if(t&&!n&&typeof t==="object"){if(ht.endsWith(s,"{}")){s=i?s:s.slice(0,-2);t=JSON.stringify(t)}else if(ht.isArray(t)&&mt(t)||(ht.isFileList(t)||ht.endsWith(s,"[]"))&&(a=ht.toArray(t))){s=pt(s);a.forEach((function t(i,n){!(ht.isUndefined(i)||i===null)&&e.append(o===true?gt([s],n,r):o===null?s:s+"[]",c(i))}));return false}}if(dt(t)){return true}e.append(gt(n,s,r),c(t));return false}const u=[];const f=Object.assign(wt,{defaultVisitor:l,convertValue:c,isVisitable:dt});function d(t,s){if(ht.isUndefined(t))return;if(u.indexOf(t)!==-1){throw Error("Circular reference detected in "+s.join("."))}u.push(t);ht.forEach(t,(function t(i,r){const o=!(ht.isUndefined(i)||i===null)&&n.call(e,i,ht.isString(r)?r.trim():r,s,f);if(o===true){d(i,s?s.concat(r):[r])}}));u.pop()}if(!ht.isObject(t)){throw new TypeError("data must be an object")}d(t);return e}function At(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function t(s){return e[s]}))}function yt(t,e){this._pairs=[];t&&bt(t,this,e)}const vt=yt.prototype;vt.append=function t(e,s){this._pairs.push([e,s])};vt.toString=function t(e){const s=e?function(t){return e.call(this,t,At)}:At;return this._pairs.map((function t(e){return s(e[0])+"="+s(e[1])}),"").join("&")};function xt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function kt(t,e,s){if(!e){return t}const i=s&&s.encode||xt;if(ht.isFunction(s)){s={serialize:s}}const n=s&&s.serialize;let r;if(n){r=n(e,s)}else{r=ht.isURLSearchParams(e)?e.toString():new yt(e,s).toString(i)}if(r){const e=t.indexOf("#");if(e!==-1){t=t.slice(0,e)}t+=(t.indexOf("?")===-1?"?":"&")+r}return t}class St{constructor(){this.handlers=[]}use(t,e,s){this.handlers.push({fulfilled:t,rejected:e,synchronous:s?s.synchronous:false,runWhen:s?s.runWhen:null});return this.handlers.length-1}eject(t){if(this.handlers[t]){this.handlers[t]=null}}clear(){if(this.handlers){this.handlers=[]}}forEach(t){ht.forEach(this.handlers,(function e(s){if(s!==null){t(s)}}))}}var Mt=St;var Ct={silentJSONParsing:true,forcedJSONParsing:true,clarifyTimeoutError:false};var Tt=typeof URLSearchParams!=="undefined"?URLSearchParams:yt;var Et=typeof FormData!=="undefined"?FormData:null;var Pt=typeof Blob!=="undefined"?Blob:null;var Nt={isBrowser:true,classes:{URLSearchParams:Tt,FormData:Et,Blob:Pt},protocols:["http","https","file","blob","url","data"]};const Dt=typeof window!=="undefined"&&typeof document!=="undefined";const It=typeof navigator==="object"&&navigator||undefined;const Rt=Dt&&(!It||["ReactNative","NativeScript","NS"].indexOf(It.product)<0);const Ft=(()=>typeof WorkerGlobalScope!=="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts==="function")();const Ot=Dt&&window.location.href||"http://localhost";var $t=Object.freeze({__proto__:null,hasBrowserEnv:Dt,hasStandardBrowserWebWorkerEnv:Ft,hasStandardBrowserEnv:Rt,navigator:It,origin:Ot});var _t={...$t,...Nt};function Bt(t,e){return bt(t,new _t.classes.URLSearchParams,{visitor:function(t,e,s,i){if(_t.isNode&&ht.isBuffer(t)){this.append(e,t.toString("base64"));return false}return i.defaultVisitor.apply(this,arguments)},...e})}function Lt(t){return ht.matchAll(/\w+|\[(\w*)]/g,t).map((t=>t[0]==="[]"?"":t[1]||t[0]))}function Ut(t){const e={};const s=Object.keys(t);let i;const n=s.length;let r;for(i=0;i<n;i++){r=s[i];e[r]=t[r]}return e}function jt(t){function e(t,s,i,n){let r=t[n++];if(r==="__proto__")return true;const o=Number.isFinite(+r);const a=n>=t.length;r=!r&&ht.isArray(i)?i.length:r;if(a){if(ht.hasOwnProp(i,r)){i[r]=[i[r],s]}else{i[r]=s}return!o}if(!i[r]||!ht.isObject(i[r])){i[r]=[]}const h=e(t,s,i[r],n);if(h&&ht.isArray(i[r])){i[r]=Ut(i[r])}return!o}if(ht.isFormData(t)&&ht.isFunction(t.entries)){const s={};ht.forEachEntry(t,((t,i)=>{e(Lt(t),i,s,0)}));return s}return null}function zt(t,e,s){if(ht.isString(t)){try{(0,JSON.parse)(t);return ht.trim(t)}catch(t){if(t.name!=="SyntaxError"){throw t}}}return(s||JSON.stringify)(t)}const Ht={transitional:Ct,adapter:["xhr","http","fetch"],transformRequest:[function t(e,s){const i=s.getContentType()||"";const n=i.indexOf("application/json")>-1;const r=ht.isObject(e);if(r&&ht.isHTMLForm(e)){e=new FormData(e)}const o=ht.isFormData(e);if(o){return n?JSON.stringify(jt(e)):e}if(ht.isArrayBuffer(e)||ht.isBuffer(e)||ht.isStream(e)||ht.isFile(e)||ht.isBlob(e)||ht.isReadableStream(e)){return e}if(ht.isArrayBufferView(e)){return e.buffer}if(ht.isURLSearchParams(e)){s.setContentType("application/x-www-form-urlencoded;charset=utf-8",false);return e.toString()}let a;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1){return Bt(e,this.formSerializer).toString()}if((a=ht.isFileList(e))||i.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return bt(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}if(r||n){s.setContentType("application/json",false);return zt(e)}return e}],transformResponse:[function t(e){const s=this.transitional||Ht.transitional;const i=s&&s.forcedJSONParsing;const n=this.responseType==="json";if(ht.isResponse(e)||ht.isReadableStream(e)){return e}if(e&&ht.isString(e)&&(i&&!this.responseType||n)){const t=s&&s.silentJSONParsing;const i=!t&&n;try{return JSON.parse(e,this.parseReviver)}catch(t){if(i){if(t.name==="SyntaxError"){throw ct.from(t,ct.ERR_BAD_RESPONSE,this,null,this.response)}throw t}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function t(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":undefined}}};ht.forEach(["delete","get","head","post","put","patch"],(t=>{Ht.headers[t]={}}));var Wt=Ht;const Gt=ht.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var Vt=t=>{const e={};let s;let i;let n;t&&t.split("\n").forEach((function t(r){n=r.indexOf(":");s=r.substring(0,n).trim().toLowerCase();i=r.substring(n+1).trim();if(!s||e[s]&&Gt[s]){return}if(s==="set-cookie"){if(e[s]){e[s].push(i)}else{e[s]=[i]}}else{e[s]=e[s]?e[s]+", "+i:i}}));return e};const Xt=Symbol("internals");function qt(t){return t&&String(t).trim().toLowerCase()}function Yt(t){if(t===false||t==null){return t}return ht.isArray(t)?t.map(Yt):String(t)}function Jt(t){const e=Object.create(null);const s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;while(i=s.exec(t)){e[i[1]]=i[2]}return e}const Kt=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Qt(t,e,s,i,n){if(ht.isFunction(i)){return i.call(this,e,s)}if(n){e=s}if(!ht.isString(e))return;if(ht.isString(i)){return e.indexOf(i)!==-1}if(ht.isRegExp(i)){return i.test(e)}}function Zt(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,s)=>e.toUpperCase()+s))}function te(t,e){const s=ht.toCamelCase(" "+e);["get","set","has"].forEach((i=>{Object.defineProperty(t,i+s,{value:function(t,s,n){return this[i].call(this,e,t,s,n)},configurable:true})}))}class ee{constructor(t){t&&this.set(t)}set(t,e,s){const i=this;function n(t,e,s){const n=qt(e);if(!n){throw new Error("header name must be a non-empty string")}const r=ht.findKey(i,n);if(!r||i[r]===undefined||s===true||s===undefined&&i[r]!==false){i[r||e]=Yt(t)}}const r=(t,e)=>ht.forEach(t,((t,s)=>n(t,s,e)));if(ht.isPlainObject(t)||t instanceof this.constructor){r(t,e)}else if(ht.isString(t)&&(t=t.trim())&&!Kt(t)){r(Vt(t),e)}else if(ht.isObject(t)&&ht.isIterable(t)){let s={},i,n;for(const e of t){if(!ht.isArray(e)){throw TypeError("Object iterator must return a key-value pair")}s[n=e[0]]=(i=s[n])?ht.isArray(i)?[...i,e[1]]:[i,e[1]]:e[1]}r(s,e)}else{t!=null&&n(e,t,s)}return this}get(t,e){t=qt(t);if(t){const s=ht.findKey(this,t);if(s){const t=this[s];if(!e){return t}if(e===true){return Jt(t)}if(ht.isFunction(e)){return e.call(this,t,s)}if(ht.isRegExp(e)){return e.exec(t)}throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){t=qt(t);if(t){const s=ht.findKey(this,t);return!!(s&&this[s]!==undefined&&(!e||Qt(this,this[s],s,e)))}return false}delete(t,e){const s=this;let i=false;function n(t){t=qt(t);if(t){const n=ht.findKey(s,t);if(n&&(!e||Qt(s,s[n],n,e))){delete s[n];i=true}}}if(ht.isArray(t)){t.forEach(n)}else{n(t)}return i}clear(t){const e=Object.keys(this);let s=e.length;let i=false;while(s--){const n=e[s];if(!t||Qt(this,this[n],n,t,true)){delete this[n];i=true}}return i}normalize(t){const e=this;const s={};ht.forEach(this,((i,n)=>{const r=ht.findKey(s,n);if(r){e[r]=Yt(i);delete e[n];return}const o=t?Zt(n):String(n).trim();if(o!==n){delete e[n]}e[o]=Yt(i);s[o]=true}));return this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);ht.forEach(this,((s,i)=>{s!=null&&s!==false&&(e[i]=t&&ht.isArray(s)?s.join(", "):s)}));return e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([t,e])=>t+": "+e)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const s=new this(t);e.forEach((t=>s.set(t)));return s}static accessor(t){const e=this[Xt]=this[Xt]={accessors:{}};const s=e.accessors;const i=this.prototype;function n(t){const e=qt(t);if(!s[e]){te(i,t);s[e]=true}}ht.isArray(t)?t.forEach(n):n(t);return this}}ee.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ht.reduceDescriptors(ee.prototype,(({value:t},e)=>{let s=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[s]=t}}}));ht.freezeMethods(ee);var se=ee;function ie(t,e){const s=this||Wt;const i=e||s;const n=se.from(i.headers);let r=i.data;ht.forEach(t,(function t(i){r=i.call(s,r,n.normalize(),e?e.status:undefined)}));n.normalize();return r}function ne(t){return!!(t&&t.__CANCEL__)}function re(t,e,s){ct.call(this,t==null?"canceled":t,ct.ERR_CANCELED,e,s);this.name="CanceledError"}ht.inherits(re,ct,{__CANCEL__:true});function oe(t,e,s){const i=s.config.validateStatus;if(!s.status||!i||i(s.status)){t(s)}else{e(new ct("Request failed with status code "+s.status,[ct.ERR_BAD_REQUEST,ct.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}}function ae(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function he(t,e){t=t||10;const s=new Array(t);const i=new Array(t);let n=0;let r=0;let o;e=e!==undefined?e:1e3;return function a(h){const c=Date.now();const l=i[r];if(!o){o=c}s[n]=h;i[n]=c;let u=r;let f=0;while(u!==n){f+=s[u++];u=u%t}n=(n+1)%t;if(n===r){r=(r+1)%t}if(c-o<e){return}const d=l&&c-l;return d?Math.round(f*1e3/d):undefined}}function ce(t,e){let s=0;let i=1e3/e;let n;let r;const o=(e,i=Date.now())=>{s=i;n=null;if(r){clearTimeout(r);r=null}t(...e)};const a=(...t)=>{const e=Date.now();const a=e-s;if(a>=i){o(t,e)}else{n=t;if(!r){r=setTimeout((()=>{r=null;o(n)}),i-a)}}};const h=()=>n&&o(n);return[a,h]}const le=(t,e,s=3)=>{let i=0;const n=he(50,250);return ce((s=>{const r=s.loaded;const o=s.lengthComputable?s.total:undefined;const a=r-i;const h=n(a);const c=r<=o;i=r;const l={loaded:r,total:o,progress:o?r/o:undefined,bytes:a,rate:h?h:undefined,estimated:h&&o&&c?(o-r)/h:undefined,event:s,lengthComputable:o!=null,[e?"download":"upload"]:true};t(l)}),s)};const ue=(t,e)=>{const s=t!=null;return[i=>e[0]({lengthComputable:s,total:t,loaded:i}),e[1]]};const fe=t=>(...e)=>ht.asap((()=>t(...e)));var de=_t.hasStandardBrowserEnv?((t,e)=>s=>{s=new URL(s,_t.origin);return t.protocol===s.protocol&&t.host===s.host&&(e||t.port===s.port)})(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>true;var pe=_t.hasStandardBrowserEnv?{write(t,e,s,i,n,r,o){if(typeof document==="undefined")return;const a=[`${t}=${encodeURIComponent(e)}`];if(ht.isNumber(s)){a.push(`expires=${new Date(s).toUTCString()}`)}if(ht.isString(i)){a.push(`path=${i}`)}if(ht.isString(n)){a.push(`domain=${n}`)}if(r===true){a.push("secure")}if(ht.isString(o)){a.push(`SameSite=${o}`)}document.cookie=a.join("; ")},read(t){if(typeof document==="undefined")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function ge(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function me(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function we(t,e,s){let i=!ge(e);if(t&&(i||s==false)){return me(t,e)}return e}const be=t=>t instanceof se?{...t}:t;function Ae(t,e){e=e||{};const s={};function i(t,e,s,i){if(ht.isPlainObject(t)&&ht.isPlainObject(e)){return ht.merge.call({caseless:i},t,e)}else if(ht.isPlainObject(e)){return ht.merge({},e)}else if(ht.isArray(e)){return e.slice()}return e}function n(t,e,s,n){if(!ht.isUndefined(e)){return i(t,e,s,n)}else if(!ht.isUndefined(t)){return i(undefined,t,s,n)}}function r(t,e){if(!ht.isUndefined(e)){return i(undefined,e)}}function o(t,e){if(!ht.isUndefined(e)){return i(undefined,e)}else if(!ht.isUndefined(t)){return i(undefined,t)}}function a(s,n,r){if(r in e){return i(s,n)}else if(r in t){return i(undefined,s)}}const h={url:r,method:r,data:r,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(t,e,s)=>n(be(t),be(e),s,true)};ht.forEach(Object.keys({...t,...e}),(function i(r){const o=h[r]||n;const c=o(t[r],e[r],r);ht.isUndefined(c)&&o!==a||(s[r]=c)}));return s}var ye=t=>{const e=Ae({},t);let{data:s,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:r,headers:o,auth:a}=e;e.headers=o=se.from(o);e.url=kt(we(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer);if(a){o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")))}if(ht.isFormData(s)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv){o.setContentType(undefined)}else if(ht.isFunction(s.getHeaders)){const t=s.getHeaders();const e=["content-type","content-length"];Object.entries(t).forEach((([t,s])=>{if(e.includes(t.toLowerCase())){o.set(t,s)}}))}}if(_t.hasStandardBrowserEnv){i&&ht.isFunction(i)&&(i=i(e));if(i||i!==false&&de(e.url)){const t=n&&r&&pe.read(r);if(t){o.set(n,t)}}}return e};const ve=typeof XMLHttpRequest!=="undefined";var xe=ve&&function(t){return new Promise((function e(s,i){const n=ye(t);let r=n.data;const o=se.from(n.headers).normalize();let{responseType:a,onUploadProgress:h,onDownloadProgress:c}=n;let l;let u,f;let d,p;function g(){d&&d();p&&p();n.cancelToken&&n.cancelToken.unsubscribe(l);n.signal&&n.signal.removeEventListener("abort",l)}let m=new XMLHttpRequest;m.open(n.method.toUpperCase(),n.url,true);m.timeout=n.timeout;function w(){if(!m){return}const e=se.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());const n=!a||a==="text"||a==="json"?m.responseText:m.response;const r={data:n,status:m.status,statusText:m.statusText,headers:e,config:t,request:m};oe((function t(e){s(e);g()}),(function t(e){i(e);g()}),r);m=null}if("onloadend"in m){m.onloadend=w}else{m.onreadystatechange=function t(){if(!m||m.readyState!==4){return}if(m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)){return}setTimeout(w)}}m.onabort=function e(){if(!m){return}i(new ct("Request aborted",ct.ECONNABORTED,t,m));m=null};m.onerror=function e(s){const n=s&&s.message?s.message:"Network Error";const r=new ct(n,ct.ERR_NETWORK,t,m);r.event=s||null;i(r);m=null};m.ontimeout=function e(){let s=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const r=n.transitional||Ct;if(n.timeoutErrorMessage){s=n.timeoutErrorMessage}i(new ct(s,r.clarifyTimeoutError?ct.ETIMEDOUT:ct.ECONNABORTED,t,m));m=null};r===undefined&&o.setContentType(null);if("setRequestHeader"in m){ht.forEach(o.toJSON(),(function t(e,s){m.setRequestHeader(s,e)}))}if(!ht.isUndefined(n.withCredentials)){m.withCredentials=!!n.withCredentials}if(a&&a!=="json"){m.responseType=n.responseType}if(c){[f,p]=le(c,true);m.addEventListener("progress",f)}if(h&&m.upload){[u,d]=le(h);m.upload.addEventListener("progress",u);m.upload.addEventListener("loadend",d)}if(n.cancelToken||n.signal){l=e=>{if(!m){return}i(!e||e.type?new re(null,t,m):e);m.abort();m=null};n.cancelToken&&n.cancelToken.subscribe(l);if(n.signal){n.signal.aborted?l():n.signal.addEventListener("abort",l)}}const b=ae(n.url);if(b&&_t.protocols.indexOf(b)===-1){i(new ct("Unsupported protocol "+b+":",ct.ERR_BAD_REQUEST,t));return}m.send(r||null)}))};const ke=(t,e)=>{const{length:s}=t=t?t.filter(Boolean):[];if(e||s){let s=new AbortController;let i;const n=function(t){if(!i){i=true;o();const e=t instanceof Error?t:this.reason;s.abort(e instanceof ct?e:new re(e instanceof Error?e.message:e))}};let r=e&&setTimeout((()=>{r=null;n(new ct(`timeout ${e} of ms exceeded`,ct.ETIMEDOUT))}),e);const o=()=>{if(t){r&&clearTimeout(r);r=null;t.forEach((t=>{t.unsubscribe?t.unsubscribe(n):t.removeEventListener("abort",n)}));t=null}};t.forEach((t=>t.addEventListener("abort",n)));const{signal:a}=s;a.unsubscribe=()=>ht.asap(o);return a}};var Se=ke;const Me=function*(t,e){let s=t.byteLength;if(s<e){yield t;return}let i=0;let n;while(i<s){n=i+e;yield t.slice(i,n);i=n}};const Ce=async function*(t,e){for await(const s of Te(t)){yield*Me(s,e)}};const Te=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:t,value:s}=await e.read();if(t){break}yield s}}finally{await e.cancel()}};const Ee=(t,e,s,i)=>{const n=Ce(t,e);let r=0;let o;let a=t=>{if(!o){o=true;i&&i(t)}};return new ReadableStream({async pull(t){try{const{done:e,value:i}=await n.next();if(e){a();t.close();return}let o=i.byteLength;if(s){let t=r+=o;s(t)}t.enqueue(new Uint8Array(i))}catch(t){a(t);throw t}},cancel(t){a(t);return n.return()}},{highWaterMark:2})};const Pe=64*1024;const{isFunction:Ne}=ht;const De=(({Request:t,Response:e})=>({Request:t,Response:e}))(ht.global);const{ReadableStream:Ie,TextEncoder:Re}=ht.global;const Fe=(t,...e)=>{try{return!!t(...e)}catch(t){return false}};const Oe=t=>{t=ht.merge.call({skipUndefined:true},De,t);const{fetch:e,Request:s,Response:i}=t;const n=e?Ne(e):typeof fetch==="function";const r=Ne(s);const o=Ne(i);if(!n){return false}const a=n&&Ne(Ie);const h=n&&(typeof Re==="function"?(t=>e=>t.encode(e))(new Re):async t=>new Uint8Array(await new s(t).arrayBuffer()));const c=r&&a&&Fe((()=>{let t=false;const e=new s(_t.origin,{body:new Ie,method:"POST",get duplex(){t=true;return"half"}}).headers.has("Content-Type");return t&&!e}));const l=o&&a&&Fe((()=>ht.isReadableStream(new i("").body)));const u={stream:l&&(t=>t.body)};n&&(()=>{["text","arrayBuffer","blob","formData","stream"].forEach((t=>{!u[t]&&(u[t]=(e,s)=>{let i=e&&e[t];if(i){return i.call(e)}throw new ct(`Response type '${t}' is not supported`,ct.ERR_NOT_SUPPORT,s)})}))})();const f=async t=>{if(t==null){return 0}if(ht.isBlob(t)){return t.size}if(ht.isSpecCompliantForm(t)){const e=new s(_t.origin,{method:"POST",body:t});return(await e.arrayBuffer()).byteLength}if(ht.isArrayBufferView(t)||ht.isArrayBuffer(t)){return t.byteLength}if(ht.isURLSearchParams(t)){t=t+""}if(ht.isString(t)){return(await h(t)).byteLength}};const d=async(t,e)=>{const s=ht.toFiniteNumber(t.getContentLength());return s==null?f(e):s};return async t=>{let{url:n,method:o,data:a,signal:h,cancelToken:f,timeout:p,onDownloadProgress:g,onUploadProgress:m,responseType:w,headers:b,withCredentials:A="same-origin",fetchOptions:y}=ye(t);let v=e||fetch;w=w?(w+"").toLowerCase():"text";let x=Se([h,f&&f.toAbortSignal()],p);let k=null;const S=x&&x.unsubscribe&&(()=>{x.unsubscribe()});let M;try{if(m&&c&&o!=="get"&&o!=="head"&&(M=await d(b,a))!==0){let t=new s(n,{method:"POST",body:a,duplex:"half"});let e;if(ht.isFormData(a)&&(e=t.headers.get("content-type"))){b.setContentType(e)}if(t.body){const[e,s]=ue(M,le(fe(m)));a=Ee(t.body,Pe,e,s)}}if(!ht.isString(A)){A=A?"include":"omit"}const e=r&&"credentials"in s.prototype;const h={...y,signal:x,method:o.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:e?A:undefined};k=r&&new s(n,h);let f=await(r?v(k,y):v(n,h));const p=l&&(w==="stream"||w==="response");if(l&&(g||p&&S)){const t={};["status","statusText","headers"].forEach((e=>{t[e]=f[e]}));const e=ht.toFiniteNumber(f.headers.get("content-length"));const[s,n]=g&&ue(e,le(fe(g),true))||[];f=new i(Ee(f.body,Pe,s,(()=>{n&&n();S&&S()})),t)}w=w||"text";let C=await u[ht.findKey(u,w)||"text"](f,t);!p&&S&&S();return await new Promise(((e,s)=>{oe(e,s,{data:C,headers:se.from(f.headers),status:f.status,statusText:f.statusText,config:t,request:k})}))}catch(e){S&&S();if(e&&e.name==="TypeError"&&/Load failed|fetch/i.test(e.message)){throw Object.assign(new ct("Network Error",ct.ERR_NETWORK,t,k),{cause:e.cause||e})}throw ct.from(e,e&&e.code,t,k)}}};const $e=new Map;const _e=t=>{let e=t&&t.env||{};const{fetch:s,Request:i,Response:n}=e;const r=[i,n,s];let o=r.length,a=o,h,c,l=$e;while(a--){h=r[a];c=l.get(h);c===undefined&&l.set(h,c=a?new Map:Oe(e));l=c}return c};_e();const Be={http:ft,xhr:xe,fetch:{get:_e}};ht.forEach(Be,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const Le=t=>`- ${t}`;const Ue=t=>ht.isFunction(t)||t===null||t===false;function je(t,e){t=ht.isArray(t)?t:[t];const{length:s}=t;let i;let n;const r={};for(let o=0;o<s;o++){i=t[o];let s;n=i;if(!Ue(i)){n=Be[(s=String(i)).toLowerCase()];if(n===undefined){throw new ct(`Unknown adapter '${s}'`)}}if(n&&(ht.isFunction(n)||(n=n.get(e)))){break}r[s||"#"+o]=n}if(!n){const t=Object.entries(r).map((([t,e])=>`adapter ${t} `+(e===false?"is not supported by the environment":"is not available in the build")));let e=s?t.length>1?"since :\n"+t.map(Le).join("\n"):" "+Le(t[0]):"as no adapter specified";throw new ct(`There is no suitable adapter to dispatch the request `+e,"ERR_NOT_SUPPORT")}return n}var ze={getAdapter:je,adapters:Be};function He(t){if(t.cancelToken){t.cancelToken.throwIfRequested()}if(t.signal&&t.signal.aborted){throw new re(null,t)}}function We(t){He(t);t.headers=se.from(t.headers);t.data=ie.call(t,t.transformRequest);if(["post","put","patch"].indexOf(t.method)!==-1){t.headers.setContentType("application/x-www-form-urlencoded",false)}const e=ze.getAdapter(t.adapter||Wt.adapter,t);return e(t).then((function e(s){He(t);s.data=ie.call(t,t.transformResponse,s);s.headers=se.from(s.headers);return s}),(function e(s){if(!ne(s)){He(t);if(s&&s.response){s.response.data=ie.call(t,t.transformResponse,s.response);s.response.headers=se.from(s.response.headers)}}return Promise.reject(s)}))}const Ge="1.13.2";const Ve={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{Ve[t]=function s(i){return typeof i===t||"a"+(e<1?"n ":" ")+t}}));const Xe={};Ve.transitional=function t(e,s,i){function n(t,e){return"[Axios v"+Ge+"] Transitional option '"+t+"'"+e+(i?". "+i:"")}return(t,i,r)=>{if(e===false){throw new ct(n(i," has been removed"+(s?" in "+s:"")),ct.ERR_DEPRECATED)}if(s&&!Xe[i]){Xe[i]=true;console.warn(n(i," has been deprecated since v"+s+" and will be removed in the near future"))}return e?e(t,i,r):true}};Ve.spelling=function t(e){return(t,s)=>{console.warn(`${s} is likely a misspelling of ${e}`);return true}};function qe(t,e,s){if(typeof t!=="object"){throw new ct("options must be an object",ct.ERR_BAD_OPTION_VALUE)}const i=Object.keys(t);let n=i.length;while(n-- >0){const r=i[n];const o=e[r];if(o){const e=t[r];const s=e===undefined||o(e,r,t);if(s!==true){throw new ct("option "+r+" must be "+s,ct.ERR_BAD_OPTION_VALUE)}continue}if(s!==true){throw new ct("Unknown option "+r,ct.ERR_BAD_OPTION)}}}var Ye={assertOptions:qe,validators:Ve};const Je=Ye.validators;class Ke{constructor(t){this.defaults=t||{};this.interceptors={request:new Mt,response:new Mt}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const s=e.stack?e.stack.replace(/^.+\n/,""):"";try{if(!t.stack){t.stack=s}else if(s&&!String(t.stack).endsWith(s.replace(/^.+\n.+\n/,""))){t.stack+="\n"+s}}catch(t){}}throw t}}_request(t,e){if(typeof t==="string"){e=e||{};e.url=t}else{e=t||{}}e=Ae(this.defaults,e);const{transitional:s,paramsSerializer:i,headers:n}=e;if(s!==undefined){Ye.assertOptions(s,{silentJSONParsing:Je.transitional(Je.boolean),forcedJSONParsing:Je.transitional(Je.boolean),clarifyTimeoutError:Je.transitional(Je.boolean)},false)}if(i!=null){if(ht.isFunction(i)){e.paramsSerializer={serialize:i}}else{Ye.assertOptions(i,{encode:Je.function,serialize:Je.function},true)}}if(e.allowAbsoluteUrls!==undefined);else if(this.defaults.allowAbsoluteUrls!==undefined){e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls}else{e.allowAbsoluteUrls=true}Ye.assertOptions(e,{baseUrl:Je.spelling("baseURL"),withXsrfToken:Je.spelling("withXSRFToken")},true);e.method=(e.method||this.defaults.method||"get").toLowerCase();let r=n&&ht.merge(n.common,n[e.method]);n&&ht.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete n[t]}));e.headers=se.concat(r,n);const o=[];let a=true;this.interceptors.request.forEach((function t(s){if(typeof s.runWhen==="function"&&s.runWhen(e)===false){return}a=a&&s.synchronous;o.unshift(s.fulfilled,s.rejected)}));const h=[];this.interceptors.response.forEach((function t(e){h.push(e.fulfilled,e.rejected)}));let c;let l=0;let u;if(!a){const t=[We.bind(this),undefined];t.unshift(...o);t.push(...h);u=t.length;c=Promise.resolve(e);while(l<u){c=c.then(t[l++],t[l++])}return c}u=o.length;let f=e;while(l<u){const t=o[l++];const e=o[l++];try{f=t(f)}catch(t){e.call(this,t);break}}try{c=We.call(this,f)}catch(t){return Promise.reject(t)}l=0;u=h.length;while(l<u){c=c.then(h[l++],h[l++])}return c}getUri(t){t=Ae(this.defaults,t);const e=we(t.baseURL,t.url,t.allowAbsoluteUrls);return kt(e,t.params,t.paramsSerializer)}}ht.forEach(["delete","get","head","options"],(function t(e){Ke.prototype[e]=function(t,s){return this.request(Ae(s||{},{method:e,url:t,data:(s||{}).data}))}}));ht.forEach(["post","put","patch"],(function t(e){function s(t){return function s(i,n,r){return this.request(Ae(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}Ke.prototype[e]=s();Ke.prototype[e+"Form"]=s(true)}));var Qe=Ke;class Ze{constructor(t){if(typeof t!=="function"){throw new TypeError("executor must be a function.")}let e;this.promise=new Promise((function t(s){e=s}));const s=this;this.promise.then((t=>{if(!s._listeners)return;let e=s._listeners.length;while(e-- >0){s._listeners[e](t)}s._listeners=null}));this.promise.then=t=>{let e;const i=new Promise((t=>{s.subscribe(t);e=t})).then(t);i.cancel=function t(){s.unsubscribe(e)};return i};t((function t(i,n,r){if(s.reason){return}s.reason=new re(i,n,r);e(s.reason)}))}throwIfRequested(){if(this.reason){throw this.reason}}subscribe(t){if(this.reason){t(this.reason);return}if(this._listeners){this._listeners.push(t)}else{this._listeners=[t]}}unsubscribe(t){if(!this._listeners){return}const e=this._listeners.indexOf(t);if(e!==-1){this._listeners.splice(e,1)}}toAbortSignal(){const t=new AbortController;const e=e=>{t.abort(e)};this.subscribe(e);t.signal.unsubscribe=()=>this.unsubscribe(e);return t.signal}static source(){let t;const e=new Ze((function e(s){t=s}));return{token:e,cancel:t}}}var ts=Ze;function es(t){return function e(s){return t.apply(null,s)}}function ss(t){return ht.isObject(t)&&t.isAxiosError===true}const is={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(is).forEach((([t,e])=>{is[e]=t}));var ns=is;function rs(e){const s=new Qe(e);const i=t(Qe.prototype.request,s);ht.extend(i,Qe.prototype,s,{allOwnKeys:true});ht.extend(i,s,null,{allOwnKeys:true});i.create=function t(s){return rs(Ae(e,s))};return i}const os=rs(Wt);os.Axios=Qe;os.CanceledError=re;os.CancelToken=ts;os.isCancel=ne;os.VERSION=Ge;os.toFormData=bt;os.AxiosError=ct;os.Cancel=os.CanceledError;os.all=function t(e){return Promise.all(e)};os.spread=es;os.isAxiosError=ss;os.mergeConfig=Ae;os.AxiosHeaders=se;os.formToJSON=t=>jt(ht.isHTMLForm(t)?new FormData(t):t);os.getAdapter=ze.getAdapter;os.HttpStatusCode=ns;os.default=os;Sr=os;return Sr}var Tr=Cr();var Er=kr(Tr);const Pr={endpoints:{graphQL:"https://dypxviim4zgwtpev7valhchaem.appsync-api.eu-west-2.amazonaws.com/graphql"}};const Nr=t=>`\n mutation AddField {\n createTemplateElement(input: {\n templateId: "${t.templateId}", \n ax: ${t.ax}, \n ay: ${t.ay}, \n bx: ${t.bx}, \n by: ${t.by}, \n elementType: ${t?.signer!==0?JSON.stringify(t.elementType):JSON.stringify("admin")}, \n role: "1",\n label: ${JSON.stringify(t.label)}, \n page: ${t.page}, \n fieldOrder: ${t.fieldOrder}, \n fontName: ${JSON.stringify(t.fontName)}, \n fontSize: ${t.fontSize}, \n helpText: ${JSON.stringify(t.helpText)}, \n hideBorder: ${t.hideBorder}, \n logicGroup: ${JSON.stringify(t.logicGroup)}, \n mapTo: ${JSON.stringify(t.mapTo)}, \n optional: ${t.optional}, \n options: ${JSON.stringify(t.options)}, \n substantive: ${t.substantive}, \n validation: ${t.validation}, \n value: ${JSON.stringify(t.value)}, \n align: ${JSON.stringify(t.align)}, \n signer: ${t.signer}, \n logicAction: ${t.logicAction}, \n labelExtra: ${JSON.stringify(t.labelExtra)}})\n }`;const Dr=t=>`mutation ChangeField {\n updateTemplateElement(input: {\n templateElementId: "${t.id}", \n ax: ${t.ax}, \n ay: ${t.ay}, \n bx: ${t.bx}, \n by: ${t.by}, \n elementType: ${t?.signer!==0?JSON.stringify(t.elementType):JSON.stringify("admin")}, \n label: ${JSON.stringify(t.label)}, \n page: ${t.page}, \n fieldOrder: ${t.fieldOrder?t.fieldOrder:null}, \n fontName: ${JSON.stringify(t.fontName)}, \n fontSize: ${t.fontSize}, \n helpText: "${t.helpText}", \n hideBorder: ${t.hideBorder}, \n logicGroup: ${JSON.stringify(t.logicGroup)}, \n mapTo: "${t.mapTo}", \n optional: ${t.optional}, \n options: ${JSON.stringify(t.options)}, \n role: "1", \n substantive: ${t.substantive}, \n validation: ${t.validation==="0"?"null":t.validation}, \n value: "${t.value}", \n align: "${t.align}", \n signer: ${t.signer}, \n logicAction: ${t.logicAction}, \n labelExtra: "${t.labelExtra}"})\n}`;const Ir=t=>`mutation DeleteField {\n deleteTemplateElement(input: {\n templateElementId: "${t.id}"})\n }`;const Rr=t=>{const e=t?.signerParent?`"${t.signerParent}"`:"null";return`\n mutation LDVAddRole {\n createTemplateRole(input: {\n templateId: "${t.templateId}" \n signerIndex: ${t.signerIndex}\n signerParent: ${e}\n name: ${JSON.stringify(t.name)}\n ordinal: ${t.ordinal}\n roleType: ${t.roleType}\n experience: "${t.experience}"\n })\n }`};const Fr=t=>`\n mutation LDVremoveRole {\n deleteTemplateRole(input: {\n templateRoleId: "${t.id}" \n })\n }`;const Or=t=>{const e=t?.signerParent?`"${t.signerParent}"`:"null";return`\n mutation LDVupdateRole {\n updateTemplateRole(input: {\n templateRoleId: "${t.id}" \n signerIndex: ${t.signerIndex}\n ordinal: ${t.ordinal}\n signerParent: ${e}\n name: ${JSON.stringify(t.name)}\n roleType: ${t.roleType.toUpperCase()}\n experience: "${t.experience}"\n })\n }`};const $r=(t,e)=>`\n mutation LDVswapRole {\n swapRoles(input: {\n roleId1: "${t.id}" \n roleId2: "${e.id}"\n })\n }`;class _r{endpoint;constructor(t){this.endpoint=t}handleEvent=async(t,e)=>{Er.defaults.headers.common["Authorization"]=e;const s=t.data;if(!s?.id)return"invalid";const i=atob(s.id);if(i.length<3)return"invalid";const n=atob(s.id).substring(0,3);let r="";switch(n){case"ele":switch(t.action){case"create":console.log(s,t);r=Nr(c(s));break;case"update":r=Dr(c(s));break;case"delete":r=Ir(s);break}break;case"rol":switch(t.action){case"create":r=Rr(s);break;case"update":r=Or(s);break;case"delete":r=Fr(s);break;case"swap":console.log(s,t);r=$r(s,t.data2);break}break;case"tpl":switch(t.action){case"update":r=h(s);break}break}const o=await this.execute(e,r);return{result:o,obj:s,event:t}};async execute(t,e,s){if(t){const i=await Er.post(this.endpoint||Pr.endpoints.graphQL,{query:e,variables:s?s:{}},{headers:{Authorization:t}});return i.data.data}else{console.warn("UNASSIGNED ACCESS TOKEN")}return Promise.reject()}}const Br=t=>`\n query LDVgetGroupData {\n group(id: "${t}"){\n id \n standardMessageConnection{\n messages {\n id\n name\n default\n body\n created\n modified\n }\n }\n scheduleConnection {\n schedules {\n id\n name\n items {\n id\n daysAfter\n frequency\n subject\n message\n when\n timeOfDay\n skipWeekend\n }\n default\n }\n }\n experienceConnection{\n experiences {\n id\n name\n language\n defaultExperience\n witnessSameDevice\n allowSignatureReuse\n attachDraft\n canReassign\n defaultReminderSubject\n defaultSubject\n finalSignerEmailSubHeader\n finalSignerEmailText\n footerTextColour\n forwarding\n penDiameter\n postSignAttach\n postSignEmail\n rejectedEmailSubheader\n senderName\n signatureAppendDate\n signatureDoneText\n signatureMouse\n signatureType\n signatureCertifiedType\n signatureUpload\n signatureAppend\n signatureAppendExtra\n signingPageText\n textBackgroundColour\n textFontColour\n typedSignatureFixedSize\n created\n modified\n witnessingRequiresSignerSMS\n witnessingRequiresWitnessSMS\n }\n }\n attachmentConnection {\n attachments {\n id\n filename\n autoAttach\n description\n created\n }\n }\n contactConnection {\n contacts{\n id\n firstName\n lastName\n email\n phoneNumber\n name\n }\n }\n }\n }\n `;async function Lr(){const t=this.groupInfo.experienceConnection.experiences.find((t=>t.defaultExperience===true));const e=this._recipients.filter((t=>t.roleType!=="WITNESS")).map(((e,s)=>{const i=this._template.roles.filter((t=>t.roleType!=="WITNESS")).find((t=>t.signerIndex===e.signerIndex));const n=e?.roleType?e?.roleType:"SIGNER";if(!i||i===undefined){const i={id:btoa("rol"+crypto.randomUUID()),signerIndex:e?.signerIndex,name:e?.lastName||"Participant "+(s+1),roleType:n,ordinal:s+1,signerParent:null,experience:t?t.id:"",templateId:this._template.id};return this.adapter.execute(this.token,Rr(i)).then((t=>{this._template.roles=[...this._template.roles,{...i,id:t.createTemplateRole}]}))}else if(e.signerIndex===1&&e.roleType!==i.roleType){this.mutate.emit([{action:"update",data:{...i,roleType:e.roleType}}]);return Promise.resolve()}else{return Promise.resolve()}}));await Promise.all(e);await Ur.bind(this)(t);l.bind(this)().then((()=>{this.update.emit({event:{recipients:this._recipients},template:this._template})}))}async function Ur(t){const e=this._recipients.filter((t=>t.roleType==="WITNESS")).map((e=>{const s=this._template.roles.find((t=>t.signerIndex===e.signerIndex%100));const i=this._template.roles.find((t=>t.signerIndex===e.signerIndex));if(s&&s!==undefined&&(!i||i===undefined)){const i={id:btoa("rol"+crypto.randomUUID()),signerIndex:e?.signerIndex,name:s.name==="Participant "+s.ordinal?"Participant "+(s.ordinal+1):s.name+" Witness",roleType:"WITNESS",ordinal:s.ordinal+1,signerParent:s.id,experience:t?t.id:"",templateId:this._template.id};return this.adapter.execute(this.token,Rr(i)).then((t=>{this._template.roles=[...this._template.roles,{...i,id:t.createTemplateRole}]}))}else{return Promise.resolve()}}));await Promise.all(e)}const jr=()=>`*,*::before,*::after{box-sizing:border-box}*{margin:0}@media (prefers-reduced-motion: no-preference){html{interpolate-size:allow-keywords}}body{line-height:1.5;-webkit-font-smoothing:antialiased}img,picture,video,canvas,svg{display:block;max-width:100%}input,button,textarea,select{font:inherit}p,h1,h2,h3,h4,h5,h6{overflow-wrap:break-word}p{text-wrap:pretty}h1,h2,h3,h4,h5,h6{text-wrap:balance}#root,#__next{isolation:isolate}:host{display:flex;flex-direction:column;width:100%;height:100vh;position:relative;overflow:hidden;container-type:size;font-family:var(--font-family, "IBM Plex Sans", sans-serif);font-size:var(--text-sm);margin:0px;padding:0px}:host *{scrollbar-width:none}:host *::-webkit-scrollbar{display:none}.ls-dv-left-slot-wrapper{position:absolute;top:50%;left:0.675rem;transform:translateY(-50%);z-index:2000}slot{justify-content:center;align-items:center;border-radius:1rem;font-size:0.75rem;font-style:normal;font-weight:500;line-height:1.25rem;width:fit-content;background-color:var(--green-30, #9df5d4);color:var(--green-100, #125241)}.ls-dv-right-slot-wrapper{position:absolute;top:50%;right:0.675rem;transform:translateY(-50%);z-index:2000}.ls-dv-validation-tag-wrapper{position:absolute;top:1rem;right:1rem;z-index:2000;display:flex;width:100%;align-items:center;justify-content:center;padding:0.375rem;gap:0.5rem;width:fit-content;border-radius:1.25rem;border:1px solid var(--gray-20, #edeff2);background:var(--white, #ffffff);box-shadow:0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)}.ls-dv-page-loader{position:absolute;display:flex;top:0;left:0;align-items:center;justify-content:center;background-color:rgba(251, 251, 251, 0.3);backdrop-filter:blur(2px);height:100%;width:100%;z-index:4000}.ls-dv-custom-loader-slot{position:absolute;top:0;left:0;height:100%;width:100%;z-index:3999}#pdf-canvas{top:0px;left:0px;width:6.25rem;height:6.25rem;box-shadow:0 0.5rem 2rem 0 rgba(0, 0, 0, 0.12)}#ls-mid-area{position:absolute;top:0;left:0;display:flex;flex-direction:column;align-items:center;width:100%;height:100%;overflow:hidden}.ls-dv-document-frame-wrapper{display:flex;flex-direction:column;justify-content:start;align-items:start;overflow:visible;max-height:100%;width:100%;overflow:scroll;padding:5rem 23.75rem 2rem 23.75rem;position:relative;user-select:none;-webkit-user-select:none}.ls-dv-document-frame-wrapper--preview{align-items:center;padding:2rem}.ls-dv-select-menu-position{position:absolute;top:0;left:calc(100% + 0.5rem);z-index:999}.ls-dv-select-menu-floating{z-index:999;pointer-events:auto}#ls-document-frame{position:relative;height:98cqh;margin-right:auto;margin-left:auto}.ls-dv-prev-button{position:relative;bottom:1.875rem}.ls-dv-next-button{position:relative;bottom:1.875rem}.ls-dv-field-box{z-index:1000}#ls-box-selector{position:absolute;visibility:hidden;background-color:color-mix(in srgb, var(--primary-20, #c7ddff) 20%, transparent);border:1px dashed var(--primary-50, #5185ff)}#ls-drag-selector{position:absolute;visibility:hidden;background-color:color-mix(in srgb, var(--primary-20, #c7ddff) 20%, transparent);border:1px dashed var(--primary-50, #5185ff)}#ls-editor-form{display:flex;width:100%;height:calc(100cqh - 2.25rem);min-height:0;position:relative;overflow:hidden;background:var(--gray-10, #f7f8fa);box-shadow:0 2px 6px 0 rgba(0, 0, 0, 0.04) inset, 0 10px 15px 0 rgba(0, 0, 0, 0.04) inset}.ls-dv-hidden{visibility:hidden;display:none;width:0px}.ls-dv-page-header{position:relative;display:flex;height:2.25rem;gap:0.5rem;padding:0.25rem 0.75rem;justify-content:center;align-items:center}.ls-dv-header-text-1{color:var(--gray-100, #45484d);font-size:0.875rem;font-style:normal;font-weight:500;line-height:1.25rem}.ls-dv-header-text-2{color:var(--gray-100, #45484d);font-size:0.875rem;font-style:normal;font-weight:400;line-height:1.25rem}.ls-dv-expand-fields-row{display:flex;align-items:center;gap:0.5rem;padding:0.5rem;cursor:pointer;color:var(--gray-80, #6f7176);font-size:0.875rem;font-style:normal;font-weight:500;line-height:1.25rem;}.ls-dv-expand-fields-row p{color:var(--gray-100, #45484d);font-size:1rem;font-style:normal;font-weight:500;line-height:1.5rem;}p{color:var(--gray-80, #6f7176);font-family:var(--font-family);font-size:var(--text-sm);font-style:normal;font-weight:400;line-height:var(--text-sm-line-height)}a{color:var(--primary-60, #4456f6);font-size:var(--text-sm);font-style:normal;font-weight:400;line-height:var(--text-sm-line-height);cursor:pointer}a:hover{text-decoration:underline;color:var(--primary-70, #2134dc)}.ls-dv-button-link,.ls-dv-button-link:hover{all:unset}select{appearance:none;height:2.25rem}.ls-dv-input-wrapper{position:relative;width:fit-content}#selectorIcon{position:absolute;top:50%;right:0.675rem;transform:translateY(-50%);pointer-events:none;color:var(--gray-80, #6f7176)}#selectLeadingIcon{position:absolute;top:50%;left:0.675rem;transform:translateY(-50%);pointer-events:none;color:var(--gray-80, #6f7176)}.ls-dv-has-leading-icon{padding-left:2.5rem}input,select,textarea{border:1px solid var(--gray-40, #d8d9dc);box-shadow:0 1px 0.125rem rgba(0, 0, 0, 0.05);padding:0.5rem 0.75rem;font-family:var(--font-family);font-size:var(--text-sm);border-radius:0.625rem;color:var(--gray-100, #45484d);font-weight:400}input::placeholder,select::placeholder,textarea::placeholder{color:var(--gray-60, #afb0b2)}input:hover,select:hover,textarea:hover{border-color:var(--gray-50, #c8c9cc);background-color:var(--white, #ffffff)}input:focus,select:focus,textarea:focus{outline:none;box-shadow:0 0 0 0.25rem var(--primary-40, #79adfc);border-color:var(--primary-60, #4456f6);background-color:var(--white, #ffffff)}input:active,select:active,textarea:active{border-color:var(--primary-50, #5185ff)}input:disabled,select:disabled,textarea:disabled{cursor:not-allowed;background-color:var(--gray-10, #f7f8fa)}input[type=checkbox]{appearance:none;position:relative;height:1rem;width:1rem;padding:0.25rem;border-radius:var(--radius-sm);border:1px solid #d1d5db;background-color:#ffffff;cursor:pointer}input[type=checkbox]:checked,input[type=checkbox].ls-dv-indeterminate{background-color:var(--primary-60, #4456f6);border:none}input[type=checkbox]:checked::after{content:"";position:absolute;top:45%;left:50%;transform:translate(-50%, -50%) rotate(-45deg) scale(-1, 1);width:0.5rem;height:0.25rem;border-bottom:0.125rem solid white;border-right:0.125rem solid white}input[type=checkbox].ls-dv-indeterminate::after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);width:0.5rem;height:0.125rem;background-color:white}input[type=checkbox]:checked:hover,input[type=checkbox].ls-dv-indeterminate:hover{background-color:var(--primary-70, #2134dc);border:none}input[type=checkbox]:hover{border:1px solid #9ca3af}input[type=checkbox]:focus,input[type=checkbox]:active{outline:none;box-shadow:0 0 0 0.25rem var(--primary-20, #c7ddff);background-color:#f0f4f8}input[type=checkbox]:disabled{background-color:#f3f4f6;outline:none;cursor:not-allowed}input[type=checkbox]:disabled:checked{background-color:#e5e7eb;border:none;outline:none;cursor:not-allowed}.ls-dv-checkbox-container{display:flex;gap:0.5rem;width:100%}.ls-dv-checkbox-label{color:var(--gray-100, #45484d);font-size:1rem;font-style:normal;font-weight:400;line-height:1rem}.ls-dv-form-label{color:var(--gray-100, #45484d);font-size:1rem;font-style:normal;font-weight:500;line-height:1.5rem}.ls-dv-form-field{display:flex;flex-direction:column;gap:0.25rem;width:100%}.ls-dv-loading-box{display:flex;justify-content:center;align-items:center;width:100%;height:100%;color:var(--primary-60, #4456f6)}button{border:0;appearance:button;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;border-radius:var(--radius-lg);background-color:var(--primary-60, #4456f6);color:white;text-transform:capitalize;min-height:2.25rem;min-width:2.25rem}button.ls-dv-tertiary-grey{border:1px solid var(--gray-40, #d8d9dc);background-color:white;color:var(--gray-80, #6f7176)}button.ls-dv-tertiary-grey:hover{border:1px solid var(--gray-50, #c8c9cc);background:var(--gray-10, #f7f8fa)}.ls-dv-button-group{display:flex;border-radius:0.625rem;border:1px solid var(--gray-30, #e0e2e5);background:var(--white, #ffffff);overflow:clip}.ls-dv-button-group button{display:flex;background:transparent;border-radius:unset;padding:0.25rem 0.75rem;min-width:2.156rem;min-height:unset;color:var(--gray-80, #6f7176)}.ls-dv-button-group button:hover{background:var(--gray-10, #f7f8fa)}.ls-dv-button-group>:first-child{border-radius:0.625rem 0 0 0.625rem}.ls-dv-button-group>:last-child{border-radius:0 0.5rem 0.5rem 0}.ls-dv-button-group>:not(:first-child){border-left:1px solid var(--gray-30, #e0e2e5)}.ls-dv-error-state{position:absolute;display:flex;top:0;left:0;align-items:center;justify-content:center;height:100%;width:100%;z-index:4000;background-color:var(--gray-10, #f7f8fa)}.ls-dv-error-card{display:flex;flex-direction:column;align-items:center;gap:0.5rem;padding:2rem;border-radius:0.75rem;background:white;box-shadow:0 0.25rem 1rem rgba(0, 0, 0, 0.08);max-width:24rem;text-align:center;color:var(--gray-80, #6f7176)}.ls-dv-error-title{color:var(--gray-100, #45484d);font-size:1.125rem;font-weight:600;line-height:1.5rem}.ls-dv-error-message{color:var(--gray-80, #6f7176);font-size:0.875rem;line-height:1.25rem}`;if(typeof URL.parse!=="function"){URL.parse=function(t,e){try{return e?new URL(t,e):new URL(t)}catch{return null}}}ai.workerSrc=`https://unpkg.com/pdfjs-dist@5.4.449/build/pdf.worker.min.mjs`;const zr=class{constructor(s){t(this,s);this.pageRendered=e(this,"pageRendered",7);this.pageChange=e(this,"pageChange",7);this.selectFields=e(this,"selectFields",7);this.mutate=e(this,"mutate",7);this.update=e(this,"update",7);this.validate=e(this,"validate",7);this.addParticipant=e(this,"addParticipant",7)}get component(){return s(this)}isPageRendering;pdfDocument;pageNumPending=null;canvas;ctx;pageDimensions;isMoving=false;isBoxing=false;selectionBox=null;hitField;edgeSide;startLocations;startMouse;_isToolboxDragging=false;_cancelToolboxDrag=null;template;token;userpool;endpoint;templateid;recipients;_recipients;language;languageChanged(t){if(t){r.changeLanguage(t)}}zoom=1;pageNum=1;pageCount=1;signer=0;groupInfo;_template;validationErrors=[];status;error=null;errorTitle=null;fontSize=w;fontFamily=b;selected=[];isLoading=true;isMutating=false;selectedDataItems=[];fieldTypeSelected={label:"Signature",formElementType:"signature",elementType:"signature",validation:0,defaultHeight:27,defaultWidth:120};mode="editor";modeHandler(t,e){if(t==="preview"){this.showstatusbar=false;this.readonly=true}else if(t==="editor"){this.showstatusbar=true;this.readonly=false}else if(t==="compose"){this.showstatusbar=true;this.readonly=false}const s=this.component.shadowRoot?.querySelectorAll("ls-editor-field");if(s){s.forEach((e=>{e.setAttribute("readonly",String(t==="preview"))}))}}templateLockedHandler(){const t=this.component.shadowRoot?.querySelectorAll("ls-editor-field");if(t){t.forEach((t=>{t.setAttribute("readonly",String(this.mode==="preview"||this._template?.locked))}))}}zoomChanged(t){const e=this.component.shadowRoot.querySelectorAll("ls-editor-field");e.forEach((e=>e.setAttribute("zoom",String(t))));const s=this.component.shadowRoot.querySelector("ls-statusbar");if(s)s.zoom=t}manager="toolbox";displayTable=false;filtertoolbox=null;showstatusbar=false;showpagepreview=false;readonly=false;showtableview=false;toolboxFilter=null;pageRendered;pageChange;selectFields;mutate;update;validate;addParticipant;adapter;_skipHistory=false;mutateHandler(t){if(this.token&&this.adapter){const e=Array.isArray(t.detail)?t.detail:[t.detail];if(!this._skipHistory){const t=new Map;e.forEach((e=>{const s=e.data;if(e.action==="update"&&s?.id){const e=this.component.shadowRoot?.getElementById("ls-field-"+s.id);if(e?.dataItem){t.set(s.id,{...e.dataItem})}}else if(e.action==="delete"&&s?.id){const e=this.component.shadowRoot?.getElementById("ls-field-"+s.id);if(e?.dataItem){t.set(s.id,{...e.dataItem})}}}));I(e,t)}this._skipHistory=false;this.isMutating=true;const s=e.map((t=>this.adapter.handleEvent(t,this.token).then((e=>{if(e==="invalid")return;if(t.action==="update"&&t.data.roleType!=="WITNESS"){const e=t.data;const s=this._template.roles.find((t=>t.id===e.id));if(s&&s.name!==e.name){const t=this._template.roles.find((t=>t.signerParent===e.id&&t.roleType==="WITNESS"));if(t){const i=t.name==="Participant "+t.ordinal;const n=t.name===s.name+" Witness";if(i||n){const s={...t,name:e.name+" Witness"};this.adapter.handleEvent({action:"update",data:s},this.token).then((t=>{if(t!=="invalid")u.bind(this)(t)}))}}}}if(t.action==="swap"||t.action==="delete"){const s=t.action==="swap"?[{id:t.data.id,hadDefault:t.data.name==="Participant "+t.data.ordinal},{id:t.data2.id,hadDefault:t.data2.name==="Participant "+t.data2.ordinal}]:null;const i=t.action==="delete"?this._template.roles.filter((t=>t.name==="Participant "+t.ordinal)).map((t=>t.id)):null;return Promise.resolve(u.bind(this)(e)).then((()=>{const t=[];if(s){for(const{id:e,hadDefault:i}of s){if(!i)continue;const s=this._template.roles.find((t=>t.id===e));if(s&&s.name!=="Participant "+s.ordinal){t.push(this.adapter.handleEvent({action:"update",data:{...s,name:"Participant "+s.ordinal}},this.token).then((t=>{if(t!=="invalid")u.bind(this)(t)})))}}}if(i){for(const e of i){const s=this._template.roles.find((t=>t.id===e));if(s&&s.name!=="Participant "+s.ordinal){t.push(this.adapter.handleEvent({action:"update",data:{...s,name:"Participant "+s.ordinal}},this.token).then((t=>{if(t!=="invalid")u.bind(this)(t)})))}}}return Promise.all(t)}))}u.bind(this)(e)})).then((()=>this.syncChange(t)))));Promise.all(s).finally((()=>{requestAnimationFrame((()=>{this.isMutating=false}))}))}}updateHandler(t){const e=t.detail;if(!e||!Array.isArray(e)||e.length===0)return;t.stopPropagation();const s=t.target;const i=s?.tagName==="LS-EDITOR-FIELD";for(const t of e){if(t?.action==="update"&&t?.data?.id){const e=t.data;this.selectedDataItems=this.selectedDataItems.map((t=>t.id===e.id?{...e}:t));const s=this.component.shadowRoot.getElementById("ls-toolbar");if(s?.dataItem){s.dataItem=s.dataItem.map((t=>t.id===e.id?{...e}:t))}if(!i){const t=this.component.shadowRoot?.getElementById("ls-field-"+e.id);if(t){t.dataItem={...e}}}}}}handleFieldTypeSelected(t){const e=this.component.shadowRoot.querySelectorAll("ls-toolbox-field");e.forEach((e=>{e.isSelected=e.formElementType===t.detail.formElementType}));this.fieldTypeSelected=t.detail}handleToolboxDragStart(t){S.bind(this)(t.detail)}addParticpantHandler(t){const e=this.groupInfo.experienceConnection.experiences.find((t=>t.defaultExperience===true));const s=t.detail.signerIndex>99?this._template.roles.find((e=>e.signerIndex===t.detail.signerIndex%100)):null;const i=t.detail.type==="WITNESS"?s.signerIndex+100:Math.max(...this._template.roles.filter((t=>t.roleType!=="WITNESS")).map((t=>t.signerIndex)))+1;const n=t.detail.signerIndex?t.detail.signerIndex:t.detail.type==="WITNESS"?100+s?.signerIndex:this._template.roles.length===0?1:i;const r=[{action:"create",data:{id:btoa("rol"+crypto.randomUUID()),name:t.detail.name?t.detail.name:t.detail.type==="WITNESS"?s?.name==="Participant "+s?.ordinal?"Participant "+(s?.ordinal+1):s?.name+" Witness":"Participant "+(this._template.roles.length+1),roleType:t.detail.type,signerIndex:n,ordinal:t.detail.type==="WITNESS"?s?.ordinal+1:this._template.roles.length+1,signerParent:t.detail.parent,experience:e.id,templateId:this._template.id}}];this.mutate.emit(r);this.signer=n}updateSigner(t){if(t.detail){this.signer=t.detail}}selectFieldForPlacement(t){const{signerIndex:e,fieldType:s}=t.detail;this.signer=e;const i=A[s]||A["signature"];let n;if(s==="signature"){n="signature"}else if(s==="initials"){n="initials"}else if(s==="auto sign"){n="admin"}else{n="text"}this.fieldTypeSelected={label:s,formElementType:s,elementType:n,validation:0,defaultHeight:i.defaultHeight,defaultWidth:i.defaultWidth};if(this.manager!=="toolbox"){this.manager="toolbox"}requestAnimationFrame((()=>{S.bind(this)(this.fieldTypeSelected)}))}selectFieldsHandler(t){const e=Array.from(this.component.shadowRoot.querySelectorAll("ls-editor-field"));this._template={...this._template,elementConnection:{...this._template.elementConnection,templateElements:e.map((t=>t.dataItem))}};var s=this.component.shadowRoot.getElementById("ls-toolbar");if(s){s.dataItem=t.detail}if(t.detail.length===0){this.selected=[]}else{console.log(t.detail,"selected");this.selectedDataItems=t.detail}const i=t.detail.length>1;e.forEach((t=>{t.selected=false;t.multiSelected=false}));t.detail.forEach((t=>{const e=this.component.shadowRoot.getElementById("ls-field-"+t.id);if(e){e.selected=true;e.multiSelected=i}}));this.selected=e.filter((t=>t.selected));if(t.detail.length===1){const e=this.component.shadowRoot.getElementById("ls-field-"+t.detail[0].id);if(e&&f(t.detail[0].validation)?.inputType==="date"&&this.mode!=="preview"){requestAnimationFrame((()=>{const t=e.shadowRoot?.getElementById("editing-input");if(t)t.showPicker()}))}}k.bind(this)();this.validationErrors=d.bind(this)(this._template)}roleHandler(t){this.signer=t.detail}async pageNext(){if(this.pageNum>=this.pdfDocument.numPages){return}this.pageNum+=1;this.queueRenderPage(this.pageNum);this.showPageFields(this.pageNum);this.pageResize();k.bind(this)()}async pagePrev(){if(this.pageNum<=1){return}this.pageNum-=1;this.queueRenderPage(this.pageNum);this.showPageFields(this.pageNum);this.pageResize();k.bind(this)()}async unselect(){const t=this.component.shadowRoot.querySelectorAll("ls-editor-field");t.forEach((t=>{t.selected=false}));this.selected=[];k.bind(this)()}pageResize(){this.canvas=this.component.shadowRoot.getElementById("pdf-canvas");const t=this.component.shadowRoot.getElementById("ls-document-frame");this.canvas.style.height=this.pageDimensions[this.pageNum-1].height*this.zoom+"px";this.canvas.style.width=this.pageDimensions[this.pageNum-1].width*this.zoom+"px";t.style.height=this.pageDimensions[this.pageNum-1].height*this.zoom+"px";t.style.width=this.pageDimensions[this.pageNum-1].width*this.zoom+"px"}async setZoom(t){this.zoom=t;this.pageResize();this.component.shadowRoot.querySelectorAll("ls-editor-field").forEach((t=>a.bind(this)(t,t.dataItem)));this.queueRenderPage(this.pageNum);this.showPageFields(this.pageNum);k.bind(this)()}clip(t,e=0){return t>1?e:t}parseTemplate(t){const e=JSON.parse(t);const s=JSON.parse(JSON.parse(e.pageDimensions));this.pageDimensions=s.map((t=>({height:t[1],width:t[0]})));const i=e.elementConnection.templateElements.map((t=>({...t,top:Math.floor(this.clip(t.ay)*this.pageDimensions[0].height),left:Math.floor(this.clip(t.ax)*this.pageDimensions[0].width),height:Math.floor((this.clip(t.by,.1)-this.clip(t.ay))*this.pageDimensions[0].height),width:Math.floor((this.clip(t.bx,.2)-this.clip(t.ax))*this.pageDimensions[0].width),templateId:e.id})));const n=e.roles.map((t=>({...t,templateId:e.id})));const r=n.some((t=>t.signerIndex===this.signer));if(!r){this.signer=n.length>0?1:0}this._template={...e,elementConnection:{...e.elementConnection,templateElements:i},roles:n}}RENDER_SCALE=2;renderPage(t){this.isPageRendering=true;if(this.pdfDocument!==undefined&&this.pdfDocument!==null){this.pdfDocument.getPage(t).then((t=>{const e=t.getViewport({scale:this.zoom*this.RENDER_SCALE});this.canvas.height=Math.floor(e.height);this.canvas.width=Math.floor(e.width);this.canvas.style.width=Math.floor(this.pageDimensions[this.pageNum-1].width*this.zoom)+"px";this.canvas.style.height=Math.floor(this.pageDimensions[this.pageNum-1].height*this.zoom)+"px";const s={canvasContext:this.ctx,viewport:e};const i=t.render(s);i.promise.then((()=>{this.isPageRendering=false;this.pageRendered.emit(this.pageNum);if(this.pageNumPending!==null){this.renderPage(this.pageNumPending);this.pageChange.emit(this.pageNumPending);this.pageNumPending=null}}))}))}}queueRenderPage(t){if(this.isPageRendering){this.pageNumPending=t}else{this.renderPage(t)}}loadAndRender(t){Gi(t).promise.then((t=>{this.pdfDocument=t;this.renderPage(this.pageNum)}))}prepareElement(t){return{...t,top:Math.floor(this.clip(t.ay)*this.pageDimensions[t.page-1].height),left:Math.floor(this.clip(t.ax)*this.pageDimensions[t.page-1].width),height:Math.floor((this.clip(t.by,.05)-this.clip(t.ay))*this.pageDimensions[t.page-1].height),width:Math.floor((this.clip(t.bx,.2)-this.clip(t.ax))*this.pageDimensions[t.page-1].width),pageDimensions:this.pageDimensions[t.page-1],templateId:this._template.id}}syncChange(t){if(t?.select==="clear"){this.unselect()}if(p(t.data)==="element"){if(t.action==="create");else if(t.action==="update"){const e=this.component.shadowRoot.getElementById("ls-field-"+t.data.id);if(e){a.bind(this)(e,t.data);const s=t.data.signer;const i=this.mode==="compose"?this._recipients?.find((t=>t.signerIndex===s)):this._template.roles.find((t=>t.signerIndex===s));e.setAttribute("assignee",s===0?"Sender":this.mode==="compose"&&i?.previousRecipientDecides===true?"To Be Decided":this.mode==="compose"?`${i?.firstName} ${i?.lastName}`:i?.name||`Participant ${s}`);this.selected=this.selected.map((s=>s.dataItem.id===t.data.id?e:s))}const s=this.component.shadowRoot.querySelectorAll("ls-editor-field");this.selected=Array.from(s).filter((t=>t.selected));this.selectedDataItems=this.selected.map((t=>t.dataItem));const i=this.component.shadowRoot.getElementById("ls-toolbar");if(i)i.dataItem=this.selectedDataItems;this._template={...this._template,elementConnection:{...this._template.elementConnection,templateElements:Array.from(s).map((t=>t.dataItem))}};this.selectedDataItems=this.selected.map((t=>t.dataItem));if(i)i.dataItem=this.selectedDataItems;k.bind(this)()}else if(t.action==="delete"){const e=this.component.shadowRoot.getElementById("ls-field-"+t.data.id);if(!e)return;const s=this._template.elementConnection.templateElements;this._template={...this._template,elementConnection:{...this._template.elementConnection,templateElements:s.filter((e=>e.id!==t.data.id))}};this.component.shadowRoot.getElementById("ls-document-frame").removeChild(e);this.selectFields.emit([])}else{console.warn("Unrecognised action, check Legalesign documentation. `create`, `update` and `delete` allowed.")}}this.validationErrors=d.bind(this)(this._template);this.validate.emit({valid:this.validationErrors.length===0,errors:this.validationErrors})}initViewer(){this.canvas=this.component.shadowRoot.getElementById("pdf-canvas");this.canvas.style.height=this.pageDimensions[this.pageNum-1].height*this.zoom+"px";this.canvas.style.width=this.pageDimensions[this.pageNum-1].width*this.zoom+"px";this.ctx=this.canvas.getContext("2d");if(this._template?.link)this.loadAndRender(this._template?.link);var t=this.component.shadowRoot.getElementById("ls-document-frame");var e=this.component.shadowRoot.getElementById("document-frame-wrapper");if(this.mode!=="preview"||this._template?.locked===true){t.addEventListener("click",M.bind(this));e.addEventListener("mousedown",C.bind(this));document.addEventListener("mousemove",T.bind(this));document.addEventListener("mouseup",E.bind(this));t.addEventListener("dblclick",P.bind(this));document.addEventListener("keydown",wr.bind(this))}const s=this.component.shadowRoot.getElementById("document-frame-wrapper");s.addEventListener("wheel",(t=>{if(!t.ctrlKey&&!t.metaKey)return;t.preventDefault();const e=t.deltaY>0?.95:1.05;const i=Math.min(Math.max(this.zoom*e,.25),5);const n=i/this.zoom;const r=s.getBoundingClientRect();const o=t.clientX-r.left;const a=t.clientY-r.top;s.scrollLeft=(s.scrollLeft+o)*n-o;s.scrollTop=(s.scrollTop+a)*n-a;this.setZoom(Math.round(i*100)/100)}),{passive:false});this.generateFields()}generateFields(t=true){if(t){const t=this.component.shadowRoot.querySelectorAll("ls-editor-field");t.forEach((t=>this.component.shadowRoot.getElementById("ls-document-frame").removeChild(t)))}const e=[...this._template.elementConnection.templateElements];this._template={...this._template,elementConnection:{...this._template.elementConnection,templateElements:[]}};e.forEach((t=>{g.bind(this)(this.component.shadowRoot.getElementById("ls-document-frame"),this.prepareElement(t))}))}showPageFields(t){const e=this.component.shadowRoot.querySelectorAll("ls-editor-field");Array.from(e).forEach((e=>{e.className=e.dataItem.page===t?"":"ls-dv-hidden";const s=e.dataItem;const i=this.mode==="compose"?this._recipients?.find((t=>t.signerIndex===s.signer)):this._template.roles.find((t=>t.signerIndex===s.signer));e.setAttribute("assignee",this.mode==="compose"&&i?.previousRecipientDecides===true?"To Be Decided":this.mode==="compose"?`${i?.firstName} ${i?.lastName}`:i?.name||`Participant ${s.signer}`)}))}async load(){this.isLoading=true;try{this.adapter=new _r(this.endpoint);const t=await this.adapter.execute(this.token,m(this.templateid));this.parseTemplate(JSON.stringify(t.template));const e=await this.adapter.execute(this.token,Br(this._template.groupId));this.groupInfo=e.group;this.initViewer();if(this.mode==="compose"){this.manager="recipient";if(!this.recipients){throw new Error('Compose mode requires a "recipients" attribute. See documentation for the expected JSON format.')}this._recipients=JSON.parse(this.recipients.replace('"','"')).sort(((t,e)=>{const s=t.signerIndex%100||100;const i=e.signerIndex%100||100;if(s!==i)return s-i;if(t.signerIndex<100&&e.signerIndex>=100)return-1;if(t.signerIndex>=100&&e.signerIndex<100)return 1;return t.signerIndex-e.signerIndex}));Lr.bind(this)()}this.validationErrors=d.bind(this)(this._template);this.validate.emit({valid:this.validationErrors.length===0,errors:this.validationErrors});this.pageCount=this._template.pageCount;this.selected=[];this.setZoom(1);this.isLoading=false;if(this.mode==="preview"){requestAnimationFrame((()=>{const t=this.component.shadowRoot.getElementById("ls-mid-area");const e=this.component.shadowRoot.getElementById("document-frame-wrapper");const s=getComputedStyle(e);const i=parseFloat(s.paddingTop)+parseFloat(s.paddingBottom);const n=parseFloat(s.paddingLeft)+parseFloat(s.paddingRight);const r=t.clientHeight-i;const o=t.clientWidth-n;const a=r/this.pageDimensions[this.pageNum-1].height;const h=o/this.pageDimensions[this.pageNum-1].width;const c=Math.min(a,h);this.setZoom(Math.round(c*100)/100)}))}}catch(t){this.isLoading=false;const e=t?.message?.includes("401")||t?.message?.includes("403")||t?.message?.includes("Unauthorized")||t?.status===401||t?.status===403;if(e){console.error("Authentication failed.",t);this.errorTitle=r.t("viewer.autherror");this.error=r.t("viewer.autherrormessage")}else{console.error("Failed to load template.",t?.message||t);this.errorTitle=r.t("viewer.loaderror");this.error=r.t("viewer.loaderrormessage")}}}componentWillLoad(){if(this.language){r.changeLanguage(this.language)}if(this.token&&!this._template)this.load()}componentDidLoad(){}handleManagerChange(t){this.manager=t}showTool(t){return this.filtertoolbox===null||this.filtertoolbox.split("|").includes(t)}checkType(t){if(this.mode==="compose"&&this._recipients){return this._recipients.find((e=>e.roleType===t&&e.signerIndex===this.signer))!==undefined}else if(this._template){return this._template.roles.find((e=>e.roleType===t&&e.signerIndex===this.signer))!==undefined}else return false}render(){return i(n,{key:"860cd3fd7e20869384201d6ca1d8fe17d5638141"},i(i.Fragment,null,this.isLoading&&i(i.Fragment,null,i("div",{key:"b543e09d6b34e2127eaa9451c6abb53101077131",class:"ls-dv-page-loader"},i("ls-loading-logo",{key:"a62b12fd4514dd46dfbde408a9b6d76ba9d4465f",size:200,colour:"var(--primary-60)"})),i("div",{key:"8c17f0fbab08d3c347cda885eb21aab179c9b1d3",class:"ls-dv-custom-loader-slot"},i("slot",{key:"4bf044a2d0f8daef3fec53c9d5d71f434a105f53",name:"custom-loader"})),this.mode==="compose"&&i("ls-compose-loader",{key:"29162cdf93d3868c8e56f7c292fd7b025ab713e5"})),this.error&&i("div",{key:"346bc38cfd1ef9734d2c38d563abbd8112402218",class:"ls-dv-error-state"},i("div",{key:"5bd9a7b89d0f862529926a80558d452aa8421981",class:"ls-dv-error-card"},i("ls-icon",{key:"7043cf0749ad888043e66427782f4a90a8978b53",name:"exclamation-circle-icon",size:32,style:{color:"var(--red-60, #dc2626)"}}),i("p",{key:"0775d103d12c28b8c95322ab98a6d6adebaa59ff",class:"ls-dv-error-title"},this.errorTitle),i("p",{key:"1edb7c8c8c7ab1acf5271a9d8cda3c8a27e42739",class:"ls-dv-error-message"},this.error))),i("div",{key:"a0e3d21e7de86d4423f4230989879f6a36df67d0",class:"ls-dv-page-header"},i("div",{key:"cd7f76a0fec9a60732c476562ed8e6e312c4b873",class:"ls-dv-left-slot-wrapper"},i("slot",{key:"73e33dfd81af6c7dd83ed8575a33bc89bf8d7838",name:"left-button"})),i("div",{key:"40827dbe7a4ca60282decd71c5f90085a05327bd",class:"ls-dv-right-slot-wrapper"},i("slot",{key:"ea5c16102e3214a30bb08d2c67a264d7278dbadf",name:"right-button"})),this.mode==="editor"&&i("div",{key:"dc8e8a4d140d1a90e5cbc5d3e010f1696db60c2e"},i("span",{key:"98f5de4a80ea7139f4e8e8c4eb1d7aad4c61678f",class:"ls-dv-header-text-1"},r.t("viewer.templatecreation")),i("span",{key:"4419f356598f25ab81a95f2e8b0d7600388bd774"},"/"),i("span",{key:"d277f171dc721460a30b603d119666937dfe1e49",class:"ls-dv-header-text-2"},this._template?.title)),this.mode==="compose"&&i("div",{key:"0cb45f674738b7416107f63b2409546d543d09a1",style:{display:"flex",alignItems:"center",gap:"0.25rem"}},i("slot",{key:"7b44d20a1fb7e6e17e5cb02b72c78d0900731add",name:"top-bar"}))),i("form",{key:"953cbb0445b52accdec5b1be92df3708ca076175",id:"ls-editor-form"},i("ls-left-bar",{key:"30869afb5260ecc4b17da3c85ec52eb9e69ca0da",mode:this.mode,selected:this.selected,manager:this.manager,signer:this.signer,filtertoolbox:this.filtertoolbox,template:this._template,recipients:this._recipients,validationErrors:this.validationErrors,fieldTypeSelected:this.fieldTypeSelected,displayTable:this.displayTable,selectedDataItems:this.selectedDataItems,busy:this.isMutating,onManagerChange:t=>this.handleManagerChange(t.detail),onClearSelected:()=>{this.unselect();const t=this.component.shadowRoot.getElementById("ls-toolbar");if(t)t.dataItem=[]}},i("slot",{key:"1cba234c80522e520b72a97be5ca13401ecfdb46",name:"recipient-panel",slot:"recipient-panel"})),i("ls-toolbar",{key:"6058bad4036b41dc01a088a33e81f099b068048f",id:"ls-toolbar",template:this._template,editor:this,groupInfo:this.groupInfo,mode:this.mode,signer:this.signer,selected:this.selected,pageNum:this.pageNum}),i("div",{key:"a8f49c80504596b13efc1d011f7512e238e088fe",id:"ls-mid-area"},i("div",{key:"83ea2d2cb6f16e945ce74cf00b8a390b93a6138a",class:{"ls-dv-document-frame-wrapper":true,"ls-dv-document-frame-wrapper--preview":this.mode==="preview"},id:"document-frame-wrapper"},i("div",{key:"27403196c0d0e3239c7cc2f7557de11e2fac89e7",id:"ls-document-frame"},i("canvas",{key:"12cdbc91cee0737d591467103bb799d83dd62a26",id:"pdf-canvas",class:this.displayTable||this.isLoading?"ls-dv-hidden":""}),i("ls-editor-table",{key:"150abecd949e8e344faf2db3b4f6c760eae95bbf",editor:this,class:this.displayTable?"":"ls-dv-hidden"}),i("div",{key:"0ce247fe481228dfcf46e1d05970d2f6e8cdf4fe",id:"ls-box-selector"}),i("div",{key:"b9be890d750a90b603bf72caae3a9d176382c69e",id:"ls-drag-selector"}),this.mode!=="preview"&&!this._template?.locked&&!this.isLoading&&this._template?.elementConnection?.templateElements?.length>0&&i("ls-select-menu",{key:"508851cee2bd2c5f51169e1bd3171f94839bc2b3",class:"ls-dv-select-menu-position",selected:this.selected,pageNum:this.pageNum,editor:this}),this.mode!=="preview"&&!this._template?.locked&&!this.isLoading&&this._template?.elementConnection?.templateElements?.length>0&&i("ls-select-menu",{key:"582b78b270ed8f794658af9647d93fef2fb6b0a3",class:"ls-dv-select-menu-floating",selected:this.selected,pageNum:this.pageNum,editor:this,floating:true}))),i("ls-statusbar",{key:"c2c0a7542db9101428faa59a4369dd0913df432f",editor:this,page:this.pageNum,pageCount:this.pageCount,mode:this.mode}),this.mode==="editor"&&i("div",{key:"57eabe80828180fd028d20d89e923a35a262a1b9",class:"ls-dv-validation-tag-wrapper"},i("ls-validation-tag",{key:"3e5094b053dabc1e9b19326cbb07a9caf630aaaf",validationErrors:this.validationErrors}),i("slot",{key:"bf6bc50cd88394f79676a13a1f3c3e5148f10a19",name:"next-button"}))))),i("ls-tooltip",{key:"b787041d5d5b1a3e7d6e10020ff61ce5c262a2e7",tooltipId:"ls-dv-tooltip"}))}static get watchers(){return{language:["languageChanged"],mode:["modeHandler"],_template:["templateLockedHandler"],zoom:["zoomChanged"]}}};zr.style=jr();export{zr as ls_document_viewer};
24
- //# sourceMappingURL=p-c2be13de.entry.js.map
23
+ /*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors */var Sr;var Mr;function Cr(){if(Mr)return Sr;Mr=1;function t(t,e){return function s(){return t.apply(e,arguments)}}const{toString:e}=Object.prototype;const{getPrototypeOf:s}=Object;const{iterator:i,toStringTag:n}=Symbol;const r=(t=>s=>{const i=e.call(s);return t[i]||(t[i]=i.slice(8,-1).toLowerCase())})(Object.create(null));const o=t=>{t=t.toLowerCase();return e=>r(e)===t};const a=t=>e=>typeof e===t;const{isArray:h}=Array;const c=a("undefined");function l(t){return t!==null&&!c(t)&&t.constructor!==null&&!c(t.constructor)&&p(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const u=o("ArrayBuffer");function f(t){let e;if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){e=ArrayBuffer.isView(t)}else{e=t&&t.buffer&&u(t.buffer)}return e}const d=a("string");const p=a("function");const g=a("number");const m=t=>t!==null&&typeof t==="object";const w=t=>t===true||t===false;const b=t=>{if(r(t)!=="object"){return false}const e=s(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(n in t)&&!(i in t)};const A=t=>{if(!m(t)||l(t)){return false}try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch(t){return false}};const y=o("Date");const v=o("File");const x=o("Blob");const k=o("FileList");const S=t=>m(t)&&p(t.pipe);const M=t=>{let e;return t&&(typeof FormData==="function"&&t instanceof FormData||p(t.append)&&((e=r(t))==="formdata"||e==="object"&&p(t.toString)&&t.toString()==="[object FormData]"))};const C=o("URLSearchParams");const[T,E,P,N]=["ReadableStream","Request","Response","Headers"].map(o);const D=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function I(t,e,{allOwnKeys:s=false}={}){if(t===null||typeof t==="undefined"){return}let i;let n;if(typeof t!=="object"){t=[t]}if(h(t)){for(i=0,n=t.length;i<n;i++){e.call(null,t[i],i,t)}}else{if(l(t)){return}const n=s?Object.getOwnPropertyNames(t):Object.keys(t);const r=n.length;let o;for(i=0;i<r;i++){o=n[i];e.call(null,t[o],o,t)}}}function R(t,e){if(l(t)){return null}e=e.toLowerCase();const s=Object.keys(t);let i=s.length;let n;while(i-- >0){n=s[i];if(e===n.toLowerCase()){return n}}return null}const F=(()=>{if(typeof globalThis!=="undefined")return globalThis;return typeof self!=="undefined"?self:typeof window!=="undefined"?window:xr})();const O=t=>!c(t)&&t!==F;function $(){const{caseless:t,skipUndefined:e}=O(this)&&this||{};const s={};const i=(i,n)=>{const r=t&&R(s,n)||n;if(b(s[r])&&b(i)){s[r]=$(s[r],i)}else if(b(i)){s[r]=$({},i)}else if(h(i)){s[r]=i.slice()}else if(!e||!c(i)){s[r]=i}};for(let t=0,e=arguments.length;t<e;t++){arguments[t]&&I(arguments[t],i)}return s}const _=(e,s,i,{allOwnKeys:n}={})=>{I(s,((s,n)=>{if(i&&p(s)){e[n]=t(s,i)}else{e[n]=s}}),{allOwnKeys:n});return e};const B=t=>{if(t.charCodeAt(0)===65279){t=t.slice(1)}return t};const L=(t,e,s,i)=>{t.prototype=Object.create(e.prototype,i);t.prototype.constructor=t;Object.defineProperty(t,"super",{value:e.prototype});s&&Object.assign(t.prototype,s)};const U=(t,e,i,n)=>{let r;let o;let a;const h={};e=e||{};if(t==null)return e;do{r=Object.getOwnPropertyNames(t);o=r.length;while(o-- >0){a=r[o];if((!n||n(a,t,e))&&!h[a]){e[a]=t[a];h[a]=true}}t=i!==false&&s(t)}while(t&&(!i||i(t,e))&&t!==Object.prototype);return e};const j=(t,e,s)=>{t=String(t);if(s===undefined||s>t.length){s=t.length}s-=e.length;const i=t.indexOf(e,s);return i!==-1&&i===s};const z=t=>{if(!t)return null;if(h(t))return t;let e=t.length;if(!g(e))return null;const s=new Array(e);while(e-- >0){s[e]=t[e]}return s};const H=(t=>e=>t&&e instanceof t)(typeof Uint8Array!=="undefined"&&s(Uint8Array));const W=(t,e)=>{const s=t&&t[i];const n=s.call(t);let r;while((r=n.next())&&!r.done){const s=r.value;e.call(t,s[0],s[1])}};const G=(t,e)=>{let s;const i=[];while((s=t.exec(e))!==null){i.push(s)}return i};const V=o("HTMLFormElement");const X=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function t(e,s,i){return s.toUpperCase()+i}));const q=(({hasOwnProperty:t})=>(e,s)=>t.call(e,s))(Object.prototype);const Y=o("RegExp");const J=(t,e)=>{const s=Object.getOwnPropertyDescriptors(t);const i={};I(s,((s,n)=>{let r;if((r=e(s,n,t))!==false){i[n]=r||s}}));Object.defineProperties(t,i)};const K=t=>{J(t,((e,s)=>{if(p(t)&&["arguments","caller","callee"].indexOf(s)!==-1){return false}const i=t[s];if(!p(i))return;e.enumerable=false;if("writable"in e){e.writable=false;return}if(!e.set){e.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")}}}))};const Q=(t,e)=>{const s={};const i=t=>{t.forEach((t=>{s[t]=true}))};h(t)?i(t):i(String(t).split(e));return s};const Z=()=>{};const tt=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function et(t){return!!(t&&p(t.append)&&t[n]==="FormData"&&t[i])}const st=t=>{const e=new Array(10);const s=(t,i)=>{if(m(t)){if(e.indexOf(t)>=0){return}if(l(t)){return t}if(!("toJSON"in t)){e[i]=t;const n=h(t)?[]:{};I(t,((t,e)=>{const r=s(t,i+1);!c(r)&&(n[e]=r)}));e[i]=undefined;return n}}return t};return s(t,0)};const it=o("AsyncFunction");const nt=t=>t&&(m(t)||p(t))&&p(t.then)&&p(t.catch);const rt=((t,e)=>{if(t){return setImmediate}return e?((t,e)=>{F.addEventListener("message",(({source:s,data:i})=>{if(s===F&&i===t){e.length&&e.shift()()}}),false);return s=>{e.push(s);F.postMessage(t,"*")}})(`axios@${Math.random()}`,[]):t=>setTimeout(t)})(typeof setImmediate==="function",p(F.postMessage));const ot=typeof queueMicrotask!=="undefined"?queueMicrotask.bind(F):typeof process!=="undefined"&&process.nextTick||rt;const at=t=>t!=null&&p(t[i]);var ht={isArray:h,isArrayBuffer:u,isBuffer:l,isFormData:M,isArrayBufferView:f,isString:d,isNumber:g,isBoolean:w,isObject:m,isPlainObject:b,isEmptyObject:A,isReadableStream:T,isRequest:E,isResponse:P,isHeaders:N,isUndefined:c,isDate:y,isFile:v,isBlob:x,isRegExp:Y,isFunction:p,isStream:S,isURLSearchParams:C,isTypedArray:H,isFileList:k,forEach:I,merge:$,extend:_,trim:D,stripBOM:B,inherits:L,toFlatObject:U,kindOf:r,kindOfTest:o,endsWith:j,toArray:z,forEachEntry:W,matchAll:G,isHTMLForm:V,hasOwnProperty:q,hasOwnProp:q,reduceDescriptors:J,freezeMethods:K,toObjectSet:Q,toCamelCase:X,noop:Z,toFiniteNumber:tt,findKey:R,global:F,isContextDefined:O,isSpecCompliantForm:et,toJSONObject:st,isAsyncFn:it,isThenable:nt,setImmediate:rt,asap:ot,isIterable:at};function ct(t,e,s,i,n){Error.call(this);if(Error.captureStackTrace){Error.captureStackTrace(this,this.constructor)}else{this.stack=(new Error).stack}this.message=t;this.name="AxiosError";e&&(this.code=e);s&&(this.config=s);i&&(this.request=i);if(n){this.response=n;this.status=n.status?n.status:null}}ht.inherits(ct,Error,{toJSON:function t(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ht.toJSONObject(this.config),code:this.code,status:this.status}}});const lt=ct.prototype;const ut={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((t=>{ut[t]={value:t}}));Object.defineProperties(ct,ut);Object.defineProperty(lt,"isAxiosError",{value:true});ct.from=(t,e,s,i,n,r)=>{const o=Object.create(lt);ht.toFlatObject(t,o,(function t(e){return e!==Error.prototype}),(t=>t!=="isAxiosError"));const a=t&&t.message?t.message:"Error";const h=e==null&&t?t.code:e;ct.call(o,a,h,s,i,n);if(t&&o.cause==null){Object.defineProperty(o,"cause",{value:t,configurable:true})}o.name=t&&t.name||"Error";r&&Object.assign(o,r);return o};var ft=null;function dt(t){return ht.isPlainObject(t)||ht.isArray(t)}function pt(t){return ht.endsWith(t,"[]")?t.slice(0,-2):t}function gt(t,e,s){if(!t)return e;return t.concat(e).map((function t(e,i){e=pt(e);return!s&&i?"["+e+"]":e})).join(s?".":"")}function mt(t){return ht.isArray(t)&&!t.some(dt)}const wt=ht.toFlatObject(ht,{},null,(function t(e){return/^is[A-Z]/.test(e)}));function bt(t,e,s){if(!ht.isObject(t)){throw new TypeError("target must be an object")}e=e||new FormData;s=ht.toFlatObject(s,{metaTokens:true,dots:false,indexes:false},false,(function t(e,s){return!ht.isUndefined(s[e])}));const i=s.metaTokens;const n=s.visitor||l;const r=s.dots;const o=s.indexes;const a=s.Blob||typeof Blob!=="undefined"&&Blob;const h=a&&ht.isSpecCompliantForm(e);if(!ht.isFunction(n)){throw new TypeError("visitor must be a function")}function c(t){if(t===null)return"";if(ht.isDate(t)){return t.toISOString()}if(ht.isBoolean(t)){return t.toString()}if(!h&&ht.isBlob(t)){throw new ct("Blob is not supported. Use a Buffer instead.")}if(ht.isArrayBuffer(t)||ht.isTypedArray(t)){return h&&typeof Blob==="function"?new Blob([t]):Buffer.from(t)}return t}function l(t,s,n){let a=t;if(t&&!n&&typeof t==="object"){if(ht.endsWith(s,"{}")){s=i?s:s.slice(0,-2);t=JSON.stringify(t)}else if(ht.isArray(t)&&mt(t)||(ht.isFileList(t)||ht.endsWith(s,"[]"))&&(a=ht.toArray(t))){s=pt(s);a.forEach((function t(i,n){!(ht.isUndefined(i)||i===null)&&e.append(o===true?gt([s],n,r):o===null?s:s+"[]",c(i))}));return false}}if(dt(t)){return true}e.append(gt(n,s,r),c(t));return false}const u=[];const f=Object.assign(wt,{defaultVisitor:l,convertValue:c,isVisitable:dt});function d(t,s){if(ht.isUndefined(t))return;if(u.indexOf(t)!==-1){throw Error("Circular reference detected in "+s.join("."))}u.push(t);ht.forEach(t,(function t(i,r){const o=!(ht.isUndefined(i)||i===null)&&n.call(e,i,ht.isString(r)?r.trim():r,s,f);if(o===true){d(i,s?s.concat(r):[r])}}));u.pop()}if(!ht.isObject(t)){throw new TypeError("data must be an object")}d(t);return e}function At(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,(function t(s){return e[s]}))}function yt(t,e){this._pairs=[];t&&bt(t,this,e)}const vt=yt.prototype;vt.append=function t(e,s){this._pairs.push([e,s])};vt.toString=function t(e){const s=e?function(t){return e.call(this,t,At)}:At;return this._pairs.map((function t(e){return s(e[0])+"="+s(e[1])}),"").join("&")};function xt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function kt(t,e,s){if(!e){return t}const i=s&&s.encode||xt;if(ht.isFunction(s)){s={serialize:s}}const n=s&&s.serialize;let r;if(n){r=n(e,s)}else{r=ht.isURLSearchParams(e)?e.toString():new yt(e,s).toString(i)}if(r){const e=t.indexOf("#");if(e!==-1){t=t.slice(0,e)}t+=(t.indexOf("?")===-1?"?":"&")+r}return t}class St{constructor(){this.handlers=[]}use(t,e,s){this.handlers.push({fulfilled:t,rejected:e,synchronous:s?s.synchronous:false,runWhen:s?s.runWhen:null});return this.handlers.length-1}eject(t){if(this.handlers[t]){this.handlers[t]=null}}clear(){if(this.handlers){this.handlers=[]}}forEach(t){ht.forEach(this.handlers,(function e(s){if(s!==null){t(s)}}))}}var Mt=St;var Ct={silentJSONParsing:true,forcedJSONParsing:true,clarifyTimeoutError:false};var Tt=typeof URLSearchParams!=="undefined"?URLSearchParams:yt;var Et=typeof FormData!=="undefined"?FormData:null;var Pt=typeof Blob!=="undefined"?Blob:null;var Nt={isBrowser:true,classes:{URLSearchParams:Tt,FormData:Et,Blob:Pt},protocols:["http","https","file","blob","url","data"]};const Dt=typeof window!=="undefined"&&typeof document!=="undefined";const It=typeof navigator==="object"&&navigator||undefined;const Rt=Dt&&(!It||["ReactNative","NativeScript","NS"].indexOf(It.product)<0);const Ft=(()=>typeof WorkerGlobalScope!=="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts==="function")();const Ot=Dt&&window.location.href||"http://localhost";var $t=Object.freeze({__proto__:null,hasBrowserEnv:Dt,hasStandardBrowserWebWorkerEnv:Ft,hasStandardBrowserEnv:Rt,navigator:It,origin:Ot});var _t={...$t,...Nt};function Bt(t,e){return bt(t,new _t.classes.URLSearchParams,{visitor:function(t,e,s,i){if(_t.isNode&&ht.isBuffer(t)){this.append(e,t.toString("base64"));return false}return i.defaultVisitor.apply(this,arguments)},...e})}function Lt(t){return ht.matchAll(/\w+|\[(\w*)]/g,t).map((t=>t[0]==="[]"?"":t[1]||t[0]))}function Ut(t){const e={};const s=Object.keys(t);let i;const n=s.length;let r;for(i=0;i<n;i++){r=s[i];e[r]=t[r]}return e}function jt(t){function e(t,s,i,n){let r=t[n++];if(r==="__proto__")return true;const o=Number.isFinite(+r);const a=n>=t.length;r=!r&&ht.isArray(i)?i.length:r;if(a){if(ht.hasOwnProp(i,r)){i[r]=[i[r],s]}else{i[r]=s}return!o}if(!i[r]||!ht.isObject(i[r])){i[r]=[]}const h=e(t,s,i[r],n);if(h&&ht.isArray(i[r])){i[r]=Ut(i[r])}return!o}if(ht.isFormData(t)&&ht.isFunction(t.entries)){const s={};ht.forEachEntry(t,((t,i)=>{e(Lt(t),i,s,0)}));return s}return null}function zt(t,e,s){if(ht.isString(t)){try{(0,JSON.parse)(t);return ht.trim(t)}catch(t){if(t.name!=="SyntaxError"){throw t}}}return(s||JSON.stringify)(t)}const Ht={transitional:Ct,adapter:["xhr","http","fetch"],transformRequest:[function t(e,s){const i=s.getContentType()||"";const n=i.indexOf("application/json")>-1;const r=ht.isObject(e);if(r&&ht.isHTMLForm(e)){e=new FormData(e)}const o=ht.isFormData(e);if(o){return n?JSON.stringify(jt(e)):e}if(ht.isArrayBuffer(e)||ht.isBuffer(e)||ht.isStream(e)||ht.isFile(e)||ht.isBlob(e)||ht.isReadableStream(e)){return e}if(ht.isArrayBufferView(e)){return e.buffer}if(ht.isURLSearchParams(e)){s.setContentType("application/x-www-form-urlencoded;charset=utf-8",false);return e.toString()}let a;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1){return Bt(e,this.formSerializer).toString()}if((a=ht.isFileList(e))||i.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return bt(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}if(r||n){s.setContentType("application/json",false);return zt(e)}return e}],transformResponse:[function t(e){const s=this.transitional||Ht.transitional;const i=s&&s.forcedJSONParsing;const n=this.responseType==="json";if(ht.isResponse(e)||ht.isReadableStream(e)){return e}if(e&&ht.isString(e)&&(i&&!this.responseType||n)){const t=s&&s.silentJSONParsing;const i=!t&&n;try{return JSON.parse(e,this.parseReviver)}catch(t){if(i){if(t.name==="SyntaxError"){throw ct.from(t,ct.ERR_BAD_RESPONSE,this,null,this.response)}throw t}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function t(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":undefined}}};ht.forEach(["delete","get","head","post","put","patch"],(t=>{Ht.headers[t]={}}));var Wt=Ht;const Gt=ht.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var Vt=t=>{const e={};let s;let i;let n;t&&t.split("\n").forEach((function t(r){n=r.indexOf(":");s=r.substring(0,n).trim().toLowerCase();i=r.substring(n+1).trim();if(!s||e[s]&&Gt[s]){return}if(s==="set-cookie"){if(e[s]){e[s].push(i)}else{e[s]=[i]}}else{e[s]=e[s]?e[s]+", "+i:i}}));return e};const Xt=Symbol("internals");function qt(t){return t&&String(t).trim().toLowerCase()}function Yt(t){if(t===false||t==null){return t}return ht.isArray(t)?t.map(Yt):String(t)}function Jt(t){const e=Object.create(null);const s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;while(i=s.exec(t)){e[i[1]]=i[2]}return e}const Kt=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Qt(t,e,s,i,n){if(ht.isFunction(i)){return i.call(this,e,s)}if(n){e=s}if(!ht.isString(e))return;if(ht.isString(i)){return e.indexOf(i)!==-1}if(ht.isRegExp(i)){return i.test(e)}}function Zt(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((t,e,s)=>e.toUpperCase()+s))}function te(t,e){const s=ht.toCamelCase(" "+e);["get","set","has"].forEach((i=>{Object.defineProperty(t,i+s,{value:function(t,s,n){return this[i].call(this,e,t,s,n)},configurable:true})}))}class ee{constructor(t){t&&this.set(t)}set(t,e,s){const i=this;function n(t,e,s){const n=qt(e);if(!n){throw new Error("header name must be a non-empty string")}const r=ht.findKey(i,n);if(!r||i[r]===undefined||s===true||s===undefined&&i[r]!==false){i[r||e]=Yt(t)}}const r=(t,e)=>ht.forEach(t,((t,s)=>n(t,s,e)));if(ht.isPlainObject(t)||t instanceof this.constructor){r(t,e)}else if(ht.isString(t)&&(t=t.trim())&&!Kt(t)){r(Vt(t),e)}else if(ht.isObject(t)&&ht.isIterable(t)){let s={},i,n;for(const e of t){if(!ht.isArray(e)){throw TypeError("Object iterator must return a key-value pair")}s[n=e[0]]=(i=s[n])?ht.isArray(i)?[...i,e[1]]:[i,e[1]]:e[1]}r(s,e)}else{t!=null&&n(e,t,s)}return this}get(t,e){t=qt(t);if(t){const s=ht.findKey(this,t);if(s){const t=this[s];if(!e){return t}if(e===true){return Jt(t)}if(ht.isFunction(e)){return e.call(this,t,s)}if(ht.isRegExp(e)){return e.exec(t)}throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){t=qt(t);if(t){const s=ht.findKey(this,t);return!!(s&&this[s]!==undefined&&(!e||Qt(this,this[s],s,e)))}return false}delete(t,e){const s=this;let i=false;function n(t){t=qt(t);if(t){const n=ht.findKey(s,t);if(n&&(!e||Qt(s,s[n],n,e))){delete s[n];i=true}}}if(ht.isArray(t)){t.forEach(n)}else{n(t)}return i}clear(t){const e=Object.keys(this);let s=e.length;let i=false;while(s--){const n=e[s];if(!t||Qt(this,this[n],n,t,true)){delete this[n];i=true}}return i}normalize(t){const e=this;const s={};ht.forEach(this,((i,n)=>{const r=ht.findKey(s,n);if(r){e[r]=Yt(i);delete e[n];return}const o=t?Zt(n):String(n).trim();if(o!==n){delete e[n]}e[o]=Yt(i);s[o]=true}));return this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);ht.forEach(this,((s,i)=>{s!=null&&s!==false&&(e[i]=t&&ht.isArray(s)?s.join(", "):s)}));return e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([t,e])=>t+": "+e)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const s=new this(t);e.forEach((t=>s.set(t)));return s}static accessor(t){const e=this[Xt]=this[Xt]={accessors:{}};const s=e.accessors;const i=this.prototype;function n(t){const e=qt(t);if(!s[e]){te(i,t);s[e]=true}}ht.isArray(t)?t.forEach(n):n(t);return this}}ee.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ht.reduceDescriptors(ee.prototype,(({value:t},e)=>{let s=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(t){this[s]=t}}}));ht.freezeMethods(ee);var se=ee;function ie(t,e){const s=this||Wt;const i=e||s;const n=se.from(i.headers);let r=i.data;ht.forEach(t,(function t(i){r=i.call(s,r,n.normalize(),e?e.status:undefined)}));n.normalize();return r}function ne(t){return!!(t&&t.__CANCEL__)}function re(t,e,s){ct.call(this,t==null?"canceled":t,ct.ERR_CANCELED,e,s);this.name="CanceledError"}ht.inherits(re,ct,{__CANCEL__:true});function oe(t,e,s){const i=s.config.validateStatus;if(!s.status||!i||i(s.status)){t(s)}else{e(new ct("Request failed with status code "+s.status,[ct.ERR_BAD_REQUEST,ct.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}}function ae(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function he(t,e){t=t||10;const s=new Array(t);const i=new Array(t);let n=0;let r=0;let o;e=e!==undefined?e:1e3;return function a(h){const c=Date.now();const l=i[r];if(!o){o=c}s[n]=h;i[n]=c;let u=r;let f=0;while(u!==n){f+=s[u++];u=u%t}n=(n+1)%t;if(n===r){r=(r+1)%t}if(c-o<e){return}const d=l&&c-l;return d?Math.round(f*1e3/d):undefined}}function ce(t,e){let s=0;let i=1e3/e;let n;let r;const o=(e,i=Date.now())=>{s=i;n=null;if(r){clearTimeout(r);r=null}t(...e)};const a=(...t)=>{const e=Date.now();const a=e-s;if(a>=i){o(t,e)}else{n=t;if(!r){r=setTimeout((()=>{r=null;o(n)}),i-a)}}};const h=()=>n&&o(n);return[a,h]}const le=(t,e,s=3)=>{let i=0;const n=he(50,250);return ce((s=>{const r=s.loaded;const o=s.lengthComputable?s.total:undefined;const a=r-i;const h=n(a);const c=r<=o;i=r;const l={loaded:r,total:o,progress:o?r/o:undefined,bytes:a,rate:h?h:undefined,estimated:h&&o&&c?(o-r)/h:undefined,event:s,lengthComputable:o!=null,[e?"download":"upload"]:true};t(l)}),s)};const ue=(t,e)=>{const s=t!=null;return[i=>e[0]({lengthComputable:s,total:t,loaded:i}),e[1]]};const fe=t=>(...e)=>ht.asap((()=>t(...e)));var de=_t.hasStandardBrowserEnv?((t,e)=>s=>{s=new URL(s,_t.origin);return t.protocol===s.protocol&&t.host===s.host&&(e||t.port===s.port)})(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>true;var pe=_t.hasStandardBrowserEnv?{write(t,e,s,i,n,r,o){if(typeof document==="undefined")return;const a=[`${t}=${encodeURIComponent(e)}`];if(ht.isNumber(s)){a.push(`expires=${new Date(s).toUTCString()}`)}if(ht.isString(i)){a.push(`path=${i}`)}if(ht.isString(n)){a.push(`domain=${n}`)}if(r===true){a.push("secure")}if(ht.isString(o)){a.push(`SameSite=${o}`)}document.cookie=a.join("; ")},read(t){if(typeof document==="undefined")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function ge(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function me(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function we(t,e,s){let i=!ge(e);if(t&&(i||s==false)){return me(t,e)}return e}const be=t=>t instanceof se?{...t}:t;function Ae(t,e){e=e||{};const s={};function i(t,e,s,i){if(ht.isPlainObject(t)&&ht.isPlainObject(e)){return ht.merge.call({caseless:i},t,e)}else if(ht.isPlainObject(e)){return ht.merge({},e)}else if(ht.isArray(e)){return e.slice()}return e}function n(t,e,s,n){if(!ht.isUndefined(e)){return i(t,e,s,n)}else if(!ht.isUndefined(t)){return i(undefined,t,s,n)}}function r(t,e){if(!ht.isUndefined(e)){return i(undefined,e)}}function o(t,e){if(!ht.isUndefined(e)){return i(undefined,e)}else if(!ht.isUndefined(t)){return i(undefined,t)}}function a(s,n,r){if(r in e){return i(s,n)}else if(r in t){return i(undefined,s)}}const h={url:r,method:r,data:r,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(t,e,s)=>n(be(t),be(e),s,true)};ht.forEach(Object.keys({...t,...e}),(function i(r){const o=h[r]||n;const c=o(t[r],e[r],r);ht.isUndefined(c)&&o!==a||(s[r]=c)}));return s}var ye=t=>{const e=Ae({},t);let{data:s,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:r,headers:o,auth:a}=e;e.headers=o=se.from(o);e.url=kt(we(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer);if(a){o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")))}if(ht.isFormData(s)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv){o.setContentType(undefined)}else if(ht.isFunction(s.getHeaders)){const t=s.getHeaders();const e=["content-type","content-length"];Object.entries(t).forEach((([t,s])=>{if(e.includes(t.toLowerCase())){o.set(t,s)}}))}}if(_t.hasStandardBrowserEnv){i&&ht.isFunction(i)&&(i=i(e));if(i||i!==false&&de(e.url)){const t=n&&r&&pe.read(r);if(t){o.set(n,t)}}}return e};const ve=typeof XMLHttpRequest!=="undefined";var xe=ve&&function(t){return new Promise((function e(s,i){const n=ye(t);let r=n.data;const o=se.from(n.headers).normalize();let{responseType:a,onUploadProgress:h,onDownloadProgress:c}=n;let l;let u,f;let d,p;function g(){d&&d();p&&p();n.cancelToken&&n.cancelToken.unsubscribe(l);n.signal&&n.signal.removeEventListener("abort",l)}let m=new XMLHttpRequest;m.open(n.method.toUpperCase(),n.url,true);m.timeout=n.timeout;function w(){if(!m){return}const e=se.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());const n=!a||a==="text"||a==="json"?m.responseText:m.response;const r={data:n,status:m.status,statusText:m.statusText,headers:e,config:t,request:m};oe((function t(e){s(e);g()}),(function t(e){i(e);g()}),r);m=null}if("onloadend"in m){m.onloadend=w}else{m.onreadystatechange=function t(){if(!m||m.readyState!==4){return}if(m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)){return}setTimeout(w)}}m.onabort=function e(){if(!m){return}i(new ct("Request aborted",ct.ECONNABORTED,t,m));m=null};m.onerror=function e(s){const n=s&&s.message?s.message:"Network Error";const r=new ct(n,ct.ERR_NETWORK,t,m);r.event=s||null;i(r);m=null};m.ontimeout=function e(){let s=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const r=n.transitional||Ct;if(n.timeoutErrorMessage){s=n.timeoutErrorMessage}i(new ct(s,r.clarifyTimeoutError?ct.ETIMEDOUT:ct.ECONNABORTED,t,m));m=null};r===undefined&&o.setContentType(null);if("setRequestHeader"in m){ht.forEach(o.toJSON(),(function t(e,s){m.setRequestHeader(s,e)}))}if(!ht.isUndefined(n.withCredentials)){m.withCredentials=!!n.withCredentials}if(a&&a!=="json"){m.responseType=n.responseType}if(c){[f,p]=le(c,true);m.addEventListener("progress",f)}if(h&&m.upload){[u,d]=le(h);m.upload.addEventListener("progress",u);m.upload.addEventListener("loadend",d)}if(n.cancelToken||n.signal){l=e=>{if(!m){return}i(!e||e.type?new re(null,t,m):e);m.abort();m=null};n.cancelToken&&n.cancelToken.subscribe(l);if(n.signal){n.signal.aborted?l():n.signal.addEventListener("abort",l)}}const b=ae(n.url);if(b&&_t.protocols.indexOf(b)===-1){i(new ct("Unsupported protocol "+b+":",ct.ERR_BAD_REQUEST,t));return}m.send(r||null)}))};const ke=(t,e)=>{const{length:s}=t=t?t.filter(Boolean):[];if(e||s){let s=new AbortController;let i;const n=function(t){if(!i){i=true;o();const e=t instanceof Error?t:this.reason;s.abort(e instanceof ct?e:new re(e instanceof Error?e.message:e))}};let r=e&&setTimeout((()=>{r=null;n(new ct(`timeout ${e} of ms exceeded`,ct.ETIMEDOUT))}),e);const o=()=>{if(t){r&&clearTimeout(r);r=null;t.forEach((t=>{t.unsubscribe?t.unsubscribe(n):t.removeEventListener("abort",n)}));t=null}};t.forEach((t=>t.addEventListener("abort",n)));const{signal:a}=s;a.unsubscribe=()=>ht.asap(o);return a}};var Se=ke;const Me=function*(t,e){let s=t.byteLength;if(s<e){yield t;return}let i=0;let n;while(i<s){n=i+e;yield t.slice(i,n);i=n}};const Ce=async function*(t,e){for await(const s of Te(t)){yield*Me(s,e)}};const Te=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:t,value:s}=await e.read();if(t){break}yield s}}finally{await e.cancel()}};const Ee=(t,e,s,i)=>{const n=Ce(t,e);let r=0;let o;let a=t=>{if(!o){o=true;i&&i(t)}};return new ReadableStream({async pull(t){try{const{done:e,value:i}=await n.next();if(e){a();t.close();return}let o=i.byteLength;if(s){let t=r+=o;s(t)}t.enqueue(new Uint8Array(i))}catch(t){a(t);throw t}},cancel(t){a(t);return n.return()}},{highWaterMark:2})};const Pe=64*1024;const{isFunction:Ne}=ht;const De=(({Request:t,Response:e})=>({Request:t,Response:e}))(ht.global);const{ReadableStream:Ie,TextEncoder:Re}=ht.global;const Fe=(t,...e)=>{try{return!!t(...e)}catch(t){return false}};const Oe=t=>{t=ht.merge.call({skipUndefined:true},De,t);const{fetch:e,Request:s,Response:i}=t;const n=e?Ne(e):typeof fetch==="function";const r=Ne(s);const o=Ne(i);if(!n){return false}const a=n&&Ne(Ie);const h=n&&(typeof Re==="function"?(t=>e=>t.encode(e))(new Re):async t=>new Uint8Array(await new s(t).arrayBuffer()));const c=r&&a&&Fe((()=>{let t=false;const e=new s(_t.origin,{body:new Ie,method:"POST",get duplex(){t=true;return"half"}}).headers.has("Content-Type");return t&&!e}));const l=o&&a&&Fe((()=>ht.isReadableStream(new i("").body)));const u={stream:l&&(t=>t.body)};n&&(()=>{["text","arrayBuffer","blob","formData","stream"].forEach((t=>{!u[t]&&(u[t]=(e,s)=>{let i=e&&e[t];if(i){return i.call(e)}throw new ct(`Response type '${t}' is not supported`,ct.ERR_NOT_SUPPORT,s)})}))})();const f=async t=>{if(t==null){return 0}if(ht.isBlob(t)){return t.size}if(ht.isSpecCompliantForm(t)){const e=new s(_t.origin,{method:"POST",body:t});return(await e.arrayBuffer()).byteLength}if(ht.isArrayBufferView(t)||ht.isArrayBuffer(t)){return t.byteLength}if(ht.isURLSearchParams(t)){t=t+""}if(ht.isString(t)){return(await h(t)).byteLength}};const d=async(t,e)=>{const s=ht.toFiniteNumber(t.getContentLength());return s==null?f(e):s};return async t=>{let{url:n,method:o,data:a,signal:h,cancelToken:f,timeout:p,onDownloadProgress:g,onUploadProgress:m,responseType:w,headers:b,withCredentials:A="same-origin",fetchOptions:y}=ye(t);let v=e||fetch;w=w?(w+"").toLowerCase():"text";let x=Se([h,f&&f.toAbortSignal()],p);let k=null;const S=x&&x.unsubscribe&&(()=>{x.unsubscribe()});let M;try{if(m&&c&&o!=="get"&&o!=="head"&&(M=await d(b,a))!==0){let t=new s(n,{method:"POST",body:a,duplex:"half"});let e;if(ht.isFormData(a)&&(e=t.headers.get("content-type"))){b.setContentType(e)}if(t.body){const[e,s]=ue(M,le(fe(m)));a=Ee(t.body,Pe,e,s)}}if(!ht.isString(A)){A=A?"include":"omit"}const e=r&&"credentials"in s.prototype;const h={...y,signal:x,method:o.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:e?A:undefined};k=r&&new s(n,h);let f=await(r?v(k,y):v(n,h));const p=l&&(w==="stream"||w==="response");if(l&&(g||p&&S)){const t={};["status","statusText","headers"].forEach((e=>{t[e]=f[e]}));const e=ht.toFiniteNumber(f.headers.get("content-length"));const[s,n]=g&&ue(e,le(fe(g),true))||[];f=new i(Ee(f.body,Pe,s,(()=>{n&&n();S&&S()})),t)}w=w||"text";let C=await u[ht.findKey(u,w)||"text"](f,t);!p&&S&&S();return await new Promise(((e,s)=>{oe(e,s,{data:C,headers:se.from(f.headers),status:f.status,statusText:f.statusText,config:t,request:k})}))}catch(e){S&&S();if(e&&e.name==="TypeError"&&/Load failed|fetch/i.test(e.message)){throw Object.assign(new ct("Network Error",ct.ERR_NETWORK,t,k),{cause:e.cause||e})}throw ct.from(e,e&&e.code,t,k)}}};const $e=new Map;const _e=t=>{let e=t&&t.env||{};const{fetch:s,Request:i,Response:n}=e;const r=[i,n,s];let o=r.length,a=o,h,c,l=$e;while(a--){h=r[a];c=l.get(h);c===undefined&&l.set(h,c=a?new Map:Oe(e));l=c}return c};_e();const Be={http:ft,xhr:xe,fetch:{get:_e}};ht.forEach(Be,((t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch(t){}Object.defineProperty(t,"adapterName",{value:e})}}));const Le=t=>`- ${t}`;const Ue=t=>ht.isFunction(t)||t===null||t===false;function je(t,e){t=ht.isArray(t)?t:[t];const{length:s}=t;let i;let n;const r={};for(let o=0;o<s;o++){i=t[o];let s;n=i;if(!Ue(i)){n=Be[(s=String(i)).toLowerCase()];if(n===undefined){throw new ct(`Unknown adapter '${s}'`)}}if(n&&(ht.isFunction(n)||(n=n.get(e)))){break}r[s||"#"+o]=n}if(!n){const t=Object.entries(r).map((([t,e])=>`adapter ${t} `+(e===false?"is not supported by the environment":"is not available in the build")));let e=s?t.length>1?"since :\n"+t.map(Le).join("\n"):" "+Le(t[0]):"as no adapter specified";throw new ct(`There is no suitable adapter to dispatch the request `+e,"ERR_NOT_SUPPORT")}return n}var ze={getAdapter:je,adapters:Be};function He(t){if(t.cancelToken){t.cancelToken.throwIfRequested()}if(t.signal&&t.signal.aborted){throw new re(null,t)}}function We(t){He(t);t.headers=se.from(t.headers);t.data=ie.call(t,t.transformRequest);if(["post","put","patch"].indexOf(t.method)!==-1){t.headers.setContentType("application/x-www-form-urlencoded",false)}const e=ze.getAdapter(t.adapter||Wt.adapter,t);return e(t).then((function e(s){He(t);s.data=ie.call(t,t.transformResponse,s);s.headers=se.from(s.headers);return s}),(function e(s){if(!ne(s)){He(t);if(s&&s.response){s.response.data=ie.call(t,t.transformResponse,s.response);s.response.headers=se.from(s.response.headers)}}return Promise.reject(s)}))}const Ge="1.13.2";const Ve={};["object","boolean","number","function","string","symbol"].forEach(((t,e)=>{Ve[t]=function s(i){return typeof i===t||"a"+(e<1?"n ":" ")+t}}));const Xe={};Ve.transitional=function t(e,s,i){function n(t,e){return"[Axios v"+Ge+"] Transitional option '"+t+"'"+e+(i?". "+i:"")}return(t,i,r)=>{if(e===false){throw new ct(n(i," has been removed"+(s?" in "+s:"")),ct.ERR_DEPRECATED)}if(s&&!Xe[i]){Xe[i]=true;console.warn(n(i," has been deprecated since v"+s+" and will be removed in the near future"))}return e?e(t,i,r):true}};Ve.spelling=function t(e){return(t,s)=>{console.warn(`${s} is likely a misspelling of ${e}`);return true}};function qe(t,e,s){if(typeof t!=="object"){throw new ct("options must be an object",ct.ERR_BAD_OPTION_VALUE)}const i=Object.keys(t);let n=i.length;while(n-- >0){const r=i[n];const o=e[r];if(o){const e=t[r];const s=e===undefined||o(e,r,t);if(s!==true){throw new ct("option "+r+" must be "+s,ct.ERR_BAD_OPTION_VALUE)}continue}if(s!==true){throw new ct("Unknown option "+r,ct.ERR_BAD_OPTION)}}}var Ye={assertOptions:qe,validators:Ve};const Je=Ye.validators;class Ke{constructor(t){this.defaults=t||{};this.interceptors={request:new Mt,response:new Mt}}async request(t,e){try{return await this._request(t,e)}catch(t){if(t instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const s=e.stack?e.stack.replace(/^.+\n/,""):"";try{if(!t.stack){t.stack=s}else if(s&&!String(t.stack).endsWith(s.replace(/^.+\n.+\n/,""))){t.stack+="\n"+s}}catch(t){}}throw t}}_request(t,e){if(typeof t==="string"){e=e||{};e.url=t}else{e=t||{}}e=Ae(this.defaults,e);const{transitional:s,paramsSerializer:i,headers:n}=e;if(s!==undefined){Ye.assertOptions(s,{silentJSONParsing:Je.transitional(Je.boolean),forcedJSONParsing:Je.transitional(Je.boolean),clarifyTimeoutError:Je.transitional(Je.boolean)},false)}if(i!=null){if(ht.isFunction(i)){e.paramsSerializer={serialize:i}}else{Ye.assertOptions(i,{encode:Je.function,serialize:Je.function},true)}}if(e.allowAbsoluteUrls!==undefined);else if(this.defaults.allowAbsoluteUrls!==undefined){e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls}else{e.allowAbsoluteUrls=true}Ye.assertOptions(e,{baseUrl:Je.spelling("baseURL"),withXsrfToken:Je.spelling("withXSRFToken")},true);e.method=(e.method||this.defaults.method||"get").toLowerCase();let r=n&&ht.merge(n.common,n[e.method]);n&&ht.forEach(["delete","get","head","post","put","patch","common"],(t=>{delete n[t]}));e.headers=se.concat(r,n);const o=[];let a=true;this.interceptors.request.forEach((function t(s){if(typeof s.runWhen==="function"&&s.runWhen(e)===false){return}a=a&&s.synchronous;o.unshift(s.fulfilled,s.rejected)}));const h=[];this.interceptors.response.forEach((function t(e){h.push(e.fulfilled,e.rejected)}));let c;let l=0;let u;if(!a){const t=[We.bind(this),undefined];t.unshift(...o);t.push(...h);u=t.length;c=Promise.resolve(e);while(l<u){c=c.then(t[l++],t[l++])}return c}u=o.length;let f=e;while(l<u){const t=o[l++];const e=o[l++];try{f=t(f)}catch(t){e.call(this,t);break}}try{c=We.call(this,f)}catch(t){return Promise.reject(t)}l=0;u=h.length;while(l<u){c=c.then(h[l++],h[l++])}return c}getUri(t){t=Ae(this.defaults,t);const e=we(t.baseURL,t.url,t.allowAbsoluteUrls);return kt(e,t.params,t.paramsSerializer)}}ht.forEach(["delete","get","head","options"],(function t(e){Ke.prototype[e]=function(t,s){return this.request(Ae(s||{},{method:e,url:t,data:(s||{}).data}))}}));ht.forEach(["post","put","patch"],(function t(e){function s(t){return function s(i,n,r){return this.request(Ae(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}Ke.prototype[e]=s();Ke.prototype[e+"Form"]=s(true)}));var Qe=Ke;class Ze{constructor(t){if(typeof t!=="function"){throw new TypeError("executor must be a function.")}let e;this.promise=new Promise((function t(s){e=s}));const s=this;this.promise.then((t=>{if(!s._listeners)return;let e=s._listeners.length;while(e-- >0){s._listeners[e](t)}s._listeners=null}));this.promise.then=t=>{let e;const i=new Promise((t=>{s.subscribe(t);e=t})).then(t);i.cancel=function t(){s.unsubscribe(e)};return i};t((function t(i,n,r){if(s.reason){return}s.reason=new re(i,n,r);e(s.reason)}))}throwIfRequested(){if(this.reason){throw this.reason}}subscribe(t){if(this.reason){t(this.reason);return}if(this._listeners){this._listeners.push(t)}else{this._listeners=[t]}}unsubscribe(t){if(!this._listeners){return}const e=this._listeners.indexOf(t);if(e!==-1){this._listeners.splice(e,1)}}toAbortSignal(){const t=new AbortController;const e=e=>{t.abort(e)};this.subscribe(e);t.signal.unsubscribe=()=>this.unsubscribe(e);return t.signal}static source(){let t;const e=new Ze((function e(s){t=s}));return{token:e,cancel:t}}}var ts=Ze;function es(t){return function e(s){return t.apply(null,s)}}function ss(t){return ht.isObject(t)&&t.isAxiosError===true}const is={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(is).forEach((([t,e])=>{is[e]=t}));var ns=is;function rs(e){const s=new Qe(e);const i=t(Qe.prototype.request,s);ht.extend(i,Qe.prototype,s,{allOwnKeys:true});ht.extend(i,s,null,{allOwnKeys:true});i.create=function t(s){return rs(Ae(e,s))};return i}const os=rs(Wt);os.Axios=Qe;os.CanceledError=re;os.CancelToken=ts;os.isCancel=ne;os.VERSION=Ge;os.toFormData=bt;os.AxiosError=ct;os.Cancel=os.CanceledError;os.all=function t(e){return Promise.all(e)};os.spread=es;os.isAxiosError=ss;os.mergeConfig=Ae;os.AxiosHeaders=se;os.formToJSON=t=>jt(ht.isHTMLForm(t)?new FormData(t):t);os.getAdapter=ze.getAdapter;os.HttpStatusCode=ns;os.default=os;Sr=os;return Sr}var Tr=Cr();var Er=kr(Tr);const Pr={endpoints:{graphQL:"https://dypxviim4zgwtpev7valhchaem.appsync-api.eu-west-2.amazonaws.com/graphql"}};const Nr=t=>`\n mutation AddField {\n createTemplateElement(input: {\n templateId: "${t.templateId}", \n ax: ${t.ax}, \n ay: ${t.ay}, \n bx: ${t.bx}, \n by: ${t.by}, \n elementType: ${t?.signer!==0?JSON.stringify(t.elementType):JSON.stringify("admin")}, \n role: "1",\n label: ${JSON.stringify(t.label)}, \n page: ${t.page}, \n fieldOrder: ${t.fieldOrder}, \n fontName: ${JSON.stringify(t.fontName)}, \n fontSize: ${t.fontSize}, \n helpText: ${JSON.stringify(t.helpText)}, \n hideBorder: ${t.hideBorder}, \n logicGroup: ${JSON.stringify(t.logicGroup)}, \n mapTo: ${JSON.stringify(t.mapTo)}, \n optional: ${t.optional}, \n options: ${JSON.stringify(t.options)}, \n substantive: ${t.substantive}, \n validation: ${t.validation}, \n value: ${JSON.stringify(t.value)}, \n align: ${JSON.stringify(t.align)}, \n signer: ${t.signer}, \n logicAction: ${t.logicAction}, \n labelExtra: ${JSON.stringify(t.labelExtra)}})\n }`;const Dr=t=>`mutation ChangeField {\n updateTemplateElement(input: {\n templateElementId: "${t.id}", \n ax: ${t.ax}, \n ay: ${t.ay}, \n bx: ${t.bx}, \n by: ${t.by}, \n elementType: ${t?.signer!==0?JSON.stringify(t.elementType):JSON.stringify("admin")}, \n label: ${JSON.stringify(t.label)}, \n page: ${t.page}, \n fieldOrder: ${t.fieldOrder?t.fieldOrder:null}, \n fontName: ${JSON.stringify(t.fontName)}, \n fontSize: ${t.fontSize}, \n helpText: "${t.helpText}", \n hideBorder: ${t.hideBorder}, \n logicGroup: ${JSON.stringify(t.logicGroup)}, \n mapTo: "${t.mapTo}", \n optional: ${t.optional}, \n options: ${JSON.stringify(t.options)}, \n role: "1", \n substantive: ${t.substantive}, \n validation: ${t.validation==="0"?"null":t.validation}, \n value: "${t.value}", \n align: "${t.align}", \n signer: ${t.signer}, \n logicAction: ${t.logicAction}, \n labelExtra: "${t.labelExtra}"})\n}`;const Ir=t=>`mutation DeleteField {\n deleteTemplateElement(input: {\n templateElementId: "${t.id}"})\n }`;const Rr=t=>{const e=t?.signerParent?`"${t.signerParent}"`:"null";return`\n mutation LDVAddRole {\n createTemplateRole(input: {\n templateId: "${t.templateId}" \n signerIndex: ${t.signerIndex}\n signerParent: ${e}\n name: ${JSON.stringify(t.name)}\n ordinal: ${t.ordinal}\n roleType: ${t.roleType}\n experience: "${t.experience}"\n })\n }`};const Fr=t=>`\n mutation LDVremoveRole {\n deleteTemplateRole(input: {\n templateRoleId: "${t.id}" \n })\n }`;const Or=t=>{const e=t?.signerParent?`"${t.signerParent}"`:"null";return`\n mutation LDVupdateRole {\n updateTemplateRole(input: {\n templateRoleId: "${t.id}" \n signerIndex: ${t.signerIndex}\n ordinal: ${t.ordinal}\n signerParent: ${e}\n name: ${JSON.stringify(t.name)}\n roleType: ${t.roleType.toUpperCase()}\n experience: "${t.experience}"\n })\n }`};const $r=(t,e)=>`\n mutation LDVswapRole {\n swapRoles(input: {\n roleId1: "${t.id}" \n roleId2: "${e.id}"\n })\n }`;class _r{endpoint;constructor(t){this.endpoint=t}handleEvent=async(t,e)=>{Er.defaults.headers.common["Authorization"]=e;const s=t.data;if(!s?.id)return"invalid";const i=atob(s.id);if(i.length<3)return"invalid";const n=atob(s.id).substring(0,3);let r="";switch(n){case"ele":switch(t.action){case"create":console.log(s,t);r=Nr(c(s));break;case"update":r=Dr(c(s));break;case"delete":r=Ir(s);break}break;case"rol":switch(t.action){case"create":r=Rr(s);break;case"update":r=Or(s);break;case"delete":r=Fr(s);break;case"swap":console.log(s,t);r=$r(s,t.data2);break}break;case"tpl":switch(t.action){case"update":r=h(s);break}break}const o=await this.execute(e,r);return{result:o,obj:s,event:t}};async execute(t,e,s){if(t){const i=await Er.post(this.endpoint||Pr.endpoints.graphQL,{query:e,variables:s?s:{}},{headers:{Authorization:t}});return i.data.data}else{console.warn("UNASSIGNED ACCESS TOKEN")}return Promise.reject()}}const Br=t=>`\n query LDVgetGroupData {\n group(id: "${t}"){\n id \n standardMessageConnection{\n messages {\n id\n name\n default\n body\n created\n modified\n }\n }\n scheduleConnection {\n schedules {\n id\n name\n items {\n id\n daysAfter\n frequency\n subject\n message\n when\n timeOfDay\n skipWeekend\n }\n default\n }\n }\n experienceConnection{\n experiences {\n id\n name\n language\n defaultExperience\n witnessSameDevice\n allowSignatureReuse\n attachDraft\n canReassign\n defaultReminderSubject\n defaultSubject\n finalSignerEmailSubHeader\n finalSignerEmailText\n footerTextColour\n forwarding\n penDiameter\n postSignAttach\n postSignEmail\n rejectedEmailSubheader\n senderName\n signatureAppendDate\n signatureDoneText\n signatureMouse\n signatureType\n signatureCertifiedType\n signatureUpload\n signatureAppend\n signatureAppendExtra\n signingPageText\n textBackgroundColour\n textFontColour\n typedSignatureFixedSize\n created\n modified\n witnessingRequiresSignerSMS\n witnessingRequiresWitnessSMS\n }\n }\n attachmentConnection {\n attachments {\n id\n filename\n autoAttach\n description\n created\n }\n }\n contactConnection {\n contacts{\n id\n firstName\n lastName\n email\n phoneNumber\n name\n }\n }\n }\n }\n `;async function Lr(){const t=this.groupInfo.experienceConnection.experiences.find((t=>t.defaultExperience===true));const e=this._recipients.filter((t=>t.roleType!=="WITNESS")).map(((e,s)=>{const i=this._template.roles.filter((t=>t.roleType!=="WITNESS")).find((t=>t.signerIndex===e.signerIndex));const n=e?.roleType?e?.roleType:"SIGNER";if(!i||i===undefined){const i={id:btoa("rol"+crypto.randomUUID()),signerIndex:e?.signerIndex,name:e?.lastName||"Participant "+(s+1),roleType:n,ordinal:s+1,signerParent:null,experience:t?t.id:"",templateId:this._template.id};return this.adapter.execute(this.token,Rr(i)).then((t=>{this._template.roles=[...this._template.roles,{...i,id:t.createTemplateRole}]}))}else if(e.signerIndex===1&&e.roleType!==i.roleType){this.mutate.emit([{action:"update",data:{...i,roleType:e.roleType}}]);return Promise.resolve()}else{return Promise.resolve()}}));await Promise.all(e);await Ur.bind(this)(t);l.bind(this)().then((()=>{this.update.emit({event:{recipients:this._recipients},template:this._template})}))}async function Ur(t){const e=this._recipients.filter((t=>t.roleType==="WITNESS")).map((e=>{const s=this._template.roles.find((t=>t.signerIndex===e.signerIndex%100));const i=this._template.roles.find((t=>t.signerIndex===e.signerIndex));if(s&&s!==undefined&&(!i||i===undefined)){const i={id:btoa("rol"+crypto.randomUUID()),signerIndex:e?.signerIndex,name:s.name==="Participant "+s.ordinal?"Participant "+(s.ordinal+1):s.name+" Witness",roleType:"WITNESS",ordinal:s.ordinal+1,signerParent:s.id,experience:t?t.id:"",templateId:this._template.id};return this.adapter.execute(this.token,Rr(i)).then((t=>{this._template.roles=[...this._template.roles,{...i,id:t.createTemplateRole}]}))}else{return Promise.resolve()}}));await Promise.all(e)}const jr=()=>`*,*::before,*::after{box-sizing:border-box}*{margin:0}@media (prefers-reduced-motion: no-preference){html{interpolate-size:allow-keywords}}body{line-height:1.5;-webkit-font-smoothing:antialiased}img,picture,video,canvas,svg{display:block;max-width:100%}input,button,textarea,select{font:inherit}p,h1,h2,h3,h4,h5,h6{overflow-wrap:break-word}p{text-wrap:pretty}h1,h2,h3,h4,h5,h6{text-wrap:balance}#root,#__next{isolation:isolate}:host{display:flex;flex-direction:column;width:100%;height:100vh;position:relative;overflow:hidden;container-type:size;font-family:var(--font-family, "IBM Plex Sans", sans-serif);font-size:var(--text-sm);margin:0px;padding:0px}:host *{scrollbar-width:none}:host *::-webkit-scrollbar{display:none}.ls-dv-left-slot-wrapper{position:absolute;top:50%;left:0.675rem;transform:translateY(-50%);z-index:2000}slot{justify-content:center;align-items:center;border-radius:1rem;font-size:0.75rem;font-style:normal;font-weight:500;line-height:1.25rem;width:fit-content;background-color:var(--green-30, #9df5d4);color:var(--green-100, #125241)}.ls-dv-right-slot-wrapper{position:absolute;top:50%;right:0.675rem;transform:translateY(-50%);z-index:2000}.ls-dv-validation-tag-wrapper{position:absolute;top:1rem;right:1rem;z-index:2000;display:flex;width:100%;align-items:center;justify-content:center;padding:0.375rem;gap:0.5rem;width:fit-content;border-radius:1.25rem;border:1px solid var(--gray-20, #edeff2);background:var(--white, #ffffff);box-shadow:0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)}.ls-dv-page-loader{position:absolute;display:flex;top:0;left:0;align-items:center;justify-content:center;background-color:rgba(251, 251, 251, 0.3);backdrop-filter:blur(2px);height:100%;width:100%;z-index:4000}.ls-dv-custom-loader-slot{position:absolute;top:0;left:0;height:100%;width:100%;z-index:3999}#pdf-canvas{top:0px;left:0px;width:6.25rem;height:6.25rem;box-shadow:0 0.5rem 2rem 0 rgba(0, 0, 0, 0.12)}#ls-mid-area{position:absolute;top:0;left:0;display:flex;flex-direction:column;align-items:center;width:100%;height:100%;overflow:hidden}.ls-dv-document-frame-wrapper{display:flex;flex-direction:column;justify-content:start;align-items:start;overflow:visible;max-height:100%;width:100%;overflow:scroll;padding:5rem 23.75rem 2rem 23.75rem;position:relative;user-select:none;-webkit-user-select:none}.ls-dv-document-frame-wrapper--preview{align-items:center;padding:2rem}.ls-dv-select-menu-position{position:absolute;top:0;left:calc(100% + 0.5rem);z-index:999}.ls-dv-select-menu-floating{z-index:999;pointer-events:auto}#ls-document-frame{position:relative;height:98cqh;margin-right:auto;margin-left:auto}.ls-dv-prev-button{position:relative;bottom:1.875rem}.ls-dv-next-button{position:relative;bottom:1.875rem}.ls-dv-field-box{z-index:1000}#ls-box-selector{position:absolute;visibility:hidden;background-color:color-mix(in srgb, var(--primary-20, #c7ddff) 20%, transparent);border:1px dashed var(--primary-50, #5185ff)}#ls-drag-selector{position:absolute;visibility:hidden;background-color:color-mix(in srgb, var(--primary-20, #c7ddff) 20%, transparent);border:1px dashed var(--primary-50, #5185ff)}#ls-editor-form{display:flex;width:100%;height:calc(100cqh - 2.25rem);min-height:0;position:relative;overflow:hidden;background:var(--gray-10, #f7f8fa);box-shadow:0 2px 6px 0 rgba(0, 0, 0, 0.04) inset, 0 10px 15px 0 rgba(0, 0, 0, 0.04) inset}.ls-dv-hidden{visibility:hidden;display:none;width:0px}.ls-dv-page-header{position:relative;display:flex;height:2.25rem;gap:0.5rem;padding:0.25rem 0.75rem;justify-content:center;align-items:center}.ls-dv-header-text-1{color:var(--gray-100, #45484d);font-size:0.875rem;font-style:normal;font-weight:500;line-height:1.25rem}.ls-dv-header-text-2{color:var(--gray-100, #45484d);font-size:0.875rem;font-style:normal;font-weight:400;line-height:1.25rem}.ls-dv-expand-fields-row{display:flex;align-items:center;gap:0.5rem;padding:0.5rem;cursor:pointer;color:var(--gray-80, #6f7176);font-size:0.875rem;font-style:normal;font-weight:500;line-height:1.25rem;}.ls-dv-expand-fields-row p{color:var(--gray-100, #45484d);font-size:1rem;font-style:normal;font-weight:500;line-height:1.5rem;}p{color:var(--gray-80, #6f7176);font-family:var(--font-family);font-size:var(--text-sm);font-style:normal;font-weight:400;line-height:var(--text-sm-line-height)}a{color:var(--primary-60, #4456f6);font-size:var(--text-sm);font-style:normal;font-weight:400;line-height:var(--text-sm-line-height);cursor:pointer}a:hover{text-decoration:underline;color:var(--primary-70, #2134dc)}.ls-dv-button-link,.ls-dv-button-link:hover{all:unset}select{appearance:none;height:2.25rem}.ls-dv-input-wrapper{position:relative;width:fit-content}#selectorIcon{position:absolute;top:50%;right:0.675rem;transform:translateY(-50%);pointer-events:none;color:var(--gray-80, #6f7176)}#selectLeadingIcon{position:absolute;top:50%;left:0.675rem;transform:translateY(-50%);pointer-events:none;color:var(--gray-80, #6f7176)}.ls-dv-has-leading-icon{padding-left:2.5rem}input,select,textarea{border:1px solid var(--gray-40, #d8d9dc);box-shadow:0 1px 0.125rem rgba(0, 0, 0, 0.05);padding:0.5rem 0.75rem;font-family:var(--font-family);font-size:var(--text-sm);border-radius:0.625rem;color:var(--gray-100, #45484d);font-weight:400}input::placeholder,select::placeholder,textarea::placeholder{color:var(--gray-60, #afb0b2)}input:hover,select:hover,textarea:hover{border-color:var(--gray-50, #c8c9cc);background-color:var(--white, #ffffff)}input:focus,select:focus,textarea:focus{outline:none;box-shadow:0 0 0 0.25rem var(--primary-40, #79adfc);border-color:var(--primary-60, #4456f6);background-color:var(--white, #ffffff)}input:active,select:active,textarea:active{border-color:var(--primary-50, #5185ff)}input:disabled,select:disabled,textarea:disabled{cursor:not-allowed;background-color:var(--gray-10, #f7f8fa)}input[type=checkbox]{appearance:none;position:relative;height:1rem;width:1rem;padding:0.25rem;border-radius:var(--radius-sm);border:1px solid #d1d5db;background-color:#ffffff;cursor:pointer}input[type=checkbox]:checked,input[type=checkbox].ls-dv-indeterminate{background-color:var(--primary-60, #4456f6);border:none}input[type=checkbox]:checked::after{content:"";position:absolute;top:45%;left:50%;transform:translate(-50%, -50%) rotate(-45deg) scale(-1, 1);width:0.5rem;height:0.25rem;border-bottom:0.125rem solid white;border-right:0.125rem solid white}input[type=checkbox].ls-dv-indeterminate::after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);width:0.5rem;height:0.125rem;background-color:white}input[type=checkbox]:checked:hover,input[type=checkbox].ls-dv-indeterminate:hover{background-color:var(--primary-70, #2134dc);border:none}input[type=checkbox]:hover{border:1px solid #9ca3af}input[type=checkbox]:focus,input[type=checkbox]:active{outline:none;box-shadow:0 0 0 0.25rem var(--primary-20, #c7ddff);background-color:#f0f4f8}input[type=checkbox]:disabled{background-color:#f3f4f6;outline:none;cursor:not-allowed}input[type=checkbox]:disabled:checked{background-color:#e5e7eb;border:none;outline:none;cursor:not-allowed}.ls-dv-checkbox-container{display:flex;gap:0.5rem;width:100%}.ls-dv-checkbox-label{color:var(--gray-100, #45484d);font-size:1rem;font-style:normal;font-weight:400;line-height:1rem}.ls-dv-form-label{color:var(--gray-100, #45484d);font-size:1rem;font-style:normal;font-weight:500;line-height:1.5rem}.ls-dv-form-field{display:flex;flex-direction:column;gap:0.25rem;width:100%}.ls-dv-loading-box{display:flex;justify-content:center;align-items:center;width:100%;height:100%;color:var(--primary-60, #4456f6)}button{border:0;appearance:button;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;border-radius:var(--radius-lg);background-color:var(--primary-60, #4456f6);color:white;text-transform:capitalize;min-height:2.25rem;min-width:2.25rem}button.ls-dv-tertiary-grey{border:1px solid var(--gray-40, #d8d9dc);background-color:white;color:var(--gray-80, #6f7176)}button.ls-dv-tertiary-grey:hover{border:1px solid var(--gray-50, #c8c9cc);background:var(--gray-10, #f7f8fa)}.ls-dv-button-group{display:flex;border-radius:0.625rem;border:1px solid var(--gray-30, #e0e2e5);background:var(--white, #ffffff);overflow:clip}.ls-dv-button-group button{display:flex;background:transparent;border-radius:unset;padding:0.25rem 0.75rem;min-width:2.156rem;min-height:unset;color:var(--gray-80, #6f7176)}.ls-dv-button-group button:hover{background:var(--gray-10, #f7f8fa)}.ls-dv-button-group>:first-child{border-radius:0.625rem 0 0 0.625rem}.ls-dv-button-group>:last-child{border-radius:0 0.5rem 0.5rem 0}.ls-dv-button-group>:not(:first-child){border-left:1px solid var(--gray-30, #e0e2e5)}.ls-dv-error-state{position:absolute;display:flex;top:0;left:0;align-items:center;justify-content:center;height:100%;width:100%;z-index:4000;background-color:var(--gray-10, #f7f8fa)}.ls-dv-error-card{display:flex;flex-direction:column;align-items:center;gap:0.5rem;padding:2rem;border-radius:0.75rem;background:white;box-shadow:0 0.25rem 1rem rgba(0, 0, 0, 0.08);max-width:24rem;text-align:center;color:var(--gray-80, #6f7176)}.ls-dv-error-title{color:var(--gray-100, #45484d);font-size:1.125rem;font-weight:600;line-height:1.5rem}.ls-dv-error-message{color:var(--gray-80, #6f7176);font-size:0.875rem;line-height:1.25rem}`;if(typeof URL.parse!=="function"){URL.parse=function(t,e){try{return e?new URL(t,e):new URL(t)}catch{return null}}}ai.workerSrc=`https://unpkg.com/pdfjs-dist@5.4.449/build/pdf.worker.min.mjs`;const zr=class{constructor(s){t(this,s);this.pageRendered=e(this,"pageRendered",7);this.pageChange=e(this,"pageChange",7);this.selectFields=e(this,"selectFields",7);this.mutate=e(this,"mutate",7);this.update=e(this,"update",7);this.validate=e(this,"validate",7);this.addParticipant=e(this,"addParticipant",7)}get component(){return s(this)}isPageRendering;pdfDocument;pageNumPending=null;canvas;ctx;pageDimensions;isMoving=false;isBoxing=false;selectionBox=null;hitField;edgeSide;startLocations;startMouse;_isToolboxDragging=false;_cancelToolboxDrag=null;template;token;userpool;endpoint;templateid;recipients;_recipients;language;languageChanged(t){if(t){r.changeLanguage(t)}}zoom=1;pageNum=1;pageCount=1;signer=0;groupInfo;_template;validationErrors=[];status;error=null;errorTitle=null;fontSize=w;fontFamily=b;selected=[];isLoading=true;isMutating=false;selectedDataItems=[];fieldTypeSelected={label:"Signature",formElementType:"signature",elementType:"signature",validation:0,defaultHeight:27,defaultWidth:120};mode="editor";modeHandler(t,e){if(t==="preview"){this.showstatusbar=false;this.readonly=true}else if(t==="editor"){this.showstatusbar=true;this.readonly=false}else if(t==="compose"){this.showstatusbar=true;this.readonly=false}const s=this.component.shadowRoot?.querySelectorAll("ls-editor-field");if(s){s.forEach((e=>{e.setAttribute("readonly",String(t==="preview"))}))}}templateLockedHandler(){const t=this.component.shadowRoot?.querySelectorAll("ls-editor-field");if(t){t.forEach((t=>{t.setAttribute("readonly",String(this.mode==="preview"||this._template?.locked))}))}}zoomChanged(t){const e=this.component.shadowRoot.querySelectorAll("ls-editor-field");e.forEach((e=>e.setAttribute("zoom",String(t))));const s=this.component.shadowRoot.querySelector("ls-statusbar");if(s)s.zoom=t}manager="toolbox";displayTable=false;filtertoolbox=null;showstatusbar=false;showpagepreview=false;readonly=false;showtableview=false;toolboxFilter=null;pageRendered;pageChange;selectFields;mutate;update;validate;addParticipant;adapter;_skipHistory=false;mutateHandler(t){if(this.token&&this.adapter){const e=Array.isArray(t.detail)?t.detail:[t.detail];if(!this._skipHistory){const t=new Map;e.forEach((e=>{const s=e.data;if(e.action==="update"&&s?.id){const e=this.component.shadowRoot?.getElementById("ls-field-"+s.id);if(e?.dataItem){t.set(s.id,{...e.dataItem})}}else if(e.action==="delete"&&s?.id){const e=this.component.shadowRoot?.getElementById("ls-field-"+s.id);if(e?.dataItem){t.set(s.id,{...e.dataItem})}}}));I(e,t)}this._skipHistory=false;this.isMutating=true;const s=e.map((t=>this.adapter.handleEvent(t,this.token).then((e=>{if(e==="invalid")return;if(t.action==="update"&&t.data.roleType!=="WITNESS"){const e=t.data;const s=this._template.roles.find((t=>t.id===e.id));if(s&&s.name!==e.name){const t=this._template.roles.find((t=>t.signerParent===e.id&&t.roleType==="WITNESS"));if(t){const i=t.name==="Participant "+t.ordinal;const n=t.name===s.name+" Witness";if(i||n){const s={...t,name:e.name+" Witness"};this.adapter.handleEvent({action:"update",data:s},this.token).then((t=>{if(t!=="invalid")u.bind(this)(t)}))}}}}if(t.action==="swap"||t.action==="delete"){const s=t.action==="swap"?[{id:t.data.id,hadDefault:t.data.name==="Participant "+t.data.ordinal},{id:t.data2.id,hadDefault:t.data2.name==="Participant "+t.data2.ordinal}]:null;const i=t.action==="delete"?this._template.roles.filter((t=>t.name==="Participant "+t.ordinal)).map((t=>t.id)):null;return Promise.resolve(u.bind(this)(e)).then((()=>{const t=[];if(s){for(const{id:e,hadDefault:i}of s){if(!i)continue;const s=this._template.roles.find((t=>t.id===e));if(s&&s.name!=="Participant "+s.ordinal){t.push(this.adapter.handleEvent({action:"update",data:{...s,name:"Participant "+s.ordinal}},this.token).then((t=>{if(t!=="invalid")u.bind(this)(t)})))}}}if(i){for(const e of i){const s=this._template.roles.find((t=>t.id===e));if(s&&s.name!=="Participant "+s.ordinal){t.push(this.adapter.handleEvent({action:"update",data:{...s,name:"Participant "+s.ordinal}},this.token).then((t=>{if(t!=="invalid")u.bind(this)(t)})))}}}return Promise.all(t)}))}u.bind(this)(e)})).then((()=>this.syncChange(t))).catch((()=>{this.validationErrors=f.bind(this)(this._template);this.validate.emit({valid:this.validationErrors.length===0,errors:this.validationErrors})}))));Promise.all(s).finally((()=>{requestAnimationFrame((()=>{this.isMutating=false}))}))}}updateHandler(t){const e=t.detail;if(!e||!Array.isArray(e)||e.length===0)return;t.stopPropagation();const s=t.target;const i=s?.tagName==="LS-EDITOR-FIELD";for(const t of e){if(t?.action==="update"&&t?.data?.id){const e=t.data;this.selectedDataItems=this.selectedDataItems.map((t=>t.id===e.id?{...e}:t));const s=this.component.shadowRoot.getElementById("ls-toolbar");if(s?.dataItem){s.dataItem=s.dataItem.map((t=>t.id===e.id?{...e}:t))}if(!i){const t=this.component.shadowRoot?.getElementById("ls-field-"+e.id);if(t){t.dataItem={...e}}}}}const n={...this._template,elementConnection:{...this._template.elementConnection,templateElements:this._template.elementConnection.templateElements.map((t=>{const s=e.find((e=>e.action==="update"&&e.data?.id===t.id));return s?{...t,...s.data}:t}))}};this.validationErrors=f.bind(this)(n);this.validate.emit({valid:this.validationErrors.length===0,errors:this.validationErrors})}handleFieldTypeSelected(t){const e=this.component.shadowRoot.querySelectorAll("ls-toolbox-field");e.forEach((e=>{e.isSelected=e.formElementType===t.detail.formElementType}));this.fieldTypeSelected=t.detail}handleToolboxDragStart(t){S.bind(this)(t.detail)}addParticpantHandler(t){const e=this.groupInfo.experienceConnection.experiences.find((t=>t.defaultExperience===true));const s=t.detail.signerIndex>99?this._template.roles.find((e=>e.signerIndex===t.detail.signerIndex%100)):null;const i=t.detail.type==="WITNESS"?s.signerIndex+100:Math.max(...this._template.roles.filter((t=>t.roleType!=="WITNESS")).map((t=>t.signerIndex)))+1;const n=t.detail.signerIndex?t.detail.signerIndex:t.detail.type==="WITNESS"?100+s?.signerIndex:this._template.roles.length===0?1:i;const r=[{action:"create",data:{id:btoa("rol"+crypto.randomUUID()),name:t.detail.name?t.detail.name:t.detail.type==="WITNESS"?s?.name==="Participant "+s?.ordinal?"Participant "+(s?.ordinal+1):s?.name+" Witness":"Participant "+(this._template.roles.length+1),roleType:t.detail.type,signerIndex:n,ordinal:t.detail.type==="WITNESS"?s?.ordinal+1:this._template.roles.length+1,signerParent:t.detail.parent,experience:e.id,templateId:this._template.id}}];this.mutate.emit(r);this.signer=n}updateSigner(t){if(t.detail){this.signer=t.detail}}selectFieldForPlacement(t){const{signerIndex:e,fieldType:s}=t.detail;this.signer=e;const i=A[s]||A["signature"];let n;if(s==="signature"){n="signature"}else if(s==="initials"){n="initials"}else if(s==="auto sign"){n="admin"}else{n="text"}this.fieldTypeSelected={label:s,formElementType:s,elementType:n,validation:0,defaultHeight:i.defaultHeight,defaultWidth:i.defaultWidth};if(this.manager!=="toolbox"){this.manager="toolbox"}requestAnimationFrame((()=>{S.bind(this)(this.fieldTypeSelected)}))}selectFieldsHandler(t){const e=Array.from(this.component.shadowRoot.querySelectorAll("ls-editor-field"));this._template={...this._template,elementConnection:{...this._template.elementConnection,templateElements:e.map((t=>t.dataItem))}};var s=this.component.shadowRoot.getElementById("ls-toolbar");if(s){s.dataItem=t.detail}if(t.detail.length===0){this.selected=[]}else{console.log(t.detail,"selected");this.selectedDataItems=t.detail}const i=t.detail.length>1;e.forEach((t=>{t.selected=false;t.multiSelected=false}));t.detail.forEach((t=>{const e=this.component.shadowRoot.getElementById("ls-field-"+t.id);if(e){e.selected=true;e.multiSelected=i}}));this.selected=e.filter((t=>t.selected));if(t.detail.length===1){const e=this.component.shadowRoot.getElementById("ls-field-"+t.detail[0].id);if(e&&d(t.detail[0].validation)?.inputType==="date"&&this.mode!=="preview"){requestAnimationFrame((()=>{const t=e.shadowRoot?.getElementById("editing-input");if(t)t.showPicker()}))}}k.bind(this)();this.validationErrors=f.bind(this)(this._template)}roleHandler(t){this.signer=t.detail}async pageNext(){if(this.pageNum>=this.pdfDocument.numPages){return}this.pageNum+=1;this.queueRenderPage(this.pageNum);this.showPageFields(this.pageNum);this.pageResize();k.bind(this)()}async pagePrev(){if(this.pageNum<=1){return}this.pageNum-=1;this.queueRenderPage(this.pageNum);this.showPageFields(this.pageNum);this.pageResize();k.bind(this)()}async unselect(){const t=this.component.shadowRoot.querySelectorAll("ls-editor-field");t.forEach((t=>{t.selected=false}));this.selected=[];k.bind(this)()}pageResize(){this.canvas=this.component.shadowRoot.getElementById("pdf-canvas");const t=this.component.shadowRoot.getElementById("ls-document-frame");this.canvas.style.height=this.pageDimensions[this.pageNum-1].height*this.zoom+"px";this.canvas.style.width=this.pageDimensions[this.pageNum-1].width*this.zoom+"px";t.style.height=this.pageDimensions[this.pageNum-1].height*this.zoom+"px";t.style.width=this.pageDimensions[this.pageNum-1].width*this.zoom+"px"}async setZoom(t){this.zoom=t;this.pageResize();this.component.shadowRoot.querySelectorAll("ls-editor-field").forEach((t=>a.bind(this)(t,t.dataItem)));this.queueRenderPage(this.pageNum);this.showPageFields(this.pageNum);k.bind(this)()}clip(t,e=0){return t>1?e:t}parseTemplate(t){const e=JSON.parse(t);const s=JSON.parse(JSON.parse(e.pageDimensions));this.pageDimensions=s.map((t=>({height:t[1],width:t[0]})));const i=e.elementConnection.templateElements.map((t=>({...t,top:Math.floor(this.clip(t.ay)*this.pageDimensions[0].height),left:Math.floor(this.clip(t.ax)*this.pageDimensions[0].width),height:Math.floor((this.clip(t.by,.1)-this.clip(t.ay))*this.pageDimensions[0].height),width:Math.floor((this.clip(t.bx,.2)-this.clip(t.ax))*this.pageDimensions[0].width),templateId:e.id})));const n=e.roles.map((t=>({...t,templateId:e.id})));const r=n.some((t=>t.signerIndex===this.signer));if(!r){this.signer=n.length>0?1:0}this._template={...e,elementConnection:{...e.elementConnection,templateElements:i},roles:n}}RENDER_SCALE=2;renderPage(t){this.isPageRendering=true;if(this.pdfDocument!==undefined&&this.pdfDocument!==null){this.pdfDocument.getPage(t).then((t=>{const e=t.getViewport({scale:this.zoom*this.RENDER_SCALE});this.canvas.height=Math.floor(e.height);this.canvas.width=Math.floor(e.width);this.canvas.style.width=Math.floor(this.pageDimensions[this.pageNum-1].width*this.zoom)+"px";this.canvas.style.height=Math.floor(this.pageDimensions[this.pageNum-1].height*this.zoom)+"px";const s={canvasContext:this.ctx,viewport:e};const i=t.render(s);i.promise.then((()=>{this.isPageRendering=false;this.pageRendered.emit(this.pageNum);if(this.pageNumPending!==null){this.renderPage(this.pageNumPending);this.pageChange.emit(this.pageNumPending);this.pageNumPending=null}}))}))}}queueRenderPage(t){if(this.isPageRendering){this.pageNumPending=t}else{this.renderPage(t)}}loadAndRender(t){Gi(t).promise.then((t=>{this.pdfDocument=t;this.renderPage(this.pageNum)}))}prepareElement(t){return{...t,top:Math.floor(this.clip(t.ay)*this.pageDimensions[t.page-1].height),left:Math.floor(this.clip(t.ax)*this.pageDimensions[t.page-1].width),height:Math.floor((this.clip(t.by,.05)-this.clip(t.ay))*this.pageDimensions[t.page-1].height),width:Math.floor((this.clip(t.bx,.2)-this.clip(t.ax))*this.pageDimensions[t.page-1].width),pageDimensions:this.pageDimensions[t.page-1],templateId:this._template.id}}syncChange(t){if(t?.select==="clear"){this.unselect()}if(p(t.data)==="element"){if(t.action==="create");else if(t.action==="update"){const e=this.component.shadowRoot.getElementById("ls-field-"+t.data.id);if(e){a.bind(this)(e,t.data);const s=t.data.signer;const i=this.mode==="compose"?this._recipients?.find((t=>t.signerIndex===s)):this._template.roles.find((t=>t.signerIndex===s));e.setAttribute("assignee",s===0?"Sender":this.mode==="compose"&&i?.previousRecipientDecides===true?"To Be Decided":this.mode==="compose"?`${i?.firstName} ${i?.lastName}`:i?.name||`Participant ${s}`);this.selected=this.selected.map((s=>s.dataItem.id===t.data.id?e:s))}const s=this.component.shadowRoot.querySelectorAll("ls-editor-field");this.selected=Array.from(s).filter((t=>t.selected));this.selectedDataItems=this.selected.map((t=>t.dataItem));const i=this.component.shadowRoot.getElementById("ls-toolbar");if(i)i.dataItem=this.selectedDataItems;this._template={...this._template,elementConnection:{...this._template.elementConnection,templateElements:Array.from(s).map((t=>t.dataItem))}};this.selectedDataItems=this.selected.map((t=>t.dataItem));if(i)i.dataItem=this.selectedDataItems;k.bind(this)()}else if(t.action==="delete"){const e=this.component.shadowRoot.getElementById("ls-field-"+t.data.id);if(!e)return;const s=this._template.elementConnection.templateElements;this._template={...this._template,elementConnection:{...this._template.elementConnection,templateElements:s.filter((e=>e.id!==t.data.id))}};this.component.shadowRoot.getElementById("ls-document-frame").removeChild(e);this.selectFields.emit([])}else{console.warn("Unrecognised action, check Legalesign documentation. `create`, `update` and `delete` allowed.")}}this.validationErrors=f.bind(this)(this._template);this.validate.emit({valid:this.validationErrors.length===0,errors:this.validationErrors})}initViewer(){this.canvas=this.component.shadowRoot.getElementById("pdf-canvas");this.canvas.style.height=this.pageDimensions[this.pageNum-1].height*this.zoom+"px";this.canvas.style.width=this.pageDimensions[this.pageNum-1].width*this.zoom+"px";this.ctx=this.canvas.getContext("2d");if(this._template?.link)this.loadAndRender(this._template?.link);var t=this.component.shadowRoot.getElementById("ls-document-frame");var e=this.component.shadowRoot.getElementById("document-frame-wrapper");if(this.mode!=="preview"||this._template?.locked===true){t.addEventListener("click",M.bind(this));e.addEventListener("mousedown",C.bind(this));document.addEventListener("mousemove",T.bind(this));document.addEventListener("mouseup",E.bind(this));t.addEventListener("dblclick",P.bind(this));document.addEventListener("keydown",wr.bind(this))}const s=this.component.shadowRoot.getElementById("document-frame-wrapper");s.addEventListener("wheel",(t=>{if(!t.ctrlKey&&!t.metaKey)return;t.preventDefault();const e=t.deltaY>0?.95:1.05;const i=Math.min(Math.max(this.zoom*e,.25),5);const n=i/this.zoom;const r=s.getBoundingClientRect();const o=t.clientX-r.left;const a=t.clientY-r.top;s.scrollLeft=(s.scrollLeft+o)*n-o;s.scrollTop=(s.scrollTop+a)*n-a;this.setZoom(Math.round(i*100)/100)}),{passive:false});this.generateFields()}generateFields(t=true){if(t){const t=this.component.shadowRoot.querySelectorAll("ls-editor-field");t.forEach((t=>this.component.shadowRoot.getElementById("ls-document-frame").removeChild(t)))}const e=[...this._template.elementConnection.templateElements];this._template={...this._template,elementConnection:{...this._template.elementConnection,templateElements:[]}};e.forEach((t=>{g.bind(this)(this.component.shadowRoot.getElementById("ls-document-frame"),this.prepareElement(t))}))}showPageFields(t){const e=this.component.shadowRoot.querySelectorAll("ls-editor-field");Array.from(e).forEach((e=>{e.className=e.dataItem.page===t?"":"ls-dv-hidden";const s=e.dataItem;const i=this.mode==="compose"?this._recipients?.find((t=>t.signerIndex===s.signer)):this._template.roles.find((t=>t.signerIndex===s.signer));e.setAttribute("assignee",this.mode==="compose"&&i?.previousRecipientDecides===true?"To Be Decided":this.mode==="compose"?`${i?.firstName} ${i?.lastName}`:i?.name||`Participant ${s.signer}`)}))}async load(){this.isLoading=true;try{this.adapter=new _r(this.endpoint);const t=await this.adapter.execute(this.token,m(this.templateid));this.parseTemplate(JSON.stringify(t.template));const e=await this.adapter.execute(this.token,Br(this._template.groupId));this.groupInfo=e.group;this.initViewer();if(this.mode==="compose"){this.manager="recipient";if(!this.recipients){throw new Error('Compose mode requires a "recipients" attribute. See documentation for the expected JSON format.')}this._recipients=JSON.parse(this.recipients.replace('"','"')).sort(((t,e)=>{const s=t.signerIndex%100||100;const i=e.signerIndex%100||100;if(s!==i)return s-i;if(t.signerIndex<100&&e.signerIndex>=100)return-1;if(t.signerIndex>=100&&e.signerIndex<100)return 1;return t.signerIndex-e.signerIndex}));Lr.bind(this)()}this.validationErrors=f.bind(this)(this._template);this.validate.emit({valid:this.validationErrors.length===0,errors:this.validationErrors});this.pageCount=this._template.pageCount;this.selected=[];this.setZoom(1);this.isLoading=false;if(this.mode==="preview"){requestAnimationFrame((()=>{const t=this.component.shadowRoot.getElementById("ls-mid-area");const e=this.component.shadowRoot.getElementById("document-frame-wrapper");const s=getComputedStyle(e);const i=parseFloat(s.paddingTop)+parseFloat(s.paddingBottom);const n=parseFloat(s.paddingLeft)+parseFloat(s.paddingRight);const r=t.clientHeight-i;const o=t.clientWidth-n;const a=r/this.pageDimensions[this.pageNum-1].height;const h=o/this.pageDimensions[this.pageNum-1].width;const c=Math.min(a,h);this.setZoom(Math.round(c*100)/100)}))}}catch(t){this.isLoading=false;const e=t?.message?.includes("401")||t?.message?.includes("403")||t?.message?.includes("Unauthorized")||t?.status===401||t?.status===403;if(e){console.error("Authentication failed.",t);this.errorTitle=r.t("viewer.autherror");this.error=r.t("viewer.autherrormessage")}else{console.error("Failed to load template.",t?.message||t);this.errorTitle=r.t("viewer.loaderror");this.error=r.t("viewer.loaderrormessage")}}}componentWillLoad(){if(this.language){r.changeLanguage(this.language)}if(this.token&&!this._template)this.load()}componentDidLoad(){}handleManagerChange(t){this.manager=t}showTool(t){return this.filtertoolbox===null||this.filtertoolbox.split("|").includes(t)}checkType(t){if(this.mode==="compose"&&this._recipients){return this._recipients.find((e=>e.roleType===t&&e.signerIndex===this.signer))!==undefined}else if(this._template){return this._template.roles.find((e=>e.roleType===t&&e.signerIndex===this.signer))!==undefined}else return false}render(){return i(n,{key:"4d4c75a54c91e7273c430d8c2b282baa73df1e00"},i(i.Fragment,null,this.isLoading&&i(i.Fragment,null,i("div",{key:"16fddb4381e60acd21ccb788f7384d462c9842f4",class:"ls-dv-page-loader"},i("ls-loading-logo",{key:"06f725f8d84b42705fc4ddd3fd30cd1b0080f0b6",size:200,colour:"var(--primary-60)"})),i("div",{key:"4111150eb3477de0f4009ed9a1804e1e64462912",class:"ls-dv-custom-loader-slot"},i("slot",{key:"78000f2316bce8a385b569e01ff8f588d77b37a2",name:"custom-loader"})),this.mode==="compose"&&i("ls-compose-loader",{key:"f4db44ff52abffca9e085e165e6efd8cd5cae9ad"})),this.error&&i("div",{key:"1dba9f3d2b69fbcc148bd788260bbd5bbf0833eb",class:"ls-dv-error-state"},i("div",{key:"58c86e02e48c7114aa3dce362716591638ac1cb0",class:"ls-dv-error-card"},i("ls-icon",{key:"340716a3374fcb4001079280ca02d0c9ff7f449b",name:"exclamation-circle-icon",size:32,style:{color:"var(--red-60, #dc2626)"}}),i("p",{key:"52948097994a8a4f838303b851a5b0e2470cb2de",class:"ls-dv-error-title"},this.errorTitle),i("p",{key:"75d191ca2ff7fe750dd0fe330cdde575971f95b2",class:"ls-dv-error-message"},this.error))),i("div",{key:"f5ff447ed5f8b0609aec7adc244c2fa1ee78f6e5",class:"ls-dv-page-header"},i("div",{key:"a01d517df7980287605cf8efc2aa4e6668c59173",class:"ls-dv-left-slot-wrapper"},i("slot",{key:"8aacd47986783c01bf8c1d593ce5bd1142facfc5",name:"left-button"})),i("div",{key:"b9e9245183f497757d3684ab25bd52279b2d0bf0",class:"ls-dv-right-slot-wrapper"},i("slot",{key:"7ce7e1b8449cee24a8fa6f99645b98f1ec67f4f3",name:"right-button"})),this.mode==="editor"&&i("div",{key:"7ae7ab56697b25a04fadb171be58efa32124a480"},i("span",{key:"7653b69dd162c49a0d87fe4584204f759bde97fc",class:"ls-dv-header-text-1"},r.t("viewer.templatecreation")),i("span",{key:"91225711049bfbb4bfd42b1c3ba4fffbfb8913b7"},"/"),i("span",{key:"f4fcda04089ccdf5cc86999ba399a5017ea461e3",class:"ls-dv-header-text-2"},this._template?.title)),this.mode==="compose"&&i("div",{key:"6bfa21d0e4c80395e1e6477074cdc0d989f12a1d",style:{display:"flex",alignItems:"center",gap:"0.25rem"}},i("slot",{key:"2a749c7fbd2f89e2bdba59b3a627be3decca9b1e",name:"top-bar"}))),i("form",{key:"436b84d724bef775dbe8e60abcfd3b1b6223b915",id:"ls-editor-form"},i("ls-left-bar",{key:"ee19abe6108dbae2ee8348a4a98ccb74c5ae72d4",mode:this.mode,selected:this.selected,manager:this.manager,signer:this.signer,filtertoolbox:this.filtertoolbox,template:this._template,recipients:this._recipients,validationErrors:this.validationErrors,fieldTypeSelected:this.fieldTypeSelected,displayTable:this.displayTable,selectedDataItems:this.selectedDataItems,busy:this.isMutating,onManagerChange:t=>this.handleManagerChange(t.detail),onClearSelected:()=>{this.unselect();const t=this.component.shadowRoot.getElementById("ls-toolbar");if(t)t.dataItem=[]}},i("slot",{key:"7da43061411b20834f28e6149bd1508d227ae4b9",name:"recipient-panel",slot:"recipient-panel"})),i("ls-toolbar",{key:"fb6b389c2c3d75eac4ff2b802ee0bd0728a7c7e1",id:"ls-toolbar",template:this._template,editor:this,groupInfo:this.groupInfo,mode:this.mode,signer:this.signer,selected:this.selected,pageNum:this.pageNum}),i("div",{key:"d8bd7fd6b6fcc26887376c8762589a8cec26b8dc",id:"ls-mid-area"},i("div",{key:"808c838b658d92d451592decf4b8113311e8d6cd",class:{"ls-dv-document-frame-wrapper":true,"ls-dv-document-frame-wrapper--preview":this.mode==="preview"},id:"document-frame-wrapper"},i("div",{key:"2a3332e5d99adf1727527f297dadc1de7efbb9c0",id:"ls-document-frame"},i("canvas",{key:"de67fd9855263650465fb7c1f818bccb2d594d55",id:"pdf-canvas",class:this.displayTable||this.isLoading?"ls-dv-hidden":""}),i("ls-editor-table",{key:"9ab1d398e33a5e8e9743017b95b700a7b625d6ba",editor:this,class:this.displayTable?"":"ls-dv-hidden"}),i("div",{key:"ed7c0ace0a6b2defdee1dd2479bf3c53af89bb4a",id:"ls-box-selector"}),i("div",{key:"2f862b72b295be46c2220dc159150b3531db20f0",id:"ls-drag-selector"}),this.mode!=="preview"&&!this._template?.locked&&!this.isLoading&&this._template?.elementConnection?.templateElements?.length>0&&i("ls-select-menu",{key:"6d8417c85f3dd9119089408b7735f50075e0048f",class:"ls-dv-select-menu-position",selected:this.selected,pageNum:this.pageNum,editor:this}),this.mode!=="preview"&&!this._template?.locked&&!this.isLoading&&this._template?.elementConnection?.templateElements?.length>0&&i("ls-select-menu",{key:"c57c5e3c6a199426a3d1884aebca895adf6be195",class:"ls-dv-select-menu-floating",selected:this.selected,pageNum:this.pageNum,editor:this,floating:true}))),i("ls-statusbar",{key:"f5987ae88a446e19a54c051ed7b0d420ce62e739",editor:this,page:this.pageNum,pageCount:this.pageCount,mode:this.mode}),this.mode==="editor"&&i("div",{key:"37f5e0db9b1a55b1d8bde72de1dcaec584b99b8c",class:"ls-dv-validation-tag-wrapper"},i("ls-validation-tag",{key:"9494671b07d6542111b42c05908a5f1c150daa83",validationErrors:this.validationErrors}),i("slot",{key:"80e799322771024181781da6cf268ff0986cdfef",name:"next-button"}))))),i("ls-tooltip",{key:"e13794838bb1484beb2c0b4bee1647b66e144042",tooltipId:"ls-dv-tooltip"}))}static get watchers(){return{language:["languageChanged"],mode:["modeHandler"],_template:["templateLockedHandler"],zoom:["zoomChanged"]}}};zr.style=jr();export{zr as ls_document_viewer};
24
+ //# sourceMappingURL=p-762b88d0.entry.js.map