@pdfme/ui 5.2.12-dev.0 → 5.2.12-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -12396,6 +12396,22 @@ const gT = /* @__PURE__ */ new Map(), vT = /* @__PURE__ */ new Map(), eIe = (e)
12396
12396
  return n % i;
12397
12397
  case "**":
12398
12398
  return n ** i;
12399
+ case "==":
12400
+ return n == i;
12401
+ case "!=":
12402
+ return n != i;
12403
+ case "===":
12404
+ return n === i;
12405
+ case "!==":
12406
+ return n !== i;
12407
+ case "<":
12408
+ return n < i;
12409
+ case ">":
12410
+ return n > i;
12411
+ case "<=":
12412
+ return n <= i;
12413
+ case ">=":
12414
+ return n >= i;
12399
12415
  default:
12400
12416
  throw new Error(`Unsupported operator: ${r.operator}`);
12401
12417
  }
package/dist/index.umd.js CHANGED
@@ -55,7 +55,7 @@ Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=1
55
55
  `;break;default:e+=String.fromCharCode(r);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},an.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(ve.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
56
56
  `&&++this.pos;case`
57
57
  `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},an.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
58
- `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Ld(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var r=this.pos-1;this.invalidStringToken(r,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(n,8);return i>255&&(n=n.slice(0,-1),i=parseInt(n,8)),this.pos+=n.length-1,t=this.input.charCodeAt(this.pos),(n!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-n.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return Zv(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},an.readHexChar=function(e){var t=this.pos,r=this.readInt(16,e);return r===null&&this.invalidStringToken(t,"Bad character escape sequence"),r},an.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,r=this.pos,n=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(Xv(i,n))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(r,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var o=this.readCodePoint();(t?Fd:Xv)(o,n)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=Ld(o),r=this.pos}else break;t=!1}return e+this.input.slice(r,this.pos)},an.readWord=function(){var e=this.readWord1(),t=ve.name;return this.keywords.test(e)&&(t=vO[e]),this.finishToken(t,e)};var sIe="8.14.0";ia.acorn={Parser:ia,version:sIe,defaultOptions:mO,Position:zw,SourceLocation:r3,getLineInfo:VK,Node:s3,TokenType:wn,tokTypes:ve,keywordTypes:vO,TokContext:fc,tokContexts:li,isIdentifierChar:Xv,isIdentifierStart:Fd,Token:MO,isNewLine:Zv,lineBreak:El,lineBreakG:RSe,nonASCIIwhitespace:QK};function lIe(e,t,r){return ia.parseExpressionAt(e,t,r)}const RO=new Map,PO=new Map,cIe=e=>{const t=JSON.stringify(e);if(PO.has(t))return PO.get(t);const r=Object.fromEntries(Object.entries(e).map(([n,i])=>{if(typeof i=="string")try{const a=JSON.parse(i);return[n,a]}catch{return[n,i]}return[n,i]}));return PO.set(t,r),r},u3=e=>String(e).padStart(2,"0"),Sq=e=>`${e.getFullYear()}/${u3(e.getMonth()+1)}/${u3(e.getDate())}`,uIe=e=>`${Sq(e)} ${u3(e.getHours())}:${u3(e.getMinutes())}`,Iq={Math,String,Number,Boolean,Array,Object,Date,JSON,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent},bo=e=>{switch(e.type){case"Literal":case"Identifier":break;case"BinaryExpression":case"LogicalExpression":{const t=e;bo(t.left),bo(t.right);break}case"UnaryExpression":{bo(e.argument);break}case"ConditionalExpression":{const t=e;bo(t.test),bo(t.consequent),bo(t.alternate);break}case"MemberExpression":{const t=e;if(bo(t.object),t.computed)bo(t.property);else{const r=t.property.name;if(["constructor","__proto__","prototype"].includes(r))throw new Error("Access to prohibited property");if(typeof r=="string"&&["toLocaleString","valueOf"].includes(r))throw new Error(`Access to prohibited method: ${r}`)}break}case"CallExpression":{const t=e;bo(t.callee),t.arguments.forEach(bo);break}case"ArrayExpression":{e.elements.forEach(r=>{r&&bo(r)});break}case"ObjectExpression":{e.properties.forEach(r=>{const n=r;bo(n.key),bo(n.value)});break}case"ArrowFunctionExpression":{const t=e;t.params.forEach(r=>{if(r.type!=="Identifier")throw new Error("Only identifier parameters are supported in arrow functions");bo(r)}),bo(t.body);break}default:throw new Error(`Unsupported syntax in placeholder: ${e.type}`)}},Pa=(e,t)=>{switch(e.type){case"Literal":return e.value;case"Identifier":{const r=e;if(Object.prototype.hasOwnProperty.call(t,r.name))return t[r.name];if(Object.prototype.hasOwnProperty.call(Iq,r.name))return Iq[r.name];throw new Error(`Undefined variable: ${r.name}`)}case"BinaryExpression":{const r=e,n=Pa(r.left,t),i=Pa(r.right,t);switch(r.operator){case"+":return n+i;case"-":return n-i;case"*":return n*i;case"/":return n/i;case"%":return n%i;case"**":return n**i;default:throw new Error(`Unsupported operator: ${r.operator}`)}}case"LogicalExpression":{const r=e,n=Pa(r.left,t),i=Pa(r.right,t);switch(r.operator){case"&&":return n&&i;case"||":return n||i;default:throw new Error(`Unsupported operator: ${r.operator}`)}}case"UnaryExpression":{const r=e,n=Pa(r.argument,t);switch(r.operator){case"+":return+n;case"-":return-n;case"!":return!n;default:throw new Error(`Unsupported operator: ${r.operator}`)}}case"ConditionalExpression":{const r=e,n=Pa(r.test,t);return Pa(n?r.consequent:r.alternate,t)}case"MemberExpression":{const r=e,n=Pa(r.object,t);let i;if(r.computed?i=Pa(r.property,t):i=r.property.name,typeof i=="string"||typeof i=="number"){if(typeof i=="string"&&["constructor","__proto__","prototype"].includes(i))throw new Error("Access to prohibited property");return n[i]}else throw new Error("Invalid property access")}case"CallExpression":{const r=e,n=Pa(r.callee,t),i=r.arguments.map(a=>Pa(a,t));if(typeof n=="function")if(r.callee.type==="MemberExpression"){const a=r.callee,o=Pa(a.object,t);if(o!==null&&(typeof o=="object"||typeof o=="number"||typeof o=="string"||typeof o=="boolean"))return n.call(o,...i);throw new Error("Invalid object in member function call")}else return n(...i);else throw new Error("Attempted to call a non-function")}case"ArrowFunctionExpression":{const r=e,n=r.params.map(a=>a.name),i=r.body;return(...a)=>{const o={...t};return n.forEach((s,l)=>{o[s]=a[l]}),Pa(i,o)}}case"ArrayExpression":return e.elements.map(n=>n?Pa(n,t):null);case"ObjectExpression":{const r=e,n={};return r.properties.forEach(i=>{const a=i;let o;if(a.key.type==="Identifier")o=a.key.name;else{const l=Pa(a.key,t);if(typeof l!="string"&&typeof l!="number")throw new Error("Object property keys must be strings or numbers");o=String(l)}const s=Pa(a.value,t);n[o]=s}),n}default:throw new Error(`Unsupported syntax in placeholder: ${e.type}`)}},Bq=e=>{const{content:t,context:r}=e;let n="",i=0;for(;i<t.length;){const a=t.indexOf("{",i);if(a===-1){n+=t.slice(i);break}n+=t.slice(i,a);let o=1,s=a+1;for(;s<t.length&&o>0;)t[s]==="{"?o++:t[s]==="}"&&o--,s++;if(o===0){const l=t.slice(a+1,s-1).trim();if(RO.has(l)){const c=RO.get(l);try{const u=c(r);n+=String(u)}catch{n+=t.slice(a,s)}}else try{const c=lIe(l,0,{ecmaVersion:"latest"});bo(c);const u=f=>Pa(c,f);RO.set(l,u);const d=u(r);n+=String(d)}catch{n+=t.slice(a,s)}i=s}else throw new Error("Invalid placeholder")}return n},DO=e=>{const{content:t,variables:r,schemas:n}=e;if(!t||typeof t!="string"||!t.includes("{")||!t.includes("}"))return t;const i=new Date,a=Sq(i),o=uIe(i),s={...Object.fromEntries(n.flat().map(u=>[u.name,u.readOnly&&u.content||""])),...r},l=cIe(s),c={date:a,dateTime:o,...l};return Object.entries(c).forEach(([u,d])=>{typeof d=="string"&&d.includes("{")&&d.includes("}")&&(c[u]=Bq({content:d,context:c}))}),Bq({content:t,context:c})},TO="en",hc="[@pdfme/ui] this instance is already destroyed",Mq="selectable",aa=30,Rq=10,_O=45,Uw=400,Pq="rgb(74, 74, 74)";var Kw={};Kw.d=(e,t)=>{for(var r in t)Kw.o(t,r)&&!Kw.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},Kw.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Pr=globalThis.pdfjsLib={};Kw.d(Pr,{AbortException:()=>zp,AnnotationEditorLayer:()=>vk,AnnotationEditorParamsType:()=>Br,AnnotationEditorType:()=>jr,AnnotationEditorUIManager:()=>Vp,AnnotationLayer:()=>l3e,AnnotationMode:()=>Sh,ColorPicker:()=>SX,DOMSVGFactory:()=>uk,DrawLayer:()=>mk,FeatureTest:()=>Vo,GlobalWorkerOptions:()=>zd,ImageKind:()=>d3,InvalidPDFException:()=>Tq,MissingPDFException:()=>Hp,OPS:()=>pc,OutputScale:()=>GO,PDFDataRangeTransport:()=>dX,PDFDateString:()=>WO,PDFWorker:()=>im,PasswordResponses:()=>pIe,PermissionFlag:()=>hIe,PixelsPerInch:()=>Bh,RenderingCancelledException:()=>HO,TextLayer:()=>nC,UnexpectedResponseException:()=>A3,Util:()=>rr,VerbosityLevel:()=>f3,XfaLayer:()=>AX,build:()=>HBe,createValidAbsoluteUrl:()=>mIe,fetchData:()=>v3,getDocument:()=>_Be,getFilenameFromUrl:()=>BIe,getPdfFilenameFromUrl:()=>MIe,getXfaPageViewport:()=>RIe,isDataScheme:()=>m3,isPdfFile:()=>zO,noContextMenu:()=>Ml,normalizeUnicode:()=>EIe,setLayerDimensions:()=>Wp,shadow:()=>dn,version:()=>QBe});const yo=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Dq=[1,0,0,1,0,0],OO=[.001,0,0,.001,0,0],dIe=1e7,kO=1.35,Ls={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Sh={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},fIe="pdfjs_internal_editor_",jr={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Br={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},hIe={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},wo={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},d3={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},oa={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},qw={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},f3={ERRORS:0,WARNINGS:1,INFOS:5},pc={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},pIe={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let h3=f3.WARNINGS;function AIe(e){Number.isInteger(e)&&(h3=e)}function gIe(){return h3}function p3(e){h3>=f3.INFOS&&console.log(`Info: ${e}`)}function Gr(e){h3>=f3.WARNINGS&&console.log(`Warning: ${e}`)}function ei(e){throw new Error(e)}function sa(e,t){e||ei(t)}function vIe(e){switch(e==null?void 0:e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function mIe(e,t=null,r=null){if(!e)return null;try{if(r&&typeof e=="string"){if(r.addDefaultProtocol&&e.startsWith("www.")){const i=e.match(/\./g);(i==null?void 0:i.length)>=2&&(e=`http://${e}`)}if(r.tryConvertEncoding)try{e=xIe(e)}catch{}}const n=t?new URL(e,t):new URL(e);if(vIe(n))return n}catch{}return null}function dn(e,t,r,n=!1){return Object.defineProperty(e,t,{value:r,enumerable:!n,configurable:!0,writable:!1}),r}const Ih=function(){function t(r,n){this.message=r,this.name=n}return t.prototype=new Error,t.constructor=t,t}();class FO extends Ih{constructor(t,r){super(t,"PasswordException"),this.code=r}}class LO extends Ih{constructor(t,r){super(t,"UnknownErrorException"),this.details=r}}class Tq extends Ih{constructor(t){super(t,"InvalidPDFException")}}class Hp extends Ih{constructor(t){super(t,"MissingPDFException")}}class A3 extends Ih{constructor(t,r){super(t,"UnexpectedResponseException"),this.status=r}}class bIe extends Ih{constructor(t){super(t,"FormatError")}}class zp extends Ih{constructor(t){super(t,"AbortException")}}function _q(e){(typeof e!="object"||(e==null?void 0:e.length)===void 0)&&ei("Invalid argument for bytesToString");const t=e.length,r=8192;if(t<r)return String.fromCharCode.apply(null,e);const n=[];for(let i=0;i<t;i+=r){const a=Math.min(i+r,t),o=e.subarray(i,a);n.push(String.fromCharCode.apply(null,o))}return n.join("")}function g3(e){typeof e!="string"&&ei("Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let n=0;n<t;++n)r[n]=e.charCodeAt(n)&255;return r}function yIe(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function NO(e){const t=Object.create(null);for(const[r,n]of e)t[r]=n;return t}function wIe(){const e=new Uint8Array(4);return e[0]=1,new Uint32Array(e.buffer,0,1)[0]===1}function CIe(){try{return new Function(""),!0}catch{return!1}}class Vo{static get isLittleEndian(){return dn(this,"isLittleEndian",wIe())}static get isEvalSupported(){return dn(this,"isEvalSupported",CIe())}static get isOffscreenCanvasSupported(){return dn(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?dn(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):dn(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,r;return dn(this,"isCSSRoundSupported",(r=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:r.call(t,"width: round(1.5px, 1px)"))}}const $O=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,"0"));class rr{static makeHexColor(t,r,n){return`#${$O[t]}${$O[r]}${$O[n]}`}static scaleMinMax(t,r){let n;t[0]?(t[0]<0&&(n=r[0],r[0]=r[2],r[2]=n),r[0]*=t[0],r[2]*=t[0],t[3]<0&&(n=r[1],r[1]=r[3],r[3]=n),r[1]*=t[3],r[3]*=t[3]):(n=r[0],r[0]=r[1],r[1]=n,n=r[2],r[2]=r[3],r[3]=n,t[1]<0&&(n=r[1],r[1]=r[3],r[3]=n),r[1]*=t[1],r[3]*=t[1],t[2]<0&&(n=r[0],r[0]=r[2],r[2]=n),r[0]*=t[2],r[2]*=t[2]),r[0]+=t[4],r[1]+=t[5],r[2]+=t[4],r[3]+=t[5]}static transform(t,r){return[t[0]*r[0]+t[2]*r[1],t[1]*r[0]+t[3]*r[1],t[0]*r[2]+t[2]*r[3],t[1]*r[2]+t[3]*r[3],t[0]*r[4]+t[2]*r[5]+t[4],t[1]*r[4]+t[3]*r[5]+t[5]]}static applyTransform(t,r){const n=t[0]*r[0]+t[1]*r[2]+r[4],i=t[0]*r[1]+t[1]*r[3]+r[5];return[n,i]}static applyInverseTransform(t,r){const n=r[0]*r[3]-r[1]*r[2],i=(t[0]*r[3]-t[1]*r[2]+r[2]*r[5]-r[4]*r[3])/n,a=(-t[0]*r[1]+t[1]*r[0]+r[4]*r[1]-r[5]*r[0])/n;return[i,a]}static getAxialAlignedBoundingBox(t,r){const n=this.applyTransform(t,r),i=this.applyTransform(t.slice(2,4),r),a=this.applyTransform([t[0],t[3]],r),o=this.applyTransform([t[2],t[1]],r);return[Math.min(n[0],i[0],a[0],o[0]),Math.min(n[1],i[1],a[1],o[1]),Math.max(n[0],i[0],a[0],o[0]),Math.max(n[1],i[1],a[1],o[1])]}static inverseTransform(t){const r=t[0]*t[3]-t[1]*t[2];return[t[3]/r,-t[1]/r,-t[2]/r,t[0]/r,(t[2]*t[5]-t[4]*t[3])/r,(t[4]*t[1]-t[5]*t[0])/r]}static singularValueDecompose2dScale(t){const r=[t[0],t[2],t[1],t[3]],n=t[0]*r[0]+t[1]*r[2],i=t[0]*r[1]+t[1]*r[3],a=t[2]*r[0]+t[3]*r[2],o=t[2]*r[1]+t[3]*r[3],s=(n+o)/2,l=Math.sqrt((n+o)**2-4*(n*o-a*i))/2,c=s+l||1,u=s-l||1;return[Math.sqrt(c),Math.sqrt(u)]}static normalizeRect(t){const r=t.slice(0);return t[0]>t[2]&&(r[0]=t[2],r[2]=t[0]),t[1]>t[3]&&(r[1]=t[3],r[3]=t[1]),r}static intersect(t,r){const n=Math.max(Math.min(t[0],t[2]),Math.min(r[0],r[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(r[0],r[2]));if(n>i)return null;const a=Math.max(Math.min(t[1],t[3]),Math.min(r[1],r[3])),o=Math.min(Math.max(t[1],t[3]),Math.max(r[1],r[3]));return a>o?null:[n,a,i,o]}static bezierBoundingBox(t,r,n,i,a,o,s,l,c){return c?(c[0]=Math.min(c[0],t,s),c[1]=Math.min(c[1],r,l),c[2]=Math.max(c[2],t,s),c[3]=Math.max(c[3],r,l)):c=[Math.min(t,s),Math.min(r,l),Math.max(t,s),Math.max(r,l)],he(this,Ef,VW).call(this,t,n,a,s,r,i,o,l,3*(-t+3*(n-a)+s),6*(t-2*n+a),3*(n-t),c),he(this,Ef,VW).call(this,t,n,a,s,r,i,o,l,3*(-r+3*(i-o)+l),6*(r-2*i+o),3*(i-r),c),c}}Ef=new WeakSet,w8=function(t,r,n,i,a,o,s,l,c,u){if(c<=0||c>=1)return;const d=1-c,f=c*c,p=f*c,A=d*(d*(d*t+3*c*r)+3*f*n)+p*i,v=d*(d*(d*a+3*c*o)+3*f*s)+p*l;u[0]=Math.min(u[0],A),u[1]=Math.min(u[1],v),u[2]=Math.max(u[2],A),u[3]=Math.max(u[3],v)},VW=function(t,r,n,i,a,o,s,l,c,u,d,f){if(Math.abs(c)<1e-12){Math.abs(u)>=1e-12&&he(this,Ef,w8).call(this,t,r,n,i,a,o,s,l,-d/u,f);return}const p=u**2-4*d*c;if(p<0)return;const A=Math.sqrt(p),v=2*c;he(this,Ef,w8).call(this,t,r,n,i,a,o,s,l,(-u+A)/v,f),he(this,Ef,w8).call(this,t,r,n,i,a,o,s,l,(-u-A)/v,f)},be(rr,Ef);function xIe(e){return decodeURIComponent(escape(e))}let jO=null,Oq=null;function EIe(e){return jO||(jO=/([\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,Oq=new Map([["ſt","ſt"]])),e.replaceAll(jO,(t,r,n)=>r?r.normalize("NFKC"):Oq.get(n))}function SIe(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const e=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(e);else for(let t=0;t<32;t++)e[t]=Math.floor(Math.random()*255);return _q(e)}const QO="pdfjs_internal_id_",jd={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};function IIe(e){return Uint8Array.prototype.toBase64?e.toBase64():btoa(_q(e))}const Qd="http://www.w3.org/2000/svg",Ag=class Ag{};Rr(Ag,"CSS",96),Rr(Ag,"PDF",72),Rr(Ag,"PDF_TO_CSS_UNITS",Ag.CSS/Ag.PDF);let Bh=Ag;async function v3(e,t="text"){if(Zw(e,document.baseURI)){const r=await fetch(e);if(!r.ok)throw new Error(r.statusText);switch(t){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"json":return r.json()}return r.text()}return new Promise((r,n)=>{const i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":r(i.response);return}r(i.responseText);return}n(new Error(i.statusText))}},i.send(null)})}class Xw{constructor({viewBox:t,scale:r,rotation:n,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.scale=r,this.rotation=n,this.offsetX=i,this.offsetY=a;const s=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,u,d,f;switch(n%=360,n<0&&(n+=360),n){case 180:c=-1,u=0,d=0,f=1;break;case 90:c=0,u=1,d=1,f=0;break;case 270:c=0,u=-1,d=-1,f=0;break;case 0:c=1,u=0,d=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(d=-d,f=-f);let p,A,v,g;c===0?(p=Math.abs(l-t[1])*r+i,A=Math.abs(s-t[0])*r+a,v=(t[3]-t[1])*r,g=(t[2]-t[0])*r):(p=Math.abs(s-t[0])*r+i,A=Math.abs(l-t[1])*r+a,v=(t[2]-t[0])*r,g=(t[3]-t[1])*r),this.transform=[c*r,u*r,d*r,f*r,p-c*r*s-d*r*l,A-u*r*s-f*r*l],this.width=v,this.height=g}get rawDims(){const{viewBox:t}=this;return dn(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:r=this.rotation,offsetX:n=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new Xw({viewBox:this.viewBox.slice(),scale:t,rotation:r,offsetX:n,offsetY:i,dontFlip:a})}convertToViewportPoint(t,r){return rr.applyTransform([t,r],this.transform)}convertToViewportRectangle(t){const r=rr.applyTransform([t[0],t[1]],this.transform),n=rr.applyTransform([t[2],t[3]],this.transform);return[r[0],r[1],n[0],n[1]]}convertToPdfPoint(t,r){return rr.applyInverseTransform([t,r],this.transform)}}class HO extends Ih{constructor(t,r=0){super(t,"RenderingCancelledException"),this.extraDelay=r}}function m3(e){const t=e.length;let r=0;for(;r<t&&e[r].trim()==="";)r++;return e.substring(r,r+5).toLowerCase()==="data:"}function zO(e){return typeof e=="string"&&/\.pdf$/i.test(e)}function BIe(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf("/")+1)}function MIe(e,t="document.pdf"){if(typeof e!="string")return t;if(m3(e))return Gr('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const r=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=r.exec(e);let a=n.exec(i[1])||n.exec(i[2])||n.exec(i[3]);if(a&&(a=a[0],a.includes("%")))try{a=n.exec(decodeURIComponent(a))[0]}catch{}return a||t}class kq{constructor(){Rr(this,"started",Object.create(null));Rr(this,"times",[])}time(t){t in this.started&&Gr(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Gr(`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 r=0;for(const{name:n}of this.times)r=Math.max(n.length,r);for(const{name:n,start:i,end:a}of this.times)t.push(`${n.padEnd(r)} ${a-i}ms
58
+ `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Ld(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var r=this.pos-1;this.invalidStringToken(r,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(n,8);return i>255&&(n=n.slice(0,-1),i=parseInt(n,8)),this.pos+=n.length-1,t=this.input.charCodeAt(this.pos),(n!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-n.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return Zv(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},an.readHexChar=function(e){var t=this.pos,r=this.readInt(16,e);return r===null&&this.invalidStringToken(t,"Bad character escape sequence"),r},an.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,r=this.pos,n=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(Xv(i,n))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(r,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var o=this.readCodePoint();(t?Fd:Xv)(o,n)||this.invalidStringToken(a,"Invalid Unicode escape"),e+=Ld(o),r=this.pos}else break;t=!1}return e+this.input.slice(r,this.pos)},an.readWord=function(){var e=this.readWord1(),t=ve.name;return this.keywords.test(e)&&(t=vO[e]),this.finishToken(t,e)};var sIe="8.14.0";ia.acorn={Parser:ia,version:sIe,defaultOptions:mO,Position:zw,SourceLocation:r3,getLineInfo:VK,Node:s3,TokenType:wn,tokTypes:ve,keywordTypes:vO,TokContext:fc,tokContexts:li,isIdentifierChar:Xv,isIdentifierStart:Fd,Token:MO,isNewLine:Zv,lineBreak:El,lineBreakG:RSe,nonASCIIwhitespace:QK};function lIe(e,t,r){return ia.parseExpressionAt(e,t,r)}const RO=new Map,PO=new Map,cIe=e=>{const t=JSON.stringify(e);if(PO.has(t))return PO.get(t);const r=Object.fromEntries(Object.entries(e).map(([n,i])=>{if(typeof i=="string")try{const a=JSON.parse(i);return[n,a]}catch{return[n,i]}return[n,i]}));return PO.set(t,r),r},u3=e=>String(e).padStart(2,"0"),Sq=e=>`${e.getFullYear()}/${u3(e.getMonth()+1)}/${u3(e.getDate())}`,uIe=e=>`${Sq(e)} ${u3(e.getHours())}:${u3(e.getMinutes())}`,Iq={Math,String,Number,Boolean,Array,Object,Date,JSON,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent},bo=e=>{switch(e.type){case"Literal":case"Identifier":break;case"BinaryExpression":case"LogicalExpression":{const t=e;bo(t.left),bo(t.right);break}case"UnaryExpression":{bo(e.argument);break}case"ConditionalExpression":{const t=e;bo(t.test),bo(t.consequent),bo(t.alternate);break}case"MemberExpression":{const t=e;if(bo(t.object),t.computed)bo(t.property);else{const r=t.property.name;if(["constructor","__proto__","prototype"].includes(r))throw new Error("Access to prohibited property");if(typeof r=="string"&&["toLocaleString","valueOf"].includes(r))throw new Error(`Access to prohibited method: ${r}`)}break}case"CallExpression":{const t=e;bo(t.callee),t.arguments.forEach(bo);break}case"ArrayExpression":{e.elements.forEach(r=>{r&&bo(r)});break}case"ObjectExpression":{e.properties.forEach(r=>{const n=r;bo(n.key),bo(n.value)});break}case"ArrowFunctionExpression":{const t=e;t.params.forEach(r=>{if(r.type!=="Identifier")throw new Error("Only identifier parameters are supported in arrow functions");bo(r)}),bo(t.body);break}default:throw new Error(`Unsupported syntax in placeholder: ${e.type}`)}},Pa=(e,t)=>{switch(e.type){case"Literal":return e.value;case"Identifier":{const r=e;if(Object.prototype.hasOwnProperty.call(t,r.name))return t[r.name];if(Object.prototype.hasOwnProperty.call(Iq,r.name))return Iq[r.name];throw new Error(`Undefined variable: ${r.name}`)}case"BinaryExpression":{const r=e,n=Pa(r.left,t),i=Pa(r.right,t);switch(r.operator){case"+":return n+i;case"-":return n-i;case"*":return n*i;case"/":return n/i;case"%":return n%i;case"**":return n**i;case"==":return n==i;case"!=":return n!=i;case"===":return n===i;case"!==":return n!==i;case"<":return n<i;case">":return n>i;case"<=":return n<=i;case">=":return n>=i;default:throw new Error(`Unsupported operator: ${r.operator}`)}}case"LogicalExpression":{const r=e,n=Pa(r.left,t),i=Pa(r.right,t);switch(r.operator){case"&&":return n&&i;case"||":return n||i;default:throw new Error(`Unsupported operator: ${r.operator}`)}}case"UnaryExpression":{const r=e,n=Pa(r.argument,t);switch(r.operator){case"+":return+n;case"-":return-n;case"!":return!n;default:throw new Error(`Unsupported operator: ${r.operator}`)}}case"ConditionalExpression":{const r=e,n=Pa(r.test,t);return Pa(n?r.consequent:r.alternate,t)}case"MemberExpression":{const r=e,n=Pa(r.object,t);let i;if(r.computed?i=Pa(r.property,t):i=r.property.name,typeof i=="string"||typeof i=="number"){if(typeof i=="string"&&["constructor","__proto__","prototype"].includes(i))throw new Error("Access to prohibited property");return n[i]}else throw new Error("Invalid property access")}case"CallExpression":{const r=e,n=Pa(r.callee,t),i=r.arguments.map(a=>Pa(a,t));if(typeof n=="function")if(r.callee.type==="MemberExpression"){const a=r.callee,o=Pa(a.object,t);if(o!==null&&(typeof o=="object"||typeof o=="number"||typeof o=="string"||typeof o=="boolean"))return n.call(o,...i);throw new Error("Invalid object in member function call")}else return n(...i);else throw new Error("Attempted to call a non-function")}case"ArrowFunctionExpression":{const r=e,n=r.params.map(a=>a.name),i=r.body;return(...a)=>{const o={...t};return n.forEach((s,l)=>{o[s]=a[l]}),Pa(i,o)}}case"ArrayExpression":return e.elements.map(n=>n?Pa(n,t):null);case"ObjectExpression":{const r=e,n={};return r.properties.forEach(i=>{const a=i;let o;if(a.key.type==="Identifier")o=a.key.name;else{const l=Pa(a.key,t);if(typeof l!="string"&&typeof l!="number")throw new Error("Object property keys must be strings or numbers");o=String(l)}const s=Pa(a.value,t);n[o]=s}),n}default:throw new Error(`Unsupported syntax in placeholder: ${e.type}`)}},Bq=e=>{const{content:t,context:r}=e;let n="",i=0;for(;i<t.length;){const a=t.indexOf("{",i);if(a===-1){n+=t.slice(i);break}n+=t.slice(i,a);let o=1,s=a+1;for(;s<t.length&&o>0;)t[s]==="{"?o++:t[s]==="}"&&o--,s++;if(o===0){const l=t.slice(a+1,s-1).trim();if(RO.has(l)){const c=RO.get(l);try{const u=c(r);n+=String(u)}catch{n+=t.slice(a,s)}}else try{const c=lIe(l,0,{ecmaVersion:"latest"});bo(c);const u=f=>Pa(c,f);RO.set(l,u);const d=u(r);n+=String(d)}catch{n+=t.slice(a,s)}i=s}else throw new Error("Invalid placeholder")}return n},DO=e=>{const{content:t,variables:r,schemas:n}=e;if(!t||typeof t!="string"||!t.includes("{")||!t.includes("}"))return t;const i=new Date,a=Sq(i),o=uIe(i),s={...Object.fromEntries(n.flat().map(u=>[u.name,u.readOnly&&u.content||""])),...r},l=cIe(s),c={date:a,dateTime:o,...l};return Object.entries(c).forEach(([u,d])=>{typeof d=="string"&&d.includes("{")&&d.includes("}")&&(c[u]=Bq({content:d,context:c}))}),Bq({content:t,context:c})},TO="en",hc="[@pdfme/ui] this instance is already destroyed",Mq="selectable",aa=30,Rq=10,_O=45,Uw=400,Pq="rgb(74, 74, 74)";var Kw={};Kw.d=(e,t)=>{for(var r in t)Kw.o(t,r)&&!Kw.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},Kw.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Pr=globalThis.pdfjsLib={};Kw.d(Pr,{AbortException:()=>zp,AnnotationEditorLayer:()=>vk,AnnotationEditorParamsType:()=>Br,AnnotationEditorType:()=>jr,AnnotationEditorUIManager:()=>Vp,AnnotationLayer:()=>l3e,AnnotationMode:()=>Sh,ColorPicker:()=>SX,DOMSVGFactory:()=>uk,DrawLayer:()=>mk,FeatureTest:()=>Vo,GlobalWorkerOptions:()=>zd,ImageKind:()=>d3,InvalidPDFException:()=>Tq,MissingPDFException:()=>Hp,OPS:()=>pc,OutputScale:()=>GO,PDFDataRangeTransport:()=>dX,PDFDateString:()=>WO,PDFWorker:()=>im,PasswordResponses:()=>pIe,PermissionFlag:()=>hIe,PixelsPerInch:()=>Bh,RenderingCancelledException:()=>HO,TextLayer:()=>nC,UnexpectedResponseException:()=>A3,Util:()=>rr,VerbosityLevel:()=>f3,XfaLayer:()=>AX,build:()=>HBe,createValidAbsoluteUrl:()=>mIe,fetchData:()=>v3,getDocument:()=>_Be,getFilenameFromUrl:()=>BIe,getPdfFilenameFromUrl:()=>MIe,getXfaPageViewport:()=>RIe,isDataScheme:()=>m3,isPdfFile:()=>zO,noContextMenu:()=>Ml,normalizeUnicode:()=>EIe,setLayerDimensions:()=>Wp,shadow:()=>dn,version:()=>QBe});const yo=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Dq=[1,0,0,1,0,0],OO=[.001,0,0,.001,0,0],dIe=1e7,kO=1.35,Ls={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Sh={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},fIe="pdfjs_internal_editor_",jr={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Br={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},hIe={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},wo={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},d3={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},oa={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},qw={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},f3={ERRORS:0,WARNINGS:1,INFOS:5},pc={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},pIe={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let h3=f3.WARNINGS;function AIe(e){Number.isInteger(e)&&(h3=e)}function gIe(){return h3}function p3(e){h3>=f3.INFOS&&console.log(`Info: ${e}`)}function Gr(e){h3>=f3.WARNINGS&&console.log(`Warning: ${e}`)}function ei(e){throw new Error(e)}function sa(e,t){e||ei(t)}function vIe(e){switch(e==null?void 0:e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function mIe(e,t=null,r=null){if(!e)return null;try{if(r&&typeof e=="string"){if(r.addDefaultProtocol&&e.startsWith("www.")){const i=e.match(/\./g);(i==null?void 0:i.length)>=2&&(e=`http://${e}`)}if(r.tryConvertEncoding)try{e=xIe(e)}catch{}}const n=t?new URL(e,t):new URL(e);if(vIe(n))return n}catch{}return null}function dn(e,t,r,n=!1){return Object.defineProperty(e,t,{value:r,enumerable:!n,configurable:!0,writable:!1}),r}const Ih=function(){function t(r,n){this.message=r,this.name=n}return t.prototype=new Error,t.constructor=t,t}();class FO extends Ih{constructor(t,r){super(t,"PasswordException"),this.code=r}}class LO extends Ih{constructor(t,r){super(t,"UnknownErrorException"),this.details=r}}class Tq extends Ih{constructor(t){super(t,"InvalidPDFException")}}class Hp extends Ih{constructor(t){super(t,"MissingPDFException")}}class A3 extends Ih{constructor(t,r){super(t,"UnexpectedResponseException"),this.status=r}}class bIe extends Ih{constructor(t){super(t,"FormatError")}}class zp extends Ih{constructor(t){super(t,"AbortException")}}function _q(e){(typeof e!="object"||(e==null?void 0:e.length)===void 0)&&ei("Invalid argument for bytesToString");const t=e.length,r=8192;if(t<r)return String.fromCharCode.apply(null,e);const n=[];for(let i=0;i<t;i+=r){const a=Math.min(i+r,t),o=e.subarray(i,a);n.push(String.fromCharCode.apply(null,o))}return n.join("")}function g3(e){typeof e!="string"&&ei("Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let n=0;n<t;++n)r[n]=e.charCodeAt(n)&255;return r}function yIe(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function NO(e){const t=Object.create(null);for(const[r,n]of e)t[r]=n;return t}function wIe(){const e=new Uint8Array(4);return e[0]=1,new Uint32Array(e.buffer,0,1)[0]===1}function CIe(){try{return new Function(""),!0}catch{return!1}}class Vo{static get isLittleEndian(){return dn(this,"isLittleEndian",wIe())}static get isEvalSupported(){return dn(this,"isEvalSupported",CIe())}static get isOffscreenCanvasSupported(){return dn(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?dn(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):dn(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,r;return dn(this,"isCSSRoundSupported",(r=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:r.call(t,"width: round(1.5px, 1px)"))}}const $O=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,"0"));class rr{static makeHexColor(t,r,n){return`#${$O[t]}${$O[r]}${$O[n]}`}static scaleMinMax(t,r){let n;t[0]?(t[0]<0&&(n=r[0],r[0]=r[2],r[2]=n),r[0]*=t[0],r[2]*=t[0],t[3]<0&&(n=r[1],r[1]=r[3],r[3]=n),r[1]*=t[3],r[3]*=t[3]):(n=r[0],r[0]=r[1],r[1]=n,n=r[2],r[2]=r[3],r[3]=n,t[1]<0&&(n=r[1],r[1]=r[3],r[3]=n),r[1]*=t[1],r[3]*=t[1],t[2]<0&&(n=r[0],r[0]=r[2],r[2]=n),r[0]*=t[2],r[2]*=t[2]),r[0]+=t[4],r[1]+=t[5],r[2]+=t[4],r[3]+=t[5]}static transform(t,r){return[t[0]*r[0]+t[2]*r[1],t[1]*r[0]+t[3]*r[1],t[0]*r[2]+t[2]*r[3],t[1]*r[2]+t[3]*r[3],t[0]*r[4]+t[2]*r[5]+t[4],t[1]*r[4]+t[3]*r[5]+t[5]]}static applyTransform(t,r){const n=t[0]*r[0]+t[1]*r[2]+r[4],i=t[0]*r[1]+t[1]*r[3]+r[5];return[n,i]}static applyInverseTransform(t,r){const n=r[0]*r[3]-r[1]*r[2],i=(t[0]*r[3]-t[1]*r[2]+r[2]*r[5]-r[4]*r[3])/n,a=(-t[0]*r[1]+t[1]*r[0]+r[4]*r[1]-r[5]*r[0])/n;return[i,a]}static getAxialAlignedBoundingBox(t,r){const n=this.applyTransform(t,r),i=this.applyTransform(t.slice(2,4),r),a=this.applyTransform([t[0],t[3]],r),o=this.applyTransform([t[2],t[1]],r);return[Math.min(n[0],i[0],a[0],o[0]),Math.min(n[1],i[1],a[1],o[1]),Math.max(n[0],i[0],a[0],o[0]),Math.max(n[1],i[1],a[1],o[1])]}static inverseTransform(t){const r=t[0]*t[3]-t[1]*t[2];return[t[3]/r,-t[1]/r,-t[2]/r,t[0]/r,(t[2]*t[5]-t[4]*t[3])/r,(t[4]*t[1]-t[5]*t[0])/r]}static singularValueDecompose2dScale(t){const r=[t[0],t[2],t[1],t[3]],n=t[0]*r[0]+t[1]*r[2],i=t[0]*r[1]+t[1]*r[3],a=t[2]*r[0]+t[3]*r[2],o=t[2]*r[1]+t[3]*r[3],s=(n+o)/2,l=Math.sqrt((n+o)**2-4*(n*o-a*i))/2,c=s+l||1,u=s-l||1;return[Math.sqrt(c),Math.sqrt(u)]}static normalizeRect(t){const r=t.slice(0);return t[0]>t[2]&&(r[0]=t[2],r[2]=t[0]),t[1]>t[3]&&(r[1]=t[3],r[3]=t[1]),r}static intersect(t,r){const n=Math.max(Math.min(t[0],t[2]),Math.min(r[0],r[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(r[0],r[2]));if(n>i)return null;const a=Math.max(Math.min(t[1],t[3]),Math.min(r[1],r[3])),o=Math.min(Math.max(t[1],t[3]),Math.max(r[1],r[3]));return a>o?null:[n,a,i,o]}static bezierBoundingBox(t,r,n,i,a,o,s,l,c){return c?(c[0]=Math.min(c[0],t,s),c[1]=Math.min(c[1],r,l),c[2]=Math.max(c[2],t,s),c[3]=Math.max(c[3],r,l)):c=[Math.min(t,s),Math.min(r,l),Math.max(t,s),Math.max(r,l)],he(this,Ef,VW).call(this,t,n,a,s,r,i,o,l,3*(-t+3*(n-a)+s),6*(t-2*n+a),3*(n-t),c),he(this,Ef,VW).call(this,t,n,a,s,r,i,o,l,3*(-r+3*(i-o)+l),6*(r-2*i+o),3*(i-r),c),c}}Ef=new WeakSet,w8=function(t,r,n,i,a,o,s,l,c,u){if(c<=0||c>=1)return;const d=1-c,f=c*c,p=f*c,A=d*(d*(d*t+3*c*r)+3*f*n)+p*i,v=d*(d*(d*a+3*c*o)+3*f*s)+p*l;u[0]=Math.min(u[0],A),u[1]=Math.min(u[1],v),u[2]=Math.max(u[2],A),u[3]=Math.max(u[3],v)},VW=function(t,r,n,i,a,o,s,l,c,u,d,f){if(Math.abs(c)<1e-12){Math.abs(u)>=1e-12&&he(this,Ef,w8).call(this,t,r,n,i,a,o,s,l,-d/u,f);return}const p=u**2-4*d*c;if(p<0)return;const A=Math.sqrt(p),v=2*c;he(this,Ef,w8).call(this,t,r,n,i,a,o,s,l,(-u+A)/v,f),he(this,Ef,w8).call(this,t,r,n,i,a,o,s,l,(-u-A)/v,f)},be(rr,Ef);function xIe(e){return decodeURIComponent(escape(e))}let jO=null,Oq=null;function EIe(e){return jO||(jO=/([\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,Oq=new Map([["ſt","ſt"]])),e.replaceAll(jO,(t,r,n)=>r?r.normalize("NFKC"):Oq.get(n))}function SIe(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const e=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(e);else for(let t=0;t<32;t++)e[t]=Math.floor(Math.random()*255);return _q(e)}const QO="pdfjs_internal_id_",jd={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};function IIe(e){return Uint8Array.prototype.toBase64?e.toBase64():btoa(_q(e))}const Qd="http://www.w3.org/2000/svg",Ag=class Ag{};Rr(Ag,"CSS",96),Rr(Ag,"PDF",72),Rr(Ag,"PDF_TO_CSS_UNITS",Ag.CSS/Ag.PDF);let Bh=Ag;async function v3(e,t="text"){if(Zw(e,document.baseURI)){const r=await fetch(e);if(!r.ok)throw new Error(r.statusText);switch(t){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"json":return r.json()}return r.text()}return new Promise((r,n)=>{const i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":r(i.response);return}r(i.responseText);return}n(new Error(i.statusText))}},i.send(null)})}class Xw{constructor({viewBox:t,scale:r,rotation:n,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.scale=r,this.rotation=n,this.offsetX=i,this.offsetY=a;const s=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,u,d,f;switch(n%=360,n<0&&(n+=360),n){case 180:c=-1,u=0,d=0,f=1;break;case 90:c=0,u=1,d=1,f=0;break;case 270:c=0,u=-1,d=-1,f=0;break;case 0:c=1,u=0,d=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(d=-d,f=-f);let p,A,v,g;c===0?(p=Math.abs(l-t[1])*r+i,A=Math.abs(s-t[0])*r+a,v=(t[3]-t[1])*r,g=(t[2]-t[0])*r):(p=Math.abs(s-t[0])*r+i,A=Math.abs(l-t[1])*r+a,v=(t[2]-t[0])*r,g=(t[3]-t[1])*r),this.transform=[c*r,u*r,d*r,f*r,p-c*r*s-d*r*l,A-u*r*s-f*r*l],this.width=v,this.height=g}get rawDims(){const{viewBox:t}=this;return dn(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:r=this.rotation,offsetX:n=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new Xw({viewBox:this.viewBox.slice(),scale:t,rotation:r,offsetX:n,offsetY:i,dontFlip:a})}convertToViewportPoint(t,r){return rr.applyTransform([t,r],this.transform)}convertToViewportRectangle(t){const r=rr.applyTransform([t[0],t[1]],this.transform),n=rr.applyTransform([t[2],t[3]],this.transform);return[r[0],r[1],n[0],n[1]]}convertToPdfPoint(t,r){return rr.applyInverseTransform([t,r],this.transform)}}class HO extends Ih{constructor(t,r=0){super(t,"RenderingCancelledException"),this.extraDelay=r}}function m3(e){const t=e.length;let r=0;for(;r<t&&e[r].trim()==="";)r++;return e.substring(r,r+5).toLowerCase()==="data:"}function zO(e){return typeof e=="string"&&/\.pdf$/i.test(e)}function BIe(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf("/")+1)}function MIe(e,t="document.pdf"){if(typeof e!="string")return t;if(m3(e))return Gr('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const r=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=r.exec(e);let a=n.exec(i[1])||n.exec(i[2])||n.exec(i[3]);if(a&&(a=a[0],a.includes("%")))try{a=n.exec(decodeURIComponent(a))[0]}catch{}return a||t}class kq{constructor(){Rr(this,"started",Object.create(null));Rr(this,"times",[])}time(t){t in this.started&&Gr(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Gr(`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 r=0;for(const{name:n}of this.times)r=Math.max(n.length,r);for(const{name:n,start:i,end:a}of this.times)t.push(`${n.padEnd(r)} ${a-i}ms
59
59
  `);return t.join("")}}function Zw(e,t){try{const{protocol:r}=t?new URL(e,t):new URL(e);return r==="http:"||r==="https:"}catch{return!1}}function Ml(e){e.preventDefault()}function Fq(e){console.log("Deprecated API usage: "+e)}class WO{static toDateObject(t){if(!t||typeof t!="string")return null;P(this,iS)||ue(this,iS,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const r=P(this,iS).exec(t);if(!r)return null;const n=parseInt(r[1],10);let i=parseInt(r[2],10);i=i>=1&&i<=12?i-1:0;let a=parseInt(r[3],10);a=a>=1&&a<=31?a:1;let o=parseInt(r[4],10);o=o>=0&&o<=23?o:0;let s=parseInt(r[5],10);s=s>=0&&s<=59?s:0;let l=parseInt(r[6],10);l=l>=0&&l<=59?l:0;const c=r[7]||"Z";let u=parseInt(r[8],10);u=u>=0&&u<=23?u:0;let d=parseInt(r[9],10)||0;return d=d>=0&&d<=59?d:0,c==="-"?(o+=u,s+=d):c==="+"&&(o-=u,s-=d),new Date(Date.UTC(n,i,a,o,s,l))}}iS=new WeakMap,be(WO,iS);function RIe(e,{scale:t=1,rotation:r=0}){const{width:n,height:i}=e.attributes.style,a=[0,0,parseInt(n),parseInt(i)];return new Xw({viewBox:a,scale:t,rotation:r})}function VO(e){if(e.startsWith("#")){const t=parseInt(e.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map(t=>parseInt(t)):e.startsWith("rgba(")?e.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(Gr(`Not a valid color format: "${e}"`),[0,0,0])}function PIe(e){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const r of e.keys()){t.style.color=r;const n=window.getComputedStyle(t).color;e.set(r,VO(n))}t.remove()}function bi(e){const{a:t,b:r,c:n,d:i,e:a,f:o}=e.getTransform();return[t,r,n,i,a,o]}function Hd(e){const{a:t,b:r,c:n,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,r,n,i,a,o]}function Wp(e,t,r=!1,n=!0){if(t instanceof Xw){const{pageWidth:i,pageHeight:a}=t.rawDims,{style:o}=e,s=Vo.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${a}px`,u=s?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,d=s?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!r||t.rotation%180===0?(o.width=u,o.height=d):(o.width=d,o.height=u)}n&&e.setAttribute("data-main-rotation",t.rotation)}class GO{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}}const Sf=class Sf{constructor(t){be(this,ns);be(this,z0,null);be(this,gg,null);be(this,Yc);be(this,vg,null);be(this,aS,null);ue(this,Yc,t),P(Sf,oS)||ue(Sf,oS,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){const t=ue(this,z0,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const r=P(this,Yc)._uiManager._signal;t.addEventListener("contextmenu",Ml,{signal:r}),t.addEventListener("pointerdown",he(Sf,r8,Jye),{signal:r});const n=ue(this,vg,document.createElement("div"));n.className="buttons",t.append(n);const i=P(this,Yc).toolbarPosition;if(i){const{style:a}=t,o=P(this,Yc)._uiManager.direction==="ltr"?1-i[0]:i[0];a.insetInlineEnd=`${100*o}%`,a.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return he(this,ns,rwe).call(this),t}get div(){return P(this,z0)}hide(){var t;P(this,z0).classList.add("hidden"),(t=P(this,gg))==null||t.hideDropdown()}show(){var t;P(this,z0).classList.remove("hidden"),(t=P(this,aS))==null||t.shown()}async addAltText(t){const r=await t.render();he(this,ns,C8).call(this,r),P(this,vg).prepend(r,P(this,ns,GW)),ue(this,aS,t)}addColorPicker(t){ue(this,gg,t);const r=t.renderButton();he(this,ns,C8).call(this,r),P(this,vg).prepend(r,P(this,ns,GW))}remove(){var t;P(this,z0).remove(),(t=P(this,gg))==null||t.destroy(),ue(this,gg,null)}};z0=new WeakMap,gg=new WeakMap,Yc=new WeakMap,vg=new WeakMap,aS=new WeakMap,oS=new WeakMap,r8=new WeakSet,Jye=function(t){t.stopPropagation()},ns=new WeakSet,ewe=function(t){P(this,Yc)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},twe=function(t){P(this,Yc)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},C8=function(t){const r=P(this,Yc)._uiManager._signal;t.addEventListener("focusin",he(this,ns,ewe).bind(this),{capture:!0,signal:r}),t.addEventListener("focusout",he(this,ns,twe).bind(this),{capture:!0,signal:r}),t.addEventListener("contextmenu",Ml,{signal:r})},rwe=function(){const{editorType:t,_uiManager:r}=P(this,Yc),n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",P(Sf,oS)[t]),he(this,ns,C8).call(this,n),n.addEventListener("click",i=>{r.delete()},{signal:r._signal}),P(this,vg).append(n)},GW=function(){const t=document.createElement("div");return t.className="divider",t},be(Sf,r8),be(Sf,oS,null);let YO=Sf;class DIe{constructor(t){be(this,W0);be(this,sS,null);be(this,mg,null);be(this,bg);ue(this,bg,t)}show(t,r,n){const[i,a]=he(this,W0,iwe).call(this,r,n),{style:o}=P(this,mg)||ue(this,mg,he(this,W0,nwe).call(this));t.append(P(this,mg)),o.insetInlineEnd=`${100*i}%`,o.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){P(this,mg).remove()}}sS=new WeakMap,mg=new WeakMap,bg=new WeakMap,W0=new WeakSet,nwe=function(){const t=ue(this,mg,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Ml,{signal:P(this,bg)._signal});const r=ue(this,sS,document.createElement("div"));return r.className="buttons",t.append(r),he(this,W0,awe).call(this),t},iwe=function(t,r){let n=0,i=0;for(const a of t){const o=a.y+a.height;if(o<n)continue;const s=a.x+(r?a.width:0);if(o>n){i=s,n=o;continue}r?s>i&&(i=s):s<i&&(i=s)}return[r?1-i:i,n]},awe=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const r=document.createElement("span");t.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=P(this,bg)._signal;t.addEventListener("contextmenu",Ml,{signal:n}),t.addEventListener("click",()=>{P(this,bg).highlightSelection("floating_button")},{signal:n}),P(this,sS).append(t)};function b3(e,t,r){for(const n of r)t.addEventListener(n,e[n].bind(e))}function TIe(e){return Math.round(Math.min(255,Math.max(1,255*e))).toString(16).padStart(2,"0")}class _Ie{constructor(){be(this,n8,0)}get id(){return`${fIe}${os(this,n8)._++}`}}n8=new WeakMap;const LW=class LW{constructor(){be(this,k1);be(this,O1,SIe());be(this,lS,0);be(this,To,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>',n=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const a=i.decode().then(()=>(n.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(n.getImageData(0,0,1,1).data.buffer)[0]===0));return dn(this,"_isSVGFittingCanvas",a)}async getFromFile(t){const{lastModified:r,name:n,size:i,type:a}=t;return he(this,k1,x8).call(this,`${r}_${n}_${i}_${a}`,t)}async getFromUrl(t){return he(this,k1,x8).call(this,t,t)}async getFromBlob(t,r){const n=await r;return he(this,k1,x8).call(this,t,n)}async getFromId(t){P(this,To)||ue(this,To,new Map);const r=P(this,To).get(t);if(!r)return null;if(r.bitmap)return r.refCounter+=1,r;if(r.file)return this.getFromFile(r.file);if(r.blobPromise){const{blobPromise:n}=r;return delete r.blobPromise,this.getFromBlob(r.id,n)}return this.getFromUrl(r.url)}getFromCanvas(t,r){P(this,To)||ue(this,To,new Map);let n=P(this,To).get(t);if(n!=null&&n.bitmap)return n.refCounter+=1,n;const i=new OffscreenCanvas(r.width,r.height);return i.getContext("2d").drawImage(r,0,0),n={bitmap:i.transferToImageBitmap(),id:`image_${P(this,O1)}_${os(this,lS)._++}`,refCounter:1,isSvg:!1},P(this,To).set(t,n),P(this,To).set(n.id,n),n}getSvgUrl(t){const r=P(this,To).get(t);return r!=null&&r.isSvg?r.svgUrl:null}deleteId(t){var i;P(this,To)||ue(this,To,new Map);const r=P(this,To).get(t);if(!r||(r.refCounter-=1,r.refCounter!==0))return;const{bitmap:n}=r;if(!r.url&&!r.file){const a=new OffscreenCanvas(n.width,n.height);a.getContext("bitmaprenderer").transferFromImageBitmap(n),r.blobPromise=a.convertToBlob()}(i=n.close)==null||i.call(n),r.bitmap=null}isValidId(t){return t.startsWith(`image_${P(this,O1)}_`)}};O1=new WeakMap,lS=new WeakMap,To=new WeakMap,k1=new WeakSet,x8=async function(t,r){P(this,To)||ue(this,To,new Map);let n=P(this,To).get(t);if(n===null)return null;if(n!=null&&n.bitmap)return n.refCounter+=1,n;try{n||(n={bitmap:null,id:`image_${P(this,O1)}_${os(this,lS)._++}`,refCounter:0,isSvg:!1});let i;if(typeof r=="string"?(n.url=r,i=await v3(r,"blob")):r instanceof File?i=n.file=r:r instanceof Blob&&(i=r),i.type==="image/svg+xml"){const a=LW._isSVGFittingCanvas,o=new FileReader,s=new Image,l=new Promise((c,u)=>{s.onload=()=>{n.bitmap=s,n.isSvg=!0,c()},o.onload=async()=>{const d=n.svgUrl=o.result;s.src=await a?`${d}#svgView(preserveAspectRatio(none))`:d},s.onerror=o.onerror=u});o.readAsDataURL(i),await l}else n.bitmap=await createImageBitmap(i);n.refCounter=1}catch(i){console.error(i),n=null}return P(this,To).set(t,n),n&&P(this,To).set(n.id,n),n};let UO=LW;class OIe{constructor(t=128){be(this,La,[]);be(this,V0,!1);be(this,cS);be(this,Na,-1);ue(this,cS,t)}add({cmd:t,undo:r,post:n,mustExec:i,type:a=NaN,overwriteIfSameType:o=!1,keepUndo:s=!1}){if(i&&t(),P(this,V0))return;const l={cmd:t,undo:r,post:n,type:a};if(P(this,Na)===-1){P(this,La).length>0&&(P(this,La).length=0),ue(this,Na,0),P(this,La).push(l);return}if(o&&P(this,La)[P(this,Na)].type===a){s&&(l.undo=P(this,La)[P(this,Na)].undo),P(this,La)[P(this,Na)]=l;return}const c=P(this,Na)+1;c===P(this,cS)?P(this,La).splice(0,1):(ue(this,Na,c),c<P(this,La).length&&P(this,La).splice(c)),P(this,La).push(l)}undo(){if(P(this,Na)===-1)return;ue(this,V0,!0);const{undo:t,post:r}=P(this,La)[P(this,Na)];t(),r==null||r(),ue(this,V0,!1),ue(this,Na,P(this,Na)-1)}redo(){if(P(this,Na)<P(this,La).length-1){ue(this,Na,P(this,Na)+1),ue(this,V0,!0);const{cmd:t,post:r}=P(this,La)[P(this,Na)];t(),r==null||r(),ue(this,V0,!1)}}hasSomethingToUndo(){return P(this,Na)!==-1}hasSomethingToRedo(){return P(this,Na)<P(this,La).length-1}destroy(){ue(this,La,null)}}La=new WeakMap,V0=new WeakMap,cS=new WeakMap,Na=new WeakMap;class Jw{constructor(t){be(this,i8);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:r}=Vo.platform;for(const[n,i,a={}]of t)for(const o of n){const s=o.startsWith("mac+");r&&s?(this.callbacks.set(o.slice(4),{callback:i,options:a}),this.allKeys.add(o.split("+").at(-1))):!r&&!s&&(this.callbacks.set(o,{callback:i,options:a}),this.allKeys.add(o.split("+").at(-1)))}}exec(t,r){if(!this.allKeys.has(r.key))return;const n=this.callbacks.get(he(this,i8,owe).call(this,r));if(!n)return;const{callback:i,options:{bubbles:a=!1,args:o=[],checker:s=null}}=n;s&&!s(t,r)||(i.bind(t,...o,r)(),a||(r.stopPropagation(),r.preventDefault()))}}i8=new WeakSet,owe=function(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const r=this.buffer.join("+");return this.buffer.length=0,r};const a8=class a8{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return PIe(t),dn(this,"_colors",t)}convert(t){const r=VO(t);if(!window.matchMedia("(forced-colors: active)").matches)return r;for(const[n,i]of this._colors)if(i.every((a,o)=>a===r[o]))return a8._colorsMapping.get(n);return r}getHexCode(t){const r=this._colors.get(t);return r?rr.makeHexColor(...r):t}};Rr(a8,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let KO=a8;const H1=class H1{constructor(t,r,n,i,a,o,s,l,c,u,d){be(this,Qt);be(this,F1,new AbortController);be(this,ol,null);be(this,ya,new Map);be(this,lo,new Map);be(this,L1,null);be(this,If,null);be(this,N1,null);be(this,Uc,new OIe);be(this,G0,null);be(this,$1,0);be(this,yg,new Set);be(this,od,null);be(this,Kc,null);be(this,wg,new Set);be(this,uS,!1);be(this,dS,!1);be(this,j1,!1);be(this,fS,null);be(this,sd,null);be(this,Y0,null);be(this,Q1,null);be(this,U0,!1);be(this,ld,null);be(this,o8,new _Ie);be(this,K0,!1);be(this,hS,!1);be(this,q0,null);be(this,Cg,null);be(this,pS,null);be(this,AS,null);be(this,$a,jr.NONE);be(this,Nn,new Set);be(this,Bf,null);be(this,xg,null);be(this,gS,null);be(this,vS,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});be(this,X0,[0,0]);be(this,cd,null);be(this,Mf,null);be(this,mS,null);be(this,ql,null);const f=this._signal=P(this,F1).signal;ue(this,Mf,t),ue(this,mS,r),ue(this,L1,n),this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:f}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),i._on("setpreference",this.onSetPreference.bind(this),{signal:f}),i._on("switchannotationeditorparams",p=>this.updateParams(p.type,p.value),{signal:f}),he(this,Qt,cwe).call(this),he(this,Qt,hwe).call(this),he(this,Qt,UW).call(this),ue(this,If,a.annotationStorage),ue(this,fS,a.filterFactory),ue(this,xg,o),ue(this,Q1,s||null),ue(this,uS,l),ue(this,dS,c),ue(this,j1,u),ue(this,AS,d||null),this.viewParameters={realScale:Bh.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=H1.prototype,r=o=>P(o,Mf).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&o.hasSomethingToControl(),n=(o,{target:s})=>{if(s instanceof HTMLInputElement){const{type:l}=s;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return dn(this,"_keyboardManager",new Jw([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],t.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:n}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:n}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(o,{target:s})=>!(s instanceof HTMLButtonElement)&&P(o,Mf).contains(s)&&!o.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(o,{target:s})=>!(s instanceof HTMLButtonElement)&&P(o,Mf).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:r}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-a,0],checker:r}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:r}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[a,0],checker:r}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:r}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-a],checker:r}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:r}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,a],checker:r}]]))}destroy(){var t,r,n,i;(t=P(this,ql))==null||t.resolve(),ue(this,ql,null),(r=P(this,F1))==null||r.abort(),ue(this,F1,null),this._signal=null;for(const a of P(this,lo).values())a.destroy();P(this,lo).clear(),P(this,ya).clear(),P(this,wg).clear(),ue(this,ol,null),P(this,Nn).clear(),P(this,Uc).destroy(),(n=P(this,L1))==null||n.destroy(),(i=P(this,ld))==null||i.hide(),ue(this,ld,null),P(this,sd)&&(clearTimeout(P(this,sd)),ue(this,sd,null)),P(this,cd)&&(clearTimeout(P(this,cd)),ue(this,cd,null))}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return P(this,AS)}get useNewAltTextFlow(){return P(this,dS)}get useNewAltTextWhenAddingImage(){return P(this,j1)}get hcmFilter(){return dn(this,"hcmFilter",P(this,xg)?P(this,fS).addHCMFilter(P(this,xg).foreground,P(this,xg).background):"none")}get direction(){return dn(this,"direction",getComputedStyle(P(this,Mf)).direction)}get highlightColors(){return dn(this,"highlightColors",P(this,Q1)?new Map(P(this,Q1).split(",").map(t=>t.split("=").map(r=>r.trim()))):null)}get highlightColorNames(){return dn(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){ue(this,pS,t)}editAltText(t,r=!1){var n;(n=P(this,L1))==null||n.editAltText(this,t,r)}switchToMode(t,r){this._eventBus.on("annotationeditormodechanged",r,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,r){this._eventBus.dispatch("setpreference",{source:this,name:t,value:r})}onSetPreference({name:t,value:r}){switch(t){case"enableNewAltTextWhenAddingImage":ue(this,j1,r);break}}onPageChanging({pageNumber:t}){ue(this,$1,t-1)}focusMainContainer(){P(this,Mf).focus()}findParent(t,r){for(const n of P(this,lo).values()){const{x:i,y:a,width:o,height:s}=n.div.getBoundingClientRect();if(t>=i&&t<=i+o&&r>=a&&r<=a+s)return n}return null}disableUserSelect(t=!1){P(this,mS).classList.toggle("noUserSelect",t)}addShouldRescale(t){P(this,wg).add(t)}removeShouldRescale(t){P(this,wg).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Bh.PDF_TO_CSS_UNITS;for(const r of P(this,wg))r.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const r=document.getSelection();if(!r||r.isCollapsed)return;const{anchorNode:n,anchorOffset:i,focusNode:a,focusOffset:o}=r,s=r.toString(),c=he(this,Qt,E8).call(this,r).closest(".textLayer"),u=this.getSelectionBoxes(c);if(!u)return;r.empty();const d=he(this,Qt,YW).call(this,c),f=P(this,$a)===jr.NONE,p=()=>{d==null||d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:n,anchorOffset:i,focusNode:a,focusOffset:o,text:s}),f&&this.showAllEditors("highlight",!0,!0)};if(f){this.switchToMode(jr.HIGHLIGHT,p);return}p()}addToAnnotationStorage(t){!t.isEmpty()&&P(this,If)&&!P(this,If).has(t.id)&&P(this,If).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,P(this,U0)&&(ue(this,U0,!1),he(this,Qt,S8).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const r of P(this,Nn))if(r.div.contains(t)){ue(this,Cg,[r,t]),r._focusEventsAllowed=!1;break}}focus(){if(!P(this,Cg))return;const[t,r]=P(this,Cg);ue(this,Cg,null),r.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),r.focus()}addEditListeners(){he(this,Qt,UW).call(this),he(this,Qt,KW).call(this)}removeEditListeners(){he(this,Qt,fwe).call(this),he(this,Qt,qW).call(this)}dragOver(t){for(const{type:r}of t.dataTransfer.items)for(const n of P(this,Kc))if(n.isHandlingMimeForPasting(r)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const r of t.dataTransfer.items)for(const n of P(this,Kc))if(n.isHandlingMimeForPasting(r.type)){n.paste(r,this.currentLayer),t.preventDefault();return}}copy(t){var n;if(t.preventDefault(),(n=P(this,ol))==null||n.commitOrRemove(),!this.hasSelection)return;const r=[];for(const i of P(this,Nn)){const a=i.serialize(!0);a&&r.push(a)}r.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(r))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:r}=t;for(const a of r.items)for(const o of P(this,Kc))if(o.isHandlingMimeForPasting(a.type)){o.paste(a,this.currentLayer);return}let n=r.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(a){Gr(`paste: "${a.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();const i=this.currentLayer;try{const a=[];for(const l of n){const c=await i.deserialize(l);if(!c)return;a.push(c)}const o=()=>{for(const l of a)he(this,Qt,XW).call(this,l);he(this,Qt,ZW).call(this,a)},s=()=>{for(const l of a)l.remove()};this.addCommands({cmd:o,undo:s,mustExec:!0})}catch(a){Gr(`paste: "${a.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),P(this,$a)!==jr.NONE&&!this.isEditorHandlingKeyboard&&H1._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,P(this,U0)&&(ue(this,U0,!1),he(this,Qt,S8).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}setEditingState(t){t?(he(this,Qt,uwe).call(this),he(this,Qt,KW).call(this),he(this,Qt,ss).call(this,{isEditing:P(this,$a)!==jr.NONE,isEmpty:he(this,Qt,yI).call(this),hasSomethingToUndo:P(this,Uc).hasSomethingToUndo(),hasSomethingToRedo:P(this,Uc).hasSomethingToRedo(),hasSelectedEditor:!1})):(he(this,Qt,dwe).call(this),he(this,Qt,qW).call(this),he(this,Qt,ss).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!P(this,Kc)){ue(this,Kc,t);for(const r of P(this,Kc))he(this,Qt,bp).call(this,r.defaultPropertiesToUpdate)}}getId(){return P(this,o8).id}get currentLayer(){return P(this,lo).get(P(this,$1))}getLayer(t){return P(this,lo).get(t)}get currentPageIndex(){return P(this,$1)}addLayer(t){P(this,lo).set(t.pageIndex,t),P(this,K0)?t.enable():t.disable()}removeLayer(t){P(this,lo).delete(t.pageIndex)}async updateMode(t,r=null,n=!1){if(P(this,$a)!==t&&!(P(this,ql)&&(await P(this,ql).promise,!P(this,ql)))){if(ue(this,ql,Promise.withResolvers()),ue(this,$a,t),t===jr.NONE){this.setEditingState(!1),he(this,Qt,Awe).call(this),P(this,ql).resolve();return}this.setEditingState(!0),await he(this,Qt,pwe).call(this),this.unselectAll();for(const i of P(this,lo).values())i.updateMode(t);if(!r){n&&this.addNewEditorFromKeyboard(),P(this,ql).resolve();return}for(const i of P(this,ya).values())i.annotationElementId===r?(this.setSelected(i),i.enterInEditMode()):i.unselect();P(this,ql).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==P(this,$a)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,r){var n;if(P(this,Kc)){switch(t){case Br.CREATE:this.currentLayer.addNewEditor();return;case Br.HIGHLIGHT_DEFAULT_COLOR:(n=P(this,pS))==null||n.updateColor(r);break;case Br.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(P(this,gS)||ue(this,gS,new Map)).set(t,r),this.showAllEditors("highlight",r);break}for(const i of P(this,Nn))i.updateParams(t,r);for(const i of P(this,Kc))i.updateDefaultParams(t,r)}}showAllEditors(t,r,n=!1){var a;for(const o of P(this,ya).values())o.editorType===t&&o.show(r);(((a=P(this,gS))==null?void 0:a.get(Br.HIGHLIGHT_SHOW_ALL))??!0)!==r&&he(this,Qt,bp).call(this,[[Br.HIGHLIGHT_SHOW_ALL,r]])}enableWaiting(t=!1){if(P(this,hS)!==t){ue(this,hS,t);for(const r of P(this,lo).values())t?r.disableClick():r.enableClick(),r.div.classList.toggle("waiting",t)}}getEditors(t){const r=[];for(const n of P(this,ya).values())n.pageIndex===t&&r.push(n);return r}getEditor(t){return P(this,ya).get(t)}addEditor(t){P(this,ya).set(t.id,t)}removeEditor(t){var r;t.div.contains(document.activeElement)&&(P(this,sd)&&clearTimeout(P(this,sd)),ue(this,sd,setTimeout(()=>{this.focusMainContainer(),ue(this,sd,null)},0))),P(this,ya).delete(t.id),this.unselect(t),(!t.annotationElementId||!P(this,yg).has(t.annotationElementId))&&((r=P(this,If))==null||r.remove(t.id))}addDeletedAnnotationElement(t){P(this,yg).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return P(this,yg).has(t)}removeDeletedAnnotationElement(t){P(this,yg).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){P(this,ol)!==t&&(ue(this,ol,t),t&&he(this,Qt,bp).call(this,t.propertiesToUpdate))}updateUI(t){P(this,Qt,gwe)===t&&he(this,Qt,bp).call(this,t.propertiesToUpdate)}toggleSelected(t){if(P(this,Nn).has(t)){P(this,Nn).delete(t),t.unselect(),he(this,Qt,ss).call(this,{hasSelectedEditor:this.hasSelection});return}P(this,Nn).add(t),t.select(),he(this,Qt,bp).call(this,t.propertiesToUpdate),he(this,Qt,ss).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const r of P(this,Nn))r!==t&&r.unselect();P(this,Nn).clear(),P(this,Nn).add(t),t.select(),he(this,Qt,bp).call(this,t.propertiesToUpdate),he(this,Qt,ss).call(this,{hasSelectedEditor:!0})}isSelected(t){return P(this,Nn).has(t)}get firstSelectedEditor(){return P(this,Nn).values().next().value}unselect(t){t.unselect(),P(this,Nn).delete(t),he(this,Qt,ss).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return P(this,Nn).size!==0}get isEnterHandled(){return P(this,Nn).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){P(this,Uc).undo(),he(this,Qt,ss).call(this,{hasSomethingToUndo:P(this,Uc).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:he(this,Qt,yI).call(this)})}redo(){P(this,Uc).redo(),he(this,Qt,ss).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:P(this,Uc).hasSomethingToRedo(),isEmpty:he(this,Qt,yI).call(this)})}addCommands(t){P(this,Uc).add(t),he(this,Qt,ss).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:he(this,Qt,yI).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...P(this,Nn)],r=()=>{for(const i of t)i.remove()},n=()=>{for(const i of t)he(this,Qt,XW).call(this,i)};this.addCommands({cmd:r,undo:n,mustExec:!0})}commitOrRemove(){var t;(t=P(this,ol))==null||t.commitOrRemove()}hasSomethingToControl(){return P(this,ol)||this.hasSelection}selectAll(){for(const t of P(this,Nn))t.commit();he(this,Qt,ZW).call(this,P(this,ya).values())}unselectAll(){if(!(P(this,ol)&&(P(this,ol).commitOrRemove(),P(this,$a)!==jr.NONE))&&this.hasSelection){for(const t of P(this,Nn))t.unselect();P(this,Nn).clear(),he(this,Qt,ss).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,r,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;P(this,X0)[0]+=t,P(this,X0)[1]+=r;const[i,a]=P(this,X0),o=[...P(this,Nn)],s=1e3;P(this,cd)&&clearTimeout(P(this,cd)),ue(this,cd,setTimeout(()=>{ue(this,cd,null),P(this,X0)[0]=P(this,X0)[1]=0,this.addCommands({cmd:()=>{for(const l of o)P(this,ya).has(l.id)&&l.translateInPage(i,a)},undo:()=>{for(const l of o)P(this,ya).has(l.id)&&l.translateInPage(-i,-a)},mustExec:!1})},s));for(const l of o)l.translateInPage(t,r)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),ue(this,od,new Map);for(const t of P(this,Nn))P(this,od).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!P(this,od))return!1;this.disableUserSelect(!1);const t=P(this,od);ue(this,od,null);let r=!1;for(const[{x:i,y:a,pageIndex:o},s]of t)s.newX=i,s.newY=a,s.newPageIndex=o,r||(r=i!==s.savedX||a!==s.savedY||o!==s.savedPageIndex);if(!r)return!1;const n=(i,a,o,s)=>{if(P(this,ya).has(i.id)){const l=P(this,lo).get(s);l?i._setParentAndPosition(l,a,o):(i.pageIndex=s,i.x=a,i.y=o)}};return this.addCommands({cmd:()=>{for(const[i,{newX:a,newY:o,newPageIndex:s}]of t)n(i,a,o,s)},undo:()=>{for(const[i,{savedX:a,savedY:o,savedPageIndex:s}]of t)n(i,a,o,s)},mustExec:!0}),!0}dragSelectedEditors(t,r){if(P(this,od))for(const n of P(this,od).keys())n.drag(t,r)}rebuild(t){if(t.parent===null){const r=this.getLayer(t.pageIndex);r?(r.changeParent(t),r.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||P(this,Nn).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return P(this,ol)===t}getActive(){return P(this,ol)}getMode(){return P(this,$a)}get imageManager(){return dn(this,"imageManager",new UO)}getSelectionBoxes(t){if(!t)return null;const r=document.getSelection();for(let c=0,u=r.rangeCount;c<u;c++)if(!t.contains(r.getRangeAt(c).commonAncestorContainer))return null;const{x:n,y:i,width:a,height:o}=t.getBoundingClientRect();let s;switch(t.getAttribute("data-main-rotation")){case"90":s=(c,u,d,f)=>({x:(u-i)/o,y:1-(c+d-n)/a,width:f/o,height:d/a});break;case"180":s=(c,u,d,f)=>({x:1-(c+d-n)/a,y:1-(u+f-i)/o,width:d/a,height:f/o});break;case"270":s=(c,u,d,f)=>({x:1-(u+f-i)/o,y:(c-n)/a,width:f/o,height:d/a});break;default:s=(c,u,d,f)=>({x:(c-n)/a,y:(u-i)/o,width:d/a,height:f/o});break}const l=[];for(let c=0,u=r.rangeCount;c<u;c++){const d=r.getRangeAt(c);if(!d.collapsed)for(const{x:f,y:p,width:A,height:v}of d.getClientRects())A===0||v===0||l.push(s(f,p,A,v))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:r}){(P(this,N1)||ue(this,N1,new Map)).set(t,r)}removeChangedExistingAnnotation({annotationElementId:t}){var r;(r=P(this,N1))==null||r.delete(t)}renderAnnotationElement(t){var i;const r=(i=P(this,N1))==null?void 0:i.get(t.data.id);if(!r)return;const n=P(this,If).getRawValue(r);n&&(P(this,$a)===jr.NONE&&!n.hasBeenModified||n.renderAnnotationElement(t))}};F1=new WeakMap,ol=new WeakMap,ya=new WeakMap,lo=new WeakMap,L1=new WeakMap,If=new WeakMap,N1=new WeakMap,Uc=new WeakMap,G0=new WeakMap,$1=new WeakMap,yg=new WeakMap,od=new WeakMap,Kc=new WeakMap,wg=new WeakMap,uS=new WeakMap,dS=new WeakMap,j1=new WeakMap,fS=new WeakMap,sd=new WeakMap,Y0=new WeakMap,Q1=new WeakMap,U0=new WeakMap,ld=new WeakMap,o8=new WeakMap,K0=new WeakMap,hS=new WeakMap,q0=new WeakMap,Cg=new WeakMap,pS=new WeakMap,AS=new WeakMap,$a=new WeakMap,Nn=new WeakMap,Bf=new WeakMap,xg=new WeakMap,gS=new WeakMap,vS=new WeakMap,X0=new WeakMap,cd=new WeakMap,Mf=new WeakMap,mS=new WeakMap,ql=new WeakMap,Qt=new WeakSet,E8=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},YW=function(t){const{currentLayer:r}=this;if(r.hasTextLayer(t))return r;for(const n of P(this,lo).values())if(n.hasTextLayer(t))return n;return null},swe=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const n=he(this,Qt,E8).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(n);i&&(P(this,ld)||ue(this,ld,new DIe(this)),P(this,ld).show(n,i,this.direction==="ltr"))},lwe=function(){var a,o,s;const t=document.getSelection();if(!t||t.isCollapsed){P(this,Bf)&&((a=P(this,ld))==null||a.hide(),ue(this,Bf,null),he(this,Qt,ss).call(this,{hasSelectedText:!1}));return}const{anchorNode:r}=t;if(r===P(this,Bf))return;const i=he(this,Qt,E8).call(this,t).closest(".textLayer");if(!i){P(this,Bf)&&((o=P(this,ld))==null||o.hide(),ue(this,Bf,null),he(this,Qt,ss).call(this,{hasSelectedText:!1}));return}if((s=P(this,ld))==null||s.hide(),ue(this,Bf,r),he(this,Qt,ss).call(this,{hasSelectedText:!0}),!(P(this,$a)!==jr.HIGHLIGHT&&P(this,$a)!==jr.NONE)&&(P(this,$a)===jr.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),ue(this,U0,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=P(this,$a)===jr.HIGHLIGHT?he(this,Qt,YW).call(this,i):null;l==null||l.toggleDrawing();const c=new AbortController,u=this.combinedSignal(c),d=f=>{f.type==="pointerup"&&f.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&he(this,Qt,S8).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:u}),window.addEventListener("blur",d,{signal:u})}},S8=function(t=""){P(this,$a)===jr.HIGHLIGHT?this.highlightSelection(t):P(this,uS)&&he(this,Qt,swe).call(this)},cwe=function(){document.addEventListener("selectionchange",he(this,Qt,lwe).bind(this),{signal:this._signal})},uwe=function(){if(P(this,Y0))return;ue(this,Y0,new AbortController);const t=this.combinedSignal(P(this,Y0));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},dwe=function(){var t;(t=P(this,Y0))==null||t.abort(),ue(this,Y0,null)},UW=function(){if(P(this,q0))return;ue(this,q0,new AbortController);const t=this.combinedSignal(P(this,q0));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},fwe=function(){var t;(t=P(this,q0))==null||t.abort(),ue(this,q0,null)},KW=function(){if(P(this,G0))return;ue(this,G0,new AbortController);const t=this.combinedSignal(P(this,G0));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})},qW=function(){var t;(t=P(this,G0))==null||t.abort(),ue(this,G0,null)},hwe=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},ss=function(t){Object.entries(t).some(([n,i])=>P(this,vS)[n]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(P(this,vS),t)}),P(this,$a)===jr.HIGHLIGHT&&t.hasSelectedEditor===!1&&he(this,Qt,bp).call(this,[[Br.HIGHLIGHT_FREE,!0]]))},bp=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},pwe=async function(){if(!P(this,K0)){ue(this,K0,!0);const t=[];for(const r of P(this,lo).values())t.push(r.enable());await Promise.all(t);for(const r of P(this,ya).values())r.enable()}},Awe=function(){if(this.unselectAll(),P(this,K0)){ue(this,K0,!1);for(const t of P(this,lo).values())t.disable();for(const t of P(this,ya).values())t.disable()}},XW=function(t){const r=P(this,lo).get(t.pageIndex);r?r.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},gwe=function(){let t=null;for(t of P(this,Nn));return t},yI=function(){if(P(this,ya).size===0)return!0;if(P(this,ya).size===1)for(const t of P(this,ya).values())return t.isEmpty();return!1},ZW=function(t){for(const r of P(this,Nn))r.unselect();P(this,Nn).clear();for(const r of t)r.isEmpty()||(P(this,Nn).add(r),r.select());he(this,Qt,ss).call(this,{hasSelectedEditor:this.hasSelection})},Rr(H1,"TRANSLATE_SMALL",1),Rr(H1,"TRANSLATE_BIG",10);let Vp=H1;const is=class is{constructor(t){be(this,Xc);be(this,ja,null);be(this,ud,!1);be(this,qc,null);be(this,z1,null);be(this,dd,null);be(this,sl,null);be(this,W1,!1);be(this,fd,null);be(this,Bs,null);be(this,Rf,null);be(this,Eg,null);be(this,hd,!1);ue(this,Bs,t),ue(this,hd,t._uiManager.useNewAltTextFlow),P(is,Z0)||ue(is,Z0,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){is._l10n??(is._l10n=t)}async render(){const t=ue(this,qc,document.createElement("button"));t.className="altText",t.tabIndex="0";const r=ue(this,z1,document.createElement("span"));t.append(r),P(this,hd)?(t.classList.add("new"),t.setAttribute("data-l10n-id",P(is,Z0).missing),r.setAttribute("data-l10n-id",P(is,Z0)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const n=P(this,Bs)._uiManager._signal;t.addEventListener("contextmenu",Ml,{signal:n}),t.addEventListener("pointerdown",a=>a.stopPropagation(),{signal:n});const i=a=>{a.preventDefault(),P(this,Bs)._uiManager.editAltText(P(this,Bs)),P(this,hd)&&P(this,Bs)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:P(this,Xc,wI)}})};return t.addEventListener("click",i,{capture:!0,signal:n}),t.addEventListener("keydown",a=>{a.target===t&&a.key==="Enter"&&(ue(this,W1,!0),i(a))},{signal:n}),await he(this,Xc,I8).call(this),t}finish(){P(this,qc)&&(P(this,qc).focus({focusVisible:P(this,W1)}),ue(this,W1,!1))}isEmpty(){return P(this,hd)?P(this,ja)===null:!P(this,ja)&&!P(this,ud)}hasData(){return P(this,hd)?P(this,ja)!==null||!!P(this,Rf):this.isEmpty()}get guessedText(){return P(this,Rf)}async setGuessedText(t){P(this,ja)===null&&(ue(this,Rf,t),ue(this,Eg,await is._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),he(this,Xc,I8).call(this))}toggleAltTextBadge(t=!1){var r;if(!P(this,hd)||P(this,ja)){(r=P(this,fd))==null||r.remove(),ue(this,fd,null);return}if(!P(this,fd)){const n=ue(this,fd,document.createElement("div"));n.className="noAltTextBadge",P(this,Bs).div.append(n)}P(this,fd).classList.toggle("hidden",!t)}serialize(t){let r=P(this,ja);return!t&&P(this,Rf)===r&&(r=P(this,Eg)),{altText:r,decorative:P(this,ud),guessedText:P(this,Rf),textWithDisclaimer:P(this,Eg)}}get data(){return{altText:P(this,ja),decorative:P(this,ud)}}set data({altText:t,decorative:r,guessedText:n,textWithDisclaimer:i,cancel:a=!1}){n&&(ue(this,Rf,n),ue(this,Eg,i)),!(P(this,ja)===t&&P(this,ud)===r)&&(a||(ue(this,ja,t),ue(this,ud,r)),he(this,Xc,I8).call(this))}toggle(t=!1){P(this,qc)&&(!t&&P(this,sl)&&(clearTimeout(P(this,sl)),ue(this,sl,null)),P(this,qc).disabled=!t)}shown(){P(this,Bs)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:P(this,Xc,wI)}})}destroy(){var t,r;(t=P(this,qc))==null||t.remove(),ue(this,qc,null),ue(this,z1,null),ue(this,dd,null),(r=P(this,fd))==null||r.remove(),ue(this,fd,null)}};ja=new WeakMap,ud=new WeakMap,qc=new WeakMap,z1=new WeakMap,dd=new WeakMap,sl=new WeakMap,W1=new WeakMap,fd=new WeakMap,Bs=new WeakMap,Rf=new WeakMap,Eg=new WeakMap,hd=new WeakMap,Z0=new WeakMap,Xc=new WeakSet,wI=function(){return P(this,ja)&&"added"||P(this,ja)===null&&this.guessedText&&"review"||"missing"},I8=async function(){var i,a,o;const t=P(this,qc);if(!t)return;if(P(this,hd)){if(t.classList.toggle("done",!!P(this,ja)),t.setAttribute("data-l10n-id",P(is,Z0)[P(this,Xc,wI)]),(i=P(this,z1))==null||i.setAttribute("data-l10n-id",P(is,Z0)[`${P(this,Xc,wI)}-label`]),!P(this,ja)){(a=P(this,dd))==null||a.remove();return}}else{if(!P(this,ja)&&!P(this,ud)){t.classList.remove("done"),(o=P(this,dd))==null||o.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let r=P(this,dd);if(!r){ue(this,dd,r=document.createElement("span")),r.className="tooltip",r.setAttribute("role","tooltip"),r.id=`alt-text-tooltip-${P(this,Bs).id}`;const s=100,l=P(this,Bs)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(P(this,sl)),ue(this,sl,null)},{once:!0}),t.addEventListener("mouseenter",()=>{ue(this,sl,setTimeout(()=>{ue(this,sl,null),P(this,dd).classList.add("show"),P(this,Bs)._reportTelemetry({action:"alt_text_tooltip"})},s))},{signal:l}),t.addEventListener("mouseleave",()=>{var c;P(this,sl)&&(clearTimeout(P(this,sl)),ue(this,sl,null)),(c=P(this,dd))==null||c.classList.remove("show")},{signal:l})}P(this,ud)?r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(r.removeAttribute("data-l10n-id"),r.textContent=P(this,ja)),r.parentNode||t.append(r);const n=P(this,Bs).getImageForAltText();n==null||n.setAttribute("aria-describedby",r.id)},be(is,Z0,null),Rr(is,"_l10n",null);let y3=is;const Dn=class Dn{constructor(t){be(this,Wr);be(this,Sg,null);be(this,Zc,null);be(this,xi,null);be(this,V1,!1);be(this,Ig,!1);be(this,co,null);be(this,Bg,null);be(this,J0,null);be(this,bS,"");be(this,Mg,!1);be(this,ep,null);be(this,yS,!1);be(this,Rg,!1);be(this,Pf,!1);be(this,pd,null);be(this,G1,0);be(this,Y1,0);be(this,Xl,null);Rr(this,"_editToolbar",null);Rr(this,"_initialOptions",Object.create(null));Rr(this,"_initialData",null);Rr(this,"_isVisible",!0);Rr(this,"_uiManager",null);Rr(this,"_focusEventsAllowed",!0);be(this,wS,!1);be(this,s8,Dn._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:r,rawDims:{pageWidth:n,pageHeight:i,pageX:a,pageY:o}}=this.parent.viewport;this.rotation=r,this.pageRotation=(360+r-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,i],this.pageTranslation=[a,o];const[s,l]=this.parentDimensions;this.x=t.x/s,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=Dn.prototype._resizeWithKeyboard,r=Vp.TRANSLATE_SMALL,n=Vp.TRANSLATE_BIG;return dn(this,"_resizerKeyboardManager",new Jw([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-r,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[r,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-r]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,r]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,n]}],[["Escape","mac+Escape"],Dn.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return dn(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const r=new kIe({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});r.annotationElementId=t.annotationElementId,r.deleted=!0,r._uiManager.addToAnnotationStorage(r)}static initialize(t,r){if(Dn._l10n??(Dn._l10n=t),Dn._l10nResizer||(Dn._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"})),Dn._borderLineWidth!==-1)return;const n=getComputedStyle(document.documentElement);Dn._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,r){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,r){ei("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return P(this,wS)}set _isDraggable(t){var r;ue(this,wS,t),(r=this.div)==null||r.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,r]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*r/(t*2),this.y+=this.width*t/(r*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*r/(t*2),this.y-=this.width*t/(r*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=P(this,s8)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):he(this,Wr,CI).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(P(this,Mg)?ue(this,Mg,!1):this.parent.setSelected(this))}focusout(t){var n;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const r=t.relatedTarget;r!=null&&r.closest(`#${this.id}`)||(t.preventDefault(),(n=this.parent)!=null&&n.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,r,n,i){const[a,o]=this.parentDimensions;[n,i]=this.screenToPageTranslation(n,i),this.x=(t+n)/a,this.y=(r+i)/o,this.fixAndSetPosition()}translate(t,r){he(this,Wr,JW).call(this,this.parentDimensions,t,r)}translateInPage(t,r){P(this,ep)||ue(this,ep,[this.x,this.y]),he(this,Wr,JW).call(this,this.pageDimensions,t,r),this.div.scrollIntoView({block:"nearest"})}drag(t,r){P(this,ep)||ue(this,ep,[this.x,this.y]);const[n,i]=this.parentDimensions;if(this.x+=t/n,this.y+=r/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:c,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,c,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[s,l]=this.getBaseTranslation();a+=s,o+=l,this.div.style.left=`${(100*a).toFixed(2)}%`,this.div.style.top=`${(100*o).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!P(this,ep)&&(P(this,ep)[0]!==this.x||P(this,ep)[1]!==this.y)}getBaseTranslation(){const[t,r]=this.parentDimensions,{_borderLineWidth:n}=Dn,i=n/t,a=n/r;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[r,n]=this.pageDimensions;let{x:i,y:a,width:o,height:s}=this;if(o*=r,s*=n,i*=r,a*=n,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(r-o,i)),a=Math.max(0,Math.min(n-s,a));break;case 90:i=Math.max(0,Math.min(r-s,i)),a=Math.min(n,Math.max(o,a));break;case 180:i=Math.min(r,Math.max(o,i)),a=Math.min(n,Math.max(s,a));break;case 270:i=Math.min(r,Math.max(s,i)),a=Math.max(0,Math.min(n-o,a));break}this.x=i/=r,this.y=a/=n;const[l,c]=this.getBaseTranslation();i+=l,a+=c;const{style:u}=this.div;u.left=`${(100*i).toFixed(2)}%`,u.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,r){var n;return he(n=Dn,CS,eV).call(n,t,r,this.parentRotation)}pageTranslationToScreen(t,r){var n;return he(n=Dn,CS,eV).call(n,t,r,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[r,n]}=this;return[r*t,n*t]}setDims(t,r){const[n,i]=this.parentDimensions;this.div.style.width=`${(100*t/n).toFixed(2)}%`,P(this,Ig)||(this.div.style.height=`${(100*r/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:r,width:n}=t,i=n.endsWith("%"),a=!P(this,Ig)&&r.endsWith("%");if(i&&a)return;const[o,s]=this.parentDimensions;i||(t.width=`${(100*parseFloat(n)/o).toFixed(2)}%`),!P(this,Ig)&&!a&&(t.height=`${(100*parseFloat(r)/s).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=P(this,xi))==null||t.finish()}async addEditToolbar(){return this._editToolbar||P(this,Rg)?this._editToolbar:(this._editToolbar=new YO(this),this.div.append(this._editToolbar.render()),P(this,xi)&&await this._editToolbar.addAltText(P(this,xi)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=P(this,xi))==null||t.destroy())}addContainer(t){var n;const r=(n=this._editToolbar)==null?void 0:n.div;r?r.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){P(this,xi)||(y3.initialize(Dn._l10n),ue(this,xi,new y3(this)),P(this,Sg)&&(P(this,xi).data=P(this,Sg),ue(this,Sg,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=P(this,xi))==null?void 0:t.data}set altTextData(t){P(this,xi)&&(P(this,xi).data=t)}get guessedAltText(){var t;return(t=P(this,xi))==null?void 0:t.guessedText}async setGuessedAltText(t){var r;await((r=P(this,xi))==null?void 0:r.setGuessedText(t))}serializeAltText(t){var r;return(r=P(this,xi))==null?void 0:r.serialize(t)}hasAltText(){return!!P(this,xi)&&!P(this,xi).isEmpty()}hasAltTextData(){var t;return((t=P(this,xi))==null?void 0:t.hasData())??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=P(this,V1)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),he(this,Wr,aV).call(this);const[t,r]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*r/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/r).toFixed(2)}%`);const[n,i]=this.getInitialTranslation();return this.translate(n,i),b3(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:r}=Vo.platform;if(t.button!==0||t.ctrlKey&&r){t.preventDefault();return}if(ue(this,Mg,!0),this._isDraggable){he(this,Wr,bwe).call(this,t);return}he(this,Wr,iV).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}moveInDOM(){P(this,pd)&&clearTimeout(P(this,pd)),ue(this,pd,setTimeout(()=>{var t;ue(this,pd,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,r,n){t.changeParent(this),this.x=r,this.y=n,this.fixAndSetPosition()}getRect(t,r,n=this.rotation){const i=this.parentScale,[a,o]=this.pageDimensions,[s,l]=this.pageTranslation,c=t/i,u=r/i,d=this.x*a,f=this.y*o,p=this.width*a,A=this.height*o;switch(n){case 0:return[d+c+s,o-f-u-A+l,d+c+p+s,o-f-u+l];case 90:return[d+u+s,o-f+c+l,d+u+A+s,o-f+c+p+l];case 180:return[d-c-p+s,o-f+u+l,d-c+s,o-f+u+A+l];case 270:return[d-u-A+s,o-f-c-p+l,d-u+s,o-f-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,r){const[n,i,a,o]=t,s=a-n,l=o-i;switch(this.rotation){case 0:return[n,r-o,s,l];case 90:return[n,r-i,l,s];case 180:return[a,r-i,s,l];case 270:return[a,r-o,l,s];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){ue(this,Rg,!0)}disableEditMode(){ue(this,Rg,!1)}isInEditMode(){return P(this,Rg)}shouldGetKeyboardEvents(){return P(this,Pf)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){he(this,Wr,aV).call(this)}rotate(t){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,r=null){ei("An editor must be serializable")}static async deserialize(t,r,n){const i=new this.prototype.constructor({parent:r,id:r.getNextId(),uiManager:n});i.rotation=t.rotation,ue(i,Sg,t.accessibilityData);const[a,o]=i.pageDimensions,[s,l,c,u]=i.getRectInCurrentCoords(t.rect,o);return i.x=s/a,i.y=l/o,i.width=c/a,i.height=u/o,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t;if((t=P(this,J0))==null||t.abort(),ue(this,J0,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),P(this,pd)&&(clearTimeout(P(this,pd)),ue(this,pd,null)),he(this,Wr,CI).call(this),this.removeEditToolbar(),P(this,Xl)){for(const r of P(this,Xl).values())clearTimeout(r);ue(this,Xl,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(he(this,Wr,vwe).call(this),P(this,co).classList.remove("hidden"),b3(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),ue(this,Bg,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const r=P(this,co).children;if(!P(this,Zc)){ue(this,Zc,Array.from(r));const o=he(this,Wr,ywe).bind(this),s=he(this,Wr,wwe).bind(this),l=this._uiManager._signal;for(const c of P(this,Zc)){const u=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",o,{signal:l}),c.addEventListener("blur",s,{signal:l}),c.addEventListener("focus",he(this,Wr,Cwe).bind(this,u),{signal:l}),c.setAttribute("data-l10n-id",Dn._l10nResizer[u])}}const n=P(this,Zc)[0];let i=0;for(const o of r){if(o===n)break;i++}const a=(360-this.rotation+this.parentRotation)%360/90*(P(this,Zc).length/4);if(a!==i){if(a<i)for(let s=0;s<i-a;s++)P(this,co).append(P(this,co).firstChild);else if(a>i)for(let s=0;s<a-i;s++)P(this,co).firstChild.before(P(this,co).lastChild);let o=0;for(const s of r){const c=P(this,Zc)[o++].getAttribute("data-resizer-name");s.setAttribute("data-l10n-id",Dn._l10nResizer[c])}}he(this,Wr,oV).call(this,0),ue(this,Pf,!0),P(this,co).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,r){P(this,Pf)&&he(this,Wr,nV).call(this,P(this,bS),{movementX:t,movementY:r})}_stopResizingWithKeyboard(){he(this,Wr,CI).call(this),this.div.focus()}select(){var t,r,n;if(this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,a;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((a=this._editToolbar)==null||a.show())});return}(r=this._editToolbar)==null||r.show(),(n=P(this,xi))==null||n.toggleAltTextBadge(!1)}unselect(){var t,r,n,i,a;(t=P(this,co))==null||t.classList.add("hidden"),(r=this.div)==null||r.classList.remove("selectedEditor"),(n=this.div)!=null&&n.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(a=P(this,xi))==null||a.toggleAltTextBadge(!0)}updateParams(t,r){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return P(this,yS)}set isEditing(t){ue(this,yS,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,r){ue(this,Ig,!0);const n=t/r,{style:i}=this.div;i.aspectRatio=n,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,r=!1){if(r){P(this,Xl)||ue(this,Xl,new Map);const{action:n}=t;let i=P(this,Xl).get(n);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),P(this,Xl).delete(n),P(this,Xl).size===0&&ue(this,Xl,null)},Dn._telemetryTimeout),P(this,Xl).set(n,i);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),ue(this,V1,!1)}disable(){this.div&&(this.div.tabIndex=-1),ue(this,V1,!0)}renderAnnotationElement(t){let r=t.container.querySelector(".annotationContent");if(!r)r=document.createElement("div"),r.classList.add("annotationContent",this.editorType),t.container.prepend(r);else if(r.nodeName==="CANVAS"){const n=r;r=document.createElement("div"),r.classList.add("annotationContent",this.editorType),n.before(r)}return r}resetAnnotationElement(t){const{firstChild:r}=t.container;(r==null?void 0:r.nodeName)==="DIV"&&r.classList.contains("annotationContent")&&r.remove()}};Sg=new WeakMap,Zc=new WeakMap,xi=new WeakMap,V1=new WeakMap,Ig=new WeakMap,co=new WeakMap,Bg=new WeakMap,J0=new WeakMap,bS=new WeakMap,Mg=new WeakMap,ep=new WeakMap,yS=new WeakMap,Rg=new WeakMap,Pf=new WeakMap,pd=new WeakMap,G1=new WeakMap,Y1=new WeakMap,Xl=new WeakMap,wS=new WeakMap,s8=new WeakMap,Wr=new WeakSet,JW=function([t,r],n,i){[n,i]=this.screenToPageTranslation(n,i),this.x+=n/t,this.y+=i/r,this.fixAndSetPosition()},CS=new WeakSet,eV=function(t,r,n){switch(n){case 90:return[r,-t];case 180:return[-t,-r];case 270:return[-r,t];default:return[t,r]}},tV=function(t){switch(t){case 90:{const[r,n]=this.pageDimensions;return[0,-r/n,n/r,0]}case 180:return[-1,0,0,-1];case 270:{const[r,n]=this.pageDimensions;return[0,r/n,-n/r,0]}default:return[1,0,0,1]}},vwe=function(){if(P(this,co))return;ue(this,co,document.createElement("div")),P(this,co).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],r=this._uiManager._signal;for(const n of t){const i=document.createElement("div");P(this,co).append(i),i.classList.add("resizer",n),i.setAttribute("data-resizer-name",n),i.addEventListener("pointerdown",he(this,Wr,mwe).bind(this,n),{signal:r}),i.addEventListener("contextmenu",Ml,{signal:r}),i.tabIndex=-1}this.div.prepend(P(this,co))},mwe=function(t,r){var A;r.preventDefault();const{isMac:n}=Vo.platform;if(r.button!==0||r.ctrlKey&&n)return;(A=P(this,xi))==null||A.toggle(!1);const i=this._isDraggable;this._isDraggable=!1;const a=new AbortController,o=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",he(this,Wr,nV).bind(this,t),{passive:!0,capture:!0,signal:o}),window.addEventListener("contextmenu",Ml,{signal:o});const s=this.x,l=this.y,c=this.width,u=this.height,d=this.parent.div.style.cursor,f=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(r.target).cursor;const p=()=>{var v;a.abort(),this.parent.togglePointerEvents(!0),(v=P(this,xi))==null||v.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=d,this.div.style.cursor=f,he(this,Wr,rV).call(this,s,l,c,u)};window.addEventListener("pointerup",p,{signal:o}),window.addEventListener("blur",p,{signal:o})},rV=function(t,r,n,i){const a=this.x,o=this.y,s=this.width,l=this.height;a===t&&o===r&&s===n&&l===i||this.addCommands({cmd:()=>{this.width=s,this.height=l,this.x=a,this.y=o;const[c,u]=this.parentDimensions;this.setDims(c*s,u*l),this.fixAndSetPosition()},undo:()=>{this.width=n,this.height=i,this.x=t,this.y=r;const[c,u]=this.parentDimensions;this.setDims(c*n,u*i),this.fixAndSetPosition()},mustExec:!0})},nV=function(t,r){const[n,i]=this.parentDimensions,a=this.x,o=this.y,s=this.width,l=this.height,c=Dn.MIN_SIZE/n,u=Dn.MIN_SIZE/i,d=M=>Math.round(M*1e4)/1e4,f=he(this,Wr,tV).call(this,this.rotation),p=(M,T)=>[f[0]*M+f[2]*T,f[1]*M+f[3]*T],A=he(this,Wr,tV).call(this,360-this.rotation),v=(M,T)=>[A[0]*M+A[2]*T,A[1]*M+A[3]*T];let g,m,y=!1,b=!1;switch(t){case"topLeft":y=!0,g=(M,T)=>[0,0],m=(M,T)=>[M,T];break;case"topMiddle":g=(M,T)=>[M/2,0],m=(M,T)=>[M/2,T];break;case"topRight":y=!0,g=(M,T)=>[M,0],m=(M,T)=>[0,T];break;case"middleRight":b=!0,g=(M,T)=>[M,T/2],m=(M,T)=>[0,T/2];break;case"bottomRight":y=!0,g=(M,T)=>[M,T],m=(M,T)=>[0,0];break;case"bottomMiddle":g=(M,T)=>[M/2,T],m=(M,T)=>[M/2,0];break;case"bottomLeft":y=!0,g=(M,T)=>[0,T],m=(M,T)=>[M,0];break;case"middleLeft":b=!0,g=(M,T)=>[0,T/2],m=(M,T)=>[M,T/2];break}const C=g(s,l),w=m(s,l);let x=p(...w);const E=d(a+x[0]),S=d(o+x[1]);let I=1,B=1,[R,_]=this.screenToPageTranslation(r.movementX,r.movementY);if([R,_]=v(R/n,_/i),y){const M=Math.hypot(s,l);I=B=Math.max(Math.min(Math.hypot(w[0]-C[0]-R,w[1]-C[1]-_)/M,1/s,1/l),c/s,u/l)}else b?I=Math.max(c,Math.min(1,Math.abs(w[0]-C[0]-R)))/s:B=Math.max(u,Math.min(1,Math.abs(w[1]-C[1]-_)))/l;const O=d(s*I),F=d(l*B);x=p(...m(O,F));const k=E-x[0],D=S-x[1];this.width=O,this.height=F,this.x=k,this.y=D,this.setDims(n*O,i*F),this.fixAndSetPosition()},iV=function(t){const{isMac:r}=Vo.platform;t.ctrlKey&&!r||t.shiftKey||t.metaKey&&r?this.parent.toggleSelected(this):this.parent.setSelected(this)},bwe=function(t){const{isSelected:r}=this;this._uiManager.setUpDragSession();const n=new AbortController,i=this._uiManager.combinedSignal(n);if(r){this.div.classList.add("moving"),ue(this,G1,t.clientX),ue(this,Y1,t.clientY);const o=s=>{const{clientX:l,clientY:c}=s,[u,d]=this.screenToPageTranslation(l-P(this,G1),c-P(this,Y1));ue(this,G1,l),ue(this,Y1,c),this._uiManager.dragSelectedEditors(u,d)};window.addEventListener("pointermove",o,{passive:!0,capture:!0,signal:i})}const a=()=>{n.abort(),r&&this.div.classList.remove("moving"),ue(this,Mg,!1),this._uiManager.endDragSession()||he(this,Wr,iV).call(this,t)};window.addEventListener("pointerup",a,{signal:i}),window.addEventListener("blur",a,{signal:i})},aV=function(){if(P(this,J0)||!this.div)return;ue(this,J0,new AbortController);const t=this._uiManager.combinedSignal(P(this,J0));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},ywe=function(t){Dn._resizerKeyboardManager.exec(this,t)},wwe=function(t){var r;P(this,Pf)&&((r=t.relatedTarget)==null?void 0:r.parentNode)!==P(this,co)&&he(this,Wr,CI).call(this)},Cwe=function(t){ue(this,bS,P(this,Pf)?t:"")},oV=function(t){if(P(this,Zc))for(const r of P(this,Zc))r.tabIndex=t},CI=function(){if(ue(this,Pf,!1),he(this,Wr,oV).call(this,-1),P(this,Bg)){const{savedX:t,savedY:r,savedWidth:n,savedHeight:i}=P(this,Bg);he(this,Wr,rV).call(this,t,r,n,i),ue(this,Bg,null)}},be(Dn,CS),Rr(Dn,"_l10n",null),Rr(Dn,"_l10nResizer",null),Rr(Dn,"_borderLineWidth",-1),Rr(Dn,"_colorManager",new KO),Rr(Dn,"_zIndex",1),Rr(Dn,"_telemetryTimeout",1e3);let kn=Dn;class kIe extends kn{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Lq=3285377520,Rl=4294901760,Cu=65535;class Nq{constructor(t){this.h1=t?t&4294967295:Lq,this.h2=t?t&4294967295:Lq}update(t){let r,n;if(typeof t=="string"){r=new Uint8Array(t.length*2),n=0;for(let v=0,g=t.length;v<g;v++){const m=t.charCodeAt(v);m<=255?r[n++]=m:(r[n++]=m>>>8,r[n++]=m&255)}}else if(ArrayBuffer.isView(t))r=t.slice(),n=r.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=n>>2,a=n-i*4,o=new Uint32Array(r.buffer,0,i);let s=0,l=0,c=this.h1,u=this.h2;const d=3432918353,f=461845907,p=d&Cu,A=f&Cu;for(let v=0;v<i;v++)v&1?(s=o[v],s=s*d&Rl|s*p&Cu,s=s<<15|s>>>17,s=s*f&Rl|s*A&Cu,c^=s,c=c<<13|c>>>19,c=c*5+3864292196):(l=o[v],l=l*d&Rl|l*p&Cu,l=l<<15|l>>>17,l=l*f&Rl|l*A&Cu,u^=l,u=u<<13|u>>>19,u=u*5+3864292196);switch(s=0,a){case 3:s^=r[i*4+2]<<16;case 2:s^=r[i*4+1]<<8;case 1:s^=r[i*4],s=s*d&Rl|s*p&Cu,s=s<<15|s>>>17,s=s*f&Rl|s*A&Cu,i&1?c^=s:u^=s}this.h1=c,this.h2=u}hexdigest(){let t=this.h1,r=this.h2;return t^=r>>>1,t=t*3981806797&Rl|t*36045&Cu,r=r*4283543511&Rl|((r<<16|t>>>16)*2950163797&Rl)>>>16,t^=r>>>1,t=t*444984403&Rl|t*60499&Cu,r=r*3301882366&Rl|((r<<16|t>>>16)*3120437893&Rl)>>>16,t^=r>>>1,(t>>>0).toString(16).padStart(8,"0")+(r>>>0).toString(16).padStart(8,"0")}}const qO=Object.freeze({map:null,hash:"",transfer:void 0});class XO{constructor(){be(this,l8);be(this,Pg,!1);be(this,Dg,null);be(this,Qa,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,r){const n=P(this,Qa).get(t);return n===void 0?r:Object.assign(r,n)}getRawValue(t){return P(this,Qa).get(t)}remove(t){if(P(this,Qa).delete(t),P(this,Qa).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const r of P(this,Qa).values())if(r instanceof kn)return;this.onAnnotationEditor(null)}}setValue(t,r){const n=P(this,Qa).get(t);let i=!1;if(n!==void 0)for(const[a,o]of Object.entries(r))n[a]!==o&&(i=!0,n[a]=o);else i=!0,P(this,Qa).set(t,r);i&&he(this,l8,xwe).call(this),r instanceof kn&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(r.constructor._type)}has(t){return P(this,Qa).has(t)}getAll(){return P(this,Qa).size>0?NO(P(this,Qa)):null}setAll(t){for(const[r,n]of Object.entries(t))this.setValue(r,n)}get size(){return P(this,Qa).size}resetModified(){P(this,Pg)&&(ue(this,Pg,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new $q(this)}get serializable(){if(P(this,Qa).size===0)return qO;const t=new Map,r=new Nq,n=[],i=Object.create(null);let a=!1;for(const[o,s]of P(this,Qa)){const l=s instanceof kn?s.serialize(!1,i):s;l&&(t.set(o,l),r.update(`${o}:${JSON.stringify(l)}`),a||(a=!!l.bitmap))}if(a)for(const o of t.values())o.bitmap&&n.push(o.bitmap);return t.size>0?{map:t,hash:r.hexdigest(),transfer:n}:qO}get editorStats(){let t=null;const r=new Map;for(const n of P(this,Qa).values()){if(!(n instanceof kn))continue;const i=n.telemetryFinalData;if(!i)continue;const{type:a}=i;r.has(a)||r.set(a,Object.getPrototypeOf(n).constructor),t||(t=Object.create(null));const o=t[a]||(t[a]=new Map);for(const[s,l]of Object.entries(i)){if(s==="type")continue;let c=o.get(s);c||(c=new Map,o.set(s,c));const u=c.get(l)??0;c.set(l,u+1)}}for(const[n,i]of r)t[n]=i.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){ue(this,Dg,null)}get modifiedIds(){if(P(this,Dg))return P(this,Dg);const t=[];for(const r of P(this,Qa).values())!(r instanceof kn)||!r.annotationElementId||!r.serialize()||t.push(r.annotationElementId);return ue(this,Dg,{ids:new Set(t),hash:t.join(",")})}}Pg=new WeakMap,Dg=new WeakMap,Qa=new WeakMap,l8=new WeakSet,xwe=function(){P(this,Pg)||(ue(this,Pg,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class $q extends XO{constructor(r){super();be(this,xS);const{map:n,hash:i,transfer:a}=r.serializable,o=structuredClone(n,a?{transfer:a}:null);ue(this,xS,{map:o,hash:i,transfer:a})}get print(){ei("Should not call PrintAnnotationStorage.print")}get serializable(){return P(this,xS)}get modifiedIds(){return dn(this,"modifiedIds",{ids:new Set,hash:""})}}xS=new WeakMap;class FIe{constructor({ownerDocument:t=globalThis.document,styleElement:r=null}){be(this,U1,new Set);this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const r=this.styleElement.sheet;r.insertRule(t,r.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),P(this,U1).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:r}){if(!(!t||P(this,U1).has(t.loadedName))){if(sa(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:i,style:a}=t,o=new FontFace(n,i,a);this.addNativeFontFace(o);try{await o.load(),P(this,U1).add(n),r==null||r(t)}catch{Gr(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}ei("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const n=t.createNativeFontFace();if(n){this.addNativeFontFace(n);try{await n.loaded}catch(i){throw Gr(`Failed to load font '${n.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const r=t.createFontFaceRule();if(r){if(this.insertRule(r),this.isSyncFontLoadingSupported)return;await new Promise(n=>{const i=this._queueLoadingCallback(n);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var r;const t=!!((r=this._document)!=null&&r.fonts);return dn(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(yo||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),dn(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function r(){for(sa(!i.done,"completeRequest() cannot be called twice."),i.done=!0;n.length>0&&n[0].done;){const a=n.shift();setTimeout(a.callback,0)}}const{loadingRequests:n}=this,i={done:!1,complete:r,callback:t};return n.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return dn(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,r){function n(C,w){return C.charCodeAt(w)<<24|C.charCodeAt(w+1)<<16|C.charCodeAt(w+2)<<8|C.charCodeAt(w+3)&255}function i(C,w,x,E){const S=C.substring(0,w),I=C.substring(w+x);return S+E+I}let a,o;const s=this._document.createElement("canvas");s.width=1,s.height=1;const l=s.getContext("2d");let c=0;function u(C,w){if(++c>30){Gr("Load test font never loaded."),w();return}if(l.font="30px "+C,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){w();return}setTimeout(u.bind(null,C,w))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,d.length,d);const A=16,v=1482184792;let g=n(f,A);for(a=0,o=d.length-3;a<o;a+=4)g=g-v+n(d,a)|0;a<d.length&&(g=g-v+n(d+"XXX",a)|0),f=i(f,A,4,yIe(g));const m=`url(data:font/opentype;base64,${btoa(f)});`,y=`@font-face {font-family:"${d}";src:${m}}`;this.insertRule(y);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 C of[t.loadedName,d]){const w=this._document.createElement("span");w.textContent="Hi",w.style.fontFamily=C,b.append(w)}this._document.body.append(b),u(d,()=>{b.remove(),r.complete()})}}U1=new WeakMap;class LIe{constructor(t,{disableFontFace:r=!1,inspectFont:n=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=r===!0,this._inspectFont=n}createNativeFontFace(){var r;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const n={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(n.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,n)}return(r=this._inspectFont)==null||r.call(this,this),t}createFontFaceRule(){var n;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${IIe(this.data)});`;let r;if(!this.cssFontInfo)r=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),r=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return(n=this._inspectFont)==null||n.call(this,this,t),r}getPathGenerator(t,r){if(this.compiledGlyphs[r]!==void 0)return this.compiledGlyphs[r];let n;try{n=t.get(this.loadedName+"_path_"+r)}catch(a){Gr(`getPathGenerator - ignoring character: "${a}".`)}if(!Array.isArray(n)||n.length===0)return this.compiledGlyphs[r]=function(a,o){};const i=[];for(let a=0,o=n.length;a<o;)switch(n[a++]){case jd.BEZIER_CURVE_TO:{const[s,l,c,u,d,f]=n.slice(a,a+6);i.push(p=>p.bezierCurveTo(s,l,c,u,d,f)),a+=6}break;case jd.MOVE_TO:{const[s,l]=n.slice(a,a+2);i.push(c=>c.moveTo(s,l)),a+=2}break;case jd.LINE_TO:{const[s,l]=n.slice(a,a+2);i.push(c=>c.lineTo(s,l)),a+=2}break;case jd.QUADRATIC_CURVE_TO:{const[s,l,c,u]=n.slice(a,a+4);i.push(d=>d.quadraticCurveTo(s,l,c,u)),a+=4}break;case jd.RESTORE:i.push(s=>s.restore());break;case jd.SAVE:i.push(s=>s.save());break;case jd.SCALE:sa(i.length===2,"Scale command is only valid at the third position.");break;case jd.TRANSFORM:{const[s,l,c,u,d,f]=n.slice(a,a+6);i.push(p=>p.transform(s,l,c,u,d,f)),a+=6}break;case jd.TRANSLATE:{const[s,l]=n.slice(a,a+2);i.push(c=>c.translate(s,l)),a+=2}break}return this.compiledGlyphs[r]=function(o,s){i[0](o),i[1](o),o.scale(s,-s);for(let l=2,c=i.length;l<c;l++)i[l](o)}}}class jq{constructor({enableHWA:t=!1}){be(this,ES,!1);ue(this,ES,t)}create(t,r){if(t<=0||r<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(t,r);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!P(this,ES)})}}reset(t,r,n){if(!t.canvas)throw new Error("Canvas is not specified");if(r<=0||n<=0)throw new Error("Invalid canvas size");t.canvas.width=r,t.canvas.height=n}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,r){ei("Abstract method `_createCanvas` called.")}}ES=new WeakMap;class NIe extends jq{constructor({ownerDocument:t=globalThis.document,enableHWA:r=!1}){super({enableHWA:r}),this._document=t}_createCanvas(t,r){const n=this._document.createElement("canvas");return n.width=t,n.height=r,n}}class Qq{constructor({baseUrl:t=null,isCompressed:r=!0}){this.baseUrl=t,this.isCompressed=r}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 r=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(r).then(n=>({cMapData:n,isCompressed:this.isCompressed})).catch(n=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${r}`)})}async _fetch(t){ei("Abstract method `_fetch` called.")}}class Hq extends Qq{async _fetch(t){const r=await v3(t,this.isCompressed?"arraybuffer":"text");return r instanceof ArrayBuffer?new Uint8Array(r):g3(r)}}class zq{addFilter(t){return"none"}addHCMFilter(t,r){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,r,n,i,a){return"none"}destroy(t=!1){}}class $Ie extends zq{constructor({docId:r,ownerDocument:n=globalThis.document}){super();be(this,Yt);be(this,Tg);be(this,_g);be(this,Ad);be(this,Df);be(this,_o);be(this,c8);be(this,Og,0);ue(this,Df,r),ue(this,_o,n)}addFilter(r){if(!r)return"none";let n=P(this,Yt,$o).get(r);if(n)return n;const[i,a,o]=he(this,Yt,B8).call(this,r),s=r.length===1?i:`${i}${a}${o}`;if(n=P(this,Yt,$o).get(s),n)return P(this,Yt,$o).set(r,n),n;const l=`g_${P(this,Df)}_transfer_map_${os(this,Og)._++}`,c=he(this,Yt,ky).call(this,l);P(this,Yt,$o).set(r,c),P(this,Yt,$o).set(s,c);const u=he(this,Yt,Fy).call(this,l);return he(this,Yt,EI).call(this,i,a,o,u),c}addHCMFilter(r,n){var A;const i=`${r}-${n}`,a="base";let o=P(this,Yt,_y).get(a);if((o==null?void 0:o.key)===i||(o?((A=o.filter)==null||A.remove(),o.key=i,o.url="none",o.filter=null):(o={key:i,url:"none",filter:null},P(this,Yt,_y).set(a,o)),!r||!n))return o.url;const s=he(this,Yt,SI).call(this,r);r=rr.makeHexColor(...s);const l=he(this,Yt,SI).call(this,n);if(n=rr.makeHexColor(...l),P(this,Yt,Oy).style.color="",r==="#000000"&&n==="#ffffff"||r===n)return o.url;const c=new Array(256);for(let v=0;v<=255;v++){const g=v/255;c[v]=g<=.03928?g/12.92:((g+.055)/1.055)**2.4}const u=c.join(","),d=`g_${P(this,Df)}_hcm_filter`,f=o.filter=he(this,Yt,Fy).call(this,d);he(this,Yt,EI).call(this,u,u,u,f),he(this,Yt,sV).call(this,f);const p=(v,g)=>{const m=s[v]/255,y=l[v]/255,b=new Array(g+1);for(let C=0;C<=g;C++)b[C]=m+C/g*(y-m);return b.join(",")};return he(this,Yt,EI).call(this,p(0,5),p(1,5),p(2,5),f),o.url=he(this,Yt,ky).call(this,d),o.url}addAlphaFilter(r){let n=P(this,Yt,$o).get(r);if(n)return n;const[i]=he(this,Yt,B8).call(this,[r]),a=`alpha_${i}`;if(n=P(this,Yt,$o).get(a),n)return P(this,Yt,$o).set(r,n),n;const o=`g_${P(this,Df)}_alpha_map_${os(this,Og)._++}`,s=he(this,Yt,ky).call(this,o);P(this,Yt,$o).set(r,s),P(this,Yt,$o).set(a,s);const l=he(this,Yt,Fy).call(this,o);return he(this,Yt,lV).call(this,i,l),s}addLuminosityFilter(r){let n=P(this,Yt,$o).get(r||"luminosity");if(n)return n;let i,a;if(r?([i]=he(this,Yt,B8).call(this,[r]),a=`luminosity_${i}`):a="luminosity",n=P(this,Yt,$o).get(a),n)return P(this,Yt,$o).set(r,n),n;const o=`g_${P(this,Df)}_luminosity_map_${os(this,Og)._++}`,s=he(this,Yt,ky).call(this,o);P(this,Yt,$o).set(r,s),P(this,Yt,$o).set(a,s);const l=he(this,Yt,Fy).call(this,o);return he(this,Yt,Ewe).call(this,l),r&&he(this,Yt,lV).call(this,i,l),s}addHighlightHCMFilter(r,n,i,a,o){var y;const s=`${n}-${i}-${a}-${o}`;let l=P(this,Yt,_y).get(r);if((l==null?void 0:l.key)===s||(l?((y=l.filter)==null||y.remove(),l.key=s,l.url="none",l.filter=null):(l={key:s,url:"none",filter:null},P(this,Yt,_y).set(r,l)),!n||!i))return l.url;const[c,u]=[n,i].map(he(this,Yt,SI).bind(this));let d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),[p,A]=[a,o].map(he(this,Yt,SI).bind(this));f<d&&([d,f,p,A]=[f,d,A,p]),P(this,Yt,Oy).style.color="";const v=(b,C,w)=>{const x=new Array(256),E=(f-d)/w,S=b/255,I=(C-b)/(255*w);let B=0;for(let R=0;R<=w;R++){const _=Math.round(d+R*E),O=S+R*I;for(let F=B;F<=_;F++)x[F]=O;B=_+1}for(let R=B;R<256;R++)x[R]=x[B-1];return x.join(",")},g=`g_${P(this,Df)}_hcm_${r}_filter`,m=l.filter=he(this,Yt,Fy).call(this,g);return he(this,Yt,sV).call(this,m),he(this,Yt,EI).call(this,v(p[0],A[0],5),v(p[1],A[1],5),v(p[2],A[2],5),m),l.url=he(this,Yt,ky).call(this,g),l.url}destroy(r=!1){r&&P(this,Yt,_y).size!==0||(P(this,Ad)&&(P(this,Ad).parentNode.parentNode.remove(),ue(this,Ad,null)),P(this,_g)&&(P(this,_g).clear(),ue(this,_g,null)),ue(this,Og,0))}}Tg=new WeakMap,_g=new WeakMap,Ad=new WeakMap,Df=new WeakMap,_o=new WeakMap,c8=new WeakMap,Og=new WeakMap,Yt=new WeakSet,$o=function(){return P(this,_g)||ue(this,_g,new Map)},_y=function(){return P(this,c8)||ue(this,c8,new Map)},Oy=function(){if(!P(this,Ad)){const r=P(this,_o).createElement("div"),{style:n}=r;n.visibility="hidden",n.contain="strict",n.width=n.height=0,n.position="absolute",n.top=n.left=0,n.zIndex=-1;const i=P(this,_o).createElementNS(Qd,"svg");i.setAttribute("width",0),i.setAttribute("height",0),ue(this,Ad,P(this,_o).createElementNS(Qd,"defs")),r.append(i),i.append(P(this,Ad)),P(this,_o).body.append(r)}return P(this,Ad)},B8=function(r){if(r.length===1){const c=r[0],u=new Array(256);for(let f=0;f<256;f++)u[f]=c[f]/255;const d=u.join(",");return[d,d,d]}const[n,i,a]=r,o=new Array(256),s=new Array(256),l=new Array(256);for(let c=0;c<256;c++)o[c]=n[c]/255,s[c]=i[c]/255,l[c]=a[c]/255;return[o.join(","),s.join(","),l.join(",")]},ky=function(r){if(P(this,Tg)===void 0){ue(this,Tg,"");const n=P(this,_o).URL;n!==P(this,_o).baseURI&&(m3(n)?Gr('#createUrl: ignore "data:"-URL for performance reasons.'):ue(this,Tg,n.split("#",1)[0]))}return`url(${P(this,Tg)}#${r})`},Ewe=function(r){const n=P(this,_o).createElementNS(Qd,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),r.append(n)},sV=function(r){const n=P(this,_o).createElementNS(Qd,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),r.append(n)},Fy=function(r){const n=P(this,_o).createElementNS(Qd,"filter");return n.setAttribute("color-interpolation-filters","sRGB"),n.setAttribute("id",r),P(this,Yt,Oy).append(n),n},xI=function(r,n,i){const a=P(this,_o).createElementNS(Qd,n);a.setAttribute("type","discrete"),a.setAttribute("tableValues",i),r.append(a)},EI=function(r,n,i,a){const o=P(this,_o).createElementNS(Qd,"feComponentTransfer");a.append(o),he(this,Yt,xI).call(this,o,"feFuncR",r),he(this,Yt,xI).call(this,o,"feFuncG",n),he(this,Yt,xI).call(this,o,"feFuncB",i)},lV=function(r,n){const i=P(this,_o).createElementNS(Qd,"feComponentTransfer");n.append(i),he(this,Yt,xI).call(this,i,"feFuncA",r)},SI=function(r){return P(this,Yt,Oy).style.color=r,VO(getComputedStyle(P(this,Yt,Oy)).getPropertyValue("color"))};class Wq{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 r=`${this.baseUrl}${t}`;return this._fetch(r).catch(n=>{throw new Error(`Unable to load font data at: ${r}`)})}async _fetch(t){ei("Abstract method `_fetch` called.")}}class Vq extends Wq{async _fetch(t){const r=await v3(t,"arraybuffer");return new Uint8Array(r)}}if(yo){var ZO=Promise.withResolvers(),eC=null;(async()=>{const t=await Promise.resolve().then(()=>t8),r=await Promise.resolve().then(()=>t8),n=await Promise.resolve().then(()=>t8),i=await Promise.resolve().then(()=>t8);let a,o;return new Map(Object.entries({fs:t,http:r,https:n,url:i,canvas:a,path2d:o}))})().then(t=>{eC=t,ZO.resolve()},t=>{Gr(`loadPackages: ${t}`),eC=new Map,ZO.resolve()})}class Mh{static get promise(){return ZO.promise}static get(t){return eC==null?void 0:eC.get(t)}}async function Gq(e){const r=await Mh.get("fs").promises.readFile(e);return new Uint8Array(r)}class jIe extends zq{}class QIe extends jq{_createCanvas(t,r){return Mh.get("canvas").createCanvas(t,r)}}class HIe extends Qq{async _fetch(t){return Gq(t)}}class zIe extends Wq{async _fetch(t){return Gq(t)}}const Go={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function JO(e,t){if(!t)return;const r=t[2]-t[0],n=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],r,n),e.clip(i)}class ek{getPattern(){ei("Abstract method `getPattern` called.")}}class WIe extends ek{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 r;this._type==="axial"?r=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(r=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const n of this._colorStops)r.addColorStop(n[0],n[1]);return r}getPattern(t,r,n,i){let a;if(i===Go.STROKE||i===Go.FILL){const o=r.current.getClippedPathBoundingBox(i,bi(t))||[0,0,0,0],s=Math.ceil(o[2]-o[0])||1,l=Math.ceil(o[3]-o[1])||1,c=r.cachedCanvases.getCanvas("pattern",s,l),u=c.context;u.clearRect(0,0,u.canvas.width,u.canvas.height),u.beginPath(),u.rect(0,0,u.canvas.width,u.canvas.height),u.translate(-o[0],-o[1]),n=rr.transform(n,[1,0,0,1,o[0],o[1]]),u.transform(...r.baseTransform),this.matrix&&u.transform(...this.matrix),JO(u,this._bbox),u.fillStyle=this._createGradient(u),u.fill(),a=t.createPattern(c.canvas,"no-repeat");const d=new DOMMatrix(n);a.setTransform(d)}else JO(t,this._bbox),a=this._createGradient(t);return a}}function tk(e,t,r,n,i,a,o,s){const l=t.coords,c=t.colors,u=e.data,d=e.width*4;let f;l[r+1]>l[n+1]&&(f=r,r=n,n=f,f=a,a=o,o=f),l[n+1]>l[i+1]&&(f=n,n=i,i=f,f=o,o=s,s=f),l[r+1]>l[n+1]&&(f=r,r=n,n=f,f=a,a=o,o=f);const p=(l[r]+t.offsetX)*t.scaleX,A=(l[r+1]+t.offsetY)*t.scaleY,v=(l[n]+t.offsetX)*t.scaleX,g=(l[n+1]+t.offsetY)*t.scaleY,m=(l[i]+t.offsetX)*t.scaleX,y=(l[i+1]+t.offsetY)*t.scaleY;if(A>=y)return;const b=c[a],C=c[a+1],w=c[a+2],x=c[o],E=c[o+1],S=c[o+2],I=c[s],B=c[s+1],R=c[s+2],_=Math.round(A),O=Math.round(y);let F,k,D,M,T,L,N,$;for(let U=_;U<=O;U++){if(U<g){const X=U<A?0:(A-U)/(A-g);F=p-(p-v)*X,k=b-(b-x)*X,D=C-(C-E)*X,M=w-(w-S)*X}else{let X;U>y?X=1:g===y?X=0:X=(g-U)/(g-y),F=v-(v-m)*X,k=x-(x-I)*X,D=E-(E-B)*X,M=S-(S-R)*X}let Y;U<A?Y=0:U>y?Y=1:Y=(A-U)/(A-y),T=p-(p-m)*Y,L=b-(b-I)*Y,N=C-(C-B)*Y,$=w-(w-R)*Y;const V=Math.round(Math.min(F,T)),K=Math.round(Math.max(F,T));let ne=d*U+V*4;for(let X=V;X<=K;X++)Y=(F-X)/(F-T),Y<0?Y=0:Y>1&&(Y=1),u[ne++]=k-(k-L)*Y|0,u[ne++]=D-(D-N)*Y|0,u[ne++]=M-(M-$)*Y|0,u[ne++]=255}}function VIe(e,t,r){const n=t.coords,i=t.colors;let a,o;switch(t.type){case"lattice":const s=t.verticesPerRow,l=Math.floor(n.length/s)-1,c=s-1;for(a=0;a<l;a++){let u=a*s;for(let d=0;d<c;d++,u++)tk(e,r,n[u],n[u+1],n[u+s],i[u],i[u+1],i[u+s]),tk(e,r,n[u+s+1],n[u+1],n[u+s],i[u+s+1],i[u+1],i[u+s])}break;case"triangles":for(a=0,o=n.length;a<o;a+=3)tk(e,r,n[a],n[a+1],n[a+2],i[a],i[a+1],i[a+2]);break;default:throw new Error("illegal figure")}}class GIe extends ek{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,r,n){const s=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-s,u=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(u*t[1]*1.1)),3e3),p=c/d,A=u/f,v={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-l,scaleX:1/p,scaleY:1/A},g=d+2*2,m=f+2*2,y=n.getCanvas("mesh",g,m),b=y.context,C=b.createImageData(d,f);if(r){const x=C.data;for(let E=0,S=x.length;E<S;E+=4)x[E]=r[0],x[E+1]=r[1],x[E+2]=r[2],x[E+3]=255}for(const x of this._figures)VIe(C,x,v);return b.putImageData(C,2,2),{canvas:y.canvas,offsetX:s-2*p,offsetY:l-2*A,scaleX:p,scaleY:A}}getPattern(t,r,n,i){JO(t,this._bbox);let a;if(i===Go.SHADING)a=rr.singularValueDecompose2dScale(bi(t));else if(a=rr.singularValueDecompose2dScale(r.baseTransform),this.matrix){const s=rr.singularValueDecompose2dScale(this.matrix);a=[a[0]*s[0],a[1]*s[1]]}const o=this._createMeshCanvas(a,i===Go.SHADING?null:this._background,r.cachedCanvases);return i!==Go.SHADING&&(t.setTransform(...r.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(o.offsetX,o.offsetY),t.scale(o.scaleX,o.scaleY),t.createPattern(o.canvas,"no-repeat")}}class YIe extends ek{getPattern(){return"hotpink"}}function UIe(e){switch(e[0]){case"RadialAxial":return new WIe(e);case"Mesh":return new GIe(e);case"Dummy":return new YIe}throw new Error(`Unknown IR type: ${e[0]}`)}const Yq={COLORED:1,UNCOLORED:2},u8=class u8{constructor(t,r,n,i,a){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=r,this.ctx=n,this.canvasGraphicsFactory=i,this.baseTransform=a}createPatternCanvas(t){const{bbox:r,operatorList:n,paintType:i,tilingType:a,color:o,canvasGraphicsFactory:s}=this;let{xstep:l,ystep:c}=this;l=Math.abs(l),c=Math.abs(c),p3("TilingType: "+a);const u=r[0],d=r[1],f=r[2],p=r[3],A=f-u,v=p-d,g=rr.singularValueDecompose2dScale(this.matrix),m=rr.singularValueDecompose2dScale(this.baseTransform),y=g[0]*m[0],b=g[1]*m[1];let C=A,w=v,x=!1,E=!1;const S=Math.ceil(l*y),I=Math.ceil(c*b),B=Math.ceil(A*y),R=Math.ceil(v*b);S>=B?C=l:x=!0,I>=R?w=c:E=!0;const _=this.getSizeAndScale(C,this.ctx.canvas.width,y),O=this.getSizeAndScale(w,this.ctx.canvas.height,b),F=t.cachedCanvases.getCanvas("pattern",_.size,O.size),k=F.context,D=s.createCanvasGraphics(k);if(D.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(D,i,o),k.translate(-_.scale*u,-O.scale*d),D.transform(_.scale,0,0,O.scale,0,0),k.save(),this.clipBbox(D,u,d,f,p),D.baseTransform=bi(D.ctx),D.executeOperatorList(n),D.endDrawing(),k.restore(),x||E){const M=F.canvas;x&&(C=l),E&&(w=c);const T=this.getSizeAndScale(C,this.ctx.canvas.width,y),L=this.getSizeAndScale(w,this.ctx.canvas.height,b),N=T.size,$=L.size,U=t.cachedCanvases.getCanvas("pattern-workaround",N,$),Y=U.context,V=x?Math.floor(A/l):0,K=E?Math.floor(v/c):0;for(let ne=0;ne<=V;ne++)for(let X=0;X<=K;X++)Y.drawImage(M,N*ne,$*X,N,$,0,0,N,$);return{canvas:U.canvas,scaleX:T.scale,scaleY:L.scale,offsetX:u,offsetY:d}}return{canvas:F.canvas,scaleX:_.scale,scaleY:O.scale,offsetX:u,offsetY:d}}getSizeAndScale(t,r,n){const i=Math.max(u8.MAX_PATTERN_SIZE,r);let a=Math.ceil(t*n);return a>=i?a=i:n=a/t,{scale:n,size:a}}clipBbox(t,r,n,i,a){const o=i-r,s=a-n;t.ctx.rect(r,n,o,s),t.current.updateRectMinMax(bi(t.ctx),[r,n,i,a]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,r,n){const i=t.ctx,a=t.current;switch(r){case Yq.COLORED:const o=this.ctx;i.fillStyle=o.fillStyle,i.strokeStyle=o.strokeStyle,a.fillColor=o.fillStyle,a.strokeColor=o.strokeStyle;break;case Yq.UNCOLORED:const s=rr.makeHexColor(n[0],n[1],n[2]);i.fillStyle=s,i.strokeStyle=s,a.fillColor=s,a.strokeColor=s;break;default:throw new bIe(`Unsupported paint type: ${r}`)}}getPattern(t,r,n,i){let a=n;i!==Go.SHADING&&(a=rr.transform(a,r.baseTransform),this.matrix&&(a=rr.transform(a,this.matrix)));const o=this.createPatternCanvas(r);let s=new DOMMatrix(a);s=s.translate(o.offsetX,o.offsetY),s=s.scale(1/o.scaleX,1/o.scaleY);const l=t.createPattern(o.canvas,"repeat");return l.setTransform(s),l}};Rr(u8,"MAX_PATTERN_SIZE",3e3);let rk=u8;function KIe({src:e,srcPos:t=0,dest:r,width:n,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){const s=Vo.isLittleEndian?4278190080:255,[l,c]=o?[a,s]:[s,a],u=n>>3,d=n&7,f=e.length;r=new Uint32Array(r.buffer);let p=0;for(let A=0;A<i;A++){for(const g=t+u;t<g;t++){const m=t<f?e[t]:255;r[p++]=m&128?c:l,r[p++]=m&64?c:l,r[p++]=m&32?c:l,r[p++]=m&16?c:l,r[p++]=m&8?c:l,r[p++]=m&4?c:l,r[p++]=m&2?c:l,r[p++]=m&1?c:l}if(d===0)continue;const v=t<f?e[t++]:255;for(let g=0;g<d;g++)r[p++]=v&1<<7-g?c:l}return{srcPos:t,destPos:p}}const Uq=16,Kq=100,qIe=15,qq=10,Xq=1e3,hs=16;function XIe(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(n,i){t.translate(n,i),this.__originalTranslate(n,i)},e.scale=function(n,i){t.scale(n,i),this.__originalScale(n,i)},e.transform=function(n,i,a,o,s,l){t.transform(n,i,a,o,s,l),this.__originalTransform(n,i,a,o,s,l)},e.setTransform=function(n,i,a,o,s,l){t.setTransform(n,i,a,o,s,l),this.__originalSetTransform(n,i,a,o,s,l)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(n){t.rotate(n),this.__originalRotate(n)},e.clip=function(n){t.clip(n),this.__originalClip(n)},e.moveTo=function(r,n){t.moveTo(r,n),this.__originalMoveTo(r,n)},e.lineTo=function(r,n){t.lineTo(r,n),this.__originalLineTo(r,n)},e.bezierCurveTo=function(r,n,i,a,o,s){t.bezierCurveTo(r,n,i,a,o,s),this.__originalBezierCurveTo(r,n,i,a,o,s)},e.rect=function(r,n,i,a){t.rect(r,n,i,a),this.__originalRect(r,n,i,a)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class ZIe{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,r,n){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,r,n)):(i=this.canvasFactory.create(r,n),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const r=this.cache[t];this.canvasFactory.destroy(r),delete this.cache[t]}}}function w3(e,t,r,n,i,a,o,s,l,c){const[u,d,f,p,A,v]=bi(e);if(d===0&&f===0){const y=o*u+A,b=Math.round(y),C=s*p+v,w=Math.round(C),x=(o+l)*u+A,E=Math.abs(Math.round(x)-b)||1,S=(s+c)*p+v,I=Math.abs(Math.round(S)-w)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(p),b,w),e.drawImage(t,r,n,i,a,0,0,E,I),e.setTransform(u,d,f,p,A,v),[E,I]}if(u===0&&p===0){const y=s*f+A,b=Math.round(y),C=o*d+v,w=Math.round(C),x=(s+c)*f+A,E=Math.abs(Math.round(x)-b)||1,S=(o+l)*d+v,I=Math.abs(Math.round(S)-w)||1;return e.setTransform(0,Math.sign(d),Math.sign(f),0,b,w),e.drawImage(t,r,n,i,a,0,0,I,E),e.setTransform(u,d,f,p,A,v),[I,E]}e.drawImage(t,r,n,i,a,o,s,l,c);const g=Math.hypot(u,d),m=Math.hypot(f,p);return[g*l,m*c]}function JIe(e){const{width:t,height:r}=e;if(t>Xq||r>Xq)return null;const n=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1;let o=new Uint8Array(a*(r+1)),s,l,c;const u=t+7&-8;let d=new Uint8Array(u*r),f=0;for(const m of e.data){let y=128;for(;y>0;)d[f++]=m&y?0:255,y>>=1}let p=0;for(f=0,d[f]!==0&&(o[0]=1,++p),l=1;l<t;l++)d[f]!==d[f+1]&&(o[l]=d[f]?2:1,++p),f++;for(d[f]!==0&&(o[l]=2,++p),s=1;s<r;s++){f=s*u,c=s*a,d[f-u]!==d[f]&&(o[c]=d[f]?1:8,++p);let m=(d[f]?4:0)+(d[f-u]?8:0);for(l=1;l<t;l++)m=(m>>2)+(d[f+1]?4:0)+(d[f-u+1]?8:0),i[m]&&(o[c+l]=i[m],++p),f++;if(d[f-u]!==d[f]&&(o[c+l]=d[f]?2:4,++p),p>n)return null}for(f=u*(r-1),c=s*a,d[f]!==0&&(o[c]=8,++p),l=1;l<t;l++)d[f]!==d[f+1]&&(o[c+l]=d[f]?4:8,++p),f++;if(d[f]!==0&&(o[c+l]=4,++p),p>n)return null;const A=new Int32Array([0,a,-1,0,-a,0,0,0,1]),v=new Path2D;for(s=0;p&&s<=r;s++){let m=s*a;const y=m+t;for(;m<y&&!o[m];)m++;if(m===y)continue;v.moveTo(m%a,s);const b=m;let C=o[m];do{const w=A[C];do m+=w;while(!o[m]);const x=o[m];x!==5&&x!==10?(C=x,o[m]=0):(C=x&51*C>>4,o[m]&=C>>2|C<<2),v.lineTo(m%a,m/a|0),o[m]||--p}while(b!==m);--s}return d=null,o=null,function(m){m.save(),m.scale(1/t,-1/r),m.translate(0,-r),m.fill(v),m.beginPath(),m.restore()}}class Zq{constructor(t,r){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Dq,this.textMatrixScale=1,this.fontMatrix=OO,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=wo.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,r])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,r){this.x=t,this.y=r}updatePathMinMax(t,r,n){[r,n]=rr.applyTransform([r,n],t),this.minX=Math.min(this.minX,r),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,r),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(t,r){const n=rr.applyTransform(r,t),i=rr.applyTransform(r.slice(2),t),a=rr.applyTransform([r[0],r[3]],t),o=rr.applyTransform([r[2],r[1]],t);this.minX=Math.min(this.minX,n[0],i[0],a[0],o[0]),this.minY=Math.min(this.minY,n[1],i[1],a[1],o[1]),this.maxX=Math.max(this.maxX,n[0],i[0],a[0],o[0]),this.maxY=Math.max(this.maxY,n[1],i[1],a[1],o[1])}updateScalingPathMinMax(t,r){rr.scaleMinMax(t,r),this.minX=Math.min(this.minX,r[0]),this.minY=Math.min(this.minY,r[1]),this.maxX=Math.max(this.maxX,r[2]),this.maxY=Math.max(this.maxY,r[3])}updateCurvePathMinMax(t,r,n,i,a,o,s,l,c,u){const d=rr.bezierBoundingBox(r,n,i,a,o,s,l,c,u);u||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Go.FILL,r=null){const n=[this.minX,this.minY,this.maxX,this.maxY];if(t===Go.STROKE){r||ei("Stroke bounding box must include transform.");const i=rr.singularValueDecompose2dScale(r),a=i[0]*this.lineWidth/2,o=i[1]*this.lineWidth/2;n[0]-=a,n[1]-=o,n[2]+=a,n[3]+=o}return n}updateClipFromPath(){const t=rr.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Go.FILL,r=null){return rr.intersect(this.clipBox,this.getPathBoundingBox(t,r))}}function Jq(e,t){if(typeof ImageData<"u"&&t instanceof ImageData){e.putImageData(t,0,0);return}const r=t.height,n=t.width,i=r%hs,a=(r-i)/hs,o=i===0?a:a+1,s=e.createImageData(n,hs);let l=0,c;const u=t.data,d=s.data;let f,p,A,v;if(t.kind===d3.GRAYSCALE_1BPP){const g=u.byteLength,m=new Uint32Array(d.buffer,0,d.byteLength>>2),y=m.length,b=n+7>>3,C=4294967295,w=Vo.isLittleEndian?4278190080:255;for(f=0;f<o;f++){for(A=f<a?hs:i,c=0,p=0;p<A;p++){const x=g-l;let E=0;const S=x>b?n:x*8-7,I=S&-8;let B=0,R=0;for(;E<I;E+=8)R=u[l++],m[c++]=R&128?C:w,m[c++]=R&64?C:w,m[c++]=R&32?C:w,m[c++]=R&16?C:w,m[c++]=R&8?C:w,m[c++]=R&4?C:w,m[c++]=R&2?C:w,m[c++]=R&1?C:w;for(;E<S;E++)B===0&&(R=u[l++],B=128),m[c++]=R&B?C:w,B>>=1}for(;c<y;)m[c++]=0;e.putImageData(s,0,f*hs)}}else if(t.kind===d3.RGBA_32BPP){for(p=0,v=n*hs*4,f=0;f<a;f++)d.set(u.subarray(l,l+v)),l+=v,e.putImageData(s,0,p),p+=hs;f<o&&(v=n*i*4,d.set(u.subarray(l,l+v)),e.putImageData(s,0,p))}else if(t.kind===d3.RGB_24BPP)for(A=hs,v=n*A,f=0;f<o;f++){for(f>=a&&(A=i,v=n*A),c=0,p=v;p--;)d[c++]=u[l++],d[c++]=u[l++],d[c++]=u[l++],d[c++]=255;e.putImageData(s,0,f*hs)}else throw new Error(`bad image kind: ${t.kind}`)}function eX(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}const r=t.height,n=t.width,i=r%hs,a=(r-i)/hs,o=i===0?a:a+1,s=e.createImageData(n,hs);let l=0;const c=t.data,u=s.data;for(let d=0;d<o;d++){const f=d<a?hs:i;({srcPos:l}=KIe({src:c,srcPos:l,dest:u,width:n,height:f,nonBlackColor:0})),e.putImageData(s,0,d*hs)}}function tC(e,t){const r=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const n of r)e[n]!==void 0&&(t[n]=e[n]);e.setLineDash!==void 0&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function C3(e){if(e.strokeStyle=e.fillStyle="#000000",e.fillRule="nonzero",e.globalAlpha=1,e.lineWidth=1,e.lineCap="butt",e.lineJoin="miter",e.miterLimit=10,e.globalCompositeOperation="source-over",e.font="10px sans-serif",e.setLineDash!==void 0&&(e.setLineDash([]),e.lineDashOffset=0),!yo){const{filter:t}=e;t!=="none"&&t!==""&&(e.filter="none")}}function tX(e,t){if(t)return!0;const r=rr.singularValueDecompose2dScale(e);r[0]=Math.fround(r[0]),r[1]=Math.fround(r[1]);const n=Math.fround((globalThis.devicePixelRatio||1)*Bh.PDF_TO_CSS_UNITS);return r[0]<=n&&r[1]<=n}const eBe=["butt","round","square"],tBe=["miter","round","bevel"],rBe={},rX={},NW=class NW{constructor(t,r,n,i,a,{optionalContentConfig:o,markedContentStack:s=null},l,c){be(this,tp);this.ctx=t,this.current=new Zq(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=r,this.objs=n,this.canvasFactory=i,this.filterFactory=a,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=s||[],this.optionalContentConfig=o,this.cachedCanvases=new ZIe(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,r=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):r}beginDrawing({transform:t,viewport:r,transparency:n=!1,background:i=null}){const a=this.ctx.canvas.width,o=this.ctx.canvas.height,s=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,a,o),this.ctx.fillStyle=s,n){const l=this.cachedCanvases.getCanvas("transparent",a,o);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...bi(this.compositeCtx))}this.ctx.save(),C3(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...r.transform),this.viewportScale=r.scale,this.baseTransform=bi(this.ctx)}executeOperatorList(t,r,n,i){const a=t.argsArray,o=t.fnArray;let s=r||0;const l=a.length;if(l===s)return s;const c=l-s>qq&&typeof n=="function",u=c?Date.now()+qIe:0;let d=0;const f=this.commonObjs,p=this.objs;let A;for(;;){if(i!==void 0&&s===i.nextBreakPoint)return i.breakIt(s,n),s;if(A=o[s],A!==pc.dependency)this[A].apply(this,a[s]);else for(const v of a[s]){const g=v.startsWith("g_")?f:p;if(!g.has(v))return g.get(v,n),s}if(s++,s===l)return s;if(c&&++d>qq){if(Date.now()>u)return n(),s;d=0}}}endDrawing(){he(this,tp,cV).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const r of t.values())typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement&&(r.width=r.height=0);t.clear()}this._cachedBitmapsMap.clear(),he(this,tp,uV).call(this)}_scaleImage(t,r){const n=t.width??t.displayWidth,i=t.height??t.displayHeight;let a=Math.max(Math.hypot(r[0],r[1]),1),o=Math.max(Math.hypot(r[2],r[3]),1),s=n,l=i,c="prescale1",u,d;for(;a>2&&s>1||o>2&&l>1;){let f=s,p=l;a>2&&s>1&&(f=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s/2),a/=s/f),o>2&&l>1&&(p=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,o/=l/p),u=this.cachedCanvases.getCanvas(c,f,p),d=u.context,d.clearRect(0,0,f,p),d.drawImage(t,0,0,s,l,0,0,f,p),t=u.canvas,s=f,l=p,c=c==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:s,paintHeight:l}}_createMaskCanvas(t){const r=this.ctx,{width:n,height:i}=t,a=this.current.fillColor,o=this.current.patternFill,s=bi(r);let l,c,u,d;if((t.bitmap||t.data)&&t.count>1){const S=t.bitmap||t.data.buffer;c=JSON.stringify(o?s:[s.slice(0,4),a]),l=this._cachedBitmapsMap.get(S),l||(l=new Map,this._cachedBitmapsMap.set(S,l));const I=l.get(c);if(I&&!o){const B=Math.round(Math.min(s[0],s[2])+s[4]),R=Math.round(Math.min(s[1],s[3])+s[5]);return{canvas:I,offsetX:B,offsetY:R}}u=I}u||(d=this.cachedCanvases.getCanvas("maskCanvas",n,i),eX(d.context,t));let f=rr.transform(s,[1/n,0,0,-1/i,0,0]);f=rr.transform(f,[1,0,0,1,0,-i]);const[p,A,v,g]=rr.getAxialAlignedBoundingBox([0,0,n,i],f),m=Math.round(v-p)||1,y=Math.round(g-A)||1,b=this.cachedCanvases.getCanvas("fillCanvas",m,y),C=b.context,w=p,x=A;C.translate(-w,-x),C.transform(...f),u||(u=this._scaleImage(d.canvas,Hd(C)),u=u.img,l&&o&&l.set(c,u)),C.imageSmoothingEnabled=tX(bi(C),t.interpolate),w3(C,u,0,0,u.width,u.height,0,0,n,i),C.globalCompositeOperation="source-in";const E=rr.transform(Hd(C),[1,0,0,1,-w,-x]);return C.fillStyle=o?a.getPattern(r,this,E,Go.FILL):a,C.fillRect(0,0,n,i),l&&!o&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,b.canvas)),{canvas:b.canvas,offsetX:Math.round(w),offsetY:Math.round(x)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=eBe[t]}setLineJoin(t){this.ctx.lineJoin=tBe[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,r){const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(t),n.lineDashOffset=r)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[r,n]of t)switch(r){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,r=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(n,t,r);this.suspendedCtx=this.ctx,this.ctx=i.context;const a=this.ctx;a.setTransform(...bi(this.suspendedCtx)),tC(this.suspendedCtx,a),XIe(a,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),tC(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const r=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,r,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,r,n,i){const a=i[0],o=i[1],s=i[2]-a,l=i[3]-o;s===0||l===0||(this.genericComposeSMask(r.context,n,s,l,r.subtype,r.backdrop,r.transferMap,a,o,r.offsetX,r.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(n.canvas,0,0),t.restore())}genericComposeSMask(t,r,n,i,a,o,s,l,c,u,d){let f=t.canvas,p=l-u,A=c-d;if(o){const g=rr.makeHexColor(...o);if(p<0||A<0||p+n>f.width||A+i>f.height){const m=this.cachedCanvases.getCanvas("maskExtension",n,i),y=m.context;y.drawImage(f,-p,-A),y.globalCompositeOperation="destination-atop",y.fillStyle=g,y.fillRect(0,0,n,i),y.globalCompositeOperation="source-over",f=m.canvas,p=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const m=new Path2D;m.rect(p,A,n,i),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=g,t.fillRect(p,A,n,i),t.restore()}}r.save(),r.globalAlpha=1,r.setTransform(1,0,0,1,0,0),a==="Alpha"&&s?r.filter=this.filterFactory.addAlphaFilter(s):a==="Luminosity"&&(r.filter=this.filterFactory.addLuminosityFilter(s));const v=new Path2D;v.rect(l,c,n,i),r.clip(v),r.globalCompositeOperation="destination-in",r.drawImage(f,p,A,n,i,l,c,n,i),r.restore()}save(){this.inSMaskMode?(tC(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),tC(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,r,n,i,a,o){this.ctx.transform(t,r,n,i,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,r,n){const i=this.ctx,a=this.current;let o=a.x,s=a.y,l,c;const u=bi(i),d=u[0]===0&&u[3]===0||u[1]===0&&u[2]===0,f=d?n.slice(0):null;for(let p=0,A=0,v=t.length;p<v;p++)switch(t[p]|0){case pc.rectangle:o=r[A++],s=r[A++];const g=r[A++],m=r[A++],y=o+g,b=s+m;i.moveTo(o,s),g===0||m===0?i.lineTo(y,b):(i.lineTo(y,s),i.lineTo(y,b),i.lineTo(o,b)),d||a.updateRectMinMax(u,[o,s,y,b]),i.closePath();break;case pc.moveTo:o=r[A++],s=r[A++],i.moveTo(o,s),d||a.updatePathMinMax(u,o,s);break;case pc.lineTo:o=r[A++],s=r[A++],i.lineTo(o,s),d||a.updatePathMinMax(u,o,s);break;case pc.curveTo:l=o,c=s,o=r[A+4],s=r[A+5],i.bezierCurveTo(r[A],r[A+1],r[A+2],r[A+3],o,s),a.updateCurvePathMinMax(u,l,c,r[A],r[A+1],r[A+2],r[A+3],o,s,f),A+=6;break;case pc.curveTo2:l=o,c=s,i.bezierCurveTo(o,s,r[A],r[A+1],r[A+2],r[A+3]),a.updateCurvePathMinMax(u,l,c,o,s,r[A],r[A+1],r[A+2],r[A+3],f),o=r[A+2],s=r[A+3],A+=4;break;case pc.curveTo3:l=o,c=s,o=r[A+2],s=r[A+3],i.bezierCurveTo(r[A],r[A+1],o,s,o,s),a.updateCurvePathMinMax(u,l,c,r[A],r[A+1],o,s,o,s,f),A+=4;break;case pc.closePath:i.closePath();break}d&&a.updateScalingPathMinMax(u,f),a.setCurrentPoint(o,s)}closePath(){this.ctx.closePath()}stroke(t=!0){const r=this.ctx,n=this.current.strokeColor;r.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof n=="object"&&(n!=null&&n.getPattern)?(r.save(),r.strokeStyle=n.getPattern(r,this,Hd(r),Go.STROKE),this.rescaleAndStroke(!1),r.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),r.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const r=this.ctx,n=this.current.fillColor,i=this.current.patternFill;let a=!1;i&&(r.save(),r.fillStyle=n.getPattern(r,this,Hd(r),Go.FILL),a=!0);const o=this.current.getClippedPathBoundingBox();this.contentVisible&&o!==null&&(this.pendingEOFill?(r.fill("evenodd"),this.pendingEOFill=!1):r.fill()),a&&r.restore(),t&&this.consumePath(o)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=rBe}eoClip(){this.pendingClip=rX}beginText(){this.current.textMatrix=Dq,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,r=this.ctx;if(t===void 0){r.beginPath();return}r.save(),r.beginPath();for(const n of t)r.setTransform(...n.transform),r.translate(n.x,n.y),n.addToPath(r,n.fontSize);r.restore(),r.clip(),r.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,r){var u;const n=this.commonObjs.get(t),i=this.current;if(!n)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=n.fontMatrix||OO,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&Gr("Invalid font matrix for font "+t),r<0?(r=-r,i.fontDirection=-1):i.fontDirection=1,this.current.font=n,this.current.fontSize=r,n.isType3Font)return;const a=n.loadedName||"sans-serif",o=((u=n.systemFontInfo)==null?void 0:u.css)||`"${a}", ${n.fallbackName}`;let s="normal";n.black?s="900":n.bold&&(s="bold");const l=n.italic?"italic":"normal";let c=r;r<Uq?c=Uq:r>Kq&&(c=Kq),this.current.fontSizeScale=r/c,this.ctx.font=`${l} ${s} ${c}px ${o}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,r){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=r}setLeadingMoveText(t,r){this.setLeading(-r),this.moveText(t,r)}setTextMatrix(t,r,n,i,a,o){this.current.textMatrix=[t,r,n,i,a,o],this.current.textMatrixScale=Math.hypot(t,r),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,r,n,i){const a=this.ctx,o=this.current,s=o.font,l=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,u=l&wo.FILL_STROKE_MASK,d=!!(l&wo.ADD_TO_PATH_FLAG),f=o.patternFill&&!s.missingFile;let p;(s.disableFontFace||d||f)&&(p=s.getPathGenerator(this.commonObjs,t)),s.disableFontFace||f?(a.save(),a.translate(r,n),a.beginPath(),p(a,c),i&&a.setTransform(...i),(u===wo.FILL||u===wo.FILL_STROKE)&&a.fill(),(u===wo.STROKE||u===wo.FILL_STROKE)&&a.stroke(),a.restore()):((u===wo.FILL||u===wo.FILL_STROKE)&&a.fillText(t,r,n),(u===wo.STROKE||u===wo.FILL_STROKE)&&a.strokeText(t,r,n)),d&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:bi(a),x:r,y:n,fontSize:c,addToPath:p})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const r=t.getImageData(0,0,10,10).data;let n=!1;for(let i=3;i<r.length;i+=4)if(r[i]>0&&r[i]<255){n=!0;break}return dn(this,"isFontSubpixelAAEnabled",n)}showText(t){const r=this.current,n=r.font;if(n.isType3Font)return this.showType3Text(t);const i=r.fontSize;if(i===0)return;const a=this.ctx,o=r.fontSizeScale,s=r.charSpacing,l=r.wordSpacing,c=r.fontDirection,u=r.textHScale*c,d=t.length,f=n.vertical,p=f?1:-1,A=n.defaultVMetrics,v=i*r.fontMatrix[0],g=r.textRenderingMode===wo.FILL&&!n.disableFontFace&&!r.patternFill;a.save(),a.transform(...r.textMatrix),a.translate(r.x,r.y+r.textRise),c>0?a.scale(u,-1):a.scale(u,1);let m;if(r.patternFill){a.save();const x=r.fillColor.getPattern(a,this,Hd(a),Go.FILL);m=bi(a),a.restore(),a.fillStyle=x}let y=r.lineWidth;const b=r.textMatrixScale;if(b===0||y===0){const x=r.textRenderingMode&wo.FILL_STROKE_MASK;(x===wo.STROKE||x===wo.FILL_STROKE)&&(y=this.getSinglePixelWidth())}else y/=b;if(o!==1&&(a.scale(o,o),y/=o),a.lineWidth=y,n.isInvalidPDFjsFont){const x=[];let E=0;for(const S of t)x.push(S.unicode),E+=S.width;a.fillText(x.join(""),0,0),r.x+=E*v*u,a.restore(),this.compose();return}let C=0,w;for(w=0;w<d;++w){const x=t[w];if(typeof x=="number"){C+=p*x*i/1e3;continue}let E=!1;const S=(x.isSpace?l:0)+s,I=x.fontChar,B=x.accent;let R,_,O=x.width;if(f){const k=x.vmetric||A,D=-(x.vmetric?k[1]:O*.5)*v,M=k[2]*v;O=k?-k[0]:O,R=D/o,_=(C+M)/o}else R=C/o,_=0;if(n.remeasure&&O>0){const k=a.measureText(I).width*1e3/i*o;if(O<k&&this.isFontSubpixelAAEnabled){const D=O/k;E=!0,a.save(),a.scale(D,1),R/=D}else O!==k&&(R+=(O-k)/2e3*i/o)}if(this.contentVisible&&(x.isInFont||n.missingFile)){if(g&&!B)a.fillText(I,R,_);else if(this.paintChar(I,R,_,m),B){const k=R+i*B.offset.x/o,D=_-i*B.offset.y/o;this.paintChar(B.fontChar,k,D,m)}}const F=f?O*v-S*c:O*v+S*c;C+=F,E&&a.restore()}f?r.y-=C:r.x+=C*u,a.restore(),this.compose()}showType3Text(t){const r=this.ctx,n=this.current,i=n.font,a=n.fontSize,o=n.fontDirection,s=i.vertical?1:-1,l=n.charSpacing,c=n.wordSpacing,u=n.textHScale*o,d=n.fontMatrix||OO,f=t.length,p=n.textRenderingMode===wo.INVISIBLE;let A,v,g,m;if(!(p||a===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,r.save(),r.transform(...n.textMatrix),r.translate(n.x,n.y),r.scale(u,o),A=0;A<f;++A){if(v=t[A],typeof v=="number"){m=s*v*a/1e3,this.ctx.translate(m,0),n.x+=m*u;continue}const y=(v.isSpace?c:0)+l,b=i.charProcOperatorList[v.operatorListId];if(!b){Gr(`Type3 character "${v.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=v,this.save(),r.scale(a,a),r.transform(...d),this.executeOperatorList(b),this.restore()),g=rr.applyTransform([v.width,0],d)[0]*a+y,r.translate(g,0),n.x+=g*u}r.restore(),this.processingType3=null}}setCharWidth(t,r){}setCharWidthAndBounds(t,r,n,i,a,o){this.ctx.rect(n,i,a-n,o-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let r;if(t[0]==="TilingPattern"){const n=t[1],i=this.baseTransform||bi(this.ctx),a={createCanvasGraphics:o=>new NW(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};r=new rk(t,n,this.ctx,a,i)}else r=this._getPattern(t[1],t[2]);return r}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,r,n){this.ctx.strokeStyle=this.current.strokeColor=rr.makeHexColor(t,r,n)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(t,r,n){this.ctx.fillStyle=this.current.fillColor=rr.makeHexColor(t,r,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,r=null){let n;return this.cachedPatterns.has(t)?n=this.cachedPatterns.get(t):(n=UIe(this.getObject(t)),this.cachedPatterns.set(t,n)),r&&(n.matrix=r),n}shadingFill(t){if(!this.contentVisible)return;const r=this.ctx;this.save();const n=this._getPattern(t);r.fillStyle=n.getPattern(r,this,Hd(r),Go.SHADING);const i=Hd(r);if(i){const{width:a,height:o}=r.canvas,[s,l,c,u]=rr.getAxialAlignedBoundingBox([0,0,a,o],i);this.ctx.fillRect(s,l,c-s,u-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){ei("Should not call beginInlineImage")}beginImageData(){ei("Should not call beginImageData")}paintFormXObjectBegin(t,r){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=bi(this.ctx),r)){const n=r[2]-r[0],i=r[3]-r[1];this.ctx.rect(r[0],r[1],n,i),this.current.updateRectMinMax(bi(this.ctx),r),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const r=this.ctx;t.isolated||p3("TODO: Support non-isolated groups."),t.knockout&&Gr("Knockout groups not supported.");const n=bi(r);if(t.matrix&&r.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=rr.getAxialAlignedBoundingBox(t.bbox,bi(r));const a=[0,0,r.canvas.width,r.canvas.height];i=rr.intersect(i,a)||[0,0,0,0];const o=Math.floor(i[0]),s=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-o,1),c=Math.max(Math.ceil(i[3])-s,1);this.current.startNewPathAndClipBox([0,0,l,c]);let u="groupAt"+this.groupLevel;t.smask&&(u+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(u,l,c),f=d.context;f.translate(-o,-s),f.transform(...n),t.smask?this.smaskStack.push({canvas:d.canvas,context:f,offsetX:o,offsetY:s,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(r.setTransform(1,0,0,1,0,0),r.translate(o,s),r.save()),tC(r,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(r),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const r=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=bi(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const a=rr.getAxialAlignedBoundingBox([0,0,r.canvas.width,r.canvas.height],i);this.ctx.drawImage(r.canvas,0,0),this.ctx.restore(),this.compose(a)}}beginAnnotation(t,r,n,i,a){if(he(this,tp,cV).call(this),C3(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),r){const o=r[2]-r[0],s=r[3]-r[1];if(a&&this.annotationCanvasMap){n=n.slice(),n[4]-=r[0],n[5]-=r[1],r=r.slice(),r[0]=r[1]=0,r[2]=o,r[3]=s;const[l,c]=rr.singularValueDecompose2dScale(bi(this.ctx)),{viewportScale:u}=this,d=Math.ceil(o*this.outputScaleX*u),f=Math.ceil(s*this.outputScaleY*u);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:p,context:A}=this.annotationCanvas;this.annotationCanvasMap.set(t,p),this.annotationCanvas.savedCtx=this.ctx,this.ctx=A,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,s*c),C3(this.ctx)}else C3(this.ctx),this.endPath(),this.ctx.rect(r[0],r[1],o,s),this.ctx.clip(),this.ctx.beginPath()}this.current=new Zq(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),he(this,tp,uV).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const r=t.count;t=this.getObject(t.data,t),t.count=r;const n=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=JIe(t)),i.compiled)){i.compiled(n);return}const a=this._createMaskCanvas(t),o=a.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(o,a.offsetX,a.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,r,n=0,i=0,a,o){if(!this.contentVisible)return;t=this.getObject(t.data,t);const s=this.ctx;s.save();const l=bi(s);s.transform(r,n,i,a,0,0);const c=this._createMaskCanvas(t);s.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let u=0,d=o.length;u<d;u+=2){const f=rr.transform(l,[r,n,i,a,o[u],o[u+1]]),[p,A]=rr.applyTransform([0,0],f);s.drawImage(c.canvas,p,A)}s.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const r=this.ctx,n=this.current.fillColor,i=this.current.patternFill;for(const a of t){const{data:o,width:s,height:l,transform:c}=a,u=this.cachedCanvases.getCanvas("maskCanvas",s,l),d=u.context;d.save();const f=this.getObject(o,a);eX(d,f),d.globalCompositeOperation="source-in",d.fillStyle=i?n.getPattern(d,this,Hd(r),Go.FILL):n,d.fillRect(0,0,s,l),d.restore(),r.save(),r.transform(...c),r.scale(1,-1),w3(r,u.canvas,0,0,s,l,0,-1,1,1),r.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const r=this.getObject(t);if(!r){Gr("Dependent image isn't ready yet");return}this.paintInlineImageXObject(r)}paintImageXObjectRepeat(t,r,n,i){if(!this.contentVisible)return;const a=this.getObject(t);if(!a){Gr("Dependent image isn't ready yet");return}const o=a.width,s=a.height,l=[];for(let c=0,u=i.length;c<u;c+=2)l.push({transform:[r,0,0,n,i[c],i[c+1]],x:0,y:0,w:o,h:s});this.paintInlineImageXObjectGroup(a,l)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:r,width:n,height:i}=t,a=this.cachedCanvases.getCanvas("inlineImage",n,i),o=a.context;return o.filter=this.current.transferMaps,o.drawImage(r,0,0),o.filter="none",a.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const r=t.width,n=t.height,i=this.ctx;if(this.save(),!yo){const{filter:s}=i;s!=="none"&&s!==""&&(i.filter="none")}i.scale(1/r,-1/n);let a;if(t.bitmap)a=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)a=t;else{const l=this.cachedCanvases.getCanvas("inlineImage",r,n).context;Jq(l,t),a=this.applyTransferMapsToCanvas(l)}const o=this._scaleImage(a,Hd(i));i.imageSmoothingEnabled=tX(bi(i),t.interpolate),w3(i,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,r,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,r){if(!this.contentVisible)return;const n=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const a=t.width,o=t.height,l=this.cachedCanvases.getCanvas("inlineImage",a,o).context;Jq(l,t),i=this.applyTransferMapsToCanvas(l)}for(const a of r)n.save(),n.transform(...a.transform),n.scale(1,-1),w3(n,i,a.x,a.y,a.w,a.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,r){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,r){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(r)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const r=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const n=this.ctx;this.pendingClip&&(r||(this.pendingClip===rX?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=bi(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const r=Math.abs(t[0]*t[3]-t[2]*t[1]),n=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(n,i)/r}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:r,b:n,c:i,d:a}=this.ctx.getTransform();let o,s;if(n===0&&i===0){const l=Math.abs(r),c=Math.abs(a);if(l===c)if(t===0)o=s=1/l;else{const u=l*t;o=s=u<1?1/u:1}else if(t===0)o=1/l,s=1/c;else{const u=l*t,d=c*t;o=u<1?1/u:1,s=d<1?1/d:1}}else{const l=Math.abs(r*a-n*i),c=Math.hypot(r,n),u=Math.hypot(i,a);if(t===0)o=u/l,s=c/l;else{const d=t*l;o=u>d?u/d:1,s=c>d?c/d:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=s}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:r}=this,{lineWidth:n}=this.current,[i,a]=this.getScaleForStroking();if(r.lineWidth=n||1,i===1&&a===1){r.stroke();return}const o=r.getLineDash();if(t&&r.save(),r.scale(i,a),o.length>0){const s=Math.max(i,a);r.setLineDash(o.map(l=>l/s)),r.lineDashOffset/=s}r.stroke(),t&&r.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};tp=new WeakSet,cV=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},uV=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const r=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=r}}};let rm=NW;for(const e in pc)rm.prototype[e]!==void 0&&(rm.prototype[pc[e]]=rm.prototype[e]);class zd{static get workerPort(){return P(this,SS)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");ue(this,SS,t)}static get workerSrc(){return P(this,IS)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");ue(this,IS,t)}}SS=new WeakMap,IS=new WeakMap,be(zd,SS,null),be(zd,IS,"");const x3={UNKNOWN:0,DATA:1,ERROR:2},Yi={UNKNOWN:0,CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Ns(e){switch(e instanceof Error||typeof e=="object"&&e!==null||ei('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new zp(e.message);case"MissingPDFException":return new Hp(e.message);case"PasswordException":return new FO(e.message,e.code);case"UnexpectedResponseException":return new A3(e.message,e.status);case"UnknownErrorException":return new LO(e.message,e.details);default:return new LO(e.message,e.toString())}}class rC{constructor(t,r,n){be(this,Zl);be(this,K1,new AbortController);this.sourceName=t,this.targetName=r,this.comObj=n,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),n.addEventListener("message",he(this,Zl,Swe).bind(this),{signal:P(this,K1).signal})}on(t,r){const n=this.actionHandler;if(n[t])throw new Error(`There is already an actionName called "${t}"`);n[t]=r}send(t,r,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:r},n)}sendWithPromise(t,r,n){const i=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[i]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:r},n)}catch(o){a.reject(o)}return a.promise}sendWithStream(t,r,n,i){const a=this.streamId++,o=this.sourceName,s=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const u=Promise.withResolvers();return this.streamControllers[a]={controller:c,startCall:u,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:o,targetName:s,action:t,streamId:a,data:r,desiredSize:c.desiredSize},i),u.promise},pull:c=>{const u=Promise.withResolvers();return this.streamControllers[a].pullCall=u,l.postMessage({sourceName:o,targetName:s,stream:Yi.PULL,streamId:a,desiredSize:c.desiredSize}),u.promise},cancel:c=>{sa(c instanceof Error,"cancel must have a valid reason");const u=Promise.withResolvers();return this.streamControllers[a].cancelCall=u,this.streamControllers[a].isClosed=!0,l.postMessage({sourceName:o,targetName:s,stream:Yi.CANCEL,streamId:a,reason:Ns(c)}),u.promise}},n)}destroy(){var t;(t=P(this,K1))==null||t.abort(),ue(this,K1,null)}}K1=new WeakMap,Zl=new WeakSet,Swe=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){he(this,Zl,Bwe).call(this,t);return}if(t.callback){const n=t.callbackId,i=this.callbackCapabilities[n];if(!i)throw new Error(`Cannot resolve callback ${n}`);if(delete this.callbackCapabilities[n],t.callback===x3.DATA)i.resolve(t.data);else if(t.callback===x3.ERROR)i.reject(Ns(t.reason));else throw new Error("Unexpected callback case");return}const r=this.actionHandler[t.action];if(!r)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const n=this.sourceName,i=t.sourceName,a=this.comObj;new Promise(function(o){o(r(t.data))}).then(function(o){a.postMessage({sourceName:n,targetName:i,callback:x3.DATA,callbackId:t.callbackId,data:o})},function(o){a.postMessage({sourceName:n,targetName:i,callback:x3.ERROR,callbackId:t.callbackId,reason:Ns(o)})});return}if(t.streamId){he(this,Zl,Iwe).call(this,t);return}r(t.data)},Iwe=function(t){const r=t.streamId,n=this.sourceName,i=t.sourceName,a=this.comObj,o=this,s=this.actionHandler[t.action],l={enqueue(c,u=1,d){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=u,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:n,targetName:i,stream:Yi.ENQUEUE,streamId:r,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:i,stream:Yi.CLOSE,streamId:r}),delete o.streamSinks[r])},error(c){sa(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:i,stream:Yi.ERROR,streamId:r,reason:Ns(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[r]=l,new Promise(function(c){c(s(t.data,l))}).then(function(){a.postMessage({sourceName:n,targetName:i,stream:Yi.START_COMPLETE,streamId:r,success:!0})},function(c){a.postMessage({sourceName:n,targetName:i,stream:Yi.START_COMPLETE,streamId:r,reason:Ns(c)})})},Bwe=function(t){const r=t.streamId,n=this.sourceName,i=t.sourceName,a=this.comObj,o=this.streamControllers[r],s=this.streamSinks[r];switch(t.stream){case Yi.START_COMPLETE:t.success?o.startCall.resolve():o.startCall.reject(Ns(t.reason));break;case Yi.PULL_COMPLETE:t.success?o.pullCall.resolve():o.pullCall.reject(Ns(t.reason));break;case Yi.PULL:if(!s){a.postMessage({sourceName:n,targetName:i,stream:Yi.PULL_COMPLETE,streamId:r,success:!0});break}s.desiredSize<=0&&t.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=t.desiredSize,new Promise(function(l){var c;l((c=s.onPull)==null?void 0:c.call(s))}).then(function(){a.postMessage({sourceName:n,targetName:i,stream:Yi.PULL_COMPLETE,streamId:r,success:!0})},function(l){a.postMessage({sourceName:n,targetName:i,stream:Yi.PULL_COMPLETE,streamId:r,reason:Ns(l)})});break;case Yi.ENQUEUE:if(sa(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(t.chunk);break;case Yi.CLOSE:if(sa(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),he(this,Zl,M8).call(this,o,r);break;case Yi.ERROR:sa(o,"error should have stream controller"),o.controller.error(Ns(t.reason)),he(this,Zl,M8).call(this,o,r);break;case Yi.CANCEL_COMPLETE:t.success?o.cancelCall.resolve():o.cancelCall.reject(Ns(t.reason)),he(this,Zl,M8).call(this,o,r);break;case Yi.CANCEL:if(!s)break;new Promise(function(l){var c;l((c=s.onCancel)==null?void 0:c.call(s,Ns(t.reason)))}).then(function(){a.postMessage({sourceName:n,targetName:i,stream:Yi.CANCEL_COMPLETE,streamId:r,success:!0})},function(l){a.postMessage({sourceName:n,targetName:i,stream:Yi.CANCEL_COMPLETE,streamId:r,reason:Ns(l)})}),s.sinkCapability.reject(Ns(t.reason)),s.isCancelled=!0,delete this.streamSinks[r];break;default:throw new Error("Unexpected stream case")}},M8=async function(t,r){var n,i,a;await Promise.allSettled([(n=t.startCall)==null?void 0:n.promise,(i=t.pullCall)==null?void 0:i.promise,(a=t.cancelCall)==null?void 0:a.promise]),delete this.streamControllers[r]};class nBe{constructor({parsedData:t,rawData:r}){be(this,kg);be(this,BS);ue(this,kg,t),ue(this,BS,r)}getRaw(){return P(this,BS)}get(t){return P(this,kg).get(t)??null}getAll(){return NO(P(this,kg))}has(t){return P(this,kg).has(t)}}kg=new WeakMap,BS=new WeakMap;const nm=Symbol("INTERNAL");class iBe{constructor(t,{name:r,intent:n,usage:i,rbGroups:a}){be(this,MS,!1);be(this,RS,!1);be(this,PS,!1);be(this,q1,!0);ue(this,MS,!!(t&Ls.DISPLAY)),ue(this,RS,!!(t&Ls.PRINT)),this.name=r,this.intent=n,this.usage=i,this.rbGroups=a}get visible(){if(P(this,PS))return P(this,q1);if(!P(this,q1))return!1;const{print:t,view:r}=this.usage;return P(this,MS)?(r==null?void 0:r.viewState)!=="OFF":P(this,RS)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,r,n=!1){t!==nm&&ei("Internal method `_setVisible` called."),ue(this,PS,n),ue(this,q1,r)}}MS=new WeakMap,RS=new WeakMap,PS=new WeakMap,q1=new WeakMap;class aBe{constructor(t,r=Ls.DISPLAY){be(this,DS);be(this,rp,null);be(this,$n,new Map);be(this,X1,null);be(this,Z1,null);if(this.renderingIntent=r,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,ue(this,Z1,t.order);for(const n of t.groups)P(this,$n).set(n.id,new iBe(r,n));if(t.baseState==="OFF")for(const n of P(this,$n).values())n._setVisible(nm,!1);for(const n of t.on)P(this,$n).get(n)._setVisible(nm,!0);for(const n of t.off)P(this,$n).get(n)._setVisible(nm,!1);ue(this,X1,this.getHash())}}isVisible(t){if(P(this,$n).size===0)return!0;if(!t)return p3("Optional content group not defined."),!0;if(t.type==="OCG")return P(this,$n).has(t.id)?P(this,$n).get(t.id).visible:(Gr(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return he(this,DS,dV).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const r of t.ids){if(!P(this,$n).has(r))return Gr(`Optional content group not found: ${r}`),!0;if(P(this,$n).get(r).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const r of t.ids){if(!P(this,$n).has(r))return Gr(`Optional content group not found: ${r}`),!0;if(!P(this,$n).get(r).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const r of t.ids){if(!P(this,$n).has(r))return Gr(`Optional content group not found: ${r}`),!0;if(!P(this,$n).get(r).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const r of t.ids){if(!P(this,$n).has(r))return Gr(`Optional content group not found: ${r}`),!0;if(P(this,$n).get(r).visible)return!1}return!0}return Gr(`Unknown optional content policy ${t.policy}.`),!0}return Gr(`Unknown group type ${t.type}.`),!0}setVisibility(t,r=!0,n=!0){var a;const i=P(this,$n).get(t);if(!i){Gr(`Optional content group not found: ${t}`);return}if(n&&r&&i.rbGroups.length)for(const o of i.rbGroups)for(const s of o)s!==t&&((a=P(this,$n).get(s))==null||a._setVisible(nm,!1,!0));i._setVisible(nm,!!r,!0),ue(this,rp,null)}setOCGState({state:t,preserveRB:r}){let n;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":n=i;continue}const a=P(this,$n).get(i);if(a)switch(n){case"ON":this.setVisibility(i,!0,r);break;case"OFF":this.setVisibility(i,!1,r);break;case"Toggle":this.setVisibility(i,!a.visible,r);break}}ue(this,rp,null)}get hasInitialVisibility(){return P(this,X1)===null||this.getHash()===P(this,X1)}getOrder(){return P(this,$n).size?P(this,Z1)?P(this,Z1).slice():[...P(this,$n).keys()]:null}getGroups(){return P(this,$n).size>0?NO(P(this,$n)):null}getGroup(t){return P(this,$n).get(t)||null}getHash(){if(P(this,rp)!==null)return P(this,rp);const t=new Nq;for(const[r,n]of P(this,$n))t.update(`${r}:${n.visible}`);return ue(this,rp,t.hexdigest())}}rp=new WeakMap,$n=new WeakMap,X1=new WeakMap,Z1=new WeakMap,DS=new WeakSet,dV=function(t){const r=t.length;if(r<2)return!0;const n=t[0];for(let i=1;i<r;i++){const a=t[i];let o;if(Array.isArray(a))o=he(this,DS,dV).call(this,a);else if(P(this,$n).has(a))o=P(this,$n).get(a).visible;else return Gr(`Optional content group not found: ${a}`),!0;switch(n){case"And":if(!o)return!1;break;case"Or":if(o)return!0;break;case"Not":return!o;default:return!0}}return n==="And"};class oBe{constructor(t,{disableRange:r=!1,disableStream:n=!1}){sa(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:a,progressiveDone:o,contentDispositionFilename:s}=t;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=s,(a==null?void 0:a.length)>0){const l=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!r,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,c)=>{this._onReceiveData({begin:l,chunk:c})}),t.addProgressListener((l,c)=>{this._onProgress({loaded:l,total:c})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:r}){const n=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{const i=this._rangeReaders.some(function(a){return a._begin!==t?!1:(a._enqueue(n),!0)});sa(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var r,n,i,a;t.total===void 0?(n=(r=this._rangeReaders[0])==null?void 0:r.onProgress)==null||n.call(r,{loaded:t.loaded}):(a=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||a.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const r=this._rangeReaders.indexOf(t);r>=0&&this._rangeReaders.splice(r,1)}getFullReader(){sa(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new sBe(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,r){if(r<=this._progressiveDataLength)return null;const n=new lBe(this,t,r);return this._pdfDataRangeTransport.requestDataRange(t,r),this._rangeReaders.push(n),n}cancelAllRequests(t){var r;(r=this._fullRequestReader)==null||r.cancel(t);for(const n of this._rangeReaders.slice(0))n.cancel(t);this._pdfDataRangeTransport.abort()}}class sBe{constructor(t,r,n=!1,i=null){this._stream=t,this._done=n||!1,this._filename=zO(i)?i:null,this._queuedChunks=r||[],this._loaded=0;for(const a of this._queuedChunks)this._loaded+=a.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class lBe{constructor(t,r,n){this._stream=t,this._begin=r,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function cBe(e){let t=!0,r=n("filename\\*","i").exec(e);if(r){r=r[1];let u=s(r);return u=unescape(u),u=l(u),u=c(u),a(u)}if(r=o(e),r){const u=c(r);return a(u)}if(r=n("filename","i").exec(e),r){r=r[1];let u=s(r);return u=c(u),a(u)}function n(u,d){return new RegExp("(?:^|;)\\s*"+u+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(u,d){if(u){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const f=new TextDecoder(u,{fatal:!0}),p=g3(d);d=f.decode(p),t=!1}catch{}}return d}function a(u){return t&&/[\x80-\xff]/.test(u)&&(u=i("utf-8",u),t&&(u=i("iso-8859-1",u))),u}function o(u){const d=[];let f;const p=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=p.exec(u))!==null;){let[,v,g,m]=f;if(v=parseInt(v,10),v in d){if(v===0)break;continue}d[v]=[g,m]}const A=[];for(let v=0;v<d.length&&v in d;++v){let[g,m]=d[v];m=s(m),g&&(m=unescape(m),v===0&&(m=l(m))),A.push(m)}return A.join("")}function s(u){if(u.startsWith('"')){const d=u.slice(1).split('\\"');for(let f=0;f<d.length;++f){const p=d[f].indexOf('"');p!==-1&&(d[f]=d[f].slice(0,p),d.length=f+1),d[f]=d[f].replaceAll(/\\(.)/g,"$1")}u=d.join('"')}return u}function l(u){const d=u.indexOf("'");if(d===-1)return u;const f=u.slice(0,d),A=u.slice(d+1).replace(/^[^']*'/,"");return i(f,A)}function c(u){return!u.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(u)?u:u.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,f,p,A){if(p==="q"||p==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(v,g){return String.fromCharCode(parseInt(g,16))}),i(f,A);try{A=atob(A)}catch{}return i(f,A)})}return""}function nk(e,t){const r=new Headers;if(!e||!t||typeof t!="object")return r;for(const n in t){const i=t[n];i!==void 0&&r.append(n,i)}return r}function ik({responseHeaders:e,isHttp:t,rangeChunkSize:r,disableRange:n}){const i={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e.get("Content-Length"),10);return!Number.isInteger(a)||(i.suggestedLength=a,a<=2*r)||n||!t||e.get("Accept-Ranges")!=="bytes"||(e.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function ak(e){const t=e.get("Content-Disposition");if(t){let r=cBe(t);if(r.includes("%"))try{r=decodeURIComponent(r)}catch{}if(zO(r))return r}return null}function E3(e,t){return e===404||e===0&&t.startsWith("file:")?new Hp('Missing PDF "'+t+'".'):new A3(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function nX(e){return e===200||e===206}function iX(e,t,r){return{method:"GET",headers:e,signal:r.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function aX(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(Gr(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}class oX{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=nk(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return sa(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new uBe(this),this._fullRequestReader}getRangeReader(t,r){if(r<=this._progressiveDataLength)return null;const n=new dBe(this,t,r);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var r;(r=this._fullRequestReader)==null||r.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class uBe{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const r=t.source;this._withCredentials=r.withCredentials||!1,this._contentLength=r.length,this._headersCapability=Promise.withResolvers(),this._disableRange=r.disableRange||!1,this._rangeChunkSize=r.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!r.disableStream,this._isRangeSupported=!r.disableRange;const n=new Headers(t.headers),i=r.url;fetch(i,iX(n,this._withCredentials,this._abortController)).then(a=>{if(!nX(a.status))throw E3(a.status,i);this._reader=a.body.getReader(),this._headersCapability.resolve();const o=a.headers,{allowRangeRequests:s,suggestedLength:l}=ik({responseHeaders:o,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=s,this._contentLength=l||this._contentLength,this._filename=ak(o),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new zp("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;await this._headersCapability.promise;const{value:t,done:r}=await this._reader.read();return r?{value:t,done:r}:(this._loaded+=t.byteLength,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded,total:this._contentLength}),{value:aX(t),done:!1})}cancel(t){var r;(r=this._reader)==null||r.cancel(t),this._abortController.abort()}}class dBe{constructor(t,r,n){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const a=new Headers(t.headers);a.append("Range",`bytes=${r}-${n-1}`);const o=i.url;fetch(o,iX(a,this._withCredentials,this._abortController)).then(s=>{if(!nX(s.status))throw E3(s.status,o);this._readCapability.resolve(),this._reader=s.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;await this._readCapability.promise;const{value:t,done:r}=await this._reader.read();return r?{value:t,done:r}:(this._loaded+=t.byteLength,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded}),{value:aX(t),done:!1})}cancel(t){var r;(r=this._reader)==null||r.cancel(t),this._abortController.abort()}}const ok=200,sk=206;function fBe(e){const t=e.response;return typeof t!="string"?t:g3(t).buffer}class hBe{constructor({url:t,httpHeaders:r,withCredentials:n}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=nk(this.isHttp,r),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,r,n){const i={begin:t,end:r};for(const a in n)i[a]=n[a];return this.request(i)}requestFull(t){return this.request(t)}request(t){const r=new XMLHttpRequest,n=this.currXhrId++,i=this.pendingRequests[n]={xhr:r};r.open("GET",this.url),r.withCredentials=this.withCredentials;for(const[a,o]of this.headers)r.setRequestHeader(a,o);return this.isHttp&&"begin"in t&&"end"in t?(r.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=sk):i.expectedStatus=ok,r.responseType="arraybuffer",t.onError&&(r.onerror=function(a){t.onError(r.status)}),r.onreadystatechange=this.onStateChange.bind(this,n),r.onprogress=this.onProgress.bind(this,n),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,r.send(null),n}onProgress(t,r){var i;const n=this.pendingRequests[t];n&&((i=n.onProgress)==null||i.call(n,r))}onStateChange(t,r){var l,c,u;const n=this.pendingRequests[t];if(!n)return;const i=n.xhr;if(i.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){(l=n.onError)==null||l.call(n,i.status);return}const a=i.status||ok;if(!(a===ok&&n.expectedStatus===sk)&&a!==n.expectedStatus){(c=n.onError)==null||c.call(n,i.status);return}const s=fBe(i);if(a===sk){const d=i.getResponseHeader("Content-Range"),f=/bytes (\d+)-(\d+)\/(\d+)/.exec(d);n.onDone({begin:parseInt(f[1],10),chunk:s})}else s?n.onDone({begin:0,chunk:s}):(u=n.onError)==null||u.call(n,i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const r=this.pendingRequests[t].xhr;delete this.pendingRequests[t],r.abort()}}class pBe{constructor(t){this._source=t,this._manager=new hBe(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const r=this._rangeRequestReaders.indexOf(t);r>=0&&this._rangeRequestReaders.splice(r,1)}getFullReader(){return sa(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new ABe(this._manager,this._source),this._fullRequestReader}getRangeReader(t,r){const n=new gBe(this._manager,t,r);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var r;(r=this._fullRequestReader)==null||r.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class ABe{constructor(t,r){this._manager=t;const n={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=r.url,this._fullRequestId=t.requestFull(n),this._headersCapability=Promise.withResolvers(),this._disableRange=r.disableRange||!1,this._contentLength=r.length,this._rangeChunkSize=r.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,r=this._manager.getRequestXhr(t),n=new Headers(r.getAllResponseHeaders().trim().split(/[\r\n]+/).map(o=>{const[s,...l]=o.split(": ");return[s,l.join(": ")]})),{allowRangeRequests:i,suggestedLength:a}=ik({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=ak(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=E3(t,this._url),this._headersCapability.reject(this._storedError);for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var r;(r=this.onProgress)==null||r.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class gBe{constructor(t,r,n){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(r,n,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const r=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:r,done:!1}):this._queuedChunk=r,this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=E3(t,this._url);for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var r;this.isStreamingSupported||(r=this.onProgress)==null||r.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const vBe=/^[a-z][a-z0-9\-+.]+:/i;function mBe(e){if(vBe.test(e))return new URL(e);const t=Mh.get("url");return new URL(t.pathToFileURL(e))}function sX(e,t,r){return e.protocol==="http:"?Mh.get("http").request(e,{headers:t},r):Mh.get("https").request(e,{headers:t},r)}class bBe{constructor(t){this.source=t,this.url=mBe(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.headers=nk(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return sa(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new CBe(this):new yBe(this),this._fullRequestReader}getRangeReader(t,r){if(r<=this._progressiveDataLength)return null;const n=this.isFsUrl?new xBe(this,t,r):new wBe(this,t,r);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){var r;(r=this._fullRequestReader)==null||r.cancel(t);for(const n of this._rangeRequestReaders.slice(0))n.cancel(t)}}class lX{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const r=t.source;this._contentLength=r.length,this._loaded=0,this._filename=null,this._disableRange=r.disableRange||!1,this._rangeChunkSize=r.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!r.disableStream,this._isRangeSupported=!r.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",r=>{this._error(r)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new zp("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class cX{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const r=t.source;this._isStreamingSupported=!r.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",r=>{this._error(r)}),this._storedError&&this._readableStream.destroy(this._storedError)}}class yBe extends lX{constructor(t){super(t);const r=Object.fromEntries(t.headers),n=i=>{if(i.statusCode===404){const l=new Hp(`Missing PDF "${this._url}".`);this._storedError=l,this._headersCapability.reject(l);return}this._headersCapability.resolve(),this._setReadableStream(i);const a=new Headers(this._readableStream.headers),{allowRangeRequests:o,suggestedLength:s}=ik({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=s||this._contentLength,this._filename=ak(a)};this._request=sX(this._url,r,n),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class wBe extends cX{constructor(t,r,n){super(t);const i=Object.fromEntries(t.headers);i.Range=`bytes=${r}-${n-1}`;const a=o=>{if(o.statusCode===404){const s=new Hp(`Missing PDF "${this._url}".`);this._storedError=s;return}this._setReadableStream(o)};this._request=sX(this._url,i,a),this._request.on("error",o=>{this._storedError=o}),this._request.end()}}class CBe extends lX{constructor(t){super(t);const r=Mh.get("fs");r.promises.lstat(this._url).then(n=>{this._contentLength=n.size,this._setReadableStream(r.createReadStream(this._url)),this._headersCapability.resolve()},n=>{n.code==="ENOENT"&&(n=new Hp(`Missing PDF "${this._url}".`)),this._storedError=n,this._headersCapability.reject(n)})}}class xBe extends cX{constructor(t,r,n){super(t);const i=Mh.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:r,end:n-1}))}}const EBe=1e5,ps=30,SBe=.8,wa=class wa{constructor({textContentSource:t,container:r,viewport:n}){be(this,_f);be(this,np,Promise.withResolvers());be(this,Ms,null);be(this,TS,!1);be(this,_S,!!((qye=globalThis.FontInspector)!=null&&qye.enabled));be(this,Fg,null);be(this,Tf,null);be(this,OS,0);be(this,kS,0);be(this,Lg,null);be(this,J1,null);be(this,ey,0);be(this,ip,0);be(this,ty,Object.create(null));be(this,FS,[]);be(this,ry,null);be(this,Ng,[]);be(this,LS,new WeakMap);be(this,NS,null);var l;if(t instanceof ReadableStream)ue(this,ry,t);else if(typeof t=="object")ue(this,ry,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');ue(this,Ms,ue(this,J1,r)),ue(this,ip,n.scale*(globalThis.devicePixelRatio||1)),ue(this,ey,n.rotation),ue(this,Tf,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:a,pageX:o,pageY:s}=n.rawDims;ue(this,NS,[1,0,0,-1,-o,s+a]),ue(this,kS,i),ue(this,OS,a),he(l=wa,ll,Pwe).call(l),Wp(r,n),P(this,np).promise.finally(()=>{P(wa,ny).delete(this),ue(this,Tf,null),ue(this,ty,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:r}=Vo.platform;return dn(this,"fontFamilyMap",new Map([["sans-serif",`${t&&r?"Calibri, ":""}sans-serif`],["monospace",`${t&&r?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{P(this,Lg).read().then(({value:r,done:n})=>{if(n){P(this,np).resolve();return}P(this,Fg)??ue(this,Fg,r.lang),Object.assign(P(this,ty),r.styles),he(this,_f,Mwe).call(this,r.items),t()},P(this,np).reject)};return ue(this,Lg,P(this,ry).getReader()),P(wa,ny).add(this),t(),P(this,np).promise}update({viewport:t,onBefore:r=null}){var a;const n=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==P(this,ey)&&(r==null||r(),ue(this,ey,i),Wp(P(this,J1),{rotation:i})),n!==P(this,ip)){r==null||r(),ue(this,ip,n);const o={div:null,properties:null,ctx:he(a=wa,ll,R8).call(a,P(this,Fg))};for(const s of P(this,Ng))o.properties=P(this,LS).get(s),o.div=s,he(this,_f,fV).call(this,o)}}cancel(){var r;const t=new zp("TextLayer task cancelled.");(r=P(this,Lg))==null||r.cancel(t).catch(()=>{}),ue(this,Lg,null),P(this,np).reject(t)}get textDivs(){return P(this,Ng)}get textContentItemsStr(){return P(this,FS)}static cleanup(){if(!(P(this,ny).size>0)){P(this,$g).clear();for(const{canvas:t}of P(this,jg).values())t.remove();P(this,jg).clear()}}};np=new WeakMap,Ms=new WeakMap,TS=new WeakMap,_S=new WeakMap,Fg=new WeakMap,Tf=new WeakMap,OS=new WeakMap,kS=new WeakMap,Lg=new WeakMap,J1=new WeakMap,ey=new WeakMap,ip=new WeakMap,ty=new WeakMap,FS=new WeakMap,ry=new WeakMap,Ng=new WeakMap,LS=new WeakMap,NS=new WeakMap,$g=new WeakMap,jg=new WeakMap,$S=new WeakMap,ap=new WeakMap,ny=new WeakMap,_f=new WeakSet,Mwe=function(t){var i,a;if(P(this,TS))return;(a=P(this,Tf)).ctx??(a.ctx=he(i=wa,ll,R8).call(i,P(this,Fg)));const r=P(this,Ng),n=P(this,FS);for(const o of t){if(r.length>EBe){Gr("Ignoring additional textDivs for performance reasons."),ue(this,TS,!0);return}if(o.str===void 0){if(o.type==="beginMarkedContentProps"||o.type==="beginMarkedContent"){const s=P(this,Ms);ue(this,Ms,document.createElement("span")),P(this,Ms).classList.add("markedContent"),o.id!==null&&P(this,Ms).setAttribute("id",`${o.id}`),s.append(P(this,Ms))}else o.type==="endMarkedContent"&&ue(this,Ms,P(this,Ms).parentNode);continue}n.push(o.str),he(this,_f,Rwe).call(this,o)}},Rwe=function(t){var v;const r=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};P(this,Ng).push(r);const i=rr.transform(P(this,NS),t.transform);let a=Math.atan2(i[1],i[0]);const o=P(this,ty)[t.fontName];o.vertical&&(a+=Math.PI/2);let s=P(this,_S)&&o.fontSubstitution||o.fontFamily;s=wa.fontFamilyMap.get(s)||s;const l=Math.hypot(i[2],i[3]),c=l*he(v=wa,ll,Dwe).call(v,s,P(this,Fg));let u,d;a===0?(u=i[4],d=i[5]-c):(u=i[4]+c*Math.sin(a),d=i[5]-c*Math.cos(a));const f="calc(var(--scale-factor)*",p=r.style;P(this,Ms)===P(this,J1)?(p.left=`${(100*u/P(this,kS)).toFixed(2)}%`,p.top=`${(100*d/P(this,OS)).toFixed(2)}%`):(p.left=`${f}${u.toFixed(2)}px)`,p.top=`${f}${d.toFixed(2)}px)`),p.fontSize=`${f}${(P(wa,ap)*l).toFixed(2)}px)`,p.fontFamily=s,n.fontSize=l,r.setAttribute("role","presentation"),r.textContent=t.str,r.dir=t.dir,P(this,_S)&&(r.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),a!==0&&(n.angle=a*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const g=Math.abs(t.transform[0]),m=Math.abs(t.transform[3]);g!==m&&Math.max(g,m)/Math.min(g,m)>1.5&&(A=!0)}if(A&&(n.canvasWidth=o.vertical?t.height:t.width),P(this,LS).set(r,n),P(this,Tf).div=r,P(this,Tf).properties=n,he(this,_f,fV).call(this,P(this,Tf)),n.hasText&&P(this,Ms).append(r),n.hasEOL){const g=document.createElement("br");g.setAttribute("role","presentation"),P(this,Ms).append(g)}},fV=function(t){var s;const{div:r,properties:n,ctx:i}=t,{style:a}=r;let o="";if(P(wa,ap)>1&&(o=`scale(${1/P(wa,ap)})`),n.canvasWidth!==0&&n.hasText){const{fontFamily:l}=a,{canvasWidth:c,fontSize:u}=n;he(s=wa,ll,hV).call(s,i,u*P(this,ip),l);const{width:d}=i.measureText(r.textContent);d>0&&(o=`scaleX(${c*P(this,ip)/d}) ${o}`)}n.angle!==0&&(o=`rotate(${n.angle}deg) ${o}`),o.length>0&&(a.transform=o)},ll=new WeakSet,R8=function(t=null){let r=P(this,jg).get(t||(t=""));if(!r){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=t,document.body.append(n),r=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),P(this,jg).set(t,r),P(this,$S).set(r,{size:0,family:""})}return r},hV=function(t,r,n){const i=P(this,$S).get(t);r===i.size&&n===i.family||(t.font=`${r}px ${n}`,i.size=r,i.family=n)},Pwe=function(){if(P(this,ap)!==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),ue(this,ap,t.getBoundingClientRect().height),t.remove()},Dwe=function(t,r){const n=P(this,$g).get(t);if(n)return n;const i=he(this,ll,R8).call(this,r);i.canvas.width=i.canvas.height=ps,he(this,ll,hV).call(this,i,ps,t);const a=i.measureText("");let o=a.fontBoundingBoxAscent,s=Math.abs(a.fontBoundingBoxDescent);if(o){const u=o/(o+s);return P(this,$g).set(t,u),i.canvas.width=i.canvas.height=0,u}i.strokeStyle="red",i.clearRect(0,0,ps,ps),i.strokeText("g",0,0);let l=i.getImageData(0,0,ps,ps).data;s=0;for(let u=l.length-1-3;u>=0;u-=4)if(l[u]>0){s=Math.ceil(u/4/ps);break}i.clearRect(0,0,ps,ps),i.strokeText("A",0,ps),l=i.getImageData(0,0,ps,ps).data,o=0;for(let u=0,d=l.length;u<d;u+=4)if(l[u]>0){o=ps-Math.floor(u/4/ps);break}i.canvas.width=i.canvas.height=0;const c=o?o/(o+s):SBe;return P(this,$g).set(t,c),c},be(wa,ll),be(wa,$g,new Map),be(wa,jg,new Map),be(wa,$S,new WeakMap),be(wa,ap,null),be(wa,ny,new Set);let nC=wa;class iC{static textContent(t){const r=[],n={items:r,styles:Object.create(null)};function i(a){var l;if(!a)return;let o=null;const s=a.name;if(s==="#text")o=a.value;else if(iC.shouldBuildText(s))(l=a==null?void 0:a.attributes)!=null&&l.textContent?o=a.attributes.textContent:a.value&&(o=a.value);else return;if(o!==null&&r.push({str:o}),!!a.children)for(const c of a.children)i(c)}return i(t),n}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const IBe=65536,BBe=100,MBe=5e3,RBe=yo?QIe:NIe,PBe=yo?HIe:Hq,DBe=yo?jIe:$Ie,TBe=yo?zIe:Vq;function _Be(e={}){typeof e=="string"||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t=new lk,{docId:r}=t,n=e.url?OBe(e.url):null,i=e.data?kBe(e.data):null,a=e.httpHeaders||null,o=e.withCredentials===!0,s=e.password??null,l=e.range instanceof dX?e.range:null,c=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:IBe;let u=e.worker instanceof im?e.worker:null;const d=e.verbosity,f=typeof e.docBaseUrl=="string"&&!m3(e.docBaseUrl)?e.docBaseUrl:null,p=typeof e.cMapUrl=="string"?e.cMapUrl:null,A=e.cMapPacked!==!1,v=e.CMapReaderFactory||PBe,g=typeof e.standardFontDataUrl=="string"?e.standardFontDataUrl:null,m=e.StandardFontDataFactory||TBe,y=e.stopAtErrors!==!0,b=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,C=e.isEvalSupported!==!1,w=typeof e.isOffscreenCanvasSupported=="boolean"?e.isOffscreenCanvasSupported:!yo,x=typeof e.isChrome=="boolean"?e.isChrome:!Vo.platform.isFirefox&&typeof window<"u"&&!!(window!=null&&window.chrome),E=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,S=typeof e.disableFontFace=="boolean"?e.disableFontFace:yo,I=e.fontExtraProperties===!0,B=e.enableXfa===!0,R=e.ownerDocument||globalThis.document,_=e.disableRange===!0,O=e.disableStream===!0,F=e.disableAutoFetch===!0,k=e.pdfBug===!0,D=e.CanvasFactory||RBe,M=e.FilterFactory||DBe,T=e.enableHWA===!0,L=l?l.length:e.length??NaN,N=typeof e.useSystemFonts=="boolean"?e.useSystemFonts:!yo&&!S,$=typeof e.useWorkerFetch=="boolean"?e.useWorkerFetch:v===Hq&&m===Vq&&p&&g&&Zw(p,document.baseURI)&&Zw(g,document.baseURI);e.canvasFactory&&Fq("`canvasFactory`-instance option, please use `CanvasFactory` instead."),e.filterFactory&&Fq("`filterFactory`-instance option, please use `FilterFactory` instead.");const U=null;AIe(d);const Y={canvasFactory:new D({ownerDocument:R,enableHWA:T}),filterFactory:new M({docId:r,ownerDocument:R}),cMapReaderFactory:$?null:new v({baseUrl:p,isCompressed:A}),standardFontDataFactory:$?null:new m({baseUrl:g})};if(!u){const ne={verbosity:d,port:zd.workerPort};u=ne.port?im.fromPort(ne):new im(ne),t._worker=u}const V={docId:r,apiVersion:"4.8.69",data:i,password:s,disableAutoFetch:F,rangeChunkSize:c,length:L,docBaseUrl:f,enableXfa:B,evaluatorOptions:{maxImageSize:b,disableFontFace:S,ignoreErrors:y,isEvalSupported:C,isOffscreenCanvasSupported:w,isChrome:x,canvasMaxAreaInBytes:E,fontExtraProperties:I,useSystemFonts:N,cMapUrl:$?p:null,standardFontDataUrl:$?g:null}},K={disableFontFace:S,fontExtraProperties:I,ownerDocument:R,pdfBug:k,styleElement:U,loadingParams:{disableAutoFetch:F,enableXfa:B}};return u.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const ne=u.messageHandler.sendWithPromise("GetDocRequest",V,i?[i.buffer]:null);let X;if(l)X=new oBe(l,{disableRange:_,disableStream:O});else if(!i){if(!n)throw new Error("getDocument - no `url` parameter provided.");let Q;yo?Q=typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&Zw(n)?oX:bBe:Q=Zw(n)?oX:pBe,X=new Q({url:n,length:L,httpHeaders:a,withCredentials:o,rangeChunkSize:c,disableRange:_,disableStream:O})}return ne.then(Q=>{if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const z=new rC(r,Q,u.port),j=new $Be(z,t,X,K,Y);t._transport=j,z.send("Ready",null)})}).catch(t._capability.reject),t}function OBe(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(yo&&typeof e=="string")return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function kBe(e){if(yo&&typeof Buffer<"u"&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e=="string")return g3(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e=="object"&&!isNaN(e==null?void 0:e.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function uX(e){return typeof e=="object"&&Number.isInteger(e==null?void 0:e.num)&&e.num>=0&&Number.isInteger(e==null?void 0:e.gen)&&e.gen>=0}const f8=class f8{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${os(f8,d8)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,r,n;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((r=this._transport)==null?void 0:r.destroy())}catch(i){throw(n=this._worker)!=null&&n.port&&delete this._worker._pendingDestroy,i}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};d8=new WeakMap,be(f8,d8,0);let lk=f8;class dX{constructor(t,r,n=!1,i=null){this.length=t,this.initialData=r,this.progressiveDone=n,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,r){for(const n of this._rangeListeners)n(t,r)}onDataProgress(t,r){this._readyCapability.promise.then(()=>{for(const n of this._progressListeners)n(t,r)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const r of this._progressiveReadListeners)r(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,r){ei("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class FBe{constructor(t,r){this._pdfInfo=t,this._transport=r}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 dn(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:r}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(r)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class LBe{constructor(t,r,n,i=!1){be(this,Jl);be(this,op,null);be(this,Of,!1);this._pageIndex=t,this._pageInfo=r,this._transport=n,this._stats=i?new kq:null,this._pdfBug=i,this.commonObjs=n.commonObjs,this.objs=new fX,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:r=this.rotate,offsetX:n=0,offsetY:i=0,dontFlip:a=!1}={}){return new Xw({viewBox:this.view,scale:t,rotation:r,offsetX:n,offsetY:i,dontFlip:a})}getAnnotations({intent:t="display"}={}){const{renderingIntent:r}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,r)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return dn(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:r,intent:n="display",annotationMode:i=Sh.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:s=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:u=null,isEditing:d=!1}){var C,w;(C=this._stats)==null||C.time("Overall");const f=this._transport.getRenderingIntent(n,i,u,d),{renderingIntent:p,cacheKey:A}=f;ue(this,Of,!1),he(this,Jl,P8).call(this),s||(s=this._transport.getOptionalContentConfig(p));let v=this._intentStates.get(A);v||(v=Object.create(null),this._intentStates.set(A,v)),v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);const g=!!(p&Ls.PRINT);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(w=this._stats)==null||w.time("Page Request"),this._pumpOperatorList(f));const m=x=>{var E;v.renderTasks.delete(y),(this._maybeCleanupAfterRender||g)&&ue(this,Of,!0),he(this,Jl,Ly).call(this,!g),x?(y.capability.reject(x),this._abortOperatorList({intentState:v,reason:x instanceof Error?x:new Error(x)})):y.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(E=globalThis.Stats)!=null&&E.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},y=new ck({callback:m,params:{canvasContext:t,viewport:r,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!g,pdfBug:this._pdfBug,pageColors:c});(v.renderTasks||(v.renderTasks=new Set)).add(y);const b=y.task;return Promise.all([v.displayReadyCapability.promise,s]).then(([x,E])=>{var S;if(this.destroyed){m();return}if((S=this._stats)==null||S.time("Rendering"),!(E.renderingIntent&p))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");y.initializeGraphics({transparency:x,optionalContentConfig:E}),y.operatorListChanged()}).catch(m),b}getOperatorList({intent:t="display",annotationMode:r=Sh.ENABLE,printAnnotationStorage:n=null,isEditing:i=!1}={}){var c;function a(){s.operatorList.lastChunk&&(s.opListReadCapability.resolve(s.operatorList),s.renderTasks.delete(l))}const o=this._transport.getRenderingIntent(t,r,n,i,!0);let s=this._intentStates.get(o.cacheKey);s||(s=Object.create(null),this._intentStates.set(o.cacheKey,s));let l;return s.opListReadCapability||(l=Object.create(null),l.operatorListChanged=a,s.opListReadCapability=Promise.withResolvers(),(s.renderTasks||(s.renderTasks=new Set)).add(l),s.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(o)),s.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:r=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:r===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>iC.textContent(n));const r=this.streamTextContent(t);return new Promise(function(n,i){function a(){o.read().then(function({value:l,done:c}){if(c){n(s);return}s.lang??(s.lang=l.lang),Object.assign(s.styles,l.styles),s.items.push(...l.items),a()},i)}const o=r.getReader(),s={items:[],styles:Object.create(null),lang:null};a()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const r of this._intentStates.values())if(this._abortOperatorList({intentState:r,reason:new Error("Page was destroyed."),force:!0}),!r.opListReadCapability)for(const n of r.renderTasks)t.push(n.completed),n.cancel();return this.objs.clear(),ue(this,Of,!1),he(this,Jl,P8).call(this),Promise.all(t)}cleanup(t=!1){ue(this,Of,!0);const r=he(this,Jl,Ly).call(this,!1);return t&&r&&this._stats&&(this._stats=new kq),r}_startRenderPage(t,r){var i,a;const n=this._intentStates.get(r);n&&((i=this._stats)==null||i.timeEnd("Page Request"),(a=n.displayReadyCapability)==null||a.resolve(t))}_renderPageChunk(t,r){for(let n=0,i=t.length;n<i;n++)r.operatorList.fnArray.push(t.fnArray[n]),r.operatorList.argsArray.push(t.argsArray[n]);r.operatorList.lastChunk=t.lastChunk,r.operatorList.separateAnnots=t.separateAnnots;for(const n of r.renderTasks)n.operatorListChanged();t.lastChunk&&he(this,Jl,Ly).call(this,!0)}_pumpOperatorList({renderingIntent:t,cacheKey:r,annotationStorageSerializable:n,modifiedIds:i}){const{map:a,transfer:o}=n,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:r,annotationStorage:a,modifiedIds:i},o).getReader(),c=this._intentStates.get(r);c.streamReader=l;const u=()=>{l.read().then(({value:d,done:f})=>{if(f){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,c),u())},d=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();he(this,Jl,Ly).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(d);else if(c.opListReadCapability)c.opListReadCapability.reject(d);else throw d}})};u()}_abortOperatorList({intentState:t,reason:r,force:n=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!n){if(t.renderTasks.size>0)return;if(r instanceof HO){let i=BBe;r.extraDelay>0&&r.extraDelay<1e3&&(i+=r.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:r,force:!0})},i);return}}if(t.streamReader.cancel(new zp(r.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,a]of this._intentStates)if(a===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}op=new WeakMap,Of=new WeakMap,Jl=new WeakSet,Ly=function(t=!1){if(he(this,Jl,P8).call(this),!P(this,Of)||this.destroyed)return!1;if(t)return ue(this,op,setTimeout(()=>{ue(this,op,null),he(this,Jl,Ly).call(this,!1)},MBe)),!1;for(const{renderTasks:r,operatorList:n}of this._intentStates.values())if(r.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),ue(this,Of,!1),!0},P8=function(){P(this,op)&&(clearTimeout(P(this,op)),ue(this,op,null))};class NBe{constructor(){be(this,kf,new Map);be(this,h8,Promise.resolve())}postMessage(t,r){const n={data:structuredClone(t,r?{transfer:r}:null)};P(this,h8).then(()=>{for(const[i]of P(this,kf))i.call(this,n)})}addEventListener(t,r,n=null){let i=null;if((n==null?void 0:n.signal)instanceof AbortSignal){const{signal:a}=n;if(a.aborted){Gr("LoopbackPort - cannot use an `aborted` signal.");return}const o=()=>this.removeEventListener(t,r);i=()=>a.removeEventListener("abort",o),a.addEventListener("abort",o)}P(this,kf).set(r,i)}removeEventListener(t,r){const n=P(this,kf).get(r);n==null||n(),P(this,kf).delete(r)}terminate(){for(const[,t]of P(this,kf))t==null||t();P(this,kf).clear()}}kf=new WeakMap,h8=new WeakMap;const hi=class hi{constructor({name:t=null,port:r=null,verbosity:n=gIe()}={}){be(this,iy);var i;if(this.name=t,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,r){if((i=P(hi,Hg))!=null&&i.has(r))throw new Error("Cannot use more than one PDFWorker per port.");(P(hi,Hg)||ue(hi,Hg,new WeakMap)).set(r,this),this._initializeFromPort(r);return}this._initialize()}get promise(){return yo?Promise.all([Mh.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new rC("main","worker",t),this._messageHandler.on("ready",function(){}),he(this,iy,D8).call(this)}_initialize(){if(P(hi,Qg)||P(hi,ay,T8)){this._setupFakeWorker();return}let{workerSrc:t}=hi;try{hi._isSameOrigin(window.location.href,t)||(t=hi._createCDNWrapper(new URL(t,window.location).href));const r=new Worker(t,{type:"module"}),n=new rC("main","worker",r),i=()=>{a.abort(),n.destroy(),r.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;r.addEventListener("error",()=>{this._webWorker||i()},{signal:a.signal}),n.on("test",s=>{if(a.abort(),this.destroyed||!s){i();return}this._messageHandler=n,this._port=r,this._webWorker=r,he(this,iy,D8).call(this)}),n.on("ready",s=>{if(a.abort(),this.destroyed){i();return}try{o()}catch{this._setupFakeWorker()}});const o=()=>{const s=new Uint8Array;n.send("test",s,[s.buffer])};o();return}catch{p3("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){P(hi,Qg)||(Gr("Setting up fake worker."),ue(hi,Qg,!0)),hi._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const r=new NBe;this._port=r;const n=`fake${os(hi,p8)._++}`,i=new rC(n+"_worker",n,r);t.setup(i,r),this._messageHandler=new rC(n,n+"_worker",r),he(this,iy,D8).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(t=P(hi,Hg))==null||t.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){var n;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const r=(n=P(this,Hg))==null?void 0:n.get(t.port);if(r){if(r._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return r}return new hi(t)}static get workerSrc(){if(zd.workerSrc)return zd.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return dn(this,"_setupFakeWorkerGlobal",(async()=>P(this,ay,T8)?P(this,ay,T8):(await import(this.workerSrc)).WorkerMessageHandler)())}};p8=new WeakMap,Qg=new WeakMap,Hg=new WeakMap,iy=new WeakSet,D8=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},ay=new WeakSet,T8=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},be(hi,ay),be(hi,p8,0),be(hi,Qg,!1),be(hi,Hg),yo&&(ue(hi,Qg,!0),zd.workerSrc||(zd.workerSrc="./pdf.worker.mjs")),hi._isSameOrigin=(t,r)=>{let n;try{if(n=new URL(t),!n.origin||n.origin==="null")return!1}catch{return!1}const i=new URL(r,n);return n.origin===i.origin},hi._createCDNWrapper=t=>{const r=`await import("${t}");`;return URL.createObjectURL(new Blob([r],{type:"text/javascript"}))};let im=hi;class $Be{constructor(t,r,n,i,a){be(this,zg);be(this,Ff,new Map);be(this,gd,new Map);be(this,oy,new Map);be(this,sy,new Map);be(this,vd,null);this.messageHandler=t,this.loadingTask=r,this.commonObjs=new fX,this.fontLoader=new FIe({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return dn(this,"annotationStorage",new XO)}getRenderingIntent(t,r=Sh.ENABLE,n=null,i=!1,a=!1){let o=Ls.DISPLAY,s=qO;switch(t){case"any":o=Ls.ANY;break;case"display":break;case"print":o=Ls.PRINT;break;default:Gr(`getRenderingIntent - invalid intent: ${t}`)}const l=o&Ls.PRINT&&n instanceof $q?n:this.annotationStorage;switch(r){case Sh.DISABLE:o+=Ls.ANNOTATIONS_DISABLE;break;case Sh.ENABLE:break;case Sh.ENABLE_FORMS:o+=Ls.ANNOTATIONS_FORMS;break;case Sh.ENABLE_STORAGE:o+=Ls.ANNOTATIONS_STORAGE,s=l.serializable;break;default:Gr(`getRenderingIntent - invalid annotationMode: ${r}`)}i&&(o+=Ls.IS_EDITING),a&&(o+=Ls.OPLIST);const{ids:c,hash:u}=l.modifiedIds,d=[o,s.hash,u];return{renderingIntent:o,cacheKey:d.join("_"),annotationStorageSerializable:s,modifiedIds:c}}destroy(){var n;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(n=P(this,vd))==null||n.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of P(this,gd).values())t.push(i._destroy());P(this,gd).clear(),P(this,oy).clear(),P(this,sy).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const r=this.messageHandler.sendWithPromise("Terminate",null);return t.push(r),Promise.all(t).then(()=>{var i;this.commonObjs.clear(),this.fontLoader.clear(),P(this,Ff).clear(),this.filterFactory.destroy(),nC.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new zp("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:r}=this;t.on("GetReader",(n,i)=>{sa(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=a=>{this._lastProgress={loaded:a.loaded,total:a.total}},i.onPull=()=>{this._fullReader.read().then(function({value:a,done:o}){if(o){i.close();return}sa(a instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{this._fullReader.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("ReaderHeadersReady",async n=>{var s;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:a,contentLength:o}=this._fullReader;return(!i||!a)&&(this._lastProgress&&((s=r.onProgress)==null||s.call(r,this._lastProgress)),this._fullReader.onProgress=l=>{var c;(c=r.onProgress)==null||c.call(r,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:a,contentLength:o}}),t.on("GetRangeReader",(n,i)=>{sa(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const a=this._networkStream.getRangeReader(n.begin,n.end);if(!a){i.close();return}i.onPull=()=>{a.read().then(function({value:o,done:s}){if(s){i.close();return}sa(o instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{i.error(o)})},i.onCancel=o=>{a.cancel(o),i.ready.catch(s=>{if(!this.destroyed)throw s})}}),t.on("GetDoc",({pdfInfo:n})=>{this._numPages=n.numPages,this._htmlForXfa=n.htmlForXfa,delete n.htmlForXfa,r._capability.resolve(new FBe(n,this))}),t.on("DocException",function(n){let i;switch(n.name){case"PasswordException":i=new FO(n.message,n.code);break;case"InvalidPDFException":i=new Tq(n.message);break;case"MissingPDFException":i=new Hp(n.message);break;case"UnexpectedResponseException":i=new A3(n.message,n.status);break;case"UnknownErrorException":i=new LO(n.message,n.details);break;default:ei("DocException - expected a valid Error.")}r._capability.reject(i)}),t.on("PasswordRequest",n=>{if(ue(this,vd,Promise.withResolvers()),r.onPassword){const i=a=>{a instanceof Error?P(this,vd).reject(a):P(this,vd).resolve({password:a})};try{r.onPassword(i,n.code)}catch(a){P(this,vd).reject(a)}}else P(this,vd).reject(new FO(n.message,n.code));return P(this,vd).promise}),t.on("DataLoaded",n=>{var i;(i=r.onProgress)==null||i.call(r,{loaded:n.length,total:n.length}),this.downloadInfoCapability.resolve(n)}),t.on("StartRenderPage",n=>{if(this.destroyed)return;P(this,gd).get(n.pageIndex)._startRenderPage(n.transparency,n.cacheKey)}),t.on("commonobj",([n,i,a])=>{var o;if(this.destroyed||this.commonObjs.has(n))return null;switch(i){case"Font":const{disableFontFace:s,fontExtraProperties:l,pdfBug:c}=this._params;if("error"in a){const p=a.error;Gr(`Error during font loading: ${p}`),this.commonObjs.resolve(n,p);break}const u=c&&((o=globalThis.FontInspector)!=null&&o.enabled)?(p,A)=>globalThis.FontInspector.fontAdded(p,A):null,d=new LIe(a,{disableFontFace:s,inspectFont:u});this.fontLoader.bind(d).catch(()=>t.sendWithPromise("FontFallback",{id:n})).finally(()=>{!l&&d.data&&(d.data=null),this.commonObjs.resolve(n,d)});break;case"CopyLocalImage":const{imageRef:f}=a;sa(f,"The imageRef must be defined.");for(const p of P(this,gd).values())for(const[,A]of p.objs)if((A==null?void 0:A.ref)===f)return A.dataLen?(this.commonObjs.resolve(n,structuredClone(A)),A.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,a);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([n,i,a,o])=>{var l;if(this.destroyed)return;const s=P(this,gd).get(i);if(!s.objs.has(n)){if(s._intentStates.size===0){(l=o==null?void 0:o.bitmap)==null||l.close();return}switch(a){case"Image":s.objs.resolve(n,o),(o==null?void 0:o.dataLen)>dIe&&(s._maybeCleanupAfterRender=!0);break;case"Pattern":s.objs.resolve(n,o);break;default:throw new Error(`Got unknown object type ${a}`)}}}),t.on("DocProgress",n=>{var i;this.destroyed||(i=r.onProgress)==null||i.call(r,{loaded:n.loaded,total:n.total})}),t.on("FetchBuiltInCMap",async n=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(n)}),t.on("FetchStandardFontData",async n=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(n)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var n;this.annotationStorage.size<=0&&Gr("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:r}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((n=this._fullReader)==null?void 0:n.filename)??null},r).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const r=t-1,n=P(this,oy).get(r);if(n)return n;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:r}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&P(this,sy).set(a.refStr,t);const o=new LBe(r,a,this,this._params.pdfBug);return P(this,gd).set(r,o),o});return P(this,oy).set(r,i),i}getPageIndex(t){return uX(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,r){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:r})}getFieldObjects(){return he(this,zg,II).call(this,"GetFieldObjects")}hasJSActions(){return he(this,zg,II).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return he(this,zg,II).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return he(this,zg,II).call(this,"GetOptionalContentConfig").then(r=>new aBe(r,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",r=P(this,Ff).get(t);if(r)return r;const n=this.messageHandler.sendWithPromise(t,null).then(i=>{var a,o;return{info:i[0],metadata:i[1]?new nBe(i[1]):null,contentDispositionFilename:((a=this._fullReader)==null?void 0:a.filename)??null,contentLength:((o=this._fullReader)==null?void 0:o.contentLength)??null}});return P(this,Ff).set(t,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const r of P(this,gd).values())if(!r.cleanup())throw new Error(`startCleanup: Page ${r.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),P(this,Ff).clear(),this.filterFactory.destroy(!0),nC.cleanup()}}cachedPageNumber(t){if(!uX(t))return null;const r=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return P(this,sy).get(r)??null}}Ff=new WeakMap,gd=new WeakMap,oy=new WeakMap,sy=new WeakMap,vd=new WeakMap,zg=new WeakSet,II=function(t,r=null){const n=P(this,Ff).get(t);if(n)return n;const i=this.messageHandler.sendWithPromise(t,r);return P(this,Ff).set(t,i),i};const S3=Symbol("INITIAL_DATA");class fX{constructor(){be(this,jS);be(this,Jc,Object.create(null))}get(t,r=null){if(r){const i=he(this,jS,pV).call(this,t);return i.promise.then(()=>r(i.data)),null}const n=P(this,Jc)[t];if(!n||n.data===S3)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return n.data}has(t){const r=P(this,Jc)[t];return!!r&&r.data!==S3}resolve(t,r=null){const n=he(this,jS,pV).call(this,t);n.data=r,n.resolve()}clear(){var t;for(const r in P(this,Jc)){const{data:n}=P(this,Jc)[r];(t=n==null?void 0:n.bitmap)==null||t.close()}ue(this,Jc,Object.create(null))}*[Symbol.iterator](){for(const t in P(this,Jc)){const{data:r}=P(this,Jc)[t];r!==S3&&(yield[t,r])}}}Jc=new WeakMap,jS=new WeakSet,pV=function(t){var r;return(r=P(this,Jc))[t]||(r[t]={...Promise.withResolvers(),data:S3})};class jBe{constructor(t){be(this,sp,null);ue(this,sp,t),this.onContinue=null}get promise(){return P(this,sp).capability.promise}cancel(t=0){P(this,sp).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=P(this,sp).operatorList;if(!t)return!1;const{annotationCanvasMap:r}=P(this,sp);return t.form||t.canvas&&(r==null?void 0:r.size)>0}}sp=new WeakMap;const Vg=class Vg{constructor({callback:t,params:r,objs:n,commonObjs:i,annotationCanvasMap:a,operatorList:o,pageIndex:s,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:u=!1,pdfBug:d=!1,pageColors:f=null}){be(this,lp,null);this.callback=t,this.params=r,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=s,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=u===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new jBe(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=r.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:r}){var s,l;if(this.cancelled)return;if(this._canvas){if(P(Vg,Wg).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.");P(Vg,Wg).add(this._canvas)}this._pdfBug&&((s=globalThis.StepperManager)!=null&&s.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:n,viewport:i,transform:a,background:o}=this.params;this.gfx=new rm(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:r},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:i,transparency:t,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(t=null,r=0){var n;this.running=!1,this.cancelled=!0,(n=this.gfx)==null||n.endDrawing(),P(this,lp)&&(window.cancelAnimationFrame(P(this,lp)),ue(this,lp,null)),P(Vg,Wg).delete(this._canvas),this.callback(t||new HO(`Rendering cancelled, page ${this._pageIndex+1}`,r))}operatorListChanged(){var t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.stepper)==null||t.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?ue(this,lp,window.requestAnimationFrame(()=>{ue(this,lp,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),P(Vg,Wg).delete(this._canvas),this.callback())))}};lp=new WeakMap,Wg=new WeakMap,be(Vg,Wg,new WeakSet);let ck=Vg;const QBe="4.8.69",HBe="3634dab10";function hX(e){return Math.floor(Math.max(0,Math.min(1,e))*255).toString(16).padStart(2,"0")}function aC(e){return Math.max(0,Math.min(255,255*e))}class pX{static CMYK_G([t,r,n,i]){return["G",1-Math.min(1,.3*t+.59*n+.11*r+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=aC(t),[t,t,t]}static G_HTML([t]){const r=hX(t);return`#${r}${r}${r}`}static RGB_G([t,r,n]){return["G",.3*t+.59*r+.11*n]}static RGB_rgb(t){return t.map(aC)}static RGB_HTML(t){return`#${t.map(hX).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,r,n,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,n+i),1-Math.min(1,r+i)]}static CMYK_rgb([t,r,n,i]){return[aC(1-Math.min(1,t+i)),aC(1-Math.min(1,n+i)),aC(1-Math.min(1,r+i))]}static CMYK_HTML(t){const r=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(r)}static RGB_CMYK([t,r,n]){const i=1-t,a=1-r,o=1-n,s=Math.min(i,a,o);return["CMYK",i,a,o,s]}}class zBe{create(t,r,n=!1){if(t<=0||r<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),n||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${r}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${r}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){ei("Abstract method `_createSVG` called.")}}class uk extends zBe{_createSVG(t){return document.createElementNS(Qd,t)}}class AX{static setupStorage(t,r,n,i,a){const o=i.getValue(r,{value:null});switch(n.name){case"textarea":if(o.value!==null&&(t.textContent=o.value),a==="print")break;t.addEventListener("input",s=>{i.setValue(r,{value:s.target.value})});break;case"input":if(n.attributes.type==="radio"||n.attributes.type==="checkbox"){if(o.value===n.attributes.xfaOn?t.setAttribute("checked",!0):o.value===n.attributes.xfaOff&&t.removeAttribute("checked"),a==="print")break;t.addEventListener("change",s=>{i.setValue(r,{value:s.target.checked?s.target.getAttribute("xfaOn"):s.target.getAttribute("xfaOff")})})}else{if(o.value!==null&&t.setAttribute("value",o.value),a==="print")break;t.addEventListener("input",s=>{i.setValue(r,{value:s.target.value})})}break;case"select":if(o.value!==null){t.setAttribute("value",o.value);for(const s of n.children)s.attributes.value===o.value?s.attributes.selected=!0:s.attributes.hasOwnProperty("selected")&&delete s.attributes.selected}t.addEventListener("input",s=>{const l=s.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(r,{value:c})});break}}static setAttributes({html:t,element:r,storage:n=null,intent:i,linkService:a}){const{attributes:o}=r,s=t instanceof HTMLAnchorElement;o.type==="radio"&&(o.name=`${o.name}-${i}`);for(const[l,c]of Object.entries(o))if(c!=null)switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!s||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}s&&a.addLinkAttributes(t,o.href,o.newWindow),n&&o.dataId&&this.setupStorage(t,o.dataId,r,n)}static render(t){var d,f;const r=t.annotationStorage,n=t.linkService,i=t.xfaHtml,a=t.intent||"display",o=document.createElement(i.name);i.attributes&&this.setAttributes({html:o,element:i,intent:a,linkService:n});const s=a!=="richText",l=t.div;if(l.append(o),t.viewport){const p=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=p}s&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const p=document.createTextNode(i.value);o.append(p),s&&iC.shouldBuildText(i.name)&&c.push(p)}return{textDivs:c}}const u=[[i,-1,o]];for(;u.length>0;){const[p,A,v]=u.at(-1);if(A+1===p.children.length){u.pop();continue}const g=p.children[++u.at(-1)[1]];if(g===null)continue;const{name:m}=g;if(m==="#text"){const b=document.createTextNode(g.value);c.push(b),v.append(b);continue}const y=(d=g==null?void 0:g.attributes)!=null&&d.xmlns?document.createElementNS(g.attributes.xmlns,m):document.createElement(m);if(v.append(y),g.attributes&&this.setAttributes({html:y,element:g,storage:r,intent:a,linkService:n}),((f=g.children)==null?void 0:f.length)>0)u.push([g,-1,y]);else if(g.value){const b=document.createTextNode(g.value);s&&iC.shouldBuildText(m)&&c.push(b),y.append(b)}}for(const p of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))p.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const r=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=r,t.div.hidden=!1}}const oC=1e3,WBe=9,Gp=new WeakSet;function Wd(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class VBe{static create(t){switch(t.data.annotationType){case oa.LINK:return new gX(t);case oa.TEXT:return new GBe(t);case oa.WIDGET:switch(t.data.fieldType){case"Tx":return new YBe(t);case"Btn":return t.data.radioButton?new vX(t):t.data.checkBox?new KBe(t):new qBe(t);case"Ch":return new XBe(t);case"Sig":return new UBe(t)}return new Yp(t);case oa.POPUP:return new dk(t);case oa.FREETEXT:return new mX(t);case oa.LINE:return new JBe(t);case oa.SQUARE:return new e3e(t);case oa.CIRCLE:return new t3e(t);case oa.POLYLINE:return new bX(t);case oa.CARET:return new n3e(t);case oa.INK:return new fk(t);case oa.POLYGON:return new r3e(t);case oa.HIGHLIGHT:return new yX(t);case oa.UNDERLINE:return new i3e(t);case oa.SQUIGGLY:return new a3e(t);case oa.STRIKEOUT:return new o3e(t);case oa.STAMP:return new wX(t);case oa.FILEATTACHMENT:return new s3e(t);default:return new Oi(t)}}}const $W=class $W{constructor(t,{isRenderable:r=!1,ignoreBorder:n=!1,createQuadrilaterals:i=!1}={}){be(this,QS);be(this,Gg,null);be(this,ly,!1);be(this,cy,null);this.isRenderable=r,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,r&&(this.container=this._createContainer(n)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:r,richText:n}){return!!(t!=null&&t.str||r!=null&&r.str||n!=null&&n.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return $W._hasPopupData(this.data)}updateEdited(t){var n;if(!this.container)return;P(this,Gg)||ue(this,Gg,{rect:this.data.rect.slice(0)});const{rect:r}=t;r&&he(this,QS,AV).call(this,r),(n=P(this,cy))==null||n.popup.updateEdited(t)}resetEdited(){var t;P(this,Gg)&&(he(this,QS,AV).call(this,P(this,Gg).rect),(t=P(this,cy))==null||t.popup.resetEdited(),ue(this,Gg,null))}_createContainer(t){const{data:r,parent:{page:n,viewport:i}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",r.id),this instanceof Yp||(a.tabIndex=oC);const{style:o}=a;if(o.zIndex=this.parent.zIndex++,r.alternativeText&&(a.title=r.alternativeText),r.noRotate&&a.classList.add("norotate"),!r.rect||this instanceof dk){const{rotation:v}=r;return!r.hasOwnCanvas&&v!==0&&this.setRotation(v,a),a}const{width:s,height:l}=Wd(r.rect);if(!t&&r.borderStyle.width>0){o.borderWidth=`${r.borderStyle.width}px`;const v=r.borderStyle.horizontalCornerRadius,g=r.borderStyle.verticalCornerRadius;if(v>0||g>0){const y=`calc(${v}px * var(--scale-factor)) / calc(${g}px * var(--scale-factor))`;o.borderRadius=y}else if(this instanceof vX){const y=`calc(${s}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;o.borderRadius=y}switch(r.borderStyle.style){case qw.SOLID:o.borderStyle="solid";break;case qw.DASHED:o.borderStyle="dashed";break;case qw.BEVELED:Gr("Unimplemented border style: beveled");break;case qw.INSET:Gr("Unimplemented border style: inset");break;case qw.UNDERLINE:o.borderBottomStyle="solid";break}const m=r.borderColor||null;m?(ue(this,ly,!0),o.borderColor=rr.makeHexColor(m[0]|0,m[1]|0,m[2]|0)):o.borderWidth=0}const c=rr.normalizeRect([r.rect[0],n.view[3]-r.rect[1]+n.view[1],r.rect[2],n.view[3]-r.rect[3]+n.view[1]]),{pageWidth:u,pageHeight:d,pageX:f,pageY:p}=i.rawDims;o.left=`${100*(c[0]-f)/u}%`,o.top=`${100*(c[1]-p)/d}%`;const{rotation:A}=r;return r.hasOwnCanvas||A===0?(o.width=`${100*s/u}%`,o.height=`${100*l/d}%`):this.setRotation(A,a),a}setRotation(t,r=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:i}=this.parent.viewport.rawDims,{width:a,height:o}=Wd(this.data.rect);let s,l;t%180===0?(s=100*a/n,l=100*o/i):(s=100*o/n,l=100*a/i),r.style.width=`${s}%`,r.style.height=`${l}%`,r.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(r,n,i)=>{const a=i.detail[r],o=a[0],s=a.slice(1);i.target.style[n]=pX[`${o}_HTML`](s),this.annotationStorage.setValue(this.data.id,{[n]:pX[`${o}_rgb`](s)})};return dn(this,"_commonActions",{display:r=>{const{display:n}=r.detail,i=n%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:n===1||n===2})},print:r=>{this.annotationStorage.setValue(this.data.id,{noPrint:!r.detail.print})},hidden:r=>{const{hidden:n}=r.detail;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:n,noView:n})},focus:r=>{setTimeout(()=>r.target.focus({preventScroll:!1}),0)},userName:r=>{r.target.title=r.detail.userName},readonly:r=>{r.target.disabled=r.detail.readonly},required:r=>{this._setRequired(r.target,r.detail.required)},bgColor:r=>{t("bgColor","backgroundColor",r)},fillColor:r=>{t("fillColor","backgroundColor",r)},fgColor:r=>{t("fgColor","color",r)},textColor:r=>{t("textColor","color",r)},borderColor:r=>{t("borderColor","borderColor",r)},strokeColor:r=>{t("strokeColor","borderColor",r)},rotation:r=>{const n=r.detail.rotation;this.setRotation(n),this.annotationStorage.setValue(this.data.id,{rotation:n})}})}_dispatchEventFromSandbox(t,r){const n=this._commonActions;for(const i of Object.keys(r.detail)){const a=t[i]||n[i];a==null||a(r)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const r=this.annotationStorage.getRawValue(this.data.id);if(!r)return;const n=this._commonActions;for(const[i,a]of Object.entries(r)){const o=n[i];if(o){const s={detail:{[i]:a},target:t};o(s),delete r[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[r,n,i,a]=this.data.rect.map(v=>Math.fround(v));if(t.length===8){const[v,g,m,y]=t.subarray(2,6);if(i===v&&a===g&&r===m&&n===y)return}const{style:o}=this.container;let s;if(P(this,ly)){const{borderColor:v,borderWidth:g}=o;o.borderWidth=0,s=["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="${v}" stroke-width="${g}">`],this.container.classList.add("hasBorder")}const l=i-r,c=a-n,{svgFactory:u}=this,d=u.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const f=u.createElement("defs");d.append(f);const p=u.createElement("clipPath"),A=`clippath_${this.data.id}`;p.setAttribute("id",A),p.setAttribute("clipPathUnits","objectBoundingBox"),f.append(p);for(let v=2,g=t.length;v<g;v+=8){const m=t[v],y=t[v+1],b=t[v+2],C=t[v+3],w=u.createElement("rect"),x=(b-r)/l,E=(a-y)/c,S=(m-b)/l,I=(y-C)/c;w.setAttribute("x",x),w.setAttribute("y",E),w.setAttribute("width",S),w.setAttribute("height",I),p.append(w),s==null||s.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${E}" width="${S}" height="${I}"/>`)}P(this,ly)&&(s.push("</g></svg>')"),o.backgroundImage=s.join("")),this.container.append(d),this.container.style.clipPath=`url(#${A})`}_createPopup(){const{data:t}=this,r=ue(this,cy,new dk({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(r.render())}render(){ei("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,r=null){const n=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:a,id:o,exportValues:s}of i){if(a===-1||o===r)continue;const l=typeof s=="string"?s:null,c=document.querySelector(`[data-element-id="${o}"]`);if(c&&!Gp.has(c)){Gr(`_getElementsByName - element not allowed: ${o}`);continue}n.push({id:o,exportValue:l,domElement:c})}return n}for(const i of document.getElementsByName(t)){const{exportValue:a}=i,o=i.getAttribute("data-element-id");o!==r&&Gp.has(i)&&n.push({id:o,exportValue:a,domElement:i})}return n}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const r of t)r.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:r}}=this;this.container.addEventListener("dblclick",()=>{var n;(n=this.linkService.eventBus)==null||n.dispatch("switchannotationeditormode",{source:this,mode:t,editId:r})})}};Gg=new WeakMap,ly=new WeakMap,cy=new WeakMap,QS=new WeakSet,AV=function(t){const{container:{style:r},data:{rect:n,rotation:i},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:o,pageX:s,pageY:l}}}}=this;n==null||n.splice(0,4,...t);const{width:c,height:u}=Wd(t);r.left=`${100*(t[0]-s)/a}%`,r.top=`${100*(o-t[3]+l)/o}%`,i===0?(r.width=`${100*c/a}%`,r.height=`${100*u/o}%`):this.setRotation(i)};let Oi=$W;class gX extends Oi{constructor(r,n=null){super(r,{isRenderable:!0,ignoreBorder:!!(n!=null&&n.ignoreBorder),createQuadrilaterals:!0});be(this,cl);this.isTooltipOnly=r.data.isTooltipOnly}render(){const{data:r,linkService:n}=this,i=document.createElement("a");i.setAttribute("data-element-id",r.id);let a=!1;return r.url?(n.addLinkAttributes(i,r.url,r.newWindow),a=!0):r.action?(this._bindNamedAction(i,r.action),a=!0):r.attachment?(he(this,cl,Twe).call(this,i,r.attachment,r.attachmentDest),a=!0):r.setOCGState?(he(this,cl,_we).call(this,i,r.setOCGState),a=!0):r.dest?(this._bindLink(i,r.dest),a=!0):(r.actions&&(r.actions.Action||r.actions["Mouse Up"]||r.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,r),a=!0),r.resetForm?(this._bindResetFormAction(i,r.resetForm),a=!0):this.isTooltipOnly&&!a&&(this._bindLink(i,""),a=!0)),this.container.classList.add("linkAnnotation"),a&&this.container.append(i),this.container}_bindLink(r,n){r.href=this.linkService.getDestinationHash(n),r.onclick=()=>(n&&this.linkService.goToDestination(n),!1),(n||n==="")&&he(this,cl,Av).call(this)}_bindNamedAction(r,n){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeNamedAction(n),!1),he(this,cl,Av).call(this)}_bindJSAction(r,n){r.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const a of Object.keys(n.actions)){const o=i.get(a);o&&(r[o]=()=>{var s;return(s=this.linkService.eventBus)==null||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n.id,name:a}}),!1})}r.onclick||(r.onclick=()=>!1),he(this,cl,Av).call(this)}_bindResetFormAction(r,n){const i=r.onclick;if(i||(r.href=this.linkService.getAnchorUrl("")),he(this,cl,Av).call(this),!this._fieldObjects){Gr('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(r.onclick=()=>!1);return}r.onclick=()=>{var d;i==null||i();const{fields:a,refs:o,include:s}=n,l=[];if(a.length!==0||o.length!==0){const f=new Set(o);for(const p of a){const A=this._fieldObjects[p]||[];for(const{id:v}of A)f.add(v)}for(const p of Object.values(this._fieldObjects))for(const A of p)f.has(A.id)===s&&l.push(A)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const c=this.annotationStorage,u=[];for(const f of l){const{id:p}=f;switch(u.push(p),f.type){case"text":{const v=f.defaultValue||"";c.setValue(p,{value:v});break}case"checkbox":case"radiobutton":{const v=f.defaultValue===f.exportValues;c.setValue(p,{value:v});break}case"combobox":case"listbox":{const v=f.defaultValue||"";c.setValue(p,{value:v});break}default:continue}const A=document.querySelector(`[data-element-id="${p}"]`);if(A){if(!Gp.has(A)){Gr(`_bindResetFormAction - element not allowed: ${p}`);continue}}else continue;A.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:u,name:"ResetForm"}})),!1}}}cl=new WeakSet,Av=function(){this.container.setAttribute("data-internal-link","")},Twe=function(r,n,i=null){r.href=this.linkService.getAnchorUrl(""),n.description&&(r.title=n.description),r.onclick=()=>{var a;return(a=this.downloadManager)==null||a.openOrDownloadData(n.content,n.filename,i),!1},he(this,cl,Av).call(this)},_we=function(r,n){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeSetOCGState(n),!1),he(this,cl,Av).call(this)};class GBe extends Oi{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Yp extends Oi{render(){return this.container}showElementAndHideCanvas(t){var r;this.data.hasOwnCanvas&&(((r=t.previousSibling)==null?void 0:r.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Vo.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,r,n,i,a){n.includes("mouse")?t.addEventListener(n,o=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:a(o),shift:o.shiftKey,modifier:this._getKeyModifier(o)}})}):t.addEventListener(n,o=>{var s;if(n==="blur"){if(!r.focused||!o.relatedTarget)return;r.focused=!1}else if(n==="focus"){if(r.focused)return;r.focused=!0}a&&((s=this.linkService.eventBus)==null||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:a(o)}}))})}_setEventListeners(t,r,n,i){var a,o,s;for(const[l,c]of n)(c==="Action"||(a=this.data.actions)!=null&&a[c])&&((c==="Focus"||c==="Blur")&&(r||(r={focused:!1})),this._setEventListener(t,r,l,c,i),c==="Focus"&&!((o=this.data.actions)!=null&&o.Blur)?this._setEventListener(t,r,"blur","Blur",null):c==="Blur"&&!((s=this.data.actions)!=null&&s.Focus)&&this._setEventListener(t,r,"focus","Focus",null))}_setBackgroundColor(t){const r=this.data.backgroundColor||null;t.style.backgroundColor=r===null?"transparent":rr.makeHexColor(r[0],r[1],r[2])}_setTextStyle(t){const r=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||WBe,a=t.style;let o;const s=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-s),u=Math.round(c/(kO*i))||1,d=c/u;o=Math.min(i,l(d/kO))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-s);o=Math.min(i,l(c/kO))}a.fontSize=`calc(${o}px * var(--scale-factor))`,a.color=rr.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(a.textAlign=r[this.data.textAlignment])}_setRequired(t,r){r?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",r)}}class YBe extends Yp{constructor(t){const r=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:r})}setPropertyOnSiblings(t,r,n,i){const a=this.annotationStorage;for(const o of this._getElementsByName(t.name,t.id))o.domElement&&(o.domElement[r]=n),a.setValue(o.id,{[i]:n})}render(){var i,a;const t=this.annotationStorage,r=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const o=t.getValue(r,{value:this.data.fieldValue});let s=o.value||"";const l=t.getValue(r,{charLimit:this.data.maxLen}).charLimit;l&&s.length>l&&(s=s.slice(0,l));let c=o.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
60
60
  `))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const u={userValue:s,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=c??s,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",c??s),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),Gp.add(n),n.setAttribute("data-element-id",r),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=oC,this._setRequired(n,this.data.required),l&&(n.maxLength=l),n.addEventListener("input",f=>{t.setValue(r,{value:f.target.value}),this.setPropertyOnSiblings(n,"value",f.target.value,"value"),u.formattedValue=null}),n.addEventListener("resetform",f=>{const p=this.data.defaultFieldValue??"";n.value=u.userValue=p,u.formattedValue=null});let d=f=>{const{formattedValue:p}=u;p!=null&&(f.target.value=p),f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",p=>{var v;if(u.focused)return;const{target:A}=p;u.userValue&&(A.value=u.userValue),u.lastCommittedValue=A.value,u.commitKey=1,(v=this.data.actions)!=null&&v.Focus||(u.focused=!0)}),n.addEventListener("updatefromsandbox",p=>{this.showElementAndHideCanvas(p.target);const A={value(v){u.userValue=v.detail.value??"",t.setValue(r,{value:u.userValue.toString()}),v.target.value=u.userValue},formattedValue(v){const{formattedValue:g}=v.detail;u.formattedValue=g,g!=null&&v.target!==document.activeElement&&(v.target.value=g),t.setValue(r,{formattedValue:g})},selRange(v){v.target.setSelectionRange(...v.detail.selRange)},charLimit:v=>{var b;const{charLimit:g}=v.detail,{target:m}=v;if(g===0){m.removeAttribute("maxLength");return}m.setAttribute("maxLength",g);let y=u.userValue;!y||y.length<=g||(y=y.slice(0,g),m.value=u.userValue=y,t.setValue(r,{value:y}),(b=this.linkService.eventBus)==null||b.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:y,willCommit:!0,commitKey:1,selStart:m.selectionStart,selEnd:m.selectionEnd}}))}};this._dispatchEventFromSandbox(A,p)}),n.addEventListener("keydown",p=>{var g;u.commitKey=1;let A=-1;if(p.key==="Escape"?A=0:p.key==="Enter"&&!this.data.multiLine?A=2:p.key==="Tab"&&(u.commitKey=3),A===-1)return;const{value:v}=p.target;u.lastCommittedValue!==v&&(u.lastCommittedValue=v,u.userValue=v,(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:v,willCommit:!0,commitKey:A,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}}))});const f=d;d=null,n.addEventListener("blur",p=>{var v,g;if(!u.focused||!p.relatedTarget)return;(v=this.data.actions)!=null&&v.Blur||(u.focused=!1);const{value:A}=p.target;u.userValue=A,u.lastCommittedValue!==A&&((g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:A,willCommit:!0,commitKey:u.commitKey,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}})),f(p)}),(a=this.data.actions)!=null&&a.Keystroke&&n.addEventListener("beforeinput",p=>{var w;u.lastCommittedValue=null;const{data:A,target:v}=p,{value:g,selectionStart:m,selectionEnd:y}=v;let b=m,C=y;switch(p.inputType){case"deleteWordBackward":{const x=g.substring(0,m).match(/\w*[^\w]*$/);x&&(b-=x[0].length);break}case"deleteWordForward":{const x=g.substring(m).match(/^[^\w]*\w*/);x&&(C+=x[0].length);break}case"deleteContentBackward":m===y&&(b-=1);break;case"deleteContentForward":m===y&&(C+=1);break}p.preventDefault(),(w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:g,change:A||"",willCommit:!1,selStart:b,selEnd:C}})}),this._setEventListeners(n,u,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],p=>p.target.value)}if(d&&n.addEventListener("blur",d),this.data.comb){const p=(this.data.rect[2]-this.data.rect[0])/l;n.classList.add("comb"),n.style.letterSpacing=`calc(${p}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class UBe extends Yp{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class KBe extends Yp{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,r=this.data,n=r.id;let i=t.getValue(n,{value:r.exportValue===r.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(n,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const a=document.createElement("input");return Gp.add(a),a.setAttribute("data-element-id",n),a.disabled=r.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=r.fieldName,i&&a.setAttribute("checked",!0),a.setAttribute("exportValue",r.exportValue),a.tabIndex=oC,a.addEventListener("change",o=>{const{name:s,checked:l}=o.target;for(const c of this._getElementsByName(s,n)){const u=l&&c.exportValue===r.exportValue;c.domElement&&(c.domElement.checked=u),t.setValue(c.id,{value:u})}t.setValue(n,{value:l})}),a.addEventListener("resetform",o=>{const s=r.defaultFieldValue||"Off";o.target.checked=s===r.exportValue}),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",o=>{const s={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(n,{value:l.target.checked})}};this._dispatchEventFromSandbox(s,o)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class vX extends Yp{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,r=this.data,n=r.id;let i=t.getValue(n,{value:r.fieldValue===r.buttonValue}).value;if(typeof i=="string"&&(i=i!==r.buttonValue,t.setValue(n,{value:i})),i)for(const o of this._getElementsByName(r.fieldName,n))t.setValue(o.id,{value:!1});const a=document.createElement("input");if(Gp.add(a),a.setAttribute("data-element-id",n),a.disabled=r.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=r.fieldName,i&&a.setAttribute("checked",!0),a.tabIndex=oC,a.addEventListener("change",o=>{const{name:s,checked:l}=o.target;for(const c of this._getElementsByName(s,n))t.setValue(c.id,{value:!1});t.setValue(n,{value:l})}),a.addEventListener("resetform",o=>{const s=r.defaultFieldValue;o.target.checked=s!=null&&s===r.buttonValue}),this.enableScripting&&this.hasJSActions){const o=r.buttonValue;a.addEventListener("updatefromsandbox",s=>{const l={value:c=>{const u=o===c.detail.value;for(const d of this._getElementsByName(c.target.name)){const f=u&&d.id===n;d.domElement&&(d.domElement.checked=f),t.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(l,s)}),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],s=>s.target.checked)}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class qBe extends gX{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const r=t.lastChild;return this.enableScripting&&this.hasJSActions&&r&&(this._setDefaultPropertiesFromJS(r),r.addEventListener("updatefromsandbox",n=>{this._dispatchEventFromSandbox({},n)})),t}}class XBe extends Yp{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,r=this.data.id,n=t.getValue(r,{value:this.data.fieldValue}),i=document.createElement("select");Gp.add(i),i.setAttribute("data-element-id",r),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=oC;let a=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",u=>{const d=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===d});for(const u of this.data.options){const d=document.createElement("option");d.textContent=u.displayValue,d.value=u.exportValue,n.value.includes(u.exportValue)&&(d.setAttribute("selected",!0),a=!1),i.append(d)}let o=null;if(a){const u=document.createElement("option");u.value=" ",u.setAttribute("hidden",!0),u.setAttribute("selected",!0),i.prepend(u),o=()=>{u.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const s=u=>{const d=u?"value":"textContent",{options:f,multiple:p}=i;return p?Array.prototype.filter.call(f,A=>A.selected).map(A=>A[d]):f.selectedIndex===-1?null:f[f.selectedIndex][d]};let l=s(!1);const c=u=>{const d=u.target.options;return Array.prototype.map.call(d,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",u=>{const d={value(f){o==null||o();const p=f.detail.value,A=new Set(Array.isArray(p)?p:[p]);for(const v of i.options)v.selected=A.has(v.value);t.setValue(r,{value:s(!0)}),l=s(!1)},multipleSelection(f){i.multiple=!0},remove(f){const p=i.options,A=f.detail.remove;p[A].selected=!1,i.remove(A),p.length>0&&Array.prototype.findIndex.call(p,g=>g.selected)===-1&&(p[0].selected=!0),t.setValue(r,{value:s(!0),items:c(f)}),l=s(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(r,{value:null,items:[]}),l=s(!1)},insert(f){const{index:p,displayValue:A,exportValue:v}=f.detail.insert,g=i.children[p],m=document.createElement("option");m.textContent=A,m.value=v,g?g.before(m):i.append(m),t.setValue(r,{value:s(!0),items:c(f)}),l=s(!1)},items(f){const{items:p}=f.detail;for(;i.length!==0;)i.remove(0);for(const A of p){const{displayValue:v,exportValue:g}=A,m=document.createElement("option");m.textContent=v,m.value=g,i.append(m)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(r,{value:s(!0),items:c(f)}),l=s(!1)},indices(f){const p=new Set(f.detail.indices);for(const A of f.target.options)A.selected=p.has(A.index);t.setValue(r,{value:s(!0)}),l=s(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(d,u)}),i.addEventListener("input",u=>{var p;const d=s(!0),f=s(!1);t.setValue(r,{value:d}),u.preventDefault(),(p=this.linkService.eventBus)==null||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:l,change:f,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],u=>u.target.value)):i.addEventListener("input",function(u){t.setValue(r,{value:s(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class dk extends Oi{constructor(t){const{data:r,elements:n}=t;super(t,{isRenderable:Oi._hasPopupData(r)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new ZBe({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),r=[];for(const n of this.elements)n.popup=t,n.container.ariaHasPopup="dialog",r.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",r.map(n=>`${QO}${n}`).join(",")),this.container}}class ZBe{constructor({container:t,color:r,elements:n,titleObj:i,modificationDate:a,contentsObj:o,richText:s,parent:l,rect:c,parentRect:u,open:d}){be(this,Qn);be(this,uy,he(this,Qn,Fwe).bind(this));be(this,A8,he(this,Qn,vV).bind(this));be(this,g8,he(this,Qn,k8).bind(this));be(this,dy,he(this,Qn,O8).bind(this));be(this,Yg,null);be(this,Di,null);be(this,Lf,null);be(this,fy,null);be(this,HS,null);be(this,zS,null);be(this,hy,null);be(this,Nf,!1);be(this,eu,null);be(this,$f,null);be(this,WS,null);be(this,jf,null);be(this,VS,null);be(this,Ug,null);be(this,Kg,!1);var f;ue(this,Di,t),ue(this,VS,i),ue(this,Lf,o),ue(this,jf,s),ue(this,zS,l),ue(this,Yg,r),ue(this,WS,c),ue(this,hy,u),ue(this,HS,n),ue(this,fy,WO.toDateObject(a)),this.trigger=n.flatMap(p=>p.getElementsToTriggerPopup());for(const p of this.trigger)p.addEventListener("click",P(this,dy)),p.addEventListener("mouseenter",P(this,g8)),p.addEventListener("mouseleave",P(this,A8)),p.classList.add("popupTriggerArea");for(const p of n)(f=p.container)==null||f.addEventListener("keydown",P(this,uy));P(this,Di).hidden=!0,d&&he(this,Qn,O8).call(this)}render(){if(P(this,eu))return;const t=ue(this,eu,document.createElement("div"));if(t.className="popup",P(this,Yg)){const a=t.style.outlineColor=rr.makeHexColor(...P(this,Yg));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${a} 30%, white)`:t.style.backgroundColor=rr.makeHexColor(...P(this,Yg).map(s=>Math.floor(.7*(255-s)+s)))}const r=document.createElement("span");r.className="header";const n=document.createElement("h1");if(r.append(n),{dir:n.dir,str:n.textContent}=P(this,VS),t.append(r),P(this,fy)){const a=document.createElement("span");a.classList.add("popupDate"),a.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),a.setAttribute("data-l10n-args",JSON.stringify({dateObj:P(this,fy).valueOf()})),r.append(a)}const i=P(this,Qn,_8);if(i)AX.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const a=this._formatContents(P(this,Lf));t.append(a)}P(this,Di).append(t)}_formatContents({str:t,dir:r}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=r;const i=t.split(/(?:\r\n?|\n)/);for(let a=0,o=i.length;a<o;++a){const s=i[a];n.append(document.createTextNode(s)),a<o-1&&n.append(document.createElement("br"))}return n}updateEdited({rect:t,popupContent:r}){var n;P(this,Ug)||ue(this,Ug,{contentsObj:P(this,Lf),richText:P(this,jf)}),t&&ue(this,$f,null),r&&(ue(this,jf,he(this,Qn,kwe).call(this,r)),ue(this,Lf,null)),(n=P(this,eu))==null||n.remove(),ue(this,eu,null)}resetEdited(){var t;P(this,Ug)&&({contentsObj:os(this,Lf)._,richText:os(this,jf)._}=P(this,Ug),ue(this,Ug,null),(t=P(this,eu))==null||t.remove(),ue(this,eu,null),ue(this,$f,null))}forceHide(){ue(this,Kg,this.isVisible),P(this,Kg)&&(P(this,Di).hidden=!0)}maybeShow(){P(this,Kg)&&(P(this,eu)||he(this,Qn,k8).call(this),ue(this,Kg,!1),P(this,Di).hidden=!1)}get isVisible(){return P(this,Di).hidden===!1}}uy=new WeakMap,A8=new WeakMap,g8=new WeakMap,dy=new WeakMap,Yg=new WeakMap,Di=new WeakMap,Lf=new WeakMap,fy=new WeakMap,HS=new WeakMap,zS=new WeakMap,hy=new WeakMap,Nf=new WeakMap,eu=new WeakMap,$f=new WeakMap,WS=new WeakMap,jf=new WeakMap,VS=new WeakMap,Ug=new WeakMap,Kg=new WeakMap,Qn=new WeakSet,_8=function(){const t=P(this,jf),r=P(this,Lf);return t!=null&&t.str&&(!(r!=null&&r.str)||r.str===t.str)&&P(this,jf).html||null},gV=function(){var t,r,n;return((n=(r=(t=P(this,Qn,_8))==null?void 0:t.attributes)==null?void 0:r.style)==null?void 0:n.fontSize)||0},Owe=function(){var t,r,n;return((n=(r=(t=P(this,Qn,_8))==null?void 0:t.attributes)==null?void 0:r.style)==null?void 0:n.color)||null},kwe=function(t){const r=[],n={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:r}]}},i={style:{color:P(this,Qn,Owe),fontSize:P(this,Qn,gV)?`calc(${P(this,Qn,gV)}px * var(--scale-factor))`:""}};for(const a of t.split(`
61
61
  `))r.push({name:"span",value:a,attributes:i});return n},Fwe=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&P(this,Nf))&&he(this,Qn,O8).call(this)},Lwe=function(){if(P(this,$f)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:i,pageY:a}}}=P(this,zS);let o=!!P(this,hy),s=o?P(this,hy):P(this,WS);for(const A of P(this,HS))if(!s||rr.intersect(A.data.rect,s)!==null){s=A.data.rect,o=!0;break}const l=rr.normalizeRect([s[0],t[3]-s[1]+t[1],s[2],t[3]-s[3]+t[1]]),u=o?s[2]-s[0]+5:0,d=l[0]+u,f=l[1];ue(this,$f,[100*(d-i)/r,100*(f-a)/n]);const{style:p}=P(this,Di);p.left=`${P(this,$f)[0]}%`,p.top=`${P(this,$f)[1]}%`},O8=function(){ue(this,Nf,!P(this,Nf)),P(this,Nf)?(he(this,Qn,k8).call(this),P(this,Di).addEventListener("click",P(this,dy)),P(this,Di).addEventListener("keydown",P(this,uy))):(he(this,Qn,vV).call(this),P(this,Di).removeEventListener("click",P(this,dy)),P(this,Di).removeEventListener("keydown",P(this,uy)))},k8=function(){P(this,eu)||this.render(),this.isVisible?P(this,Nf)&&P(this,Di).classList.add("focused"):(he(this,Qn,Lwe).call(this),P(this,Di).hidden=!1,P(this,Di).style.zIndex=parseInt(P(this,Di).style.zIndex)+1e3)},vV=function(){P(this,Di).classList.remove("focused"),!(P(this,Nf)||!this.isVisible)&&(P(this,Di).hidden=!0,P(this,Di).style.zIndex=parseInt(P(this,Di).style.zIndex)-1e3)};class mX extends Oi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=jr.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const r of this.textContent){const n=document.createElement("span");n.textContent=r,t.append(n)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class JBe extends Oi{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});be(this,GS,null)}render(){this.container.classList.add("lineAnnotation");const r=this.data,{width:n,height:i}=Wd(r.rect),a=this.svgFactory.create(n,i,!0),o=ue(this,GS,this.svgFactory.createElement("svg:line"));return o.setAttribute("x1",r.rect[2]-r.lineCoordinates[0]),o.setAttribute("y1",r.rect[3]-r.lineCoordinates[1]),o.setAttribute("x2",r.rect[2]-r.lineCoordinates[2]),o.setAttribute("y2",r.rect[3]-r.lineCoordinates[3]),o.setAttribute("stroke-width",r.borderStyle.width||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),a.append(o),this.container.append(a),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return P(this,GS)}addHighlightArea(){this.container.classList.add("highlightArea")}}GS=new WeakMap;class e3e extends Oi{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});be(this,YS,null)}render(){this.container.classList.add("squareAnnotation");const r=this.data,{width:n,height:i}=Wd(r.rect),a=this.svgFactory.create(n,i,!0),o=r.borderStyle.width,s=ue(this,YS,this.svgFactory.createElement("svg:rect"));return s.setAttribute("x",o/2),s.setAttribute("y",o/2),s.setAttribute("width",n-o),s.setAttribute("height",i-o),s.setAttribute("stroke-width",o||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),a.append(s),this.container.append(a),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return P(this,YS)}addHighlightArea(){this.container.classList.add("highlightArea")}}YS=new WeakMap;class t3e extends Oi{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});be(this,US,null)}render(){this.container.classList.add("circleAnnotation");const r=this.data,{width:n,height:i}=Wd(r.rect),a=this.svgFactory.create(n,i,!0),o=r.borderStyle.width,s=ue(this,US,this.svgFactory.createElement("svg:ellipse"));return s.setAttribute("cx",n/2),s.setAttribute("cy",i/2),s.setAttribute("rx",n/2-o/2),s.setAttribute("ry",i/2-o/2),s.setAttribute("stroke-width",o||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),a.append(s),this.container.append(a),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return P(this,US)}addHighlightArea(){this.container.classList.add("highlightArea")}}US=new WeakMap;class bX extends Oi{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});be(this,KS,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,vertices:n,borderStyle:i,popupRef:a}}=this;if(!n)return this.container;const{width:o,height:s}=Wd(r),l=this.svgFactory.create(o,s,!0);let c=[];for(let d=0,f=n.length;d<f;d+=2){const p=n[d]-r[0],A=r[3]-n[d+1];c.push(`${p},${A}`)}c=c.join(" ");const u=ue(this,KS,this.svgFactory.createElement(this.svgElementName));return u.setAttribute("points",c),u.setAttribute("stroke-width",i.width||1),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),l.append(u),this.container.append(l),!a&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return P(this,KS)}addHighlightArea(){this.container.classList.add("highlightArea")}}KS=new WeakMap;class r3e extends bX{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class n3e extends Oi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class fk extends Oi{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});be(this,qS,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?jr.HIGHLIGHT:jr.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,inkLists:n,borderStyle:i,popupRef:a}}=this,{width:o,height:s}=Wd(r),l=this.svgFactory.create(o,s,!0);for(const c of n){let u=[];for(let f=0,p=c.length;f<p;f+=2){const A=c[f]-r[0],v=r[3]-c[f+1];u.push(`${A},${v}`)}u=u.join(" ");const d=this.svgFactory.createElement(this.svgElementName);P(this,qS).push(d),d.setAttribute("points",u),d.setAttribute("stroke-width",i.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),l.append(d)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}getElementsToTriggerPopup(){return P(this,qS)}addHighlightArea(){this.container.classList.add("highlightArea")}}qS=new WeakMap;class yX extends Oi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=jr.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class i3e extends Oi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class a3e extends Oi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class o3e extends Oi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class wX extends Oi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=jr.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class s3e extends Oi{constructor(r){var i;super(r,{isRenderable:!0});be(this,ZS);be(this,XS,null);const{file:n}=this.data;this.filename=n.filename,this.content=n.content,(i=this.linkService.eventBus)==null||i.dispatch("fileattachmentannotation",{source:this,...n})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:r,data:n}=this;let i;n.hasAppearance||n.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(n.name)?"paperclip":"pushpin"}.svg`,n.fillAlpha&&n.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(n.fillAlpha*100)}%);`)),i.addEventListener("dblclick",he(this,ZS,mV).bind(this)),ue(this,XS,i);const{isMac:a}=Vo.platform;return r.addEventListener("keydown",o=>{o.key==="Enter"&&(a?o.metaKey:o.ctrlKey)&&he(this,ZS,mV).call(this)}),!n.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),r.append(i),r}getElementsToTriggerPopup(){return P(this,XS)}addHighlightArea(){this.container.classList.add("highlightArea")}}XS=new WeakMap,ZS=new WeakSet,mV=function(){var r;(r=this.downloadManager)==null||r.openOrDownloadData(this.content,this.filename)};class l3e{constructor({div:t,accessibilityManager:r,annotationCanvasMap:n,annotationEditorUIManager:i,page:a,viewport:o,structTreeLayer:s}){be(this,Zg);be(this,JS,null);be(this,qg,null);be(this,Xg,new Map);be(this,eI,null);this.div=t,ue(this,JS,r),ue(this,qg,n),ue(this,eI,s||null),this.page=a,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return P(this,Xg).size>0}async render(t){var o;const{annotations:r}=t,n=this.div;Wp(n,this.viewport);const i=new Map,a={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new uk,annotationStorage:t.annotationStorage||new XO,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const s of r){if(s.noHTML)continue;const l=s.annotationType===oa.POPUP;if(l){const d=i.get(s.id);if(!d)continue;a.elements=d}else{const{width:d,height:f}=Wd(s.rect);if(d<=0||f<=0)continue}a.data=s;const c=VBe.create(a);if(!c.isRenderable)continue;if(!l&&s.popupRef){const d=i.get(s.popupRef);d?d.push(c):i.set(s.popupRef,[c])}const u=c.render();s.hidden&&(u.style.visibility="hidden"),await he(this,Zg,Nwe).call(this,u,s.id),c._isEditable&&(P(this,Xg).set(c.data.id,c),(o=this._annotationEditorUIManager)==null||o.renderAnnotationElement(c))}he(this,Zg,bV).call(this)}update({viewport:t}){const r=this.div;this.viewport=t,Wp(r,{rotation:t.rotation}),he(this,Zg,bV).call(this),r.hidden=!1}getEditableAnnotations(){return Array.from(P(this,Xg).values())}getEditableAnnotation(t){return P(this,Xg).get(t)}}JS=new WeakMap,qg=new WeakMap,Xg=new WeakMap,eI=new WeakMap,Zg=new WeakSet,Nwe=async function(t,r){var o,s;const n=t.firstChild||t,i=n.id=`${QO}${r}`,a=await((o=P(this,eI))==null?void 0:o.getAriaAttributes(i));if(a)for(const[l,c]of a)n.setAttribute(l,c);this.div.append(t),(s=P(this,JS))==null||s.moveElementInDOM(this.div,t,n,!1)},bV=function(){if(!P(this,qg))return;const t=this.div;for(const[r,n]of P(this,qg)){const i=t.querySelector(`[data-annotation-id="${r}"]`);if(!i)continue;n.className="annotationContent";const{firstChild:a}=i;a?a.nodeName==="CANVAS"?a.replaceWith(n):a.classList.contains("annotationContent")?a.after(n):a.before(n):i.append(n)}P(this,qg).clear()};const I3=/\r\n?|\n/g,Jn=class Jn extends kn{constructor(r){super({...r,name:"freeTextEditor"});be(this,ea);be(this,tu);be(this,ul,"");be(this,tI,`${this.id}-editor`);be(this,Jg,null);be(this,dl);ue(this,tu,r.color||Jn._defaultColor||kn._defaultLineColor),ue(this,dl,r.fontSize||Jn._defaultFontSize)}static get _keyboardManager(){const r=Jn.prototype,n=o=>o.isEmpty(),i=Vp.TRANSLATE_SMALL,a=Vp.TRANSLATE_BIG;return dn(this,"_keyboardManager",new Jw([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],r.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],r.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],r._translateEmpty,{args:[-i,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r._translateEmpty,{args:[-a,0],checker:n}],[["ArrowRight","mac+ArrowRight"],r._translateEmpty,{args:[i,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r._translateEmpty,{args:[a,0],checker:n}],[["ArrowUp","mac+ArrowUp"],r._translateEmpty,{args:[0,-i],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r._translateEmpty,{args:[0,-a],checker:n}],[["ArrowDown","mac+ArrowDown"],r._translateEmpty,{args:[0,i],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r._translateEmpty,{args:[0,a],checker:n}]]))}static initialize(r,n){kn.initialize(r,n);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(r,n){switch(r){case Br.FREETEXT_SIZE:Jn._defaultFontSize=n;break;case Br.FREETEXT_COLOR:Jn._defaultColor=n;break}}updateParams(r,n){switch(r){case Br.FREETEXT_SIZE:he(this,ea,$we).call(this,n);break;case Br.FREETEXT_COLOR:he(this,ea,jwe).call(this,n);break}}static get defaultPropertiesToUpdate(){return[[Br.FREETEXT_SIZE,Jn._defaultFontSize],[Br.FREETEXT_COLOR,Jn._defaultColor||kn._defaultLineColor]]}get propertiesToUpdate(){return[[Br.FREETEXT_SIZE,P(this,dl)],[Br.FREETEXT_COLOR,P(this,tu)]]}_translateEmpty(r,n){this._uiManager.translateSelectedEditors(r,n,!0)}getInitialTranslation(){const r=this.parentScale;return[-Jn._internalPadding*r,-(Jn._internalPadding+P(this,dl))*r]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(jr.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),ue(this,Jg,new AbortController);const r=this._uiManager.combinedSignal(P(this,Jg));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:r}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:r}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:r}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:r}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:r})}disableEditMode(){var r;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",P(this,tI)),this._isDraggable=!0,(r=P(this,Jg))==null||r.abort(),ue(this,Jg,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(r){this._focusEventsAllowed&&(super.focusin(r),r.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var r;this.width||(this.enableEditMode(),this.editorDiv.focus(),(r=this._initialOptions)!=null&&r.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const r=P(this,ul),n=ue(this,ul,he(this,ea,Qwe).call(this).trimEnd());if(r===n)return;const i=a=>{if(ue(this,ul,a),!a){this.remove();return}he(this,ea,N8).call(this),this._uiManager.rebuild(this),he(this,ea,F8).call(this)};this.addCommands({cmd:()=>{i(n)},undo:()=>{i(r)},mustExec:!1}),he(this,ea,F8).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(r){this.enterInEditMode()}keydown(r){r.target===this.div&&r.key==="Enter"&&(this.enterInEditMode(),r.preventDefault())}editorDivKeydown(r){Jn._keyboardManager.exec(this,r)}editorDivFocus(r){this.isEditing=!0}editorDivBlur(r){this.isEditing=!1}editorDivInput(r){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let r,n;this.width&&(r=this.x,n=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",P(this,tI)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${P(this,dl)}px * var(--scale-factor))`,i.color=P(this,tu),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),b3(this,this.div,["dblclick","keydown"]),this.width){const[a,o]=this.parentDimensions;if(this.annotationElementId){const{position:s}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[u,d]=this.pageDimensions,[f,p]=this.pageTranslation;let A,v;switch(this.rotation){case 0:A=r+(s[0]-f)/u,v=n+this.height-(s[1]-p)/d;break;case 90:A=r+(s[0]-f)/u,v=n-(s[1]-p)/d,[l,c]=[c,-l];break;case 180:A=r-this.width+(s[0]-f)/u,v=n-(s[1]-p)/d,[l,c]=[-l,-c];break;case 270:A=r+(s[0]-f-this.height*d)/u,v=n+(s[1]-p-this.width*u)/d,[l,c]=[-c,l];break}this.setAt(A*a,v*o,l,c)}else this.setAt(r*a,n*o,this.width*a,this.height*o);he(this,ea,N8).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(r){var A,v,g;const n=r.clipboardData||window.clipboardData,{types:i}=n;if(i.length===1&&i[0]==="text/plain")return;r.preventDefault();const a=he(A=Jn,Qf,yV).call(A,n.getData("text")||"").replaceAll(I3,`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "5.2.12-dev.0",
3
+ "version": "5.2.12-dev.1",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",