PageSourceSearch

https://tasova.gen.tr/assets/EditionsAdmin-BvJj-hxs.js

js tasova.gen.tr collected 2026-09-29 12:35:52 UTC 488,846 bytes, 60 lines download raw bytes

1var FA=Object.defineProperty;var Sm=p=>{throw TypeError(p)};var RA=(p,t,e)=>t in p?FA(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var T=(p,t,e)=>RA(p,typeof t!="symbol"?t+"":t,e),Xf=(p,t,e)=>t.has(p)||Sm("Cannot "+e);var n=(p,t,e)=>(Xf(p,t,"read from private field"),e?e.call(p):t.get(p)),m=(p,t,e)=>t.has(p)?Sm("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(p):t.set(p,e),f=(p,t,e,s)=>(Xf(p,t,"write to private field"),s?s.call(p,e):t.set(p,e),e),b=(p,t,e)=>(Xf(p,t,"access private method"),e);var It=(p,t,e,s)=>({set _(i){f(p,t,i,e)},get _(){return n(p,t,s)}});import{u as OA,e as NA,j as X}from"./vendor-query-6hJe-_u2.js";import{r as xh}from"./vendor-react-C0FiJME3.js";import{a7 as BA,a4 as Em,f as xm,a8 as Cm,a9 as _m,g as Tm,K as Yf,B as Kf,L as km,a5 as Pm,W as Mm,aa as HA,ab as qd,s as Oo}from"./index-CiNRwlWe.js";import{L as qf}from"./label-Dw8Wo2bN.js";import{U as UA}from"./upload-Bs1WqnPf.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const GA=BA("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),ms=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Mn=[1/0,1/0,-1/0,-1/0],ta=new Float32Array(Mn),np=[.001,0,0,.001,0,0],Be="http://www.w3.org/2000/svg",gs={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Nn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},jo="pdfjs_internal_id_",Ah="pdfjs_internal_editor_",W={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},et={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},jA={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Zt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},au={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Lt={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},No={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Mf={ERRORS:0,WARNINGS:1,INFOS:5},di={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},Ch={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},$A={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Df=Mf.WARNINGS;function zA(p){Number.isInteger(p)&&(Df=p)}function VA(){return Df}function If(p){Df>=Mf.INFOS&&console.info(`Info: ${p}`)}function Y(p){Df>=Mf.WARNINGS&&console.warn(`Warning: ${p}`)}function st(p){throw new Error(p)}function Bt(p,t){p||st(t)}function WA(p){switch(p==null?void 0:p.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function hb(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=KA(p)}catch{}}const s=t?URL.parse(p,t):URL.parse(p);return WA(s)?s:null}function cb(p,t,e=!1){const s=URL.parse(p);return s?(s.hash=t,s.href):e&&hb(p,"http://example.com")?p.split("#",1)[0]+`${t?`#${t}`:""}`:""}function rp(p){return p.substring(p.lastIndexOf("/")+1)}function j(p,t,e,s=!1){return Object.defineProperty(p,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Lo=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class ap extends Lo{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Qf extends Lo{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class op extends Lo{constructor(t){super(t,"InvalidPDFException")}}class Xu extends Lo{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class XA extends Lo{constructor(t){super(t,"FormatError")}}class jr extends Lo{constructor(t){super(t,"AbortException")}}function YA(p){(typeof p!="object"||(p==null?void 0:p.length)===void 0)&&st("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 Lf(p){typeof p!="string"&&st("Invalid argument for stringToBytes");const t=p.length,e=new Uint8Array(t);for(let s=0;s<t;
6++s)e[s]=p.charCodeAt(s)&255;return e}class gt{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return j(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return j(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return j(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return j(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return j(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return j(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")),j(this,"isCanvasFilterSupported",(t==null?void 0:t.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return j(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",j(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return j(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var Dn,ou,lp;class D{static get hexNums(){return j(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],u=t[s+c+1];t[s+c]=d*i+u*a+l,t[s+c+1]=d*r+u*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],u=t[2],g=t[3];let y=i*c+l,A=y,S=i*u+l,w=S,v=o*d+h,E=v,x=o*g+h,C=x;if(r!==0||a!==0){const _=r*c,k=r*u,P=a*d,M=a*g;y+=P,w+=P,S+=M,A+=M,v+=_,C+=_,x+=k,E+=k}s[0]=Math.min(s[0],y,S,A,w),s[1]=Math.min(s[1],v,x,E,C),s[2]=Math.max(s[2],y,S,A,w),s[3]=Math.max(s[3],v,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,Dn,lp).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,Dn,lp).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)}}Dn=new WeakSet,ou=function(t,e,s,i,r,a,o,l,h,c){if(h<=0||h>=1)return;const d=1-h,u=h*h,g=u*h,y=d*(d*(d*t+3*h*e)+3*u*s)+g*i,A=d*(d*(d*r+3*h*a)+3*u*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)},lp=function(t,e,s,i,r,a,o,l,h,c,d,u){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,Dn,ou).call(this,t,e,s,i,r,a,o,l,-d/c,u);return}const g=c**2-4*d*h;if(g<0)return;const y=Math.sqrt(g),A=2*h;b(this,Dn,ou).call(this,t,e,s,i,r,a,o,l,(-c+y)/A,u),b(this,Dn,ou).call(this,t,e,s,i,r,a,o,l,(-c-y)/A,u)},m(D,Dn);function KA(p){return decodeURIComponent(escape(p))}let Jf=null,Dm=null;function qA(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,Dm=new Map([["ſt","ſt"]])),p.replaceAll(Jf,(t,e,s)=>e?e.normalize("NFKC"):Dm.get(s))}function db(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const p=new Uint8Array(32);return crypto.getRandomValues(p),YA(p)}function QA(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 Sh=()=>[],em=()=>new Map,hp=()=>Object.create(null),JA=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(p){return[...this].join(p)});function xt(p,t,e){return Math.min(Math.max(p,t),e)}class Wd{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,u,g;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,d=0,u=0,g=1;break;case 90:c=0,d=1,u=1,g=0;break;case 270:c=0,d=-1,u=-1,g=0;break;case 0:c=1,d=0,u=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(u=-u,g=-g);let y,A,S,w;c===0?(y=Math.abs(h-t[1])*s+r,A=Math.abs(l-t[0])*s+a,S=(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,S=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[c*s,d*s,u*s,g*s,y-c*s*l-u*s*h,A-d*s*l-g*s*h],this.width=S,this.height=w}get rawDims(){const t=this.viewBox;return j(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 Wd({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 Zh{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;
6else if(Zh.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 ZA=/url\(|image-set\(/i,t0=/^on/i;var rc,cp;class sm{static get _allowedHtmlElements(){return j(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 j(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return j(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return j(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return j(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&&!t0.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,u]of Object.entries(h))c.has(d)&&!ZA.test(u)&&(t.style[d]=u)}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,u,g;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=b(this,rc,cp).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&&Zh.shouldBuildText(i.name)&&h.push(y)}return{textDivs:h}}const c=[[i,-1,a]];for(;c.length>0;){const[y,A,S]=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:v}=w;if(v==="#text"){const x=document.createTextNode(w.value);h.push(x),S.append(x);continue}const E=b(this,rc,cp).call(this,v,(u=w.attributes)==null?void 0:u.xmlns,r);if(E){if(S.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&&Zh.shouldBuildText(v)&&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 Wd({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}rc=new WeakSet,cp=function(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===Be&&this._allowedSvgElements.has(t)?document.createElementNS(Be,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null},m(sm,rc);const qr=class qr{};T(qr,"CSS",96),T(qr,"PDF",72),T(qr,"PDF_TO_CSS_UNITS",qr.CSS/qr.PDF);let $r=qr;async function im(p,t="text"){if(Kh(p,document.baseURI)){const e=await fetch(p);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const 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 nm extends Lo{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Ff(p){const t=p.length;let e=0;for(;e<t&&p[e].trim()==="";)e++;return p.substring(e,e+5).toLowerCase()==="data:"}function rm(p){return typeof p=="string"&&/\.pdf$/i.test(p)}function e0(p){return[p]=p.split(/[#?]/,1),rp(p)}function s0(p,t="document.pdf"){if(typeof p!="string")return t;if(Ff(p))return Y('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=rp(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=rp(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 Bn;class Im{constructor(){m(this,Bn,new Map);T(this,"times",[])}time(t){n(this,Bn).has(t)&&Y(`Timer is already running for ${t}`),n(this,Bn).set(t,Date.now())}timeEnd(t){n(this,Bn).has(t)||Y(`Timer has not been started for ${t}`),this.times.push({name:t,start:n(this,Bn).get(t),end:Date.now()}),n(this,Bn).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}
6ms
7`).join("")}}Bn=new WeakMap;function Kh(p,t){const e=t?URL.parse(p,t):URL.parse(p);return/https?:/.test((e==null?void 0:e.protocol)??"")}function ni(p){p.preventDefault()}function se(p){p.preventDefault(),p.stopPropagation()}var ac;class Yu{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,ac)||f(this,ac,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,ac).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))}}ac=new WeakMap,m(Yu,ac);function Xd(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 Yd(p){const t=Xd(p);return t?t.slice(0,3):(Y(`Not a valid color format: "${p}"`),[0,0,0])}function i0(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,Yd(s))}t.remove()}function vt(p){const{a:t,b:e,c:s,d:i,e:r,f:a}=p.getTransform();return[t,e,s,i,r,a]}function oi(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 ko(p,t,e=!1,s=!0){if(t instanceof Wd){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 ri{constructor(){const{pixelRatio:t}=ri;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=ri.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 dp=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class n0{static get isDarkMode(){var t;return j(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class r0{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(),j(this,"commentForegroundColor",Yd(s))}}function a0(p,t){t=xt(t??1,0,1);const e=255*(1-t);return p.map(s=>Math.round(s*t+e))}function Lm(p,t){const e=p[0]/255,s=p[1]/255,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 up(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;
7case 5:case 6:t[0]=r+o,t[1]=o,t[2]=a+o;break}}function fp(p){return p<=.03928?p/12.92:((p+.055)/1.055)**2.4}function Fm(p,t,e){up(p,e),e.map(fp);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];up(t,e),e.map(fp);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const Rm=new Map;function o0(p,t){const e=p[0]+p[1]*256+p[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=Rm.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);Lm(p,a);const o=i.subarray(6,9);Lm(t,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),Fm(a,o,r)<h){let c,d;l?(c=a[2],d=1):(c=0,d=a[2]);const u=.005;for(;d-c>u;){const g=a[2]=(c+d)/2;l===Fm(a,o,r)<h?c=g:d=g}a[2]=l?d:c}return up(a,r),s=D.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),Rm.set(e,s),s}function ub({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 sm.render({xfaHtml:p,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function fb(p){const t=new Path2D;if(!p)return t;for(let e=0,s=p.length;e<s;)switch(p[e++]){case Ch.moveTo:t.moveTo(p[e++],p[e++]);break;case Ch.lineTo:t.lineTo(p[e++],p[e++]);break;case Ch.curveTo:t.bezierCurveTo(p[e++],p[e++],p[e++],p[e++],p[e++],p[e++]);break;case Ch.quadraticCurveTo:t.quadraticCurveTo(p[e++],p[e++],p[e++],p[e++]);break;case Ch.closePath:t.closePath();break;default:Y(`Unrecognized drawing path operator: ${p[e-1]}`);break}return t}var Hn,Un,xs,Cs,oc,Gn,Wo,Xo,lc,sf,pb,we,gb,mb,Bo,kh;const Vi=class Vi{constructor(t){m(this,we);m(this,Hn,null);m(this,Un,null);m(this,xs);m(this,Cs,null);m(this,oc,null);m(this,Gn,null);m(this,Wo,null);m(this,Xo,null);f(this,xs,t),n(Vi,lc)||f(Vi,lc,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const t=f(this,Hn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,xs)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",ni,{signal:e}),t.addEventListener("pointerdown",b(Vi,sf,pb),{signal:e}));const s=f(this,Cs,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,xs).toolbarPosition;if(i){const{style:r}=t,a=n(this,xs)._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,Hn)}hide(){var t;n(this,Hn).classList.add("hidden"),(t=n(this,Un))==null||t.hideDropdown()}show(){var t,e;n(this,Hn).classList.remove("hidden"),(t=n(this,oc))==null||t.shown(),(e=n(this,Gn))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=n(this,xs),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",n(Vi,lc)[t]),b(this,we,Bo).call(this,s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,Cs).append(s)}async addAltText(t){const e=await t.render();b(this,we,Bo).call(this,e),n(this,Cs).append(e,n(this,we,kh)),f(this,oc,t)}addComment(t,e=null){if(n(this,Gn))return;const s=t.renderForToolbar();if(!s)return;b(this,we,Bo).call(this,s);const i=f(this,Wo,n(this,we,kh));e?(n(this,Cs).insertBefore(s,e),n(this,Cs).insertBefore(i,e)):n(this,Cs).append(s,i),f(this,Gn,t),t.toolbar=this}addColorPicker(t){if(n(this,Un))return;f(this,Un,t);const e=t.renderButton();b(this,we,Bo).call(this,e),n(this,Cs).append(e,n(this,we,kh))}async addEditSignatureButton(t){const e=f(this,Xo,await t.renderEditButton(n(this,xs)));b(this,we,Bo).call(this,e),n(this,Cs).append(e,n(this,we,kh))}removeButton(t){var e,s;switch(t){case"comment":(e=n(this,Gn))==null||e.removeToolbarCommentButton(),f(this,Gn,null),(s=n(this,Wo))==null||s.remove(),f(this,Wo,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,Cs).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){n(this,Xo)&&(n(this,Xo).title=t)}remove(){var t;n(this,Hn).remove(),(t=n(this,Un))==null||t.destroy(),f(this,Un,null)}};Hn=new WeakMap,Un=new WeakMap,xs=new WeakMap,Cs=new WeakMap,oc=new WeakMap,Gn=new WeakMap,Wo=new WeakMap,Xo=new WeakMap,lc=new WeakMap,sf=new WeakSet,pb=function(t){t.stopPropagation()},we=new WeakSet,gb=function(t){n(this,xs)._focusEventsAllowed=!1,se(t)},mb=function(t){n(this,xs)._focusEventsAllowed=!0,se(t)},Bo=function(t){const e=n(this,xs)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,we,gb).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,we,mb).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ni,{signal:e}),!0)},kh=function(){const t=document.createElement("div");return t.className="divider",t},m(Vi,sf),m(Vi,lc,null);let pp=Vi;var hc,ea,ui,Ln,bb,yb,gp;class l0{constructor(t){m(this,Ln);m(this,hc,null);m(this,ea,null);m(this,ui);f(this,ui,t)}show(t,e,s){const[i,r]=b(this,Ln,yb).call(this,e,s),{style:a}=n(this,ea)||f(this,ea,b(this,Ln,bb).call(this));t.append(n(this,ea)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,ea).remove()}}hc=new WeakMap,ea=new WeakMap,ui=new WeakMap,Ln=new WeakSet,bb=function(){const t=f(this,ea,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=n(this,ui).direction;const e=n(this,ui)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",ni,{signal:e});const s=f(this,hc,document.createElement("div"));return s.className="buttons",t.append(s),n(this,ui).hasCommentManager()&&b(this,Ln,gp).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,ui).commentSelection("floating_button")}),b(this,Ln,gp).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,ui).highlightSelection("floating_button")}),t},yb=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]},gp=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,ui)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",ni,{signal:o}),r.addEventListener("click",i,{signal:o})),n(this,hc).append(r)};
7const h0="59968104-cc61-4cf9-b570-014b35b3709c",Zf=Object.freeze({internal:h0});function Ab(p,t,e){for(const s of e)t.addEventListener(s,p[s].bind(p))}var sa,ia,Yo,na;const ct=class ct{static initializeAndAddPointerId(t){(n(ct,ia)||f(ct,ia,new Set)).add(t)}static setPointer(t,e){n(ct,sa)||f(ct,sa,e),n(ct,na)??f(ct,na,t)}static setTimeStamp(t){f(ct,Yo,t)}static isSamePointerId(t){return n(ct,sa)===t}static isSamePointerIdOrRemove(t){var e;return n(ct,sa)===t?!0:((e=n(ct,ia))==null||e.delete(t),!1)}static isSamePointerType(t){return n(ct,na)===t}static isInitializedAndDifferentPointerType(t){return n(ct,na)!==null&&!ct.isSamePointerType(t)}static isSameTimeStamp(t){return n(ct,Yo)===t}static isUsingMultiplePointers(){var t;return((t=n(ct,ia))==null?void 0:t.size)>=1}static clearPointerType(){f(ct,na,null)}static clearPointerIds(){f(ct,sa,NaN),f(ct,ia,null)}static clearTimeStamp(){f(ct,Yo,NaN)}};sa=new WeakMap,ia=new WeakMap,Yo=new WeakMap,na=new WeakMap,m(ct,sa,NaN),m(ct,ia,null),m(ct,Yo,NaN),m(ct,na,null);let xe=ct;var nf;class c0{constructor(){m(this,nf,0)}get id(){return`${Ah}${It(this,nf)._++}`}}nf=new WeakMap;var Ko,cc,Ce,qo,lu;const gm=class gm{constructor(){m(this,qo);m(this,Ko,db());m(this,cc,0);m(this,Ce,null)}static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Be}"><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 j(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return b(this,qo,lu).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return b(this,qo,lu).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,qo,lu).call(this,t,s)}async getFromId(t){n(this,Ce)||f(this,Ce,new Map);const e=n(this,Ce).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){n(this,Ce)||f(this,Ce,new Map);let s=n(this,Ce).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,Ko)}_${It(this,cc)._++}`,refCounter:1,isSvg:!1},n(this,Ce).set(t,s),n(this,Ce).set(s.id,s),s}getSvgUrl(t){const e=n(this,Ce).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,Ce)||f(this,Ce,new Map);const e=n(this,Ce).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,Ko)}_`)}};Ko=new WeakMap,cc=new WeakMap,Ce=new WeakMap,qo=new WeakSet,lu=async function(t,e){n(this,Ce)||f(this,Ce,new Map);let s=n(this,Ce).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,Ko)}_${It(this,cc)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await im(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=gm._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){Y(i),s=null}return n(this,Ce).set(t,s),s&&n(this,Ce).set(s.id,s),s};let mp=gm;var zt,jn,dc,Ft;class d0{constructor(t=128){m(this,zt,[]);m(this,jn,!1);m(this,dc);m(this,Ft,-1);f(this,dc,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,jn))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,Ft)===-1){n(this,zt).length>0&&(n(this,zt).length=0),f(this,Ft,0),n(this,zt).push(l);return}if(a&&n(this,zt)[n(this,Ft)].type===r){o&&(l.undo=n(this,zt)[n(this,Ft)].undo),n(this,zt)[n(this,Ft)]=l;return}const h=n(this,Ft)+1;h===n(this,dc)?n(this,zt).splice(0,1):(f(this,Ft,h),h<n(this,zt).length&&n(this,zt).splice(h)),n(this,zt).push(l)}undo(){if(n(this,Ft)===-1)return;f(this,jn,!0);const{undo:t,post:e}=n(this,zt)[n(this,Ft)];t(),e==null||e(),f(this,jn,!1),f(this,Ft,n(this,Ft)-1)}redo(){if(n(this,Ft)<n(this,zt).length-1){f(this,Ft,n(this,Ft)+1),f(this,jn,!0);const{cmd:t,post:e}=n(this,zt)[n(this,Ft)];t(),e==null||e(),f(this,jn,!1)}}hasSomethingToUndo(){return n(this,Ft)!==-1}hasSomethingToRedo(){return n(this,Ft)<n(this,zt).length-1}cleanType(t){if(n(this,Ft)!==-1){for(let e=n(this,Ft);e>=0;e--)if(n(this,zt)[e].type!==t){n(this,zt).splice(e+1,n(this,Ft)-e),f(this,Ft,e);return}n(this,zt).length=0,f(this,Ft,-1)}}destroy(){f(this,zt,null)}}zt=new WeakMap,jn=new WeakMap,dc=new WeakMap,Ft=new WeakMap;var wh,wb,vb;const ze=class ze{constructor(t){var s;this.callbacks=new Map;const{isMac:e}=gt.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 u=l.startsWith("mac+");if(e!==u)continue;u&&(h=l.slice(4))}const[c,d]=b(s=ze,wh,wb).call(s,h);c!==null&&this.callbacks.getOrInsertComputed(c,Sh).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,wh,vb).call(c,e.code);
7if(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||se(e))}};wh=new WeakSet,wb=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){Y(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":i}return e===null&&Y(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]},vb=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,wh),T(ze,"ALT",1),T(ze,"CTRL",2),T(ze,"META",4),T(ze,"SHIFT",8);let Po=ze;const rf=class rf{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return i0(t),j(this,"_colors",t)}convert(t){const e=Yd(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 rf._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?D.makeHexColor(...e):t}};T(rf,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let bp=rf;var Qo,ts,Jo,Tt,Rt,Zo,tl,el,_e,sl,_s,ae,$n,zn,Vn,Wn,fi,Ts,ra,uc,fc,il,pc,pi,Xn,nl,Yn,gi,af,Xi,rl,gc,Kn,aa,al,qn,mc,Yt,dt,Yi,Qn,Jn,bc,ol,yc,Zn,mi,Ki,Ac,wc,ks,R,hu,yp,Sb,Eb,Ph,xb,Cb,_b,Ap,Tb,kb,Pb,Mb,De,$i,Db,Ib,wp,Lb,Mh,vp;const $o=class $o{constructor(t,e,s,i,r,a,o,l,h,c,d,u,g,y,A,S){m(this,R);m(this,Qo,new AbortController);m(this,ts,null);m(this,Jo,null);m(this,Tt,new Map);m(this,Rt,new Map);m(this,Zo,null);m(this,tl,null);m(this,el,null);m(this,_e,null);m(this,sl,null);m(this,_s,new d0);m(this,ae,null);m(this,$n,null);m(this,zn,null);m(this,Vn,0);m(this,Wn,new Set);m(this,fi,null);m(this,Ts,null);m(this,ra,new Set);T(this,"_editorUndoBar",null);m(this,uc,!1);m(this,fc,!1);m(this,il,!1);m(this,pc,null);m(this,pi,null);m(this,Xn,null);m(this,nl,null);m(this,Yn,!1);m(this,gi,null);m(this,af,new c0);m(this,Xi,!1);m(this,rl,!1);m(this,gc,!1);m(this,Kn,null);m(this,aa,null);m(this,al,null);m(this,qn,null);m(this,mc,null);m(this,Yt,W.NONE);m(this,dt,new Set);m(this,Yi,null);m(this,Qn,null);m(this,Jn,null);m(this,bc,null);m(this,ol,null);m(this,yc,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});m(this,Zn,[0,0]);m(this,mi,null);m(this,Ki,null);m(this,Ac,null);m(this,wc,null);m(this,ks,null);const w=this._signal=n(this,Qo).signal;f(this,Ki,t),f(this,Ac,e),f(this,wc,s),f(this,el,i),f(this,ae,r),f(this,Qn,a),f(this,ol,l),this._eventBus=o;const v={signal:w,...Zf};o.on("editingaction",this.onEditingAction.bind(this),v),o.on("pagechanging",this.onPageChanging.bind(this),v),o.on("scalechanging",this.onScaleChanging.bind(this),v),o.on("rotationchanging",this.onRotationChanging.bind(this),v),o.on("setpreference",this.onSetPreference.bind(this),v),o.on("switchannotationeditorparams",E=>this.updateParams(E.type,E.value),v),window.addEventListener("pointerdown",()=>{f(this,rl,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{f(this,rl,!1)},{capture:!0,signal:w}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:w}),b(this,R,xb).call(this),b(this,R,Mb).call(this),b(this,R,Ap).call(this),f(this,_e,l.annotationStorage),f(this,pc,l.filterFactory),f(this,Jn,h),f(this,nl,c||null),f(this,uc,d),f(this,fc,u),f(this,il,g),f(this,mc,y||null),this.viewParameters={realScale:$r.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=A||null,this._supportsPinchToZoom=S!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=$o.prototype,e=a=>n(a,Ki).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return j(this,"_keyboardManager",new Po([[["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,Ki).contains(o)&&!a.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,Ki).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,ks))==null||t.resolve(),f(this,ks,null),(e=n(this,Qo))==null||e.abort(),f(this,Qo,null),this._signal=null;for(const c of n(this,Rt).values())c.destroy();n(this,Rt).clear(),n(this,Tt).clear(),n(this,ra).clear(),(s=n(this,qn))==null||s.clear(),f(this,ts,null),n(this,dt).clear(),n(this,_s).destroy(),(i=n(this,el))==null||i.destroy(),(r=n(this,ae))==null||r.destroy(),(a=n(this,Qn))==null||a.destroy(),(o=n(this,gi))==null||o.hide(),f(this,gi,null),(l=n(this,al))==null||l.destroy(),f(this,al,null),f(this,Jo,null),n(this,pi)&&(clearTimeout(n(this,pi)),f(this,pi,null)),n(this,mi)&&(clearTimeout(n(this,mi)),f(this,mi,null)),(h=this._editorUndoBar)==null||h.destroy(),f(this,ol,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,mc)}get useNewAltTextFlow(){return n(this,fc)}get useNewAltTextWhenAddingImage(){return n(this,il)}get hcmFilter(){return j(this,"hcmFilter",n(this,Jn)?n(this,pc).addHCMFilter(n(this,Jn).foreground,n(this,Jn).background):"none")}get direction(){return j(this,"direction",getComputedStyle(n(this,Ki)).direction)}get _highlightColors(){return j(this,"_highlightColors",n(this,nl)?new Map(n(this,nl).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 j(this,"highlightColors",null);const e=new Map,s=!!n(this,Jn);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 j(this,"highlightColors",e)}get highlightColorNames(){return j(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),f(this,zn,t)}setMainHighlightColorPicker(t){f(this,al,t)}editAltText(t,e=!1){var s;(s=n(this,el))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!n(this,ae)}editComment(t,e,s,i){var r;(r=n(this,ae))==null||r.showDialog(this,t,e,s,i)}selectComment(t,e){const s=n(this,Rt).get(t),i=s==null?void 0:s.getEditorByUID(e);i==null||i.toggleComment(!0,!0)}updateComment(t){var e;(e=n(this,ae))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=n(this,ae))==null||e.updatePopupColor(t)}
7removeComment(t){var e;(e=n(this,ae))==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,ae))==null||i.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=n(this,ae))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=n(this,ae))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(n(this,Rt).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,Zf),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,...Zf}),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":f(this,il,e);break}}onPageChanging({pageNumber:t}){f(this,Vn,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();n(this,Rt).delete(t),n(this,Vn)===t&&f(this,Vn,0)}focusMainContainer(){n(this,Ki).focus()}findParent(t,e){for(const s of n(this,Rt).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,Ac).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,ra).add(t)}removeShouldRescale(t){n(this,ra).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*$r.PDF_TO_CSS_UNITS;for(const s of n(this,ra))s.onScaleChanging();(e=n(this,zn))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),c=b(this,R,hu).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;s.empty();const u=b(this,R,yp).call(this,c),g=n(this,Yt)===W.NONE,y=()=>{const A=u==null?void 0:u.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,_e))return null;const e=`${Ah}${t}`,s=n(this,_e).getRawValue(e);return s&&n(this,_e).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&n(this,_e)&&!n(this,_e).has(t.id)&&n(this,_e).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,wc);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,n(this,Yn)&&(f(this,Yn,!1),b(this,R,Ph).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,dt))if(e.div.contains(t)){f(this,aa,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,aa))return;const[t,e]=n(this,aa);f(this,aa,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,R,Ap).call(this),this.setEditingState(!0)}removeEditListeners(){b(this,R,Tb).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,Ts))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,Ts))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,ts))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];
7for(const i of n(this,dt)){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,Ts))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){Y(`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,wp).call(this,l);b(this,R,vp).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){Y(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,Yt)!==W.NONE&&!this.isEditorHandlingKeyboard&&$o._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Yn)&&(f(this,Yn,!1),b(this,R,Ph).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,tl).get(t)||[])i.pageIndex=e;const s=n(this,Zo).get(t);s&&(s.pageIndex=e,n(this,Rt).set(e,s),n(this,Xi)?s.enable():s.disable())}startUpdatePages(){f(this,Zo,new Map(n(this,Rt))),n(this,Rt).clear();const t=f(this,tl,new Map),e=s=>{t.getOrInsertComputed(s.pageIndex,Sh).push(s)};for(const s of n(this,Tt).values())e(s);for(const[s,i]of n(this,_e))s.startsWith(Ah)&&!n(this,Tt).has(s)&&Number.isInteger(i==null?void 0:i.pageIndex)&&e(i)}endUpdatePages(){f(this,Zo,null),f(this,tl,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,_e).setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,r]of n(this,_e))r.pageIndex===s&&r.isClone&&(n(this,_e).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,kb).call(this),b(this,R,De).call(this,{isEditing:n(this,Yt)!==W.NONE,isEmpty:b(this,R,Mh).call(this),hasSomethingToUndo:n(this,_s).hasSomethingToUndo(),hasSomethingToRedo:n(this,_s).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,R,_b).call(this),b(this,R,Pb).call(this),b(this,R,De).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,Ts)){f(this,Ts,t);for(const e of n(this,Ts))b(this,R,$i).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,af).id}get currentLayer(){return n(this,Rt).get(n(this,Vn))}getLayer(t){return n(this,Rt).get(t)}get currentPageIndex(){return n(this,Vn)}addLayer(t){n(this,Rt).set(t.pageIndex,t),n(this,Xi)?t.enable():t.disable()}removeLayer(t){n(this,Rt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1,a=!1){var o,l,h,c,d,u;if(n(this,Yt)!==t&&!(n(this,ks)&&(await n(this,ks).promise,!n(this,ks)))){if(f(this,ks,Promise.withResolvers()),(o=n(this,zn))==null||o.commitOrRemove(),n(this,Yt)===W.POPUP&&((l=n(this,ae))==null||l.hideSidebar()),(h=n(this,ae))==null||h.destroyPopup(),f(this,Yt,t),t===W.NONE){this.setEditingState(!1),b(this,R,Ib).call(this);for(const g of n(this,Tt).values())g.hideStandaloneCommentButton();(c=this._editorUndoBar)==null||c.hide(),this.toggleComment(null),n(this,ks).resolve();return}for(const g of n(this,Tt).values())g.addStandaloneCommentButton();t===W.SIGNATURE&&await((d=n(this,Qn))==null?void 0:d.loadSignatures()),s&&xe.clearPointerType(),this.setEditingState(!0),await b(this,R,Db).call(this),this.unselectAll();for(const g of n(this,Rt).values())g.updateMode(t);if(t===W.POPUP){n(this,Jo)||f(this,Jo,await n(this,ol).getAnnotationsByType(new Set(n(this,Ts).map(A=>A._editorType))));const g=new Set,y=[];for(const A of n(this,Tt).values()){const{annotationElementId:S,hasComment:w,deleted:v}=A;S&&g.add(S),w&&!v&&y.push(A.getData())}for(const A of n(this,Jo)){const{id:S,popupRef:w,contentsObj:v}=A;w&&(v!=null&&v.str)&&!g.has(S)&&!n(this,Wn).has(S)&&y.push(A)}(u=n(this,ae))==null||u.showSidebar(y)}if(!e){i&&this.addNewEditorFromKeyboard(),n(this,ks).resolve();return}for(const g of n(this,Tt).values())g.uid===e?(this.setSelected(g),a?g.editComment():r?g.enterInEditMode():g.focus()):g.unselect();n(this,ks).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,Yt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,Ts)){switch(t){case et.CREATE:this.currentLayer.addNewEditor(e);return;case et.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,bc)||f(this,bc,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of n(this,dt))s.updateParams(t,e);else for(const s of n(this,Ts))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,Tt).values())a.editorType===t&&a.show(e);(((r=n(this,bc))==null?void 0:r.get(et.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,R,$i).call(this,[[et.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,gc)!==t){f(this,gc,t);for(const e of n(this,Rt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of n(this,Tt).values())e.pageIndex===t&&(yield e)}getEditor(t){return n(this,Tt).get(t)}addEditor(t){n(this,Tt).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,pi)&&clearTimeout(n(this,pi)),f(this,pi,setTimeout(()=>{this.focusMainContainer(),f(this,pi,null)},0))),n(this,Tt).delete(t.id),t.annotationElementId&&((e=n(this,qn))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,Wn).has(t.annotationElementId))&&((s=n(this,_e))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,Wn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}
7isDeletedAnnotationElement(t){return n(this,Wn).has(t)}removeDeletedAnnotationElement(t){n(this,Wn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,ts)!==t&&(f(this,ts,t),t&&b(this,R,$i).call(this,t.propertiesToUpdate))}updateUI(t){n(this,R,Lb)===t&&b(this,R,$i).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,R,$i).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,dt).has(t)){n(this,dt).delete(t),t.unselect(),b(this,R,De).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,dt).add(t),t.select(),b(this,R,$i).call(this,t.propertiesToUpdate),b(this,R,De).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=n(this,zn))==null||e.commitOrRemove();for(const i of n(this,dt))i!==t&&i.unselect();(s=n(this,ae))==null||s.destroyPopup(),n(this,dt).clear(),n(this,dt).add(t),t.select(),b(this,R,$i).call(this,t.propertiesToUpdate),b(this,R,De).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return n(this,dt).values().next().value}unselect(t){t.unselect(),n(this,dt).delete(t),b(this,R,De).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,dt).size!==0}get isEnterHandled(){return n(this,dt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,_s).undo(),b(this,R,De).call(this,{hasSomethingToUndo:n(this,_s).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,R,Mh).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,_s).redo(),b(this,R,De).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,_s).hasSomethingToRedo(),isEmpty:b(this,R,Mh).call(this)})}addCommands(t){n(this,_s).add(t),b(this,R,De).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,R,Mh).call(this)})}cleanUndoStack(t){n(this,_s).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,dt)],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,wp).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,ts))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,ts)||this.hasSelection}selectAll(){for(const t of n(this,dt))t.commit();b(this,R,vp).call(this,n(this,Tt).values())}unselectAll(){var t,e;if(!(n(this,ts)&&(n(this,ts).commitOrRemove(),n(this,Yt)!==W.NONE))&&!((t=n(this,zn))!=null&&t.commitOrRemove())&&((e=n(this,ae))==null||e.destroyPopup(),!!this.hasSelection)){for(const s of n(this,dt))s.unselect();n(this,dt).clear(),b(this,R,De).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,Zn)[0]+=t,n(this,Zn)[1]+=e;const[i,r]=n(this,Zn),a=[...n(this,dt)],o=1e3;n(this,mi)&&clearTimeout(n(this,mi)),f(this,mi,setTimeout(()=>{f(this,mi,null),n(this,Zn)[0]=n(this,Zn)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,Tt).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,Tt).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),f(this,fi,new Map);for(const t of n(this,dt))n(this,fi).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,fi))return!1;this.disableUserSelect(!1);const t=n(this,fi);f(this,fi,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,Tt).has(i.id)){const l=n(this,Rt).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,fi))for(const s of n(this,fi).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,dt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,ts)===t}getActive(){return n(this,ts)}getMode(){return n(this,Yt)}isEditingMode(){return n(this,Yt)!==W.NONE}get imageManager(){return j(this,"imageManager",new mp)}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,u)=>({x:(c-i)/a,y:1-(h+d-s)/r,width:u/a,height:d/r});break;case"180":o=(h,c,d,u)=>({x:1-(h+d-s)/r,y:1-(c+u-i)/a,width:d/r,height:u/a});break;case"270":o=(h,c,d,u)=>({x:1-(c+u-i)/a,y:(h-s)/r,width:u/a,height:d/r});break;default:o=(h,c,d,u)=>({x:(h-s)/r,y:(c-i)/a,width:d/r,height:u/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:u,y:g,width:y,height:A}of d.getClientRects())y===0||A===0||l.push(o(u,g,y,A))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,sl)||f(this,sl,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,sl))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,sl))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,_e).getRawValue(e);s&&(n(this,Yt)===W.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const i=(r=n(this,qn))==null?void 0:r.get(t);i&&(i.setCanvas(e,s),n(this,qn).delete(t))}addMissingCanvas(t,e){(n(this,qn)||f(this,qn,new Map)).set(t,e)}};Qo=new WeakMap,ts=new WeakMap,Jo=new WeakMap,Tt=new WeakMap,Rt=new WeakMap,Zo=new WeakMap,tl=new WeakMap,el=new WeakMap,_e=new WeakMap,sl=new WeakMap,_s=new WeakMap,ae=new WeakMap,$n=new WeakMap,zn=new WeakMap,Vn=new WeakMap,Wn=new WeakMap,fi=new WeakMap,Ts=new WeakMap,ra=new WeakMap,uc=new WeakMap,fc=new WeakMap,il=new WeakMap,pc=new WeakMap,pi=new WeakMap,Xn=new WeakMap,nl=new WeakMap,Yn=new WeakMap,gi=new WeakMap,af=new WeakMap,Xi=new WeakMap,rl=new WeakMap,gc=new WeakMap,Kn=new WeakMap,aa=new WeakMap,al=new WeakMap,qn=new WeakMap,mc=new WeakMap,Yt=new WeakMap,dt=new WeakMap,Yi=new WeakMap,Qn=new WeakMap,Jn=new WeakMap,bc=new WeakMap,ol=new WeakMap,yc=new WeakMap,Zn=new WeakMap,mi=new WeakMap,Ki=new WeakMap,Ac=new WeakMap,wc=new WeakMap,ks=new WeakMap,R=new WeakSet,hu=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},yp=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,Rt).values())if(s.hasTextLayer(t))return s;return null},Sb=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;
7const s=b(this,R,hu).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,gi)||f(this,gi,new l0(this)),n(this,gi).show(s,i,this.direction==="ltr"))},Eb=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){n(this,Yi)&&((r=n(this,gi))==null||r.hide(),f(this,Yi,null),b(this,R,De).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,Yi))return;const i=b(this,R,hu).call(this,t).closest(".textLayer");if(!i){n(this,Yi)&&((a=n(this,gi))==null||a.hide(),f(this,Yi,null),b(this,R,De).call(this,{hasSelectedText:!1}));return}if((o=n(this,gi))==null||o.hide(),f(this,Yi,e),b(this,R,De).call(this,{hasSelectedText:!0}),!(n(this,Yt)!==W.HIGHLIGHT&&n(this,Yt)!==W.NONE)&&(n(this,Yt)===W.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),f(this,Yn,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,Yt)===W.HIGHLIGHT?b(this,R,yp).call(this,i):null;if(l==null||l.toggleDrawing(),n(this,rl)){const h=new AbortController,c=this.combinedSignal(h),d=u=>{u.type==="pointerup"&&u.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),u.type==="pointerup"&&b(this,R,Ph).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,Ph).call(this,"main_toolbar")}},Ph=function(t=""){n(this,Yt)===W.HIGHLIGHT?this.highlightSelection(t):n(this,uc)&&b(this,R,Sb).call(this)},xb=function(){document.addEventListener("selectionchange",b(this,R,Eb).bind(this),{signal:this._signal})},Cb=function(){if(n(this,Xn))return;f(this,Xn,new AbortController);const t=this.combinedSignal(n(this,Xn));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},_b=function(){var t;(t=n(this,Xn))==null||t.abort(),f(this,Xn,null)},Ap=function(){if(n(this,Kn))return;f(this,Kn,new AbortController);const t=this.combinedSignal(n(this,Kn));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Tb=function(){var t;(t=n(this,Kn))==null||t.abort(),f(this,Kn,null)},kb=function(){if(n(this,$n))return;f(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(),f(this,$n,null)},Mb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},De=function(t){Object.entries(t).some(([s,i])=>n(this,yc)[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(n(this,yc),t)}),n(this,Yt)===W.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,R,$i).call(this,[[et.HIGHLIGHT_FREE,!0]]))},$i=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Db=async function(){if(!n(this,Xi)){f(this,Xi,!0);const t=[];for(const e of n(this,Rt).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,Tt).values())e.enable()}},Ib=function(){if(this.unselectAll(),n(this,Xi)){f(this,Xi,!1);for(const t of n(this,Rt).values())t.disable();for(const t of n(this,Tt).values())t.disable()}},wp=function(t){const e=n(this,Rt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Lb=function(){let t=null;for(t of n(this,dt));return t},Mh=function(){if(n(this,Tt).size===0)return!0;if(n(this,Tt).size===1)for(const t of n(this,Tt).values())return t.isEmpty();return!1},vp=function(t){for(const e of n(this,dt))e.unselect();n(this,dt).clear();for(const e of t)e.isEmpty()||(n(this,dt).add(e),e.select());b(this,R,De).call(this,{hasSelectedEditor:this.hasSelection})},T($o,"TRANSLATE_SMALL",1),T($o,"TRANSLATE_BIG",10);let Mo=$o;var oe,bi,$s,ll,yi,es,hl,Ai,We,qi,oa,wi,tr,ii,Dh,cu;const Ie=class Ie{constructor(t){m(this,ii);m(this,oe,null);m(this,bi,!1);m(this,$s,null);m(this,ll,null);m(this,yi,null);m(this,es,null);m(this,hl,!1);m(this,Ai,null);m(this,We,null);m(this,qi,null);m(this,oa,null);m(this,wi,!1);f(this,We,t),f(this,wi,t._uiManager.useNewAltTextFlow),n(Ie,tr)||f(Ie,tr,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){Ie._l10n??(Ie._l10n=t)}async render(){const t=f(this,$s,document.createElement("button"));t.className="altText",t.tabIndex="0";
7const e=f(this,ll,document.createElement("span"));t.append(e),n(this,wi)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(Ie,tr).missing),e.setAttribute("data-l10n-id",n(Ie,tr)["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,We)._uiManager._signal;t.addEventListener("contextmenu",ni,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,We)._uiManager.editAltText(n(this,We)),n(this,wi)&&n(this,We)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,ii,Dh)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(f(this,hl,!0),i(r))},{signal:s}),await b(this,ii,cu).call(this),t}finish(){n(this,$s)&&(n(this,$s).focus({focusVisible:n(this,hl)}),f(this,hl,!1))}isEmpty(){return n(this,wi)?n(this,oe)===null:!n(this,oe)&&!n(this,bi)}hasData(){return n(this,wi)?n(this,oe)!==null||!!n(this,qi):this.isEmpty()}get guessedText(){return n(this,qi)}async setGuessedText(t){n(this,oe)===null&&(f(this,qi,t),f(this,oa,await Ie._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,ii,cu).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,wi)||n(this,oe)){(e=n(this,Ai))==null||e.remove(),f(this,Ai,null);return}if(!n(this,Ai)){const s=f(this,Ai,document.createElement("div"));s.className="noAltTextBadge",n(this,We).div.append(s)}n(this,Ai).classList.toggle("hidden",!t)}serialize(t){let e=n(this,oe);return!t&&n(this,qi)===e&&(e=n(this,oa)),{altText:e,decorative:n(this,bi),guessedText:n(this,qi),textWithDisclaimer:n(this,oa)}}get data(){return{altText:n(this,oe),decorative:n(this,bi)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(f(this,qi,s),f(this,oa,i)),!(n(this,oe)===t&&n(this,bi)===e)&&(r||(f(this,oe,t),f(this,bi,e)),b(this,ii,cu).call(this))}toggle(t=!1){n(this,$s)&&(!t&&n(this,es)&&(clearTimeout(n(this,es)),f(this,es,null)),n(this,$s).disabled=!t)}shown(){n(this,We)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,ii,Dh)}})}destroy(){var t,e;(t=n(this,$s))==null||t.remove(),f(this,$s,null),f(this,ll,null),f(this,yi,null),(e=n(this,Ai))==null||e.remove(),f(this,Ai,null)}};oe=new WeakMap,bi=new WeakMap,$s=new WeakMap,ll=new WeakMap,yi=new WeakMap,es=new WeakMap,hl=new WeakMap,Ai=new WeakMap,We=new WeakMap,qi=new WeakMap,oa=new WeakMap,wi=new WeakMap,tr=new WeakMap,ii=new WeakSet,Dh=function(){return n(this,oe)&&"added"||n(this,oe)===null&&this.guessedText&&"review"||"missing"},cu=async function(){var i,r,a;const t=n(this,$s);if(!t)return;if(n(this,wi)){if(t.classList.toggle("done",!!n(this,oe)),t.setAttribute("data-l10n-id",n(Ie,tr)[n(this,ii,Dh)]),(i=n(this,ll))==null||i.setAttribute("data-l10n-id",n(Ie,tr)[`${n(this,ii,Dh)}-label`]),!n(this,oe)){(r=n(this,yi))==null||r.remove();return}}else{if(!n(this,oe)&&!n(this,bi)){t.classList.remove("done"),(a=n(this,yi))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,yi);if(!e){f(this,yi,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,We).id}`;const o=100,l=n(this,We)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,es)),f(this,es,null)},{once:!0}),t.addEventListener("mouseenter",()=>{f(this,es,setTimeout(()=>{f(this,es,null),n(this,yi).classList.add("show"),n(this,We)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;n(this,es)&&(clearTimeout(n(this,es)),f(this,es,null)),(h=n(this,yi))==null||h.classList.remove("show")},{signal:l})}n(this,bi)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,oe)),e.parentNode||t.append(e);const s=n(this,We).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},m(Ie,tr,null),T(Ie,"_l10n",null);let Ku=Ie;var fe,Ps,la,wt,vc,er,Ms,sr,ir,ha,Sc,Sp;class Qd{constructor(t){m(this,Sc);m(this,fe,null);m(this,Ps,null);m(this,la,!1);m(this,wt,null);m(this,vc,null);m(this,er,null);m(this,Ms,null);m(this,sr,null);m(this,ir,!1);m(this,ha,null);f(this,wt,t)}renderForToolbar(){const t=f(this,Ps,document.createElement("button"));
7return t.className="comment",b(this,Sc,Sp).call(this,t,!1)}renderForStandalone(){const t=f(this,fe,document.createElement("button"));t.className="annotationCommentButton";const e=n(this,wt).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(n(this,wt)._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,wt).commentButtonColor;i&&(s.backgroundColor=i)}return b(this,Sc,Sp).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=n(this,fe)??n(this,Ps))==null||t.focus()},0)}onUpdatedColor(){if(!n(this,fe))return;const t=n(this,wt).commentButtonColor;t&&(n(this,fe).style.backgroundColor=t),n(this,wt)._uiManager.updatePopupColor(n(this,wt))}get commentButtonWidth(){var t;return(((t=n(this,fe))==null?void 0:t.getBoundingClientRect().width)??0)/n(this,wt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,ha))return n(this,ha);if(!n(this,fe))return null;const{x:t,y:e,height:s}=n(this,fe).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,wt).parent.boundingClientRect;return[(t-i)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){f(this,ha,t)}hasDefaultPopupPosition(){return n(this,ha)===null}removeStandaloneCommentButton(){var t;(t=n(this,fe))==null||t.remove(),f(this,fe,null)}removeToolbarCommentButton(){var t;(t=n(this,Ps))==null||t.remove(),f(this,Ps,null)}setCommentButtonStates({selected:t,hasPopup:e}){n(this,fe)&&(n(this,fe).classList.toggle("selected",t),n(this,fe).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=n(this,wt).commentButtonPosition;const{width:c,height:d,x:u,y:g}=n(this,wt);s=u+s*c,i=g+i*d}const r=n(this,wt).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;n(this,wt)._uiManager.editComment(n(this,wt),a+s*l,o+i*h,{...t,parentDimensions:r})}finish(){n(this,Ps)&&(n(this,Ps).focus({focusVisible:n(this,la)}),f(this,la,!1))}isDeleted(){return n(this,ir)||n(this,Ms)===""}isEmpty(){return n(this,Ms)===null}hasBeenEdited(){return this.isDeleted()||n(this,Ms)!==n(this,vc)}serialize(){return this.data}get data(){return{text:n(this,Ms),richText:n(this,er),date:n(this,sr),deleted:this.isDeleted()}}set data(t){if(t!==n(this,Ms)&&f(this,er,null),t===null){f(this,Ms,""),f(this,ir,!0);return}f(this,Ms,t),f(this,sr,new Date),f(this,ir,!1)}restoreData({text:t,richText:e,date:s}){f(this,Ms,t),f(this,er,e),f(this,sr,s),f(this,ir,!1)}setInitialText(t,e=null){f(this,vc,t),this.data=t,f(this,sr,null),f(this,er,e)}shown(){}destroy(){var t,e;(t=n(this,Ps))==null||t.remove(),f(this,Ps,null),(e=n(this,fe))==null||e.remove(),f(this,fe,null),f(this,Ms,""),f(this,er,null),f(this,sr,null),f(this,wt,null),f(this,la,!1),f(this,ir,!1)}}fe=new WeakMap,Ps=new WeakMap,la=new WeakMap,wt=new WeakMap,vc=new WeakMap,er=new WeakMap,Ms=new WeakMap,sr=new WeakMap,ir=new WeakMap,ha=new WeakMap,Sc=new WeakSet,Sp=function(t,e){if(!n(this,wt)._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,wt)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=n(this,wt)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",ni,{signal:s}),e&&(t.addEventListener("focusin",r=>{n(this,wt)._focusEventsAllowed=!1,se(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{n(this,wt)._focusEventsAllowed=!0,se(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===n(this,Ps)?this.edit():n(this,wt).toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(f(this,la,!0),i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{n(this,wt).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{n(this,wt).toggleComment(!1,!1)},{signal:s}),t};
7function Om(p){p.preventDefault()}const Nm=1e-4;function tp(p){return p.cancelable?(se(p),!0):(p.stopPropagation(),!1)}var cl,nr,Ec,xc,Cc,_c,Tc,ca,rr,Qi,da,vi,Ji,ua,Zi,ar,Dt,Rb,Ep,xp,Cp,du,Ob,Nb,_p;class Fb{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,Dt);m(this,cl);m(this,nr,!1);m(this,Ec,null);m(this,xc);m(this,Cc);m(this,_c);m(this,Tc);m(this,ca);m(this,rr,!1);m(this,Qi,null);m(this,da);m(this,vi,new Set);m(this,Ji,null);m(this,ua);m(this,Zi,null);m(this,ar,0);f(this,cl,t),f(this,Ec,s),f(this,xc,e),f(this,Cc,i),f(this,_c,r),f(this,Tc,a),f(this,ca,o),f(this,ua,new AbortController),f(this,da,AbortSignal.any([l,n(this,ua).signal])),t.addEventListener("touchstart",b(this,Dt,Rb).bind(this),{passive:!1,signal:n(this,da)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/ri.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/ri.pixelRatio}destroy(){var t,e;b(this,Dt,_p).call(this),n(this,vi).clear(),(t=n(this,ua))==null||t.abort(),f(this,ua,null),(e=n(this,Qi))==null||e.abort(),f(this,Qi,null)}}cl=new WeakMap,nr=new WeakMap,Ec=new WeakMap,xc=new WeakMap,Cc=new WeakMap,_c=new WeakMap,Tc=new WeakMap,ca=new WeakMap,rr=new WeakMap,Qi=new WeakMap,da=new WeakMap,vi=new WeakMap,Ji=new WeakMap,ua=new WeakMap,Zi=new WeakMap,ar=new WeakMap,Dt=new WeakSet,Rb=function(t){var s,i;if((s=n(this,xc))!=null&&s.call(this))return;b(this,Dt,xp).call(this,t);const e=n(this,vi);for(const{identifier:r}of t.changedTouches)e.add(r);if(e.size===1){b(this,Dt,Ep).call(this);return}if(!n(this,Zi)){f(this,Zi,new AbortController);const r=AbortSignal.any([n(this,da),n(this,Zi).signal]),a=n(this,cl),o={signal:r,capture:!1,passive:!1};a.addEventListener("touchmove",b(this,Dt,Ob).bind(this),o);const l=b(this,Dt,Nb).bind(this);a.addEventListener("touchend",l,o),a.addEventListener("touchcancel",l,o),o.capture=!0,a.addEventListener("pointerdown",se,o),a.addEventListener("pointermove",se,o),a.addEventListener("pointercancel",Om,o),a.addEventListener("pointerup",Om,o),(i=n(this,Cc))==null||i.call(this)}f(this,rr,tp(t)),b(this,Dt,du).call(this,t)},Ep=function(){if(n(this,Qi))return;const t=f(this,Qi,new AbortController),e=AbortSignal.any([n(this,da),t.signal]),s=n(this,cl),i={capture:!0,signal:e,passive:!1},r=a=>{var o;a.pointerType==="touch"&&((o=n(this,Qi))==null||o.abort(),f(this,Qi,null))};s.addEventListener("pointerdown",a=>{a.pointerType==="touch"&&(se(a),r(a))},i),s.addEventListener("pointerup",r,i),s.addEventListener("pointercancel",r,i)},xp=function(t){const e=n(this,vi);if(e.size===0)return;const s=f(this,vi,new Set);for(const{identifier:i}of t.touches)e.has(i)&&s.add(i)},Cp=function(t){const e=n(this,vi),s=[];for(const i of t.touches)e.has(i.identifier)&&s.push(i);return s},du=function(t){var r;const e=b(this,Dt,Cp).call(this,t);if(e.length!==2||(r=n(this,Ec))!=null&&r.call(this)){f(this,Ji,null);return}const[s,i]=e;f(this,Ji,{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})},Ob=function(t){var F,H,Ct,_t;if(!n(this,Ji))return;const e=b(this,Dt,Cp).call(this,t);if(e.length!==2)return;const s=n(this,rr);if(f(this,rr,tp(t)),!n(this,rr))return;if(!s){b(this,Dt,du).call(this,t);return}const[i,r]=e,{screenX:a,screenY:o}=i,{screenX:l,screenY:h}=r,c=n(this,Ji),{touch0X:d,touch0Y:u,touch1X:g,touch1Y:y,panX:A,panY:S}=c,w=g-d,v=y-u,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=_-S,M=(a+l)/2,L=(o+h)/2,N=Math.hypot(M-c.screenPanX,L-c.screenPanY);c.screenPanX=M,c.screenPanY=L;const tt=Math.hypot(E,x),Q=Math.hypot(w,v),Z=n(this,nr)?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*N;if(tt<Nm||Q<Nm||Math.abs(Q-tt)<=Z){(k||P)&&((F=n(this,ca))==null||F.call(this,k,P));return}c.touch0X=a,c.touch0Y=o,c.touch1X=l,c.touch1Y=h;const $t=Math.sign(tt-Q);if(!n(this,nr)){f(this,nr,!0),f(this,ar,$t),(k||P)&&((H=n(this,ca))==null||H.call(this,k,P));return}if(n(this,ar)){const Me=n(this,ar);if(f(this,ar,0),$t!==Me&&Math.abs(tt-Q)<=2*N){f(this,nr,!1),(k||P)&&((Ct=n(this,ca))==null||Ct.call(this,k,P));return}}(_t=n(this,_c))==null||_t.call(this,[A,S],Q,tt,k,P)},Nb=function(t){if(b(this,Dt,xp).call(this,t),n(this,vi).size>=2){b(this,Dt,du).call(this,t);return}const e=!!n(this,Ji);b(this,Dt,_p).call(this),n(this,vi).size===1&&b(this,Dt,Ep).call(this),e&&tp(t)},_p=function(){var t;f(this,Ji,null),f(this,nr,!1),f(this,ar,0),f(this,rr,!1),n(this,Zi)&&(n(this,Zi).abort(),f(this,Zi,null),(t=n(this,Tc))==null||t.call(this))};var fa,zs,kt,ot,tn,dl,or,kc,pe,pa,en,Ds,lr,Pc,ga,ss,Mc,ma,sn,Si,ul,fl,Is,hr,Dc,of,$,Tp,Ic,kp,uu,Bb,Hb,Pp,fu,Mp,Ub,Gb,jb,Dp,$b,Ip,Lp,zb,Vb,Wb,Fp,Ih;const V=class V{constructor(t){m(this,$);m(this,fa,null);m(this,zs,null);m(this,kt,null);m(this,ot,null);m(this,tn,null);m(this,dl,!1);m(this,or,null);m(this,kc,"");m(this,pe,null);m(this,pa,null);m(this,en,null);m(this,Ds,null);m(this,lr,null);m(this,Pc,"");m(this,ga,!1);m(this,ss,null);m(this,Mc,!1);m(this,ma,!1);m(this,sn,!1);m(this,Si,null);m(this,ul,0);m(this,fl,0);m(this,Is,null);m(this,hr,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,Dc,!1);m(this,of,V._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=V.prototype._resizeWithKeyboard,e=Mo.TRANSLATE_SMALL,s=Mo.TRANSLATE_BIG;return j(this,"_resizerKeyboardManager",new Po([[["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"],V.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 j(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new u0({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(V._l10n??(V._l10n=t),V._l10nAlert??(V._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"})),V._l10nResizer??(V._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"})),V._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);V._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){st("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,Dc)}set _isDraggable(t){var e;f(this,Dc,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
7setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=n(this,of)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(b(this,$,Ih).call(this),(e=n(this,Ds))==null||e.remove(),f(this,Ds,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,ga)?f(this,ga,!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,$,Tp).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,ss)||f(this,ss,[this.x,this.y,this.width,this.height]),b(this,$,Tp).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,ss)||f(this,ss,[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:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(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,ss)&&(n(this,ss)[0]!==this.x||n(this,ss)[1]!==this.y)}get _hasBeenResized(){return!!n(this,ss)&&(n(this,ss)[2]!==this.width||n(this,ss)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=V,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=xt(r,0,s-o),a=xt(a,0,i-l);break;case 90:r=xt(r,0,s-l),a=xt(a,o,i);break;case 180:r=xt(r,o,s),a=xt(a,l,i);break;case 270:r=xt(r,l,s),a=xt(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=V,Ic,kp).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=V,Ic,kp).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,kt))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,ma))return this._editToolbar;this._editToolbar=new pp(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")}
7removeCommentButtonFromToolbar(){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,kt))==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,kt)||(Ku.initialize(V._l10n),f(this,kt,new Ku(this)),n(this,fa)&&(n(this,kt).data=n(this,fa),f(this,fa,null))),n(this,kt)}get altTextData(){var t;return(t=n(this,kt))==null?void 0:t.data}set altTextData(t){n(this,kt)&&(n(this,kt).data=t)}get guessedAltText(){var t;return(t=n(this,kt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,kt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,kt))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,kt)&&!n(this,kt).isEmpty()}hasAltTextData(){var t;return((t=n(this,kt))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=n(this,ot))==null||t.focusButton()}addCommentButton(){return this.canAddComment?n(this,ot)||f(this,ot,new Qd(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(n(this,tn)){this._uiManager.isEditingMode()&&n(this,tn).classList.remove("hidden");return}this.hasComment&&(f(this,tn,n(this,ot).renderForStandalone()),this.div.append(n(this,tn)))}}removeStandaloneCommentButton(){n(this,ot).removeStandaloneCommentButton(),f(this,tn,null)}hideStandaloneCommentButton(){var t;(t=n(this,tn))==null||t.classList.add("hidden")}get comment(){if(!n(this,ot))return null;const{data:{richText:t,text:e,date:s,deleted:i}}=n(this,ot);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){n(this,ot)||f(this,ot,new Qd(this)),typeof t=="object"&&t!==null?n(this,ot).restoreData(t):n(this,ot).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,ot)||f(this,ot,new Qd(this)),n(this,ot).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,ot))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=n(this,ot))==null?void 0:t.isDeleted()}get hasComment(){return!!n(this,ot)&&!n(this,ot).isEmpty()&&!n(this,ot).isDeleted()}async editComment(t){n(this,ot)||f(this,ot,new Qd(this)),n(this,ot).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){n(this,ot).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,ot).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,dl)?-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,$,Ip).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),Ab(this,t,["keydown","pointerdown","dblclick"]),b(this,$,Lp).call(this),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=gt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(f(this,ga,!0),this._isDraggable){b(this,$,$b).call(this,t);return}b(this,$,Dp).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,Si)&&clearTimeout(n(this,Si)),f(this,Si,setTimeout(()=>{var t;f(this,Si,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/i,c=e/i,d=this.x*r,u=this.y*a,g=this.width*r,y=this.height*a;switch(s){case 0:return[d+h+o,a-u-c-y+l,d+h+g+o,a-u-c+l];case 90:return[d+c+o,a-u+h+l,d+c+y+o,a-u+h+g+l];case 180:return[d-h-g+o,a-u+c+l,d-h+o,a-u+c+y+l];case 270:return[d-c-y+o,a-u-h-g+l,d-c+o,a-u-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&&V._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=n(this,ot))==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),f(this,ma,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),f(this,ma,!1),!0):!1}isInEditMode(){return n(this,ma)}shouldGetKeyboardEvents(){return n(this,sn)}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}
7rebuild(){b(this,$,Ip).call(this),b(this,$,Lp).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,f(i,fa,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,lr))==null||t.abort(),f(this,lr,null),this.isEmpty()||this.commit(),(e=n(this,hr))==null||e.destroy(),f(this,hr,null),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),n(this,Si)&&(clearTimeout(n(this,Si)),f(this,Si,null)),b(this,$,Ih).call(this),this.removeEditToolbar(),n(this,Is)){for(const i of n(this,Is).values())clearTimeout(i);f(this,Is,null)}this.parent=null,(s=n(this,Ds))==null||s.remove(),f(this,Ds,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,$,Bb).call(this),n(this,pe).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[V._round(s+(r-s)*t),V._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,ot).commentPopupPositionInLayer}set commentPopupPosition(t){n(this,ot).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return n(this,ot).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,ot).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=n(this,ot))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),f(this,en,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,pe).children;if(!n(this,zs)){f(this,zs,Array.from(e));const a=b(this,$,zb).bind(this),o=b(this,$,Vb).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,$,Wb).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",V._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,pe).append(n(this,pe).firstElementChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,pe).firstElementChild.before(n(this,pe).lastElementChild);let a=0;for(const o of e){const h=n(this,zs)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",V._l10nResizer[h])}}b(this,$,Fp).call(this,0),f(this,sn,!0),n(this,pe).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,sn)&&b(this,$,Mp).call(this,n(this,Pc),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,$,Ih).call(this),this.div.focus()}select(){var t,e,s;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=n(this,kt))==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,pe))==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,kt))==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,Mc)}set isEditing(t){f(this,Mc,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,Is)||f(this,Is,new Map);const{action:s}=t;let i=n(this,Is).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,Is).delete(s),n(this,Is).size===0&&f(this,Is,null)},V._telemetryTimeout),n(this,Is).set(s,i);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}
7show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),f(this,dl,!1)}disable(){this.div&&(this.div.tabIndex=-1),f(this,dl,!0)}updateFakeAnnotationElement(t){if(!n(this,Ds)&&!this.deleted){f(this,Ds,t.addFakeAnnotation(this));return}if(this.deleted){n(this,Ds).remove(),f(this,Ds,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,Ds).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()}};fa=new WeakMap,zs=new WeakMap,kt=new WeakMap,ot=new WeakMap,tn=new WeakMap,dl=new WeakMap,or=new WeakMap,kc=new WeakMap,pe=new WeakMap,pa=new WeakMap,en=new WeakMap,Ds=new WeakMap,lr=new WeakMap,Pc=new WeakMap,ga=new WeakMap,ss=new WeakMap,Mc=new WeakMap,ma=new WeakMap,sn=new WeakMap,Si=new WeakMap,ul=new WeakMap,fl=new WeakMap,Is=new WeakMap,hr=new WeakMap,Dc=new WeakMap,of=new WeakMap,$=new WeakSet,Tp=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()},Ic=new WeakSet,kp=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]}},uu=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]}},Bb=function(){if(n(this,pe))return;f(this,pe,document.createElement("div")),n(this,pe).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,pe).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,$,Hb).bind(this,s),{signal:e}),i.addEventListener("contextmenu",ni,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,pe))},Hb=function(t,e){var c;e.preventDefault();const{isMac:s}=gt.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=n(this,kt))==null||c.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,f(this,pa,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,$,Mp).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",se,{passive:!1,signal:a}),window.addEventListener("contextmenu",ni,{signal:a}),f(this,en,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var d;r.abort(),this.parent.togglePointerEvents(!0),(d=n(this,kt))==null||d.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,$,fu).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},Pp=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},fu=function(){if(!n(this,en))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,en);f(this,en,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,$,Pp).bind(this,r,a,o,l),undo:b(this,$,Pp).bind(this,t,e,s,i),mustExec:!0})},Mp=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=V.MIN_SIZE/s,c=V.MIN_SIZE/i,d=b(this,$,uu).call(this,this.rotation),u=(F,H)=>[d[0]*F+d[2]*H,d[1]*F+d[3]*H],g=b(this,$,uu).call(this,360-this.rotation),y=(F,H)=>[g[0]*F+g[2]*H,g[1]*F+g[3]*H];let A,S,w=!1,v=!1;switch(t){case"topLeft":w=!0,A=(F,H)=>[0,0],S=(F,H)=>[F,H];break;case"topMiddle":A=(F,H)=>[F/2,0],S=(F,H)=>[F/2,H];break;case"topRight":w=!0,A=(F,H)=>[F,0],S=(F,H)=>[0,H];break;case"middleRight":v=!0,A=(F,H)=>[F,H/2],S=(F,H)=>[0,H/2];break;case"bottomRight":w=!0,A=(F,H)=>[F,H],S=(F,H)=>[0,0];break;case"bottomMiddle":A=(F,H)=>[F/2,H],S=(F,H)=>[F/2,0];break;case"bottomLeft":w=!0,A=(F,H)=>[0,H],S=(F,H)=>[F,0];break;case"middleLeft":v=!0,A=(F,H)=>[0,H/2],S=(F,H)=>[F,H/2];break}const E=A(o,l),x=S(o,l);let C=u(...x);
7const _=V._round(r+C[0]),k=V._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,[Ct,_t]=n(this,pa);[L,N]=this.screenToPageTranslation(F-Ct,H-_t),n(this,pa)[0]=F,n(this,pa)[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 v?P=xt(Math.abs(x[0]-E[0]-L),h,1)/o:M=xt(Math.abs(x[1]-E[1]-N),c,1)/l;const tt=V._round(o*P),Q=V._round(l*M);C=u(...S(tt,Q));const Z=_-C[0],$t=k-C[1];n(this,ss)||f(this,ss,[this.x,this.y,this.width,this.height]),this.width=tt,this.height=Q,this.x=Z,this.y=$t,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Ub=function(){var t;f(this,en,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,kt))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},Gb=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=b(this,$,uu).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,u=this.width,g=this.height,y=V.MIN_SIZE/l,A=V.MIN_SIZE/h;r=Math.max(Math.min(r,1/u,1/g),y/u,A/g);const S=V._round(u*r),w=V._round(g*r);if(S===u&&w===g)return;n(this,ss)||f(this,ss,[c,d,u,g]);const v=o(u/2,g/2),E=V._round(c+v[0]),x=V._round(d+v[1]),C=o(S/2,w/2);this.x=E-C[0],this.y=x-C[1],this.width=S,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},jb=function(){var t;(t=n(this,kt))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,$,fu).call(this)},Dp=function(t){const{isMac:e}=gt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},$b=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(),f(this,or,null),f(this,ga,!1),this._uiManager.endDragSession()||b(this,$,Dp).call(this,h),s&&this._onStopDragging()};e&&(f(this,ul,t.clientX),f(this,fl,t.clientY),f(this,or,t.pointerId),f(this,kc,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:d,pointerId:u}=h;if(u!==n(this,or)){se(h);return}const[g,y]=this.screenToPageTranslation(c-n(this,ul),d-n(this,fl));f(this,ul,c),f(this,fl,d),this._uiManager.dragSelectedEditors(g,y),this.div.scrollIntoView({block:"nearest"})},a),window.addEventListener("touchmove",se,a),window.addEventListener("pointerdown",h=>{h.pointerType===n(this,kc)&&(n(this,hr)||h.isPrimary)&&o(h),se(h)},a));const l=h=>{if(!n(this,or)||n(this,or)===h.pointerId){o(h);return}se(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Ip=function(){if(n(this,lr)||!this.div)return;f(this,lr,new AbortController);const t=this._uiManager.combinedSignal(n(this,lr));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Lp=function(){n(this,hr)||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||f(this,hr,new Fb({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,$,Ub).bind(this),onPinching:b(this,$,Gb).bind(this),onPinchEnd:b(this,$,jb).bind(this),signal:this._uiManager._signal}))},zb=function(t){V._resizerKeyboardManager.exec(this,t)},Vb=function(t){var e;n(this,sn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,pe)&&b(this,$,Ih).call(this)},Wb=function(t){f(this,Pc,n(this,sn)?t:"")},Fp=function(t){if(n(this,zs))for(const e of n(this,zs))e.tabIndex=t},Ih=function(){f(this,sn,!1),b(this,$,Fp).call(this,-1),b(this,$,fu).call(this)},m(V,Ic),T(V,"_l10n",null),T(V,"_l10nAlert",null),T(V,"_l10nResizer",null),T(V,"_borderLineWidth",-1),T(V,"_colorManager",new bp),T(V,"_zIndex",1),T(V,"_telemetryTimeout",1e3);let bt=V;class u0 extends bt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Bm=3285377520,Ss=4294901760,li=65535;class Rp{constructor(t){this.h1=t?t&4294967295:Bm,this.h2=t?t&4294967295:Bm}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let A=0,S=t.length;A<S;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,u=461845907,g=d&li,y=u&li;for(let A=0;A<i;
7A++)A&1?(o=a[A],o=o*d&Ss|o*g&li,o=o<<15|o>>>17,o=o*u&Ss|o*y&li,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[A],l=l*d&Ss|l*g&li,l=l<<15|l>>>17,l=l*u&Ss|l*y&li,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;case 1:o^=e[i*4],o=o*d&Ss|o*g&li,o=o<<15|o>>>17,o=o*u&Ss|o*y&li,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&Ss|t*36045&li,e=e*4283543511&Ss|((e<<16|t>>>16)*2950163797&Ss)>>>16,t^=e>>>1,t=t*444984403&Ss|t*60499&li,e=e*3301882366&Ss|((e<<16|t>>>16)*3120437893&Ss)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const tc=Object.freeze({map:null,hash:"",transfer:void 0});var ba,ya,nn,ge,lf,Xb;class am{constructor(){m(this,lf);m(this,ba,!1);m(this,ya,null);m(this,nn,null);m(this,ge,new Map);T(this,"onSetModified",null);T(this,"onResetModified",null);T(this,"onAnnotationEditor",null)}getValue(t,e){const s=n(this,ge).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,ge).get(t)}remove(t){var s;const e=n(this,ge).get(t);e!==void 0&&(e instanceof bt&&n(this,nn).delete(e.annotationElementId),n(this,ge).delete(t),n(this,ge).size===0&&this.resetModified(),!n(this,ge).values().some(i=>i instanceof bt)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var r;const s=n(this,ge).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,ge).set(t,e);i&&b(this,lf,Xb).call(this),e instanceof bt&&((n(this,nn)||f(this,nn,new Map)).set(e.annotationElementId,e),(r=this.onAnnotationEditor)==null||r.call(this,e.constructor._type))}has(t){return n(this,ge).has(t)}get size(){return n(this,ge).size}resetModified(){var t;n(this,ba)&&(f(this,ba,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new Yb(this)}get serializable(){if(n(this,ge).size===0)return tc;const t=new Map,e=new Rp,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,ge)){const l=o instanceof bt?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}:tc}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of n(this,ge).values()){if(!(r instanceof bt)){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,em);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(){f(this,ya,null)}updateEditor(t,e){var i;const s=(i=n(this,nn))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=n(this,nn))==null?void 0:e.get(t))||null}get modifiedIds(){if(n(this,ya))return n(this,ya);const t=[];if(n(this,nn))for(const s of n(this,nn).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new Rp;s.update(t.join(",")),e=s.hexdigest()}return f(this,ya,{ids:new Set(t),hash:e})}[Symbol.iterator](){return n(this,ge).entries()}}ba=new WeakMap,ya=new WeakMap,nn=new WeakMap,ge=new WeakMap,lf=new WeakSet,Xb=function(){var t;n(this,ba)||(f(this,ba,!0),(t=this.onSetModified)==null||t.call(this))};var Lc;class Yb extends am{constructor(e){super();m(this,Lc,tc);const{serializable:s}=e;if(s===tc)return;const{map:i,hash:r,transfer:a}=s,o=structuredClone(i,a?{transfer:a}:null);f(this,Lc,{map:o,hash:r,transfer:[]})}get print(){st("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,Lc)}get modifiedIds(){return j(this,"modifiedIds",{ids:new Set,hash:""})}}Lc=new WeakMap;const Ro="__forcedDependency",{floor:Hm,ceil:Um}=Math;function Gm(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 f0(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 Op=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var pl,cr;class p0{constructor(t,e){m(this,pl);m(this,cr);f(this,pl,t),f(this,cr,e)}get length(){return n(this,pl).length}isEmpty(t){return n(this,pl)[t]===Op}minX(t){return n(this,cr)[t*4+0]/256}minY(t){return n(this,cr)[t*4+1]/256}maxX(t){return(n(this,cr)[t*4+2]+1)/256}maxY(t){return(n(this,cr)[t*4+3]+1)/256}}pl=new WeakMap,cr=new WeakMap;const jm=(p,t)=>p==null?void 0:p.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));
7var rn,rt,Et,Aa,wa,va,Te,Fc,Np;class g0{constructor(t,e){m(this,Fc);m(this,rn,[[1,0,0,1,0,0]]);m(this,rt,[-1/0,-1/0,1/0,1/0]);m(this,Et,new Float64Array(Mn));T(this,"_pendingBBoxIdx",-1);m(this,Aa);m(this,wa);m(this,va);m(this,Te);T(this,"_savesStack",[]);T(this,"_markedContentStack",[]);f(this,Aa,t.width),f(this,wa,t.height),b(this,Fc,Np).call(this,e)}growOperationsCount(t){t>=n(this,Te).length&&b(this,Fc,Np).call(this,t,n(this,Te))}get clipBox(){return n(this,rt)}save(t){return f(this,rt,{__proto__:n(this,rt)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(n(this,rt));if(s===null)return this;f(this,rt,s);const i=this._savesStack.pop();return i!==void 0&&(e==null||e(i,t),n(this,Te)[t]=n(this,Te)[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,Te)[t]=n(this,Te)[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e==null||e(s,t),n(this,Te)[t]=n(this,Te)[s]),this}pushBaseTransform(t){return n(this,rn).push(D.multiplyByDOMMatrix(n(this,rn).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,rn).length>1&&n(this,rn).pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,n(this,Et).set(Mn,0)),this}recordClipBox(t,e,s,i,r,a){const o=D.multiplyByDOMMatrix(n(this,rn).at(-1),e.getTransform()),l=Mn.slice();D.axialAlignedBoundingBox([s,r,i,a],o,l);const h=D.intersect(n(this,rt),l);return h?(n(this,rt)[0]=h[0],n(this,rt)[1]=h[1],n(this,rt)[2]=h[2],n(this,rt)[3]=h[3]):(n(this,rt)[0]=n(this,rt)[1]=1/0,n(this,rt)[2]=n(this,rt)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,rt);
7if(o[0]===1/0)return this;const l=D.multiplyByDOMMatrix(n(this,rn).at(-1),e.getTransform());if(o[0]===-1/0)return D.axialAlignedBoundingBox([s,r,i,a],l,n(this,Et)),this;const h=Mn.slice();return D.axialAlignedBoundingBox([s,r,i,a],l,h),n(this,Et)[0]=xt(h[0],o[0],n(this,Et)[0]),n(this,Et)[1]=xt(h[1],o[1],n(this,Et)[1]),n(this,Et)[2]=xt(h[2],n(this,Et)[2],o[2]),n(this,Et)[3]=xt(h[3],n(this,Et)[3],o[3]),this}recordFullPageBBox(t){return n(this,Et)[0]=Math.max(0,n(this,rt)[0]),n(this,Et)[1]=Math.max(0,n(this,rt)[1]),n(this,Et)[2]=Math.min(n(this,Aa),n(this,rt)[2]),n(this,Et)[3]=Math.min(n(this,wa),n(this,rt)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=Hm(n(this,Et)[0]*256/n(this,Aa)),r=Hm(n(this,Et)[1]*256/n(this,wa)),a=Um(n(this,Et)[2]*256/n(this,Aa)),o=Um(n(this,Et)[3]*256/n(this,wa));if(Gm(n(this,va),t,i,r,a,o),s)for(const l of s)for(const h of l)h!==t&&Gm(n(this,va),h,i,r,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,n(this,rt)[0]=Math.max(n(this,rt)[0],n(this,Et)[0]),n(this,rt)[1]=Math.max(n(this,rt)[1],n(this,Et)[1]),n(this,rt)[2]=Math.min(n(this,rt)[2],n(this,Et)[2]),n(this,rt)[3]=Math.min(n(this,rt)[3],n(this,Et)[3])),this}take(){return new p0(n(this,Te),n(this,va))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,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}}rn=new WeakMap,rt=new WeakMap,Et=new WeakMap,Aa=new WeakMap,wa=new WeakMap,va=new WeakMap,Te=new WeakMap,Fc=new WeakSet,Np=function(t,e){const s=new ArrayBuffer(t*4);f(this,va,new Uint8ClampedArray(s)),f(this,Te,new Uint32Array(s)),e&&e.length>0?(n(this,Te).set(e),n(this,Te).fill(Op,e.length)):n(this,Te).fill(Op)};var Xe,Ye,Sa,Vs,gl,dr,ur,ut;class m0{constructor(t,e=!1){m(this,Xe,{__proto__:null});m(this,Ye,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Ro]:[]});m(this,Sa,new Map);m(this,Vs,new Set);m(this,gl,new Map);m(this,dr);m(this,ur);m(this,ut);f(this,ut,t),e&&(f(this,dr,new Map),f(this,ur,(s,i)=>{jm(n(this,dr),i).dependencies.add(s)}))}get clipBox(){return n(this,ut).clipBox}growOperationsCount(t){n(this,ut).growOperationsCount(t)}save(t){return f(this,Xe,{__proto__:n(this,Xe)}),f(this,Ye,{__proto__:n(this,Ye),transform:{__proto__:n(this,Ye).transform},moveText:{__proto__:n(this,Ye).moveText},sameLineText:{__proto__:n(this,Ye).sameLineText},[Ro]:{__proto__:n(this,Ye)[Ro]}}),n(this,ut).save(t),this}restore(t){n(this,ut).restore(t,n(this,ur));const e=Object.getPrototypeOf(n(this,Xe));return e===null?this:(f(this,Xe,e),f(this,Ye,Object.getPrototypeOf(n(this,Ye))),this)}recordOpenMarker(t){return n(this,ut).recordOpenMarker(t,n(this,ur)),this}getOpenMarker(){return n(this,ut).getOpenMarker()}recordCloseMarker(t){return n(this,ut).recordCloseMarker(t,n(this,ur)),this}beginMarkedContent(t){return n(this,ut).beginMarkedContent(t),this}endMarkedContent(t){return n(this,ut).endMarkedContent(t,n(this,ur)),this}pushBaseTransform(t){return n(this,ut).pushBaseTransform(t),this}popBaseTransform(){return n(this,ut).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Xe)[t]=e,this}recordIncrementalData(t,e){return n(this,Ye)[t].push(e),this}resetIncrementalData(t,e){return n(this,Ye)[t].length=0,this}recordNamedData(t,e){return n(this,Sa).set(t,e),this}recordSimpleDataFromNamed(t,e,s){n(this,Xe)[t]=n(this,Sa).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Ro,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,Xe)&&this.recordFutureForcedDependency(e,n(this,Xe)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,Vs))this.recordFutureForcedDependency(Ro,t);return this}resetBBox(t){return n(this,ut).resetBBox(t),this}recordClipBox(t,e,s,i,r,a){return n(this,ut).recordClipBox(t,e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,ut).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,gl).get(s),h!==!1&&(c=[0,0,0,0],D.axialAlignedBoundingBox(l,s.fontMatrix,c),(i!==1||r!==0||a!==0)&&f0(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,gl).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,ut).recordFullPageBBox(t),this}getSimpleIndex(t){return n(this,Xe)[t]}recordDependencies(t,e){const s=n(this,Vs),i=n(this,Xe),r=n(this,Ye);for(const a of e)a in n(this,Xe)?s.add(i[a]):a in r&&r[a].forEac
7h(s.add,s);return this}recordNamedDependency(t,e){return n(this,Sa).has(e)&&n(this,Vs).add(n(this,Sa).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Ro]),n(this,dr)){const i=jm(n(this,dr),t),{dependencies:r}=i;n(this,Vs).forEach(r.add,r),n(this,ut)._savesStack.forEach(r.add,r),n(this,ut)._markedContentStack.forEach(r.add,r),r.delete(t),i.isRenderingOperation=!0}const s=!e&&t===n(this,ut)._pendingBBoxIdx;return n(this,ut).recordOperation(t,e,[n(this,Vs),n(this,ut)._savesStack,n(this,ut)._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,ut)._pendingBBoxIdx;return n(this,ut).bboxToClipBoxDropOperation(t),s&&n(this,Vs).clear(),this}take(){return n(this,gl).clear(),n(this,ut).take()}takeDebugMetadata(){return n(this,dr)}}Xe=new WeakMap,Ye=new WeakMap,Sa=new WeakMap,Vs=new WeakMap,gl=new WeakMap,dr=new WeakMap,ur=new WeakMap,ut=new WeakMap;var ft,Ut,Ws,ml,bl;const mm=class mm{constructor(t,e,s){m(this,ft);m(this,Ut);m(this,Ws);m(this,ml,0);m(this,bl,0);if(t instanceof mm&&n(t,Ws)===!!s)return t;f(this,ft,t),f(this,Ut,e),f(this,Ws,!!s)}get clipBox(){return n(this,ft).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return It(this,bl)._++,n(this,ft).save(n(this,Ut)),this}restore(t){return n(this,bl)>0&&(n(this,ft).restore(n(this,Ut)),It(this,bl)._--),this}recordOpenMarker(t){return It(this,ml)._++,this}getOpenMarker(){return n(this,ml)>0?n(this,Ut):n(this,ft).getOpenMarker()}recordCloseMarker(t){return It(this,ml)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,ft).pushBaseTransform(t),this}popBaseTransform(){return n(this,ft).popBaseTransform(),this}recordSimpleData(t,e){return n(this,ft).recordSimpleData(t,n(this,Ut)),this}recordIncrementalData(t,e){return n(this,ft).recordIncrementalData(t,n(this,Ut)),this}resetIncrementalData(t,e){return n(this,ft).resetIncrementalData(t,n(this,Ut)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return n(this,ft).recordSimpleDataFromNamed(t,e,n(this,Ut)),this}recordFutureForcedDependency(t,e){return n(this,ft).recordFutureForcedDependency(t,n(this,Ut)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,ft).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,ft).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,Ws)||n(this,ft).resetBBox(n(this,Ut)),this}recordClipBox(t,e,s,i,r,a){return n(this,Ws)||n(this,ft).recordClipBox(n(this,Ut),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Ws)||n(this,ft).recordBBox(n(this,Ut),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,Ws)||n(this,ft).recordCharacterBBox(n(this,Ut),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,Ws)||n(this,ft).recordFullPageBBox(n(this,Ut)),this}getSimpleIndex(t){return n(this,ft).getSimpleIndex(t)}recordDependencies(t,e){return n(this,ft).recordDependencies(n(this,Ut),e),this}recordNamedDependency(t,e){return n(this,ft).recordNamedDependency(n(this,Ut),e),this}recordOperation(t){return n(this,ft).recordOperation(n(this,Ut),!0),this}recordShowTextOperation(t){return n(this,ft).recordShowTextOperation(n(this,Ut),!0),this}bboxToClipBoxDropOperation(t){return n(this,Ws)||n(this,ft).bboxToClipBoxDropOperation(n(this,Ut),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};ft=new WeakMap,Ut=new WeakMap,Ws=new WeakMap,ml=new WeakMap,bl=new WeakMap;let ec=mm;const Es={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
7ilter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};var Ea,xa,Ca,_a,Ta,Rc;const Qh=class Qh{constructor(t){m(this,Ea);m(this,xa);m(this,Ca,4);m(this,_a,0);m(this,Ta,new(n(Qh,Rc))(n(this,Ca)*6));f(this,Ea,t.width),f(this,xa,t.height)}record(t,e,s,i){if(n(this,_a)===n(this,Ca)){f(this,Ca,n(this,Ca)*2);const o=new(n(Qh,Rc))(n(this,Ca)*6);o.set(n(this,Ta)),f(this,Ta,o)}const r=vt(t);let a;if(i[0]!==1/0){const o=Mn.slice();D.axialAlignedBoundingBox([0,-s,e,0],r,o);const l=D.intersect(i,o);if(!l)return;const[h,c,d,u]=l;if(h!==o[0]||c!==o[1]||d!==o[2]||u!==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,u,d,c];else{const S=d-h,w=u-c,v=y*y,E=A*A,x=A*y,C=E-v,_=(w*E-S*x)/C,k=(w*x-S*v)/C;a=[h+k,c,h,c+_,d,u-_]}}}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,Ea),a[1]/=n(this,xa),a[2]/=n(this,Ea),a[3]/=n(this,xa),a[4]/=n(this,Ea),a[5]/=n(this,xa),n(this,Ta).set(a,n(this,_a)*6),It(this,_a)._++}take(){return n(this,Ta).subarray(0,n(this,_a)*6)}};Ea=new WeakMap,xa=new WeakMap,Ca=new WeakMap,_a=new WeakMap,Ta=new WeakMap,Rc=new WeakMap,m(Qh,Rc,gt.isFloat16ArraySupported?Float16Array:Float32Array);let Bp=Qh;const $m=new RegExp("\\p{Cc}","u");function b0(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||$m.test(i)||i==="\\"&&(++s>=e||$m.test(p[s])))return!1}return!0}function zm(p){return b0(p)?p:`"${p.replaceAll(/["\\\p{Cc}]/gu,e=>e==='"'||e==="\\"?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}var yl,Xs,hf,Kb;class y0{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){m(this,hf);m(this,yl,new Set);m(this,Xs,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,hf,Kb).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,yl).clear(),n(this,Xs)){const{adoptedStyleSheets:t}=this._document;t!=null&&t.includes(n(this,Xs))&&(this._document.adoptedStyleSheets=t.filter(e=>e!==n(this,Xs))),f(this,Xs,null)}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,yl).has(t.loadedName))){if(Bt(!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,yl).add(i),s==null||s(t)}catch{Y(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}st("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 Y(`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 j(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return j(this,"isSyncFontLoadingSupported",ms||gt.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(Bt(!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 j(this,"_loadTestFont",t)}
7_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){Y("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 u=`lt${Date.now()}${this.loadTestFontId++}`;let g=this._loadTestFont;g=r(g,976,u.length,u);const A=16,S=1482184792;let w=s(g,A);for(a=0,o=u.length-3;a<o;a+=4)w=w-S+s(u,a)|0;a<u.length&&(w=w-S+s(u+"XXX",a)|0),g=r(g,A,4,i(w));const v=`url(data:font/opentype;base64,${btoa(g)});`,E=`@font-face {font-family:"${u}";src:${v}}`;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,u]){const _=this._document.createElement("span");_.textContent="Hi",_.style.fontFamily=C,x.append(_)}this._document.body.append(x),d(u,()=>{x.remove(),e.complete()})}}yl=new WeakMap,Xs=new WeakMap,hf=new WeakSet,Kb=function(){var e;if(n(this,Xs))return n(this,Xs);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),f(this,Xs,i)}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),f(this,Xs,this.styleElement.sheet)};var pt;class A0{constructor(t,e=null,s,i){T(this,"compiledGlyphs",Object.create(null));m(this,pt);f(this,pt,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(zm(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:${zm(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){Y(`getPathGenerator - ignoring character: "${a}".`)}const r=fb(i==null?void 0:i.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return n(this,pt).black}get bold(){return n(this,pt).bold}get disableFontFace(){return n(this,pt).disableFontFace}set disableFontFace(t){j(this,"disableFontFace",!!t)}get fontExtraProperties(){return n(this,pt).fontExtraProperties}get isInvalidPDFjsFont(){return n(this,pt).isInvalidPDFjsFont}get isType3Font(){return n(this,pt).isType3Font}get italic(){return n(this,pt).italic}get missingFile(){return n(this,pt).missingFile}get remeasure(){return n(this,pt).remeasure}get vertical(){return n(this,pt).vertical}get ascent(){return n(this,pt).ascent}get defaultWidth(){return n(this,pt).defaultWidth}get descent(){return n(this,pt).descent}get bbox(){return n(this,pt).bbox}get fontMatrix(){return n(this,pt).fontMatrix}get fallbackName(){return n(this,pt).fallbackName}get loadedName(){return n(this,pt).loadedName}get mimetype(){return n(this,pt).mimetype}get name(){return n(this,pt).name}get data(){return n(this,pt).data}clearData(){n(this,pt).clearData()}get cssFontInfo(){return n(this,pt).cssFontInfo}get systemFontInfo(){return n(this,pt).systemFontInfo}get defaultVMetrics(){return n(this,pt).defaultVMetrics}}pt=new WeakMap;class qb{}T(qb,"strings",["fontFamily","fontWeight","italicAngle"]);class Qb{}T(Qb,"strings",["css","loadedName","baseFontName","src"]);const Ee=class Ee{};
7T(Ee,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),T(Ee,"numbers",["ascent","defaultWidth","descent"]),T(Ee,"strings",["fallbackName","loadedName","mimetype","name"]),T(Ee,"OFFSET_NUMBERS",Math.ceil(Ee.bools.length*2/8)),T(Ee,"OFFSET_BBOX",Ee.OFFSET_NUMBERS+Ee.numbers.length*8),T(Ee,"OFFSET_FONT_MATRIX",Ee.OFFSET_BBOX+1+2*4),T(Ee,"OFFSET_DEFAULT_VMETRICS",Ee.OFFSET_FONT_MATRIX+1+8*6),T(Ee,"OFFSET_STRINGS",Ee.OFFSET_DEFAULT_VMETRICS+1+2*3);let Je=Ee;class He{}T(He,"KIND",0),T(He,"HAS_BBOX",1),T(He,"HAS_BACKGROUND",2),T(He,"SHADING_TYPE",3),T(He,"N_COORD",4),T(He,"N_COLOR",8),T(He,"N_STOP",12),T(He,"N_FIGURES",16);class qu{static get decoder(){return j(this,"decoder",new TextDecoder)}static get encoder(){return j(this,"encoder",new TextEncoder)}}var Oc,Al,wl,pu;class w0{constructor(t){m(this,wl);m(this,Oc);m(this,Al);f(this,Oc,t),f(this,Al,new DataView(t))}get fontFamily(){return b(this,wl,pu).call(this,0)}get fontWeight(){return b(this,wl,pu).call(this,1)}get italicAngle(){return b(this,wl,pu).call(this,2)}}Oc=new WeakMap,Al=new WeakMap,wl=new WeakSet,pu=function(t){Bt(t<qb.strings.length,"Invalid string index");const{decoder:e}=qu;let s=0;for(let r=0;r<t;r++)s+=n(this,Al).getUint32(s)+4;const i=n(this,Al).getUint32(s);return e.decode(new Uint8Array(n(this,Oc),s+4,i))};var ka,Ei,Pa,Lh;class v0{constructor(t){m(this,Pa);m(this,ka);m(this,Ei);f(this,ka,t),f(this,Ei,new DataView(t))}get guessFallback(){return n(this,Ei).getUint8(0)!==0}get css(){return b(this,Pa,Lh).call(this,0)}get loadedName(){return b(this,Pa,Lh).call(this,1)}get baseFontName(){return b(this,Pa,Lh).call(this,2)}get src(){return b(this,Pa,Lh).call(this,3)}get style(){const{decoder:t}=qu;let e=1;e+=4+n(this,Ei).getUint32(e);const s=n(this,Ei).getUint32(e),i=t.decode(new Uint8Array(n(this,ka),e+4,s));e+=4+s;const r=n(this,Ei).getUint32(e),a=t.decode(new Uint8Array(n(this,ka),e+4,r));return{style:i,weight:a}}}ka=new WeakMap,Ei=new WeakMap,Pa=new WeakSet,Lh=function(t){Bt(t<Qb.strings.length,"Invalid string index");const{decoder:e}=qu;let s=5;for(let r=0;r<t;r++)s+=n(this,Ei).getUint32(s)+4;const i=n(this,Ei).getUint32(s);return e.decode(new Uint8Array(n(this,ka),s+4,i))};var Ys,Vt,lt,Gs,gu,mu,Fh,Hp;class S0{constructor({buffer:t,extra:e}){m(this,lt);m(this,Ys);m(this,Vt);f(this,Ys,t),f(this,Vt,new DataView(t)),e&&Object.assign(this,e)}get black(){return b(this,lt,Gs).call(this,0)}get bold(){return b(this,lt,Gs).call(this,1)}get disableFontFace(){return b(this,lt,Gs).call(this,2)}get fontExtraProperties(){return b(this,lt,Gs).call(this,3)}get isInvalidPDFjsFont(){return b(this,lt,Gs).call(this,4)}get isType3Font(){return b(this,lt,Gs).call(this,5)}get italic(){return b(this,lt,Gs).call(this,6)}get missingFile(){return b(this,lt,Gs).call(this,7)}get remeasure(){return b(this,lt,Gs).call(this,8)}get vertical(){return b(this,lt,Gs).call(this,9)}get ascent(){return b(this,lt,gu).call(this,0)}get defaultWidth(){return b(this,lt,gu).call(this,1)}get descent(){return b(this,lt,gu).call(this,2)}get bbox(){return b(this,lt,mu).call(this,Je.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return b(this,lt,mu).call(this,Je.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return b(this,lt,mu).call(this,Je.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}get fallbackName(){return b(this,lt,Fh).call(this,0)}get loadedName(){return b(this,lt,Fh).call(this,1)}get mimetype(){return b(this,lt,Fh).call(this,2)}get name(){return b(this,lt,Fh).call(this,3)}get data(){const{offset:t,length:e}=b(this,lt,Hp).call(this);return e===0?void 0:new Uint8Array(n(this,Ys),t+4,e)}clearData(){const{offset:t,length:e}=b(this,lt,Hp).call(this);e!==0&&(n(this,Vt).setUint32(t,0),f(this,Ys,new Uint8Array(n(this,Ys),0,t+4).slice().buffer),f(this,Vt,new DataView(n(this,Ys))))}get cssFontInfo(){let t=Je.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,Ys),t+4,i)),new w0(r.buffer)}get systemFontInfo(){let t=Je.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);return i.set(new Uint8Array(n(this,Ys),t+4,s)),new v0(i.buffer)}}Ys=new WeakMap,Vt=new WeakMap,lt=new WeakSet,Gs=function(t){Bt(t<Je.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},gu=function(t){return Bt(t<Je.numbers.length,"Invalid number index"),n(this,Vt).getFloat64(Je.OFFSET_NUMBERS+t*8)},mu=function(t,e,s,i){const r=n(this,Vt).getUint8(t);if(r===0)return;Bt(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},Fh=function(t){Bt(t<Je.strings.length,"Invalid string index");const{decoder:e}=qu;let s=Je.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,Ys),s+4,i))},Hp=function(){let t=Je.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[He.KIND],s=!!this.data[He.HAS_BBOX],i=!!this.data[He.HAS_BACKGROUND],r=t.getUint32(He.N_COORD,!0),a=t.getUint32(He.N_COLOR,!0),o=t.getUint32(He.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;
7const S=t.getUint32(l,!0);l+=4,d.push([A,`#${S.toString(16).padStart(6,"0")}`])}let u=null;if(s){u=[];for(let y=0;y<4;++y)u.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",u,d,Array.from(h.slice(0,2)),Array.from(h.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",u,d,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(e===3){const y=this.data[He.SHADING_TYPE];let A=null;if(h.length>0){A=Mn.slice();for(let S=0,w=h.length;S<w;S+=2)D.pointBoundingBox(h[S],h[S+1],A)}return["Mesh",y,h,c,r,A,u,g]}throw new Error(`Unsupported pattern kind: ${e}`)}}var vl;class x0{constructor(t){m(this,vl);f(this,vl,t)}get path(){return gt.isFloat16ArraySupported?new Float16Array(n(this,vl)):new Float32Array(n(this,vl))}}vl=new WeakMap;function C0(p){if(p instanceof URL)return p;if(typeof p=="string"){if(ms){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 _0(p){if(ms&&typeof Buffer<"u"&&p instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(p instanceof Uint8Array&&p.byteLength===p.buffer.byteLength)return p;if(typeof p=="string")return Lf(p);if(p instanceof ArrayBuffer||ArrayBuffer.isView(p)||typeof p=="object"&&!isNaN(p==null?void 0:p.length))return new Uint8Array(p);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Jd(p){if(typeof p!="string")return null;if(p.endsWith("/"))return p;throw new Error(`Invalid factory url: "${p}" must include trailing slash.`)}const Up=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,T0=p=>typeof p=="object"&&typeof(p==null?void 0:p.name)=="string",k0=QA.bind(null,Up,T0);var an,cf;class P0{constructor(){m(this,an,new Map);m(this,cf,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,cf).then(()=>{for(const[i]of n(this,an))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){Y("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,an).set(e,i)}removeEventListener(t,e){const s=n(this,an).get(e);s==null||s(),n(this,an).delete(e)}terminate(){for(const[,t]of n(this,an))t==null||t();n(this,an).clear()}}an=new WeakMap,cf=new WeakMap;const Zd={DATA:1,ERROR:2},Xt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Vm(){}function $e(p){if(p instanceof jr||p instanceof op||p instanceof ap||p instanceof Xu||p instanceof Qf)return p;switch(p instanceof Error||typeof p=="object"&&p!==null||st('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),p.name){case"AbortException":return new jr(p.message);case"InvalidPDFException":return new op(p.message);case"PasswordException":return new ap(p.message,p.code);case"ResponseException":return new Xu(p.message,p.status,p.missing);case"UnknownErrorException":return new Qf(p.message,p.details)}return new Qf(p.message,p.toString())}var Sl,Us,Jb,Zb,ty,bu;class Rh{constructor(t,e,s){m(this,Us);m(this,Sl,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,Us,Jb).bind(this),{signal:n(this,Sl).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)}
7sendWithPromise(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:Xt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{Bt(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:Xt.CANCEL,streamId:r,reason:$e(h)}),c.promise}},s)}destroy(){var t;(t=n(this,Sl))==null||t.abort(),f(this,Sl,null)}}Sl=new WeakMap,Us=new WeakSet,Jb=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){b(this,Us,ty).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===Zd.DATA)i.resolve(t.data);else if(t.callback===Zd.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:Zd.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:Zd.ERROR,callbackId:t.callbackId,reason:$e(a)})});return}if(t.streamId){b(this,Us,Zb).call(this,t);return}e(t.data)},Zb=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 u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:Xt.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Xt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){Bt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:Xt.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:Xt.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Xt.START_COMPLETE,streamId:e,reason:$e(h)})})},ty=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 Xt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject($e(t.reason));break;case Xt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject($e(t.reason));break;case Xt.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:Xt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||Vm).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Xt.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Xt.PULL_COMPLETE,streamId:e,reason:$e(h)})});break;case Xt.ENQUEUE:if(Bt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Xt.CLOSE:if(Bt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,Us,bu).call(this,a,e);break;case Xt.ERROR:Bt(a,"error should have stream controller"),a.controller.error($e(t.reason)),b(this,Us,bu).call(this,a,e);break;
7case Xt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject($e(t.reason)),b(this,Us,bu).call(this,a,e);break;case Xt.CANCEL:if(!o)break;const l=$e(t.reason);Promise.try(o.onCancel||Vm,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:Xt.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:Xt.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")}},bu=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 df;class ey{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){m(this,df,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:st(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const i=`${s}${e}`;return this._fetch(i,t).catch(r=>{throw new Error(`Unable to load ${n(this,df)[t]} data at: ${i}`)})}async _fetch(t,e){st("Abstract method `_fetch` called.")}}df=new WeakMap;class Wm extends ey{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await im(t,s);return i instanceof Uint8Array?i:Lf(i)}}var Nc;class sy{constructor({enableHWA:t=!1}){m(this,Nc,!1);f(this,Nc,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!n(this,Nc)})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){st("Abstract method `_createCanvas` called.")}}Nc=new WeakMap;class M0 extends sy{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 iy{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 Ma,El,on,xi,le,Da,fr,I,re,Oh,hi,yu,Vr,ny,Gp,Wr,Nh,Bh,jp,Hh,ry,$p,ay;class D0 extends iy{constructor({docId:e,ownerDocument:s=globalThis.document}){super();m(this,I);m(this,Ma);m(this,El);m(this,on);m(this,xi);m(this,le);m(this,Da);m(this,fr,0);f(this,xi,e),f(this,le,s)}addFilter(e){if(!e)return"none";let s=n(this,I,re).get(e);if(s)return s;const[i,r,a]=b(this,I,yu).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,I,re).get(o),s)return n(this,I,re).set(e,s),s;const l=`g_${n(this,xi)}_transfer_map_${It(this,fr)._++}`,h=b(this,I,Vr).call(this,l);n(this,I,re).set(e,h),n(this,I,re).set(o,h);const c=b(this,I,Wr).call(this,l);return b(this,I,Bh).call(this,i,r,a,c),h}addHCMFilter(e,s){var y;const i=`${e}-${s}`,r="base";let a=n(this,I,Oh).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,Oh).set(r,a)),!e||!s))return a.url;const o=b(this,I,Hh).call(this,e);e=D.makeHexColor(...o);const l=b(this,I,Hh).call(this,s);if(s=D.makeHexColor(...l),b(this,I,$p).call(this),e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=Array.from({length:256},(A,S)=>fp(S/255)).join(","),d=`g_${n(this,xi)}_hcm_filter`,u=a.filter=b(this,I,Wr).call(this,d);b(this,I,Bh).call(this,c,c,c,u),b(this,I,Gp).call(this,u);const g=(A,S)=>{const w=o[A]/255,v=l[A]/255,E=new Array(S+1);for(let x=0;x<=S;x++)E[x]=w+x/S*(v-w);return E.join(",")};return b(this,I,Bh).call(this,g(0,5),g(1,5),g(2,5),u),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"||!gt.platform.isFirefox?null:{"backdrop-filter":s,"background-color":"transparent"}}addAlphaFilter(e){let s=n(this,I,re).get(e);if(s)return s;const[i]=b(this,I,yu).call(this,[e]),r=`alpha_${i}`;if(s=n(this,I,re).get(r),s)return n(this,I,re).set(e,s),s;const a=`g_${n(this,xi)}_alpha_map_${It(this,fr)._++}`,o=b(this,I,Vr).call(this,a);n(this,I,re).set(e,o),n(this,I,re).set(r,o);const l=b(this,I,Wr).call(this,a);return b(this,I,jp).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,I,re).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=b(this,I,yu).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,I,re).get(r),s)return n(this,I,re).set(e,s),s;const a=`g_${n(this,xi)}_luminosity_map_${It(this,fr)._++}`,o=b(this,I,Vr).call(this,a);n(this,I,re).set(e,o),n(this,I,re).set(r,o);const l=b(this,I,Wr).call(this,a);return b(this,I,ny).call(this,l),e&&b(this,I,jp).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,re).get(i);if(r)return r;const a=`g_${n(this,xi)}_knockout_filter_${It(this,fr)._++}`,o=b(this,I,Vr).call(this,a);n(this,I,re).set(i,o);const l=b(this,I,Wr).call(this,a),h=n(this,le).createElementNS(Be,"feComponentTransfer");l.append(h);const c=n(this,le).createElementNS(Be,"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 v;const o=`${s}-${i}-${r}-${a}`;let l=n(this,I,Oh).get(e);if((l==null?void 0:l.key)===o||(l?((v=l.filter)==null||v.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},n(this,I,Oh).set(e,l)),!s||!i))return l.url;const[h,c]=[s,i].map(b(this,I,Hh).bind(this));let d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[g,y]=[r,a].map(b(this,I,ay).bind(this));u<d&&([d,u,g,y]=[u,d,y,g]),b(this,I,$p).call(this);const A=(E,x,C)=>{const _=new Array(256),k=(u-d)/C,P=E/255,M=(x-E)/(255*C);let L=0;for(let N=0;N<=C;N++){const tt=Math.round(d+N*k),Q=P+N*M;for(let Z=L;Z<=tt;Z++)_[Z]=Q;L=tt+1}for(let N=L;N<256;N++)_[N]=_[L-1];return _.join(",")},S=`g_${n(this,xi)}_hcm_${e}
7_filter`,w=l.filter=b(this,I,Wr).call(this,S);return b(this,I,Gp).call(this,w),b(this,I,Bh).call(this,A(g[0],y[0],5),A(g[1],y[1],5),A(g[2],y[2],5),w),l.url=b(this,I,Vr).call(this,S),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,Da))!=null&&s.size)||((i=n(this,on))==null||i.parentNode.parentNode.remove(),f(this,on,null),(r=n(this,El))==null||r.clear(),f(this,El,null),(a=n(this,Da))==null||a.clear(),f(this,Da,null),f(this,fr,0))}}Ma=new WeakMap,El=new WeakMap,on=new WeakMap,xi=new WeakMap,le=new WeakMap,Da=new WeakMap,fr=new WeakMap,I=new WeakSet,re=function(){return n(this,El)||f(this,El,new Map)},Oh=function(){return n(this,Da)||f(this,Da,new Map)},hi=function(){if(!n(this,on)){const e=n(this,le).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,le).createElementNS(Be,"svg");i.setAttribute("width",0),i.setAttribute("height",0),f(this,on,n(this,le).createElementNS(Be,"defs")),e.append(i),i.append(n(this,on)),n(this,le).body.append(e)}return n(this,on)},yu=function(e){if(e.length===1){const h=e[0],c=new Array(256);for(let u=0;u<256;u++)c[u]=h[u]/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,Ma)===void 0){f(this,Ma,"");const s=n(this,le).URL;s!==n(this,le).baseURI&&(Ff(s)?Y('#createUrl: ignore "data:"-URL for performance reasons.'):f(this,Ma,cb(s,"")))}return`url(${n(this,Ma)}#${e})`},ny=function(e){const s=n(this,le).createElementNS(Be,"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)},Gp=function(e){const s=n(this,le).createElementNS(Be,"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)},Wr=function(e){const s=n(this,le).createElementNS(Be,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,I,hi).append(s),s},Nh=function(e,s,i){const r=n(this,le).createElementNS(Be,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},Bh=function(e,s,i,r){const a=n(this,le).createElementNS(Be,"feComponentTransfer");r.append(a),b(this,I,Nh).call(this,a,"feFuncR",e),b(this,I,Nh).call(this,a,"feFuncG",s),b(this,I,Nh).call(this,a,"feFuncB",i)},jp=function(e,s){const i=n(this,le).createElementNS(Be,"feComponentTransfer");
7s.append(i),b(this,I,Nh).call(this,i,"feFuncA",e)},Hh=function(e){return n(this,I,hi).style.color="CanvasText",n(this,I,hi).style.backgroundColor=e,Yd(getComputedStyle(n(this,I,hi)).getPropertyValue("background-color"))},ry=function(e){return n(this,I,hi).style.color="CanvasText",n(this,I,hi).style.backgroundColor=e,Xd(getComputedStyle(n(this,I,hi)).getPropertyValue("background-color"))},$p=function(){n(this,I,hi).style.color="",n(this,I,hi).style.backgroundColor=""},ay=function(e){const[s,i,r,a]=b(this,I,ry).call(this,e);if(a===1)return[s,i,r];const[o,l,h]=b(this,I,Hh).call(this,"Canvas");return[ep(s,o,a),ep(i,l,a),ep(r,h,a)]};function ep(p,t,e){return Math.round(e*p+(1-e)*t)}ms&&Y("Please use the `legacy` build in Node.js environments.");async function I0(p){const e=await process.getBuiltinModule("fs/promises").readFile(p);return new Uint8Array(e)}class L0 extends iy{}class F0 extends sy{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class R0 extends ey{async _fetch(t,e){return I0(t)}}function oy({src:p,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=gt.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,d=s&7,u=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 v=p[t];e[y]=l^-(v>>7&1)&u,e[y+1]=l^-(v>>6&1)&u,e[y+2]=l^-(v>>5&1)&u,e[y+3]=l^-(v>>4&1)&u,e[y+4]=l^-(v>>3&1)&u,e[y+5]=l^-(v>>2&1)&u,e[y+6]=l^-(v>>1&1)&u,e[y+7]=l^-(v&1)&u}if(d===0)continue;const S=t<g?p[t++]:255;for(let w=0;w<d;++w,++y)e[y]=l^-(S>>7-w&1)&u}return{srcPos:t,destPos:y}}function O0({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=gt.isLittleEndian?4278190080:255;if(gt.isLittleEndian){for(;a<l-2;a+=3,s+=4){const d=h[a],u=h[a+1],g=h[a+2];e[s]=d|c,e[s+1]=d>>>24|u<<8|c,e[s+2]=u>>>16|g<<16|c,e[s+3]=g>>>8|c}for(let d=a*4,u=t+o;d<u;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],u=h[a+1],g=h[a+2];e[s]=d|c,e[s+1]=d<<24|u>>>8|c,e[s+2]=u<<16|g>>>16|c,e[s+3]=g<<8|c}for(let d=a*4,u=t+o;d<u;d+=3)e[s++]=p[d]<<24|p[d+1]<<16|p[d+2]<<8|c}return{srcPos:t+o,destPos:s}}const N0=`
8struct Uniforms {
9  offsetX      : f32,
10  offsetY      : f32,
11  scaleX       : f32,
12  scaleY       : f32,
13  paddedWidth  : f32,
14  paddedHeight : f32,
15  borderSize   : f32,
16  _pad         : f32,
17};
18
19@group(0) @binding(0) var<uniform> u : Uniforms;
20
21struct VertexInput {
22  @location(0) position : vec2<f32>,
23  @location(1) color    : vec4<f32>,
24};
25
26struct VertexOutput {
27  @builtin(position) position : vec4<f32>,
28  @location(0)       color    : vec3<f32>,
29};
30
31@vertex
32fn vs_main(in : VertexInput) -> VertexOutput {
33  var out : VertexOutput;
34  let cx = (in.position.x + u.offsetX) * u.scaleX;
35  let cy = (in.position.y + u.offsetY) * u.scaleY;
36  out.position = vec4<f32>(
37    ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
38    1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
39    0.0,
40    1.0
41  );
42  out.color = in.color.rgb;
43  return out;
44}
45
46@fragment
47fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
48  return vec4<f32>(in.color, 1.0);
49}
50`;var uf,ln,Ia,xl,ff,ly;class B0{constructor(){m(this,ff);m(this,uf,null);m(this,ln,null);m(this,Ia,null);m(this,xl,null)}init(){return n(this,uf)||f(this,uf,b(this,ff,ly).call(this))}get isReady(){return n(this,ln)!==null}loadMeshShader(){if(!n(this,ln)||n(this,Ia))return;const t=n(this,ln).createShaderModule({code:N0});f(this,Ia,n(this,ln).createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:2*4,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:n(this,xl)}]},primitive:{topology:"triangle-list"}}))}draw(t,e,s,i,r,a,o,l){this.loadMeshShader();const h=n(this,ln),{offsetX:c,offsetY:d,scaleX:u,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 S=h.createBuffer({size:8*4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h.queue.writeBuffer(S,0,new Float32Array([c,d,u,g,a,o,l,0]));const w=h.createBindGroup({layout:n(this,Ia).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:S}}]}),v=new OffscreenCanvas(a,o),E=v.getContext("webgpu");E.configure({device:h,format:n(this,xl),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,Ia)),_.setBindGroup(0,w),_.setVertexBuffer(0,y),_.setVertexBuffer(1,A),_.draw(s)),_.end(),h.queue.submit([C.finish()]),y.destroy(),A.destroy(),S.destroy(),v.transferToImageBitmap()}}uf=new WeakMap,ln=new WeakMap,Ia=new WeakMap,xl=new WeakMap,ff=new WeakSet,ly=async function(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{const e=await navigator.gpu.requestAdapter();
50return e?(f(this,xl,navigator.gpu.getPreferredCanvasFormat()),f(this,ln,await e.requestDevice()),!0):!1}catch{return!1}};const Rf=new B0;function H0(){return Rf.init()}function U0(){return Rf.isReady}function G0(){Rf.loadMeshShader()}function j0(p,t,e,s,i,r,a,o){return Rf.draw(p,t,e,s,i,r,a,o)}const ye={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Au(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 om{constructor(){T(this,"matrix",null)}isModifyingCurrentTransform(){return!1}getPattern(){st("Abstract method `getPattern` called.")}}class $0 extends om{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===ye.STROKE||i===ye.FILL){if(this.isOriginBased()){let u=D.transform(s,e.baseTransform);this.matrix&&(u=D.transform(u,this.matrix));const g=.001,y=Math.hypot(u[0],u[1]),A=Math.hypot(u[2],u[3]),S=(u[0]*u[2]+u[1]*u[3])/(y*A);if(Math.abs(S)<g)if(this.isRadial()){if(Math.abs(y-A)<g)return this._createGradient(t,u)}else return this._createGradient(t,u)}const a=e.current.getClippedPathBoundingBox(i,vt(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),Au(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(),Au(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),Au(t,this._bbox),r=this._createGradient(t);return r}}function z0(p,t,e,s,i,r,a,o){const l=t.coords,h=t.colors,c=p.data,d=p.width*4;let u;l[e*2+1]>l[s*2+1]&&(u=e,e=s,s=u,u=r,r=a,a=u),l[s*2+1]>l[i*2+1]&&(u=s,s=i,i=u,u=a,a=o,o=u),l[e*2+1]>l[s*2+1]&&(u=e,e=s,s=u,u=r,r=a,a=u);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,S=(l[s*2+1]+t.offsetY)*t.scaleY,w=(l[i*2]+t.offsetX)*t.scaleX,v=(l[i*2+1]+t.offsetY)*t.scaleY;if(y>=v)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],tt=Math.round(y),Q=Math.round(v);let Z,$t,F,H,Ct,_t,Me,de;for(let Wt=tt;Wt<=Q;Wt++){if(Wt<S){const At=Wt<y?0:(y-Wt)/(y-S);Z=g-(g-A)*At,$t=E-(E-_)*At,F=x-(x-k)*At,H=C-(C-P)*At}else{let At;Wt>v?At=1:S===v?At=0:At=(S-Wt)/(S-v),Z=A-(A-w)*At,$t=_-(_-M)*At,F=k-(k-L)*At,H=P-(P-N)*At}let ht;Wt<y?ht=0:Wt>v?ht=1:ht=(y-Wt)/(y-v),Ct=g-(g-w)*ht,_t=E-(E-M)*ht,Me=x-(x-L)*ht,de=C-(C-N)*ht;const ai=Math.round(Math.min(Z,Ct)),Eh=Math.round(Math.max(Z,Ct));let ne=d*Wt+ai*4;for(let At=ai;At<=Eh;At++)ht=(Z-At)/(Z-Ct),ht<0?ht=0:ht>
501&&(ht=1),c[ne++]=$t-($t-_t)*ht|0,c[ne++]=F-(F-Me)*ht|0,c[ne++]=H-(H-de)*ht|0,c[ne++]=255}}class V0 extends om{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],G0()}_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,u=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3)||1,g=h?h/d:1,y=c?c/u:1,A={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/y},S=d+2*2,w=u+2*2,v=s.create(S,w);if(U0()&&this._vertexCount>48)v.context.drawImage(j0(this._posData,this._colData,this._vertexCount,A,e,S,w,2),0,0);else{const E=v.context.createImageData(d,u);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)z0(E,A,x,x+1,x+2,x,x+1,x+2);v.context.putImageData(E,2,2)}return{canvas:v.canvas,offsetX:o-2*g,offsetY:l-2*y,scaleX:g,scaleY:y}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){Au(t,this._bbox);const r=new Float32Array(2);if(i===ye.SHADING)D.singularValueDecompose2dScale(vt(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===ye.SHADING?null:this._background,e.canvasFactory);i!==ye.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 W0 extends om{getPattern(){return"hotpink"}}function X0(p){switch(p[0]){case"RadialAxial":return new $0(p);case"Mesh":return new V0(p);case"Dummy":return new W0}throw new Error(`Unknown IR type: ${p[0]}`)}const Xm={COLORED:1,UNCOLORED:2},pf=class pf{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,u=Math.ceil((s+t-r)/h)-1,g=Math.floor((i-l)/c)+1,y=Math.ceil((i+e-a)/c)-1;return u<=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 u,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(),(u=d.dependencyTracker)==null||u.save(),this.clipBbox(d,r,a,o,l),d.baseTransform=vt(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 ec(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 u=h-o,g=c-l,[y,A]=this._getCombinedScales(),S=this.getSizeAndScale(u,this.ctx.canvas.width,y),w=this.getSizeAndScale(g,this.ctx.canvas.height,A),v=this._renderTileCanvas(t,a,S,w);t.ctx.drawImage(v.canvas,o,l,u,g),t.canvasFactory.destroy(v)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,o,l,h,c),t.baseTransformStack.push(t.baseTransform),t.baseTransform=vt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();
50t.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),If("TilingType: "+this.tilingType);const[d,u]=this._getCombinedScales();let g=o,y=l,A=!1,S=!1;Math.ceil(h*d)>=Math.ceil(o*d)?g=h:A=!0,Math.ceil(c*u)>=Math.ceil(l*u)?y=c:S=!0;const w=this.getSizeAndScale(g,this.ctx.canvas.width,d),v=this.getSizeAndScale(y,this.ctx.canvas.height,u),E=this._renderTileCanvas(t,e,w,v);if(A||S){const x=E.canvas;A&&(g=h),S&&(y=c);const C=this.getSizeAndScale(g,this.ctx.canvas.width,d),_=this.getSizeAndScale(y,this.ctx.canvas.height,u),k=C.size,P=_.size,M=t.canvasFactory.create(k,P),L=M.context,N=A?Math.floor(o/h):0,tt=S?Math.floor(l/c):0;for(let Q=0;Q<=N;Q++)for(let Z=0;Z<=tt;Z++)L.drawImage(x,k*Q,P*Z,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:v.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){const i=Math.max(pf.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],vt(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 Xm.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case Xm.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new XA(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){const a=i!==ye.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(pf,"MAX_PATTERN_SIZE",3e3);let qh=pf;const Y0=16,K0=100,q0=15,Ym=10,Qe=16,bs=new Float32Array(2);function Km(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 tu(p,t,e,s,i,r,a,o,l,h){const[c,d,u,g,y,A]=vt(p);if(d===0&&u===0){const v=a*c+y,E=Math.round(v),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,u,g,y,A),[k,M]}if(c===0&&g===0){const v=o*u+y,E=Math.round(v),x=a*d+A,C=Math.round(x),_=(o+h)*u+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(u),0,E,C),p.drawImage(t,e,s,i,r,0,0,M,k),p.setTransform(c,d,u,g,y,A),[M,k]}p.drawImage(t,e,s,i,r,a,o,l,h);const S=Math.hypot(c,d),w=Math.hypot(u,g);return[S*l,w*h]}class qm{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",np);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",Zt.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",ta.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=ye.FILL,e=null){const s=this.minMax.slice();if(t===ye.STROKE){e||st("Stroke bounding box must include transform."),D.singularValueDecompose2dScale(e,bs);const i=bs[0]*this.lineWidth/2,r=bs[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(ta,
500)}getClippedPathBoundingBox(t=ye.FILL,e=null){return D.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Qm(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 u;if(i===au.GRAYSCALE_1BPP)for(u=0;u<o;u++)({srcPos:h}=oy({src:c,srcPos:h,dest:d,width:e,height:u<a?Qe:r})),p.putImageData(l,0,u*Qe);else if(i===au.RGBA_32BPP){let g=0,y=e*Qe*4;for(u=0;u<a;u++)d.set(c.subarray(h,h+y)),h+=y,p.putImageData(l,0,g),g+=Qe;u<o&&(y=e*r*4,d.set(c.subarray(h,h+y)),p.putImageData(l,0,g))}else if(i===au.RGB_24BPP)for(u=0;u<o;u++)({srcPos:h}=O0({src:c,srcPos:h,dest:new Uint32Array(d.buffer),width:e,height:u<a?Qe:r})),p.putImageData(l,0,u*Qe);else throw new Error(`bad image kind: ${i}`)}function Jm(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}=oy({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 eu(p){p.strokeStyle=p.fillStyle="#000000",p.fillRule="nonzero",p.globalAlpha=1,p.lineWidth=1,p.lineCap="butt",p.lineJoin="miter",p.miterLimit=10,p.globalCompositeOperation="source-over",p.font="10px sans-serif",p.setLineDash!==void 0&&(p.setLineDash([]),p.lineDashOffset=0);const{filter:t}=p;t!=="none"&&t!==""&&(p.filter="none")}function Zm(p,t){if(t)return!0;D.singularValueDecompose2dScale(p,bs);const e=Math.fround(ri.pixelRatio*$r.PDF_TO_CSS_UNITS);return bs[0]<=e&&bs[1]<=e}const Q0=["butt","round","square"],J0=["miter","round","bevel"],Z0={},tb={};var gf,is,pr,La,Fa,Ra,Oa,Na,Ba,Ha,Ci,U,zp,Vp,Wp,Xp,Yp,je,Se,Kp,hy,wu;const Qr=class Qr{constructor(t,e,s,i,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c,d){m(this,U);m(this,is,0);m(this,pr,0);m(this,La,null);m(this,Fa,null);m(this,Ra,null);m(this,Oa,null);m(this,Na,1);m(this,Ba);m(this,Ha,null);m(this,Ci,[]);this.ctx=t,this.current=new qm(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(...vt(this.compositeCtx))}this.ctx.save(),eu(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=vt(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>Ym&&typeof s=="function",d=c?Date.now()+q0:0;let u=0;const g=this.commonObjs,y=this.objs;let A,S;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],S=a[l]??null,A!==di.dependency)S===null?this[A](l):this[A](l,...S);else for(const v of S){(w=this.dependencyTracker)==null||w.recordNamedData(v,l);const E=v.startsWith("g_")?g:y;if(!E.has(v))return E.get(v,s),l}if(l++,l===h)return l;if(c&&++u>Ym){if(Date.now()>d)return s(),l;u=0}}}endDrawing(){b(this,U,zp).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,Ci))b(this,U,wu).call(this,t);n(this,Ci).length=0,f(this,La,null),f(this,Fa,null),f(this,Ra,null),f(this,Oa,null),f(this,Na,1),f(this,Ha,null),f(this,pr,0),f(this,is,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,Vp).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,v=d;l>2&&c>1&&(w=Math.ceil(c/2),l/=c/w),h>2&&d>1&&(v=Math.ceil(d/2),h/=d/v),o.push({newWidth:w,newHeight:v}),c=w,d=v}if(o.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(o.length===1){const{newWidth:w,newHeight:v}=o[0],E=this.canvasFactory.create(w,v);return E.context.drawImage(t,0,0,s,i,0,0,w,v),{img:E.canvas,paintWidth:w,paintHeight:v,tmpCanvas:E}}let u=this.canvasFactory.create(1,1),g=this.canvasFactory.create(1,1),y=s,A=i,S=t;for(const{newWidth:w,newHeight:v}of o)this.canvasFactory.reset(g,w,v),g.context.drawImage(S,0,0,y,A,0,0,w,v),[u,g]=[g,u],S=u.canvas,y=w,A=v;return this.canvasFactory.destroy(g),{img:u.canvas,paintWidth:y,paintHeight:A,tmpCanvas:u}}_createMaskCanvas(t,e){var N,tt;const s=this.ctx,{width:i,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=vt(s);let h,c,d,u;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,em);const Z=h.get(c);if(Z&&!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,Es.transformAndFill),{canvas:Z,offsetX:$t,offsetY:F}}d=Z}d||(u=this.canvasFactory.create(i,r),Jm(u.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=ta.slice();D.axialAlignedBoundingBox([0,0,i,r],g,y);const[A,S,w,v]=y,E=Math.round(w-A)||1,x=Math.round(v-S)||1,C=this.canvasFactory.create(E,x),_=C.context,k=A,P=S;_.translate(-k,-P),_.transform(...g);let M=null;if(!d){const Q=this._scaleImage(u.canvas,oi(_));d=Q.img,M=Q.tmpCanvas,d!==u.canvas&&(this.canvasFactory.destroy(u),u=null),h&&o&&(h.set(c,d),M=null,u=null)}_.imageSmoothingEnabled=Zm(vt(_),e.interpolate),tu(_,d,0,0,d.width,d.height,0,0,i,r),M&&this.canvasFactory.destroy(M),u&&this.canvasFactory.destroy(u),_.globalCompositeOperation="source-in";const L=D.transform(oi(_),[1,0,0,1,-k,-P]);return _.fillStyle=o?a.getPattern(s,this,L,ye.FILL,t):a,_.fillRect(0,0,i,r),h&&!o&&h.set(c,C.canvas),(tt=this.dependencyTracker)==null||tt.recordDependencies(t,Es.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=Q0[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=J0[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)}
50setRenderingIntent(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;if(!a&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=t;return}let o;if(s==="Luminosity"&&i){const[v,E,x]=Xd(i),C=Math.round(.3*v+.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,u=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,S,w;u?(A=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,h,c,y,g),S=0,w=0):(A=this._bakeSMaskCanvas(e,0,0,e.width,e.height,y,g),S=t.offsetX,w=t.offsetY),this.smaskPreparedEntry=A,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=S,this.smaskPreparedOffsetY=w,this.smaskPreparedOOBAlpha=!u&&o!==0?o:null}_bakeSMaskCanvas(t,e,s,i,r,a,o){!a&&!o&&st("_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 u=gt.isCanvasFilterSupported&&d.filter!=="none"&&d.filter!=="";if(d.drawImage(l.canvas,0,0),gt.isCanvasFilterSupported&&(d.filter="none"),!u){const g=d.getImageData(0,0,i,r),{data:y}=g,{transferMap:A}=o;if(o.subtype==="Luminosity")for(let S=0,w=y.length;S<w;S+=4){const v=.3*y[S]+.59*y[S+1]+.11*y[S+2]+.5|0;y[S]=y[S+1]=y[S+2]=0,y[S+3]=(A==null?void 0:A[v])??v}else for(let S=3,w=y.length;S<w;S+=4)y[S]=A[y[S]];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),Km(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,pr)>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(
50))}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,u=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 S=Math.min(r+o,e.offsetX+e.canvas.width),w=Math.min(a+l,e.offsetY+e.canvas.height);u=S-c,g=w-d}if(u>0&&g>0){const S=c-this.smaskPreparedOffsetX,w=d-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(c,d,u,g),s.clip(v),s.globalCompositeOperation="destination-in",s.drawImage(h.canvas,S,w,u,g,c,d,u,g),s.restore()}A&&y<255&&this._applySMaskOOBAlpha(s,r,a,o,l,c,d,c+u,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 u=new Path2D;u.rect(e,s,i,r),d&&u.rect(a,o,l-a,h-o),t.save(),t.globalAlpha=c/255,t.setTransform(1,0,0,1,0,0),t.clip(u,"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()}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!==di.stroke&&e!==di.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,r);return}if(this.dependencyTracker!==null){const o=e===di.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]=fb(r)),D.axialAlignedBoundingBox(i,vt(this.ctx),this.current.minMax);const a=this.current.tilingPatternDims;if(a&&e!==di.stroke&&e!==di.closeStroke&&this.current.fillColor instanceof qh){const o=D.intersect(this.current.clipBox,this.current.minMax);o?this.current.fillColor.updatePatternDims(o,a):this.current.tilingPatternDims=null}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var o;const i=s&&b(this,U,je).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,oi(r),ye.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,Es.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(ye.STROKE,vt(this.ctx))),r.globalAlpha=this.current.fillAlpha,b(this,U,Se).call(this,i)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var c,d,u;const i=s&&b(this,U,je).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,Es.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,Se).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,oi(r),ye.FILL,t),A){const S=new Path2D;S.addPath(e,r.getTransform().invertSelf().multiplySelf(A)),e=S}l=!0}this.contentVisible&&h!==null&&(this.pendingEOFill?(r.fill(e,"evenodd"),this.pendingEOFill=!1):r.fill(e)),l&&(r.restore(
50),(u=this.dependencyTracker)==null||u.restore(t)),s&&this.consumePath(t,e,h),b(this,U,Se).call(this,i)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const s=b(this,U,je).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,Se).call(this,s)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var i;const s=b(this,U,je).call(this,this.current.fillAlpha);this.ctx.fill(e),(i=this.dependencyTracker)==null||i.recordDependencies(t,Es.rawFillPath).recordOperation(t),b(this,U,Se).call(this,s)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=Z0}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=tb}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker: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,u;(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||np,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&Y("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=((u=i.systemFontInfo)==null?void 0:u.css)||`"${a}", ${i.fallbackName}`;let l="normal";i.black?l="900":i.bold&&(l="bold");const h=i.italic?"italic":"normal",c=xt(s,Y0,K0);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,v,E,x;const o=this.ctx,l=this.current,h=l.font,c=l.textRenderingMode,d=l.fontSize/l.fontSizeScale,u=c&Zt.FILL_STROKE_MASK,g=!!(c&Zt.ADD_TO_PATH_FLAG),y=l.patternFill&&!h.missingFile,A=l.patternStroke&&!h.missingFile;let S;if((h.disableFontFace||g||y||A)&&!h.missingFile&&(S=h.getPathGenerator(this.commonObjs,e)),S&&(h.disableFontFace||y||A)){o.save(),o.translate(s,i),o.scale(d,-d
50),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,o,h);let C;if(u===Zt.FILL||u===Zt.FILL_STROKE)if(r){C=o.getTransform(),o.setTransform(...r);const _=b(this,U,Kp).call(this,S,C,r);o.fill(_)}else o.fill(S);if(u===Zt.STROKE||u===Zt.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,bs),o.lineWidth*=Math.max(bs[0],bs[1])/d,o.stroke(b(this,U,Kp).call(this,S,C,a))}else o.lineWidth/=d,o.stroke(S);o.restore()}else(u===Zt.FILL||u===Zt.FILL_STROKE)&&(o.fillText(e,s,i),(v=this.dependencyTracker)==null||v.recordCharacterBBox(t,o,h,d,s,i,()=>o.measureText(e))),(u===Zt.STROKE||u===Zt.FILL_STROKE)&&(this.dependencyTracker&&((E=this.dependencyTracker)==null||E.recordCharacterBBox(t,o,h,d,s,i,()=>o.measureText(e)).recordDependencies(t,Es.stroke)),o.strokeText(e,s,i));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:vt(o),x:s,y:i,fontSize:d,path:S}),(x=this.dependencyTracker)==null||x.recordCharacterBBox(t,o,h,d,s,i))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let i=!1;for(let r=3;r<s.length;r+=4)if(s[r]>0&&s[r]<255){i=!0;break}return j(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var tt,Q,Z,$t;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Es.showText).resetBBox(t),this.current.textRenderingMode&Zt.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,je).call(this,s.fillAlpha);this.showType3Text(t,e),(tt=this.dependencyTracker)==null||tt.recordShowTextOperation(t),b(this,U,Se).call(this,F);return}const r=s.fontSize;if(r===0){(Q=this.dependencyTracker)==null||Q.recordOperation(t);return}const a=b(this,U,je).call(this,s.fillAlpha),o=this.ctx,l=s.fontSizeScale,h=s.charSpacing,c=s.wordSpacing,d=s.fontDirection,u=s.textHScale*d,g=e.length,y=i.vertical,A=y?1:-1,S=i.defaultVMetrics,w=r*s.fontMatrix[0],v=s.textRenderingMode===Zt.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(u,-1):o.scale(u,1);let E,x;const C=s.textRenderingMode&Zt.FILL_STROKE_MASK,_=C===Zt.FILL||C===Zt.FILL_STROKE,k=C===Zt.STROKE||C===Zt.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,oi(o),ye.FILL,t);E=vt(o),o.restore(),o.fillStyle=F}if(k&&s.patternStroke){o.save();const F=s.strokeColor.getPattern(o,this,oi(o),ye.STROKE,t);x=vt(o),o.restore(),o.strokeStyle=F}if(i.isInvalidPDFjsFont){const F=[];let H=0;for(const _t of e)F.push(_t.unicode),H+=_t.width;const Ct=F.join("");if(o.fillText(Ct,0,0),this.dependencyTracker!==null){const _t=o.measureText(Ct);this.dependencyTracker.recordBBox(t,this.ctx,-_t.actualBoundingBoxLeft,_t.actualBoundingBoxRight,-_t.actualBoundingBoxAscent,_t.actualBoundingBoxDescent).recordShowTextOperation(t)}
50s.x+=H*w*u,o.restore(),this.compose(),b(this,U,Se).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 Ct=(F.isSpace?c:0)+h,_t=F.fontChar,Me=F.accent;let de,Wt,ht=F.width;if(y){const ne=F.vmetric||S,At=-(F.vmetric?ne[1]:ht*.5)*w,zf=ne[2]*w;ht=ne?-ne[0]:ht,de=At/l,Wt=(L+zf)/l}else de=L/l,Wt=0;let ai;if(i.remeasure&&ht>0){ai=o.measureText(_t);const ne=ai.width*1e3/r*l;if(ht<ne&&this.isFontSubpixelAAEnabled){const At=ht/ne;H=!0,o.save(),o.scale(At,1),de/=At}else ht!==ne&&(de+=(ht-ne)/2e3*r/l)}if(this.contentVisible&&(F.isInFont||i.missingFile)){if(v&&!Me)o.fillText(_t,de,Wt),(Z=this.dependencyTracker)==null||Z.recordCharacterBBox(t,o,ai?{bbox:null}:i,r/l,de,Wt,()=>ai??o.measureText(_t));else if(this.paintChar(t,_t,de,Wt,E,x),Me){const ne=de+r*Me.offset.x/l,At=Wt-r*Me.offset.y/l;this.paintChar(t,Me.fontChar,ne,At,E,x)}}const Eh=y?ht*w-Ct*d:ht*w+Ct*d;L+=Eh,H&&o.restore()}y?s.y-=L:s.x+=L*u,o.restore(),this.compose(),($t=this.dependencyTracker)==null||$t.recordShowTextOperation(t),b(this,U,Se).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,u=i.fontMatrix||np,g=e.length,y=i.textRenderingMode===Zt.INVISIBLE;let A,S,w,v;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 ec(E,t):null,A=0;A<g;++A){if(S=e[A],typeof S=="number"){v=l*S*a/1e3,this.ctx.translate(v,0),i.x+=v*d;continue}const x=(S.isSpace?c:0)+h,C=r.charProcOperatorList.get(S.operatorListId);C?this.contentVisible&&(this.save(),C.fnArray[0]===di.setCharWidth&&(i.fillAlpha=i.strokeAlpha=1,s.globalAlpha=1),s.scale(a,a),s.transform(...u),this.executeOperatorList(C),this.restore()):Y(`Type3 character "${S.operatorListId}" is not available.`);const _=[S.width,0];D.applyTransform(_,u),w=_[0]*a+x,s.translate(w,0),i.x+=w*d}s.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||vt(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 ec(this.dependencyTracker,o,!0):null)};s=new qh(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 qh?[0,0,0,0]:null}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
50setStrokeTransparent(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,()=>X0(this.getObject(t,e)));return s&&(i.matrix=s),i}shadingFill(t,e){var o;if(!this.contentVisible)return;const s=b(this,U,je).call(this,this.current.fillAlpha),i=this.ctx;this.save(t);const r=this._getPattern(t,e);i.fillStyle=r.getPattern(i,this,oi(i),ye.SHADING,t);const a=oi(i);if(a){const{width:l,height:h}=i.canvas,c=ta.slice();D.axialAlignedBoundingBox([0,0,l,h],a,c);const[d,u,g,y]=c;this.ctx.fillRect(d,u,g-d,y-u)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Es.transform).recordDependencies(t,Es.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),b(this,U,Se).call(this,s)}beginInlineImage(){st("Should not call beginInlineImage")}beginImageData(){st("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=vt(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,is)===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,Ci).push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&n(this,is)===0&&If("TODO: Fully support non-isolated non-knockout groups.");const r=vt(i);e.matrix&&i.transform(...e.matrix);const a=[0,0,i.canvas.width,i.canvas.height];let o;e.bbox?(o=ta.slice(),D.axialAlignedBoundingBox(e.bbox,vt(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 u=this.canvasFactory.create(c,d);e.smask&&this.smaskGroupCanvases.push(u);const g=u.context,y=e.knockout&&!e.isolated?i:null,A=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&n(this,is)>0,S=e.knockout?this.canvasFactory.create(c,d):null,w=n(this,is);e.knockout?It(this,is)._++:f(this,is,0),g.translate(-l,-h),g.transform(...r);const v=!e.isolated&&!e.smask&&e.needsIsolation,E=v&&!s&&w===0&&!e.knockout&&!e.isGray&&e.hasSoftMask&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none";if(v&&(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:u.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,Ci).push({backdropCtx:y,savedKnockoutLevel:w,offsetX:l,offsetY:h,hasInnerBackdrop:A,replaceBackdrop:E,knockoutMaskEntry:S,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,Ci).pop();if(r&&f(this,is,r.savedKnockoutLevel),i===null){this.restore(t);return}if(e.isGray&&b(this,U,hy).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(
50),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),b(this,U,wu).call(this,r);else{this.ctx.restore();const o=vt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...o);const l=ta.slice();D.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],o,l);const h=n(this,Ci).at(-1);if(n(this,is)>0)if(r.hasInnerBackdrop){const{width:c,height:d}=s.canvas,u=this.canvasFactory.create(c,d),g=u.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,Wp).call(this,s.canvas);g.globalCompositeOperation="destination-in",g.drawImage(y.canvas,0,0);const A=this.ctx.globalCompositeOperation,S=this.ctx.globalAlpha,w=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...o),this.ctx.globalAlpha=1,gt.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(y.canvas,0,0),this.ctx.globalCompositeOperation=A,this.ctx.globalAlpha=S,gt.isCanvasFilterSupported&&(this.ctx.filter=w??"none"),this.ctx.drawImage(u.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(y),this.canvasFactory.destroy(u)}else{const c=(h==null?void 0:h.backdropCtx)??null;b(this,U,Yp).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,wu).call(this,r),this.compose(l)}}beginAnnotation(t,e,s,i,r,a,o){if(b(this,U,zp).call(this),eu(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const l=s[2]-s[0],h=s[3]-s[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],D.singularValueDecompose2dScale(vt(this.ctx),bs);const{viewportScale:c}=this,d=Math.ceil(l*this.outputScaleX*c),u=Math.ceil(h*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:g,context:y}=this.annotationCanvas;if(o){const A=this.annotationCanvasMap.getOrInsertComputed(e,Sh);g.setAttribute("data-canvas-name",o);const S=A.findIndex(w=>w.getAttribute("data-canvas-name")===o);S===-1?A.push(g):A[S]=g}else this.annotationCanvasMap.set(e,g);this.annotationCanvas.savedCtx=this.ctx,this.ctx=y,this.ctx.save(),this.ctx.setTransform(bs[0],0,0,-bs[1],0,h*bs[1]),eu(this.ctx)}else{eu(this.ctx),this.endPath(t);const c=new Path2D;c.rect(s[0],s[1],l,h),this.ctx.clip(c)}}this.current=new qm(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...r),this.baseTransform=vt(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),b(this,U,Vp).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,je).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,Se).call(this,i)}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,a,o){var u,g,y;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=b(this,U,je).call(this,this.current.fillAlpha),h=this.ctx;h.save();const c=vt(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]),(u=this.dependencyTracker)==null||u.resetBBox(t);for(let A=0,S=o.length;A<S;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)}
50h.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),(y=this.dependencyTracker)==null||y.recordOperation(t),b(this,U,Se).call(this,l)}paintImageMaskXObjectGroup(t,e){var o,l,h;if(!this.contentVisible)return;const s=b(this,U,je).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,Es.transformAndFill);for(const c of e){const{data:d,width:u,height:g,transform:y}=c,A=this.canvasFactory.create(u,g),S=A.context;S.save();const w=this.getObject(t,d,c);Jm(S,w),S.globalCompositeOperation="source-in",S.fillStyle=a?r.getPattern(S,this,oi(i),ye.FILL,t):r,S.fillRect(0,0,u,g),S.restore(),i.save(),i.transform(...y),i.scale(1,-1),tu(i,A.canvas,0,0,u,g,0,-1,1,1),this.canvasFactory.destroy(A),(l=this.dependencyTracker)==null||l.recordBBox(t,i,0,u,0,g),i.restore()}this.compose(),(h=this.dependencyTracker)==null||h.recordOperation(t),b(this,U,Se).call(this,s)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){Y("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){Y("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,je).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 u=this.applyTransferMapsToBitmap(e);l=u.img,h=u.canvasEntry}else{const u=this.canvasFactory.create(s,i);Qm(u.context,e),l=this.applyTransferMapsToCanvas(u.context),h=u}const c=this._scaleImage(l,oi(a));a.imageSmoothingEnabled=Zm(vt(a),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,a,0,s,-i,0).recordDependencies(t,Es.imageXObject).recordOperation(t),(d=this.imagesTracker)==null||d.record(a,s,i,this.dependencyTracker.clipBox)),tu(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,Se).call(this,r)}paintInlineImageXObjectGroup(t,e,s){var l,h,c;if(!this.contentVisible)return;const i=b(this,U,je).call(this,this.current.fillAlpha),r=this.ctx;let a,o=null;if(e.bitmap)a=e.bitmap;else{const d=e.width,u=e.height,g=this.canvasFactory.create(d,u);Qm(g.context,e),a=this.applyTransferMapsToCanvas(g.context),o=g}(l=this.dependencyTracker)==null||l.resetBBox(t);for(const d of s)r.save(),r.transform(...d.transform),r.scale(1,-1),tu(r,a,d.x,d.y,d.w,d.h,0,-1,1,1),(h=this.dependencyTracker)==null||h.recordBBox(t,r,0,1,-1,0),r.restore();o&&this.canvasFactory.destroy(o),(c=this.dependencyTracker)==null||c.recordOperation(t),this.compose(),b(this,U,Se).call(this,i)}paintSolidColorImageMask(t){var s;if(!this.contentVisible)return;const e=b(this,U,je).call(this,this.current.fillAlpha);(s=this.dependencyTracker)==null||s.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Es.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),b(this,U,Se).call(this,e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var 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===tb?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=vt(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,gf)??f(Qr,gf,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);
50s.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}};gf=new WeakMap,is=new WeakMap,pr=new WeakMap,La=new WeakMap,Fa=new WeakMap,Ra=new WeakMap,Oa=new WeakMap,Na=new WeakMap,Ba=new WeakMap,Ha=new WeakMap,Ci=new WeakMap,U=new WeakSet,zp=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)},Vp=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}}},Wp=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,Ba)===void 0&&f(this,Ba,gt.isCanvasFilterSupported?new Map:"none");let h="none";if(l&&n(this,Ba)instanceof Map&&(h=n(this,Ba).getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s))),!l||h!=="none")return e&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,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),u=c.data,g=d.data,y=s>0?1/s:1e6;for(let A=3,S=u.length;A<S;A+=4)g[A]=Math.min(Math.round(u[A]*y),255);return o.putImageData(d,0,0),a},Xp=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},Yp=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:u,height:g}=e,y=b(this,U,Wp).call(this,e,o,d),A=t.globalCompositeOperation;if(t.save(),t.setTransform(...r),t.globalAlpha=1,gt.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(y.canvas,0,0),i){const[S,w]=a,v=b(this,U,Xp).call(this,l,"knockoutBackdropEntry",u,g),E=v.context;E.drawImage(i,S,w,u,g,0,0,u,g),E.globalCompositeOperation="destination-in",E.drawImage(y.canvas,0,0),E.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(v.canvas,0,0),l||this.canvasFactory.destroy(v)}t.globalCompositeOperation=A,t.globalAlpha=h,gt.isCanvasFilterSupported&&(t.filter=c??"none"),t.drawImage(e,0,0),t.restore(),o||this.canvasFactory.destroy(y)},je=function(t=1){if(n(this,is)===0||n(this,pr)>0||!this.contentVisible)return!1;It(this,pr)._++,f(this,Na,t);const e=n(this,Ci).at(-1),{canvas:s}=this.ctx,i=b(this,U,Xp).call(this,e,"knockoutTempEntry",s.width,s.height);f(this,La,i);const r=i.context;return r.save(),r.setTransform(this.ctx.getTransform()),zr(this.ctx,r),f(this,Oa,r.globalCompositeOperation),r.globalCompositeOperation="source-over",Km(r,this.ctx),f(this,Ha,e),f(this,Fa,this.ctx),f(this,Ra,this.suspendedCtx),this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0},Se=function(t){var l;if(!t)return;const e=n(this,La),s=n(this,Fa),i=n(this,Ra),r=e.context;f(this,La,null),f(this,Fa,null),f(this,Ra,null),this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=i),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=n(this,Oa),f(this,Oa,null),zr(this.ctx,s),this.ctx=s;const a=n(this,Ha);f(this,Ha,null);const o=n(this,Na);f(this,Na,1);try{b(this,U,Yp).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,
50knockoutAlpha:o})}finally{r.restore(),It(this,pr)._--,a||this.canvasFactory.destroy(e)}},Kp=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i},hy=function(t){const{canvas:e}=t,{width:s,height:i}=e;if(gt.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)},wu=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,gf,null);let Vo=Qr;for(const p in di)Vo.prototype[p]!==void 0&&(Vo.prototype[di[p]]=Vo.prototype[p]);var Bc,Hc;class Of{constructor(t,e,s){m(this,Bc,null);m(this,Hc,null);T(this,"_fullReader",null);T(this,"_rangeReaders",new Set);T(this,"_source",null);this._source=t,f(this,Bc,e),f(this,Hc,s)}get _progressiveDataLength(){var t;return((t=this._fullReader)==null?void 0:t._loaded)??0}getFullReader(){return Bt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new(n(this,Bc))(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new(n(this,Hc))(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){var e;(e=this._fullReader)==null||e.cancel(t);for(const s of new Set(this._rangeReaders))s.cancel(t)}}Bc=new WeakMap,Hc=new WeakMap;class Nf{constructor(t){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(){st("Abstract method `read` called")}cancel(t){st("Abstract method `cancel` called")}}class Bf{constructor(t,e,s){T(this,"_stream",null);this._stream=t}async read(){st("Abstract method `read` called")}cancel(t){st("Abstract method `cancel` called")}}function tw(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 u=new TextDecoder(c,{fatal:!0}),g=Lf(d);d=u.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 u;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=g.exec(c))!==null;){let[,A,S,w]=u;if(A=parseInt(A,10),A in d){if(A===0)break;continue}d[A]=[S,w]}const y=[];for(let A=0;A<d.length&&A in d;++A){let[S,w]=d[A];w=o(w),S&&(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 u=0;u<d.length;++u){const g=d[u].indexOf('"');g!==-1&&(d[u]=d[u].slice(0,g),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function l(c){const d=c.indexOf("'");if(d===-1)return c;const u=c.slice(0,d),y=c.slice(d+1).replace(/^[^']*'/,"");return i(u,y)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,u,g,y){if(g==="q"||g==="Q")return y=y.replaceAll("_"," "),y=y.replaceAll(/=([0-9a-f]{2})/gi,function(A,S){return String.fromCharCode(parseInt(S,16))}),i(u,y);try{y=atob(y)}catch{}return i(u,y)})}return""}function cy(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 ew(p){let t=p.length;for(;t>0&&p[t-1]!==" "&&/\s/.test(p[t-1]);)t--;return p.slice(0,t)}function Hf(p){var t;return((t=URL.parse(p))==null?void 0:t.origin)??null}function dy({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 uy(p){const t=p.get("Content-Disposition");if(t){let e=tw(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(rm(e))return e}return null}
50function Uf(p,t){return new Xu(`Unexpected server response (${p}) while retrieving PDF "${t.href}".`,p,p===404||p===0&&t.protocol==="file:")}function fy(p,t){if(p!==t)throw new Error(`Expected range response-origin "${p}" to match "${t}".`)}function py(p,t,e,s){return fetch(p,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function gy(p,t){if(p!==200&&p!==206)throw Uf(p,t)}function Gf(p){if(p instanceof Uint8Array)return p.buffer;if(p instanceof ArrayBuffer)return p;throw new Error(`getArrayBuffer - unexpected data: ${p}`)}class sw extends Of{constructor(e){super(e,iw,nw);T(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;Bt(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=cy(!0,s)}}class iw extends Nf{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);py(a,l,o,this._abortController).then(h=>{e._responseOrigin=Hf(h.url),gy(h.status,a),this._reader=h.body.getReader();const c=h.headers,{contentLength:d,isRangeSupported:u}=dy({responseHeaders:c,isHttp:!0,rangeChunkSize:r,disableRange:s});this._contentLength=d,this._isRangeSupported=u,this._filename=uy(c),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new jr("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:Gf(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}class nw extends Bf{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}`),py(r,o,a,this._abortController).then(l=>{const h=Hf(l.url);fy(h,e._responseOrigin),gy(l.status,r),this._reader=l.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:Gf(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}function eb(p){return p instanceof Uint8Array&&p.byteLength===p.buffer.byteLength?p.buffer:new Uint8Array(p).buffer}function jf(){for(const p of this._requests)p.resolve({value:void 0,done:!0});this._requests.length=0}var mf,my;class rw extends Of{constructor(e){super(e,aw,ow);m(this,mf);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=eb(i);this._queuedChunks.push(o)}this._progressiveDone=r;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":b(this,mf,my).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()}}mf=new WeakSet,my=function(e,s){const i=eb(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);Bt(r,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),r._enqueue(i)}};var Uc;class aw extends Nf{constructor(e){super(e);m(this,Uc,jf.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,rm(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,Uc).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&n(this,Uc).call(this)}}Uc=new WeakMap;var Gc;class ow extends Bf{constructor(e,s,i){super(e,s,i);m(this,Gc,jf.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,Gc).call(this)),this._done=!0,(s=this.onDone)==null||s.call(this))}async read(){if(this._queuedChunk){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,n(this,Gc).call(this),(s=this.onDone)==null||s.call(this)}}Gc=new WeakMap;const sp=200,sb=206;function lw(p){return typeof p!="string"?p:Lf(p).buffer}var _i,vh,by,yy;class hw extends Of{constructor(e){super(e,cw,dw);m(this,vh);m(this,_i,new WeakMap);T(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=cy(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,_i).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===sb||r===sp):i.validateStatus=r=>r===sp,s.responseType="arraybuffer",Bt(e.onError,"Expected `onError` callback to be provided."),s.onerror=()=>e.onError(s.status),s.onreadystatechange=b(this,vh,yy).bind(this,s),s.onprogress=b(this,vh,by).bind(this,s),s.send(null),s}
50_abortRequest(e){n(this,_i).has(e)&&(n(this,_i).delete(e),e.abort())}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}_i=new WeakMap,vh=new WeakSet,by=function(e,s){var r;const i=n(this,_i).get(e);(r=i==null?void 0:i.onProgress)==null||r.call(i,s)},yy=function(e,s){const i=n(this,_i).get(e);if(!i||(e.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),e.readyState!==4)||!n(this,_i).has(e))return;if(n(this,_i).delete(e),e.status===0&&this.isHttp){i.onError(e.status);return}const r=e.status||sp;if(!i.validateStatus(r)){i.onError(e.status);return}const a=lw(e.response);if(r===sb){const o=e.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(o)?i.onDone(a):(Y('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone(a):i.onError(e.status)};var jc,Gi,Ay,wy,vy,Sy;class cw extends Nf{constructor(e){super(e);m(this,Gi);m(this,jc,jf.bind(this));T(this,"_cachedChunks",[]);T(this,"_done",!1);T(this,"_requests",[]);T(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:b(this,Gi,Ay).bind(this),onDone:b(this,Gi,wy).bind(this),onError:b(this,Gi,vy).bind(this),onProgress:b(this,Gi,Sy).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,jc).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}jc=new WeakMap,Gi=new WeakSet,Ay=function(){const e=this._stream,{disableRange:s,rangeChunkSize:i}=e._source,r=this._fullRequestXhr;e._responseOrigin=Hf(r.responseURL);const a=r.getAllResponseHeaders(),o=new Headers(a?ew(a.trimStart()).split(/[\r\n]+/).map(c=>{const[d,...u]=c.split(": ");return[d,u.join(": ")]}):[]),{contentLength:l,isRangeSupported:h}=dy({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:i,disableRange:s});this._contentLength=l,this._isRangeSupported=h,this._filename=uy(o),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()},wy=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,jc).call(this)},vy=function(e){this._storedError=Uf(e,this._stream.url),this._headersCapability.reject(this._storedError);for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0},Sy=function(e){var s;(s=this.onProgress)==null||s.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})};var $c,Fn,Ey,xy,qp;class dw extends Bf{constructor(e,s,i){super(e,s,i);m(this,Fn);m(this,$c,jf.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,Fn,Ey).bind(this),onDone:b(this,Fn,xy).bind(this),onError:b(this,Fn,qp).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,$c).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}$c=new WeakMap,Fn=new WeakSet,Ey=function(){var s;const e=Hf((s=this._requestXhr)==null?void 0:s.responseURL);try{fy(e,this._stream._responseOrigin)}catch(i){this._storedError=i,b(this,Fn,qp).call(this,0)}},xy=function(e){var s;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,n(this,$c).call(this),(s=this.onClosed)==null||s.call(this)},qp=function(e){this._storedError??(this._storedError=Uf(e,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function Cy(p,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),i=e.createReadStream(p,t);return s.toWeb(i)}class uw extends Of{constructor(t){super(t,fw,pw);const{url:e}=t;Bt(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class fw extends Nf{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 jr("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=Uf(0,a)),this._headersCapability.reject(l)})}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:Gf(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}class pw extends Bf{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:Gf(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}function gw(p){return Kh(p)?sw:ms?uw:hw}var zc,Vc;class Hi{static get workerPort(){return n(this,zc)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");f(this,zc,t)}static get workerSrc(){return n(this,Vc)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");f(this,Vc,t)}}zc=new WeakMap,Vc=new WeakMap,m(Hi,zc,null),m(Hi,Vc,"");var Cl,Wc;class mw{constructor({parsedData:t,rawData:e}){m(this,Cl);m(this,Wc);f(this,Cl,t),f(this,Wc,e)}getRaw(){return n(this,Wc)}get(t){return n(this,Cl).get(t)??null}[Symbol.iterator](){return n(this,Cl).entries()}}Cl=new WeakMap,Wc=new WeakMap;const Xr=Symbol("INTERNAL");var Xc,Yc,_l,Ua;class bw{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){m(this,Xc,!1);m(this,Yc,!1);m(this,_l,!1);m(this,Ua,!0);f(this,Xc,!!(t&gs.DISPLAY)),f(this,Yc,!!(t&gs.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,_l))return n(this,Ua);if(!n(this,Ua))return!1;const{print:t,view:e}=this.usage;return n(this,Xc)?(e==null?void 0:e.viewState)!=="OFF":n(this,Yc)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==Xr&&st("Internal method `_setVisible` called."),f(this,_l,s),f(this,Ua,e)}get serializable(){return{userSet:n(this,_l),visible:n(this,Ua)}}}Xc=new WeakMap,Yc=new WeakMap,_l=new WeakMap,Ua=new WeakMap;var gr,nt,Tl,kl,Kc,qc,Jp;const bm=class bm{constructor(t,e=gs.DISPLAY,s=null){m(this,qc);m(this,gr,null);m(this,nt,new Map);m(this,Tl,null);m(this,kl,null);m(this,Kc);T(this,"creator",null);T(this,"name",null);if(f(this,Kc,t),this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,f(this,kl,t.order);for(const i of t.groups)n(this,nt).set(i.id,new bw(e,i));if(s){s.size!==n(this,nt).size&&st("Incorrect serialized groupState.");for(const[i,r]of s)n(this,nt).get(i)._setVisible(Xr,r.visible,r.userSet)}else{if(t.baseState==="OFF")for(const i of n(this,nt).values())i._setVisible(Xr,!1);for(const i of t.on)n(this,nt).get(i)._setVisible(Xr,!0);for(const i of t.off)n(this,nt).get(i)._setVisible(Xr,!1)}f(this,Tl,this.getHash())}}isVisible(t){if(n(this,nt).size===0)return!0;
50if(!t)return If("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,nt).has(t.id)?n(this,nt).get(t.id).visible:(Y(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,qc,Jp).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,nt).has(e))return Y(`Optional content group not found: ${e}`),!0;if(n(this,nt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,nt).has(e))return Y(`Optional content group not found: ${e}`),!0;if(!n(this,nt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,nt).has(e))return Y(`Optional content group not found: ${e}`),!0;if(!n(this,nt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,nt).has(e))return Y(`Optional content group not found: ${e}`),!0;if(n(this,nt).get(e).visible)return!1}return!0}return Y(`Unknown optional content policy ${t.policy}.`),!0}return Y(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,nt).get(t);if(!i){Y(`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,nt).get(o))==null||r._setVisible(Xr,!1,!0));i._setVisible(Xr,!!e,!0),f(this,gr,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,nt).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}}f(this,gr,null)}get hasInitialVisibility(){return n(this,Tl)===null||this.getHash()===n(this,Tl)}getOrder(){return n(this,nt).size?n(this,kl)?n(this,kl).slice():[...n(this,nt).keys()]:null}getGroup(t){return n(this,nt).get(t)||null}getHash(){if(n(this,gr)!==null)return n(this,gr);const t=new Rp;for(const[e,s]of n(this,nt))t.update(`${e}:${s.visible}`);return f(this,gr,t.hexdigest())}[Symbol.iterator](){return n(this,nt).entries()}get serializable(){const t=new Map;for(const[e,s]of n(this,nt))t.set(e,s.serializable);return{data:n(this,Kc),renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new bm(t,e,s)}};gr=new WeakMap,nt=new WeakMap,Tl=new WeakMap,kl=new WeakMap,Kc=new WeakMap,qc=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,qc,Jp).call(this,r);else if(n(this,nt).has(r))a=n(this,nt).get(r).visible;else return Y(`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 Qp=bm;var Ot,Ls,te,Ga,Ti,ve,Uh,vu,Zp,tg;class yw{constructor(){m(this,ve);m(this,Ot,null);m(this,Ls,null);m(this,te,0);m(this,Ga,null);m(this,Ti,null)}get pagesNumber(){return n(this,te)}set pagesNumber(t){n(this,te)!==t&&(f(this,te,t),f(this,Ot,null),f(this,Ls,null))}movePages(t,e,s){b(this,ve,Uh).call(this);const i=n(this,Ot),r=e.length,a=new Uint32Array(r);let o=0;for(let u=0;u<r;u++){const g=e[u]-1;a[u]=i[g],g<s&&o++}const l=n(this,te),h=l-r,c=new Int32Array(l),d=xt(s-o,0,h);for(let u=0,g=0;u<l;u++)t.has(u+1)||(i[g]=i[u],c[g++]=u+1);i.copyWithin(d+r,d,h),i.set(a,d),c.copyWithin(d+r,d,h),c.set(e,d),f(this,Ls,c),i.every((u,g)=>u===g+1)&&f(this,Ot,null)}deletePages(t){b(this,ve,Uh).call(this);const e=n(this,Ot),s=b(this,ve,vu).call(this);f(this,Ti,{pageNumberToId:e.slice(),pagesNumber:n(this,te),prevPageNumbers:n(this,Ls).slice()});const i=n(this,te)-t.length;f(this,te,i);const r=f(this,Ot,new Uint32Array(i));f(this,Ls,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,ve,Zp).call(this,s,new Set(t))}cancelDelete(){n(this,Ti)&&(f(this,Ot,n(this,Ti).pageNumberToId),f(this,te,n(this,Ti).pagesNumber),f(this,Ls,n(this,Ti).prevPageNumbers),f(this,Ti,null))}cleanSavedData(){f(this,Ti,null)}copyPages(t){b(this,ve,Uh).call(this),f(this,Ga,{pageNumbers:t,pageIds:t.map(e=>n(this,Ot)[e-1])})}cancelCopy(){f(this,Ga,null)}pastePages(t){b(this,ve,Uh).call(this);const e=n(this,Ot),s=b(this,ve,vu).call(this),{pageNumbers:i,pageIds:r}=n(this,Ga),a=n(this,te)+i.length;f(this,te,a);const o=f(this,Ot,new Uint32Array(a));f(this,Ls,new Int32Array(a)),o.set(e.subarray(0,t),0),o.set(r,t),o.set(e.subarray(t),t+i.length),b(this,ve,Zp).call(this,s,null,t,i),f(this,Ga,null)}hasBeenAltered(){return n(this,Ot)!==null}getPageMappingForSaving(t=null,e=b(this,ve,tg).call(this)){t??(t=b(this,ve,vu).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,Sh).push(s+1)}return this.getPageMappingForSaving(e,b(this,ve,tg).call(this,t))}getPrevPageNumber(t){var e;return((e=n(this,Ls))==null?void 0:e[t-1])??0}getPageNumber(t){if(!n(this,Ot))return t;const e=n(this,Ot);for(let s=0,i=n(this,te);s<i;s++)if(e[s]===t)return s+1;return 0}getPageId(t){var e;return((e=n(this,Ot))==null?void 0:e[t-1])??t}getMapping(){var t;return(t=n(this,Ot))==null?void 0:t.subarray(0,this.pagesNumber)}}Ot=new WeakMap,Ls=new WeakMap,te=new WeakMap,Ga=new WeakMap,Ti=new WeakMap,ve=new WeakSet,Uh=function(){if(n(this,Ot))return;const t=n(this,te),e=f(this,Ot,new Uint32Array(t));for(let s=0;s<t;s++)e[s]=s+1;f(this,Ls,new Int32Array(e))},vu=function(){const t=new Map,e=n(this,Ot);for(let s=0,i=n(this,te);s<i;s++){const r=e[s],a=t.get(r);a?a.push(s+1):t.set(r,[s+1])}return t},Zp=function(t,e=null,s=-1,i=null){const r=n(this,Ls),a=n(this,Ot),o=s+((i==null?void 0:i.length)??0),l=new Map;for(let h=0,c=n(this,te);h<c;h++){if(h>=s&&h<o){r[h]=-i[h-s];continue}const d=a[h],u=t.get(d);let g=l.get(d)||0;if(e&&u)for(;g<u.length&&e.has(u[g]);)g++;r[h]=u==null?void 0:u[g],l.set(d,g+1)}},tg=function(t=null){if(!n(this,Ot))return null;const e=new Int32Array(n(this,te)).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,te);i<r;i++){const a=n(this,Ot)[i],o=s.get(a)??0;s.set(a,o+1),e[i]=o}return e};const Ho=Symbol("INITIAL_DATA"),ib=()=>({...Promise.withResolvers(),data:Ho});var Fs;class _y{constructor(){m(this,Fs,new Map)}get(t,e=null){if(e){const i=n(this,Fs).getOrInsertComputed(t,ib);return i.promise.then(()=>e(i.data)),null}const s=n(this,Fs).get(t);if(!s||s.data===Ho)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,Fs).get(t);return!!e&&e.data!==Ho}delete(t){const e=n(this,Fs).get(t);return!e||e.data===Ho?!1:(n(this,Fs).delete(t),!0)}resolve(t,e=null){const s=n(this,Fs).getOrInsertComputed(t,ib);if(s.data!==Ho)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){var t;for(const{data:e}
50of n(this,Fs).values())(t=e==null?void 0:e.bitmap)==null||t.close();n(this,Fs).clear()}*[Symbol.iterator](){for(const[t,{data:e}]of n(this,Fs))e!==Ho&&(yield[t,e])}}Fs=new WeakMap;const Aw=1e5,nb=30;var lb,mr,Fe,Qc,Jc,Pl,ja,hn,Zc,td,$a,ed,Ml,br,Dl,sd,Il,za,id,nd,Ll,Va,rd,Fl,Rl,Rn,Ty,ky,eg,As,Su,sg,Py,My;const ue=class ue{constructor({textContentSource:t,images:e,container:s,viewport:i}){m(this,Rn);m(this,mr,Promise.withResolvers());m(this,Fe,null);m(this,Qc,!1);m(this,Jc,!!((lb=globalThis.FontInspector)!=null&&lb.enabled));m(this,Pl,null);m(this,ja,null);m(this,hn,null);m(this,Zc,0);m(this,td,0);m(this,$a,null);m(this,ed,null);m(this,Ml,0);m(this,br,0);m(this,Dl,Object.create(null));m(this,sd,[]);m(this,Il,null);m(this,za,[]);m(this,id,new WeakMap);m(this,nd,null);var h;if(t instanceof ReadableStream)f(this,Il,t);else if(typeof t=="object")f(this,Il,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');f(this,Fe,f(this,ed,s)),f(this,Pl,e),f(this,br,i.scale*ri.pixelRatio),f(this,Ml,i.rotation),f(this,hn,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:a,pageX:o,pageY:l}=i.rawDims;f(this,nd,[1,0,0,-1,-o,l+a]),f(this,td,r),f(this,Zc,a),b(h=ue,As,Py).call(h),s.style.setProperty("--min-font-size",n(ue,Fl)),ko(s,i),n(this,mr).promise.finally(()=>{n(ue,Rl).delete(this),f(this,hn,null),f(this,Dl,null)}
50).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=gt.platform;return j(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){n(this,Pl)&&n(this,Fe).append(n(this,Pl).render());const t=()=>{n(this,$a).read().then(({value:e,done:s})=>{if(s){n(this,mr).resolve();return}n(this,ja)??f(this,ja,e.lang),Object.assign(n(this,Dl),e.styles),b(this,Rn,Ty).call(this,e.items),t()},n(this,mr).reject)};return f(this,$a,n(this,Il).getReader()),n(ue,Rl).add(this),t(),n(this,mr).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*ri.pixelRatio,i=t.rotation;if(i!==n(this,Ml)&&(e==null||e(),f(this,Ml,i),ko(n(this,ed),{rotation:i})),s!==n(this,br)){e==null||e(),f(this,br,s);const a={div:null,properties:null,ctx:b(r=ue,As,Su).call(r,n(this,ja))};for(const o of n(this,za))a.properties=n(this,id).get(o),a.div=o,b(this,Rn,eg).call(this,a)}}cancel(){var e;const t=new jr("TextLayer task cancelled.");(e=n(this,$a))==null||e.cancel(t).catch(()=>{}),f(this,$a,null),n(this,mr).reject(t)}get textDivs(){return n(this,za)}get textContentItemsStr(){return n(this,sd)}static cleanup(){if(!(n(this,Rl).size>0)){n(this,Ll).clear();for(const{canvas:t}of n(this,Va).values())t.remove();n(this,Va).clear()}}};mr=new WeakMap,Fe=new WeakMap,Qc=new WeakMap,Jc=new WeakMap,Pl=new WeakMap,ja=new WeakMap,hn=new WeakMap,Zc=new WeakMap,td=new WeakMap,$a=new WeakMap,ed=new WeakMap,Ml=new WeakMap,br=new WeakMap,Dl=new WeakMap,sd=new WeakMap,Il=new WeakMap,za=new WeakMap,id=new WeakMap,nd=new WeakMap,Ll=new WeakMap,Va=new WeakMap,rd=new WeakMap,Fl=new WeakMap,Rl=new WeakMap,Rn=new WeakSet,Ty=function(t){var i,r;if(n(this,Qc))return;(r=n(this,hn)).ctx??(r.ctx=b(i=ue,As,Su).call(i,n(this,ja)));const e=n(this,za),s=n(this,sd);for(const a of t){if(e.length>Aw){Y("Ignoring additional textDivs for performance reasons."),f(this,Qc,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,Fe);f(this,Fe,document.createElement("span")),n(this,Fe).classList.add("markedContent"),a.id&&n(this,Fe).setAttribute("id",a.id),a.tag==="Artifact"&&(n(this,Fe).ariaHidden=!0),o.append(n(this,Fe))}else a.type==="endMarkedContent"&&f(this,Fe,n(this,Fe).parentNode);continue}s.push(a.str),b(this,Rn,ky).call(this,a)}},ky=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,nd),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,Dl)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,Jc)&&a.fontSubstitution||a.fontFamily;o=ue.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),h=l*b(y=ue,As,My).call(y,o,a,n(this,ja));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 u=e.style;u.left=`${(100*c/n(this,td)).toFixed(2)}%`,u.top=`${(100*d/n(this,Zc)).toFixed(2)}%`,u.setProperty("--font-height",`${l.toFixed(2)}px`),u.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,n(this,Jc)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const A=Math.abs(t.transform[0]),S=Math.abs(t.transform[3]);A!==S&&Math.max(A,S)/Math.min(A,S)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),n(this,id).set(e,s),n(this,hn).div=e,n(this,hn).properties=s,b(this,Rn,eg).call(this,n(this,hn)),s.hasText&&n(this,Fe).append(e),s.hasEOL){const A=document.createElement("br");A.setAttribute("role","presentation"),n(this,Fe).append(A)}},eg=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=ue,As,sg).call(a,i,h*n(this,br),o);const{width:c}=i.measureText(e.textContent);c>0&&r.setProperty("--scale-x",l*n(this,br)/c)}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)},As=new WeakSet,Su=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,rd).set(e,{size:0,family:""})}return e},sg=function(t,e,s){const i=n(this,rd).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},Py=function(){if(n(this,Fl)!==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),f(this,Fl,t.getBoundingClientRect().height),t.remove()},My=function(t,e,s){const i=n(this,Ll).get(t);if(i)return i;const r=b(this,As,Su).call(this,s);r.canvas.width=r.canvas.height=nb,b(this,As,sg).call(this,r,nb,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):(gt.platform.isFirefox&&Y("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.desce
50nt)),n(this,Ll).set(t,h),h},m(ue,As),m(ue,Ll,new Map),m(ue,Va,new Map),m(ue,rd,new WeakMap),m(ue,Fl,null),m(ue,Rl,new Set);let sc=ue;const ww=100;function Dy(p={}){const t=new ig,{docId:e}=t,s=p.url?C0(p.url):null,i=p.data?_0(p.data):null,r=p.httpHeaders||null,a=p.withCredentials===!0,o=p.password??null,l=p.range instanceof Iy?p.range:null,h=Number.isInteger(p.rangeChunkSize)&&p.rangeChunkSize>0?p.rangeChunkSize:2**16;let c=p.worker instanceof ic?p.worker:null;const d=p.verbosity,u=typeof p.docBaseUrl=="string"&&!Ff(p.docBaseUrl)?p.docBaseUrl:null,g=Jd(p.cMapUrl),y=p.cMapPacked!==!1,A=Jd(p.iccUrl),S=Jd(p.standardFontDataUrl),w=Jd(p.wasmUrl),v=p.stopAtErrors!==!0,E=Number.isInteger(p.maxImageSize)&&p.maxImageSize>-1?p.maxImageSize:-1,x=typeof p.isOffscreenCanvasSupported=="boolean"?p.isOffscreenCanvasSupported:!ms,C=typeof p.isImageDecoderSupported=="boolean"?p.isImageDecoderSupported:!ms,_=Number.isInteger(p.canvasMaxAreaInBytes)?p.canvasMaxAreaInBytes:-1,k=typeof p.disableFontFace=="boolean"?p.disableFontFace:ms,P=p.fontExtraProperties===!0,M=p.enableXfa===!0,L=p.ownerDocument||globalThis.document,N=p.disableRange===!0,tt=p.disableStream===!0,Q=p.disableAutoFetch===!0,Z=p.pdfBug===!0,$t=p.CanvasFactory||(ms?F0:M0),F=p.FilterFactory||(ms?L0:D0),H=p.BinaryDataFactory||(ms?R0:Wm),Ct=p.enableHWA===!0,Me=p.enableWebGPU===!0?H0():Promise.resolve(!1),de=p.useWasm!==!1,Wt=p.pagesMapper||new yw,ht=typeof p.useSystemFonts=="boolean"?p.useSystemFonts:!ms&&!k,ai=typeof p.useWorkerFetch=="boolean"?p.useWorkerFetch:!!(H===Wm&&g&&y&&S&&w&&Kh(g,document.baseURI)&&Kh(S,document.baseURI)&&Kh(w,document.baseURI)),Eh=null;zA(d);const ne={canvasFactory:new $t({ownerDocument:L,enableHWA:Ct}),filterFactory:new F({docId:e,ownerDocument:L}),binaryDataFactory:ai?null:new H({cMapUrl:g,standardFontDataUrl:S,wasmUrl:w})};c||(c=ic.create({verbosity:d,port:Hi.workerPort}),t._worker=c);const At={docId:e,apiVersion:"6.3.289",data:i,password:o,disableAutoFetch:Q,rangeChunkSize:h,docBaseUrl:u,enableXfa:M,evaluatorOptions:{maxImageSize:E,disableFontFace:k,ignoreErrors:v,isOffscreenCanvasSupported:x,isImageDecoderSupported:C,canvasMaxAreaInBytes:_,fontExtraProperties:P,useSystemFonts:ht,useWasm:de,useWorkerFetch:ai,cMapUrl:g,cMapPacked:y,iccUrl:A,standardFontDataUrl:S,wasmUrl:w,hasGPU:!1}},zf={ownerDocument:L,pdfBug:Z,styleElement:Eh,enableHWA:Ct,loadingParams:{disableAutoFetch:Q,enableXfa:M}};return Promise.all([c.promise,Me]).then(function([,DA]){if(c.destroyed)throw new Error("Worker was destroyed");At.evaluatorOptions.hasGPU=DA;const IA=c.messageHandler.sendWithPromise("GetDocRequest",At,i?[i.buffer]:null);let Vf;if(!i)if(l)Vf=new rw({pdfDataRangeTransport:l,disableRange:N,disableStream:tt});else if(s){const Wf=gw(s);Vf=new Wf({url:s,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:N,disableStream:tt})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return IA.then(Wf=>{if(c.destroyed)throw new Error("Worker was destroyed");const vm=new Rh(e,Wf,c.port),LA=new Sw(vm,t,Vf,zf,ne,Wt);if(t._transport=LA,t.destroyed)throw new Error("Loading aborted");vm.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}var bf;const yf=class yf{constructor(){T(this,"_capability",Promise.withResolvers());T(this,"_setupCapability",Promise.withResolvers());T(this,"_transport",null);T(this,"_worker",null);T(this,"docId",`d${It(yf,bf)._++}`);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()}};bf=new WeakMap,m(yf,bf,0);let ig=yf;var Ol,Wa;class Iy{constructor(t,e,s=!1,i=null){m(this,Ol,Promise.withResolvers());m(this,Wa,null);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){n(this,Wa).call(this,{type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){n(this,Ol).promise.then(()=>{n(this,Wa).call(this,{type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){n(this,Ol).promise.then(()=>{n(this,Wa).call(this,{type:"progressiveDone"})})}transportReady(t){f(this,Wa,t),n(this,Ol).resolve()}requestDataRange(t,e){st("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Ol=new WeakMap,Wa=new WeakMap;class vw{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 j(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}
50=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 cn,Xa,Ya,Gh;const ym=class ym{constructor(t,e,s,i,r=!1){m(this,Ya);m(this,cn,!1);m(this,Xa,null);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new Im:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new _y,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,f(this,Xa,i),this.imageCoordinates=null}clone(t){const e=new ym(t,this._pageInfo,this._transport,n(this,Xa),this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new Wd({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return j(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}
50render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=Nn.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:u=!1,recordImages:g=!1,recordOperations:y=!1,operationsFilter:A=null}){var Q,Z,$t;(Q=this._stats)==null||Q.time("Overall");const S=this._transport.getRenderingIntent(i,r,d,u),{renderingIntent:w,cacheKey:v}=S;f(this,cn,!1),l||(l=this._transport.getOptionalContentConfig(w));const E=this._intentStates.getOrInsertComputed(v,hp);E.streamReaderCancelTimeout&&(clearTimeout(E.streamReaderCancelTimeout),E.streamReaderCancelTimeout=null);const x=!!(w&gs.PRINT);E.displayReadyCapability||(E.displayReadyCapability=Promise.withResolvers(),E.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(Z=this._stats)==null||Z.time("Page Request"),this._pumpOperatorList(S));const C=!!(this._pdfBug&&(($t=globalThis.StepperManager)!=null&&$t.enabled)),_=!!e&&!this.recordedBBoxes&&(y||C),k=!!e&&!this.imageCoordinates&&g,P=F=>{var H,Ct,_t,Me;if(E.renderTasks.delete(N),_){const de=(H=N.gfx)==null?void 0:H.dependencyTracker.take();de&&((Ct=N.stepper)==null||Ct.setOperatorBBoxes(de,N.gfx.dependencyTracker.takeDebugMetadata()),y&&(this.recordedBBoxes=de))}k&&!F&&(this.imageCoordinates=(_t=N.gfx)==null?void 0:_t.imagesTracker.take()),x&&f(this,cn,!0),b(this,Ya,Gh).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"),(Me=globalThis.Stats)!=null&&Me.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let M=null,L=null;(_||k)&&(L=new g0(e,E.operatorList.length)),_&&(M=new m0(L,C));const N=new rg({callback:P,params:{canvas:e,canvasContext:t,dependencyTracker:M??L,imagesTracker:k?new Bp(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 tt=N.task;return Promise.all([E.displayReadyCapability.promise,l]).then(([F,H])=>{var Ct;if(this.destroyed){P();return}if((Ct=this._stats)==null||Ct.time("Rendering"),!(H.renderingIntent&w))throw new Error("Mu
50st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");N.initializeGraphics({transparency:F,optionalContentConfig:H}),N.operatorListChanged()}).catch(P),tt}getOperatorList({intent:t="display",annotationMode:e=Nn.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,hp);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,Xa).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=>Zh.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(),f(this,cn,!1),Promise.all(t)}cleanup(t=!1){f(this,cn,!0);const e=b(this,Ya,Gh).call(this);return t&&e&&this._stats&&(this._stats=new Im),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,Ya,Gh).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,Xa).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:u})=>{if(u){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 u of h.renderTasks)u.operatorListChanged();b(this,Ya,Gh).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 nm){let i=ww;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 jr(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}};cn=new WeakMap,Xa=new WeakMap,Ya=new WeakSet,Gh=function(){if(!n(this,cn)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),f(this,cn,!1),!0};let ng=ym;var yr,Ks,dn,Ka,Af,qa,Qa,Ue,Eu,Ly,Fy,jh,Nl,xu;const Ht=class Ht{constructor({name:t=null,port:e=null,verbosity:s=VA()}={}){m(this,Ue);m(this,yr,Promise.withResolvers());m(this,Ks,null);m(this,dn,null);m(this,Ka,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(Ht,Qa).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(Ht,Qa).set(e,this),b(this,Ue,Ly).call(this,e)}else b(this,Ue,Fy).call(this)}get promise(){return n(this,yr).promise}get port(){return n(this,dn)}get messageHandler(){return n(this,Ks)}destroy(){var t,e;this.destroyed=!0,(t=n(this,Ka))==null||t.terminate(),f(this,Ka,null),n(Ht,Qa).delete(n(this,dn)),f(this,dn,null),(e=n(this,Ks))==null||e.destroy(),f(this,Ks,null)}static create(t){const e=n(this,Qa).get(t==null?void 0:t.port);
50if(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 Ht(t)}static get workerSrc(){if(Hi.workerSrc)return Hi.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return j(this,"_setupFakeWorkerGlobal",(async()=>n(this,Nl,xu)?n(this,Nl,xu):(await import(this.workerSrc)).WorkerMessageHandler)())}};yr=new WeakMap,Ks=new WeakMap,dn=new WeakMap,Ka=new WeakMap,Af=new WeakMap,qa=new WeakMap,Qa=new WeakMap,Ue=new WeakSet,Eu=function(){n(this,yr).resolve(),n(this,Ks).send("configure",{verbosity:this.verbosity})},Ly=function(t){f(this,dn,t),f(this,Ks,new Rh("main","worker",t)),n(this,Ks).on("ready",()=>{}),b(this,Ue,Eu).call(this)},Fy=function(){if(n(Ht,qa)||n(Ht,Nl,xu)){b(this,Ue,jh).call(this);return}let{workerSrc:t}=Ht;try{Ht._isSameOrigin(window.location,t)||(t=Ht._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Rh("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?n(this,yr).reject(new Error("Worker was destroyed")):b(this,Ue,jh).call(this)},r=new AbortController;e.addEventListener("error",()=>{n(this,Ka)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}f(this,Ks,s),f(this,dn,e),f(this,Ka,e),b(this,Ue,Eu).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{b(this,Ue,jh).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{If("The worker has been disabled.")}b(this,Ue,jh).call(this)},jh=function(){n(Ht,qa)||(Y("Setting up fake worker."),f(Ht,qa,!0)),Ht._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){n(this,yr).reject(new Error("Worker was destroyed"));return}const e=new P0;f(this,dn,e);const s=`fake${It(Ht,Af)._++}`,i=new Rh(s+"_worker",s,e);t.setup(i,e),f(this,Ks,new Rh(s,s+"_worker",e)),b(this,Ue,Eu).call(this)}).catch(t=>{n(this,yr).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Nl=new WeakSet,xu=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},m(Ht,Nl),m(Ht,Af,0),m(Ht,qa,!1),m(Ht,Qa,new WeakMap),ms&&(f(Ht,qa,!0),Hi.workerSrc||(Hi.workerSrc="./pdf.worker.mjs")),Ht._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},Ht._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let ic=Ht;var ns,Ja,un,qs,Za,Bl,fn,Hs,Uo,Cu;class Sw{constructor(t,e,s,i,r,a){m(this,Hs);T(this,"downloadInfoCapability",Promise.withResolvers());m(this,ns,null);m(this,Ja,new Map);m(this,un,null);m(this,qs,new Map);m(this,Za,new Map);m(this,Bl,new Map);m(this,fn,null);this.messageHandler=t,this.loadingTask=e,f(this,un,s),this.commonObjs=new _y,this.fontLoader=new y0({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,qs).set(e,t),n(this,Za).set(e,Promise.resolve(t))}get annotationStorage(){return j(this,"annotationStorage",new am)}getRenderingIntent(t,e=Nn.ENABLE,s=null,i=!1,r=!1){let a=gs.DISPLAY,o=tc;switch(t){case"any":a=gs.ANY;break;case"display":break;case"print":a=gs.PRINT;break;default:Y(`getRenderingIntent - invalid intent: ${t}`)}const l=a&gs.PRINT&&s instanceof Yb?s:this.annotationStorage;switch(e){case Nn.DISABLE:a+=gs.ANNOTATIONS_DISABLE;break;case Nn.ENABLE:break;case Nn.ENABLE_FORMS:a+=gs.ANNOTATIONS_FORMS;break;case Nn.ENABLE_STORAGE:a+=gs.ANNOTATIONS_STORAGE,o=l.serializable;break;default:Y(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=gs.IS_EDITING),r&&(a+=gs.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,fn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,qs).values())t.push(i._destroy());n(this,qs).clear(),n(this,Za).clear(),n(this,Bl).clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();
50const 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,Ja).clear(),this.filterFactory.destroy(),sc.cleanup(),(i=n(this,un))==null||i.cancelAllRequests(new jr("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)=>{Bt(n(this,un),"GetReader - no `BasePDFStream` instance available."),f(this,ns,n(this,un).getFullReader()),n(this,ns).onProgress=r=>b(this,Hs,Cu).call(this,r),i.onPull=()=>{n(this,ns).read().then(function({value:r,done:a}){if(a){i.close();return}Bt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n(this,ns).cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{await n(this,ns).headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=n(this,ns);return i&&r&&(n(this,ns).onProgress=null),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{Bt(n(this,un),"GetRangeReader - no `BasePDFStream` instance available.");const r=n(this,un).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}Bt(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 vw(s,this))}),t.on("DocException",s=>{e._capability.reject($e(s))}),t.on("PasswordRequest",s=>{f(this,fn,Promise.withResolvers());try{if(!e.onPassword)throw $e(s);const i=r=>{r instanceof Error?n(this,fn).reject(r):n(this,fn).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,fn).reject(i)}return n(this,fn).promise}),t.on("DataLoaded",s=>{b(this,Hs,Cu).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,qs).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 u=r.error;Y(`Error during font loading: ${u}`),this.commonObjs.resolve(s,u);break}const o=new S0(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(u,g)=>globalThis.FontInspector.fontAdded(u,g):null,h=new A0(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;Bt(c,"The imageRef must be defined.");for(const u of n(this,qs).values())for(const[,g]of u.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 x0(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,qs).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,Hs,Cu).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)})}
50getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&Y("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,ns))==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,u]of l){if((u==null?void 0:u.pageIndex)!==void 0&&u.pageIndex>=0&&u.pageIndex<h.length){const g=(e==null?void 0:e[u.pageIndex])??0,y=h[u.pageIndex]-1;if(y!==u.pageIndex||g!==0){c.set(d,{...u,pageIndex:y,copyLevel:g});continue}}c.set(d,u)}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,Za).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,Bl).set(a.refStr,s);const o=new ng(e,a,this,this.pagesMapper,this._params.pdfBug);return n(this,qs).set(e,o),o});return n(this,Za).set(e,r),r}async getPageIndex(t){if(!Up(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,Hs,Uo).call(this,"GetFieldObjects")}getSignatures(){return b(this,Hs,Uo).call(this,"GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return b(this,Hs,Uo).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,Hs,Uo).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,Hs,Uo).call(this,"GetOptionalContentConfig").then(e=>new Qp(e,t))}
50getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return n(this,Ja).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>{var s,i;return{info:e[0],metadata:e[1]?new mw(e[1]):null,contentDispositionFilename:((s=n(this,ns))==null?void 0:s.filename)??null,contentLength:((i=n(this,ns))==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,qs).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,Ja).clear(),this.filterFactory.destroy(!0),sc.cleanup()}}cachedPageNumber(t){if(!Up(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=n(this,Bl).get(e);if(s>=0){const i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}ns=new WeakMap,Ja=new WeakMap,un=new WeakMap,qs=new WeakMap,Za=new WeakMap,Bl=new WeakMap,fn=new WeakMap,Hs=new WeakSet,Uo=function(t,e=null){return n(this,Ja).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))},Cu=function({loaded:t,total:e}){var s,i;(i=(s=this.loadingTask).onProgress)==null||i.call(s,{loaded:t,total:e,percent:e?xt(Math.round(t/e*100),0,100):NaN})};class Ew{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 Ar,to;const Jr=class Jr{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:u=null,enableHWA:g=!1,operationsFilter:y=null}){m(this,Ar,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=u,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 Ew(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(Jr,to).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");n(Jr,to).add(this._canvas)}this._pdfBug&&((h=globalThis.StepperManager)!=null&&h.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:i,background:r,dependencyTracker:a,imagesTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Vo(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,Ar)&&(window.cancelAnimationFrame(n(this,Ar)),f(this,Ar,null)),n(Jr,to).delete(this._canvas),t||(t=new nm(`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?f(this,Ar,window.requestAnimationFrame(()=>{f(this,Ar,null),this._nextBound().catch(this._cancelBound)}
50)):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(Jr,to).delete(this._canvas),this.callback())))}};Ar=new WeakMap,to=new WeakMap,m(Jr,to,new WeakSet);let rg=Jr;const xw="6.3.289",Cw="1c8020a7d";var rs,eo,Hl,ee,ad,Ul,pn,od,wr,Qs,ld,mt,ag,og,lg,Yr,Ry,On;const Ve=class Ve{constructor({editor:t=null,uiManager:e=null}){m(this,mt);m(this,rs,null);m(this,eo,null);m(this,Hl);m(this,ee,null);m(this,ad,!1);m(this,Ul,!1);m(this,pn,null);m(this,od);m(this,wr,null);m(this,Qs,null);var s,i;t?(f(this,Ul,!1),f(this,pn,t)):f(this,Ul,!0),f(this,Qs,(t==null?void 0:t._uiManager)||e),f(this,od,n(this,Qs)._eventBus),f(this,Hl,((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,ld)||f(Ve,ld,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return j(this,"_keyboardManager",new Po([[["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=f(this,rs,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",n(this,pn)&&(t.ariaControls=`${n(this,pn).id}_colorpicker_dropdown`);const e=n(this,Qs)._signal;t.addEventListener("click",b(this,mt,Yr).bind(this),{signal:e}),t.addEventListener("keydown",b(this,mt,lg).bind(this),{signal:e});const s=f(this,eo,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,Hl),t.append(s),t}renderMainDropdown(){const t=f(this,ee,b(this,mt,ag).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===n(this,rs)){b(this,mt,Yr).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,mt,og).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,mt,On)){b(this,mt,Yr).call(this,t);return}if(t.target===n(this,rs)){(e=n(this,ee).firstElementChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,ee))==null?void 0:e.firstElementChild)||t.target===n(this,rs)){n(this,mt,On)&&this._hideDropdownFromKeyboard();return}n(this,mt,On)||b(this,mt,Yr).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,mt,On)){b(this,mt,Yr).call(this,t);return}(e=n(this,ee).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,mt,On)){b(this,mt,Yr).call(this,t);return}(e=n(this,ee).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,ee))==null||t.classList.add("hidden"),n(this,rs).ariaExpanded="false",(e=n(this,wr))==null||e.abort(),f(this,wr,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,Ul)){if(!n(this,mt,On)){(t=n(this,pn))==null||t.unselect();return}this.hideDropdown(),n(this,rs).focus({preventScroll:!0,focusVisible:n(this,ad)})}}update(t){if(n(this,eo)&&(n(this,eo).style.backgroundColor=t),!n(this,ee))return;const e=n(this,Qs).highlightColors.values();for(const s of n(this,ee).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=n(this,rs))==null||t.remove(),f(this,rs,null),f(this,eo,null),(e=n(this,ee))==null||e.remove(),f(this,ee,null)}};rs=new WeakMap,eo=new WeakMap,Hl=new WeakMap,ee=new WeakMap,ad=new WeakMap,Ul=new WeakMap,pn=new WeakMap,od=new WeakMap,wr=new WeakMap,Qs=new WeakMap,ld=new WeakMap,mt=new WeakSet,ag=function(){const t=document.createElement("div"),e=n(this,Qs)._signal;t.addEventListener("contextmenu",ni,{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,pn)&&(t.id=`${n(this,pn).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,ld)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,Hl),r.addEventListener("click",b(this,mt,og).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",b(this,mt,lg).bind(this),{signal:e}),t},og=function(t,e){e.stopPropagation(),n(this,od).dispatch("switchannotationeditorparams",{source:this,type:et.HIGHLIGHT_COLOR,value:t}),this.update(t)},lg=function(t){Ve._keyboardManager.exec(this,t)},Yr=function(t){if(n(this,mt,On)){this.hideDropdown();return}if(f(this,ad,t.detail===0),n(this,wr)||(f(this,wr,new AbortController),window.addEventListener("pointerdown",b(this,mt,Ry).bind(this),{signal:n(this,Qs).combinedSignal(n(this,wr))})),n(this,rs).ariaExpanded="true",n(this,ee)){n(this,ee).classList.remove("hidden");return}const e=f(this,ee,b(this,mt,ag).call(this));n(this,rs).append(e)},Ry=function(t){var e;(e=n(this,ee))!=null&&e.contains(t.target)||this.hideDropdown()},On=function(){return n(this,ee)&&!n(this,ee).classList.contains("hidden")},m(Ve,ld,null);let Qu=Ve;var as,Gl,so,gn,hd;const Zr=class Zr{constructor(t){m(this,as,null);m(this,Gl,!1);m(this,so,null);m(this,gn,null);f(this,so,t),f(this,gn,t._uiManager),n(Zr,hd)||f(Zr,hd,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,as))return n(this,as);const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:r,opacity:a}=n(this,so),o=f(this,Gl,gt.isAlphaColorInputSupported&&i!==void 0),l=f(this,as,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(Zr,hd)[t]),l.addEventListener("input",()=>{if(o){const h=Xd(l.value);
50if(!h)return;const[c,d,u,g]=h,y=D.makeHexColor(c,d,u);s!==void 0?n(this,gn).updateParams(s,{color:y,opacity:g}):(n(this,gn).updateParams(e,y),n(this,gn).updateParams(i,g))}else n(this,gn).updateParams(e,l.value)},{signal:n(this,gn)._signal}),l}update(t){if(n(this,as))if(n(this,Gl)){const e=D.hexNums[Math.round(n(this,so).opacity*255)];n(this,as).value=t+e}else n(this,as).value=t}updateOpacity(t){if(!n(this,as)||!n(this,Gl))return;const e=D.hexNums[Math.round(t*255)];n(this,as).value=n(this,so).color+e}destroy(){var t;(t=n(this,as))==null||t.remove(),f(this,as,null)}hideDropdown(){}};as=new WeakMap,Gl=new WeakMap,so=new WeakMap,gn=new WeakMap,hd=new WeakMap,m(Zr,hd,null);let Ju=Zr;function rb(p){return Math.floor(xt(p,0,1)*255).toString(16).padStart(2,"0")}function _h(p){return xt(p,0,1)*255}class ab{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=_h(t),[t,t,t]}static G_HTML([t]){const e=rb(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(_h)}static RGB_HTML(t){return`#${t.map(rb).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[_h(1-Math.min(1,t+i)),_h(1-Math.min(1,s+i)),_h(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 _w{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){st("Abstract method `_createSVG` called.")}}class Zu extends _w{_createSVG(t){return document.createElementNS(Be,t)}}const Tw=9,Do=new WeakSet,kw=new Date().getTimezoneOffset()*60*1e3;class ip{static create(t){switch(t.data.annotationType){case Lt.LINK:return new lm(t);case Lt.TEXT:return new Mw(t);case Lt.WIDGET:switch(t.data.fieldType){case"Tx":return new Dw(t);case"Btn":return t.data.radioButton?new Fw(t):t.data.checkBox?new Lw(t):new Rw(t);case"Ch":return new Ow(t);case"Sig":return new Iw(t)}return new Fo(t);case Lt.POPUP:return new cg(t);case Lt.FREETEXT:return new jy(t);case Lt.LINE:return new Bw(t);case Lt.SQUARE:return new Hw(t);case Lt.CIRCLE:return new Uw(t);case Lt.POLYLINE:return new $y(t);case Lt.CARET:return new jw(t);case Lt.INK:return new hm(t);case Lt.POLYGON:return new Gw(t);case Lt.HIGHLIGHT:return new zy(t);case Lt.UNDERLINE:return new $w(t);case Lt.SQUIGGLY:return new zw(t);case Lt.STRIKEOUT:return new Vw(t);case Lt.STAMP:return new Vy(t);case Lt.FILEATTACHMENT:return new Ww(t);case Lt.RICHMEDIA:case Lt.SCREEN:case Lt.SOUND:return new Wy(t);default:return new Mt(t)}}}var io,jl,Rs,cd,hg;const Am=class Am{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){m(this,cd);m(this,io,null);m(this,jl,!1);m(this,Rs,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 Am._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}
50get 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(`${Ah}${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(`${Ah}${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,Rs))==null?void 0:t.popup)||this.popup)==null||e.remove(),f(this,Rs,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(n(this,io)||f(this,io,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&b(this,cd,hg).call(this,e);let i=((r=n(this,Rs))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,Rs).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),f(this,Rs,null),this.popup=null))}resetEdited(){var t;n(this,io)&&(b(this,cd,hg).call(this,n(this,io).rect),(t=n(this,Rs))==null||t.popup.resetEdited(),f(this,io,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 Fo)&&!(this instanceof lm)&&!(this instanceof Wy)&&
50(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 cg){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,S=e.borderStyle.verticalCornerRadius;if(A>0||S>0){const v=`calc(${A}px * var(--total-scale-factor)) / calc(${S}px * var(--total-scale-factor))`;a.borderRadius=v}switch(e.borderStyle.style){case No.SOLID:a.borderStyle="solid";break;case No.DASHED:a.borderStyle="dashed";break;case No.BEVELED:Y("Unimplemented border style: beveled");break;case No.INSET:Y("Unimplemented border style: inset");break;case No.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(f(this,jl,!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:u,pageY:g}=i.rawDims;a.left=`${100*(h[0]-u)/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]=ab[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:ab[`${a}_rgb`](o)})};return j(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(()=>e.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]}}}
50_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,S,w,v]=t.subarray(2,6);if(i===A&&r===S&&e===w&&s===v)return}const{style:a}=this.container;let o;if(n(this,jl)){const{borderColor:A,borderWidth:S}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${Be}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${A}" stroke-width="${S}">`],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 u=c.createElement("defs");d.append(u);const g=c.createElement("clipPath"),y=`clippath_${this.data.id}`;g.setAttribute("id",y),g.setAttribute("clipPathUnits","objectBoundingBox"),u.append(g);for(let A=2,S=t.length;A<S;A+=8){const w=t[A],v=t[A+1],E=t[A+2],x=t[A+3],C=c.createElement("rect"),_=(E-e)/l,k=(r-v)/h,P=(w-E)/l,M=(v-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,jl)&&(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),f(this,Rs,new cg({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,Rs)||this.popup||this.data.popupRef)}get extraPopupElement(){return n(this,Rs)}render(){st("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&&!Do.has(h)){Y(`_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&&Do.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]}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":D.makeHexColor(...e)}};io=new WeakMap,jl=new WeakMap,Rs=new WeakMap,cd=new WeakSet,hg=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 Mt=Am;class Pw extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}
50get 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 ys,Kr,Oy,Ny;class lm extends Mt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});m(this,ys);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,ys,Oy).call(this,i,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(b(this,ys,Ny).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,ys,Kr).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,ys,Kr).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,ys,Kr).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,ys,Kr).call(this),!this._fieldObjects){Y('_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 u=new Set(a);for(const g of r){const y=this._fieldObjects.get(g)||[];for(const{id:A}of y)u.add(A)}for(const g of this._fieldObjects.values())for(const y of g)u.has(y.id)===o&&l.push(y)}else for(const u of this._fieldObjects.values())l.push(...u);const h=this.annotationStorage,c=[];for(const u of l){const{id:g}=u;switch(c.push(g),u.type){case"text":{const A=u.defaultValue||"";h.setValue(g,{value:A});break}case"checkbox":case"radiobutton":{const A=u.defaultValue===u.exportValues;h.setValue(g,{value:A});break}case"combobox":case"listbox":{const A=u.defaultValue||"";h.setValue(g,{value:A});break}default:continue}const y=document.querySelector(`[data-element-id="${g}"]`);if(y){if(!Do.has(y)){Y(`_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}}}ys=new WeakSet,Kr=function(){this.container.setAttribute("data-internal-link","")},Oy=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,ys,Kr).call(this)},Ny=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),b(this,ys,Kr).call(this)};class Mw extends Mt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}
50class Fo extends Mt{render(){return this.container}_getKeyModifier(t){return gt.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||Tw,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 Dw extends Fo{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;
50for(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(`
51`))||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")),Do.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:u,timeStep:g}=this.data,y=!!u&&this.enableScripting;d&&(s.title=d),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",S=>{t.setValue(e,{value:S.target.value}),this.setPropertyOnSiblings(s,"value",S.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",S=>{const w=this.data.defaultFieldValue??"";s.value=c.userValue=w,c.formattedValue=null});let A=S=>{const{formattedValue:w}=c;w!=null&&(S.target.value=w),S.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",w=>{var E;if(c.focused)return;const{target:v}=w;if(y&&(v.type=u,g&&(v.step=g)),c.userValue){const x=c.userValue;if(y)if(u==="time"){const C=new Date(x),_=[C.getHours(),C.getMinutes(),C.getSeconds()];v.value=_.map(k=>k.toString().padStart(2,"0")).join(":")}else v.value=new Date(x-kw).toISOString().split(u==="date"?"T":".",1)[0];else v.value=x}c.lastCommittedValue=v.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 v={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(v,w)}),s.addEventListener("keydown",w=>{var x;c.commitKey=1;let v=-1;if(w.key==="Escape"?v=0:w.key==="Enter"&&!this.data.multiLine?v=2:w.key==="Tab"&&(c.commitKey=3),v===-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:v,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const S=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:v}=w;let{value:E}=v;if(y){if(E&&u==="time"){const _=E.split(":").map(k=>parseInt(k,10));E=new Date(2e3,0,1,_[0],_[1],_[2]||0).valueOf(),v.step=""}else E.includes("T")||(E=`${E}T00:00`),E=new Date(E).valueOf();v.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,
51commitKey:c.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),S(w)}),(r=this.data.actions)!=null&&r.has("Keystroke")&&s.addEventListener("beforeinput",w=>{var M;c.lastCommittedValue=null;const{data:v,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:v||"",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 v=this.data.textAlignment;if(v===1||v===2){const E=()=>{const x=l-s.value.length;s.style.setProperty("--comb-offset",`${v===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 Iw extends Fo{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Lw extends Fo{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 Do.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 Fo{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(Do.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 u=c&&d.id===s;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};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}}
vendor: 4,134 bytes, line 51
51class Rw extends lm{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 Ow extends Fo{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");Do.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 u=this.data.defaultFieldValue;for(const g of i.options)g.selected=g.value===u});const a=(d,u)=>{const g=u.replaceAll(" "," ");d.textContent=g,g!==u&&d.setAttribute("display-value",u)};for(const d of this.data.options){const u=document.createElement("option");a(u,d.displayValue),u.value=d.exportValue,s.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),r=!1),i.append(u)}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 u=d?"value":"textContent",{options:g,multiple:y}=i;return y?Array.prototype.filter.call(g,A=>A.selected).map(A=>A[u]):g.selectedIndex===-1?null:g[g.selectedIndex][u]};let h=l(!1);const c=d=>{const u=d.target.options;return Array.prototype.map.call(u,g=>({displayValue:g.getAttribute("display-value")||g.textContent,exportValue:g.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const u={value(g){o==null||o();const y=g.detail.value,A=new Set(Array.isArray(y)?y:[y]);for(const S of i.options)S.selected=A.has(S.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:S}=g.detail.insert,w=i.children[y],v=document.createElement("option");a(v,A),v.value=S,w?w.before(v):i.append(v),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:S,exportValue:w}=A,v=document.createElement("option");a(v,S),v.value=w,i.append(v)}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(u,d)}),i.addEventListener("input",d=>{var y;const u=l(!0),g=l(!1);t.setValue(e,{value:u}),d.preventDefault(),(y=this.linkService.eventBus)==null||y.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:h,change:g,changeEx:u,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 dd,dg;class cg extends Mt{constructor(e){const{data:s,elements:i,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&Mt._hasPopupData(s)});
51m(this,dd);if(this.elements=i,a&&Mt._hasPopupData(s)){const o=this.popup=b(this,dd,dg).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,dd,dg).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=>`${jo}${r}`).join(",")),this.container}}dd=new WeakSet,dg=function(){return new Nw({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 os,vr,wf,vf,$l,zl,Gt,ki,Sr,no,Vl,Wl,Pi,ls,mn,bn,jt,yn,Er,ud,An,Xl,ro,xr,he,Cr,q,_u,ug,fg,pg,Tu,gg,By,Hy,Uy,Gy,ku,Pu,mg;class Nw{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:d,commentManager:u=null}){m(this,q);m(this,os,null);m(this,vr,b(this,q,Uy).bind(this));m(this,wf,b(this,q,mg).bind(this));m(this,vf,b(this,q,Pu).bind(this));m(this,$l,b(this,q,ku).bind(this));m(this,zl,null);m(this,Gt,null);m(this,ki,null);m(this,Sr,null);m(this,no,null);m(this,Vl,null);m(this,Wl,null);m(this,Pi,!1);m(this,ls,null);m(this,mn,null);m(this,bn,null);m(this,jt,null);m(this,yn,null);m(this,Er,null);m(this,ud,null);m(this,An,null);m(this,Xl,null);m(this,ro,null);m(this,xr,!1);m(this,he,null);m(this,Cr,null);f(this,Gt,t),f(this,Xl,i),f(this,ki,a),f(this,An,o),f(this,Vl,l),f(this,zl,e),f(this,ud,h),f(this,Wl,c),f(this,no,s),f(this,os,u),f(this,he,s[0]),f(this,Sr,Yu.toDateObject(r)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup()),u||(b(this,q,_u).call(this),n(this,Gt).hidden=!0,d&&b(this,q,ku).call(this))}renderCommentButton(){if(n(this,jt)){n(this,jt).parentNode||n(this,he).container.after(n(this,jt));return}if(n(this,yn)||b(this,q,ug).call(this),!n(this,yn))return;const{signal:t}=f(this,mn,new AbortController),e=n(this,he).hasOwnCommentButton,s=()=>{n(this,os).toggleCommentPopup(this,!0,void 0,!e)},i=()=>{n(this,os).toggleCommentPopup(this,!1,!0,!e)},r=()=>{n(this,os).toggleCommentPopup(this,!1,!1)};if(e){f(this,jt,n(this,he).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",n(this,vr),{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=f(this,jt,document.createElement("button"));a.className="annotationCommentButton";const o=n(this,he).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,q,pg).call(this),b(this,q,fg).call(this),a.addEventListener("keydown",n(this,vr),{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,he).commentData;return t?n(this,Vl)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=n(this,jt))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}=n(this,he).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return n(this,jt)}get comment(){return n(this,Cr)||f(this,Cr,n(this,he).commentText),n(this,Cr)}set comment(t){t!==this.comment&&(n(this,he).commentText=f(this,Cr,t))}focus(){var t;(t=n(this,he).container)==null||t.focus()}get parentBoundingClientRect(){return n(this,he).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){n(this,jt)&&(n(this,jt).classList.toggle("selected",t),n(this,jt).ariaExpanded=e)}setSelectedCommentButton(t){n(this,jt).classList.toggle("selected",t)}get commentPopupPosition(){if(n(this,Er))return n(this,Er);const{x:t,y:e,height:s}=n(this,jt).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,he).layer.getBoundingClientRect();return[(t-i)/a,(e+s-r)/o]}set commentPopupPosition(t){f(this,Er,t)}hasDefaultPopupPosition(){return n(this,Er)===null}get commentButtonPosition(){return n(this,yn)}get commentButtonWidth(){return n(this,jt).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=n(this,Er)||this.commentButtonPosition.map(h=>h/100),i=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=i;
51n(this,os).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:i})}render(){var s,i;if(n(this,ls))return;const t=f(this,ls,document.createElement("div"));if(t.className="popup",n(this,zl)){const r=t.style.outlineColor=D.makeHexColor(...n(this,zl));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=n(this,Xl))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=n(this,Xl)}if(t.append(e),n(this,Sr)){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,Sr).valueOf()})),r.dateTime=n(this,Sr).toISOString(),e.append(r)}ub({html:n(this,q,Tu)||n(this,ki).str,dir:(i=n(this,ki))==null?void 0:i.dir,className:"popupContent"},t),n(this,Gt).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var i;if(n(this,os)){s?(this.remove(),f(this,Cr,null)):e&&(e.deleted?this.remove():(b(this,q,pg).call(this),f(this,Cr,e.text))),t&&(f(this,yn,null),b(this,q,ug).call(this),b(this,q,fg).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}b(this,q,_u).call(this),n(this,ro)||f(this,ro,{contentsObj:n(this,ki),richText:n(this,An)}),t&&f(this,bn,null),e&&e.text&&(f(this,An,b(this,q,Hy).call(this,e.text)),f(this,Sr,Yu.toDateObject(e.date)),f(this,ki,null)),(i=n(this,ls))==null||i.remove(),f(this,ls,null)}resetEdited(){var t;n(this,ro)&&({contentsObj:It(this,ki)._,richText:It(this,An)._}=n(this,ro),f(this,ro,null),(t=n(this,ls))==null||t.remove(),f(this,ls,null),f(this,bn,null))}remove(){var t,e,s;if((t=n(this,mn))==null||t.abort(),f(this,mn,null),(e=n(this,ls))==null||e.remove(),f(this,ls,null),f(this,xr,!1),f(this,Pi,!1),(s=n(this,jt))==null||s.remove(),f(this,jt,null),this.trigger)for(const i of this.trigger)i.classList.remove("popupTriggerArea")}forceHide(){f(this,xr,this.isVisible),n(this,xr)&&(n(this,Gt).hidden=!0)}maybeShow(){n(this,os)||(b(this,q,_u).call(this),n(this,xr)&&(n(this,ls)||b(this,q,Pu).call(this),f(this,xr,!1),n(this,Gt).hidden=!1))}get isVisible(){return!n(this,os)&&n(this,Gt).hidden===!1}}os=new WeakMap,vr=new WeakMap,wf=new WeakMap,vf=new WeakMap,$l=new WeakMap,zl=new WeakMap,Gt=new WeakMap,ki=new WeakMap,Sr=new WeakMap,no=new WeakMap,Vl=new WeakMap,Wl=new WeakMap,Pi=new WeakMap,ls=new WeakMap,mn=new WeakMap,bn=new WeakMap,jt=new WeakMap,yn=new WeakMap,Er=new WeakMap,ud=new WeakMap,An=new WeakMap,Xl=new WeakMap,ro=new WeakMap,xr=new WeakMap,he=new WeakMap,Cr=new WeakMap,q=new WeakSet,_u=function(){var e;if(n(this,mn))return;f(this,mn,new AbortController);const{signal:t}=n(this,mn);for(const s of this.trigger)s.addEventListener("click",n(this,$l),{signal:t}),s.addEventListener("pointerenter",n(this,vf),{signal:t}),s.addEventListener("pointerleave",n(this,wf),{signal:t}),s.classList.add("popupTriggerArea");for(const s of n(this,no))(e=s.container)==null||e.addEventListener("keydown",n(this,vr),{signal:t})},ug=function(){const t=n(this,no).find(e=>e.hasCommentButton);t&&f(this,yn,t._normalizePoint(t.commentButtonPosition))},fg=function(){if(n(this,he).extraPopupElement&&!n(this,he).editor)return;n(this,jt)||this.renderCommentButton();const[t,e]=n(this,yn),{style:s}=n(this,jt);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},pg=function(){n(this,he).extraPopupElement||(n(this,jt)||this.renderCommentButton(),n(this,jt).style.backgroundColor=this.commentButtonColor||"")},Tu=function(){const t=n(this,An),e=n(this,ki);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&n(this,An).html||null},gg=function(){var t,e,s;return((s=(e=(t=n(this,q,Tu))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},By=function(){var t,e,s;return((s=(e=(t=n(this,q,Tu))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},Hy=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,q,By),fontSize:n(this,q,gg)?`calc(${n(this,q,gg)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
52`))e.push({name:"span",value:r,attributes:i});return s},Uy=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,Pi))&&b(this,q,ku).call(this)},Gy=function(){if(n(this,bn)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=n(this,Vl);let a=!!n(this,Wl),o=a?n(this,Wl):n(this,ud);for(const y of n(this,no))if(!o||D.intersect(y.data.rect,o)!==null){o=y.data.rect,a=!0;break}const l=D.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),c=a?o[2]-o[0]+5:0,d=l[0]+c,u=l[1];f(this,bn,[100*(d-i)/e,100*(u-r)/s]);const{style:g}=n(this,Gt);g.left=`${n(this,bn)[0]}%`,g.top=`${n(this,bn)[1]}%`},ku=function(){if(n(this,os)){n(this,os).toggleCommentPopup(this,!1);return}f(this,Pi,!n(this,Pi)),n(this,Pi)?(b(this,q,Pu).call(this),n(this,Gt).addEventListener("click",n(this,$l)),n(this,Gt).addEventListener("keydown",n(this,vr))):(b(this,q,mg).call(this),n(this,Gt).removeEventListener("click",n(this,$l)),n(this,Gt).removeEventListener("keydown",n(this,vr)))},Pu=function(){n(this,ls)||this.render(),this.isVisible?n(this,Pi)&&n(this,Gt).classList.add("focused"):(b(this,q,Gy).call(this),n(this,Gt).hidden=!1,n(this,Gt).style.zIndex=parseInt(n(this,Gt).style.zIndex,10)+1e3)},mg=function(){n(this,Gt).classList.remove("focused"),!(n(this,Pi)||!this.isVisible)&&(n(this,Gt).hidden=!0,n(this,Gt).style.zIndex=parseInt(n(this,Gt).style.zIndex,10)-1e3)};
52class jy extends Mt{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 fd;class Bw extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,fd,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=f(this,fd,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,fd)}addHighlightArea(){this.container.classList.add("highlightArea")}}fd=new WeakMap;var pd;class Hw extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,pd,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=f(this,pd,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",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,pd)}addHighlightArea(){this.container.classList.add("highlightArea")}}pd=new WeakMap;var gd;class Uw extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,gd,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=f(this,gd,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,gd)}addHighlightArea(){this.container.classList.add("highlightArea")}}gd=new WeakMap;var md;class $y extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,md,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle: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,u=s.length;d<u;d+=2){const g=s[d]-e[0],y=e[3]-s[d+1];h.push(`${g},${y}`)}h=h.join(" ");const c=f(this,md,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,md)}addHighlightArea(){this.container.classList.add("highlightArea")}}md=new WeakMap;class Gw extends $y{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class jw extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}
52var bd,ao,yd,bg;class hm extends Mt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,yd);m(this,bd,null);m(this,ao,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?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,yd,bg).call(this,s,e),c=this.svgFactory.create(l,h,!0),d=f(this,bd,this.svgFactory.createElement("svg:g"));c.append(d),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",o);for(const u of i){const g=this.svgFactory.createElement(this.svgElementName);n(this,ao).push(g),g.setAttribute("points",u.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,bd);if(s>=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,ao).length;o<l;o++)n(this,ao)[o].setAttribute("points",i[o].join(","));if(r){const{transform:o,width:l,height:h}=b(this,yd,bg).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return n(this,ao)}addHighlightArea(){this.container.classList.add("highlightArea")}}bd=new WeakMap,ao=new WeakMap,yd=new WeakSet,bg=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 zy extends Mt{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 $w extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class zw extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Vw extends Mt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Vy extends Mt{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}}
52var Ad,wd,yg;class Ww extends Mt{constructor(e){var r;super(e,{isRenderable:!0});m(this,wd);m(this,Ad,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,wd,yg).bind(this)),f(this,Ad,i);const{isMac:r}=gt.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&b(this,wd,yg).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,Ad)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ad=new WeakMap,wd=new WeakSet,yg=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 Yl,oo,wn,Io,Xy,Ag;class Wy extends Mt{constructor(e){super(e,{isRenderable:!!e.data.richMedia});m(this,Io);m(this,Yl,new AbortController);m(this,oo,null);m(this,wn,null)}render(){this.container.classList.add("mediaAnnotation");const{filename:e}=this.data.richMedia,s=document.createElement("button");return s.className="mediaPlayButton",s.type="button",s.title=s.ariaLabel=e,s.addEventListener("click",()=>b(this,Io,Xy).call(this,s),{signal:n(this,Yl).signal}),this.container.append(s),this.container}destroy(){n(this,Yl).abort(),n(this,wn)&&(n(this,wn).pause(),n(this,wn).removeAttribute("src"),n(this,wn).load(),f(this,wn,null)),b(this,Io,Ag).call(this)}}Yl=new WeakMap,oo=new WeakMap,wn=new WeakMap,Io=new WeakSet,Xy=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,Yl),l=URL.createObjectURL(new Blob([a],{type:r}));f(this,oo,l);const h=r.startsWith("audio/"),c=document.createElement(h?"audio":"video");if(f(this,wn,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,u=!1;const g=()=>{c.controls=d||u};this.container.addEventListener("pointerenter",()=>{d=!0,g()},{signal:o}),this.container.addEventListener("pointerleave",()=>{d=!1,g()},{signal:o}),this.container.addEventListener("focusin",()=>{u=!0,g()},{signal:o}),this.container.addEventListener("focusout",()=>{u=!1,g()},{signal:o})}c.addEventListener("emptied",()=>b(this,Io,Ag).call(this,l),{once:!0,signal:o}),e.replaceWith(c),c.play().catch(()=>{})},Ag=function(e=n(this,oo)){e&&e===n(this,oo)&&(URL.revokeObjectURL(e),f(this,oo,null))};var _r,lo,Kl,vn,ql,ho,ke,vd,Ui,Mu,Du;const wm=class wm{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:
52a,structTreeLayer:o,commentManager:l,linkService:h,annotationStorage:c}){m(this,Ui);m(this,_r,null);m(this,lo,null);m(this,Kl,null);m(this,vn,new Map);m(this,ql,null);m(this,ho,null);m(this,ke,[]);m(this,vd,!1);T(this,"zIndex",0);this.div=t,f(this,_r,e),f(this,lo,s),f(this,ql,o||null),f(this,ho,h||null),f(this,Kl,c||new am),this.page=r,this.viewport=a,this._annotationEditorUIManager=i,this._commentManager=l||null}hasEditableAnnotations(){return n(this,vn).size>0}async render(t){var l;const{annotations:e,optionalContentConfig:s}=t,i=this.div;ko(i,this.viewport);const r=new Map,a=[],o={data:null,layer:i,linkService:n(this,ho),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Zu,annotationStorage:n(this,Kl),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===Lt.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=ip.create(o);if(!d.isRenderable)continue;c||(n(this,ke).push(d),h.popupRef&&r.getOrInsertComputed(h.popupRef,Sh).push(d));const u=d.render();h.hidden&&(u.style.visibility="hidden"),d.updateOC(s),d._isEditable&&(n(this,vn).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}await b(this,Ui,Mu).call(this);for(const h of a){const c=o.elements=r.get(h.id);o.data=h;const d=ip.create(o);if(!d.isRenderable)continue;const u=d.render();d.contentElement.id=`${jo}${h.id}`,h.hidden&&(u.style.visibility="hidden"),c.at(-1).container.after(u)}b(this,Ui,Du).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:n(this,ho),svgFactory:new Zu,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=wm._defaultBorderStyle),e.data=s;const i=ip.create(e);i.isRenderable&&(i.render(),i.contentElement.id=`${jo}${s.id}`,n(this,ke).push(i))}await b(this,Ui,Mu).call(this)}update({viewport:t,optionalContentConfig:e}){const s=this.div;this.viewport=t,ko(s,{rotation:t.rotation});for(const i of n(this,ke))i.updateOC(e);b(this,Ui,Du).call(this),s.hidden=!1}destroy(){var t,e;for(const s of n(this,ke))(t=s.destroy)==null||t.call(s),(e=n(this,_r))==null||e.removePointerInTextLayer(s.contentElement);n(this,ke).length=0,n(this,vn).clear(),this.div.replaceChildren()}refreshCanvases(){b(this,Ui,Du).call(this)}getEditableAnnotations(){return n(this,vn).values()}getEditableAnnotation(t){return n(this,vn).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:i}=t,r=new Pw({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:n(this,ho),annotationStorage:n(this,Kl)});return r.render(),r.contentElement.id=`${jo}${s}`,r.createOrUpdatePopup(),n(this,ke).push(r),r}removeAnnotation(t){var i;const e=n(this,ke).findIndex(r=>r.data.id===t);if(e<0)return;const[s]=n(this,ke).splice(e,1);(i=n(this,_r))==null||i.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);b(this,Ui,Mu).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return j(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:No.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};_r=new WeakMap,lo=new WeakMap,Kl=new WeakMap,vn=new WeakMap,ql=new WeakMap,ho=new WeakMap,ke=new WeakMap,vd=new WeakMap,Ui=new WeakSet,Mu=async function(){var s,i,r,a;if(n(this,ke).length===0)return;this.div.replaceChildren();const t=[];if(!n(this,vd)){f(this,vd,!0);for(const{contentElement:o,data:{hidden:l,id:h,oc:c}}of n(this,ke)){const d=o.id=`${jo}${h}`,u=o.localName==="a"&&!l&&!c;t.push((s=n(this,ql))==null?void 0:s.getAriaAttributes(d,{enableLinkOwnership:u}).then(g=>{if(g)for(const[y,A]of g)o.setAttribute(y,A)}))}}n(this,ke).sort(({data:{rect:[o,l,h,c]}},{data:{rect:[d,u,g,y]}})=>{if(o===h&&l===c)return 1;if(d===g&&u===y)return-1;const A=c,S=l,w=(l+c)/2,v=y,E=u,x=(u+y)/2;if(w>=v&&x<=S)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,ke))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,_r)){const o=await((a=n(this,ql))==null?void 0:a.getAnnotationIds());for(const{contentElement:l}of n(this,ke))o!=null&&o.has(l.id)||n(this,_r).addPointerInTextLayer(l,!1)}},Du=function(){var e;if(!n(this,lo))return;const t=this.div;for(const[s,i]of n(this,lo)){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,u=i.length;d<u;d++)c.after(i[d]),c=i[d]}n(this,lo).delete(s);const h=n(this,vn).get(s);h&&(h._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,r.id,i),h._hasNoCanvas=!1):h.canvas=i)}};let wg=wm;const su=/\r\n?|\n/g;var hs,Sd,co,cs,Jt,Yy,Ky,qy,Iu,In,Lu,Fu,Qy,Sg,Jy;const St=class St extends bt{constructor(e){super({...e,name:"freeTextEditor"});m(this,Jt);m(this,hs,"");m(this,Sd,`${this.id}-editor`);m(this,co,null);m(this,cs);T(this,"_colorPicker",null);this.color=e.color||St._defaultColor||bt._defaultLineColor,f(this,cs,e.fontSize||St._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert(bt._l10nAlert.freetext),this.canAddComment=!1}static get _keyboardManager(){const e=St.prototype,s=a=>a.isEmpty(),i=Mo.TRANSLATE_SMALL,r=Mo.TRANSLATE_BIG;return j(this,"_keyboardManager",new Po([[["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){bt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}
52static updateDefaultParams(e,s){switch(e){case et.FREETEXT_SIZE:St._defaultFontSize=s;break;case et.FREETEXT_COLOR:St._defaultColor=s;break}}updateParams(e,s){switch(e){case et.FREETEXT_SIZE:b(this,Jt,Yy).call(this,s);break;case et.FREETEXT_COLOR:b(this,Jt,Ky).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[et.FREETEXT_SIZE,St._defaultFontSize],[et.FREETEXT_COLOR,St._defaultColor||bt._defaultLineColor]]}get propertiesToUpdate(){return[[et.FREETEXT_SIZE,n(this,cs)],[et.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Ju(this)),[["colorPicker",this._colorPicker]]}get colorType(){return et.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[-St._internalPadding*e,-(St._internalPadding+n(this,cs))*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"),f(this,co,new AbortController);const e=this._uiManager.combinedSignal(n(this,co));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",n(this,Sd)),this._isDraggable=!0,(e=n(this,co))==null||e.abort(),f(this,co,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=n(this,hs),s=f(this,hs,b(this,Jt,qy).call(this).trimEnd());if(e===s)return;const i=r=>{if(f(this,hs,r),!r){this.remove();return}b(this,Jt,Fu).call(this),this._uiManager.rebuild(this),b(this,Jt,Iu).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),b(this,Jt,Iu).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){St._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,Sd)),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,cs)}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;
52if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[c,d]=this.pageDimensions,[u,g]=this.pageTranslation;let y,A;switch(this.rotation){case 0:y=e+(o[0]-u)/c,A=s+this.height-(o[1]-g)/d;break;case 90:y=e+(o[0]-u)/c,A=s-(o[1]-g)/d,[l,h]=[h,-l];break;case 180:y=e-this.width+(o[0]-u)/c,A=s-(o[1]-g)/d,[l,h]=[-l,-h];break;case 270:y=e+(o[0]-u-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,Jt,Fu).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,S;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const r=b(y=St,In,Sg).call(y,s.getData("text")||"").replaceAll(su,`
53`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(`
54`)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:h}=o,c=[],d=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(d.push(l.nodeValue.slice(h).replaceAll(su,"")),w!==this.editorDiv){let v=c;for(const E of this.editorDiv.childNodes){if(E===w){v=d;continue}v.push(b(A=St,In,Lu).call(A,E))}}c.push(l.nodeValue.slice(0,h).replaceAll(su,""))}else if(l===this.editorDiv){let w=c,v=0;for(const E of this.editorDiv.childNodes)v++===h&&(w=d),w.push(b(S=St,In,Lu).call(S,E))}f(this,hs,`${c.join(`
55`)}${r}${d.join(`
56`)}`),b(this,Jt,Fu).call(this);const u=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 v=w.nodeValue.length;if(g<=v){u.setStart(w,g),u.setEnd(w,g);break}g-=v}a.removeAllRanges(),a.addRange(u)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=St._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,i){var o;let r=null;if(e instanceof jy){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:c,rotation:d,id:u,popupRef:g,richText:y,contentsObj:A,creationDate:S,modificationDate:w},textContent:v,textPosition:E,parent:{page:{pageNumber:x}}}=e;if(!(v!=null&&v.length))return null;r=e={annotationType:W.FREETEXT,color:Array.from(h),fontSize:l,value:v.join(`
57`),position:E,pageIndex:x-1,rect:c.slice(0),rotation:d,annotationElementId:u,id:u,deleted:!1,popupRef:g,comment:(A==null?void 0:A.str)||null,richText:y,creationDate:S,modificationDate:w}}const a=await super.deserialize(e,s,i);return f(a,cs,e.fontSize),a.color=D.makeHexColor(...e.color),f(a,hs,b(o=St,In,Sg).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=bt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(e),{color:s,fontSize:n(this,cs),value:b(this,Jt,Qy).call(this)});return this.addComment(i),e?(i.isCopy=!0,i):this.annotationElementId&&!b(this,Jt,Jy).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,cs)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const r of n(this,hs).split(`
58`)){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,hs)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};hs=new WeakMap,Sd=new WeakMap,co=new WeakMap,cs=new WeakMap,Jt=new WeakSet,Yy=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,cs))*this.parentScale),f(this,cs,r),b(this,Jt,Iu).call(this)},i=n(this,cs);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:et.FREETEXT_S
58IZE,overwriteIfSameType:!0,keepUndo:!0})},Ky=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:et.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},qy=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=St,In,Lu).call(i,r)),s=r);return e.join(`
59`)},Iu=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()},In=new WeakSet,Lu=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(su,"")},Fu=function(){if(this.editorDiv.replaceChildren(),!!n(this,hs))for(const e of n(this,hs).split(`
60`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Qy=function(){return n(this,hs).replaceAll(" "," ")},Sg=function(e){return e.replaceAll(" "," ")},Jy=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(St,In),T(St,"_freeTextDefaultContent",""),T(St,"_internalPadding",0),T(St,"_defaultColor",null),T(St,"_defaultFontSize",10),T(St,"_type","freetext"),T(St,"_editorType",W.FREETEXT);let vg=St;var uo;class cm{constructor(){m(this,uo,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,uo)[t]=e}toSVGProperties(){const t=n(this,uo);return f(this,uo,Object.create(null)),{root:t}}reset(){f(this,uo,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){st("Not implemented")}}uo=new WeakMap;var Ql,Jl,Kt,fo,po,Zl,z,Eg,xg,Cg,_g,$h,Tg,kg,Pg,zh,Zy,Ru,Vh,Go;const K=class K extends bt{constructor(e){super(e);m(this,z);m(this,Ql,null);m(this,Jl);T(this,"_clipPathId",null);T(this,"_colorPicker",null);T(this,"_drawId",null);T(this,"_drawOutlines",null);T(this,"_focusDrawId",null);f(this,Jl,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,z,Eg).call(this,e),b(this,z,zh).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){st("Not implemented")}static get typesMap(){st("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(K,Kt).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,z,Vh).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,u)=>{var g;o.updateProperty(r,d),o.updateProperty(a,u),this._drawOutlines.updateProperty(r,d),this._drawOutlines.updateProperty(a,u),(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,K._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(b(this,z,Ru).call(this)),{bbox:b(this,z,Go).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,K._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(b(this,z,Ru).call(this)),{bbox:b(this,z,Go).call(this)})),b(this,z,_g).call(this)}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,z,Go).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,K._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(b(this,z,Ru).call(this),this.parentDimensions),{bbox:b(this,z,Go).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,Jl)&&(f(this,Jl,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this._uiManager.removeShouldRescale(this),b(this,z,Pg).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,z,zh).call(this),b(this,z,Vh).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,z,Pg).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,z,zh).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),b(this,z,Tg).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,K._mergeSVGProperties({bbox:b(this,z,Go).call(this,e)},this._drawOutlines.updateRotation(s))),b(this,z,_g).call(this,s)}show(e=this._isVisible){super.show(e),b(this,z,Tg).call(this)}select(){super.select(),b(this,z,$h).call(this,{hovered:!1,selected:!0})}unselect(){super.unselect(),b(this,z,$h).call(this,{selected:!1})}pointerover(){this.isSelected||b(this,z,$h).call(this,{hovered:!0})}pointerleave(){this.isSelected||b(this,z,$h).call(this,{hovered:!1})}onScaleChanging(){if(!this.parent)return;const e=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);e&&b(this,z,Vh).call(this,e)}static onScaleChangingWhenDrawing(){}
60render(){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=f(this,Ql,document.createElement("div"));return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this._clipPathId&&(r.style.clipPath=this._clipPathId),Ab(this,r,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e){st("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(xe.isInitializedAndDifferentPointerType(o))return;const l=this._getDrawingTarget(e,r),[h,c]=this._getPointerCoords(r),{viewport:{rotation:d}}=e,{x:u,y:g,width:y,height:A}=l.getBoundingClientRect(),S=f(K,fo,new AbortController),w=e.combinedSignal(S);if(xe.setPointer(o,a),window.addEventListener("pointerup",C=>{xe.isSamePointerIdOrRemove(C.pointerId)&&this._endDraw(C)},{signal:w}),window.addEventListener("pointercancel",C=>{xe.isSamePointerIdOrRemove(C.pointerId)&&this._endDrawingSession()},{signal:w}),window.addEventListener("pointerdown",C=>{xe.isSamePointerType(C.pointerType)&&(xe.initializeAndAddPointerId(C.pointerId),n(K,Kt).isCancellable()&&(n(K,Kt).removeLastElement(),n(K,Kt).isEmpty()?this._endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:w}),window.addEventListener("contextmenu",ni,{signal:w}),l.addEventListener("pointermove",this._drawMove.bind(this),{signal:w}),l.addEventListener("touchmove",C=>{xe.isSameTimeStamp(C.timeStamp)&&se(C)},{signal:w}),this._addDrawingListeners(l,w),e.toggleDrawing(),(x=s._editorUndoBar)==null||x.hide(),n(K,Kt)){e.drawLayer.updateProperties(this._currentDrawId,n(K,Kt).startNew(h,c,y,A,d));return}s.updateUIForDefaultProperties(this),f(K,Kt,this.createDrawerInstance({x:h,y:c,box:[u,g,y,A],rotation:d,parent:e,isLTR:i})),f(K,po,this.getDefaultDrawingOptions()),this._currentParent=e;const{id:v,clipPathId:E}=e.drawLayer.draw(this._mergeSVGProperties(n(K,po).toSVGProperties(),n(K,Kt).defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=v,f(K,Zl,this._hasClipPath?E:null)}static _drawMove(e){var r;if(xe.isSameTimeStamp(e.timeStamp),!n(K,Kt)||!xe.isSamePointerId(e.pointerId))return;if(xe.isUsingMultiplePointers()){this._endDraw(e);return}let s;const i=(r=e.getCoalescedEvents)==null?void 0:r.call(e);if(i!=null&&i.length){const a=[];for(const o of i)a.push(...this._getPointerCoords(o,e));s=n(K,Kt).addPoints(a)}else s=n(K,Kt).add(...this._getPointerCoords(e));this._currentParent.drawLayer.updateProperties(this._currentDrawId,s),xe.setTimeStamp(e.timeStamp),se(e)}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,f(K,Kt,null),f(K,po,null),f(K,Zl,null),xe.clearTimeStamp()),n(K,fo)&&(n(K,fo).abort(),f(K,fo,null),xe.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(K,Kt).end(...this._getPointerCoords(e)):n(K,Kt).end()),this.supportMultipleDrawings){const i=n(K,Kt),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:et.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(et.DRAW_STEP),!n(K,Kt).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:n(K,Zl),drawOutlines:n(K,Kt).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(K,po),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){st("Not implemented")}static async deserialize(e,s,i){var d,u;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);
60return c.createDrawingOptions(e),b(d=c,z,Eg).call(d,{drawOutlines:h}),b(u=c,z,zh).call(u),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}};Ql=new WeakMap,Jl=new WeakMap,Kt=new WeakMap,fo=new WeakMap,po=new WeakMap,Zl=new WeakMap,z=new WeakSet,Eg=function({drawOutlines:e,drawId:s,drawingOptions:i,clipPathId:r}){this._drawOutlines=e,this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(bt._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this._clipPathId=r??null,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties),b(this,z,Cg).call(this,this.parent)):this._drawId=b(this,z,xg).call(this,e,this.parent),b(this,z,Vh).call(this,e.box)},xg=function(e,s){const{id:i,clipPathId:r}=s.drawLayer.draw(K._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,this.constructor._hasClipPath);return this.constructor._hasClipPath&&(this._clipPathId=r),b(this,z,Cg).call(this,s),i},Cg=function(e){const s=this._drawOutlines.getFocusSVGProperties(n(this,z,kg));s&&(this._focusDrawId=e.drawLayer.drawOutline(s,this._drawOutlines.focusMustRemoveSelfIntersections))},_g=function(e=n(this,z,kg)){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(e)))},$h=function(e){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,{rootClass:e}))},Tg=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})},kg=function(){return(this.parentRotation-this._drawRotation+360)%360},Pg=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()},zh=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,z,xg).call(this,this._drawOutlines,e),this._clipPathId&&n(this,Ql)&&(n(this,Ql).style.clipPath=this._clipPathId)}},Zy=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]}},Ru=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]}},Vh=function(e){[this.x,this.y,this.width,this.height]=b(this,z,Zy).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Go=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(K,"_currentDrawId",-1),T(K,"_currentParent",null),m(K,Kt,null),m(K,fo,null),m(K,po,null),m(K,Zl,null),T(K,"_INNER_MARGIN",3);let nc=K;class O{constructor(){T(this,"focusOutline",null)}toSVGPath(){st("Abstract method `toSVGPath` must be implemented.")}get box(){st("Abstract getter `box` must be implemented.")}serialize(t,e){st("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){st("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;
60o+=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 ds,Os,th,eh,Js,J,go,mo,Ed,xd,sh,ih,Mi,Cd,Sf,Ef,ie,Wh,tA,eA,sA,iA,nA,rA;const Wi=class Wi{constructor(t,e,s,i,r,a,o=0){m(this,ie);m(this,ds);m(this,Os,[]);m(this,th);m(this,eh);m(this,Js,[]);m(this,J,new Float32Array(18));m(this,go);m(this,mo);m(this,Ed);m(this,xd);m(this,sh);m(this,ih);m(this,Mi,[]);f(this,ds,s),f(this,ih,r*i),f(this,eh,a),n(this,J).set([NaN,NaN,NaN,NaN,t,e],6),f(this,th,o),f(this,xd,n(Wi,Cd)*i),f(this,Ed,n(Wi,Ef)*i),f(this,sh,i),n(this,Mi).push(t,e)}isEmpty(){return isNaN(n(this,J)[8])}isCancellable(){return n(this,Mi).length<=10}removeLastElement(){return n(this,J).fill(NaN),n(this,Js).length=n(this,Os).length=n(this,Mi).length=0,{path:{d:""}}}add(t,e){var M;f(this,go,t),f(this,mo,e);const[s,i,r,a]=n(this,ds);let[o,l,h,c]=n(this,J).subarray(8,12);const d=t-h,u=e-c,g=Math.hypot(d,u);if(g<n(this,Ed))return!1;const y=g-n(this,xd),A=y/g,S=A*d,w=A*u;let v=o,E=l;o=h,l=c,h+=S,c+=w,(M=n(this,Mi))==null||M.push(t,e);const x=-w/y,C=S/y,_=x*n(this,ih),k=C*n(this,ih);return n(this,J).set(n(this,J).subarray(2,8),0),n(this,J).set([h+_,c+k],4),n(this,J).set(n(this,J).subarray(14,18),12),n(this,J).set([h-_,c-k],16),isNaN(n(this,J)[6])?(n(this,Js).length===0&&(n(this,J).set([o+_,l+k],2),n(this,Js).push(NaN,NaN,NaN,NaN,(o+_-s)/r,(l+k-i)/a),n(this,J).set([o-_,l-k],14),n(this,Os).push(NaN,NaN,NaN,NaN,(o-_-s)/r,(l-k-i)/a)),n(this,J).set([v,E,o,l,h,c],6),!this.isEmpty()):(n(this,J).set([v,E,o,l,h,c],6),Math.abs(Math.atan2(E-l,v-o)-Math.atan2(w,S))<Math.PI/2?([o,l,h,c]=n(this,J).subarray(2,6),n(this,Js).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,v,E]=n(this,J).subarray(14,18),n(this,Os).push(NaN,NaN,NaN,NaN,((v+o)/2-s)/r,((E+l)/2-i)/a),!0):([v,E,o,l,h,c]=n(this,J).subarray(0,6),n(this,Js).push(((v+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,v,E]=n(this,J).subarray(12,18),n(this,Os).push(((v+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,Js),e=n(this,Os);if(isNaN(n(this,J)[6])&&!this.isEmpty())return b(this,ie,tA).call(this);const s=[];
60s.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,ie,sA).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,ie,eA).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new aA(t,e,s,i,r,a)}getOutlines(){var d;const t=n(this,Js),e=n(this,Os),s=n(this,J),[i,r,a,o]=n(this,ds),l=new Float32Array((((d=n(this,Mi))==null?void 0:d.length)??0)+2);for(let u=0,g=l.length-2;u<g;u+=2)l[u]=(n(this,Mi)[u]-i)/a,l[u+1]=(n(this,Mi)[u+1]-r)/o;if(l[l.length-2]=(n(this,go)-i)/a,l[l.length-1]=(n(this,mo)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,ie,iA).call(this,l);const h=new Float32Array(n(this,Js).length+24+n(this,Os).length);let c=t.length;for(let u=0;u<c;u+=2){if(isNaN(t[u])){h[u]=h[u+1]=NaN;continue}h[u]=t[u],h[u+1]=t[u+1]}c=b(this,ie,rA).call(this,h,c);for(let u=e.length-6;u>=6;u-=6)for(let g=0;g<6;g+=2){if(isNaN(e[u+g])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[u+g],h[c+1]=e[u+g+1],c+=2}return b(this,ie,nA).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,ds),n(this,sh),n(this,th),n(this,eh))}};ds=new WeakMap,Os=new WeakMap,th=new WeakMap,eh=new WeakMap,Js=new WeakMap,J=new WeakMap,go=new WeakMap,mo=new WeakMap,Ed=new WeakMap,xd=new WeakMap,sh=new WeakMap,ih=new WeakMap,Mi=new WeakMap,Cd=new WeakMap,Sf=new WeakMap,Ef=new WeakMap,ie=new WeakSet,Wh=function(){const t=n(this,J).subarray(4,6),e=n(this,J).subarray(16,18),[s,i,r,a]=n(this,ds);return[(n(this,go)+(t[0]-e[0])/2-s)/r,(n(this,mo)+(t[1]-e[1])/2-i)/a,(n(this,go)+(e[0]-t[0])/2-s)/r,(n(this,mo)+(e[1]-t[1])/2-i)/a]},tA=function(){const[t,e,s,i]=n(this,ds),[r,a,o,l]=b(this,ie,Wh).call(this);return`M${(n(this,J)[2]-t)/s} ${(n(this,J)[3]-e)/i} L${(n(this,J)[4]-t)/s} ${(n(this,J)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,J)[16]-t)/s} ${(n(this,J)[17]-e)/i} L${(n(this,J)[14]-t)/s} ${(n(this,J)[15]-e)/i} Z`},eA=function(t){const e=n(this,Os);t.push(`L${e[4]} ${e[5]} Z`)},sA=function(t){const[e,s,i,r]=n(this,ds),a=n(this,J).subarray(4,6),o=n(this,J).subarray(16,18),[l,h,c,d]=b(this,ie,Wh).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}`)},iA=function(t){const e=n(this,J),[s,i,r,a]=n(this,ds),[o,l,h,c]=b(this,ie,Wh).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,ds),n(this,sh),n(this,th),n(this,eh))},nA=function(t,e){const s=n(this,Os);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},rA=function(t,e){const s=n(this,J).subarray(4,6),i=n(this,J).subarray(16,18),[r,a,o,l]=n(this,ds),[h,c,d,u]=b(this,ie,Wh).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,u,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},m(Wi,Cd,8),m(Wi,Sf,2),m(Wi,Ef,n(Wi,Cd)+n(Wi,Sf));let tf=Wi;var nh,Di,Sn,_d,Zs,Td,Nt,xf,oA;class aA extends O{constructor(e,s,i,r,a,o){super();m(this,xf);m(this,nh);m(this,Di,new Float32Array(4));m(this,Sn);m(this,_d);m(this,Zs);m(this,Td);m(this,Nt);f(this,Nt,e),f(this,Zs,s),f(this,nh,i),f(this,Td,r),f(this,Sn,a),f(this,_d,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,xf,oA).call(this,o);const[l,h,c,d]=n(this,Di);for(let u=0,g=e.length;u<g;u+=2)e[u]=(e[u]-l)/c,e[u+1]=(e[u+1]-h)/d;for(let u=0,g=s.length;u<g;u+=2)s[u]=(s[u]-l)/c,s[u+1]=(s[u+1]-h)/d}toSVGPath(){const e=[`M${n(this,Nt)[4]} ${n(this,Nt)[5]}`];for(let s=6,i=n(this,Nt).length;s<i;s+=6){if(isNaN(n(this,Nt)[s])){e.push(`L${n(this,Nt)[s+4]} ${n(this,Nt)[s+5]}`);continue}e.push(`C${n(this,Nt)[s]} ${n(this,Nt)[s+1]} ${n(this,Nt)[s+2]} ${n(this,Nt)[s+3]} ${n(this,Nt)[s+4]} ${n(this,Nt)[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,Nt),e,r,o,-l),c=O._rescale(n(this,Zs),e,r,o,-l);break;case 90:h=O._rescaleAndSwap(n(this,Nt),e,s,o,l),c=O._rescaleAndSwap(n(this,Zs),e,s,o,l);break;case 180:h=O._rescale(n(this,Nt),i,s,-o,l),c=O._rescale(n(this,Zs),i,s,-o,l);break;case 270:h=O._rescaleAndSwap(n(this,Nt),i,r,-o,-l),c=O._rescaleAndSwap(n(this,Zs),i,r,
60-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,Di)}newOutliner(e,s,i,r,a,o,l=0){return new tf(e,s,i,r,a,o,l)}updateThickness(e){const s=this.getNewOutline(e);return f(this,Nt,n(s,Nt)),f(this,Zs,n(s,Zs)),n(this,Di).set(n(s,Di)),this.firstPoint=s.firstPoint,this.lastPoint=s.lastPoint,n(this,Di)}getNewOutline(e,s){const[i,r,a,o]=n(this,Di),[l,h,c,d]=n(this,nh),u=a*c,g=o*d,y=i*c+l,A=r*d+h,S=n(this,Zs),w=this.newOutliner(S[0]*u+y,S[1]*g+A,n(this,nh),n(this,Td),e,n(this,_d),s??n(this,Sn));for(let v=2,E=S.length;v<E;v+=2)w.add(S[v]*u+y,S[v+1]*g+A);return w.getOutlines()}}nh=new WeakMap,Di=new WeakMap,Sn=new WeakMap,_d=new WeakMap,Zs=new WeakMap,Td=new WeakMap,Nt=new WeakMap,xf=new WeakSet,oA=function(e){const s=n(this,Nt);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,u=new Float32Array(4);for(let y=6,A=s.length;y<A;y+=6){const S=s[y+4],w=s[y+5];isNaN(s[y])?(D.pointBoundingBox(S,w,a),l>w?(o=S,l=w):l===w&&(o=d(o,S)),c<w?(h=S,c=w):c===w&&(h=d(h,S))):(u.set(Mn,0),D.bezierBoundingBox(i,r,...s.slice(y,y+6),u),D.rectBoundingBox(...u,a),l>u[1]?(o=u[0],l=u[1]):l===u[1]&&(o=d(o,u[0])),c<u[3]?(h=u[2],c=u[3]):c===u[3]&&(h=d(h,u[2]))),i=S,r=w}const g=n(this,Di);g[0]=a[0]-n(this,Sn),g[1]=a[1]-n(this,Sn),g[2]=a[2]-a[0]+2*n(this,Sn),g[3]=a[3]-a[1]+2*n(this,Sn),this.firstPoint=[o,l],this.lastPoint=[h,c]};function lA(p){return{bbox:p.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:p.isFree},path:{d:p.toSVGPath()}}}function hA(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 kd,Pd,Md,Tr,ti,Ge,cA,Ou,dA,uA,Dg;class Mg{constructor(t,e=0,s=0,i=!0){m(this,Ge);m(this,kd);m(this,Pd);m(this,Md);m(this,Tr,[]);m(this,ti,[]);const r=Mn.slice(),o=10**-4;for(const{x:S,y:w,width:v,height:E}of t){const x=Math.floor((S-e)/o)*o,C=Math.ceil((S+v+e)/o)*o,_=Math.floor((w-e)/o)*o,k=Math.ceil((w+E+e)/o)*o,P=[x,_,k,!0],M=[C,_,k,!1];n(this,Tr).push(P,M),D.rectBoundingBox(x,_,C,k,r)}const l=r[2]-r[0]+2*s,h=r[3]-r[1]+2*s,c=r[0]-s,d=r[1]-s;let u=i?-1/0:1/0,g=1/0;const y=n(this,Tr).at(i?-1:-2),A=[y[0],y[2]];for(const S of n(this,Tr)){const[w,v,E,x]=S;!x&&i?v<g?(g=v,u=w):v===g&&(u=Math.max(u,w)):x&&!i&&(v<g?(g=v,u=w):v===g&&(u=Math.min(u,w))),S[0]=(w-c)/l,S[1]=(v-d)/h,S[2]=(E-d)/h}f(this,kd,new Float32Array([c,d,l,h])),f(this,Pd,[u,g]),f(this,Md,A)}getOutlines(){n(this,Tr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,Tr))e[3]?(t.push(...b(this,Ge,Dg).call(this,e)),b(this,Ge,dA).call(this,e)):(b(this,Ge,uA).call(this,e),t.push(...b(this,Ge,Dg).call(this,e)));return b(this,Ge,cA).call(this,t)}}kd=new WeakMap,Pd=new WeakMap,Md=new WeakMap,Tr=new WeakMap,ti=new WeakMap,Ge=new WeakSet,cA=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 u=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,u!==o&&(r.push(u,g,o,g===l?l:h),u=o),g=g===l?h:l}r.push(u,g)}return new Ig(i,n(this,kd),n(this,Pd),n(this,Md))},Ou=function(t){const e=n(this,ti);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},dA=function([,t,e]){const s=b(this,Ge,Ou).call(this,t);n(this,ti).splice(s,0,[t,e])},uA=function([,t,e]){const s=b(this,Ge,Ou).call(this,t);for(let i=s;i<n(this,ti).length;i++){const[r,a]=n(this,ti)[i];if(r!==t)break;if(r===t&&a===e){n(this,ti).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,ti)[i];if(r!==t)break;if(r===t&&a===e){n(this,ti).splice(i,1);return}}},Dg=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,Ge,Ou).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,ti)[o];for(let c=0,d=r.length;c<d;c++){const[,u,g]=r[c];if(!(h<=u||g<=l)){if(u>=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 Dd,Id,rh;class Ig extends O{constructor(e,s,i,r){super();m(this,Dd);m(this,Id,null);m(this,rh);f(this,rh,e),f(this,Dd,s),this.firstPoint=i,this.lastPoint=r}static build(e,s){const i=new Mg(e,.001).getOutlines();return f(i,Id,e),i.focusOutline=new Mg(e,.0025,.001,s).getOutlines(),i}get isFree(){return!1}get defaultSVGProperties(){return lA(this)}getFocusSVGProperties(e){return hA(this,e)}updateRotation(e){return{root:{"data-main-rotation":e}}}serializeQuadPoints([e,s],[i,r]){const a=n(this,Id),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:d,height:u}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-u*r,l+=8}return o}toSVGPath(){const e=[];for(const s of n(this,rh)){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,rh)){const d=new Array(c.length);for(let u=0;u<c.length;u+=2)d[u]=e+c[u]*l,d[u+1]=r-c[u+1]*h;o.push(d)}return o}get box(){return n(this,Dd)}}Dd=new WeakMap,Id=new WeakMap,rh=new WeakMap;class dm extends tf{newFreeDrawOutline(t,e,s,i,r,a){return new Lg(t,e,s,i,r,a)}}var us,Ld;class Xw{constructor(t,e,s,i,r,a,o){m(this,us);m(this,Ld);f(this,us,new dm(t,e,s,i,r,a,o)),f(this,Ld,r)}add(t,e){return n(this,us).add(t,e)?{path:{d:n(this,us).toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)e=n(this,us).add(t[s],t[s+1])||e;return e?{path:{d:n(this,us).toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return n(this,us).isEmpty()}isCancellable(){return n(this,us).isCancellable()}removeLastElement(){return n(this,us).removeLastElement()}updateProperty(t,e){return null}getOutlines(){const t=n(this,us).getOutlines();return t.buildFocusOutline(2*n(this,Ld)),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:n(this,us).toSVGPath()}}}}us=new WeakMap,Ld=new WeakMap;var Cf;const _f=class _f extends aA{newOutliner(t,e,s,i,r,a,o=0){return new dm(t,e,s,i,r,a,o)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+n(_f,Cf),.0025)}get defaultSVGProperties(){return lA(this)}getFocusSVGProperties(t){return hA(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()}}}};Cf=new WeakMap,m(_f,Cf,1.5);let Lg=_f;class um extends cm{constructor(t=null){super(),super.updateProperties(t)}updateSVGProperty(t,e){t!=="thickness"&&super.updateSVGProperty(t,e)}clone(){const t=new um;return t.updateAll(this),t}}var ah,Fd,Rd,Od,Nd,oh,ws,Fg,fA,Nu,pA;const Le=class Le extends nc{constructor(e){var s;super({...e,name:"highlightEditor"});m(this,ws);m(this,ah,null);m(this,Fd,0);m(this,Rd,null);m(this,Od,0);m(this,Nd,"");m(this,oh,"");f(this,ah,e.anchorNode||null),f(this,Fd,e.anchorOffset||0),f(this,Rd,e.focusNode||null),f(this,Od,e.focusOffset||0),f(this,Nd,e.methodOfCreation||((s=this._drawOutlines)!=null&&s.isFree?"main_toolbar":"")),f(this,oh,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static get _keyboardManager(){const e=Le.prototype;return j(this,"_keyboardManager",new Po([[["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;bt.initialize(e,s),this._defaultDrawingOptions||(this._defaultDrawingOptions=new um({fill:((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066","fill-opacity":Le._DEFAULT_OPACITY,thickness:Le._DEFAULT_THICKNESS}))}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get typesMap(){return j(this,"typesMap",new Map([[et.HIGHLIGHT_COLOR,"fill"],[et.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||Le.getDefaultDrawingOptions()),s&&(e={...e,drawOutlines:Ig.build(s,this._uiManager.direction==="ltr")}),super._addOutlines(e))}get colorType(){return et.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,Nd)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("
60color").size}}translateInPage(e,s){}get toolbarPosition(){return b(this,ws,Fg).call(this,this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return b(this,ws,Fg).call(this,this._drawOutlines.firstPoint)}updateParams(e,s){switch(e){case et.HIGHLIGHT_COLOR:this._updateColorAndOpacity(s,Le._DEFAULT_OPACITY,e),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(s)},!0);break;case et.HIGHLIGHT_THICKNESS:super.updateParams(e,s),this._reportTelemetry({action:"thickness_changed",thickness:s},!0);break}}get propertiesToUpdate(){const e=super.propertiesToUpdate;return e.push([et.HIGHLIGHT_FREE,this._drawOutlines.isFree]),e}get toolbarButtons(){return this._uiManager.highlightColors?(this._colorPicker=new Qu({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,oh)&&(e.setAttribute("aria-label",n(this,oh)),e.setAttribute("role","mark")),this._drawOutlines.isFree?e.classList.add("free"):e.addEventListener("keydown",b(this,ws,fA).bind(this),{signal:this._uiManager._signal}),this.enableEditing(),e}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,ws,Nu).call(this,!0);break;case 1:case 3:b(this,ws,Nu).call(this,!1);break}}unselect(){super.unselect(),this._drawOutlines.isFree||b(this,ws,Nu).call(this,!1)}static createDrawerInstance({x:e,y:s,box:i,parent:r,isLTR:a}){return new Xw(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",se,{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}=Le;this._drawingOptions=Le.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,S=h.length;A<S;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 Ig.build(y,l.direction==="ltr")}const c=o.thickness||this._defaultDrawingOptions.thickness,d=(o.inkLists||o.outlines.points)[0],u=new dm(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)u.add(d[y]-e,r-(d[y+1]-s));const g=u.getOutlines();return g.buildFocusOutline(c),g}static async deserialize(e,s,i){let r=null;if(e instanceof zy){const{data:{quadPoints:o,rect:l,rotation:h,id:c,color:d,opacity:u,popupRef:g,richText:y,contentsObj:A,creationDate:S,modificationDate:w},parent:{page:{pageNumber:v}}}=e;r=e={annotationType:W.HIGHLIGHT,color:Array.from(d),opacity:u,quadPoints:o,pageIndex:v-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:S,modificationDate:w}}else if(e instanceof hm){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,borderStyle:{rawWidth:u},popupRef:g,richText:y,contentsObj:A,creationDate:S,modificationDate:w},parent:{page:{pageNumber:v}}}=e;r=e={annotationType:W.HIGHLIGHT,color:Array.from(d),thickness:u,inkLists:o,pageIndex:v-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:S,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:bt._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,ws,pA).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)}};ah=new WeakMap,Fd=new WeakMap,Rd=new WeakMap,Od=new WeakMap,Nd=new WeakMap,oh=new WeakMap,ws=new WeakSet,Fg=function([e,s]){const[i,r,a,o]=this._drawOutlines.box;
60return[(e-i)/a,(s-r)/o]},fA=function(e){Le._keyboardManager.exec(this,e)},Nu=function(e){if(!n(this,ah))return;const s=window.getSelection();e?s.setPosition(n(this,ah),n(this,Fd)):s.setPosition(n(this,Rd),n(this,Od))},pA=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},T(Le,"_DEFAULT_OPACITY",1),T(Le,"_DEFAULT_THICKNESS",12),T(Le,"_defaultDrawingOptions",null),T(Le,"_type","highlight"),T(Le,"_editorType",W.HIGHLIGHT);let ef=Le;var Ii,kr,qt,me,bo,lh,be,Qt,Ns,yo,Ao,wo,vs,Bu,Hu,Rg;class Yw{constructor(t,e,s,i,r,a){m(this,vs);m(this,Ii,new Float64Array(6));m(this,kr,new Float64Array(2));m(this,qt);m(this,me);m(this,bo);m(this,lh);m(this,be);m(this,Qt,"");m(this,Ns,0);m(this,yo,new Kd);m(this,Ao);m(this,wo);f(this,Ao,s),f(this,wo,i),f(this,bo,r),f(this,lh,a),[t,e]=b(this,vs,Bu).call(this,t,e);const o=f(this,qt,[NaN,NaN,NaN,NaN,t,e]);f(this,be,[t,e]),f(this,me,[{line:o,points:n(this,be)}]),n(this,Ii).set(o,0),n(this,kr).set([t,e],0)}updateProperty(t,e){t==="stroke-width"&&f(this,lh,e)}isEmpty(){var t;return!((t=n(this,me))!=null&&t.length)}isCancellable(){return n(this,be).length<=10}add(t,e){return b(this,vs,Hu).call(this,t,e)&&this.toSVGPath(),{path:{d:b(this,vs,Rg).call(this)}}}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)b(this,vs,Hu).call(this,t[s],t[s+1])&&(e=!0,n(this,be).length<=6&&(this.toSVGPath(),e=!1));return e&&this.toSVGPath(),{path:{d:b(this,vs,Rg).call(this)}}}end(t,e){return t!==void 0&&b(this,vs,Hu).call(this,t,e)?{path:{d:this.toSVGPath()}}:n(this,be).length===2?{path:{d:this.toSVGPath()}}:{path:{d:n(this,Qt)}}}startNew(t,e,s,i,r){f(this,Ao,s),f(this,wo,i),f(this,bo,r),[t,e]=b(this,vs,Bu).call(this,t,e);const a=f(this,qt,[NaN,NaN,NaN,NaN,t,e]);f(this,be,[t,e]),n(this,kr).set([t,e],0);const o=n(this,me).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,me).push({line:a,points:n(this,be)}),n(this,Ii).set(a,0),f(this,Ns,0),this.toSVGPath(),null}getLastElement(){return n(this,me).at(-1)}setLastElement(t){return n(this,me)?(n(this,me).push(t),f(this,qt,t.line),f(this,be,t.points),f(this,Ns,0),{path:{d:this.toSVGPath()}}):n(this,yo).setLastElement(t)}removeLastElement(){if(!n(this,me))return n(this,yo).removeLastElement();n(this,me).pop(),f(this,Qt,"");for(let t=0,e=n(this,me).length;t<e;t++){const{line:s,points:i}=n(this,me)[t];f(this,qt,s),f(this,be,i),f(this,Ns,0),this.toSVGPath()}return{path:{d:n(this,Qt)}}}toSVGPath(){const t=O.svgRound(n(this,qt)[4]),e=O.svgRound(n(this,qt)[5]);if(n(this,be).length===2)return f(this,Qt,`${n(this,Qt)} M ${t} ${e} Z`),n(this,Qt);if(n(this,be).length<=6){const i=n(this,Qt).lastIndexOf("M");f(this,Qt,`${n(this,Qt).slice(0,i)} M ${t} ${e}`),f(this,Ns,6)}if(n(this,be).length===4){const i=O.svgRound(n(this,qt)[10]),r=O.svgRound(n(this,qt)[11]);return f(this,Qt,`${n(this,Qt)} L ${i} ${r}`),f(this,Ns,12),n(this,Qt)}const s=[];n(this,Ns)===0&&(s.push(`M ${t} ${e}`),f(this,Ns,6));for(let i=n(this,Ns),r=n(this,qt).length;i<r;i+=6){const[a,o,l,h,c,d]=n(this,qt).slice(i,i+6).map(O.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${d}`)}return f(this,Qt,n(this,Qt)+s.join(" ")),f(this,Ns,n(this,qt).length),n(this,Qt)}getOutlines(t,e,s,i){const r=n(this,me).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,yo).build(n(this,me),t,e,s,n(this,bo),n(this,lh),i),f(this,Ii,null),f(this,qt,null),f(this,me,null),f(this,Qt,null),n(this,yo)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Ii=new WeakMap,kr=new WeakMap,qt=new WeakMap,me=new WeakMap,bo=new WeakMap,lh=new WeakMap,be=new WeakMap,Qt=new WeakMap,Ns=new WeakMap,yo=new WeakMap,Ao=new WeakMap,wo=new WeakMap,vs=new WeakSet,Bu=function(t,e){return O._normalizePoint(t,e,n(this,Ao),n(this,wo),n(this,bo))},Hu=function(t,e){[t,e]=b(this,vs,Bu).call(this,t,e),n(this,kr).set([t,e],0);const[s,i,r,a]=n(this,Ii).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,Ao)*o,n(this,wo)*l)<=2?!1:(n(this,be).push(t,e),isNaN(s)?(n(this,Ii).set([r,a,t,e],2),n(this,qt).push(NaN,NaN,NaN,NaN,t,e),!0):(isNaN(n(this,Ii)[0])&&n(this,qt).splice(6,6),n(this,Ii).set([s,i,r,a,t,e],0),n(this,qt).push(...O.createBezierPoints(s,i,r,a,t,e)),!0))},Rg=function(){const t=O.svgRound(n(this,kr)[0]),e=O.svgRound(n(this,kr)[1]);if(n(this,be).length===2){const s=O.svgRound(n(this,qt)[4]),i=O.svgRound(n(this,qt)[5]);return`${n(this,Qt)} M ${s} ${i} L ${t} ${e}`}return`${n(this,Qt)} L ${t} ${e}`};var Re,Bd,Hd,fs,Li,Fi,hh,ch,vo,Ae,zi,gA,mA,bA;class Kd extends O{constructor(){super(...arguments);m(this,Ae);m(this,Re);m(this,Bd,0);m(this,Hd);m(this,fs);m(this,Li);m(this,Fi);m(this,hh);m(this,ch);m(this,vo)}build(e,s,i,r,a,o,l){f(this,Li,s),f(this,Fi,i),f(this,hh,r),f(this,ch,a),f(this,vo,o),f(this,Hd,l??0),f(this,fs,e),b(this,Ae,mA).call(this)}get thickness(){return n(this,vo)}setLastElement(e){return n(this,fs).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,fs).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,fs)){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,u]=b(this,Ae,gA).call(this);let g,y,A,S,w,v,E,x,C;
60switch(n(this,ch)){case 0:C=O._rescale,g=e,y=s+r,A=i,S=-r,w=e+h*i,v=s+(1-c-u)*r,E=e+(h+d)*i,x=s+(1-c)*r;break;case 90:C=O._rescaleAndSwap,g=e,y=s,A=i,S=r,w=e+c*i,v=s+h*r,E=e+(c+u)*i,x=s+(h+d)*r;break;case 180:C=O._rescale,g=e+i,y=s,A=-i,S=r,w=e+(1-h-d)*i,v=s+c*r,E=e+(1-h)*i,x=s+(c+u)*r;break;case 270:C=O._rescaleAndSwap,g=e+i,y=s+r,A=-i,S=-r,w=e+(1-c-u)*i,v=s+(1-h-d)*r,E=e+(1-c)*i,x=s+(1-h)*r;break}for(const{line:_,points:k}of n(this,fs))o.push(C(_,g,y,A,S,a?new Array(_.length):null)),l.push(C(k,g,y,A,S,a?new Array(k.length):null));return{lines:o,points:l,rect:[w,v,E,x]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const d=[];let u,g,y,A,S;switch(h){case 0:S=O._rescale,u=-e/i,g=s/r+1,y=1/i,A=-1/r;break;case 90:S=O._rescaleAndSwap,u=-s/r,g=-e/i,y=1/r,A=1/i;break;case 180:S=O._rescale,u=e/i+1,g=-s/r,y=-1/i,A=1/r;break;case 270:S=O._rescaleAndSwap,u=s/r+1,g=e/i+1,y=-1/r,A=-1/i;break}if(!o){o=[];for(const v of l){const E=v.length;if(E===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]));continue}if(E===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));continue}const x=new Float32Array(3*(E-2));o.push(x);let[C,_,k,P]=v.subarray(0,4);x.set([NaN,NaN,NaN,NaN,C,_],0);for(let M=4;M<E;M+=2){const L=v[M],N=v[M+1];x.set(O.createBezierPoints(C,_,k,P,L,N),(M-2)*3),[C,_,k,P]=[k,P,L,N]}}}for(let v=0,E=o.length;v<E;v++)d.push({line:S(o[v].map(x=>x??NaN),u,g,y,A),points:S(l[v].map(x=>x??NaN),u,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,Re)}updateProperty(e,s){return e==="stroke-width"?b(this,Ae,bA).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,Ae,zi).call(this);f(this,Li,e),f(this,Fi,s),f(this,hh,i);const[o,l]=b(this,Ae,zi).call(this),h=o-r,c=l-a,d=n(this,Re);return d[0]-=h,d[1]-=c,d[2]+=2*h,d[3]+=2*c,d}updateRotation(e){return f(this,Bd,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,Re).map(O.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,Re);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${O.svgRound(e)} ${O.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,Re);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,Bd)){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,Ae,zi).call(this),[l,h,c,d]=n(this,Re);if(Math.abs(c-a)<=O.PRECISION||Math.abs(d-o)<=O.PRECISION){const S=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(${S} ${w})`}}}const u=(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(${u} ${g}) translate(${O.svgRound(-a)} ${O.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,Ae,zi).call(this),l=n(this,Re),[h,c,d,u]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(d-a)<=O.PRECISION||Math.abs(u-o)<=O.PRECISION){const w=e+i/2-(h+d/2),v=s+r/2-(c+u/2);for(const{line:E,points:x}of n(this,fs))O._translate(E,w,v,E),O._translate(x,w,v,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)/(u-2*o),A=-g*(h+a)+e+a,S=-y*(c+o)+s+o;if(g!==1||y!==1||A!==0||S!==0)for(const{line:w,points:v}of n(this,fs))O._rescale(w,A,S,g,y,w),O._rescale(v,A,S,g,y,v);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,Re),l=e-o[0],h=s-o[1];if(n(this,Li)===r&&n(this,Fi)===a)for(const{line:c,points:d}of n(this,fs))O._translate(c,l,h,c),O._translate(d,l,h,d);else{const c=n(this,Li)/r,d=n(this,Fi)/a;f(this,Li,r),f(this,Fi,a);for(const{line:u,points:g}of n(this,fs))O._rescale(u,l,h,c,d,u),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,Re);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}}}Re=new WeakMap,Bd=new WeakMap,Hd=new WeakMap,fs=new WeakMap,Li=new WeakMap,Fi=new WeakMap,hh=new WeakMap,ch=new WeakMap,vo=new WeakMap,Ae=new WeakSet,zi=function(e=n(this,vo)){const s=n(this,Hd)+e/2*n(this,hh);return n(this,ch)%180===0?[s/n(this,Li),s/n(this,Fi)]:[s/n(this,Fi),s/n(this,Li)]},gA=function(){const[e,s,i,r]=n(this,Re),[a,o]=b(this,Ae,zi).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},mA=function(){const e=f(this,Re,ta.slice());for(const{line:r}of n(this,fs)){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;
60l+=6){const[c,d,u,g,y,A]=r.subarray(l,l+6);D.bezierBoundingBox(a,o,c,d,u,g,y,A,e),a=y,o=A}}const[s,i]=b(this,Ae,zi).call(this);e[0]=xt(e[0]-s,0,1),e[1]=xt(e[1]-i,0,1),e[2]=xt(e[2]+s,0,1),e[3]=xt(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},bA=function(e){const[s,i]=b(this,Ae,zi).call(this);f(this,vo,e);const[r,a]=b(this,Ae,zi).call(this),[o,l]=[r-s,a-i],h=n(this,Re);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class $f extends cm{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:bt._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 $f(this._viewParameters);return t.updateAll(this),t}}var Tf,yA;const zo=class zo extends nc{constructor(e){super({...e,name:"inkEditor"});m(this,Tf);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){bt.initialize(e,s),this._defaultDrawingOptions=new $f(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,"typesMap",new Map([[et.INK_THICKNESS,"stroke-width"],[et.INK_COLOR,"stroke"],[et.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:e,y:s,box:[,,i,r],rotation:a}){return new Yw(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return Kd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof hm){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:d,opacity:u,borderStyle:{rawWidth:g},popupRef:y,richText:A,contentsObj:S,creationDate:w,modificationDate:v},parent:{page:{pageNumber:E}}}=e;r=e={annotationType:W.INK,color:Array.from(d),thickness:g,opacity:u,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:(S==null?void 0:S.str)||null,creationDate:w,modificationDate:v}}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 Ju(this)),[["colorPicker",this._colorPicker]]}get colorType(){return et.INK_COLOR}get colorAndOpacityType(){return et.INK_COLOR_AND_OPACITY}get opacityType(){return et.INK_OPACITY}updateParams(e,s){if(e===et.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===et.INK_COLOR_AND_OPACITY){super.updateDefaultParams(et.INK_COLOR,s.color),super.updateDefaultParams(et.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=zo.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:bt._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,Tf,yA).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}};Tf=new WeakSet,yA=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(zo,"_type","ink"),T(zo,"_editorType",W.INK),T(zo,"_defaultDrawingOptions",null);let Og=zo;class Ng extends Kd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const iu=8,Th=3;var So,at,Bg,ei,AA,wA,Hg,Uu,vA,SA,EA,Ug,Gg,xA;class Pn{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,u=c.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:g,actualBoundingBoxRight:y,actualBoundingBoxAscent:A,actualBoundingBoxDescent:S,fontBoundingBoxAscent:w,fontBoundingBoxDescent:v,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(S)||d,Math.abs(w)+Math.abs(v)||d)*x);h=new OffscreenCanvas(C,_),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=u,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,at,Ug).call(this,c.getImageData(0,0,C,_).data),P=b(this,at,EA).call(this,k),M=b(this,at,Gg).call(this,P),L=b(this,at,Hg).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,at,xA).call(this,t),[h,c]=b(this,at,SA).call(this,a,o,l,Math.hypot(o,l)*n(this,So).sigmaSFactor,n(this,So).sigmaR,n(this,So).kernelSize),d=b(this,at,Gg).call(this,c),u=b(this,at,Hg).call(this,h,o,l,d);return this.processDrawnLines({lines:{curves:u,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,u=[],g=Math.min(e/h,s/c),y=g/e,A=g/s,S=[];for(const{points:v}of l){const E=a?b(this,at,vA).call(this,v):v;if(!E)continue;S.push(E);const x=E.length,C=new Float32Array(x),_=new Float32Array(3*(x===2?2:x-2));if(u.push({line:_,points:C}
60),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 tt=C[N]=E[N]*y,Q=C[N+1]=E[N+1]*A;_.set(O.createBezierPoints(k,P,M,L,tt,Q),(N-2)*3),[k,P,M,L]=[M,L,tt,Q]}}if(u.length===0)return null;const w=o?new Ng:new Kd;return w.build(u,e,s,1,i,o?0:d,r),{outline:w,newCurves:S,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 v of t){l+=v.length;for(let E=2,x=v.length;E<x;E++){const C=v[E]-v[E-2];a=Math.min(a,C),o=Math.max(o,C)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,d=iu+Th*c,u=new Uint32Array(d);let g=0;u[g++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*h.BYTES_PER_ELEMENT,u[g++]=0,u[g++]=i,u[g++]=r,u[g++]=e?0:1,u[g++]=Math.max(0,Math.floor(s??0)),u[g++]=c,u[g++]=h.BYTES_PER_ELEMENT;for(const v of t)u[g++]=v.length-2,u[g++]=v[0],u[g++]=v[1];const y=new CompressionStream("deflate-raw"),A=y.writable.getWriter();await A.ready,A.write(u);const S=h.prototype.constructor;for(const v of t){const E=new S(v.length-2);for(let x=2,C=v.length;x<C;x++)E[x-2]=v[x]-v[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],u=l[4]===0,g=l[5],y=l[6],A=l[7],S=[],w=(iu+Th*y)*Uint32Array.BYTES_PER_ELEMENT;let v;switch(A){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(a.buffer,w);break}o=0;for(let E=0;E<y;E++){const x=l[Th*E+iu],C=new Float32Array(x+2);S.push(C);for(let _=0;_<Th-1;_++)C[_]=l[Th*E+iu+_+1];for(let _=0;_<x;_++)C[_+2]=C[_]+v[o++]}return{areContours:u,thickness:g,outlines:S,width:c,height:d}}catch(e){return Y(`decompressSignature: ${e}`),null}}}So=new WeakMap,at=new WeakSet,Bg=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},ei=new WeakMap,AA=function(t,e,s,i,r,a,o){const l=b(this,at,Bg).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,d=n(this,ei)[2*c],u=n(this,ei)[2*c+1];if(t[(s+d)*e+(i+u)]!==0)return c}return-1},wA=function(t,e,s,i,r,a,o){const l=b(this,at,Bg).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,d=n(this,ei)[2*c],u=n(this,ei)[2*c+1];if(t[(s+d)*e+(i+u)]!==0)return c}return-1},Hg=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 u=c*e+d,g=a[u];if(g===0)continue;let y=c,A=d;if(g===1&&a[u-1]===0)o+=1,A-=1;else if(g>=1&&a[u+1]===0)o+=1,A+=1,g>1&&(l=g);else{g!==1&&(l=Math.abs(g));continue}const S=[d,c],w=A===d+1,v={isHole:w,points:S,id:o,parent:0};h.push(v);let E;for(const N of h)if(N.id===l){E=N;break}E?E.isHole?v.parent=w?E.parent:l:v.parent=w?l:E.parent:v.parent=w?l:0;const x=b(this,at,AA).call(this,a,e,c,d,y,A,0);if(x===-1){a[u]=-o,a[u]!==1&&(l=Math.abs(a[u]));continue}let C=n(this,ei)[2*x],_=n(this,ei)[2*x+1];const k=c+C,P=d+_;y=k,A=P;let M=c,L=d;for(;;){const N=b(this,at,wA).call(this,a,e,M,L,y,A,1);C=n(this,ei)[2*N],_=n(this,ei)[2*N+1];const tt=M+C,Q=L+_;S.push(Q,tt);const Z=M*e+L;if(a[Z+1]===0?a[Z]=-o:a[Z]===1&&(a[Z]=o),tt===c&&Q===d&&M===k&&L===P){a[u]!==1&&(l=Math.abs(a[u]));break}else y=M,A=L,M=tt,L=Q}}}return h},Uu=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,u=c*a-d
60*r,g=l/o,y=1/h,A=Math.atan(g),S=Math.cos(A),w=Math.sin(A),v=y*(Math.abs(S)+Math.abs(w)),E=y*(1-v+v**2),x=Math.max(Math.atan(Math.abs(w+S)*E),Math.atan(Math.abs(w-S)*E));let C=0,_=e;for(let k=e+2;k<s-2;k+=2){const P=Math.abs(u-c*t[k+1]+d*t[k]);P>C&&(_=k,C=P)}C>(h*x)**2?(b(this,at,Uu).call(this,t,e,_+2,i),b(this,at,Uu).call(this,t,_,s,i)):i.push(r,a)},vA=function(t){const e=[],s=t.length;return b(this,at,Uu).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},SA=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 S=(A-h)**2;for(let w=0;w<a;w++)o[A*a+w]=Math.exp((S+(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 u=t.length,g=new Uint8Array(u),y=new Uint32Array(256);for(let A=0;A<s;A++)for(let S=0;S<e;S++){const w=A*e+S,v=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=S+P-h;if(M<0||M>=e)continue;const L=t[k*e+M],N=o[_*a+P]*c[Math.abs(L-v)];E+=L*N,x+=N}}const C=g[w]=Math.round(E/x);y[C]++}return[g,y]},EA=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Ug=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},Gg=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},xA=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,So);let a=s,o=i;if(s>r||i>r){let u=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(u/2),o=Math.ceil(g/2);const v=new OffscreenCanvas(a,o);v.getContext("2d").drawImage(t,0,0,u,g,0,0,a,o),u=a,g=o,t!==e&&t.close(),t=v.transferToImageBitmap()}const S=Math.min(r/a,r/o);a=Math.round(a*S),o=Math.round(o*S)}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,at,Ug).call(this,c),a,o]},m(Pn,at),m(Pn,So,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),m(Pn,ei,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class fm extends cm{constructor(){super(),super.updateProperties({fill:bt._defaultLineColor,"stroke-width":0})}clone(){const t=new fm;return t.updateAll(this),t}}class pm extends $f{constructor(t){super(t),super.updateProperties({stroke:bt._defaultLineColor,"stroke-width":1})}clone(){const t=new pm(this._viewParameters);return t.updateAll(this),t}}var Pr,Ri,Mr,Eo;const Ze=class Ze extends nc{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});m(this,Pr,!1);m(this,Ri,null);m(this,Mr,null);m(this,Eo,null);this._willKeepAspectRatio=!0,f(this,Mr,e.signatureData||null),f(this,Ri,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){bt.initialize(e,s),this._defaultDrawingOptions=new fm,this._defaultDrawnSignatureOptions=new pm(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return j(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,Ri)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(n(this,Mr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=n(this,Mr),{rawDims:{pageWidth:d,pageHeight:u},rotation:g}=this.parent.viewport,y=Pn.processDrawnLines({lines:r,pageWidth:d,pageHeight:u,rotation:g,innerMargin:Ze._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,Ri)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){f(this,Eo,e),this.addEditToolbar()}getUuid(){return n(this,Eo)}get description(){return n(this,Ri)}set description(e){f(this,Ri,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:r,height:a}=n(this,Mr),o=Math.max(r,a),l=Pn.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}=f(this,Mr,e);f(this,Pr,l instanceof Ng),this.description=i;let h;n(this,Pr)?h=Ze.getDefaultDrawingOptions():(h=Ze._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 Pn.process(e,s,i,r,Ze._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return Pn.extractContoursFromText(e,s,i,r,a,Ze._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Pn.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:Ze._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Ze.getDefaultDrawingOptions():(this._drawingOptions=Ze._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,Pr),color:[0,0,0],thickness:n(this,Pr)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,Eo),a.isCopy=!0):a.lines=s,n(this,Ri)&&(a.accessibilityData={type:"Figure",alt:n(this,Ri)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?Ng.deserialize(e,s,i,r,a,o):Kd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return f(r,Pr,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",f(r,Eo,e.uuid),r}};Pr=new WeakMap,Ri=new WeakMap,Mr=new WeakMap,Eo=new WeakMap,T(Ze,"_type","signature"),T(Ze,"_editorType",W.SIGNATURE),T(Ze,"_defaultDrawingOptions",null);let jg=Ze;var Pt,ce,Dr,En,Ir,dh,xn,xo,Oi,ps,uh,it,Xh,Yh,Gu,ju,$u,zg,zu,CA;class $g extends bt{constructor(e){super({...e,name:"stampEditor"});m(this,it);m(this,Pt,null);m(this,ce,null);m(this,Dr,null);m(this,En,null);m(this,Ir,null);m(this,dh,"");m(this,xn,null);m(this,xo,!1);m(this,Oi,null);m(this,ps,!1);m(this,uh,!1);f(this,En,e.bitmapUrl),f(this,Ir,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){bt.initialize(e,s)}static isHandlingMimeForPasting(e){return dp.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,ce)&&(f(this,Pt,null),this._uiManager.imageManager.deleteId(n(this,ce)),(e=n(this,xn))==null||e.remove(),f(this,xn,null),n(this,Oi)&&(clearTimeout(n(this,Oi)),f(this,Oi,null))),super.remove()}rebuild(){if(!this.parent){n(this,ce)&&b(this,it,Gu).call(this);return}super.rebuild(),this.div!==null&&(n(this,ce)&&n(this,xn)===null&&b(this,it,Gu).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,Dr)||n(this,Pt)||n(this,En)||n(this,Ir)||n(this,ce)||n(this,xo))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}
60render(){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,xo)||(n(this,Pt)?b(this,it,ju).call(this):b(this,it,Gu).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)&&(f(this,ce,i),r&&f(this,Pt,r),f(this,xo,!1),b(this,it,ju).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,Oi)!==null&&clearTimeout(n(this,Oi)),f(this,Oi,setTimeout(()=>{f(this,Oi,null),b(this,it,zg).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,Pt),o=new ri;let l=n(this,Pt),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,ps)||(l=b(this,it,$u).call(this,g,y));const A=d.getContext("2d");A.filter=this._uiManager.hcmFilter;let S="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":n0.isDarkMode&&(S="#8f8f9d",w="#42414d");const v=15,E=v*o.sx,x=v*o.sy,C=new OffscreenCanvas(E*2,x*2),_=C.getContext("2d");_.fillStyle=S,_.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 u=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,Pt),r>e||a>e){const w=Math.min(e/r,e/a);g=Math.floor(r*w),y=Math.floor(a*w),n(this,ps)||(l=b(this,it,$u).call(this,g,y))}const S=new OffscreenCanvas(g,y).getContext("2d",{willReadFrequently:!0});S.drawImage(l,0,0,l.width,l.height,0,0,g,y),u={width:g,height:y,data:S.getImageData(0,0,g,y).data}}return{canvas:d,width:h,height:c,imageData:u}}static async deserialize(e,s,i){var S;let r=null,a=!1;if(e instanceof Vy){const{data:{rect:w,rotation:v,id:E,structParent:x,popupRef:C,richText:_,contentsObj:k,creationDate:P,modificationDate:M},container:L,parent:{page:{pageNumber:N}},canvas:tt}=e;let Q,Z;tt?(delete e.canvas,{id:Q,bitmap:Z}=i.imageManager.getFromCanvas(L.id,tt),tt.remove()):(a=!0,e._hasNoCanvas=!0);const $t=((S=await s._structTree.getAriaAttributes(`${jo}${E}`))==null?void 0:S.get("aria-label"))||"";r=e={annotationType:W.STAMP,bitmapId:Q,bitmap:Z,pageIndex:N-1,rect:w.slice(0),rotation:v,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:u,accessibilityData:g}=e;a?(i.addMissingCanvas(e.id,o),f(o,xo,!0)):d&&i.imageManager.isValidId(d)?(f(o,ce,d),h&&f(o,Pt,h)):f(o,En,c),f(o,ps,u);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),f(o,uh,!!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,ce),isSvg:n(this,ps)});if(this.addComment(i),e)return i.bitmapUrl=b(this,it,zu).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,it,CA).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,ps)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,ce)))s.stamps.set(n(this,ce),{area:o,serialized:i}),i.bitmap=b(this,it,zu).call(this,!1);else if(n(this,ps)){const l=s.stamps.get(n(this,ce));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,it,zu).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}Pt=new WeakMap,ce=new WeakMap,Dr=new WeakMap,En=new WeakMap,Ir=new WeakMap,dh=new WeakMap,xn=new WeakMap,xo=new WeakMap,Oi=new WeakMap,ps=new WeakMap,uh=new WeakMap,it=new WeakSet,Xh=function(e,s=!1){if(!e){this.remove();return}f(this,Pt,e.bitmap),s||(f(this,ce,e.id),f(this,ps,e.isSvg)),e.file&&f(this,dh,e.file.name),b(this,it,ju).call(this)},Yh=function(){if(f(this,Dr,null),this._uiManager.enableWaiting(!1),!!n(this,xn)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Pt)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Pt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Gu=function(){if(n(this,ce)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,ce)).then(i=>b(this,it,Xh).call(this,i,!0)).finally(()=>b(this,it,Yh).call(this));return}if(n(this,En)){const i=n(this,En);f(this,En,null),this._uiManager.enableWaiting(!0),f(this,Dr,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,it,Xh).call(this,r)).finally(()=>b(this,it,Yh).call(this)));return}if(n(this,Ir)){const i=n(this,Ir);f(this,Ir,null),this._uiManager.enableWaiting(!0),f(this,Dr,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,it,Xh).call(this,r)).finally(()=>b(this,it,Yh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=dp.join(",");const s=this._uiManager._signal;f(this,Dr,new Promise(i=>{e.addEventListener("change",async()=>
60{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,it,Xh).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,it,Yh).call(this))),e.click()},ju=function(){var h;const{div:e}=this;let{width:s,height:i}=n(this,Pt);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=f(this,xn,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,it,zg).call(this),n(this,uh)||(this.parent.addUndoableEditor(this),f(this,uh,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,dh)&&this.div.setAttribute("aria-description",n(this,dh)),this.annotationElementId||this._uiManager.a11yAlert(bt._l10nAlert.stamp)},$u=function(e,s){const{width:i,height:r}=n(this,Pt);let a=i,o=r,l=n(this,Pt);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},zg=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new ri,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,xn);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,ps)?n(this,Pt):b(this,it,$u).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)},zu=function(e){if(e){if(n(this,ps)){const r=this._uiManager.imageManager.getSvgUrl(n(this,ce));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,Pt),s.getContext("2d").drawImage(n(this,Pt),0,0),s.toDataURL()}if(n(this,ps)){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,Pt),0,0,n(this,Pt).width,n(this,Pt).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,Pt))},CA=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($g,"_type","stamp"),T($g,"_editorType",W.STAMP);var Co,fh,Lr,Fr,Cn,Ke,Rr,ph,gh,si,_n,qe,Tn,Or,mh,B,Nr,yt,Wg,_A,ci,Xg,Yg,Vu;const js=class js{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){m(this,yt);m(this,Co);m(this,fh,!1);m(this,Lr,null);m(this,Fr,null);m(this,Cn,null);m(this,Ke,new Map);m(this,Rr,!1);m(this,ph,!1);m(this,gh,!1);m(this,si,null);m(this,_n,null);m(this,qe,null);m(this,Tn,null);m(this,Or,null);m(this,mh,-1);m(this,B);const d=[...n(js,Nr).values()];if(!js._initialized){js._initialized=!0;for(const u of d)u.initialize(c,t)}t.registerEditorTypes(d),f(this,B,t),this.pageIndex=e,this.div=s,f(this,Co,r),f(this,Lr,a),this.viewport=h,f(this,qe,l),this.drawLayer=o,this._structTree=i,n(this,B).addLayer(this)}get isEmpty(){return n(this,Ke).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,yt,Vu).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(js,Nr).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,qe))==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,Lr))==null||e.togglePointerEvents(t)}async enable(){var s;f(this,gh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,Or))==null||s.abort(),f(this,Or,null);const t=new Set;for(const i of n(this,yt,Wg))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,B).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,Lr);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())}f(this,gh,!1),n(this,B)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(f(this,ph,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,qe)&&!n(this,Or)){f(this,Or,new AbortController);const r=n(this,B).combinedSignal(n(this,Or));n(this,qe).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,d=n(this,mh);if(c-d>500){f(this,mh,c);return}f(this,mh,-1);const{classList:u}=this.div;u.toggle("getElements",!0);const g=document.elementsFromPoint(l,h);if(u.toggle("getElements",!1),!this.div.contains(g[0]))return;let y;const A=new RegExp(`^${Ah}[0-9]+$`);for(const w of g)if(A.test(w.id)){y=w.id;break}if(!y)return;const S=n(this,Ke).get(y);(S==null?void 0:S.annotationElementId)===null&&(se(a),S.dblclick(a))},{signal:r,capture:!0})}const t=n(this,Lr),e=[];
60if(t){const r=new Map,a=new Map;for(const o of n(this,yt,Wg)){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,yt,Vu).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(js,Nr).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),f(this,ph,!1)}getEditableAnnotation(t){var e;return((e=n(this,Lr))==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,qe))!=null&&t.div&&!n(this,Tn)){f(this,Tn,new AbortController);const e=n(this,B).combinedSignal(n(this,Tn));n(this,qe).div.addEventListener("pointerdown",b(this,yt,_A).bind(this),{signal:e}),n(this,qe).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,qe))!=null&&t.div&&n(this,Tn)&&(n(this,Tn).abort(),f(this,Tn,null),n(this,qe).div.classList.remove("highlighting"))}enableClick(){if(n(this,Fr))return;f(this,Fr,new AbortController);const t=n(this,B).combinedSignal(n(this,Fr));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,Fr))==null||t.abort(),f(this,Fr,null)}attach(t){n(this,Ke).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,Ke).delete(t.id),(e=n(this,Co))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,ph)&&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),bt.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)))}add(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,gh)),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,Cn)&&(t._focusEventsAllowed=!1,f(this,Cn,setTimeout(()=>{f(this,Cn,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,Co))==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,Ke).values())if(e.uid===t)return e;return null}combinedSignal(t){return n(this,B).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,yt,ci))==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,yt,Yg).call(this),r=n(this,B).getId(),a=b(this,yt,Xg).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(js,Nr).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,yt,Xg).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,yt,Yg).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}=gt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,Rr)||(f(this,Rr,!1),(i=n(this,yt,ci))!=null&&i.isDrawer&&n(this,yt,ci).supportMultipleDrawings))return;if(!n(this,fh)){f(this,fh,!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,Rr)){f(this,Rr,!1);return}const{isMac:e}=gt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(f(this,Rr,!0),(i=n(this,yt,ci))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,B).getActive();f(this,fh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,si)){n(this,yt,ci).startDrawing(this,n(this,B),!1,t);return}n(this,B).setCurrentDrawingSession(this),f(this,si,new AbortController);const e=n(this,B).combinedSignal(n(this,si));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(f(this,_n,null),this.commitOrRemove())},{signal:e}),n(this,yt,ci).startDrawing(this,n(this,B),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&f(this,_n,e);return}n(this,_n)&&setTimeout(()=>{var e;(e=n(this,_n))==null||e.focus(),f(this,_n,null)},0)}endDrawingSession(t=!1){return n(this,si)?(n(this,B).setCurrentDrawingSession(null),n(this,si).abort(),f(this,si,null),f(this,_n,null),n(this,yt,ci).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,si)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,si)&&n(this,yt,ci).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,Cn)&&(clearTimeout(n(this,Cn)),f(this,Cn,null));for(const s of n(this,Ke).values())(e=n(this,Co))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,Ke).clear(),n(this,B).removeLayer(this)}async render({viewport:t}){this.viewport=t,ko(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,yt,Vu).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,ko(this.div,{rotation:s}),e!==s)for(const i of n(this,Ke).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}};Co=new WeakMap,fh=new WeakMap,Lr=new WeakMap,Fr=new WeakMap,Cn=new WeakMap,Ke=new WeakMap,Rr=new WeakMap,ph=new WeakMap,gh=new WeakMap,si=new WeakMap,_n=new WeakMap,qe=new WeakMap,Tn=new WeakMap,Or=new WeakMap,mh=new WeakMap,B=new WeakMap,Nr=new WeakMap,yt=new WeakSet,Wg=function(){return n(this,Ke).size!==0?n(this,Ke).values():n(this,B).getEditors(this.pageIndex)},_A=function(t){n(this,B).unselectAll();const{target:e}=t;if(e===n(this,qe).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&n(this,qe).div.contains(e)){const{isMac:s}=gt.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,B).showAllEditors("highlight",!0,!0),ef.startDrawing(this,n(this,B),n(this,B).direction==="ltr",t),t.preventDefault()}},ci=function(){return n(js,Nr).get(n(this,B).getMode())},Xg=function(t){const e=n(this,yt,ci);return e?new e.prototype.constructor(t):null},Yg=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,u]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:u}},Vu=function(){for(const t of n(this,Ke).values())t.isEmpty()&&t.remove()},T(js,"_initialized",!1),m(js,Nr,new Map([vg,Og,$g,ef,jg].map(t=>[t._editorType,t])));let Vg=js;function Kw(p,t){return p===t?0:p.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function nu(p){var t;return p?p.nodeType===Node.ELEMENT_NODE?p.closest(".textLayer"):((t=p.parentElement)==null?void 0:t.closest(".textLayer"))||null:null}function qw(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 ob(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 Oe,Ne,Bs,Ud,Gd,_o,To,jd,kf,Br,Hr,Ur,Gr,kn,Pe,qg,Qg,TA,Wu,kA,ji,Jg,PA,Zg;const G=class G{constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){m(this,ji);m(this,Oe,null);m(this,Ne,new Map);m(this,Bs,null);m(this,Ud,null);m(this,Gd,null);m(this,_o,null);m(this,To,new Map);if(this.pageIndex=s,f(this,Ud,t),f(this,Gd,e),i){const r=n(G,kn).get(i);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),n(G,Hr).delete(r.selectionDiv)),n(G,kn).set(i,{drawLayer:this}),n(G,Gr).add(i),f(this,Bs,i),f(this,_o,new MutationObserver(a=>{var o,l,h;if(!(!n(this,Oe)||!((o=n(this,Bs))!=null&&o.isConnected)||!b(l=G,Pe,Qg).call(l))){for(const{addedNodes:c}of a)for(const d of c)if(d.nodeType===Node.ELEMENT_NODE&&d.classList.contains("endOfContent")){b(h=G,Pe,Wu).call(h);return}}})),n(this,_o).observe(i,{childList:!0}),n(G,Br)===null){f(G,Br,new AbortController);const{signal:a}=n(G,Br);document.addEventListener("selectionchange",b(G,Pe,Wu).bind(G),{signal:a}),document.addEventListener("pointerdown",()=>{f(G,Ur,!0)},{signal:a}),document.addEventListener("pointerup",()=>{f(G,Ur,!1)},{signal:a}),window.addEventListener("blur",()=>{f(G,Ur,!1)},{signal:a})}}}setParent(t){var e,s,i;if(!n(this,Oe)){f(this,Oe,t),(e=n(this,Bs))!=null&&e.isConnected&&b(s=G,Pe,Qg).call(s)&&b(i=G,Pe,Wu).call(i);return}if(n(this,Oe)!==t){if(n(this,Ne).size>0)for(const r of n(this,Ne).values())r.remove(),t.append(r);f(this,Oe,t)}}static get _svgFactory(){return j(this,"_svgFactory",new Zu)}draw(t,e=!1,s=!1){const i=It(G,jd)._++,r=b(this,ji,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,To).set(i,o);const h=s?b(this,ji,PA).call(this,a,l):null,c=G._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,Ne).set(i,r),{id:i,clipPathId:`url(#${h})`}}
60drawOutline(t,e){const s=It(G,jd)._++,i=b(this,ji,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 u=G._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.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,Ne).set(s,i),s}finalizeDraw(t,e){n(this,To).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,Ne).get(t):t;if(o){if(s&&b(this,ji,Zg).call(this,o,s),i&&b(l=G,Pe,kA).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,ji,Zg).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,Ne).get(t);s&&(n(e,Oe).append(s),n(this,Ne).delete(t),n(e,Ne).set(t,s))}remove(t){n(this,To).delete(t),n(this,Oe)!==null&&(n(this,Ne).get(t).remove(),n(this,Ne).delete(t))}destroy(){var t,e,s;f(this,Oe,null);for(const i of n(this,Ne).values())i.remove();if(n(this,Ne).clear(),n(this,To).clear(),(t=n(this,_o))==null||t.disconnect(),f(this,_o,null),n(this,Bs)){const i=n(G,kn).get(n(this,Bs));(i==null?void 0:i.drawLayer)===this&&(b(e=G,Pe,qg).call(e,n(this,Bs)),n(G,kn).delete(n(this,Bs)),n(G,Gr).delete(n(this,Bs)),n(G,Gr).size===0&&((s=n(G,Br))==null||s.abort(),f(G,Br,null),f(G,Ur,!1))),f(this,Bs,null)}}};Oe=new WeakMap,Ne=new WeakMap,Bs=new WeakMap,Ud=new WeakMap,Gd=new WeakMap,_o=new WeakMap,To=new WeakMap,jd=new WeakMap,kf=new WeakMap,Br=new WeakMap,Hr=new WeakMap,Ur=new WeakMap,Gr=new WeakMap,kn=new WeakMap,Pe=new WeakSet,qg=function(t){const e=n(this,kn).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),n(this,Hr).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},Qg=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},TA=function(){return n(this,Gr).keys().filter(t=>t.isConnected).toArray().sort(Kw)},Wu=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of n(this,Hr))o.remove();n(this,Hr).clear();return}const e=new WeakMap,s=b(this,Pe,TA).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:u,endOffset:g}=h,y=nu(c),A=nu(u);const S=y===null,w=A===null;if(n(this,Ur)&&S!==w)return;if(t.rangeCount===1){const{anchorNode:x,anchorOffset:C,focusNode:_,focusOffset:k}=t,P=nu(x),M=nu(_),L=qw(x,C,_,k);P&&M&&L!==null&&(L?(c=x,d=C,y=P,u=_,g=k,A=M):(c=_,d=k,y=M,u=x,g=C,A=P))}const v=s.filter(x=>h.intersectsNode(x));if(v.length===0)continue;let E=!1;if(y||(y=v[0],c=y,d=0,E=!0),A||(A=v.at(-1),u=A,g=A.childNodes.length,E=!0),u.nodeType===Node.ELEMENT_NODE){if(u.classList.contains("endOfContent")){const x=u.previousSibling;if(!x)continue;u=x,g=x.nodeType===Node.TEXT_NODE?x.textContent.length:x.childNodes.length}else if(u.classList.contains("textLayer")&&u.childNodes.length===g){const x=ob(u,g,A);if(!x)continue;u=x.container,g=x.offset}}if(c.nodeType===Node.ELEMENT_NODE){const x=ob(c,d,y);if(!x)continue;c=x.container,d=x.offset}if(y===A&&!E&&v.includes(y)){i.push([h,y]);continue}for(const x of v){const C=x.firstChild;if(!C)continue;const _=document.createRange();if(x===y?_.setStart(c,d):_.setStartBefore(C),x===A)_.setEnd(u,g);
60else{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,Gr))r.has(o)||b(this,Pe,qg).call(this,o);for(const[o,l]of i){const h=n(G,kn).get(l);if(!h)continue;let c=e.get(l);if(!c){const A=l.getBoundingClientRect();c=(S,w,v,E)=>({x:(S-A.x)/A.width,y:(w-A.y)/A.height,width:v/A.width,height:E/A.height}),e.set(l,c)}const d=[];for(let{x:A,y:S,width:w,height:v}of o.getClientRects())w===0||v===0||({x:A,y:S,width:w,height:v}=c(A,S,w,v),!(w===1&&v===1)&&d.push(`M${A} ${S} h${w} v${v} h-${w} Z`));if(d.length===0)continue;const u=h.drawLayer;let g=h.selectionDiv,y=h.path;if(!g){const A=`clip_selection_${It(G,kf)._++}`;g=document.createElement("div"),g.className="selection",g.style.clipPath=`url(#${A})`;const S=(a=n(u,Ud))==null?void 0:a.createSelectionStyle(n(u,Gd));if(S)for(const[E,x]of Object.entries(S))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 v=G._svgFactory.createElement("clipPath");v.setAttribute("id",A),v.setAttribute("clipPathUnits","objectBoundingBox"),y=G._svgFactory.createElement("path"),v.append(y),w.append(v),g.append(w),h.path=y,h.selectionDiv=g}n(u,Oe)&&g.parentNode!==n(u,Oe)&&(n(u,Oe).append(g),n(this,Hr).add(g)),y.setAttribute("d",d.join(" "))}},kA=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}%`},ji=new WeakSet,Jg=function(){const t=G._svgFactory.create(1,1,!0);return n(this,Oe).append(t),t.setAttribute("aria-hidden","true"),t},PA=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},Zg=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},m(G,Pe),m(G,jd,0),m(G,kf,0),m(G,Br,null),m(G,Hr,new Set),m(G,Ur,!1),m(G,Gr,new Set),m(G,kn,new WeakMap);let Kg=G;function ru(p){return`${(p*100).toFixed(2)}%`}var bh,$d,zd,yh,Ni,Bi,Vd,Pf,MA;const Jh=class Jh{constructor(t,e,s,i){m(this,Pf);m(this,bh,[]);m(this,$d,new Map);m(this,zd,null);m(this,yh,0);m(this,Ni,0);m(this,Bi,0);f(this,yh,t),f(this,bh,e),f(this,Ni,s.rawDims.pageWidth),f(this,Bi,s.rawDims.pageHeight),f(this,zd,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<n(this,bh).length;e+=6){const s=b(this,Pf,MA).call(this,n(this,bh).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,$d).get(s);if(!i)return;const r=(w=n(Jh,Vd))==null?void 0:w.deref();if(r===s)return;r&&(r.width=0,r.height=0),f(Jh,Vd,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:h,height:c}=i,d=n(this,zd).call(this),u=Math.ceil(o*d.width),g=Math.ceil(l*d.height),y=Math.floor((o+h/n(this,Ni))*d.width),A=Math.floor((l+c/n(this,Bi))*d.height);s.width=y-u,s.height=A-g;const S=s.getContext("2d");S.setTransform(...a),S.translate(-u,-g),S.drawImage(d,0,0)}),t}};bh=new WeakMap,$d=new WeakMap,zd=new WeakMap,yh=new WeakMap,Ni=new WeakMap,Bi=new WeakMap,Vd=new WeakMap,Pf=new WeakSet,MA=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,Ni),(a-e)*n(this,Bi)),l=Math.hypot((s-t)*n(this,Ni),(i-e)*n(this,Bi));if(o<n(this,yh)||l<n(this,yh))return null;const h=[(r-t)*n(this,Ni)/o,(a-e)*n(this,Bi)/o,(s-t)*n(this,Ni)/l,(i-e)*n(this,Bi)/l,0,0],c=D.inverseTransform(h),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:ru(t),top:ru(e),width:ru(o/n(this,Ni)),height:ru(l/n(this,Bi)),transformOrigin:"0% 0%",transform:`matrix(${h.join(",")})`}),n(this,$d).set(d,{inverseTransform:c,width:o,height:l,x1:t,y1:e}),d},m(Jh,Vd,null);let tm=Jh;globalThis._pdfjsTestingUtils={HighlightOutliner:Mg};globalThis.pdfjsLib={AbortException:jr,AnnotationEditorLayer:Vg,AnnotationEditorParamsType:et,AnnotationEditorType:W,AnnotationEditorUIManager:Mo,AnnotationLayer:wg,AnnotationMode:Nn,AnnotationType:Lt,applyOpacity:a0,build:Cw,ColorPicker:Qu,createValidAbsoluteUrl:hb,CSSConstants:r0,DOMSVGFactory:Zu,DrawLayer:Kg,FeatureTest:gt,fetchData:im,findContrastColor:o0,getDocument:Dy,getFilenameFromUrl:e0,getPdfFilenameFromUrl:s0,getRGB:Yd,getRGBA:Xd,getUuid:db,GlobalWorkerOptions:Hi,ImageKind:au,InvalidPDFException:op,isDataScheme:Ff,isPdfFile:rm,isValidExplicitDest:k0,makeArr:Sh,makeMap:em,makeObj:hp,makeSet:JA,MathClamp:xt,noContextMenu:ni,normalizeUnicode:qA,OPS:di,OutputScale:ri,PasswordException:ap,PasswordResponses:$A,PDFDataRangeTransport:Iy,PDFDateString:Yu,PDFWorker:ic,PermissionFlag:jA,PixelsPerInch:$r,RenderingCancelledException:nm,renderRichText:ub,ResponseException:Xu,setLayerDimensions:ko,shadow:j,SignatureExtractor:Pn,stopEvent:se,SupportedImageMimeTypes:dp,TextLayer:sc,TextLayerImages:tm,TouchManager:Fb,updateUrlHash:cb,Util:D,VerbosityLevel:Mf,version:xw,XfaLayer:sm};const Qw="/assets/pdf.worker.min-Dswkl-cV.mjs";Hi.workerSrc=Qw;async function Jw(p,t=900){const e=await p.arrayBuffer(),s=await Dy({data:e}).promise,i=await s.getPage(1),r=i.getViewport({scale:1}),a=i.getViewport({scale:t/r.width}),o=document.createElement("canvas");o.width=Math.round(a.width),o.height=Math.round(a.height);const l=o.getContext("2d");l.fillStyle="#ffffff",l.fillRect(0,0,o.width,o.height),await i.render({canvas:o,canvasContext:l,viewport:
60a}).promise;const h=await new Promise((d,u)=>o.toBlob(g=>g?d(g):u(new Error("Kapak oluşturulamadı")),"image/jpeg",.85)),c=s.numPages;return{blob:h,pageCount:c}}const Zw=p=>p.toLowerCase().replace(/ı/g,"i").replace(/ğ/g,"g").replace(/ü/g,"u").replace(/ş/g,"s").replace(/ö/g,"o").replace(/ç/g,"c").replace(/[^a-z0-9.]+/g,"-").replace(/(^-|-$)/g,"");async function tv(){const{data:p,error:t}=await Oo.from("editions").select("id, title, issue_no, published_date, pdf_url, cover_url, page_count, active, views").order("published_date",{ascending:!1});if(t)throw t;return p||[]}const ov=()=>{const p=OA(),{data:t=[],isLoading:e}=NA({queryKey:["admin-editions"],queryFn:tv}),[s,i]=xh.useState(new Date().toISOString().slice(0,10)),[r,a]=xh.useState(""),[o,l]=xh.useState(null),[h,c]=xh.useState(!1),[d,u]=xh.useState(""),g=async(v,E,x)=>{const C=`editions/${Date.now()}-${Zw(E)}`,{error:_}=await Oo.storage.from("media").upload(C,v,{cacheControl:"31536000",upsert:!1,contentType:x});if(_)throw _;return Oo.storage.from("media").getPublicUrl(C).data.publicUrl},y=async()=>{if(!o){qd({title:"PDF dosyası seçin",variant:"destructive"});return}c(!0);try{u("Önizleme oluşturuluyor…");let v=null,E=null;try{const{blob:k,pageCount:P}=await Jw(o);E=P,v=await g(k,`kapak-${s}.jpg`,"image/jpeg")}catch{qd({title:"Önizleme oluşturulamadı",description:"Sayı kapaksız eklenecek."})}u("PDF yükleniyor…");const x=await g(o,o.name,"application/pdf"),C=`${Pm(s)} Taşova Havadis`,{error:_}=await Oo.from("editions").insert({title:C,published_date:s,issue_no:r?Number(r):null,pdf_url:x,cover_url:v,page_count:E});if(_)throw _;qd({title:"Sayı eklendi"}),a(""),l(null),p.invalidateQueries({queryKey:["admin-editions"]}),p.invalidateQueries({queryKey:["editions-widget"]}),p.invalidateQueries({queryKey:["editions-page"]})}catch(v){qd({title:"Yüklenemedi",description:v.message,variant:"destructive"})}finally{c(!1),u("")}},A=async v=>{await Oo.from("editions").update({active:!v.active}).eq("id",v.id),p.invalidateQueries({queryKey:["admin-editions"]}),p.invalidateQueries({queryKey:["editions-widget"]})},S=async v=>{confirm(`"${v.title}" silinsin mi?`)&&(await Oo.from("editions").delete().eq("id",v.id),p.invalidateQueries({queryKey:["admin-editions"]}),p.invalidateQueries({queryKey:["editions-widget"]}))},w=t.reduce((v,E)=>v+(E.views??0),0);return X.jsxs("div",{className:"space-y-5",children:[X.jsxs("h1",{className:"text-xl font-semibold flex items-center gap-2",children:[X.jsx(Em,{className:"h-5 w-5"})," Dijital Gazete"]}),X.jsxs(xm,{className:"bg-white border-none shadow-sm",children:[X.jsx(Cm,{className:"pb-2 border-b bg-[#f0f0f1] rounded-t-lg",children:X.jsx(_m,{className:"text-sm font-semibold",children:"Yeni Sayı Ekle"})}),X.jsxs(Tm,{className:"pt-4 grid gap-4 md:grid-cols-2",children:[X.jsxs("div",{children:[X.jsx(qf,{children:"PDF Dosyası *"}),X.jsx(Yf,{type:"file",accept:"application/pdf",onChange:v=>{var E;return l(((E=v.target.files)==null?void 0:E[0])??null)}}),X.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Başlık, kapak önizlemesi ve sayfa sayısı PDF'den otomatik oluşturulur."})]}),X.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[X.jsxs("div",{children:[X.jsx(qf,{children:"Yayın Tarihi *"}),X.jsx(Yf,{type:"date",value:s,onChange:v=>i(v.target.value)})]}),X.jsxs("div",{children:[X.jsx(qf,{children:"Sayı No"}),X.jsx(Yf,{value:r,onChange:v=>a(v.target.value),placeholder:"Örn. 142"})]})]}),X.jsx("div",{className:"md:col-span-2",children:X.jsxs(Kf,{onClick:y,disabled:h,className:"gap-2",children:[h?X.jsx(km,{className:"h-4 w-4 animate-spin"}):X.jsx(UA,{className:"h-4 w-4"}),h?d||"Yükleniyor…":"Sayıyı Yayınla"]})})]})]}),X.jsxs(xm,{className:"bg-white border-none shadow-sm",children:[X.jsx(Cm,{className:"pb-2 border-b bg-[#f0f0f1] rounded-t-lg",children:X.jsxs(_m,{className:"text-sm font-semibold",children:["Sayılar (",t.length,") · Toplam okunma: ",w.toLocaleString("tr-TR")]})}),X.jsx(Tm,{className:"pt-4",children:e?X.jsx(km,{className:"h-5 w-5 animate-spin"}):t.length===0?X.jsx("p",{className:"text-sm text-muted-foreground",children:"Henüz sayı yok."}):X.jsx("ul",{className:"divide-y",children:t.map(v=>X.jsxs("li",{className:"flex items-center gap-3 py-2",children:[X.jsx("div",{className:"h-14 w-10 shrink-0 overflow-hidden rounded bg-muted",children:v.cover_url?X.jsx("img",{src:v.cover_url,alt:"",className:"h-full w-full object-cover"}):X.jsx("div",{className:"flex h-full items-center justify-center",children:X.jsx(Em,{className:"h-4 w-4 text-muted-foreground"})})}),X.jsxs("div",{className:"min-w-0 flex-1",children:[X.jsx("a",{href:v.pdf_url,target:"_blank",rel:"noopener",className:"text-sm font-medium hover:underline",children:v.title}),X.jsxs("p",{className:"text-xs text-muted-foreground",children:[Pm(v.published_date),v.issue_no?` · Sayı ${v.issue_no}`:"",v.page_count?` · ${v.page_count} sayfa`:"",v.active?"":" · Gizli"]})]}),X.jsxs("span",{className:"flex items-center gap-1 text-xs tabular-nums text-muted-foreground",title:"Okunma",children:[X.jsx(Mm,{className:"h-3.5 w-3.5"}
60)," ",(v.views??0).toLocaleString("tr-TR")]}),X.jsx(Kf,{variant:"ghost",size:"icon",onClick:()=>A(v),title:v.active?"Gizle":"Yayınla",children:v.active?X.jsx(Mm,{className:"h-4 w-4"}):X.jsx(GA,{className:"h-4 w-4"})}),X.jsx(Kf,{variant:"ghost",size:"icon",onClick:()=>S(v),title:"Sil",children:X.jsx(HA,{className:"h-4 w-4 text-destructive"})})]},v.id))})})]})]})};export{ov as default};

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.