@agentsky/desktop-ui 0.4.126 → 0.4.128
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/app.js +2477 -2433
- package/dist/chunks/chunk-VC46IEJQ.js +1 -0
- package/dist/chunks/{pdf-X7LWVG5W.js → pdf-7GWOIJM5.js} +1 -1
- package/dist/editors/editors.mjs +117 -117
- package/dist/messages/zh.json +161 -4
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ht=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),vt=[1/0,1/0,-1/0,-1/0],Pt=new Float32Array(vt),Ps=[.001,0,0,.001,0,0];var nt="http://www.w3.org/2000/svg",lt={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Et={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},zt="pdfjs_internal_id_",Wt="pdfjs_internal_editor_",O={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},B={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},gr={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};var J={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},He={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Y={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,RICHMEDIA:27};var Gt={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var ds={ERRORS:0,WARNINGS:1,INFOS:5},mt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},te={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},mr={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},us=ds.WARNINGS;function br(h){Number.isInteger(h)&&(us=h)}function yr(){return us}function fs(h){us>=ds.INFOS&&console.info(`Info: ${h}`)}function R(h){us>=ds.WARNINGS&&console.warn(`Warning: ${h}`)}function H(h){throw new Error(h)}function K(h,t){h||H(t)}function Ar(h){switch(h?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Kn(h,t=null,e=null){if(!h)return null;if(e&&typeof h=="string"&&(e.addDefaultProtocol&&h.startsWith("www.")&&h.match(/\./g)?.length>=2&&(h=`http://${h}`),e.tryConvertEncoding))try{h=vr(h)}catch{}let s=t?URL.parse(h,t):URL.parse(h);return Ar(s)?s:null}function qn(h,t,e=!1){let s=URL.parse(h);return s?(s.hash=t,s.href):e&&Kn(h,"http://example.com")?h.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Ms(h){return h.substring(h.lastIndexOf("/")+1)}function D(h,t,e,s=!1){return Object.defineProperty(h,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}var Nt=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})(),oe=class extends Nt{constructor(t,e){super(t,"PasswordException"),this.code=e}},ie=class extends Nt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},le=class extends Nt{constructor(t){super(t,"InvalidPDFException")}},Xt=class extends Nt{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}},Ds=class extends Nt{constructor(t){super(t,"FormatError")}},bt=class extends Nt{constructor(t){super(t,"AbortException")}};function wr(h){(typeof h!="object"||h?.length===void 0)&&H("Invalid argument for bytesToString");let t=h.length,e=8192;if(t<e)return String.fromCharCode.apply(null,h);let s=[];for(let i=0;i<t;i+=e){let n=Math.min(i+e,t),r=h.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function ps(h){typeof h!="string"&&H("Invalid argument for stringToBytes");let t=h.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=h.charCodeAt(s)&255;return e}var U=class{static get isLittleEndian(){let t=new Uint8Array(4);t[0]=1;let e=new Uint32Array(t.buffer,0,1);return D(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return D(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return D(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return D(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return D(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){let{platform:t,userAgent:e}=navigator;return D(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),D(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return D(this,"isAlphaColorInputSupported",!1);let t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",D(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return D(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}},x=class{static get hexNums(){return D(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){let i=t[s],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let c=0;c<6;c+=2){let d=t[s+c],u=t[s+c+1];t[s+c]=d*i+u*r+o,t[s+c+1]=d*n+u*a+l}}static applyInverseTransform(t,e){let s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],c=t[0],d=t[1],u=t[2],f=t[3],p=i*c+o,g=p,m=i*u+o,b=m,y=a*d+l,A=y,v=a*f+l,w=v;if(n!==0||r!==0){let S=n*c,E=n*u,_=r*d,C=r*f;p+=_,b+=_,m+=C,g+=C,y+=S,w+=S,v+=E,A+=E}s[0]=Math.min(s[0],p,m,g,b),s[1]=Math.min(s[1],y,v,A,w),s[2]=Math.max(s[2],p,m,g,b),s[3]=Math.max(s[3],y,v,A,w)}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){let s=t[0],i=t[1],n=t[2],r=t[3],a=s**2+i**2,o=s*n+i*r,l=n**2+r**2,c=(a+l)/2,d=Math.sqrt(c**2-(a*l-o**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||1)}static normalizeRect(t){let e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){let s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;let n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[s,n,i,r]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,a,o,l,c){if(l<=0||l>=1)return;let d=1-l,u=l*l,f=u*l,p=d*(d*(d*t+3*l*e)+3*u*s)+f*i,g=d*(d*(d*n+3*l*r)+3*u*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,s,i,n,r,a,o,l,c,d,u){if(Math.abs(l)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/c,u);return}let f=c**2-4*d*l;if(f<0)return;let p=Math.sqrt(f),g=2*l;this.#t(t,e,s,i,n,r,a,o,(-c+p)/g,u),this.#t(t,e,s,i,n,r,a,o,(-c-p)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),l),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),l)}};function vr(h){return decodeURIComponent(escape(h))}var _s=null,Sn=null;function Sr(h){return _s||(_s=/([\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,Sn=new Map([["\uFB05","\u017Ft"]])),h.replaceAll(_s,(t,e,s)=>e?e.normalize("NFKC"):Sn.get(s))}function Qn(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let h=new Uint8Array(32);return crypto.getRandomValues(h),wr(h)}function Er(h,t,e){if(!Array.isArray(e)||e.length<2)return!1;let[s,i,...n]=e;if(!h(s)&&!Number.isInteger(s)||!t(i))return!1;let r=n.length,a=!0;switch(i.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;a=!1;break;default:return!1}for(let o of n)if(!(typeof o=="number"||a&&o===null))return!1;return!0}var Zt=()=>[],yn=()=>new Map,Is=()=>Object.create(null),_r=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(h){return[...this].join(h)});function j(h,t,e){return Math.min(Math.max(h,t),e)}var he=class h{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;let o=(t[2]+t[0])/2,l=(t[3]+t[1])/2,c,d,u,f;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,m,b;c===0?(p=Math.abs(l-t[1])*s+n,g=Math.abs(o-t[0])*s+r,m=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+n,g=Math.abs(l-t[1])*s+r,m=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[c*s,d*s,u*s,f*s,p-c*s*o-u*s*l,g-d*s*o-f*s*l],this.width=m,this.height=b}get rawDims(){let t=this.viewBox;return D(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new h({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){let s=[t,e];return x.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){let s=[t,e];return x.applyInverseTransform(s,this.transform),s}},ce=class h{static textContent(t){let e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null,a=n.name;if(a==="#text")r=n.value;else if(h.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(let o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}},xr=/url\(|image-set\(/i,Cr=/^on/i,Ge=class{static get _allowedHtmlElements(){return D(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return D(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return D(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return D(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return D(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,n){let r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(let a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:Object.hasOwn(a.attributes,"selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{let o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){let{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(let[o,l]of Object.entries(r))if(l!=null&&!Cr.test(o)&&!(i==="richText"&&!this._allowedRichTextAttributes.has(o)))switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){let c=this._allowedRichTextStyles;for(let[d,u]of Object.entries(l))c.has(d)&&!xr.test(u)&&(t.style[d]=u)}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&n?.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static#t(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===nt&&this._allowedSvgElements.has(t)?document.createElementNS(nt,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){let e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=this.#t(i.name,i.attributes?.xmlns,n)??document.createElement("div");i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});let a=n!=="richText",o=t.div;if(o.append(r),t.viewport){let d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(i.children.length===0){if(i.value){let d=document.createTextNode(i.value);r.append(d),a&&ce.shouldBuildText(i.name)&&l.push(d)}return{textDivs:l}}let c=[[i,-1,r]];for(;c.length>0;){let[d,u,f]=c.at(-1);if(u+1===d.children.length){c.pop();continue}let p=d.children[++c.at(-1)[1]];if(p===null)continue;let{name:g}=p;if(g==="#text"){let b=document.createTextNode(p.value);l.push(b),f.append(b);continue}let m=this.#t(g,p.attributes?.xmlns,n);if(m){if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:n,linkService:s}),p.children?.length>0)c.push([p,-1,m]);else if(p.value){let b=document.createTextNode(p.value);a&&ce.shouldBuildText(g)&&l.push(b),m.append(b)}}}for(let d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){let{width:i,height:n}=t.attributes.style;return new he({viewBox:[0,0,parseInt(i,10),parseInt(n,10)],userUnit:1,scale:e,rotation:s})}},xt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function An(h,t="text"){if(ne(h,document.baseURI)){let e=await fetch(h);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{let i=new XMLHttpRequest;i.open("GET",h,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}var de=class extends Nt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function gs(h){let t=h.length,e=0;for(;e<t&&h[e].trim()==="";)e++;return h.substring(e,e+5).toLowerCase()==="data:"}function wn(h){return typeof h=="string"&&/\.pdf$/i.test(h)}function Tr(h){return[h]=h.split(/[#?]/,1),Ms(h)}function kr(h,t="document.pdf"){if(typeof h!="string")return t;if(gs(h))return R('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let s=(a=>{try{return new URL(a)}catch{}try{return new URL(decodeURIComponent(a))}catch{}try{return new URL(a,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{}return null})(h);if(!s)return t;let i=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=Ms(o),o.length===4&&n.test(o))?a:o}catch{return a}},n=/\.pdf$/i,r=Ms(s.pathname);if(n.test(r))return i(r);if(s.searchParams.size>0){let a=l=>[...l].findLast(c=>n.test(c)),o=a(s.searchParams.values())??a(s.searchParams.keys());if(o)return i(o)}if(s.hash){let{hash:a}=s,o=-1;for(let{index:l}of a.matchAll(/\.pdf\b/gi))o=l;if(o>0){let l=o;for(;l>0&&!"/?#=".includes(a[l-1]);)l--;if(l<o)return i(a.slice(l,o+4))}}return t}var $e=class{#t=new Map;times=[];time(t){this.#t.has(t)&&R(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||R(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){let t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
|
|
1
|
+
import"./chunk-VC46IEJQ.js";var ht=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),vt=[1/0,1/0,-1/0,-1/0],Pt=new Float32Array(vt),Ps=[.001,0,0,.001,0,0];var nt="http://www.w3.org/2000/svg",lt={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Et={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},zt="pdfjs_internal_id_",Wt="pdfjs_internal_editor_",O={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},B={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},gr={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};var J={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},He={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Y={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,RICHMEDIA:27};var Gt={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var ds={ERRORS:0,WARNINGS:1,INFOS:5},mt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},te={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},mr={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},us=ds.WARNINGS;function br(h){Number.isInteger(h)&&(us=h)}function yr(){return us}function fs(h){us>=ds.INFOS&&console.info(`Info: ${h}`)}function R(h){us>=ds.WARNINGS&&console.warn(`Warning: ${h}`)}function H(h){throw new Error(h)}function K(h,t){h||H(t)}function Ar(h){switch(h?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Kn(h,t=null,e=null){if(!h)return null;if(e&&typeof h=="string"&&(e.addDefaultProtocol&&h.startsWith("www.")&&h.match(/\./g)?.length>=2&&(h=`http://${h}`),e.tryConvertEncoding))try{h=vr(h)}catch{}let s=t?URL.parse(h,t):URL.parse(h);return Ar(s)?s:null}function qn(h,t,e=!1){let s=URL.parse(h);return s?(s.hash=t,s.href):e&&Kn(h,"http://example.com")?h.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Ms(h){return h.substring(h.lastIndexOf("/")+1)}function D(h,t,e,s=!1){return Object.defineProperty(h,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}var Nt=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})(),oe=class extends Nt{constructor(t,e){super(t,"PasswordException"),this.code=e}},ie=class extends Nt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},le=class extends Nt{constructor(t){super(t,"InvalidPDFException")}},Xt=class extends Nt{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}},Ds=class extends Nt{constructor(t){super(t,"FormatError")}},bt=class extends Nt{constructor(t){super(t,"AbortException")}};function wr(h){(typeof h!="object"||h?.length===void 0)&&H("Invalid argument for bytesToString");let t=h.length,e=8192;if(t<e)return String.fromCharCode.apply(null,h);let s=[];for(let i=0;i<t;i+=e){let n=Math.min(i+e,t),r=h.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function ps(h){typeof h!="string"&&H("Invalid argument for stringToBytes");let t=h.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=h.charCodeAt(s)&255;return e}var U=class{static get isLittleEndian(){let t=new Uint8Array(4);t[0]=1;let e=new Uint32Array(t.buffer,0,1);return D(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return D(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return D(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return D(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return D(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){let{platform:t,userAgent:e}=navigator;return D(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),D(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return D(this,"isAlphaColorInputSupported",!1);let t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",D(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return D(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}},x=class{static get hexNums(){return D(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){let i=t[s],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let c=0;c<6;c+=2){let d=t[s+c],u=t[s+c+1];t[s+c]=d*i+u*r+o,t[s+c+1]=d*n+u*a+l}}static applyInverseTransform(t,e){let s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],c=t[0],d=t[1],u=t[2],f=t[3],p=i*c+o,g=p,m=i*u+o,b=m,y=a*d+l,A=y,v=a*f+l,w=v;if(n!==0||r!==0){let S=n*c,E=n*u,_=r*d,C=r*f;p+=_,b+=_,m+=C,g+=C,y+=S,w+=S,v+=E,A+=E}s[0]=Math.min(s[0],p,m,g,b),s[1]=Math.min(s[1],y,v,A,w),s[2]=Math.max(s[2],p,m,g,b),s[3]=Math.max(s[3],y,v,A,w)}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){let s=t[0],i=t[1],n=t[2],r=t[3],a=s**2+i**2,o=s*n+i*r,l=n**2+r**2,c=(a+l)/2,d=Math.sqrt(c**2-(a*l-o**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||1)}static normalizeRect(t){let e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){let s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;let n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[s,n,i,r]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,a,o,l,c){if(l<=0||l>=1)return;let d=1-l,u=l*l,f=u*l,p=d*(d*(d*t+3*l*e)+3*u*s)+f*i,g=d*(d*(d*n+3*l*r)+3*u*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,s,i,n,r,a,o,l,c,d,u){if(Math.abs(l)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,i,n,r,a,o,-d/c,u);return}let f=c**2-4*d*l;if(f<0)return;let p=Math.sqrt(f),g=2*l;this.#t(t,e,s,i,n,r,a,o,(-c+p)/g,u),this.#t(t,e,s,i,n,r,a,o,(-c-p)/g,u)}static bezierBoundingBox(t,e,s,i,n,r,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),l),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),l)}};function vr(h){return decodeURIComponent(escape(h))}var _s=null,Sn=null;function Sr(h){return _s||(_s=/([\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,Sn=new Map([["\uFB05","\u017Ft"]])),h.replaceAll(_s,(t,e,s)=>e?e.normalize("NFKC"):Sn.get(s))}function Qn(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let h=new Uint8Array(32);return crypto.getRandomValues(h),wr(h)}function Er(h,t,e){if(!Array.isArray(e)||e.length<2)return!1;let[s,i,...n]=e;if(!h(s)&&!Number.isInteger(s)||!t(i))return!1;let r=n.length,a=!0;switch(i.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;a=!1;break;default:return!1}for(let o of n)if(!(typeof o=="number"||a&&o===null))return!1;return!0}var Zt=()=>[],yn=()=>new Map,Is=()=>Object.create(null),_r=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(h){return[...this].join(h)});function j(h,t,e){return Math.min(Math.max(h,t),e)}var he=class h{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;let o=(t[2]+t[0])/2,l=(t[3]+t[1])/2,c,d,u,f;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,m,b;c===0?(p=Math.abs(l-t[1])*s+n,g=Math.abs(o-t[0])*s+r,m=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+n,g=Math.abs(l-t[1])*s+r,m=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[c*s,d*s,u*s,f*s,p-c*s*o-u*s*l,g-d*s*o-f*s*l],this.width=m,this.height=b}get rawDims(){let t=this.viewBox;return D(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new h({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){let s=[t,e];return x.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){let s=[t,e];return x.applyInverseTransform(s,this.transform),s}},ce=class h{static textContent(t){let e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null,a=n.name;if(a==="#text")r=n.value;else if(h.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(let o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}},xr=/url\(|image-set\(/i,Cr=/^on/i,Ge=class{static get _allowedHtmlElements(){return D(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return D(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return D(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return D(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return D(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,n){let r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(let a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:Object.hasOwn(a.attributes,"selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{let o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){let{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(let[o,l]of Object.entries(r))if(l!=null&&!Cr.test(o)&&!(i==="richText"&&!this._allowedRichTextAttributes.has(o)))switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){let c=this._allowedRichTextStyles;for(let[d,u]of Object.entries(l))c.has(d)&&!xr.test(u)&&(t.style[d]=u)}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&n?.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static#t(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===nt&&this._allowedSvgElements.has(t)?document.createElementNS(nt,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){let e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=this.#t(i.name,i.attributes?.xmlns,n)??document.createElement("div");i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});let a=n!=="richText",o=t.div;if(o.append(r),t.viewport){let d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(i.children.length===0){if(i.value){let d=document.createTextNode(i.value);r.append(d),a&&ce.shouldBuildText(i.name)&&l.push(d)}return{textDivs:l}}let c=[[i,-1,r]];for(;c.length>0;){let[d,u,f]=c.at(-1);if(u+1===d.children.length){c.pop();continue}let p=d.children[++c.at(-1)[1]];if(p===null)continue;let{name:g}=p;if(g==="#text"){let b=document.createTextNode(p.value);l.push(b),f.append(b);continue}let m=this.#t(g,p.attributes?.xmlns,n);if(m){if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:n,linkService:s}),p.children?.length>0)c.push([p,-1,m]);else if(p.value){let b=document.createTextNode(p.value);a&&ce.shouldBuildText(g)&&l.push(b),m.append(b)}}}for(let d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){let{width:i,height:n}=t.attributes.style;return new he({viewBox:[0,0,parseInt(i,10),parseInt(n,10)],userUnit:1,scale:e,rotation:s})}},xt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function An(h,t="text"){if(ne(h,document.baseURI)){let e=await fetch(h);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{let i=new XMLHttpRequest;i.open("GET",h,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}var de=class extends Nt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function gs(h){let t=h.length,e=0;for(;e<t&&h[e].trim()==="";)e++;return h.substring(e,e+5).toLowerCase()==="data:"}function wn(h){return typeof h=="string"&&/\.pdf$/i.test(h)}function Tr(h){return[h]=h.split(/[#?]/,1),Ms(h)}function kr(h,t="document.pdf"){if(typeof h!="string")return t;if(gs(h))return R('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let s=(a=>{try{return new URL(a)}catch{}try{return new URL(decodeURIComponent(a))}catch{}try{return new URL(a,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{}return null})(h);if(!s)return t;let i=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=Ms(o),o.length===4&&n.test(o))?a:o}catch{return a}},n=/\.pdf$/i,r=Ms(s.pathname);if(n.test(r))return i(r);if(s.searchParams.size>0){let a=l=>[...l].findLast(c=>n.test(c)),o=a(s.searchParams.values())??a(s.searchParams.keys());if(o)return i(o)}if(s.hash){let{hash:a}=s,o=-1;for(let{index:l}of a.matchAll(/\.pdf\b/gi))o=l;if(o>0){let l=o;for(;l>0&&!"/?#=".includes(a[l-1]);)l--;if(l<o)return i(a.slice(l,o+4))}}return t}var $e=class{#t=new Map;times=[];time(t){this.#t.has(t)&&R(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||R(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){let t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
|
|
2
2
|
`).join("")}};function ne(h,t){let e=t?URL.parse(h,t):URL.parse(h);return/https?:/.test(e?.protocol??"")}function ft(h){h.preventDefault()}function Z(h){h.preventDefault(),h.stopPropagation()}var ue=class{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#t.exec(t);if(!e)return null;let s=parseInt(e[1],10),i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,l==="-"?(r+=c,a+=d):l==="+"&&(r-=c,a-=d),new Date(Date.UTC(s,i,n,r,a,o))}};function Pe(h){if(h.startsWith("#")){let e=h.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(h.startsWith("rgb(")){let[e,s,i]=h.slice(4,-1).split(",").map(n=>parseInt(n,10));return[e,s,i,1]}if(h.startsWith("rgba(")){let e=h.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}let t=h.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function Me(h){let t=Pe(h);return t?t.slice(0,3):(R(`Not a valid color format: "${h}"`),[0,0,0])}function Pr(h){let t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(let e of h.keys()){t.style.color=e;let s=window.getComputedStyle(t).color;h.set(e,Me(s))}t.remove()}function $(h){let{a:t,b:e,c:s,d:i,e:n,f:r}=h.getTransform();return[t,e,s,i,n,r]}function pt(h){let{a:t,b:e,c:s,d:i,e:n,f:r}=h.getTransform().invertSelf();return[t,e,s,i,n,r]}function It(h,t,e=!1,s=!0){if(t instanceof he){let{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=h,a=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-y))`;!e||t.rotation%180===0?(r.width=a,r.height=o):(r.width=o,r.height=a)}s&&h.setAttribute("data-main-rotation",t.rotation)}var yt=class h{constructor(){let{pixelRatio:t}=h;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,n=-1){let r=1/0,a=1/0,o=1/0;s=h.capPixels(s,n),s>0&&(r=Math.sqrt(s/(t*e))),i!==-1&&(a=i/t,o=i/e);let l=Math.min(r,a,o);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}},Ls=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"],Os=class{static get isDarkMode(){return D(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}},Rs=class{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:s}=window.getComputedStyle(t);return t.remove(),D(this,"commentForegroundColor",Me(s))}};function Mr(h,t){t=j(t??1,0,1);let e=255*(1-t);return h.map(s=>Math.round(s*t+e))}function En(h,t){let e=h[0]/255,s=h[1]/255,i=h[2]/255,n=Math.max(e,s,i),r=Math.min(e,s,i),a=(n+r)/2;if(n===r)t[0]=t[1]=0;else{let o=n-r;switch(t[1]=a<.5?o/(n+r):o/(2-n-r),n){case e:t[0]=((s-i)/o+(s<i?6:0))*60;break;case s:t[0]=((i-e)/o+2)*60;break;case i:t[0]=((e-s)/o+4)*60;break}}t[2]=a}function Fs(h,t){let e=h[0],s=h[1],i=h[2],n=(1-Math.abs(2*i-1))*s,r=n*(1-Math.abs(e/60%2-1)),a=i-n/2;switch(Math.floor(e/60)){case 0:t[0]=n+a,t[1]=r+a,t[2]=a;break;case 1:t[0]=r+a,t[1]=n+a,t[2]=a;break;case 2:t[0]=a,t[1]=n+a,t[2]=r+a;break;case 3:t[0]=a,t[1]=r+a,t[2]=n+a;break;case 4:t[0]=r+a,t[1]=a,t[2]=n+a;break;case 5:case 6:t[0]=n+a,t[1]=a,t[2]=r+a;break}}function Ns(h){return h<=.03928?h/12.92:((h+.055)/1.055)**2.4}function _n(h,t,e){Fs(h,e),e.map(Ns);let s=.2126*e[0]+.7152*e[1]+.0722*e[2];Fs(t,e),e.map(Ns);let i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}var xn=new Map;function Dr(h,t){let e=h[0]+h[1]*256+h[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,s=xn.get(e);if(s)return s;let i=new Float32Array(9),n=i.subarray(0,3),r=i.subarray(3,6);En(h,r);let a=i.subarray(6,9);En(t,a);let o=a[2]<.5,l=o?12:4.5;if(r[2]=o?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]),_n(r,a,n)<l){let c,d;o?(c=r[2],d=1):(c=0,d=r[2]);let u=.005;for(;d-c>u;){let f=r[2]=(c+d)/2;o===_n(r,a,n)<l?c=f:d=f}r[2]=o?d:c}return Fs(r,n),s=x.makeHexColor(Math.round(n[0]*255),Math.round(n[1]*255),Math.round(n[2]*255)),xn.set(e,s),s}function Jn({html:h,dir:t,className:e},s){let i=document.createDocumentFragment();if(typeof h=="string"){let n=document.createElement("p");n.dir=t||"auto";let r=h.split(/\r\n?|\n/);for(let a=0,o=r.length;a<o;++a){let l=r[a];n.append(document.createTextNode(l)),a<o-1&&n.append(document.createElement("br"))}i.append(n)}else Ge.render({xfaHtml:h,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function Zn(h){let t=new Path2D;if(!h)return t;for(let e=0,s=h.length;e<s;)switch(h[e++]){case te.moveTo:t.moveTo(h[e++],h[e++]);break;case te.lineTo:t.lineTo(h[e++],h[e++]);break;case te.curveTo:t.bezierCurveTo(h[e++],h[e++],h[e++],h[e++],h[e++],h[e++]);break;case te.quadraticCurveTo:t.quadraticCurveTo(h[e++],h[e++],h[e++],h[e++]);break;case te.closePath:t.closePath();break;default:R(`Unrecognized drawing path operator: ${h[e-1]}`);break}return t}var Bs=class h{#t=null;#e=null;#s;#i=null;#n=null;#a=null;#r=null;#o=null;static#l=null;constructor(t){this.#s=t,h.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#s._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",ft,{signal:e}),t.addEventListener("pointerdown",h.#h,{signal:e}));let s=this.#i=document.createElement("div");s.className="buttons",t.append(s);let i=this.#s.toolbarPosition;if(i){let{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#h(t){t.stopPropagation()}#u(t){this.#s._focusEventsAllowed=!1,Z(t)}#d(t){this.#s._focusEventsAllowed=!0,Z(t)}#f(t){let e=this.#s._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ft,{signal:e}),!0)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#n?.shown(),this.#a?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#s,s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",h.#l[t]),this.#f(s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),this.#i.append(s)}get#g(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#f(e),this.#i.append(e,this.#g),this.#n=t}addComment(t,e=null){if(this.#a)return;let s=t.renderForToolbar();if(!s)return;this.#f(s);let i=this.#r=this.#g;e?(this.#i.insertBefore(s,e),this.#i.insertBefore(i,e)):this.#i.append(s,i),this.#a=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;let e=t.renderButton();this.#f(e),this.#i.append(e,this.#g)}async addEditSignatureButton(t){let e=this.#o=await t.renderEditButton(this.#s);this.#f(e),this.#i.append(e,this.#g)}removeButton(t){t==="comment"&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#r?.remove(),this.#r=null)}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;let i=this.#i.querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){this.#o&&(this.#o.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}},Hs=class{#t=null;#e=null;#s;constructor(t){this.#s=t}#i(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=this.#s.direction;let e=this.#s._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",ft,{signal:e});let s=this.#t=document.createElement("div");return s.className="buttons",t.append(s),this.#s.hasCommentManager()&&this.#a("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#s.commentSelection("floating_button")}),this.#a("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#s.highlightSelection("floating_button")}),t}#n(t,e){let s=0,i=0;for(let n of t){let r=n.y+n.height;if(r<s)continue;let a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){let[i,n]=this.#n(e,s),{style:r}=this.#e||=this.#i();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#a(t,e,s,i){let n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);let r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",s);let a=this.#s._signal;a instanceof AbortSignal&&!a.aborted&&(n.addEventListener("contextmenu",ft,{signal:a}),n.addEventListener("click",i,{signal:a})),this.#t.append(n)}},Ir="59968104-cc61-4cf9-b570-014b35b3709c",xs=Object.freeze({internal:Ir});function tr(h,t,e){for(let s of e)t.addEventListener(s,h[s].bind(h))}var it=class h{static#t=NaN;static#e=null;static#s=NaN;static#i=null;static initializeAndAddPointerId(t){(h.#e||=new Set).add(t)}static setPointer(t,e){h.#t||=e,h.#i??=t}static setTimeStamp(t){h.#s=t}static isSamePointerId(t){return h.#t===t}static isSamePointerIdOrRemove(t){return h.#t===t?!0:(h.#e?.delete(t),!1)}static isSamePointerType(t){return h.#i===t}static isInitializedAndDifferentPointerType(t){return h.#i!==null&&!h.isSamePointerType(t)}static isSameTimeStamp(t){return h.#s===t}static isUsingMultiplePointers(){return h.#e?.size>=1}static clearPointerType(){h.#i=null}static clearPointerIds(){h.#t=NaN,h.#e=null}static clearTimeStamp(){h.#s=NaN}},Us=class{#t=0;get id(){return`${Wt}${this.#t++}`}},Gs=class h{#t=Qn();#e=0;#s=null;static get _isSVGFittingCanvas(){let t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${nt}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;let n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return D(this,"_isSVGFittingCanvas",n)}async#i(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await An(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){let n=h._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((l,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,l()},r.onload=async()=>{let d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){R(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){let{lastModified:e,name:s,size:i,type:n}=t;return this.#i(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,e){let s=await e;return this.#i(t,s)}async getFromId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s?.bitmap)return s.refCounter+=1,s;let i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#s.set(t,s),this.#s.set(s.id,s),s}getSvgUrl(t){let e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;let{bitmap:s}=e;if(!e.url&&!e.file){let i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}},$s=class{#t=[];#e=!1;#s;#i=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;let o={cmd:t,undo:e,post:s,type:n};if(this.#i===-1){this.#t.length>0&&(this.#t.length=0),this.#i=0,this.#t.push(o);return}if(r&&this.#t[this.#i].type===n){a&&(o.undo=this.#t[this.#i].undo),this.#t[this.#i]=o;return}let l=this.#i+1;l===this.#s?this.#t.splice(0,1):(this.#i=l,l<this.#t.length&&this.#t.splice(l)),this.#t.push(o)}undo(){if(this.#i===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i!==-1){for(let e=this.#i;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#i-e),this.#i=e;return}this.#t.length=0,this.#i=-1}}destroy(){this.#t=null}},Lt=class h{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;let{isMac:e}=U.platform;for(let[s,i,n={}]of t){let r=s.some(a=>a.startsWith("mac+"));for(let a of s){let o=a;if(r){let d=a.startsWith("mac+");if(e!==d)continue;d&&(o=a.slice(4))}let[l,c]=h.#t(o);l!==null&&this.callbacks.getOrInsertComputed(l,Zt).push({callback:i,options:n,modifiers:c})}}}static#t(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;let n=i.toUpperCase(),r=h[n];if(r){s|=r;continue}if(e!==null){R(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=n==="SPACE"?" ":i}return e===null&&R(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]}static#e(t){let e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?e[1]?.toLowerCase()??e[2]:null}exec(t,e){let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;let c=h.#e(e.code);if(c===null||c===e.key||(s=this.callbacks.get(c),!s))return}let i=(e.altKey?h.ALT:0)|(e.ctrlKey?h.CTRL:0)|(e.metaKey?h.META:0)|(e.shiftKey?h.SHIFT:0),n=s.find(c=>c.modifiers===i);if(!n)return;let{callback:r,options:{bubbles:a=!1,args:o=[],checker:l=null}}=n;l&&!l(t,e)||(r.bind(t,...o,e)(),a||Z(e))}},zs=class h{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return Pr(t),D(this,"_colors",t)}convert(t){let e=Me(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return h._colorsMapping.get(s);return e}getHexCode(t){let e=this._colors.get(t);return e?x.makeHexColor(...e):t}},Ot=class h{#t=new AbortController;#e=null;#s=null;#i=new Map;#n=new Map;#a=null;#r=null;#o=null;#l=null;#h=null;#u=new $s;#d=null;#f=null;#g=null;#m=0;#c=new Set;#p=null;#b=null;#y=new Set;_editorUndoBar=null;#A=!1;#w=!1;#E=!1;#S=null;#_=null;#x=null;#M=null;#k=!1;#T=null;#I=new Us;#D=!1;#L=!1;#U=!1;#O=null;#F=null;#j=null;#N=null;#G=null;#C=O.NONE;#v=new Set;#B=null;#$=null;#V=null;#q=null;#Y=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#R=[0,0];#W=null;#X=null;#tt=null;#et=null;#H=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=h.prototype,e=r=>r.#X.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){let{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return D(this,"_keyboardManager",new Lt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(a)&&!r.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,l,c,d,u,f,p,g,m){let b=this._signal=this.#t.signal;this.#X=t,this.#tt=e,this.#et=s,this.#o=i,this.#d=n,this.#$=r,this.#Y=o,this._eventBus=a;let y={signal:b,...xs};a.on("editingaction",this.onEditingAction.bind(this),y),a.on("pagechanging",this.onPageChanging.bind(this),y),a.on("scalechanging",this.onScaleChanging.bind(this),y),a.on("rotationchanging",this.onRotationChanging.bind(this),y),a.on("setpreference",this.onSetPreference.bind(this),y),a.on("switchannotationeditorparams",A=>this.updateParams(A.type,A.value),y),window.addEventListener("pointerdown",()=>{this.#L=!0},{capture:!0,signal:b}),window.addEventListener("pointerup",()=>{this.#L=!1},{capture:!0,signal:b}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:b}),this.#lt(),this.#pt(),this.#it(),this.#l=o.annotationStorage,this.#S=o.filterFactory,this.#V=l,this.#M=c||null,this.#A=d,this.#w=u,this.#E=f,this.#G=p||null,this.viewParameters={realScale:xt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=m!==!1,n?.setSidebarUiManager(this)}destroy(){this.#H?.resolve(),this.#H=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#n.values())t.destroy();this.#n.clear(),this.#i.clear(),this.#y.clear(),this.#N?.clear(),this.#e=null,this.#v.clear(),this.#u.destroy(),this.#o?.destroy(),this.#d?.destroy(),this.#$?.destroy(),this.#T?.hide(),this.#T=null,this.#j?.destroy(),this.#j=null,this.#s=null,this.#_&&(clearTimeout(this.#_),this.#_=null),this.#W&&(clearTimeout(this.#W),this.#W=null),this._editorUndoBar?.destroy(),this.#Y=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#G}get useNewAltTextFlow(){return this.#w}get useNewAltTextWhenAddingImage(){return this.#E}get hcmFilter(){return D(this,"hcmFilter",this.#V?this.#S.addHCMFilter(this.#V.foreground,this.#V.background):"none")}get direction(){return D(this,"direction",getComputedStyle(this.#X).direction)}get _highlightColors(){return D(this,"_highlightColors",this.#M?new Map(this.#M.split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return D(this,"highlightColors",null);let e=new Map,s=!!this.#V;for(let[i,n]of t){let r=i.endsWith("_HCM");if(s&&r){e.set(i.replace("_HCM",""),n);continue}!s&&!r&&e.set(i,n)}return D(this,"highlightColors",e)}get highlightColorNames(){return D(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#g=t}setMainHighlightColorPicker(t){this.#j=t}editAltText(t,e=!1){this.#o?.editAltText(this,t,e)}hasCommentManager(){return!!this.#d}editComment(t,e,s,i){this.#d?.showDialog(this,t,e,s,i)}selectComment(t,e){this.#n.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#d?.updateComment(t.getData())}updatePopupColor(t){this.#d?.updatePopupColor(t)}removeComment(t){this.#d?.removeComments([t.uid])}deleteComment(t,e){let s=()=>{t.comment=e},i=()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){this.#d?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#d?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#d?.dialogElement||null}async waitForEditorsRendered(t){if(this.#n.has(t-1))return;let{resolve:e,promise:s}=Promise.withResolvers(),i=n=>{n.pageNumber===t&&(this._eventBus.off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i,xs),await s}getSignature(t){this.#$?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#$}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...xs}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){t==="enableNewAltTextWhenAddingImage"&&(this.#E=e)}onPageChanging({pageNumber:t}){this.#m=t-1}deletePage(t){for(let e of this.getEditors(t))e.remove();this.#n.delete(t),this.#m===t&&(this.#m=0)}focusMainContainer(){this.#X.focus()}findParent(t,e){for(let s of this.#n.values()){let{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#tt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*xt.PDF_TO_CSS_UNITS;for(let e of this.#y)e.onScaleChanging();this.#g?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#Z({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#st(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let s of this.#n.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t="",e=!1){let s=document.getSelection();if(!s||s.isCollapsed)return;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a}=s,o=s.toString(),c=this.#Z(s).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;s.empty();let u=this.#st(c),f=this.#C===O.NONE,p=()=>{let g=u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a,text:o});f&&this.showAllEditors("highlight",!0,!0),e&&g?.editComment()};if(f){this.switchToMode(O.HIGHLIGHT,p);return}p()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#at(){let t=document.getSelection();if(!t||t.isCollapsed)return;let s=this.#Z(t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#T||=new Hs(this),this.#T.show(s,i,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#l)return null;let e=`${Wt}${t}`,s=this.#l.getRawValue(e);return s&&this.#l.remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&this.#l&&!this.#l.has(t.id)&&this.#l.setValue(t.id,t)}a11yAlert(t,e=null){let s=this.#et;s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}#ot(){let t=document.getSelection();if(!t||t.isCollapsed){this.#B&&(this.#T?.hide(),this.#B=null,this.#P({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#B)return;let i=this.#Z(t).closest(".textLayer");if(!i){this.#B&&(this.#T?.hide(),this.#B=null,this.#P({hasSelectedText:!1}));return}if(this.#T?.hide(),this.#B=e,this.#P({hasSelectedText:!0}),!(this.#C!==O.HIGHLIGHT&&this.#C!==O.NONE)&&(this.#C===O.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#k=this.isShiftKeyDown,!this.isShiftKeyDown)){let n=this.#C===O.HIGHLIGHT?this.#st(i):null;if(n?.toggleDrawing(),this.#L){let r=new AbortController,a=this.combinedSignal(r),o=l=>{l.type==="pointerup"&&l.button!==0||(r.abort(),n?.toggleDrawing(!0),l.type==="pointerup"&&this.#Q("main_toolbar"))};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}else n?.toggleDrawing(!0),this.#Q("main_toolbar")}}#Q(t=""){this.#C===O.HIGHLIGHT?this.highlightSelection(t):this.#A&&this.#at()}#lt(){document.addEventListener("selectionchange",this.#ot.bind(this),{signal:this._signal})}#ht(){if(this.#x)return;this.#x=new AbortController;let t=this.combinedSignal(this.#x);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ct(){this.#x?.abort(),this.#x=null}blur(){if(this.isShiftKeyDown=!1,this.#k&&(this.#k=!1,this.#Q("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#v)if(e.div.contains(t)){this.#F=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#F)return;let[t,e]=this.#F;this.#F=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#it(){if(this.#O)return;this.#O=new AbortController;let t=this.combinedSignal(this.#O);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#dt(){this.#O?.abort(),this.#O=null}#ut(){if(this.#f)return;this.#f=new AbortController;let t=this.combinedSignal(this.#f);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})}#ft(){this.#f?.abort(),this.#f=null}#pt(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#it(),this.setEditingState(!0)}removeEditListeners(){this.#dt(),this.setEditingState(!1)}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let s of this.#b)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let s of this.#b)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let s of this.#v){let i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let n of e.items)for(let r of this.#b)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){R(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();let i=this.currentLayer;try{let n=[];for(let o of s){let l=await i.deserialize(o);if(!l)return;n.push(l)}let r=()=>{for(let o of n)this.#nt(o);this.#rt(n)},a=()=>{for(let o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){R(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==O.NONE&&!this.isEditorHandlingKeyboard&&h._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#k&&(this.#k=!1,this.#Q("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(t,e){for(let i of this.#r.get(t)||[])i.pageIndex=e;let s=this.#a.get(t);s&&(s.pageIndex=e,this.#n.set(e,s),this.#D?s.enable():s.disable())}startUpdatePages(){this.#a=new Map(this.#n),this.#n.clear();let t=this.#r=new Map,e=s=>{t.getOrInsertComputed(s.pageIndex,Zt).push(s)};for(let s of this.#i.values())e(s);for(let[s,i]of this.#l)s.startsWith(Wt)&&!this.#i.has(s)&&Number.isInteger(i?.pageIndex)&&e(i)}endUpdatePages(){this.#a=null,this.#r=null}clonePage(t,e){for(let s of this.getEditors(t)){let i=s.serialize(s.mode!==O.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,this.#l.setValue(i.id,i))}}findClonesForPage(t){let e=[],{pageIndex:s}=t;for(let[i,n]of this.#l)n.pageIndex===s&&n.isClone&&(this.#l.remove(i),e.push(t.deserialize(n).then(r=>{r&&(r.isClone=!0,t.addOrRebuild(r))})));return Promise.all(e)}#P(t){Object.entries(t).some(([s,i])=>this.#K[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#C===O.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#z([[B.HIGHLIGHT_FREE,!0]]))}#z(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#ht(),this.#ut(),this.#P({isEditing:this.#C!==O.NONE,isEmpty:this.#J(),hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ct(),this.#ft(),this.#P({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#b){this.#b=t;for(let e of this.#b)this.#z(e.defaultPropertiesToUpdate)}}getId(){return this.#I.id}get currentLayer(){return this.#n.get(this.#m)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#m}addLayer(t){this.#n.set(t.pageIndex,t),this.#D?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,n=!1,r=!1){if(this.#C!==t&&!(this.#H&&(await this.#H.promise,!this.#H))){if(this.#H=Promise.withResolvers(),this.#g?.commitOrRemove(),this.#C===O.POPUP&&this.#d?.hideSidebar(),this.#d?.destroyPopup(),this.#C=t,t===O.NONE){this.setEditingState(!1),this.#mt();for(let a of this.#i.values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#H.resolve();return}for(let a of this.#i.values())a.addStandaloneCommentButton();t===O.SIGNATURE&&await this.#$?.loadSignatures(),s&&it.clearPointerType(),this.setEditingState(!0),await this.#gt(),this.unselectAll();for(let a of this.#n.values())a.updateMode(t);if(t===O.POPUP){this.#s||=await this.#Y.getAnnotationsByType(new Set(this.#b.map(l=>l._editorType)));let a=new Set,o=[];for(let l of this.#i.values()){let{annotationElementId:c,hasComment:d,deleted:u}=l;c&&a.add(c),d&&!u&&o.push(l.getData())}for(let l of this.#s){let{id:c,popupRef:d,contentsObj:u}=l;d&&u?.str&&!a.has(c)&&!this.#c.has(c)&&o.push(l)}this.#d?.showSidebar(o)}if(!e){i&&this.addNewEditorFromKeyboard(),this.#H.resolve();return}for(let a of this.#i.values())a.uid===e?(this.setSelected(a),r?a.editComment():n?a.enterInEditMode():a.focus()):a.unselect();this.#H.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#b){switch(t){case B.CREATE:this.currentLayer.addNewEditor(e);return;case B.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#q||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(let s of this.#v)s.updateParams(t,e);else for(let s of this.#b)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(let n of this.#i.values())n.editorType===t&&n.show(e);(this.#q?.get(B.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#z([[B.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#U!==t){this.#U=t;for(let e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#gt(){if(!this.#D){this.#D=!0;let t=[];for(let e of this.#n.values())t.push(e.enable());await Promise.all(t);for(let e of this.#i.values())e.enable()}}#mt(){if(this.unselectAll(),this.#D){this.#D=!1;for(let t of this.#n.values())t.disable();for(let t of this.#i.values())t.disable()}}*getEditors(t){for(let e of this.#i.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#i.get(t)}addEditor(t){this.#i.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.focusMainContainer(),this.#_=null},0)),this.#i.delete(t.id),t.annotationElementId&&this.#N?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!this.#c.has(t.annotationElementId))&&this.#l?.remove(t.id)}addDeletedAnnotationElement(t){this.#c.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#c.has(t)}removeDeletedAnnotationElement(t){this.#c.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#nt(t){let e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#z(t.propertiesToUpdate))}get#bt(){let t=null;for(t of this.#v);return t}updateUI(t){this.#bt===t&&this.#z(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#z(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#v.has(t)){this.#v.delete(t),t.unselect(),this.#P({hasSelectedEditor:this.hasSelection});return}this.#v.add(t),t.select(),this.#z(t.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#g?.commitOrRemove();for(let e of this.#v)e!==t&&e.unselect();this.#d?.destroyPopup(),this.#v.clear(),this.#v.add(t),t.select(),this.#z(t.propertiesToUpdate),this.#P({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#v.values().next().value}unselect(t){t.unselect(),this.#v.delete(t),this.#P({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#u.undo(),this.#P({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#J()}),this._editorUndoBar?.hide()}redo(){this.#u.redo(),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#J()})}addCommands(t){this.#u.add(t),this.#P({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#J()})}cleanUndoStack(t){this.#u.cleanType(t)}#J(){if(this.#i.size===0)return!0;if(this.#i.size===1)for(let t of this.#i.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#v],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(let n of e)n.remove()},i=()=>{for(let n of e)this.#nt(n)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#rt(t){for(let e of this.#v)e.unselect();this.#v.clear();for(let e of t)e.isEmpty()||(this.#v.add(e),e.select());this.#P({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#v)t.commit();this.#rt(this.#i.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==O.NONE))&&!this.#g?.commitOrRemove()&&(this.#d?.destroyPopup(),!!this.hasSelection)){for(let t of this.#v)t.unselect();this.#v.clear(),this.#P({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#R[0]+=t,this.#R[1]+=e;let[i,n]=this.#R,r=[...this.#v],a=1e3;this.#W&&clearTimeout(this.#W),this.#W=setTimeout(()=>{this.#W=null,this.#R[0]=this.#R[1]=0,this.addCommands({cmd:()=>{for(let o of r)this.#i.has(o.id)&&(o.translateInPage(i,n),o.translationDone())},undo:()=>{for(let o of r)this.#i.has(o.id)&&(o.translateInPage(-i,-n),o.translationDone())},mustExec:!1})},a);for(let o of r)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#p=new Map;for(let t of this.#v)this.#p.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#p)return!1;this.disableUserSelect(!1);let t=this.#p;this.#p=null;let e=!1;for(let[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;let s=(i,n,r,a)=>{if(this.#i.has(i.id)){let o=this.#n.get(a);o?i._setParentAndPosition(o,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(let[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(let[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#p)for(let s of this.#p.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){let e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#v.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}isEditingMode(){return this.#C!==O.NONE}get imageManager(){return D(this,"imageManager",new Gs)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let l=0,c=e.rangeCount;l<c;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;let{x:s,y:i,width:n,height:r}=t.getBoundingClientRect(),a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,c,d,u)=>({x:(c-i)/r,y:1-(l+d-s)/n,width:u/r,height:d/n});break;case"180":a=(l,c,d,u)=>({x:1-(l+d-s)/n,y:1-(c+u-i)/r,width:d/n,height:u/r});break;case"270":a=(l,c,d,u)=>({x:1-(c+u-i)/r,y:(l-s)/n,width:u/r,height:d/n});break;default:a=(l,c,d,u)=>({x:(l-s)/n,y:(c-i)/r,width:d/n,height:u/r});break}let o=[];for(let l=0,c=e.rangeCount;l<c;l++){let d=e.getRangeAt(l);if(!d.collapsed)for(let{x:u,y:f,width:p,height:g}of d.getClientRects())p===0||g===0||o.push(a(u,f,p,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#h||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#h?.delete(t)}renderAnnotationElement(t){let e=this.#h?.get(t.data.id);if(!e)return;let s=this.#l.getRawValue(e);s&&(this.#C===O.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){let i=this.#N?.get(t);i&&(i.setCanvas(e,s),this.#N.delete(t))}addMissingCanvas(t,e){(this.#N||=new Map).set(t,e)}},ze=class h{#t=null;#e=!1;#s=null;#i=null;#n=null;#a=null;#r=!1;#o=null;#l=null;#h=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#l=t,this.#d=t._uiManager.useNewAltTextFlow,h.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){h._l10n??=t}async render(){let t=this.#s=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#i=document.createElement("span");t.append(e),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",h.#f.missing),e.setAttribute("data-l10n-id",h.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let s=this.#l._uiManager._signal;t.addEventListener("contextmenu",ft,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});let i=n=>{n.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#d&&this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#g}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#r=!0,i(n))},{signal:s}),await this.#m(),t}get#g(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#s&&(this.#s.focus({focusVisible:this.#r}),this.#r=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#h:this.isEmpty()}get guessedText(){return this.#h}async setGuessedText(t){this.#t===null&&(this.#h=t,this.#u=await h._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#m())}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){let e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#l.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#h===e&&(e=this.#u),{altText:e,decorative:this.#e,guessedText:this.#h,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(this.#h=s,this.#u=i),!(this.#t===t&&this.#e===e)&&(n||(this.#t=t,this.#e=e),this.#m())}toggle(t=!1){this.#s&&(!t&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#s.disabled=!t)}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#g}})}destroy(){this.#s?.remove(),this.#s=null,this.#i=null,this.#n=null,this.#o?.remove(),this.#o=null}async#m(){let t=this.#s;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",h.#f[this.#g]),this.#i?.setAttribute("data-l10n-id",h.#f[`${this.#g}-label`]),!this.#t){this.#n?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#l.id}`;let i=100,n=this.#l._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#a=setTimeout(()=>{this.#a=null,this.#n.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:n}),t.addEventListener("mouseleave",()=>{this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n?.classList.remove("show")},{signal:n})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#l.getElementForAltText()?.setAttribute("aria-describedby",e.id)}},jt=class{#t=null;#e=null;#s=!1;#i=null;#n=null;#a=null;#r=null;#o=null;#l=!1;#h=null;constructor(t){this.#i=t}renderForToolbar(){let t=this.#e=document.createElement("button");return t.className="comment",this.#u(t,!1)}renderForStandalone(){let t=this.#t=document.createElement("button");t.className="annotationCommentButton";let e=this.#i.commentButtonPosition;if(e){let{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#i._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let i=this.#i.commentButtonColor;i&&(s.backgroundColor=i)}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;let t=this.#i.commentButtonColor;t&&(this.#t.style.backgroundColor=t),this.#i._uiManager.updatePopupColor(this.#i)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#i.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#h)return this.#h;if(!this.#t)return null;let{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:i,y:n,width:r,height:a}=this.#i.parent.boundingClientRect;return[(t-i)/r,(e+s-n)/a]}set commentPopupPositionInLayer(t){this.#h=t}hasDefaultPopupPosition(){return this.#h===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t&&(this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e)}#u(t,e){if(!this.#i._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#i._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));let s=this.#i._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",ft,{signal:s}),e&&(t.addEventListener("focusin",n=>{this.#i._focusEventsAllowed=!1,Z(n)},{capture:!0,signal:s}),t.addEventListener("focusout",n=>{this.#i._focusEventsAllowed=!0,Z(n)},{capture:!0,signal:s})),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});let i=n=>{n.preventDefault(),t===this.#e?this.edit():this.#i.toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#s=!0,i(n))},{signal:s}),t.addEventListener("pointerenter",()=>{this.#i.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#i.toggleComment(!1,!1)},{signal:s}),t}edit(t){let e=this.commentPopupPositionInLayer,s,i;if(e)[s,i]=e;else{[s,i]=this.#i.commentButtonPosition;let{width:c,height:d,x:u,y:f}=this.#i;s=u+s*c,i=f+i*d}let n=this.#i.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;this.#i._uiManager.editComment(this.#i,r+s*o,a+i*l,{...t,parentDimensions:n})}finish(){this.#e&&(this.#e.focus({focusVisible:this.#s}),this.#s=!1)}isDeleted(){return this.#l||this.#r===""}isEmpty(){return this.#r===null}hasBeenEdited(){return this.isDeleted()||this.#r!==this.#n}serialize(){return this.data}get data(){return{text:this.#r,richText:this.#a,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#r&&(this.#a=null),t===null){this.#r="",this.#l=!0;return}this.#r=t,this.#o=new Date,this.#l=!1}restoreData({text:t,richText:e,date:s}){this.#r=t,this.#a=e,this.#o=s,this.#l=!1}setInitialText(t,e=null){this.#n=t,this.data=t,this.#o=null,this.#a=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#r="",this.#a=null,this.#o=null,this.#i=null,this.#s=!1,this.#l=!1}};function Cn(h){h.preventDefault()}var Tn=1e-4;function Cs(h){return h.cancelable?(Z(h),!0):(h.stopPropagation(),!1)}var je=class{#t;#e=!1;#s=null;#i;#n;#a;#r;#o;#l=!1;#h=null;#u;#d=new Set;#f=null;#g;#m=null;#c=0;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,onPanning:a=null,signal:o}){this.#t=t,this.#s=s,this.#i=e,this.#n=i,this.#a=n,this.#r=r,this.#o=a,this.#g=new AbortController,this.#u=AbortSignal.any([o,this.#g.signal]),t.addEventListener("touchstart",this.#p.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/yt.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/yt.pixelRatio}#p(t){if(this.#i?.())return;this.#y(t);let e=this.#d;for(let{identifier:s}of t.changedTouches)e.add(s);if(e.size===1){this.#b();return}if(!this.#m){this.#m=new AbortController;let s=AbortSignal.any([this.#u,this.#m.signal]),i=this.#t,n={signal:s,capture:!1,passive:!1};i.addEventListener("touchmove",this.#E.bind(this),n);let r=this.#S.bind(this);i.addEventListener("touchend",r,n),i.addEventListener("touchcancel",r,n),n.capture=!0,i.addEventListener("pointerdown",Z,n),i.addEventListener("pointermove",Z,n),i.addEventListener("pointercancel",Cn,n),i.addEventListener("pointerup",Cn,n),this.#n?.()}this.#l=Cs(t),this.#w(t)}#b(){if(this.#h)return;let t=this.#h=new AbortController,e=AbortSignal.any([this.#u,t.signal]),s=this.#t,i={capture:!0,signal:e,passive:!1},n=r=>{r.pointerType==="touch"&&(this.#h?.abort(),this.#h=null)};s.addEventListener("pointerdown",r=>{r.pointerType==="touch"&&(Z(r),n(r))},i),s.addEventListener("pointerup",n,i),s.addEventListener("pointercancel",n,i)}#y(t){let e=this.#d;if(e.size===0)return;let s=this.#d=new Set;for(let{identifier:i}of t.touches)e.has(i)&&s.add(i)}#A(t){let e=this.#d,s=[];for(let i of t.touches)e.has(i.identifier)&&s.push(i);return s}#w(t){let e=this.#A(t);if(e.length!==2||this.#s?.()){this.#f=null;return}let[s,i]=e;this.#f={touch0X:s.screenX,touch0Y:s.screenY,touch1X:i.screenX,touch1Y:i.screenY,panX:(s.clientX+i.clientX)/2,panY:(s.clientY+i.clientY)/2,screenPanX:(s.screenX+i.screenX)/2,screenPanY:(s.screenY+i.screenY)/2}}#E(t){if(!this.#f)return;let e=this.#A(t);if(e.length!==2)return;let s=this.#l;if(this.#l=Cs(t),!this.#l)return;if(!s){this.#w(t);return}let[i,n]=e,{screenX:r,screenY:a}=i,{screenX:o,screenY:l}=n,c=this.#f,{touch0X:d,touch0Y:u,touch1X:f,touch1Y:p,panX:g,panY:m}=c,b=f-d,y=p-u,A=o-r,v=l-a,w=(i.clientX+n.clientX)/2,S=(i.clientY+n.clientY)/2;c.panX=w,c.panY=S;let E=w-g,_=S-m,C=(r+o)/2,k=(a+l)/2,P=Math.hypot(C-c.screenPanX,k-c.screenPanY);c.screenPanX=C,c.screenPanY=k;let M=Math.hypot(A,v),F=Math.hypot(b,y),N=this.#e?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*P;if(M<Tn||F<Tn||Math.abs(F-M)<=N){(E||_)&&this.#o?.(E,_);return}c.touch0X=r,c.touch0Y=a,c.touch1X=o,c.touch1Y=l;let V=Math.sign(M-F);if(!this.#e){this.#e=!0,this.#c=V,(E||_)&&this.#o?.(E,_);return}if(this.#c){let I=this.#c;if(this.#c=0,V!==I&&Math.abs(M-F)<=2*P){this.#e=!1,(E||_)&&this.#o?.(E,_);return}}this.#a?.([g,m],F,M,E,_)}#S(t){if(this.#y(t),this.#d.size>=2){this.#w(t);return}let e=!!this.#f;this.#_(),this.#d.size===1&&this.#b(),e&&Cs(t)}#_(){this.#f=null,this.#e=!1,this.#c=0,this.#l=!1,this.#m&&(this.#m.abort(),this.#m=null,this.#r?.())}destroy(){this.#_(),this.#d.clear(),this.#g?.abort(),this.#g=null,this.#h?.abort(),this.#h=null}},G=class h{#t=null;#e=null;#s=null;#i=null;#n=null;#a=!1;#r=null;#o="";#l=null;#h=null;#u=null;#d=null;#f=null;#g="";#m=!1;#c=null;#p=!1;#b=!1;#y=!1;#A=null;#w=0;#E=0;#S=null;#_=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#x=!1;#M=h._zIndex++;static _borderLineWidth=-1;static _colorManager=new zs;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=h.prototype._resizeWithKeyboard,e=Ot.TRANSLATE_SMALL,s=Ot.TRANSLATE_BIG;return D(this,"_resizerKeyboardManager",new Lt([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],h.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;let{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];let[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return D(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new js({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(h._l10n??=t,h._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),h._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"}),h._borderLineWidth!==-1)return;let s=getComputedStyle(document.documentElement);h._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){H("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#x}set _isDraggable(t){this.#x=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#M}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#R(),this.#d?.remove(),this.#d=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){let[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}let[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}#k([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#k(this.parentDimensions,t,e)}translateInPage(t,e){this.#c||=[this.x,this.y,this.width,this.height],this.#k(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#c||=[this.x,this.y,this.width,this.height];let{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:d,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this,[o,l]=this.getBaseTranslation();r+=o,a+=l;let{style:c}=s;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#c&&(this.#c[0]!==this.x||this.#c[1]!==this.y)}get _hasBeenResized(){return!!this.#c&&(this.#c[2]!==this.width||this.#c[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:s}=h,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[s,i]}=this,{x:n,y:r,width:a,height:o}=this;if(a*=s,o*=i,n*=s,r*=i,this._mustFixPosition)switch(t){case 0:n=j(n,0,s-a),r=j(r,0,i-o);break;case 90:n=j(n,0,s-o),r=j(r,a,i);break;case 180:n=j(n,a,s),r=j(r,o,i);break;case 270:n=j(n,o,s),r=j(r,0,i-a);break}this.x=n/=s,this.y=r/=i;let[l,c]=this.getBaseTranslation();n+=l,r+=c,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#T(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return h.#T(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return h.#T(t,e,360-this.parentRotation)}#I(t){switch(t){case 90:{let[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){let{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#D(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let s of t){let i=document.createElement("div");this.#l.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#L.bind(this,s),{signal:e}),i.addEventListener("contextmenu",ft,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#l)}#L(t,e){e.preventDefault();let{isMac:s}=U.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);let i=this._isDraggable;this._isDraggable=!1,this.#h=[e.screenX,e.screenY];let n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#F.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Z,{passive:!1,signal:r}),window.addEventListener("contextmenu",ft,{signal:r}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#O()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#U(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#O(){if(!this.#u)return;let{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;let n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===s&&o===i||this.addCommands({cmd:this.#U.bind(this,n,r,a,o),undo:this.#U.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#F(t,e){let[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=h.MIN_SIZE/s,c=h.MIN_SIZE/i,d=this.#I(this.rotation),u=(I,L)=>[d[0]*I+d[2]*L,d[1]*I+d[3]*L],f=this.#I(360-this.rotation),p=(I,L)=>[f[0]*I+f[2]*L,f[1]*I+f[3]*L],g,m,b=!1,y=!1;switch(t){case"topLeft":b=!0,g=(I,L)=>[0,0],m=(I,L)=>[I,L];break;case"topMiddle":g=(I,L)=>[I/2,0],m=(I,L)=>[I/2,L];break;case"topRight":b=!0,g=(I,L)=>[I,0],m=(I,L)=>[0,L];break;case"middleRight":y=!0,g=(I,L)=>[I,L/2],m=(I,L)=>[0,L/2];break;case"bottomRight":b=!0,g=(I,L)=>[I,L],m=(I,L)=>[0,0];break;case"bottomMiddle":g=(I,L)=>[I/2,L],m=(I,L)=>[I/2,0];break;case"bottomLeft":b=!0,g=(I,L)=>[0,L],m=(I,L)=>[I,0];break;case"middleLeft":y=!0,g=(I,L)=>[0,L/2],m=(I,L)=>[I,L/2];break}let A=g(a,o),v=m(a,o),w=u(...v),S=h._round(n+w[0]),E=h._round(r+w[1]),_=1,C=1,k,P;if(e.fromKeyboard)({deltaX:k,deltaY:P}=e);else{let{screenX:I,screenY:L}=e,[et,st]=this.#h;[k,P]=this.screenToPageTranslation(I-et,L-st),this.#h[0]=I,this.#h[1]=L}if([k,P]=p(k/s,P/i),b){let I=Math.hypot(a,o);_=C=Math.max(Math.min(Math.hypot(v[0]-A[0]-k,v[1]-A[1]-P)/I,1/a,1/o),l/a,c/o)}else y?_=j(Math.abs(v[0]-A[0]-k),l,1)/a:C=j(Math.abs(v[1]-A[1]-P),c,1)/o;let M=h._round(a*_),F=h._round(o*C);w=u(...m(M,F));let N=S-w[0],V=E-w[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=M,this.height=F,this.x=N,this.y=V,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#s?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#b)return this._editToolbar;this._editToolbar=new Bs(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#s?.destroy()}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#s||(ze.initialize(h._l10n),this.#s=new ze(this),this.#t&&(this.#s.data=this.#t,this.#t=null)),this.#s}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}get guessedAltText(){return this.#s?.guessedText}async setGuessedAltText(t){await this.#s?.setGuessedText(t)}serializeAltText(t){return this.#s?.serialize(t)}hasAltText(){return!!this.#s&&!this.#s.isEmpty()}hasAltTextData(){return this.#s?.hasData()??!1}focusCommentButton(){this.#i?.focusButton()}addCommentButton(){return this.canAddComment?this.#i||=new jt(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#n){this._uiManager.isEditingMode()&&this.#n.classList.remove("hidden");return}this.hasComment&&(this.#n=this.#i.renderForStandalone(),this.div.append(this.#n))}}removeStandaloneCommentButton(){this.#i.removeStandaloneCommentButton(),this.#n=null}hideStandaloneCommentButton(){this.#n?.classList.add("hidden")}get comment(){if(!this.#i)return null;let{data:{richText:t,text:e,date:s,deleted:i}}=this.#i;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#i||=new jt(this),typeof t=="object"&&t!==null?this.#i.restoreData(t):this.#i.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:s}){if(!e||(this.#i||=new jt(this),this.#i.setInitialText(t,s),!this.annotationElementId))return;let i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#i?.hasBeenEdited()}get hasDeletedComment(){return this.#i?.isDeleted()}get hasComment(){return!!this.#i&&!this.#i.isEmpty()&&!this.#i.isDeleted()}async editComment(t){this.#i||=new jt(this),this.#i.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#i.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,i]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,a=r+n+1,o=i-100,l=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#i.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#a?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#B();let[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);let[i,n]=this.getInitialTranslation();return this.translate(i,n),tr(this,t,["keydown","pointerdown","dblclick"]),this.#$(),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#j(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#s?.toggle(!1),this.parent.togglePointerEvents(!1)}#N(t,e,s){let n=.7*(s/e)+1-.7;if(n===1)return;let r=this.#I(this.rotation),a=(S,E)=>[r[0]*S+r[2]*E,r[1]*S+r[3]*E],[o,l]=this.parentDimensions,c=this.x,d=this.y,u=this.width,f=this.height,p=h.MIN_SIZE/o,g=h.MIN_SIZE/l;n=Math.max(Math.min(n,1/u,1/f),p/u,g/f);let m=h._round(u*n),b=h._round(f*n);if(m===u&&b===f)return;this.#c||=[c,d,u,f];let y=a(u/2,f/2),A=h._round(c+y[0]),v=h._round(d+y[1]),w=a(m/2,b/2);this.x=A-w[0],this.y=v-w[1],this.width=m,this.height=b,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#G(){this.#s?.toggle(!0),this.parent.togglePointerEvents(!0),this.#O()}pointerdown(t){let{isMac:e}=U.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#v(t);return}this.#C(t)}#C(t){let{isMac:e}=U.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#v(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1,i=new AbortController,n=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:n},a=l=>{i.abort(),this.#r=null,this.#m=!1,this._uiManager.endDragSession()||this.#C(l),s&&this._onStopDragging()};e&&(this.#w=t.clientX,this.#E=t.clientY,this.#r=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",l=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:c,clientY:d,pointerId:u}=l;if(u!==this.#r){Z(l);return}let[f,p]=this.screenToPageTranslation(c-this.#w,d-this.#E);this.#w=c,this.#E=d,this._uiManager.dragSelectedEditors(f,p),this.div.scrollIntoView({block:"nearest"})},r),window.addEventListener("touchmove",Z,r),window.addEventListener("pointerdown",l=>{l.pointerType===this.#o&&(this.#_||l.isPrimary)&&a(l),Z(l)},r));let o=l=>{if(!this.#r||this.#r===l.pointerId){a(l);return}Z(l)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#A&&clearTimeout(this.#A),this.#A=setTimeout(()=>{this.#A=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){let i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/i,c=e/i,d=this.x*n,u=this.y*r,f=this.width*n,p=this.height*r;switch(s){case 0:return[d+l+a,r-u-c-p+o,d+l+f+a,r-u-c+o];case 90:return[d+c+a,r-u+l+o,d+c+p+a,r-u+l+f+o];case 180:return[d-l-f+a,r-u+c+o,d-l+a,r-u+c+p+o];case 270:return[d-c-p+a,r-u-l-f+o,d-c+a,r-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&h._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#i?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:s,opacity:i,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:c}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:s||c,popupRef:!n,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#b=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#b=!1,!0):!1}isInEditMode(){return this.#b}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}#B(){if(this.#f||!this.div)return;this.#f=new AbortController;let t=this._uiManager.combinedSignal(this.#f);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}#$(){this.#_||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||(this.#_=new je({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#j.bind(this),onPinching:this.#N.bind(this),onPinchEnd:this.#G.bind(this),signal:this._uiManager._signal}))}rebuild(){this.#B(),this.#$()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,s){let i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,i.#t=t.accessibilityData,i._isCopy=t.isCopy||!1;let[n,r]=i.pageDimensions,[a,o,l,c]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=l/n,i.height=c/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.#_?.destroy(),this.#_=null,this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#A&&(clearTimeout(this.#A),this.#A=null),this.#R(),this.removeEditToolbar(),this.#S){for(let t of this.#S.values())clearTimeout(t);this.#S=null}this.parent=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#D(),this.#l.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[s,i,n,r]=this.getPDFRect();return[h._round(s+(n-s)*t),h._round(i+(r-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#i.commentPopupPositionInLayer}set commentPopupPosition(t){this.#i.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#i.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#i.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#i?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#l.children;if(!this.#e){this.#e=Array.from(e);let r=this.#V.bind(this),a=this.#q.bind(this),o=this._uiManager._signal;for(let l of this.#e){let c=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#Y.bind(this,c),{signal:o}),l.setAttribute("data-l10n-id",h._l10nResizer[c])}}let s=this.#e[0],i=0;for(let r of e){if(r===s)break;i++}let n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#l.append(this.#l.firstElementChild);else if(n>i)for(let a=0;a<n-i;a++)this.#l.firstElementChild.before(this.#l.lastElementChild);let r=0;for(let a of e){let l=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",h._l10nResizer[l])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#V(t){h._resizerKeyboardManager.exec(this,t)}#q(t){this.#y&&t.relatedTarget?.parentNode!==this.#l&&this.#R()}#Y(t){this.#g=this.#y?t:""}#K(t){if(this.#e)for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#y&&this.#F(this.#g,{deltaX:t,deltaY:e,fromKeyboard:!0})}#R(){this.#y=!1,this.#K(-1),this.#O()}_stopResizingWithKeyboard(){this.#R(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#s?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#s?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#S||=new Map;let{action:s}=t,i=this.#S.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(s),this.#S.size===0&&(this.#S=null)},h._telemetryTimeout),this.#S.set(s,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(t){if(!this.#d&&!this.deleted){this.#d=t.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){let s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){let{firstElementChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}},js=class extends G{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},kn=3285377520,dt=4294901760,gt=65535,fe=class{constructor(t){this.h1=t?t&4294967295:kn,this.h2=t?t&4294967295:kn}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,m=t.length;g<m;g++){let b=t.charCodeAt(g);b<=255?e[s++]=b:(e[s++]=b>>>8,e[s++]=b&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");let i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i),a=0,o=0,l=this.h1,c=this.h2,d=3432918353,u=461845907,f=d>,p=u>for(let g=0;g<i;g++)g&1?(a=r[g],a=a*d&dt|a*f>,a=a<<15|a>>>17,a=a*u&dt|a*p>,l^=a,l=l<<13|l>>>19,l=l*5+3864292196):(o=r[g],o=o*d&dt|o*f>,o=o<<15|o>>>17,o=o*u&dt|o*p>,c^=o,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&dt|a*f>,a=a<<15|a>>>17,a=a*u&dt|a*p>,i&1?l^=a:c^=a}this.h1=l,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&dt|t*36045>,e=e*4283543511&dt|((e<<16|t>>>16)*2950163797&dt)>>>16,t^=e>>>1,t=t*444984403&dt|t*60499>,e=e*3301882366&dt|((e<<16|t>>>16)*3120437893&dt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}},pe=Object.freeze({map:null,hash:"",transfer:void 0}),ge=class{#t=!1;#e=null;#s=null;#i=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){let s=this.#i.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#i.get(t)}remove(t){let e=this.#i.get(t);e!==void 0&&(e instanceof G&&this.#s.delete(e.annotationElementId),this.#i.delete(t),this.#i.size===0&&this.resetModified(),!this.#i.values().some(s=>s instanceof G)&&this.onAnnotationEditor?.(null))}setValue(t,e){let s=this.#i.get(t),i=!1;if(s!==void 0)for(let[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,this.#i.set(t,e);i&&this.#n(),e instanceof G&&((this.#s||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#i.has(t)}get size(){return this.#i.size}#n(){this.#t||(this.#t=!0,this.onSetModified?.())}resetModified(){this.#t&&(this.#t=!1,this.onResetModified?.())}get print(){return new Ve(this)}get serializable(){if(this.#i.size===0)return pe;let t=new Map,e=new fe,s=[],i=Object.create(null),n=!1;for(let[r,a]of this.#i){let o=a instanceof G?a.serialize(!1,i):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(let r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:pe}get editorStats(){let t=null,e=new Map,s=0,i=0;for(let n of this.#i.values()){if(!(n instanceof G)){n.popup&&(n.popup.deleted?i+=1:s+=1);continue}n.isCommentDeleted?i+=1:n.hasEditedComment&&(s+=1);let r=n.telemetryFinalData;if(!r)continue;let{type:a}=r;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(n).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[l,c]of Object.entries(r)){if(l==="type")continue;let d=o.getOrInsertComputed(l,yn);d.set(c,(d.get(c)??0)+1)}}if((i>0||s>0)&&(t||=Object.create(null),t.comments={deleted:i,edited:s}),!t)return null;for(let[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){let s=this.#s?.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){return this.#s?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;let t=[];if(this.#s)for(let s of this.#s.values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){let s=new fe;s.update(t.join(",")),e=s.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#i.entries()}},Ve=class extends ge{#t=pe;constructor(t){super();let{serializable:e}=t;if(e===pe)return;let{map:s,hash:i,transfer:n}=e,r=structuredClone(s,n?{transfer:n}:null);this.#t={map:r,hash:i,transfer:[]}}get print(){H("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return D(this,"modifiedIds",{ids:new Set,hash:""})}},Ut="__forcedDependency",{floor:Pn,ceil:Mn}=Math;function Dn(h,t,e,s,i,n){h[t*4+0]=Math.min(h[t*4+0],e),h[t*4+1]=Math.min(h[t*4+1],s),h[t*4+2]=Math.max(h[t*4+2],i),h[t*4+3]=Math.max(h[t*4+3],n)}function Lr(h,t,e,s,i){let n;h?(h<0&&(n=i[0],i[0]=i[2],i[2]=n),i[0]*=h,i[2]*=h,t<0&&(n=i[1],i[1]=i[3],i[3]=n),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}var Vs=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0],Ws=class{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===Vs}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}},In=(h,t)=>h?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1})),Xs=class{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#s=new Float64Array(vt);_pendingBBoxIdx=-1;#i;#n;#a;#r;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#i=t.width,this.#n=t.height,this.#o(e)}growOperationsCount(t){t>=this.#r.length&&this.#o(t,this.#r)}#o(t,e){let s=new ArrayBuffer(t*4);this.#a=new Uint8ClampedArray(s),this.#r=new Uint32Array(s),e&&e.length>0?(this.#r.set(e),this.#r.fill(Vs,e.length)):this.#r.fill(Vs)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){let s=Object.getPrototypeOf(this.#e);if(s===null)return this;this.#e=s;let i=this._savesStack.pop();return i!==void 0&&(e?.(i,t),this.#r[t]=this.#r[i]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){let s=this._savesStack.pop();return s!==void 0&&(e?.(s,t),this.#r[t]=this.#r[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){let s=this._markedContentStack.pop();return s!==void 0&&(e?.(s,t),this.#r[t]=this.#r[s]),this}pushBaseTransform(t){return this.#t.push(x.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){return this.#t.length>1&&this.#t.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#s.set(vt,0)),this}recordClipBox(t,e,s,i,n,r){let a=x.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=vt.slice();x.axialAlignedBoundingBox([s,n,i,r],a,o);let l=x.intersect(this.#e,o);return l?(this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3]):(this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0),this}recordBBox(t,e,s,i,n,r){let a=this.#e;if(a[0]===1/0)return this;let o=x.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return x.axialAlignedBoundingBox([s,n,i,r],o,this.#s),this;let l=vt.slice();return x.axialAlignedBoundingBox([s,n,i,r],o,l),this.#s[0]=j(l[0],a[0],this.#s[0]),this.#s[1]=j(l[1],a[1],this.#s[1]),this.#s[2]=j(l[2],this.#s[2],a[2]),this.#s[3]=j(l[3],this.#s[3],a[3]),this}recordFullPageBBox(t){return this.#s[0]=Math.max(0,this.#e[0]),this.#s[1]=Math.max(0,this.#e[1]),this.#s[2]=Math.min(this.#i,this.#e[2]),this.#s[3]=Math.min(this.#n,this.#e[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;let i=Pn(this.#s[0]*256/this.#i),n=Pn(this.#s[1]*256/this.#n),r=Mn(this.#s[2]*256/this.#i),a=Mn(this.#s[3]*256/this.#n);if(Dn(this.#a,t,i,n,r,a),s)for(let o of s)for(let l of o)l!==t&&Dn(this.#a,l,i,n,r,a);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#s[0]),this.#e[1]=Math.max(this.#e[1],this.#s[1]),this.#e[2]=Math.min(this.#e[2],this.#s[2]),this.#e[3]=Math.min(this.#e[3],this.#s[3])),this}take(){return new Ws(this.#r,this.#a)}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}},Ys=class{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[Ut]:[]};#s=new Map;#i=new Set;#n=new Map;#a;#r;#o;constructor(t,e=!1){this.#o=t,e&&(this.#a=new Map,this.#r=(s,i)=>{In(this.#a,i).dependencies.add(s)})}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[Ut]:{__proto__:this.#e[Ut]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#r);let e=Object.getPrototypeOf(this.#t);return e===null?this:(this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this)}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#r),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#r),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#r),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#s.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#s.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Ut,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)e in this.#t&&this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#i)this.recordFutureForcedDependency(Ut,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,s,i,n,r){return this.#o.recordClipBox(t,e,s,i,n,r),this}recordBBox(t,e,s,i,n,r){return this.#o.recordBBox(t,e,s,i,n,r),this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){let o=s.bbox,l,c;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#n.get(s),l!==!1&&(c=[0,0,0,0],x.axialAlignedBoundingBox(o,s.fontMatrix,c),(i!==1||n!==0||r!==0)&&Lr(i,-i,n,r,c),l)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!a)return this.recordFullPageBBox(t);let d=a();return o&&c&&l===void 0&&(l=c[0]<=n-d.actualBoundingBoxLeft&&c[2]>=n+d.actualBoundingBoxRight&&c[1]<=r-d.actualBoundingBoxAscent&&c[3]>=r+d.actualBoundingBoxDescent,this.#n.set(s,l),l)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,n-d.actualBoundingBoxLeft,n+d.actualBoundingBoxRight,r-d.actualBoundingBoxAscent,r+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){let s=this.#i,i=this.#t,n=this.#e;for(let r of e)r in this.#t?s.add(i[r]):r in n&&n[r].forEach(s.add,s);return this}recordNamedDependency(t,e){return this.#s.has(e)&&this.#i.add(this.#s.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Ut]),this.#a){let i=In(this.#a,t),{dependencies:n}=i;this.#i.forEach(n.add,n),this.#o._savesStack.forEach(n.add,n),this.#o._markedContentStack.forEach(n.add,n),n.delete(t),i.isRenderingOperation=!0}let s=!e&&t===this.#o._pendingBBoxIdx;return this.#o.recordOperation(t,e,[this.#i,this.#o._savesStack,this.#o._markedContentStack]),s&&this.#i.clear(),this}recordShowTextOperation(t,e=!1){let s=Array.from(this.#i);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(let i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){let s=!e&&t===this.#o._pendingBBoxIdx;return this.#o.bboxToClipBoxDropOperation(t),s&&this.#i.clear(),this}take(){return this.#n.clear(),this.#o.take()}takeDebugMetadata(){return this.#a}},me=class h{#t;#e;#s;#i=0;#n=0;constructor(t,e,s){if(t instanceof h&&t.#s===!!s)return t;this.#t=t,this.#e=e,this.#s=!!s}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#n++,this.#t.save(this.#e),this}restore(t){return this.#n>0&&(this.#t.restore(this.#e),this.#n--),this}recordOpenMarker(t){return this.#i++,this}getOpenMarker(){return this.#i>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#i--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#s||this.#t.resetBBox(this.#e),this}recordClipBox(t,e,s,i,n,r){return this.#s||this.#t.recordClipBox(this.#e,e,s,i,n,r),this}recordBBox(t,e,s,i,n,r){return this.#s||this.#t.recordBBox(this.#e,e,s,i,n,r),this}recordCharacterBBox(t,e,s,i,n,r,a){return this.#s||this.#t.recordCharacterBBox(this.#e,e,s,i,n,r,a),this}recordFullPageBBox(t){return this.#s||this.#t.recordFullPageBBox(this.#e),this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){return this.#s||this.#t.bboxToClipBoxDropOperation(this.#e,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}},ut={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},Ks=class h{#t;#e;#s=4;#i=0;#n=new h.#a(this.#s*6);static#a=U.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,s,i){if(this.#i===this.#s){this.#s*=2;let a=new h.#a(this.#s*6);a.set(this.#n),this.#n=a}let n=$(t),r;if(i[0]!==1/0){let a=vt.slice();x.axialAlignedBoundingBox([0,-s,e,0],n,a);let o=x.intersect(i,a);if(!o)return;let[l,c,d,u]=o;if(l!==a[0]||c!==a[1]||d!==a[2]||u!==a[3]){let f=Math.atan2(n[1],n[0]),p=Math.abs(Math.sin(f)),g=Math.abs(Math.cos(f));if(p<1e-6||g<1e-6||Math.abs(p-g)<1e-6)r=[l,c,l,u,d,c];else{let m=d-l,b=u-c,y=p*p,A=g*g,v=g*p,w=A-y,S=(b*A-m*v)/w,E=(b*v-m*y)/w;r=[l+E,c,l,c+S,d,u-S]}}}r||(r=[0,-s,0,0,e,-s],x.applyTransform(r,n,0),x.applyTransform(r,n,2),x.applyTransform(r,n,4)),r[0]/=this.#t,r[1]/=this.#e,r[2]/=this.#t,r[3]/=this.#e,r[4]/=this.#t,r[5]/=this.#e,this.#n.set(r,this.#i*6),this.#i++}take(){return this.#n.subarray(0,this.#i*6)}},Ln=new RegExp("\\p{Cc}","u");function Or(h){let t=h[0];if(h.length<2||t!=='"'&&t!=="'"||h.at(-1)!==t)return!1;let e=h.length-1;for(let s=1;s<e;s++){let i=h[s];if(i===t||Ln.test(i)||i==="\\"&&(++s>=e||Ln.test(h[s])))return!1}return!0}function On(h){return Or(h)?h:`"${h.replaceAll(/["\\\p{Cc}]/gu,e=>e==='"'||e==="\\"?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}var qs=class{#t=new Set;#e=null;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){let e=this.#s();e.insertRule(t,e.cssRules.length)}#s(){if(this.#e)return this.#e;let t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){let{adoptedStyleSheets:e}=this._document;if(e){let s=new t;return e.push(s),this.#e=s}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),this.#e=this.styleElement.sheet}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),this.#t.clear(),this.#e){let{adoptedStyleSheets:t}=this._document;t?.includes(this.#e)&&(this._document.adoptedStyleSheets=t.filter(e=>e!==this.#e)),this.#e=null}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||this.#t.has(t.loadedName))){if(K(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:n,style:r}=t,a=new FontFace(i,n,r);this.addNativeFontFace(a);try{await a.load(),this.#t.add(i),s?.(t)}catch{R(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}H("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){let s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw R(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{let i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){let t=!!this._document?.fonts;return D(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return D(this,"isSyncFontLoadingSupported",ht||U.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(K(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){let n=s.shift();setTimeout(n.callback,0)}}let{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){let t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return D(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(w,S){return w.charCodeAt(S)<<24|w.charCodeAt(S+1)<<16|w.charCodeAt(S+2)<<8|w.charCodeAt(S+3)&255}function i(w){return String.fromCharCode(w>>24&255,w>>16&255,w>>8&255,w&255)}function n(w,S,E,_){let C=w.substring(0,S),k=w.substring(S+E);return C+_+k}let r,a,o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),c=0;function d(w,S){if(++c>30){R("Load test font never loaded."),S();return}if(l.font="30px "+w,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){S();return}setTimeout(d.bind(null,w,S))}let u=`lt${Date.now()}${this.loadTestFontId++}`,f=this._loadTestFont;f=n(f,976,u.length,u);let g=16,m=1482184792,b=s(f,g);for(r=0,a=u.length-3;r<a;r+=4)b=b-m+s(u,r)|0;r<u.length&&(b=b-m+s(u+"XXX",r)|0),f=n(f,g,4,i(b));let y=`url(data:font/opentype;base64,${btoa(f)});`,A=`@font-face {font-family:"${u}";src:${y}}`;this.insertRule(A);let v=this._document.createElement("div");v.style.visibility="hidden",v.style.width=v.style.height="10px",v.style.position="absolute",v.style.top=v.style.left="0px";for(let w of[t.loadedName,u]){let S=this._document.createElement("span");S.textContent="Hi",S.style.fontFamily=w,v.append(S)}this._document.body.append(v),d(u,()=>{v.remove(),e.complete()})}},Qs=class{compiledGlyphs=Object.create(null);#t;constructor(t,e=null,s,i){this.#t=t,this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(On(this.cssFontInfo.fontFamily),this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:${On(this.cssFontInfo.fontFamily)};${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e,i;try{i=t.get(s)}catch(r){R(`getPathGenerator - ignoring character: "${r}".`)}let n=Zn(i?.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}get black(){return this.#t.black}get bold(){return this.#t.bold}get disableFontFace(){return this.#t.disableFontFace}set disableFontFace(t){D(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#t.fontExtraProperties}get isInvalidPDFjsFont(){return this.#t.isInvalidPDFjsFont}get isType3Font(){return this.#t.isType3Font}get italic(){return this.#t.italic}get missingFile(){return this.#t.missingFile}get remeasure(){return this.#t.remeasure}get vertical(){return this.#t.vertical}get ascent(){return this.#t.ascent}get defaultWidth(){return this.#t.defaultWidth}get descent(){return this.#t.descent}get bbox(){return this.#t.bbox}get fontMatrix(){return this.#t.fontMatrix}get fallbackName(){return this.#t.fallbackName}get loadedName(){return this.#t.loadedName}get mimetype(){return this.#t.mimetype}get name(){return this.#t.name}get data(){return this.#t.data}clearData(){this.#t.clearData()}get cssFontInfo(){return this.#t.cssFontInfo}get systemFontInfo(){return this.#t.systemFontInfo}get defaultVMetrics(){return this.#t.defaultVMetrics}},Js=class{static strings=["fontFamily","fontWeight","italicAngle"]},Zs=class{static strings=["css","loadedName","baseFontName","src"]},ot=class{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6},wt=class{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16},Yt=class{static get decoder(){return D(this,"decoder",new TextDecoder)}static get encoder(){return D(this,"encoder",new TextEncoder)}},ti=class{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){K(t<Js.strings.length,"Invalid string index");let{decoder:e}=Yt,s=0;for(let n=0;n<t;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,i))}get fontFamily(){return this.#s(0)}get fontWeight(){return this.#s(1)}get italicAngle(){return this.#s(2)}},ei=class{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}get guessFallback(){return this.#e.getUint8(0)!==0}#s(t){K(t<Zs.strings.length,"Invalid string index");let{decoder:e}=Yt,s=5;for(let n=0;n<t;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,i))}get css(){return this.#s(0)}get loadedName(){return this.#s(1)}get baseFontName(){return this.#s(2)}get src(){return this.#s(3)}get style(){let{decoder:t}=Yt,e=1;e+=4+this.#e.getUint32(e);let s=this.#e.getUint32(e),i=t.decode(new Uint8Array(this.#t,e+4,s));e+=4+s;let n=this.#e.getUint32(e),r=t.decode(new Uint8Array(this.#t,e+4,n));return{style:i,weight:r}}},si=class{#t;#e;constructor({buffer:t,extra:e}){this.#t=t,this.#e=new DataView(t),e&&Object.assign(this,e)}#s(t){K(t<ot.bools.length,"Invalid boolean index");let e=Math.floor(t/4),s=t*2%8,i=this.#e.getUint8(e)>>s&3;return i===0?void 0:i===2}get black(){return this.#s(0)}get bold(){return this.#s(1)}get disableFontFace(){return this.#s(2)}get fontExtraProperties(){return this.#s(3)}get isInvalidPDFjsFont(){return this.#s(4)}get isType3Font(){return this.#s(5)}get italic(){return this.#s(6)}get missingFile(){return this.#s(7)}get remeasure(){return this.#s(8)}get vertical(){return this.#s(9)}#i(t){return K(t<ot.numbers.length,"Invalid number index"),this.#e.getFloat64(ot.OFFSET_NUMBERS+t*8)}get ascent(){return this.#i(0)}get defaultWidth(){return this.#i(1)}get descent(){return this.#i(2)}#n(t,e,s,i){let n=this.#e.getUint8(t);if(n===0)return;K(n===e,"Invalid array length."),t+=1;let r=new Array(n);for(let a=0;a<n;a++)r[a]=this.#e[s](t,!0),t+=i;return r}get bbox(){return this.#n(ot.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#n(ot.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#n(ot.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#a(t){K(t<ot.strings.length,"Invalid string index");let{decoder:e}=Yt,s=ot.OFFSET_STRINGS+4;for(let n=0;n<t;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,i))}get fallbackName(){return this.#a(0)}get loadedName(){return this.#a(1)}get mimetype(){return this.#a(2)}get name(){return this.#a(3)}#r(){let t=ot.OFFSET_STRINGS,e=this.#e.getUint32(t);t+=4+e;let s=this.#e.getUint32(t);t+=4+s;let i=this.#e.getUint32(t);t+=4+i;let n=this.#e.getUint32(t);return{offset:t,length:n}}get data(){let{offset:t,length:e}=this.#r();return e===0?void 0:new Uint8Array(this.#t,t+4,e)}clearData(){let{offset:t,length:e}=this.#r();e!==0&&(this.#e.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#e=new DataView(this.#t))}get cssFontInfo(){let t=ot.OFFSET_STRINGS,e=this.#e.getUint32(t);t+=4+e;let s=this.#e.getUint32(t);t+=4+s;let i=this.#e.getUint32(t);if(i===0)return null;let n=new Uint8Array(i);return n.set(new Uint8Array(this.#t,t+4,i)),new ti(n.buffer)}get systemFontInfo(){let t=ot.OFFSET_STRINGS,e=this.#e.getUint32(t);t+=4+e;let s=this.#e.getUint32(t);if(s===0)return null;let i=new Uint8Array(s);return i.set(new Uint8Array(this.#t,t+4,s)),new ei(i.buffer)}},ii=class{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){let t=this.view,e=this.data[wt.KIND],s=!!this.data[wt.HAS_BBOX],i=!!this.data[wt.HAS_BACKGROUND],n=t.getUint32(wt.N_COORD,!0),r=t.getUint32(wt.N_COLOR,!0),a=t.getUint32(wt.N_STOP,!0),o=20,l=new Float32Array(this.buffer,o,n*2);o+=n*8;let c=new Uint8Array(this.buffer,o,r*4);o+=r*4;let d=[];for(let p=0;p<a;++p){let g=t.getFloat32(o,!0);o+=4;let m=t.getUint32(o,!0);o+=4,d.push([g,`#${m.toString(16).padStart(6,"0")}`])}let u=null;if(s){u=[];for(let p=0;p<4;++p)u.push(t.getFloat32(o,!0)),o+=4}let f=null;if(i&&(f=new Uint8Array(this.buffer,o,3),o+=3),e===1)return["RadialAxial","axial",u,d,Array.from(l.slice(0,2)),Array.from(l.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",u,d,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(e===3){let p=this.data[wt.SHADING_TYPE],g=null;if(l.length>0){g=vt.slice();for(let m=0,b=l.length;m<b;m+=2)x.pointBoundingBox(l[m],l[m+1],g)}return["Mesh",p,l,c,n,g,u,f]}throw new Error(`Unsupported pattern kind: ${e}`)}},ni=class{#t;constructor(t){this.#t=t}get path(){return U.isFloat16ArraySupported?new Float16Array(this.#t):new Float32Array(this.#t)}};function Rr(h){if(h instanceof URL)return h;if(typeof h=="string"){if(ht){if(/^[a-z][a-z0-9\-+.]+:/i.test(h))return new URL(h);let e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(h))}let t=URL.parse(h,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Fr(h){if(ht&&typeof Buffer<"u"&&h instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength)return h;if(typeof h=="string")return ps(h);if(h instanceof ArrayBuffer||ArrayBuffer.isView(h)||typeof h=="object"&&!isNaN(h?.length))return new Uint8Array(h);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function De(h){if(typeof h!="string")return null;if(h.endsWith("/"))return h;throw new Error(`Invalid factory url: "${h}" must include trailing slash.`)}var ri=h=>typeof h=="object"&&Number.isInteger(h?.num)&&h.num>=0&&Number.isInteger(h?.gen)&&h.gen>=0,Nr=h=>typeof h=="object"&&typeof h?.name=="string",Br=Er.bind(null,ri,Nr),ai=class{#t=new Map;#e=Promise.resolve();postMessage(t,e){let s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){let{signal:n}=s;if(n.aborted){R("LoopbackPort - cannot use an `aborted` signal.");return}let r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}},Ie={DATA:1,ERROR:2},q={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Rn(){}function rt(h){if(h instanceof bt||h instanceof le||h instanceof oe||h instanceof Xt||h instanceof ie)return h;switch(h instanceof Error||typeof h=="object"&&h!==null||H('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),h.name){case"AbortException":return new bt(h.message);case"InvalidPDFException":return new le(h.message);case"PasswordException":return new oe(h.message,h.code);case"ResponseException":return new Xt(h.message,h.status,h.missing);case"UnknownErrorException":return new ie(h.message,h.details)}return new ie(h.message,h.toString())}var Mt=class{#t=new AbortController;constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#i(t);return}if(t.callback){let s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===Ie.DATA)i.resolve(t.data);else if(t.callback===Ie.ERROR)i.reject(rt(t.reason));else throw new Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let s=this.sourceName,i=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:s,targetName:i,callback:Ie.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:s,targetName:i,callback:Ie.ERROR,callbackId:t.callbackId,reason:rt(r)})});return}if(t.streamId){this.#s(t);return}e(t.data)}on(t,e){let s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){let i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){let n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:l=>{let c=Promise.withResolvers();return this.streamControllers[n]={controller:l,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:l.desiredSize},i),c.promise},pull:l=>{let c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:q.PULL,streamId:n,desiredSize:l.desiredSize}),c.promise},cancel:l=>{K(l instanceof Error,"cancel must have a valid reason");let c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:q.CANCEL,streamId:n,reason:rt(l)}),c.promise}},s)}#s(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(l,c=1,d){if(this.isCancelled)return;let u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:q.ENQUEUE,streamId:e,chunk:l},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:q.CLOSE,streamId:e}),delete r.streamSinks[e])},error(l){K(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:q.ERROR,streamId:e,reason:rt(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:q.START_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:q.START_COMPLETE,streamId:e,reason:rt(l)})})}#i(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case q.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(rt(t.reason));break;case q.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(rt(t.reason));break;case q.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:q.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Rn).then(function(){n.postMessage({sourceName:s,targetName:i,stream:q.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:q.PULL_COMPLETE,streamId:e,reason:rt(l)})});break;case q.ENQUEUE:if(K(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case q.CLOSE:if(K(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#n(r,e);break;case q.ERROR:K(r,"error should have stream controller"),r.controller.error(rt(t.reason)),this.#n(r,e);break;case q.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(rt(t.reason)),this.#n(r,e);break;case q.CANCEL:if(!a)break;let o=rt(t.reason);Promise.try(a.onCancel||Rn,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:q.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:q.CANCEL_COMPLETE,streamId:e,reason:rt(l)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#n(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}},We=class{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:H(`Not implemented: ${t}`)}let s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);let i=`${s}${e}`;return this._fetch(i,t).catch(n=>{throw new Error(`Unable to load ${this.#t[t]} data at: ${i}`)})}async _fetch(t,e){H("Abstract method `_fetch` called.")}},Xe=class extends We{async _fetch(t,e){let s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await An(t,s);return i instanceof Uint8Array?i:ps(i)}},Ye=class{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");let s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){let{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){H("Abstract method `_createCanvas` called.")}},oi=class extends Ye{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let s=this._document.createElement("canvas");return s.width=t,s.height=e,s}},Ke=class{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}},li=class extends Ke{#t;#e;#s;#i;#n;#a;#r=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#i=t,this.#n=e}get#o(){return this.#e||=new Map}get#l(){return this.#a||=new Map}get#h(){if(!this.#s){let t=this.#n.createElement("div"),{style:e}=t;e.colorScheme="only light",e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let s=this.#n.createElementNS(nt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#s=this.#n.createElementNS(nt,"defs"),t.append(s),s.append(this.#s),this.#n.body.append(t)}return this.#s}#u(t){if(t.length===1){let o=t[0],l=new Array(256);for(let d=0;d<256;d++)l[d]=o[d]/255;let c=l.join(",");return[c,c,c]}let[e,s,i]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=s[o]/255,a[o]=i[o]/255;return[n.join(","),r.join(","),a.join(",")]}#d(t){if(this.#t===void 0){this.#t="";let e=this.#n.URL;e!==this.#n.baseURI&&(gs(e)?R('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=qn(e,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;let[s,i,n]=this.#u(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#o.get(r),e)return this.#o.set(t,e),e;let a=`g_${this.#i}_transfer_map_${this.#r++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(r,o);let l=this.#m(a);return this.#p(s,i,n,l),o}addHCMFilter(t,e){let s=`${t}-${e}`,i="base",n=this.#l.get(i);if(n?.key===s||(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},this.#l.set(i,n)),!t||!e))return n.url;let r=this.#y(t);t=x.makeHexColor(...r);let a=this.#y(e);if(e=x.makeHexColor(...a),this.#w(),t==="#000000"&&e==="#ffffff"||t===e)return n.url;let l=Array.from({length:256},(f,p)=>Ns(p/255)).join(","),c=`g_${this.#i}_hcm_filter`,d=n.filter=this.#m(c);this.#p(l,l,l,d),this.#g(d);let u=(f,p)=>{let g=r[f]/255,m=a[f]/255,b=new Array(p+1);for(let y=0;y<=p;y++)b[y]=g+y/p*(m-g);return b.join(",")};return this.#p(u(0,5),u(1,5),u(2,5),d),n.url=this.#d(c),n.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){let e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();return e==="none"||!U.platform.isFirefox?null:{"backdrop-filter":e,"background-color":"transparent"}}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;let[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#i}_alpha_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#m(n);return this.#b(s,a),r}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#u([t]),i=`luminosity_${s}`):i="luminosity",e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#i}_luminosity_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#m(n);return this.#f(a),t&&this.#b(s,a),r}addKnockoutFilter(t=0){let e=t>0?Math.min(1/t,1e6):1e6,s=`knockout_${e}`,i=this.#o.get(s);if(i)return i;let n=`g_${this.#i}_knockout_filter_${this.#r++}`,r=this.#d(n);this.#o.set(s,r);let a=this.#m(n),o=this.#n.createElementNS(nt,"feComponentTransfer");a.append(o);let l=this.#n.createElementNS(nt,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),r}addHighlightHCMFilter(t,e,s,i,n){let r=`${e}-${s}-${i}-${n}`,a=this.#l.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#l.set(t,a)),!e||!s))return a.url;let[o,l]=[e,s].map(this.#y.bind(this)),c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[u,f]=[i,n].map(this.#E.bind(this));d<c&&([c,d,u,f]=[d,c,f,u]),this.#w();let p=(b,y,A)=>{let v=new Array(256),w=(d-c)/A,S=b/255,E=(y-b)/(255*A),_=0;for(let C=0;C<=A;C++){let k=Math.round(c+C*w),P=S+C*E;for(let M=_;M<=k;M++)v[M]=P;_=k+1}for(let C=_;C<256;C++)v[C]=v[_-1];return v.join(",")},g=`g_${this.#i}_hcm_${t}_filter`,m=a.filter=this.#m(g);return this.#g(m),this.#p(p(u[0],f[0],5),p(u[1],f[1],5),p(u[2],f[2],5),m),a.url=this.#d(g),a.url}destroy(t=!1){t&&this.#a?.size||(this.#s?.parentNode.parentNode.remove(),this.#s=null,this.#e?.clear(),this.#e=null,this.#a?.clear(),this.#a=null,this.#r=0)}#f(t){let e=this.#n.createElementNS(nt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#g(t){let e=this.#n.createElementNS(nt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#m(t){let e=this.#n.createElementNS(nt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#h.append(e),e}#c(t,e,s){let i=this.#n.createElementNS(nt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#p(t,e,s,i){let n=this.#n.createElementNS(nt,"feComponentTransfer");i.append(n),this.#c(n,"feFuncR",t),this.#c(n,"feFuncG",e),this.#c(n,"feFuncB",s)}#b(t,e){let s=this.#n.createElementNS(nt,"feComponentTransfer");e.append(s),this.#c(s,"feFuncA",t)}#y(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,Me(getComputedStyle(this.#h).getPropertyValue("background-color"))}#A(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,Pe(getComputedStyle(this.#h).getPropertyValue("background-color"))}#w(){this.#h.style.color="",this.#h.style.backgroundColor=""}#E(t){let[e,s,i,n]=this.#A(t);if(n===1)return[e,s,i];let[r,a,o]=this.#y("Canvas");return[Ts(e,r,n),Ts(s,a,n),Ts(i,o,n)]}};function Ts(h,t,e){return Math.round(e*h+(1-e)*t)}ht&&R("Please use the `legacy` build in Node.js environments.");async function Hr(h){let e=await process.getBuiltinModule("fs/promises").readFile(h);return new Uint8Array(e)}var hi=class extends Ke{},ci=class extends Ye{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}},di=class extends We{async _fetch(t,e){return Hr(t)}};function er({src:h,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){let a=U.isLittleEndian?4278190080:255,[o,l]=r?[n,a]:[a,n],c=s>>3,d=s&7,u=o^l,f=h.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<i;++g){for(let b=t+c;t<b;++t,p+=8){let y=h[t];e[p]=o^-(y>>7&1)&u,e[p+1]=o^-(y>>6&1)&u,e[p+2]=o^-(y>>5&1)&u,e[p+3]=o^-(y>>4&1)&u,e[p+4]=o^-(y>>3&1)&u,e[p+5]=o^-(y>>2&1)&u,e[p+6]=o^-(y>>1&1)&u,e[p+7]=o^-(y&1)&u}if(d===0)continue;let m=t<f?h[t++]:255;for(let b=0;b<d;++b,++p)e[p]=o^-(m>>7-b&1)&u}return{srcPos:t,destPos:p}}function Ur({src:h,srcPos:t=0,dest:e,destPos:s=0,width:i,height:n}){let r=0,a=i*n*3,o=a>>2,l=new Uint32Array(h.buffer,t,o),c=U.isLittleEndian?4278190080:255;if(U.isLittleEndian){for(;r<o-2;r+=3,s+=4){let d=l[r],u=l[r+1],f=l[r+2];e[s]=d|c,e[s+1]=d>>>24|u<<8|c,e[s+2]=u>>>16|f<<16|c,e[s+3]=f>>>8|c}for(let d=r*4,u=t+a;d<u;d+=3)e[s++]=h[d]|h[d+1]<<8|h[d+2]<<16|c}else{for(;r<o-2;r+=3,s+=4){let d=l[r],u=l[r+1],f=l[r+2];e[s]=d|c,e[s+1]=d<<24|u>>>8|c,e[s+2]=u<<16|f>>>16|c,e[s+3]=f<<8|c}for(let d=r*4,u=t+a;d<u;d+=3)e[s++]=h[d]<<24|h[d+1]<<16|h[d+2]<<8|c}return{srcPos:t+a,destPos:s}}var Gr=`
|
|
3
3
|
struct Uniforms {
|
|
4
4
|
offsetX : f32,
|