PageSourceSearch

https://healthserve.ae/assets/pdf-CZ9a0SDA.js

js healthserve.ae collected 2026-10-04 02:40:32 UTC 479,441 bytes, 55 lines download raw bytes

1var cA=Object.defineProperty;var rm=p=>{throw TypeError(p)};var dA=(p,t,e)=>t in p?cA(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var _=(p,t,e)=>dA(p,typeof t!="symbol"?t+"":t,e),Xf=(p,t,e)=>t.has(p)||rm("Cannot "+e);var i=(p,t,e)=>(Xf(p,t,"read from private field"),e?e.call(p):t.get(p)),m=(p,t,e)=>t.has(p)?rm("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(p):t.set(p,e),u=(p,t,e,s)=>(Xf(p,t,"write to private field"),s?s.call(p,e):t.set(p,e),e),b=(p,t,e)=>(Xf(p,t,"access private method"),e);var Et=(p,t,e,s)=>({set _(n){u(p,t,n,e)},get _(){return i(p,t,s)}});const vs=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),In=[1/0,1/0,-1/0,-1/0],Zr=new Float32Array(In),ep=[.001,0,0,.001,0,0],He="http://www.w3.org/2000/svg",ws={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Hn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Vo="pdfjs_internal_id_",Zh="pdfjs_internal_editor_",V={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},X={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},uA={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Qt={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},au={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Pt={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},Ho={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Pf={ERRORS:0,WARNINGS:1,INFOS:5},fi={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},Ch={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},fA={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Df=Pf.WARNINGS;function pA(p){Number.isInteger(p)&&(Df=p)}function gA(){return Df}function If(p){Df>=Pf.INFOS&&console.info(`Info: ${p}`)}function W(p){Df>=Pf.WARNINGS&&console.warn(`Warning: ${p}`)}function it(p){throw new Error(p)}function Rt(p,t){p||it(t)}function mA(p){switch(p==null?void 0:p.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Fm(p,t=null,e=null){if(!p)return null;if(e&&typeof p=="string"){if(e.addDefaultProtocol&&p.startsWith("www.")){const n=p.match(/\./g);(n==null?void 0:n.length)>=2&&(p=`http://${p}`)}if(e.tryConvertEncoding)try{p=AA(p)}catch{}}const s=t?URL.parse(p,t):URL.parse(p);return mA(s)?s:null}
1function Om(p,t,e=!1){const s=URL.parse(p);return s?(s.hash=t,s.href):e&&Fm(p,"http://example.com")?p.split("#",1)[0]+`${t?`#${t}`:""}`:""}function sp(p){return p.substring(p.lastIndexOf("/")+1)}function $(p,t,e,s=!1){return Object.defineProperty(p,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Oo=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class ip extends Oo{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Yf extends Oo{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class np extends Oo{constructor(t){super(t,"InvalidPDFException")}}class Xu extends Oo{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class bA extends Oo{constructor(t){super(t,"FormatError")}}class Ur extends Oo{constructor(t){super(t,"AbortException")}}function yA(p){(typeof p!="object"||(p==null?void 0:p.length)===void 0)&&it("Invalid argument for bytesToString");const t=p.length,e=8192;if(t<e)return String.fromCharCode.apply(null,p);const s=[];for(let n=0;n<t;n+=e){const r=Math.min(n+e,t),a=p.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Lf(p){typeof p!="string"&&it("Invalid argument for stringToBytes");const t=p.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=p.charCodeAt(s)&255;return e}class bt{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return $(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return $(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return $(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return $(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return $(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return $(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")),$(this,"isCanvasFilterSupported",(t==null?void 0:t.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return $(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",$(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return $(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var Ln,ou,rp;class D{static get hexNums(){return $(this,"hexNums",Array.from(Array(256).keys(),t=>t.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){const n=t[s],r=t[s+1];t[s]=n*e[0]+r*e[2]+e[4],t[s+1]=n*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const n=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5];for(let c=0;c<6;c+=2){const d=t[s+c],f=t[s+c+1];t[s+c]=d*n+f*a+l,t[s+c+1]=d*r+f*o+h}}static applyInverseTransform(t,e){const s=t[0],n=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-n*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+n*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const n=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5],c=t[0],d=t[1],f=t[2],g=t[3];let y=n*c+l,A=y,v=n*f+l,w=v,S=o*d+h,E=S,x=o*g+h,C=x;if(r!==0||a!==0){const T=r*c,k=r*f,P=a*d,M=a*g;y+=P,w+=P,v+=M,A+=M,S+=T,C+=T,x+=k,E+=k}s[0]=Math.min(s[0],y,v,A,w),s[1]=Math.min(s[1],S,x,E,C),s[2]=Math.max(s[2],y,v,A,w),s[3]=Math.max(s[3],S,x,E,C)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const s=t[0],n=t[1],r=t[2],a=t[3],o=s**2+n**2,l=s*r+n*a,h=r**2+
1a**2,c=(o+h)/2,d=Math.sqrt(c**2-(o*h-l**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>n)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[s,r,n,a]}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,n,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,n),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,n)}static bezierBoundingBox(t,e,s,n,r,a,o,l,h){h[0]=Math.min(h[0],t,o),h[1]=Math.min(h[1],e,l),h[2]=Math.max(h[2],t,o),h[3]=Math.max(h[3],e,l),b(this,Ln,rp).call(this,t,s,r,o,e,n,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),h),b(this,Ln,rp).call(this,t,s,r,o,e,n,a,l,3*(-e+3*(n-a)+l),6*(e-2*n+a),3*(n-e),h)}}Ln=new WeakSet,ou=function(t,e,s,n,r,a,o,l,h,c){if(h<=0||h>=1)return;const d=1-h,f=h*h,g=f*h,y=d*(d*(d*t+3*h*e)+3*f*s)+g*n,A=d*(d*(d*r+3*h*a)+3*f*o)+g*l;c[0]=Math.min(c[0],y),c[1]=Math.min(c[1],A),c[2]=Math.max(c[2],y),c[3]=Math.max(c[3],A)},rp=function(t,e,s,n,r,a,o,l,h,c,d,f){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,Ln,ou).call(this,t,e,s,n,r,a,o,l,-d/c,f);return}const g=c**2-4*d*h;if(g<0)return;const y=Math.sqrt(g),A=2*h;b(this,Ln,ou).call(this,t,e,s,n,r,a,o,l,(-c+y)/A,f),b(this,Ln,ou).call(this,t,e,s,n,r,a,o,l,(-c-y)/A,f)},m(D,Ln);function AA(p){return decodeURIComponent(escape(p))}let Kf=null,am=null;function wA(p){return Kf||(Kf=/([\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,am=new Map([["ſt","ſt"]])),p.replaceAll(Kf,(t,e,s)=>e?e.normalize("NFKC"):am.get(s))}function Nm(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const p=new Uint8Array(32);return crypto.getRandomValues(p),yA(p)}function vA(p,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,n,...r]=e;if(!p(s)&&!Number.isInteger(s)||!t(n))return!1;const a=r.length;let o=!0;switch(n.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}const Wd=()=>[],Hg=()=>new Map,ap=()=>Object.create(null),SA=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(p){return[...this].join(p)});function Tt(p,t,e){return Math.min(Math.max(p,t),e)}class Xd{constructor({viewBox:t,userUnit:e,scale:s,rotation:n,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=n,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,d,f,g;switch(n%=360,n<0&&(n+=360),n){case 180:c=-1,d=0,f=0,g=1;break;case 90:c=0,d=1,f=1,g=0;break;case 270:c=0,d=-1,f=-1,g=0;break;case 0:c=1,d=0,f=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(f=-f,g=-g);let y,A,v,w;c===0?(y=Math.abs(h-t[1])*s+r,A=Math.abs(l-t[0])*s+a,v=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(y=Math.abs(l-t[0])*s+r,A=Math.abs(h-t[1])*s+a,v=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[c*s,d*s,f*s,g*s,y-c*s*l-f*s*h,A-d*s*l-g*s*h],this.width=v,this.height=w}get rawDims(){const t=this.viewBox;return $(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:n=this.offsetY,dontFlip:r=!1}={}){return new Xd({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return D.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return D.applyInverseTransform(s,this.transform),s}}class tc{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function n(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;
1else if(tc.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const h of r.children)n(h)}return n(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const EA=/url\(|image-set\(/i,xA=/^on/i;var rc,op;class Ug{static get _allowedHtmlElements(){return $(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 $(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return $(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return $(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return $(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,n,r){const a=n.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="print")break;t.addEventListener("input",o=>{n.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",o=>{n.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),r==="print")break;t.addEventListener("input",o=>{n.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:Object.hasOwn(o.attributes,"selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,h=l.selectedIndex===-1?"":l[l.selectedIndex].value;n.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:n,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${n}`);for(const[l,h]of Object.entries(a))if(h!=null&&!xA.test(l)&&!(n==="richText"&&!this._allowedRichTextAttributes.has(l)))switch(l){case"class":h.length&&t.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":if(n==="richText"){const c=this._allowedRichTextStyles;for(const[d,f]of Object.entries(h))c.has(d)&&!EA.test(f)&&(t.style[d]=f)}else Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&(r==null||r.addLinkAttributes(t,a.href,a.newWindow)),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var d,f,g;const e=t.annotationStorage,s=t.linkService,n=t.xfaHtml,r=t.intent||"display",a=b(this,rc,op).call(this,n.name,(d=n.attributes)==null?void 0:d.xmlns,r)??document.createElement("div");n.attributes&&this.setAttributes({html:a,element:n,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const y=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=y}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(n.children.length===0){if(n.value){const y=document.createTextNode(n.value);a.append(y),o&&tc.shouldBuildText(n.name)&&h.push(y)}return{textDivs:h}}const c=[[n,-1,a]];for(;c.length>0;){const[y,A,v]=c.at(-1);if(A+1===y.children.length){c.pop();continue}const w=y.children[++c.at(-1)[1]];if(w===null)continue;const{name:S}=w;if(S==="#text"){const x=document.createTextNode(w.value);h.push(x),v.append(x);continue}const E=b(this,rc,op).call(this,S,(f=w.attributes)==null?void 0:f.xmlns,r);if(E){if(v.append(E),w.attributes&&this.setAttributes({html:E,element:w,storage:e,intent:r,linkService:s}),((g=w.children)==null?void 0:g.length)>0)c.push([w,-1,E]);else if(w.value){const x=document.createTextNode(w.value);o&&tc.shouldBuildText(S)&&h.push(x),E.append(x)}}}for(const y of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))y.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:n,height:r}=t.attributes.style;return new Xd({viewBox:[0,0,parseInt(n,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}rc=new WeakSet,op=function(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===He&&this._allowedSvgElements.has(t)?document.createElementNS(He,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null},m(Ug,rc);const qr=class qr{};_(qr,"CSS",96),_(qr,"PDF",72),_(qr,"PDF_TO_CSS_UNITS",qr.CSS/qr.PDF);let Gr=qr;async function Gg(p,t="text"){if(Kh(p,document.baseURI)){const e=await fetch(p);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)=>{const n=new XMLHttpRequest;n.open("GET",p,!0),n.responseType=t==="bytes"?"arraybuffer":t,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE){if(n.status===200||n.status===0){switch(t){case"bytes":e(new Uint8Array(n.response));return;case"blob":case"json":e(n.response);return}e(n.responseText);return}s(new Error(n.statusText))}},n.send(null)})}class $g extends Oo{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Rf(p){const t=p.length;let e=0;for(;e<t&&p[e].trim()==="";)e++;return p.substring(e,e+5).toLowerCase()==="data:"}function zg(p){return typeof p=="string"&&/\.pdf$/i.test(p)}function CA(p){return[p]=p.split(/[#?]/,1),sp(p)}function TA(p,t="document.pdf"){if(typeof p!="string")return t;if(Rf(p))return W('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(o=>{try{return new URL(o)}catch{}try{return new URL(decodeURIComponent(o))}catch{}try{return new URL(o,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{}return null})(p);if(!s)return t;const n=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=sp(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=sp(s.pathname);if(r.test(a))return n(a);if(s.searchParams.size>0){const o=h=>[...h].findLast(c=>r.test(c)),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return n(l)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return n(l[0])}return t}var Un;class om{constructor(){m(this,Un,new Map);_(this,"times",[])}time(t){i(this,Un).has(t)&&W(`Timer is already running for ${t}`),i(this,Un).set(t,Date.now())}timeEnd(t){i(this,Un).has(t)||W(`Timer has not been started for ${t}`),this.times.push({name:t,start:i(this,Un).get(t),end:Date.now()}),i(this,Un).delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}
1ms
2`).join("")}}Un=new WeakMap;function Kh(p,t){const e=t?URL.parse(p,t):URL.parse(p);return/https?:/.test((e==null?void 0:e.protocol)??"")}function js(p){p.preventDefault()}function Lt(p){p.preventDefault(),p.stopPropagation()}var ac;class Yu{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;i(this,ac)||u(this,ac,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const e=i(this,ac).exec(t);if(!e)return null;const s=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,h==="-"?(a+=c,o+=d):h==="+"&&(a-=c,o-=d),new Date(Date.UTC(s,n,r,a,o,l))}}ac=new WeakMap,m(Yu,ac);function Yd(p){if(p.startsWith("#")){const e=p.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(p.startsWith("rgb(")){const[e,s,n]=p.slice(4,-1).split(",").map(r=>parseInt(r,10));return[e,s,n,1]}if(p.startsWith("rgba(")){const e=p.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=p.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 Kd(p){const t=Yd(p);return t?t.slice(0,3):(W(`Not a valid color format: "${p}"`),[0,0,0])}function _A(p){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of p.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;p.set(e,Kd(s))}t.remove()}function St(p){const{a:t,b:e,c:s,d:n,e:r,f:a}=p.getTransform();return[t,e,s,n,r,a]}function hi(p){const{a:t,b:e,c:s,d:n,e:r,f:a}=p.getTransform().invertSelf();return[t,e,s,n,r,a]}function Do(p,t,e=!1,s=!0){if(t instanceof Xd){const{pageWidth:n,pageHeight:r}=t.rawDims,{style:a}=p,o=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;!e||t.rotation%180===0?(a.width=o,a.height=l):(a.width=l,a.height=o)}s&&p.setAttribute("data-main-rotation",t.rotation)}class Hi{constructor(){const{pixelRatio:t}=Hi;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,n,r=-1){let a=1/0,o=1/0,l=1/0;s=Hi.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),n!==-1&&(o=n/t,l=n/e);const h=Math.min(a,o,l);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const lp=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class kA{static get isDarkMode(){var t;return $(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class MA{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),$(this,"commentForegroundColor",Kd(s))}}function PA(p,t){t=Tt(t??1,0,1);const e=255*(1-t);return p.map(s=>Math.round(s*t+e))}function lm(p,t){const e=p[0]/255,s=p[1]/255,n=p[2]/255,r=Math.max(e,s,n),a=Math.min(e,s,n),o=(r+a)/2;if(r===a)t[0]=t[1]=0;else{const l=r-a;switch(t[1]=o<.5?l/(r+a):l/(2-r-a),r){case e:t[0]=((s-n)/l+(s<n?6:0))*60;break;case s:t[0]=((n-e)/l+2)*60;break;case n:t[0]=((e-s)/l+4)*60;break}}t[2]=o}function hp(p,t){const e=p[0],s=p[1],n=p[2],r=(1-Math.abs(2*n-1))*s,a=r*(1-Math.abs(e/60%2-1)),o=n-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+o,t[1]=a+o,t[2]=o;break;case 1:t[0]=a+o,t[1]=r+o,t[2]=o;break;case 2:t[0]=o,t[1]=r+o,t[2]=a+o;break;case 3:t[0]=o,t[1]=a+o,t[2]=r+o;break;case 4:t[0]=a+o,t[1]=o,t[2]=r+o;break;
2case 5:case 6:t[0]=r+o,t[1]=o,t[2]=a+o;break}}function hm(p){return p<=.03928?p/12.92:((p+.055)/1.055)**2.4}function cm(p,t,e){hp(p,e),e.map(hm);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];hp(t,e),e.map(hm);const n=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}const dm=new Map;function DA(p,t){const e=p[0]+p[1]*256+p[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=dm.get(e);if(s)return s;const n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);lm(p,a);const o=n.subarray(6,9);lm(t,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),cm(a,o,r)<h){let c,d;l?(c=a[2],d=1):(c=0,d=a[2]);const f=.005;for(;d-c>f;){const g=a[2]=(c+d)/2;l===cm(a,o,r)<h?c=g:d=g}a[2]=l?d:c}return hp(a,r),s=D.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),dm.set(e,s),s}function Bm({html:p,dir:t,className:e},s){const n=document.createDocumentFragment();if(typeof p=="string"){const r=document.createElement("p");r.dir=t||"auto";const a=p.split(/\r\n?|\n/);for(let o=0,l=a.length;o<l;++o){const h=a[o];r.append(document.createTextNode(h)),o<l-1&&r.append(document.createElement("br"))}n.append(r)}else Ug.render({xfaHtml:p,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",e),s.append(n)}function Hm(p){const t=new Path2D;if(!p)return t;for(let e=0,s=p.length;e<s;)switch(p[e++]){case Ch.moveTo:t.moveTo(p[e++],p[e++]);break;case Ch.lineTo:t.lineTo(p[e++],p[e++]);break;case Ch.curveTo:t.bezierCurveTo(p[e++],p[e++],p[e++],p[e++],p[e++],p[e++]);break;case Ch.quadraticCurveTo:t.quadraticCurveTo(p[e++],p[e++],p[e++],p[e++]);break;case Ch.closePath:t.closePath();break;default:W(`Unrecognized drawing path operator: ${p[e-1]}`);break}return t}var Gn,$n,_s,ks,oc,zn,Ko,qo,lc,nf,Um,ve,Gm,$m,Uo,kh;const ji=class ji{constructor(t){m(this,ve);m(this,Gn,null);m(this,$n,null);m(this,_s);m(this,ks,null);m(this,oc,null);m(this,zn,null);m(this,Ko,null);m(this,qo,null);u(this,_s,t),i(ji,lc)||u(ji,lc,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const t=u(this,Gn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=i(this,_s)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",js,{signal:e}),t.addEventListener("pointerdown",b(ji,nf,Um),{signal:e}));const s=u(this,ks,document.createElement("div"));s.className="buttons",t.append(s);const n=i(this,_s).toolbarPosition;if(n){const{style:r}=t,a=i(this,_s)._uiManager.direction==="ltr"?1-n[0]:n[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return i(this,Gn)}hide(){var t;i(this,Gn).classList.add("hidden"),(t=i(this,$n))==null||t.hideDropdown()}show(){var t,e;i(this,Gn).classList.remove("hidden"),(t=i(this,oc))==null||t.shown(),(e=i(this,zn))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=i(this,_s),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",i(ji,lc)[t]),b(this,ve,Uo).call(this,s)&&s.addEventListener("click",n=>{e.delete()},{signal:e._signal}),i(this,ks).append(s)}async addAltText(t){const e=await t.render();b(this,ve,Uo).call(this,e),i(this,ks).append(e,i(this,ve,kh)),u(this,oc,t)}addComment(t,e=null){if(i(this,zn))return;const s=t.renderForToolbar();if(!s)return;b(this,ve,Uo).call(this,s);const n=u(this,Ko,i(this,ve,kh));e?(i(this,ks).insertBefore(s,e),i(this,ks).insertBefore(n,e)):i(this,ks).append(s,n),u(this,zn,t),t.toolbar=this}addColorPicker(t){if(i(this,$n))return;u(this,$n,t);const e=t.renderButton();b(this,ve,Uo).call(this,e),i(this,ks).append(e,i(this,ve,kh))}async addEditSignatureButton(t){const e=u(this,qo,await t.renderEditButton(i(this,_s)));b(this,ve,Uo).call(this,e),i(this,ks).append(e,i(this,ve,kh))}removeButton(t){var e,s;switch(t){case"comment":(e=i(this,zn))==null||e.removeToolbarCommentButton(),u(this,zn,null),(s=i(this,Ko))==null||s.remove(),u(this,Ko,null);break}}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;const n=i(this,ks).querySelector(s);n&&t==="comment"&&this.addComment(e,n)}updateEditSignatureButton(t){i(this,qo)&&(i(this,qo).title=t)}remove(){var t;i(this,Gn).remove(),(t=i(this,$n))==null||t.destroy(),u(this,$n,null)}};Gn=new WeakMap,$n=new WeakMap,_s=new WeakMap,ks=new WeakMap,oc=new WeakMap,zn=new WeakMap,Ko=new WeakMap,qo=new WeakMap,lc=new WeakMap,nf=new WeakSet,Um=function(t){t.stopPropagation()},ve=new WeakSet,Gm=function(t){i(this,_s)._focusEventsAllowed=!1,Lt(t)},$m=function(t){i(this,_s)._focusEventsAllowed=!0,Lt(t)},Uo=function(t){const e=i(this,_s)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,ve,Gm).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,ve,$m).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",js,{signal:e}),!0)},kh=function(){const t=document.createElement("div");return t.className="divider",t},m(ji,nf),m(ji,lc,null);let cp=ji;var hc,ta,Wi,Fn,zm,jm,dp;class IA{constructor(t){m(this,Fn);m(this,hc,null);m(this,ta,null);m(this,Wi);u(this,Wi,t)}show(t,e,s){const[n,r]=b(this,Fn,jm).call(this,e,s),{style:a}=i(this,ta)||u(this,ta,b(this,Fn,zm).call(this));t.append(i(this,ta)),a.insetInlineEnd=`${100*n}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){i(this,ta).remove()}}hc=new WeakMap,ta=new WeakMap,Wi=new WeakMap,Fn=new WeakSet,zm=function(){const t=u(this,ta,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=i(this,Wi)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",js,{signal:e});const s=u(this,hc,document.createElement("div"));return s.className="buttons",t.append(s),i(this,Wi).hasCommentManager()&&b(this,Fn,dp).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{i(this,Wi).commentSelection("floating_button")}),b(this,Fn,dp).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{i(this,Wi).highlightSelection("floating_button")}),t},jm=function(t,e){let s=0,n=0;for(const r of t){const a=r.y+r.height;if(a<s)continue;const o=r.x+(e?r.width:0);if(a>s){n=o,s=a;continue}e?o>n&&(n=o):o<n&&(n=o)}return[e?1-n:n,s]},dp=function(t,e,s,n){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const a=document.createElement("span");r.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",s);const o=i(this,Wi)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",js,{signal:o}),r.addEventListener("click",n,{signal:o})),i(this,hc).append(r)};const LA="f63eb798-ea37-4556-98de-f8303ee5a694",qf=Object.freeze({internal:LA});function Vm(p,t,e){for(const s of e)t.addEventListener(s,p[s].bind(p))}var ea,sa,Qo,ia;const ut=class ut{static initializeAndAddPointerId(t){(i(ut,sa)||u(ut,sa,new Set)).add(t)}static setPointer(t,e){i(ut,ea)||u(ut,ea,e),i(ut,ia)??u(ut,ia,t)}static setTimeStamp(t){u(ut,Qo,t)}static isSamePointerId(t){return i(ut,ea)===t}static isSamePointerIdOrRemove(t){var e;return i(ut,ea)===t?!0:((e=i(ut,sa))==null||e.delete(t),!1)}static isSamePointerType(t){return i(ut,ia)===t}static isInitializedAndDifferentPointerType(t){return i(ut,ia)!==null&&!ut.isSamePointerType(t)}static isSameTimeStamp(t){return i(ut,Qo)===t}static isUsingMultiplePointers(){var t;return((t=i(ut,sa))==null?void 0:t.size)>=1}static clearPointerType(){u(ut,ia,null)}static clearPointerIds(){u(ut,ea,NaN),u(ut,sa,null)}static clearTimeStamp(){u(ut,Qo,NaN)}};ea=new WeakMap,sa=new WeakMap,Qo=new WeakMap,ia=new WeakMap,m(ut,ea,NaN),m(ut,sa,null),m(ut,Qo,NaN),m(ut,ia,null);let xe=ut;var rf;class RA{constructor(){m(this,rf,0)}get id(){return`${Zh}${Et(this,rf)._++}`}}rf=new WeakMap;var Jo,cc,Ce,Zo,lu;const qg=class qg{constructor(){m(this,Zo);m(this,Jo,Nm());m(this,cc,0);m(this,Ce,null)}static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${He}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),n=new Image;n.src=t;const r=n.decode().then(()=>
2(s.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return $(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:n,type:r}=t;return b(this,Zo,lu).call(this,`${e}_${s}_${n}_${r}`,t)}async getFromUrl(t){return b(this,Zo,lu).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,Zo,lu).call(this,t,s)}async getFromId(t){i(this,Ce)||u(this,Ce,new Map);const e=i(this,Ce).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){i(this,Ce)||u(this,Ce,new Map);let s=i(this,Ce).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),s={bitmap:n.transferToImageBitmap(),id:`image_${i(this,Jo)}_${Et(this,cc)._++}`,refCounter:1,isSvg:!1},i(this,Ce).set(t,s),i(this,Ce).set(s.id,s),s}getSvgUrl(t){const e=i(this,Ce).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var n;i(this,Ce)||u(this,Ce,new Map);const e=i(this,Ce).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(n=s.close)==null||n.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${i(this,Jo)}_`)}};Jo=new WeakMap,cc=new WeakMap,Ce=new WeakMap,Zo=new WeakSet,lu=async function(t,e){i(this,Ce)||u(this,Ce,new Map);let s=i(this,Ce).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${i(this,Jo)}_${Et(this,cc)._++}`,refCounter:0,isSvg:!1});let n;if(typeof e=="string"?(s.url=e,n=await Gg(e,"blob")):e instanceof File?n=s.file=e:e instanceof Blob&&(n=e),n.type==="image/svg+xml"){const r=qg._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=async()=>{const d=s.svgUrl=a.result;o.src=await r?`${d}#svgView(preserveAspectRatio(none))`:d},o.onerror=a.onerror=c});a.readAsDataURL(n),await l}else s.bitmap=await createImageBitmap(n);s.refCounter=1}catch(n){W(n),s=null}return i(this,Ce).set(t,s),s&&i(this,Ce).set(s.id,s),s};let up=qg;var zt,jn,dc,Dt;class FA{constructor(t=128){m(this,zt,[]);m(this,jn,!1);m(this,dc);m(this,Dt,-1);u(this,dc,t)}add({cmd:t,undo:e,post:s,mustExec:n,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(n&&t(),i(this,jn))return;const l={cmd:t,undo:e,post:s,type:r};if(i(this,Dt)===-1){i(this,zt).length>0&&(i(this,zt).length=0),u(this,Dt,0),i(this,zt).push(l);return}if(a&&i(this,zt)[i(this,Dt)].type===r){o&&(l.undo=i(this,zt)[i(this,Dt)].undo),i(this,zt)[i(this,Dt)]=l;return}const h=i(this,Dt)+1;h===i(this,dc)?i(this,zt).splice(0,1):(u(this,Dt,h),h<i(this,zt).length&&i(this,zt).splice(h)),i(this,zt).push(l)}undo(){if(i(this,Dt)===-1)return;u(this,jn,!0);const{undo:t,post:e}=i(this,zt)[i(this,Dt)];t(),e==null||e(),u(this,jn,!1),u(this,Dt,i(this,Dt)-1)}redo(){if(i(this,Dt)<i(this,zt).length-1){u(this,Dt,i(this,Dt)+1),u(this,jn,!0);const{cmd:t,post:e}=i(this,zt)[i(this,Dt)];t(),e==null||e(),u(this,jn,!1)}}hasSomethingToUndo(){return i(this,Dt)!==-1}hasSomethingToRedo(){return i(this,Dt)<i(this,zt).length-1}cleanType(t){if(i(this,Dt)!==-1){for(let e=i(this,Dt);e>=0;e--)if(i(this,zt)[e].type!==t){i(this,zt).splice(e+1,i(this,Dt)-e),u(this,Dt,e);return}i(this,zt).length=0,u(this,Dt,-1)}}destroy(){u(this,zt,null)}}zt=new WeakMap,jn=new WeakMap,dc=new WeakMap,Dt=new WeakMap;var Sh,Wm,Xm;const Ve=class Ve{constructor(t){var s;this.callbacks=new Map;const{isMac:e}=bt.platform;for(const[n,r,a={}]of t){const o=n.some(l=>l.startsWith("mac+"));for(const l of n){let h=l;if(o){const f=l.startsWith("mac+");if(e!==f)continue;f&&(h=l.slice(4))}const[c,d]=b(s=Ve,Sh,Wm).call(s,h);c!==null&&this.callbacks.getOrInsertComputed(c,Wd).push({callback:r,options:a,modifiers:d})}}}exec(t,e){var c;let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const d=b(c=Ve,Sh,Xm).call(c,e.code);
2if(d===null||d===e.key||(s=this.callbacks.get(d),!s))return}const n=(e.altKey?Ve.ALT:0)|(e.ctrlKey?Ve.CTRL:0)|(e.metaKey?Ve.META:0)|(e.shiftKey?Ve.SHIFT:0),r=s.find(d=>d.modifiers===n);if(!r)return;const{callback:a,options:{bubbles:o=!1,args:l=[],checker:h=null}}=r;h&&!h(t,e)||(a.bind(t,...l,e)(),o||Lt(e))}};Sh=new WeakSet,Wm=function(t){let e=null,s=0;for(let n of t.split("+")){if(n=n.trim(),!n)continue;const r=n.toUpperCase(),a=Ve[r];if(a){s|=a;continue}if(e!==null){W(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":n}return e===null&&W(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]},Xm=function(t){var s;const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?((s=e[1])==null?void 0:s.toLowerCase())??e[2]:null},m(Ve,Sh),_(Ve,"ALT",1),_(Ve,"CTRL",2),_(Ve,"META",4),_(Ve,"SHIFT",8);let Io=Ve;const af=class af{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return _A(t),$(this,"_colors",t)}convert(t){const e=Kd(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,n]of this._colors)if(n.every((r,a)=>r===e[a]))return af._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?D.makeHexColor(...e):t}};_(af,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let fp=af;var tl,is,el,Nt,It,sl,il,Le,nl,Ms,se,Vn,Wn,Xn,Yn,pi,Ps,na,uc,fc,rl,pc,gi,Kn,al,qn,mi,of,Xi,ol,gc,Qn,ra,ll,Jn,mc,Kt,ft,Yi,Zn,tr,bc,hl,yc,er,bi,Ki,Ac,wc,Ds,R,hu,pp,Ym,Km,Mh,qm,Qm,Jm,gp,Zm,tb,eb,sb,De,$i,ib,nb,mp,rb,Ph,bp;const Wo=class Wo{constructor(t,e,s,n,r,a,o,l,h,c,d,f,g,y,A,v){m(this,R);m(this,tl,new AbortController);m(this,is,null);m(this,el,null);m(this,Nt,new Map);m(this,It,new Map);m(this,sl,null);m(this,il,null);m(this,Le,null);m(this,nl,null);m(this,Ms,new FA);m(this,se,null);m(this,Vn,null);m(this,Wn,null);m(this,Xn,0);m(this,Yn,new Set);m(this,pi,null);m(this,Ps,null);m(this,na,new Set);_(this,"_editorUndoBar",null);m(this,uc,!1);m(this,fc,!1);m(this,rl,!1);m(this,pc,null);m(this,gi,null);m(this,Kn,null);m(this,al,null);m(this,qn,!1);m(this,mi,null);m(this,of,new RA);m(this,Xi,!1);m(this,ol,!1);m(this,gc,!1);m(this,Qn,null);m(this,ra,null);m(this,ll,null);m(this,Jn,null);m(this,mc,null);m(this,Kt,V.NONE);m(this,ft,new Set);m(this,Yi,null);m(this,Zn,null);m(this,tr,null);m(this,bc,null);m(this,hl,null);m(this,yc,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});m(this,er,[0,0]);m(this,bi,null);m(this,Ki,null);m(this,Ac,null);m(this,wc,null);m(this,Ds,null);const w=this._signal=i(this,tl).signal;u(this,Ki,t),u(this,Ac,e),u(this,wc,s),u(this,il,n),u(this,se,r),u(this,Zn,a),u(this,hl,l),this._eventBus=o;const S={signal:w,...qf};o.on("editingaction",this.onEditingAction.bind(this),S),o.on("pagechanging",this.onPageChanging.bind(this),S),o.on("scalechanging",this.onScaleChanging.bind(this),S),o.on("rotationchanging",this.onRotationChanging.bind(this),S),o.on("setpreference",this.onSetPreference.bind(this),S),o.on("switchannotationeditorparams",E=>this.updateParams(E.type,E.value),S),window.addEventListener("pointerdown",()=>{u(this,ol,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{u(this,ol,!1)},{capture:!0,signal:w}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:w}),b(this,R,qm).call(this),b(this,R,sb).call(this),b(this,R,gp).call(this),u(this,Le,l.annotationStorage),u(this,pc,l.filterFactory),u(this,tr,h),u(this,al,c||null),u(this,uc,d),u(this,fc,f),u(this,rl,g),u(this,mc,y||null),this.viewParameters={realScale:Gr.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=A||null,this._supportsPinchToZoom=v!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=Wo.prototype,e=a=>i(a,Ki).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return $(this,"_keyboardManager",new Io([[["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:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&i(a,Ki).contains(o)&&!a.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&i(a,Ki).contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,n,r,a,o,l,h;(t=i(this,Ds))==null||t.resolve(),u(this,Ds,null),(e=i(this,tl))==null||e.abort(),u(this,tl,null),this._signal=null;for(const c of i(this,It).values())c.destroy();i(this,It).clear(),i(this,Nt).clear(),i(this,na).clear(),(s=i(this,Jn))==null||s.clear(),u(this,is,null),i(this,ft).clear(),i(this,Ms).destroy(),(n=i(this,il))==null||n.destroy(),(r=i(this,se))==null||r.destroy(),(a=i(this,Zn))==null||a.destroy(),(o=i(this,mi))==null||o.hide(),u(this,mi,null),(l=i(this,ll))==null||l.destroy(),u(this,ll,null),u(this,el,null),i(this,gi)&&(clearTimeout(i(this,gi)),u(this,gi,null)),i(this,bi)&&(clearTimeout(i(this,bi)),u(this,bi,null)),(h=this._editorUndoBar)==null||h.destroy(),u(this,hl,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return i(this,mc)}get useNewAltTextFlow(){return i(this,fc)}get useNewAltTextWhenAddingImage(){return i(this,rl)}get hcmFilter(){return $(this,"hcmFilter",i(this,tr)?i(this,pc).addHCMFilter(i(this,tr).foreground,i(this,tr).background):"none")}get direction(){return $(this,"direction",getComputedStyle(i(this,Ki)).direction)}get _highlightColors(){return $(this,"_highlightColors",i(this,al)?new Map(i(this,al).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return $(this,"highlightColors",null);const e=new Map,s=!!i(this,tr);for(const[n,r]of t){const a=n.endsWith("_HCM");if(s&&a){e.set(n.replace("_HCM",""),r);continue}!s&&!a&&e.set(n,r)}return $(this,"highlightColors",e)}get highlightColorNames(){return $(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),u(this,Wn,t)}setMainHighlightColorPicker(t){u(this,ll,t)}editAltText(t,e=!1){var s;(s=i(this,il))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!i(this,se)}editComment(t,e,s,n){var r;(r=i(this,se))==null||r.showDialog(this,t,e,s,n)}selectComment(t,e){const s=i(this,It).get(t),n=s==null?void 0:s.getEditorByUID(e);n==null||n.toggleComment(!0,!0)}updateComment(t){var e;(e=i(this,se))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=i(this,se))==null||e.updatePopupColor(t)}
2removeComment(t){var e;(e=i(this,se))==null||e.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},n=()=>{var r;(r=this._editorUndoBar)==null||r.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:n,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){var n;(n=i(this,se))==null||n.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=i(this,se))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=i(this,se))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(i(this,It).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),n=r=>{r.pageNumber===t&&(this._eventBus.off("editorsrendered",n),e())};this._eventBus.on("editorsrendered",n,qf),await s}getSignature(t){var e;(e=i(this,Zn))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return i(this,Zn)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...qf}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":u(this,rl,e);break}}onPageChanging({pageNumber:t}){u(this,Xn,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();i(this,It).delete(t),i(this,Xn)===t&&u(this,Xn,0)}focusMainContainer(){i(this,Ki).focus()}findParent(t,e){for(const s of i(this,It).values()){const{x:n,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(t>=n&&t<=n+a&&e>=r&&e<=r+o)return s}return null}disableUserSelect(t=!1){i(this,Ac).classList.toggle("noUserSelect",t)}addShouldRescale(t){i(this,na).add(t)}removeShouldRescale(t){i(this,na).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Gr.PDF_TO_CSS_UNITS;for(const s of i(this,na))s.onScaleChanging();(e=i(this,Wn))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),c=b(this,R,hu).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;s.empty();const f=b(this,R,pp).call(this,c),g=i(this,Kt)===V.NONE,y=()=>{const A=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o,text:l});g&&this.showAllEditors("highlight",!0,!0),e&&(A==null||A.editComment())};if(g){this.switchToMode(V.HIGHLIGHT,y);return}y()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){var t;this.commitOrRemove(),(t=this.currentLayer)==null||t.endDrawingSession(!1)}getAndRemoveDataFromAnnotationStorage(t){if(!i(this,Le))return null;const e=`${Zh}${t}`,s=i(this,Le).getRawValue(e);return s&&i(this,Le).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&i(this,Le)&&!i(this,Le).has(t.id)&&i(this,Le).setValue(t.id,t)}a11yAlert(t,e=null){const s=i(this,wc);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,i(this,qn)&&(u(this,qn,!1),b(this,R,Mh).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of i(this,ft))if(e.div.contains(t)){u(this,ra,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!i(this,ra))return;const[t,e]=i(this,ra);u(this,ra,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,R,gp).call(this),this.setEditingState(!0)}removeEditListeners(){b(this,R,Zm).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of i(this,Ps))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of i(this,Ps))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=i(this,is))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];
2for(const n of i(this,ft)){const r=n.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const a of i(this,Ps))if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){W(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const n=this.currentLayer;try{const r=[];for(const l of s){const h=await n.deserialize(l);if(!h)return;r.push(h)}const a=()=>{for(const l of r)b(this,R,mp).call(this,l);b(this,R,bp).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){W(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),i(this,Kt)!==V.NONE&&!this.isEditorHandlingKeyboard&&Wo._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,i(this,qn)&&(u(this,qn,!1),b(this,R,Mh).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(t,e){for(const n of this.getEditors(t))n.pageIndex=e;const s=i(this,sl).get(t);s&&(s.pageIndex=e,i(this,It).set(e,s),i(this,Xi)?s.enable():s.disable())}startUpdatePages(){u(this,sl,new Map(i(this,It))),i(this,It).clear()}endUpdatePages(){u(this,sl,null)}clonePage(t,e){for(const s of this.getEditors(t)){const n=s.serialize(s.mode!==V.HIGHLIGHT);n&&(n.pageIndex=e,n.id=this.getId(),n.isClone=!0,delete n.popupRef,i(this,Le).setValue(n.id,n))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[n,r]of i(this,Le))r.pageIndex===s&&r.isClone&&(i(this,Le).remove(n),e.push(t.deserialize(r).then(a=>{a&&(a.isClone=!0,t.addOrRebuild(a))})));return Promise.all(e)}setEditingState(t){t?(b(this,R,Qm).call(this),b(this,R,tb).call(this),b(this,R,De).call(this,{isEditing:i(this,Kt)!==V.NONE,isEmpty:b(this,R,Ph).call(this),hasSomethingToUndo:i(this,Ms).hasSomethingToUndo(),hasSomethingToRedo:i(this,Ms).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,R,Jm).call(this),b(this,R,eb).call(this),b(this,R,De).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!i(this,Ps)){u(this,Ps,t);for(const e of i(this,Ps))b(this,R,$i).call(this,e.defaultPropertiesToUpdate)}}getId(){return i(this,of).id}get currentLayer(){return i(this,It).get(i(this,Xn))}getLayer(t){return i(this,It).get(t)}get currentPageIndex(){return i(this,Xn)}addLayer(t){i(this,It).set(t.pageIndex,t),i(this,Xi)?t.enable():t.disable()}removeLayer(t){i(this,It).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,n=!1,r=!1,a=!1){var o,l,h,c,d,f;if(i(this,Kt)!==t&&!(i(this,Ds)&&(await i(this,Ds).promise,!i(this,Ds)))){if(u(this,Ds,Promise.withResolvers()),(o=i(this,Wn))==null||o.commitOrRemove(),i(this,Kt)===V.POPUP&&((l=i(this,se))==null||l.hideSidebar()),(h=i(this,se))==null||h.destroyPopup(),u(this,Kt,t),t===V.NONE){this.setEditingState(!1),b(this,R,nb).call(this);for(const g of i(this,Nt).values())g.hideStandaloneCommentButton();(c=this._editorUndoBar)==null||c.hide(),this.toggleComment(null),i(this,Ds).resolve();return}for(const g of i(this,Nt).values())g.addStandaloneCommentButton();t===V.SIGNATURE&&await((d=i(this,Zn))==null?void 0:d.loadSignatures()),s&&xe.clearPointerType(),this.setEditingState(!0),await b(this,R,ib).call(this),this.unselectAll();for(const g of i(this,It).values())g.updateMode(t);if(t===V.POPUP){i(this,el)||u(this,el,await i(this,hl).getAnnotationsByType(new Set(i(this,Ps).map(A=>A._editorType))));const g=new Set,y=[];for(const A of i(this,Nt).values()){const{annotationElementId:v,hasComment:w,deleted:S}=A;v&&g.add(v),w&&!S&&y.push(A.getData())}for(const A of i(this,el)){const{id:v,popupRef:w,contentsObj:S}=A;w&&(S!=null&&S.str)&&!g.has(v)&&!i(this,Yn).has(v)&&y.push(A)}(f=i(this,se))==null||f.showSidebar(y)}if(!e){n&&this.addNewEditorFromKeyboard(),i(this,Ds).resolve();return}for(const g of i(this,Nt).values())g.uid===e?(this.setSelected(g),a?g.editComment():r?g.enterInEditMode():g.focus()):g.unselect();i(this,Ds).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==i(this,Kt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(i(this,Ps)){switch(t){case X.CREATE:this.currentLayer.addNewEditor(e);return;case X.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(i(this,bc)||u(this,bc,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of i(this,ft))s.updateParams(t,e);else for(const s of i(this,Ps))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of i(this,Nt).values())a.editorType===t&&a.show(e);(((r=i(this,bc))==null?void 0:r.get(X.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,R,$i).call(this,[[X.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(i(this,gc)!==t){u(this,gc,t);for(const e of i(this,It).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of i(this,Nt).values())e.pageIndex===t&&(yield e)}getEditor(t){return i(this,Nt).get(t)}addEditor(t){i(this,Nt).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(i(this,gi)&&clearTimeout(i(this,gi)),u(this,gi,setTimeout(()=>{this.focusMainContainer(),u(this,gi,null)},0))),i(this,Nt).delete(t.id),t.annotationElementId&&((e=i(this,Jn))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!i(this,Yn).has(t.annotationElementId))&&((s=i(this,Le))==null||s.remove(t.id))}addDeletedAnnotationElement(t){i(this,Yn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}
2isDeletedAnnotationElement(t){return i(this,Yn).has(t)}removeDeletedAnnotationElement(t){i(this,Yn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){i(this,is)!==t&&(u(this,is,t),t&&b(this,R,$i).call(this,t.propertiesToUpdate))}updateUI(t){i(this,R,rb)===t&&b(this,R,$i).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,R,$i).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(i(this,ft).has(t)){i(this,ft).delete(t),t.unselect(),b(this,R,De).call(this,{hasSelectedEditor:this.hasSelection});return}i(this,ft).add(t),t.select(),b(this,R,$i).call(this,t.propertiesToUpdate),b(this,R,De).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=i(this,Wn))==null||e.commitOrRemove();for(const n of i(this,ft))n!==t&&n.unselect();(s=i(this,se))==null||s.destroyPopup(),i(this,ft).clear(),i(this,ft).add(t),t.select(),b(this,R,$i).call(this,t.propertiesToUpdate),b(this,R,De).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return i(this,ft).values().next().value}unselect(t){t.unselect(),i(this,ft).delete(t),b(this,R,De).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return i(this,ft).size!==0}get isEnterHandled(){return i(this,ft).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;i(this,Ms).undo(),b(this,R,De).call(this,{hasSomethingToUndo:i(this,Ms).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,R,Ph).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){i(this,Ms).redo(),b(this,R,De).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:i(this,Ms).hasSomethingToRedo(),isEmpty:b(this,R,Ph).call(this)})}addCommands(t){i(this,Ms).add(t),b(this,R,De).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,R,Ph).call(this)})}cleanUndoStack(t){i(this,Ms).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...i(this,ft)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(n,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},n=()=>{for(const a of e)b(this,R,mp).call(this,a)};this.addCommands({cmd:s,undo:n,mustExec:!0})}commitOrRemove(){var t;(t=i(this,is))==null||t.commitOrRemove()}hasSomethingToControl(){return i(this,is)||this.hasSelection}selectAll(){for(const t of i(this,ft))t.commit();b(this,R,bp).call(this,i(this,Nt).values())}unselectAll(){var t,e;if(!(i(this,is)&&(i(this,is).commitOrRemove(),i(this,Kt)!==V.NONE))&&!((t=i(this,Wn))!=null&&t.commitOrRemove())&&((e=i(this,se))==null||e.destroyPopup(),!!this.hasSelection)){for(const s of i(this,ft))s.unselect();i(this,ft).clear(),b(this,R,De).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;i(this,er)[0]+=t,i(this,er)[1]+=e;const[n,r]=i(this,er),a=[...i(this,ft)],o=1e3;i(this,bi)&&clearTimeout(i(this,bi)),u(this,bi,setTimeout(()=>{u(this,bi,null),i(this,er)[0]=i(this,er)[1]=0,this.addCommands({cmd:()=>{for(const l of a)i(this,Nt).has(l.id)&&(l.translateInPage(n,r),l.translationDone())},undo:()=>{for(const l of a)i(this,Nt).has(l.id)&&(l.translateInPage(-n,-r),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),u(this,pi,new Map);for(const t of i(this,ft))i(this,pi).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!i(this,pi))return!1;this.disableUserSelect(!1);const t=i(this,pi);u(this,pi,null);let e=!1;for(const[{x:n,y:r,pageIndex:a},o]of t)o.newX=n,o.newY=r,o.newPageIndex=a,e||(e=n!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(n,r,a,o)=>{if(i(this,Nt).has(n.id)){const l=i(this,It).get(o);l?n._setParentAndPosition(l,r,a):(n.pageIndex=o,n.x=r,n.y=a)}};return this.addCommands({cmd:()=>{for(const[n,{newX:r,newY:a,newPageIndex:o}]of t)s(n,r,a,o)},undo:()=>{for(const[n,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(n,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(i(this,pi))for(const s of i(this,pi).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||i(this,ft).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return i(this,is)===t}getActive(){return i(this,is)}getMode(){return i(this,Kt)}isEditingMode(){return i(this,Kt)!==V.NONE}get imageManager(){return $(this,"imageManager",new up)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:n,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(h,c,d,f)=>({x:(c-n)/a,y:1-(h+d-s)/r,width:f/a,height:d/r});break;case"180":o=(h,c,d,f)=>({x:1-(h+d-s)/r,y:1-(c+f-n)/a,width:d/r,height:f/a});break;case"270":o=(h,c,d,f)=>({x:1-(c+f-n)/a,y:(h-s)/r,width:f/a,height:d/r});break;default:o=(h,c,d,f)=>({x:(h-s)/r,y:(c-n)/a,width:d/r,height:f/a});break}const l=[];for(let h=0,c=e.rangeCount;h<c;h++){const d=e.getRangeAt(h);if(!d.collapsed)for(const{x:f,y:g,width:y,height:A}of d.getClientRects())y===0||A===0||l.push(o(f,g,y,A))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(i(this,nl)||u(this,nl,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=i(this,nl))==null||e.delete(t)}renderAnnotationElement(t){var n;const e=(n=i(this,nl))==null?void 0:n.get(t.data.id);if(!e)return;const s=i(this,Le).getRawValue(e);s&&(i(this,Kt)===V.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const n=(r=i(this,Jn))==null?void 0:r.get(t);n&&(n.setCanvas(e,s),i(this,Jn).delete(t))}addMissingCanvas(t,e){(i(this,Jn)||u(this,Jn,new Map)).set(t,e)}};
2tl=new WeakMap,is=new WeakMap,el=new WeakMap,Nt=new WeakMap,It=new WeakMap,sl=new WeakMap,il=new WeakMap,Le=new WeakMap,nl=new WeakMap,Ms=new WeakMap,se=new WeakMap,Vn=new WeakMap,Wn=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,pi=new WeakMap,Ps=new WeakMap,na=new WeakMap,uc=new WeakMap,fc=new WeakMap,rl=new WeakMap,pc=new WeakMap,gi=new WeakMap,Kn=new WeakMap,al=new WeakMap,qn=new WeakMap,mi=new WeakMap,of=new WeakMap,Xi=new WeakMap,ol=new WeakMap,gc=new WeakMap,Qn=new WeakMap,ra=new WeakMap,ll=new WeakMap,Jn=new WeakMap,mc=new WeakMap,Kt=new WeakMap,ft=new WeakMap,Yi=new WeakMap,Zn=new WeakMap,tr=new WeakMap,bc=new WeakMap,hl=new WeakMap,yc=new WeakMap,er=new WeakMap,bi=new WeakMap,Ki=new WeakMap,Ac=new WeakMap,wc=new WeakMap,Ds=new WeakMap,R=new WeakSet,hu=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},pp=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of i(this,It).values())if(s.hasTextLayer(t))return s;return null},Ym=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,R,hu).call(this,t).closest(".textLayer"),n=this.getSelectionBoxes(s);n&&(i(this,mi)||u(this,mi,new IA(this)),i(this,mi).show(s,n,this.direction==="ltr"))},Km=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){i(this,Yi)&&((r=i(this,mi))==null||r.hide(),u(this,Yi,null),b(this,R,De).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===i(this,Yi))return;const n=b(this,R,hu).call(this,t).closest(".textLayer");if(!n){i(this,Yi)&&((a=i(this,mi))==null||a.hide(),u(this,Yi,null),b(this,R,De).call(this,{hasSelectedText:!1}));return}if((o=i(this,mi))==null||o.hide(),u(this,Yi,e),b(this,R,De).call(this,{hasSelectedText:!0}),!(i(this,Kt)!==V.HIGHLIGHT&&i(this,Kt)!==V.NONE)&&(i(this,Kt)===V.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),u(this,qn,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=i(this,Kt)===V.HIGHLIGHT?b(this,R,pp).call(this,n):null;if(l==null||l.toggleDrawing(),i(this,ol)){const h=new AbortController,c=this.combinedSignal(h),d=f=>{f.type==="pointerup"&&f.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&b(this,R,Mh).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("blur",d,{signal:c})}else l==null||l.toggleDrawing(!0),b(this,R,Mh).call(this,"main_toolbar")}},Mh=function(t=""){i(this,Kt)===V.HIGHLIGHT?this.highlightSelection(t):i(this,uc)&&b(this,R,Ym).call(this)},qm=function(){document.addEventListener("selectionchange",b(this,R,Km).bind(this),{signal:this._signal})},Qm=function(){if(i(this,Kn))return;u(this,Kn,new AbortController);const t=this.combinedSignal(i(this,Kn));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Jm=function(){var t;(t=i(this,Kn))==null||t.abort(),u(this,Kn,null)},gp=function(){if(i(this,Qn))return;u(this,Qn,new AbortController);const t=this.combinedSignal(i(this,Qn));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Zm=function(){var t;(t=i(this,Qn))==null||t.abort(),u(this,Qn,null)},tb=function(){if(i(this,Vn))return;u(this,Vn,new AbortController);const t=this.combinedSignal(i(this,Vn));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})},eb=function(){var t;(t=i(this,Vn))==null||t.abort(),u(this,Vn,null)},sb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},De=function(t){Object.entries(t).some(([s,n])=>i(this,yc)[s]!==n)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(i(this,yc),t)}),i(this,Kt)===V.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,R,$i).call(this,[[X.HIGHLIGHT_FREE,!0]]))},$i=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},ib=async function(){if(!i(this,Xi)){u(this,Xi,!0);const t=[];for(const e of i(this,It).values())t.push(e.enable());await Promise.all(t);for(const e of i(this,Nt).values())e.enable()}},nb=function(){if(this.unselectAll(),i(this,Xi)){u(this,Xi,!1);for(const t of i(this,It).values())t.disable();for(const t of i(this,Nt).values())t.disable()}},mp=function(t){const e=i(this,It).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},rb=function(){let t=null;for(t of i(this,ft));return t},Ph=function(){if(i(this,Nt).size===0)return!0;
2if(i(this,Nt).size===1)for(const t of i(this,Nt).values())return t.isEmpty();return!1},bp=function(t){for(const e of i(this,ft))e.unselect();i(this,ft).clear();for(const e of t)e.isEmpty()||(i(this,ft).add(e),e.select());b(this,R,De).call(this,{hasSelectedEditor:this.hasSelection})},_(Wo,"TRANSLATE_SMALL",1),_(Wo,"TRANSLATE_BIG",10);let Lo=Wo;var ie,yi,Xs,cl,Ai,ns,dl,wi,Xe,qi,aa,vi,sr,oi,Dh,cu;const Ie=class Ie{constructor(t){m(this,oi);m(this,ie,null);m(this,yi,!1);m(this,Xs,null);m(this,cl,null);m(this,Ai,null);m(this,ns,null);m(this,dl,!1);m(this,wi,null);m(this,Xe,null);m(this,qi,null);m(this,aa,null);m(this,vi,!1);u(this,Xe,t),u(this,vi,t._uiManager.useNewAltTextFlow),i(Ie,sr)||u(Ie,sr,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){Ie._l10n??(Ie._l10n=t)}async render(){const t=u(this,Xs,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=u(this,cl,document.createElement("span"));t.append(e),i(this,vi)?(t.classList.add("new"),t.setAttribute("data-l10n-id",i(Ie,sr).missing),e.setAttribute("data-l10n-id",i(Ie,sr)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=i(this,Xe)._uiManager._signal;t.addEventListener("contextmenu",js,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const n=r=>{r.preventDefault(),i(this,Xe)._uiManager.editAltText(i(this,Xe)),i(this,vi)&&i(this,Xe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:i(this,oi,Dh)}})};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(u(this,dl,!0),n(r))},{signal:s}),await b(this,oi,cu).call(this),t}finish(){i(this,Xs)&&(i(this,Xs).focus({focusVisible:i(this,dl)}),u(this,dl,!1))}isEmpty(){return i(this,vi)?i(this,ie)===null:!i(this,ie)&&!i(this,yi)}hasData(){return i(this,vi)?i(this,ie)!==null||!!i(this,qi):this.isEmpty()}get guessedText(){return i(this,qi)}async setGuessedText(t){i(this,ie)===null&&(u(this,qi,t),u(this,aa,await Ie._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,oi,cu).call(this))}toggleAltTextBadge(t=!1){var e;if(!i(this,vi)||i(this,ie)){(e=i(this,wi))==null||e.remove(),u(this,wi,null);return}if(!i(this,wi)){const s=u(this,wi,document.createElement("div"));s.className="noAltTextBadge",i(this,Xe).div.append(s)}i(this,wi).classList.toggle("hidden",!t)}serialize(t){let e=i(this,ie);return!t&&i(this,qi)===e&&(e=i(this,aa)),{altText:e,decorative:i(this,yi),guessedText:i(this,qi),textWithDisclaimer:i(this,aa)}}get data(){return{altText:i(this,ie),decorative:i(this,yi)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:n,cancel:r=!1}){s&&(u(this,qi,s),u(this,aa,n)),!(i(this,ie)===t&&i(this,yi)===e)&&(r||(u(this,ie,t),u(this,yi,e)),b(this,oi,cu).call(this))}toggle(t=!1){i(this,Xs)&&(!t&&i(this,ns)&&(clearTimeout(i(this,ns)),u(this,ns,null)),i(this,Xs).disabled=!t)}shown(){i(this,Xe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:i(this,oi,Dh)}})}destroy(){var t,e;(t=i(this,Xs))==null||t.remove(),u(this,Xs,null),u(this,cl,null),u(this,Ai,null),(e=i(this,wi))==null||e.remove(),u(this,wi,null)}};ie=new WeakMap,yi=new WeakMap,Xs=new WeakMap,cl=new WeakMap,Ai=new WeakMap,ns=new WeakMap,dl=new WeakMap,wi=new WeakMap,Xe=new WeakMap,qi=new WeakMap,aa=new WeakMap,vi=new WeakMap,sr=new WeakMap,oi=new WeakSet,Dh=function(){return i(this,ie)&&"added"||i(this,ie)===null&&this.guessedText&&"review"||"missing"},cu=async function(){var n,r,a;const t=i(this,Xs);if(!t)return;if(i(this,vi)){if(t.classList.toggle("done",!!i(this,ie)),t.setAttribute("data-l10n-id",i(Ie,sr)[i(this,oi,Dh)]),(n=i(this,cl))==null||n.setAttribute("data-l10n-id",i(Ie,sr)[`${i(this,oi,Dh)}-label`]),!i(this,ie)){(r=i(this,Ai))==null||r.remove();return}}else{if(!i(this,ie)&&!i(this,yi)){t.classList.remove("done"),(a=i(this,Ai))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=i(this,Ai);if(!e){u(this,Ai,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${i(this,Xe).id}`;const o=100,l=i(this,Xe)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(i(this,ns)),u(this,ns,null)},{once:!0}),t.addEventListener("mouseenter",()=>{u(this,ns,setTimeout(()=>{u(this,ns,null),i(this,Ai).classList.add("show"),i(this,Xe)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;i(this,ns)&&(clearTimeout(i(this,ns)),u(this,ns,null)),(h=i(this,Ai))==null||h.classList.remove("show")},{signal:l})}i(this,yi)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=i(this,ie)),e.parentNode||t.append(e);const s=i(this,Xe).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},m(Ie,sr,null),_(Ie,"_l10n",null);let Ku=Ie;var ue,Is,oa,vt,vc,ir,Ls,nr,rr,la,Sc,yp;class Qd{constructor(t){m(this,Sc);m(this,ue,null);m(this,Is,null);m(this,oa,!1);m(this,vt,null);m(this,vc,null);m(this,ir,null);m(this,Ls,null);m(this,nr,null);m(this,rr,!1);m(this,la,null);u(this,vt,t)}renderForToolbar(){const t=u(this,Is,document.createElement("button"));
2return t.className="comment",b(this,Sc,yp).call(this,t,!1)}renderForStandalone(){const t=u(this,ue,document.createElement("button"));t.className="annotationCommentButton";const e=i(this,vt).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(i(this,vt)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const n=i(this,vt).commentButtonColor;n&&(s.backgroundColor=n)}return b(this,Sc,yp).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=i(this,ue)??i(this,Is))==null||t.focus()},0)}onUpdatedColor(){if(!i(this,ue))return;const t=i(this,vt).commentButtonColor;t&&(i(this,ue).style.backgroundColor=t),i(this,vt)._uiManager.updatePopupColor(i(this,vt))}get commentButtonWidth(){var t;return(((t=i(this,ue))==null?void 0:t.getBoundingClientRect().width)??0)/i(this,vt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(i(this,la))return i(this,la);if(!i(this,ue))return null;const{x:t,y:e,height:s}=i(this,ue).getBoundingClientRect(),{x:n,y:r,width:a,height:o}=i(this,vt).parent.boundingClientRect;return[(t-n)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){u(this,la,t)}hasDefaultPopupPosition(){return i(this,la)===null}removeStandaloneCommentButton(){var t;(t=i(this,ue))==null||t.remove(),u(this,ue,null)}removeToolbarCommentButton(){var t;(t=i(this,Is))==null||t.remove(),u(this,Is,null)}setCommentButtonStates({selected:t,hasPopup:e}){i(this,ue)&&(i(this,ue).classList.toggle("selected",t),i(this,ue).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,n;if(e)[s,n]=e;else{[s,n]=i(this,vt).commentButtonPosition;const{width:c,height:d,x:f,y:g}=i(this,vt);s=f+s*c,n=g+n*d}const r=i(this,vt).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;i(this,vt)._uiManager.editComment(i(this,vt),a+s*l,o+n*h,{...t,parentDimensions:r})}finish(){i(this,Is)&&(i(this,Is).focus({focusVisible:i(this,oa)}),u(this,oa,!1))}isDeleted(){return i(this,rr)||i(this,Ls)===""}isEmpty(){return i(this,Ls)===null}hasBeenEdited(){return this.isDeleted()||i(this,Ls)!==i(this,vc)}serialize(){return this.data}get data(){return{text:i(this,Ls),richText:i(this,ir),date:i(this,nr),deleted:this.isDeleted()}}set data(t){if(t!==i(this,Ls)&&u(this,ir,null),t===null){u(this,Ls,""),u(this,rr,!0);return}u(this,Ls,t),u(this,nr,new Date),u(this,rr,!1)}restoreData({text:t,richText:e,date:s}){u(this,Ls,t),u(this,ir,e),u(this,nr,s),u(this,rr,!1)}setInitialText(t,e=null){u(this,vc,t),this.data=t,u(this,nr,null),u(this,ir,e)}shown(){}destroy(){var t,e;(t=i(this,Is))==null||t.remove(),u(this,Is,null),(e=i(this,ue))==null||e.remove(),u(this,ue,null),u(this,Ls,""),u(this,ir,null),u(this,nr,null),u(this,vt,null),u(this,oa,!1),u(this,rr,!1)}}ue=new WeakMap,Is=new WeakMap,oa=new WeakMap,vt=new WeakMap,vc=new WeakMap,ir=new WeakMap,Ls=new WeakMap,nr=new WeakMap,rr=new WeakMap,la=new WeakMap,Sc=new WeakSet,yp=function(t,e){if(!i(this,vt)._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=[i(this,vt)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=i(this,vt)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",js,{signal:s}),e&&(t.addEventListener("focusin",r=>{i(this,vt)._focusEventsAllowed=!1,Lt(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{i(this,vt)._focusEventsAllowed=!0,Lt(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const n=r=>{r.preventDefault(),t===i(this,Is)?this.edit():i(this,vt).toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(u(this,oa,!0),n(r))},{signal:s}),t.addEventListener("pointerenter",()=>{i(this,vt).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{i(this,vt).toggleComment(!1,!1)},{signal:s}),t};var ul,ha,Ec,xc,Cc,Tc,_c,Qi,ca,Ji,da,Zi,$r,ab,ob,lb;const Qg=class Qg{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:n=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){m(this,$r);m(this,ul);m(this,ha,!1);m(this,Ec,null);m(this,xc);m(this,Cc);m(this,Tc);m(this,_c);m(this,Qi,null);m(this,ca);m(this,Ji,null);m(this,da);
2m(this,Zi,null);u(this,ul,t),u(this,Ec,s),u(this,xc,e),u(this,Cc,n),u(this,Tc,r),u(this,_c,a),u(this,da,new AbortController),u(this,ca,AbortSignal.any([o,i(this,da).signal])),t.addEventListener("touchstart",b(this,$r,ab).bind(this),{passive:!1,signal:i(this,ca)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Hi.pixelRatio}destroy(){var t,e;(t=i(this,da))==null||t.abort(),u(this,da,null),(e=i(this,Qi))==null||e.abort(),u(this,Qi,null)}};ul=new WeakMap,ha=new WeakMap,Ec=new WeakMap,xc=new WeakMap,Cc=new WeakMap,Tc=new WeakMap,_c=new WeakMap,Qi=new WeakMap,ca=new WeakMap,Ji=new WeakMap,da=new WeakMap,Zi=new WeakMap,$r=new WeakSet,ab=function(t){var n,r,a;if((n=i(this,xc))!=null&&n.call(this))return;if(t.touches.length===1){if(i(this,Qi))return;const o=u(this,Qi,new AbortController),l=AbortSignal.any([i(this,ca),o.signal]),h=i(this,ul),c={capture:!0,signal:l,passive:!1},d=f=>{var g;f.pointerType==="touch"&&((g=i(this,Qi))==null||g.abort(),u(this,Qi,null))};h.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(Lt(f),d(f))},c),h.addEventListener("pointerup",d,c),h.addEventListener("pointercancel",d,c);return}if(!i(this,Zi)){u(this,Zi,new AbortController);const o=AbortSignal.any([i(this,ca),i(this,Zi).signal]),l=i(this,ul),h={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",b(this,$r,ob).bind(this),h);const c=b(this,$r,lb).bind(this);l.addEventListener("touchend",c,h),l.addEventListener("touchcancel",c,h),h.capture=!0,l.addEventListener("pointerdown",Lt,h),l.addEventListener("pointermove",Lt,h),l.addEventListener("pointercancel",Lt,h),l.addEventListener("pointerup",Lt,h),(r=i(this,Cc))==null||r.call(this)}if(Lt(t),t.touches.length!==2||(a=i(this,Ec))!=null&&a.call(this)){u(this,Ji,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),u(this,Ji,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},ob=function(t){var x;if(!i(this,Ji)||t.touches.length!==2)return;Lt(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:n,screenY:r}=e,{screenX:a,screenY:o}=s,l=i(this,Ji),{touch0X:h,touch0Y:c,touch1X:d,touch1Y:f}=l,g=d-h,y=f-c,A=a-n,v=o-r,w=Math.hypot(A,v)||1,S=Math.hypot(g,y)||1;if(!i(this,ha)&&Math.abs(S-w)<=Qg.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!i(this,ha)){u(this,ha,!0);return}const E=[(n+a)/2,(r+o)/2];(x=i(this,Tc))==null||x.call(this,E,S,w)},lb=function(t){var e;t.touches.length>=2||(i(this,Zi)&&(i(this,Zi).abort(),u(this,Zi,null),(e=i(this,_c))==null||e.call(this)),i(this,Ji)&&(Lt(t),u(this,Ji,null),u(this,ha,!1)))};let qu=Qg;var ua,Ys,_t,ht,tn,fl,ar,kc,fe,fa,en,Rs,or,Mc,pa,rs,Pc,ga,sn,Si,pl,gl,Fs,ma,Dc,lf,z,Ap,Ic,wp,du,hb,cb,vp,uu,Sp,db,ub,fb,Ep,pb,xp,gb,mb,bb,Cp,Ih;const j=class j{constructor(t){m(this,z);m(this,ua,null);m(this,Ys,null);m(this,_t,null);m(this,ht,null);m(this,tn,null);m(this,fl,!1);m(this,ar,null);m(this,kc,"");m(this,fe,null);m(this,fa,null);m(this,en,null);m(this,Rs,null);m(this,or,null);m(this,Mc,"");m(this,pa,!1);m(this,rs,null);m(this,Pc,!1);m(this,ga,!1);m(this,sn,!1);m(this,Si,null);m(this,pl,0);m(this,gl,0);m(this,Fs,null);m(this,ma,null);_(this,"isSelected",!1);_(this,"_isCopy",!1);_(this,"_editToolbar",null);_(this,"_initialOptions",Object.create(null));_(this,"_initialData",null);_(this,"_isVisible",!0);_(this,"_uiManager",null);_(this,"_focusEventsAllowed",!0);m(this,Dc,!1);m(this,lf,j._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,n],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=j.prototype._resizeWithKeyboard,e=Lo.TRANSLATE_SMALL,s=Lo.TRANSLATE_BIG;return $(this,"_resizerKeyboardManager",new Io([[["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"],j.prototype._stopResizingWithKeyboard]]))}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 $(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new OA({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(j._l10n??(j._l10n=t),j._l10nAlert??(j._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"})),j._l10nResizer??(j._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"})),j._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);j._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){it("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return i(this,Dc)}set _isDraggable(t){var e;u(this,Dc,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=i(this,lf)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(b(this,z,Ih).call(this),(e=i(this,Rs))==null||e.remove(),u(this,Rs,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(i(this,pa)?u(this,pa,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,n){const[r,a]=this.parentDimensions;[s,n]=this.screenToPageTranslation(s,n),this.x=(t+s)/r,this.y=(e+n)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,n]=this.parentDimensions;this.setAt(t*s,e*n,this.width*s,this.height*n),this._onTranslated()}translate(t,e){b(this,z,Ap).call(this,this.parentDimensions,t,e)}translateInPage(t,e){i(this,rs)||u(this,rs,[this.x,this.y,this.width,this.height]),b(this,z,Ap).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){i(this,rs)||u(this,rs,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[n,r]}=this;if(this.x+=t/n,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,h]=this.getBaseTranslation();a+=l,o+=h;const{style:c}=s;c.left=`${(100*a).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!i(this,rs)&&(i(this,rs)[0]!==this.x||i(this,rs)[1]!==this.y)}get _hasBeenResized(){return!!i(this,rs)&&(i(this,rs)[2]!==this.width||i(this,rs)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=j,n=s/t,r=s/e;switch(this.rotation){case 90:return[-n,r];case 180:return[n,r];case 270:return[n,-r];default:return[-n,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,n]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=n,r*=s,a*=n,this._mustFixPosition)switch(t){case 0:r=Tt(r,0,s-o),a=Tt(a,0,n-l);break;case 90:r=Tt(r,0,s-l),a=Tt(a,o,n);break;case 180:r=Tt(r,o,s),a=Tt(a,l,n);break;case 270:r=Tt(r,l,s),a=Tt(a,0,n-o);break}this.x=r/=s,this.y=a/=n;const[h,c]=this.getBaseTranslation();r+=h,a+=c,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return b(s=j,Ic,wp).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=j,Ic,wp).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=i(this,_t))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||i(this,ga))return this._editToolbar;this._editToolbar=new cp(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}
2removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=i(this,_t))==null||e.destroy()}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return i(this,_t)||(Ku.initialize(j._l10n),u(this,_t,new Ku(this)),i(this,ua)&&(i(this,_t).data=i(this,ua),u(this,ua,null))),i(this,_t)}get altTextData(){var t;return(t=i(this,_t))==null?void 0:t.data}set altTextData(t){i(this,_t)&&(i(this,_t).data=t)}get guessedAltText(){var t;return(t=i(this,_t))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=i(this,_t))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=i(this,_t))==null?void 0:e.serialize(t)}hasAltText(){return!!i(this,_t)&&!i(this,_t).isEmpty()}hasAltTextData(){var t;return((t=i(this,_t))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=i(this,ht))==null||t.focusButton()}addCommentButton(){return this.canAddComment?i(this,ht)||u(this,ht,new Qd(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(i(this,tn)){this._uiManager.isEditingMode()&&i(this,tn).classList.remove("hidden");return}this.hasComment&&(u(this,tn,i(this,ht).renderForStandalone()),this.div.append(i(this,tn)))}}removeStandaloneCommentButton(){i(this,ht).removeStandaloneCommentButton(),u(this,tn,null)}hideStandaloneCommentButton(){var t;(t=i(this,tn))==null||t.classList.add("hidden")}get comment(){if(!i(this,ht))return null;const{data:{richText:t,text:e,date:s,deleted:n}}=i(this,ht);return{text:e,richText:t,date:s,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){i(this,ht)||u(this,ht,new Qd(this)),typeof t=="object"&&t!==null?i(this,ht).restoreData(t):i(this,ht).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||(i(this,ht)||u(this,ht,new Qd(this)),i(this,ht).setInitialText(t,s),!this.annotationElementId))return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){var t;return(t=i(this,ht))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=i(this,ht))==null?void 0:t.isDeleted()}get hasComment(){return!!i(this,ht)&&!i(this,ht).isEmpty()&&!i(this,ht).isDeleted()}async editComment(t){i(this,ht)||u(this,ht,new Qd(this)),i(this,ht).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){i(this,ht).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,n]=t.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=n-100,h=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,h,n]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){i(this,ht).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=i(this,fl)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),b(this,z,xp).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[n,r]=this.getInitialTranslation();return this.translate(n,r),Vm(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(i(this,ma)||u(this,ma,new qu({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,z,db).bind(this),onPinching:b(this,z,ub).bind(this),onPinchEnd:b(this,z,fb).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=bt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(u(this,pa,!0),this._isDraggable){b(this,z,pb).call(this,t);return}b(this,z,Ep).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){i(this,Si)&&clearTimeout(i(this,Si)),u(this,Si,setTimeout(()=>{var t;u(this,Si,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const n=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/n,c=e/n,d=this.x*r,f=this.y*a,g=this.width*r,y=this.height*a;switch(s){case 0:return[d+h+o,a-f-c-y+l,d+h+g+o,a-f-c+l];case 90:return[d+c+o,a-f+h+l,d+c+y+o,a-f+h+g+l];case 180:return[d-h-g+o,a-f+c+l,d-h+o,a-f+c+y+l];case 270:return[d-c-y+o,a-f-h-g+l,d-c+o,a-f-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,n,r,a]=t,o=r-s,l=a-n;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-n,l,o];case 180:return[r,e-n,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&j._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=i(this,ht))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:n,deleted:r,richText:a},uid:o,pageIndex:l,creationDate:h,modificationDate:c}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:h,modificationDate:s||c,popupRef:!r,color:e,opacity:n}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),u(this,ga,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),u(this,ga,!1),!0):!1}isInEditMode(){return i(this,ga)}shouldGetKeyboardEvents(){return i(this,sn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:n}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&n>0&&t<r&&s>0}rebuild(){b(this,z,xp).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(t,e,s){const n=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});n.rotation=t.rotation,u(n,ua,t.accessibilityData),n._isCopy=t.isCopy||!1;const[r,a]=n.pageDimensions,[o,l,h,c]=n.getRectInCurrentCoords(t.rect,a);return n.x=o/r,n.y=l/a,n.width=h/r,n.height=c/a,n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e,s;if((t=i(this,or))==null||t.abort(),u(this,or,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),i(this,Si)&&(clearTimeout(i(this,Si)),u(this,Si,null)),b(this,z,Ih).call(this),this.removeEditToolbar(),i(this,Fs)){for(const n of i(this,Fs).values())clearTimeout(n);u(this,Fs,null)}this.parent=null,(e=i(this,ma))==null||e.destroy(),u(this,ma,null),(s=i(this,Rs))==null||s.remove(),u(this,Rs,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,z,hb).call(this),i(this,fe).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,n,r,a]=this.getPDFRect();return[j._round(s+(r-s)*t),j._round(n+(a-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return i(this,ht).commentPopupPositionInLayer}set commentPopupPosition(t){i(this,ht).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return i(this,ht).hasDefaultPopupPosition()}get commentButtonWidth(){return i(this,ht).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=i(this,ht))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),u(this,en,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=i(this,fe).children;if(!i(this,Ys)){u(this,Ys,Array.from(e));const a=b(this,z,gb).bind(this),o=b(this,z,mb).bind(this),l=this._uiManager._signal;for(const h of i(this,Ys)){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",a,{signal:l}),h.addEventListener("blur",o,{signal:l}),h.addEventListener("focus",b(this,z,bb).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",j._l10nResizer[c])}}const s=i(this,Ys)[0];let n=0;for(const a of e){if(a===s)break;n++}const r=(360-this.rotation+this.parentRotation)%360/90*(i(this,Ys).length/4);if(r!==n){if(r<n)for(let o=0;o<n-r;o++)i(this,fe).append(i(this,fe).firstElementChild);else if(r>n)for(let o=0;o<r-n;o++)i(this,fe).firstElementChild.before(i(this,fe).lastElementChild);let a=0;for(const o of e){const h=i(this,Ys)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",j._l10nResizer[h])}}b(this,z,Cp).call(this,0),u(this,sn,!0),i(this,fe).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){i(this,sn)&&b(this,z,Sp).call(this,i(this,Mc),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,z,Ih).call(this),this.div.focus()}select(){var t,e,s;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var n,r;(n=this.div)!=null&&n.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=i(this,_t))==null||s.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,s,n,r;this.isSelected&&(this.isSelected=!1,(t=i(this,fe))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(n=this._editToolbar)==null||n.hide(),(r=i(this,_t))==null||r.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 i(this,Pc)}set isEditing(t){u(this,Pc,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){i(this,Fs)||u(this,Fs,new Map);const{action:s}=t;let n=i(this,Fs).get(s);n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(t),i(this,Fs).delete(s),i(this,Fs).size===0&&u(this,Fs,null)},j._telemetryTimeout),i(this,Fs).set(s,n);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}
2show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),u(this,fl,!1)}disable(){this.div&&(this.div.tabIndex=-1),u(this,fl,!0)}updateFakeAnnotationElement(t){if(!i(this,Rs)&&!this.deleted){u(this,Rs,t.addFakeAnnotation(this));return}if(this.deleted){i(this,Rs).remove(),u(this,Rs,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&i(this,Rs).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"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};ua=new WeakMap,Ys=new WeakMap,_t=new WeakMap,ht=new WeakMap,tn=new WeakMap,fl=new WeakMap,ar=new WeakMap,kc=new WeakMap,fe=new WeakMap,fa=new WeakMap,en=new WeakMap,Rs=new WeakMap,or=new WeakMap,Mc=new WeakMap,pa=new WeakMap,rs=new WeakMap,Pc=new WeakMap,ga=new WeakMap,sn=new WeakMap,Si=new WeakMap,pl=new WeakMap,gl=new WeakMap,Fs=new WeakMap,ma=new WeakMap,Dc=new WeakMap,lf=new WeakMap,z=new WeakSet,Ap=function([t,e],s,n){[s,n]=this.screenToPageTranslation(s,n),this.x+=s/t,this.y+=n/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Ic=new WeakSet,wp=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},du=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},hb=function(){if(i(this,fe))return;u(this,fe,document.createElement("div")),i(this,fe).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const n=document.createElement("div");i(this,fe).append(n),n.classList.add("resizer",s),n.setAttribute("data-resizer-name",s),n.addEventListener("pointerdown",b(this,z,cb).bind(this,s),{signal:e}),n.addEventListener("contextmenu",js,{signal:e}),n.tabIndex=-1}this.div.prepend(i(this,fe))},cb=function(t,e){var c;e.preventDefault();const{isMac:s}=bt.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=i(this,_t))==null||c.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,u(this,fa,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,z,Sp).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Lt,{passive:!1,signal:a}),window.addEventListener("contextmenu",js,{signal:a}),u(this,en,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var d;r.abort(),this.parent.togglePointerEvents(!0),(d=i(this,_t))==null||d.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,z,uu).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},vp=function(t,e,s,n){this.width=s,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},uu=function(){if(!i(this,en))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:n}=i(this,en);u(this,en,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===n||this.addCommands({cmd:b(this,z,vp).bind(this,r,a,o,l),undo:b(this,z,vp).bind(this,t,e,s,n),mustExec:!0})},Sp=function(t,e){const[s,n]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=j.MIN_SIZE/s,c=j.MIN_SIZE/n,d=b(this,z,du).call(this,this.rotation),f=(F,U)=>[d[0]*F+d[2]*U,d[1]*F+d[3]*U],g=b(this,z,du).call(this,360-this.rotation),y=(F,U)=>[g[0]*F+g[2]*U,g[1]*F+g[3]*U];let A,v,w=!1,S=!1;switch(t){case"topLeft":w=!0,A=(F,U)=>[0,0],v=(F,U)=>[F,U];break;case"topMiddle":A=(F,U)=>[F/2,0],v=(F,U)=>[F/2,U];break;case"topRight":w=!0,A=(F,U)=>[F,0],v=(F,U)=>[0,U];break;case"middleRight":S=!0,A=(F,U)=>[F,U/2],v=(F,U)=>[0,U/2];break;case"bottomRight":w=!0,A=(F,U)=>[F,U],v=(F,U)=>[0,0];break;case"bottomMiddle":A=(F,U)=>[F/2,U],v=(F,U)=>[F/2,0];break;case"bottomLeft":w=!0,A=(F,U)=>[0,U],v=(F,U)=>[F,0];break;case"middleLeft":S=!0,A=(F,U)=>[0,U/2],v=(F,U)=>[F,U/2];break}const E=A(o,l),x=v(o,l);let C=f(...x);
2const T=j._round(r+C[0]),k=j._round(a+C[1]);let P=1,M=1,L,O;if(e.fromKeyboard)({deltaX:L,deltaY:O}=e);else{const{screenX:F,screenY:U}=e,[Gt,$t]=i(this,fa);[L,O]=this.screenToPageTranslation(F-Gt,U-$t),i(this,fa)[0]=F,i(this,fa)[1]=U}if([L,O]=y(L/s,O/n),w){const F=Math.hypot(o,l);P=M=Math.max(Math.min(Math.hypot(x[0]-E[0]-L,x[1]-E[1]-O)/F,1/o,1/l),h/o,c/l)}else S?P=Tt(Math.abs(x[0]-E[0]-L),h,1)/o:M=Tt(Math.abs(x[1]-E[1]-O),c,1)/l;const Q=j._round(o*P),J=j._round(l*M);C=f(...v(Q,J));const q=T-C[0],Ft=k-C[1];i(this,rs)||u(this,rs,[this.x,this.y,this.width,this.height]),this.width=Q,this.height=J,this.x=q,this.y=Ft,this.setDims(),this.fixAndSetPosition(),this._onResizing()},db=function(){var t;u(this,en,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=i(this,_t))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},ub=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=b(this,z,du).call(this,this.rotation),o=(T,k)=>[a[0]*T+a[2]*k,a[1]*T+a[3]*k],[l,h]=this.parentDimensions,c=this.x,d=this.y,f=this.width,g=this.height,y=j.MIN_SIZE/l,A=j.MIN_SIZE/h;r=Math.max(Math.min(r,1/f,1/g),y/f,A/g);
2const v=j._round(f*r),w=j._round(g*r);if(v===f&&w===g)return;i(this,rs)||u(this,rs,[c,d,f,g]);const S=o(f/2,g/2),E=j._round(c+S[0]),x=j._round(d+S[1]),C=o(v/2,w/2);this.x=E-C[0],this.y=x-C[1],this.width=v,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},fb=function(){var t;(t=i(this,_t))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,z,uu).call(this)},Ep=function(t){const{isMac:e}=bt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},pb=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const n=new AbortController,r=this._uiManager.combinedSignal(n),a={capture:!0,passive:!1,signal:r},o=h=>{n.abort(),u(this,ar,null),u(this,pa,!1),this._uiManager.endDragSession()||b(this,z,Ep).call(this,h),s&&this._onStopDragging()};e&&(u(this,pl,t.clientX),u(this,gl,t.clientY),u(this,ar,t.pointerId),u(this,kc,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:d,pointerId:f}=h;if(f!==i(this,ar)){Lt(h);return}const[g,y]=this.screenToPageTranslation(c-i(this,pl),d-i(this,gl));u(this,pl,c),u(this,gl,d),this._uiManager.dragSelectedEditors(g,y)},a),window.addEventListener("touchmove",Lt,a),window.addEventListener("pointerdown",h=>{h.pointerType===i(this,kc)&&(i(this,ma)||h.isPrimary)&&o(h),Lt(h)},a));const l=h=>{if(!i(this,ar)||i(this,ar)===h.pointerId){o(h);return}Lt(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},xp=function(){if(i(this,or)||!this.div)return;u(this,or,new AbortController);const t=this._uiManager.combinedSignal(i(this,or));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},gb=function(t){j._resizerKeyboardManager.exec(this,t)},mb=function(t){var e;i(this,sn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==i(this,fe)&&b(this,z,Ih).call(this)},bb=function(t){u(this,Mc,i(this,sn)?t:"")},Cp=function(t){if(i(this,Ys))for(const e of i(this,Ys))e.tabIndex=t},Ih=function(){u(this,sn,!1),b(this,z,Cp).call(this,-1),b(this,z,uu).call(this)},m(j,Ic),_(j,"_l10n",null),_(j,"_l10nAlert",null),_(j,"_l10nResizer",null),_(j,"_borderLineWidth",-1),_(j,"_colorManager",new fp),_(j,"_zIndex",1),_(j,"_telemetryTimeout",1e3);let ot=j;class OA extends ot{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const um=3285377520,Cs=4294901760,ci=65535;class Tp{constructor(t){this.h1=t?t&4294967295:um,this.h2=t?t&4294967295:um}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let A=0,v=t.length;A<v;A++){const w=t.charCodeAt(A);w<=255?e[s++]=w:(e[s++]=w>>>8,e[s++]=w&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const n=s>>2,r=s-n*4,a=new Uint32Array(e.buffer,0,n);let o=0,l=0,h=this.h1,c=this.h2;const d=3432918353,f=461845907,g=d&ci,y=f&ci;for(let A=0;A<n;A++)A&1?(o=a[A],o=o*d&Cs|o*g&ci,o=o<<15|o>>>17,o=o*f&Cs|o*y&ci,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[A],l=l*d&Cs|l*g&ci,l=l<<15|l>>>17,l=l*f&Cs|l*y&ci,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,r){case 3:o^=e[n*4+2]<<16;case 2:o^=e[n*4+1]<<8;case 1:o^=e[n*4],o=o*d&Cs|o*g&ci,o=o<<15|o>>>17,o=o*f&Cs|o*y&ci,n&1?h^=o:c^=o}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Cs|t*36045&ci,e=e*4283543511&Cs|((e<<16|t>>>16)*2950163797&Cs)>>>16,t^=e>>>1,t=t*444984403&Cs|t*60499&ci,e=e*3301882366&Cs|((e<<16|t>>>16)*3120437893&Cs)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ec=Object.freeze({map:null,hash:"",transfer:void 0});var ba,ya,nn,pe,hf,yb;class jg{constructor(){m(this,hf);m(this,ba,!1);m(this,ya,null);m(this,nn,null);m(this,pe,new Map);_(this,"onSetModified",null);_(this,"onResetModified",null);_(this,"onAnnotationEditor",null)}getValue(t,e){const s=i(this,pe).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return i(this,pe).get(t)}remove(t){var s;const e=i(this,pe).get(t);e!==void 0&&(e instanceof ot&&i(this,nn).delete(e.annotationElementId),i(this,pe).delete(t),i(this,pe).size===0&&this.resetModified(),!i(this,pe).values().some(n=>n instanceof ot)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var r;const s=i(this,pe).get(t);let n=!1;
2if(s!==void 0)for(const[a,o]of Object.entries(e))s[a]!==o&&(n=!0,s[a]=o);else n=!0,i(this,pe).set(t,e);n&&b(this,hf,yb).call(this),e instanceof ot&&((i(this,nn)||u(this,nn,new Map)).set(e.annotationElementId,e),(r=this.onAnnotationEditor)==null||r.call(this,e.constructor._type))}has(t){return i(this,pe).has(t)}get size(){return i(this,pe).size}resetModified(){var t;i(this,ba)&&(u(this,ba,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new Ab(this)}get serializable(){if(i(this,pe).size===0)return ec;const t=new Map,e=new Tp,s=[],n=Object.create(null);let r=!1;for(const[a,o]of i(this,pe)){const l=o instanceof ot?o.serialize(!1,n):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:ec}get editorStats(){let t=null;const e=new Map;let s=0,n=0;for(const r of i(this,pe).values()){if(!(r instanceof ot)){r.popup&&(r.popup.deleted?n+=1:s+=1);continue}r.isCommentDeleted?n+=1:r.hasEditedComment&&(s+=1);const a=r.telemetryFinalData;if(!a)continue;const{type:o}=a;e.getOrInsertComputed(o,()=>Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));const l=t[o]||(t[o]=new Map);for(const[h,c]of Object.entries(a)){if(h==="type")continue;const d=l.getOrInsertComputed(h,Hg);d.set(c,(d.get(c)??0)+1)}}if((n>0||s>0)&&(t||(t=Object.create(null)),t.comments={deleted:n,edited:s}),!t)return null;for(const[r,a]of e)t[r]=a.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){u(this,ya,null)}updateEditor(t,e){var n;const s=(n=i(this,nn))==null?void 0:n.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=i(this,nn))==null?void 0:e.get(t))||null}get modifiedIds(){if(i(this,ya))return i(this,ya);const t=[];if(i(this,nn))for(const s of i(this,nn).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new Tp;s.update(t.join(",")),e=s.hexdigest()}return u(this,ya,{ids:new Set(t),hash:e})}[Symbol.iterator](){return i(this,pe).entries()}}ba=new WeakMap,ya=new WeakMap,nn=new WeakMap,pe=new WeakMap,hf=new WeakSet,yb=function(){var t;i(this,ba)||(u(this,ba,!0),(t=this.onSetModified)==null||t.call(this))};var Lc;class Ab extends jg{constructor(e){super();m(this,Lc,ec);const{serializable:s}=e;if(s===ec)return;const{map:n,hash:r,transfer:a}=s,o=structuredClone(n,a?{transfer:a}:null);u(this,Lc,{map:o,hash:r,transfer:[]})}get print(){it("Should not call PrintAnnotationStorage.print")}get serializable(){return i(this,Lc)}get modifiedIds(){return $(this,"modifiedIds",{ids:new Set,hash:""})}}Lc=new WeakMap;const Bo="__forcedDependency",{floor:fm,ceil:pm}=Math;function gm(p,t,e,s,n,r){p[t*4+0]=Math.min(p[t*4+0],e),p[t*4+1]=Math.min(p[t*4+1],s),p[t*4+2]=Math.max(p[t*4+2],n),p[t*4+3]=Math.max(p[t*4+3],r)}function NA(p,t,e,s,n){let r;p?(p<0&&(r=n[0],n[0]=n[2],n[2]=r),n[0]*=p,n[2]*=p,t<0&&(r=n[1],n[1]=n[3],n[3]=r),n[1]*=t,n[3]*=t):n.fill(0),n[0]+=e,n[1]+=s,n[2]+=e,n[3]+=s}const _p=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var ml,lr;class BA{constructor(t,e){m(this,ml);m(this,lr);u(this,ml,t),u(this,lr,e)}get length(){return i(this,ml).length}isEmpty(t){return i(this,ml)[t]===_p}minX(t){return i(this,lr)[t*4+0]/256}minY(t){return i(this,lr)[t*4+1]/256}maxX(t){return(i(this,lr)[t*4+2]+1)/256}maxY(t){return(i(this,lr)[t*4+3]+1)/256}}ml=new WeakMap,lr=new WeakMap;const mm=(p,t)=>p==null?void 0:p.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var rn,at,Ct,Aa,wa,va,Te,Rc,kp;class HA{constructor(t,e){m(this,Rc);m(this,rn,[[1,0,0,1,0,0]]);m(this,at,[-1/0,-1/0,1/0,1/0]);m(this,Ct,new Float64Array(In));_(this,"_pendingBBoxIdx",-1);m(this,Aa);m(this,wa);m(this,va);m(this,Te);_(this,"_savesStack",[]);_(this,"_markedContentStack",[]);u(this,Aa,t.width),u(this,wa,t.height),b(this,Rc,kp).call(this,e)}growOperationsCount(t){t>=i(this,Te).length&&b(this,Rc,kp).call(this,t,i(this,Te))}get clipBox(){return i(this,at)}save(t){return u(this,at,{__proto__:i(this,at)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(i(this,at));if(s===null)return this;u(this,at,s);const n=this._savesStack.pop();return n!==void 0&&(e==null||e(n,t),i(this,Te)[t]=i(this,Te)[n]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e==null||e(s,t),i(this,Te)[t]=i(this,Te)[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e==null||e(s,t),i(this,Te)[t]=i(this,Te)[s]),this}pushBaseTransform(t){return i(this,rn).push(D.multiplyByDOMMatrix(i(this,rn).at(-1),t.getTransform())),this}popBaseTransform(){return i(this,rn).length>1&&i(this,rn).pop(),this}
2resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,i(this,Ct).set(In,0)),this}recordClipBox(t,e,s,n,r,a){const o=D.multiplyByDOMMatrix(i(this,rn).at(-1),e.getTransform()),l=In.slice();D.axialAlignedBoundingBox([s,r,n,a],o,l);const h=D.intersect(i(this,at),l);return h?(i(this,at)[0]=h[0],i(this,at)[1]=h[1],i(this,at)[2]=h[2],i(this,at)[3]=h[3]):(i(this,at)[0]=i(this,at)[1]=1/0,i(this,at)[2]=i(this,at)[3]=-1/0),this}recordBBox(t,e,s,n,r,a){const o=i(this,at);if(o[0]===1/0)return this;const l=D.multiplyByDOMMatrix(i(this,rn).at(-1),e.getTransform());if(o[0]===-1/0)return D.axialAlignedBoundingBox([s,r,n,a],l,i(this,Ct)),this;const h=In.slice();return D.axialAlignedBoundingBox([s,r,n,a],l,h),i(this,Ct)[0]=Tt(h[0],o[0],i(this,Ct)[0]),i(this,Ct)[1]=Tt(h[1],o[1],i(this,Ct)[1]),i(this,Ct)[2]=Tt(h[2],i(this,Ct)[2],o[2]),i(this,Ct)[3]=Tt(h[3],i(this,Ct)[3],o[3]),this}recordFullPageBBox(t){return i(this,Ct)[0]=Math.max(0,i(this,at)[0]),i(this,Ct)[1]=Math.max(0,i(this,at)[1]),i(this,Ct)[2]=Math.min(i(this,Aa),i(this,at)[2]),i(this,Ct)[3]=Math.min(i(this,wa),i(this,at)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const n=fm(i(this,Ct)[0]*256/i(this,Aa)),r=fm(i(this,Ct)[1]*256/i(this,wa)),a=pm(i(this,Ct)[2]*256/i(this,Aa)),o=pm(i(this,Ct)[3]*256/i(this,wa));if(gm(i(this,va),t,n,r,a,o),s)for(const l of s)for(const h of l)h!==t&&gm(i(this,va),h,n,r,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,i(this,at)[0]=Math.max(i(this,at)[0],i(this,Ct)[0]),i(this,at)[1]=Math.max(i(this,at)[1],i(this,Ct)[1]),i(this,at)[2]=Math.min(i(this,at)[2],i(this,Ct)[2]),i(this,at)[3]=Math.min(i(this,at)[3],i(this,Ct)[3])),this}take(){return new BA(i(this,Te),i(this,va))}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,n=1,r=0,a=0,o){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}rn=new WeakMap,at=new WeakMap,Ct=new WeakMap,Aa=new WeakMap,wa=new WeakMap,va=new WeakMap,Te=new WeakMap,Rc=new WeakSet,kp=function(t,e){const s=new ArrayBuffer(t*4);u(this,va,new Uint8ClampedArray(s)),u(this,Te,new Uint32Array(s)),e&&e.length>0?(i(this,Te).set(e),i(this,Te).fill(_p,e.length)):i(this,Te).fill(_p)};var Ye,Ke,Sa,Ks,bl,hr,cr,pt;class UA{constructor(t,e=!1){m(this,Ye,{__proto__:null});m(this,Ke,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Bo]:[]});m(this,Sa,new Map);m(this,Ks,new Set);m(this,bl,new Map);m(this,hr);m(this,cr);m(this,pt);u(this,pt,t),e&&(u(this,hr,new Map),u(this,cr,(s,n)=>{mm(i(this,hr),n).dependencies.add(s)}))}get clipBox(){return i(this,pt).clipBox}growOperationsCount(t){i(this,pt).growOperationsCount(t)}save(t){return u(this,Ye,{__proto__:i(this,Ye)}),u(this,Ke,{__proto__:i(this,Ke),transform:{__proto__:i(this,Ke).transform},moveText:{__proto__:i(this,Ke).moveText},sameLineText:{__proto__:i(this,Ke).sameLineText},[Bo]:{__proto__:i(this,Ke)[Bo]}}),i(this,pt).save(t),this}restore(t){i(this,pt).restore(t,i(this,cr));const e=Object.getPrototypeOf(i(this,Ye));return e===null?this:(u(this,Ye,e),u(this,Ke,Object.getPrototypeOf(i(this,Ke))),this)}recordOpenMarker(t){return i(this,pt).recordOpenMarker(t,i(this,cr)),this}getOpenMarker(){return i(this,pt).getOpenMarker()}recordCloseMarker(t){return i(this,pt).recordCloseMarker(t,i(this,cr)),this}beginMarkedContent(t){return i(this,pt).beginMarkedContent(t),this}endMarkedContent(t){return i(this,pt).endMarkedContent(t,i(this,cr)),this}pushBaseTransform(t){return i(this,pt).pushBaseTransform(t),this}popBaseTransform(){return i(this,pt).popBaseTransform(),this}recordSimpleData(t,e){return i(this,Ye)[t]=e,this}recordIncrementalData(t,e){return i(this,Ke)[t].push(e),this}resetIncrementalData(t,e){return i(this,Ke)[t].length=0,this}recordNamedData(t,e){return i(this,Sa).set(t,e),this}recordSimpleDataFromNamed(t,e,s){i(this,Ye)[t]=i(this,Sa).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Bo,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in i(this,Ye)&&this.recordFutureForcedDependency(e,i(this,Ye)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of i(this,Ks))this.recordFutureForcedDependency(Bo,t);return this}resetBBox(t){return i(this,pt).resetBBox(t),this}recordClipBox(t,e,s,n,r,a){return i(this,pt).recordClipBox(t,e,s,n,r,a),this}recordBBox(t,e,s,n,r,a){return i(this,pt).recordBBox(t,e,s,n,r,a),this}recordCharacterBBox(t,e,s,n=1,r=0,a=0,o){const l=s.bbox;let h,c;if(l&&(h=l[2]!==l[0]&&l[3]!==l[1]&&i(this,bl).get(s),h!==!1&&(c=[0,0,0,0],D.axialAlignedBoundingBox(l,s.fontMatrix,c),(n!==1||r!==0||a!==0)&&NA(n,-n,r,a,c),h)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(t);const d=o();return l&&c&&h===void 0&&(h=c[0]<=r-d.actualBoundingBoxLeft&&c[2]>=r+d.actualBoundingBoxRight&&c[1]<=a-d.actualBoundingBoxAscent&&c[3]>=a+d.actualBoundingBoxDescent,i(this,bl).set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return i(this,pt).recordFullPageBBox(t),this}getSimpleIndex(t){return i(this,Ye)[t]}recordDependencies(t,e){const s=i(this,Ks),n=i(this,Ye),r=i(this,Ke);for(const a of e)a in i(this,Ye)?s.add(n[a]):a in r&&r[a].forEac
2h(s.add,s);return this}recordNamedDependency(t,e){return i(this,Sa).has(e)&&i(this,Ks).add(i(this,Sa).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Bo]),i(this,hr)){const n=mm(i(this,hr),t),{dependencies:r}=n;i(this,Ks).forEach(r.add,r),i(this,pt)._savesStack.forEach(r.add,r),i(this,pt)._markedContentStack.forEach(r.add,r),r.delete(t),n.isRenderingOperation=!0}const s=!e&&t===i(this,pt)._pendingBBoxIdx;return i(this,pt).recordOperation(t,e,[i(this,Ks),i(this,pt)._savesStack,i(this,pt)._markedContentStack]),s&&i(this,Ks).clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(i(this,Ks));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const n of s)this.recordIncrementalData("sameLineText",n);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===i(this,pt)._pendingBBoxIdx;return i(this,pt).bboxToClipBoxDropOperation(t),s&&i(this,Ks).clear(),this}take(){return i(this,bl).clear(),i(this,pt).take()}takeDebugMetadata(){return i(this,hr)}}Ye=new WeakMap,Ke=new WeakMap,Sa=new WeakMap,Ks=new WeakMap,bl=new WeakMap,hr=new WeakMap,cr=new WeakMap,pt=new WeakMap;var gt,Bt,qs,yl,Al;const Jg=class Jg{constructor(t,e,s){m(this,gt);m(this,Bt);m(this,qs);m(this,yl,0);m(this,Al,0);if(t instanceof Jg&&i(t,qs)===!!s)return t;u(this,gt,t),u(this,Bt,e),u(this,qs,!!s)}get clipBox(){return i(this,gt).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return Et(this,Al)._++,i(this,gt).save(i(this,Bt)),this}restore(t){return i(this,Al)>0&&(i(this,gt).restore(i(this,Bt)),Et(this,Al)._--),this}recordOpenMarker(t){return Et(this,yl)._++,this}getOpenMarker(){return i(this,yl)>0?i(this,Bt):i(this,gt).getOpenMarker()}recordCloseMarker(t){return Et(this,yl)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return i(this,gt).pushBaseTransform(t),this}popBaseTransform(){return i(this,gt).popBaseTransform(),this}recordSimpleData(t,e){return i(this,gt).recordSimpleData(t,i(this,Bt)),this}recordIncrementalData(t,e){return i(this,gt).recordIncrementalData(t,i(this,Bt)),this}resetIncrementalData(t,e){return i(this,gt).resetIncrementalData(t,i(this,Bt)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return i(this,gt).recordSimpleDataFromNamed(t,e,i(this,Bt)),this}recordFutureForcedDependency(t,e){return i(this,gt).recordFutureForcedDependency(t,i(this,Bt)),this}inheritSimpleDataAsFutureForcedDependencies(t){return i(this,gt).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return i(this,gt).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return i(this,qs)||i(this,gt).resetBBox(i(this,Bt)),this}recordClipBox(t,e,s,n,r,a){return i(this,qs)||i(this,gt).recordClipBox(i(this,Bt),e,s,n,r,a),this}recordBBox(t,e,s,n,r,a){return i(this,qs)||i(this,gt).recordBBox(i(this,Bt),e,s,n,r,a),this}recordCharacterBBox(t,e,s,n,r,a,o){return i(this,qs)||i(this,gt).recordCharacterBBox(i(this,Bt),e,s,n,r,a,o),this}recordFullPageBBox(t){return i(this,qs)||i(this,gt).recordFullPageBBox(i(this,Bt)),this}getSimpleIndex(t){return i(this,gt).getSimpleIndex(t)}recordDependencies(t,e){return i(this,gt).recordDependencies(i(this,Bt),e),this}recordNamedDependency(t,e){return i(this,gt).recordNamedDependency(i(this,Bt),e),this}recordOperation(t){return i(this,gt).recordOperation(i(this,Bt),!0),this}recordShowTextOperation(t){return i(this,gt).recordShowTextOperation(i(this,Bt),!0),this}bboxToClipBoxDropOperation(t){return i(this,qs)||i(this,gt).bboxToClipBoxDropOperation(i(this,Bt),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};gt=new WeakMap,Bt=new WeakMap,qs=new WeakMap,yl=new WeakMap,Al=new WeakMap;let sc=Jg;const Ts={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:["f
2ilter","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"]};var Ea,xa,Ca,Ta,_a,Fc;const Qh=class Qh{constructor(t){m(this,Ea);m(this,xa);m(this,Ca,4);m(this,Ta,0);m(this,_a,new(i(Qh,Fc))(i(this,Ca)*6));u(this,Ea,t.width),u(this,xa,t.height)}record(t,e,s,n){if(i(this,Ta)===i(this,Ca)){u(this,Ca,i(this,Ca)*2);const o=new(i(Qh,Fc))(i(this,Ca)*6);o.set(i(this,_a)),u(this,_a,o)}const r=St(t);let a;if(n[0]!==1/0){const o=In.slice();D.axialAlignedBoundingBox([0,-s,e,0],r,o);const l=D.intersect(n,o);if(!l)return;const[h,c,d,f]=l;if(h!==o[0]||c!==o[1]||d!==o[2]||f!==o[3]){const g=Math.atan2(r[1],r[0]),y=Math.abs(Math.sin(g)),A=Math.abs(Math.cos(g));if(y<1e-6||A<1e-6||Math.abs(y-A)<1e-6)a=[h,c,h,f,d,c];else{const v=d-h,w=f-c,S=y*y,E=A*A,x=A*y,C=E-S,T=(w*E-v*x)/C,k=(w*x-v*S)/C;a=[h+k,c,h,c+T,d,f-T]}}}a||(a=[0,-s,0,0,e,-s],D.applyTransform(a,r,0),D.applyTransform(a,r,2),D.applyTransform(a,r,4)),a[0]/=i(this,Ea),a[1]/=i(this,xa),a[2]/=i(this,Ea),a[3]/=i(this,xa),a[4]/=i(this,Ea),a[5]/=i(this,xa),i(this,_a).set(a,i(this,Ta)*6),Et(this,Ta)._++}take(){return i(this,_a).subarray(0,i(this,Ta)*6)}};Ea=new WeakMap,xa=new WeakMap,Ca=new WeakMap,Ta=new WeakMap,_a=new WeakMap,Fc=new WeakMap,m(Qh,Fc,bt.isFloat16ArraySupported?Float16Array:Float32Array);let Mp=Qh;var wl,Qs,cf,wb;class GA{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){m(this,cf);m(this,wl,new Set);m(this,Qs,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){const e=b(this,cf,wb).call(this);e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),i(this,wl).clear(),i(this,Qs)){const{adoptedStyleSheets:t}=this._document;t!=null&&t.includes(i(this,Qs))&&(this._document.adoptedStyleSheets=t.filter(e=>e!==i(this,Qs))),u(this,Qs,null)}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||i(this,wl).has(t.loadedName))){if(Rt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:r,style:a}=t,o=new FontFace(n,r,a);this.addNativeFontFace(o);try{await o.load(),i(this,wl).add(n),s==null||s(t)}catch{W(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}it("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(n){throw W(`Failed to load font '${s.family}': '${n}'.`),t.disableFontFace=!0,n}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const n=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,n)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return $(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return $(this,"isSyncFontLoadingSupported",vs||bt.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(Rt(!n.done,"completeRequest() cannot be called twice."),n.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,n={done:!1,complete:e,callback:t};return s.push(n),n}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return $(this,"_loadTestFont",t)}
2_prepareFontLoadEvent(t,e){function s(C,T){return C.charCodeAt(T)<<24|C.charCodeAt(T+1)<<16|C.charCodeAt(T+2)<<8|C.charCodeAt(T+3)&255}function n(C){return String.fromCharCode(C>>24&255,C>>16&255,C>>8&255,C&255)}function r(C,T,k,P){const M=C.substring(0,T),L=C.substring(T+k);return M+P+L}let a,o;const l=this._document.createElement("canvas");l.width=1,l.height=1;const h=l.getContext("2d");let c=0;function d(C,T){if(++c>30){W("Load test font never loaded."),T();return}if(h.font="30px "+C,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0){T();return}setTimeout(d.bind(null,C,T))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let g=this._loadTestFont;g=r(g,976,f.length,f);const A=16,v=1482184792;let w=s(g,A);for(a=0,o=f.length-3;a<o;a+=4)w=w-v+s(f,a)|0;a<f.length&&(w=w-v+s(f+"XXX",a)|0),g=r(g,A,4,n(w));const S=`url(data:font/opentype;base64,${btoa(g)});`,E=`@font-face {font-family:"${f}";src:${S}}`;this.insertRule(E);const x=this._document.createElement("div");x.style.visibility="hidden",x.style.width=x.style.height="10px",x.style.position="absolute",x.style.top=x.style.left="0px";for(const C of[t.loadedName,f]){const T=this._document.createElement("span");T.textContent="Hi",T.style.fontFamily=C,x.append(T)}this._document.body.append(x),d(f,()=>{x.remove(),e.complete()})}}wl=new WeakMap,Qs=new WeakMap,cf=new WeakSet,wb=function(){var e;if(i(this,Qs))return i(this,Qs);const t=((e=this._document.defaultView)==null?void 0:e.CSSStyleSheet)||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:s}=this._document;if(s){const n=new t;return s.push(n),u(this,Qs,n)}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),u(this,Qs,this.styleElement.sheet)};var mt;class $A{constructor(t,e=null,s,n){_(this,"compiledGlyphs",Object.create(null));m(this,mt);u(this,mt,t),this._inspectFont=e,s&&(this.charProcOperatorList=s),n&&Object.assign(this,n)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let n;try{n=t.get(s)}catch(a){W(`getPathGenerator - ignoring character: "${a}".`)}const r=Hm(n==null?void 0:n.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return i(this,mt).black}get bold(){return i(this,mt).bold}get disableFontFace(){return i(this,mt).disableFontFace}set disableFontFace(t){$(this,"disableFontFace",!!t)}get fontExtraProperties(){return i(this,mt).fontExtraProperties}get isInvalidPDFjsFont(){return i(this,mt).isInvalidPDFjsFont}get isType3Font(){return i(this,mt).isType3Font}get italic(){return i(this,mt).italic}get missingFile(){return i(this,mt).missingFile}get remeasure(){return i(this,mt).remeasure}get vertical(){return i(this,mt).vertical}get ascent(){return i(this,mt).ascent}get defaultWidth(){return i(this,mt).defaultWidth}get descent(){return i(this,mt).descent}get bbox(){return i(this,mt).bbox}get fontMatrix(){return i(this,mt).fontMatrix}get fallbackName(){return i(this,mt).fallbackName}get loadedName(){return i(this,mt).loadedName}get mimetype(){return i(this,mt).mimetype}get name(){return i(this,mt).name}get data(){return i(this,mt).data}clearData(){i(this,mt).clearData()}get cssFontInfo(){return i(this,mt).cssFontInfo}get systemFontInfo(){return i(this,mt).systemFontInfo}get defaultVMetrics(){return i(this,mt).defaultVMetrics}}mt=new WeakMap;class vb{}_(vb,"strings",["fontFamily","fontWeight","italicAngle"]);class Sb{}_(Sb,"strings",["css","loadedName","baseFontName","src"]);const Ee=class Ee{};
2_(Ee,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),_(Ee,"numbers",["ascent","defaultWidth","descent"]),_(Ee,"strings",["fallbackName","loadedName","mimetype","name"]),_(Ee,"OFFSET_NUMBERS",Math.ceil(Ee.bools.length*2/8)),_(Ee,"OFFSET_BBOX",Ee.OFFSET_NUMBERS+Ee.numbers.length*8),_(Ee,"OFFSET_FONT_MATRIX",Ee.OFFSET_BBOX+1+2*4),_(Ee,"OFFSET_DEFAULT_VMETRICS",Ee.OFFSET_FONT_MATRIX+1+8*6),_(Ee,"OFFSET_STRINGS",Ee.OFFSET_DEFAULT_VMETRICS+1+2*3);let es=Ee;class Ue{}_(Ue,"KIND",0),_(Ue,"HAS_BBOX",1),_(Ue,"HAS_BACKGROUND",2),_(Ue,"SHADING_TYPE",3),_(Ue,"N_COORD",4),_(Ue,"N_COLOR",8),_(Ue,"N_STOP",12),_(Ue,"N_FIGURES",16);var Oc,df,vl,Sl,fu;class zA{constructor(t){m(this,Sl);m(this,Oc);m(this,df,new TextDecoder);m(this,vl);u(this,Oc,t),u(this,vl,new DataView(t))}get fontFamily(){return b(this,Sl,fu).call(this,0)}get fontWeight(){return b(this,Sl,fu).call(this,1)}get italicAngle(){return b(this,Sl,fu).call(this,2)}}Oc=new WeakMap,df=new WeakMap,vl=new WeakMap,Sl=new WeakSet,fu=function(t){Rt(t<vb.strings.length,"Invalid string index");let e=0;for(let n=0;n<t;n++)e+=i(this,vl).getUint32(e)+4;const s=i(this,vl).getUint32(e);return i(this,df).decode(new Uint8Array(i(this,Oc),e+4,s))};var ka,El,Ei,Ma,Lh;class jA{constructor(t){m(this,Ma);m(this,ka);m(this,El,new TextDecoder);m(this,Ei);u(this,ka,t),u(this,Ei,new DataView(t))}get guessFallback(){return i(this,Ei).getUint8(0)!==0}get css(){return b(this,Ma,Lh).call(this,0)}get loadedName(){return b(this,Ma,Lh).call(this,1)}get baseFontName(){return b(this,Ma,Lh).call(this,2)}get src(){return b(this,Ma,Lh).call(this,3)}get style(){let t=1;t+=4+i(this,Ei).getUint32(t);const e=i(this,Ei).getUint32(t),s=i(this,El).decode(new Uint8Array(i(this,ka),t+4,e));t+=4+e;const n=i(this,Ei).getUint32(t),r=i(this,El).decode(new Uint8Array(i(this,ka),t+4,n));return{style:s,weight:r}}}ka=new WeakMap,El=new WeakMap,Ei=new WeakMap,Ma=new WeakSet,Lh=function(t){Rt(t<Sb.strings.length,"Invalid string index");let e=5;for(let n=0;n<t;n++)e+=i(this,Ei).getUint32(e)+4;const s=i(this,Ei).getUint32(e);return i(this,El).decode(new Uint8Array(i(this,ka),e+4,s))};var Js,uf,jt,ct,Vs,pu,gu,Rh,Pp;class VA{constructor({buffer:t,extra:e}){m(this,ct);m(this,Js);m(this,uf,new TextDecoder);m(this,jt);u(this,Js,t),u(this,jt,new DataView(t)),e&&Object.assign(this,e)}get black(){return b(this,ct,Vs).call(this,0)}get bold(){return b(this,ct,Vs).call(this,1)}get disableFontFace(){return b(this,ct,Vs).call(this,2)}get fontExtraProperties(){return b(this,ct,Vs).call(this,3)}get isInvalidPDFjsFont(){return b(this,ct,Vs).call(this,4)}get isType3Font(){return b(this,ct,Vs).call(this,5)}get italic(){return b(this,ct,Vs).call(this,6)}get missingFile(){return b(this,ct,Vs).call(this,7)}get remeasure(){return b(this,ct,Vs).call(this,8)}get vertical(){return b(this,ct,Vs).call(this,9)}get ascent(){return b(this,ct,pu).call(this,0)}get defaultWidth(){return b(this,ct,pu).call(this,1)}get descent(){return b(this,ct,pu).call(this,2)}get bbox(){return b(this,ct,gu).call(this,es.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return b(this,ct,gu).call(this,es.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return b(this,ct,gu).call(this,es.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}get fallbackName(){return b(this,ct,Rh).call(this,0)}get loadedName(){return b(this,ct,Rh).call(this,1)}get mimetype(){return b(this,ct,Rh).call(this,2)}get name(){return b(this,ct,Rh).call(this,3)}get data(){const{offset:t,length:e}=b(this,ct,Pp).call(this);return e===0?void 0:new Uint8Array(i(this,Js),t+4,e)}clearData(){const{offset:t,length:e}=b(this,ct,Pp).call(this);e!==0&&(i(this,jt).setUint32(t,0),u(this,Js,new Uint8Array(i(this,Js),0,t+4).slice().buffer),u(this,jt,new DataView(i(this,Js))))}get cssFontInfo(){let t=es.OFFSET_STRINGS;const e=i(this,jt).getUint32(t);t+=4+e;const s=i(this,jt).getUint32(t);t+=4+s;const n=i(this,jt).getUint32(t);if(n===0)return null;const r=new Uint8Array(n);return r.set(new Uint8Array(i(this,Js),t+4,n)),new zA(r.buffer)}get systemFontInfo(){let t=es.OFFSET_STRINGS;const e=i(this,jt).getUint32(t);t+=4+e;const s=i(this,jt).getUint32(t);if(s===0)return null;const n=new Uint8Array(s);return n.set(new Uint8Array(i(this,Js),t+4,s)),new jA(n.buffer)}}Js=new WeakMap,uf=new WeakMap,jt=new WeakMap,ct=new WeakSet,Vs=function(t){Rt(t<es.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,n=i(this,jt).getUint8(e)>>s&3;return n===0?void 0:n===2},pu=function(t){return Rt(t<es.numbers.length,"Invalid number index"),i(this,jt).getFloat64(es.OFFSET_NUMBERS+t*8)},gu=function(t,e,s,n){const r=i(this,jt).getUint8(t);if(r===0)return;Rt(r===e,"Invalid array length."),t+=1;const a=new Array(r);for(let o=0;o<r;o++)a[o]=i(this,jt)[s](t,!0),t+=n;return a},Rh=function(t){Rt(t<es.strings.length,"Invalid string index");let e=es.OFFSET_STRINGS+4;for(let n=0;n<t;n++)e+=i(this,jt).getUint32(e)+4;const s=i(this,jt).getUint32(e);return i(this,uf).decode(new Uint8Array(i(this,Js),e+4,s))},Pp=function(){let t=es.OFFSET_STRINGS;const e=i(this,jt).getUint32(t);t+=4+e;const s=i(this,jt).getUint32(t);t+=4+s;const n=i(this,jt).getUint32(t);t+=4+n;const r=i(this,jt).getUint32(t);return{offset:t,length:r}};class WA{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[Ue.KIND],s=!!this.data[Ue.HAS_BBOX],n=!!this.data[Ue.HAS_BACKGROUND],r=t.getUint32(Ue.N_COORD,!0),a=t.getUint32(Ue.N_COLOR,!0),o=t.getUint32(Ue.N_STOP,!0);let l=20;const h=new Float32Array(this.buffer,l,r*2);l+=r*8;const c=new Uint8Array(this.buffer,l,a*4);l+=a*4;const d=[];for(let y=0;y<o;++y){const A=t.getFloat32(l,!0);l+=4;
2const v=t.getUint32(l,!0);l+=4,d.push([A,`#${v.toString(16).padStart(6,"0")}`])}let f=null;if(s){f=[];for(let y=0;y<4;++y)f.push(t.getFloat32(l,!0)),l+=4}let g=null;if(n&&(g=new Uint8Array(this.buffer,l,3),l+=3),e===1)return["RadialAxial","axial",f,d,Array.from(h.slice(0,2)),Array.from(h.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",f,d,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(e===3){const y=this.data[Ue.SHADING_TYPE];let A=null;if(h.length>0){A=In.slice();for(let v=0,w=h.length;v<w;v+=2)D.pointBoundingBox(h[v],h[v+1],A)}return["Mesh",y,h,c,r,A,f,g]}throw new Error(`Unsupported pattern kind: ${e}`)}}var xl;class XA{constructor(t){m(this,xl);u(this,xl,t)}get path(){return bt.isFloat16ArraySupported?new Float16Array(i(this,xl)):new Float32Array(i(this,xl))}}xl=new WeakMap;function YA(p){if(p instanceof URL)return p;if(typeof p=="string"){if(vs){if(/^[a-z][a-z0-9\-+.]+:/i.test(p))return new URL(p);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(p))}const t=URL.parse(p,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 KA(p){if(vs&&typeof Buffer<"u"&&p instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(p instanceof Uint8Array&&p.byteLength===p.buffer.byteLength)return p;if(typeof p=="string")return Lf(p);if(p instanceof ArrayBuffer||ArrayBuffer.isView(p)||typeof p=="object"&&!isNaN(p==null?void 0:p.length))return new Uint8Array(p);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Jd(p){if(typeof p!="string")return null;if(p.endsWith("/"))return p;throw new Error(`Invalid factory url: "${p}" must include trailing slash.`)}const Dp=p=>typeof p=="object"&&Number.isInteger(p==null?void 0:p.num)&&p.num>=0&&Number.isInteger(p==null?void 0:p.gen)&&p.gen>=0,qA=p=>typeof p=="object"&&typeof(p==null?void 0:p.name)=="string",QA=vA.bind(null,Dp,qA);var an,ff;class JA{constructor(){m(this,an,new Map);m(this,ff,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};i(this,ff).then(()=>{for(const[n]of i(this,an))n.call(this,s)})}addEventListener(t,e,s=null){let n=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){W("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);n=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}i(this,an).set(e,n)}removeEventListener(t,e){const s=i(this,an).get(e);s==null||s(),i(this,an).delete(e)}terminate(){for(const[,t]of i(this,an))t==null||t();i(this,an).clear()}}an=new WeakMap,ff=new WeakMap;const Zd={DATA:1,ERROR:2},Yt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function bm(){}function je(p){if(p instanceof Ur||p instanceof np||p instanceof ip||p instanceof Xu||p instanceof Yf)return p;switch(p instanceof Error||typeof p=="object"&&p!==null||it('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),p.name){case"AbortException":return new Ur(p.message);case"InvalidPDFException":return new np(p.message);case"PasswordException":return new ip(p.message,p.code);case"ResponseException":return new Xu(p.message,p.status,p.missing);case"UnknownErrorException":return new Yf(p.message,p.details)}return new Yf(p.message,p.toString())}var Cl,zs,Eb,xb,Cb,mu;class Fh{constructor(t,e,s){m(this,zs);m(this,Cl,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",b(this,zs,Eb).bind(this),{signal:i(this,Cl).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}
2sendWithPromise(t,e,s){const n=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[n]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,n){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:r,data:e,desiredSize:h.desiredSize},n),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[r].pullCall=c,l.postMessage({sourceName:a,targetName:o,stream:Yt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{Rt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[r].cancelCall=c,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:Yt.CANCEL,streamId:r,reason:je(h)}),c.promise}},s)}destroy(){var t;(t=i(this,Cl))==null||t.abort(),u(this,Cl,null)}}Cl=new WeakMap,zs=new WeakSet,Eb=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){b(this,zs,Cb).call(this,t);return}if(t.callback){const s=t.callbackId,n=this.callbackCapabilities[s];if(!n)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===Zd.DATA)n.resolve(t.data);else if(t.callback===Zd.ERROR)n.reject(je(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,n=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:n,callback:Zd.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:n,callback:Zd.ERROR,callbackId:t.callbackId,reason:je(a)})});return}if(t.streamId){b(this,zs,xb).call(this,t);return}e(t.data)},xb=function(t){const e=t.streamId,s=this.sourceName,n=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(h,c=1,d){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=c,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:n,stream:Yt.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:n,stream:Yt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){Rt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:n,stream:Yt.ERROR,streamId:e,reason:je(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,Promise.try(o,t.data,l).then(function(){r.postMessage({sourceName:s,targetName:n,stream:Yt.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:Yt.START_COMPLETE,streamId:e,reason:je(h)})})},Cb=function(t){const e=t.streamId,s=this.sourceName,n=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Yt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(je(t.reason));break;case Yt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(je(t.reason));break;case Yt.PULL:if(!o){r.postMessage({sourceName:s,targetName:n,stream:Yt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||bm).then(function(){r.postMessage({sourceName:s,targetName:n,stream:Yt.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:Yt.PULL_COMPLETE,streamId:e,reason:je(h)})});break;case Yt.ENQUEUE:if(Rt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Yt.CLOSE:if(Rt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,zs,mu).call(this,a,e);break;case Yt.ERROR:Rt(a,"error should have stream controller"),a.controller.error(je(t.reason)),b(this,zs,mu).call(this,a,e);break;case Yt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(je(t.reason)),b(this,zs,mu).call(this,a,e);break;case Yt.CANCEL:if(!o)break;const l=je(t.reason);Promise.try(o.onCancel||bm,l).then(function(){r.postMessage({sourceName:s,targetName:n,stream:Yt.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:n,stream:Yt.CANCEL_COMPLETE,streamId:e,reason:je(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},mu=async function(t,e){var s,n,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(n=t.pullCall)==null?void 0:n.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var pf;
2class Tb{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){m(this,pf,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));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:it(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const n=`${s}${e}`;return this._fetch(n,t).catch(r=>{throw new Error(`Unable to load ${i(this,pf)[t]} data at: ${n}`)})}async _fetch(t,e){it("Abstract method `_fetch` called.")}}pf=new WeakMap;class ym extends Tb{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",n=await Gg(t,s);return n instanceof Uint8Array?n:Lf(n)}}var Nc;class _b{constructor({enableHWA:t=!1}){m(this,Nc,!1);u(this,Nc,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!i(this,Nc)})}}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){const{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){it("Abstract method `_createCanvas` called.")}}Nc=new WeakMap;class ZA extends _b{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class kb{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,n,r){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}var Pa,Tl,on,xi,ne,Da,dr,I,ee,Oh,di,bu,jr,Mb,Ip,Vr,Nh,Bh,Lp,Hh,Pb,Rp,Db;class t0 extends kb{constructor({docId:e,ownerDocument:s=globalThis.document}){super();m(this,I);m(this,Pa);m(this,Tl);m(this,on);m(this,xi);m(this,ne);m(this,Da);m(this,dr,0);u(this,xi,e),u(this,ne,s)}addFilter(e){if(!e)return"none";let s=i(this,I,ee).get(e);if(s)return s;const[n,r,a]=b(this,I,bu).call(this,e),o=e.length===1?n:`${n}${r}${a}`;if(s=i(this,I,ee).get(o),s)return i(this,I,ee).set(e,s),s;const l=`g_${i(this,xi)}_transfer_map_${Et(this,dr)._++}`,h=b(this,I,jr).call(this,l);i(this,I,ee).set(e,h),i(this,I,ee).set(o,h);const c=b(this,I,Vr).call(this,l);return b(this,I,Bh).call(this,n,r,a,c),h}addHCMFilter(e,s){var y;const n=`${e}-${s}`,r="base";let a=i(this,I,Oh).get(r);if((a==null?void 0:a.key)===n||(a?((y=a.filter)==null||y.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},i(this,I,Oh).set(r,a)),!e||!s))return a.url;const o=b(this,I,Hh).call(this,e);e=D.makeHexColor(...o);const l=b(this,I,Hh).call(this,s);if(s=D.makeHexColor(...l),b(this,I,Rp).call(this),e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let A=0;A<=255;A++){const v=A/255;h[A]=v<=.03928?v/12.92:((v+.055)/1.055)**2.4}const c=h.join(","),d=`g_${i(this,xi)}_hcm_filter`,f=a.filter=b(this,I,Vr).call(this,d);b(this,I,Bh).call(this,c,c,c,f),b(this,I,Ip).call(this,f);const g=(A,v)=>{const w=o[A]/255,S=l[A]/255,E=new Array(v+1);for(let x=0;x<=v;x++)E[x]=w+x/v*(S-w);return E.join(",")};return b(this,I,Bh).call(this,g(0,5),g(1,5),g(2,5),f),a.url=b(this,I,jr).call(this,d),a.url}addSelectionHCMFilter(e,s){return this.addHighlightHCMFilter("selection",e,s,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(e=null){const s=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return s==="none"||!bt.platform.isFirefox?null:{"backdrop-filter":s,"background-color":"transparent"}}addAlphaFilter(e){let s=i(this,I,ee).get(e);if(s)return s;const[n]=b(this,I,bu).call(this,[e]),r=`alpha_${n}`;if(s=i(this,I,ee).get(r),s)return i(this,I,ee).set(e,s),s;const a=`g_${i(this,xi)}_alpha_map_${Et(this,dr)._++}`,o=b(this,I,jr).call(this,a);i(this,I,ee).set(e,o),i(this,I,ee).set(r,o);const l=b(this,I,Vr).call(this,a);return b(this,I,Lp).call(this,n,l),o}addLuminosityFilter(e){let s=i(this,I,ee).get(e||"luminosity");if(s)return s;let n,r;if(e?([n]=b(this,I,bu).call(this,[e]),r=`luminosity_${n}`):r="luminosity",s=i(this,I,ee).get(r),s)return i(this,I,ee).set(e,s),s;const a=`g_${i(this,xi)}_luminosity_map_${Et(this,dr)._++}`,o=b(this,I,jr).call(this,a);i(this,I,ee).set(e,o),i(this,I,ee).set(r,o);const l=b(this,I,Vr).call(this,a);return b(this,I,Mb).call(this,l),e&&b(this,I,Lp).call(this,n,l),o}addKnockoutFilter(e=0){const s=e>0?Math.min(1/e,1e6):1e6,n=`knockout_${s}`,r=i(this,I,ee).get(n);if(r)return r;const a=`g_${i(this,xi)}_knockout_filter_${Et(this,dr)._++}`,o=b(this,I,jr).call(this,a);i(this,I,ee).set(n,o);const l=b(this,I,Vr).call(this,a),h=i(this,ne).createElementNS(He,"feComponentTransfer");l.append(h);const c=i(this,ne).createElementNS(He,"feFuncA");return c.setAttribute("type","linear"),c.setAttribute("slope",`${s}`),c.setAttribute("intercept","0"),h.append(c),o}addHighlightHCMFilter(e,s,n,r,a){var S;const o=`${s}-${n}-${r}-${a}`;let l=i(this,I,Oh).get(e);if((l==null?void 0:l.key)===o||(l?((S=l.filter)==null||S.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},i(this,I,Oh).set(e,l)),!s||!n))return l.url;const[h,c]=[s,n].map(b(this,I,Hh).bind(this));let d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),f=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[g,y]=[r,a].map(b(this,I,Db).bind(this));f<d&&([d,f,g,y]=[f,d,y,g]),b(this,I,Rp).call(this);const A=(E,x,C)=>{const T=new Array(256),k=(f-d)/C,P=E/255,M=(x-E)/(255*C);let L=0;for(let O=0;O<=C;O++){const Q=Math.round(d+O*k),J=P+O*M;for(let q=L;q<=Q;q++)T[q]=J;L=Q+1}for(let O=L;O<256;O++)T[O]=T[L-1];return T.join(",")},v=`g_${i(this,xi)}_hcm_${e}
2_filter`,w=l.filter=b(this,I,Vr).call(this,v);return b(this,I,Ip).call(this,w),b(this,I,Bh).call(this,A(g[0],y[0],5),A(g[1],y[1],5),A(g[2],y[2],5),w),l.url=b(this,I,jr).call(this,v),l.url}destroy(e=!1){var s,n,r,a;e&&((s=i(this,Da))!=null&&s.size)||((n=i(this,on))==null||n.parentNode.parentNode.remove(),u(this,on,null),(r=i(this,Tl))==null||r.clear(),u(this,Tl,null),(a=i(this,Da))==null||a.clear(),u(this,Da,null),u(this,dr,0))}}Pa=new WeakMap,Tl=new WeakMap,on=new WeakMap,xi=new WeakMap,ne=new WeakMap,Da=new WeakMap,dr=new WeakMap,I=new WeakSet,ee=function(){return i(this,Tl)||u(this,Tl,new Map)},Oh=function(){return i(this,Da)||u(this,Da,new Map)},di=function(){if(!i(this,on)){const e=i(this,ne).createElement("div"),{style:s}=e;s.colorScheme="only light",s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const n=i(this,ne).createElementNS(He,"svg");n.setAttribute("width",0),n.setAttribute("height",0),u(this,on,i(this,ne).createElementNS(He,"defs")),e.append(n),n.append(i(this,on)),i(this,ne).body.append(e)}return i(this,on)},bu=function(e){if(e.length===1){const h=e[0],c=new Array(256);for(let f=0;f<256;f++)c[f]=h[f]/255;const d=c.join(",");return[d,d,d]}const[s,n,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let h=0;h<256;h++)a[h]=s[h]/255,o[h]=n[h]/255,l[h]=r[h]/255;return[a.join(","),o.join(","),l.join(",")]},jr=function(e){if(i(this,Pa)===void 0){u(this,Pa,"");const s=i(this,ne).URL;s!==i(this,ne).baseURI&&(Rf(s)?W('#createUrl: ignore "data:"-URL for performance reasons.'):u(this,Pa,Om(s,"")))}return`url(${i(this,Pa)}#${e})`},Mb=function(e){const s=i(this,ne).createElementNS(He,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},Ip=function(e){const s=i(this,ne).createElementNS(He,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},Vr=function(e){const s=i(this,ne).createElementNS(He,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),i(this,I,di).append(s),s},Nh=function(e,s,n){const r=i(this,ne).createElementNS(He,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),e.append(r)},Bh=function(e,s,n,r){const a=i(this,ne).createElementNS(He,"feComponentTransfer");r.append(a),b(this,I,Nh).call(this,a,"feFuncR",e),b(this,I,Nh).call(this,a,"feFuncG",s),b(this,I,Nh).call(this,a,"feFuncB",n)},Lp=function(e,s){const n=i(this,ne).createElementNS(He,"feComponentTransfer");
2s.append(n),b(this,I,Nh).call(this,n,"feFuncA",e)},Hh=function(e){return i(this,I,di).style.color="CanvasText",i(this,I,di).style.backgroundColor=e,Kd(getComputedStyle(i(this,I,di)).getPropertyValue("background-color"))},Pb=function(e){return i(this,I,di).style.color="CanvasText",i(this,I,di).style.backgroundColor=e,Yd(getComputedStyle(i(this,I,di)).getPropertyValue("background-color"))},Rp=function(){i(this,I,di).style.color="",i(this,I,di).style.backgroundColor=""},Db=function(e){const[s,n,r,a]=b(this,I,Pb).call(this,e);if(a===1)return[s,n,r];const[o,l,h]=b(this,I,Hh).call(this,"Canvas");return[Qf(s,o,a),Qf(n,l,a),Qf(r,h,a)]};function Qf(p,t,e){return Math.round(e*p+(1-e)*t)}vs&&W("Please use the `legacy` build in Node.js environments.");async function e0(p){const e=await process.getBuiltinModule("fs/promises").readFile(p);return new Uint8Array(e)}class s0 extends kb{}class i0 extends _b{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class n0 extends Tb{async _fetch(t,e){return e0(t)}}function Ib({src:p,srcPos:t=0,dest:e,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=bt.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,d=s&7,f=l^h,g=p.length;e=new Uint32Array(e.buffer);let y=0;for(let A=0;A<n;++A){for(const w=t+c;t<w;++t,y+=8){const S=p[t];e[y]=l^-(S>>7&1)&f,e[y+1]=l^-(S>>6&1)&f,e[y+2]=l^-(S>>5&1)&f,e[y+3]=l^-(S>>4&1)&f,e[y+4]=l^-(S>>3&1)&f,e[y+5]=l^-(S>>2&1)&f,e[y+6]=l^-(S>>1&1)&f,e[y+7]=l^-(S&1)&f}if(d===0)continue;const v=t<g?p[t++]:255;for(let w=0;w<d;++w,++y)e[y]=l^-(v>>7-w&1)&f}return{srcPos:t,destPos:y}}function r0({src:p,srcPos:t=0,dest:e,destPos:s=0,width:n,height:r}){let a=0;const o=n*r*3,l=o>>2,h=new Uint32Array(p.buffer,t,l),c=bt.isLittleEndian?4278190080:255;if(bt.isLittleEndian){for(;a<l-2;a+=3,s+=4){const d=h[a],f=h[a+1],g=h[a+2];e[s]=d|c,e[s+1]=d>>>24|f<<8|c,e[s+2]=f>>>16|g<<16|c,e[s+3]=g>>>8|c}for(let d=a*4,f=t+o;d<f;d+=3)e[s++]=p[d]|p[d+1]<<8|p[d+2]<<16|c}else{for(;a<l-2;a+=3,s+=4){const d=h[a],f=h[a+1],g=h[a+2];e[s]=d|c,e[s+1]=d<<24|f>>>8|c,e[s+2]=f<<16|g>>>16|c,e[s+3]=g<<8|c}for(let d=a*4,f=t+o;d<f;d+=3)e[s++]=p[d]<<24|p[d+1]<<16|p[d+2]<<8|c}return{srcPos:t+o,destPos:s}}const a0=`
3struct Uniforms {
4  offsetX      : f32,
5  offsetY      : f32,
6  scaleX       : f32,
7  scaleY       : f32,
8  paddedWidth  : f32,
9  paddedHeight : f32,
10  borderSize   : f32,
11  _pad         : f32,
12};
13
14@group(0) @binding(0) var<uniform> u : Uniforms;
15
16struct VertexInput {
17  @location(0) position : vec2<f32>,
18  @location(1) color    : vec4<f32>,
19};
20
21struct VertexOutput {
22  @builtin(position) position : vec4<f32>,
23  @location(0)       color    : vec3<f32>,
24};
25
26@vertex
27fn vs_main(in : VertexInput) -> VertexOutput {
28  var out : VertexOutput;
29  let cx = (in.position.x + u.offsetX) * u.scaleX;
30  let cy = (in.position.y + u.offsetY) * u.scaleY;
31  out.position = vec4<f32>(
32    ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
33    1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
34    0.0,
35    1.0
36  );
37  out.color = in.color.rgb;
38  return out;
39}
40
41@fragment
42fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
43  return vec4<f32>(in.color, 1.0);
44}
45`;var gf,ln,Ia,_l,mf,Lb;class o0{constructor(){m(this,mf);m(this,gf,null);m(this,ln,null);m(this,Ia,null);m(this,_l,null)}init(){return i(this,gf)||u(this,gf,b(this,mf,Lb).call(this))}get isReady(){return i(this,ln)!==null}loadMeshShader(){if(!i(this,ln)||i(this,Ia))return;const t=i(this,ln).createShaderModule({code:a0});u(this,Ia,i(this,ln).createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:2*4,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:i(this,_l)}]},primitive:{topology:"triangle-list"}}))}draw(t,e,s,n,r,a,o,l){this.loadMeshShader();const h=i(this,ln),{offsetX:c,offsetY:d,scaleX:f,scaleY:g}=n,y=h.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&h.queue.writeBuffer(y,0,t);const A=h.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&h.queue.writeBuffer(A,0,e);const v=h.createBuffer({size:8*4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h.queue.writeBuffer(v,0,new Float32Array([c,d,f,g,a,o,l,0]));const w=h.createBindGroup({layout:i(this,Ia).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:v}}]}),S=new OffscreenCanvas(a,o),E=S.getContext("webgpu");E.configure({device:h,format:i(this,_l),alphaMode:r?"opaque":"premultiplied"});const x=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},C=h.createCommandEncoder(),T=C.beginRenderPass({colorAttachments:[{view:E.getCurrentTexture().createView(),clearValue:x,loadOp:"clear",storeOp:"store"}]});return s>0&&(T.setPipeline(i(this,Ia)),T.setBindGroup(0,w),T.setVertexBuffer(0,y),T.setVertexBuffer(1,A),T.draw(s)),T.end(),h.queue.submit([C.finish()]),y.destroy(),A.destroy(),v.destroy(),S.transferToImageBitmap()}}gf=new WeakMap,ln=new WeakMap,Ia=new WeakMap,_l=new WeakMap,mf=new WeakSet,Lb=async function(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{const e=await navigator.gpu.requestAdapter();
45return e?(u(this,_l,navigator.gpu.getPreferredCanvasFormat()),u(this,ln,await e.requestDevice()),!0):!1}catch{return!1}};const Ff=new o0;function l0(){return Ff.init()}function h0(){return Ff.isReady}function c0(){Ff.loadMeshShader()}function d0(p,t,e,s,n,r,a,o){return Ff.draw(p,t,e,s,n,r,a,o)}const Ae={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function yu(p,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],n=new Path2D;n.rect(t[0],t[1],e,s),p.clip(n)}class Vg{constructor(){_(this,"matrix",null)}isModifyingCurrentTransform(){return!1}getPattern(){it("Abstract method `getPattern` called.")}}class u0 extends Vg{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7]}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,n=this._p0,r=this._p1;if(e&&(n=n.slice(),r=r.slice(),D.applyTransform(n,e),D.applyTransform(r,e)),this._type==="axial")s=t.createLinearGradient(n[0],n[1],r[0],r[1]);else if(this._type==="radial"){let a=this._r0,o=this._r1;if(e){const l=new Float32Array(2);D.singularValueDecompose2dScale(e,l),a*=l[0],o*=l[0]}s=t.createRadialGradient(n[0],n[1],a,r[0],r[1],o)}for(const a of this._colorStops)s.addColorStop(a[0],a[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,n=this._p0;e&&(s=s.slice(),n=n.slice(),D.applyTransform(s,e),D.applyTransform(n,e));let r=this._r1,a=this._r0;if(e){const h=new Float32Array(2);D.singularValueDecompose2dScale(e,h),r*=h[0],a*=h[0]}const o=t.createRadialGradient(s[0],s[1],r,n[0],n[1],a),l=this._colorStops.map(([h,c])=>[1-h,c]).reverse();for(const[h,c]of l)o.addColorStop(h,c);return o}getPattern(t,e,s,n){let r;if(n===Ae.STROKE||n===Ae.FILL){if(this.isOriginBased()){let f=D.transform(s,e.baseTransform);this.matrix&&(f=D.transform(f,this.matrix));const g=.001,y=Math.hypot(f[0],f[1]),A=Math.hypot(f[2],f[3]),v=(f[0]*f[2]+f[1]*f[3])/(y*A);if(Math.abs(v)<g)if(this.isRadial()){if(Math.abs(y-A)<g)return this._createGradient(t,f)}else return this._createGradient(t,f)}const a=e.current.getClippedPathBoundingBox(n,St(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,h=e.canvasFactory.create(o,l),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-a[0],-a[1]),s=D.transform(s,[1,0,0,1,a[0],a[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),yu(c,this._bbox),this.areConic()&&(c.fillStyle=this._createReversedGradient(c),c.fill()),c.fillStyle=this._createGradient(c),c.fill(),r=t.createPattern(h.canvas,"no-repeat"),e.canvasFactory.destroy(h);const d=new DOMMatrix(s);r.setTransform(d)}else this.areConic()&&(t.save(),yu(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),yu(t,this._bbox),r=this._createGradient(t);return r}}function f0(p,t,e,s,n,r,a,o){const l=t.coords,h=t.colors,c=p.data,d=p.width*4;let f;l[e*2+1]>l[s*2+1]&&(f=e,e=s,s=f,f=r,r=a,a=f),l[s*2+1]>l[n*2+1]&&(f=s,s=n,n=f,f=a,a=o,o=f),l[e*2+1]>l[s*2+1]&&(f=e,e=s,s=f,f=r,r=a,a=f);const g=(l[e*2]+t.offsetX)*t.scaleX,y=(l[e*2+1]+t.offsetY)*t.scaleY,A=(l[s*2]+t.offsetX)*t.scaleX,v=(l[s*2+1]+t.offsetY)*t.scaleY,w=(l[n*2]+t.offsetX)*t.scaleX,S=(l[n*2+1]+t.offsetY)*t.scaleY;if(y>=S)return;const E=h[r*4],x=h[r*4+1],C=h[r*4+2],T=h[a*4],k=h[a*4+1],P=h[a*4+2],M=h[o*4],L=h[o*4+1],O=h[o*4+2],Q=Math.round(y),J=Math.round(S);let q,Ft,F,U,Gt,$t,ts,ce;for(let Xt=Q;Xt<=J;Xt++){if(Xt<v){const wt=Xt<y?0:(y-Xt)/(y-v);q=g-(g-A)*wt,Ft=E-(E-T)*wt,F=x-(x-k)*wt,U=C-(C-P)*wt}else{let wt;Xt>S?wt=1:v===S?wt=0:wt=(v-Xt)/(v-S),q=A-(A-w)*wt,Ft=T-(T-M)*wt,F=k-(k-L)*wt,U=P-(P-O)*wt}let dt;Xt<y?dt=0:Xt>S?dt=1:dt=(y-Xt)/(y-S),Gt=g-(g-w)*dt,$t=E-(E-M)*dt,ts=x-(x-L)*dt,ce=C-(C-O)*dt;const li=Math.round(Math.min(q,Gt)),xh=Math.round(Math.max(q,Gt));let te=d*Xt+li*4;for(let wt=li;wt<=xh;wt++)dt=(q-wt)/(q-Gt),dt<0?dt=0:dt>
451&&(dt=1),c[te++]=Ft-(Ft-$t)*dt|0,c[te++]=F-(F-ts)*dt|0,c[te++]=U-(U-ce)*dt|0,c[te++]=255}}class p0 extends Vg{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],c0()}_createMeshCanvas(t,e,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-o,c=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3)||1,f=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3)||1,g=h?h/d:1,y=c?c/f:1,A={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/y},v=d+2*2,w=f+2*2,S=s.create(v,w);if(h0()&&this._vertexCount>48)S.context.drawImage(d0(this._posData,this._colData,this._vertexCount,A,e,v,w,2),0,0);else{const E=S.context.createImageData(d,f);if(e){const x=E.data;for(let C=0,T=x.length;C<T;C+=4)x[C]=e[0],x[C+1]=e[1],x[C+2]=e[2],x[C+3]=255}for(let x=0,C=this._vertexCount;x<C;x+=3)f0(E,A,x,x+1,x+2,x,x+1,x+2);S.context.putImageData(E,2,2)}return{canvas:S.canvas,offsetX:o-2*g,offsetY:l-2*y,scaleX:g,scaleY:y}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,n){yu(t,this._bbox);const r=new Float32Array(2);if(n===Ae.SHADING)D.singularValueDecompose2dScale(St(t),r);else if(this.matrix){D.singularValueDecompose2dScale(this.matrix,r);const[l,h]=r;D.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=l,r[1]*=h}else D.singularValueDecompose2dScale(e.baseTransform,r);const a=this._createMeshCanvas(r,n===Ae.SHADING?null:this._background,e.canvasFactory);n!==Ae.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY);const o=t.createPattern(a.canvas,"no-repeat");return e.canvasFactory.destroy(a),o}}class g0 extends Vg{getPattern(){return"hotpink"}}function m0(p){switch(p[0]){case"RadialAxial":return new u0(p);case"Mesh":return new p0(p);case"Dummy":return new g0}throw new Error(`Unknown IR type: ${p[0]}`)}const Am={COLORED:1,UNCOLORED:2},bf=class bf{constructor(t,e,s,n){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=n,this.patternBaseMatrix=this.matrix?D.transform(n,this.matrix):n}canSkipPatternCanvas([t,e,s,n]){const[r,a,o,l]=this.bbox,h=Math.abs(this.xstep),c=Math.abs(this.ystep);if(t>h+1e-6||e>c+1e-6)return null;const d=Math.floor((s-o)/h)+1,f=Math.ceil((s+t-r)/h)-1,g=Math.floor((n-l)/c)+1,y=Math.ceil((n+e-a)/c)-1;return f<=d&&y<=g?[d,g]:null}updatePatternDims(t,e){const s=D.inverseTransform(this.patternBaseMatrix),n=[t[0],t[1]],r=[t[2],t[3]];D.applyTransform(n,s),D.applyTransform(r,s),e[0]=Math.abs(r[0]-n[0]),e[1]=Math.abs(r[1]-n[1]),e[2]=Math.min(n[0],r[0]),e[3]=Math.min(n[1],r[1])}_renderTileCanvas(t,e,s,n){var f,g;const[r,a,o,l]=this.bbox,h=t.canvasFactory.create(s.size,n.size),c=h.context,d=this.canvasGraphicsFactory.createCanvasGraphics(c,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),c.translate(-s.scale*r,-n.scale*a),d.transform(0,s.scale,0,0,n.scale,0,0),c.save(),(f=d.dependencyTracker)==null||f.save(),this.clipBbox(d,r,a,o,l),d.baseTransform=St(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),(g=d.dependencyTracker)==null||g.restore(),c.restore(),h}_getCombinedScales(){const t=new Float32Array(2);D.singularValueDecompose2dScale(this.matrix,t);const[e,s]=t;return D.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[n,r],a){const[o,l,h,c]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new sc(d,a)),t.save(),s?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(n*this.xstep,r*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){const f=h-o,g=c-l,[y,A]=this._getCombinedScales(),v=this.getSizeAndScale(f,this.ctx.canvas.width,y),w=this.getSizeAndScale(g,this.ctx.canvas.height,A),S=this._renderTileCanvas(t,a,v,w);t.ctx.drawImage(S.canvas,o,l,f,g),t.canvasFactory.destroy(S)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,o,l,h,c),t.baseTransformStack.push(t.baseTransform),t.baseTransform=St(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();
45t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[s,n,r,a]=this.bbox,o=r-s,l=a-n;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),If("TilingType: "+this.tilingType);const[d,f]=this._getCombinedScales();let g=o,y=l,A=!1,v=!1;Math.ceil(h*d)>=Math.ceil(o*d)?g=h:A=!0,Math.ceil(c*f)>=Math.ceil(l*f)?y=c:v=!0;const w=this.getSizeAndScale(g,this.ctx.canvas.width,d),S=this.getSizeAndScale(y,this.ctx.canvas.height,f),E=this._renderTileCanvas(t,e,w,S);if(A||v){const x=E.canvas;A&&(g=h),v&&(y=c);const C=this.getSizeAndScale(g,this.ctx.canvas.width,d),T=this.getSizeAndScale(y,this.ctx.canvas.height,f),k=C.size,P=T.size,M=t.canvasFactory.create(k,P),L=M.context,O=A?Math.floor(o/h):0,Q=v?Math.floor(l/c):0;for(let J=0;J<=O;J++)for(let q=0;q<=Q;q++)L.drawImage(x,k*J,P*q,k,P,0,0,k,P);return t.canvasFactory.destroy(E),{canvas:M.canvas,canvasEntry:M,scaleX:C.scale,scaleY:T.scale,offsetX:s,offsetY:n}}return{canvas:E.canvas,canvasEntry:E,scaleX:w.scale,scaleY:S.scale,offsetX:s,offsetY:n}}getSizeAndScale(t,e,s){const n=Math.max(bf.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=n?r=n:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,n,r){const a=n-e,o=r-s,l=new Path2D;l.rect(e,s,a,o),D.axialAlignedBoundingBox([e,s,n,r],St(t.ctx),t.current.minMax),t.ctx.clip(l),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){const n=t.ctx,r=t.current;switch(r.patternFill=r.patternStroke=!1,e){case Am.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;n.fillStyle=r.fillColor=a,n.strokeStyle=r.strokeColor=o;break;case Am.UNCOLORED:n.fillStyle=n.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new bA(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,n,r){const a=n!==Ae.SHADING?D.transform(s,this.patternBaseMatrix):s,o=this.createPatternCanvas(e,r);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const h=t.createPattern(o.canvas,"repeat");return e.canvasFactory.destroy(o.canvasEntry),h.setTransform(l),h}};_(bf,"MAX_PATTERN_SIZE",3e3);let qh=bf;const b0=16,y0=100,A0=15,wm=10,Ze=16,Jf=new DOMMatrix,Ss=new Float32Array(2);function vm(p,t){if(p._removeMirroring)throw new Error("Context is already forwarding operations.");const e=new Map;for(const s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const n=p[s];typeof n!="function"||typeof t[s]!="function"||(e.set(s,n),p[s]=function(...r){return t[s](...r),n.apply(this,r)})}p._removeMirroring=()=>{for(const[s,n]of e)p[s]=n;delete p._removeMirroring}}function tu(p,t,e,s,n,r,a,o,l,h){const[c,d,f,g,y,A]=St(p);if(d===0&&f===0){const S=a*c+y,E=Math.round(S),x=o*g+A,C=Math.round(x),T=(a+l)*c+y,k=Math.abs(Math.round(T)-E)||1,P=(o+h)*g+A,M=Math.abs(Math.round(P)-C)||1;return p.setTransform(Math.sign(c),0,0,Math.sign(g),E,C),p.drawImage(t,e,s,n,r,0,0,k,M),p.setTransform(c,d,f,g,y,A),[k,M]}if(c===0&&g===0){const S=o*f+y,E=Math.round(S),x=a*d+A,C=Math.round(x),T=(o+h)*f+y,k=Math.abs(Math.round(T)-E)||1,P=(a+l)*d+A,M=Math.abs(Math.round(P)-C)||1;return p.setTransform(0,Math.sign(d),Math.sign(f),0,E,C),p.drawImage(t,e,s,n,r,0,0,M,k),p.setTransform(c,d,f,g,y,A),[M,k]}p.drawImage(t,e,s,n,r,a,o,l,h);const v=Math.hypot(c,d),w=Math.hypot(f,g);return[v*l,w*h]}class Sm{constructor(t,e){_(this,"alphaIsShape",!1);_(this,"fontSize",0);_(this,"fontSizeScale",1);_(this,"textMatrix",null);_(this,"textMatrixScale",1);_(this,"fontMatrix",ep);_(this,"leading",0);_(this,"x",0);_(this,"y",0);_(this,"lineX",0);_(this,"lineY",0);_(this,"charSpacing",0);_(this,"wordSpacing",0);_(this,"textHScale",1);_(this,"textRenderingMode",Qt.FILL);_(this,"textRise",0);_(this,"fillColor","#000000");_(this,"strokeColor","#000000");_(this,"tilingPatternDims",null);_(this,"patternFill",!1);_(this,"patternStroke",!1);_(this,"fillAlpha",1);_(this,"strokeAlpha",1);_(this,"lineWidth",1);_(this,"activeSMask",null);_(this,"transferMaps","none");_(this,"minMax",Zr.slice());this.clipBox=new Float32Array([0,0,t,e])}clone(){var e;const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=(e=this.tilingPatternDims)==null?void 0:e.slice(),t}getPathBoundingBox(t=Ae.FILL,e=null){const s=this.minMax.slice();if(t===Ae.STROKE){e||it("Stroke bounding box must include transform."),D.singularValueDecompose2dScale(e,Ss);const n=Ss[0]*this.lineWidth/2,r=Ss[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=D.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(Zr,0)}getClippedPathBoundingBox(t=Ae.FILL,e=null){return D.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Em(p,t){const{width:e,height:s,kind:n}=t,r=s%Ze,a=(s-r)/Ze,o=r===0?a:a+1,l=p.createImageData(e,Ze);let h=0;const c=t.data,d=l.data;let f;if(n===au.GRAYSCALE_1BPP)for(f=0;f<o;f++)({srcPos:h}=Ib({src:c,srcPos:h,dest:d,width:e,height:f<a?Ze:r})),p.putImageData(l,0,f*Ze);else if(n===au.RGBA_32BPP){let g=0,y=e*Ze*4;for(f=0;f<a;f++)d.set(c.subarray(h,h+y)),h+=y,p.putImageData(l,0,g),g+=Ze;f<o&&(y=e*r*4,d.set(c.subarray(h,h+y)),p.putImageData(l,0,g))}else if(n===au.RGB_24BPP)for(f=0;f<o;f++)({srcPos:h}=r0({src:c,srcPos:h,dest:new Uint32Array(d.buffer),width:e,height:f<a?Ze:r})),p.putImageData(l,0,f*Ze);else throw new Error(`bad image kind: ${n}`)}function xm(p,t){if(t.bitmap){p.drawImage(t.bitmap,0,0);return}const{width:e,height:s}=t,n=s%Ze,r=(s-n)/Ze,a=n===0?r:r+1,o=p.createImageData(e,Ze);let l=0;const h=t.data,c=o.data;for(let d=0;d<a;d++)({srcPos:l}=Ib({src:h,srcPos:l,dest:c,width:e,height:d<r?Ze:n,nonBlackColor:0})),p.putImageData(o,0,d*Ze)}function zr(p,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)p[s]!==void 0&&(t[s]=p[s]);p.setLineDash!==void 0&&(t.setLineDash(p.getLineDash()),t.lineDashOffset=p.lineDashOffset)}function eu(p){p.strokeStyle=p.fillStyle="#000000",p.fillRule="nonzero",p.globalAlpha=1,p.lineWidth=1,p.lineCap="butt",p.lineJoin="miter",p.miterLimit=10,p.globalCompositeOperation="source-over",p.font="10px sans-serif",p.setLineDash!==void 0&&(p.setLineDash([]),p.lineDashOffset=0);const{filter:t}=p;t!=="none"&&t!==""&&(p.filter="none")}function Cm(p,t){if(t)return!0;D.singularValueDecompose2dScale(p,Ss);const e=Math.fround(Hi.pixelRatio*Gr.PDF_TO_CSS_UNITS);return Ss[0]<=e&&Ss[1]<=e}const w0=["butt","round","square"],v0=["miter","round","bevel"],S0={},Tm={};
45var as,ur,La,Ra,Fa,Oa,Na,Ba,Ha,Ci,H,Fp,Op,Np,Bp,Hp,ze,Se,Up,Rb,Au;const Zg=class Zg{constructor(t,e,s,n,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c,d){m(this,H);m(this,as,0);m(this,ur,0);m(this,La,null);m(this,Ra,null);m(this,Fa,null);m(this,Oa,null);m(this,Na,1);m(this,Ba);m(this,Ha,null);m(this,Ci,[]);this.ctx=t,this.current=new Sm(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=n,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=c??null,this.imagesTracker=d??null}getObject(t,e,s=null){var n;return typeof e=="string"?((n=this.dependencyTracker)==null||n.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:n=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.transparentCanvasEntry=this.canvasFactory.create(r,a);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=l,this.ctx.save(),this.ctx.transform(...St(this.compositeCtx))}this.ctx.save(),eu(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=St(this.ctx)}executeOperatorList(t,e,s,n,r){var w;const a=t.argsArray,o=t.fnArray;let l=e||0;const h=a.length;if(h===l)return l;const c=h-l>wm&&typeof s=="function",d=c?Date.now()+A0:0;let f=0;const g=this.commonObjs,y=this.objs;let A,v;for(;;){if(n!==void 0){if(l===n.nextBreakPoint)return n.breakIt(l,s),l;if(n.shouldSkip(l)){if(++l===h)return l;continue}}if(!r||r(l))if(A=o[l],v=a[l]??null,A!==fi.dependency)v===null?this[A](l):this[A](l,...v);else for(const S of v){(w=this.dependencyTracker)==null||w.recordNamedData(S,l);const E=S.startsWith("g_")?g:y;if(!E.has(S))return E.get(S,s),l}if(l++,l===h)return l;if(c&&++f>wm){if(Date.now()>d)return s(),l;f=0}}}endDrawing(){b(this,H,Fp).call(this);for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(const t of i(this,Ci))b(this,H,Au).call(this,t);i(this,Ci).length=0,u(this,La,null),u(this,Ra,null),u(this,Fa,null),u(this,Oa,null),u(this,Na,1),u(this,Ha,null),u(this,ur,0),u(this,as,0),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),b(this,H,Op).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,n=t.height??t.displayHeight,r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=[];let l=r,h=a,c=s,d=n;for(;l>2&&c>1||h>2&&d>1;){let w=c,S=d;l>2&&c>1&&(w=Math.ceil(c/2),l/=c/w),h>2&&d>1&&(S=Math.ceil(d/2),h/=d/S),o.push({newWidth:w,newHeight:S}),c=w,d=S}if(o.length===0)return{img:t,paintWidth:s,paintHeight:n,tmpCanvas:null};if(o.length===1){const{newWidth:w,newHeight:S}=o[0],E=this.canvasFactory.create(w,S);return E.context.drawImage(t,0,0,s,n,0,0,w,S),{img:E.canvas,paintWidth:w,paintHeight:S,tmpCanvas:E}}let f=this.canvasFactory.create(1,1),g=this.canvasFactory.create(1,1),y=s,A=n,v=t;for(const{newWidth:w,newHeight:S}of o)this.canvasFactory.reset(g,w,S),g.context.drawImage(v,0,0,y,A,0,0,w,S),[f,g]=[g,f],v=f.canvas,y=w,A=S;return this.canvasFactory.destroy(g),{img:f.canvas,paintWidth:y,paintHeight:A,tmpCanvas:f}}_createMaskCanvas(t,e){var O,Q;const s=this.ctx,{width:n,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=St(s);let h,c,d,f;if((e.bitmap||e.data)&&e.count>1){const J=e.bitmap||e.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),a]),h=this._cachedBitmapsMap.getOrInsertComputed(J,Hg);const q=h.get(c);if(q&&!o){const Ft=Math.round(Math.min(l[0],l[2])+l[4]),F=Math.round(Math.min(l[1],l[3])+l[5]);return(O=this.dependencyTracker)==null||O.recordDependencies(t,Ts.transformAndFill),{canvas:q,offsetX:Ft,offsetY:F}}d=q}d||(f=this.canvasFactory.create(n,r),xm(f.context,e));let g=D.transform(l,[1/n,0,0,-1/r,0,0]);g=D.transform(g,[1,0,0,1,0,-r]);const y=Zr.slice();D.axialAlignedBoundingBox([0,0,n,r],g,y);
45const[A,v,w,S]=y,E=Math.round(w-A)||1,x=Math.round(S-v)||1,C=this.canvasFactory.create(E,x),T=C.context,k=A,P=v;T.translate(-k,-P),T.transform(...g);let M=null;if(!d){const J=this._scaleImage(f.canvas,hi(T));d=J.img,M=J.tmpCanvas,d!==f.canvas&&(this.canvasFactory.destroy(f),f=null),h&&o&&(h.set(c,d),M=null,f=null)}T.imageSmoothingEnabled=Cm(St(T),e.interpolate),tu(T,d,0,0,d.width,d.height,0,0,n,r),M&&this.canvasFactory.destroy(M),f&&this.canvasFactory.destroy(f),T.globalCompositeOperation="source-in";const L=D.transform(hi(T),[1,0,0,1,-k,-P]);return T.fillStyle=o?a.getPattern(s,this,L,Ae.FILL,t):a,T.fillRect(0,0,n,r),h&&!o&&h.set(c,C.canvas),(Q=this.dependencyTracker)==null||Q.recordDependencies(t,Ts.transformAndFill),{canvas:C.canvas,canvasEntry:h&&!o?null:C,offsetX:Math.round(k),offsetY:Math.round(P)}}setLineWidth(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",t),this.ctx.lineCap=w0[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=v0[e]}setMiterLimit(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,n,r,a,o;for(const[l,h]of e)switch(l){case"LW":this.setLineWidth(t,h);break;case"LC":this.setLineCap(t,h);break;case"LJ":this.setLineJoin(t,h);break;case"ML":this.setMiterLimit(t,h);break;case"D":this.setDash(t,h[0],h[1]);break;case"RI":this.setRenderingIntent(t,h);break;case"FL":this.setFlatness(t,h);break;case"Font":this.setFont(t,h[0],h[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=h;break;case"ca":(n=this.dependencyTracker)==null||n.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=h;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=h;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",t),this.current.activeSMask=h?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(h);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t))}checkSMaskState(t){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){const{canvas:e,subtype:s,backdrop:n,transferMap:r}=t,a=s==="Luminosity"||s==="Alpha"&&r;if(!a&&!(s==="Luminosity"&&n)){this.smaskPreparedFor=t;return}let o;if(s==="Luminosity"&&n){const[S,E,x]=Yd(n),C=Math.round(.3*S+.59*E+.11*x);o=(r==null?void 0:r[C])??C}else o=(r==null?void 0:r[0])??0;const l=4,{width:h,height:c}=this.ctx.canvas,d=e.width*e.height,f=h*c<l*d,g=a?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(r):this.filterFactory.addLuminosityFilter(r),subtype:s,transferMap:r}:null,y=s==="Luminosity"?n:null;let A,v,w;f?(A=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,h,c,y,g),v=0,w=0):(A=this._bakeSMaskCanvas(e,0,0,e.width,e.height,y,g),v=t.offsetX,w=t.offsetY),this.smaskPreparedEntry=A,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=v,this.smaskPreparedOffsetY=w,this.smaskPreparedOOBAlpha=!f&&o!==0?o:null}_bakeSMaskCanvas(t,e,s,n,r,a,o){!a&&!o&&it("_bakeSMaskCanvas with 
45neither backdrop nor filter");const l=this.canvasFactory.create(n,r),h=l.context;if(h.drawImage(t,e,s),a&&(h.globalCompositeOperation="destination-atop",h.fillStyle=a,h.fillRect(0,0,n,r)),!o)return l;const c=this.canvasFactory.create(n,r),d=c.context;d.filter=o.url;const f=bt.isCanvasFilterSupported&&d.filter!=="none"&&d.filter!=="";if(d.drawImage(l.canvas,0,0),bt.isCanvasFilterSupported&&(d.filter="none"),!f){const g=d.getImageData(0,0,n,r),{data:y}=g,{transferMap:A}=o;if(o.subtype==="Luminosity")for(let v=0,w=y.length;v<w;v+=4){const S=.3*y[v]+.59*y[v+1]+.11*y[v+2]+.5|0;y[v]=y[v+1]=y[v+2]=0,y[v+3]=(A==null?void 0:A[S])??S}else for(let v=3,w=y.length;v<w;v+=4)y[v]=A[y[v]];d.putImageData(g,0,0)}return this.canvasFactory.destroy(l),c}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:e,height:s}=this.ctx.canvas,n=this.canvasFactory.create(e,s);this.smaskScratchCanvas=n,this.suspendedCtx=this.ctx;const r=this.ctx=n.context;r.setTransform(this.suspendedCtx.getTransform()),zr(this.suspendedCtx,r),vm(r,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),zr(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx,n=i(this,ur)>0&&s===this.ctx;this.composeSMask(n?null:s,e,this.ctx,t),!n&&(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,s,n){const r=n[0],a=n[1],o=n[2]-r,l=n[3]-a;if(o===0||l===0)return;const h=this.smaskPreparedEntry;if(h){let c=r,d=a,f=o,g=l;const y=this.smaskPreparedOOBAlpha,A=y!==null;if(A){c=Math.max(r,e.offsetX),d=Math.max(a,e.offsetY);const v=Math.min(r+o,e.offsetX+e.canvas.width),w=Math.min(a+l,e.offsetY+e.canvas.height);f=v-c,g=w-d}if(f>0&&g>0){const v=c-this.smaskPreparedOffsetX,w=d-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const S=new Path2D;S.rect(c,d,f,g),s.clip(S),s.globalCompositeOperation="destination-in",s.drawImage(h.canvas,v,w,f,g,c,d,f,g),s.restore()}A&&y<255&&this._applySMaskOOBAlpha(s,r,a,o,l,c,d,c+f,d+g,y)}else this.genericComposeSMask(e,s,o,l,r,a);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,r,a,o,l,r,a,o,l),t.restore())}_applySMaskOOBAlpha(t,e,s,n,r,a,o,l,h,c){const d=a<l&&o<h;if(d&&a===e&&o===s&&l===e+n&&h===s+r)return;const f=new Path2D;f.rect(e,s,n,r),d&&f.rect(a,o,l-a,h-o),t.save(),t.globalAlpha=c/255,t.setTransform(1,0,0,1,0,0),t.clip(f,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,s,n,r),t.restore()}genericComposeSMask(t,e,s,n,r,a){const{context:o,offsetX:l,offsetY:h}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const c=new Path2D;c.rect(r,a,s,n),e.clip(c),e.globalCompositeOperation="destination-in",e.drawImage(o.canvas,r-l,a-h,s,n,r,a,s,n),e.restore()}save(t){var s;this.inSMaskMode&&zr(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(s=this.dependencyTracker)==null||s.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(zr(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,n,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,n,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,n){let[r]=s;if(!n){r||(r=s[0]=new Path2D),e!==fi.stroke&&e!==fi.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,r);return}if(this.dependencyTracker!==null){const o=e===fi.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,n[0]-o,n[2]+o,n[1]-o,n[3]+o).recordDependencies(t,["transform"])}r instanceof Path2D||(r=s[0]=Hm(r)),D.axialAlignedBoundingBox(n,St(this.ctx),this.current.minMax);const a=this.current.tilingPatternDims;if(a&&e!==fi.stroke&&e!==fi.closeStroke&&this.current.fillColor instanceof qh){const o=D.intersect(this.current.clipBox,this.current.minMax);o?this.current.fillColor.updatePatternDims(o,a):this.current.tilingPatternDims=null}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var o;const n=s&&b(this,H,ze).call(this,this.current.strokeAlpha),r=this.ctx,a=this.current.strokeColor;if(r.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof a=="object"&&(a!=null&&a.getPattern)){const l=a.isModifyingCurrentTransform()?r.getTransform():null;if(r.save(),r.strokeStyle=a.getPattern(r,this,hi(r),Ae.STROKE,t),l){const h=new Path2D;h.addPath(e,r.getTransform().invertSelf().multiplySelf(l)),e=h}
45this.rescaleAndStroke(e,!1),r.restore()}else this.rescaleAndStroke(e,!0);(o=this.dependencyTracker)==null||o.recordDependencies(t,Ts.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(Ae.STROKE,St(this.ctx))),r.globalAlpha=this.current.fillAlpha,b(this,H,Se).call(this,n)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var c,d,f;const n=s&&b(this,H,ze).call(this,this.current.fillAlpha),r=this.ctx,a=this.current.fillColor,o=this.current.patternFill;let l=!1;const h=this.current.getClippedPathBoundingBox();if((c=this.dependencyTracker)==null||c.recordDependencies(t,Ts.fill),o){const g=this.current.tilingPatternDims,y=g&&a.canSkipPatternCanvas(g);if(y){a.drawPattern(this,e,this.pendingEOFill,y,t),this.pendingEOFill=!1,s&&this.consumePath(t,e,h),this.current.tilingPatternDims=null,b(this,H,Se).call(this,n);return}const A=a.isModifyingCurrentTransform()?r.getTransform():null;if((d=this.dependencyTracker)==null||d.save(t),r.save(),r.fillStyle=a.getPattern(r,this,hi(r),Ae.FILL,t),A){const v=new Path2D;v.addPath(e,r.getTransform().invertSelf().multiplySelf(A)),e=v}l=!0}this.contentVisible&&h!==null&&(this.pendingEOFill?(r.fill(e,"evenodd"),this.pendingEOFill=!1):r.fill(e)),l&&(r.restore(),(f=this.dependencyTracker)==null||f.restore(t)),s&&this.consumePath(t,e,h),b(this,H,Se).call(this,n)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const s=b(this,H,ze).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),b(this,H,Se).call(this,s)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var n;const s=b(this,H,ze).call(this,this.current.fillAlpha);this.ctx.fill(e),(n=this.dependencyTracker)==null||n.recordDependencies(t,Ts.rawFillPath).recordOperation(t),b(this,H,Se).call(this,s)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=S0}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=Tm}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:n}=this;e!==void 0&&n.recordFutureForcedDependency("textClip",n.getOpenMarker()).recordFutureForcedDependency("textClip",t),n.recordCloseMarker(t)}if(e!==void 0){const n=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:h,path:c}of e)c&&n.addPath(c,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(h,-h));s.clip(n)}delete this.pendingTextPaths}setCharSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){var d,f;(d=this.dependencyTracker)==null||d.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||ep,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&W("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=s,n.isType3Font)return;const a=n.loadedName||"sans-serif",o=((f=n.systemFontInfo)==null?void 0:f.css)||`"${a}", ${n.fallbackName}`;let l="normal";n.black?l="900":n.bold&&(l="bold");const h=n.italic?"italic":"normal",c=Tt(s,b0,y0);this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${l} ${c}px ${o}`}setTextRenderingMode(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}
45paintChar(t,e,s,n,r,a){var w,S,E,x;const o=this.ctx,l=this.current,h=l.font,c=l.textRenderingMode,d=l.fontSize/l.fontSizeScale,f=c&Qt.FILL_STROKE_MASK,g=!!(c&Qt.ADD_TO_PATH_FLAG),y=l.patternFill&&!h.missingFile,A=l.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||g||y||A)&&!h.missingFile&&(v=h.getPathGenerator(this.commonObjs,e)),v&&(h.disableFontFace||y||A)){o.save(),o.translate(s,n),o.scale(d,-d),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,o,h);let C;if(f===Qt.FILL||f===Qt.FILL_STROKE)if(r){C=o.getTransform(),o.setTransform(...r);const T=b(this,H,Up).call(this,v,C,r);o.fill(T)}else o.fill(v);if(f===Qt.STROKE||f===Qt.FILL_STROKE)if(a){C||(C=o.getTransform()),o.setTransform(...a);const{a:T,b:k,c:P,d:M}=C,L=D.inverseTransform(a),O=D.transform([T,k,P,M,0,0],L);D.singularValueDecompose2dScale(O,Ss),o.lineWidth*=Math.max(Ss[0],Ss[1])/d,o.stroke(b(this,H,Up).call(this,v,C,a))}else o.lineWidth/=d,o.stroke(v);o.restore()}else(f===Qt.FILL||f===Qt.FILL_STROKE)&&(o.fillText(e,s,n),(S=this.dependencyTracker)==null||S.recordCharacterBBox(t,o,h,d,s,n,()=>o.measureText(e))),(f===Qt.STROKE||f===Qt.FILL_STROKE)&&(this.dependencyTracker&&((E=this.dependencyTracker)==null||E.recordCharacterBBox(t,o,h,d,s,n,()=>o.measureText(e)).recordDependencies(t,Ts.stroke)),o.strokeText(e,s,n));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:St(o),x:s,y:n,fontSize:d,path:v}),(x=this.dependencyTracker)==null||x.recordCharacterBBox(t,o,h,d,s,n))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let n=!1;for(let r=3;r<s.length;r+=4)if(s[r]>0&&s[r]<255){n=!0;break}return $(this,"isFontSubpixelAAEnabled",n)}showText(t,e){var Q,J,q,Ft;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Ts.showText).resetBBox(t),this.current.textRenderingMode&Qt.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,n=s.font;if(n.isType3Font){const F=b(this,H,ze).call(this,s.fillAlpha);this.showType3Text(t,e),(Q=this.dependencyTracker)==null||Q.recordShowTextOperation(t),b(this,H,Se).call(this,F);return}const r=s.fontSize;if(r===0){(J=this.dependencyTracker)==null||J.recordOperation(t);return}const a=b(this,H,ze).call(this,s.fillAlpha),o=this.ctx,l=s.fontSizeScale,h=s.charSpacing,c=s.wordSpacing,d=s.fontDirection,f=s.textHScale*d,g=e.length,y=n.vertical,A=y?1:-1,v=n.defaultVMetrics,w=r*s.fontMatrix[0],S=s.textRenderingMode===Qt.FILL&&!n.disableFontFace&&!s.patternFill;o.save(),s.textMatrix&&o.transform(...s.textMatrix),o.translate(s.x,s.y+s.textRise),d>0?o.scale(f,-1):o.scale(f,1);let E,x;const C=s.textRenderingMode&Qt.FILL_STROKE_MASK,T=C===Qt.FILL||C===Qt.FILL_STROKE,k=C===Qt.STROKE||C===Qt.FILL_STROKE;let P=s.lineWidth;const M=s.textMatrixScale;if(M===0||P===0?k&&(P=this.getSinglePixelWidth()):P/=M,l!==1&&(o.scale(l,l),P/=l),o.lineWidth=P,T&&s.patternFill){o.save();const F=s.fillColor.getPattern(o,this,hi(o),Ae.FILL,t);E=St(o),o.restore(),o.fillStyle=F}if(k&&s.patternStroke){o.save();const F=s.strokeColor.getPattern(o,this,hi(o),Ae.STROKE,t);x=St(o),o.restore(),o.strokeStyle=F}if(n.isInvalidPDFjsFont){const F=[];let U=0;for(const $t of e)F.push($t.unicode),U+=$t.width;const Gt=F.join("");if(o.fillText(Gt,0,0),this.dependencyTracker!==null){const $t=o.measureText(Gt);this.dependencyTracker.recordBBox(t,this.ctx,-$t.actualBoundingBoxLeft,$t.actualBoundingBoxRight,-$t.actualBoundingBoxAscent,$t.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=U*w*f,o.restore(),this.compose(),b(this,H,Se).call(this,a);return}let L=0,O;for(O=0;O<g;++O){const F=e[O];if(typeof F=="number"){L+=A*F*r/1e3;continue}let U=!1;const Gt=(F.isSpace?c:0)+h,$t=F.fontChar,ts=F.accent;let ce,Xt,dt=F.width;if(y){const te=F.vmetric||v,wt=-(F.vmetric?te[1]:dt*.5)*w,jf=te[2]*w;dt=te?-te[0]:dt,ce=wt/l,Xt=(L+jf)/l}else ce=L/l,Xt=0;let li;if(n.remeasure&&dt>0){li=o.measureText($t);const te=li.width*1e3/r*l;if(dt<te&&this.isFontSubpixelAAEnabled){const wt=dt/te;U=!0,o.save(),o.scale(wt,1),ce/=wt}else dt!==te&&(ce+=(dt-te)/2e3*r/l)}if(this.contentVisible&&(F.isInFont||n.missingFile)){if(S&&!ts)o.fillText($t,ce,Xt),(q=this.dependencyTracker)==null||q.recordCharacterBBox(t,o,li?{bbox:null}:n,r/l,ce,Xt,()=>li??o.measureText($t));else if(this.paintChar(t,$t,ce,Xt,E,x),ts){const te=ce+r*ts.offset.x/l,wt=Xt-r*ts.offset.y/l;this.paintChar(t,ts.fontChar,te,wt,E,x)}}const xh=y?dt*w-Gt*d:dt*w+Gt*d;
45L+=xh,U&&o.restore()}y?s.y-=L:s.x+=L*f,o.restore(),this.compose(),(Ft=this.dependencyTracker)==null||Ft.recordShowTextOperation(t),b(this,H,Se).call(this,a)}showType3Text(t,e){const s=this.ctx,n=this.current,r=n.font,a=n.fontSize,o=n.fontDirection,l=r.vertical?1:-1,h=n.charSpacing,c=n.wordSpacing,d=n.textHScale*o,f=n.fontMatrix||ep,g=e.length,y=n.textRenderingMode===Qt.INVISIBLE;let A,v,w,S;if(y||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),n.textMatrix&&s.transform(...n.textMatrix),s.translate(n.x,n.y+n.textRise),s.scale(d,o);const E=this.dependencyTracker;for(this.dependencyTracker=E?new sc(E,t):null,A=0;A<g;++A){if(v=e[A],typeof v=="number"){S=l*v*a/1e3,this.ctx.translate(S,0),n.x+=S*d;continue}const x=(v.isSpace?c:0)+h,C=r.charProcOperatorList[v.operatorListId];C?this.contentVisible&&(this.save(),C.fnArray[0]===fi.setCharWidth&&(n.fillAlpha=n.strokeAlpha=1,s.globalAlpha=1),s.scale(a,a),s.transform(...f),this.executeOperatorList(C),this.restore()):W(`Type3 character "${v.operatorListId}" is not available.`);const T=[v.width,0];D.applyTransform(T,f),w=T[0]*a+x,s.translate(w,0),n.x+=w*d}s.restore(),E&&(this.dependencyTracker=E)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,n,r,a,o){var h;const l=new Path2D;l.rect(n,r,a-n,o-r),this.ctx.clip(l),(h=this.dependencyTracker)==null||h.recordBBox(t,this.ctx,n,a,r,o).recordClipBox(t,this.ctx,n,a,r,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const n=this.baseTransform||St(this.ctx),r={createCanvasGraphics:(a,o)=>new Zg(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new sc(this.dependencyTracker,o,!0):null)};s=new qh(e,this.ctx,r,n)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("fillColor",t);const s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof qh?[0,0,0,0]:null}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
45setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){const n=this.cachedPatterns.getOrInsertComputed(e,()=>m0(this.getObject(t,e)));return s&&(n.matrix=s),n}shadingFill(t,e){var o;if(!this.contentVisible)return;const s=b(this,H,ze).call(this,this.current.fillAlpha),n=this.ctx;this.save(t);const r=this._getPattern(t,e);n.fillStyle=r.getPattern(n,this,hi(n),Ae.SHADING,t);const a=hi(n);if(a){const{width:l,height:h}=n.canvas,c=Zr.slice();D.axialAlignedBoundingBox([0,0,l,h],a,c);const[d,f,g,y]=c;this.ctx.fillRect(d,f,g-d,y-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Ts.transform).recordDependencies(t,Ts.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),b(this,H,Se).call(this,s)}beginInlineImage(){it("Should not call beginInlineImage")}beginImageData(){it("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var n;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=St(this.ctx),s)){D.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[r,a,o,l]=s,h=new Path2D;h.rect(r,a,o-r,l-a),this.ctx.clip(h),(n=this.dependencyTracker)==null||n.recordClipBox(t,this.ctx,r,o,a,l),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var x;if(!this.contentVisible)return;this.save(t);const{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);const n=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&i(this,as)===0&&n.globalAlpha===1&&n.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let C=new Path2D;const[T,k,P,M]=e.bbox;if(C.rect(T,k,P-T,M-k),e.matrix){const L=new Path2D;L.addPath(C,new DOMMatrix(e.matrix)),C=L}n.clip(C)}this.groupStack.push(null),i(this,Ci).push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&i(this,as)===0&&If("TODO: Fully support non-isolated non-knockout groups.");const r=St(n);e.matrix&&n.transform(...e.matrix);const a=[0,0,n.canvas.width,n.canvas.height];let o;e.bbox?(o=Zr.slice(),D.axialAlignedBoundingBox(e.bbox,St(n),o),o=D.intersect(o,a)||[0,0,0,0]):o=a;const l=Math.floor(o[0]),h=Math.floor(o[1]),c=Math.max(Math.ceil(o[2])-l,1),d=Math.max(Math.ceil(o[3])-h,1);this.current.startNewPathAndClipBox([0,0,c,d]);const f=this.canvasFactory.create(c,d);e.smask&&this.smaskGroupCanvases.push(f);const g=f.context,y=e.knockout&&!e.isolated?n:null,A=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&i(this,as)>0,v=e.knockout?this.canvasFactory.create(c,d):null,w=i(this,as);e.knockout?Et(this,as)._++:u(this,as,0),g.translate(-l,-h),g.transform(...r);const S=!e.isolated&&!e.smask&&e.needsIsolation,E=S&&!s&&w===0&&!e.knockout&&!e.isGray&&e.hasSoftMask&&n.globalAlpha===1&&n.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none";if(S&&(s||E)&&(g.save(),g.setTransform(1,0,0,1,0,0),g.drawImage(n.canvas,-l,-h),g.restore()),e.bbox){let C=new Path2D;const[T,k,P,M]=e.bbox;if(C.rect(T,k,P-T,M-k),e.matrix){const L=new Path2D;L.addPath(C,new DOMMatrix(e.matrix)),C=L}g.clip(C)}e.smask&&this.smaskStack.push({canvas:f.canvas,context:g,offsetX:l,offsetY:h,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(n.setTransform(1,0,0,1,0,0),n.translate(l,h),n.save()),zr(n,g),this.ctx=g,(x=this.dependencyTracker)==null||x.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(n),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(n),i(this,Ci).push({backdropCtx:y,savedKnockoutLevel:w,offsetX:l,offsetY:h,hasInnerBackdrop:A,replaceBackdrop:E,knockoutMaskEntry:v,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){var a;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,n=this.groupStack.pop(),r=i(this,Ci).pop();if(r&&u(this,as,r.savedKnockoutLevel),n===null){this.restore(t);return}if(e.isGray&&b(this,H,Rb).call(this,s),this.ctx=n,this.ctx.imageSmoothingEnabled=!1,(a=this.dependencyTracker)==null||a.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(
45),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),b(this,H,Au).call(this,r);else{this.ctx.restore();const o=St(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...o);const l=Zr.slice();D.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],o,l);const h=i(this,Ci).at(-1);if(i(this,as)>0)if(r.hasInnerBackdrop){const{width:c,height:d}=s.canvas,f=this.canvasFactory.create(c,d),g=f.context;g.drawImage(n.canvas,r.offsetX,r.offsetY,c,d,0,0,c,d),g.globalCompositeOperation="source-over",g.drawImage(s.canvas,0,0);const y=b(this,H,Np).call(this,s.canvas);g.globalCompositeOperation="destination-in",g.drawImage(y.canvas,0,0);const A=this.ctx.globalCompositeOperation,v=this.ctx.globalAlpha,w=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...o),this.ctx.globalAlpha=1,bt.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(y.canvas,0,0),this.ctx.globalCompositeOperation=A,this.ctx.globalAlpha=v,bt.isCanvasFilterSupported&&(this.ctx.filter=w??"none"),this.ctx.drawImage(f.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(y),this.canvasFactory.destroy(f)}else{const c=(h==null?void 0:h.backdropCtx)??null;b(this,H,Hp).call(this,this.ctx,s.canvas,{backdropCanvas:(c==null?void 0:c.canvas)??null,destTransform:o,backdropOffset:c?[h.offsetX+r.offsetX,h.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(r.replaceBackdrop){const c=new Path2D;c.rect(0,0,s.canvas.width,s.canvas.height),this.ctx.clip(c),this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(s.canvas,0,0)}this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),b(this,H,Au).call(this,r),this.compose(l)}}beginAnnotation(t,e,s,n,r,a,o){if(b(this,H,Fp).call(this),eu(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const l=s[2]-s[0],h=s[3]-s[1];if(a&&this.annotationCanvasMap){n=n.slice(),n[4]-=s[0],n[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=l,s[3]=h,D.singularValueDecompose2dScale(St(this.ctx),Ss);const{viewportScale:c}=this,d=Math.ceil(l*this.outputScaleX*c),f=Math.ceil(h*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:g,context:y}=this.annotationCanvas;if(o){const A=this.annotationCanvasMap.getOrInsertComputed(e,Wd);g.setAttribute("data-canvas-name",o);const v=A.findIndex(w=>w.getAttribute("data-canvas-name")===o);v===-1?A.push(g):A[v]=g}else this.annotationCanvasMap.set(e,g);this.annotationCanvas.savedCtx=this.ctx,this.ctx=y,this.ctx.save(),this.ctx.setTransform(Ss[0],0,0,-Ss[1],0,h*Ss[1]),eu(this.ctx)}else{eu(this.ctx),this.endPath(t);const c=new Path2D;c.rect(s[0],s[1],l,h),this.ctx.clip(c)}}this.current=new Sm(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...n),this.transform(t,...r),this.baseTransform=St(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),b(this,H,Op).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){var l;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const n=b(this,H,ze).call(this,this.current.fillAlpha),r=this.ctx,a=this._createMaskCanvas(t,e),o=a.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(o,a.offsetX,a.offsetY),(l=this.dependencyTracker)==null||l.resetBBox(t).recordBBox(t,this.ctx,a.offsetX,a.offsetX+o.width,a.offsetY,a.offsetY+o.height).recordOperation(t),r.restore(),a.canvasEntry&&this.canvasFactory.destroy(a.canvasEntry),this.compose(),b(this,H,Se).call(this,n)}paintImageMaskXObjectRepeat(t,e,s,n=0,r=0,a,o){var f,g,y;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=b(this,H,ze).call(this,this.current.fillAlpha),h=this.ctx;h.save();const c=St(h);h.transform(s,n,r,a,0,0);const d=this._createMaskCanvas(t,e);h.setTransform(1,0,0,1,d.offsetX-c[4],d.offsetY-c[5]),(f=this.dependencyTracker)==null||f.resetBBox(t);for(let A=0,v=o.length;A<v;A+=2){const w=D.transform(c,[s,n,r,a,o[A],o[A+1]]);h.drawImage(d.canvas,w[4],w[5]),(g=this.dependencyTracker)==null||g.recordBBox(t,this.ctx,w[4],w[4]+d.canvas.width,w[5],w[5]+d.canvas.height)}
45h.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),(y=this.dependencyTracker)==null||y.recordOperation(t),b(this,H,Se).call(this,l)}paintImageMaskXObjectGroup(t,e){var o,l,h;if(!this.contentVisible)return;const s=b(this,H,ze).call(this,this.current.fillAlpha),n=this.ctx,r=this.current.fillColor,a=this.current.patternFill;(o=this.dependencyTracker)==null||o.resetBBox(t).recordDependencies(t,Ts.transformAndFill);for(const c of e){const{data:d,width:f,height:g,transform:y}=c,A=this.canvasFactory.create(f,g),v=A.context;v.save();const w=this.getObject(t,d,c);xm(v,w),v.globalCompositeOperation="source-in",v.fillStyle=a?r.getPattern(v,this,hi(n),Ae.FILL,t):r,v.fillRect(0,0,f,g),v.restore(),n.save(),n.transform(...y),n.scale(1,-1),tu(n,A.canvas,0,0,f,g,0,-1,1,1),this.canvasFactory.destroy(A),(l=this.dependencyTracker)==null||l.recordBBox(t,n,0,f,0,g),n.restore()}this.compose(),(h=this.dependencyTracker)==null||h.recordOperation(t),b(this,H,Se).call(this,s)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){W("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,n,r){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a){W("Dependent image isn't ready yet");return}const o=a.width,l=a.height,h=[];for(let c=0,d=r.length;c<d;c+=2)h.push({transform:[s,0,0,n,r[c],r[c+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(t,a,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return{img:t.bitmap,canvasEntry:null};const{bitmap:e,width:s,height:n}=t,r=this.canvasFactory.create(s,n),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",{img:r.canvas,canvasEntry:r}}paintInlineImageXObject(t,e){var d;if(!this.contentVisible)return;const s=e.width,n=e.height,r=b(this,H,ze).call(this,this.current.fillAlpha),a=this.ctx;this.save(t);const{filter:o}=a;o!=="none"&&o!==""&&(a.filter="none"),a.scale(1/s,-1/n);let l,h=null;if(e.bitmap){const f=this.applyTransferMapsToBitmap(e);l=f.img,h=f.canvasEntry}else{const f=this.canvasFactory.create(s,n);Em(f.context,e),l=this.applyTransferMapsToCanvas(f.context),h=f}const c=this._scaleImage(l,hi(a));a.imageSmoothingEnabled=Cm(St(a),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,a,0,s,-n,0).recordDependencies(t,Ts.imageXObject).recordOperation(t),(d=this.imagesTracker)==null||d.record(a,s,n,this.dependencyTracker.clipBox)),tu(a,c.img,0,0,c.paintWidth,c.paintHeight,0,-n,s,n),c.tmpCanvas&&this.canvasFactory.destroy(c.tmpCanvas),h&&this.canvasFactory.destroy(h),this.compose(),this.restore(t),b(this,H,Se).call(this,r)}paintInlineImageXObjectGroup(t,e,s){var l,h,c;if(!this.contentVisible)return;const n=b(this,H,ze).call(this,this.current.fillAlpha),r=this.ctx;let a,o=null;if(e.bitmap)a=e.bitmap;else{const d=e.width,f=e.height,g=this.canvasFactory.create(d,f);Em(g.context,e),a=this.applyTransferMapsToCanvas(g.context),o=g}(l=this.dependencyTracker)==null||l.resetBBox(t);for(const d of s)r.save(),r.transform(...d.transform),r.scale(1,-1),tu(r,a,d.x,d.y,d.w,d.h,0,-1,1,1),(h=this.dependencyTracker)==null||h.recordBBox(t,r,0,1,-1,0),r.restore();o&&this.canvasFactory.destroy(o),(c=this.dependencyTracker)==null||c.recordOperation(t),this.compose(),b(this,H,Se).call(this,n)}paintSolidColorImageMask(t){var s;if(!this.contentVisible)return;const e=b(this,H,ze).call(this,this.current.fillAlpha);(s=this.dependencyTracker)==null||s.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ts.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),b(this,H,Se).call(this,e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var n;(n=this.dependencyTracker)==null||n.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){var a,o;const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(n||(this.pendingClip===Tm?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(o=this.dependencyTracker)==null||o.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=St(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:n,d:r}=this.ctx.getTransform();let a,o;if(s===0&&n===0){const l=Math.abs(e),h=Math.abs(r);if(l===h)if(t===0)a=o=1/l;else{const c=l*t;a=o=c<1?1/c:1}else if(t===0)a=1/l,o=1/h;else{const c=l*t,d=h*t;a=c<1?1/c:1,o=d<1?1/d:1}}else{const l=Math.abs(e*r-s*n),h=Math.hypot(e,s),c=Math.hypot(n,r);if(t===0)a=c/l,o=h/l;else{const d=t*l;a=c>d?c/d:1,o=h>d?h/d:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:n}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(n||1)*r,s.stroke(t);return}const o=s.getLineDash();e&&s.save(),s.scale(r,a),Jf.a=1/r,Jf.d=1/a;const l=new Path2D;if(l.addPath(t,Jf),o.length>0){const h=Math.max(r,a);
45s.setLineDash(o.map(c=>c/h)),s.lineDashOffset/=h}s.lineWidth=n||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};as=new WeakMap,ur=new WeakMap,La=new WeakMap,Ra=new WeakMap,Fa=new WeakMap,Oa=new WeakMap,Na=new WeakMap,Ba=new WeakMap,Ha=new WeakMap,Ci=new WeakMap,H=new WeakSet,Fp=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)},Op=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Np=function(t,e=null,s=1){const{width:n,height:r}=t,a=e??this.canvasFactory.create(n,r),o=a.context;s=Math.round(s*255)/255;const l=s<1;l&&i(this,Ba)===void 0&&u(this,Ba,bt.isCanvasFilterSupported?new Map:"none");let h="none";if(l&&i(this,Ba)instanceof Map&&(h=i(this,Ba).getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s))),!l||h!=="none")return e&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,n,r),o.restore()),o.filter=h,o.drawImage(t,0,0),o.filter="none",a;const c=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,n,r),d=o.createImageData(n,r),f=c.data,g=d.data,y=s>0?1/s:1e6;for(let A=3,v=f.length;A<v;A+=4)g[A]=Math.min(Math.round(f[A]*y),255);return o.putImageData(d,0,0),a},Bp=function(t,e,s,n){let r=(t==null?void 0:t[e])??null;if(r&&(r.canvas.width!==s||r.canvas.height!==n)&&(this.canvasFactory.destroy(r),r=null),!r)return r=this.canvasFactory.create(s,n),t&&(t[e]=r),r;const a=r.context;return a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s,n),a.restore(),r},Hp=function(t,e,s={}){const{backdropCanvas:n=null,destTransform:r=[1,0,0,1,0,0],backdropOffset:a=[0,0],reuseMaskEntry:o=null,poolMeta:l=null,sourceAlpha:h=1,sourceFilter:c="none",knockoutAlpha:d=1}=s,{width:f,height:g}=e,y=b(this,H,Np).call(this,e,o,d),A=t.globalCompositeOperation;if(t.save(),t.setTransform(...r),t.globalAlpha=1,bt.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(y.canvas,0,0),n){const[v,w]=a,S=b(this,H,Bp).call(this,l,"knockoutBackdropEntry",f,g),E=S.context;E.drawImage(n,v,w,f,g,0,0,f,g),E.globalCompositeOperation="destination-in",E.drawImage(y.canvas,0,0),E.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(S.canvas,0,0),l||this.canvasFactory.destroy(S)}t.globalCompositeOperation=A,t.globalAlpha=h,bt.isCanvasFilterSupported&&(t.filter=c??"none"),t.drawImage(e,0,0),t.restore(),o||this.canvasFactory.destroy(y)},ze=function(t=1){if(i(this,as)===0||i(this,ur)>0||!this.contentVisible)return!1;Et(this,ur)._++,u(this,Na,t);const e=i(this,Ci).at(-1),{canvas:s}=this.ctx,n=b(this,H,Bp).call(this,e,"knockoutTempEntry",s.width,s.height);u(this,La,n);const r=n.context;return r.save(),r.setTransform(this.ctx.getTransform()),zr(this.ctx,r),u(this,Oa,r.globalCompositeOperation),r.globalCompositeOperation="source-over",vm(r,this.ctx),u(this,Ha,e),u(this,Ra,this.ctx),u(this,Fa,this.suspendedCtx),this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0},Se=function(t){var l;if(!t)return;const e=i(this,La),s=i(this,Ra),n=i(this,Fa),r=e.context;u(this,La,null),u(this,Ra,null),u(this,Fa,null),this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=n),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=i(this,Oa),u(this,Oa,null),zr(this.ctx,s),this.ctx=s;const a=i(this,Ha);u(this,Ha,null);const o=i(this,Na);u(this,Na,1);try{b(this,H,Hp).call(this,n??s,e.canvas,{backdropCanvas:((l=a==null?void 0:a.backdropCtx)==null?void 0:l.canvas)??null,backdropOffset:a!=null&&a.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:(a==null?void 0:a.knockoutMaskEntry)??null,poolMeta:a,
45knockoutAlpha:o})}finally{r.restore(),Et(this,ur)._--,a||this.canvasFactory.destroy(e)}},Up=function(t,e,s){const n=new Path2D;return n.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),n},Rb=function(t){const{canvas:e}=t,{width:s,height:n}=e;if(bt.isCanvasFilterSupported){t.save(),t.setTransform(1,0,0,1,0,0),t.filter="grayscale(1)",t.globalAlpha=1,t.globalCompositeOperation="copy",t.drawImage(e,0,0),t.restore();return}const r=t.getImageData(0,0,s,n),{data:a}=r;for(let o=0,l=a.length;o<l;o+=4){const h=a[o]*.2126+a[o+1]*.7152+a[o+2]*.0722+.5|0;a[o]=a[o+1]=a[o+2]=h}t.putImageData(r,0,0)},Au=function(t){t&&(t.knockoutMaskEntry&&(this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null),t.knockoutTempEntry&&(this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null),t.knockoutBackdropEntry&&(this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null))};let Yo=Zg;for(const p in fi)Yo.prototype[p]!==void 0&&(Yo.prototype[fi[p]]=Yo.prototype[p]);var Bc,Hc;class Of{constructor(t,e,s){m(this,Bc,null);m(this,Hc,null);_(this,"_fullReader",null);_(this,"_rangeReaders",new Set);_(this,"_source",null);this._source=t,u(this,Bc,e),u(this,Hc,s)}get _progressiveDataLength(){var t;return((t=this._fullReader)==null?void 0:t._loaded)??0}getFullReader(){return Rt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new(i(this,Bc))(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new(i(this,Hc))(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){var e;(e=this._fullReader)==null||e.cancel(t);for(const s of new Set(this._rangeReaders))s.cancel(t)}}Bc=new WeakMap,Hc=new WeakMap;class Nf{constructor(t){_(this,"onProgress",null);_(this,"_contentLength",0);_(this,"_filename",null);_(this,"_headersCapability",Promise.withResolvers());_(this,"_isRangeSupported",!1);_(this,"_isStreamingSupported",!1);_(this,"_loaded",0);_(this,"_stream",null);this._stream=t}_callOnProgress(){var t;(t=this.onProgress)==null||t.call(this,{loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){it("Abstract method `read` called")}cancel(t){it("Abstract method `cancel` called")}}class Bf{constructor(t,e,s){_(this,"_stream",null);this._stream=t}async read(){it("Abstract method `read` called")}cancel(t){it("Abstract method `cancel` called")}}function E0(p){let t=!0,e=s("filename\\*","i").exec(p);if(e){e=e[1];let c=o(e);return c=unescape(c),c=l(c),c=h(c),r(c)}if(e=a(p),e){const c=h(e);return r(c)}if(e=s("filename","i").exec(p),e){e=e[1];let c=o(e);return c=h(c),r(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function n(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const f=new TextDecoder(c,{fatal:!0}),g=Lf(d);d=f.decode(g),t=!1}catch{}}return d}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=n("utf-8",c),t&&(c=n("iso-8859-1",c))),c}function a(c){const d=[];let f;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=g.exec(c))!==null;){let[,A,v,w]=f;if(A=parseInt(A,10),A in d){if(A===0)break;continue}d[A]=[v,w]}const y=[];for(let A=0;A<d.length&&A in d;++A){let[v,w]=d[A];w=o(w),v&&(w=unescape(w),A===0&&(w=l(w))),y.push(w)}return y.join("")}function o(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let f=0;f<d.length;++f){const g=d[f].indexOf('"');g!==-1&&(d[f]=d[f].slice(0,g),d.length=f+1),d[f]=d[f].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function l(c){const d=c.indexOf("'");if(d===-1)return c;const f=c.slice(0,d),y=c.slice(d+1).replace(/^[^']*'/,"");return n(f,y)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,f,g,y){if(g==="q"||g==="Q")return y=y.replaceAll("_"," "),y=y.replaceAll(/=([0-9a-f]{2})/gi,function(A,v){return String.fromCharCode(parseInt(v,16))}),n(f,y);try{y=atob(y)}catch{}return n(f,y)})}return""}function Fb(p,t){const e=new Headers;if(!p||!t||typeof t!="object")return e;for(const s in t){const n=t[s];n!==void 0&&e.append(s,n)}return e}function Hf(p){var t;return((t=URL.parse(p))==null?void 0:t.origin)??null}function Ob({responseHeaders:p,isHttp:t,rangeChunkSize:e,disableRange:s}){const n={contentLength:0,isRangeSupported:!1},r=parseInt(p.get("Content-Length"),10);return!Number.isInteger(r)||(n.contentLength=r,r<=2*e)||s||!t||p.get("Accept-Ranges")!=="bytes"||(p.get("Content-Encoding")||"identity")==="identity"&&(n.isRangeSupported=!0),n}function Nb(p){const t=p.get("Content-Disposition");if(t){let e=E0(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(zg(e))return e}return null}
45function Uf(p,t){return new Xu(`Unexpected server response (${p}) while retrieving PDF "${t.href}".`,p,p===404||p===0&&t.protocol==="file:")}function Bb(p,t){if(p!==t)throw new Error(`Expected range response-origin "${p}" to match "${t}".`)}function Hb(p,t,e,s){return fetch(p,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function Ub(p,t){if(p!==200&&p!==206)throw Uf(p,t)}function Gf(p){if(p instanceof Uint8Array)return p.buffer;if(p instanceof ArrayBuffer)return p;throw new Error(`getArrayBuffer - unexpected data: ${p}`)}class x0 extends Of{constructor(e){super(e,C0,T0);_(this,"_responseOrigin",null);const{httpHeaders:s,url:n}=e;Rt(/https?:/.test(n.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Fb(!0,s)}}class C0 extends Nf{constructor(e){super(e);_(this,"_abortController",new AbortController);_(this,"_reader",null);const{disableRange:s,disableStream:n,rangeChunkSize:r,url:a,withCredentials:o}=e._source;this._isStreamingSupported=!n;const l=new Headers(e.headers);Hb(a,l,o,this._abortController).then(h=>{e._responseOrigin=Hf(h.url),Ub(h.status,a),this._reader=h.body.getReader();const c=h.headers,{contentLength:d,isRangeSupported:f}=Ob({responseHeaders:c,isHttp:!0,rangeChunkSize:r,disableRange:s});this._contentLength=d,this._isRangeSupported=f,this._filename=Nb(c),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ur("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:Gf(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}class T0 extends Bf{constructor(e,s,n){super(e,s,n);_(this,"_abortController",new AbortController);_(this,"_readCapability",Promise.withResolvers());_(this,"_reader",null);const{url:r,withCredentials:a}=e._source,o=new Headers(e.headers);o.append("Range",`bytes=${s}-${n-1}`),Hb(r,o,a,this._abortController).then(l=>{const h=Hf(l.url);Bb(h,e._responseOrigin),Ub(l.status,r),this._reader=l.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:Gf(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}function _m(p){return p instanceof Uint8Array&&p.byteLength===p.buffer.byteLength?p.buffer:new Uint8Array(p).buffer}function $f(){for(const p of this._requests)p.resolve({value:void 0,done:!0});this._requests.length=0}var yf,Gb;class _0 extends Of{constructor(e){super(e,k0,M0);m(this,yf);_(this,"_progressiveDone",!1);_(this,"_queuedChunks",[]);const{pdfDataRangeTransport:s}=e,{initialData:n,progressiveDone:r}=s;if((n==null?void 0:n.length)>0){const o=_m(n);this._queuedChunks.push(o)}this._progressiveDone=r;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":b(this,yf,Gb).call(this,o.begin,o.chunk);break;case"progressiveDone":(l=this._fullReader)==null||l.progressiveDone(),this._progressiveDone=!0;break}};s.transportReady(a)}getFullReader(){const e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,s){const n=super.getRangeReader(e,s);return n&&(n.onDone=()=>this._rangeReaders.delete(n),this._source.pdfDataRangeTransport.requestDataRange(e,s)),n}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}}yf=new WeakSet,Gb=function(e,s){const n=_m(s);if(e===void 0)this._fullReader?this._fullReader._enqueue(n):this._queuedChunks.push(n);else{const r=this._rangeReaders.keys().find(a=>a._begin===e);Rt(r,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),r._enqueue(n)}};var Uc;class k0 extends Nf{constructor(e){super(e);m(this,Uc,$f.bind(this));_(this,"_done",!1);_(this,"_queuedChunks",null);_(this,"_requests",[]);const{pdfDataRangeTransport:s,disableRange:n,disableStream:r}=e._source,{length:a,contentDispositionFilename:o}=s;this._queuedChunks=e._queuedChunks||[];for(const h of this._queuedChunks)this._loaded+=h.byteLength;this._done=e._progressiveDone,this._contentLength=a,this._isStreamingSupported=!r,this._isRangeSupported=!n,zg(o)&&(this._filename=o),this._headersCapability.resolve();const l=this._loaded;Promise.resolve().then(()=>{l>0&&this._loaded===l&&this._callOnProgress()})}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,i(this,Uc).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&i(this,Uc).call(this)}}Uc=new WeakMap;var Gc;class M0 extends Bf{constructor(e,s,n){super(e,s,n);m(this,Gc,$f.bind(this));_(this,"onDone",null);_(this,"_begin",-1);_(this,"_done",!1);_(this,"_queuedChunk",null);_(this,"_requests",[]);this._begin=s}_enqueue(e){var s;this._done||(this._requests.length===0?this._queuedChunk=e:(this._requests.shift().resolve({value:e,done:!1}),i(this,Gc).call(this)),this._done=!0,(s=this.onDone)==null||s.call(this))}async read(){if(this._queuedChunk){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,i(this,Gc).call(this),(s=this.onDone)==null||s.call(this)}}Gc=new WeakMap;const Zf=200,km=206;function P0(p){return typeof p!="string"?p:Lf(p).buffer}var Ti,Eh,$b,zb;class D0 extends Of{constructor(e){super(e,I0,L0);m(this,Eh);m(this,Ti,new WeakMap);_(this,"_responseOrigin",null);const{httpHeaders:s,url:n}=e;this.url=n,this.isHttp=/https?:/.test(n.protocol),this.headers=Fb(this.isHttp,s)}_request(e){const s=new XMLHttpRequest,n={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};i(this,Ti).set(s,n),s.open("GET",this.url),s.withCredentials=this._source.withCredentials;for(const[r,a]of this.headers)s.setRequestHeader(r,a);return this.isHttp&&"begin"in e&&"end"in e?(s.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),n.validateStatus=r=>r===km||r===Zf):n.validateStatus=r=>r===Zf,s.responseType="arraybuffer",Rt(e.onError,"Expected `onError` callback to be provided."),s.onerror=()=>e.onError(s.status),s.onreadystatechange=b(this,Eh,zb).bind(this,s),s.onprogress=b(this,Eh,$b).bind(this,s),s.send(null),s}
45_abortRequest(e){i(this,Ti).has(e)&&(i(this,Ti).delete(e),e.abort())}getRangeReader(e,s){const n=super.getRangeReader(e,s);return n&&(n.onClosed=()=>this._rangeReaders.delete(n)),n}}Ti=new WeakMap,Eh=new WeakSet,$b=function(e,s){var r;const n=i(this,Ti).get(e);(r=n==null?void 0:n.onProgress)==null||r.call(n,s)},zb=function(e,s){const n=i(this,Ti).get(e);if(!n||(e.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),e.readyState!==4)||!i(this,Ti).has(e))return;if(i(this,Ti).delete(e),e.status===0&&this.isHttp){n.onError(e.status);return}const r=e.status||Zf;if(!n.validateStatus(r)){n.onError(e.status);return}const a=P0(e.response);if(r===km){const o=e.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(o)?n.onDone(a):(W('Missing or invalid "Content-Range" header.'),n.onError(0))}else a?n.onDone(a):n.onError(e.status)};var $c,Ui,jb,Vb,Wb,Xb;class I0 extends Nf{constructor(e){super(e);m(this,Ui);m(this,$c,$f.bind(this));_(this,"_cachedChunks",[]);_(this,"_done",!1);_(this,"_requests",[]);_(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:b(this,Ui,jb).bind(this),onDone:b(this,Ui,Vb).bind(this),onError:b(this,Ui,Wb).bind(this),onProgress:b(this,Ui,Xb).bind(this)})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e),i(this,$c).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}$c=new WeakMap,Ui=new WeakSet,jb=function(){const e=this._stream,{disableRange:s,rangeChunkSize:n}=e._source,r=this._fullRequestXhr;e._responseOrigin=Hf(r.responseURL);const a=r.getAllResponseHeaders(),o=new Headers(a?a.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(c=>{const[d,...f]=c.split(": ");return[d,f.join(": ")]}):[]),{contentLength:l,isRangeSupported:h}=Ob({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:n,disableRange:s});this._contentLength=l,this._isRangeSupported=h,this._filename=Nb(o),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()},Vb=function(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._cachedChunks.push(e),this._done=!0,this._cachedChunks.length===0&&i(this,$c).call(this)},Wb=function(e){this._storedError=Uf(e,this._stream.url),this._headersCapability.reject(this._storedError);for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0},Xb=function(e){var s;(s=this.onProgress)==null||s.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})};var zc,On,Yb,Kb,Gp;class L0 extends Bf{constructor(e,s,n){super(e,s,n);m(this,On);m(this,zc,$f.bind(this));_(this,"onClosed",null);_(this,"_done",!1);_(this,"_queuedChunk",null);_(this,"_requests",[]);_(this,"_storedError",null);this._requestXhr=e._request({begin:s,end:n,onHeadersReceived:b(this,On,Yb).bind(this),onDone:b(this,On,Kb).bind(this),onError:b(this,On,Gp).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,i(this,zc).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}zc=new WeakMap,On=new WeakSet,Yb=function(){var s;const e=Hf((s=this._requestXhr)==null?void 0:s.responseURL);try{Bb(e,this._stream._responseOrigin)}catch(n){this._storedError=n,b(this,On,Gp).call(this,0)}},Kb=function(e){var s;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,i(this,zc).call(this),(s=this.onClosed)==null||s.call(this)},Gp=function(e){this._storedError??(this._storedError=Uf(e,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function qb(p,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),n=e.createReadStream(p,t);return s.toWeb(n)}class R0 extends Of{constructor(t){super(t,F0,O0);const{url:e}=t;Rt(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class F0 extends Nf{constructor(e){super(e);_(this,"_reader",null);const{disableRange:s,disableStream:n,rangeChunkSize:r,url:a}=e._source;this._isStreamingSupported=!n,process.getBuiltinModule("fs/promises").lstat(a).then(l=>{const h=qb(a);this._reader=h.getReader();const{size:c}=l;this._contentLength=c,this._isRangeSupported=!s&&c>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new 
45Ur("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=Uf(0,a)),this._headersCapability.reject(l)})}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:Gf(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}class O0 extends Bf{constructor(e,s,n){super(e,s,n);_(this,"_readCapability",Promise.withResolvers());_(this,"_reader",null);const{url:r}=e._source;try{const a=qb(r,{start:s,end:n-1});this._reader=a.getReader(),this._readCapability.resolve()}catch(a){this._readCapability.reject(a)}}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:Gf(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}function N0(p){return Kh(p)?x0:vs?R0:D0}var jc,Vc;class Pn{static get workerPort(){return i(this,jc)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");u(this,jc,t)}static get workerSrc(){return i(this,Vc)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");u(this,Vc,t)}}jc=new WeakMap,Vc=new WeakMap,m(Pn,jc,null),m(Pn,Vc,"");var kl,Wc;class B0{constructor({parsedData:t,rawData:e}){m(this,kl);m(this,Wc);u(this,kl,t),u(this,Wc,e)}getRaw(){return i(this,Wc)}get(t){return i(this,kl).get(t)??null}[Symbol.iterator](){return i(this,kl).entries()}}kl=new WeakMap,Wc=new WeakMap;const Wr=Symbol("INTERNAL");var Xc,Yc,Ml,Ua;class H0{constructor(t,{name:e,intent:s,usage:n,rbGroups:r}){m(this,Xc,!1);m(this,Yc,!1);m(this,Ml,!1);m(this,Ua,!0);u(this,Xc,!!(t&ws.DISPLAY)),u(this,Yc,!!(t&ws.PRINT)),this.name=e,this.intent=s,this.usage=n,this.rbGroups=r}get visible(){if(i(this,Ml))return i(this,Ua);if(!i(this,Ua))return!1;const{print:t,view:e}=this.usage;return i(this,Xc)?(e==null?void 0:e.viewState)!=="OFF":i(this,Yc)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==Wr&&it("Internal method `_setVisible` called."),u(this,Ml,s),u(this,Ua,e)}get serializable(){return{userSet:i(this,Ml),visible:i(this,Ua)}}}Xc=new WeakMap,Yc=new WeakMap,Ml=new WeakMap,Ua=new WeakMap;var fr,rt,Pl,Dl,Kc,qc,zp;const tm=class tm{constructor(t,e=ws.DISPLAY,s=null){m(this,qc);m(this,fr,null);m(this,rt,new Map);m(this,Pl,null);m(this,Dl,null);m(this,Kc);_(this,"creator",null);_(this,"name",null);if(u(this,Kc,t),this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,u(this,Dl,t.order);for(const n of t.groups)i(this,rt).set(n.id,new H0(e,n));if(s){s.size!==i(this,rt).size&&it("Incorrect serialized groupState.");for(const[n,r]of s)i(this,rt).get(n)._setVisible(Wr,r.visible,r.userSet)}else{if(t.baseState==="OFF")for(const n of i(this,rt).values())n._setVisible(Wr,!1);for(const n of t.on)i(this,rt).get(n)._setVisible(Wr,!0);for(const n of t.off)i(this,rt).get(n)._setVisible(Wr,!1)}u(this,Pl,this.getHash())}}isVisible(t){if(i(this,rt).size===0)return!0;if(!t)return If("Optional content group not defined."),!0;if(t.type==="OCG")return i(this,rt).has(t.id)?i(this,rt).get(t.id).visible:(W(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,qc,zp).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!i(this,rt).has(e))return W(`Optional content group not found: ${e}`),!0;if(i(this,rt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!i(this,rt).has(e))return W(`Optional content group not found: ${e}`),!0;if(!i(this,rt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!i(this,rt).has(e))return W(`Optional content group not found: ${e}`),!0;if(!i(this,rt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!i(this,rt).has(e))return W(`Optional content group not found: ${e}`),!0;if(i(this,rt).get(e).visible)return!1}return!0}return W(`Unknown optional content policy ${t.policy}.`),!0}return W(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const n=i(this,rt).get(t);if(!n){W(`Optional content group not found: ${t}`);return}if(s&&e&&n.rbGroups.length)for(const a of n.rbGroups)for(const o of a)o!==t&&((r=i(this,rt).get(o))==null||r._setVisible(Wr,!1,!0));n._setVisible(Wr,!!e,!0),u(this,fr,null)}setOCGState({state:t,preserveRB:e}){let s;for(const n of t){switch(n){case"ON":case"OFF":case"Toggle":s=n;continue}const r=i(this,rt).get(n);if(r)switch(s){case"ON":this.setVisibility(n,!0,e);break;case"OFF":this.setVisibility(n,!1,e);break;case"Toggle":this.setVisibility(n,!r.visible,e);break}}u(this,fr,null)}get hasInitialVisibility(){return i(this,Pl)===null||this.getHash()===i(this,Pl)}getOrder(){return i(this,rt).size?i(this,Dl)?i(this,Dl).slice():[...i(this,rt).keys()]:null}getGroup(t){return i(this,rt).get(t)||null}getHash(){if(i(this,fr)!==null)return i(this,fr);const t=new Tp;for(const[e,s]of i(this,rt))t.update(`${e}:${s.visible}`);return u(this,fr,t.hexdigest())}[Symbol.iterator](){return i(this,rt).entries()}get serializable(){const t=new Map;for(const[e,s]of i(this,rt))t.set(e,s.serializable);return{data:i(this,Kc),renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new tm(t,e,s)}};fr=new WeakMap,rt=new WeakMap,Pl=new WeakMap,Dl=new WeakMap,Kc=new WeakMap,qc=new WeakSet,zp=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let n=1;n<e;n++){const r=t[n];let a;if(Array.isArray(r))a=b(this,qc,zp).call(this,r);else if(i(this,rt).has(r))a=i(this,rt).get(r).visible;else return W(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};let $p=tm;var Vt,Zs,ge,Ga,_i,Me,Uh,Gh,wu;class U0{constructor(){m(this,Me);m(this,Vt,null);m(this,Zs,null);m(this,ge,0);m(this,Ga,null);m(this,_i,null)}get pagesNumber(){return i(this,ge)}set pagesNumber(t){i(this,ge)!==t&&(u(this,ge,t),u(this,Vt,null),u(this,Zs,null))}movePages(t,e,s){b(this,Me,Uh).call(this);const n=i(this,Vt),r=b(this,Me,Gh).call(this),a=e.length,o=new Uint32Array(a);let l=0;for(let f=0;f<a;f++){const g=e[f]-1;o[f]=n[g],g<s&&l++}const h=i(this,ge),c=h-a,d=Tt(s-l,0,c);for(let f=0,g=0;f<h;f++)t.has(f+1)||(n[g++]=n[f]);n.copyWithin(d+a,d,c),n.set(o,d),b(this,Me,wu).call(this,r),n.every((f,g)=>f===g+1)&&u(this,Vt,null)}deletePages(t){b(this,Me,Uh).call(this);const e=i(this,Vt),s=b(this,Me,Gh).call(this);u(this,_i,{pageNumberToId:e.slice(),pagesNumber:i(this,ge),prevPageNumbers:i(this,Zs).slice()});const n=i(this,ge)-t.length;u(this,ge,n);const r=u(this,Vt,new Uint32Array(n));u(this,Zs,new Int32Array(n));let a=0,o=0;for(const l of t){const h=l-1;h!==a&&(r.set(e.subarray(a,h),o),o+=h-a),a=h+1}a<e.length&&r.set(e.subarray(a),o),b(this,Me,wu).call(this,s,new Set(t))}cancelDelete(){i(this,_i)&&(u(this,Vt,i(this,_i).pageNumberToId),u(this,ge,i(this,_i).pagesNumber),u(this,Zs,i(this,_i).prevPageNumbers),u(this,_i,null))}cleanSavedData(){u(this,_i,null)}copyPages(t){b(this,Me,Uh).call(this),u(this,Ga,{pageNumbers:t,pageIds:t.map(e=>i(this,Vt)[e-1])})}cancelCopy(){u(this,Ga,null)}pastePages(t){b(this,Me,Uh).call(this);const e=i(this,Vt),s=b(this,Me,Gh).call(this),{pageNumbers:n,pageIds:r}=i(this,Ga),a=i(this,ge)+n.length;u(this,ge,a);const o=u(this,Vt,new Uint32Array(a));u(this,Zs,new Int32Array(a)),o.set(e.subarray(0,t),0),o.set(r,t),o.set(e.subarray(t),t+n.length),b(this,Me,wu).call(this,s,null,t,n),u(this,Ga,null)}hasBeenAltered(){return i(this,Vt)!==null}getPageMappingForSaving(t=null){t??(t=b(this,Me,Gh).call(this));let e=0;for(const n of t.values())e=Math.max(e,n.length);const s=new Array(e);for(let n=0;n<e;n++)s[n]={document:null,pageIndices:[],includePages:[]};for(const[n,r]of t)for(let a=0,o=r.length;a<o;a++)s[a].includePages.push([n-1,r[a]-1]);for(const{includePages:n,pageIndices:r}of s){n.sort((a,o)=>a[0]-o[0]);for(let a=0,o=n.length;a<o;a++)r.push(n[a][1]),n[a]=n[a][0]}return s}extractPages(t){t=Array.from(t).sort((s,n)=>s-n);const e=new Map;for(let s=0,n=t.length;s<n;s++){const r=this.getPageId(t[s]);e.getOrInsertComputed(r,Wd).push(s+1)}return this.getPageMappingForSaving(e)}getPrevPageNumber(t){var e;return((e=i(this,Zs))==null?void 0:e[t-1])??0}getPageNumber(t){if(!i(this,Vt))return t;const e=i(this,Vt);for(let s=0,n=i(this,ge);s<n;s++)if(e[s]===t)return s+1;return 0}getPageId(t){var e;return((e=i(this,Vt))==null?void 0:e[t-1])??t}getMapping(){var t;return(t=i(this,Vt))==null?void 0:t.subarray(0,this.pagesNumber)}}Vt=new WeakMap,Zs=new WeakMap,ge=new WeakMap,Ga=new WeakMap,_i=new WeakMap,Me=new WeakSet,Uh=function(){if(i(this,Vt))return;const t=i(this,ge),e=u(this,Vt,new Uint32Array(t));for(let s=0;s<t;s++)e[s]=s+1;u(this,Zs,new Int32Array(e))},Gh=function(){const t=new Map,e=i(this,Vt);for(let s=0,n=i(this,ge);s<n;s++){const r=e[s],a=t.get(r);a?a.push(s+1):t.set(r,[s+1])}return t},wu=function(t,e=null,s=-1,n=null){const r=i(this,Zs),a=i(this,Vt),o=s+((n==null?void 0:n.length)??0),l=new Map;for(let h=0,c=i(this,ge);h<c;h++){if(h>=s&&h<o){r[h]=-n[h-s];continue}const d=a[h],f=t.get(d);let g=l.get(d)||0;if(e&&f)for(;g<f.length&&e.has(f[g]);)g++;r[h]=f==null?void 0:f[g],l.set(d,g+1)}};const Go=Symbol("INITIAL_DATA"),Mm=()=>({...Promise.withResolvers(),data:Go});var Os;class Qb{constructor(){m(this,Os,new Map)}get(t,e=null){if(e){const n=i(this,Os).getOrInsertComputed(t,Mm);return n.promise.then(()=>e(n.data)),null}const s=i(this,Os).get(t);if(!s||s.data===Go)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=i(this,Os).get(t);return!!e&&e.data!==Go}delete(t){const e=i(this,Os).get(t);return!e||e.data===Go?!1:(i(this,Os).delete(t),!0)}resolve(t,e=null){const s=i(this,Os).getOrInsertComputed(t,Mm);if(s.data!==Go)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){var t;for(const{data:e}
45of i(this,Os).values())(t=e==null?void 0:e.bitmap)==null||t.close();i(this,Os).clear()}*[Symbol.iterator](){for(const[t,{data:e}]of i(this,Os))e!==Go&&(yield[t,e])}}Os=new WeakMap;const G0=1e5,Pm=30;var Rm,pr,Re,Qc,Jc,Il,$a,hn,Zc,td,za,ed,Ll,gr,Rl,sd,Fl,ja,id,nd,Ol,Va,rd,Nl,Bl,Nn,Jb,Zb,jp,xs,vu,Vp,ty,ey;const de=class de{constructor({textContentSource:t,images:e,container:s,viewport:n}){m(this,Nn);m(this,pr,Promise.withResolvers());m(this,Re,null);m(this,Qc,!1);m(this,Jc,!!((Rm=globalThis.FontInspector)!=null&&Rm.enabled));m(this,Il,null);m(this,$a,null);m(this,hn,null);m(this,Zc,0);m(this,td,0);m(this,za,null);m(this,ed,null);m(this,Ll,0);m(this,gr,0);m(this,Rl,Object.create(null));m(this,sd,[]);m(this,Fl,null);m(this,ja,[]);m(this,id,new WeakMap);m(this,nd,null);var h;if(t instanceof ReadableStream)u(this,Fl,t);else if(typeof t=="object")u(this,Fl,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');u(this,Re,u(this,ed,s)),u(this,Il,e),u(this,gr,n.scale*Hi.pixelRatio),u(this,Ll,n.rotation),u(this,hn,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:a,pageX:o,pageY:l}=n.rawDims;u(this,nd,[1,0,0,-1,-o,l+a]),u(this,td,r),u(this,Zc,a),b(h=de,xs,ty).call(h),s.style.setProperty("--min-font-size",i(de,Nl)),Do(s,n),i(this,pr).promise.finally(()=>{i(de,Bl).delete(this),u(this,hn,null),u(this,Rl,null)}
45).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=bt.platform;return $(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){i(this,Il)&&i(this,Re).append(i(this,Il).render());const t=()=>{i(this,za).read().then(({value:e,done:s})=>{if(s){i(this,pr).resolve();return}i(this,$a)??u(this,$a,e.lang),Object.assign(i(this,Rl),e.styles),b(this,Nn,Jb).call(this,e.items),t()},i(this,pr).reject)};return u(this,za,i(this,Fl).getReader()),i(de,Bl).add(this),t(),i(this,pr).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*Hi.pixelRatio,n=t.rotation;if(n!==i(this,Ll)&&(e==null||e(),u(this,Ll,n),Do(i(this,ed),{rotation:n})),s!==i(this,gr)){e==null||e(),u(this,gr,s);const a={div:null,properties:null,ctx:b(r=de,xs,vu).call(r,i(this,$a))};for(const o of i(this,ja))a.properties=i(this,id).get(o),a.div=o,b(this,Nn,jp).call(this,a)}}cancel(){var e;const t=new Ur("TextLayer task cancelled.");(e=i(this,za))==null||e.cancel(t).catch(()=>{}),u(this,za,null),i(this,pr).reject(t)}get textDivs(){return i(this,ja)}get textContentItemsStr(){return i(this,sd)}static cleanup(){if(!(i(this,Bl).size>0)){i(this,Ol).clear();for(const{canvas:t}of i(this,Va).values())t.remove();i(this,Va).clear()}}};pr=new WeakMap,Re=new WeakMap,Qc=new WeakMap,Jc=new WeakMap,Il=new WeakMap,$a=new WeakMap,hn=new WeakMap,Zc=new WeakMap,td=new WeakMap,za=new WeakMap,ed=new WeakMap,Ll=new WeakMap,gr=new WeakMap,Rl=new WeakMap,sd=new WeakMap,Fl=new WeakMap,ja=new WeakMap,id=new WeakMap,nd=new WeakMap,Ol=new WeakMap,Va=new WeakMap,rd=new WeakMap,Nl=new WeakMap,Bl=new WeakMap,Nn=new WeakSet,Jb=function(t){var n,r;if(i(this,Qc))return;(r=i(this,hn)).ctx??(r.ctx=b(n=de,xs,vu).call(n,i(this,$a)));const e=i(this,ja),s=i(this,sd);for(const a of t){if(e.length>G0){W("Ignoring additional textDivs for performance reasons."),u(this,Qc,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=i(this,Re);u(this,Re,document.createElement("span")),i(this,Re).classList.add("markedContent"),a.id&&i(this,Re).setAttribute("id",a.id),a.tag==="Artifact"&&(i(this,Re).ariaHidden=!0),o.append(i(this,Re))}else a.type==="endMarkedContent"&&u(this,Re,i(this,Re).parentNode);continue}s.push(a.str),b(this,Nn,Zb).call(this,a)}},Zb=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};i(this,ja).push(e);const n=D.transform(i(this,nd),t.transform);let r=Math.atan2(n[1],n[0]);const a=i(this,Rl)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=i(this,Jc)&&a.fontSubstitution||a.fontFamily;o=de.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*b(y=de,xs,ey).call(y,o,a,i(this,$a));let c,d;
45r===0?(c=n[4],d=n[5]-h):(c=n[4]+h*Math.sin(r),d=n[5]-h*Math.cos(r));const f=e.style;f.left=`${(100*c/i(this,td)).toFixed(2)}%`,f.top=`${(100*d/i(this,Zc)).toFixed(2)}%`,f.setProperty("--font-height",`${l.toFixed(2)}px`),f.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,i(this,Jc)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const A=Math.abs(t.transform[0]),v=Math.abs(t.transform[3]);A!==v&&Math.max(A,v)/Math.min(A,v)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),i(this,id).set(e,s),i(this,hn).div=e,i(this,hn).properties=s,b(this,Nn,jp).call(this,i(this,hn)),s.hasText&&i(this,Re).append(e),s.hasEOL){const A=document.createElement("br");A.setAttribute("role","presentation"),i(this,Re).append(A)}},jp=function(t){var a;const{div:e,properties:s,ctx:n}=t,{style:r}=e;if(s.canvasWidth!==0&&s.hasText){const{fontFamily:o}=r,{canvasWidth:l,fontSize:h}=s;b(a=de,xs,Vp).call(a,n,h*i(this,gr),o);const{width:c}=n.measureText(e.textContent);c>0&&r.setProperty("--scale-x",l*i(this,gr)/c)}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)},xs=new WeakSet,vu=function(t=null){let e=i(this,Va).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),i(this,Va).set(t,e),i(this,rd).set(e,{size:0,family:""})}return e},Vp=function(t,e,s){const n=i(this,rd).get(t);e===n.size&&s===n.family||(t.font=`${e}px ${s}`,n.size=e,n.family=s)},ty=function(){if(i(this,Nl)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),u(this,Nl,t.getBoundingClientRect().height),t.remove()},ey=function(t,e,s){const n=i(this,Ol).get(t);if(n)return n;const r=b(this,xs,vu).call(this,s);r.canvas.width=r.canvas.height=Pm,b(this,xs,Vp).call(this,r,Pm,t);const a=r.measureText(""),o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let h=.8;return o?h=o/(o+l):(bt.platform.isFirefox&&W("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.descent)),i(this,Ol).set(t,h),h},m(de,xs),m(de,Ol,new Map),m(de,Va,new Map),m(de,rd,new WeakMap),m(de,Nl,null),m(de,Bl,new Set);let ic=de;const $0=100;function z0(p={}){const t=new Wp,{docId:e}=t,s=p.url?YA(p.url):null,n=p.data?KA(p.data):null,r=p.httpHeaders||null,a=p.withCredentials===!0,o=p.password??null,l=p.range instanceof sy?p.range:null,h=Number.isInteger(p.rangeChunkSize)&&p.rangeChunkSize>0?p.rangeChunkSize:2**16;let c=p.worker instanceof nc?p.worker:null;const d=p.verbosity,f=typeof p.docBaseUrl=="string"&&!Rf(p.docBaseUrl)?p.docBaseUrl:null,g=Jd(p.cMapUrl),y=p.cMapPacked!==!1,A=Jd(p.iccUrl),v=Jd(p.standardFontDataUrl),w=Jd(p.wasmUrl),S=p.stopAtErrors!==!0,E=Number.isInteger(p.maxImageSize)&&p.maxImageSize>-1?p.maxImageSize:-1,x=typeof p.isOffscreenCanvasSupported=="boolean"?p.isOffscreenCanvasSupported:!vs,C=typeof p.isImageDecoderSupported=="boolean"?p.isImageDecoderSupported:!vs,T=Number.isInteger(p.canvasMaxAreaInBytes)?p.canvasMaxAreaInBytes:-1,k=typeof p.disableFontFace=="boolean"?p.disableFontFace:vs,P=p.fontExtraProperties===!0,M=p.enableXfa===!0,L=p.ownerDocument||globalThis.document,O=p.disableRange===!0,Q=p.disableStream===!0,J=p.disableAutoFetch===!0,q=p.pdfBug===!0,Ft=p.CanvasFactory||(vs?i0:ZA),F=p.FilterFactory||(vs?s0:t0),U=p.BinaryDataFactory||(vs?n0:ym),Gt=p.enableHWA===!0,ts=p.enableWebGPU===!0?l0():Promise.resolve(!1),ce=p.useWasm!==!1,Xt=p.pagesMapper||new U0,dt=typeof p.useSystemFonts=="boolean"?p.useSystemFonts:!vs&&!k,li=typeof p.useWorkerFetch=="boolean"?p.useWorkerFetch:!!(U===ym&&g&&y&&v&&w&&Kh(g,document.baseURI)&&Kh(v,document.baseURI)&&Kh(w,document.baseURI)),xh=null;pA(d);const te={canvasFactory:new Ft({ownerDocument:L,enableHWA:Gt}),filterFactory:new F({docId:e,ownerDocument:L}),binaryDataFactory:li?null:new U({cMapUrl:g,standardFontDataUrl:v,wasmUrl:w})};c||(c=nc.create({verbosity:d,port:Pn.workerPort}),t._worker=c);const wt={docId:e,apiVersion:"6.2.108",data:n,password:o,disableAutoFetch:J,rangeChunkSize:h,docBaseUrl:f,enableXfa:M,evaluatorOptions:{maxImageSize:E,disableFontFace:k,ignoreErrors:S,isOffscreenCanvasSupported:x,isImageDecoderSupported:C,canvasMaxAreaInBytes:T,fontExtraProperties:P,useSystemFonts:dt,useWasm:ce,useWorkerFetch:li,cMapUrl:g,cMapPacked:y,iccUrl:A,standardFontDataUrl:v,wasmUrl:w,hasGPU:!1}},jf={ownerDocument:L,pdfBug:q,styleElement:xh,enableHWA:Gt,loadingParams:{disableAutoFetch:J,enableXfa:M}};return Promise.all([c.promise,ts]).then(function([,oA]){if(c.destroyed)throw new Error("Worker was destroyed");wt.evaluatorOptions.hasGPU=oA;
45const lA=c.messageHandler.sendWithPromise("GetDocRequest",wt,n?[n.buffer]:null);let Vf;if(!n)if(l)Vf=new _0({pdfDataRangeTransport:l,disableRange:O,disableStream:Q});else if(s){const Wf=N0(s);Vf=new Wf({url:s,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:O,disableStream:Q})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return lA.then(Wf=>{if(c.destroyed)throw new Error("Worker was destroyed");const nm=new Fh(e,Wf,c.port),hA=new V0(nm,t,Vf,jf,te,Xt);if(t._transport=hA,t.destroyed)throw new Error("Loading aborted");nm.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}var Af;const wf=class wf{constructor(){_(this,"_capability",Promise.withResolvers());_(this,"_setupCapability",Promise.withResolvers());_(this,"_transport",null);_(this,"_worker",null);_(this,"docId",`d${Et(wf,Af)._++}`);_(this,"destroyed",!1);_(this,"onPassword",null);_(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,n;this.destroyed=!0,this._capability.promise.catch(()=>{});try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(n=this._worker)==null||n.destroy(),this._worker=null}async getData(){return this._transport.getData()}};Af=new WeakMap,m(wf,Af,0);let Wp=wf;var Hl,Wa;class sy{constructor(t,e,s=!1,n=null){m(this,Hl,Promise.withResolvers());m(this,Wa,null);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=n}onDataRange(t,e){i(this,Wa).call(this,{type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){i(this,Hl).promise.then(()=>{i(this,Wa).call(this,{type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){i(this,Hl).promise.then(()=>{i(this,Wa).call(this,{type:"progressiveDone"})})}transportReady(t){u(this,Wa,t),i(this,Hl).resolve()}requestDataRange(t,e){it("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Hl=new WeakMap,Wa=new WeakMap;class j0{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return $(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}getSignatures(){return this._transport.getSignatures()}getSignatureData(t){return this._transport.getSignatureData(t)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var cn,Xa,Ya,$h;const em=class em{constructor(t,e,s,n,r=!1){m(this,Ya);m(this,cn,!1);m(this,Xa,null);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new om:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new Qb,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,u(this,Xa,n),this.imageCoordinates=null}clone(t){const e=new em(t,this._pageInfo,this._transport,i(this,Xa),this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:n=0,dontFlip:r=!1}={}){return new Xd({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}
45=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return $(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:n="display",annotationMode:r=Hn.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:f=!1,recordImages:g=!1,recordOperations:y=!1,operationsFilter:A=null}){var J,q,Ft;(J=this._stats)==null||J.time("Overall");const v=this._transport.getRenderingIntent(n,r,d,f),{renderingIntent:w,cacheKey:S}=v;u(this,cn,!1),l||(l=this._transport.getOptionalContentConfig(w));const E=this._intentStates.getOrInsertComputed(S,ap);E.streamReaderCancelTimeout&&(clearTimeout(E.streamReaderCancelTimeout),E.streamReaderCancelTimeout=null);const x=!!(w&ws.PRINT);E.displayReadyCapability||(E.displayReadyCapability=Promise.withResolvers(),E.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(q=this._stats)==null||q.time("Page Request"),this._pumpOperatorList(v));const C=!!(this._pdfBug&&((Ft=globalThis.StepperManager)!=null&&Ft.enabled)),T=!!e&&!this.recordedBBoxes&&(y||C),k=!!e&&!this.imageCoordinates&&g,P=F=>{var U,Gt,$t,ts;if(E.renderTasks.delete(O),T){const ce=(U=O.gfx)==null?void 0:U.dependencyTracker.take();ce&&((Gt=O.stepper)==null||Gt.setOperatorBBoxes(ce,O.gfx.dependencyTracker.takeDebugMetadata()),y&&(this.recordedBBoxes=ce))}k&&!F&&(this.imageCoordinates=($t=O.gfx)==null?void 0:$t.imagesTracker.take()),x&&u(this,cn,!0),b(this,Ya,$h).call(this),F?(O.capability.reject(F),this._abortOperatorList({intentState:E,reason:F instanceof Error?F:new Error(F)})):O.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(ts=globalThis.Stats)!=null&&ts.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let M=null,L=null;(T||k)&&(L=new HA(e,E.operatorList.length)),T&&(M=new UA(L,C));const O=new Yp({callback:P,params:{canvas:e,canvasContext:t,dependencyTracker:M??L,imagesTracker:k?new Mp(e):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:E.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!x,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:A});(E.renderTasks||(E.renderTasks=new Set)).add(O);const Q=O.task;return Promise.all([E.displayReadyCapability.promise,l]).then(([F,U])=>{var Gt;if(this.destroyed){P();return}if((Gt=this._stats)==null||Gt.time("Rendering"),!(U.renderingIntent&w))throw new Error("Mu
45st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");O.initializeGraphics({transparency:F,optionalContentConfig:U}),O.operatorListChanged()}).catch(P),Q}getOperatorList({intent:t="display",annotationMode:e=Hn.ENABLE,printAnnotationStorage:s=null,isEditing:n=!1}={}){var h;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,n,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,ap);let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:i(this,Xa).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(n){return n.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>tc.textContent(n));const e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(const n of e)s.lang??(s.lang=n.lang),Object.assign(s.styles,n.styles),s.items.push(...n.items);return s}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),u(this,cn,!1),Promise.all(t)}cleanup(t=!1){u(this,cn,!0);const e=b(this,Ya,$h).call(this);return t&&e&&this._stats&&(this._stats=new om),e}_startRenderPage(t,e){var n,r;const s=this._intentStates.get(e);s&&((n=this._stats)==null||n.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,n=t.length;s<n;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&b(this,Ya,$h).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:n}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:i(this,Xa).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:n},void 0,a).getReader(),h=this._intentStates.get(e);h.streamReader=l;const c=()=>{l.read().then(({value:d,done:f})=>{if(f){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,h),c())},d=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const f of h.renderTasks)f.operatorListChanged();b(this,Ya,$h).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(d);else if(h.opListReadCapability)h.opListReadCapability.reject(d);else throw d}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof $g){let n=$0;e.extraDelay>0&&e.extraDelay<1e3&&(n+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},n);return}}
45if(t.streamReader.cancel(new Ur(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[n,r]of this._intentStates)if(r===t){this._intentStates.delete(n);break}this.cleanup()}}}get stats(){return this._stats}};cn=new WeakMap,Xa=new WeakMap,Ya=new WeakSet,$h=function(){if(!i(this,cn)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),u(this,cn,!1),!0};let Xp=em;var mr,ti,dn,Ka,vf,qa,Qa,Ge,Su,iy,ny,zh,Ul,Eu;const Ot=class Ot{constructor({name:t=null,port:e=null,verbosity:s=gA()}={}){m(this,Ge);m(this,mr,Promise.withResolvers());m(this,ti,null);m(this,dn,null);m(this,Ka,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(i(Ot,Qa).has(e))throw new Error("Cannot use more than one PDFWorker per port.");i(Ot,Qa).set(e,this),b(this,Ge,iy).call(this,e)}else b(this,Ge,ny).call(this)}get promise(){return i(this,mr).promise}get port(){return i(this,dn)}get messageHandler(){return i(this,ti)}destroy(){var t,e;this.destroyed=!0,(t=i(this,Ka))==null||t.terminate(),u(this,Ka,null),i(Ot,Qa).delete(i(this,dn)),u(this,dn,null),(e=i(this,ti))==null||e.destroy(),u(this,ti,null)}static create(t){const e=i(this,Qa).get(t==null?void 0:t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Ot(t)}static get workerSrc(){if(Pn.workerSrc)return Pn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return $(this,"_setupFakeWorkerGlobal",(async()=>i(this,Ul,Eu)?i(this,Ul,Eu):(await import(this.workerSrc)).WorkerMessageHandler)())}};mr=new WeakMap,ti=new WeakMap,dn=new WeakMap,Ka=new WeakMap,vf=new WeakMap,qa=new WeakMap,Qa=new WeakMap,Ge=new WeakSet,Su=function(){i(this,mr).resolve(),i(this,ti).send("configure",{verbosity:this.verbosity})},iy=function(t){u(this,dn,t),u(this,ti,new Fh("main","worker",t)),i(this,ti).on("ready",()=>{}),b(this,Ge,Su).call(this)},ny=function(){if(i(Ot,qa)||i(Ot,Ul,Eu)){b(this,Ge,zh).call(this);return}let{workerSrc:t}=Ot;try{Ot._isSameOrigin(window.location,t)||(t=Ot._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Fh("main","worker",e),n=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?i(this,mr).reject(new Error("Worker was destroyed")):b(this,Ge,zh).call(this)},r=new AbortController;e.addEventListener("error",()=>{i(this,Ka)||n()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){n();return}u(this,ti,s),u(this,dn,e),u(this,Ka,e),b(this,Ge,Su).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){n();return}try{a()}catch{b(this,Ge,zh).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{If("The worker has been disabled.")}b(this,Ge,zh).call(this)},zh=function(){i(Ot,qa)||(W("Setting up fake worker."),u(Ot,qa,!0)),Ot._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){i(this,mr).reject(new Error("Worker was destroyed"));return}const e=new JA;u(this,dn,e);const s=`fake${Et(Ot,vf)._++}`,n=new Fh(s+"_worker",s,e);t.setup(n,e),u(this,ti,new Fh(s,s+"_worker",e)),b(this,Ge,Su).call(this)}).catch(t=>{i(this,mr).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Ul=new WeakSet,Eu=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},m(Ot,Ul),m(Ot,vf,0),m(Ot,qa,!1),m(Ot,Qa,new WeakMap),vs&&(u(Ot,qa,!0),Pn.workerSrc||(Pn.workerSrc="./pdf.worker.mjs")),Ot._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const n=new URL(e,s);return s.origin===n.origin},Ot._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let nc=Ot;var os,Ja,un,ei,Za,Gl,fn,Gs,$o,xu;class V0{constructor(t,e,s,n,r,a){m(this,Gs);_(this,"downloadInfoCapability",Promise.withResolvers());m(this,os,null);m(this,Ja,new Map);m(this,un,null);m(this,ei,new Map);m(this,Za,new Map);m(this,Gl,new Map);m(this,fn,null);this.messageHandler=t,this.loadingTask=e,u(this,un,s),this.commonObjs=new Qb,this.fontLoader=new GA({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.enableHWA=n.enableHWA,this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:e}=t;i(this,ei).set(e,t),i(this,Za).set(e,Promise.resolve(t))}get annotationStorage(){return $(this,"annotationStorage",new jg)}
45getRenderingIntent(t,e=Hn.ENABLE,s=null,n=!1,r=!1){let a=ws.DISPLAY,o=ec;switch(t){case"any":a=ws.ANY;break;case"display":break;case"print":a=ws.PRINT;break;default:W(`getRenderingIntent - invalid intent: ${t}`)}const l=a&ws.PRINT&&s instanceof Ab?s:this.annotationStorage;switch(e){case Hn.DISABLE:a+=ws.ANNOTATIONS_DISABLE;break;case Hn.ENABLE:break;case Hn.ENABLE_FORMS:a+=ws.ANNOTATIONS_FORMS;break;case Hn.ENABLE_STORAGE:a+=ws.ANNOTATIONS_STORAGE,o=l.serializable;break;default:W(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(a+=ws.IS_EDITING),r&&(a+=ws.OPLIST);const{ids:h,hash:c}=l.modifiedIds,d=[a,o.hash,c];return{renderingIntent:a,cacheKey:d.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=i(this,fn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const n of i(this,ei).values())t.push(n._destroy());i(this,ei).clear(),i(this,Za).clear(),i(this,Gl).clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var n,r;this.commonObjs.clear(),this.fontLoader.clear(),i(this,Ja).clear(),this.filterFactory.destroy(),ic.cleanup(),(n=i(this,un))==null||n.cancelAllRequests(new Ur("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,n)=>{Rt(i(this,un),"GetReader - no `BasePDFStream` instance available."),u(this,os,i(this,un).getFullReader()),i(this,os).onProgress=r=>b(this,Gs,xu).call(this,r),n.onPull=()=>{i(this,os).read().then(function({value:r,done:a}){if(a){n.close();return}Rt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{n.error(r)})},n.onCancel=r=>{i(this,os).cancel(r),n.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{await i(this,os).headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:a}=i(this,os);return n&&r&&(i(this,os).onProgress=null),{isStreamingSupported:n,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,n)=>{Rt(i(this,un),"GetRangeReader - no `BasePDFStream` instance available.");const r=i(this,un).getRangeReader(s.begin,s.end);if(!r){n.close();return}n.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){n.close();return}Rt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{n.error(a)})},n.onCancel=a=>{r.cancel(a),n.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new j0(s,this))}),t.on("DocException",s=>{e._capability.reject(je(s))}),t.on("PasswordRequest",s=>{u(this,fn,Promise.withResolvers());try{if(!e.onPassword)throw je(s);const n=r=>{r instanceof Error?i(this,fn).reject(r):i(this,fn).resolve({password:r})};e.onPassword(n,s.code)}catch(n){i(this,fn).reject(n)}return i(this,fn).promise}),t.on("DataLoaded",s=>{b(this,Gs,xu).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;i(this,ei).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,n,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(n){case"Font":if("error"in r){const f=r.error;W(`Error during font loading: ${f}`),this.commonObjs.resolve(s,f);break}const o=new VA(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(f,g)=>globalThis.FontInspector.fontAdded(f,g):null,h=new $A(o,l,r.charProcOperatorList,r.extra);this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{h.fontExtraProperties||h.clearData(),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:c}=r;Rt(c,"The imageRef must be defined.");for(const f of i(this,ei).values())for(const[,g]of f.objs){if((g==null?void 0:g.ref)!==c)continue;if(!g.dataLen)return null;const y=structuredClone(g);return this.commonObjs.resolve(s,y),g.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new XA(r));break;case"Image":this.commonObjs.resolve(s,r);break;case"Pattern":const d=new WA(r);this.commonObjs.resolve(s,d.getIR());break;default:throw new Error(`Got unknown common object type ${n}`)}return null}),t.on("obj",([s,n,r,a])=>{var l;if(this.destroyed)return;const o=i(this,ei).get(n);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{this.destroyed||b(this,Gs,xu).call(this,s)}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}
45getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&W("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=i(this,os))==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){var r;const e={pageInfos:t};let s;const n=globalThis.ImageBitmap;if(typeof n=="function"){const a=Array.isArray(t)?t:[t];for(const o of a)(o==null?void 0:o.image)instanceof n&&(s||(s=[])).push(o.image)}if(this.annotationStorage.size>0){const a=this.annotationStorage.serializable;let{map:o}=a;(r=a.transfer)!=null&&r.length&&(s?s.push(...a.transfer):s=a.transfer);const l=this.pagesMapper.getMapping();if(l){const h=new Map;for(const[c,d]of o){if((d==null?void 0:d.pageIndex)!==void 0&&d.pageIndex>=0&&d.pageIndex<l.length){const f=l[d.pageIndex]-1;if(f!==d.pageIndex){h.set(c,{...d,pageIndex:f});continue}}h.set(c,d)}o=h}e.annotationStorage=o}return this.messageHandler.sendWithPromise("ExtractPages",e,s).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.pagesMapper.getPageId(t)-1,n=i(this,Za).get(e);if(n)return n;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&i(this,Gl).set(a.refStr,s);const o=new Xp(e,a,this,this.pagesMapper,this._params.pdfBug);return i(this,ei).set(e,o),o});return i(this,Za).set(e,r),r}async getPageIndex(t){if(!Dp(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return b(this,Gs,$o).call(this,"GetFieldObjects")}getSignatures(){return b(this,Gs,$o).call(this,"GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return b(this,Gs,$o).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return b(this,Gs,$o).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return b(this,Gs,$o).call(this,"GetOptionalContentConfig").then(e=>new $p(e,t))}
45getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return i(this,Ja).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>{var s,n;return{info:e[0],metadata:e[1]?new B0(e[1]):null,contentDispositionFilename:((s=i(this,os))==null?void 0:s.filename)??null,contentLength:((n=i(this,os))==null?void 0:n.contentLength)??null,hasStructTree:e[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of i(this,ei).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),i(this,Ja).clear(),this.filterFactory.destroy(!0),ic.cleanup()}}cachedPageNumber(t){if(!Dp(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=i(this,Gl).get(e);if(s>=0){const n=this.pagesMapper.getPageNumber(s+1);if(n!==0)return n}return null}}os=new WeakMap,Ja=new WeakMap,un=new WeakMap,ei=new WeakMap,Za=new WeakMap,Gl=new WeakMap,fn=new WeakMap,Gs=new WeakSet,$o=function(t,e=null){return i(this,Ja).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))},xu=function({loaded:t,total:e}){var s,n;(n=(s=this.loadingTask).onProgress)==null||n.call(s,{loaded:t,total:e,percent:e?Tt(Math.round(t/e*100),0,100):NaN})};class W0{constructor(t){_(this,"_internalRenderTask",null);_(this,"onContinue",null);_(this,"onError",null);this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&(e==null?void 0:e.size)>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}var br,to;const Qr=class Qr{constructor({callback:t,params:e,objs:s,commonObjs:n,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:f=null,enableHWA:g=!1,operationsFilter:y=null}){m(this,br,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=n,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new W0(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=g,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=y}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var h,c;if(this.cancelled)return;if(this._canvas){if(i(Qr,to).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");i(Qr,to).add(this._canvas)}this._pdfBug&&((h=globalThis.StepperManager)!=null&&h.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:n,background:r,dependencyTracker:a,imagesTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Yo(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a,o),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(c=this.graphicsReadyCallback)==null||c.call(this)}cancel(t=null,e=0){var s,n,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),i(this,br)&&(window.cancelAnimationFrame(i(this,br)),u(this,br,null)),i(Qr,to).delete(this._canvas),t||(t=new $g(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(n=this.task).onError)==null||r.call(n,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?u(this,br,window.requestAnimationFrame(()=>{u(this,br,null),this._nextBound().catch(this._cancelBound)}
45)):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),i(Qr,to).delete(this._canvas),this.callback())))}};br=new WeakMap,to=new WeakMap,m(Qr,to,new WeakSet);let Yp=Qr;const X0="6.2.108",Y0="0365cbde0";var ls,eo,$l,Jt,ad,zl,pn,od,yr,si,ld,yt,Kp,qp,Qp,Xr,ry,Bn;const We=class We{constructor({editor:t=null,uiManager:e=null}){m(this,yt);m(this,ls,null);m(this,eo,null);m(this,$l);m(this,Jt,null);m(this,ad,!1);m(this,zl,!1);m(this,pn,null);m(this,od);m(this,yr,null);m(this,si,null);var s,n;t?(u(this,zl,!1),u(this,pn,t)):u(this,zl,!0),u(this,si,(t==null?void 0:t._uiManager)||e),u(this,od,i(this,si)._eventBus),u(this,$l,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((n=i(this,si))==null?void 0:n.highlightColors.values().next().value)||"#FFFF98"),i(We,ld)||u(We,ld,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return $(this,"_keyboardManager",new Io([[["Escape"],We.prototype._hideDropdownFromKeyboard],[["Space"],We.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],We.prototype._moveToNext],[["ArrowUp","ArrowLeft"],We.prototype._moveToPrevious],[["Home"],We.prototype._moveToBeginning],[["End"],We.prototype._moveToEnd]]))}renderButton(){const t=u(this,ls,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",i(this,pn)&&(t.ariaControls=`${i(this,pn).id}_colorpicker_dropdown`);const e=i(this,si)._signal;t.addEventListener("click",b(this,yt,Xr).bind(this),{signal:e}),t.addEventListener("keydown",b(this,yt,Qp).bind(this),{signal:e});const s=u(this,eo,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=i(this,$l),t.append(s),t}renderMainDropdown(){const t=u(this,Jt,b(this,yt,Kp).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===i(this,ls)){b(this,yt,Xr).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,yt,qp).call(this,e,t)}_moveToNext(t){var e,s;if(!i(this,yt,Bn)){b(this,yt,Xr).call(this,t);return}if(t.target===i(this,ls)){(e=i(this,Jt).firstElementChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=i(this,Jt))==null?void 0:e.firstElementChild)||t.target===i(this,ls)){i(this,yt,Bn)&&this._hideDropdownFromKeyboard();return}i(this,yt,Bn)||b(this,yt,Xr).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!i(this,yt,Bn)){b(this,yt,Xr).call(this,t);return}(e=i(this,Jt).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!i(this,yt,Bn)){b(this,yt,Xr).call(this,t);return}(e=i(this,Jt).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=i(this,Jt))==null||t.classList.add("hidden"),i(this,ls).ariaExpanded="false",(e=i(this,yr))==null||e.abort(),u(this,yr,null)}_hideDropdownFromKeyboard(){var t;if(!i(this,zl)){if(!i(this,yt,Bn)){(t=i(this,pn))==null||t.unselect();return}this.hideDropdown(),i(this,ls).focus({preventScroll:!0,focusVisible:i(this,ad)})}}updateColor(t){if(i(this,eo)&&(i(this,eo).style.backgroundColor=t),!i(this,Jt))return;const e=i(this,si).highlightColors.values();for(const s of i(this,Jt).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=i(this,ls))==null||t.remove(),u(this,ls,null),u(this,eo,null),(e=i(this,Jt))==null||e.remove(),u(this,Jt,null)}};ls=new WeakMap,eo=new WeakMap,$l=new WeakMap,Jt=new WeakMap,ad=new WeakMap,zl=new WeakMap,pn=new WeakMap,od=new WeakMap,yr=new WeakMap,si=new WeakMap,ld=new WeakMap,yt=new WeakSet,Kp=function(){const t=document.createElement("div"),e=i(this,si)._signal;t.addEventListener("contextmenu",js,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),i(this,pn)&&(t.id=`${i(this,pn).id}_colorpicker_dropdown`);for(const[s,n]of i(this,si).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",n),r.title=s,r.setAttribute("data-l10n-id",i(We,ld)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=n,r.ariaSelected=n===i(this,$l),r.addEventListener("click",b(this,yt,qp).bind(this,n),{signal:e}),t.append(r)}return t.addEventListener("keydown",b(this,yt,Qp).bind(this),{signal:e}),t},qp=function(t,e){e.stopPropagation(),i(this,od).dispatch("switchannotationeditorparams",{source:this,type:X.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},Qp=function(t){We._keyboardManager.exec(this,t)},Xr=function(t){if(i(this,yt,Bn)){this.hideDropdown();return}if(u(this,ad,t.detail===0),i(this,yr)||(u(this,yr,new AbortController),window.addEventListener("pointerdown",b(this,yt,ry).bind(this),{signal:i(this,si).combinedSignal(i(this,yr))})),i(this,ls).ariaExpanded="true",i(this,Jt)){i(this,Jt).classList.remove("hidden");return}const e=u(this,Jt,b(this,yt,Kp).call(this));i(this,ls).append(e)},ry=function(t){var e;(e=i(this,Jt))!=null&&e.contains(t.target)||this.hideDropdown()},Bn=function(){return i(this,Jt)&&!i(this,Jt).classList.contains("hidden")},m(We,ld,null);let Qu=We;var hs,jl,so,gn,hd;const Jr=class Jr{constructor(t){m(this,hs,null);m(this,jl,!1);m(this,so,null);m(this,gn,null);u(this,so,t),u(this,gn,t._uiManager),i(Jr,hd)||u(Jr,hd,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(i(this,hs))return i(this,hs);const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:n,color:r,opacity:a}=i(this,so),o=u(this,jl,bt.isAlphaColorInputSupported&&n!==void 0),l=u(this,hs,document.createElement("input"));if(l.type="color",o){l.setAttribute("alpha","");const h=D.hexNums[Math.round((a??1)*255)];l.value=(r||"#000000")+h}else l.value=r||"#000000";return l.className="basicColorPicker",l.tabIndex=0,l.setAttribute("data-l10n-id",i(Jr,hd)[t]),l.addEventListener("input",()=>{if(o){const h=Yd(l.value);
45if(!h)return;const[c,d,f,g]=h,y=D.makeHexColor(c,d,f);s!==void 0?i(this,gn).updateParams(s,{color:y,opacity:g}):(i(this,gn).updateParams(e,y),i(this,gn).updateParams(n,g))}else i(this,gn).updateParams(e,l.value)},{signal:i(this,gn)._signal}),l}update(t){if(i(this,hs))if(i(this,jl)){const e=D.hexNums[Math.round(i(this,so).opacity*255)];i(this,hs).value=t+e}else i(this,hs).value=t}updateOpacity(t){if(!i(this,hs)||!i(this,jl))return;const e=D.hexNums[Math.round(t*255)];i(this,hs).value=i(this,so).color+e}destroy(){var t;(t=i(this,hs))==null||t.remove(),u(this,hs,null)}hideDropdown(){}};hs=new WeakMap,jl=new WeakMap,so=new WeakMap,gn=new WeakMap,hd=new WeakMap,m(Jr,hd,null);let Ju=Jr;function Dm(p){return Math.floor(Tt(p,0,1)*255).toString(16).padStart(2,"0")}function Th(p){return Tt(p,0,1)*255}class Im{static CMYK_G([t,e,s,n]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+n)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Th(t),[t,t,t]}static G_HTML([t]){const e=Dm(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Th)}static RGB_HTML(t){return`#${t.map(Dm).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,s+n),1-Math.min(1,e+n)]}static CMYK_rgb([t,e,s,n]){return[Th(1-Math.min(1,t+n)),Th(1-Math.min(1,s+n)),Th(1-Math.min(1,e+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const n=1-t,r=1-e,a=1-s,o=Math.min(n,r,a);return["CMYK",n,r,a,o]}}class K0{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),s||(n.setAttribute("width",`${t}px`),n.setAttribute("height",`${e}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${t} ${e}`),n}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){it("Abstract method `_createSVG` called.")}}class Zu extends K0{_createSVG(t){return document.createElementNS(He,t)}}const q0=9,Ro=new WeakSet,Q0=new Date().getTimezoneOffset()*60*1e3;class tp{static create(t){switch(t.data.annotationType){case Pt.LINK:return new Wg(t);case Pt.TEXT:return new Z0(t);case Pt.WIDGET:switch(t.data.fieldType){case"Tx":return new tw(t);case"Btn":return t.data.radioButton?new iw(t):t.data.checkBox?new sw(t):new nw(t);case"Ch":return new rw(t);case"Sig":return new ew(t)}return new No(t);case Pt.POPUP:return new Zp(t);case Pt.FREETEXT:return new uy(t);case Pt.LINE:return new ow(t);case Pt.SQUARE:return new lw(t);case Pt.CIRCLE:return new hw(t);case Pt.POLYLINE:return new fy(t);case Pt.CARET:return new dw(t);case Pt.INK:return new Xg(t);case Pt.POLYGON:return new cw(t);case Pt.HIGHLIGHT:return new py(t);case Pt.UNDERLINE:return new uw(t);case Pt.SQUIGGLY:return new fw(t);case Pt.STRIKEOUT:return new pw(t);case Pt.STAMP:return new gy(t);case Pt.FILEATTACHMENT:return new gw(t);case Pt.RICHMEDIA:case Pt.SCREEN:case Pt.SOUND:return new my(t);default:return new Mt(t)}}}var io,Vl,Ns,cd,Jp;const sm=class sm{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:n=!1}={}){m(this,cd);m(this,io,null);m(this,Vl,!1);m(this,Ns,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(s)),n&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return sm._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:t}=this,e=(s=this.annotationStorage)==null?void 0:s.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}
45get commentButtonPosition(){var o;const t=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:n}=this.data;let r=-1/0,a=-1/0;if((e==null?void 0:e.length)>=8){for(let l=0;l<e.length;l+=8)e[l+1]>a?(a=e[l+1],r=e[l+2]):e[l+1]===a&&(r=Math.max(r,e[l+2]));return[r,a]}if((s==null?void 0:s.length)>=1){for(const l of s)for(let h=0,c=l.length;h<c;h+=2)l[h+1]>a?(a=l[h+1],r=l[h]):l[h+1]===a&&(r=Math.max(r,l[h]));if(r!==1/0)return[r,a]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-a)/n,t}get commentText(){var e,s,n;const{data:t}=this;return((s=(e=this.annotationStorage.getRawValue(`${Zh}${t.id}`))==null?void 0:e.popup)==null?void 0:s.contents)||((n=t.contentsObj)==null?void 0:n.str)||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${Zh}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=i(this,Ns))==null?void 0:t.popup)||this.popup)==null||e.remove(),u(this,Ns,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(i(this,io)||u(this,io,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&b(this,cd,Jp).call(this,e);let n=((r=i(this,Ns))==null?void 0:r.popup)||this.popup;!n&&(s!=null&&s.text)&&(this._createPopup(s),n=i(this,Ns).popup),n&&(n.updateEdited(t),s!=null&&s.deleted&&(n.remove(),u(this,Ns,null),this.popup=null))}resetEdited(){var t;i(this,io)&&(b(this,cd,Jp).call(this,i(this,io).rect),(t=i(this,Ns))==null||t.popup.resetEdited(),u(this,io,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:n}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof No)&&!(this instanceof Wg)&&!(this instanceof my)&&(r.tabIndex=0);const{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof Zp){const{rotation:A}=e;return!e.hasOwnCanvas&&A!==0&&this.setRotation(A,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const A=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(A>0||v>0){const S=`calc(${A}px * var(--total-scale-factor)) / calc(${v}px * var(--total-scale-factor))`;a.borderRadius=S}switch(e.borderStyle.style){case Ho.SOLID:a.borderStyle="solid";break;case Ho.DASHED:a.borderStyle="dashed";break;case Ho.BEVELED:W("Unimplemented border style: beveled");break;case Ho.INSET:W("Unimplemented border style: inset");break;case Ho.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(u(this,Vl,!0),a.borderColor=D.makeHexColor(...w)):a.borderWidth=0}const h=D.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:f,pageY:g}=n.rawDims;a.left=`${100*(h[0]-f)/c}%`,a.top=`${100*(h[1]-g)/d}%`;const{rotation:y}=e;return e.hasOwnCanvas||y===0?(a.width=`${100*o/c}%`,a.height=`${100*l/d}%`):this.setRotation(y,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:n}=this.parent.viewport.rawDims;let{width:r,height:a}=this;t%180!==0&&([r,a]=[a,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*a/n}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,n)=>{const r=n.detail[e],a=r[0],o=r.slice(1);n.target.style[s]=Im[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Im[`${a}_rgb`](o)})};return $(this,"_commonActions",{display:e=>{const{display:s}=e.detail,n=s%2===1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>
45e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const n of Object.keys(e.detail)){const r=t[n]||s[n];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[n,r]of Object.entries(e)){const a=s[n];if(a){const o={detail:{[n]:r},target:t};a(o),delete e[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,n,r]=this.data.rect.map(A=>Math.fround(A));if(t.length===8){const[A,v,w,S]=t.subarray(2,6);if(n===A&&r===v&&e===w&&s===S)return}const{style:a}=this.container;let o;if(i(this,Vl)){const{borderColor:A,borderWidth:v}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${He}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${A}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const l=n-e,h=r-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const f=c.createElement("defs");d.append(f);const g=c.createElement("clipPath"),y=`clippath_${this.data.id}`;g.setAttribute("id",y),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let A=2,v=t.length;A<v;A+=8){const w=t[A],S=t[A+1],E=t[A+2],x=t[A+3],C=c.createElement("rect"),T=(E-e)/l,k=(r-S)/h,P=(w-E)/l,M=(S-x)/h;C.setAttribute("x",T),C.setAttribute("y",k),C.setAttribute("width",P),C.setAttribute("height",M),g.append(C),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${T}" y="${k}" width="${P}" height="${M}"/>`)}i(this,Vl)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(d),this.container.style.clipPath=`url(#${y})`}_createPopup(t=null){const{data:e}=this;let s,n;t?(s={str:t.text},n=t.date):(s=e.contentsObj,n=e.modificationDate),u(this,Ns,new Zp({data:{color:e.color,titleObj:e.titleObj,modificationDate:n,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(i(this,Ns)||this.popup||this.data.popupRef)}get extraPopupElement(){return i(this,Ns)}render(){it("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const n=this._fieldObjects[t]||[];for(const{page:r,id:a,exportValues:o}of n){if(r===-1||a===e)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!Ro.has(h)){W(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:h})}return s}for(const n of document.getElementsByName(t)){const{exportValue:r}=n,a=n.getAttribute("data-element-id");a!==e&&Ro.has(n)&&s.push({id:a,exportValue:r,domElement:n})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;t.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}
45_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":D.makeHexColor(...e)}};io=new WeakMap,Vl=new WeakMap,Ns=new WeakMap,cd=new WeakSet,Jp=function(t){const{container:{style:e},data:{rect:s,rotation:n},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,n===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(n)};let Mt=sm;class J0 extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}var Es,Yr,ay,oy;class Wg extends Mt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});m(this,Es);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action,e.overlaidText),r=!0):e.attachment?(b(this,Es,ay).call(this,n,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(b(this,Es,oy).call(this,n,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(n,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&(this.contentElement=n,this.container.append(n)),this.container}_bindLink(e,s,n=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&b(this,Es,Yr).call(this),n&&(e.title=n)}_bindNamedAction(e,s,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),n&&(e.title=n),b(this,Es,Yr).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=n.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),b(this,Es,Yr).call(this)}_bindResetFormAction(e,s){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),b(this,Es,Yr).call(this),!this._fieldObjects){W('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{var d;n==null||n();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const f=new Set(a);for(const g of r){const y=this._fieldObjects[g]||[];for(const{id:A}of y)f.add(A)}for(const g of Object.values(this._fieldObjects))for(const y of g)f.has(y.id)===o&&l.push(y)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const h=this.annotationStorage,c=[];for(const f of l){const{id:g}=f;switch(c.push(g),f.type){case"text":{const A=f.defaultValue||"";h.setValue(g,{value:A});break}case"checkbox":case"radiobutton":{const A=f.defaultValue===f.exportValues;h.setValue(g,{value:A});break}case"combobox":case"listbox":{const A=f.defaultValue||"";h.setValue(g,{value:A});break}default:continue}const y=document.querySelector(`[data-element-id="${g}"]`);if(y){if(!Ro.has(y)){W(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;y.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}}}Es=new WeakSet,Yr=function(){this.container.setAttribute("data-internal-link","")},ay=function(e,s,n,r="",a=null){e.href=this.linkService.getAnchorUrl(""),n.description?e.title=n.description:r&&(e.title=r);const o=async()=>{var h;const l=await this.linkService.getAttachmentContent(s);l&&((h=this.downloadManager)==null||h.openOrDownloadData(l,n.filename,a))};e.onclick=()=>(o(),!1),b(this,Es,Yr).call(this)},oy=function(e,s,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),n&&(e.title=n),b(this,Es,Yr).call(this)};class Z0 extends Mt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}
45class No extends Mt{render(){return this.container}_getKeyModifier(t){return bt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,n,r){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(a)}}))})}_setEventListeners(t,e,s,n){var r,a,o;for(const[l,h]of s)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,h,n),h==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||q0,r=t.style;let a;const o=2,l=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o),c=Math.round(h/(1.35*n))||1,d=h/c;a=Math.min(n,l(d/1.35))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(n,l(h/1.35))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=D.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class tw extends No{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,n){const r=this.annotationStorage;
45for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[n]:s})}render(){var n,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let h=a.formattedValue||((n=this.data.textContent)==null?void 0:n.join(`
46`))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const c={userValue:o,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=h??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",h??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),t.has(e)&&this.container.classList.add("sandboxModified")),Ro.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:d,datetimeType:f,timeStep:g}=this.data,y=!!f&&this.enableScripting;d&&(s.title=d),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",v=>{t.setValue(e,{value:v.target.value}),this.setPropertyOnSiblings(s,"value",v.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",v=>{const w=this.data.defaultFieldValue??"";s.value=c.userValue=w,c.formattedValue=null});let A=v=>{const{formattedValue:w}=c;w!=null&&(v.target.value=w),v.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",w=>{var E;if(c.focused)return;const{target:S}=w;if(y&&(S.type=f,g&&(S.step=g)),c.userValue){const x=c.userValue;if(y)if(f==="time"){const C=new Date(x),T=[C.getHours(),C.getMinutes(),C.getSeconds()];S.value=T.map(k=>k.toString().padStart(2,"0")).join(":")}else S.value=new Date(x-Q0).toISOString().split(f==="date"?"T":".",1)[0];else S.value=x}c.lastCommittedValue=S.value,c.commitKey=1,(E=this.data.actions)!=null&&E.Focus||(c.focused=!0)}),s.addEventListener("updatefromsandbox",w=>{this.container.classList.add("sandboxModified");const S={value(E){c.userValue=E.detail.value??"",y||t.setValue(e,{value:c.userValue.toString()}),E.target.value=c.userValue},formattedValue(E){const{formattedValue:x}=E.detail;c.formattedValue=x,x!=null&&E.target!==document.activeElement&&(E.target.value=x);const C={formattedValue:x};y&&(C.value=x),t.setValue(e,C)},selRange(E){E.target.setSelectionRange(...E.detail.selRange)},charLimit:E=>{var k;const{charLimit:x}=E.detail,{target:C}=E;if(x===0){C.removeAttribute("maxLength");return}C.setAttribute("maxLength",x);let T=c.userValue;!T||T.length<=x||(T=T.slice(0,x),C.value=c.userValue=T,t.setValue(e,{value:T}),(k=this.linkService.eventBus)==null||k.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:T,willCommit:!0,commitKey:1,selStart:C.selectionStart,selEnd:C.selectionEnd}}))}};this._dispatchEventFromSandbox(S,w)}),s.addEventListener("keydown",w=>{var x;c.commitKey=1;let S=-1;if(w.key==="Escape"?S=0:w.key==="Enter"&&!this.data.multiLine?S=2:w.key==="Tab"&&(c.commitKey=3),S===-1)return;const{value:E}=w.target;c.lastCommittedValue!==E&&(c.lastCommittedValue=E,c.userValue=E,(x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:S,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const v=A;A=null,s.addEventListener("blur",w=>{var x,C;if(!c.focused||!w.relatedTarget)return;(x=this.data.actions)!=null&&x.Blur||(c.focused=!1);const{target:S}=w;let{value:E}=S;if(y){if(E&&f==="time"){const T=E.split(":").map(k=>parseInt(k,10));E=new Date(2e3,0,1,T[0],T[1],T[2]||0).valueOf(),S.step=""}else E.includes("T")||(E=`${E}T00:00`),E=new Date(E).valueOf();S.type="text"}c.userValue=E,c.lastCommittedValue!==E&&((C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,
46commitKey:c.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),v(w)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",w=>{var M;c.lastCommittedValue=null;const{data:S,target:E}=w,{value:x,selectionStart:C,selectionEnd:T}=E;let k=C,P=T;switch(w.inputType){case"deleteWordBackward":{const L=x.substring(0,C).match(/\w*\W*$/);L&&(k-=L[0].length);break}case"deleteWordForward":{const L=x.substring(C).match(/^\W*\w*/);L&&(P+=L[0].length);break}case"deleteContentBackward":C===T&&(k-=1);break;case"deleteContentForward":C===T&&(P+=1);break}w.preventDefault(),(M=this.linkService.eventBus)==null||M.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:x,change:S||"",willCommit:!1,selStart:k,selEnd:P}})}),this._setEventListeners(s,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],w=>w.target.value)}if(A&&s.addEventListener("blur",A),this.data.comb){const w=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${w}px * var(--total-scale-factor))`);const S=this.data.textAlignment;if(S===1||S===2){const E=()=>{const x=l-s.value.length;s.style.setProperty("--comb-offset",`${S===1?x>>1:x}`)};E();for(const x of["input","blur","resetform","updatefromsandbox"])s.addEventListener(x,E)}}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class ew extends No{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class sw extends No{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let n=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof n=="string"&&(n=n!=="Off",t.setValue(s,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return Ro.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,n&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s)){const c=l&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class iw extends No{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let n=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof n=="string"&&(n=n!==e.buttonValue,t.setValue(s,{value:n})),n)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const r=document.createElement("input");if(Ro.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,n&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:h=>{const c=a===h.detail.value;for(const d of this._getElementsByName(h.target.name)){const f=c&&d.id===s;d.domElement&&(d.domElement.checked=f),t.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}
46class nw extends Wg{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class rw extends No{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");Ro.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",d=>{const f=this.data.defaultFieldValue;for(const g of n.options)g.selected=g.value===f});const a=(d,f)=>{const g=f.replaceAll(" "," ");d.textContent=g,g!==f&&d.setAttribute("display-value",f)};for(const d of this.data.options){const f=document.createElement("option");a(f,d.displayValue),f.value=d.exportValue,s.value.includes(d.exportValue)&&(f.setAttribute("selected",!0),r=!1),n.append(f)}let o=null;if(r){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),n.prepend(d),o=()=>{d.remove(),n.removeEventListener("input",o),o=null},n.addEventListener("input",o)}const l=d=>{const f=d?"value":"textContent",{options:g,multiple:y}=n;return y?Array.prototype.filter.call(g,A=>A.selected).map(A=>A[f]):g.selectedIndex===-1?null:g[g.selectedIndex][f]};let h=l(!1);const c=d=>{const f=d.target.options;return Array.prototype.map.call(f,g=>({displayValue:g.getAttribute("display-value")||g.textContent,exportValue:g.value}))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",d=>{const f={value(g){o==null||o();const y=g.detail.value,A=new Set(Array.isArray(y)?y:[y]);for(const v of n.options)v.selected=A.has(v.value);t.setValue(e,{value:l(!0)}),h=l(!1)},multipleSelection(g){n.multiple=!0},remove(g){const y=n.options,A=g.detail.remove;y[A].selected=!1,n.remove(A),y.length>0&&Array.prototype.findIndex.call(y,w=>w.selected)===-1&&(y[0].selected=!0),t.setValue(e,{value:l(!0),items:c(g)}),h=l(!1)},clear(g){for(;n.length!==0;)n.remove(0);t.setValue(e,{value:null,items:[]}),h=l(!1)},insert(g){const{index:y,displayValue:A,exportValue:v}=g.detail.insert,w=n.children[y],S=document.createElement("option");a(S,A),S.value=v,w?w.before(S):n.append(S),t.setValue(e,{value:l(!0),items:c(g)}),h=l(!1)},items(g){const{items:y}=g.detail;for(;n.length!==0;)n.remove(0);for(const A of y){const{displayValue:v,exportValue:w}=A,S=document.createElement("option");a(S,v),S.value=w,n.append(S)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:l(!0),items:c(g)}),h=l(!1)},indices(g){const y=new Set(g.detail.indices);for(const A of g.target.options)A.selected=y.has(A.index);t.setValue(e,{value:l(!0)}),h=l(!1)},editable(g){g.target.disabled=!g.detail.editable}};this._dispatchEventFromSandbox(f,d)}),n.addEventListener("input",d=>{var y;const f=l(!0),g=l(!1);t.setValue(e,{value:f}),d.preventDefault(),(y=this.linkService.eventBus)==null||y.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:h,change:g,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):n.addEventListener("input",function(d){t.setValue(e,{value:l(!0)})}),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}var dd,tg;class Zp extends Mt{constructor(e){const{data:s,elements:n,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&Mt._hasPopupData(s)});
46m(this,dd);if(this.elements=n,a&&Mt._hasPopupData(s)){const o=this.popup=b(this,dd,tg).call(this);for(const l of n)l.popup=o}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";const s=this.popup=b(this,dd,tg).call(this),n=[];for(const r of this.elements)r.popup=s,r.container.ariaHasPopup="dialog",n.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",n.map(r=>`${Vo}${r}`).join(",")),this.container}}dd=new WeakSet,tg=function(){return new aw({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})};var cs,Ar,Sf,Ef,Wl,Xl,Ht,ki,wr,no,Yl,Kl,Mi,ds,mn,bn,Ut,yn,vr,ud,An,ql,ro,Sr,re,Er,K,Cu,eg,sg,ig,Tu,ng,ly,hy,cy,dy,_u,ku,rg;class aw{constructor({container:t,color:e,elements:s,titleObj:n,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:d,commentManager:f=null}){m(this,K);m(this,cs,null);m(this,Ar,b(this,K,cy).bind(this));m(this,Sf,b(this,K,rg).bind(this));m(this,Ef,b(this,K,ku).bind(this));m(this,Wl,b(this,K,_u).bind(this));m(this,Xl,null);m(this,Ht,null);m(this,ki,null);m(this,wr,null);m(this,no,null);m(this,Yl,null);m(this,Kl,null);m(this,Mi,!1);m(this,ds,null);m(this,mn,null);m(this,bn,null);m(this,Ut,null);m(this,yn,null);m(this,vr,null);m(this,ud,null);m(this,An,null);m(this,ql,null);m(this,ro,null);m(this,Sr,!1);m(this,re,null);m(this,Er,null);u(this,Ht,t),u(this,ql,n),u(this,ki,a),u(this,An,o),u(this,Yl,l),u(this,Xl,e),u(this,ud,h),u(this,Kl,c),u(this,no,s),u(this,cs,f),u(this,re,s[0]),u(this,wr,Yu.toDateObject(r)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup()),f||(b(this,K,Cu).call(this),i(this,Ht).hidden=!0,d&&b(this,K,_u).call(this))}renderCommentButton(){if(i(this,Ut)){i(this,Ut).parentNode||i(this,re).container.after(i(this,Ut));return}if(i(this,yn)||b(this,K,eg).call(this),!i(this,yn))return;const{signal:t}=u(this,mn,new AbortController),e=i(this,re).hasOwnCommentButton,s=()=>{i(this,cs).toggleCommentPopup(this,!0,void 0,!e)},n=()=>{i(this,cs).toggleCommentPopup(this,!1,!0,!e)},r=()=>{i(this,cs).toggleCommentPopup(this,!1,!1)};if(e){u(this,Ut,i(this,re).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",i(this,Ar),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",n,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),a.classList.add("popupTriggerArea")}else{const a=u(this,Ut,document.createElement("button"));a.className="annotationCommentButton";const o=i(this,re).container;a.style.zIndex=parseInt(o.style.zIndex,10)+1,a.tabIndex=0,a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.setAttribute("data-l10n-id","pdfjs-show-comment-button"),b(this,K,ig).call(this),b(this,K,sg).call(this),a.addEventListener("keydown",i(this,Ar),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",n,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),o.after(a)}}get commentButtonColor(){const{color:t,opacity:e}=i(this,re).commentData;return t?i(this,Yl)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=i(this,Ut))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:n,modificationDate:r}=i(this,re).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:n,modificationDate:r}}get elementBeforePopup(){return i(this,Ut)}get comment(){return i(this,Er)||u(this,Er,i(this,re).commentText),i(this,Er)}set comment(t){t!==this.comment&&(i(this,re).commentText=u(this,Er,t))}focus(){var t;(t=i(this,re).container)==null||t.focus()}get parentBoundingClientRect(){return i(this,re).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){i(this,Ut)&&(i(this,Ut).classList.toggle("selected",t),i(this,Ut).ariaExpanded=e)}setSelectedCommentButton(t){i(this,Ut).classList.toggle("selected",t)}get commentPopupPosition(){if(i(this,vr))return i(this,vr);const{x:t,y:e,height:s}=i(this,Ut).getBoundingClientRect(),{x:n,y:r,width:a,height:o}=i(this,re).layer.getBoundingClientRect();return[(t-n)/a,(e+s-r)/o]}set commentPopupPosition(t){u(this,vr,t)}hasDefaultPopupPosition(){return i(this,vr)===null}get commentButtonPosition(){return i(this,yn)}get commentButtonWidth(){return i(this,Ut).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=i(this,vr)||this.commentButtonPosition.map(h=>h/100),n=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=n;i(this,cs).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:n})}render(){var s,n;if(i(this,ds))return;const t=u(this,ds,document.createElement("div"));if(t.className="popup",i(this,Xl)){const r=t.style.outlineColor=D.makeHexColor(...i(this,Xl));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=i(this,ql))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=i(this,ql)}if(t.append(e),i(this,wr)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:i(this,wr).valueOf()})),r.dateTime=i(this,wr).toISOString(),e.append(r)}Bm({html:i(this,K,Tu)||i(this,ki).str,dir:(n=i(this,ki))==null?void 0:n.dir,className:"popupContent"},t),i(this,Ht).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var n;if(i(this,cs)){s?(this.remove(),u(this,Er,null)):e&&(e.deleted?this.remove():(b(this,K,ig).call(this),u(this,Er,e.text))),t&&(u(this,yn,null),b(this,K,eg).call(this),b(this,K,sg).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}b(this,K,Cu).call(this),i(this,ro)||u(this,ro,{contentsObj:i(this,ki),richText:i(this,An)}),t&&u(this,bn,null),e&&e.text&&(u(this,An,b(this,K,hy).call(this,e.text)),u(this,wr,Yu.toDateObject(e.date)),u(this,ki,null)),(n=i(this,ds))==null||n.remove(),u(this,ds,null)}resetEdited(){var t;i(this,ro)&&({contentsObj:Et(this,ki)._,richText:Et(this,An)._}=i(this,ro),u(this,ro,null),(t=i(this,ds))==null||t.remove(),u(this,ds,null),u(this,bn,null))}remove(){var t,e,s;if((t=i(this,mn))==null||t.abort(),u(this,mn,null),(e=i(this,ds))==null||e.remove(),u(this,ds,null),u(this,Sr,!1),u(this,Mi,!1),(s=i(this,Ut))==null||s.remove(),u(this,Ut,null),this.trigger)for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){u(this,Sr,this.isVisible),i(this,Sr)&&(i(this,Ht).hidden=!0)}maybeShow(){i(this,cs)||(b(this,K,Cu).call(this),i(this,Sr)&&(i(this,ds)||b(this,K,ku).call(this),u(this,Sr,!1),i(this,Ht).hidden=!1))}get isVisible(){return i(this,cs)?!1:i(this,Ht).hidden===!1}}cs=new WeakMap,Ar=new WeakMap,Sf=new WeakMap,Ef=new WeakMap,Wl=new WeakMap,Xl=new WeakMap,Ht=new WeakMap,ki=new WeakMap,wr=new WeakMap,no=new WeakMap,Yl=new WeakMap,Kl=new WeakMap,Mi=new WeakMap,ds=new WeakMap,mn=new WeakMap,bn=new WeakMap,Ut=ne
46w WeakMap,yn=new WeakMap,vr=new WeakMap,ud=new WeakMap,An=new WeakMap,ql=new WeakMap,ro=new WeakMap,Sr=new WeakMap,re=new WeakMap,Er=new WeakMap,K=new WeakSet,Cu=function(){var e;if(i(this,mn))return;u(this,mn,new AbortController);const{signal:t}=i(this,mn);for(const s of this.trigger)s.addEventListener("click",i(this,Wl),{signal:t}),s.addEventListener("pointerenter",i(this,Ef),{signal:t}),s.addEventListener("pointerleave",i(this,Sf),{signal:t}),s.classList.add("popupTriggerArea");for(const s of i(this,no))(e=s.container)==null||e.addEventListener("keydown",i(this,Ar),{signal:t})},eg=function(){const t=i(this,no).find(e=>e.hasCommentButton);t&&u(this,yn,t._normalizePoint(t.commentButtonPosition))},sg=function(){if(i(this,re).extraPopupElement&&!i(this,re).editor)return;i(this,Ut)||this.renderCommentButton();const[t,e]=i(this,yn),{style:s}=i(this,Ut);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},ig=function(){i(this,re).extraPopupElement||(i(this,Ut)||this.renderCommentButton(),i(this,Ut).style.backgroundColor=this.commentButtonColor||"")},Tu=function(){const t=i(this,An),e=i(this,ki);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&i(this,An).html||null},ng=function(){var t,e,s;return((s=(e=(t=i(this,K,Tu))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},ly=function(){var t,e,s;return((s=(e=(t=i(this,K,Tu))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},hy=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:i(this,K,ly),fontSize:i(this,K,ng)?`calc(${i(this,K,ng)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
47`))e.push({name:"span",value:r,attributes:n});return s},cy=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&i(this,Mi))&&b(this,K,_u).call(this)},dy=function(){if(i(this,bn)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:n,pageY:r}}}=i(this,Yl);let a=!!i(this,Kl),o=a?i(this,Kl):i(this,ud);for(const y of i(this,no))if(!o||D.intersect(y.data.rect,o)!==null){o=y.data.rect,a=!0;break}const l=D.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),c=a?o[2]-o[0]+5:0,d=l[0]+c,f=l[1];
47u(this,bn,[100*(d-n)/e,100*(f-r)/s]);const{style:g}=i(this,Ht);g.left=`${i(this,bn)[0]}%`,g.top=`${i(this,bn)[1]}%`},_u=function(){if(i(this,cs)){i(this,cs).toggleCommentPopup(this,!1);return}u(this,Mi,!i(this,Mi)),i(this,Mi)?(b(this,K,ku).call(this),i(this,Ht).addEventListener("click",i(this,Wl)),i(this,Ht).addEventListener("keydown",i(this,Ar))):(b(this,K,rg).call(this),i(this,Ht).removeEventListener("click",i(this,Wl)),i(this,Ht).removeEventListener("keydown",i(this,Ar)))},ku=function(){i(this,ds)||this.render(),this.isVisible?i(this,Mi)&&i(this,Ht).classList.add("focused"):(b(this,K,dy).call(this),i(this,Ht).hidden=!1,i(this,Ht).style.zIndex=parseInt(i(this,Ht).style.zIndex,10)+1e3)},rg=function(){i(this,Ht).classList.remove("focused"),!(i(this,Mi)||!this.isVisible)&&(i(this,Ht).hidden=!0,i(this,Ht).style.zIndex=parseInt(i(this,Ht).style.zIndex,10)-1e3)};class uy extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=V.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var fd;class ow extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,fd,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:s,height:n}=this,r=this.svgFactory.create(s,n,!0),a=u(this,fd,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return i(this,fd)}addHighlightArea(){this.container.classList.add("highlightArea")}}fd=new WeakMap;var pd;class lw extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,pd,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:s,height:n}=this,r=this.svgFactory.create(s,n,!0),a=e.borderStyle.width,o=u(this,pd,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",n-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return i(this,pd)}addHighlightArea(){this.container.classList.add("highlightArea")}}pd=new WeakMap;var gd;class hw extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,gd,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:s,height:n}=this,r=this.svgFactory.create(s,n,!0),a=e.borderStyle.width,o=u(this,gd,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",n/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",n/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return i(this,gd)}addHighlightArea(){this.container.classList.add("highlightArea")}}gd=new WeakMap;var md;class fy extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,md,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:n,popupRef:r},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let h=[];for(let d=0,f=s.length;d<f;d+=2){const g=s[d]-e[0],y=e[3]-s[d+1];h.push(`${g},${y}`)}h=h.join(" ");const c=u(this,md,this.svgFactory.createElement(this.svgElementName));return c.setAttribute("points",h),c.setAttribute("stroke-width",n.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),l.append(c),this.container.append(l),!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return i(this,md)}addHighlightArea(){this.container.classList.add("highlightArea")}}md=new WeakMap;class cw extends fy{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class dw extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}
47var bd,ao,yd,ag;class Xg extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,yd);m(this,bd,null);m(this,ao,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?V.HIGHLIGHT:V.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:n,borderStyle:r,popupRef:a}}=this,{transform:o,width:l,height:h}=b(this,yd,ag).call(this,s,e),c=this.svgFactory.create(l,h,!0),d=u(this,bd,this.svgFactory.createElement("svg:g"));c.append(d),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",o);for(const f of n){const g=this.svgFactory.createElement(this.svgElementName);i(this,ao).push(g),g.setAttribute("points",f.join(",")),d.append(g)}return!a&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:n,rect:r}=e,a=i(this,bd);if(s>=0&&a.setAttribute("stroke-width",s||1),n)for(let o=0,l=i(this,ao).length;o<l;o++)i(this,ao)[o].setAttribute("points",n[o].join(","));if(r){const{transform:o,width:l,height:h}=b(this,yd,ag).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return i(this,ao)}addHighlightArea(){this.container.classList.add("highlightArea")}}bd=new WeakMap,ao=new WeakMap,yd=new WeakSet,ag=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class py extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=V.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class uw extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class fw extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class pw extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class gy extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=V.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}
47var Ad,wd,og;class gw extends Mt{constructor(e){var r;super(e,{isRenderable:!0});m(this,wd);m(this,Ad,null);const{fileId:s,file:n}=this.data;this.filename=n.filename,this.content=n.content,this.fileId=s,(r=this.linkService.eventBus)==null||r.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...n})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let n;s.hasAppearance||s.fillAlpha===0?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),n.addEventListener("dblclick",b(this,wd,og).bind(this)),u(this,Ad,n);const{isMac:r}=bt.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&b(this,wd,og).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return i(this,Ad)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ad=new WeakMap,wd=new WeakSet,og=async function(){var a;const{fileId:e,filename:s,content:n}=this,r=await this.linkService.getAttachmentContent(e)||n;r&&((a=this.downloadManager)==null||a.openOrDownloadData(r,s))};var Ql,oo,wn,Fo,by,lg;class my extends Mt{constructor(e){super(e,{isRenderable:!!e.data.richMedia});m(this,Fo);m(this,Ql,new AbortController);m(this,oo,null);m(this,wn,null)}render(){this.container.classList.add("mediaAnnotation");const{filename:e}=this.data.richMedia,s=document.createElement("button");return s.className="mediaPlayButton",s.type="button",s.title=s.ariaLabel=e,s.addEventListener("click",()=>b(this,Fo,by).call(this,s),{signal:i(this,Ql).signal}),this.container.append(s),this.container}destroy(){i(this,Ql).abort(),i(this,wn)&&(i(this,wn).pause(),i(this,wn).removeAttribute("src"),i(this,wn).load(),u(this,wn,null)),b(this,Fo,lg).call(this)}}Ql=new WeakMap,oo=new WeakMap,wn=new WeakMap,Fo=new WeakSet,by=async function(e){const{fileId:s,filename:n,contentType:r}=this.data.richMedia;e.disabled=!0;let a;try{a=await this.linkService.getAttachmentContent(s)}catch{return}finally{e.disabled=!1}if(!a||!e.isConnected)return;const{signal:o}=i(this,Ql),l=URL.createObjectURL(new Blob([a],{type:r}));u(this,oo,l);const h=r.startsWith("audio/"),c=document.createElement(h?"audio":"video");if(u(this,wn,c),c.className="mediaContent",this._setBackgroundColor(c),c.src=l,c.title=n,c.controls=!0,c.autoplay=!0,c.tabIndex=0,h){let d=!1,f=!1;const g=()=>{c.controls=d||f};this.container.addEventListener("pointerenter",()=>{d=!0,g()},{signal:o}),this.container.addEventListener("pointerleave",()=>{d=!1,g()},{signal:o}),this.container.addEventListener("focusin",()=>{f=!0,g()},{signal:o}),this.container.addEventListener("focusout",()=>{f=!1,g()},{signal:o})}c.addEventListener("emptied",()=>b(this,Fo,lg).call(this,l),{once:!0,signal:o}),e.replaceWith(c),c.play().catch(()=>{})},lg=function(e=i(this,oo)){e&&e===i(this,oo)&&(URL.revokeObjectURL(e),u(this,oo,null))};var xr,lo,Jl,vn,vd,ho,_e,Sd,Bi,Mu,Pu;const im=class im{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:n,page:r,viewport:
47a,structTreeLayer:o,commentManager:l,linkService:h,annotationStorage:c}){m(this,Bi);m(this,xr,null);m(this,lo,null);m(this,Jl,null);m(this,vn,new Map);m(this,vd,null);m(this,ho,null);m(this,_e,[]);m(this,Sd,!1);_(this,"zIndex",0);this.div=t,u(this,xr,e),u(this,lo,s),u(this,vd,o||null),u(this,ho,h||null),u(this,Jl,c||new jg),this.page=r,this.viewport=a,this._annotationEditorUIManager=n,this._commentManager=l||null}hasEditableAnnotations(){return i(this,vn).size>0}async render(t){var l;const{annotations:e,optionalContentConfig:s}=t,n=this.div;Do(n,this.viewport);const r=new Map,a=[],o={data:null,layer:n,linkService:i(this,ho),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Zu,annotationStorage:i(this,Jl),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const h of e){if(h.noHTML)continue;const c=h.annotationType===Pt.POPUP;if(c){const g=r.get(h.id);if(!g)continue;if(!this._commentManager){a.push(h);continue}o.elements=g}else if(h.rect[2]===h.rect[0]||h.rect[3]===h.rect[1])continue;o.data=h;const d=tp.create(o);if(!d.isRenderable)continue;c||(i(this,_e).push(d),h.popupRef&&r.getOrInsertComputed(h.popupRef,Wd).push(d));const f=d.render();h.hidden&&(f.style.visibility="hidden"),d.updateOC(s),d._isEditable&&(i(this,vn).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}await b(this,Bi,Mu).call(this);for(const h of a){const c=o.elements=r.get(h.id);o.data=h;const d=tp.create(o);if(!d.isRenderable)continue;const f=d.render();d.contentElement.id=`${Vo}${h.id}`,h.hidden&&(f.style.visibility="hidden"),c.at(-1).container.after(f)}b(this,Bi,Pu).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:i(this,ho),svgFactory:new Zu,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=im._defaultBorderStyle),e.data=s;const n=tp.create(e);n.isRenderable&&(n.render(),n.contentElement.id=`${Vo}${s.id}`,i(this,_e).push(n))}await b(this,Bi,Mu).call(this)}update({viewport:t,optionalContentConfig:e}){const s=this.div;this.viewport=t,Do(s,{rotation:t.rotation});for(const n of i(this,_e))n.updateOC(e);b(this,Bi,Pu).call(this),s.hidden=!1}destroy(){var t,e;for(const s of i(this,_e))(t=s.destroy)==null||t.call(s),(e=i(this,xr))==null||e.removePointerInTextLayer(s.contentElement);i(this,_e).length=0,i(this,vn).clear(),this.div.replaceChildren()}refreshCanvases(){b(this,Bi,Pu).call(this)}getEditableAnnotations(){return i(this,vn).values()}getEditableAnnotation(t){return i(this,vn).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:n}=t,r=new J0({data:{id:s,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:i(this,ho),annotationStorage:i(this,Jl)});return r.render(),r.contentElement.id=`${Vo}${s}`,r.createOrUpdatePopup(),i(this,_e).push(r),r}removeAnnotation(t){var n;const e=i(this,_e).findIndex(r=>r.data.id===t);if(e<0)return;const[s]=i(this,_e).splice(e,1);(n=i(this,xr))==null||n.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);b(this,Bi,Mu).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return $(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Ho.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};xr=new WeakMap,lo=new WeakMap,Jl=new WeakMap,vn=new WeakMap,vd=new WeakMap,ho=new WeakMap,_e=new WeakMap,Sd=new WeakMap,Bi=new WeakSet,Mu=async function(){var s,n,r;if(i(this,_e).length===0)return;this.div.replaceChildren();const t=[];if(!i(this,Sd)){u(this,Sd,!0);for(const{contentElement:a,data:{id:o}}of i(this,_e)){const l=a.id=`${Vo}${o}`;t.push((s=i(this,vd))==null?void 0:s.getAriaAttributes(l).then(h=>{if(h)for(const[c,d]of h)a.setAttribute(c,d)}))}}i(this,_e).sort(({data:{rect:[a,o,l,h]}},{data:{rect:[c,d,f,g]}})=>{if(a===l&&o===h)return 1;if(c===f&&d===g)return-1;const y=h,A=o,v=(o+h)/2,w=g,S=d,E=(d+g)/2;if(v>=w&&E<=A)return-1;if(E>=y&&v<=S)return 1;const x=(a+l)/2,C=(c+f)/2;return x-C});const e=document.createDocumentFragment();for(const a of i(this,_e))e.append(a.container),this._commentManager?(r=((n=a.extraPopupElement)==null?void 0:n.popup)||a.popup)==null||r.renderCommentButton():a.extraPopupElement&&e.append(a.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),i(this,xr))for(const a of i(this,_e))i(this,xr).addPointerInTextLayer(a.contentElement,!1)},Pu=function(){var e;if(!i(this,lo))return;const t=this.div;for(const[s,n]of i(this,lo)){const r=t.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;if(Array.isArray(n))for(const c of n)c.className="annotationContent",c.ariaHidden=!0;else n.className="annotationContent",n.ariaHidden=!0;const a=[];for(const c of r.children)c.nodeName==="CANVAS"&&a.push(c);for(const c of a)c.remove();const o=Array.isArray(n)?n[0]:n,{firstChild:l}=r;if(l?l.classList.contains("annotationContent")?l.after(o):l.before(o):r.append(o),Array.isArray(n)){let c=o;for(let d=1,f=n.length;d<f;d++)c.after(n[d]),c=n[d]}i(this,lo).delete(s);const h=i(this,vn).get(s);h&&(h._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,r.id,n),h._hasNoCanvas=!1):h.canvas=n)}};let hg=im;const su=/\r\n?|\n/g;var us,Ed,co,fs,qt,yy,Ay,wy,Du,Rn,Iu,Lu,vy,dg,Sy;const xt=class xt extends ot{constructor(e){super({...e,name:"freeTextEditor"});m(this,qt);m(this,us,"");m(this,Ed,`${this.id}-editor`);m(this,co,null);m(this,fs);_(this,"_colorPicker",null);this.color=e.color||xt._defaultColor||ot._defaultLineColor,u(this,fs,e.fontSize||xt._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert(ot._l10nAlert.freetext),this.canAddComment=!1}static get _keyboardManager(){const e=xt.prototype,s=a=>a.isEmpty(),n=Lo.TRANSLATE_SMALL,r=Lo.TRANSLATE_BIG;return $(this,"_keyboardManager",new Io([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],e.commitOrRemove],[["Escape"],e.commitOrRemove],[["ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight"],e._translateEmpty,{args:[n,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp"],e._translateEmpty,{args:[0,-n],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown"],e._translateEmpty,{args:[0,n],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(e,s){ot.initialize(e,s);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}
47static updateDefaultParams(e,s){switch(e){case X.FREETEXT_SIZE:xt._defaultFontSize=s;break;case X.FREETEXT_COLOR:xt._defaultColor=s;break}}updateParams(e,s){switch(e){case X.FREETEXT_SIZE:b(this,qt,yy).call(this,s);break;case X.FREETEXT_COLOR:b(this,qt,Ay).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[X.FREETEXT_SIZE,xt._defaultFontSize],[X.FREETEXT_COLOR,xt._defaultColor||ot._defaultLineColor]]}get propertiesToUpdate(){return[[X.FREETEXT_SIZE,i(this,fs)],[X.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Ju(this)),[["colorPicker",this._colorPicker]]}get colorType(){return X.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-xt._internalPadding*e,-(xt._internalPadding+i(this,fs))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),u(this,co,new AbortController);const e=this._uiManager.combinedSignal(i(this,co));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",i(this,Ed)),this._isDraggable=!0,(e=i(this,co))==null||e.abort(),u(this,co,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=i(this,us),s=u(this,us,b(this,qt,wy).call(this).trimEnd());if(e===s)return;const n=r=>{if(u(this,us,r),!r){this.remove();return}b(this,qt,Lu).call(this),this._uiManager.rebuild(this),b(this,qt,Du).call(this)};this.addCommands({cmd:()=>{n(s)},undo:()=>{n(e)},mustExec:!1}),b(this,qt,Du).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){xt._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,s;(this._isCopy||this.annotationElementId)&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",i(this,Ed)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:n}=this.editorDiv;if(n.fontSize=`calc(${i(this,fs)}px * var(--total-scale-factor))`,n.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[r,a]=this.parentDimensions;
47if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[c,d]=this.pageDimensions,[f,g]=this.pageTranslation;let y,A;switch(this.rotation){case 0:y=e+(o[0]-f)/c,A=s+this.height-(o[1]-g)/d;break;case 90:y=e+(o[0]-f)/c,A=s-(o[1]-g)/d,[l,h]=[h,-l];break;case 180:y=e-this.width+(o[0]-f)/c,A=s-(o[1]-g)/d,[l,h]=[-l,-h];break;case 270:y=e+(o[0]-f-this.height*d)/c,A=s+(o[1]-g-this.width*c)/d,[l,h]=[-h,l];break}this.setAt(y*r,A*a,l,h)}else this._moveAfterPaste(e,s);b(this,qt,Lu).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var y,A,v;const s=e.clipboardData||window.clipboardData,{types:n}=s;if(n.length===1&&n[0]==="text/plain")return;e.preventDefault();const r=b(y=xt,Rn,dg).call(y,s.getData("text")||"").replaceAll(su,`
48`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(`
49`)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:h}=o,c=[],d=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(d.push(l.nodeValue.slice(h).replaceAll(su,"")),w!==this.editorDiv){let S=c;for(const E of this.editorDiv.childNodes){if(E===w){S=d;continue}S.push(b(A=xt,Rn,Iu).call(A,E))}}c.push(l.nodeValue.slice(0,h).replaceAll(su,""))}else if(l===this.editorDiv){let w=c,S=0;for(const E of this.editorDiv.childNodes)S++===h&&(w=d),w.push(b(v=xt,Rn,Iu).call(v,E))}u(this,us,`${c.join(`
50`)}${r}${d.join(`
51`)}`),b(this,qt,Lu).call(this);const f=new Range;let g=Math.sumPrecise(c.map(w=>w.length));for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const S=w.nodeValue.length;if(g<=S){f.setStart(w,g),f.setEnd(w,g);break}g-=S}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=xt._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,n){var o;let r=null;if(e instanceof uy){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:c,rotation:d,id:f,popupRef:g,richText:y,contentsObj:A,creationDate:v,modificationDate:w},textContent:S,textPosition:E,parent:{page:{pageNumber:x}}}=e;if(!(S!=null&&S.length))return null;r=e={annotationType:V.FREETEXT,color:Array.from(h),fontSize:l,value:S.join(`
52`),position:E,pageIndex:x-1,rect:c.slice(0),rotation:d,annotationElementId:f,id:f,deleted:!1,popupRef:g,comment:(A==null?void 0:A.str)||null,richText:y,creationDate:v,modificationDate:w}}const a=await super.deserialize(e,s,n);return u(a,fs,e.fontSize),a.color=D.makeHexColor(...e.color),u(a,us,b(o=xt,Rn,dg).call(o,e.value)),a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=ot._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:s,fontSize:i(this,fs),value:b(this,qt,vy).call(this)});return this.addComment(n),e?(n.isCopy=!0,n):this.annotationElementId&&!b(this,qt,Sy).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:n}=s;n.fontSize=`calc(${i(this,fs)}px * var(--total-scale-factor))`,n.color=this.color,s.replaceChildren();for(const r of i(this,us).split(`
53`)){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),s.append(a)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:i(this,us)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};us=new WeakMap,Ed=new WeakMap,co=new WeakMap,fs=new WeakMap,qt=new WeakSet,yy=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-i(this,fs))*this.parentScale),u(this,fs,r),b(this,qt,Du).call(this)},n=i(this,fs);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:X.FREETEXT_S
53IZE,overwriteIfSameType:!0,keepUndo:!0})},Ay=function(e){const s=r=>{this.color=r,this.onUpdatedColor()},n=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:X.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},wy=function(){var n;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(b(n=xt,Rn,Iu).call(n,r)),s=r);return e.join(`
54`)},Du=function(){const[e,s]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),n=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=n.width/e,this.height=n.height/s):(this.width=n.height/e,this.height=n.width/s),this.fixAndSetPosition()},Rn=new WeakSet,Iu=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(su,"")},Lu=function(){if(this.editorDiv.replaceChildren(),!!i(this,us))for(const e of i(this,us).split(`
55`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},vy=function(){return i(this,us).replaceAll(" "," ")},dg=function(e){return e.replaceAll(" "," ")},Sy=function(e){const{value:s,fontSize:n,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==n||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},m(xt,Rn),_(xt,"_freeTextDefaultContent",""),_(xt,"_internalPadding",0),_(xt,"_defaultColor",null),_(xt,"_defaultFontSize",10),_(xt,"_type","freetext"),_(xt,"_editorType",V.FREETEXT);let cg=xt;class N{toSVGPath(){it("Abstract method `toSVGPath` must be implemented.")}get box(){it("Abstract getter `box` must be implemented.")}serialize(t,e){it("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,n,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*n,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,n,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*n,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,n){n||(n=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)n[r]=e+t[r],n[r+1]=s+t[r+1];return n}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,n,r){switch(r){case 90:return[1-e/s,t/n];case 180:return[1-t/s,1-e/n];case 270:return[e/s,1-t/n];default:return[t/s,e/n]}}static createBezierPoints(t,e,s,n,r,a){return[(t+5*s)/6,(e+5*n)/6,(5*s+r)/6,(5*n+a)/6,(s+r)/2,(n+a)/2]}}_(N,"PRECISION",1e-4);var ps,ii,Zl,th,Pi,Z,uo,fo,xd,Cd,eh,sh,Cr,Td,xf,Cf,Zt,jh,Ey,xy,Cy,Ty,_y,ky;const Vi=class Vi{constructor({x:t,y:e},s,n,r,a,o=0){m(this,Zt);m(this,ps);m(this,ii,[]);m(this,Zl);m(this,th);m(this,Pi,[]);m(this,Z,new Float32Array(18));m(this,uo);m(this,fo);m(this,xd);
vendor: 1,722 bytes, line 55
55m(this,Cd);m(this,eh);m(this,sh);m(this,Cr,[]);u(this,ps,s),u(this,sh,r*n),u(this,th,a),i(this,Z).set([NaN,NaN,NaN,NaN,t,e],6),u(this,Zl,o),u(this,Cd,i(Vi,Td)*n),u(this,xd,i(Vi,Cf)*n),u(this,eh,n),i(this,Cr).push(t,e)}isEmpty(){return isNaN(i(this,Z)[8])}add({x:t,y:e}){var M;u(this,uo,t),u(this,fo,e);const[s,n,r,a]=i(this,ps);let[o,l,h,c]=i(this,Z).subarray(8,12);const d=t-h,f=e-c,g=Math.hypot(d,f);if(g<i(this,xd))return!1;const y=g-i(this,Cd),A=y/g,v=A*d,w=A*f;let S=o,E=l;o=h,l=c,h+=v,c+=w,(M=i(this,Cr))==null||M.push(t,e);const x=-w/y,C=v/y,T=x*i(this,sh),k=C*i(this,sh);return i(this,Z).set(i(this,Z).subarray(2,8),0),i(this,Z).set([h+T,c+k],4),i(this,Z).set(i(this,Z).subarray(14,18),12),i(this,Z).set([h-T,c-k],16),isNaN(i(this,Z)[6])?(i(this,Pi).length===0&&(i(this,Z).set([o+T,l+k],2),i(this,Pi).push(NaN,NaN,NaN,NaN,(o+T-s)/r,(l+k-n)/a),i(this,Z).set([o-T,l-k],14),i(this,ii).push(NaN,NaN,NaN,NaN,(o-T-s)/r,(l-k-n)/a)),i(this,Z).set([S,E,o,l,h,c],6),!this.isEmpty()):(i(this,Z).set([S,E,o,l,h,c],6),Math.abs(Math.atan2(E-l,S-o)-Math.atan2(w,v))<Math.PI/2?([o,l,h,c]=i(this,Z).subarray(2,6),i(this,Pi).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-n)/a),[o,l,S,E]=i(this,Z).subarray(14,18),i(this,ii).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((E+l)/2-n)/a),!0):([S,E,o,l,h,c]=i(this,Z).subarray(0,6),i(this,Pi).push(((S+5*o)/6-s)/r,((E+5*l)/6-n)/a,((5*o+h)/6-s)/r,((5*l+c)/6-n)/a,((o+h)/2-s)/r,((l+c)/2-n)/a),[h,c,o,l,S,E]=i(this,Z).subarray(12,18),i(this,ii).push(((S+5*o)/6-s)/r,((E+5*l)/6-n)/a,((5*o+h)/6-s)/r,((5*l+c)/6-n)/a,((o+h)/2-s)/r,((l+c)/2-n)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=i(this,Pi),e=i(this,ii);if(isNaN(i(this,Z)[6])&&!this.isEmpty())return b(this,Zt,Ey).call(this);const s=[];
55s.push(`M${t[4]} ${t[5]}`);for(let n=6;n<t.length;n+=6)isNaN(t[n])?s.push(`L${t[n+4]} ${t[n+5]}`):s.push(`C${t[n]} ${t[n+1]} ${t[n+2]} ${t[n+3]} ${t[n+4]} ${t[n+5]}`);b(this,Zt,Cy).call(this,s);for(let n=e.length-6;n>=6;n-=6)isNaN(e[n])?s.push(`L${e[n+4]} ${e[n+5]}`):s.push(`C${e[n]} ${e[n+1]} ${e[n+2]} ${e[n+3]} ${e[n+4]} ${e[n+5]}`);return b(this,Zt,xy).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,n,r,a){return new My(t,e,s,n,r,a)}getOutlines(){var d;const t=i(this,Pi),e=i(this,ii),s=i(this,Z),[n,r,a,o]=i(this,ps),l=new Float32Array((((d=i(this,Cr))==null?void 0:d.length)??0)+2);for(let f=0,g=l.length-2;f<g;f+=2)l[f]=(i(this,Cr)[f]-n)/a,l[f+1]=(i(this,Cr)[f+1]-r)/o;if(l[l.length-2]=(i(this,uo)-n)/a,l[l.length-1]=(i(this,fo)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,Zt,Ty).call(this,l);const h=new Float32Array(i(this,Pi).length+24+i(this,ii).length);let c=t.length;for(let f=0;f<c;f+=2){if(isNaN(t[f])){h[f]=h[f+1]=NaN;continue}h[f]=t[f],h[f+1]=t[f+1]}c=b(this,Zt,ky).call(this,h,c);for(let f=e.length-6;f>=6;f-=6)for(let g=0;g<6;g+=2){if(isNaN(e[f+g])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[f+g],h[c+1]=e[f+g+1],c+=2}return b(this,Zt,_y).call(this,h,c),this.newFreeDrawOutline(h,l,i(this,ps),i(this,eh),i(this,Zl),i(this,th))}};ps=new WeakMap,ii=new WeakMap,Zl=new WeakMap,th=new WeakMap,Pi=new WeakMap,Z=new WeakMap,uo=new WeakMap,fo=new WeakMap,xd=new WeakMap,Cd=new WeakMap,eh=new WeakMap,sh=new WeakMap,Cr=new WeakMap,Td=new WeakMap,xf=new WeakMap,Cf=new WeakMap,Zt=new WeakSet,jh=function(){const t=i(this,Z).subarray(4,6),e=i(this,Z).subarray(16,18),[s,n,r,a]=i(this,ps);return[(i(this,uo)+(t[0]-e[0])/2-s)/r,(i(this,fo)+(t[1]-e[1])/2-n)/a,(i(this,uo)+(e[0]-t[0])/2-s)/r,(i(this,fo)+(e[1]-t[1])/2-n)/a]},Ey=function(){const[t,e,s,n]=i(this,ps),[r,a,o,l]=b(this,Zt,jh).call(this);return`M${(i(this,Z)[2]-t)/s} ${(i(this,Z)[3]-e)/n} L${(i(this,Z)[4]-t)/s} ${(i(this,Z)[5]-e)/n} L${r} ${a} L${o} ${l} L${(i(this,Z)[16]-t)/s} ${(i(this,Z)[17]-e)/n} L${(i(this,Z)[14]-t)/s} ${(i(this,Z)[15]-e)/n} Z`},xy=function(t){const e=i(this,ii);t.push(`L${e[4]} ${e[5]} Z`)},Cy=function(t){const[e,s,n,r]=i(this,ps),a=i(this,Z).subarray(4,6),o=i(this,Z).subarray(16,18),[l,h,c,d]=b(this,Zt,jh).call(this);t.push(`L${(a[0]-e)/n} ${(a[1]-s)/r} L${l} ${h} L${c} ${d} L${(o[0]-e)/n} ${(o[1]-s)/r}`)},Ty=function(t){const e=i(this,Z),[s,n,r,a]=i(this,ps),[o,l,h,c]=b(this,Zt,jh).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-n)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-n)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-n)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-n)/a],0),this.newFreeDrawOutline(d,t,i(this,ps),i(this,eh),i(this,Zl),i(this,th))},_y=function(t,e){const s=i(this,ii);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},ky=function(t,e){const s=i(this,Z).subarray(4,6),n=i(this,Z).subarray(16,18),[r,a,o,l]=i(this,ps),[h,c,d,f]=b(this,Zt,jh).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,d,f,NaN,NaN,NaN,NaN,(n[0]-r)/o,(n[1]-a)/l],e),e+=24},m(Vi,Td,8),m(Vi,xf,2),m(Vi,Cf,i(Vi,Td)+i(Vi,xf));let tf=Vi;var ih,po,Sn,_d,gs,kd,Wt,Tf,Py;class My extends N{constructor(e,s,n,r,a,o){super();m(this,Tf);m(this,ih);m(this,po,new Float32Array(4));m(this,Sn);m(this,_d);m(this,gs);m(this,kd);m(this,Wt);u(this,Wt,e),u(this,gs,s),u(this,ih,n),u(this,kd,r),u(this,Sn,a),u(this,_d,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,Tf,Py).call(this,o);const[l,h,c,d]=i(this,po);for(let f=0,g=e.length;f<g;f+=2)e[f]=(e[f]-l)/c,e[f+1]=(e[f+1]-h)/d;for(let f=0,g=s.length;f<g;f+=2)s[f]=(s[f]-l)/c,s[f+1]=(s[f+1]-h)/d}toSVGPath(){const e=[`M${i(this,Wt)[4]} ${i(this,Wt)[5]}`];for(let s=6,n=i(this,Wt).length;s<n;s+=6){if(isNaN(i(this,Wt)[s])){e.push(`L${i(this,Wt)[s+4]} ${i(this,Wt)[s+5]}`);continue}e.push(`C${i(this,Wt)[s]} ${i(this,Wt)[s+1]} ${i(this,Wt)[s+2]} ${i(this,Wt)[s+3]} ${i(this,Wt)[s+4]} ${i(this,Wt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,n,r],a){const o=n-e,l=r-s;let h,c;switch(a){case 0:h=N._rescale(i(this,Wt),e,r,o,-l),c=N._rescale(i(this,gs),e,r,o,-l);break;case 90:h=N._rescaleAndSwap(i(this,Wt),e,s,o,l),c=N._rescaleAndSwap(i(this,gs),e,s,o,l);break;case 180:h=N._rescale(i(this,Wt),n,s,-o,l),c=N._rescale(i(this,gs),n,s,-o,l);break;case 270:h=N._rescaleAndSwap(i(this,Wt),n,r,-o,-l),c=N._rescaleAndSwap(i(this,gs),n,r,
55-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return i(this,po)}newOutliner(e,s,n,r,a,o=0){return new tf(e,s,n,r,a,o)}getNewOutline(e,s){const[n,r,a,o]=i(this,po),[l,h,c,d]=i(this,ih),f=a*c,g=o*d,y=n*c+l,A=r*d+h,v=this.newOutliner({x:i(this,gs)[0]*f+y,y:i(this,gs)[1]*g+A},i(this,ih),i(this,kd),e,i(this,_d),s??i(this,Sn));for(let w=2;w<i(this,gs).length;w+=2)v.add({x:i(this,gs)[w]*f+y,y:i(this,gs)[w+1]*g+A});return v.getOutlines()}}ih=new WeakMap,po=new WeakMap,Sn=new WeakMap,_d=new WeakMap,gs=new WeakMap,kd=new WeakMap,Wt=new WeakMap,Tf=new WeakSet,Py=function(e){const s=i(this,Wt);let n=s[4],r=s[5];const a=[n,r,n,r];let o=n,l=r,h=n,c=r;const d=e?Math.max:Math.min,f=new Float32Array(4);for(let y=6,A=s.length;y<A;y+=6){const v=s[y+4],w=s[y+5];isNaN(s[y])?(D.pointBoundingBox(v,w,a),l>w?(o=v,l=w):l===w&&(o=d(o,v)),c<w?(h=v,c=w):c===w&&(h=d(h,v))):(f.set(In,0),D.bezierBoundingBox(n,r,...s.slice(y,y+6),f),D.rectBoundingBox(...f,a),l>f[1]?(o=f[0],l=f[1]):l===f[1]&&(o=d(o,f[0])),c<f[3]?(h=f[2],c=f[3]):c===f[3]&&(h=d(h,f[2]))),n=v,r=w}const g=i(this,po);g[0]=a[0]-i(this,Sn),g[1]=a[1]-i(this,Sn),g[2]=a[2]-a[0]+2*i(this,Sn),g[3]=a[3]-a[1]+2*i(this,Sn),this.firstPoint=[o,l],this.lastPoint=[h,c]};var Md,Pd,Dd,Tr,ni,$e,Dy,Ru,Iy,Ly,fg;class ug{constructor(t,e=0,s=0,n=!0){m(this,$e);m(this,Md);m(this,Pd);m(this,Dd);m(this,Tr,[]);m(this,ni,[]);const r=In.slice(),o=10**-4;for(const{x:v,y:w,width:S,height:E}of t){const x=Math.floor((v-e)/o)*o,C=Math.ceil((v+S+e)/o)*o,T=Math.floor((w-e)/o)*o,k=Math.ceil((w+E+e)/o)*o,P=[x,T,k,!0],M=[C,T,k,!1];i(this,Tr).push(P,M),D.rectBoundingBox(x,T,C,k,r)}const l=r[2]-r[0]+2*s,h=r[3]-r[1]+2*s,c=r[0]-s,d=r[1]-s;let f=n?-1/0:1/0,g=1/0;const y=i(this,Tr).at(n?-1:-2),A=[y[0],y[2]];for(const v of i(this,Tr)){const[w,S,E,x]=v;!x&&n?S<g?(g=S,f=w):S===g&&(f=Math.max(f,w)):x&&!n&&(S<g?(g=S,f=w):S===g&&(f=Math.min(f,w))),v[0]=(w-c)/l,v[1]=(S-d)/h,v[2]=(E-d)/h}u(this,Md,new Float32Array([c,d,l,h])),u(this,Pd,[f,g]),u(this,Dd,A)}getOutlines(){i(this,Tr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of i(this,Tr))e[3]?(t.push(...b(this,$e,fg).call(this,e)),b(this,$e,Iy).call(this,e)):(b(this,$e,Ly).call(this,e),t.push(...b(this,$e,fg).call(this,e)));return b(this,$e,Dy).call(this,t)}}Md=new WeakMap,Pd=new WeakMap,Dd=new WeakMap,Tr=new WeakMap,ni=new WeakMap,$e=new WeakSet,Dy=function(t){const e=[],s=new Set;for(const a of t){const[o,l,h]=a;e.push([o,l,a],[o,h,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],h=e[a+1][2];l.push(h),h.push(l),s.add(l),s.add(h)}const n=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,h,c,d]=a;s.delete(a);let f=o,g=l;for(r=[o,h],n.push(r);;){let y;if(s.has(c))y=c;else if(s.has(d))y=d;else break;s.delete(y),[o,l,h,c,d]=y,f!==o&&(r.push(f,g,o,g===l?l:h),f=o),g=g===l?h:l}r.push(f,g)}return new mw(n,i(this,Md),i(this,Pd),i(this,Dd))},Ru=function(t){const e=i(this,ni);let s=0,n=e.length-1;for(;s<=n;){const r=s+n>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:n=r-1}return n+1},Iy=function([,t,e]){const s=b(this,$e,Ru).call(this,t);i(this,ni).splice(s,0,[t,e])},Ly=function([,t,e]){const s=b(this,$e,Ru).call(this,t);for(let n=s;n<i(this,ni).length;n++){const[r,a]=i(this,ni)[n];if(r!==t)break;if(r===t&&a===e){i(this,ni).splice(n,1);return}}for(let n=s-1;n>=0;n--){const[r,a]=i(this,ni)[n];if(r!==t)break;if(r===t&&a===e){i(this,ni).splice(n,1);return}}},fg=function(t){const[e,s,n]=t,r=[[e,s,n]],a=b(this,$e,Ru).call(this,n);for(let o=0;o<a;o++){const[l,h]=i(this,ni)[o];for(let c=0,d=r.length;c<d;c++){const[,f,g]=r[c];if(!(h<=f||g<=l)){if(f>=l){if(g>h)r[c][1]=h;else{if(d===1)return[];r.splice(c,1),c--,d--}continue}r[c][2]=l,g>h&&r.push([e,h,g])}}}return r};var Id,nh;class mw extends N{constructor(e,s,n,r){super();m(this,Id);m(this,nh);u(this,nh,e),u(this,Id,s),this.firstPoint=n,this.lastPoint=r}toSVGPath(){const e=[];for(const s of i(this,nh)){let[n,r]=s;e.push(`M${n} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===n?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),n=o)}e.push("Z")}return e.join(" ")}serialize([e,s,n,r],a){const o=[],l=n-e,h=r-s;for(const c of i(this,nh)){const d=new Array(c.length);for(let f=0;f<c.length;f+=2)d[f]=e+c[f]*l,d[f+1]=r-c[f+1]*h;o.push(d)}return o}get box(){return i(this,Id)}}Id=new WeakMap,nh=new WeakMap;class pg extends tf{newFreeDrawOutline(t,e,s,n,r,a){return new bw(t,e,s,n,r,a)}}class bw extends My{newOutliner(t,e,s,n,r,a=0){return new pg(t,e,s,n,r,a)}}var rh,Ld,En,go,Rd,qe,Fd,Od,mo,ms,bs,me,ah,oh,ke,lh,Bs,Nd,Y,gg,Fu,Ry,Fy,Oy,mg,Kr,$s,zo,Ny,Ou,Nu,By,Hy,Uy,Gy,$y;const nt=class nt extends ot{constructor(e){super({...e,name:"highlightEditor"});m(this,Y);m(this,rh,null);m(this,Ld,0);m(this,En);m(this,go,null);m(this,Rd,null);m(this,qe,null);m(this,Fd,null);m(this,Od,0);m(this,mo,null);m(this,ms,null);m(this,bs,null);m(this,me,!1);m(this,ah,null);m(this,oh,null);m(this,ke,null);m(this,lh,"");m(this,Bs);m(this,Nd,"");this.color=e.color||nt._defaultColor,u(this,Bs,e.thickness||nt._defaultThickness),this.opacity=e.opacity||nt._defaultOpacity,u(this,En,e.boxes||null),u(this,Nd,e.methodOfCreation||""),u(this,lh,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(u(this,me,!0),b(this,Y,Fu).call(this,e),b(this,Y,Kr).call(this)):i(this,En)&&(u(this,rh,e.anchorNode),u(this,Ld,e.anchorOffset),u(this,Fd,e.focusNode),u(this,Od,e.focusOffset),b(this,Y,gg).call(this),b(this,Y,Kr).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(ot._l10nAlert.highlight)}static get _keyboardManager(){const e=nt.prototype;return $(this,"_keyboardManager",new Io([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:i(this,me)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:i(this,Bs),methodOfCreation:i(this,Nd)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("
55color").size}}static initialize(e,s){var n;ot.initialize(e,s),nt._defaultColor||(nt._defaultColor=((n=s.highlightColors)==null?void 0:n.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case X.HIGHLIGHT_COLOR:nt._defaultColor=s;break;case X.HIGHLIGHT_THICKNESS:nt._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return i(this,oh)}get commentButtonPosition(){return i(this,ah)}updateParams(e,s){switch(e){case X.HIGHLIGHT_COLOR:b(this,Y,Ry).call(this,s);break;case X.HIGHLIGHT_THICKNESS:b(this,Y,Fy).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[X.HIGHLIGHT_COLOR,nt._defaultColor],[X.HIGHLIGHT_THICKNESS,nt._defaultThickness]]}get propertiesToUpdate(){return[[X.HIGHLIGHT_COLOR,this.color||nt._defaultColor],[X.HIGHLIGHT_THICKNESS,i(this,Bs)||nt._defaultThickness],[X.HIGHLIGHT_FREE,i(this,me)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(i(this,bs),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=i(this,Rd))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",u(this,Rd,new Qu({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(b(this,Y,Nu).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,Y,Nu).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){b(this,Y,mg).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,Y,Kr).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let s=!1;this.parent&&!e?b(this,Y,mg).call(this):e&&(b(this,Y,Kr).call(this,e),s=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let n;i(this,me)?(e=(e-this.rotation+360)%360,n=b(r=nt,$s,zo).call(r,i(this,ms).box,e)):n=b(a=nt,$s,zo).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(i(this,bs),{bbox:n,root:{"data-main-rotation":e}}),s.updateProperties(i(this,ke),{bbox:b(o=nt,$s,zo).call(o,i(this,qe).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();i(this,lh)&&(e.setAttribute("aria-label",i(this,lh)),e.setAttribute("role","mark")),i(this,me)?e.classList.add("free"):this.div.addEventListener("keydown",b(this,Y,Ny).bind(this),{signal:this._uiManager._signal});const s=u(this,mo,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=i(this,go),this.setDims(),Vm(this,i(this,mo),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(i(this,ke),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(i(this,ke),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,Y,Ou).call(this,!0);break;case 1:case 3:b(this,Y,Ou).call(this,!1);break}}select(){var e;super.select(),i(this,ke)&&((e=this.parent)==null||e.drawLayer.updateProperties(i(this,ke),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),i(this,ke)&&((e=this.parent)==null||e.drawLayer.updateProperties(i(this,ke),{rootClass:{selected:!1}}),i(this,me)||b(this,Y,Ou).call(this,!1))}get _mustFixPosition(){return!i(this,me)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(i(this,bs),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(i(this,ke),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:n,x:r,y:a}){const{x:o,y:l,width:h,height:c}=n.getBoundingClientRect(),d=new AbortController,f=e.combinedSignal(d),g=y=>
55{d.abort(),b(this,$s,Gy).call(this,e,y)};window.addEventListener("blur",g,{signal:f}),window.addEventListener("pointerup",g,{signal:f}),window.addEventListener("pointerdown",Lt,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",js,{signal:f}),n.addEventListener("pointermove",b(this,$s,Uy).bind(this,e),{signal:f}),this._freeHighlight=new pg({x:r,y:a},[o,l,h,c],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,s,n){var v,w,S,E;let r=null;if(e instanceof py){const{data:{quadPoints:x,rect:C,rotation:T,id:k,color:P,opacity:M,popupRef:L,richText:O,contentsObj:Q,creationDate:J,modificationDate:q},parent:{page:{pageNumber:Ft}}}=e;r=e={annotationType:V.HIGHLIGHT,color:Array.from(P),opacity:M,quadPoints:x,boxes:null,pageIndex:Ft-1,rect:C.slice(0),rotation:T,annotationElementId:k,id:k,deleted:!1,popupRef:L,richText:O,comment:(Q==null?void 0:Q.str)||null,creationDate:J,modificationDate:q}}else if(e instanceof Xg){const{data:{inkLists:x,rect:C,rotation:T,id:k,color:P,borderStyle:{rawWidth:M},popupRef:L,richText:O,contentsObj:Q,creationDate:J,modificationDate:q},parent:{page:{pageNumber:Ft}}}=e;r=e={annotationType:V.HIGHLIGHT,color:Array.from(P),thickness:M,inkLists:x,boxes:null,pageIndex:Ft-1,rect:C.slice(0),rotation:T,annotationElementId:k,id:k,deleted:!1,popupRef:L,richText:O,comment:(Q==null?void 0:Q.str)||null,creationDate:J,modificationDate:q}}const{color:a,quadPoints:o,inkLists:l,outlines:h,opacity:c}=e,d=await super.deserialize(e,s,n);d.color=D.makeHexColor(...a),d.opacity=c||1,l&&u(d,Bs,e.thickness),d._initialData=r,e.comment&&d.setCommentData(e);const[f,g]=d.pageDimensions,[y,A]=d.pageTranslation;if(o){const x=u(d,En,[]);for(let C=0;C<o.length;C+=8)x.push({x:(o[C]-y)/f,y:1-(o[C+1]-A)/g,width:(o[C+2]-o[C])/f,height:(o[C+1]-o[C+5])/g});b(v=d,Y,gg).call(v),b(w=d,Y,Kr).call(w),d.rotate(d.rotation)}else if(l||h){u(d,me,!0);const x=(l||h.points)[0],C={x:x[0]-y,y:g-(x[1]-A)},T=new pg(C,[0,0,f,g],1,i(d,Bs)/2,!0,.001);for(let M=0,L=x.length;M<L;M+=2)C.x=x[M]-y,C.y=g-(x[M+1]-A),T.add(C);const{id:k,clipPathId:P}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:T.toSVGPath()}},!0,!0);b(S=d,Y,Fu).call(S,{highlightOutlines:T.getOutlines(),highlightId:k,clipPathId:P}),b(E=d,Y,Kr).call(E),d.rotate(d.parentRotation)}return d}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=ot._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);return Object.assign(n,{color:s,opacity:this.opacity,thickness:i(this,Bs),quadPoints:b(this,Y,By).call(this),outlines:b(this,Y,Hy).call(this,n.rect)}),this.addComment(n),this.annotationElementId&&!b(this,Y,$y).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};rh=new WeakMap,Ld=new WeakMap,En=new WeakMap,go=new WeakMap,Rd=new WeakMap,qe=new WeakMap,Fd=new WeakMap,Od=new WeakMap,mo=new WeakMap,ms=new WeakMap,bs=new WeakMap,me=new WeakMap,ah=new WeakMap,oh=new WeakMap,ke=new WeakMap,lh=new WeakMap,Bs=new WeakMap,Nd=new WeakMap,Y=new WeakSet,gg=function(){const e=new ug(i(this,En),.001);u(this,ms,e.getOutlines()),[this.x,this.y,this.width,this.height]=i(this,ms).box;const s=new ug(i(this,En),.0025,.001,this._uiManager.direction==="ltr");u(this,qe,s.getOutlines());const{firstPoint:n}=i(this,ms);u(this,ah,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]);const{lastPoint:r}=i(this,qe);u(this,oh,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},Fu=function({highlightOutlines:e,highlightId:s,clipPathId:n}){var f,g;if(u(this,ms,e),u(this,qe,e.getNewOutline(i(this,Bs)/2+1.5,.0025)),s>=0)u(this,bs,s),u(this,go,n),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),u(this,ke,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:i(this,qe).box,path:{d:i(this,qe).toSVGPath()}},!0));else if(this.parent){const y=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(i(this,bs),{bbox:b(f=nt,$s,zo).call(f,i(this,ms).box,(y-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(i(this,ke),{bbox:b(g=nt,$s,zo).call(g,i(this,qe).box,y),path:{d:i(this,qe).toSVGPath()}})}const[a,o,l,h]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[y,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/y,this.height=h*y/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[y,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/y,this.height=h*y/A;break}}const{firstPoint:c}=e;u(this,ah,[(c[0]-a)/l,(c[1]-o)/h]);const{lastPoint:d}=i(this,qe);u(this,oh,[(d[0]-a)/l,(d[1]-o)/h])},Ry=function(e){const s=(a,o)=>{this.color=a,this.opacity=o,this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:s.bind(this,e,nt._defaultOpacity),undo:s.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:X.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},Fy=function(e){const s=i(this,Bs),n=r=>
55{u(this,Bs,r),b(this,Y,Oy).call(this,r)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:X.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Oy=function(e){i(this,me)&&(b(this,Y,Fu).call(this,{highlightOutlines:i(this,ms).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},mg=function(){i(this,bs)===null||!this.parent||(this.parent.drawLayer.remove(i(this,bs)),u(this,bs,null),this.parent.drawLayer.remove(i(this,ke)),u(this,ke,null))},Kr=function(e=this.parent){i(this,bs)===null&&({id:Et(this,bs)._,clipPathId:Et(this,go)._}=e.drawLayer.draw({bbox:i(this,ms).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:i(this,me)},path:{d:i(this,ms).toSVGPath()}},!1,!0),u(this,ke,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:i(this,me)},bbox:i(this,qe).box,path:{d:i(this,qe).toSVGPath()}},i(this,me))),i(this,mo)&&(i(this,mo).style.clipPath=i(this,go)))},$s=new WeakSet,zo=function([e,s,n,r],a){switch(a){case 90:return[1-s-r,e,r,n];case 180:return[1-e-n,1-s-r,n,r];case 270:return[s,1-e-n,r,n]}return[e,s,n,r]},Ny=function(e){nt._keyboardManager.exec(this,e)},Ou=function(e){if(!i(this,rh))return;const s=window.getSelection();e?s.setPosition(i(this,rh),i(this,Ld)):s.setPosition(i(this,Fd),i(this,Od))},Nu=function(){return i(this,me)?this.rotation:0},By=function(){if(i(this,me))return null;const[e,s]=this.pageDimensions,[n,r]=this.pageTranslation,a=i(this,En),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:d,height:f}of a){const g=h*e+n,y=(1-c)*s+r;o[l]=o[l+4]=g,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=g+d*e,o[l+5]=o[l+7]=y-f*s,l+=8}return o},Hy=function(e){return i(this,ms).serialize(e,b(this,Y,Nu).call(this))},Uy=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Gy=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},$y=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((n,r)=>n!==s[r])},m(nt,$s),_(nt,"_defaultColor",null),_(nt,"_defaultOpacity",1),_(nt,"_defaultThickness",12),_(nt,"_type","highlight"),_(nt,"_editorType",V.HIGHLIGHT),_(nt,"_freeHighlightId",-1),_(nt,"_freeHighlight",null),_(nt,"_freeHighlightClipId","");let ef=nt;var bo;class zy{constructor(){m(this,bo,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){i(this,bo)[t]=e}toSVGProperties(){const t=i(this,bo);return u(this,bo,Object.create(null)),{root:t}}reset(){u(this,bo,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){it("Not implemented")}}bo=new WeakMap;var Fe,hh,ae,yo,Ao,et,bg,yg,Ag,Vh,jy,Bu,Wh,jo;const tt=class tt extends ot{constructor(e){super(e);m(this,et);m(this,Fe,null);m(this,hh);_(this,"_colorPicker",null);_(this,"_drawId",null);u(this,hh,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(b(this,et,bg).call(this,e),b(this,et,Vh).call(this))}static _mergeSVGProperties(e,s){const n=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))n.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){it("Not implemented")}static get typesMap(){it("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,s),this._currentParent&&(i(tt,ae).updateProperty(n,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[n,r]of this.typesMap)e.push([n,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[n,r]of this.constructor.typesMap)e.push([n,s[r]]);return e}_updateProperty(e,s,n){const r=this._drawingOptions,a=r[s],o=l=>{var c;r.updateProperty(s,l);const h=i(this,Fe).updateProperty(s,l);h&&b(this,et,Wh).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,n),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,s){const n=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),a=this._drawingOptions,o=a[n],l=a[r],h=(c,d)=>{var f;a.updateProperty(n,c),a.updateProperty(r,d),i(this,Fe).updateProperty(n,c),i(this,Fe).updateProperty(r,d),(f=this.parent)==null||f.drawLayer.updateProperties(this._drawId,a.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:h.bind(this,e,s),undo:h.bind(this,o,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:X.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties(i(this,Fe).getPathResizingSVGProperties(b(this,et,Bu).call(this)),{bbox:b(this,et,jo).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties(i(this,Fe).getPathResizedSVGProperties(b(this,et,Bu).call(this)),{bbox:b(this,et,jo).call(this)}))}_onTranslating(e,s){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{bbox:b(this,et,jo).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties(i(this,Fe).getPathTranslatedSVGProperties(b(this,et,Bu).call(this),this.parentDimensions),{bbox:b(this,et,jo).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,i(this,hh)&&(u(this,hh,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){b(this,et,Ag).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,et,Vh).call(this),b(this,et,Wh).call(this,i(this,Fe).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,et,Ag).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,et,Vh).call(this,e),s=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,tt._mergeSVGProperties({bbox:b(this,et,jo).call(this)},i(this,Fe).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&b(this,et,Wh).call(this,i(this,Fe).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}
55render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const n=super.render();n.classList.add("draw");const r=document.createElement("div");return n.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),n}static createDrawerInstance(e,s,n,r,a){it("Not implemented")}static startDrawing(e,s,n,r){var v;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(xe.isInitializedAndDifferentPointerType(c))return;const{viewport:{rotation:d}}=e,{width:f,height:g}=a.getBoundingClientRect(),y=u(tt,yo,new AbortController),A=e.combinedSignal(y);if(xe.setPointer(c,h),window.addEventListener("pointerup",w=>{xe.isSamePointerIdOrRemove(w.pointerId)&&this._endDraw(w)},{signal:A}),window.addEventListener("pointercancel",w=>{xe.isSamePointerIdOrRemove(w.pointerId)&&this._currentParent.endDrawingSession()},{signal:A}),window.addEventListener("pointerdown",w=>{xe.isSamePointerType(w.pointerType)&&(xe.initializeAndAddPointerId(w.pointerId),i(tt,ae).isCancellable()&&(i(tt,ae).removeLastElement(),i(tt,ae).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:A}),window.addEventListener("contextmenu",js,{signal:A}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:A}),a.addEventListener("touchmove",w=>{xe.isSameTimeStamp(w.timeStamp)&&Lt(w)},{signal:A}),e.toggleDrawing(),(v=s._editorUndoBar)==null||v.hide(),i(tt,ae)){e.drawLayer.updateProperties(this._currentDrawId,i(tt,ae).startNew(o,l,f,g,d));return}s.updateUIForDefaultProperties(this),u(tt,ae,this.createDrawerInstance(o,l,f,g,d)),u(tt,Ao,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(i(tt,Ao).toSVGProperties(),i(tt,ae).defaultSVGProperties),!0,!1)}static _drawMove(e){if(xe.isSameTimeStamp(e.timeStamp),!i(tt,ae))return;const{offsetX:s,offsetY:n,pointerId:r}=e;if(xe.isSamePointerId(r)){if(xe.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,i(tt,ae).add(s,n)),xe.setTimeStamp(e.timeStamp),Lt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,u(tt,ae,null),u(tt,Ao,null),xe.clearTimeStamp()),i(tt,yo)&&(i(tt,yo).abort(),u(tt,yo,null),xe.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,i(tt,ae).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const n=i(tt,ae),r=this._currentDrawId,a=n.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,n.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,n.removeLastElement())},mustExec:!1,type:X.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(X.DRAW_STEP),!i(tt,ae).isEmpty()){const{pageDimensions:[n,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:i(tt,ae).getOutlines(n*a,r*a,a,this._INNER_MARGIN),drawingOptions:i(tt,Ao),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,n,r,a,o){it("Not implemented")}static async deserialize(e,s,n){var d,f;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),c=await super.deserialize(e,s,n);return c.createDrawingOptions(e),b(d=c,et,bg).call(d,{drawOutlines:h}),b(f=c,et,Vh).call(f),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,n]=this.pageTranslation,[r,a]=this.pageDimensions;return i(this,Fe).serialize([s,n,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Fe=new WeakMap,hh=new WeakMap,ae=new WeakMap,yo=new WeakMap,Ao=new WeakMap,et=new WeakSet,bg=function({drawOutlines:e,drawId:s,drawingOptions:n}){u(this,Fe,e),this._drawingOptions||(this._drawingOptions=n),this.annotationElementId||this._uiManager.a11yAlert(ot._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=b(this,et,yg).call(this,e,this.parent),b(this,et,Wh).call(this,e.box)},yg=function(e,s){const{id:n}=s.drawLayer.draw(tt._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n},Ag=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Vh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,et,yg).call(this,i(this,Fe),e)}},jy=function([e,s,n,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,n*(o/a),r*(a/o)];case 180:return[1-e,1-s,n,r];case 270:return[1-s,e,n*(o/a),r*(a/o)];default:return[e,s,n,r]}},Bu=function(){const{x:e,y:s,width:n,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,n*(a/o),r*(o/a)];case 180:return[1-e,1-s,n,r];case 270:return[s,1-e,n*(a/o),r*(o/a)];default:return[e,s,n,r]}},Wh=function(e){[this.x,this.y,this.width,this.height]=b(this,et,jy).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},jo=function(){const{x:e,y:s,width:n,height:r,rotation:a,parentRotation:o,parentDimensions:[l,h]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,n];case 2:return[1-e-n,1-s-r,n,r];case 3:return[s,1-e-n,r,n];case 4:return[e,s-n*(l/h),r*(h/l),n*(l/h)];case 5:return[1-s,e,n*(l/h),r*(h/l)];case 6:return[1-e-r*(h/l),1-s,r*(h/l),n*(l/h)];
55case 7:return[s-n*(l/h),1-e-r*(h/l),n*(l/h),r*(h/l)];case 8:return[e-n,s-r,n,r];case 9:return[1-s,e-n,r,n];case 10:return[1-e,1-s,n,r];case 11:return[s-r,1-e,r,n];case 12:return[e-r*(h/l),s,r*(h/l),n*(l/h)];case 13:return[1-s-n*(l/h),e-r*(h/l),n*(l/h),r*(h/l)];case 14:return[1-e,1-s-n*(l/h),r*(h/l),n*(l/h)];case 15:return[s,1-e,n*(l/h),r*(h/l)];default:return[e,s,n,r]}},_(tt,"_currentDrawId",-1),_(tt,"_currentParent",null),m(tt,ae,null),m(tt,yo,null),m(tt,Ao,null),_(tt,"_INNER_MARGIN",3);let sf=tt;var Di,oe,be,wo,ch,Oe,ye,Hs,vo,So,Eo,dh,Hu;class yw{constructor(t,e,s,n,r,a){m(this,dh);m(this,Di,new Float64Array(6));m(this,oe);m(this,be);m(this,wo);m(this,ch);m(this,Oe);m(this,ye,"");m(this,Hs,0);m(this,vo,new qd);m(this,So);m(this,Eo);u(this,So,s),u(this,Eo,n),u(this,wo,r),u(this,ch,a),[t,e]=b(this,dh,Hu).call(this,t,e);const o=u(this,oe,[NaN,NaN,NaN,NaN,t,e]);u(this,Oe,[t,e]),u(this,be,[{line:o,points:i(this,Oe)}]),i(this,Di).set(o,0)}updateProperty(t,e){t==="stroke-width"&&u(this,ch,e)}isEmpty(){var t;return!((t=i(this,be))!=null&&t.length)}isCancellable(){return i(this,Oe).length<=10}add(t,e){[t,e]=b(this,dh,Hu).call(this,t,e);const[s,n,r,a]=i(this,Di).subarray(2,6),o=t-r,l=e-a;return Math.hypot(i(this,So)*o,i(this,Eo)*l)<=2?null:(i(this,Oe).push(t,e),isNaN(s)?(i(this,Di).set([r,a,t,e],2),i(this,oe).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(i(this,Di)[0])&&i(this,oe).splice(6,6),i(this,Di).set([s,n,r,a,t,e],0),i(this,oe).push(...N.createBezierPoints(s,n,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(i(this,Oe).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,n,r){u(this,So,s),u(this,Eo,n),u(this,wo,r),[t,e]=b(this,dh,Hu).call(this,t,e);const a=u(this,oe,[NaN,NaN,NaN,NaN,t,e]);u(this,Oe,[t,e]);const o=i(this,be).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),i(this,be).push({line:a,points:i(this,Oe)}),i(this,Di).set(a,0),u(this,Hs,0),this.toSVGPath(),null}getLastElement(){return i(this,be).at(-1)}setLastElement(t){return i(this,be)?(i(this,be).push(t),u(this,oe,t.line),u(this,Oe,t.points),u(this,Hs,0),{path:{d:this.toSVGPath()}}):i(this,vo).setLastElement(t)}removeLastElement(){if(!i(this,be))return i(this,vo).removeLastElement();i(this,be).pop(),u(this,ye,"");for(let t=0,e=i(this,be).length;t<e;t++){const{line:s,points:n}=i(this,be)[t];u(this,oe,s),u(this,Oe,n),u(this,Hs,0),this.toSVGPath()}return{path:{d:i(this,ye)}}}toSVGPath(){const t=N.svgRound(i(this,oe)[4]),e=N.svgRound(i(this,oe)[5]);if(i(this,Oe).length===2)return u(this,ye,`${i(this,ye)} M ${t} ${e} Z`),i(this,ye);if(i(this,Oe).length<=6){const n=i(this,ye).lastIndexOf("M");u(this,ye,`${i(this,ye).slice(0,n)} M ${t} ${e}`),u(this,Hs,6)}if(i(this,Oe).length===4){const n=N.svgRound(i(this,oe)[10]),r=N.svgRound(i(this,oe)[11]);return u(this,ye,`${i(this,ye)} L ${n} ${r}`),u(this,Hs,12),i(this,ye)}const s=[];i(this,Hs)===0&&(s.push(`M ${t} ${e}`),u(this,Hs,6));for(let n=i(this,Hs),r=i(this,oe).length;n<r;n+=6){const[a,o,l,h,c,d]=i(this,oe).slice(n,n+6).map(N.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}return u(this,ye,i(this,ye)+s.join(" ")),u(this,Hs,i(this,oe).length),i(this,ye)}getOutlines(t,e,s,n){const r=i(this,be).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),i(this,vo).build(i(this,be),t,e,s,i(this,wo),i(this,ch),n),u(this,Di,null),u(this,oe,null),u(this,be,null),u(this,ye,null),i(this,vo)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Di=new WeakMap,oe=new WeakMap,be=new WeakMap,wo=new WeakMap,ch=new WeakMap,Oe=new WeakMap,ye=new WeakMap,Hs=new WeakMap,vo=new WeakMap,So=new WeakMap,Eo=new WeakMap,dh=new WeakSet,Hu=function(t,e){return N._normalizePoint(t,e,i(this,So),i(this,Eo),i(this,wo))};var Ne,Bd,Hd,ys,Ii,Li,uh,fh,xo,we,zi,Vy,Wy,Xy;class qd extends N{constructor(){super(...arguments);m(this,we);m(this,Ne);m(this,Bd,0);m(this,Hd);m(this,ys);m(this,Ii);m(this,Li);m(this,uh);m(this,fh);m(this,xo)}build(e,s,n,r,a,o,l){u(this,Ii,s),u(this,Li,n),u(this,uh,r),u(this,fh,a),u(this,xo,o),u(this,Hd,l??0),u(this,ys,e),b(this,we,Wy).call(this)}get thickness(){return i(this,xo)}setLastElement(e){return i(this,ys).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return i(this,ys).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of i(this,ys)){if(e.push(`M${N.svgRound(s[4])} ${N.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${N.svgRound(s[10])} ${N.svgRound(s[11])}`);continue}for(let n=6,r=s.length;n<r;n+=6){const[a,o,l,h,c,d]=s.subarray(n,n+6).map(N.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}}return e.join("")}serialize([e,s,n,r],a){const o=[],l=[],[h,c,d,f]=b(this,we,Vy).call(this);let g,y,A,v,w,S,E,x,C;switch(i(this,fh)){case 0:C=N._rescale,g=e,y=s+r,A=n,v=-r,w=e+h*n,S=s+(1-c-f)*r,E=e+(h+d)*n,x=s+(1-c)*r;break;case 90:C=N._rescaleAndSwap,g=e,y=s,A=n,v=r,w=e+c*n,S=s+h*r,E=e+(c+f)*n,x=s+(h+d)*r;break;case 180:C=N._rescale,g=e+n,y=s,A=-n,v=r,w=e+(1-h-d)*n,S=s+c*r,E=e+(1-h)*n,x=s+(c+f)*r;break;case 270:C=N._rescaleAndSwap,g=e+n,y=s+r,A=-n,v=-r,w=e+(1-c-f)*n,S=s+(1-h-d)*r,E=e+(1-c)*n,x=s+(1-h)*r;break}for(const{line:T,points:k}of i(this,ys))o.push(C(T,g,y,A,v,a?new Array(T.length):null)),l.push(C(k,g,y,A,v,a?new Array(k.length):null));return{lines:o,points:l,rect:[w,S,E,x]}}static deserialize(e,s,n,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const d=[];let f,g,y,A,v;switch(h){case 0:v=N._rescale,f=-e/n,g=s/r+1,y=1/n,A=-1/r;break;case 90:v=N._rescaleAndSwap,f=-s/r,g=-e/n,y=1/r,A=1/n;break;case 180:v=N._rescale,f=e/n+1,g=-s/r,y=-1/n,A=1/r;break;case 270:v=N._rescaleAndSwap,f=s/r+1,g=e/n+1,y=-1/r,A=-1/n;break}if(!o){o=[];for(const S of l){const E=S.length;if(E===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1]]));continue}if(E===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1],NaN,NaN,NaN,NaN,S[2],S[3]]));continue}const x=new Float32Array(3*(E-2));o.push(x);let[C,T,k,P]=S.subarray(0,4);x.set([NaN,NaN,NaN,NaN,C,T],0);for(let M=4;M<E;M+=2){const L=S[M],O=S[M+1];x.set(N.createBezierPoints(C,T,k,P,L,O),(M-2)*3),[C,T,k,P]=[k,P,L,O]}}}for(let S=0,E=o.length;S<E;S++)d.push({line:v(o[S].map(x=>x??NaN),f,g,y,A),points:v(l[S].map(x=>x??NaN),f,g,y,A)});const w=new this.prototype.constructor;return w.build(d,n,r,1,h,c,a),w}get box(){return i(this,Ne)}updateProperty(e,s){return e==="stroke-width"?b(this,we,Xy).call(this,s):null}updateParentDimensions([e,s],n){const[r,a]=b(this,we,zi).call(this);u(this,Ii,e),u(this,Li,s),u(this,uh,n);const[o,l]=b(this,we,zi).call(this),h=o-r,c=l-a,d=i(this,Ne);return d[0]-=h,d[1]-=c,d[2]+=2*h,d[3]+=2*c,d}updateRotation(e){return u(this,Bd,e),{path:{transform:this.rotationTransform}}}get viewBox(){return i(this,Ne).map(N.svgRound).join(" ")}get defaultProperties(){const[e,s]=i(this,Ne);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=i(this,Ne);let n=0,r=0,a=0,o=0,l=0,h=0;switch(i(this,Bd)){case 90:r=s/e,a=-e/s,l=e;break;case 180:n=-1,o=-1,l=e,h=s;break;case 270:r=-s/e,a=e/s,h=s;break;default:return""}return`matrix(${n} ${r} ${a} ${o} ${N.svgRound(l)} ${N.svgRound(h)})`}getPathResizingSVGProperties([e,s,n,r]){const[a,o]=b(this,we,zi).call(this),[l,h,c,d]=i(this,Ne);if(Math.abs(c-a)<=N.PRECISION||Math.abs(d-o)<=N.PRECISION){const v=e+n/2-(l+c/2),w=s+r/2-(h+d/2);return{path:{"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const f=(n-2*a)/(c-2*a),g=(r-2*o)/(d-2*o),y=c/n,A=d/r;return{path:{"transform-origin":`${N.svgRound(l)} ${N.svgRound(h)}`,transform:`${this.rotationTransform} scale(${y} ${A}) translate(${N.svgRound(a)} ${N.svgRound(o)}) scale(${f} ${g}) translate(${N.svgRound(-a)} ${N.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,n,r]){const[a,o]=b(this,we,zi).call(this),l=i(this,Ne),[h,c,d,f]=l;if(l[0]=e,l[1]=s,l[2]=n,l[3]=r,Math.abs(d-a)<=N.PRECISION||Math.abs(f-o)<=N.PRECISION){const w=e+n/2-(h+d/2),S=s+r/2-(c+f/2);for(const{line:E,points:x}of i(this,ys))N._translate(E,w,S,E),N._translate(x,w,S,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(n-2*a)/(d-2*a),y=(r-2*o)/(f-2*o),A=-g*(h+a)+e+a,v=-y*(c+o)+s+o;if(g!==1||y!==1||A!==0||v!==0)for(const{line:w,points:S}of i(this,ys))N._rescale(w,A,v,g,y,w),N._rescale(S,A,v,g,y,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],n){const[r,a]=n,o=i(this,Ne),l=e-o[0],h=s-o[1];if(i(this,Ii)===r&&i(this,Li)===a)for(const{line:c,points:d}of i(this,ys))N._translate(c,l,h,c),N._translate(d,l,h,d);else{const c=i(this,Ii)/r,d=i(this,Li)/a;u(this,Ii,r),u(this,Li,a);for(const{line:f,points:g}of i(this,ys))N._rescale(f,l,h,c,d,f),N._rescale(g,l,h,c,d,g);o[2]*=c,o[3]*=d}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${N.svgRound(e)} ${N.svgRound(s)}`}}}get defaultSVGProperties(){const e=i(this,Ne);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${N.svgRound(e[0])} ${N.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}Ne=new WeakMap,Bd=new WeakMap,Hd=new WeakMap,ys=new WeakMap,Ii=new WeakMap,Li=new WeakMap,uh=new WeakMap,fh=new WeakMap,xo=new WeakMap,we=new WeakSet,zi=function(e=i(this,xo)){const s=i(this,Hd)+e/2*i(this,uh);return i(this,fh)%180===0?[s/i(this,Ii),s/i(this,Li)]:[s/i(this,Li),s/i(this,Ii)]},Vy=function(){const[e,s,n,r]=i(this,Ne),[a,o]=b(this,we,zi).call(this,0);return[e+a,s+o,n-2*a,r-2*o]},Wy=function(){const e=u(this,Ne,Zr.slice());for(const{line:r}of i(this,ys)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)D.pointBoundingBox(r[l],r[l+1],e);continue}let a=r[4],o=r[5];for(let l=6,h=r.length;l<h;
55l+=6){const[c,d,f,g,y,A]=r.subarray(l,l+6);D.bezierBoundingBox(a,o,c,d,f,g,y,A,e),a=y,o=A}}const[s,n]=b(this,we,zi).call(this);e[0]=Tt(e[0]-s,0,1),e[1]=Tt(e[1]-n,0,1),e[2]=Tt(e[2]+s,0,1),e[3]=Tt(e[3]+n,0,1),e[2]-=e[0],e[3]-=e[1]},Xy=function(e){const[s,n]=b(this,we,zi).call(this);u(this,xo,e);const[r,a]=b(this,we,zi).call(this),[o,l]=[r-s,a-n],h=i(this,Ne);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class zf extends zy{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:ot._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new zf(this._viewParameters);return t.updateAll(this),t}}var _f,Yy;const Xo=class Xo extends sf{constructor(e){super({...e,name:"inkEditor"});m(this,_f);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){ot.initialize(e,s),this._defaultDrawingOptions=new zf(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return $(this,"typesMap",new Map([[X.INK_THICKNESS,"stroke-width"],[X.INK_COLOR,"stroke"],[X.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,n,r,a){return new yw(e,s,n,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,n,r,a,o){return qd.deserialize(e,s,n,r,a,o)}static async deserialize(e,s,n){let r=null;if(e instanceof Xg){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,opacity:f,borderStyle:{rawWidth:g},popupRef:y,richText:A,contentsObj:v,creationDate:w,modificationDate:S},parent:{page:{pageNumber:E}}}=e;r=e={annotationType:V.INK,color:Array.from(d),thickness:g,opacity:f,paths:{points:o},boxes:null,pageIndex:E-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:y,richText:A,comment:(v==null?void 0:v.str)||null,creationDate:w,modificationDate:S}}const a=await super.deserialize(e,s,n);return a._initialData=r,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Ju(this)),[["colorPicker",this._colorPicker]]}get colorType(){return X.INK_COLOR}get colorAndOpacityType(){return X.INK_COLOR_AND_OPACITY}get opacityType(){return X.INK_OPACITY}updateParams(e,s){if(e===X.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===X.INK_COLOR_AND_OPACITY){super.updateDefaultParams(X.INK_COLOR,s.color),super.updateDefaultParams(X.INK_OPACITY,s.opacity);return}super.updateDefaultParams(e,s)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:n}=this;s.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:n}){this._drawingOptions=Xo.getDefaultDrawingOptions({stroke:D.makeHexColor(...e),"stroke-width":s,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(e),{color:ot._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:n}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!b(this,_f,Yy).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};_f=new WeakSet,Yy=function(e){const{color:s,thickness:n,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==n||e.opacity!==r||e.pageIndex!==a},_(Xo,"_type","ink"),_(Xo,"_editorType",V.INK),_(Xo,"_defaultDrawingOptions",null);let wg=Xo;class vg extends qd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const iu=8,_h=3;var Co,lt,Sg,ri,Ky,qy,Eg,Uu,Qy,Jy,Zy,xg,Cg,tA;class Dn{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:n},r,a,o,l){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const d=200,f=c.font=`${s} ${n} ${d}px ${e}`,{actualBoundingBoxLeft:g,actualBoundingBoxRight:y,actualBoundingBoxAscent:A,actualBoundingBoxDescent:v,fontBoundingBoxAscent:w,fontBoundingBoxDescent:S,width:E}=c.measureText(t),x=1.5,C=Math.ceil(Math.max(Math.abs(g)+Math.abs(y)||0,E)*x),T=Math.ceil(Math.max(Math.abs(A)+Math.abs(v)||d,Math.abs(w)+Math.abs(S)||d)*x);h=new OffscreenCanvas(C,T),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=f,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,C,T),c.fillStyle="black",c.fillText(t,C*(x-1)/2,T*(3-x)/2);const k=b(this,lt,xg).call(this,c.getImageData(0,0,C,T).data),P=b(this,lt,Zy).call(this,k),M=b(this,lt,Cg).call(this,P),L=b(this,lt,Eg).call(this,k,C,T,M);return this.processDrawnLines({lines:{curves:L,width:C,height:T},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,n,r){const[a,o,l]=b(this,lt,tA).call(this,t),[h,c]=b(this,lt,Jy).call(this,a,o,l,Math.hypot(o,l)*i(this,Co).sigmaSFactor,i(this,C
55o).sigmaR,i(this,Co).kernelSize),d=b(this,lt,Cg).call(this,c),f=b(this,lt,Eg).call(this,h,o,l,d);return this.processDrawnLines({lines:{curves:f,width:o,height:l},pageWidth:e,pageHeight:s,rotation:n,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:n,innerMargin:r,mustSmooth:a,areContours:o}){n%180!==0&&([e,s]=[s,e]);const{curves:l,width:h,height:c}=t,d=t.thickness??0,f=[],g=Math.min(e/h,s/c),y=g/e,A=g/s,v=[];for(const{points:S}of l){const E=a?b(this,lt,Qy).call(this,S):S;if(!E)continue;v.push(E);const x=E.length,C=new Float32Array(x),T=new Float32Array(3*(x===2?2:x-2));if(f.push({line:T,points:C}),x===2){C[0]=E[0]*y,C[1]=E[1]*A,T.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[k,P,M,L]=E;k*=y,P*=A,M*=y,L*=A,C.set([k,P,M,L],0),T.set([NaN,NaN,NaN,NaN,k,P],0);for(let O=4;O<x;O+=2){const Q=C[O]=E[O]*y,J=C[O+1]=E[O+1]*A;T.set(N.createBezierPoints(k,P,M,L,Q,J),(O-2)*3),[k,P,M,L]=[M,L,Q,J]}}if(f.length===0)return null;const w=o?new vg:new qd;return w.build(f,e,s,1,n,o?0:d,r),{outline:w,newCurves:v,areContours:o,thickness:d,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:n,height:r}){let a=1/0,o=-1/0,l=0;for(const S of t){l+=S.length;for(let E=2,x=S.length;E<x;E++){const C=S[E]-S[E-2];a=Math.min(a,C),o=Math.max(o,C)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,d=iu+_h*c,f=new Uint32Array(d);let g=0;f[g++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*h.BYTES_PER_ELEMENT,f[g++]=0,f[g++]=n,f[g++]=r,f[g++]=e?0:1,f[g++]=Math.max(0,Math.floor(s??0)),f[g++]=c,f[g++]=h.BYTES_PER_ELEMENT;for(const S of t)f[g++]=S.length-2,f[g++]=S[0],f[g++]=S[1];const y=new CompressionStream("deflate-raw"),A=y.writable.getWriter();await A.ready,A.write(f);const v=h.prototype.constructor;for(const S of t){const E=new v(S.length-2);for(let x=2,C=S.length;x<C;x++)E[x-2]=S[x]-S[x-2];A.write(E)}return A.close(),(await new Response(y.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const E of s)a||(a=new Uint8Array(new Uint32Array(E.buffer,0,4)[0])),a.set(E,o),o+=E.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const c=l[2],d=l[3],f=l[4]===0,g=l[5],y=l[6],A=l[7],v=[],w=(iu+_h*y)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(A){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,w);break}o=0;for(let E=0;E<y;E++){const x=l[_h*E+iu],C=new Float32Array(x+2);v.push(C);for(let T=0;T<_h-1;T++)C[T]=l[_h*E+iu+T+1];for(let T=0;T<x;T++)C[T+2]=C[T]+S[o++]}return{areContours:f,thickness:g,outlines:v,width:c,height:d}}catch(e){return W(`decompressSignature: ${e}`),null}}}Co=new WeakMap,lt=new WeakSet,Sg=function(t,e,s,n){return s-=t,n-=e,s===0?n>0?0:4:s===1?n+6:2-n},ri=new WeakMap,Ky=function(t,e,s,n,r,a,o){const l=b(this,lt,Sg).call(this,s,n,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,d=i(this,ri)[2*c],f=i(this,ri)[2*c+1];if(t[(s+d)*e+(n+f)]!==0)return c}return-1},qy=function(t,e,s,n,r,a,o){const l=b(this,lt,Sg).call(this,s,n,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,d=i(this,ri)[2*c],f=i(this,ri)[2*c+1];if(t[(s+d)*e+(n+f)]!==0)return c}return-1},Eg=function(t,e,s,n){const r=t.length,a=new Int32Array(r);for(let c=0;c<r;c++)a[c]=t[c]<=n?1:0;for(let c=1;c<s-1;c++)a[c*e]=a[c*e+e-1]=0;for(let c=0;c<e;c++)a[c]=a[e*s-1-c]=0;let o=1,l;const h=[];for(let c=1;c<s-1;c++){l=1;for(let d=1;d<e-1;d++){const f=c*e+d,g=a[f];if(g===0)continue;let y=c,A=d;if(g===1&&a[f-1]===0)o+=1,A-=1;else if(g>=1&&a[f+1]===0)o+=1,A+=1,g>1&&(l=g);else{g!==1&&(l=Math.abs(g));continue}const v=[d,c],w=A===d+1,S={isHole:w,points:v,id:o,parent:0};h.push(S);let E;for(const O of h)if(O.id===l){E=O;break}E?E.isHole?S.parent=w?E.parent:l:S.parent=w?l:E.parent:S.parent=w?l:0;const x=b(this,lt,Ky).call(this,a,e,c,d,y,A,0);if(x===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let C=i(this,ri)[2*x],T=i(this,ri)[2*x+1];const k=c+C,P=d+T;y=k,A=P;let M=c,L=d;for(;;){const O=b(this,lt,qy).call(this,a,e,M,L,y,A,1);C=i(this,ri)[2*O],T=i(this,ri)[2*O+1];const Q=M+C,J=L+T;v.push(J,Q);const q=M*e+L;if(a[q+1]===0?a[q]=-o:a[q]===1&&(a[q]=o),Q===c&&J===d&&M===k&&L===P){a[f]!==1&&(l=Math.abs(a[f]));break}else y=M,A=L,M=Q,L=J}}}return h},Uu=function(t,e,s,n){if(s-e<=4){for(let k=e;k<s-2;k+=2)n.push(t[k],t[k+1]);return}const r=t[e],a=t[e+1],o=t[s-4]-r,l=t[s-3]-a,h=Math.hypot(o,l),c=o/h,d=l/h,f=c*a-d*r,g=l/o,y=1/h,A=Math.atan(g),v=Math.cos(A),w=Math.sin(A),S=y*(Math.abs(v)+Math.abs(w)),E=y*(1-S+S**2),x=Math.max(Math.atan(Math.abs(w+v)*E),Math.atan(Math.abs(w-v)*E));let C=0,T=e;for(let k=e+2;k<s-2;k+=2){const P=Math.abs(f-c*t[k+1]+d*t[k]);P>C&&(T=k,C=P)}C>(h*x)**2?(b(this,lt,Uu).call(this,t,e,T+2,n),b(this,lt,Uu).call(this,t,T,s,n)):n.push(r,a)},Qy=function(t){const e=[],s=t.length;return b(this,lt,Uu).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},Jy=function(t,e,s,n,r,a){const o=new Float32Array(a**2),l=-2*n**2,h=a>>1;for(let A=0;A<a;A++){const v=(A-h)**2;for(let w=0;w<a;w++)o[A*a+w]=Math.exp((v+(w-h)**2)/l)}const c=new Float32Array(256),d=-2*r**2;for(let A=0;A<256;A++)c[A]=Math.exp(A**2/d);const f=t.length,g=new Uint8Array(f),y=new Uint32Array(256);for(let A=0;A<s;A++)for(let v=0;v<e;v++){const w=A*e+v,S=t[w];let E=0,x=0;for(let T=0;T<a;T++){const k=A+T-h;if(!(k<0||k>=s))for(let P=0;P<a;P++){const M=v+P-h;if(M<0||M>=e)continue;
55const L=t[k*e+M],O=o[T*a+P]*c[Math.abs(L-S)];E+=L*O,x+=O}}const C=g[w]=Math.round(E/x);y[C]++}return[g,y]},Zy=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},xg=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let n=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const h=s[o]=t[o<<2];n=Math.max(n,h),r=Math.min(r,h)}const a=255/(n-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},Cg=function(t){let e,s=-1/0,n=-1/0;const r=t.findIndex(l=>l!==0);let a=r,o=r;for(e=r;e<256;e++){const l=t[e];l>s&&(e-a>n&&(n=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},tA=function(t){const e=t,{width:s,height:n}=t,{maxDim:r}=i(this,Co);let a=s,o=n;if(s>r||n>r){let f=s,g=n,y=Math.log2(Math.max(s,n)/r);const A=Math.floor(y);y=y===A?A-1:A;for(let w=0;w<y;w++){a=Math.ceil(f/2),o=Math.ceil(g/2);const S=new OffscreenCanvas(a,o);S.getContext("2d").drawImage(t,0,0,f,g,0,0,a,o),f=a,g=o,t!==e&&t.close(),t=S.transferToImageBitmap()}const v=Math.min(r/a,r/o);a=Math.round(a*v),o=Math.round(o*v)}const h=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,a,o),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,a,o);const c=h.getImageData(0,0,a,o).data;return[b(this,lt,xg).call(this,c),a,o]},m(Dn,lt),m(Dn,Co,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),m(Dn,ri,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class Yg extends zy{constructor(){super(),super.updateProperties({fill:ot._defaultLineColor,"stroke-width":0})}clone(){const t=new Yg;return t.updateAll(this),t}}class Kg extends zf{constructor(t){super(t),super.updateProperties({stroke:ot._defaultLineColor,"stroke-width":1})}clone(){const t=new Kg(this._viewParameters);return t.updateAll(this),t}}var _r,Ri,kr,To;const ss=class ss extends sf{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});m(this,_r,!1);m(this,Ri,null);m(this,kr,null);m(this,To,null);this._willKeepAspectRatio=!0,u(this,kr,e.signatureData||null),u(this,Ri,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){ot.initialize(e,s),this._defaultDrawingOptions=new Yg,this._defaultDrawnSignatureOptions=new Kg(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return $(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!i(this,Ri)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,s;const{_isCopy:n}=this;if(n&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(i(this,kr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=i(this,kr),{rawDims:{pageWidth:d,pageHeight:f},rotation:g}=this.parent.viewport,y=Dn.processDrawnLines({lines:r,pageWidth:d,pageHeight:f,rotation:g,innerMargin:ss._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(y,c,l,h)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:i(this,Ri)||""}));return n&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){u(this,To,e),this.addEditToolbar()}getUuid(){return i(this,To)}get description(){return i(this,Ri)}set description(e){u(this,Ri,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:n,width:r,height:a}=i(this,kr),o=Math.max(r,a),l=Dn.processDrawnLines({lines:{curves:e.map(h=>({points:h})),thickness:n,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,n,r){const{x:a,y:o}=this,{outline:l}=u(this,kr,e);u(this,_r,l instanceof vg),this.description=n;let h;i(this,_r)?h=ss.getDefaultDrawingOptions():(h=ss._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let d=s/c;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!n}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:n},rotation:r}=this.parent.viewport;return Dn.process(e,s,n,r,ss._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:n,pageHeight:r},rotation:a}=this.parent.viewport;return Dn.extractContoursFromText(e,s,n,r,a,ss._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:n},rotation:r}=this.parent.viewport;return Dn.processDrawnLines({lines:e,pageWidth:s,pageHeight:n,rotation:r,innerMargin:ss._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=ss.getDefaultDrawingOptions():(this._drawingOptions=ss._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:i(this,_r),color:[0,0,0],thickness:i(this,_r)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:n},a.uuid=i(this,To),a.isCopy=!0):a.lines=s,i(this,Ri)&&(a.accessibilityData={type:"Figure",alt:i(this,Ri)}),a}static deserializeDraw(e,s,n,r,a,o){return o.areContours?vg.deserialize(e,s,n,r,a,o):qd.deserialize(e,s,n,r,a,o)}static async deserialize(e,s,n){var a;const r=await super.deserialize(e,s,n);return u(r,_r,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",u(r,To,e.uuid),r}};_r=new WeakMap,Ri=new WeakMap,kr=new WeakMap,To=new WeakMap,_(ss,"_type","signature"),_(ss,"_editorType",V.SIGNATURE),_(ss,"_defaultDrawingOptions",null);let Tg=ss;var kt,le,Mr,xn,Pr,ph,Cn,_o,Fi,As,gh,st,Xh,Yh,Gu,$u,zu,kg,ju,eA;class _g extends ot{constructor(e){super({...e,name:"stampEditor"});m(this,st);m(this,kt,null);m(this,le,null);m(this,Mr,null);m(this,xn,null);m(this,Pr,null);m(this,ph,"");m(this,Cn,null);m(this,_o,!1);m(this,Fi,null);m(this,As,!1);m(this,gh,!1);u(this,xn,e.bitmapUrl),u(this,Pr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){ot.initialize(e,s)}static isHandlingMimeForPasting(e){return lp.includes(e)}static paste(e,s){s.pasteEditor({mode:V.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await n.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return await this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e;i(this,le)&&(u(this,kt,null),this._uiManager.imageManager.deleteId(i(this,le)),(e=i(this,Cn))==null||e.remove(),u(this,Cn,null),i(this,Fi)&&(clearTimeout(i(this,Fi)),u(this,Fi,null))),super.remove()}rebuild(){if(!this.parent){i(this,le)&&b(this,st,Gu).call(this);return}super.rebuild(),this.div!==null&&(i(this,le)&&i(this,Cn)===null&&b(this,st,Gu).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(i(this,Mr)||i(this,kt)||i(this,xn)||i(this,Pr)||i(this,le)||i(this,_o))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}
55render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),i(this,_o)||(i(this,kt)?b(this,st,$u).call(this):b(this,st,Gu).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),n&&this._uiManager.imageManager.isValidId(n)&&(u(this,le,n),r&&u(this,kt,r),u(this,_o,!1),b(this,st,$u).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;i(this,Fi)!==null&&clearTimeout(i(this,Fi)),u(this,Fi,setTimeout(()=>{u(this,Fi,null),b(this,st,kg).call(this)},200))}copyCanvas(e,s,n=!1){e||(e=224);const{width:r,height:a}=i(this,kt),o=new Hi;let l=i(this,kt),h=r,c=a,d=null;if(s){if(r>s||a>s){const k=Math.min(s/r,s/a);h=Math.floor(r*k),c=Math.floor(a*k)}d=document.createElement("canvas");const g=d.width=Math.ceil(h*o.sx),y=d.height=Math.ceil(c*o.sy);i(this,As)||(l=b(this,st,zu).call(this,g,y));const A=d.getContext("2d");A.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":kA.isDarkMode&&(v="#8f8f9d",w="#42414d");const S=15,E=S*o.sx,x=S*o.sy,C=new OffscreenCanvas(E*2,x*2),T=C.getContext("2d");T.fillStyle=v,T.fillRect(0,0,E*2,x*2),T.fillStyle=w,T.fillRect(0,0,E,x),T.fillRect(E,x,E,x),A.fillStyle=A.createPattern(C,"repeat"),A.fillRect(0,0,g,y),A.drawImage(l,0,0,l.width,l.height,0,0,g,y)}let f=null;if(n){let g,y;if(o.symmetric&&l.width<e&&l.height<e)g=l.width,y=l.height;else if(l=i(this,kt),r>e||a>e){const w=Math.min(e/r,e/a);g=Math.floor(r*w),y=Math.floor(a*w),i(this,As)||(l=b(this,st,zu).call(this,g,y))}const v=new OffscreenCanvas(g,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,g,y),f={width:g,height:y,data:v.getImageData(0,0,g,y).data}}return{canvas:d,width:h,height:c,imageData:f}}static async deserialize(e,s,n){var v;let r=null,a=!1;if(e instanceof gy){const{data:{rect:w,rotation:S,id:E,structParent:x,popupRef:C,richText:T,contentsObj:k,creationDate:P,modificationDate:M},container:L,parent:{page:{pageNumber:O}},canvas:Q}=e;let J,q;Q?(delete e.canvas,{id:J,bitmap:q}=n.imageManager.getFromCanvas(L.id,Q),Q.remove()):(a=!0,e._hasNoCanvas=!0);const Ft=((v=await s._structTree.getAriaAttributes(`${Vo}${E}`))==null?void 0:v.get("aria-label"))||"";r=e={annotationType:V.STAMP,bitmapId:J,bitmap:q,pageIndex:O-1,rect:w.slice(0),rotation:S,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:Ft},isSvg:!1,structParent:x,popupRef:C,richText:T,comment:(k==null?void 0:k.str)||null,creationDate:P,modificationDate:M}}const o=await super.deserialize(e,s,n),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:d,isSvg:f,accessibilityData:g}=e;a?(n.addMissingCanvas(e.id,o),u(o,_o,!0)):d&&n.imageManager.isValidId(d)?(u(o,le,d),h&&u(o,kt,h)):u(o,xn,c),u(o,As,f);const[y,A]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/A,g&&(o.altTextData=g),o._initialData=r,e.comment&&o.setCommentData(e),u(o,gh,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n=Object.assign(super.serialize(e),{bitmapId:i(this,le),isSvg:i(this,As)});if(this.addComment(n),e)return n.bitmapUrl=b(this,st,ju).call(this,!0),n.accessibilityData=this.serializeAltText(!0),n.isCopy=!0,n;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(n.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=b(this,st,eA).call(this,n);return l.isSame?null:(l.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1,n.id=this.annotationElementId,delete n.bitmapId,n)}if(s===null)return n;s.stamps||(s.stamps=new Map);const o=i(this,As)?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!s.stamps.has(i(this,le)))s.stamps.set(i(this,le),{area:o,serialized:n}),n.bitmap=b(this,st,ju).call(this,!1);else if(i(this,As)){const l=s.stamps.get(i(this,le));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,st,ju).call(this,!1))}return n}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}kt=new WeakMap,le=new WeakMap,Mr=new WeakMap,xn=new WeakMap,Pr=new WeakMap,ph=new WeakMap,Cn=new WeakMap,_o=new WeakMap,Fi=new WeakMap,As=new WeakMap,gh=new WeakMap,st=new WeakSet,Xh=function(e,s=!1){if(!e){this.remove();return}u(this,kt,e.bitmap),s||(u(this,le,e.id),u(this,As,e.isSvg)),e.file&&u(this,ph,e.file.name),b(this,st,$u).call(this)},Yh=function(){if(u(this,Mr,null),this._uiManager.enableWaiting(!1),!!i(this,Cn)){if
55(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&i(this,kt)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&i(this,kt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Gu=function(){if(i(this,le)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(i(this,le)).then(n=>b(this,st,Xh).call(this,n,!0)).finally(()=>b(this,st,Yh).call(this));return}if(i(this,xn)){const n=i(this,xn);u(this,xn,null),this._uiManager.enableWaiting(!0),u(this,Mr,this._uiManager.imageManager.getFromUrl(n).then(r=>b(this,st,Xh).call(this,r)).finally(()=>b(this,st,Yh).call(this)));return}if(i(this,Pr)){const n=i(this,Pr);u(this,Pr,null),this._uiManager.enableWaiting(!0),u(this,Mr,this._uiManager.imageManager.getFromFile(n).then(r=>b(this,st,Xh).call(this,r)).finally(()=>b(this,st,Yh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=lp.join(",");const s=this._uiManager._signal;u(this,Mr,new Promise(n=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),b(this,st,Xh).call(this,r)}n()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),n()},{signal:s})}).finally(()=>b(this,st,Yh).call(this))),e.click()},$u=function(){var h;const{div:e}=this;let{width:s,height:n}=i(this,kt);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,n=this.height*a;else if(s>o*r||n>o*a){const c=Math.min(o*r/s,o*a/n);s*=c,n*=c}this._uiManager.enableWaiting(!1);const l=u(this,Cn,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=n/a,this.setDims(),(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),b(this,st,kg).call(this),i(this,gh)||(this.parent.addUndoableEditor(this),u(this,gh,!0)),this._reportTelemetry({action:"inserted_image"}),i(this,ph)&&this.div.setAttribute("aria-description",i(this,ph)),this.annotationElementId||this._uiManager.a11yAlert(ot._l10nAlert.stamp)},zu=function(e,s){const{width:n,height:r}=i(this,kt);let a=n,o=r,l=i(this,kt);for(;a>2*e||o>2*s;){const h=a,c=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const d=new OffscreenCanvas(a,o);d.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=d.transferToImageBitmap()}return l},kg=function(){const[e,s]=this.parentDimensions,{width:n,height:r}=this,a=new Hi,o=Math.ceil(n*e*a.sx),l=Math.ceil(r*s*a.sy),h=i(this,Cn);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=i(this,As)?i(this,kt):b(this,st,zu).call(this,o,l),d=h.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(c,0,0,c.width,c.height,0,0,o,l)},ju=function(e){if(e){if(i(this,As)){const r=this._uiManager.imageManager.getSvgUrl(i(this,le));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=i(this,kt),s.getContext("2d").drawImage(i(this,kt),0,0),s.toDataURL()}if(i(this,As)){const[s,n]=this.pageDimensions,r=Math.round(this.width*s*Gr.PDF_TO_CSS_UNITS),a=Math.round(this.height*n*Gr.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(i(this,kt),0,0,i(this,kt).width,i(this,kt).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(i(this,kt))},eA=function(e){var o;const{pageIndex:s,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},_(_g,"_type","stamp"),_(_g,"_editorType",V.STAMP);var ko,mh,Dr,Ir,Tn,Qe,Lr,bh,yh,ai,_n,he,kn,Rr,Ah,B,Fr,At,Pg,sA,ui,Dg,Ig,Vu;const Ws=class Ws{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){m(this,At);m(this,ko);m(this,mh,!1);m(this,Dr,null);m(this,Ir,null);m(this,Tn,null);m(this,Qe,new Map);m(this,Lr,!1);m(this,bh,!1);m(this,yh,!1);m(this,ai,null);m(this,_n,null);m(this,he,null);m(this,kn,null);m(this,Rr,null);m(this,Ah,-1);m(this,B);const d=[...i(Ws,Fr).values()];if(!Ws._initialized){Ws._initialized=!0;for(const f of d)f.initialize(c,t)}
55t.registerEditorTypes(d),u(this,B,t),this.pageIndex=e,this.div=s,u(this,ko,r),u(this,Dr,a),this.viewport=h,u(this,he,l),this.drawLayer=o,this._structTree=n,i(this,B).addLayer(this)}get isEmpty(){return i(this,Qe).size===0}get isInvisible(){return this.isEmpty&&i(this,B).getMode()===V.NONE}updateToolbar(t){i(this,B).updateToolbar(t)}updateMode(t=i(this,B).getMode()){switch(b(this,At,Vu).call(this),t){case V.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case V.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case V.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===V.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of i(Ws,Fr).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=i(this,he))==null?void 0:e.div)}setEditingState(t){i(this,B).setEditingState(t)}addCommands(t){i(this,B).addCommands(t)}cleanUndoStack(t){i(this,B).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=i(this,Dr))==null||e.togglePointerEvents(t)}async enable(){var s;u(this,yh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=i(this,Rr))==null||s.abort(),u(this,Rr,null);const t=new Set;for(const n of i(this,At,Pg))n.enableEditing(),n.show(!0),n.annotationElementId&&(i(this,B).removeChangedExistingAnnotation(n),t.add(n.annotationElementId));const e=i(this,Dr);if(e)for(const n of e.getEditableAnnotations()){if(n.hide(),i(this,B).isDeletedAnnotationElement(n.data.id)||t.has(n.data.id))continue;const r=await this.deserialize(n);r&&(this.addOrRebuild(r),r.enableEditing())}u(this,yh,!1),i(this,B)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var n;if(u(this,bh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),i(this,he)&&!i(this,Rr)){u(this,Rr,new AbortController);const r=i(this,B).combinedSignal(i(this,Rr));i(this,he).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,d=i(this,Ah);if(c-d>500){u(this,Ah,c);return}u(this,Ah,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const g=document.elementsFromPoint(l,h);if(f.toggle("getElements",!1),!this.div.contains(g[0]))return;let y;const A=new RegExp(`^${Zh}[0-9]+$`);for(const w of g)if(A.test(w.id)){y=w.id;break}if(!y)return;const v=i(this,Qe).get(y);(v==null?void 0:v.annotationElementId)===null&&(Lt(a),v.dblclick(a))},{signal:r,capture:!0})}const t=i(this,Dr),e=[];if(t){const r=new Map,a=new Map;for(const o of i(this,At,Pg)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(n=this.getEditableAnnotation(o.annotationElementId))==null||n.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(i(this,B).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let h=a.get(l);if(h){h.resetAnnotationElement(o),h.show(!1),o.show();continue}h=r.get(l),h&&(i(this,B).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}b(this,At,Vu).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of i(Ws,Fr).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),u(this,bh,!1)}getEditableAnnotation(t){var e;return((e=i(this,Dr))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){i(this,B).getActive()!==t&&i(this,B).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=i(this,he))!=null&&t.div&&!i(this,kn)){u(this,kn,new AbortController);const e=i(this,B).combinedSignal(i(this,kn));i(this,he).div.addEventListener("pointerdown",b(this,At,sA).bind(this),{signal:e}),i(this,he).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=i(this,he))!=null&&t.div&&i(this,kn)&&(i(this,kn).abort(),u(this,kn,null),i(this,he).div.classList.remove("highlighting"))}enableClick(){if(i(this,Ir))return;u(this,Ir,new AbortController);const t=i(this,B).combinedSignal(i(this,Ir));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=i(this,Ir))==null||t.abort(),u(this,Ir,null)}attach(t){i(this,Qe).set(t.id,t);const{annotationElementId:e}=t;e&&i(this,B).isDeletedAnnotationElement(e)&&i(this,B).removeDeletedAnnotationElement(t)}detach(t){var e;i(this,Qe).delete(t.id),(e=i(this,ko))==null||e.removePointerInTextLayer(t.contentDiv),!i(this,bh)&&t.annotationElementId&&i(this,B).addDeletedAnnotationElement(t)}remove(t){this.detach(t),i(this,B).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(i(this,B).addDeletedAnnotationElement(t),ot.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}
55add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),i(this,B).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!i(this,yh)),i(this,B).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!i(this,Tn)&&(t._focusEventsAllowed=!1,u(this,Tn,setTimeout(()=>{u(this,Tn,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:i(this,B)._signal}),e.focus())},0))),t._structTreeParentId=(s=i(this,ko))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of i(this,Qe).values())if(e.uid===t)return e;return null}combinedSignal(t){return i(this,B).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=i(this,At,ui))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await i(this,B).updateMode(t.mode);const{offsetX:s,offsetY:n}=b(this,At,Ig).call(this),r=i(this,B).getId(),a=b(this,At,Dg).call(this,{parent:this,id:r,x:s,y:n,uiManager:i(this,B),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=i(Ws,Fr).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,i(this,B)))||null}createAndAddNewEditor(t,e,s={}){const n=i(this,B).getId(),r=b(this,At,Dg).call(this,{parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:i(this,B),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,At,Ig).call(this),!0,t)}setSelected(t){i(this,B).setSelected(t)}toggleSelected(t){i(this,B).toggleSelected(t)}unselect(t){i(this,B).unselect(t)}pointerup(t){var n;const{isMac:e}=bt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!i(this,Lr)||(u(this,Lr,!1),(n=i(this,At,ui))!=null&&n.isDrawer&&i(this,At,ui).supportMultipleDrawings))return;if(!i(this,mh)){u(this,mh,!0);return}const s=i(this,B).getMode();if(s===V.STAMP||s===V.POPUP||s===V.SIGNATURE){i(this,B).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var n;if(i(this,B).getMode()===V.HIGHLIGHT&&this.enableTextSelection(),i(this,Lr)){u(this,Lr,!1);return}const{isMac:e}=bt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(u(this,Lr,!0),(n=i(this,At,ui))!=null&&n.isDrawer){this.startDrawingSession(t);return}const s=i(this,B).getActive();u(this,mh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),i(this,ai)){i(this,At,ui).startDrawing(this,i(this,B),!1,t);return}i(this,B).setCurrentDrawingSession(this),u(this,ai,new AbortController);const e=i(this,B).combinedSignal(i(this,ai));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(u(this,_n,null),this.commitOrRemove())},{signal:e}),i(this,At,ui).startDrawing(this,i(this,B),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&u(this,_n,e);return}i(this,_n)&&setTimeout(()=>{var e;(e=i(this,_n))==null||e.focus(),u(this,_n,null)},0)}endDrawingSession(t=!1){return i(this,ai)?(i(this,B).setCurrentDrawingSession(null),i(this,ai).abort(),u(this,ai,null),u(this,_n,null),i(this,At,ui).endDrawing(t)):null}findNewParent(t,e,s){const n=i(this,B).findParent(e,s);return n===null||n===this?!1:(n.changeParent(t),!0)}commitOrRemove(){return i(this,ai)?(this.endDrawingSession(),!0):!1}onScaleChanging(){i(this,ai)&&i(this,At,ui).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=i(this,B).getActive())==null?void 0:t.parent)===this&&(i(this,B).commitOrRemove(),i(this,B).setActiveEditor(null)),i(this,Tn)&&(clearTimeout(i(this,Tn)),u(this,Tn,null));for(const s of i(this,Qe).values())(e=i(this,ko))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,i(this,Qe).clear(),i(this,B).removeLayer(this)}async render({viewport:t}){this.viewport=t,Do(this.div,t);for(const e of i(this,B).getEditors(this.pageIndex))this.add(e),e.rebuild();await i(this,B).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){i(this,B).commitOrRemove(),b(this,At,Vu).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Do(this.div,{rotation:s}),e!==s)for(const n of i(this,Qe).values())n.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return i(this,B).viewParameters.realScale}};ko=new WeakMap,mh=new WeakMap,Dr=new WeakMap,Ir=new WeakMap,Tn=new WeakMap,Qe=new WeakMap,Lr=new WeakMap,bh=new WeakMap,yh=new WeakMap,ai=new WeakMap,_n=new WeakMap,he
55=new WeakMap,kn=new WeakMap,Rr=new WeakMap,Ah=new WeakMap,B=new WeakMap,Fr=new WeakMap,At=new WeakSet,Pg=function(){return i(this,Qe).size!==0?i(this,Qe).values():i(this,B).getEditors(this.pageIndex)},sA=function(t){i(this,B).unselectAll();const{target:e}=t;if(e===i(this,he).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&i(this,he).div.contains(e)){const{isMac:s}=bt.platform;if(t.button!==0||t.ctrlKey&&s)return;i(this,B).showAllEditors("highlight",!0,!0),i(this,he).div.classList.add("free"),this.toggleDrawing(),ef.startHighlighting(this,i(this,B).direction==="ltr",{target:i(this,he).div,x:t.x,y:t.y}),i(this,he).div.addEventListener("pointerup",()=>{i(this,he).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:i(this,B)._signal}),t.preventDefault()}},ui=function(){return i(Ws,Fr).get(i(this,B).getMode())},Dg=function(t){const e=i(this,At,ui);return e?new e.prototype.constructor(t):null},Ig=function(){const{x:t,y:e,width:s,height:n}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+n),h=(r+o)/2-t,c=(a+l)/2-e,[d,f]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:f}},Vu=function(){for(const t of i(this,Qe).values())t.isEmpty()&&t.remove()},_(Ws,"_initialized",!1),m(Ws,Fr,new Map([cg,wg,_g,ef,Tg].map(t=>[t._editorType,t])));let Mg=Ws;function Aw(p,t){return p===t?0:p.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function nu(p){var t;return p?p.nodeType===Node.ELEMENT_NODE?p.closest(".textLayer"):((t=p.parentElement)==null?void 0:t.closest(".textLayer"))||null:null}function ww(p,t,e,s){if(p===e)return t<=s;const n=p.compareDocumentPosition(e);return n&Node.DOCUMENT_POSITION_FOLLOWING?!0:n&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function Lm(p,t,e){if(p.nodeType!==Node.ELEMENT_NODE||!p.classList.contains("textLayer")||t!==p.childNodes.length)return{container:p,offset:t};let s=p.lastChild;return(s==null?void 0:s.nodeType)===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}var Je,Be,Us,Ud,Gd,Mo,Po,$d,kf,Or,Nr,Br,Hr,Mn,Pe,Rg,Fg,iA,Wu,nA,Gi,Og,rA,Ng;const G=class G{constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:n=null}){m(this,Gi);m(this,Je,null);m(this,Be,new Map);m(this,Us,null);m(this,Ud,null);m(this,Gd,null);m(this,Mo,null);m(this,Po,new Map);if(this.pageIndex=s,u(this,Ud,t),u(this,Gd,e),n){const r=i(G,Mn).get(n);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),i(G,Nr).delete(r.selectionDiv)),i(G,Mn).set(n,{drawLayer:this}),i(G,Hr).add(n),u(this,Us,n),u(this,Mo,new MutationObserver(a=>{var o,l,h;if(!(!i(this,Je)||!((o=i(this,Us))!=null&&o.isConnected)||!b(l=G,Pe,Fg).call(l))){for(const{addedNodes:c}of a)for(const d of c)if(d.nodeType===Node.ELEMENT_NODE&&d.classList.contains("endOfContent")){b(h=G,Pe,Wu).call(h);return}}})),i(this,Mo).observe(n,{childList:!0}),i(G,Or)===null){u(G,Or,new AbortController);const{signal:a}=i(G,Or);document.addEventListener("selectionchange",b(G,Pe,Wu).bind(G),{signal:a}),document.addEventListener("pointerdown",()=>{u(G,Br,!0)},{signal:a}),document.addEventListener("pointerup",()=>{u(G,Br,!1)},{signal:a}),window.addEventListener("blur",()=>{u(G,Br,!1)},{signal:a})}}}setParent(t){var e,s,n;if(!i(this,Je)){u(this,Je,t),(e=i(this,Us))!=null&&e.isConnected&&b(s=G,Pe,Fg).call(s)&&b(n=G,Pe,Wu).call(n);return}if(i(this,Je)!==t){if(i(this,Be).size>0)for(const r of i(this,Be).values())r.remove(),t.append(r);u(this,Je,t)}}static get _svgFactory(){return $(this,"_svgFactory",new Zu)}draw(t,e=!1,s=!1){const n=Et(G,$d)._++,r=b(this,Gi,Og).call(this),a=G._svgFactory.createElement("defs");r.append(a);const o=G._svgFactory.createElement("path");a.append(o);const l=`path_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&i(this,Po).set(n,o);const h=s?b(this,Gi,rA).call(this,a,l):null,c=G._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),i(this,Be).set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=Et(G,$d)._++,n=b(this,Gi,Og).call(this),r=G._svgFactory.createElement("defs");n.append(r);const a=G._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const d=G._svgFactory.createElement("mask");r.append(d),l=`mask_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const f=G._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const g=G._svgFactory.createElement("use");d.append(g),g.setAttribute("href",`#${o}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const h=G._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return n.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(n,t),i(this,Be).set(s,n),s}finalizeDraw(t,e){i(this,Po).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:n,rootClass:r,path:a}=e,o=typeof t=="number"?i(this,Be).get(t):t;if(o){if(s&&b(this,Gi,Ng).call(this,o,s),n&&b(l=G,Pe,nA).call(l,o,n),r){const{classList:h}=o;for(const[c,d]of Object.entries(r))h.toggle(c,d)}if(a){const c=o.firstElementChild.firstElementChild;b(this,Gi,Ng).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=i(this,Be).get(t);s&&(i(e,Je).append(s),i(this,Be).delete(t),i(e,Be).set(t,s))}remove(t){i(this,Po).delete(t),i(this,Je)!==null&&(i(this,Be).get(t).remove(),i(this,Be).delete(t))}destroy(){var t,e,s;u(this,Je,null);for(const n of i(this,Be).values())n.remove();if(i(this,Be).clear(),i(this,Po).clear(),(t=i(this,Mo))==null||t.disconnect(),u(this,Mo,null),i(this,Us)){const n=i(G,Mn).get(i(this,Us));(n==null?void 0:n.drawLayer)===this&&(b(e=G,Pe,Rg).call(e,i(this,Us)),i(G,Mn).delete(i(this,Us)),i(G,Hr).delete(i(this,Us)),i(G,Hr).size===0&&((s=i(G,Or))==null||s.abort(),u(G,Or,null),u(G,Br,!1))),u(this,Us,null)}}};Je=new WeakMap,Be=new WeakMap,Us=new WeakMap,Ud=new WeakMap,Gd=new WeakMap,Mo=new WeakMap,Po=new WeakMap,$d=new WeakMap,kf=new WeakMap,Or=new WeakMap,Nr=new WeakMap,Br=new WeakMap,Hr=new WeakMap,Mn=new WeakMap,Pe=new WeakSet,Rg=function(t){const e=i(this,Mn).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),i(this,Nr).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},Fg=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},iA=function(){return i(this,Hr).keys().filter(t=>t.isConnected).toArray().sort(Aw)},Wu=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of i(this,Nr))o.remove();i(this,Nr).clear();return}
55const e=new WeakMap,s=b(this,Pe,iA).call(this),n=[];for(let o=0,l=t.rangeCount;o<l;o++){const h=t.getRangeAt(o);if(h.collapsed)continue;let{startContainer:c,startOffset:d,endContainer:f,endOffset:g}=h,y=nu(c),A=nu(f);const v=y===null,w=A===null;if(i(this,Br)&&v!==w)return;if(t.rangeCount===1){const{anchorNode:x,anchorOffset:C,focusNode:T,focusOffset:k}=t,P=nu(x),M=nu(T),L=ww(x,C,T,k);P&&M&&L!==null&&(L?(c=x,d=C,y=P,f=T,g=k,A=M):(c=T,d=k,y=M,f=x,g=C,A=P))}const S=s.filter(x=>h.intersectsNode(x));if(S.length===0)continue;let E=!1;if(y||(y=S[0],c=y,d=0,E=!0),A||(A=S.at(-1),f=A,g=A.childNodes.length,E=!0),f.nodeType===Node.ELEMENT_NODE){if(f.classList.contains("endOfContent")){const x=f.previousSibling;if(!x)continue;f=x,g=x.nodeType===Node.TEXT_NODE?x.textContent.length:x.childNodes.length}else if(f.classList.contains("textLayer")&&f.childNodes.length===g){const x=Lm(f,g,A);if(!x)continue;f=x.container,g=x.offset}}if(c.nodeType===Node.ELEMENT_NODE){const x=Lm(c,d,y);if(!x)continue;c=x.container,d=x.offset}if(y===A&&!E&&S.includes(y)){n.push([h,y]);continue}for(const x of S){const C=x.firstChild;if(!C)continue;const T=document.createRange();if(x===y?T.setStart(c,d):T.setStartBefore(C),x===A)T.setEnd(f,g);
55else{const k=x.lastChild;if(!k)continue;if(k.nodeType===Node.ELEMENT_NODE&&k.classList.contains("endOfContent")){const P=k.previousSibling;if(!P)continue;T.setEndAfter(P)}else T.setEndAfter(k)}T.collapsed||n.push([T,x])}}const r=new Set(n.map(o=>o[1]));for(const o of i(this,Hr))r.has(o)||b(this,Pe,Rg).call(this,o);for(const[o,l]of n){const h=i(G,Mn).get(l);if(!h)continue;let c=e.get(l);if(!c){const A=l.getBoundingClientRect();c=(v,w,S,E)=>({x:(v-A.x)/A.width,y:(w-A.y)/A.height,width:S/A.width,height:E/A.height}),e.set(l,c)}const d=[];for(let{x:A,y:v,width:w,height:S}of o.getClientRects())w===0||S===0||({x:A,y:v,width:w,height:S}=c(A,v,w,S),!(w===1&&S===1)&&d.push(`M${A} ${v} h${w} v${S} h-${w} Z`));if(d.length===0)continue;const f=h.drawLayer;let g=h.selectionDiv,y=h.path;if(!g){const A=`clip_selection_${Et(G,kf)._++}`;g=document.createElement("div"),g.className="selection",g.style.clipPath=`url(#${A})`;const v=(a=i(f,Ud))==null?void 0:a.createSelectionStyle(i(f,Gd));if(v)for(const[E,x]of Object.entries(v))g.style.setProperty(E,x);const w=G._svgFactory.create(1,1,!0);w.setAttribute("aria-hidden","true"),w.setAttribute("width","100%"),w.setAttribute("height","100%");const S=G._svgFactory.createElement("clipPath");S.setAttribute("id",A),S.setAttribute("clipPathUnits","objectBoundingBox"),y=G._svgFactory.createElement("path"),S.append(y),w.append(S),g.append(w),h.path=y,h.selectionDiv=g}!g.parentNode&&i(f,Je)&&(i(f,Je).append(g),i(this,Nr).add(g)),y.setAttribute("d",d.join(" "))}},nA=function(t,[e,s,n,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*n}%`,a.height=`${100*r}%`},Gi=new WeakSet,Og=function(){const t=G._svgFactory.create(1,1,!0);return i(this,Je).append(t),t.setAttribute("aria-hidden","true"),t},rA=function(t,e){const s=G._svgFactory.createElement("clipPath");t.append(s);const n=`clip_${e}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const r=G._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),n},Ng=function(t,e){for(const[s,n]of Object.entries(e))n===null?t.removeAttribute(s):t.setAttribute(s,n)},m(G,Pe),m(G,$d,0),m(G,kf,0),m(G,Or,null),m(G,Nr,new Set),m(G,Br,!1),m(G,Hr,new Set),m(G,Mn,new WeakMap);let Lg=G;function ru(p){return`${(p*100).toFixed(2)}%`}var wh,zd,jd,vh,Oi,Ni,Vd,Mf,aA;const Jh=class Jh{constructor(t,e,s,n){m(this,Mf);m(this,wh,[]);m(this,zd,new Map);m(this,jd,null);m(this,vh,0);m(this,Oi,0);m(this,Ni,0);u(this,vh,t),u(this,wh,e),u(this,Oi,s.rawDims.pageWidth),u(this,Ni,s.rawDims.pageHeight),u(this,jd,n)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<i(this,wh).length;e+=6){const s=b(this,Mf,aA).call(this,i(this,wh).subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{var w;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,n=i(this,zd).get(s);if(!n)return;const r=(w=i(Jh,Vd))==null?void 0:w.deref();if(r===s)return;r&&(r.width=0,r.height=0),u(Jh,Vd,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:h,height:c}=n,d=i(this,jd).call(this),f=Math.ceil(o*d.width),g=Math.ceil(l*d.height),y=Math.floor((o+h/i(this,Oi))*d.width),A=Math.floor((l+c/i(this,Ni))*d.height);s.width=y-f,s.height=A-g;const v=s.getContext("2d");v.setTransform(...a),v.translate(-f,-g),v.drawImage(d,0,0)}),t}};wh=new WeakMap,zd=new WeakMap,jd=new WeakMap,vh=new WeakMap,Oi=new WeakMap,Ni=new WeakMap,Vd=new WeakMap,Mf=new WeakSet,aA=function([t,e,s,n,r,a]){const o=Math.hypot((r-t)*i(this,Oi),(a-e)*i(this,Ni)),l=Math.hypot((s-t)*i(this,Oi),(n-e)*i(this,Ni));if(o<i(this,vh)||l<i(this,vh))return null;const h=[(r-t)*i(this,Oi)/o,(a-e)*i(this,Ni)/o,(s-t)*i(this,Oi)/l,(n-e)*i(this,Ni)/l,0,0],c=D.inverseTransform(h),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:ru(t),top:ru(e),width:ru(o/i(this,Oi)),height:ru(l/i(this,Ni)),transformOrigin:"0% 0%",transform:`matrix(${h.join(",")})`}),i(this,zd).set(d,{inverseTransform:c,width:o,height:l,x1:t,y1:e}),d},m(Jh,Vd,null);let Bg=Jh;globalThis._pdfjsTestingUtils={HighlightOutliner:ug};globalThis.pdfjsLib={AbortException:Ur,AnnotationEditorLayer:Mg,AnnotationEditorParamsType:X,AnnotationEditorType:V,AnnotationEditorUIManager:Lo,AnnotationLayer:hg,AnnotationMode:Hn,AnnotationType:Pt,applyOpacity:PA,build:Y0,ColorPicker:Qu,createValidAbsoluteUrl:Fm,CSSConstants:MA,DOMSVGFactory:Zu,DrawLayer:Lg,FeatureTest:bt,fetchData:Gg,findContrastColor:DA,getDocument:z0,getFilenameFromUrl:CA,getPdfFilenameFromUrl:TA,getRGB:Kd,getRGBA:Yd,getUuid:Nm,GlobalWorkerOptions:Pn,ImageKind:au,InvalidPDFException:np,isDataScheme:Rf,isPdfFile:zg,isValidExplicitDest:QA,makeArr:Wd,makeMap:Hg,makeObj:ap,makeSet:SA,MathClamp:Tt,noContextMenu:js,normalizeUnicode:wA,OPS:fi,OutputScale:Hi,PasswordException:ip,PasswordResponses:fA,PDFDataRangeTransport:sy,PDFDateString:Yu,PDFWorker:nc,PermissionFlag:uA,PixelsPerInch:Gr,RenderingCancelledException:$g,renderRichText:Bm,ResponseException:Xu,setLayerDimensions:Do,shadow:$,SignatureExtractor:Dn,stopEvent:Lt,SupportedImageMimeTypes:lp,TextLayer:ic,TextLayerImages:Bg,TouchManager:qu,updateUrlHash:Om,Util:D,VerbosityLevel:Pf,version:X0,XfaLayer:Ug};export{Ur as AbortException,Mg as AnnotationEditorLayer,X as AnnotationEditorParamsType,V as AnnotationEditorType,Lo as AnnotationEditorUIManager,hg as AnnotationLayer,Hn as AnnotationMode,Pt as AnnotationType,MA as CSSConstants,Qu as ColorPicker,Zu as DOMSVGFactory,Lg as DrawLayer,bt as FeatureTest,Pn as GlobalWorkerOptions,au as ImageKind,np as InvalidPDFException,Tt as MathClamp,fi as OPS,Hi as OutputScale,sy as PDFDataRangeTransport,Yu as PDFDateString,nc as PDFWorker,ip as PasswordException,fA as PasswordResponses,uA as PermissionFlag,Gr as PixelsPerInch,$g as RenderingCancelledException,Xu as ResponseException,Dn as SignatureExtractor,lp as SupportedImageMimeTypes,ic as TextLayer,Bg as TextLayerImages,qu as TouchManager,D as Util,Pf as VerbosityLevel,Ug as XfaLayer,PA as applyOpacity,Y0 as build,Fm as createValidAbsoluteUrl,Gg as fetchData,DA as findContrastColor,z0 as getDocument,CA as getFilenameFromUrl,TA as getPdfFilenameFromUrl,Kd as getRGB,Yd as getRGBA,Nm as getUuid,Rf as isDataScheme,zg as isPdfFile,QA as isValidExplicitDest,Wd as makeArr,Hg as makeMap,ap as makeObj,SA as makeSet,js as noContextMenu,wA as normalizeUnicode,Bm as renderRichText,Do as setLayerDimensions,$ as shadow,Lt as stopEvent,Om as updateUrlHash,X0 as version};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.