PageSourceSearch

https://flipperbee.com/assets/pdf-TtSH7s3_.js

js flipperbee.com collected 2026-10-06 16:58:16 UTC 483,151 bytes, 55 lines download raw bytes

1var yA=Object.defineProperty;var gm=p=>{throw TypeError(p)};var AA=(p,t,e)=>t in p?yA(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var T=(p,t,e)=>AA(p,typeof t!="symbol"?t+"":t,e),zf=(p,t,e)=>t.has(p)||gm("Cannot "+e);var n=(p,t,e)=>(zf(p,t,"read from private field"),e?e.call(p):t.get(p)),m=(p,t,e)=>t.has(p)?gm("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(p):t.set(p,e),u=(p,t,e,s)=>(zf(p,t,"write to private field"),s?s.call(p,e):t.set(p,e),e),b=(p,t,e)=>(zf(p,t,"access private method"),e);var Dt=(p,t,e,s)=>({set _(i){u(p,t,i,e)},get _(){return n(p,t,s)}});const gs=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Pn=[1/0,1/0,-1/0,-1/0],Zr=new Float32Array(Pn),Qf=[.001,0,0,.001,0,0],Ne="http://www.w3.org/2000/svg",ps={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},On={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Uo="pdfjs_internal_id_",bh="pdfjs_internal_editor_",W={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},tt={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},wA={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Jt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},su={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},It={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},Ro={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},_f={ERRORS:0,WARNINGS:1,INFOS:5},ci={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},Sh={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},vA={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Tf=_f.WARNINGS;function SA(p){Number.isInteger(p)&&(Tf=p)}function EA(){return Tf}function kf(p){Tf>=_f.INFOS&&console.info(`Info: ${p}`)}function X(p){Tf>=_f.WARNINGS&&console.warn(`Warning: ${p}`)}function et(p){throw new Error(p)}function Nt(p,t){p||et(t)}function xA(p){switch(p==null?void 0:p.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Ym(p,t=null,e=null){if(!p)return null;if(e&&typeof p=="string"){if(e.addDefaultProtocol&&p.startsWith("www.")){const i=p.match(/\./g);(i==null?void 0:i.length)>=2&&(p=`http://${p}`)}if(e.tryConvertEncoding)try{p=TA(p)}catch{}}const s=t?URL.parse(p,t):URL.parse(p);return xA(s)?s:null}function Km(p,t,e=!1){const s=URL.parse(p);return s?(s.hash=t,s.href):e&&Ym(p,"http://example.com")?p.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Jf(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 Io=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class Zf extends Io{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Vf extends Io{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class tp extends Io{constructor(t){super(t,"InvalidPDFException")}}class zu extends Io{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class CA extends Io{constructor(t){super(t,"FormatError")}}class Gr extends Io{constructor(t){super(t,"AbortException")}}function _A(p){(typeof p!="object"||(p==null?void 0:p.length)===void 0)&&et("Invalid argument for bytesToString");const t=p.length,e=8192;if(t<e)return String.fromCharCode.apply(null,p);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),a=p.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Pf(p){typeof p!="string"&&et("Invalid argument for stringToBytes");const t=p.length,e=new Uint8Array(t);for(let s=0;s<t;
1++s)e[s]=p.charCodeAt(s)&255;return e}class pt{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 Mn,iu,ep;class D{static get hexNums(){return $(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=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*i+f*a+l,t[s+c+1]=d*r+f*o+h}}static applyInverseTransform(t,e){const s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const i=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=i*c+l,A=y,v=i*f+l,w=v,S=o*d+h,E=S,x=o*g+h,C=x;if(r!==0||a!==0){const _=r*c,k=r*f,P=a*d,M=a*g;y+=P,w+=P,v+=M,A+=M,S+=_,C+=_,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],i=t[1],r=t[2],a=t[3],o=s**2+i**2,l=s*r+i*a,h=r**2+a**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])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)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,i,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,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static bezierBoundingBox(t,e,s,i,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,Mn,ep).call(this,t,s,r,o,e,i,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),h),b(this,Mn,ep).call(this,t,s,r,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),h)}}Mn=new WeakSet,iu=function(t,e,s,i,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*i,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)},ep=function(t,e,s,i,r,a,o,l,h,c,d,f){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,Mn,iu).call(this,t,e,s,i,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,Mn,iu).call(this,t,e,s,i,r,a,o,l,(-c+y)/A,f),b(this,Mn,iu).call(this,t,e,s,i,r,a,o,l,(-c-y)/A,f)},m(D,Mn);function TA(p){return decodeURIComponent(escape(p))}let jf=null,mm=null;function kA(p){return jf||(jf=/([\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,mm=new Map([["ſt","ſt"]])),p.replaceAll(jf,(t,e,s)=>e?e.normalize("NFKC"):mm.get(s))}function qm(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const p=new Uint8Array(32);return crypto.getRandomValues(p),_A(p)}function PA(p,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!p(s)&&!Number.isInteger(s)||!t(i))return!1;const a=r.length;let o=!0;switch(i.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 wh=()=>[],Yg=()=>new Map,sp=()=>Object.create(null),MA=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(p){return[...this].join(p)});function Et(p,t,e){return Math.min(Math.max(p,t),e)}class zd{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,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(i%=360,i<0&&(i+=360),i){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:i=this.offsetY,dontFlip:r=!1}={}){return new zd({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,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 qh{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;
1else if(qh.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)i(h)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const DA=/url\(|image-set\(/i,IA=/^on/i;var sc,ip;class Kg{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,i,r){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="print")break;t.addEventListener("input",o=>{i.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=>{i.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=>{i.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;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,h]of Object.entries(a))if(h!=null&&!IA.test(l)&&!(i==="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(i==="richText"){const c=this._allowedRichTextStyles;for(const[d,f]of Object.entries(h))c.has(d)&&!DA.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,i=t.xfaHtml,r=t.intent||"display",a=b(this,sc,ip).call(this,i.name,(d=i.attributes)==null?void 0:d.xmlns,r)??document.createElement("div");i.attributes&&this.setAttributes({html:a,element:i,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(i.children.length===0){if(i.value){const y=document.createTextNode(i.value);a.append(y),o&&qh.shouldBuildText(i.name)&&h.push(y)}return{textDivs:h}}const c=[[i,-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,sc,ip).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&&qh.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:i,height:r}=t.attributes.style;return new zd({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}sc=new WeakSet,ip=function(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===Ne&&this._allowedSvgElements.has(t)?document.createElementNS(Ne,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null},m(Kg,sc);const Kr=class Kr{};T(Kr,"CSS",96),T(Kr,"PDF",72),T(Kr,"PDF_TO_CSS_UNITS",Kr.CSS/Kr.PDF);let $r=Kr;async function qg(p,t="text"){if(Wh(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 i=new XMLHttpRequest;i.open("GET",p,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class Qg extends Io{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Mf(p){const t=p.length;let e=0;for(;e<t&&p[e].trim()==="";)e++;return p.substring(e,e+5).toLowerCase()==="data:"}function Jg(p){return typeof p=="string"&&/\.pdf$/i.test(p)}function LA(p){return[p]=p.split(/[#?]/,1),Jf(p)}function FA(p,t="document.pdf"){if(typeof p!="string")return t;if(Mf(p))return X('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 i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=Jf(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=Jf(s.pathname);if(r.test(a))return i(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 i(l)}if(s.hash){const{hash:o}=s;let l=-1;for(const{index:h}of o.matchAll(/\.pdf\b/gi))l=h;if(l>0){let h=l;for(;h>0&&!"/?#=".includes(o[h-1]);)h--;if(h<l)return i(o.slice(h,l+4))}}return t}var Nn;class bm{constructor(){m(this,Nn,new Map);T(this,"times",[])}time(t){n(this,Nn).has(t)&&X(`Timer is already running for ${t}`),n(this,Nn).set(t,Date.now())}timeEnd(t){n(this,Nn).has(t)||X(`Timer has not been started for ${t}`),this.times.push({name:t,start:n(this,Nn).get(t),end:Date.now()}),n(this,Nn).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("")}}Nn=new WeakMap;function Wh(p,t){const e=t?URL.parse(p,t):URL.parse(p);return/https?:/.test((e==null?void 0:e.protocol)??"")}function ii(p){p.preventDefault()}function ee(p){p.preventDefault(),p.stopPropagation()}var ic;class Vu{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,ic)||u(this,ic,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,ic).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let 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,i,r,a,o,l))}}ic=new WeakMap,m(Vu,ic);function Vd(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,i]=p.slice(4,-1).split(",").map(r=>parseInt(r,10));return[e,s,i,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 jd(p){const t=Vd(p);return t?t.slice(0,3):(X(`Not a valid color format: "${p}"`),[0,0,0])}function RA(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,jd(s))}t.remove()}function wt(p){const{a:t,b:e,c:s,d:i,e:r,f:a}=p.getTransform();return[t,e,s,i,r,a]}function ai(p){const{a:t,b:e,c:s,d:i,e:r,f:a}=p.getTransform().invertSelf();return[t,e,s,i,r,a]}function To(p,t,e=!1,s=!0){if(t instanceof zd){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=p,o=`round(down, var(--total-scale-factor) * ${i}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 ni{constructor(){const{pixelRatio:t}=ni;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let a=1/0,o=1/0,l=1/0;s=ni.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),i!==-1&&(o=i/t,l=i/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 np=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class OA{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 NA{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",jd(s))}}function BA(p,t){t=Et(t??1,0,1);const e=255*(1-t);return p.map(s=>Math.round(s*t+e))}function ym(p,t){const e=p[0]/255,s=p[1]/255,i=p[2]/255,r=Math.max(e,s,i),a=Math.min(e,s,i),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-i)/l+(s<i?6:0))*60;break;case s:t[0]=((i-e)/l+2)*60;break;case i:t[0]=((e-s)/l+4)*60;break}}t[2]=o}function rp(p,t){const e=p[0],s=p[1],i=p[2],r=(1-Math.abs(2*i-1))*s,a=r*(1-Math.abs(e/60%2-1)),o=i-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 ap(p){return p<=.03928?p/12.92:((p+.055)/1.055)**2.4}function Am(p,t,e){rp(p,e),e.map(ap);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];rp(t,e),e.map(ap);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const wm=new Map;function HA(p,t){const e=p[0]+p[1]*256+p[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=wm.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);ym(p,a);const o=i.subarray(6,9);ym(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]),Am(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===Am(a,o,r)<h?c=g:d=g}a[2]=l?d:c}return rp(a,r),s=D.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),wm.set(e,s),s}function Qm({html:p,dir:t,className:e},s){const i=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"))}i.append(r)}else Kg.render({xfaHtml:p,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function Jm(p){const t=new Path2D;if(!p)return t;for(let e=0,s=p.length;e<s;)switch(p[e++]){case Sh.moveTo:t.moveTo(p[e++],p[e++]);break;case Sh.lineTo:t.lineTo(p[e++],p[e++]);break;case Sh.curveTo:t.bezierCurveTo(p[e++],p[e++],p[e++],p[e++],p[e++],p[e++]);break;case Sh.quadraticCurveTo:t.quadraticCurveTo(p[e++],p[e++],p[e++],p[e++]);break;case Sh.closePath:t.closePath();break;default:X(`Unrecognized drawing path operator: ${p[e-1]}`);break}return t}var Bn,Hn,Es,xs,nc,Un,Vo,jo,rc,Ju,Zm,Ae,tb,eb,Oo,Ch;const zi=class zi{constructor(t){m(this,Ae);m(this,Bn,null);m(this,Hn,null);m(this,Es);m(this,xs,null);m(this,nc,null);m(this,Un,null);m(this,Vo,null);m(this,jo,null);u(this,Es,t),n(zi,rc)||u(zi,rc,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,Bn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,Es)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",ii,{signal:e}),t.addEventListener("pointerdown",b(zi,Ju,Zm),{signal:e}));const s=u(this,xs,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,Es).toolbarPosition;if(i){const{style:r}=t,a=n(this,Es)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return n(this,Bn)}hide(){var t;n(this,Bn).classList.add("hidden"),(t=n(this,Hn))==null||t.hideDropdown()}show(){var t,e;n(this,Bn).classList.remove("hidden"),(t=n(this,nc))==null||t.shown(),(e=n(this,Un))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=n(this,Es),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",n(zi,rc)[t]),b(this,Ae,Oo).call(this,s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,xs).append(s)}async addAltText(t){const e=await t.render();b(this,Ae,Oo).call(this,e),n(this,xs).append(e,n(this,Ae,Ch)),u(this,nc,t)}addComment(t,e=null){if(n(this,Un))return;const s=t.renderForToolbar();if(!s)return;b(this,Ae,Oo).call(this,s);const i=u(this,Vo,n(this,Ae,Ch));e?(n(this,xs).insertBefore(s,e),n(this,xs).insertBefore(i,e)):n(this,xs).append(s,i),u(this,Un,t),t.toolbar=this}addColorPicker(t){if(n(this,Hn))return;u(this,Hn,t);const e=t.renderButton();b(this,Ae,Oo).call(this,e),n(this,xs).append(e,n(this,Ae,Ch))}async addEditSignatureButton(t){const e=u(this,jo,await t.renderEditButton(n(this,Es)));b(this,Ae,Oo).call(this,e),n(this,xs).append(e,n(this,Ae,Ch))}removeButton(t){var e,s;switch(t){case"comment":(e=n(this,Un))==null||e.removeToolbarCommentButton(),u(this,Un,null),(s=n(this,Vo))==null||s.remove(),u(this,Vo,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 i=n(this,xs).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){n(this,jo)&&(n(this,jo).title=t)}remove(){var t;n(this,Bn).remove(),(t=n(this,Hn))==null||t.destroy(),u(this,Hn,null)}};Bn=new WeakMap,Hn=new WeakMap,Es=new WeakMap,xs=new WeakMap,nc=new WeakMap,Un=new WeakMap,Vo=new WeakMap,jo=new WeakMap,rc=new WeakMap,Ju=new WeakSet,Zm=function(t){t.stopPropagation()},Ae=new WeakSet,tb=function(t){n(this,Es)._focusEventsAllowed=!1,ee(t)},eb=function(t){n(this,Es)._focusEventsAllowed=!0,ee(t)},Oo=function(t){const e=n(this,Es)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,Ae,tb).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,Ae,eb).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ii,{signal:e}),!0)},Ch=function(){const t=document.createElement("div");return t.className="divider",t},m(zi,Ju),m(zi,rc,null);let op=zi;var ac,ta,di,In,sb,ib,lp;class UA{constructor(t){m(this,In);m(this,ac,null);m(this,ta,null);m(this,di);u(this,di,t)}show(t,e,s){const[i,r]=b(this,In,ib).call(this,e,s),{style:a}=n(this,ta)||u(this,ta,b(this,In,sb).call(this));t.append(n(this,ta)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,ta).remove()}}ac=new WeakMap,ta=new WeakMap,di=new WeakMap,In=new WeakSet,sb=function(){const t=u(this,ta,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=n(this,di).direction;const e=n(this,di)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",ii,{signal:e});const s=u(this,ac,document.createElement("div"));return s.className="buttons",t.append(s),n(this,di).hasCommentManager()&&b(this,In,lp).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,di).commentSelection("floating_button")}),b(this,In,lp).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,di).highlightSelection("floating_button")}),t},ib=function(t,e){let s=0,i=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){i=o,s=a;continue}e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},lp=function(t,e,s,i){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=n(this,di)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",ii,{signal:o}),r.addEventListener("click",i,{signal:o})),n(this,ac).append(r)};
2const GA="59968104-cc61-4cf9-b570-014b35b3709c",Wf=Object.freeze({internal:GA});function nb(p,t,e){for(const s of e)t.addEventListener(s,p[s].bind(p))}var ea,sa,Wo,ia;const ht=class ht{static initializeAndAddPointerId(t){(n(ht,sa)||u(ht,sa,new Set)).add(t)}static setPointer(t,e){n(ht,ea)||u(ht,ea,e),n(ht,ia)??u(ht,ia,t)}static setTimeStamp(t){u(ht,Wo,t)}static isSamePointerId(t){return n(ht,ea)===t}static isSamePointerIdOrRemove(t){var e;return n(ht,ea)===t?!0:((e=n(ht,sa))==null||e.delete(t),!1)}static isSamePointerType(t){return n(ht,ia)===t}static isInitializedAndDifferentPointerType(t){return n(ht,ia)!==null&&!ht.isSamePointerType(t)}static isSameTimeStamp(t){return n(ht,Wo)===t}static isUsingMultiplePointers(){var t;return((t=n(ht,sa))==null?void 0:t.size)>=1}static clearPointerType(){u(ht,ia,null)}static clearPointerIds(){u(ht,ea,NaN),u(ht,sa,null)}static clearTimeStamp(){u(ht,Wo,NaN)}};ea=new WeakMap,sa=new WeakMap,Wo=new WeakMap,ia=new WeakMap,m(ht,ea,NaN),m(ht,sa,null),m(ht,Wo,NaN),m(ht,ia,null);let Ee=ht;var Zu;class $A{constructor(){m(this,Zu,0)}get id(){return`${bh}${Dt(this,Zu)._++}`}}Zu=new WeakMap;var Xo,oc,xe,Yo,nu;const lm=class lm{constructor(){m(this,Yo);m(this,Xo,qm());m(this,oc,0);m(this,xe,null)}static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Ne}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return $(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return b(this,Yo,nu).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return b(this,Yo,nu).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,Yo,nu).call(this,t,s)}async getFromId(t){n(this,xe)||u(this,xe,new Map);const e=n(this,xe).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){n(this,xe)||u(this,xe,new Map);let s=n(this,xe).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${n(this,Xo)}_${Dt(this,oc)._++}`,refCounter:1,isSvg:!1},n(this,xe).set(t,s),n(this,xe).set(s.id,s),s}getSvgUrl(t){const e=n(this,xe).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,xe)||u(this,xe,new Map);const e=n(this,xe).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()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,Xo)}_`)}};Xo=new WeakMap,oc=new WeakMap,xe=new WeakMap,Yo=new WeakSet,nu=async function(t,e){n(this,xe)||u(this,xe,new Map);let s=n(this,xe).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,Xo)}_${Dt(this,oc)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await qg(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=lm._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(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){X(i),s=null}return n(this,xe).set(t,s),s&&n(this,xe).set(s.id,s),s};let hp=lm;var zt,Gn,lc,Lt;class zA{constructor(t=128){m(this,zt,[]);m(this,Gn,!1);m(this,lc);m(this,Lt,-1);u(this,lc,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,Gn))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,Lt)===-1){n(this,zt).length>0&&(n(this,zt).length=0),u(this,Lt,0),n(this,zt).push(l);return}if(a&&n(this,zt)[n(this,Lt)].type===r){o&&(l.undo=n(this,zt)[n(this,Lt)].undo),n(this,zt)[n(this,Lt)]=l;return}const h=n(this,Lt)+1;h===n(this,lc)?n(this,zt).splice(0,1):(u(this,Lt,h),h<n(this,zt).length&&n(this,zt).splice(h)),n(this,zt).push(l)}undo(){if(n(this,Lt)===-1)return;u(this,Gn,!0);const{undo:t,post:e}=n(this,zt)[n(this,Lt)];t(),e==null||e(),u(this,Gn,!1),u(this,Lt,n(this,Lt)-1)}redo(){if(n(this,Lt)<n(this,zt).length-1){u(this,Lt,n(this,Lt)+1),u(this,Gn,!0);const{cmd:t,post:e}=n(this,zt)[n(this,Lt)];t(),e==null||e(),u(this,Gn,!1)}}hasSomethingToUndo(){return n(this,Lt)!==-1}hasSomethingToRedo(){return n(this,Lt)<n(this,zt).length-1}cleanType(t){if(n(this,Lt)!==-1){for(let e=n(this,Lt);e>=0;e--)if(n(this,zt)[e].type!==t){n(this,zt).splice(e+1,n(this,Lt)-e),u(this,Lt,e);return}n(this,zt).length=0,u(this,Lt,-1)}}destroy(){u(this,zt,null)}}zt=new WeakMap,Gn=new WeakMap,lc=new WeakMap,Lt=new WeakMap;var yh,rb,ab;const ze=class ze{constructor(t){var s;this.callbacks=new Map;const{isMac:e}=pt.platform;for(const[i,r,a={}]of t){const o=i.some(l=>l.startsWith("mac+"));for(const l of i){let h=l;if(o){const f=l.startsWith("mac+");if(e!==f)continue;f&&(h=l.slice(4))}const[c,d]=b(s=ze,yh,rb).call(s,h);c!==null&&this.callbacks.getOrInsertComputed(c,wh).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=ze,yh,ab).call(c,e.code);
2if(d===null||d===e.key||(s=this.callbacks.get(d),!s))return}const i=(e.altKey?ze.ALT:0)|(e.ctrlKey?ze.CTRL:0)|(e.metaKey?ze.META:0)|(e.shiftKey?ze.SHIFT:0),r=s.find(d=>d.modifiers===i);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||ee(e))}};yh=new WeakSet,rb=function(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const r=i.toUpperCase(),a=ze[r];if(a){s|=a;continue}if(e!==null){X(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":i}return e===null&&X(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]},ab=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(ze,yh),T(ze,"ALT",1),T(ze,"CTRL",2),T(ze,"META",4),T(ze,"SHIFT",8);let ko=ze;const tf=class tf{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return RA(t),$(this,"_colors",t)}convert(t){const e=jd(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,a)=>r===e[a]))return tf._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?D.makeHexColor(...e):t}};T(tf,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let cp=tf;var Ko,Ze,qo,_t,Ft,Qo,Jo,Zo,Ce,tl,Cs,re,$n,zn,Vn,jn,ui,_s,na,hc,cc,el,dc,fi,Wn,sl,Xn,pi,ef,ji,il,uc,Yn,ra,nl,Kn,fc,Xt,ct,Wi,qn,Qn,pc,rl,gc,Jn,gi,Xi,mc,bc,Ts,R,ru,dp,ob,lb,_h,hb,cb,db,up,ub,fb,pb,gb,Me,Gi,mb,bb,fp,yb,Th,pp;const Go=class Go{constructor(t,e,s,i,r,a,o,l,h,c,d,f,g,y,A,v){m(this,R);m(this,Ko,new AbortController);m(this,Ze,null);m(this,qo,null);m(this,_t,new Map);m(this,Ft,new Map);m(this,Qo,null);m(this,Jo,null);m(this,Zo,null);m(this,Ce,null);m(this,tl,null);m(this,Cs,new zA);m(this,re,null);m(this,$n,null);m(this,zn,null);m(this,Vn,0);m(this,jn,new Set);m(this,ui,null);m(this,_s,null);m(this,na,new Set);T(this,"_editorUndoBar",null);m(this,hc,!1);m(this,cc,!1);m(this,el,!1);m(this,dc,null);m(this,fi,null);m(this,Wn,null);m(this,sl,null);m(this,Xn,!1);m(this,pi,null);m(this,ef,new $A);m(this,ji,!1);m(this,il,!1);m(this,uc,!1);m(this,Yn,null);m(this,ra,null);m(this,nl,null);m(this,Kn,null);m(this,fc,null);m(this,Xt,W.NONE);m(this,ct,new Set);m(this,Wi,null);m(this,qn,null);m(this,Qn,null);m(this,pc,null);m(this,rl,null);m(this,gc,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});m(this,Jn,[0,0]);m(this,gi,null);m(this,Xi,null);m(this,mc,null);m(this,bc,null);m(this,Ts,null);const w=this._signal=n(this,Ko).signal;u(this,Xi,t),u(this,mc,e),u(this,bc,s),u(this,Zo,i),u(this,re,r),u(this,qn,a),u(this,rl,l),this._eventBus=o;const S={signal:w,...Wf};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,il,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{u(this,il,!1)},{capture:!0,signal:w}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:w}),b(this,R,hb).call(this),b(this,R,gb).call(this),b(this,R,up).call(this),u(this,Ce,l.annotationStorage),u(this,dc,l.filterFactory),u(this,Qn,h),u(this,sl,c||null),u(this,hc,d),u(this,cc,f),u(this,el,g),u(this,fc,y||null),this.viewParameters={realScale:$r.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=Go.prototype,e=a=>n(a,Xi).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},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return $(this,"_keyboardManager",new ko([[["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)&&n(a,Xi).contains(o)&&!a.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,Xi).contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,i,r,a,o,l,h;(t=n(this,Ts))==null||t.resolve(),u(this,Ts,null),(e=n(this,Ko))==null||e.abort(),u(this,Ko,null),this._signal=null;for(const c of n(this,Ft).values())c.destroy();n(this,Ft).clear(),n(this,_t).clear(),n(this,na).clear(),(s=n(this,Kn))==null||s.clear(),u(this,Ze,null),n(this,ct).clear(),n(this,Cs).destroy(),(i=n(this,Zo)
2)==null||i.destroy(),(r=n(this,re))==null||r.destroy(),(a=n(this,qn))==null||a.destroy(),(o=n(this,pi))==null||o.hide(),u(this,pi,null),(l=n(this,nl))==null||l.destroy(),u(this,nl,null),u(this,qo,null),n(this,fi)&&(clearTimeout(n(this,fi)),u(this,fi,null)),n(this,gi)&&(clearTimeout(n(this,gi)),u(this,gi,null)),(h=this._editorUndoBar)==null||h.destroy(),u(this,rl,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,fc)}get useNewAltTextFlow(){return n(this,cc)}get useNewAltTextWhenAddingImage(){return n(this,el)}get hcmFilter(){return $(this,"hcmFilter",n(this,Qn)?n(this,dc).addHCMFilter(n(this,Qn).foreground,n(this,Qn).background):"none")}get direction(){return $(this,"direction",getComputedStyle(n(this,Xi)).direction)}get _highlightColors(){return $(this,"_highlightColors",n(this,sl)?new Map(n(this,sl).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=!!n(this,Qn);for(const[i,r]of t){const a=i.endsWith("_HCM");if(s&&a){e.set(i.replace("_HCM",""),r);continue}!s&&!a&&e.set(i,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,zn,t)}setMainHighlightColorPicker(t){u(this,nl,t)}editAltText(t,e=!1){var s;(s=n(this,Zo))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!n(this,re)}editComment(t,e,s,i){var r;(r=n(this,re))==null||r.showDialog(this,t,e,s,i)}selectComment(t,e){const s=n(this,Ft).get(t),i=s==null?void 0:s.getEditorByUID(e);i==null||i.toggleComment(!0,!0)}updateComment(t){var e;(e=n(this,re))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=n(this,re))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=n(this,re))==null||e.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},i=()=>{var r;(r=this._editorUndoBar)==null||r.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){var i;(i=n(this,re))==null||i.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=n(this,re))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=n(this,re))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(n(this,Ft).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=r=>{r.pageNumber===t&&(this._eventBus.off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i,Wf),await s}getSignature(t){var e;(e=n(this,qn))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,qn)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...Wf}),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,el,e);break}}onPageChanging({pageNumber:t}){u(this,Vn,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();n(this,Ft).delete(t),n(this,Vn)===t&&u(this,Vn,0)}focusMainContainer(){n(this,Xi).focus()}findParent(t,e){for(const s of n(this,Ft).values()){const{x:i,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=r&&e<=r+o)return s}return null}disableUserSelect(t=!1){n(this,mc).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,na).add(t)}removeShouldRescale(t){n(this,na).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*$r.PDF_TO_CSS_UNITS;for(const s of n(this,na))s.onScaleChanging();(e=n(this,zn))==null||e.onScaleChanging()}
2onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),c=b(this,R,ru).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;s.empty();const f=b(this,R,dp).call(this,c),g=n(this,Xt)===W.NONE,y=()=>{const A=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});g&&this.showAllEditors("highlight",!0,!0),e&&(A==null||A.editComment())};if(g){this.switchToMode(W.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(!n(this,Ce))return null;const e=`${bh}${t}`,s=n(this,Ce).getRawValue(e);return s&&n(this,Ce).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&n(this,Ce)&&!n(this,Ce).has(t.id)&&n(this,Ce).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,bc);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,n(this,Xn)&&(u(this,Xn,!1),b(this,R,_h).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,ct))if(e.div.contains(t)){u(this,ra,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,ra))return;const[t,e]=n(this,ra);u(this,ra,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,R,up).call(this),this.setEditingState(!0)}removeEditListeners(){b(this,R,ub).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,_s))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of n(this,_s))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,Ze))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,ct)){const r=i.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 n(this,_s))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){X(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const h=await i.deserialize(l);if(!h)return;r.push(h)}const a=()=>{for(const l of r)b(this,R,fp).call(this,l);b(this,R,pp).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){X(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,Xt)!==W.NONE&&!this.isEditorHandlingKeyboard&&Go._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Xn)&&(u(this,Xn,!1),b(this,R,_h).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 i of n(this,Jo).get(t)||[])i.pageIndex=e;const s=n(this,Qo).get(t);s&&(s.pageIndex=e,n(this,Ft).set(e,s),n(this,ji)?s.enable():s.disable())}startUpdatePages(){u(this,Qo,new Map(n(this,Ft))),n(this,Ft).clear();const t=u(this,Jo,new Map),e=s=>{t.getOrInsertComputed(s.pageIndex,wh).push(s)};for(const s of n(this,_t).values())e(s);for(const[s,i]of n(this,Ce))s.startsWith(bh)&&!n(this,_t).has(s)&&Number.isInteger(i==null?void 0:i.pageIndex)&&e(i)}endUpdatePages(){u(this,Qo,null),u(this,Jo,null)}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==W.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,n(this,Ce).setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;
2for(const[i,r]of n(this,Ce))r.pageIndex===s&&r.isClone&&(n(this,Ce).remove(i),e.push(t.deserialize(r).then(a=>{a&&(a.isClone=!0,t.addOrRebuild(a))})));return Promise.all(e)}setEditingState(t){t?(b(this,R,cb).call(this),b(this,R,fb).call(this),b(this,R,Me).call(this,{isEditing:n(this,Xt)!==W.NONE,isEmpty:b(this,R,Th).call(this),hasSomethingToUndo:n(this,Cs).hasSomethingToUndo(),hasSomethingToRedo:n(this,Cs).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,R,db).call(this),b(this,R,pb).call(this),b(this,R,Me).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,_s)){u(this,_s,t);for(const e of n(this,_s))b(this,R,Gi).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,ef).id}get currentLayer(){return n(this,Ft).get(n(this,Vn))}getLayer(t){return n(this,Ft).get(t)}get currentPageIndex(){return n(this,Vn)}addLayer(t){n(this,Ft).set(t.pageIndex,t),n(this,ji)?t.enable():t.disable()}removeLayer(t){n(this,Ft).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1,a=!1){var o,l,h,c,d,f;if(n(this,Xt)!==t&&!(n(this,Ts)&&(await n(this,Ts).promise,!n(this,Ts)))){if(u(this,Ts,Promise.withResolvers()),(o=n(this,zn))==null||o.commitOrRemove(),n(this,Xt)===W.POPUP&&((l=n(this,re))==null||l.hideSidebar()),(h=n(this,re))==null||h.destroyPopup(),u(this,Xt,t),t===W.NONE){this.setEditingState(!1),b(this,R,bb).call(this);for(const g of n(this,_t).values())g.hideStandaloneCommentButton();(c=this._editorUndoBar)==null||c.hide(),this.toggleComment(null),n(this,Ts).resolve();return}for(const g of n(this,_t).values())g.addStandaloneCommentButton();t===W.SIGNATURE&&await((d=n(this,qn))==null?void 0:d.loadSignatures()),s&&Ee.clearPointerType(),this.setEditingState(!0),await b(this,R,mb).call(this),this.unselectAll();for(const g of n(this,Ft).values())g.updateMode(t);if(t===W.POPUP){n(this,qo)||u(this,qo,await n(this,rl).getAnnotationsByType(new Set(n(this,_s).map(A=>A._editorType))));const g=new Set,y=[];for(const A of n(this,_t).values()){const{annotationElementId:v,hasComment:w,deleted:S}=A;v&&g.add(v),w&&!S&&y.push(A.getData())}for(const A of n(this,qo)){const{id:v,popupRef:w,contentsObj:S}=A;w&&(S!=null&&S.str)&&!g.has(v)&&!n(this,jn).has(v)&&y.push(A)}(f=n(this,re))==null||f.showSidebar(y)}if(!e){i&&this.addNewEditorFromKeyboard(),n(this,Ts).resolve();return}for(const g of n(this,_t).values())g.uid===e?(this.setSelected(g),a?g.editComment():r?g.enterInEditMode():g.focus()):g.unselect();n(this,Ts).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,Xt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,_s)){switch(t){case tt.CREATE:this.currentLayer.addNewEditor(e);return;case tt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,pc)||u(this,pc,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of n(this,ct))s.updateParams(t,e);else for(const s of n(this,_s))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,_t).values())a.editorType===t&&a.show(e);(((r=n(this,pc))==null?void 0:r.get(tt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,R,Gi).call(this,[[tt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,uc)!==t){u(this,uc,t);for(const e of n(this,Ft).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of n(this,_t).values())e.pageIndex===t&&(yield e)}getEditor(t){return n(this,_t).get(t)}addEditor(t){n(this,_t).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,fi)&&clearTimeout(n(this,fi)),u(this,fi,setTimeout(()=>{this.focusMainContainer(),u(this,fi,null)},0))),n(this,_t).delete(t.id),t.annotationElementId&&((e=n(this,Kn))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,jn).has(t.annotationElementId))&&((s=n(this,Ce))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,jn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}
2isDeletedAnnotationElement(t){return n(this,jn).has(t)}removeDeletedAnnotationElement(t){n(this,jn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,Ze)!==t&&(u(this,Ze,t),t&&b(this,R,Gi).call(this,t.propertiesToUpdate))}updateUI(t){n(this,R,yb)===t&&b(this,R,Gi).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,R,Gi).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,ct).has(t)){n(this,ct).delete(t),t.unselect(),b(this,R,Me).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,ct).add(t),t.select(),b(this,R,Gi).call(this,t.propertiesToUpdate),b(this,R,Me).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=n(this,zn))==null||e.commitOrRemove();for(const i of n(this,ct))i!==t&&i.unselect();(s=n(this,re))==null||s.destroyPopup(),n(this,ct).clear(),n(this,ct).add(t),t.select(),b(this,R,Gi).call(this,t.propertiesToUpdate),b(this,R,Me).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return n(this,ct).values().next().value}unselect(t){t.unselect(),n(this,ct).delete(t),b(this,R,Me).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,ct).size!==0}get isEnterHandled(){return n(this,ct).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,Cs).undo(),b(this,R,Me).call(this,{hasSomethingToUndo:n(this,Cs).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,R,Th).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,Cs).redo(),b(this,R,Me).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,Cs).hasSomethingToRedo(),isEmpty:b(this,R,Th).call(this)})}addCommands(t){n(this,Cs).add(t),b(this,R,Me).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,R,Th).call(this)})}cleanUndoStack(t){n(this,Cs).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]:[...n(this,ct)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(i,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},i=()=>{for(const a of e)b(this,R,fp).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,Ze))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,Ze)||this.hasSelection}selectAll(){for(const t of n(this,ct))t.commit();b(this,R,pp).call(this,n(this,_t).values())}unselectAll(){var t,e;if(!(n(this,Ze)&&(n(this,Ze).commitOrRemove(),n(this,Xt)!==W.NONE))&&!((t=n(this,zn))!=null&&t.commitOrRemove())&&((e=n(this,re))==null||e.destroyPopup(),!!this.hasSelection)){for(const s of n(this,ct))s.unselect();n(this,ct).clear(),b(this,R,Me).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,Jn)[0]+=t,n(this,Jn)[1]+=e;const[i,r]=n(this,Jn),a=[...n(this,ct)],o=1e3;n(this,gi)&&clearTimeout(n(this,gi)),u(this,gi,setTimeout(()=>{u(this,gi,null),n(this,Jn)[0]=n(this,Jn)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,_t).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,_t).has(l.id)&&(l.translateInPage(-i,-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,ui,new Map);for(const t of n(this,ct))n(this,ui).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,ui))return!1;this.disableUserSelect(!1);const t=n(this,ui);u(this,ui,null);let e=!1;for(const[{x:i,y:r,pageIndex:a},o]of t)o.newX=i,o.newY=r,o.newPageIndex=a,e||(e=i!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,r,a,o)=>{if(n(this,_t).has(i.id)){const l=n(this,Ft).get(o);l?i._setParentAndPosition(l,r,a):(i.pageIndex=o,i.x=r,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:a,newPageIndex:o}]of t)s(i,r,a,o)},undo:()=>{for(const[i,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(i,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,ui))for(const s of n(this,ui).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())||n(this,ct).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,Ze)===t}getActive(){return n(this,Ze)}getMode(){return n(this,Xt)}isEditingMode(){return n(this,Xt)!==W.NONE}get imageManager(){return $(this,"imageManager",new hp)}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:i,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(h,c,d,f)=>({x:(c-i)/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-i)/a,width:d/r,height:f/a});break;case"270":o=(h,c,d,f)=>({x:1-(c+f-i)/a,y:(h-s)/r,width:f/a,height:d/r});break;default:o=(h,c,d,f)=>({x:(h-s)/r,y:(c-i)/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}){(n(this,tl)||u(this,tl,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,tl))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,tl))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,Ce).getRawValue(e);s&&(n(this,Xt)===W.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const i=(r=n(this,Kn))==null?void 0:r.get(t);i&&(i.setCanvas(e,s),n(this,Kn).delete(t))}addMissingCanvas(t,e){(n(this,Kn)||u(this,Kn,new Map)).set(t,e)}};
2Ko=new WeakMap,Ze=new WeakMap,qo=new WeakMap,_t=new WeakMap,Ft=new WeakMap,Qo=new WeakMap,Jo=new WeakMap,Zo=new WeakMap,Ce=new WeakMap,tl=new WeakMap,Cs=new WeakMap,re=new WeakMap,$n=new WeakMap,zn=new WeakMap,Vn=new WeakMap,jn=new WeakMap,ui=new WeakMap,_s=new WeakMap,na=new WeakMap,hc=new WeakMap,cc=new WeakMap,el=new WeakMap,dc=new WeakMap,fi=new WeakMap,Wn=new WeakMap,sl=new WeakMap,Xn=new WeakMap,pi=new WeakMap,ef=new WeakMap,ji=new WeakMap,il=new WeakMap,uc=new WeakMap,Yn=new WeakMap,ra=new WeakMap,nl=new WeakMap,Kn=new WeakMap,fc=new WeakMap,Xt=new WeakMap,ct=new WeakMap,Wi=new WeakMap,qn=new WeakMap,Qn=new WeakMap,pc=new WeakMap,rl=new WeakMap,gc=new WeakMap,Jn=new WeakMap,gi=new WeakMap,Xi=new WeakMap,mc=new WeakMap,bc=new WeakMap,Ts=new WeakMap,R=new WeakSet,ru=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},dp=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,Ft).values())if(s.hasTextLayer(t))return s;return null},ob=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,R,ru).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,pi)||u(this,pi,new UA(this)),n(this,pi).show(s,i,this.direction==="ltr"))},lb=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){n(this,Wi)&&((r=n(this,pi))==null||r.hide(),u(this,Wi,null),b(this,R,Me).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,Wi))return;const i=b(this,R,ru).call(this,t).closest(".textLayer");if(!i){n(this,Wi)&&((a=n(this,pi))==null||a.hide(),u(this,Wi,null),b(this,R,Me).call(this,{hasSelectedText:!1}));return}if((o=n(this,pi))==null||o.hide(),u(this,Wi,e),b(this,R,Me).call(this,{hasSelectedText:!0}),!(n(this,Xt)!==W.HIGHLIGHT&&n(this,Xt)!==W.NONE)&&(n(this,Xt)===W.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),u(this,Xn,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,Xt)===W.HIGHLIGHT?b(this,R,dp).call(this,i):null;if(l==null||l.toggleDrawing(),n(this,il)){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,_h).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,_h).call(this,"main_toolbar")}},_h=function(t=""){n(this,Xt)===W.HIGHLIGHT?this.highlightSelection(t):n(this,hc)&&b(this,R,ob).call(this)},hb=function(){document.addEventListener("selectionchange",b(this,R,lb).bind(this),{signal:this._signal})},cb=function(){if(n(this,Wn))return;u(this,Wn,new AbortController);const t=this.combinedSignal(n(this,Wn));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},db=function(){var t;(t=n(this,Wn))==null||t.abort(),u(this,Wn,null)},up=function(){if(n(this,Yn))return;u(this,Yn,new AbortController);const t=this.combinedSignal(n(this,Yn));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},ub=function(){var t;(t=n(this,Yn))==null||t.abort(),u(this,Yn,null)},fb=function(){if(n(this,$n))return;u(this,$n,new AbortController);const t=this.combinedSignal(n(this,$n));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})},pb=function(){var t;(t=n(this,$n))==null||t.abort(),u(this,$n,null)},gb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Me=function(t){Object.entries(t).some(([s,i])=>n(this,gc)[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(n(this,gc),t)}),n(this,Xt)===W.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,R,Gi).call(this,[[tt.HIGHLIGHT_FREE,!0]]))},Gi=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},mb=async function(){if(!n(this,ji)){u(this,ji,!0);const t=[];for(const e of n(this,Ft).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,_t).values())e.enable()}},bb=function(){if(this.unselectAll(),n(this,ji)){u(this,ji,!1);for(const t of n(this,Ft).values())t.disable();for(const t of n(this,_t).values())t.disable()}},fp=function(t){const e=n(this,Ft).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},yb=function(){let t=null;for(t of n(this,ct));return t},Th=function(){if(n(this,_t).size===0)return!0;
2if(n(this,_t).size===1)for(const t of n(this,_t).values())return t.isEmpty();return!1},pp=function(t){for(const e of n(this,ct))e.unselect();n(this,ct).clear();for(const e of t)e.isEmpty()||(n(this,ct).add(e),e.select());b(this,R,Me).call(this,{hasSelectedEditor:this.hasSelection})},T(Go,"TRANSLATE_SMALL",1),T(Go,"TRANSLATE_BIG",10);let Po=Go;var ae,mi,$s,al,bi,ts,ol,yi,je,Yi,aa,Ai,Zn,si,kh,au;const De=class De{constructor(t){m(this,si);m(this,ae,null);m(this,mi,!1);m(this,$s,null);m(this,al,null);m(this,bi,null);m(this,ts,null);m(this,ol,!1);m(this,yi,null);m(this,je,null);m(this,Yi,null);m(this,aa,null);m(this,Ai,!1);u(this,je,t),u(this,Ai,t._uiManager.useNewAltTextFlow),n(De,Zn)||u(De,Zn,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){De._l10n??(De._l10n=t)}async render(){const t=u(this,$s,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=u(this,al,document.createElement("span"));t.append(e),n(this,Ai)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(De,Zn).missing),e.setAttribute("data-l10n-id",n(De,Zn)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=n(this,je)._uiManager._signal;t.addEventListener("contextmenu",ii,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,je)._uiManager.editAltText(n(this,je)),n(this,Ai)&&n(this,je)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,si,kh)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(u(this,ol,!0),i(r))},{signal:s}),await b(this,si,au).call(this),t}finish(){n(this,$s)&&(n(this,$s).focus({focusVisible:n(this,ol)}),u(this,ol,!1))}isEmpty(){return n(this,Ai)?n(this,ae)===null:!n(this,ae)&&!n(this,mi)}hasData(){return n(this,Ai)?n(this,ae)!==null||!!n(this,Yi):this.isEmpty()}get guessedText(){return n(this,Yi)}async setGuessedText(t){n(this,ae)===null&&(u(this,Yi,t),u(this,aa,await De._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,si,au).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,Ai)||n(this,ae)){(e=n(this,yi))==null||e.remove(),u(this,yi,null);return}if(!n(this,yi)){const s=u(this,yi,document.createElement("div"));s.className="noAltTextBadge",n(this,je).div.append(s)}n(this,yi).classList.toggle("hidden",!t)}serialize(t){let e=n(this,ae);return!t&&n(this,Yi)===e&&(e=n(this,aa)),{altText:e,decorative:n(this,mi),guessedText:n(this,Yi),textWithDisclaimer:n(this,aa)}}get data(){return{altText:n(this,ae),decorative:n(this,mi)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(u(this,Yi,s),u(this,aa,i)),!(n(this,ae)===t&&n(this,mi)===e)&&(r||(u(this,ae,t),u(this,mi,e)),b(this,si,au).call(this))}toggle(t=!1){n(this,$s)&&(!t&&n(this,ts)&&(clearTimeout(n(this,ts)),u(this,ts,null)),n(this,$s).disabled=!t)}shown(){n(this,je)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,si,kh)}})}destroy(){var t,e;(t=n(this,$s))==null||t.remove(),u(this,$s,null),u(this,al,null),u(this,bi,null),(e=n(this,yi))==null||e.remove(),u(this,yi,null)}};ae=new WeakMap,mi=new WeakMap,$s=new WeakMap,al=new WeakMap,bi=new WeakMap,ts=new WeakMap,ol=new WeakMap,yi=new WeakMap,je=new WeakMap,Yi=new WeakMap,aa=new WeakMap,Ai=new WeakMap,Zn=new WeakMap,si=new WeakSet,kh=function(){return n(this,ae)&&"added"||n(this,ae)===null&&this.guessedText&&"review"||"missing"},au=async function(){var i,r,a;const t=n(this,$s);if(!t)return;if(n(this,Ai)){if(t.classList.toggle("done",!!n(this,ae)),t.setAttribute("data-l10n-id",n(De,Zn)[n(this,si,kh)]),(i=n(this,al))==null||i.setAttribute("data-l10n-id",n(De,Zn)[`${n(this,si,kh)}-label`]),!n(this,ae)){(r=n(this,bi))==null||r.remove();return}}else{if(!n(this,ae)&&!n(this,mi)){t.classList.remove("done"),(a=n(this,bi))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,bi);if(!e){u(this,bi,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,je).id}`;const o=100,l=n(this,je)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,ts)),u(this,ts,null)},{once:!0}),t.addEventListener("mouseenter",()=>{u(this,ts,setTimeout(()=>{u(this,ts,null),n(this,bi).classList.add("show"),n(this,je)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;n(this,ts)&&(clearTimeout(n(this,ts)),u(this,ts,null)),(h=n(this,bi))==null||h.classList.remove("show")},{signal:l})}n(this,mi)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,ae)),e.parentNode||t.append(e);const s=n(this,je).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},m(De,Zn,null),T(De,"_l10n",null);let ju=De;var ue,ks,oa,At,yc,tr,Ps,er,sr,la,Ac,gp;class Xd{constructor(t){m(this,Ac);m(this,ue,null);m(this,ks,null);m(this,oa,!1);m(this,At,null);m(this,yc,null);m(this,tr,null);m(this,Ps,null);m(this,er,null);m(this,sr,!1);m(this,la,null);u(this,At,t)}renderForToolbar(){const t=u(this,ks,document.createElement("button"));
2return t.className="comment",b(this,Ac,gp).call(this,t,!1)}renderForStandalone(){const t=u(this,ue,document.createElement("button"));t.className="annotationCommentButton";const e=n(this,At).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(n(this,At)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=n(this,At).commentButtonColor;i&&(s.backgroundColor=i)}return b(this,Ac,gp).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=n(this,ue)??n(this,ks))==null||t.focus()},0)}onUpdatedColor(){if(!n(this,ue))return;const t=n(this,At).commentButtonColor;t&&(n(this,ue).style.backgroundColor=t),n(this,At)._uiManager.updatePopupColor(n(this,At))}get commentButtonWidth(){var t;return(((t=n(this,ue))==null?void 0:t.getBoundingClientRect().width)??0)/n(this,At).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,la))return n(this,la);if(!n(this,ue))return null;const{x:t,y:e,height:s}=n(this,ue).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,At).parent.boundingClientRect;return[(t-i)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){u(this,la,t)}hasDefaultPopupPosition(){return n(this,la)===null}removeStandaloneCommentButton(){var t;(t=n(this,ue))==null||t.remove(),u(this,ue,null)}removeToolbarCommentButton(){var t;(t=n(this,ks))==null||t.remove(),u(this,ks,null)}setCommentButtonStates({selected:t,hasPopup:e}){n(this,ue)&&(n(this,ue).classList.toggle("selected",t),n(this,ue).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=n(this,At).commentButtonPosition;const{width:c,height:d,x:f,y:g}=n(this,At);s=f+s*c,i=g+i*d}const r=n(this,At).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;n(this,At)._uiManager.editComment(n(this,At),a+s*l,o+i*h,{...t,parentDimensions:r})}finish(){n(this,ks)&&(n(this,ks).focus({focusVisible:n(this,oa)}),u(this,oa,!1))}isDeleted(){return n(this,sr)||n(this,Ps)===""}isEmpty(){return n(this,Ps)===null}hasBeenEdited(){return this.isDeleted()||n(this,Ps)!==n(this,yc)}serialize(){return this.data}get data(){return{text:n(this,Ps),richText:n(this,tr),date:n(this,er),deleted:this.isDeleted()}}set data(t){if(t!==n(this,Ps)&&u(this,tr,null),t===null){u(this,Ps,""),u(this,sr,!0);return}u(this,Ps,t),u(this,er,new Date),u(this,sr,!1)}restoreData({text:t,richText:e,date:s}){u(this,Ps,t),u(this,tr,e),u(this,er,s),u(this,sr,!1)}setInitialText(t,e=null){u(this,yc,t),this.data=t,u(this,er,null),u(this,tr,e)}shown(){}destroy(){var t,e;(t=n(this,ks))==null||t.remove(),u(this,ks,null),(e=n(this,ue))==null||e.remove(),u(this,ue,null),u(this,Ps,""),u(this,tr,null),u(this,er,null),u(this,At,null),u(this,oa,!1),u(this,sr,!1)}}ue=new WeakMap,ks=new WeakMap,oa=new WeakMap,At=new WeakMap,yc=new WeakMap,tr=new WeakMap,Ps=new WeakMap,er=new WeakMap,sr=new WeakMap,la=new WeakMap,Ac=new WeakSet,gp=function(t,e){if(!n(this,At)._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=[n(this,At)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=n(this,At)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",ii,{signal:s}),e&&(t.addEventListener("focusin",r=>{n(this,At)._focusEventsAllowed=!1,ee(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{n(this,At)._focusEventsAllowed=!0,ee(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===n(this,ks)?this.edit():n(this,At).toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(u(this,oa,!0),i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{n(this,At).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{n(this,At).toggleComment(!1,!1)},{signal:s}),t};function vm(p){p.preventDefault()}const Sm=1e-4;function Xf(p){return p.cancelable?(ee(p),!0):(p.stopPropagation(),!1)}var ll,ir,wc,vc,Sc,Ec,xc,ha,nr,Ki,ca,wi,qi,da,Qi,rr,Mt,wb,mp,bp,yp,ou,vb,Sb,Ap;
2class Ab{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,onPanning:o=null,signal:l}){m(this,Mt);m(this,ll);m(this,ir,!1);m(this,wc,null);m(this,vc);m(this,Sc);m(this,Ec);m(this,xc);m(this,ha);m(this,nr,!1);m(this,Ki,null);m(this,ca);m(this,wi,new Set);m(this,qi,null);m(this,da);m(this,Qi,null);m(this,rr,0);u(this,ll,t),u(this,wc,s),u(this,vc,e),u(this,Sc,i),u(this,Ec,r),u(this,xc,a),u(this,ha,o),u(this,da,new AbortController),u(this,ca,AbortSignal.any([l,n(this,da).signal])),t.addEventListener("touchstart",b(this,Mt,wb).bind(this),{passive:!1,signal:n(this,ca)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/ni.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/ni.pixelRatio}destroy(){var t,e;b(this,Mt,Ap).call(this),n(this,wi).clear(),(t=n(this,da))==null||t.abort(),u(this,da,null),(e=n(this,Ki))==null||e.abort(),u(this,Ki,null)}}ll=new WeakMap,ir=new WeakMap,wc=new WeakMap,vc=new WeakMap,Sc=new WeakMap,Ec=new WeakMap,xc=new WeakMap,ha=new WeakMap,nr=new WeakMap,Ki=new WeakMap,ca=new WeakMap,wi=new WeakMap,qi=new WeakMap,da=new WeakMap,Qi=new WeakMap,rr=new WeakMap,Mt=new WeakSet,wb=function(t){var s,i;if((s=n(this,vc))!=null&&s.call(this))return;b(this,Mt,bp).call(this,t);const e=n(this,wi);for(const{identifier:r}of t.changedTouches)e.add(r);if(e.size===1){b(this,Mt,mp).call(this);return}if(!n(this,Qi)){u(this,Qi,new AbortController);const r=AbortSignal.any([n(this,ca),n(this,Qi).signal]),a=n(this,ll),o={signal:r,capture:!1,passive:!1};a.addEventListener("touchmove",b(this,Mt,vb).bind(this),o);const l=b(this,Mt,Sb).bind(this);a.addEventListener("touchend",l,o),a.addEventListener("touchcancel",l,o),o.capture=!0,a.addEventListener("pointerdown",ee,o),a.addEventListener("pointermove",ee,o),a.addEventListener("pointercancel",vm,o),a.addEventListener("pointerup",vm,o),(i=n(this,Sc))==null||i.call(this)}u(this,nr,Xf(t)),b(this,Mt,ou).call(this,t)},mp=function(){if(n(this,Ki))return;const t=u(this,Ki,new AbortController),e=AbortSignal.any([n(this,ca),t.signal]),s=n(this,ll),i={capture:!0,signal:e,passive:!1},r=a=>{var o;a.pointerType==="touch"&&((o=n(this,Ki))==null||o.abort(),u(this,Ki,null))};s.addEventListener("pointerdown",a=>{a.pointerType==="touch"&&(ee(a),r(a))},i),s.addEventListener("pointerup",r,i),s.addEventListener("pointercancel",r,i)},bp=function(t){const e=n(this,wi);if(e.size===0)return;const s=u(this,wi,new Set);for(const{identifier:i}of t.touches)e.has(i)&&s.add(i)},yp=function(t){const e=n(this,wi),s=[];for(const i of t.touches)e.has(i.identifier)&&s.push(i);return s},ou=function(t){var r;const e=b(this,Mt,yp).call(this,t);if(e.length!==2||(r=n(this,wc))!=null&&r.call(this)){u(this,qi,null);return}const[s,i]=e;u(this,qi,{touch0X:s.screenX,touch0Y:s.screenY,touch1X:i.screenX,touch1Y:i.screenY,panX:(s.clientX+i.clientX)/2,panY:(s.clientY+i.clientY)/2,screenPanX:(s.screenX+i.screenX)/2,screenPanY:(s.screenY+i.screenY)/2})},vb=function(t){var F,H,xt,Ct;if(!n(this,qi))return;const e=b(this,Mt,yp).call(this,t);if(e.length!==2)return;const s=n(this,nr);if(u(this,nr,Xf(t)),!n(this,nr))return;if(!s){b(this,Mt,ou).call(this,t);return}const[i,r]=e,{screenX:a,screenY:o}=i,{screenX:l,screenY:h}=r,c=n(this,qi),{touch0X:d,touch0Y:f,touch1X:g,touch1Y:y,panX:A,panY:v}=c,w=g-d,S=y-f,E=l-a,x=h-o,C=(i.clientX+r.clientX)/2,_=(i.clientY+r.clientY)/2;c.panX=C,c.panY=_;const k=C-A,P=_-v,M=(a+l)/2,L=(o+h)/2,N=Math.hypot(M-c.screenPanX,L-c.screenPanY);c.screenPanX=M,c.screenPanY=L;const Z=Math.hypot(E,x),q=Math.hypot(w,S),J=n(this,ir)?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*N;if(Z<Sm||q<Sm||Math.abs(q-Z)<=J){(k||P)&&((F=n(this,ha))==null||F.call(this,k,P));return}c.touch0X=a,c.touch0Y=o,c.touch1X=l,c.touch1Y=h;const $t=Math.sign(Z-q);if(!n(this,ir)){u(this,ir,!0),u(this,rr,$t),(k||P)&&((H=n(this,ha))==null||H.call(this,k,P));return}if(n(this,rr)){const Pe=n(this,rr);if(u(this,rr,0),$t!==Pe&&Math.abs(Z-q)<=2*N){u(this,ir,!1),(k||P)&&((xt=n(this,ha))==null||xt.call(this,k,P));return}}(Ct=n(this,Ec))==null||Ct.call(this,[A,v],q,Z,k,P)},Sb=function(t){if(b(this,Mt,bp).call(this,t),n(this,wi).size>=2){b(this,Mt,ou).call(this,t);return}const e=!!n(this,qi);b(this,Mt,Ap).call(this),n(this,wi).size===1&&b(this,Mt,mp).call(this),e&&Xf(t)},Ap=function(){var t;u(this,qi,null),u(this,ir,!1),u(this,rr,0),u(this,nr,!1),n(this,Qi)&&(n(this,Qi).abort(),u(this,Qi,null),(t=n(this,xc))==null||t.call(this))};var ua,zs,Tt,at,Ji,hl,ar,Cc,fe,fa,Zi,Ms,or,_c,pa,es,Tc,ga,tn,vi,cl,dl,Ds,lr,kc,sf,z,wp,Pc,vp,lu,Eb,xb,Sp,hu,Ep,Cb,_b,Tb,xp,kb,Cp,_p,Pb,Mb,Db,Tp,Ph;const j=class j{constructor(t){m(this,z);m(this,ua,null);m(this,zs,null);m(this,Tt,null);m(this,at,null);m(this,Ji,null);m(this,hl,!1);m(this,ar,null);m(this,Cc,"");m(this,fe,null);m(this,fa,null);m(this,Zi,null);m(this,Ms,null);m(this,or,null);m(this,_c,"");m(this,pa,!1);m(this,es,null);m(this,Tc,!1);m(this,ga,!1);m(this,tn,!1);m(this,vi,null);m(this,cl,0);m(this,dl,0);m(this,Ds,null);m(this,lr,null);T(this,"isSelected",!1);T(this,"_isCopy",!1);T(this,"_editToolbar",null);T(this,"_initialOptions",Object.create(null));T(this,"_initialData",null);T(this,"_isVisible",!0);T(this,"_uiManager",null);T(this,"_focusEventsAllowed",!0);m(this,kc,!1);m(this,sf,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:i,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],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=Po.TRANSLATE_SMALL,s=Po.TRANSLATE_BIG;return $(this,"_resizerKeyboardManager",new ko([[["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 VA({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){et("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,kc)}set _isDraggable(t){var e;u(this,kc,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=n(this,sf)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(b(this,z,Ph).call(this),(e=n(this,Ms))==null||e.remove(),u(this,Ms,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(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,i){const[r,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){b(this,z,wp).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,es)||u(this,es,[this.x,this.y,this.width,this.height]),b(this,z,wp).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,es)||u(this,es,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,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)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,es)&&(n(this,es)[0]!==this.x||n(this,es)[1]!==this.y)}get _hasBeenResized(){return!!n(this,es)&&(n(this,es)[2]!==this.width||n(this,es)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=j,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=i,r*=s,a*=i,this._mustFixPosition)switch(t){case 0:r=Et(r,0,s-o),a=Et(a,0,i-l);break;case 90:r=Et(r,0,s-l),a=Et(a,o,i);break;case 180:r=Et(r,o,s),a=Et(a,l,i);break;case 270:r=Et(r,l,s),a=Et(a,0,i-o);break}this.x=r/=s,this.y=a/=i;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,Pc,vp).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=j,Pc,vp).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=n(this,Tt))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,ga))return this._editToolbar;this._editToolbar=new op(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=n(this,Tt))==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 n(this,Tt)||(ju.initialize(j._l10n),u(this,Tt,new ju(this)),n(this,ua)&&(n(this,Tt).data=n(this,ua),u(this,ua,null))),n(this,Tt)}get altTextData(){var t;return(t=n(this,Tt))==null?void 0:t.data}set altTextData(t){n(this,Tt)&&(n(this,Tt).data=t)}get guessedAltText(){var t;return(t=n(this,Tt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,Tt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,Tt))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,Tt)&&!n(this,Tt).isEmpty()}hasAltTextData(){var t;return((t=n(this,Tt))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=n(this,at))==null||t.focusButton()}addCommentButton(){return this.canAddComment?n(this,at)||u(this,at,new Xd(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(n(this,Ji)){this._uiManager.isEditingMode()&&n(this,Ji).classList.remove("hidden");return}this.hasComment&&(u(this,Ji,n(this,at).renderForStandalone()),this.div.append(n(this,Ji)))}}removeStandaloneCommentButton(){n(this,at).removeStandaloneCommentButton(),u(this,Ji,null)}hideStandaloneCommentButton(){var t;(t=n(this,Ji))==null||t.classList.add("hidden")}get comment(){if(!n(this,at))return null;const{data:{richText:t,text:e,date:s,deleted:i}}=n(this,at);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){n(this,at)||u(this,at,new Xd(this)),typeof t=="object"&&t!==null?n(this,at).restoreData(t):n(this,at).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||(n(this,at)||u(this,at,new Xd(this)),n(this,at).setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){var t;return(t=n(this,at))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=n(this,at))==null?void 0:t.isDeleted()}get hasComment(){return!!n(this,at)&&!n(this,at).isEmpty()&&!n(this,at).isDeleted()}async editComment(t){n(this,at)||u(this,at,new Xd(this)),n(this,at).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){n(this,at).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=i-100,h=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,h,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){n(this,at).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=n(this,hl)?-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,Cp).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),nb(this,t,["keydown","pointerdown","dblclick"]),b(this,z,_p).call(this),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=pt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(u(this,pa,!0),this._isDraggable){b(this,z,kb).call(this,t);return}b(this,z,xp).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,vi)&&clearTimeout(n(this,vi)),u(this,vi,setTimeout(()=>{var t;u(this,vi,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 i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/i,c=e/i,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,i,r,a]=t,o=r-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[r,e-i,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=n(this,at))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,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:i}}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 n(this,ga)}shouldGetKeyboardEvents(){return n(this,tn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&i>0&&t<r&&s>0}rebuild(){b(this,z,Cp).call(this),b(this,z,_p).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 i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,u(i,ua,t.accessibilityData),i._isCopy=t.isCopy||!1;const[r,a]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/r,i.y=l/a,i.width=h/r,i.height=c/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e,s;if((t=n(this,or))==null||t.abort(),u(this,or,null),this.isEmpty()||this.commit(),(e=n(this,lr))==null||e.destroy(),u(this,lr,null),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),n(this,vi)&&(clearTimeout(n(this,vi)),u(this,vi,null)),b(this,z,Ph).call(this),this.removeEditToolbar(),n(this,Ds)){for(const i of n(this,Ds).values())clearTimeout(i);u(this,Ds,null)}this.parent=null,(s=n(this,Ms))==null||s.remove(),u(this,Ms,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,z,Eb).call(this),n(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,i,r,a]=this.getPDFRect();return[j._round(s+(r-s)*t),j._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,at).commentPopupPositionInLayer}set commentPopupPosition(t){n(this,at).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return n(this,at).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,at).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=n(this,at))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),u(this,Zi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,fe).children;if(!n(this,zs)){u(this,zs,Array.from(e));const a=b(this,z,Pb).bind(this),o=b(this,z,Mb).bind(this),l=this._uiManager._signal;for(const h of n(this,zs)){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,Db).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",j._l10nResizer[c])}}const s=n(this,zs)[0];let i=0;for(const a of e){if(a===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(n(this,zs).length/4);if(r!==i){if(r<i)for(let o=0;o<i-r;o++)n(this,fe).append(n(this,fe).firstElementChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,fe).firstElementChild.before(n(this,fe).lastElementChild);let a=0;for(const o of e){const h=n(this,zs)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",j._l10nResizer[h])}}b(this,z,Tp).call(this,0),u(this,tn,!0),n(this,fe).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,tn)&&b(this,z,Ep).call(this,n(this,_c),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,z,Ph).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 i,r;
2(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=n(this,Tt))==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,i,r;this.isSelected&&(this.isSelected=!1,(t=n(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}),(i=this._editToolbar)==null||i.hide(),(r=n(this,Tt))==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 n(this,Tc)}set isEditing(t){u(this,Tc,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){n(this,Ds)||u(this,Ds,new Map);const{action:s}=t;let i=n(this,Ds).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,Ds).delete(s),n(this,Ds).size===0&&u(this,Ds,null)},j._telemetryTimeout),n(this,Ds).set(s,i);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),u(this,hl,!1)}disable(){this.div&&(this.div.tabIndex=-1),u(this,hl,!0)}updateFakeAnnotationElement(t){if(!n(this,Ms)&&!this.deleted){u(this,Ms,t.addFakeAnnotation(this));return}if(this.deleted){n(this,Ms).remove(),u(this,Ms,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,Ms).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,zs=new WeakMap,Tt=new WeakMap,at=new WeakMap,Ji=new WeakMap,hl=new WeakMap,ar=new WeakMap,Cc=new WeakMap,fe=new WeakMap,fa=new WeakMap,Zi=new WeakMap,Ms=new WeakMap,or=new WeakMap,_c=new WeakMap,pa=new WeakMap,es=new WeakMap,Tc=new WeakMap,ga=new WeakMap,tn=new WeakMap,vi=new WeakMap,cl=new WeakMap,dl=new WeakMap,Ds=new WeakMap,lr=new WeakMap,kc=new WeakMap,sf=new WeakMap,z=new WeakSet,wp=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Pc=new WeakSet,vp=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]}},lu=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]}},Eb=function(){if(n(this,fe))return;u(this,fe,document.createElement("div")),n(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 i=document.createElement("div");n(this,fe).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,z,xb).bind(this,s),{signal:e}),i.addEventListener("contextmenu",ii,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,fe))},xb=function(t,e){var c;e.preventDefault();const{isMac:s}=pt.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=n(this,Tt))==null||c.toggle(!1);const i=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,Ep).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",ee,{passive:!1,signal:a}),window.addEventListener("contextmenu",ii,{signal:a}),u(this,Zi,{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=n(this,Tt))==null||d.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,z,hu).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},Sp=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},hu=function(){if(!n(this,Zi))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,Zi);u(this,Zi,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===i||this.addCommands({cmd:b(this,z,Sp).bind(this,r,a,o,l),undo:b(this,z,Sp).bind(this,t,e,s,i),mustExec:!0})},Ep=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=j.MIN_SIZE/s,c=j.MIN_SIZE/i,d=b(this,z,lu).call(this,this.rotation),f=(F,H)=>[d[0]*F+d[2]*H,d[1]*F+d[3]*H],g=b(this,z,lu).call(this,360-this.rotation),y=(F,H)=>[g[0]*F+g[2]*H,g[1]*F+g[3]*H];let A,v,w=!1,S=!1;switch(t){case"topLeft":w=!0,A=(F,H)=>[0,0],v=(F,H)=>[F,H];break;case"topMiddle":A=(F,H)=>[F/2,0],v=(F,H)=>[F/2,H];break;case"topRight":w=!0,A=(F,H)=>[F,0],v=(F,H)=>[0,H];break;case"middleRight":S=!0,A=(F,H)=>[F,H/2],v=(F,H)=>[0,H/2];break;case"bottomRight":w=!0,A=(F,H)=>[F,H],v=(F,H)=>[0,0];break;case"bottomMiddle":A=(F,H)=>[F/2,H],v=(F,H)=>[F/2,0];break;case"bottomLeft":w=!0,A=(F,H)=>[0,H],v=(F,H)=>[F,0];break;case"middleLeft":S=!0,A=(F,H)=>[0,H/2],v=(F,H)=>[F,H/2];break}const E=A(o,l),x=v(o,l);let C=f(...x);
2const _=j._round(r+C[0]),k=j._round(a+C[1]);let P=1,M=1,L,N;if(e.fromKeyboard)({deltaX:L,deltaY:N}=e);else{const{screenX:F,screenY:H}=e,[xt,Ct]=n(this,fa);[L,N]=this.screenToPageTranslation(F-xt,H-Ct),n(this,fa)[0]=F,n(this,fa)[1]=H}if([L,N]=y(L/s,N/i),w){const F=Math.hypot(o,l);P=M=Math.max(Math.min(Math.hypot(x[0]-E[0]-L,x[1]-E[1]-N)/F,1/o,1/l),h/o,c/l)}else S?P=Et(Math.abs(x[0]-E[0]-L),h,1)/o:M=Et(Math.abs(x[1]-E[1]-N),c,1)/l;const Z=j._round(o*P),q=j._round(l*M);C=f(...v(Z,q));const J=_-C[0],$t=k-C[1];n(this,es)||u(this,es,[this.x,this.y,this.width,this.height]),this.width=Z,this.height=q,this.x=J,this.y=$t,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Cb=function(){var t;u(this,Zi,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,Tt))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},_b=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=b(this,z,lu).call(this,this.rotation),o=(_,k)=>[a[0]*_+a[2]*k,a[1]*_+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;n(this,es)||u(this,es,[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()},Tb=function(){var t;(t=n(this,Tt))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,z,hu).call(this)},xp=function(t){const{isMac:e}=pt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},kb=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:r},o=h=>{i.abort(),u(this,ar,null),u(this,pa,!1),this._uiManager.endDragSession()||b(this,z,xp).call(this,h),s&&this._onStopDragging()};e&&(u(this,cl,t.clientX),u(this,dl,t.clientY),u(this,ar,t.pointerId),u(this,Cc,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!==n(this,ar)){ee(h);return}const[g,y]=this.screenToPageTranslation(c-n(this,cl),d-n(this,dl));u(this,cl,c),u(this,dl,d),this._uiManager.dragSelectedEditors(g,y),this.div.scrollIntoView({block:"nearest"})},a),window.addEventListener("touchmove",ee,a),window.addEventListener("pointerdown",h=>{h.pointerType===n(this,Cc)&&(n(this,lr)||h.isPrimary)&&o(h),ee(h)},a));const l=h=>{if(!n(this,ar)||n(this,ar)===h.pointerId){o(h);return}ee(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Cp=function(){if(n(this,or)||!this.div)return;u(this,or,new AbortController);const t=this._uiManager.combinedSignal(n(this,or));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},_p=function(){n(this,lr)||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||u(this,lr,new Ab({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,z,Cb).bind(this),onPinching:b(this,z,_b).bind(this),onPinchEnd:b(this,z,Tb).bind(this),signal:this._uiManager._signal}))},Pb=function(t){j._resizerKeyboardManager.exec(this,t)},Mb=function(t){var e;n(this,tn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,fe)&&b(this,z,Ph).call(this)},Db=function(t){u(this,_c,n(this,tn)?t:"")},Tp=function(t){if(n(this,zs))for(const e of n(this,zs))e.tabIndex=t},Ph=function(){u(this,tn,!1),b(this,z,Tp).call(this,-1),b(this,z,hu).call(this)},m(j,Pc),T(j,"_l10n",null),T(j,"_l10nAlert",null),T(j,"_l10nResizer",null),T(j,"_borderLineWidth",-1),T(j,"_colorManager",new cp),T(j,"_zIndex",1),T(j,"_telemetryTimeout",1e3);let mt=j;class VA extends mt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Em=3285377520,vs=4294901760,oi=65535;class kp{constructor(t){this.h1=t?t&4294967295:Em,this.h2=t?t&4294967295:Em}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 i=s>>2,r=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,h=this.h1,c=this.h2;const d=3432918353,f=461845907,g=d&oi,y=f&oi;for(let A=0;A<i;A++)A&1?(o=a[A],o=o*d&vs|o*g&oi,o=o<<15|o>>>17,o=o*f&vs|o*y&oi,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[A],l=l*d&vs|l*g&oi,l=l<<15|l>>>17,l=l*f&vs|l*y&oi,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,r){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;
2case 1:o^=e[i*4],o=o*d&vs|o*g&oi,o=o<<15|o>>>17,o=o*f&vs|o*y&oi,i&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&vs|t*36045&oi,e=e*4283543511&vs|((e<<16|t>>>16)*2950163797&vs)>>>16,t^=e>>>1,t=t*444984403&vs|t*60499&oi,e=e*3301882366&vs|((e<<16|t>>>16)*3120437893&vs)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Qh=Object.freeze({map:null,hash:"",transfer:void 0});var ma,ba,en,pe,nf,Ib;class Zg{constructor(){m(this,nf);m(this,ma,!1);m(this,ba,null);m(this,en,null);m(this,pe,new Map);T(this,"onSetModified",null);T(this,"onResetModified",null);T(this,"onAnnotationEditor",null)}getValue(t,e){const s=n(this,pe).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,pe).get(t)}remove(t){var s;const e=n(this,pe).get(t);e!==void 0&&(e instanceof mt&&n(this,en).delete(e.annotationElementId),n(this,pe).delete(t),n(this,pe).size===0&&this.resetModified(),!n(this,pe).values().some(i=>i instanceof mt)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var r;const s=n(this,pe).get(t);let i=!1;if(s!==void 0)for(const[a,o]of Object.entries(e))s[a]!==o&&(i=!0,s[a]=o);else i=!0,n(this,pe).set(t,e);i&&b(this,nf,Ib).call(this),e instanceof mt&&((n(this,en)||u(this,en,new Map)).set(e.annotationElementId,e),(r=this.onAnnotationEditor)==null||r.call(this,e.constructor._type))}has(t){return n(this,pe).has(t)}get size(){return n(this,pe).size}resetModified(){var t;n(this,ma)&&(u(this,ma,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new Lb(this)}get serializable(){if(n(this,pe).size===0)return Qh;const t=new Map,e=new kp,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,pe)){const l=o instanceof mt?o.serialize(!1,i):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}:Qh}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of n(this,pe).values()){if(!(r instanceof mt)){r.popup&&(r.popup.deleted?i+=1:s+=1);continue}r.isCommentDeleted?i+=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,Yg);d.set(c,(d.get(c)??0)+1)}}if((i>0||s>0)&&(t||(t=Object.create(null)),t.comments={deleted:i,edited:s}),!t)return null;for(const[r,a]of e)t[r]=a.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){u(this,ba,null)}updateEditor(t,e){var i;const s=(i=n(this,en))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=n(this,en))==null?void 0:e.get(t))||null}get modifiedIds(){if(n(this,ba))return n(this,ba);const t=[];if(n(this,en))for(const s of n(this,en).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new kp;s.update(t.join(",")),e=s.hexdigest()}return u(this,ba,{ids:new Set(t),hash:e})}[Symbol.iterator](){return n(this,pe).entries()}}ma=new WeakMap,ba=new WeakMap,en=new WeakMap,pe=new WeakMap,nf=new WeakSet,Ib=function(){var t;n(this,ma)||(u(this,ma,!0),(t=this.onSetModified)==null||t.call(this))};var Mc;class Lb extends Zg{constructor(e){super();m(this,Mc,Qh);const{serializable:s}=e;if(s===Qh)return;const{map:i,hash:r,transfer:a}=s,o=structuredClone(i,a?{transfer:a}:null);u(this,Mc,{map:o,hash:r,transfer:[]})}get print(){et("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,Mc)}get modifiedIds(){return $(this,"modifiedIds",{ids:new Set,hash:""})}}Mc=new WeakMap;const Fo="__forcedDependency",{floor:xm,ceil:Cm}=Math;function _m(p,t,e,s,i,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],i),p[t*4+3]=Math.max(p[t*4+3],r)}function jA(p,t,e,s,i){let r;p?(p<0&&(r=i[0],i[0]=i[2],i[2]=r),i[0]*=p,i[2]*=p,t<0&&(r=i[1],i[1]=i[3],i[3]=r),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}const Pp=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var ul,hr;class WA{constructor(t,e){m(this,ul);m(this,hr);u(this,ul,t),u(this,hr,e)}get length(){return n(this,ul).length}isEmpty(t){return n(this,ul)[t]===Pp}minX(t){return n(this,hr)[t*4+0]/256}minY(t){return n(this,hr)[t*4+1]/256}maxX(t){return(n(this,hr)[t*4+2]+1)/256}maxY(t){return(n(this,hr)[t*4+3]+1)/256}}
2ul=new WeakMap,hr=new WeakMap;const Tm=(p,t)=>p==null?void 0:p.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var sn,nt,St,ya,Aa,wa,_e,Dc,Mp;class XA{constructor(t,e){m(this,Dc);m(this,sn,[[1,0,0,1,0,0]]);m(this,nt,[-1/0,-1/0,1/0,1/0]);m(this,St,new Float64Array(Pn));T(this,"_pendingBBoxIdx",-1);m(this,ya);m(this,Aa);m(this,wa);m(this,_e);T(this,"_savesStack",[]);T(this,"_markedContentStack",[]);u(this,ya,t.width),u(this,Aa,t.height),b(this,Dc,Mp).call(this,e)}growOperationsCount(t){t>=n(this,_e).length&&b(this,Dc,Mp).call(this,t,n(this,_e))}get clipBox(){return n(this,nt)}save(t){return u(this,nt,{__proto__:n(this,nt)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(n(this,nt));if(s===null)return this;u(this,nt,s);const i=this._savesStack.pop();return i!==void 0&&(e==null||e(i,t),n(this,_e)[t]=n(this,_e)[i]),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),n(this,_e)[t]=n(this,_e)[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),n(this,_e)[t]=n(this,_e)[s]),this}pushBaseTransform(t){return n(this,sn).push(D.multiplyByDOMMatrix(n(this,sn).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,sn).length>1&&n(this,sn).pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,n(this,St).set(Pn,0)),this}recordClipBox(t,e,s,i,r,a){const o=D.multiplyByDOMMatrix(n(this,sn).at(-1),e.getTransform()),l=Pn.slice();D.axialAlignedBoundingBox([s,r,i,a],o,l);const h=D.intersect(n(this,nt),l);return h?(n(this,nt)[0]=h[0],n(this,nt)[1]=h[1],n(this,nt)[2]=h[2],n(this,nt)[3]=h[3]):(n(this,nt)[0]=n(this,nt)[1]=1/0,n(this,nt)[2]=n(this,nt)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,nt);if(o[0]===1/0)return this;const l=D.multiplyByDOMMatrix(n(this,sn).at(-1),e.getTransform());if(o[0]===-1/0)return D.axialAlignedBoundingBox([s,r,i,a],l,n(this,St)),this;const h=Pn.slice();return D.axialAlignedBoundingBox([s,r,i,a],l,h),n(this,St)[0]=Et(h[0],o[0],n(this,St)[0]),n(this,St)[1]=Et(h[1],o[1],n(this,St)[1]),n(this,St)[2]=Et(h[2],n(this,St)[2],o[2]),n(this,St)[3]=Et(h[3],n(this,St)[3],o[3]),this}recordFullPageBBox(t){return n(this,St)[0]=Math.max(0,n(this,nt)[0]),n(this,St)[1]=Math.max(0,n(this,nt)[1]),n(this,St)[2]=Math.min(n(this,ya),n(this,nt)[2]),n(this,St)[3]=Math.min(n(this,Aa),n(this,nt)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=xm(n(this,St)[0]*256/n(this,ya)),r=xm(n(this,St)[1]*256/n(this,Aa)),a=Cm(n(this,St)[2]*256/n(this,ya)),o=Cm(n(this,St)[3]*256/n(this,Aa));if(_m(n(this,wa),t,i,r,a,o),s)for(const l of s)for(const h of l)h!==t&&_m(n(this,wa),h,i,r,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,n(this,nt)[0]=Math.max(n(this,nt)[0],n(this,St)[0]),n(this,nt)[1]=Math.max(n(this,nt)[1],n(this,St)[1]),n(this,nt)[2]=Math.min(n(this,nt)[2],n(this,St)[2]),n(this,nt)[3]=Math.min(n(this,nt)[3],n(this,St)[3])),this}take(){return new WA(n(this,_e),n(this,wa))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,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}}sn=new WeakMap,nt=new WeakMap,St=new WeakMap,ya=new WeakMap,Aa=new WeakMap,wa=new WeakMap,_e=new WeakMap,Dc=new WeakSet,Mp=function(t,e){const s=new ArrayBuffer(t*4);u(this,wa,new Uint8ClampedArray(s)),u(this,_e,new Uint32Array(s)),e&&e.length>0?(n(this,_e).set(e),n(this,_e).fill(Pp,e.length)):n(this,_e).fill(Pp)};var We,Xe,va,Vs,fl,cr,dr,dt;class YA{constructor(t,e=!1){m(this,We,{__proto__:null});m(this,Xe,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Fo]:[]});m(this,va,new Map);m(this,Vs,new Set);m(this,fl,new Map);m(this,cr);m(this,dr);m(this,dt);u(this,dt,t),e&&(u(this,cr,new Map),u(this,dr,(s,i)=>{Tm(n(this,cr),i).dependencies.add(s)}))}get clipBox(){return n(this,dt).clipBox}growOperationsCount(t){n(this,dt).growOperationsCount(t)}save(t){return u(this,We,{__proto__:n(this,We)}),u(this,Xe,{__proto__:n(this,Xe),transform:{__proto__:n(this,Xe).transform},moveText:{__proto__:n(this,Xe).moveText},sameLineText:{__proto__:n(this,Xe).sameLineText},[Fo]:{__proto__:n(this,Xe)[Fo]}}),n(this,dt).save(t),this}restore(t){n(this,dt).restore(t,n(this,dr));const e=Object.getPrototypeOf(n(this,We));return e===null?this:(u(this,We,e),u(this,Xe,Object.getPrototypeOf(n(this,Xe))),this)}recordOpenMarker(t){return n(this,dt).recordOpenMarker(t,n(this,dr)),this}getOpenMarker(){return n(this,dt).getOpenMarker()}recordCloseMarker(t){return n(this,dt).recordCloseMarker(t,n(this,dr)),this}beginMarkedContent(t){return n(this,dt).beginMarkedContent(t),this}endMarkedContent(t){return n(this,dt).endMarkedContent(t,n(this,dr)),this}pushBaseTransform(t){return n(this,dt).pushBaseTransform(t),this}popBaseTransform(){return n(this,dt).popBaseTransform(),this}recordSimpleData(t,e){return n(this,We)[t]=e,this}recordIncrementalData(t,e){return n(this,Xe)[t].push(e),this}resetIncrementalData(t,e){return n(this,Xe)[t].length=0,this}recordNamedData(t,e){return n(this,va).set(t,e),this}recordSimpleDataFromNamed(t,e,s){n(this,We)[t]=n(this,va).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Fo,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,We)&&this.recordFutureForcedDependency(e,n(this,We)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,Vs))this.recordFutureForcedDependency(Fo,t);return this}resetBBox(t){return n(this,dt).resetBBox(t),this}recordClipBox(t,e,s,i,r,a){return n(this,dt).recordClipBox(t,e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,dt).recordBBox(t,e,s,i,r,a),this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){const l=s.bbox;let h,c;if(l&&(h=l[2]!==l[0]&&l[3]!==l[1]&&n(this,fl).get(s),h!==!1&&(c=[0,0,0,0],D.axialAlignedBoundingBox(l,s.fontMatrix,c),(i!==1||r!==0||a!==0)&&jA(i,-i,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,n(this,fl).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 n(this,dt).recordFullPageBBox(t),this}getSimpleIndex(t){return n(this,We)[t]}recordDependencies(t,e){const s=n(this,Vs),i=n(this,We),r=n(this,Xe);for(const a of e)a in n(this,We)?s.add(i[a]):a in r&&r[a].forEac
2h(s.add,s);return this}recordNamedDependency(t,e){return n(this,va).has(e)&&n(this,Vs).add(n(this,va).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Fo]),n(this,cr)){const i=Tm(n(this,cr),t),{dependencies:r}=i;n(this,Vs).forEach(r.add,r),n(this,dt)._savesStack.forEach(r.add,r),n(this,dt)._markedContentStack.forEach(r.add,r),r.delete(t),i.isRenderingOperation=!0}const s=!e&&t===n(this,dt)._pendingBBoxIdx;return n(this,dt).recordOperation(t,e,[n(this,Vs),n(this,dt)._savesStack,n(this,dt)._markedContentStack]),s&&n(this,Vs).clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(n(this,Vs));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===n(this,dt)._pendingBBoxIdx;return n(this,dt).bboxToClipBoxDropOperation(t),s&&n(this,Vs).clear(),this}take(){return n(this,fl).clear(),n(this,dt).take()}takeDebugMetadata(){return n(this,cr)}}We=new WeakMap,Xe=new WeakMap,va=new WeakMap,Vs=new WeakMap,fl=new WeakMap,cr=new WeakMap,dr=new WeakMap,dt=new WeakMap;var ut,Ht,js,pl,gl;const hm=class hm{constructor(t,e,s){m(this,ut);m(this,Ht);m(this,js);m(this,pl,0);m(this,gl,0);if(t instanceof hm&&n(t,js)===!!s)return t;u(this,ut,t),u(this,Ht,e),u(this,js,!!s)}get clipBox(){return n(this,ut).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return Dt(this,gl)._++,n(this,ut).save(n(this,Ht)),this}restore(t){return n(this,gl)>0&&(n(this,ut).restore(n(this,Ht)),Dt(this,gl)._--),this}recordOpenMarker(t){return Dt(this,pl)._++,this}getOpenMarker(){return n(this,pl)>0?n(this,Ht):n(this,ut).getOpenMarker()}recordCloseMarker(t){return Dt(this,pl)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,ut).pushBaseTransform(t),this}popBaseTransform(){return n(this,ut).popBaseTransform(),this}recordSimpleData(t,e){return n(this,ut).recordSimpleData(t,n(this,Ht)),this}recordIncrementalData(t,e){return n(this,ut).recordIncrementalData(t,n(this,Ht)),this}resetIncrementalData(t,e){return n(this,ut).resetIncrementalData(t,n(this,Ht)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return n(this,ut).recordSimpleDataFromNamed(t,e,n(this,Ht)),this}recordFutureForcedDependency(t,e){return n(this,ut).recordFutureForcedDependency(t,n(this,Ht)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,ut).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,ut).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,js)||n(this,ut).resetBBox(n(this,Ht)),this}recordClipBox(t,e,s,i,r,a){return n(this,js)||n(this,ut).recordClipBox(n(this,Ht),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,js)||n(this,ut).recordBBox(n(this,Ht),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,js)||n(this,ut).recordCharacterBBox(n(this,Ht),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,js)||n(this,ut).recordFullPageBBox(n(this,Ht)),this}getSimpleIndex(t){return n(this,ut).getSimpleIndex(t)}recordDependencies(t,e){return n(this,ut).recordDependencies(n(this,Ht),e),this}recordNamedDependency(t,e){return n(this,ut).recordNamedDependency(n(this,Ht),e),this}recordOperation(t){return n(this,ut).recordOperation(n(this,Ht),!0),this}recordShowTextOperation(t){return n(this,ut).recordShowTextOperation(n(this,Ht),!0),this}bboxToClipBoxDropOperation(t){return n(this,js)||n(this,ut).bboxToClipBoxDropOperation(n(this,Ht),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};ut=new WeakMap,Ht=new WeakMap,js=new WeakMap,pl=new WeakMap,gl=new WeakMap;let Jh=hm;const Ss={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 Sa,Ea,xa,Ca,_a,Ic;const Yh=class Yh{constructor(t){m(this,Sa);m(this,Ea);m(this,xa,4);m(this,Ca,0);m(this,_a,new(n(Yh,Ic))(n(this,xa)*6));u(this,Sa,t.width),u(this,Ea,t.height)}record(t,e,s,i){if(n(this,Ca)===n(this,xa)){u(this,xa,n(this,xa)*2);const o=new(n(Yh,Ic))(n(this,xa)*6);o.set(n(this,_a)),u(this,_a,o)}const r=wt(t);let a;if(i[0]!==1/0){const o=Pn.slice();D.axialAlignedBoundingBox([0,-s,e,0],r,o);const l=D.intersect(i,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,_=(w*E-v*x)/C,k=(w*x-v*S)/C;a=[h+k,c,h,c+_,d,f-_]}}}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]/=n(this,Sa),a[1]/=n(this,Ea),a[2]/=n(this,Sa),a[3]/=n(this,Ea),a[4]/=n(this,Sa),a[5]/=n(this,Ea),n(this,_a).set(a,n(this,Ca)*6),Dt(this,Ca)._++}take(){return n(this,_a).subarray(0,n(this,Ca)*6)}};Sa=new WeakMap,Ea=new WeakMap,xa=new WeakMap,Ca=new WeakMap,_a=new WeakMap,Ic=new WeakMap,m(Yh,Ic,pt.isFloat16ArraySupported?Float16Array:Float32Array);let Dp=Yh;const km=new RegExp("\\p{Cc}","u");function KA(p){const t=p[0];if(p.length<2||t!=='"'&&t!=="'"||p.at(-1)!==t)return!1;const e=p.length-1;for(let s=1;s<e;s++){const i=p[s];if(i===t||km.test(i)||i==="\\"&&(++s>=e||km.test(p[s])))return!1}return!0}function Pm(p){return KA(p)?p:`"${p.replaceAll(/["\\\p{Cc}]/gu,e=>e==='"'||e==="\\"?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}var ml,Ws,rf,Fb;class qA{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){m(this,rf);m(this,ml,new Set);m(this,Ws,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,rf,Fb).call(this);e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),n(this,ml).clear(),n(this,Ws)){const{adoptedStyleSheets:t}=this._document;
2t!=null&&t.includes(n(this,Ws))&&(this._document.adoptedStyleSheets=t.filter(e=>e!==n(this,Ws))),u(this,Ws,null)}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,ml).has(t.loadedName))){if(Nt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:a}=t,o=new FontFace(i,r,a);this.addNativeFontFace(o);try{await o.load(),n(this,ml).add(i),s==null||s(t)}catch{X(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}et("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw X(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return $(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return $(this,"isSyncFontLoadingSupported",gs||pt.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(Nt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return $(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(C,_){return C.charCodeAt(_)<<24|C.charCodeAt(_+1)<<16|C.charCodeAt(_+2)<<8|C.charCodeAt(_+3)&255}function i(C){return String.fromCharCode(C>>24&255,C>>16&255,C>>8&255,C&255)}function r(C,_,k,P){const M=C.substring(0,_),L=C.substring(_+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,_){if(++c>30){X("Load test font never loaded."),_();return}if(h.font="30px "+C,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0){_();return}setTimeout(d.bind(null,C,_))}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,i(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 _=this._document.createElement("span");_.textContent="Hi",_.style.fontFamily=C,x.append(_)}this._document.body.append(x),d(f,()=>{x.remove(),e.complete()})}}ml=new WeakMap,Ws=new WeakMap,rf=new WeakSet,Fb=function(){var e;if(n(this,Ws))return n(this,Ws);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 i=new t;return s.push(i),u(this,Ws,i)}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),u(this,Ws,this.styleElement.sheet)};var ft;class QA{constructor(t,e=null,s,i){T(this,"compiledGlyphs",Object.create(null));m(this,ft);u(this,ft,t),this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}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(Pm(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 i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:${Pm(this.cssFontInfo.fontFamily)};${i}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 i;try{i=t.get(s)}catch(a){X(`getPathGenerator - ignoring character: "${a}".`)}const r=Jm(i==null?void 0:i.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return n(this,ft).black}get bold(){return n(this,ft).bold}get disableFontFace(){return n(this,ft).disableFontFace}set disableFontFace(t){$(this,"disableFontFace",!!t)}get fontExtraProperties(){return n(this,ft).fontExtraProperties}get isInvalidPDFjsFont(){return n(this,ft).isInvalidPDFjsFont}get isType3Font(){return n(this,ft).isType3Font}get italic(){return n(this,ft).italic}get missingFile(){return n(this,ft).missingFile}get remeasure(){return n(this,ft).remeasure}get vertical(){return n(this,ft).vertical}get ascent(){return n(this,ft).ascent}get defaultWidth(){return n(this,ft).defaultWidth}get descent(){return n(this,ft).descent}get bbox(){return n(this,ft).bbox}get fontMatrix(){return n(this,ft).fontMatrix}get fallbackName(){return n(this,ft).fallbackName}get loadedName(){return n(this,ft).loadedName}get mimetype(){return n(this,ft).mimetype}get name(){return n(this,ft).name}get data(){return n(this,ft).data}clearData(){n(this,ft).clearData()}get cssFontInfo(){return n(this,ft).cssFontInfo}get systemFontInfo(){return n(this,ft).systemFontInfo}get defaultVMetrics(){return n(this,ft).defaultVMetrics}}ft=new WeakMap;class Rb{}T(Rb,"strings",["fontFamily","fontWeight","italicAngle"]);class Ob{}T(Ob,"strings",["css","loadedName","baseFontName","src"]);const Se=class Se{};
2T(Se,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),T(Se,"numbers",["ascent","defaultWidth","descent"]),T(Se,"strings",["fallbackName","loadedName","mimetype","name"]),T(Se,"OFFSET_NUMBERS",Math.ceil(Se.bools.length*2/8)),T(Se,"OFFSET_BBOX",Se.OFFSET_NUMBERS+Se.numbers.length*8),T(Se,"OFFSET_FONT_MATRIX",Se.OFFSET_BBOX+1+2*4),T(Se,"OFFSET_DEFAULT_VMETRICS",Se.OFFSET_FONT_MATRIX+1+8*6),T(Se,"OFFSET_STRINGS",Se.OFFSET_DEFAULT_VMETRICS+1+2*3);let Qe=Se;class Be{}T(Be,"KIND",0),T(Be,"HAS_BBOX",1),T(Be,"HAS_BACKGROUND",2),T(Be,"SHADING_TYPE",3),T(Be,"N_COORD",4),T(Be,"N_COLOR",8),T(Be,"N_STOP",12),T(Be,"N_FIGURES",16);class Wu{static get decoder(){return $(this,"decoder",new TextDecoder)}static get encoder(){return $(this,"encoder",new TextEncoder)}}var Lc,bl,yl,cu;class JA{constructor(t){m(this,yl);m(this,Lc);m(this,bl);u(this,Lc,t),u(this,bl,new DataView(t))}get fontFamily(){return b(this,yl,cu).call(this,0)}get fontWeight(){return b(this,yl,cu).call(this,1)}get italicAngle(){return b(this,yl,cu).call(this,2)}}Lc=new WeakMap,bl=new WeakMap,yl=new WeakSet,cu=function(t){Nt(t<Rb.strings.length,"Invalid string index");const{decoder:e}=Wu;let s=0;for(let r=0;r<t;r++)s+=n(this,bl).getUint32(s)+4;const i=n(this,bl).getUint32(s);return e.decode(new Uint8Array(n(this,Lc),s+4,i))};var Ta,Si,ka,Mh;class ZA{constructor(t){m(this,ka);m(this,Ta);m(this,Si);u(this,Ta,t),u(this,Si,new DataView(t))}get guessFallback(){return n(this,Si).getUint8(0)!==0}get css(){return b(this,ka,Mh).call(this,0)}get loadedName(){return b(this,ka,Mh).call(this,1)}get baseFontName(){return b(this,ka,Mh).call(this,2)}get src(){return b(this,ka,Mh).call(this,3)}get style(){const{decoder:t}=Wu;let e=1;e+=4+n(this,Si).getUint32(e);const s=n(this,Si).getUint32(e),i=t.decode(new Uint8Array(n(this,Ta),e+4,s));e+=4+s;const r=n(this,Si).getUint32(e),a=t.decode(new Uint8Array(n(this,Ta),e+4,r));return{style:i,weight:a}}}Ta=new WeakMap,Si=new WeakMap,ka=new WeakSet,Mh=function(t){Nt(t<Ob.strings.length,"Invalid string index");const{decoder:e}=Wu;let s=5;for(let r=0;r<t;r++)s+=n(this,Si).getUint32(s)+4;const i=n(this,Si).getUint32(s);return e.decode(new Uint8Array(n(this,Ta),s+4,i))};var Xs,Vt,ot,Us,du,uu,Dh,Ip;class t0{constructor({buffer:t,extra:e}){m(this,ot);m(this,Xs);m(this,Vt);u(this,Xs,t),u(this,Vt,new DataView(t)),e&&Object.assign(this,e)}get black(){return b(this,ot,Us).call(this,0)}get bold(){return b(this,ot,Us).call(this,1)}get disableFontFace(){return b(this,ot,Us).call(this,2)}get fontExtraProperties(){return b(this,ot,Us).call(this,3)}get isInvalidPDFjsFont(){return b(this,ot,Us).call(this,4)}get isType3Font(){return b(this,ot,Us).call(this,5)}get italic(){return b(this,ot,Us).call(this,6)}get missingFile(){return b(this,ot,Us).call(this,7)}get remeasure(){return b(this,ot,Us).call(this,8)}get vertical(){return b(this,ot,Us).call(this,9)}get ascent(){return b(this,ot,du).call(this,0)}get defaultWidth(){return b(this,ot,du).call(this,1)}get descent(){return b(this,ot,du).call(this,2)}get bbox(){return b(this,ot,uu).call(this,Qe.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return b(this,ot,uu).call(this,Qe.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return b(this,ot,uu).call(this,Qe.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}get fallbackName(){return b(this,ot,Dh).call(this,0)}get loadedName(){return b(this,ot,Dh).call(this,1)}get mimetype(){return b(this,ot,Dh).call(this,2)}get name(){return b(this,ot,Dh).call(this,3)}get data(){const{offset:t,length:e}=b(this,ot,Ip).call(this);return e===0?void 0:new Uint8Array(n(this,Xs),t+4,e)}clearData(){const{offset:t,length:e}=b(this,ot,Ip).call(this);e!==0&&(n(this,Vt).setUint32(t,0),u(this,Xs,new Uint8Array(n(this,Xs),0,t+4).slice().buffer),u(this,Vt,new DataView(n(this,Xs))))}get cssFontInfo(){let t=Qe.OFFSET_STRINGS;const e=n(this,Vt).getUint32(t);t+=4+e;const s=n(this,Vt).getUint32(t);t+=4+s;const i=n(this,Vt).getUint32(t);if(i===0)return null;const r=new Uint8Array(i);return r.set(new Uint8Array(n(this,Xs),t+4,i)),new JA(r.buffer)}get systemFontInfo(){let t=Qe.OFFSET_STRINGS;const e=n(this,Vt).getUint32(t);t+=4+e;const s=n(this,Vt).getUint32(t);if(s===0)return null;const i=new Uint8Array(s);
2return i.set(new Uint8Array(n(this,Xs),t+4,s)),new ZA(i.buffer)}}Xs=new WeakMap,Vt=new WeakMap,ot=new WeakSet,Us=function(t){Nt(t<Qe.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=n(this,Vt).getUint8(e)>>s&3;return i===0?void 0:i===2},du=function(t){return Nt(t<Qe.numbers.length,"Invalid number index"),n(this,Vt).getFloat64(Qe.OFFSET_NUMBERS+t*8)},uu=function(t,e,s,i){const r=n(this,Vt).getUint8(t);if(r===0)return;Nt(r===e,"Invalid array length."),t+=1;const a=new Array(r);for(let o=0;o<r;o++)a[o]=n(this,Vt)[s](t,!0),t+=i;return a},Dh=function(t){Nt(t<Qe.strings.length,"Invalid string index");const{decoder:e}=Wu;let s=Qe.OFFSET_STRINGS+4;for(let r=0;r<t;r++)s+=n(this,Vt).getUint32(s)+4;const i=n(this,Vt).getUint32(s);return e.decode(new Uint8Array(n(this,Xs),s+4,i))},Ip=function(){let t=Qe.OFFSET_STRINGS;const e=n(this,Vt).getUint32(t);t+=4+e;const s=n(this,Vt).getUint32(t);t+=4+s;const i=n(this,Vt).getUint32(t);t+=4+i;const r=n(this,Vt).getUint32(t);return{offset:t,length:r}};class e0{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[Be.KIND],s=!!this.data[Be.HAS_BBOX],i=!!this.data[Be.HAS_BACKGROUND],r=t.getUint32(Be.N_COORD,!0),a=t.getUint32(Be.N_COLOR,!0),o=t.getUint32(Be.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;const 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(i&&(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[Be.SHADING_TYPE];let A=null;if(h.length>0){A=Pn.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 Al;class s0{constructor(t){m(this,Al);u(this,Al,t)}get path(){return pt.isFloat16ArraySupported?new Float16Array(n(this,Al)):new Float32Array(n(this,Al))}}Al=new WeakMap;function i0(p){if(p instanceof URL)return p;if(typeof p=="string"){if(gs){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 n0(p){if(gs&&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 Pf(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 Yd(p){if(typeof p!="string")return null;if(p.endsWith("/"))return p;throw new Error(`Invalid factory url: "${p}" must include trailing slash.`)}const Lp=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,r0=p=>typeof p=="object"&&typeof(p==null?void 0:p.name)=="string",a0=PA.bind(null,Lp,r0);var nn,af;class o0{constructor(){m(this,nn,new Map);m(this,af,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,af).then(()=>{for(const[i]of n(this,nn))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){X("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,nn).set(e,i)}removeEventListener(t,e){const s=n(this,nn).get(e);s==null||s(),n(this,nn).delete(e)}terminate(){for(const[,t]of n(this,nn))t==null||t();n(this,nn).clear()}}nn=new WeakMap,af=new WeakMap;const Kd={DATA:1,ERROR:2},Wt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Mm(){}function $e(p){if(p instanceof Gr||p instanceof tp||p instanceof Zf||p instanceof zu||p instanceof Vf)return p;switch(p instanceof Error||typeof p=="object"&&p!==null||et('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),p.name){case"AbortException":return new Gr(p.message);case"InvalidPDFException":return new tp(p.message);case"PasswordException":return new Zf(p.message,p.code);case"ResponseException":return new zu(p.message,p.status,p.missing);case"UnknownErrorException":return new Vf(p.message,p.details)}return new Vf(p.message,p.toString())}var wl,Hs,Nb,Bb,Hb,fu;class Ih{constructor(t,e,s){m(this,Hs);m(this,wl,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,Hs,Nb).bind(this),{signal:n(this,wl).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 i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,i){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},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[r].pullCall=c,l.postMessage({sourceName:a,targetName:o,stream:Wt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{Nt(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:Wt.CANCEL,streamId:r,reason:$e(h)}),c.promise}},s)}destroy(){var t;(t=n(this,wl))==null||t.abort(),u(this,wl,null)}}wl=new WeakMap,Hs=new WeakSet,Nb=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){b(this,Hs,Hb).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===Kd.DATA)i.resolve(t.data);else if(t.callback===Kd.ERROR)i.reject($e(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:i,callback:Kd.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:Kd.ERROR,callbackId:t.callbackId,reason:$e(a)})});return}if(t.streamId){b(this,Hs,Bb).call(this,t);return}e(t.data)},Bb=function(t){const e=t.streamId,s=this.sourceName,i=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:i,stream:Wt.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Wt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){Nt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Wt.ERROR,streamId:e,reason:$e(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:i,stream:Wt.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Wt.START_COMPLETE,streamId:e,reason:$e(h)})})},Hb=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Wt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject($e(t.reason));break;case Wt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject($e(t.reason));break;case Wt.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:Wt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||Mm).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Wt.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Wt.PULL_COMPLETE,streamId:e,reason:$e(h)})});break;case Wt.ENQUEUE:if(Nt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Wt.CLOSE:if(Nt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,Hs,fu).call(this,a,e);break;case Wt.ERROR:Nt(a,"error should have stream controller"),a.controller.error($e(t.reason)),b(this,Hs,fu).call(this,a,e);break;case Wt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject($e(t.reason)),b(this,Hs,fu).call(this,a,e);break;case Wt.CANCEL:if(!o)break;const l=$e(t.reason);Promise.try(o.onCancel||Mm,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Wt.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Wt.CANCEL_COMPLETE,streamId:e,reason:$e(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},fu=async function(t,e){var s,i,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var of;class Ub{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){m(this,of,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:et(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const i=`${s}${e}`;
2return this._fetch(i,t).catch(r=>{throw new Error(`Unable to load ${n(this,of)[t]} data at: ${i}`)})}async _fetch(t,e){et("Abstract method `_fetch` called.")}}of=new WeakMap;class Dm extends Ub{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await qg(t,s);return i instanceof Uint8Array?i:Pf(i)}}var Fc;class Gb{constructor({enableHWA:t=!1}){m(this,Fc,!1);u(this,Fc,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!n(this,Fc)})}}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){et("Abstract method `_createCanvas` called.")}}Fc=new WeakMap;class l0 extends Gb{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 $b{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}var Pa,vl,rn,Ei,oe,Ma,ur,I,ne,Lh,li,pu,Vr,zb,Fp,jr,Fh,Rh,Rp,Oh,Vb,Op,jb;class h0 extends $b{constructor({docId:e,ownerDocument:s=globalThis.document}){super();m(this,I);m(this,Pa);m(this,vl);m(this,rn);m(this,Ei);m(this,oe);m(this,Ma);m(this,ur,0);u(this,Ei,e),u(this,oe,s)}addFilter(e){if(!e)return"none";let s=n(this,I,ne).get(e);if(s)return s;const[i,r,a]=b(this,I,pu).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,I,ne).get(o),s)return n(this,I,ne).set(e,s),s;const l=`g_${n(this,Ei)}_transfer_map_${Dt(this,ur)._++}`,h=b(this,I,Vr).call(this,l);n(this,I,ne).set(e,h),n(this,I,ne).set(o,h);const c=b(this,I,jr).call(this,l);return b(this,I,Rh).call(this,i,r,a,c),h}addHCMFilter(e,s){var y;const i=`${e}-${s}`,r="base";let a=n(this,I,Lh).get(r);if((a==null?void 0:a.key)===i||(a?((y=a.filter)==null||y.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},n(this,I,Lh).set(r,a)),!e||!s))return a.url;const o=b(this,I,Oh).call(this,e);e=D.makeHexColor(...o);const l=b(this,I,Oh).call(this,s);if(s=D.makeHexColor(...l),b(this,I,Op).call(this),e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=Array.from({length:256},(A,v)=>ap(v/255)).join(","),d=`g_${n(this,Ei)}_hcm_filter`,f=a.filter=b(this,I,jr).call(this,d);b(this,I,Rh).call(this,c,c,c,f),b(this,I,Fp).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,Rh).call(this,g(0,5),g(1,5),g(2,5),f),a.url=b(this,I,Vr).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"||!pt.platform.isFirefox?null:{"backdrop-filter":s,"background-color":"transparent"}}addAlphaFilter(e){let s=n(this,I,ne).get(e);if(s)return s;const[i]=b(this,I,pu).call(this,[e]),r=`alpha_${i}`;if(s=n(this,I,ne).get(r),s)return n(this,I,ne).set(e,s),s;const a=`g_${n(this,Ei)}_alpha_map_${Dt(this,ur)._++}`,o=b(this,I,Vr).call(this,a);n(this,I,ne).set(e,o),n(this,I,ne).set(r,o);const l=b(this,I,jr).call(this,a);return b(this,I,Rp).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,I,ne).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=b(this,I,pu).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,I,ne).get(r),s)return n(this,I,ne).set(e,s),s;const a=`g_${n(this,Ei)}_luminosity_map_${Dt(this,ur)._++}`,o=b(this,I,Vr).call(this,a);n(this,I,ne).set(e,o),n(this,I,ne).set(r,o);const l=b(this,I,jr).call(this,a);return b(this,I,zb).call(this,l),e&&b(this,I,Rp).call(this,i,l),o}addKnockoutFilter(e=0){const s=e>0?Math.min(1/e,1e6):1e6,i=`knockout_${s}`,r=n(this,I,ne).get(i);if(r)return r;const a=`g_${n(this,Ei)}_knockout_filter_${Dt(this,ur)._++}`,o=b(this,I,Vr).call(this,a);n(this,I,ne).set(i,o);const l=b(this,I,jr).call(this,a),h=n(this,oe).createElementNS(Ne,"feComponentTransfer");l.append(h);const c=n(this,oe).createElementNS(Ne,"feFuncA");return c.setAttribute("type","linear"),c.setAttribute("slope",`${s}`),c.setAttribute("intercept","0"),h.append(c),o}addHighlightHCMFilter(e,s,i,r,a){var S;const o=`${s}-${i}-${r}-${a}`;let l=n(this,I,Lh).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},n(this,I,Lh).set(e,l)),!s||!i))return l.url;const[h,c]=[s,i].map(b(this,I,Oh).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,jb).bind(this));f<d&&([d,f,g,y]=[f,d,y,g]),b(this,I,Op).call(this);const A=(E,x,C)=>{const _=new Array(256),k=(f-d)/C,P=E/255,M=(x-E)/(255*C);let L=0;for(let N=0;N<=C;N++){const Z=Math.round(d+N*k),q=P+N*M;for(let J=L;J<=Z;J++)_[J]=q;L=Z+1}for(let N=L;N<256;N++)_[N]=_[L-1];return _.join(",")},v=`g_${n(this,Ei)}_hcm_${e}
2_filter`,w=l.filter=b(this,I,jr).call(this,v);return b(this,I,Fp).call(this,w),b(this,I,Rh).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,Vr).call(this,v),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,Ma))!=null&&s.size)||((i=n(this,rn))==null||i.parentNode.parentNode.remove(),u(this,rn,null),(r=n(this,vl))==null||r.clear(),u(this,vl,null),(a=n(this,Ma))==null||a.clear(),u(this,Ma,null),u(this,ur,0))}}Pa=new WeakMap,vl=new WeakMap,rn=new WeakMap,Ei=new WeakMap,oe=new WeakMap,Ma=new WeakMap,ur=new WeakMap,I=new WeakSet,ne=function(){return n(this,vl)||u(this,vl,new Map)},Lh=function(){return n(this,Ma)||u(this,Ma,new Map)},li=function(){if(!n(this,rn)){const e=n(this,oe).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 i=n(this,oe).createElementNS(Ne,"svg");i.setAttribute("width",0),i.setAttribute("height",0),u(this,rn,n(this,oe).createElementNS(Ne,"defs")),e.append(i),i.append(n(this,rn)),n(this,oe).body.append(e)}return n(this,rn)},pu=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,i,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]=i[h]/255,l[h]=r[h]/255;return[a.join(","),o.join(","),l.join(",")]},Vr=function(e){if(n(this,Pa)===void 0){u(this,Pa,"");const s=n(this,oe).URL;s!==n(this,oe).baseURI&&(Mf(s)?X('#createUrl: ignore "data:"-URL for performance reasons.'):u(this,Pa,Km(s,"")))}return`url(${n(this,Pa)}#${e})`},zb=function(e){const s=n(this,oe).createElementNS(Ne,"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)},Fp=function(e){const s=n(this,oe).createElementNS(Ne,"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)},jr=function(e){const s=n(this,oe).createElementNS(Ne,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,I,li).append(s),s},Fh=function(e,s,i){const r=n(this,oe).createElementNS(Ne,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},Rh=function(e,s,i,r){const a=n(this,oe).createElementNS(Ne,"feComponentTransfer");r.append(a),b(this,I,Fh).call(this,a,"feFuncR",e),b(this,I,Fh).call(this,a,"feFuncG",s),b(this,I,Fh).call(this,a,"feFuncB",i)},Rp=function(e,s){const i=n(this,oe).createElementNS(Ne,"feComponentTransfer");
2s.append(i),b(this,I,Fh).call(this,i,"feFuncA",e)},Oh=function(e){return n(this,I,li).style.color="CanvasText",n(this,I,li).style.backgroundColor=e,jd(getComputedStyle(n(this,I,li)).getPropertyValue("background-color"))},Vb=function(e){return n(this,I,li).style.color="CanvasText",n(this,I,li).style.backgroundColor=e,Vd(getComputedStyle(n(this,I,li)).getPropertyValue("background-color"))},Op=function(){n(this,I,li).style.color="",n(this,I,li).style.backgroundColor=""},jb=function(e){const[s,i,r,a]=b(this,I,Vb).call(this,e);if(a===1)return[s,i,r];const[o,l,h]=b(this,I,Oh).call(this,"Canvas");return[Yf(s,o,a),Yf(i,l,a),Yf(r,h,a)]};function Yf(p,t,e){return Math.round(e*p+(1-e)*t)}gs&&X("Please use the `legacy` build in Node.js environments.");async function c0(p){const e=await process.getBuiltinModule("fs/promises").readFile(p);return new Uint8Array(e)}class d0 extends $b{}class u0 extends Gb{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class f0 extends Ub{async _fetch(t,e){return c0(t)}}function Wb({src:p,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=pt.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<i;++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 p0({src:p,srcPos:t=0,dest:e,destPos:s=0,width:i,height:r}){let a=0;const o=i*r*3,l=o>>2,h=new Uint32Array(p.buffer,t,l),c=pt.isLittleEndian?4278190080:255;if(pt.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 g0=`
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 lf,an,Da,Sl,hf,Xb;class m0{constructor(){m(this,hf);m(this,lf,null);m(this,an,null);m(this,Da,null);m(this,Sl,null)}init(){return n(this,lf)||u(this,lf,b(this,hf,Xb).call(this))}get isReady(){return n(this,an)!==null}loadMeshShader(){if(!n(this,an)||n(this,Da))return;const t=n(this,an).createShaderModule({code:g0});u(this,Da,n(this,an).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:n(this,Sl)}]},primitive:{topology:"triangle-list"}}))}draw(t,e,s,i,r,a,o,l){this.loadMeshShader();const h=n(this,an),{offsetX:c,offsetY:d,scaleX:f,scaleY:g}=i,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:n(this,Da).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:v}}]}),S=new OffscreenCanvas(a,o),E=S.getContext("webgpu");E.configure({device:h,format:n(this,Sl),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(),_=C.beginRenderPass({colorAttachments:[{view:E.getCurrentTexture().createView(),clearValue:x,loadOp:"clear",storeOp:"store"}]});return s>0&&(_.setPipeline(n(this,Da)),_.setBindGroup(0,w),_.setVertexBuffer(0,y),_.setVertexBuffer(1,A),_.draw(s)),_.end(),h.queue.submit([C.finish()]),y.destroy(),A.destroy(),v.destroy(),S.transferToImageBitmap()}}lf=new WeakMap,an=new WeakMap,Da=new WeakMap,Sl=new WeakMap,hf=new WeakSet,Xb=async function(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{const e=await navigator.gpu.requestAdapter();
45return e?(u(this,Sl,navigator.gpu.getPreferredCanvasFormat()),u(this,an,await e.requestDevice()),!0):!1}catch{return!1}};const Df=new m0;function b0(){return Df.init()}function y0(){return Df.isReady}function A0(){Df.loadMeshShader()}function w0(p,t,e,s,i,r,a,o){return Df.draw(p,t,e,s,i,r,a,o)}const be={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function gu(p,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),p.clip(i)}class tm{constructor(){T(this,"matrix",null)}isModifyingCurrentTransform(){return!1}getPattern(){et("Abstract method `getPattern` called.")}}class v0 extends tm{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,i=this._p0,r=this._p1;if(e&&(i=i.slice(),r=r.slice(),D.applyTransform(i,e),D.applyTransform(r,e)),this._type==="axial")s=t.createLinearGradient(i[0],i[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(i[0],i[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,i=this._p0;e&&(s=s.slice(),i=i.slice(),D.applyTransform(s,e),D.applyTransform(i,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,i[0],i[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,i){let r;if(i===be.STROKE||i===be.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(i,wt(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),gu(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(),gu(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),gu(t,this._bbox),r=this._createGradient(t);return r}}function S0(p,t,e,s,i,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[i*2+1]&&(f=s,s=i,i=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[i*2]+t.offsetX)*t.scaleX,S=(l[i*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],_=h[a*4],k=h[a*4+1],P=h[a*4+2],M=h[o*4],L=h[o*4+1],N=h[o*4+2],Z=Math.round(y),q=Math.round(S);let J,$t,F,H,xt,Ct,Pe,ce;for(let jt=Z;jt<=q;jt++){if(jt<v){const yt=jt<y?0:(y-jt)/(y-v);J=g-(g-A)*yt,$t=E-(E-_)*yt,F=x-(x-k)*yt,H=C-(C-P)*yt}else{let yt;jt>S?yt=1:v===S?yt=0:yt=(v-jt)/(v-S),J=A-(A-w)*yt,$t=_-(_-M)*yt,F=k-(k-L)*yt,H=P-(P-N)*yt}let lt;jt<y?lt=0:jt>S?lt=1:lt=(y-jt)/(y-S),xt=g-(g-w)*lt,Ct=E-(E-M)*lt,Pe=x-(x-L)*lt,ce=C-(C-N)*lt;const ri=Math.round(Math.min(J,xt)),vh=Math.round(Math.max(J,xt));let ie=d*jt+ri*4;
45for(let yt=ri;yt<=vh;yt++)lt=(J-yt)/(J-xt),lt<0?lt=0:lt>1&&(lt=1),c[ie++]=$t-($t-Ct)*lt|0,c[ie++]=F-(F-Pe)*lt|0,c[ie++]=H-(H-ce)*lt|0,c[ie++]=255}}class E0 extends tm{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],A0()}_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(y0()&&this._vertexCount>48)S.context.drawImage(w0(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,_=x.length;C<_;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)S0(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,i){gu(t,this._bbox);const r=new Float32Array(2);if(i===be.SHADING)D.singularValueDecompose2dScale(wt(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,i===be.SHADING?null:this._background,e.canvasFactory);i!==be.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 x0 extends tm{getPattern(){return"hotpink"}}function C0(p){switch(p[0]){case"RadialAxial":return new v0(p);case"Mesh":return new E0(p);case"Dummy":return new x0}throw new Error(`Unknown IR type: ${p[0]}`)}const Im={COLORED:1,UNCOLORED:2},cf=class cf{constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i,this.patternBaseMatrix=this.matrix?D.transform(i,this.matrix):i}canSkipPatternCanvas([t,e,s,i]){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((i-l)/c)+1,y=Math.ceil((i+e-a)/c)-1;return f<=d&&y<=g?[d,g]:null}updatePatternDims(t,e){const s=D.inverseTransform(this.patternBaseMatrix),i=[t[0],t[1]],r=[t[2],t[3]];D.applyTransform(i,s),D.applyTransform(r,s),e[0]=Math.abs(r[0]-i[0]),e[1]=Math.abs(r[1]-i[1]),e[2]=Math.min(i[0],r[0]),e[3]=Math.min(i[1],r[1])}_renderTileCanvas(t,e,s,i){var f,g;const[r,a,o,l]=this.bbox,h=t.canvasFactory.create(s.size,i.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,-i.scale*a),d.transform(0,s.scale,0,0,i.scale,0,0),c.save(),(f=d.dependencyTracker)==null||f.save(),this.clipBbox(d,r,a,o,l),d.baseTransform=wt(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,[i,r],a){const[o,l,h,c]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new Jh(d,a)),t.save(),s?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(i*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=wt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();
45t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[s,i,r,a]=this.bbox,o=r-s,l=a-i;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),kf("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),_=this.getSizeAndScale(y,this.ctx.canvas.height,f),k=C.size,P=_.size,M=t.canvasFactory.create(k,P),L=M.context,N=A?Math.floor(o/h):0,Z=v?Math.floor(l/c):0;for(let q=0;q<=N;q++)for(let J=0;J<=Z;J++)L.drawImage(x,k*q,P*J,k,P,0,0,k,P);return t.canvasFactory.destroy(E),{canvas:M.canvas,canvasEntry:M,scaleX:C.scale,scaleY:_.scale,offsetX:s,offsetY:i}}return{canvas:E.canvas,canvasEntry:E,scaleX:w.scale,scaleY:S.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){const i=Math.max(cf.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const a=i-e,o=r-s,l=new Path2D;l.rect(e,s,a,o),D.axialAlignedBoundingBox([e,s,i,r],wt(t.ctx),t.current.minMax),t.ctx.clip(l),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,r=t.current;switch(r.patternFill=r.patternStroke=!1,e){case Im.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case Im.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new CA(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){const a=i!==be.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}};T(cf,"MAX_PATTERN_SIZE",3e3);let Xh=cf;const _0=16,T0=100,k0=15,Lm=10,qe=16,ms=new Float32Array(2);function Fm(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 i=p[s];typeof i!="function"||typeof t[s]!="function"||(e.set(s,i),p[s]=function(...r){return t[s](...r),i.apply(this,r)})}p._removeMirroring=()=>{for(const[s,i]of e)p[s]=i;delete p._removeMirroring}}function qd(p,t,e,s,i,r,a,o,l,h){const[c,d,f,g,y,A]=wt(p);if(d===0&&f===0){const S=a*c+y,E=Math.round(S),x=o*g+A,C=Math.round(x),_=(a+l)*c+y,k=Math.abs(Math.round(_)-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,i,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),_=(o+h)*f+y,k=Math.abs(Math.round(_)-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,i,r,0,0,M,k),p.setTransform(c,d,f,g,y,A),[M,k]}p.drawImage(t,e,s,i,r,a,o,l,h);const v=Math.hypot(c,d),w=Math.hypot(f,g);return[v*l,w*h]}class Rm{constructor(t,e){T(this,"alphaIsShape",!1);T(this,"fontSize",0);T(this,"fontSizeScale",1);T(this,"textMatrix",null);T(this,"textMatrixScale",1);T(this,"fontMatrix",Qf);T(this,"leading",0);T(this,"x",0);T(this,"y",0);T(this,"lineX",0);T(this,"lineY",0);T(this,"charSpacing",0);T(this,"wordSpacing",0);T(this,"textHScale",1);T(this,"textRenderingMode",Jt.FILL);T(this,"textRise",0);T(this,"fillColor","#000000");T(this,"strokeColor","#000000");T(this,"tilingPatternDims",null);T(this,"patternFill",!1);T(this,"patternStroke",!1);T(this,"fillAlpha",1);T(this,"strokeAlpha",1);T(this,"lineWidth",1);T(this,"activeSMask",null);T(this,"transferMaps","none");T(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=be.FILL,e=null){const s=this.minMax.slice();if(t===be.STROKE){e||et("Stroke bounding box must include transform."),D.singularValueDecompose2dScale(e,ms);const i=ms[0]*this.lineWidth/2,r=ms[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,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=be.FILL,e=null){return D.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}
45function Om(p,t){const{width:e,height:s,kind:i}=t,r=s%qe,a=(s-r)/qe,o=r===0?a:a+1,l=p.createImageData(e,qe);let h=0;const c=t.data,d=l.data;let f;if(i===su.GRAYSCALE_1BPP)for(f=0;f<o;f++)({srcPos:h}=Wb({src:c,srcPos:h,dest:d,width:e,height:f<a?qe:r})),p.putImageData(l,0,f*qe);else if(i===su.RGBA_32BPP){let g=0,y=e*qe*4;for(f=0;f<a;f++)d.set(c.subarray(h,h+y)),h+=y,p.putImageData(l,0,g),g+=qe;f<o&&(y=e*r*4,d.set(c.subarray(h,h+y)),p.putImageData(l,0,g))}else if(i===su.RGB_24BPP)for(f=0;f<o;f++)({srcPos:h}=p0({src:c,srcPos:h,dest:new Uint32Array(d.buffer),width:e,height:f<a?qe:r})),p.putImageData(l,0,f*qe);else throw new Error(`bad image kind: ${i}`)}function Nm(p,t){if(t.bitmap){p.drawImage(t.bitmap,0,0);return}const{width:e,height:s}=t,i=s%qe,r=(s-i)/qe,a=i===0?r:r+1,o=p.createImageData(e,qe);let l=0;const h=t.data,c=o.data;for(let d=0;d<a;d++)({srcPos:l}=Wb({src:h,srcPos:l,dest:c,width:e,height:d<r?qe:i,nonBlackColor:0})),p.putImageData(o,0,d*qe)}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 Qd(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 Bm(p,t){if(t)return!0;D.singularValueDecompose2dScale(p,ms);const e=Math.fround(ni.pixelRatio*$r.PDF_TO_CSS_UNITS);return ms[0]<=e&&ms[1]<=e}const P0=["butt","round","square"],M0=["miter","round","bevel"],D0={},Hm={};var df,ss,fr,Ia,La,Fa,Ra,Oa,Na,Ba,xi,U,Np,Bp,Hp,Up,Gp,Ge,ve,$p,Yb,mu;const qr=class qr{constructor(t,e,s,i,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c,d){m(this,U);m(this,ss,0);m(this,fr,0);m(this,Ia,null);m(this,La,null);m(this,Fa,null);m(this,Ra,null);m(this,Oa,1);m(this,Na);m(this,Ba,null);m(this,xi,[]);this.ctx=t,this.current=new Rm(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=i,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 i;return typeof e=="string"?((i=this.dependencyTracker)==null||i.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#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(...wt(this.compositeCtx))}this.ctx.save(),Qd(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=wt(this.ctx)}executeOperatorList(t,e,s,i,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>Lm&&typeof s=="function",d=c?Date.now()+k0:0;let f=0;const g=this.commonObjs,y=this.objs;let A,v;for(;;){if(i!==void 0){if(l===i.nextBreakPoint)return i.breakIt(l,s),l;if(i.shouldSkip(l)){if(++l===h)return l;continue}}if(!r||r(l))if(A=o[l],v=a[l]??null,A!==ci.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>Lm){if(Date.now()>d)return s(),l;f=0}}}endDrawing(){b(this,U,Np).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 n(this,xi))b(this,U,mu).call(this,t);n(this,xi).length=0,u(this,Ia,null),u(this,La,null),u(this,Fa,null),u(this,Ra,null),u(this,Oa,1),u(this,Ba,null),u(this,fr,0),u(this,ss,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,U,Bp).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=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=i;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}
45),c=w,d=S}if(o.length===0)return{img:t,paintWidth:s,paintHeight:i,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,i,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=i,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 N,Z;const s=this.ctx,{width:i,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=wt(s);let h,c,d,f;if((e.bitmap||e.data)&&e.count>1){const q=e.bitmap||e.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),a]),h=this._cachedBitmapsMap.getOrInsertComputed(q,Yg);const J=h.get(c);if(J&&!o){const $t=Math.round(Math.min(l[0],l[2])+l[4]),F=Math.round(Math.min(l[1],l[3])+l[5]);return(N=this.dependencyTracker)==null||N.recordDependencies(t,Ss.transformAndFill),{canvas:J,offsetX:$t,offsetY:F}}d=J}d||(f=this.canvasFactory.create(i,r),Nm(f.context,e));let g=D.transform(l,[1/i,0,0,-1/r,0,0]);g=D.transform(g,[1,0,0,1,0,-r]);const y=Zr.slice();D.axialAlignedBoundingBox([0,0,i,r],g,y);const[A,v,w,S]=y,E=Math.round(w-A)||1,x=Math.round(S-v)||1,C=this.canvasFactory.create(E,x),_=C.context,k=A,P=v;_.translate(-k,-P),_.transform(...g);let M=null;if(!d){const q=this._scaleImage(f.canvas,ai(_));d=q.img,M=q.tmpCanvas,d!==f.canvas&&(this.canvasFactory.destroy(f),f=null),h&&o&&(h.set(c,d),M=null,f=null)}_.imageSmoothingEnabled=Bm(wt(_),e.interpolate),qd(_,d,0,0,d.width,d.height,0,0,i,r),M&&this.canvasFactory.destroy(M),f&&this.canvasFactory.destroy(f),_.globalCompositeOperation="source-in";const L=D.transform(ai(_),[1,0,0,1,-k,-P]);return _.fillStyle=o?a.getPattern(s,this,L,be.FILL,t):a,_.fillRect(0,0,i,r),h&&!o&&h.set(c,C.canvas),(Z=this.dependencyTracker)==null||Z.recordDependencies(t,Ss.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=P0[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=M0[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 i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,i,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":(i=this.dependencyTracker)==null||i.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:i,transferMap:r}=t,a=s==="Luminosity"||s==="Alpha"&&r;
45if(!a&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=t;return}let o;if(s==="Luminosity"&&i){const[S,E,x]=Vd(i),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"?i: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,i,r,a,o){!a&&!o&&et("_bakeSMaskCanvas with neither backdrop nor filter");const l=this.canvasFactory.create(i,r),h=l.context;if(h.drawImage(t,e,s),a&&(h.globalCompositeOperation="destination-atop",h.fillStyle=a,h.fillRect(0,0,i,r)),!o)return l;const c=this.canvasFactory.create(i,r),d=c.context;d.filter=o.url;const f=pt.isCanvasFilterSupported&&d.filter!=="none"&&d.filter!=="";if(d.drawImage(l.canvas,0,0),pt.isCanvasFilterSupported&&(d.filter="none"),!f){const g=d.getImageData(0,0,i,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,i=this.canvasFactory.create(e,s);this.smaskScratchCanvas=i,this.suspendedCtx=this.ctx;const r=this.ctx=i.context;r.setTransform(this.suspendedCtx.getTransform()),zr(this.suspendedCtx,r),Fm(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,i=n(this,fr)>0&&s===this.ctx;this.composeSMask(i?null:s,e,this.ctx,t),!i&&(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,s,i){const r=i[0],a=i[1],o=i[2]-r,l=i[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,i,r,a,o,l,h,c){const d=a<l&&o<h;if(d&&a===e&&o===s&&l===e+i&&h===s+r)return;const f=new Path2D;f.rect(e,s,i,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,i,r),t.restore()}genericComposeSMask(t,e,s,i,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,i),e.clip(c),e.globalCompositeOperation="destination-in",e.drawImage(o.canvas,r-l,a-h,s,i,r,a,s,i),e.restore(
45)}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,i,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[r]=s;if(!i){r||(r=s[0]=new Path2D),e!==ci.stroke&&e!==ci.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,r);return}if(this.dependencyTracker!==null){const o=e===ci.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-o,i[2]+o,i[1]-o,i[3]+o).recordDependencies(t,["transform"])}r instanceof Path2D||(r=s[0]=Jm(r)),D.axialAlignedBoundingBox(i,wt(this.ctx),this.current.minMax);const a=this.current.tilingPatternDims;if(a&&e!==ci.stroke&&e!==ci.closeStroke&&this.current.fillColor instanceof Xh){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 i=s&&b(this,U,Ge).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,ai(r),be.STROKE,t),l){const h=new Path2D;h.addPath(e,r.getTransform().invertSelf().multiplySelf(l)),e=h}this.rescaleAndStroke(e,!1),r.restore()}else this.rescaleAndStroke(e,!0);(o=this.dependencyTracker)==null||o.recordDependencies(t,Ss.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(be.STROKE,wt(this.ctx))),r.globalAlpha=this.current.fillAlpha,b(this,U,ve).call(this,i)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var c,d,f;const i=s&&b(this,U,Ge).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,Ss.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,U,ve).call(this,i);return}const A=a.isModifyingCurrentTransform()?r.getTransform():null;if((d=this.dependencyTracker)==null||d.save(t),r.save(),r.fillStyle=a.getPattern(r,this,ai(r),be.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,U,ve).call(this,i)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const s=b(this,U,Ge).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,U,ve).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 i;const s=b(this,U,Ge).call(this,this.current.fillAlpha);this.ctx.fill(e),(i=this.dependencyTracker)==null||i.recordDependencies(t,Ss.rawFillPath).recordOperation(t),b(this,U,ve).call(this,s)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=D0}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=Hm}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,
45(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:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){const i=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:h,path:c}of e)c&&i.addPath(c,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(h,-h));s.clip(i)}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 i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||Qf,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&X("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const a=i.loadedName||"sans-serif",o=((f=i.systemFontInfo)==null?void 0:f.css)||`"${a}", ${i.fallbackName}`;let l="normal";i.black?l="900":i.bold&&(l="bold");const h=i.italic?"italic":"normal",c=Et(s,_0,T0);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 i;(i=this.dependencyTracker)==null||i.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 i;(i=this.dependencyTracker)==null||i.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)}paintChar(t,e,s,i,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&Jt.FILL_STROKE_MASK,g=!!(c&Jt.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,i),o.scale(d,-d),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,o,h);let C;if(f===Jt.FILL||f===Jt.FILL_STROKE)if(r){C=o.getTransform(),o.setTransform(...r);const _=b(this,U,$p).call(this,v,C,r);o.fill(_)}else o.fill(v);if(f===Jt.STROKE||f===Jt.FILL_STROKE)if(a){C||(C=o.getTransform()),o.setTransform(...a);const{a:_,b:k,c:P,d:M}=C,L=D.inverseTransform(a),N=D.transform([_,k,P,M,0,0],L);D.singularValueDecompose2dScale(N,ms),o.lineWidth*=Math.max(ms[0],ms[1])/d,o.stroke(b(this,U,$p).call(this,v,C,a))}else o.lineWidth/=d,o.stroke(v);o.restore()}else(f===Jt.FILL||f===Jt.FILL_STROKE)&&(o.fillText(e,s,i),(S=this.dependencyTracker)==null||S.recordCharacterBBox(t,o,h,d,s,i,()=>o.measureText(e))),(f===Jt.STROKE||f===Jt.FILL_STROKE)&&(this.dependencyTracker&&((E=this.dependencyTracker)==null||E.recordCharacterBBox(t,o,h,d,s,i,()=>o.measureText(e)).recordDependencies(t,Ss.stroke)),o.strokeText(e,s,i));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:wt(o),x:s,y:i,fontSize:d,path:v}),(x=this.dependencyTracker)==null||x.recordCharacterBBox(t,o,h,d,s,i))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,
4510),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 i=!1;for(let r=3;r<s.length;r+=4)if(s[r]>0&&s[r]<255){i=!0;break}return $(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var Z,q,J,$t;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Ss.showText).resetBBox(t),this.current.textRenderingMode&Jt.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){const F=b(this,U,Ge).call(this,s.fillAlpha);this.showType3Text(t,e),(Z=this.dependencyTracker)==null||Z.recordShowTextOperation(t),b(this,U,ve).call(this,F);return}const r=s.fontSize;if(r===0){(q=this.dependencyTracker)==null||q.recordOperation(t);return}const a=b(this,U,Ge).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=i.vertical,A=y?1:-1,v=i.defaultVMetrics,w=r*s.fontMatrix[0],S=s.textRenderingMode===Jt.FILL&&!i.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&Jt.FILL_STROKE_MASK,_=C===Jt.FILL||C===Jt.FILL_STROKE,k=C===Jt.STROKE||C===Jt.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,_&&s.patternFill){o.save();const F=s.fillColor.getPattern(o,this,ai(o),be.FILL,t);E=wt(o),o.restore(),o.fillStyle=F}if(k&&s.patternStroke){o.save();const F=s.strokeColor.getPattern(o,this,ai(o),be.STROKE,t);x=wt(o),o.restore(),o.strokeStyle=F}if(i.isInvalidPDFjsFont){const F=[];let H=0;for(const Ct of e)F.push(Ct.unicode),H+=Ct.width;const xt=F.join("");if(o.fillText(xt,0,0),this.dependencyTracker!==null){const Ct=o.measureText(xt);this.dependencyTracker.recordBBox(t,this.ctx,-Ct.actualBoundingBoxLeft,Ct.actualBoundingBoxRight,-Ct.actualBoundingBoxAscent,Ct.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=H*w*f,o.restore(),this.compose(),b(this,U,ve).call(this,a);return}let L=0,N;for(N=0;N<g;++N){const F=e[N];if(typeof F=="number"){L+=A*F*r/1e3;continue}let H=!1;const xt=(F.isSpace?c:0)+h,Ct=F.fontChar,Pe=F.accent;let ce,jt,lt=F.width;if(y){const ie=F.vmetric||v,yt=-(F.vmetric?ie[1]:lt*.5)*w,Uf=ie[2]*w;lt=ie?-ie[0]:lt,ce=yt/l,jt=(L+Uf)/l}else ce=L/l,jt=0;let ri;if(i.remeasure&&lt>0){ri=o.measureText(Ct);const ie=ri.width*1e3/r*l;if(lt<ie&&this.isFontSubpixelAAEnabled){const yt=lt/ie;H=!0,o.save(),o.scale(yt,1),ce/=yt}else lt!==ie&&(ce+=(lt-ie)/2e3*r/l)}if(this.contentVisible&&(F.isInFont||i.missingFile)){if(S&&!Pe)o.fillText(Ct,ce,jt),(J=this.dependencyTracker)==null||J.recordCharacterBBox(t,o,ri?{bbox:null}:i,r/l,ce,jt,()=>ri??o.measureText(Ct));else if(this.paintChar(t,Ct,ce,jt,E,x),Pe){const ie=ce+r*Pe.offset.x/l,yt=jt-r*Pe.offset.y/l;this.paintChar(t,Pe.fontChar,ie,yt,E,x)}}const vh=y?lt*w-xt*d:lt*w+xt*d;L+=vh,H&&o.restore()}y?s.y-=L:s.x+=L*f,o.restore(),this.compose(),($t=this.dependencyTracker)==null||$t.recordShowTextOperation(t),b(this,U,ve).call(this,a)}showType3Text(t,e){const s=this.ctx,i=this.current,r=i.font,a=i.fontSize,o=i.fontDirection,l=r.vertical?1:-1,h=i.charSpacing,c=i.wordSpacing,d=i.textHScale*o,f=i.fontMatrix||Qf,g=e.length,y=i.textRenderingMode===Jt.INVISIBLE;let A,v,w,S;if(y||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(d,o);const E=this.dependencyTracker;for(this.dependencyTracker=E?new Jh(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),i.x+=S*d;continue}const x=(v.isSpace?c:0)+h,C=r.charProcOperatorList.get(v.operatorListId);C?this.contentVisible&&(this.save(),C.fnArray[0]===ci.setCharWidth&&(i.fillAlpha=i.strokeAlpha=1,s.globalAlpha=1),s.scale(a,a),s.transform(...f),this.executeOperatorList(C),this.restore()):X(`Type3 character "${v.operatorListId}" is not available.`);const _=[v.width,0];D.applyTransform(_,f),w=_[0]*a+x,s.translate(w,0),i.x+=w*d}
45s.restore(),E&&(this.dependencyTracker=E)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,r,a,o){var h;const l=new Path2D;l.rect(i,r,a-i,o-r),this.ctx.clip(l),(h=this.dependencyTracker)==null||h.recordBBox(t,this.ctx,i,a,r,o).recordClipBox(t,this.ctx,i,a,r,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const i=this.baseTransform||wt(this.ctx),r={createCanvasGraphics:(a,o)=>new qr(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Jh(this.dependencyTracker,o,!0):null)};s=new Xh(e,this.ctx,r,i)}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 i;(i=this.dependencyTracker)==null||i.recordSimpleData("fillColor",t);const s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof Xh?[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 i=this.cachedPatterns.getOrInsertComputed(e,()=>C0(this.getObject(t,e)));return s&&(i.matrix=s),i}shadingFill(t,e){var o;if(!this.contentVisible)return;const s=b(this,U,Ge).call(this,this.current.fillAlpha),i=this.ctx;this.save(t);const r=this._getPattern(t,e);i.fillStyle=r.getPattern(i,this,ai(i),be.SHADING,t);const a=ai(i);if(a){const{width:l,height:h}=i.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,Ss.transform).recordDependencies(t,Ss.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),b(this,U,ve).call(this,s)}beginInlineImage(){et("Should not call beginInlineImage")}beginImageData(){et("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var i;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=wt(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),(i=this.dependencyTracker)==null||i.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 i=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&n(this,ss)===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let C=new Path2D;const[_,k,P,M]=e.bbox;if(C.rect(_,k,P-_,M-k),e.matrix){const L=new Path2D;L.addPath(C,new DOMMatrix(e.matrix)),C=L}i.clip(C)}this.groupStack.push(null),n(this,xi).push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&n(this,ss)===0&&kf("TODO: Fully support non-isolated non-knockout groups.");const r=wt(i);e.matrix&&i.transform(...e.matrix);const a=[0,0,i.canvas.width,i.canvas.height];let o;e.bbox?(o=Zr.slice(),D.axialAlignedBoundingBox(e.bbox,wt(i),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?i:null,A=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&n(this,ss)>0,v=e.knockout?this.canvasFactory.create(c,d):null,w=n(this,ss);e.knockout?Dt(this,ss)._++:u(this,ss,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&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none";if(S&&(s||E)&&(g.save(),g.setTransform(1,0,0,1,0,0),g.drawImage(i.canvas,-l,-h),g.restore()),e.bbox){let C=new Path2D;const[_,k,P,M]=e.bbox;if(C.rect(_,k,P-_,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)&&(i.setTransform(1,0,0,1,0,0),i.translate(l,h),i.save()),zr(i,g),this.ctx=g,(x=this.dependencyTracker)==null||x.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),n(this,xi).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,i=this.groupStack.pop(),r=n(this,xi).pop();if(r&&u(this,ss,r.savedKnockoutLevel),i===null){this.restore(t);return}if(e.isGray&&b(this,U,Yb).call(this,s),this.ctx=i,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,U,mu).call(this,r);else{this.ctx.restore();const o=wt(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=n(this,xi).at(-1);if(n(this,ss)>0)if(r.hasInnerBackdrop){const{width:c,height:d}=s.canvas,f=this.canvasFactory.create(c,d),g=f.context;g.drawImage(i.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,U,Hp).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,pt.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,pt.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,U,Gp).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,U,mu).call(this,r),this.compose(l)}}beginAnnotation(t,e,s,i,r,a,o){if(b(this,U,Np).call(this),Qd(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){i=i.slice(),i[4]-=s[0],i[5]-=s[1],D.singularValueDecompose2dScale(wt(this.ctx),ms);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,wh);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(ms[0],0,0,-ms[1],0,h*ms[1]),Qd(this.ctx)}else{Qd(this.ctx),this.endPath(t);const c=new Path2D;c.rect(s[0],s[1],l,h),this.ctx.clip(c)}}this.current=new Rm(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...r),this.baseTransform=wt(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),b(this,U,Bp).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 i=b(this,U,Ge).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,U,ve).call(this,i)}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,a,o){var f,g,y;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=b(this,U,Ge).call(this,this.current.fillAlpha),h=this.ctx;h.save();const c=wt(h);h.transform(s,i,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,i,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,U,ve).call(this,l)}paintImageMaskXObjectGroup(t,e){var o,l,h;if(!this.contentVisible)return;const s=b(this,U,Ge).call(this,this.current.fillAlpha),i=this.ctx,r=this.current.fillColor,a=this.current.patternFill;(o=this.dependencyTracker)==null||o.resetBBox(t).recordDependencies(t,Ss.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);Nm(v,w),v.globalCompositeOperation="source-in",v.fillStyle=a?r.getPattern(v,this,ai(i),be.FILL,t):r,v.fillRect(0,0,f,g),v.restore(),i.save(),i.transform(...y),i.scale(1,-1),qd(i,A.canvas,0,0,f,g,0,-1,1,1),this.canvasFactory.destroy(A),(l=this.dependencyTracker)==null||l.recordBBox(t,i,0,f,0,g),i.restore()}this.compose(),(h=this.dependencyTracker)==null||h.recordOperation(t),b(this,U,ve).call(this,s)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){X("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,r){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a){X("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,i,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:i}=t,r=this.canvasFactory.create(s,i),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,i=e.height,r=b(this,U,Ge).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/i);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,i);Om(f.context,e),l=this.applyTransferMapsToCanvas(f.context),h=f}const c=this._scaleImage(l,ai(a));a.imageSmoothingEnabled=Bm(wt(a),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,a,0,s,-i,0).recordDependencies(t,Ss.imageXObject).recordOperation(t),(d=this.imagesTracker)==null||d.record(a,s,i,this.dependencyTracker.clipBox)),qd(a,c.img,0,0,c.paintWidth,c.paintHeight,0,-i,s,i),c.tmpCanvas&&this.canvasFactory.destroy(c.tmpCanvas),h&&this.canvasFactory.destroy(h),this.compose(),this.restore(t),b(this,U,ve).call(this,r)}paintInlineImageXObjectGroup(t,e,s){var l,h,c;if(!this.contentVisible)return;const i=b(this,U,Ge).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);Om(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),qd(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,U,ve).call(this,i)}paintSolidColorImageMask(t){var s;if(!this.contentVisible)return;const e=b(this,U,Ge).call(this,this.current.fillAlpha);(s=this.dependencyTracker)==null||s.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ss.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),b(this,U,ve).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 i;(i=this.dependencyTracker)==null||i.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 i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(i||(this.pendingClip===Hm?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=wt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:r}=this.ctx.getTransform();let a,o;if(s===0&&i===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*i),h=Math.hypot(e,s),c=Math.hypot(i,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:i}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(i||1)*r,s.stroke(t);return}const o=n(qr,df)??u(qr,df,new DOMMatrix),l=s.getLineDash();e&&s.save(),s.scale(r,a),o.a=1/r,o.d=1/a;const h=new Path2D;if(h.addPath(t,o),l.length>0){const c=Math.max(r,a);
45s.setLineDash(l.map(d=>d/c)),s.lineDashOffset/=c}s.lineWidth=i||1,s.stroke(h),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};df=new WeakMap,ss=new WeakMap,fr=new WeakMap,Ia=new WeakMap,La=new WeakMap,Fa=new WeakMap,Ra=new WeakMap,Oa=new WeakMap,Na=new WeakMap,Ba=new WeakMap,xi=new WeakMap,U=new WeakSet,Np=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)},Bp=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}}},Hp=function(t,e=null,s=1){const{width:i,height:r}=t,a=e??this.canvasFactory.create(i,r),o=a.context;s=Math.round(s*255)/255;const l=s<1;l&&n(this,Na)===void 0&&u(this,Na,pt.isCanvasFilterSupported?new Map:"none");let h="none";if(l&&n(this,Na)instanceof Map&&(h=n(this,Na).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,i,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,i,r),d=o.createImageData(i,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},Up=function(t,e,s,i){let r=(t==null?void 0:t[e])??null;if(r&&(r.canvas.width!==s||r.canvas.height!==i)&&(this.canvasFactory.destroy(r),r=null),!r)return r=this.canvasFactory.create(s,i),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,i),a.restore(),r},Gp=function(t,e,s={}){const{backdropCanvas:i=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,U,Hp).call(this,e,o,d),A=t.globalCompositeOperation;if(t.save(),t.setTransform(...r),t.globalAlpha=1,pt.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(y.canvas,0,0),i){const[v,w]=a,S=b(this,U,Up).call(this,l,"knockoutBackdropEntry",f,g),E=S.context;E.drawImage(i,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,pt.isCanvasFilterSupported&&(t.filter=c??"none"),t.drawImage(e,0,0),t.restore(),o||this.canvasFactory.destroy(y)},Ge=function(t=1){if(n(this,ss)===0||n(this,fr)>0||!this.contentVisible)return!1;Dt(this,fr)._++,u(this,Oa,t);const e=n(this,xi).at(-1),{canvas:s}=this.ctx,i=b(this,U,Up).call(this,e,"knockoutTempEntry",s.width,s.height);u(this,Ia,i);const r=i.context;return r.save(),r.setTransform(this.ctx.getTransform()),zr(this.ctx,r),u(this,Ra,r.globalCompositeOperation),r.globalCompositeOperation="source-over",Fm(r,this.ctx),u(this,Ba,e),u(this,La,this.ctx),u(this,Fa,this.suspendedCtx),this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0},ve=function(t){var l;if(!t)return;const e=n(this,Ia),s=n(this,La),i=n(this,Fa),r=e.context;u(this,Ia,null),u(this,La,null),u(this,Fa,null),this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=i),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=n(this,Ra),u(this,Ra,null),zr(this.ctx,s),this.ctx=s;const a=n(this,Ba);u(this,Ba,null);const o=n(this,Oa);u(this,Oa,1);try{b(this,U,Gp).call(this,i??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(),Dt(this,fr)._--,a||this.canvasFactory.destroy(e)}},$p=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i},Yb=function(t){const{canvas:e}=t,{width:s,height:i}=e;if(pt.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,i),{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)},mu=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))},m(qr,df,null);let zo=qr;for(const p in ci)zo.prototype[p]!==void 0&&(zo.prototype[ci[p]]=zo.prototype[p]);var Rc,Oc;class If{constructor(t,e,s){m(this,Rc,null);m(this,Oc,null);T(this,"_fullReader",null);T(this,"_rangeReaders",new Set);T(this,"_source",null);this._source=t,u(this,Rc,e),u(this,Oc,s)}get _progressiveDataLength(){var t;return((t=this._fullReader)==null?void 0:t._loaded)??0}getFullReader(){return Nt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new(n(this,Rc))(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new(n(this,Oc))(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)}}Rc=new WeakMap,Oc=new WeakMap;class Lf{constructor(t){T(this,"onProgress",null);T(this,"_contentLength",0);T(this,"_filename",null);T(this,"_headersCapability",Promise.withResolvers());T(this,"_isRangeSupported",!1);T(this,"_isStreamingSupported",!1);T(this,"_loaded",0);T(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(){et("Abstract method `read` called")}cancel(t){et("Abstract method `cancel` called")}}class Ff{constructor(t,e,s){T(this,"_stream",null);this._stream=t}async read(){et("Abstract method `read` called")}cancel(t){et("Abstract method `cancel` called")}}function I0(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 i(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const f=new TextDecoder(c,{fatal:!0}),g=Pf(d);d=f.decode(g),t=!1}catch{}}return d}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("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 i(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))}),i(f,y);try{y=atob(y)}catch{}return i(f,y)})}return""}function Kb(p,t){const e=new Headers;if(!p||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function L0(p){let t=p.length;for(;t>0&&p[t-1]!==" "&&/\s/.test(p[t-1]);)t--;return p.slice(0,t)}function Rf(p){var t;return((t=URL.parse(p))==null?void 0:t.origin)??null}function qb({responseHeaders:p,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={contentLength:0,isRangeSupported:!1},r=parseInt(p.get("Content-Length"),10);return!Number.isInteger(r)||(i.contentLength=r,r<=2*e)||s||!t||p.get("Accept-Ranges")!=="bytes"||(p.get("Content-Encoding")||"identity")==="identity"&&(i.isRangeSupported=!0),i}function Qb(p){const t=p.get("Content-Disposition");if(t){let e=I0(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Jg(e))return e}return null}
45function Of(p,t){return new zu(`Unexpected server response (${p}) while retrieving PDF "${t.href}".`,p,p===404||p===0&&t.protocol==="file:")}function Jb(p,t){if(p!==t)throw new Error(`Expected range response-origin "${p}" to match "${t}".`)}function Zb(p,t,e,s){return fetch(p,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function ty(p,t){if(p!==200&&p!==206)throw Of(p,t)}function Nf(p){if(p instanceof Uint8Array)return p.buffer;if(p instanceof ArrayBuffer)return p;throw new Error(`getArrayBuffer - unexpected data: ${p}`)}class F0 extends If{constructor(e){super(e,R0,O0);T(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;Nt(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Kb(!0,s)}}class R0 extends Lf{constructor(e){super(e);T(this,"_abortController",new AbortController);T(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:r,url:a,withCredentials:o}=e._source;this._isStreamingSupported=!i;const l=new Headers(e.headers);Zb(a,l,o,this._abortController).then(h=>{e._responseOrigin=Rf(h.url),ty(h.status,a),this._reader=h.body.getReader();const c=h.headers,{contentLength:d,isRangeSupported:f}=qb({responseHeaders:c,isHttp:!0,rangeChunkSize:r,disableRange:s});this._contentLength=d,this._isRangeSupported=f,this._filename=Qb(c),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Gr("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:Nf(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}class O0 extends Ff{constructor(e,s,i){super(e,s,i);T(this,"_abortController",new AbortController);T(this,"_readCapability",Promise.withResolvers());T(this,"_reader",null);const{url:r,withCredentials:a}=e._source,o=new Headers(e.headers);o.append("Range",`bytes=${s}-${i-1}`),Zb(r,o,a,this._abortController).then(l=>{const h=Rf(l.url);Jb(h,e._responseOrigin),ty(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:Nf(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}function Um(p){return p instanceof Uint8Array&&p.byteLength===p.buffer.byteLength?p.buffer:new Uint8Array(p).buffer}function Bf(){for(const p of this._requests)p.resolve({value:void 0,done:!0});this._requests.length=0}var uf,ey;class N0 extends If{constructor(e){super(e,B0,H0);m(this,uf);T(this,"_progressiveDone",!1);T(this,"_queuedChunks",[]);const{pdfDataRangeTransport:s}=e,{initialData:i,progressiveDone:r}=s;if((i==null?void 0:i.length)>0){const o=Um(i);this._queuedChunks.push(o)}this._progressiveDone=r;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":b(this,uf,ey).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 i=super.getRangeReader(e,s);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(e,s)),i}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}}uf=new WeakSet,ey=function(e,s){const i=Um(s);if(e===void 0)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const r=this._rangeReaders.keys().find(a=>a._begin===e);Nt(r,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),r._enqueue(i)}};var Nc;class B0 extends Lf{constructor(e){super(e);m(this,Nc,Bf.bind(this));T(this,"_done",!1);T(this,"_queuedChunks",null);T(this,"_requests",[]);const{pdfDataRangeTransport:s,disableRange:i,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=!i,Jg(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,n(this,Nc).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&n(this,Nc).call(this)}}Nc=new WeakMap;var Bc;class H0 extends Ff{constructor(e,s,i){super(e,s,i);m(this,Bc,Bf.bind(this));T(this,"onDone",null);T(this,"_begin",-1);T(this,"_done",!1);T(this,"_queuedChunk",null);T(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}),n(this,Bc).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,n(this,Bc).call(this),(s=this.onDone)==null||s.call(this)}}Bc=new WeakMap;const Kf=200,Gm=206;function U0(p){return typeof p!="string"?p:Pf(p).buffer}var Ci,Ah,sy,iy;class G0 extends If{constructor(e){super(e,$0,z0);m(this,Ah);m(this,Ci,new WeakMap);T(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=Kb(this.isHttp,s)}_request(e){const s=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};n(this,Ci).set(s,i),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}`),i.validateStatus=r=>r===Gm||r===Kf):i.validateStatus=r=>r===Kf,s.responseType="arraybuffer",Nt(e.onError,"Expected `onError` callback to be provided."),s.onerror=()=>e.onError(s.status),s.onreadystatechange=b(this,Ah,iy).bind(this,s),s.onprogress=b(this,Ah,sy).bind(this,s),s.send(null),s}
45_abortRequest(e){n(this,Ci).has(e)&&(n(this,Ci).delete(e),e.abort())}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}Ci=new WeakMap,Ah=new WeakSet,sy=function(e,s){var r;const i=n(this,Ci).get(e);(r=i==null?void 0:i.onProgress)==null||r.call(i,s)},iy=function(e,s){const i=n(this,Ci).get(e);if(!i||(e.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),e.readyState!==4)||!n(this,Ci).has(e))return;if(n(this,Ci).delete(e),e.status===0&&this.isHttp){i.onError(e.status);return}const r=e.status||Kf;if(!i.validateStatus(r)){i.onError(e.status);return}const a=U0(e.response);if(r===Gm){const o=e.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(o)?i.onDone(a):(X('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone(a):i.onError(e.status)};var Hc,Hi,ny,ry,ay,oy;class $0 extends Lf{constructor(e){super(e);m(this,Hi);m(this,Hc,Bf.bind(this));T(this,"_cachedChunks",[]);T(this,"_done",!1);T(this,"_requests",[]);T(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:b(this,Hi,ny).bind(this),onDone:b(this,Hi,ry).bind(this),onError:b(this,Hi,ay).bind(this),onProgress:b(this,Hi,oy).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),n(this,Hc).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}Hc=new WeakMap,Hi=new WeakSet,ny=function(){const e=this._stream,{disableRange:s,rangeChunkSize:i}=e._source,r=this._fullRequestXhr;e._responseOrigin=Rf(r.responseURL);const a=r.getAllResponseHeaders(),o=new Headers(a?L0(a.trimStart()).split(/[\r\n]+/).map(c=>{const[d,...f]=c.split(": ");return[d,f.join(": ")]}):[]),{contentLength:l,isRangeSupported:h}=qb({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:i,disableRange:s});this._contentLength=l,this._isRangeSupported=h,this._filename=Qb(o),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()},ry=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&&n(this,Hc).call(this)},ay=function(e){this._storedError=Of(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},oy=function(e){var s;(s=this.onProgress)==null||s.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})};var Uc,Ln,ly,hy,zp;class z0 extends Ff{constructor(e,s,i){super(e,s,i);m(this,Ln);m(this,Uc,Bf.bind(this));T(this,"onClosed",null);T(this,"_done",!1);T(this,"_queuedChunk",null);T(this,"_requests",[]);T(this,"_storedError",null);this._requestXhr=e._request({begin:s,end:i,onHeadersReceived:b(this,Ln,ly).bind(this),onDone:b(this,Ln,hy).bind(this),onError:b(this,Ln,zp).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,n(this,Uc).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}Uc=new WeakMap,Ln=new WeakSet,ly=function(){var s;const e=Rf((s=this._requestXhr)==null?void 0:s.responseURL);try{Jb(e,this._stream._responseOrigin)}catch(i){this._storedError=i,b(this,Ln,zp).call(this,0)}},hy=function(e){var s;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,n(this,Uc).call(this),(s=this.onClosed)==null||s.call(this)},zp=function(e){this._storedError??(this._storedError=Of(e,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function cy(p,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),i=e.createReadStream(p,t);return s.toWeb(i)}class V0 extends If{constructor(t){super(t,j0,W0);const{url:e}=t;Nt(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class j0 extends Lf{constructor(e){super(e);T(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:r,url:a}=e._source;this._isStreamingSupported=!i,process.getBuiltinModule("fs/promises").lstat(a).then(l=>{const h=cy(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 Gr("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=Of(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:Nf(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}class W0 extends Ff{constructor(e,s,i){super(e,s,i);T(this,"_readCapability",Promise.withResolvers());T(this,"_reader",null);const{url:r}=e._source;try{const a=cy(r,{start:s,end:i-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:Nf(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}function X0(p){return Wh(p)?F0:gs?V0:G0}var Gc,$c;class Tn{static get workerPort(){return n(this,Gc)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");u(this,Gc,t)}static get workerSrc(){return n(this,$c)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");u(this,$c,t)}}Gc=new WeakMap,$c=new WeakMap,m(Tn,Gc,null),m(Tn,$c,"");var El,zc;class Y0{constructor({parsedData:t,rawData:e}){m(this,El);m(this,zc);u(this,El,t),u(this,zc,e)}getRaw(){return n(this,zc)}get(t){return n(this,El).get(t)??null}[Symbol.iterator](){return n(this,El).entries()}}El=new WeakMap,zc=new WeakMap;const Wr=Symbol("INTERNAL");var Vc,jc,xl,Ha;class K0{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){m(this,Vc,!1);m(this,jc,!1);m(this,xl,!1);m(this,Ha,!0);u(this,Vc,!!(t&ps.DISPLAY)),u(this,jc,!!(t&ps.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,xl))return n(this,Ha);
45if(!n(this,Ha))return!1;const{print:t,view:e}=this.usage;return n(this,Vc)?(e==null?void 0:e.viewState)!=="OFF":n(this,jc)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==Wr&&et("Internal method `_setVisible` called."),u(this,xl,s),u(this,Ha,e)}get serializable(){return{userSet:n(this,xl),visible:n(this,Ha)}}}Vc=new WeakMap,jc=new WeakMap,xl=new WeakMap,Ha=new WeakMap;var pr,it,Cl,_l,Wc,Xc,jp;const cm=class cm{constructor(t,e=ps.DISPLAY,s=null){m(this,Xc);m(this,pr,null);m(this,it,new Map);m(this,Cl,null);m(this,_l,null);m(this,Wc);T(this,"creator",null);T(this,"name",null);if(u(this,Wc,t),this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,u(this,_l,t.order);for(const i of t.groups)n(this,it).set(i.id,new K0(e,i));if(s){s.size!==n(this,it).size&&et("Incorrect serialized groupState.");for(const[i,r]of s)n(this,it).get(i)._setVisible(Wr,r.visible,r.userSet)}else{if(t.baseState==="OFF")for(const i of n(this,it).values())i._setVisible(Wr,!1);for(const i of t.on)n(this,it).get(i)._setVisible(Wr,!0);for(const i of t.off)n(this,it).get(i)._setVisible(Wr,!1)}u(this,Cl,this.getHash())}}isVisible(t){if(n(this,it).size===0)return!0;if(!t)return kf("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,it).has(t.id)?n(this,it).get(t.id).visible:(X(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,Xc,jp).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,it).has(e))return X(`Optional content group not found: ${e}`),!0;if(n(this,it).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,it).has(e))return X(`Optional content group not found: ${e}`),!0;if(!n(this,it).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,it).has(e))return X(`Optional content group not found: ${e}`),!0;if(!n(this,it).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,it).has(e))return X(`Optional content group not found: ${e}`),!0;if(n(this,it).get(e).visible)return!1}return!0}return X(`Unknown optional content policy ${t.policy}.`),!0}return X(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,it).get(t);if(!i){X(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((r=n(this,it).get(o))==null||r._setVisible(Wr,!1,!0));i._setVisible(Wr,!!e,!0),u(this,pr,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=n(this,it).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}u(this,pr,null)}get hasInitialVisibility(){return n(this,Cl)===null||this.getHash()===n(this,Cl)}getOrder(){return n(this,it).size?n(this,_l)?n(this,_l).slice():[...n(this,it).keys()]:null}getGroup(t){return n(this,it).get(t)||null}getHash(){if(n(this,pr)!==null)return n(this,pr);const t=new kp;for(const[e,s]of n(this,it))t.update(`${e}:${s.visible}`);return u(this,pr,t.hexdigest())}[Symbol.iterator](){return n(this,it).entries()}get serializable(){const t=new Map;for(const[e,s]of n(this,it))t.set(e,s.serializable);return{data:n(this,Wc),renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new cm(t,e,s)}};pr=new WeakMap,it=new WeakMap,Cl=new WeakMap,_l=new WeakMap,Wc=new WeakMap,Xc=new WeakSet,jp=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const r=t[i];let a;if(Array.isArray(r))a=b(this,Xc,jp).call(this,r);else if(n(this,it).has(r))a=n(this,it).get(r).visible;else return X(`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 Vp=cm;var Rt,Is,Zt,Ua,_i,we,Nh,bu,Wp,Xp;class q0{constructor(){m(this,we);m(this,Rt,null);m(this,Is,null);m(this,Zt,0);m(this,Ua,null);m(this,_i,null)}get pagesNumber(){return n(this,Zt)}set pagesNumber(t){n(this,Zt)!==t&&(u(this,Zt,t),u(this,Rt,null),u(this,Is,null))}movePages(t,e,s){b(this,we,Nh).call(this);const i=n(this,Rt),r=e.length,a=new Uint32Array(r);let o=0;for(let f=0;f<r;f++){const g=e[f]-1;a[f]=i[g],g<s&&o++}const l=n(this,Zt),h=l-r,c=new Int32Array(l),d=Et(s-o,0,h);for(let f=0,g=0;f<l;f++)t.has(f+1)||(i[g]=i[f],c[g++]=f+1);i.copyWithin(d+r,d,h),i.set(a,d),c.copyWithin(d+r,d,h),c.set(e,d),u(this,Is,c),i.every((f,g)=>f===g+1)&&u(this,Rt,null)}deletePages(t){b(this,we,Nh).call(this);const e=n(this,Rt),s=b(this,we,bu).call(this);u(this,_i,{pageNumberToId:e.slice(),pagesNumber:n(this,Zt),prevPageNumbers:n(this,Is).slice()});const i=n(this,Zt)-t.length;u(this,Zt,i);const r=u(this,Rt,new Uint32Array(i));u(this,Is,new Int32Array(i));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,we,Wp).call(this,s,new Set(t))}cancelDelete(){n(this,_i)&&(u(this,Rt,n(this,_i).pageNumberToId),u(this,Zt,n(this,_i).pagesNumber),u(this,Is,n(this,_i).prevPageNumbers),u(this,_i,null))}cleanSavedData(){u(this,_i,null)}copyPages(t){b(this,we,Nh).call(this),u(this,Ua,{pageNumbers:t,pageIds:t.map(e=>n(this,Rt)[e-1])})}cancelCopy(){u(this,Ua,null)}pastePages(t){b(this,we,Nh).call(this);const e=n(this,Rt),s=b(this,we,bu).call(this),{pageNumbers:i,pageIds:r}=n(this,Ua),a=n(this,Zt)+i.length;u(this,Zt,a);const o=u(this,Rt,new Uint32Array(a));u(this,Is,new Int32Array(a)),o.set(e.subarray(0,t),0),o.set(r,t),o.set(e.subarray(t),t+i.length),b(this,we,Wp).call(this,s,null,t,i),u(this,Ua,null)}hasBeenAltered(){return n(this,Rt)!==null}getPageMappingForSaving(t=null,e=b(this,we,Xp).call(this)){t??(t=b(this,we,bu).call(this));let s=0;for(const r of t.values())s=Math.max(s,r.length);const i=new Array(s);for(let r=0;r<s;r++)i[r]={document:null,pageIndices:[],includePages:[]};for(const[r,a]of t)for(let o=0,l=a.length;o<l;o++)i[o].includePages.push([r-1,a[o]-1]);for(const{includePages:r,pageIndices:a}of i){r.sort((o,l)=>o[0]-l[0]);for(let o=0,l=r.length;o<l;o++)a.push(r[o][1]),r[o]=r[o][0]}return{pageInfos:i,copyLevels:e}}extractPages(t){t=Array.from(t).sort((s,i)=>s-i);const e=new Map;for(let s=0,i=t.length;s<i;s++){const r=this.getPageId(t[s]);e.getOrInsertComputed(r,wh).push(s+1)}return this.getPageMappingForSaving(e,b(this,we,Xp).call(this,t))}getPrevPageNumber(t){var e;return((e=n(this,Is))==null?void 0:e[t-1])??0}getPageNumber(t){if(!n(this,Rt))return t;const e=n(this,Rt);for(let s=0,i=n(this,Zt);s<i;s++)if(e[s]===t)return s+1;return 0}getPageId(t){var e;return((e=n(this,Rt))==null?void 0:e[t-1])??t}getMapping(){var t;return(t=n(this,Rt))==null?void 0:t.subarray(0,this.pagesNumber)}}Rt=new WeakMap,Is=new WeakMap,Zt=new WeakMap,Ua=new WeakMap,_i=new WeakMap,we=new WeakSet,Nh=function(){if(n(this,Rt))return;const t=n(this,Zt),e=u(this,Rt,new Uint32Array(t));for(let s=0;s<t;s++)e[s]=s+1;u(this,Is,new Int32Array(e))},bu=function(){const t=new Map,e=n(this,Rt);for(let s=0,i=n(this,Zt);s<i;s++){const r=e[s],a=t.get(r);a?a.push(s+1):t.set(r,[s+1])}return t},Wp=function(t,e=null,s=-1,i=null){const r=n(this,Is),a=n(this,Rt),o=s+((i==null?void 0:i.length)??0),l=new Map;for(let h=0,c=n(this,Zt);h<c;h++){if(h>=s&&h<o){r[h]=-i[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)}},Xp=function(t=null){if(!n(this,Rt))return null;const e=new Int32Array(n(this,Zt)).fill(-1),s=new Map;if(t)for(const i of t){const r=this.getPageId(i),a=s.get(r)??0;s.set(r,a+1),e[i-1]=a}else for(let i=0,r=n(this,Zt);i<r;i++){const a=n(this,Rt)[i],o=s.get(a)??0;s.set(a,o+1),e[i]=o}return e};const No=Symbol("INITIAL_DATA"),$m=()=>({...Promise.withResolvers(),data:No});var Ls;class dy{constructor(){m(this,Ls,new Map)}get(t,e=null){if(e){const i=n(this,Ls).getOrInsertComputed(t,$m);return i.promise.then(()=>e(i.data)),null}const s=n(this,Ls).get(t);if(!s||s.data===No)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,Ls).get(t);return!!e&&e.data!==No}delete(t){const e=n(this,Ls).get(t);return!e||e.data===No?!1:(n(this,Ls).delete(t),!0)}resolve(t,e=null){const s=n(this,Ls).getOrInsertComputed(t,$m);if(s.data!==No)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){var t;for(const{data:e}
45of n(this,Ls).values())(t=e==null?void 0:e.bitmap)==null||t.close();n(this,Ls).clear()}*[Symbol.iterator](){for(const[t,{data:e}]of n(this,Ls))e!==No&&(yield[t,e])}}Ls=new WeakMap;const Q0=1e5,zm=30;var Xm,gr,Le,Yc,Kc,Tl,Ga,on,qc,Qc,$a,Jc,kl,mr,Pl,Zc,Ml,za,td,ed,Dl,Va,sd,Il,Ll,Fn,uy,fy,Yp,ys,yu,Kp,py,gy;const de=class de{constructor({textContentSource:t,images:e,container:s,viewport:i}){m(this,Fn);m(this,gr,Promise.withResolvers());m(this,Le,null);m(this,Yc,!1);m(this,Kc,!!((Xm=globalThis.FontInspector)!=null&&Xm.enabled));m(this,Tl,null);m(this,Ga,null);m(this,on,null);m(this,qc,0);m(this,Qc,0);m(this,$a,null);m(this,Jc,null);m(this,kl,0);m(this,mr,0);m(this,Pl,Object.create(null));m(this,Zc,[]);m(this,Ml,null);m(this,za,[]);m(this,td,new WeakMap);m(this,ed,null);var h;if(t instanceof ReadableStream)u(this,Ml,t);else if(typeof t=="object")u(this,Ml,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');u(this,Le,u(this,Jc,s)),u(this,Tl,e),u(this,mr,i.scale*ni.pixelRatio),u(this,kl,i.rotation),u(this,on,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:a,pageX:o,pageY:l}=i.rawDims;u(this,ed,[1,0,0,-1,-o,l+a]),u(this,Qc,r),u(this,qc,a),b(h=de,ys,py).call(h),s.style.setProperty("--min-font-size",n(de,Il)),To(s,i),n(this,gr).promise.finally(()=>{n(de,Ll).delete(this),u(this,on,null),u(this,Pl,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=pt.platform;return $(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){n(this,Tl)&&n(this,Le).append(n(this,Tl).render());const t=()=>{n(this,$a).read().then(({value:e,done:s})=>{if(s){n(this,gr).resolve();return}n(this,Ga)??u(this,Ga,e.lang),Object.assign(n(this,Pl),e.styles),b(this,Fn,uy).call(this,e.items),t()},n(this,gr).reject)};return u(this,$a,n(this,Ml).getReader()),n(de,Ll).add(this),t(),n(this,gr).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*ni.pixelRatio,i=t.rotation;if(i!==n(this,kl)&&(e==null||e(),u(this,kl,i),To(n(this,Jc),{rotation:i})),s!==n(this,mr)){e==null||e(),u(this,mr,s);const a={div:null,properties:null,ctx:b(r=de,ys,yu).call(r,n(this,Ga))};for(const o of n(this,za))a.properties=n(this,td).get(o),a.div=o,b(this,Fn,Yp).call(this,a)}}cancel(){var e;const t=new Gr("TextLayer task cancelled.");(e=n(this,$a))==null||e.cancel(t).catch(()=>{}),u(this,$a,null),n(this,gr).reject(t)}get textDivs(){return n(this,za)}get textContentItemsStr(){return n(this,Zc)}static cleanup(){if(!(n(this,Ll).size>0)){n(this,Dl).clear();for(const{canvas:t}of n(this,Va).values())t.remove();n(this,Va).clear()}}};gr=new WeakMap,Le=new WeakMap,Yc=new WeakMap,Kc=new WeakMap,Tl=new WeakMap,Ga=new WeakMap,on=new WeakMap,qc=new WeakMap,Qc=new WeakMap,$a=new WeakMap,Jc=new WeakMap,kl=new WeakMap,mr=new WeakMap,Pl=new WeakMap,Zc=new WeakMap,Ml=new WeakMap,za=new WeakMap,td=new WeakMap,ed=new WeakMap,Dl=new WeakMap,Va=new WeakMap,sd=new WeakMap,Il=new WeakMap,Ll=new WeakMap,Fn=new WeakSet,uy=function(t){var i,r;if(n(this,Yc))return;(r=n(this,on)).ctx??(r.ctx=b(i=de,ys,yu).call(i,n(this,Ga)));const e=n(this,za),s=n(this,Zc);for(const a of t){if(e.length>Q0){X("Ignoring additional textDivs for performance reasons."),u(this,Yc,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,Le);u(this,Le,document.createElement("span")),n(this,Le).classList.add("markedContent"),a.id&&n(this,Le).setAttribute("id",a.id),a.tag==="Artifact"&&(n(this,Le).ariaHidden=!0),o.append(n(this,Le))}else a.type==="endMarkedContent"&&u(this,Le,n(this,Le).parentNode);continue}s.push(a.str),b(this,Fn,fy).call(this,a)}},fy=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,za).push(e);const i=D.transform(n(this,ed),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,Pl)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,Kc)&&a.fontSubstitution||a.fontFamily;o=de.fontFamilyMap.get(o)||o;
45const l=Math.hypot(i[2],i[3]),h=l*b(y=de,ys,gy).call(y,o,a,n(this,Ga));let c,d;r===0?(c=i[4],d=i[5]-h):(c=i[4]+h*Math.sin(r),d=i[5]-h*Math.cos(r));const f=e.style;f.left=`${(100*c/n(this,Qc)).toFixed(2)}%`,f.top=`${(100*d/n(this,qc)).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,n(this,Kc)&&(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),n(this,td).set(e,s),n(this,on).div=e,n(this,on).properties=s,b(this,Fn,Yp).call(this,n(this,on)),s.hasText&&n(this,Le).append(e),s.hasEOL){const A=document.createElement("br");A.setAttribute("role","presentation"),n(this,Le).append(A)}},Yp=function(t){var a;const{div:e,properties:s,ctx:i}=t,{style:r}=e;if(s.canvasWidth!==0&&s.hasText){const{fontFamily:o}=r,{canvasWidth:l,fontSize:h}=s;b(a=de,ys,Kp).call(a,i,h*n(this,mr),o);const{width:c}=i.measureText(e.textContent);c>0&&r.setProperty("--scale-x",l*n(this,mr)/c)}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)},ys=new WeakSet,yu=function(t=null){let e=n(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}),n(this,Va).set(t,e),n(this,sd).set(e,{size:0,family:""})}return e},Kp=function(t,e,s){const i=n(this,sd).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},py=function(){if(n(this,Il)!==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,Il,t.getBoundingClientRect().height),t.remove()},gy=function(t,e,s){const i=n(this,Dl).get(t);if(i)return i;const r=b(this,ys,yu).call(this,s);r.canvas.width=r.canvas.height=zm,b(this,ys,Kp).call(this,r,zm,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):(pt.platform.isFirefox&&X("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)),n(this,Dl).set(t,h),h},m(de,ys),m(de,Dl,new Map),m(de,Va,new Map),m(de,sd,new WeakMap),m(de,Il,null),m(de,Ll,new Set);let Zh=de;const J0=100;function Z0(p={}){const t=new qp,{docId:e}=t,s=p.url?i0(p.url):null,i=p.data?n0(p.data):null,r=p.httpHeaders||null,a=p.withCredentials===!0,o=p.password??null,l=p.range instanceof my?p.range:null,h=Number.isInteger(p.rangeChunkSize)&&p.rangeChunkSize>0?p.rangeChunkSize:2**16;let c=p.worker instanceof tc?p.worker:null;const d=p.verbosity,f=typeof p.docBaseUrl=="string"&&!Mf(p.docBaseUrl)?p.docBaseUrl:null,g=Yd(p.cMapUrl),y=p.cMapPacked!==!1,A=Yd(p.iccUrl),v=Yd(p.standardFontDataUrl),w=Yd(p.wasmUrl),S=p.stopAtErrors!==!0,E=Number.isInteger(p.maxImageSize)&&p.maxImageSize>-1?p.maxImageSize:-1,x=typeof p.isOffscreenCanvasSupported=="boolean"?p.isOffscreenCanvasSupported:!gs,C=typeof p.isImageDecoderSupported=="boolean"?p.isImageDecoderSupported:!gs,_=Number.isInteger(p.canvasMaxAreaInBytes)?p.canvasMaxAreaInBytes:-1,k=typeof p.disableFontFace=="boolean"?p.disableFontFace:gs,P=p.fontExtraProperties===!0,M=p.enableXfa===!0,L=p.ownerDocument||globalThis.document,N=p.disableRange===!0,Z=p.disableStream===!0,q=p.disableAutoFetch===!0,J=p.pdfBug===!0,$t=p.CanvasFactory||(gs?u0:l0),F=p.FilterFactory||(gs?d0:h0),H=p.BinaryDataFactory||(gs?f0:Dm),xt=p.enableHWA===!0,Pe=p.enableWebGPU===!0?b0():Promise.resolve(!1),ce=p.useWasm!==!1,jt=p.pagesMapper||new q0,lt=typeof p.useSystemFonts=="boolean"?p.useSystemFonts:!gs&&!k,ri=typeof p.useWorkerFetch=="boolean"?p.useWorkerFetch:!!(H===Dm&&g&&y&&v&&w&&Wh(g,document.baseURI)&&Wh(v,document.baseURI)&&Wh(w,document.baseURI)),vh=null;SA(d);const ie={canvasFactory:new $t({ownerDocument:L,enableHWA:xt}),filterFactory:new F({docId:e,ownerDocument:L}),binaryDataFactory:ri?null:new H({cMapUrl:g,standardFontDataUrl:v,wasmUrl:w})};c||(c=tc.create({verbosity:d,port:Tn.workerPort}),t._worker=c);const yt={docId:e,apiVersion:"6.3.289",data:i,password:o,disableAutoFetch:q,rangeChunkSize:h,docBaseUrl:f,enableXfa:M,evaluatorOptions:{maxImageSize:E,disableFontFace:k,ignoreErrors:S,isOffscreenCanvasSupported:x,isImageDecoderSupported:C,canvasMaxAreaInBytes:_,fontExtraProperties:P,useSystemFonts:lt,useWasm:ce,useWorkerFetch:ri,cMapUrl:g,cMapPacked:y,iccUrl:A,standardFontDataUrl:v,wasmUrl:w,hasGPU:!1}},Uf={ownerDocument:L,pdfBug:J,styleElement:vh,enableHWA:xt,loadingParams:{disableAutoFetch:q,enableXfa:M}};return Promise.all([c.promise,Pe]).then(function([,gA]){if(c.destroyed)throw new Error("Worker was destroyed");yt.evaluatorOptions.hasGPU=gA;
45const mA=c.messageHandler.sendWithPromise("GetDocRequest",yt,i?[i.buffer]:null);let Gf;if(!i)if(l)Gf=new N0({pdfDataRangeTransport:l,disableRange:N,disableStream:Z});else if(s){const $f=X0(s);Gf=new $f({url:s,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:N,disableStream:Z})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return mA.then($f=>{if(c.destroyed)throw new Error("Worker was destroyed");const pm=new Ih(e,$f,c.port),bA=new ew(pm,t,Gf,Uf,ie,jt);if(t._transport=bA,t.destroyed)throw new Error("Loading aborted");pm.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}var ff;const pf=class pf{constructor(){T(this,"_capability",Promise.withResolvers());T(this,"_setupCapability",Promise.withResolvers());T(this,"_transport",null);T(this,"_worker",null);T(this,"docId",`d${Dt(pf,ff)._++}`);T(this,"destroyed",!1);T(this,"onPassword",null);T(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;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,(i=this._worker)==null||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};ff=new WeakMap,m(pf,ff,0);let qp=pf;var Fl,ja;class my{constructor(t,e,s=!1,i=null){m(this,Fl,Promise.withResolvers());m(this,ja,null);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){n(this,ja).call(this,{type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){n(this,Fl).promise.then(()=>{n(this,ja).call(this,{type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){n(this,Fl).promise.then(()=>{n(this,ja).call(this,{type:"progressiveDone"})})}transportReady(t){u(this,ja,t),n(this,Fl).resolve()}requestDataRange(t,e){et("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Fl=new WeakMap,ja=new WeakMap;class tw{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,e=null){return this._transport.extractPages(t,e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}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 ln,Wa,Xa,Bh;const dm=class dm{constructor(t,e,s,i,r=!1){m(this,Xa);m(this,ln,!1);m(this,Wa,null);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new bm:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new dy,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,u(this,Wa,i),this.imageCoordinates=null}clone(t){const e=new dm(t,this._pageInfo,this._transport,n(this,Wa),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:i=0,dontFlip:r=!1}={}){return new zd({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,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:i="display",annotationMode:r=On.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 q,J,$t;(q=this._stats)==null||q.time("Overall");const v=this._transport.getRenderingIntent(i,r,d,f),{renderingIntent:w,cacheKey:S}=v;u(this,ln,!1),l||(l=this._transport.getOptionalContentConfig(w));const E=this._intentStates.getOrInsertComputed(S,sp);E.streamReaderCancelTimeout&&(clearTimeout(E.streamReaderCancelTimeout),E.streamReaderCancelTimeout=null);const x=!!(w&ps.PRINT);E.displayReadyCapability||(E.displayReadyCapability=Promise.withResolvers(),E.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(J=this._stats)==null||J.time("Page Request"),this._pumpOperatorList(v));const C=!!(this._pdfBug&&(($t=globalThis.StepperManager)!=null&&$t.enabled)),_=!!e&&!this.recordedBBoxes&&(y||C),k=!!e&&!this.imageCoordinates&&g,P=F=>{var H,xt,Ct,Pe;if(E.renderTasks.delete(N),_){const ce=(H=N.gfx)==null?void 0:H.dependencyTracker.take();ce&&((xt=N.stepper)==null||xt.setOperatorBBoxes(ce,N.gfx.dependencyTracker.takeDebugMetadata()),y&&(this.recordedBBoxes=ce))}k&&!F&&(this.imageCoordinates=(Ct=N.gfx)==null?void 0:Ct.imagesTracker.take()),x&&u(this,ln,!0),b(this,Xa,Bh).call(this),F?(N.capability.reject(F),this._abortOperatorList({intentState:E,reason:F instanceof Error?F:new Error(F)})):N.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(Pe=globalThis.Stats)!=null&&Pe.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let M=null,L=null;(_||k)&&(L=new XA(e,E.operatorList.length)),_&&(M=new YA(L,C));const N=new Jp({callback:P,params:{canvas:e,canvasContext:t,dependencyTracker:M??L,imagesTracker:k?new Dp(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(N);const Z=N.task;return Promise.all([E.displayReadyCapability.promise,l]).then(([F,H])=>{var xt;if(this.destroyed){P();return}if((xt=this._stats)==null||xt.time("Rendering"),!(H.renderingIntent&w))throw new Error("Mu
45st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");N.initializeGraphics({transparency:F,optionalContentConfig:H}),N.operatorListChanged()}).catch(P),Z}getOperatorList({intent:t="display",annotationMode:e=On.ENABLE,printAnnotationStorage:s=null,isEditing:i=!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,i,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,sp);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:n(this,Wa).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>qh.textContent(i));const e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(const i of e)s.lang??(s.lang=i.lang),Object.assign(s.styles,i.styles),s.items.push(...i.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,ln,!1),Promise.all(t)}cleanup(t=!1){u(this,ln,!0);const e=b(this,Xa,Bh).call(this);return t&&e&&this._stats&&(this._stats=new bm),e}_startRenderPage(t,e){var i,r;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&b(this,Xa,Bh).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:n(this,Wa).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},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,Xa,Bh).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 Qg){let i=J0;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new Gr(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}};ln=new WeakMap,Wa=new WeakMap,Xa=new WeakSet,Bh=function(){if(!n(this,ln)||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,ln,!1),!0};let Qp=dm;var br,Ys,hn,Ya,gf,Ka,qa,He,Au,by,yy,Hh,Rl,wu;const Bt=class Bt{constructor({name:t=null,port:e=null,verbosity:s=EA()}={}){m(this,He);m(this,br,Promise.withResolvers());m(this,Ys,null);m(this,hn,null);m(this,Ya,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(Bt,qa).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(Bt,qa).set(e,this),b(this,He,by).call(this,e)}else b(this,He,yy).call(this)}get promise(){return n(this,br).promise}get port(){return n(this,hn)}get messageHandler(){return n(this,Ys)}destroy(){var t,e;this.destroyed=!0,(t=n(this,Ya))==null||t.terminate(),u(this,Ya,null),n(Bt,qa).delete(n(this,hn)),u(this,hn,null),(e=n(this,Ys))==null||e.destroy(),u(this,Ys,null)}static create(t){const e=n(this,qa).get(t==null?void 0:t.port);
45if(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 Bt(t)}static get workerSrc(){if(Tn.workerSrc)return Tn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return $(this,"_setupFakeWorkerGlobal",(async()=>n(this,Rl,wu)?n(this,Rl,wu):(await import(this.workerSrc)).WorkerMessageHandler)())}};br=new WeakMap,Ys=new WeakMap,hn=new WeakMap,Ya=new WeakMap,gf=new WeakMap,Ka=new WeakMap,qa=new WeakMap,He=new WeakSet,Au=function(){n(this,br).resolve(),n(this,Ys).send("configure",{verbosity:this.verbosity})},by=function(t){u(this,hn,t),u(this,Ys,new Ih("main","worker",t)),n(this,Ys).on("ready",()=>{}),b(this,He,Au).call(this)},yy=function(){if(n(Bt,Ka)||n(Bt,Rl,wu)){b(this,He,Hh).call(this);return}let{workerSrc:t}=Bt;try{Bt._isSameOrigin(window.location,t)||(t=Bt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Ih("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?n(this,br).reject(new Error("Worker was destroyed")):b(this,He,Hh).call(this)},r=new AbortController;e.addEventListener("error",()=>{n(this,Ya)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}u(this,Ys,s),u(this,hn,e),u(this,Ya,e),b(this,He,Au).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{b(this,He,Hh).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{kf("The worker has been disabled.")}b(this,He,Hh).call(this)},Hh=function(){n(Bt,Ka)||(X("Setting up fake worker."),u(Bt,Ka,!0)),Bt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){n(this,br).reject(new Error("Worker was destroyed"));return}const e=new o0;u(this,hn,e);const s=`fake${Dt(Bt,gf)._++}`,i=new Ih(s+"_worker",s,e);t.setup(i,e),u(this,Ys,new Ih(s,s+"_worker",e)),b(this,He,Au).call(this)}).catch(t=>{n(this,br).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Rl=new WeakSet,wu=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},m(Bt,Rl),m(Bt,gf,0),m(Bt,Ka,!1),m(Bt,qa,new WeakMap),gs&&(u(Bt,Ka,!0),Tn.workerSrc||(Tn.workerSrc="./pdf.worker.mjs")),Bt._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const i=new URL(e,s);return s.origin===i.origin},Bt._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let tc=Bt;var is,Qa,cn,Ks,Ja,Ol,dn,Bs,Bo,vu;class ew{constructor(t,e,s,i,r,a){m(this,Bs);T(this,"downloadInfoCapability",Promise.withResolvers());m(this,is,null);m(this,Qa,new Map);m(this,cn,null);m(this,Ks,new Map);m(this,Ja,new Map);m(this,Ol,new Map);m(this,dn,null);this.messageHandler=t,this.loadingTask=e,u(this,cn,s),this.commonObjs=new dy,this.fontLoader=new qA({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.enableHWA=i.enableHWA,this.loadingParams=i.loadingParams,this._params=i,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;n(this,Ks).set(e,t),n(this,Ja).set(e,Promise.resolve(t))}get annotationStorage(){return $(this,"annotationStorage",new Zg)}getRenderingIntent(t,e=On.ENABLE,s=null,i=!1,r=!1){let a=ps.DISPLAY,o=Qh;switch(t){case"any":a=ps.ANY;break;case"display":break;case"print":a=ps.PRINT;break;default:X(`getRenderingIntent - invalid intent: ${t}`)}const l=a&ps.PRINT&&s instanceof Lb?s:this.annotationStorage;switch(e){case On.DISABLE:a+=ps.ANNOTATIONS_DISABLE;break;case On.ENABLE:break;case On.ENABLE_FORMS:a+=ps.ANNOTATIONS_FORMS;break;case On.ENABLE_STORAGE:a+=ps.ANNOTATIONS_STORAGE,o=l.serializable;break;default:X(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=ps.IS_EDITING),r&&(a+=ps.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=n(this,dn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,Ks).values())t.push(i._destroy());n(this,Ks).clear(),n(this,Ja).clear(),n(this,Ol).clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();
45const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,r;this.commonObjs.clear(),this.fontLoader.clear(),n(this,Qa).clear(),this.filterFactory.destroy(),Zh.cleanup(),(i=n(this,cn))==null||i.cancelAllRequests(new Gr("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,i)=>{Nt(n(this,cn),"GetReader - no `BasePDFStream` instance available."),u(this,is,n(this,cn).getFullReader()),n(this,is).onProgress=r=>b(this,Bs,vu).call(this,r),i.onPull=()=>{n(this,is).read().then(function({value:r,done:a}){if(a){i.close();return}Nt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n(this,is).cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{await n(this,is).headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=n(this,is);return i&&r&&(n(this,is).onProgress=null),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{Nt(n(this,cn),"GetRangeReader - no `BasePDFStream` instance available.");const r=n(this,cn).getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){i.close();return}Nt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{r.cancel(a),i.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 tw(s,this))}),t.on("DocException",s=>{e._capability.reject($e(s))}),t.on("PasswordRequest",s=>{u(this,dn,Promise.withResolvers());try{if(!e.onPassword)throw $e(s);const i=r=>{r instanceof Error?n(this,dn).reject(r):n(this,dn).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,dn).reject(i)}return n(this,dn).promise}),t.on("DataLoaded",s=>{b(this,Bs,vu).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,Ks).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in r){const f=r.error;X(`Error during font loading: ${f}`),this.commonObjs.resolve(s,f);break}const o=new t0(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(f,g)=>globalThis.FontInspector.fontAdded(f,g):null,h=new QA(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;Nt(c,"The imageRef must be defined.");for(const f of n(this,Ks).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 s0(r));break;case"Image":this.commonObjs.resolve(s,r);break;case"Pattern":const d=new e0(r);this.commonObjs.resolve(s,d.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,r,a])=>{var l;if(this.destroyed)return;const o=n(this,Ks).get(i);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,Bs,vu).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&&X("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=n(this,is))==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t,e=null){var a;const s={pageInfos:t};let i;const r=globalThis.ImageBitmap;if(typeof r=="function"){const o=Array.isArray(t)?t:[t];for(const l of o)(l==null?void 0:l.image)instanceof r&&(i||(i=[])).push(l.image)}if(this.annotationStorage.size>0){const o=this.annotationStorage.serializable;let{map:l}=o;(a=o.transfer)!=null&&a.length&&(i?i.push(...o.transfer):i=o.transfer);const h=this.pagesMapper.getMapping();if(h){const c=new Map;for(const[d,f]of l){if((f==null?void 0:f.pageIndex)!==void 0&&f.pageIndex>=0&&f.pageIndex<h.length){const g=(e==null?void 0:e[f.pageIndex])??0,y=h[f.pageIndex]-1;if(y!==f.pageIndex||g!==0){c.set(d,{...f,pageIndex:y,copyLevel:g});continue}}c.set(d,f)}l=c}s.annotationStorage=l}return this.messageHandler.sendWithPromise("ExtractPages",s,i).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,i=n(this,Ja).get(e);if(i)return i;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&n(this,Ol).set(a.refStr,s);const o=new Qp(e,a,this,this.pagesMapper,this._params.pdfBug);return n(this,Ks).set(e,o),o});return n(this,Ja).set(e,r),r}async getPageIndex(t){if(!Lp(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,Bs,Bo).call(this,"GetFieldObjects")}getSignatures(){return b(this,Bs,Bo).call(this,"GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return b(this,Bs,Bo).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,Bs,Bo).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,Bs,Bo).call(this,"GetOptionalContentConfig").then(e=>new Vp(e,t))}
45getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return n(this,Qa).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>{var s,i;return{info:e[0],metadata:e[1]?new Y0(e[1]):null,contentDispositionFilename:((s=n(this,is))==null?void 0:s.filename)??null,contentLength:((i=n(this,is))==null?void 0:i.contentLength)??null,hasStructTree:e[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of n(this,Ks).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,Qa).clear(),this.filterFactory.destroy(!0),Zh.cleanup()}}cachedPageNumber(t){if(!Lp(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=n(this,Ol).get(e);if(s>=0){const i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}is=new WeakMap,Qa=new WeakMap,cn=new WeakMap,Ks=new WeakMap,Ja=new WeakMap,Ol=new WeakMap,dn=new WeakMap,Bs=new WeakSet,Bo=function(t,e=null){return n(this,Qa).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))},vu=function({loaded:t,total:e}){var s,i;(i=(s=this.loadingTask).onProgress)==null||i.call(s,{loaded:t,total:e,percent:e?Et(Math.round(t/e*100),0,100):NaN})};class sw{constructor(t){T(this,"_internalRenderTask",null);T(this,"onContinue",null);T(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 yr,Za;const Qr=class Qr{constructor({callback:t,params:e,objs:s,commonObjs:i,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,yr,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,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 sw(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(n(Qr,Za).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");n(Qr,Za).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:i,background:r,dependencyTracker:a,imagesTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new zo(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a,o),this.gfx.beginDrawing({transform:i,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,i,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),n(this,yr)&&(window.cancelAnimationFrame(n(this,yr)),u(this,yr,null)),n(Qr,Za).delete(this._canvas),t||(t=new Qg(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(i=this.task).onError)==null||r.call(i,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,yr,window.requestAnimationFrame(()=>{u(this,yr,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(),n(Qr,Za).delete(this._canvas),this.callback())))}};yr=new WeakMap,Za=new WeakMap,m(Qr,Za,new WeakSet);let Jp=Qr;const iw="6.3.289",nw="1c8020a7d";var ns,to,Nl,te,id,Bl,un,nd,Ar,qs,rd,gt,Zp,tg,eg,Xr,Ay,Rn;const Ve=class Ve{constructor({editor:t=null,uiManager:e=null}){m(this,gt);m(this,ns,null);m(this,to,null);m(this,Nl);m(this,te,null);m(this,id,!1);m(this,Bl,!1);m(this,un,null);m(this,nd);m(this,Ar,null);m(this,qs,null);var s,i;t?(u(this,Bl,!1),u(this,un,t)):u(this,Bl,!0),u(this,qs,(t==null?void 0:t._uiManager)||e),u(this,nd,n(this,qs)._eventBus),u(this,Nl,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((i=n(this,qs))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),n(Ve,rd)||u(Ve,rd,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 ko([[["Escape"],Ve.prototype._hideDropdownFromKeyboard],[["Space"],Ve.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],Ve.prototype._moveToNext],[["ArrowUp","ArrowLeft"],Ve.prototype._moveToPrevious],[["Home"],Ve.prototype._moveToBeginning],[["End"],Ve.prototype._moveToEnd]]))}renderButton(){const t=u(this,ns,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",n(this,un)&&(t.ariaControls=`${n(this,un).id}_colorpicker_dropdown`);const e=n(this,qs)._signal;t.addEventListener("click",b(this,gt,Xr).bind(this),{signal:e}),t.addEventListener("keydown",b(this,gt,eg).bind(this),{signal:e});const s=u(this,to,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,Nl),t.append(s),t}renderMainDropdown(){const t=u(this,te,b(this,gt,Zp).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===n(this,ns)){b(this,gt,Xr).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,gt,tg).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,gt,Rn)){b(this,gt,Xr).call(this,t);return}if(t.target===n(this,ns)){(e=n(this,te).firstElementChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,te))==null?void 0:e.firstElementChild)||t.target===n(this,ns)){n(this,gt,Rn)&&this._hideDropdownFromKeyboard();return}n(this,gt,Rn)||b(this,gt,Xr).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,gt,Rn)){b(this,gt,Xr).call(this,t);return}(e=n(this,te).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,gt,Rn)){b(this,gt,Xr).call(this,t);return}(e=n(this,te).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,te))==null||t.classList.add("hidden"),n(this,ns).ariaExpanded="false",(e=n(this,Ar))==null||e.abort(),u(this,Ar,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,Bl)){if(!n(this,gt,Rn)){(t=n(this,un))==null||t.unselect();return}this.hideDropdown(),n(this,ns).focus({preventScroll:!0,focusVisible:n(this,id)})}}update(t){if(n(this,to)&&(n(this,to).style.backgroundColor=t),!n(this,te))return;const e=n(this,qs).highlightColors.values();for(const s of n(this,te).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=n(this,ns))==null||t.remove(),u(this,ns,null),u(this,to,null),(e=n(this,te))==null||e.remove(),u(this,te,null)}};ns=new WeakMap,to=new WeakMap,Nl=new WeakMap,te=new WeakMap,id=new WeakMap,Bl=new WeakMap,un=new WeakMap,nd=new WeakMap,Ar=new WeakMap,qs=new WeakMap,rd=new WeakMap,gt=new WeakSet,Zp=function(){const t=document.createElement("div"),e=n(this,qs)._signal;t.addEventListener("contextmenu",ii,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),n(this,un)&&(t.id=`${n(this,un).id}_colorpicker_dropdown`);for(const[s,i]of n(this,qs).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",n(Ve,rd)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,Nl),r.addEventListener("click",b(this,gt,tg).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",b(this,gt,eg).bind(this),{signal:e}),t},tg=function(t,e){e.stopPropagation(),n(this,nd).dispatch("switchannotationeditorparams",{source:this,type:tt.HIGHLIGHT_COLOR,value:t}),this.update(t)},eg=function(t){Ve._keyboardManager.exec(this,t)},Xr=function(t){if(n(this,gt,Rn)){this.hideDropdown();return}if(u(this,id,t.detail===0),n(this,Ar)||(u(this,Ar,new AbortController),window.addEventListener("pointerdown",b(this,gt,Ay).bind(this),{signal:n(this,qs).combinedSignal(n(this,Ar))})),n(this,ns).ariaExpanded="true",n(this,te)){n(this,te).classList.remove("hidden");return}const e=u(this,te,b(this,gt,Zp).call(this));n(this,ns).append(e)},Ay=function(t){var e;(e=n(this,te))!=null&&e.contains(t.target)||this.hideDropdown()},Rn=function(){return n(this,te)&&!n(this,te).classList.contains("hidden")},m(Ve,rd,null);let Xu=Ve;var rs,Hl,eo,fn,ad;const Jr=class Jr{constructor(t){m(this,rs,null);m(this,Hl,!1);m(this,eo,null);m(this,fn,null);
45u(this,eo,t),u(this,fn,t._uiManager),n(Jr,ad)||u(Jr,ad,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,rs))return n(this,rs);const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:r,opacity:a}=n(this,eo),o=u(this,Hl,pt.isAlphaColorInputSupported&&i!==void 0),l=u(this,rs,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",n(Jr,ad)[t]),l.addEventListener("input",()=>{if(o){const h=Vd(l.value);if(!h)return;const[c,d,f,g]=h,y=D.makeHexColor(c,d,f);s!==void 0?n(this,fn).updateParams(s,{color:y,opacity:g}):(n(this,fn).updateParams(e,y),n(this,fn).updateParams(i,g))}else n(this,fn).updateParams(e,l.value)},{signal:n(this,fn)._signal}),l}update(t){if(n(this,rs))if(n(this,Hl)){const e=D.hexNums[Math.round(n(this,eo).opacity*255)];n(this,rs).value=t+e}else n(this,rs).value=t}updateOpacity(t){if(!n(this,rs)||!n(this,Hl))return;const e=D.hexNums[Math.round(t*255)];n(this,rs).value=n(this,eo).color+e}destroy(){var t;(t=n(this,rs))==null||t.remove(),u(this,rs,null)}hideDropdown(){}};rs=new WeakMap,Hl=new WeakMap,eo=new WeakMap,fn=new WeakMap,ad=new WeakMap,m(Jr,ad,null);let Yu=Jr;function Vm(p){return Math.floor(Et(p,0,1)*255).toString(16).padStart(2,"0")}function Eh(p){return Et(p,0,1)*255}class jm{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Eh(t),[t,t,t]}static G_HTML([t]){const e=Vm(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(Eh)}static RGB_HTML(t){return`#${t.map(Vm).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Eh(1-Math.min(1,t+i)),Eh(1-Math.min(1,s+i)),Eh(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,r=1-e,a=1-s,o=Math.min(i,r,a);return["CMYK",i,r,a,o]}}class rw{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){et("Abstract method `_createSVG` called.")}}class Ku extends rw{_createSVG(t){return document.createElementNS(Ne,t)}}const aw=9,Mo=new WeakSet,ow=new Date().getTimezoneOffset()*60*1e3;class qf{static create(t){switch(t.data.annotationType){case It.LINK:return new em(t);case It.TEXT:return new hw(t);case It.WIDGET:switch(t.data.fieldType){case"Tx":return new cw(t);case"Btn":return t.data.radioButton?new fw(t):t.data.checkBox?new uw(t):new pw(t);case"Ch":return new gw(t);case"Sig":return new dw(t)}return new Lo(t);case It.POPUP:return new ig(t);case It.FREETEXT:return new _y(t);case It.LINE:return new bw(t);case It.SQUARE:return new yw(t);case It.CIRCLE:return new Aw(t);case It.POLYLINE:return new Ty(t);case It.CARET:return new vw(t);case It.INK:return new sm(t);case It.POLYGON:return new ww(t);case It.HIGHLIGHT:return new ky(t);case It.UNDERLINE:return new Sw(t);case It.SQUIGGLY:return new Ew(t);case It.STRIKEOUT:return new xw(t);case It.STAMP:return new Py(t);case It.FILEATTACHMENT:return new Cw(t);case It.RICHMEDIA:case It.SCREEN:case It.SOUND:return new My(t);default:return new Pt(t)}}}var so,Ul,Fs,od,sg;const um=class um{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){m(this,od);m(this,so,null);m(this,Ul,!1);m(this,Fs,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)),i&&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 um._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:i}=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 i?[i[2],i[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,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)/i,t}get commentText(){var e,s,i;const{data:t}=this;return((s=(e=this.annotationStorage.getRawValue(`${bh}${t.id}`))==null?void 0:e.popup)==null?void 0:s.contents)||((i=t.contentsObj)==null?void 0:i.str)||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${bh}${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=n(this,Fs))==null?void 0:t.popup)||this.popup)==null||e.remove(),u(this,Fs,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(n(this,so)||u(this,so,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&b(this,od,sg).call(this,e);let i=((r=n(this,Fs))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,Fs).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),u(this,Fs,null),this.popup=null))}resetEdited(){var t;n(this,so)&&(b(this,od,sg).call(this,n(this,so).rect),(t=n(this,Fs))==null||t.popup.resetEdited(),u(this,so,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof Lo)&&!(this instanceof em)&&!(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 ig){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 Ro.SOLID:a.borderStyle="solid";break;case Ro.DASHED:a.borderStyle="dashed";break;case Ro.BEVELED:X("Unimplemented border style: beveled");break;case Ro.INSET:X("Unimplemented border style: inset");break;case Ro.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(u(this,Ul,!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}=i.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:i}=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/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const r=i.detail[e],a=r[0],o=r.slice(1);i.target.style[s]=jm[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:jm[`${a}_rgb`](o)})};return $(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>
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 i of Object.keys(e.detail)){const r=t[i]||s[i];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[i,r]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:r},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(Math.fround);if(t.length===8){const[A,v,w,S]=t.subarray(2,6);if(i===A&&r===v&&e===w&&s===S)return}const{style:a}=this.container;let o;if(n(this,Ul)){const{borderColor:A,borderWidth:v}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${Ne}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${A}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const l=i-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"),_=(E-e)/l,k=(r-S)/h,P=(w-E)/l,M=(S-x)/h;C.setAttribute("x",_),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="${_}" y="${k}" width="${P}" height="${M}"/>`)}n(this,Ul)&&(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,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate),u(this,Fs,new ig({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(n(this,Fs)||this.popup||this.data.popupRef)}get extraPopupElement(){return n(this,Fs)}render(){et("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects.get(t)||[];for(const{page:r,id:a,exportValues:o}of i){if(r===-1||a===e)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!Mo.has(h)){X(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:h})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,a=i.getAttribute("data-element-id");a!==e&&Mo.has(i)&&s.push({id:a,exportValue:r,domElement:i})}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)}};so=new WeakMap,Ul=new WeakMap,Fs=new WeakMap,od=new WeakSet,sg=function(t){const{container:{style:e},data:{rect:s,rotation:i},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}%`,i===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(i)};let Pt=um;class lw extends Pt{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 bs,Yr,wy,vy;class em extends Pt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});m(this,bs);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(i,e.action,e.overlaidText),r=!0):e.attachment?(b(this,bs,wy).call(this,i,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(b(this,bs,vy).call(this,i,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(i,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.has("Action")||e.actions.has("Mouse Up")||e.actions.has("Mouse Down"))&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),r=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&(this.contentElement=i,this.container.append(i)),this.container}_bindLink(e,s,i=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&b(this,bs,Yr).call(this),i&&(e.title=i)}_bindNamedAction(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),i&&(e.title=i),b(this,bs,Yr).call(this)}_bindJSAction(e,{actions:s,id:i,overlaidText:r}){e.href=this.linkService.getAnchorUrl("");const a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const o of s.keys()){const l=a.get(o);l&&(e[l]=()=>{var h;return(h=this.linkService.eventBus)==null||h.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:o}}),!1})}r&&(e.title=r),e.onclick||(e.onclick=()=>!1),b(this,bs,Yr).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,bs,Yr).call(this),!this._fieldObjects){X('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var d;i==null||i();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.get(g)||[];for(const{id:A}of y)f.add(A)}for(const g of this._fieldObjects.values())for(const y of g)f.has(y.id)===o&&l.push(y)}else for(const f of this._fieldObjects.values())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(!Mo.has(y)){X(`_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}}}bs=new WeakSet,Yr=function(){this.container.setAttribute("data-internal-link","")},wy=function(e,s,i,r="",a=null){e.href=this.linkService.getAnchorUrl(""),i.description?e.title=i.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,i.filename,a))};e.onclick=()=>(o(),!1),b(this,bs,Yr).call(this)},vy=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),b(this,bs,Yr).call(this)};class hw extends Pt{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 Lo extends Pt{render(){return this.container}_getKeyModifier(t){return pt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,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:i,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:i,value:r(a)}}))})}_setEventListeners(t,e,s,i){const{actions:r}=this.data;for(const[a,o]of s)(o==="Action"||r!=null&&r.has(o))&&((o==="Focus"||o==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,a,o,i),o==="Focus"&&!(r!=null&&r.has("Blur"))?this._setEventListener(t,e,"blur","Blur",null):o==="Blur"&&!(r!=null&&r.has("Focus"))&&this._setEventListener(t,e,"focus","Focus",null))}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||aw,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*i))||1,d=h/c;a=Math.min(i,l(d/1.35))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,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 cw extends Lo{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const r=this.annotationStorage;
45for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[i]:s})}render(){var i,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||((i=this.data.textContent)==null?void 0:i.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")),Mo.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),_=[C.getHours(),C.getMinutes(),C.getSeconds()];S.value=_.map(k=>k.toString().padStart(2,"0")).join(":")}else S.value=new Date(x-ow).toISOString().split(f==="date"?"T":".",1)[0];else S.value=x}c.lastCommittedValue=S.value,c.commitKey=1,(E=this.data.actions)!=null&&E.has("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 _=c.userValue;!_||_.length<=x||(_=_.slice(0,x),C.value=c.userValue=_,t.setValue(e,{value:_}),(k=this.linkService.eventBus)==null||k.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,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.has("Blur")||(c.focused=!1);const{target:S}=w;let{value:E}=S;if(y){if(E&&f==="time"){const _=E.split(":").map(k=>parseInt(k,10));E=new Date(2e3,0,1,_[0],_[1],_[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.has("Keystroke")&&s.addEventListener("beforeinput",w=>{var M;c.lastCommittedValue=null;const{data:S,target:E}=w,{value:x,selectionStart:C,selectionEnd:_}=E;let k=C,P=_;switch(w.inputType){case"deleteWordBackward":{const L=/\w/;for(;k>0&&!L.test(x[k-1]);)k--;for(;k>0&&L.test(x[k-1]);)k--;break}case"deleteWordForward":{const L=x.substring(C).match(/^\W*\w*/);L&&(P+=L[0].length);break}case"deleteContentBackward":C===_&&(k-=1);break;case"deleteContentForward":C===_&&(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 dw extends Lo{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class uw extends Lo{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return Mo.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,i&&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 fw extends Lo{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const r=document.createElement("input");if(Mo.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,i&&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 pw extends em{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 gw extends Lo{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Mo.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",d=>{const f=this.data.defaultFieldValue;for(const g of i.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),i.append(f)}let o=null;if(r){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),o=()=>{d.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const l=d=>{const f=d?"value":"textContent",{options:g,multiple:y}=i;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?(i.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 i.options)v.selected=A.has(v.value);t.setValue(e,{value:l(!0)}),h=l(!1)},multipleSelection(g){i.multiple=!0},remove(g){const y=i.options,A=g.detail.remove;y[A].selected=!1,i.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(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),h=l(!1)},insert(g){const{index:y,displayValue:A,exportValue:v}=g.detail.insert,w=i.children[y],S=document.createElement("option");a(S,A),S.value=v,w?w.before(S):i.append(S),t.setValue(e,{value:l(!0),items:c(g)}),h=l(!1)},items(g){const{items:y}=g.detail;for(;i.length!==0;)i.remove(0);for(const A of y){const{displayValue:v,exportValue:w}=A,S=document.createElement("option");a(S,v),S.value=w,i.append(S)}i.options.length>0&&(i.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)}),i.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(i,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)):i.addEventListener("input",function(d){t.setValue(e,{value:l(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}var ld,ng;class ig extends Pt{constructor(e){const{data:s,elements:i,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&Pt._hasPopupData(s)});
46m(this,ld);if(this.elements=i,a&&Pt._hasPopupData(s)){const o=this.popup=b(this,ld,ng).call(this);for(const l of i)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,ld,ng).call(this),i=[];for(const r of this.elements)r.popup=s,r.container.ariaHasPopup="dialog",i.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(r=>`${Uo}${r}`).join(",")),this.container}}ld=new WeakSet,ng=function(){return new mw({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 as,wr,mf,bf,Gl,$l,Ut,Ti,vr,io,zl,Vl,ki,os,pn,gn,Gt,mn,Sr,hd,bn,jl,no,Er,le,xr,K,Su,rg,ag,og,Eu,lg,Sy,Ey,xy,Cy,xu,Cu,hg;class mw{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:d,commentManager:f=null}){m(this,K);m(this,as,null);m(this,wr,b(this,K,xy).bind(this));m(this,mf,b(this,K,hg).bind(this));m(this,bf,b(this,K,Cu).bind(this));m(this,Gl,b(this,K,xu).bind(this));m(this,$l,null);m(this,Ut,null);m(this,Ti,null);m(this,vr,null);m(this,io,null);m(this,zl,null);m(this,Vl,null);m(this,ki,!1);m(this,os,null);m(this,pn,null);m(this,gn,null);m(this,Gt,null);m(this,mn,null);m(this,Sr,null);m(this,hd,null);m(this,bn,null);m(this,jl,null);m(this,no,null);m(this,Er,!1);m(this,le,null);m(this,xr,null);u(this,Ut,t),u(this,jl,i),u(this,Ti,a),u(this,bn,o),u(this,zl,l),u(this,$l,e),u(this,hd,h),u(this,Vl,c),u(this,io,s),u(this,as,f),u(this,le,s[0]),u(this,vr,Vu.toDateObject(r)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup()),f||(b(this,K,Su).call(this),n(this,Ut).hidden=!0,d&&b(this,K,xu).call(this))}renderCommentButton(){if(n(this,Gt)){n(this,Gt).parentNode||n(this,le).container.after(n(this,Gt));return}if(n(this,mn)||b(this,K,rg).call(this),!n(this,mn))return;const{signal:t}=u(this,pn,new AbortController),e=n(this,le).hasOwnCommentButton,s=()=>{n(this,as).toggleCommentPopup(this,!0,void 0,!e)},i=()=>{n(this,as).toggleCommentPopup(this,!1,!0,!e)},r=()=>{n(this,as).toggleCommentPopup(this,!1,!1)};if(e){u(this,Gt,n(this,le).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",n(this,wr),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),a.classList.add("popupTriggerArea")}else{const a=u(this,Gt,document.createElement("button"));a.className="annotationCommentButton";const o=n(this,le).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,og).call(this),b(this,K,ag).call(this),a.addEventListener("keydown",n(this,wr),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),o.after(a)}}get commentButtonColor(){const{color:t,opacity:e}=n(this,le).commentData;return t?n(this,zl)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=n(this,Gt))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}=n(this,le).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return n(this,Gt)}get comment(){return n(this,xr)||u(this,xr,n(this,le).commentText),n(this,xr)}set comment(t){t!==this.comment&&(n(this,le).commentText=u(this,xr,t))}focus(){var t;(t=n(this,le).container)==null||t.focus()}get parentBoundingClientRect(){return n(this,le).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){n(this,Gt)&&(n(this,Gt).classList.toggle("selected",t),n(this,Gt).ariaExpanded=e)}setSelectedCommentButton(t){n(this,Gt).classList.toggle("selected",t)}get commentPopupPosition(){if(n(this,Sr))return n(this,Sr);const{x:t,y:e,height:s}=n(this,Gt).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,le).layer.getBoundingClientRect();return[(t-i)/a,(e+s-r)/o]}set commentPopupPosition(t){u(this,Sr,t)}hasDefaultPopupPosition(){return n(this,Sr)===null}get commentButtonPosition(){return n(this,mn)}get commentButtonWidth(){return n(this,Gt).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=n(this,Sr)||this.commentButtonPosition.map(h=>h/100),i=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=i;
46n(this,as).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:i})}render(){var s,i;if(n(this,os))return;const t=u(this,os,document.createElement("div"));if(t.className="popup",n(this,$l)){const r=t.style.outlineColor=D.makeHexColor(...n(this,$l));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=n(this,jl))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=n(this,jl)}if(t.append(e),n(this,vr)){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:n(this,vr).valueOf()})),r.dateTime=n(this,vr).toISOString(),e.append(r)}Qm({html:n(this,K,Eu)||n(this,Ti).str,dir:(i=n(this,Ti))==null?void 0:i.dir,className:"popupContent"},t),n(this,Ut).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var i;if(n(this,as)){s?(this.remove(),u(this,xr,null)):e&&(e.deleted?this.remove():(b(this,K,og).call(this),u(this,xr,e.text))),t&&(u(this,mn,null),b(this,K,rg).call(this),b(this,K,ag).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}b(this,K,Su).call(this),n(this,no)||u(this,no,{contentsObj:n(this,Ti),richText:n(this,bn)}),t&&u(this,gn,null),e&&e.text&&(u(this,bn,b(this,K,Ey).call(this,e.text)),u(this,vr,Vu.toDateObject(e.date)),u(this,Ti,null)),(i=n(this,os))==null||i.remove(),u(this,os,null)}resetEdited(){var t;n(this,no)&&({contentsObj:Dt(this,Ti)._,richText:Dt(this,bn)._}=n(this,no),u(this,no,null),(t=n(this,os))==null||t.remove(),u(this,os,null),u(this,gn,null))}remove(){var t,e,s;if((t=n(this,pn))==null||t.abort(),u(this,pn,null),(e=n(this,os))==null||e.remove(),u(this,os,null),u(this,Er,!1),u(this,ki,!1),(s=n(this,Gt))==null||s.remove(),u(this,Gt,null),this.trigger)for(const i of this.trigger)i.classList.remove("popupTriggerArea")}forceHide(){u(this,Er,this.isVisible),n(this,Er)&&(n(this,Ut).hidden=!0)}maybeShow(){n(this,as)||(b(this,K,Su).call(this),n(this,Er)&&(n(this,os)||b(this,K,Cu).call(this),u(this,Er,!1),n(this,Ut).hidden=!1))}get isVisible(){return!n(this,as)&&n(this,Ut).hidden===!1}}as=new WeakMap,wr=new WeakMap,mf=new WeakMap,bf=new WeakMap,Gl=new WeakMap,$l=new WeakMap,Ut=new WeakMap,Ti=new WeakMap,vr=new WeakMap,io=new WeakMap,zl=new WeakMap,Vl=new WeakMap,ki=new WeakMap,os=new WeakMap,pn=new WeakMap,gn=new WeakMap,Gt=new WeakMap,mn=new WeakMap,Sr=new WeakMap,hd=new WeakMap,bn=new WeakMap,jl=new WeakMap,no=new WeakMap,Er=new WeakMap,le=new WeakMap,xr=new WeakMap,K=new WeakSet,Su=function(){var e;if(n(this,pn))return;u(this,pn,new AbortController);const{signal:t}=n(this,pn);for(const s of this.trigger)s.addEventListener("click",n(this,Gl),{signal:t}),s.addEventListener("pointerenter",n(this,bf),{signal:t}),s.addEventListener("pointerleave",n(this,mf),{signal:t}),s.classList.add("popupTriggerArea");for(const s of n(this,io))(e=s.container)==null||e.addEventListener("keydown",n(this,wr),{signal:t})},rg=function(){const t=n(this,io).find(e=>e.hasCommentButton);t&&u(this,mn,t._normalizePoint(t.commentButtonPosition))},ag=function(){if(n(this,le).extraPopupElement&&!n(this,le).editor)return;n(this,Gt)||this.renderCommentButton();const[t,e]=n(this,mn),{style:s}=n(this,Gt);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},og=function(){n(this,le).extraPopupElement||(n(this,Gt)||this.renderCommentButton(),n(this,Gt).style.backgroundColor=this.commentButtonColor||"")},Eu=function(){const t=n(this,bn),e=n(this,Ti);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&n(this,bn).html||null},lg=function(){var t,e,s;return((s=(e=(t=n(this,K,Eu))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},Sy=function(){var t,e,s;return((s=(e=(t=n(this,K,Eu))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},Ey=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,K,Sy),fontSize:n(this,K,lg)?`calc(${n(this,K,lg)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
47`))e.push({name:"span",value:r,attributes:i});return s},xy=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,ki))&&b(this,K,xu).call(this)},Cy=function(){if(n(this,gn)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=n(this,zl);let a=!!n(this,Vl),o=a?n(this,Vl):n(this,hd);for(const y of n(this,io))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,gn,[100*(d-i)/e,100*(f-r)/s]);const{style:g}=n(this,Ut);g.left=`${n(this,gn)[0]}%`,g.top=`${n(this,gn)[1]}%`},xu=function(){if(n(this,as)){n(this,as).toggleCommentPopup(this,!1);return}u(this,ki,!n(this,ki)),n(this,ki)?(b(this,K,Cu).call(this),n(this,Ut).addEventListener("click",n(this,Gl)),n(this,Ut).addEventListener("keydown",n(this,wr))):(b(this,K,hg).call(this),n(this,Ut).removeEventListener("click",n(this,Gl)),n(this,Ut).removeEventListener("keydown",n(this,wr)))},Cu=function(){n(this,os)||this.render(),this.isVisible?n(this,ki)&&n(this,Ut).classList.add("focused"):(b(this,K,Cy).call(this),n(this,Ut).hidden=!1,n(this,Ut).style.zIndex=parseInt(n(this,Ut).style.zIndex,10)+1e3)},hg=function(){n(this,Ut).classList.remove("focused"),!(n(this,ki)||!this.isVisible)&&(n(this,Ut).hidden=!0,n(this,Ut).style.zIndex=parseInt(n(this,Ut).style.zIndex,10)-1e3)};class _y extends Pt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=W.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 cd;class bw extends Pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,cd,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=u(this,cd,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 n(this,cd)}addHighlightArea(){this.container.classList.add("highlightArea")}}cd=new WeakMap;var dd;class yw extends Pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,dd,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=u(this,dd,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",i-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 n(this,dd)}addHighlightArea(){this.container.classList.add("highlightArea")}}dd=new WeakMap;var ud;class Aw extends Pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,ud,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=u(this,ud,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",i/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 n(this,ud)}addHighlightArea(){this.container.classList.add("highlightArea")}}ud=new WeakMap;var fd;class Ty extends Pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,fd,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,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,fd,this.svgFactory.createElement(this.svgElementName));return c.setAttribute("points",h),c.setAttribute("stroke-width",i.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 n(this,fd)}addHighlightArea(){this.container.classList.add("highlightArea")}}fd=new WeakMap;class ww extends Ty{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class vw extends Pt{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 pd,ro,gd,cg;class sm extends Pt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,gd);m(this,pd,null);m(this,ro,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?W.HIGHLIGHT:W.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:i,borderStyle:r,popupRef:a}}=this,{transform:o,width:l,height:h}=b(this,gd,cg).call(this,s,e),c=this.svgFactory.create(l,h,!0),d=u(this,pd,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 i){const g=this.svgFactory.createElement(this.svgElementName);n(this,ro).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:i,rect:r}=e,a=n(this,pd);if(s>=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,ro).length;o<l;o++)n(this,ro)[o].setAttribute("points",i[o].join(","));if(r){const{transform:o,width:l,height:h}=b(this,gd,cg).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return n(this,ro)}addHighlightArea(){this.container.classList.add("highlightArea")}}pd=new WeakMap,ro=new WeakMap,gd=new WeakSet,cg=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 ky extends Pt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=W.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 Sw extends Pt{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 Ew extends Pt{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 xw extends Pt{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 Py extends Pt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=W.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 md,bd,dg;class Cw extends Pt{constructor(e){var r;super(e,{isRenderable:!0});m(this,bd);m(this,md,null);const{fileId:s,file:i}=this.data;this.filename=i.filename,this.content=i.content,this.fileId=s,(r=this.linkService.eventBus)==null||r.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",b(this,bd,dg).bind(this)),u(this,md,i);const{isMac:r}=pt.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&b(this,bd,dg).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,md)}addHighlightArea(){this.container.classList.add("highlightArea")}}md=new WeakMap,bd=new WeakSet,dg=async function(){var a;const{fileId:e,filename:s,content:i}=this,r=await this.linkService.getAttachmentContent(e)||i;r&&((a=this.downloadManager)==null||a.openOrDownloadData(r,s))};var Wl,ao,yn,Do,Dy,ug;class My extends Pt{constructor(e){super(e,{isRenderable:!!e.data.richMedia});m(this,Do);m(this,Wl,new AbortController);m(this,ao,null);m(this,yn,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,Do,Dy).call(this,s),{signal:n(this,Wl).signal}),this.container.append(s),this.container}destroy(){n(this,Wl).abort(),n(this,yn)&&(n(this,yn).pause(),n(this,yn).removeAttribute("src"),n(this,yn).load(),u(this,yn,null)),b(this,Do,ug).call(this)}}Wl=new WeakMap,ao=new WeakMap,yn=new WeakMap,Do=new WeakSet,Dy=async function(e){const{fileId:s,filename:i,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}=n(this,Wl),l=URL.createObjectURL(new Blob([a],{type:r}));u(this,ao,l);const h=r.startsWith("audio/"),c=document.createElement(h?"audio":"video");if(u(this,yn,c),c.className="mediaContent",this._setBackgroundColor(c),c.src=l,c.title=i,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,Do,ug).call(this,l),{once:!0,signal:o}),e.replaceWith(c),c.play().catch(()=>{})},ug=function(e=n(this,ao)){e&&e===n(this,ao)&&(URL.revokeObjectURL(e),u(this,ao,null))};var Cr,oo,Xl,An,Yl,lo,Te,yd,Bi,_u,Tu;const fm=class fm{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:
47a,structTreeLayer:o,commentManager:l,linkService:h,annotationStorage:c}){m(this,Bi);m(this,Cr,null);m(this,oo,null);m(this,Xl,null);m(this,An,new Map);m(this,Yl,null);m(this,lo,null);m(this,Te,[]);m(this,yd,!1);T(this,"zIndex",0);this.div=t,u(this,Cr,e),u(this,oo,s),u(this,Yl,o||null),u(this,lo,h||null),u(this,Xl,c||new Zg),this.page=r,this.viewport=a,this._annotationEditorUIManager=i,this._commentManager=l||null}hasEditableAnnotations(){return n(this,An).size>0}async render(t){var l;const{annotations:e,optionalContentConfig:s}=t,i=this.div;To(i,this.viewport);const r=new Map,a=[],o={data:null,layer:i,linkService:n(this,lo),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Ku,annotationStorage:n(this,Xl),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===It.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=qf.create(o);if(!d.isRenderable)continue;c||(n(this,Te).push(d),h.popupRef&&r.getOrInsertComputed(h.popupRef,wh).push(d));const f=d.render();h.hidden&&(f.style.visibility="hidden"),d.updateOC(s),d._isEditable&&(n(this,An).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}await b(this,Bi,_u).call(this);for(const h of a){const c=o.elements=r.get(h.id);o.data=h;const d=qf.create(o);if(!d.isRenderable)continue;const f=d.render();d.contentElement.id=`${Uo}${h.id}`,h.hidden&&(f.style.visibility="hidden"),c.at(-1).container.after(f)}b(this,Bi,Tu).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:n(this,lo),svgFactory:new Ku,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=fm._defaultBorderStyle),e.data=s;const i=qf.create(e);i.isRenderable&&(i.render(),i.contentElement.id=`${Uo}${s.id}`,n(this,Te).push(i))}await b(this,Bi,_u).call(this)}update({viewport:t,optionalContentConfig:e}){const s=this.div;this.viewport=t,To(s,{rotation:t.rotation});for(const i of n(this,Te))i.updateOC(e);b(this,Bi,Tu).call(this),s.hidden=!1}destroy(){var t,e;for(const s of n(this,Te))(t=s.destroy)==null||t.call(s),(e=n(this,Cr))==null||e.removePointerInTextLayer(s.contentElement);n(this,Te).length=0,n(this,An).clear(),this.div.replaceChildren()}refreshCanvases(){b(this,Bi,Tu).call(this)}getEditableAnnotations(){return n(this,An).values()}getEditableAnnotation(t){return n(this,An).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:i}=t,r=new lw({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:n(this,lo),annotationStorage:n(this,Xl)});return r.render(),r.contentElement.id=`${Uo}${s}`,r.createOrUpdatePopup(),n(this,Te).push(r),r}removeAnnotation(t){var i;const e=n(this,Te).findIndex(r=>r.data.id===t);if(e<0)return;const[s]=n(this,Te).splice(e,1);(i=n(this,Cr))==null||i.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);b(this,Bi,_u).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return $(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Ro.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};Cr=new WeakMap,oo=new WeakMap,Xl=new WeakMap,An=new WeakMap,Yl=new WeakMap,lo=new WeakMap,Te=new WeakMap,yd=new WeakMap,Bi=new WeakSet,_u=async function(){var s,i,r,a;if(n(this,Te).length===0)return;this.div.replaceChildren();const t=[];if(!n(this,yd)){u(this,yd,!0);for(const{contentElement:o,data:{hidden:l,id:h,oc:c}}of n(this,Te)){const d=o.id=`${Uo}${h}`,f=o.localName==="a"&&!l&&!c;t.push((s=n(this,Yl))==null?void 0:s.getAriaAttributes(d,{enableLinkOwnership:f}).then(g=>{if(g)for(const[y,A]of g)o.setAttribute(y,A)}))}}n(this,Te).sort(({data:{rect:[o,l,h,c]}},{data:{rect:[d,f,g,y]}})=>{if(o===h&&l===c)return 1;if(d===g&&f===y)return-1;const A=c,v=l,w=(l+c)/2,S=y,E=f,x=(f+y)/2;if(w>=S&&x<=v)return-1;if(x>=A&&w<=E)return 1;const C=(o+h)/2,_=(d+g)/2;return C-_});const e=document.createDocumentFragment();for(const o of n(this,Te))e.append(o.container),this._commentManager?(r=((i=o.extraPopupElement)==null?void 0:i.popup)||o.popup)==null||r.renderCommentButton():o.extraPopupElement&&e.append(o.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),n(this,Cr)){const o=await((a=n(this,Yl))==null?void 0:a.getAnnotationIds());for(const{contentElement:l}of n(this,Te))o!=null&&o.has(l.id)||n(this,Cr).addPointerInTextLayer(l,!1)}},Tu=function(){var e;if(!n(this,oo))return;const t=this.div;for(const[s,i]of n(this,oo)){const r=t.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;if(Array.isArray(i))for(const c of i)c.className="annotationContent",c.ariaHidden=!0;else i.className="annotationContent",i.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(i)?i[0]:i,{firstChild:l}=r;if(l?l.classList.contains("annotationContent")?l.after(o):l.before(o):r.append(o),Array.isArray(i)){let c=o;for(let d=1,f=i.length;d<f;d++)c.after(i[d]),c=i[d]}n(this,oo).delete(s);const h=n(this,An).get(s);h&&(h._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,r.id,i),h._hasNoCanvas=!1):h.canvas=i)}};let fg=fm;const Jd=/\r\n?|\n/g;var ls,Ad,ho,hs,Qt,Iy,Ly,Fy,ku,Dn,Pu,Mu,Ry,gg,Oy;const vt=class vt extends mt{constructor(e){super({...e,name:"freeTextEditor"});m(this,Qt);m(this,ls,"");m(this,Ad,`${this.id}-editor`);m(this,ho,null);m(this,hs);T(this,"_colorPicker",null);this.color=e.color||vt._defaultColor||mt._defaultLineColor,u(this,hs,e.fontSize||vt._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert(mt._l10nAlert.freetext),this.canAddComment=!1}static get _keyboardManager(){const e=vt.prototype,s=a=>a.isEmpty(),i=Po.TRANSLATE_SMALL,r=Po.TRANSLATE_BIG;return $(this,"_keyboardManager",new ko([[["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:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(e,s){mt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}
47static updateDefaultParams(e,s){switch(e){case tt.FREETEXT_SIZE:vt._defaultFontSize=s;break;case tt.FREETEXT_COLOR:vt._defaultColor=s;break}}updateParams(e,s){switch(e){case tt.FREETEXT_SIZE:b(this,Qt,Iy).call(this,s);break;case tt.FREETEXT_COLOR:b(this,Qt,Ly).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[tt.FREETEXT_SIZE,vt._defaultFontSize],[tt.FREETEXT_COLOR,vt._defaultColor||mt._defaultLineColor]]}get propertiesToUpdate(){return[[tt.FREETEXT_SIZE,n(this,hs)],[tt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Yu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return tt.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[-vt._internalPadding*e,-(vt._internalPadding+n(this,hs))*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,ho,new AbortController);const e=this._uiManager.combinedSignal(n(this,ho));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",n(this,Ad)),this._isDraggable=!0,(e=n(this,ho))==null||e.abort(),u(this,ho,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=n(this,ls),s=u(this,ls,b(this,Qt,Fy).call(this).trimEnd());if(e===s)return;const i=r=>{if(u(this,ls,r),!r){this.remove();return}b(this,Qt,Mu).call(this),this._uiManager.rebuild(this),b(this,Qt,ku).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),b(this,Qt,ku).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){vt._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",n(this,Ad)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${n(this,hs)}px * var(--total-scale-factor))`,i.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,Mu).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:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const r=b(y=vt,Dn,gg).call(y,s.getData("text")||"").replaceAll(Jd,`
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(Jd,"")),w!==this.editorDiv){let S=c;for(const E of this.editorDiv.childNodes){if(E===w){S=d;continue}S.push(b(A=vt,Dn,Pu).call(A,E))}}c.push(l.nodeValue.slice(0,h).replaceAll(Jd,""))}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=vt,Dn,Pu).call(v,E))}u(this,ls,`${c.join(`
50`)}${r}${d.join(`
51`)}`),b(this,Qt,Mu).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=vt._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,i){var o;let r=null;if(e instanceof _y){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:W.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,i);return u(a,hs,e.fontSize),a.color=D.makeHexColor(...e.color),u(a,ls,b(o=vt,Dn,gg).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=mt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(e),{color:s,fontSize:n(this,hs),value:b(this,Qt,Ry).call(this)});return this.addComment(i),e?(i.isCopy=!0,i):this.annotationElementId&&!b(this,Qt,Oy).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:i}=s;i.fontSize=`calc(${n(this,hs)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const r of n(this,ls).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:n(this,ls)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};ls=new WeakMap,Ad=new WeakMap,ho=new WeakMap,hs=new WeakMap,Qt=new WeakSet,Iy=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,hs))*this.parentScale),u(this,hs,r),b(this,Qt,ku).call(this)},i=n(this,hs);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:tt.FREETEXT_S
53IZE,overwriteIfSameType:!0,keepUndo:!0})},Ly=function(e){const s=r=>{this.color=r,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:tt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Fy=function(){var i;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(i=vt,Dn,Pu).call(i,r)),s=r);return e.join(`
54`)},ku=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=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),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},Dn=new WeakSet,Pu=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Jd,"")},Mu=function(){if(this.editorDiv.replaceChildren(),!!n(this,ls))for(const e of n(this,ls).split(`
55`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Ry=function(){return n(this,ls).replaceAll(" "," ")},gg=function(e){return e.replaceAll(" "," ")},Oy=function(e){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},m(vt,Dn),T(vt,"_freeTextDefaultContent",""),T(vt,"_internalPadding",0),T(vt,"_defaultColor",null),T(vt,"_defaultFontSize",10),T(vt,"_type","freetext"),T(vt,"_editorType",W.FREETEXT);let pg=vt;var co;class im{constructor(){m(this,co,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,co)[t]=e}toSVGProperties(){const t=n(this,co);return u(this,co,Object.create(null)),{root:t}}reset(){u(this,co,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){et("Not implemented")}}co=new WeakMap;var Kl,ql,Yt,uo,fo,Ql,V,mg,bg,yg,Ag,Uh,wg,vg,Sg,Gh,Ny,Du,$h,Ho;const Y=class Y extends mt{constructor(e){super(e);m(this,V);m(this,Kl,null);m(this,ql);T(this,"_clipPathId",null);T(this,"_colorPicker",null);T(this,"_drawId",null);T(this,"_drawOutlines",null);T(this,"_focusDrawId",null);u(this,ql,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,V,mg).call(this,e),b(this,V,Gh).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))i.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){et("Not implemented")}static get typesMap(){et("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(Y,Yt).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)e.push([i,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)e.push([i,s[r]]);return e}_updateProperty(e,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var c;r.updateProperty(s,l);const h=this._drawOutlines.updateProperty(s,l);h&&b(this,V,$h).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,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,s,i=this.colorAndOpacityType){const r=this.constructor.typesMap.get(this.colorType),a=this._opacityName,o=this._drawingOptions,l=o[r],h=o[a],c=(d,f)=>{var g;o.updateProperty(r,d),o.updateProperty(a,f),this._drawOutlines.updateProperty(r,d),this._drawOutlines.updateProperty(a,f),(g=this.parent)==null||g.drawLayer.updateProperties(this._drawId,o.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:c.bind(this,e,s),undo:c.bind(this,l,h),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,Y._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(b(this,V,Du).call(this)),{bbox:b(this,V,Ho).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,Y._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(b(this,V,Du).call(this)),{bbox:b(this,V,Ho).call(this)}
55)),b(this,V,Ag).call(this)}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,V,Ho).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,Y._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(b(this,V,Du).call(this),this.parentDimensions),{bbox:b(this,V,Ho).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}})}get _mustBeDisabledOnCommit(){return!0}commit(){super.commit(),this._mustBeDisabledOnCommit&&(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,n(this,ql)&&(u(this,ql,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this._uiManager.removeShouldRescale(this),b(this,V,Sg).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,V,Gh).call(this),b(this,V,$h).call(this,this._drawOutlines.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,V,Sg).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,V,Gh).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),b(this,V,wg).call(this),s&&this.select()}rotate(e=this.parentRotation){if(!this.parent||this._drawId===null)return;const s=(e-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,Y._mergeSVGProperties({bbox:b(this,V,Ho).call(this,e)},this._drawOutlines.updateRotation(s))),b(this,V,Ag).call(this,s)}show(e=this._isVisible){super.show(e),b(this,V,wg).call(this)}select(){super.select(),b(this,V,Uh).call(this,{hovered:!1,selected:!0})}unselect(){super.unselect(),b(this,V,Uh).call(this,{selected:!1})}pointerover(){this.isSelected||b(this,V,Uh).call(this,{hovered:!0})}pointerleave(){this.isSelected||b(this,V,Uh).call(this,{hovered:!1})}onScaleChanging(){if(!this.parent)return;const e=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);e&&b(this,V,$h).call(this,e)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();this.constructor._hasDrawClass&&i.classList.add("draw");const r=u(this,Kl,document.createElement("div"));return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this._clipPathId&&(r.style.clipPath=this._clipPathId),nb(this,r,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e){et("Not implemented")}static _getDrawingTarget(e,{target:s}){return s}static _getPointerCoords({offsetX:e,offsetY:s,clientX:i,clientY:r},a=null){if(!a)return[e,s];let o=i-a.clientX,l=r-a.clientY;switch(this._currentParent.viewport.rotation){case 90:[o,l]=[l,-o];break;case 180:[o,l]=[-o,-l];break;case 270:[o,l]=[-l,o];break}return[a.offsetX+o,a.offsetY+l]}static _addDrawingListeners(e,s){}static _endDrawingSession(e=!1){return this._currentParent.endDrawingSession(e)}static startDrawing(e,s,i,r){var x;const{pointerId:a,pointerType:o}=r;if(Ee.isInitializedAndDifferentPointerType(o))return;const l=this._getDrawingTarget(e,r),[h,c]=this._getPointerCoords(r),{viewport:{rotation:d}}=e,{x:f,y:g,width:y,height:A}=l.getBoundingClientRect(),v=u(Y,uo,new AbortController),w=e.combinedSignal(v);if(Ee.setPointer(o,a),window.addEventListener("pointerup",C=>{Ee.isSamePointerIdOrRemove(C.pointerId)&&this._endDraw(C)},{signal:w}),window.addEventListener("pointercancel",C=>{Ee.isSamePointerIdOrRemove(C.pointerId)&&this._endDrawingSession()},{signal:w}),window.addEventListener("pointerdown",C=>{Ee.isSamePointerType(C.pointerType)&&(Ee.initializeAndAddPointerId(C.pointerId),n(Y,Yt).isCancellable()&&(n(Y,Yt).removeLastElement(),n(Y,Yt).isEmpty()?this._endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:w}),window.addEventListener("contextmenu",ii,{signal:w}),l.addEventListener("pointermove",this._drawMove.bind(this),{signal:w}),l.addEventListener("touchmove",C=>{Ee.isSameTimeStamp(C.timeStamp)&&ee(C)},{signal:w}),this._addDrawingListeners(l,w),e.toggleDrawing(),(x=s._editorUndoBar)==null||x.hide(),n(Y,Yt)){e.drawLayer.updateProperties(this._currentDrawId,n(Y,Yt).startNew(h,c,y,A,d));return}s.updateUIForDefaultProperties(this),u(Y,Yt,this.createDrawerInstance({x:h,y:c,box:[f,g,y,A],rotation:d,parent:e,isLTR:i})),u(Y,fo,this.getDefaultDrawingOptions()),this._currentParent=e;const{id:S,clipPathId:E}=e.drawLayer.draw(this._mergeSVGProperties(n(Y,fo).toSVGProperties(),n(Y,Yt).defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=S,u(Y,Ql,this._hasClipPath?E:null)}static _drawMove(e){var r;if(Ee.isSameTimeStamp(e.timeStamp),!n(Y,Yt)||!Ee.isSamePointerId(e.pointerId))return;if(Ee.isUsingMultiplePointers()){this._endDraw(e);return}let s;const i=(r=e.getCoalescedEvents)==null?void 0:r.call(e);
55if(i!=null&&i.length){const a=[];for(const o of i)a.push(...this._getPointerCoords(o,e));s=n(Y,Yt).addPoints(a)}else s=n(Y,Yt).add(...this._getPointerCoords(e));this._currentParent.drawLayer.updateProperties(this._currentDrawId,s),Ee.setTimeStamp(e.timeStamp),ee(e)}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,u(Y,Yt,null),u(Y,fo,null),u(Y,Ql,null),Ee.clearTimeStamp()),n(Y,uo)&&(n(Y,uo).abort(),u(Y,uo,null),Ee.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),s.drawLayer.updateProperties(this._currentDrawId,(e==null?void 0:e.target)===s.div?n(Y,Yt).end(...this._getPointerCoords(e)):n(Y,Yt).end()),this.supportMultipleDrawings){const i=n(Y,Yt),r=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,i.removeLastElement())},mustExec:!1,type:tt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(tt.DRAW_STEP),!n(Y,Yt).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:n(Y,Ql),drawOutlines:n(Y,Yt).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(Y,fo),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,r,a,o,l){et("Not implemented")}static async deserialize(e,s,i){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,i),c=await super.deserialize(e,s,i);return c.createDrawingOptions(e),b(d=c,V,mg).call(d,{drawOutlines:h}),b(f=c,V,Gh).call(f),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return this._drawOutlines.serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Kl=new WeakMap,ql=new WeakMap,Yt=new WeakMap,uo=new WeakMap,fo=new WeakMap,Ql=new WeakMap,V=new WeakSet,mg=function({drawOutlines:e,drawId:s,drawingOptions:i,clipPathId:r}){this._drawOutlines=e,this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(mt._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this._clipPathId=r??null,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties),b(this,V,yg).call(this,this.parent)):this._drawId=b(this,V,bg).call(this,e,this.parent),b(this,V,$h).call(this,e.box)},bg=function(e,s){const{id:i,clipPathId:r}=s.drawLayer.draw(Y._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,this.constructor._hasClipPath);return this.constructor._hasClipPath&&(this._clipPathId=r),b(this,V,yg).call(this,s),i},yg=function(e){const s=this._drawOutlines.getFocusSVGProperties(n(this,V,vg));s&&(this._focusDrawId=e.drawLayer.drawOutline(s,this._drawOutlines.focusMustRemoveSelfIntersections))},Ag=function(e=n(this,V,vg)){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(e)))},Uh=function(e){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,{rootClass:e}))},wg=function(){const{parent:e,_drawId:s,_focusDrawId:i,_isVisible:r}=this;if(!e||s===null)return;const a={hidden:!r};e.drawLayer.updateProperties(s,{rootClass:a}),i!==null&&e.drawLayer.updateProperties(i,{rootClass:a})},vg=function(){return(this.parentRotation-this._drawRotation+360)%360},Sg=function(){if(this._drawId===null||!this.parent)return;const{drawLayer:e}=this.parent;e.remove(this._drawId),this._drawId=null,this._focusDrawId!==null&&(e.remove(this._focusDrawId),this._focusDrawId=null),this._drawingOptions.reset()},Gh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){const{drawLayer:s}=this.parent;s.updateParent(this._drawId,e.drawLayer),this._focusDrawId!==null&&s.updateParent(this._focusDrawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,V,bg).call(this,this._drawOutlines,e),this._clipPathId&&n(this,Kl)&&(n(this,Kl).style.clipPath=this._clipPathId)}},Ny=function([e,s,i,r]){const{parentDimensions:[a,o],_drawRotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),r*(a/o)];case 180:return[1-e,1-s,i,r];case 270:return[1-s,e,i*(o/a),r*(a/o)];default:return[e,s,i,r]}},Du=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],_drawRotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),r*(o/a)];case 180:return[1-e,1-s,i,r];case 270:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}},$h=function(e){[this.x,this.y,this.width,this.height]=b(this,V,Ny).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Ho=function(e=this.parentRotation){const{x:s,y:i,width:r,height:a,_drawRotation:o,parentDimensions:[l,h]}=this;switch((o*4+e)/90){case 1:return[1-i-a,s,a,r];case 2:return[1-s-r,1-i-a,r,a];case 3:return[i,1-s-r,a,r];case 4:return[s,i-r*(l/h),a*(h/l),r*(l/h)];case 5:return[1-i,s,r*(l/h),a*(h/l)];case 6:return[1-s-a*(h/l),1-i,a*(h/l),r*(l/h)];case 7:return[i-r*(l/h),1-s-a*(h/l),r*(l/h),a*(h/l)];case 8:return[s-r,i-a,r,a];case 9:return[1-i,s-r,a,r];case 10:return[1-s,1-i,r,a];case 11:return[i-a,1-s,a,r];case 12:return[s-a*(h/l),i,a*(h/l),r*(l/h)];case 13:return[1-i-r*(l/h),s-a*(h/l),r*(l/h),a*(h/l)];case 14:return[1-s,1-i-r*(l/h),a*(h/l),r*(l/h)];case 15:return[i,1-s,r*(l/h),a*(h/l)];default:return[s,i,r,a]}},T(Y,"_currentDrawId",-1),T(Y,"_currentParent",null),m(Y,Yt,null),m(Y,uo,null),m(Y,fo,null),m(Y,Ql,null),T(Y,"_INNER_MARGIN",3);let ec=Y;class O{constructor(){T(this,"focusOutline",null)}toSVGPath(){et("Abstract method `toSVGPath` must be implemented.")}get box(){et("Abstract getter `box` must be implemented.")}serialize(t,e){et("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){et("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(t){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(t,e){return null}updateParentDimensions(t,e){return null}serializeQuadPoints(t,e){return null}updateRotation(t){return{}}getPathResizingSVGProperties(t){return{}}getPathResizedSVGProperties(t){return{}}getPathTranslatedSVGProperties(t,e){return{}}static _rotateBox([t,e,s,i],r){switch(r){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}static _rescale(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*i,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;
55o+=2)a[o]=e+t[o+1]*i,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r){switch(r){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static createBezierPoints(t,e,s,i,r,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+a)/6,(s+r)/2,(i+a)/2]}}T(O,"PRECISION",1e-4);var cs,Rs,Jl,Zl,Qs,Q,po,go,wd,vd,th,eh,Pi,Sd,yf,Af,se,zh,By,Hy,Uy,Gy,$y,zy;const Vi=class Vi{constructor(t,e,s,i,r,a,o=0){m(this,se);m(this,cs);m(this,Rs,[]);m(this,Jl);m(this,Zl);m(this,Qs,[]);m(this,Q,new Float32Array(18));m(this,po);m(this,go);m(this,wd);m(this,vd);m(this,th);m(this,eh);m(this,Pi,[]);u(this,cs,s),u(this,eh,r*i),u(this,Zl,a),n(this,Q).set([NaN,NaN,NaN,NaN,t,e],6),u(this,Jl,o),u(this,vd,n(Vi,Sd)*i),u(this,wd,n(Vi,Af)*i),u(this,th,i),n(this,Pi).push(t,e)}isEmpty(){return isNaN(n(this,Q)[8])}isCancellable(){return n(this,Pi).length<=10}removeLastElement(){return n(this,Q).fill(NaN),n(this,Qs).length=n(this,Rs).length=n(this,Pi).length=0,{path:{d:""}}}add(t,e){var M;u(this,po,t),u(this,go,e);const[s,i,r,a]=n(this,cs);let[o,l,h,c]=n(this,Q).subarray(8,12);const d=t-h,f=e-c,g=Math.hypot(d,f);if(g<n(this,wd))return!1;const y=g-n(this,vd),A=y/g,v=A*d,w=A*f;let S=o,E=l;o=h,l=c,h+=v,c+=w,(M=n(this,Pi))==null||M.push(t,e);const x=-w/y,C=v/y,_=x*n(this,eh),k=C*n(this,eh);return n(this,Q).set(n(this,Q).subarray(2,8),0),n(this,Q).set([h+_,c+k],4),n(this,Q).set(n(this,Q).subarray(14,18),12),n(this,Q).set([h-_,c-k],16),isNaN(n(this,Q)[6])?(n(this,Qs).length===0&&(n(this,Q).set([o+_,l+k],2),n(this,Qs).push(NaN,NaN,NaN,NaN,(o+_-s)/r,(l+k-i)/a),n(this,Q).set([o-_,l-k],14),n(this,Rs).push(NaN,NaN,NaN,NaN,(o-_-s)/r,(l-k-i)/a)),n(this,Q).set([S,E,o,l,h,c],6),!this.isEmpty()):(n(this,Q).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]=n(this,Q).subarray(2,6),n(this,Qs).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,S,E]=n(this,Q).subarray(14,18),n(this,Rs).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((E+l)/2-i)/a),!0):([S,E,o,l,h,c]=n(this,Q).subarray(0,6),n(this,Qs).push(((S+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),[h,c,o,l,S,E]=n(this,Q).subarray(12,18),n(this,Rs).push(((S+5*o)/6-s)/r,((E+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,Qs),e=n(this,Rs);if(isNaN(n(this,Q)[6])&&!this.isEmpty())return b(this,se,By).call(this);const s=[];
55s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);b(this,se,Uy).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return b(this,se,Hy).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new Vy(t,e,s,i,r,a)}getOutlines(){var d;const t=n(this,Qs),e=n(this,Rs),s=n(this,Q),[i,r,a,o]=n(this,cs),l=new Float32Array((((d=n(this,Pi))==null?void 0:d.length)??0)+2);for(let f=0,g=l.length-2;f<g;f+=2)l[f]=(n(this,Pi)[f]-i)/a,l[f+1]=(n(this,Pi)[f+1]-r)/o;if(l[l.length-2]=(n(this,po)-i)/a,l[l.length-1]=(n(this,go)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,se,Gy).call(this,l);const h=new Float32Array(n(this,Qs).length+24+n(this,Rs).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,se,zy).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,se,$y).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,cs),n(this,th),n(this,Jl),n(this,Zl))}};cs=new WeakMap,Rs=new WeakMap,Jl=new WeakMap,Zl=new WeakMap,Qs=new WeakMap,Q=new WeakMap,po=new WeakMap,go=new WeakMap,wd=new WeakMap,vd=new WeakMap,th=new WeakMap,eh=new WeakMap,Pi=new WeakMap,Sd=new WeakMap,yf=new WeakMap,Af=new WeakMap,se=new WeakSet,zh=function(){const t=n(this,Q).subarray(4,6),e=n(this,Q).subarray(16,18),[s,i,r,a]=n(this,cs);return[(n(this,po)+(t[0]-e[0])/2-s)/r,(n(this,go)+(t[1]-e[1])/2-i)/a,(n(this,po)+(e[0]-t[0])/2-s)/r,(n(this,go)+(e[1]-t[1])/2-i)/a]},By=function(){const[t,e,s,i]=n(this,cs),[r,a,o,l]=b(this,se,zh).call(this);return`M${(n(this,Q)[2]-t)/s} ${(n(this,Q)[3]-e)/i} L${(n(this,Q)[4]-t)/s} ${(n(this,Q)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,Q)[16]-t)/s} ${(n(this,Q)[17]-e)/i} L${(n(this,Q)[14]-t)/s} ${(n(this,Q)[15]-e)/i} Z`},Hy=function(t){const e=n(this,Rs);t.push(`L${e[4]} ${e[5]} Z`)},Uy=function(t){const[e,s,i,r]=n(this,cs),a=n(this,Q).subarray(4,6),o=n(this,Q).subarray(16,18),[l,h,c,d]=b(this,se,zh).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${h} L${c} ${d} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},Gy=function(t){const e=n(this,Q),[s,i,r,a]=n(this,cs),[o,l,h,c]=b(this,se,zh).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/a],0),this.newFreeDrawOutline(d,t,n(this,cs),n(this,th),n(this,Jl),n(this,Zl))},$y=function(t,e){const s=n(this,Rs);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},zy=function(t,e){const s=n(this,Q).subarray(4,6),i=n(this,Q).subarray(16,18),[r,a,o,l]=n(this,cs),[h,c,d,f]=b(this,se,zh).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,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},m(Vi,Sd,8),m(Vi,yf,2),m(Vi,Af,n(Vi,Sd)+n(Vi,yf));let qu=Vi;var sh,Mi,wn,Ed,Js,xd,Ot,wf,jy;class Vy extends O{constructor(e,s,i,r,a,o){super();m(this,wf);m(this,sh);m(this,Mi,new Float32Array(4));m(this,wn);m(this,Ed);m(this,Js);m(this,xd);
55m(this,Ot);u(this,Ot,e),u(this,Js,s),u(this,sh,i),u(this,xd,r),u(this,wn,a),u(this,Ed,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,wf,jy).call(this,o);const[l,h,c,d]=n(this,Mi);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${n(this,Ot)[4]} ${n(this,Ot)[5]}`];for(let s=6,i=n(this,Ot).length;s<i;s+=6){if(isNaN(n(this,Ot)[s])){e.push(`L${n(this,Ot)[s+4]} ${n(this,Ot)[s+5]}`);continue}e.push(`C${n(this,Ot)[s]} ${n(this,Ot)[s+1]} ${n(this,Ot)[s+2]} ${n(this,Ot)[s+3]} ${n(this,Ot)[s+4]} ${n(this,Ot)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,r],a){const o=i-e,l=r-s;let h,c;switch(a){case 0:h=O._rescale(n(this,Ot),e,r,o,-l),c=O._rescale(n(this,Js),e,r,o,-l);break;case 90:h=O._rescaleAndSwap(n(this,Ot),e,s,o,l),c=O._rescaleAndSwap(n(this,Js),e,s,o,l);break;case 180:h=O._rescale(n(this,Ot),i,s,-o,l),c=O._rescale(n(this,Js),i,s,-o,l);break;case 270:h=O._rescaleAndSwap(n(this,Ot),i,r,-o,-l),c=O._rescaleAndSwap(n(this,Js),i,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,Mi)}newOutliner(e,s,i,r,a,o,l=0){return new qu(e,s,i,r,a,o,l)}updateThickness(e){const s=this.getNewOutline(e);return u(this,Ot,n(s,Ot)),u(this,Js,n(s,Js)),n(this,Mi).set(n(s,Mi)),this.firstPoint=s.firstPoint,this.lastPoint=s.lastPoint,n(this,Mi)}getNewOutline(e,s){const[i,r,a,o]=n(this,Mi),[l,h,c,d]=n(this,sh),f=a*c,g=o*d,y=i*c+l,A=r*d+h,v=n(this,Js),w=this.newOutliner(v[0]*f+y,v[1]*g+A,n(this,sh),n(this,xd),e,n(this,Ed),s??n(this,wn));for(let S=2,E=v.length;S<E;S+=2)w.add(v[S]*f+y,v[S+1]*g+A);return w.getOutlines()}}sh=new WeakMap,Mi=new WeakMap,wn=new WeakMap,Ed=new WeakMap,Js=new WeakMap,xd=new WeakMap,Ot=new WeakMap,wf=new WeakSet,jy=function(e){const s=n(this,Ot);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r,h=i,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(Pn,0),D.bezierBoundingBox(i,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]))),i=v,r=w}const g=n(this,Mi);g[0]=a[0]-n(this,wn),g[1]=a[1]-n(this,wn),g[2]=a[2]-a[0]+2*n(this,wn),g[3]=a[3]-a[1]+2*n(this,wn),this.firstPoint=[o,l],this.lastPoint=[h,c]};function Wy(p){return{bbox:p.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:p.isFree},path:{d:p.toSVGPath()}}}function Xy(p,t){const{focusOutline:e}=p;return{bbox:O._rotateBox(e.box,t),root:{"data-main-rotation":t},rootClass:{highlightOutline:!0,free:p.isFree},path:{d:e.toSVGPath()}}}var Cd,_d,Td,_r,Zs,Ue,Yy,Iu,Ky,qy,xg;class Eg{constructor(t,e=0,s=0,i=!0){m(this,Ue);m(this,Cd);m(this,_d);m(this,Td);m(this,_r,[]);m(this,Zs,[]);const r=Pn.slice(),a=10**-4;for(const{x:A,y:v,width:w,height:S}of t){const E=Math.floor((A-e)/a)*a,x=Math.ceil((A+w+e)/a)*a,C=Math.floor((v-e)/a)*a,_=Math.ceil((v+S+e)/a)*a,k=[E,C,_,!0],P=[x,C,_,!1];n(this,_r).push(k,P),D.rectBoundingBox(E,C,x,_,r)}const o=r[2]-r[0]+2*s,l=r[3]-r[1]+2*s,h=r[0]-s,c=r[1]-s;let d=i?-1/0:1/0,f=1/0;const g=n(this,_r).at(i?-1:-2),y=[g[0],g[2]];for(const A of n(this,_r)){const[v,w,S,E]=A;!E&&i?w<f?(f=w,d=v):w===f&&(d=Math.max(d,v)):E&&!i&&(w<f?(f=w,d=v):w===f&&(d=Math.min(d,v))),A[0]=(v-h)/o,A[1]=(w-c)/l,A[2]=(S-c)/l}u(this,Cd,new Float32Array([h,c,o,l])),u(this,_d,[d,f]),u(this,Td,y)}getOutlines(){n(this,_r).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,_r))e[3]?(t.push(...b(this,Ue,xg).call(this,e)),b(this,Ue,Ky).call(this,e)):(b(this,Ue,qy).call(this,e),t.push(...b(this,Ue,xg).call(this,e)));return b(this,Ue,Yy).call(this,t)}}Cd=new WeakMap,_d=new WeakMap,Td=new WeakMap,_r=new WeakMap,Zs=new WeakMap,Ue=new WeakSet,Yy=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 i=[];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],i.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 Cg(i,n(this,Cd),n(this,_d),n(this,Td))},Iu=function(t){const e=n(this,Zs);let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:i=r-1}return i+1},Ky=function([,t,e]){const s=b(this,Ue,Iu).call(this,t);n(this,Zs).splice(s,0,[t,e])},qy=function([,t,e]){const s=b(this,Ue,Iu).call(this,t);for(let i=s;i<n(this,Zs).length;i++){const[r,a]=n(this,Zs)[i];if(r!==t)break;
55if(r===t&&a===e){n(this,Zs).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,Zs)[i];if(r!==t)break;if(r===t&&a===e){n(this,Zs).splice(i,1);return}}},xg=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,Ue,Iu).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,Zs)[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 kd,Pd,ih;class Cg extends O{constructor(e,s,i,r){super();m(this,kd);m(this,Pd,null);m(this,ih);u(this,ih,e),u(this,kd,s),this.firstPoint=i,this.lastPoint=r}static build(e,s){const i=new Eg(e,.001).getOutlines();return u(i,Pd,e),i.focusOutline=new Eg(e,.0025,.001,s).getOutlines(),i}get isFree(){return!1}get defaultSVGProperties(){return Wy(this)}getFocusSVGProperties(e){return Xy(this,e)}updateRotation(e){return{root:{"data-main-rotation":e}}}serializeQuadPoints([e,s],[i,r]){const a=n(this,Pd),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:d,height:f}of a){const g=h*i+e,y=(1-c)*r+s;o[l]=o[l+4]=g,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=g+d*i,o[l+5]=o[l+7]=y-f*r,l+=8}return o}toSVGPath(){const e=[];for(const s of n(this,ih)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,r],a){const o=[],l=i-e,h=r-s;for(const c of n(this,ih)){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 n(this,kd)}}kd=new WeakMap,Pd=new WeakMap,ih=new WeakMap;class nm extends qu{newFreeDrawOutline(t,e,s,i,r,a){return new _g(t,e,s,i,r,a)}}var ds,Md;class _w{constructor(t,e,s,i,r,a,o){m(this,ds);m(this,Md);u(this,ds,new nm(t,e,s,i,r,a,o)),u(this,Md,r)}add(t,e){return n(this,ds).add(t,e)?{path:{d:n(this,ds).toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)e=n(this,ds).add(t[s],t[s+1])||e;return e?{path:{d:n(this,ds).toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return n(this,ds).isEmpty()}isCancellable(){return n(this,ds).isCancellable()}removeLastElement(){return n(this,ds).removeLastElement()}updateProperty(t,e){return null}getOutlines(){const t=n(this,ds).getOutlines();return t.buildFocusOutline(2*n(this,Md)),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:n(this,ds).toSVGPath()}}}}ds=new WeakMap,Md=new WeakMap;var vf;const Sf=class Sf extends Vy{newOutliner(t,e,s,i,r,a,o=0){return new nm(t,e,s,i,r,a,o)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+n(Sf,vf),.0025)}get defaultSVGProperties(){return Wy(this)}getFocusSVGProperties(t){return Xy(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;const s=this.updateThickness(e/2);return this.buildFocusOutline(e),s}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}};vf=new WeakMap,m(Sf,vf,1.5);let _g=Sf;class rm extends im{constructor(t=null){super(),super.updateProperties(t)}updateSVGProperty(t,e){t!=="thickness"&&super.updateSVGProperty(t,e)}clone(){const t=new rm;return t.updateAll(this),t}}var nh,Dd,Id,Ld,Fd,rh,As,Tg,Qy,Lu,Jy;const Ie=class Ie extends ec{constructor(e){var s;super({...e,name:"highlightEditor"});m(this,As);m(this,nh,null);m(this,Dd,0);m(this,Id,null);m(this,Ld,0);m(this,Fd,"");m(this,rh,"");u(this,nh,e.anchorNode||null),u(this,Dd,e.anchorOffset||0),u(this,Id,e.focusNode||null),u(this,Ld,e.focusOffset||0),u(this,Fd,e.methodOfCreation||((s=this._drawOutlines)!=null&&s.isFree?"main_toolbar":"")),u(this,rh,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static get _keyboardManager(){const e=Ie.prototype;return $(this,"_keyboardManager",new ko([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}static initialize(e,s){var i;mt.initialize(e,s),this._defaultDrawingOptions||(this._defaultDrawingOptions=new rm({fill:((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066","fill-opacity":Ie._DEFAULT_OPACITY,thickness:Ie._DEFAULT_THICKNESS}))}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get typesMap(){return $(this,"typesMap",new Map([[tt.HIGHLIGHT_COLOR,"fill"],[tt.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(e){const{boxes:s,drawOutlines:i}=e;!s&&!i||(this._drawingOptions||(this._drawingOptions=e.drawingOptions||Ie.getDefaultDrawingOptions()),s&&(e={...e,drawOutlines:Cg.build(s,this._uiManager.direction==="ltr")}),super._addOutlines(e))}get colorType(){return tt.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){var e;return(e=this._drawOutlines)!=null&&e.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){var e;return!((e=this._drawOutlines)!=null&&e.isFree)}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:n(this,Fd)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("
55color").size}}translateInPage(e,s){}get toolbarPosition(){return b(this,As,Tg).call(this,this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return b(this,As,Tg).call(this,this._drawOutlines.firstPoint)}updateParams(e,s){switch(e){case tt.HIGHLIGHT_COLOR:this._updateColorAndOpacity(s,Ie._DEFAULT_OPACITY,e),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(s)},!0);break;case tt.HIGHLIGHT_THICKNESS:super.updateParams(e,s),this._reportTelemetry({action:"thickness_changed",thickness:s},!0);break}}get propertiesToUpdate(){const e=super.propertiesToUpdate;return e.push([tt.HIGHLIGHT_FREE,this._drawOutlines.isFree]),e}get toolbarButtons(){return this._uiManager.highlightColors?(this._colorPicker=new Xu({editor:this}),[["colorPicker",this._colorPicker]]):super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(e,s){return super.getRect(e,s,this._drawRotation)}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}render(){if(this.div)return this.div;const e=super.render();return n(this,rh)&&(e.setAttribute("aria-label",n(this,rh)),e.setAttribute("role","mark")),this._drawOutlines.isFree?e.classList.add("free"):e.addEventListener("keydown",b(this,As,Qy).bind(this),{signal:this._uiManager._signal}),this.enableEditing(),e}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,As,Lu).call(this,!0);break;case 1:case 3:b(this,As,Lu).call(this,!1);break}}unselect(){super.unselect(),this._drawOutlines.isFree||b(this,As,Lu).call(this,!1)}static createDrawerInstance({x:e,y:s,box:i,parent:r,isLTR:a}){return new _w(e,s,i,r.scale,this._defaultDrawingOptions.thickness/2,a,.001)}static _getDrawingTarget(e,{target:s}){return s.closest(".textLayer")}static _getPointerCoords({x:e,y:s}){return[e,s]}static _addDrawingListeners(e,s){e.classList.add("free"),s.addEventListener("abort",()=>e.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:s}),window.addEventListener("pointerdown",ee,{capture:!0,passive:!1,signal:s})}static _endDrawingSession(e=!1){return this.endDrawing(e)}createDrawingOptions({color:e,opacity:s,thickness:i}){const{_defaultDrawingOptions:r,_DEFAULT_OPACITY:a}=Ie;this._drawingOptions=Ie.getDefaultDrawingOptions({fill:D.makeHexColor(...e),"fill-opacity":s||a,thickness:i||r.thickness})}static deserializeDraw(e,s,i,r,a,o,l){const{quadPoints:h}=o;if(h){const y=[];for(let A=0,v=h.length;A<v;A+=8)y.push({x:(h[A]-e)/i,y:1-(h[A+1]-s)/r,width:(h[A+2]-h[A])/i,height:(h[A+1]-h[A+5])/r});return Cg.build(y,l.direction==="ltr")}const c=o.thickness||this._defaultDrawingOptions.thickness,d=(o.inkLists||o.outlines.points)[0],f=new nm(d[0]-e,r-(d[1]-s),[0,0,i,r],1,c/2,!0,.001);for(let y=0,A=d.length;y<A;y+=2)f.add(d[y]-e,r-(d[y+1]-s));const g=f.getOutlines();return g.buildFocusOutline(c),g}static async deserialize(e,s,i){let r=null;if(e instanceof ky){const{data:{quadPoints:o,rect:l,rotation:h,id:c,color:d,opacity:f,popupRef:g,richText:y,contentsObj:A,creationDate:v,modificationDate:w},parent:{page:{pageNumber:S}}}=e;r=e={annotationType:W.HIGHLIGHT,color:Array.from(d),opacity:f,quadPoints:o,pageIndex:S-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:g,richText:y,comment:(A==null?void 0:A.str)||null,creationDate:v,modificationDate:w}}else if(e instanceof sm){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,borderStyle:{rawWidth:f},popupRef:g,richText:y,contentsObj:A,creationDate:v,modificationDate:w},parent:{page:{pageNumber:S}}}=e;r=e={annotationType:W.HIGHLIGHT,color:Array.from(d),thickness:f,inkLists:o,pageIndex:S-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:g,richText:y,comment:(A==null?void 0:A.str)||null,creationDate:v,modificationDate:w}}const a=await super.deserialize(e,s,i);return a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=super.serialize(e);return Object.assign(s,{color:mt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(s.rect,this._drawRotation)}),this.addComment(s),this.annotationElementId&&!b(this,As,Jy).call(this,s)?null:(s.id=this.annotationElementId,s)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}};nh=new WeakMap,Dd=new WeakMap,Id=new WeakMap,Ld=new WeakMap,Fd=new WeakMap,rh=new WeakMap,As=new WeakSet,Tg=function([e,s]){const[i,r,a,o]=this._drawOutlines.box;
55return[(e-i)/a,(s-r)/o]},Qy=function(e){Ie._keyboardManager.exec(this,e)},Lu=function(e){if(!n(this,nh))return;const s=window.getSelection();e?s.setPosition(n(this,nh),n(this,Dd)):s.setPosition(n(this,Id),n(this,Ld))},Jy=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},T(Ie,"_DEFAULT_OPACITY",1),T(Ie,"_DEFAULT_THICKNESS",12),T(Ie,"_defaultDrawingOptions",null),T(Ie,"_type","highlight"),T(Ie,"_editorType",W.HIGHLIGHT);let Qu=Ie;var Di,Tr,Kt,ge,mo,ah,me,qt,Os,bo,yo,Ao,ws,Fu,Ru,kg;class Tw{constructor(t,e,s,i,r,a){m(this,ws);m(this,Di,new Float64Array(6));m(this,Tr,new Float64Array(2));m(this,Kt);m(this,ge);m(this,mo);m(this,ah);m(this,me);m(this,qt,"");m(this,Os,0);m(this,bo,new Wd);m(this,yo);m(this,Ao);u(this,yo,s),u(this,Ao,i),u(this,mo,r),u(this,ah,a),[t,e]=b(this,ws,Fu).call(this,t,e);const o=u(this,Kt,[NaN,NaN,NaN,NaN,t,e]);u(this,me,[t,e]),u(this,ge,[{line:o,points:n(this,me)}]),n(this,Di).set(o,0),n(this,Tr).set([t,e],0)}updateProperty(t,e){t==="stroke-width"&&u(this,ah,e)}isEmpty(){var t;return!((t=n(this,ge))!=null&&t.length)}isCancellable(){return n(this,me).length<=10}add(t,e){return b(this,ws,Ru).call(this,t,e)&&this.toSVGPath(),{path:{d:b(this,ws,kg).call(this)}}}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)b(this,ws,Ru).call(this,t[s],t[s+1])&&(e=!0,n(this,me).length<=6&&(this.toSVGPath(),e=!1));return e&&this.toSVGPath(),{path:{d:b(this,ws,kg).call(this)}}}end(t,e){return t!==void 0&&b(this,ws,Ru).call(this,t,e)?{path:{d:this.toSVGPath()}}:n(this,me).length===2?{path:{d:this.toSVGPath()}}:{path:{d:n(this,qt)}}}startNew(t,e,s,i,r){u(this,yo,s),u(this,Ao,i),u(this,mo,r),[t,e]=b(this,ws,Fu).call(this,t,e);const a=u(this,Kt,[NaN,NaN,NaN,NaN,t,e]);u(this,me,[t,e]),n(this,Tr).set([t,e],0);const o=n(this,ge).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,ge).push({line:a,points:n(this,me)}),n(this,Di).set(a,0),u(this,Os,0),this.toSVGPath(),null}getLastElement(){return n(this,ge).at(-1)}setLastElement(t){return n(this,ge)?(n(this,ge).push(t),u(this,Kt,t.line),u(this,me,t.points),u(this,Os,0),{path:{d:this.toSVGPath()}}):n(this,bo).setLastElement(t)}removeLastElement(){if(!n(this,ge))return n(this,bo).removeLastElement();n(this,ge).pop(),u(this,qt,"");for(let t=0,e=n(this,ge).length;t<e;t++){const{line:s,points:i}=n(this,ge)[t];u(this,Kt,s),u(this,me,i),u(this,Os,0),this.toSVGPath()}return{path:{d:n(this,qt)}}}toSVGPath(){const t=O.svgRound(n(this,Kt)[4]),e=O.svgRound(n(this,Kt)[5]);if(n(this,me).length===2)return u(this,qt,`${n(this,qt)} M ${t} ${e} Z`),n(this,qt);if(n(this,me).length<=6){const i=n(this,qt).lastIndexOf("M");u(this,qt,`${n(this,qt).slice(0,i)} M ${t} ${e}`),u(this,Os,6)}if(n(this,me).length===4){const i=O.svgRound(n(this,Kt)[10]),r=O.svgRound(n(this,Kt)[11]);return u(this,qt,`${n(this,qt)} L ${i} ${r}`),u(this,Os,12),n(this,qt)}const s=[];n(this,Os)===0&&(s.push(`M ${t} ${e}`),u(this,Os,6));for(let i=n(this,Os),r=n(this,Kt).length;i<r;i+=6){const[a,o,l,h,c,d]=n(this,Kt).slice(i,i+6).map(O.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}return u(this,qt,n(this,qt)+s.join(" ")),u(this,Os,n(this,Kt).length),n(this,qt)}getOutlines(t,e,s,i){const r=n(this,ge).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,bo).build(n(this,ge),t,e,s,n(this,mo),n(this,ah),i),u(this,Di,null),u(this,Kt,null),u(this,ge,null),u(this,qt,null),n(this,bo)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Di=new WeakMap,Tr=new WeakMap,Kt=new WeakMap,ge=new WeakMap,mo=new WeakMap,ah=new WeakMap,me=new WeakMap,qt=new WeakMap,Os=new WeakMap,bo=new WeakMap,yo=new WeakMap,Ao=new WeakMap,ws=new WeakSet,Fu=function(t,e){return O._normalizePoint(t,e,n(this,yo),n(this,Ao),n(this,mo))},Ru=function(t,e){[t,e]=b(this,ws,Fu).call(this,t,e),n(this,Tr).set([t,e],0);const[s,i,r,a]=n(this,Di).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,yo)*o,n(this,Ao)*l)<=2?!1:(n(this,me).push(t,e),isNaN(s)?(n(this,Di).set([r,a,t,e],2),n(this,Kt).push(NaN,NaN,NaN,NaN,t,e),!0):(isNaN(n(this,Di)[0])&&n(this,Kt).splice(6,6),n(this,Di).set([s,i,r,a,t,e],0),n(this,Kt).push(...O.createBezierPoints(s,i,r,a,t,e)),!0))},kg=function(){const t=O.svgRound(n(this,Tr)[0]),e=O.svgRound(n(this,Tr)[1]);if(n(this,me).length===2){const s=O.svgRound(n(this,Kt)[4]),i=O.svgRound(n(this,Kt)[5]);return`${n(this,qt)} M ${s} ${i} L ${t} ${e}`}return`${n(this,qt)} L ${t} ${e}`};var Fe,Rd,Od,us,Ii,Li,oh,lh,wo,ye,$i,Zy,tA,eA;class Wd extends O{constructor(){super(...arguments);m(this,ye);m(this,Fe);m(this,Rd,0);m(this,Od);m(this,us);m(this,Ii);m(this,Li);m(this,oh);m(this,lh);m(this,wo)}build(e,s,i,r,a,o,l){u(this,Ii,s),u(this,Li,i),u(this,oh,r),u(this,lh,a),u(this,wo,o),u(this,Od,l??0),u(this,us,e),b(this,ye,tA).call(this)}get thickness(){return n(this,wo)}setLastElement(e){return n(this,us).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,us).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,us)){if(e.push(`M${O.svgRound(s[4])} ${O.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${O.svgRound(s[10])} ${O.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,h,c,d]=s.subarray(i,i+6).map(O.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[h,c,d,f]=b(this,ye,Zy).call(this);let g,y,A,v,w,S,E,x,C;switch(n(this,lh)){case 0:C=O._rescale,g=e,y=s+r,A=i,v=-r,w=e+h*i,S=s+(1-c-f)*r,E=e+(h+d)*i,x=s+(1-c)*r;break;case 90:C=O._rescaleAndSwap,g=e,y=s,A=i,v=r,w=e+c*i,S=s+h*r,E=e+(c+f)*i,x=s+(h+d)*r;break;case 180:C=O._rescale,g=e+i,y=s,A=-i,v=r,w=e+(1-h-d)*i,S=s+c*r,E=e+(1-h)*i,x=s+(c+f)*r;break;case 270:C=O._rescaleAndSwap,g=e+i,y=s+r,A=-i,v=-r,w=e+(1-c-f)*i,S=s+(1-h-d)*r,E=e+(1-c)*i,x=s+(1-h)*r;break}for(const{line:_,points:k}of n(this,us))o.push(C(_,g,y,A,v,a?new Array(_.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,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const d=[];let f,g,y,A,v;switch(h){case 0:v=O._rescale,f=-e/i,g=s/r+1,y=1/i,A=-1/r;break;case 90:v=O._rescaleAndSwap,f=-s/r,g=-e/i,y=1/r,A=1/i;break;case 180:v=O._rescale,f=e/i+1,g=-s/r,y=-1/i,A=1/r;break;case 270:v=O._rescaleAndSwap,f=s/r+1,g=e/i+1,y=-1/r,A=-1/i;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,_,k,P]=S.subarray(0,4);x.set([NaN,NaN,NaN,NaN,C,_],0);for(let M=4;M<E;M+=2){const L=S[M],N=S[M+1];x.set(O.createBezierPoints(C,_,k,P,L,N),(M-2)*3),[C,_,k,P]=[k,P,L,N]}}}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,i,r,1,h,c,a),w}get box(){return n(this,Fe)}updateProperty(e,s){return e==="stroke-width"?b(this,ye,eA).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,ye,$i).call(this);u(this,Ii,e),u(this,Li,s),u(this,oh,i);const[o,l]=b(this,ye,$i).call(this),h=o-r,c=l-a,d=n(this,Fe);return d[0]-=h,d[1]-=c,d[2]+=2*h,d[3]+=2*c,d}updateRotation(e){return u(this,Rd,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,Fe).map(O.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,Fe);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,Fe);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,Rd)){case 90:r=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,h=s;break;case 270:r=-s/e,a=e/s,h=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${O.svgRound(l)} ${O.svgRound(h)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=b(this,ye,$i).call(this),[l,h,c,d]=n(this,Fe);if(Math.abs(c-a)<=O.PRECISION||Math.abs(d-o)<=O.PRECISION){const v=e+i/2-(l+c/2),w=s+r/2-(h+d/2);return{path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const f=(i-2*a)/(c-2*a),g=(r-2*o)/(d-2*o),y=c/i,A=d/r;return{path:{"transform-origin":`${O.svgRound(l)} ${O.svgRound(h)}`,transform:`${this.rotationTransform} scale(${y} ${A}) translate(${O.svgRound(a)} ${O.svgRound(o)}) scale(${f} ${g}) translate(${O.svgRound(-a)} ${O.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,ye,$i).call(this),l=n(this,Fe),[h,c,d,f]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(d-a)<=O.PRECISION||Math.abs(f-o)<=O.PRECISION){const w=e+i/2-(h+d/2),S=s+r/2-(c+f/2);for(const{line:E,points:x}of n(this,us))O._translate(E,w,S,E),O._translate(x,w,S,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(i-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 n(this,us))O._rescale(w,A,v,g,y,w),O._rescale(S,A,v,g,y,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,Fe),l=e-o[0],h=s-o[1];if(n(this,Ii)===r&&n(this,Li)===a)for(const{line:c,points:d}of n(this,us))O._translate(c,l,h,c),O._translate(d,l,h,d);else{const c=n(this,Ii)/r,d=n(this,Li)/a;u(this,Ii,r),u(this,Li,a);for(const{line:f,points:g}of n(this,us))O._rescale(f,l,h,c,d,f),O._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":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,Fe);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${O.svgRound(e[0])} ${O.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}Fe=new WeakMap,Rd=new WeakMap,Od=new WeakMap,us=new WeakMap,Ii=new WeakMap,Li=new WeakMap,oh=new WeakMap,lh=new WeakMap,wo=new WeakMap,ye=new WeakSet,$i=function(e=n(this,wo)){const s=n(this,Od)+e/2*n(this,oh);return n(this,lh)%180===0?[s/n(this,Ii),s/n(this,Li)]:[s/n(this,Li),s/n(this,Ii)]},Zy=function(){const[e,s,i,r]=n(this,Fe),[a,o]=b(this,ye,$i).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},tA=function(){const e=u(this,Fe,Zr.slice());for(const{line:r}of n(this,us)){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,i]=b(this,ye,$i).call(this);e[0]=Et(e[0]-s,0,1),e[1]=Et(e[1]-i,0,1),e[2]=Et(e[2]+s,0,1),e[3]=Et(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},eA=function(e){const[s,i]=b(this,ye,$i).call(this);u(this,wo,e);const[r,a]=b(this,ye,$i).call(this),[o,l]=[r-s,a-i],h=n(this,Fe);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class Hf extends im{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:mt._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 Hf(this._viewParameters);return t.updateAll(this),t}}var Ef,sA;const $o=class $o extends ec{constructor(e){super({...e,name:"inkEditor"});m(this,Ef);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){mt.initialize(e,s),this._defaultDrawingOptions=new Hf(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([[tt.INK_THICKNESS,"stroke-width"],[tt.INK_COLOR,"stroke"],[tt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:e,y:s,box:[,,i,r],rotation:a}){return new Tw(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return Wd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof sm){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:W.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,i);return a._initialData=r,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Yu(this)),[["colorPicker",this._colorPicker]]}get colorType(){return tt.INK_COLOR}get colorAndOpacityType(){return tt.INK_COLOR_AND_OPACITY}get opacityType(){return tt.INK_OPACITY}updateParams(e,s){if(e===tt.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===tt.INK_COLOR_AND_OPACITY){super.updateDefaultParams(tt.INK_COLOR,s.color),super.updateDefaultParams(tt.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:i}=this;s.updateSVGProperty("stroke-width"),i.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:i}){this._drawingOptions=$o.getDefaultDrawingOptions({stroke:D.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(e),{color:mt._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:i}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!b(this,Ef,sA).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};Ef=new WeakSet,sA=function(e){const{color:s,thickness:i,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},T($o,"_type","ink"),T($o,"_editorType",W.INK),T($o,"_defaultDrawingOptions",null);let Pg=$o;class Mg extends Wd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Zd=8,xh=3;var vo,rt,Dg,ti,iA,nA,Ig,Ou,rA,aA,oA,Lg,Fg,lA;class kn{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,a,o,l){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const d=200,f=c.font=`${s} ${i} ${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),_=Math.ceil(Math.max(Math.abs(A)+Math.abs(v)||d,Math.abs(w)+Math.abs(S)||d)*x);h=new OffscreenCanvas(C,_),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=f,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,C,_),c.fillStyle="black",c.fillText(t,C*(x-1)/2,_*(3-x)/2);const k=b(this,rt,Lg).call(this,c.getImageData(0,0,C,_).data),P=b(this,rt,oA).call(this,k),M=b(this,rt,Fg).call(this,P),L=b(this,rt,Ig).call(this,k,C,_,M);return this.processDrawnLines({lines:{curves:L,width:C,height:_},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[a,o,l]=b(this,rt,lA).call(this,t),[h,c]=b(this,rt,aA).call(this,a,o,l,Math.hypot(o,l)*n(this,vo).sigmaSFactor,n(this,vo).sigmaR,n(this,vo).kernelSize),d=b(this,rt,Fg).call(this,c),f=b(this,rt,Ig).call(this,h,o,l,d);return this.processDrawnLines({lines:{curves:f,width:o,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:a,areContours:o}){i%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,rt,rA).call(this,S):S;if(!E)continue;v.push(E);const x=E.length,C=new Float32Array(x),_=new Float32Array(3*(x===2?2:x-2));if(f.push({line:_,points:C}
55),x===2){C[0]=E[0]*y,C[1]=E[1]*A,_.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),_.set([NaN,NaN,NaN,NaN,k,P],0);for(let N=4;N<x;N+=2){const Z=C[N]=E[N]*y,q=C[N+1]=E[N+1]*A;_.set(O.createBezierPoints(k,P,M,L,Z,q),(N-2)*3),[k,P,M,L]=[M,L,Z,q]}}if(f.length===0)return null;const w=o?new Mg:new Wd;return w.build(f,e,s,1,i,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:i,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=Zd+xh*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++]=i,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:i}=new DecompressionStream("deflate-raw"),r=i.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=(Zd+xh*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[xh*E+Zd],C=new Float32Array(x+2);v.push(C);for(let _=0;_<xh-1;_++)C[_]=l[xh*E+Zd+_+1];for(let _=0;_<x;_++)C[_+2]=C[_]+S[o++]}return{areContours:f,thickness:g,outlines:v,width:c,height:d}}catch(e){return X(`decompressSignature: ${e}`),null}}}vo=new WeakMap,rt=new WeakSet,Dg=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},ti=new WeakMap,iA=function(t,e,s,i,r,a,o){const l=b(this,rt,Dg).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,d=n(this,ti)[2*c],f=n(this,ti)[2*c+1];if(t[(s+d)*e+(i+f)]!==0)return c}return-1},nA=function(t,e,s,i,r,a,o){const l=b(this,rt,Dg).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,d=n(this,ti)[2*c],f=n(this,ti)[2*c+1];if(t[(s+d)*e+(i+f)]!==0)return c}return-1},Ig=function(t,e,s,i){const r=t.length,a=new Int32Array(r);for(let c=0;c<r;c++)a[c]=t[c]<=i?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 N of h)if(N.id===l){E=N;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,rt,iA).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=n(this,ti)[2*x],_=n(this,ti)[2*x+1];const k=c+C,P=d+_;y=k,A=P;let M=c,L=d;for(;;){const N=b(this,rt,nA).call(this,a,e,M,L,y,A,1);C=n(this,ti)[2*N],_=n(this,ti)[2*N+1];const Z=M+C,q=L+_;v.push(q,Z);const J=M*e+L;if(a[J+1]===0?a[J]=-o:a[J]===1&&(a[J]=o),Z===c&&q===d&&M===k&&L===P){a[f]!==1&&(l=Math.abs(a[f]));break}else y=M,A=L,M=Z,L=q}}}return h},Ou=function(t,e,s,i){if(s-e<=4){for(let k=e;k<s-2;k+=2)i.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,_=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&&(_=k,C=P)}C>(h*x)**2?(b(this,rt,Ou).call(this,t,e,_+2,i),b(this,rt,Ou).call(this,t,_,s,i)):i.push(r,a)},rA=function(t){const e=[],s=t.length;return b(this,rt,Ou).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},aA=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**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 _=0;_<a;_++){const k=A+_-h;if(!(k<0||k>=s))for(let P=0;P<a;P++){const M=v+P-h;if(M<0||M>=e)continue;const L=t[k*e+M],N=o[_*a+P]*c[Math.abs(L-S)];E+=L*N,x+=N}}const C=g[w]=Math.round(E/x);y[C]++}return[g,y]},oA=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Lg=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const h=s[o]=t[o<<2];i=Math.max(i,h),r=Math.min(r,h)}const a=255/(i-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},Fg=function(t){let e,s=-1/0,i=-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>i&&(i=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},lA=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,vo);let a=s,o=i;if(s>r||i>r){let f=s,g=i,y=Math.log2(Math.max(s,i)/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,rt,Lg).call(this,c),a,o]},m(kn,rt),m(kn,vo,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),m(kn,ti,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class am extends im{constructor(){super(),super.updateProperties({fill:mt._defaultLineColor,"stroke-width":0})}clone(){const t=new am;return t.updateAll(this),t}}class om extends Hf{constructor(t){super(t),super.updateProperties({stroke:mt._defaultLineColor,"stroke-width":1})}clone(){const t=new om(this._viewParameters);return t.updateAll(this),t}}var kr,Fi,Pr,So;const Je=class Je extends ec{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});m(this,kr,!1);m(this,Fi,null);m(this,Pr,null);m(this,So,null);this._willKeepAspectRatio=!0,u(this,Pr,e.signatureData||null),u(this,Fi,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){mt.initialize(e,s),this._defaultDrawingOptions=new am,this._defaultDrawnSignatureOptions=new om(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:!!n(this,Fi)}}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()}
55render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(n(this,Pr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=n(this,Pr),{rawDims:{pageWidth:d,pageHeight:f},rotation:g}=this.parent.viewport,y=kn.processDrawnLines({lines:r,pageWidth:d,pageHeight:f,rotation:g,innerMargin:Je._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:n(this,Fi)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){u(this,So,e),this.addEditToolbar()}getUuid(){return n(this,So)}get description(){return n(this,Fi)}set description(e){u(this,Fi,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:i,width:r,height:a}=n(this,Pr),o=Math.max(r,a),l=kn.processDrawnLines({lines:{curves:e.map(h=>({points:h})),thickness:i,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,i,r){const{x:a,y:o}=this,{outline:l}=u(this,Pr,e);u(this,kr,l instanceof Mg),this.description=i;let h;n(this,kr)?h=Je.getDefaultDrawingOptions():(h=Je._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:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return kn.process(e,s,i,r,Je._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return kn.extractContoursFromText(e,s,i,r,a,Je._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return kn.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:Je._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Je.getDefaultDrawingOptions():(this._drawingOptions=Je._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:n(this,kr),color:[0,0,0],thickness:n(this,kr)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,So),a.isCopy=!0):a.lines=s,n(this,Fi)&&(a.accessibilityData={type:"Figure",alt:n(this,Fi)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?Mg.deserialize(e,s,i,r,a,o):Wd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return u(r,kr,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",u(r,So,e.uuid),r}};kr=new WeakMap,Fi=new WeakMap,Pr=new WeakMap,So=new WeakMap,T(Je,"_type","signature"),T(Je,"_editorType",W.SIGNATURE),T(Je,"_defaultDrawingOptions",null);let Rg=Je;var kt,he,Mr,vn,Dr,hh,Sn,Eo,Ri,fs,ch,st,Vh,jh,Nu,Bu,Hu,Ng,Uu,hA;class Og extends mt{constructor(e){super({...e,name:"stampEditor"});m(this,st);m(this,kt,null);m(this,he,null);m(this,Mr,null);m(this,vn,null);m(this,Dr,null);m(this,hh,"");m(this,Sn,null);m(this,Eo,!1);m(this,Ri,null);m(this,fs,!1);m(this,ch,!1);u(this,vn,e.bitmapUrl),u(this,Dr,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){mt.initialize(e,s)}static isHandlingMimeForPasting(e){return np.includes(e)}static paste(e,s){s.pasteEditor({mode:W.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:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.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 i.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;n(this,he)&&(u(this,kt,null),this._uiManager.imageManager.deleteId(n(this,he)),(e=n(this,Sn))==null||e.remove(),u(this,Sn,null),n(this,Ri)&&(clearTimeout(n(this,Ri)),u(this,Ri,null))),super.remove()}rebuild(){if(!this.parent){n(this,he)&&b(this,st,Nu).call(this);return}super.rebuild(),this.div!==null&&(n(this,he)&&n(this,Sn)===null&&b(this,st,Nu).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,Mr)||n(this,kt)||n(this,vn)||n(this,Dr)||n(this,he)||n(this,Eo))}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(),n(this,Eo)||(n(this,kt)?b(this,st,Bu).call(this):b(this,st,Nu).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(u(this,he,i),r&&u(this,kt,r),u(this,Eo,!1),b(this,st,Bu).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,Ri)!==null&&clearTimeout(n(this,Ri)),u(this,Ri,setTimeout(()=>{u(this,Ri,null),b(this,st,Ng).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,kt),o=new ni;let l=n(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);n(this,fs)||(l=b(this,st,Hu).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":OA.isDarkMode&&(v="#8f8f9d",w="#42414d");const S=15,E=S*o.sx,x=S*o.sy,C=new OffscreenCanvas(E*2,x*2),_=C.getContext("2d");_.fillStyle=v,_.fillRect(0,0,E*2,x*2),_.fillStyle=w,_.fillRect(0,0,E,x),_.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(i){let g,y;if(o.symmetric&&l.width<e&&l.height<e)g=l.width,y=l.height;else if(l=n(this,kt),r>e||a>e){const w=Math.min(e/r,e/a);g=Math.floor(r*w),y=Math.floor(a*w),n(this,fs)||(l=b(this,st,Hu).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,i){var v;let r=null,a=!1;if(e instanceof Py){const{data:{rect:w,rotation:S,id:E,structParent:x,popupRef:C,richText:_,contentsObj:k,creationDate:P,modificationDate:M},container:L,parent:{page:{pageNumber:N}},canvas:Z}=e;let q,J;Z?(delete e.canvas,{id:q,bitmap:J}=i.imageManager.getFromCanvas(L.id,Z),Z.remove()):(a=!0,e._hasNoCanvas=!0);const $t=((v=await s._structTree.getAriaAttributes(`${Uo}${E}`))==null?void 0:v.get("aria-label"))||"";r=e={annotationType:W.STAMP,bitmapId:q,bitmap:J,pageIndex:N-1,rect:w.slice(0),rotation:S,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:$t},isSvg:!1,structParent:x,popupRef:C,richText:_,comment:(k==null?void 0:k.str)||null,creationDate:P,modificationDate:M}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:d,isSvg:f,accessibilityData:g}=e;a?(i.addMissingCanvas(e.id,o),u(o,Eo,!0)):d&&i.imageManager.isValidId(d)?(u(o,he,d),h&&u(o,kt,h)):u(o,vn,c),u(o,fs,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,ch,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(e),{bitmapId:n(this,he),isSvg:n(this,fs)});if(this.addComment(i),e)return i.bitmapUrl=b(this,st,Uu).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=b(this,st,hA).call(this,i);return l.isSame?null:(l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,fs)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,he)))s.stamps.set(n(this,he),{area:o,serialized:i}),i.bitmap=b(this,st,Uu).call(this,!1);else if(n(this,fs)){const l=s.stamps.get(n(this,he));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,st,Uu).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}
55kt=new WeakMap,he=new WeakMap,Mr=new WeakMap,vn=new WeakMap,Dr=new WeakMap,hh=new WeakMap,Sn=new WeakMap,Eo=new WeakMap,Ri=new WeakMap,fs=new WeakMap,ch=new WeakMap,st=new WeakSet,Vh=function(e,s=!1){if(!e){this.remove();return}u(this,kt,e.bitmap),s||(u(this,he,e.id),u(this,fs,e.isSvg)),e.file&&u(this,hh,e.file.name),b(this,st,Bu).call(this)},jh=function(){if(u(this,Mr,null),this._uiManager.enableWaiting(!1),!!n(this,Sn)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,kt)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(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()}},Nu=function(){if(n(this,he)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,he)).then(i=>b(this,st,Vh).call(this,i,!0)).finally(()=>b(this,st,jh).call(this));return}if(n(this,vn)){const i=n(this,vn);u(this,vn,null),this._uiManager.enableWaiting(!0),u(this,Mr,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,st,Vh).call(this,r)).finally(()=>b(this,st,jh).call(this)));return}if(n(this,Dr)){const i=n(this,Dr);u(this,Dr,null),this._uiManager.enableWaiting(!0),u(this,Mr,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,st,Vh).call(this,r)).finally(()=>b(this,st,jh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=np.join(",");const s=this._uiManager._signal;u(this,Mr,new Promise(i=>{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,Vh).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,st,jh).call(this))),e.click()},Bu=function(){var h;const{div:e}=this;let{width:s,height:i}=n(this,kt);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const c=Math.min(o*r/s,o*a/i);s*=c,i*=c}this._uiManager.enableWaiting(!1);const l=u(this,Sn,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=i/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,Ng).call(this),n(this,ch)||(this.parent.addUndoableEditor(this),u(this,ch,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,hh)&&this.div.setAttribute("aria-description",n(this,hh)),this.annotationElementId||this._uiManager.a11yAlert(mt._l10nAlert.stamp)},Hu=function(e,s){const{width:i,height:r}=n(this,kt);let a=i,o=r,l=n(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},Ng=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new ni,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,Sn);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,fs)?n(this,kt):b(this,st,Hu).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)},Uu=function(e){if(e){if(n(this,fs)){const r=this._uiManager.imageManager.getSvgUrl(n(this,he));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,kt),s.getContext("2d").drawImage(n(this,kt),0,0),s.toDataURL()}if(n(this,fs)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*$r.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*$r.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,kt),0,0,n(this,kt).width,n(this,kt).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,kt))},hA=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},T(Og,"_type","stamp"),T(Og,"_editorType",W.STAMP);var xo,dh,Ir,Lr,En,Ye,Fr,uh,fh,ei,xn,Ke,Cn,Rr,ph,B,Or,bt,Hg,cA,hi,Ug,Gg,Gu;const Gs=class Gs{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){m(this,bt);m(this,xo);m(this,dh,!1);m(this,Ir,null);m(this,Lr,null);m(this,En,null);m(this,Ye,new Map);m(this,Fr,!1);m(this,uh,!1);m(this,fh,!1);m(this,ei,null);m(this,xn,null);m(this,Ke,null);m(this,Cn,null);m(this,Rr,null);m(this,ph,-1);m(this,B);const d=[...n(Gs,Or).values()];if(!Gs._initialized){Gs._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,xo,r),u(this,Ir,a),this.viewport=h,u(this,Ke,l),this.drawLayer=o,this._structTree=i,n(this,B).addLayer(this)}get isEmpty(){return n(this,Ye).size===0}get isInvisible(){return this.isEmpty&&n(this,B).getMode()===W.NONE}updateToolbar(t){n(this,B).updateToolbar(t)}updateMode(t=n(this,B).getMode()){switch(b(this,bt,Gu).call(this),t){case W.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case W.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case W.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===W.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n(Gs,Or).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,Ke))==null?void 0:e.div)}setEditingState(t){n(this,B).setEditingState(t)}addCommands(t){n(this,B).addCommands(t)}cleanUndoStack(t){n(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=n(this,Ir))==null||e.togglePointerEvents(t)}async enable(){var s;u(this,fh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,Rr))==null||s.abort(),u(this,Rr,null);const t=new Set;for(const i of n(this,bt,Hg))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,B).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,Ir);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),n(this,B).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}u(this,fh,!1),n(this,B)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(u(this,uh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,Ke)&&!n(this,Rr)){u(this,Rr,new AbortController);const r=n(this,B).combinedSignal(n(this,Rr));n(this,Ke).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,d=n(this,ph);if(c-d>500){u(this,ph,c);return}u(this,ph,-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(`^${bh}[0-9]+$`);for(const w of g)if(A.test(w.id)){y=w.id;break}if(!y)return;const v=n(this,Ye).get(y);(v==null?void 0:v.annotationElementId)===null&&(ee(a),v.dblclick(a))},{signal:r,capture:!0})}const t=n(this,Ir),e=[];if(t){const r=new Map,a=new Map;for(const o of n(this,bt,Hg)){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);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(n(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&&(n(this,B).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}b(this,bt,Gu).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(Gs,Or).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),u(this,uh,!1)}getEditableAnnotation(t){var e;return((e=n(this,Ir))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,B).getActive()!==t&&n(this,B).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,Ke))!=null&&t.div&&!n(this,Cn)){u(this,Cn,new AbortController);const e=n(this,B).combinedSignal(n(this,Cn));n(this,Ke).div.addEventListener("pointerdown",b(this,bt,cA).bind(this),{signal:e}),n(this,Ke).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,Ke))!=null&&t.div&&n(this,Cn)&&(n(this,Cn).abort(),u(this,Cn,null),n(this,Ke).div.classList.remove("highlighting"))}enableClick(){if(n(this,Lr))return;u(this,Lr,new AbortController);const t=n(this,B).combinedSignal(n(this,Lr));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=n(this,Lr))==null||t.abort(),u(this,Lr,null)}attach(t){n(this,Ye).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,B).isDeletedAnnotationElement(e)&&n(this,B).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,Ye).delete(t.id),(e=n(this,xo))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,uh)&&t.annotationElementId&&n(this,B).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,B).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,B).addDeletedAnnotationElement(t),mt.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),n(this,B).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,fh)),n(this,B).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,En)&&(t._focusEventsAllowed=!1,u(this,En,setTimeout(()=>{u(this,En,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,B)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,xo))==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 n(this,Ye).values())if(e.uid===t)return e;return null}combinedSignal(t){return n(this,B).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,bt,hi))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,B).updateMode(t.mode);const{offsetX:s,offsetY:i}=b(this,bt,Gg).call(this),r=n(this,B).getId(),a=b(this,bt,Ug).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,B),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n(Gs,Or).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,B)))||null}createAndAddNewEditor(t,e,s={}){const i=n(this,B).getId(),r=b(this,bt,Ug).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,B),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,bt,Gg).call(this),!0,t)}setSelected(t){n(this,B).setSelected(t)}toggleSelected(t){n(this,B).toggleSelected(t)}unselect(t){n(this,B).unselect(t)}pointerup(t){var i;const{isMac:e}=pt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,Fr)||(u(this,Fr,!1),(i=n(this,bt,hi))!=null&&i.isDrawer&&n(this,bt,hi).supportMultipleDrawings))return;if(!n(this,dh)){u(this,dh,!0);return}const s=n(this,B).getMode();if(s===W.STAMP||s===W.POPUP||s===W.SIGNATURE){n(this,B).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,B).getMode()===W.HIGHLIGHT&&this.enableTextSelection(),n(this,Fr)){u(this,Fr,!1);return}const{isMac:e}=pt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(u(this,Fr,!0),(i=n(this,bt,hi))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,B).getActive();u(this,dh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,ei)){n(this,bt,hi).startDrawing(this,n(this,B),!1,t);return}n(this,B).setCurrentDrawingSession(this),u(this,ei,new AbortController);const e=n(this,B).combinedSignal(n(this,ei));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(u(this,xn,null),this.commitOrRemove())},{signal:e}),n(this,bt,hi).startDrawing(this,n(this,B),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&u(this,xn,e);return}n(this,xn)&&setTimeout(()=>{var e;(e=n(this,xn))==null||e.focus(),u(this,xn,null)},0)}endDrawingSession(t=!1){return n(this,ei)?(n(this,B).setCurrentDrawingSession(null),n(this,ei).abort(),u(this,ei,null),u(this,xn,null),n(this,bt,hi).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,B).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,ei)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,ei)&&n(this,bt,hi).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,B).getActive())==null?void 0:t.parent)===this&&(n(this,B).commitOrRemove(),n(this,B).setActiveEditor(null)),n(this,En)&&(clearTimeout(n(this,En)),u(this,En,null));for(const s of n(this,Ye).values())(e=n(this,xo))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,Ye).clear(),n(this,B).removeLayer(this)}async render({viewport:t}){this.viewport=t,To(this.div,t);for(const e of n(this,B).getEditors(this.pageIndex))this.add(e),e.rebuild();await n(this,B).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){n(this,B).commitOrRemove(),b(this,bt,Gu).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,To(this.div,{rotation:s}),e!==s)for(const i of n(this,Ye).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,B).viewParameters.realScale}};xo=new WeakMap,dh=new WeakMap,Ir=new WeakMap,Lr=new WeakMap,En=new WeakMap,Ye=new WeakMap,Fr=new WeakMap,uh=new WeakMap,fh=new WeakMap,ei=new WeakMap,xn=new WeakMap,Ke=new WeakMap,Cn=new WeakMap,Rr=new WeakMap,ph=new WeakMap,B=new WeakMap,Or=new WeakMap,bt=new WeakSet,Hg=function(){return n(this,Ye).size!==0?n(this,Ye).values():n(this,B).getEditors(this.pageIndex)},cA=function(t){n(this,B).unselectAll();const{target:e}=t;if(e===n(this,Ke).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&n(this,Ke).div.contains(e)){const{isMac:s}=pt.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,B).showAllEditors("highlight",!0,!0),Qu.startDrawing(this,n(this,B),n(this,B).direction==="ltr",t),t.preventDefault()}},hi=function(){return n(Gs,Or).get(n(this,B).getMode())},Ug=function(t){const e=n(this,bt,hi);return e?new e.prototype.constructor(t):null},Gg=function(){const{x:t,y:e,width:s,height:i}=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+i),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}},Gu=function(){for(const t of n(this,Ye).values())t.isEmpty()&&t.remove()},T(Gs,"_initialized",!1),m(Gs,Or,new Map([pg,Pg,Og,Qu,Rg].map(t=>[t._editorType,t])));let Bg=Gs;function kw(p,t){return p===t?0:p.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function tu(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 Pw(p,t,e,s){if(p===e)return t<=s;const i=p.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function Wm(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 Re,Oe,Ns,Nd,Bd,Co,_o,Hd,xf,Nr,Br,Hr,Ur,_n,ke,zg,Vg,dA,$u,uA,Ui,jg,fA,Wg;const G=class G{constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){m(this,Ui);m(this,Re,null);m(this,Oe,new Map);m(this,Ns,null);m(this,Nd,null);m(this,Bd,null);m(this,Co,null);m(this,_o,new Map);if(this.pageIndex=s,u(this,Nd,t),u(this,Bd,e),i){const r=n(G,_n).get(i);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),n(G,Br).delete(r.selectionDiv)),n(G,_n).set(i,{drawLayer:this}),n(G,Ur).add(i),u(this,Ns,i),u(this,Co,new MutationObserver(a=>{var o,l,h;if(!(!n(this,Re)||!((o=n(this,Ns))!=null&&o.isConnected)||!b(l=G,ke,Vg).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,ke,$u).call(h);return}}}
55)),n(this,Co).observe(i,{childList:!0}),n(G,Nr)===null){u(G,Nr,new AbortController);const{signal:a}=n(G,Nr);document.addEventListener("selectionchange",b(G,ke,$u).bind(G),{signal:a}),document.addEventListener("pointerdown",()=>{u(G,Hr,!0)},{signal:a}),document.addEventListener("pointerup",()=>{u(G,Hr,!1)},{signal:a}),window.addEventListener("blur",()=>{u(G,Hr,!1)},{signal:a})}}}setParent(t){var e,s,i;if(!n(this,Re)){u(this,Re,t),(e=n(this,Ns))!=null&&e.isConnected&&b(s=G,ke,Vg).call(s)&&b(i=G,ke,$u).call(i);return}if(n(this,Re)!==t){if(n(this,Oe).size>0)for(const r of n(this,Oe).values())r.remove(),t.append(r);u(this,Re,t)}}static get _svgFactory(){return $(this,"_svgFactory",new Ku)}draw(t,e=!1,s=!1){const i=Dt(G,Hd)._++,r=b(this,Ui,jg).call(this),a=G._svgFactory.createElement("defs");r.append(a);const o=G._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,_o).set(i,o);const h=s?b(this,Ui,fA).call(this,a,l):null,c=G._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,Oe).set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=Dt(G,Hd)._++,i=b(this,Ui,jg).call(this),r=G._svgFactory.createElement("defs");i.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");i.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,Oe).set(s,i),s}finalizeDraw(t,e){n(this,_o).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:r,path:a}=e,o=typeof t=="number"?n(this,Oe).get(t):t;if(o){if(s&&b(this,Ui,Wg).call(this,o,s),i&&b(l=G,ke,uA).call(l,o,i),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,Ui,Wg).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,Oe).get(t);s&&(n(e,Re).append(s),n(this,Oe).delete(t),n(e,Oe).set(t,s))}remove(t){n(this,_o).delete(t),n(this,Re)!==null&&(n(this,Oe).get(t).remove(),n(this,Oe).delete(t))}destroy(){var t,e,s;u(this,Re,null);for(const i of n(this,Oe).values())i.remove();if(n(this,Oe).clear(),n(this,_o).clear(),(t=n(this,Co))==null||t.disconnect(),u(this,Co,null),n(this,Ns)){const i=n(G,_n).get(n(this,Ns));(i==null?void 0:i.drawLayer)===this&&(b(e=G,ke,zg).call(e,n(this,Ns)),n(G,_n).delete(n(this,Ns)),n(G,Ur).delete(n(this,Ns)),n(G,Ur).size===0&&((s=n(G,Nr))==null||s.abort(),u(G,Nr,null),u(G,Hr,!1))),u(this,Ns,null)}}};Re=new WeakMap,Oe=new WeakMap,Ns=new WeakMap,Nd=new WeakMap,Bd=new WeakMap,Co=new WeakMap,_o=new WeakMap,Hd=new WeakMap,xf=new WeakMap,Nr=new WeakMap,Br=new WeakMap,Hr=new WeakMap,Ur=new WeakMap,_n=new WeakMap,ke=new WeakSet,zg=function(t){const e=n(this,_n).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),n(this,Br).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},Vg=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},dA=function(){return n(this,Ur).keys().filter(t=>t.isConnected).toArray().sort(kw)},$u=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of n(this,Br))o.remove();n(this,Br).clear();return}const e=new WeakMap,s=b(this,ke,dA).call(this),i=[];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=tu(c),A=tu(f);const v=y===null,w=A===null;if(n(this,Hr)&&v!==w)return;if(t.rangeCount===1){const{anchorNode:x,anchorOffset:C,focusNode:_,focusOffset:k}=t,P=tu(x),M=tu(_),L=Pw(x,C,_,k);
55P&&M&&L!==null&&(L?(c=x,d=C,y=P,f=_,g=k,A=M):(c=_,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=Wm(f,g,A);if(!x)continue;f=x.container,g=x.offset}}if(c.nodeType===Node.ELEMENT_NODE){const x=Wm(c,d,y);if(!x)continue;c=x.container,d=x.offset}if(y===A&&!E&&S.includes(y)){i.push([h,y]);continue}for(const x of S){const C=x.firstChild;if(!C)continue;const _=document.createRange();if(x===y?_.setStart(c,d):_.setStartBefore(C),x===A)_.setEnd(f,g);else{const k=x.lastChild;if(!k)continue;if(k.nodeType===Node.ELEMENT_NODE&&k.classList.contains("endOfContent")){const P=k.previousSibling;if(!P)continue;_.setEndAfter(P)}else _.setEndAfter(k)}_.collapsed||i.push([_,x])}}const r=new Set(i.map(o=>o[1]));for(const o of n(this,Ur))r.has(o)||b(this,ke,zg).call(this,o);for(const[o,l]of i){const h=n(G,_n).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_${Dt(G,xf)._++}`;g=document.createElement("div"),g.className="selection",g.style.clipPath=`url(#${A})`;const v=(a=n(f,Nd))==null?void 0:a.createSelectionStyle(n(f,Bd));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}n(f,Re)&&g.parentNode!==n(f,Re)&&(n(f,Re).append(g),n(this,Br).add(g)),y.setAttribute("d",d.join(" "))}},uA=function(t,[e,s,i,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},Ui=new WeakSet,jg=function(){const t=G._svgFactory.create(1,1,!0);return n(this,Re).append(t),t.setAttribute("aria-hidden","true"),t},fA=function(t,e){const s=G._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=G._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},Wg=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},m(G,ke),m(G,Hd,0),m(G,xf,0),m(G,Nr,null),m(G,Br,new Set),m(G,Hr,!1),m(G,Ur,new Set),m(G,_n,new WeakMap);let $g=G;function eu(p){return`${(p*100).toFixed(2)}%`}var gh,Ud,Gd,mh,Oi,Ni,$d,Cf,pA;const Kh=class Kh{constructor(t,e,s,i){m(this,Cf);m(this,gh,[]);m(this,Ud,new Map);m(this,Gd,null);m(this,mh,0);m(this,Oi,0);m(this,Ni,0);u(this,mh,t),u(this,gh,e),u(this,Oi,s.rawDims.pageWidth),u(this,Ni,s.rawDims.pageHeight),u(this,Gd,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<n(this,gh).length;e+=6){const s=b(this,Cf,pA).call(this,n(this,gh).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,i=n(this,Ud).get(s);if(!i)return;const r=(w=n(Kh,$d))==null?void 0:w.deref();if(r===s)return;r&&(r.width=0,r.height=0),u(Kh,$d,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:h,height:c}=i,d=n(this,Gd).call(this),f=Math.ceil(o*d.width),g=Math.ceil(l*d.height),y=Math.floor((o+h/n(this,Oi))*d.width),A=Math.floor((l+c/n(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}};gh=new WeakMap,Ud=new WeakMap,Gd=new WeakMap,mh=new WeakMap,Oi=new WeakMap,Ni=new WeakMap,$d=new WeakMap,Cf=new WeakSet,pA=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,Oi),(
55a-e)*n(this,Ni)),l=Math.hypot((s-t)*n(this,Oi),(i-e)*n(this,Ni));if(o<n(this,mh)||l<n(this,mh))return null;const h=[(r-t)*n(this,Oi)/o,(a-e)*n(this,Ni)/o,(s-t)*n(this,Oi)/l,(i-e)*n(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:eu(t),top:eu(e),width:eu(o/n(this,Oi)),height:eu(l/n(this,Ni)),transformOrigin:"0% 0%",transform:`matrix(${h.join(",")})`}),n(this,Ud).set(d,{inverseTransform:c,width:o,height:l,x1:t,y1:e}),d},m(Kh,$d,null);let Xg=Kh;globalThis._pdfjsTestingUtils={HighlightOutliner:Eg};globalThis.pdfjsLib={AbortException:Gr,AnnotationEditorLayer:Bg,AnnotationEditorParamsType:tt,AnnotationEditorType:W,AnnotationEditorUIManager:Po,AnnotationLayer:fg,AnnotationMode:On,AnnotationType:It,applyOpacity:BA,build:nw,ColorPicker:Xu,createValidAbsoluteUrl:Ym,CSSConstants:NA,DOMSVGFactory:Ku,DrawLayer:$g,FeatureTest:pt,fetchData:qg,findContrastColor:HA,getDocument:Z0,getFilenameFromUrl:LA,getPdfFilenameFromUrl:FA,getRGB:jd,getRGBA:Vd,getUuid:qm,GlobalWorkerOptions:Tn,ImageKind:su,InvalidPDFException:tp,isDataScheme:Mf,isPdfFile:Jg,isValidExplicitDest:a0,makeArr:wh,makeMap:Yg,makeObj:sp,makeSet:MA,MathClamp:Et,noContextMenu:ii,normalizeUnicode:kA,OPS:ci,OutputScale:ni,PasswordException:Zf,PasswordResponses:vA,PDFDataRangeTransport:my,PDFDateString:Vu,PDFWorker:tc,PermissionFlag:wA,PixelsPerInch:$r,RenderingCancelledException:Qg,renderRichText:Qm,ResponseException:zu,setLayerDimensions:To,shadow:$,SignatureExtractor:kn,stopEvent:ee,SupportedImageMimeTypes:np,TextLayer:Zh,TextLayerImages:Xg,TouchManager:Ab,updateUrlHash:Km,Util:D,VerbosityLevel:_f,version:iw,XfaLayer:Kg};export{Gr as AbortException,Bg as AnnotationEditorLayer,tt as AnnotationEditorParamsType,W as AnnotationEditorType,Po as AnnotationEditorUIManager,fg as AnnotationLayer,On as AnnotationMode,It as AnnotationType,NA as CSSConstants,Xu as ColorPicker,Ku as DOMSVGFactory,$g as DrawLayer,pt as FeatureTest,Tn as GlobalWorkerOptions,su as ImageKind,tp as InvalidPDFException,Et as MathClamp,ci as OPS,ni as OutputScale,my as PDFDataRangeTransport,Vu as PDFDateString,tc as PDFWorker,Zf as PasswordException,vA as PasswordResponses,wA as PermissionFlag,$r as PixelsPerInch,Qg as RenderingCancelledException,zu as ResponseException,kn as SignatureExtractor,np as SupportedImageMimeTypes,Zh as TextLayer,Xg as TextLayerImages,Ab as TouchManager,D as Util,_f as VerbosityLevel,Kg as XfaLayer,BA as applyOpacity,nw as build,Ym as createValidAbsoluteUrl,qg as fetchData,HA as findContrastColor,Z0 as getDocument,LA as getFilenameFromUrl,FA as getPdfFilenameFromUrl,jd as getRGB,Vd as getRGBA,qm as getUuid,Mf as isDataScheme,Jg as isPdfFile,a0 as isValidExplicitDest,wh as makeArr,Yg as makeMap,sp as makeObj,MA as makeSet,ii as noContextMenu,kA as normalizeUnicode,Qm as renderRichText,To as setLayerDimensions,$ as shadow,ee as stopEvent,Km as updateUrlHash,iw 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.