1import{p as ba}from"./app-CrT3tLfm.js";const wt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Bt=[1/0,1/0,-1/0,-1/0],ee=new Float32Array(Bt),es=[.001,0,0,.001,0,0],ut="http://www.w3.org/2000/svg",yt={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Ht={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},me="pdfjs_internal_id_",Ee="pdfjs_internal_editor_",j={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},z={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},ya={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},rt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},li={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},tt={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},ue={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Ai={ERRORS:0,WARNINGS:1,INFOS:5},Lt={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},Ce={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},wa={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Ei=Ai.WARNINGS;function va(h){Number.isInteger(h)&&(Ei=h)}function Aa(){return Ei}function Si(h){Ei>=Ai.INFOS&&console.info(`Info: ${h}`)}function $(h){Ei>=Ai.WARNINGS&&console.warn(`Warning: ${h}`)}function W(h){throw new Error(h)}function et(h,t){h||W(t)}function Ea(h){switch(h?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function mr(h,t=null,e=null){if(!h)return null;if(e&&typeof h=="string"&&(e.addDefaultProtocol&&h.startsWith("www.")&&h.match(/\./g)?.length>=2&&(h=`http://${h}`),e.tryConvertEncoding))try{h=_a(h)}catch{}const i=t?URL.parse(h,t):URL.parse(h);return Ea(i)?i:null}function br(h,t,e=!1){const i=URL.parse(h);return i?(i.hash=t,i.href):e&&mr(h,"http://example.com")?h.split("#",1)[0]+`${t?`#${t}`:""}`:""}function is(h){return h.substring(h.lastIndexOf("/")+1)}function F(h,t,e,i=!1){return Object.defineProperty(h,t,{value:e,enumerable:!i,configurable:!0,writable:!1}),e}const ae=(function(){function t(e,i){this.message=e,this.name=i}return t.prototype=new Error,t.constructor=t,t})();let ss=class extends ae{constructor(t,e){super(t,"PasswordException"),this.code=e}};class Ui extends ae{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let ns=class extends ae{constructor(t){super(t,"InvalidPDFException")}},fi=class extends ae{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}};class Sa extends ae{constructor(t){super(t,"FormatError")}}let zt=class extends ae{constructor(t){super(t,"AbortException")}};function xa(h){(typeof h!="object"||h?.length===void 0)&&W("Invalid argument for bytesToString");const t=h.length,e=8192;if(t<e)return String.fromCharCode.apply(null,h);const i=[];for(let s=0;s<t;s+=e){const n=Math.min(s+e,t),r=h.subarray(s,n);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function xi(h){typeof h!="string"&&W("Invalid argument for stringToBytes");const t=h.length,e=new Uint8Array(t);for(let i=0;i<t;
1++i)e[i]=h.charCodeAt(i)&255;return e}let Y=class{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return F(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return F(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return F(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return F(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return F(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return F(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")),F(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return F(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",F(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return F(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}},k=class{static get hexNums(){return F(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,i){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[i]}`}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,i=0){const s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let c=0;c<6;c+=2){const d=t[i+c],u=t[i+c+1];t[i+c]=d*s+u*r+o,t[i+c+1]=d*n+u*a+l}}static applyInverseTransform(t,e){const i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){const s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],c=t[0],d=t[1],u=t[2],f=t[3];let p=s*c+o,g=p,m=s*u+o,b=m,y=a*d+l,w=y,A=a*f+l,v=A;if(n!==0||r!==0){const E=n*c,_=n*u,C=r*d,S=r*f;p+=C,b+=C,m+=S,g+=S,y+=E,v+=E,A+=_,w+=_}i[0]=Math.min(i[0],p,m,g,b),i[1]=Math.min(i[1],y,A,w,v),i[2]=Math.max(i[2],p,m,g,b),i[3]=Math.max(i[3],y,A,w,v)}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 i=t[0],s=t[1],n=t[2],r=t[3],a=i**2+s**2,o=i*n+s*r,l=n**2+r**2,c=(a+l)/2,d=Math.sqrt(c**2-(a*l-o**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||1)}static normalizeRect(t){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 i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static#t(t,e,i,s,n,r,a,o,l,c){if(l<=0||l>=1)return;const d=1-l,u=l*l,f=u*l,p=d*(d*(d*t+3*l*e)+3*u*i)+f*s,g=d*(d*(d*n+3*l*r)+3*u*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,i,s,n,r,a,o,l,c,d,u){if(Math.abs(l)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,i,s,n,r,a,o,-d/c,u);return}const f=c**2-4*d*l;if(f<0)return;const p=Math.sqrt(f),g=2*l;this.#t(t,e,i,s,n,r,a,o,(-c+p)/g,u),this.#t(t,e,i,s,n,r,a,o,(-c-p)/g,u)}static bezierBoundingBox(t,e,i,s,n,r,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,i,n,a,e,s,r,o,3*(-t+3*(i-n)+a),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,a,e,s,r,o,3*(-e+3*(s-r)+o),6*(e-2*s+r),3*(s-e),l)}};function _a(h){return decodeURIComponent(escape(h))}let Vi=null,tn=null;function Ca(h){return Vi||(Vi=/([\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,tn=new Map([["ï¬
","ſt"]])),h.replaceAll(Vi,(t,e,i)=>e?e.normalize("NFKC"):tn.get(i))}function yr(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const h=new Uint8Array(32);return crypto.getRandomValues(h),xa(h)}function Pa(h,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[i,s,...n]=e;if(!h(i)&&!Number.isInteger(i)||!t(s))return!1;const r=n.length;let a=!0;switch(s.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;a=!1;break;default:return!1}for(const o of n)if(!(typeof o=="number"||a&&o===null))return!1;return!0}const _e=()=>[],ks=()=>new Map,rs=()=>Object.create(null),Ta=()=>new Set;typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(h){return[...this].join(h)});function Q(h,t,e){return Math.min(Math.max(h,t),e)}class We{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,d,u,f;switch(s%=360,s<0&&(s+=360),s){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,m,b;c===0?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+r,m=(t[3]-t[1])*i,b=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+r,m=(t[2]-t[0])*i,b=(t[3]-t[1])*i),this.transform=[c*i,d*i,u*i,f*i,p-c*i*o-u*i*l,g-d*i*o-f*i*l],this.width=m,this.height=b}get rawDims(){const t=this.viewBox;return F(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:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new We({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){const i=[t,e];return k.applyTransform(i,this.transform),i}convertToPdfPoint(t,e){const i=[t,e];return k.applyInverseTransform(i,this.transform),i}}class Fe{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};
1function s(n){if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(Fe.shouldBuildText(a))n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const o of n.children)s(o)}return s(t),i}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const ka=/url\(|image-set\(/i,Ma=/^on/i;let wr=class{static get _allowedHtmlElements(){return F(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 F(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return F(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return F(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return F(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,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{s.setValue(e,{value:a.target.value})});break;case"input":if(i.attributes.type==="radio"||i.attributes.type==="checkbox"){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{s.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{s.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of i.children)a.attributes.value===r.value?a.attributes.selected=!0:Object.hasOwn(a.attributes,"selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;s.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${s}`);for(const[o,l]of Object.entries(r))if(l!=null&&!Ma.test(o)&&!(s==="richText"&&!this._allowedRichTextAttributes.has(o)))switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(s==="richText"){const c=this._allowedRichTextStyles;for(const[d,u]of Object.entries(l))c.has(d)&&!ka.test(u)&&(t.style[d]=u)}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&n?.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static#t(t,e,i){return i==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===ut&&this._allowedSvgElements.has(t)?document.createElementNS(ut,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=this.#t(s.name,s.attributes?.xmlns,n)??document.createElement("div");s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});const a=n!=="richText",o=t.div;if(o.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(s.children.length===0){if(s.value){const d=document.createTextNode(s.value);r.append(d),a&&Fe.shouldBuildText(s.name)&&l.push(d)}return{textDivs:l}}const c=[[s,-1,r]];for(;c.length>0;){const[d,u,f]=c.at(-1);if(u+1===d.children.length){c.pop();continue}const p=d.children[++c.at(-1)[1]];if(p===null)continue;const{name:g}=p;if(g==="#text"){const b=document.createTextNode(p.value);l.push(b),f.append(b);continue}const m=this.#t(g,p.attributes?.xmlns,n);if(m){if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:n,linkService:i}),p.children?.length>0)c.push([p,-1,m]);else if(p.value){const b=document.createTextNode(p.value);a&&Fe.shouldBuildText(g)&&l.push(b),m.append(b)}}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:l}}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:i=0}){const{width:s,height:n}=t.attributes.style;return new We({viewBox:[0,0,parseInt(s,10),parseInt(n,10)],userUnit:1,scale:e,rotation:i})}},Se=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Ms(h,t="text"){if(De(h,document.baseURI)){const e=await fetch(h);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,i)=>{const s=new XMLHttpRequest;s.open("GET",h,!0),s.responseType=t==="bytes"?"arraybuffer":t,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE){if(s.status===200||s.status===0){switch(t){case"bytes":e(new Uint8Array(s.response));return;case"blob":case"json":e(s.response);return}e(s.responseText);return}i(new Error(s.statusText))}},s.send(null)})}let Is=class extends ae{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function _i(h){const t=h.length;let e=0;for(;e<t&&h[e].trim()==="";)e++;return h.substring(e,e+5).toLowerCase()==="data:"}function Ls(h){return typeof h=="string"&&/\.pdf$/i.test(h)}function Ia(h){return[h]=h.split(/[#?]/,1),is(h)}function La(h,t="document.pdf"){if(typeof h!="string")return t;if(_i(h))return $('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const i=(a=>{try{return new URL(a)}catch{}try{return new URL(decodeURIComponent(a))}catch{}try{return new URL(a,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{}return null})(h);if(!i)return t;const s=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=is(o),o.length===4&&n.test(o))?a:o}catch{return a}},n=/\.pdf$/i,r=is(i.pathname);if(n.test(r))return s(r);if(i.searchParams.size>0){const a=l=>[...l].findLast(c=>n.test(c)),o=a(i.searchParams.values())??a(i.searchParams.keys());if(o)return s(o)}if(i.hash){const{hash:a}=i;let o=-1;for(const{index:l}of a.matchAll(/\.pdf\b/gi))o=l;if(o>0){let l=o;for(;l>
10&&!"/?#=".includes(a[l-1]);)l--;if(l<o)return s(a.slice(l,o+4))}}return t}class en{#t=new Map;times=[];time(t){this.#t.has(t)&&$(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||$(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms 2`).join("")}}function De(h,t){const e=t?URL.parse(h,t):URL.parse(h);return/https?:/.test(e?.protocol??"")}function Ct(h){h.preventDefault()}function at(h){h.preventDefault(),h.stopPropagation()}let as=class{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=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,l==="-"?(r+=c,a+=d):l==="+"&&(r-=c,a-=d),new Date(Date.UTC(i,s,n,r,a,o))}};function Ge(h){if(h.startsWith("#")){const e=h.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(h.startsWith("rgb(")){const[e,i,s]=h.slice(4,-1).split(",").map(n=>parseInt(n,10));return[e,i,s,1]}if(h.startsWith("rgba(")){const e=h.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=h.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function Xe(h){const t=Ge(h);return t?t.slice(0,3):($(`Not a valid color format: "${h}"`),[0,0,0])}function Da(h){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of h.keys()){t.style.color=e;const i=window.getComputedStyle(t).color;h.set(e,Xe(i))}t.remove()}function q(h){const{a:t,b:e,c:i,d:s,e:n,f:r}=h.getTransform();return[t,e,i,s,n,r]}function Pt(h){const{a:t,b:e,c:i,d:s,e:n,f:r}=h.getTransform().invertSelf();return[t,e,i,s,n,r]}function ne(h,t,e=!1,i=!0){if(t instanceof We){const{pageWidth:s,pageHeight:n}=t.rawDims,{style:r}=h,a=`round(down, var(--total-scale-factor) * ${s}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-y))`;!e||t.rotation%180===0?(r.width=a,r.height=o):(r.width=o,r.height=a)}i&&h.setAttribute("data-main-rotation",t.rotation)}let Wt=class os{constructor(){const{pixelRatio:t}=os;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,i,s,n=-1){let r=1/0,a=1/0,o=1/0;i=os.capPixels(i,n),i>0&&(r=Math.sqrt(i/(t*e))),s!==-1&&(a=s/t,o=s/e);const l=Math.min(r,a,o);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}};const ls=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Ra{static get isDarkMode(){return F(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}let Na=class{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:i}=window.getComputedStyle(t);return t.remove(),F(this,"commentForegroundColor",Xe(i))}};function Oa(h,t){t=Q(t??1,0,1);const e=255*(1-t);return h.map(i=>Math.round(i*t+e))}function sn(h,t){const e=h[0]/255,i=h[1]/255,s=h[2]/255,n=Math.max(e,i,s),r=Math.min(e,i,s),a=(n+r)/2;if(n===r)t[0]=t[1]=0;else{const o=n-r;switch(t[1]=a<.5?o/(n+r):o/(2-n-r),n){case e:t[0]=((i-s)/o+(i<s?6:0))*60;break;case i:t[0]=((s-e)/o+2)*60;break;case s:t[0]=((e-i)/o+4)*60;break}}t[2]=a}function hs(h,t){const e=h[0],i=h[1],s=h[2],n=(1-Math.abs(2*s-1))*i,r=n*(1-Math.abs(e/60%2-1)),a=s-n/2;switch(Math.floor(e/60)){case 0:t[0]=n+a,t[1]=r+a,t[2]=a;break;case 1:t[0]=r+a,t[1]=n+a,t[2]=a;break;case 2:t[0]=a,t[1]=n+a,t[2]=r+a;break;case 3:t[0]=a,t[1]=r+a,t[2]=n+a;break;case 4:t[0]=r+a,t[1]=a,t[2]=n+a;break;
2case 5:case 6:t[0]=n+a,t[1]=a,t[2]=r+a;break}}function cs(h){return h<=.03928?h/12.92:((h+.055)/1.055)**2.4}function nn(h,t,e){hs(h,e),e.map(cs);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];hs(t,e),e.map(cs);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];return i>s?(i+.05)/(s+.05):(s+.05)/(i+.05)}const rn=new Map;function Fa(h,t){const e=h[0]+h[1]*256+h[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let i=rn.get(e);if(i)return i;const s=new Float32Array(9),n=s.subarray(0,3),r=s.subarray(3,6);sn(h,r);const a=s.subarray(6,9);sn(t,a);const o=a[2]<.5,l=o?12:4.5;if(r[2]=o?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]),nn(r,a,n)<l){let c,d;o?(c=r[2],d=1):(c=0,d=r[2]);const u=.005;for(;d-c>u;){const f=r[2]=(c+d)/2;o===nn(r,a,n)<l?c=f:d=f}r[2]=o?d:c}return hs(r,n),i=k.makeHexColor(Math.round(n[0]*255),Math.round(n[1]*255),Math.round(n[2]*255)),rn.set(e,i),i}function vr({html:h,dir:t,className:e},i){const s=document.createDocumentFragment();if(typeof h=="string"){const n=document.createElement("p");n.dir=t||"auto";const r=h.split(/\r\n?|\n/);for(let a=0,o=r.length;a<o;++a){const l=r[a];n.append(document.createTextNode(l)),a<o-1&&n.append(document.createElement("br"))}s.append(n)}else wr.render({xfaHtml:h,div:s,intent:"richText"});s.firstElementChild.classList.add("richText",e),i.append(s)}function Ar(h){const t=new Path2D;if(!h)return t;for(let e=0,i=h.length;e<i;)switch(h[e++]){case Ce.moveTo:t.moveTo(h[e++],h[e++]);break;case Ce.lineTo:t.lineTo(h[e++],h[e++]);break;case Ce.curveTo:t.bezierCurveTo(h[e++],h[e++],h[e++],h[e++],h[e++],h[e++]);break;case Ce.quadraticCurveTo:t.quadraticCurveTo(h[e++],h[e++],h[e++],h[e++]);break;case Ce.closePath:t.closePath();break;default:$(`Unrecognized drawing path operator: ${h[e-1]}`);break}return t}class Re{#t=null;#e=null;#i;#s=null;#n=null;#r=null;#a=null;#o=null;static#l=null;constructor(t){this.#i=t,Re.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#i._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",Ct,{signal:e}),t.addEventListener("pointerdown",Re.#h,{signal:e}));const i=this.#s=document.createElement("div");i.className="buttons",t.append(i);const s=this.#i.toolbarPosition;if(s){const{style:n}=t,r=this.#i._uiManager.direction==="ltr"?1-s[0]:s[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#h(t){t.stopPropagation()}#u(t){this.#i._focusEventsAllowed=!1,at(t)}#d(t){this.#i._focusEventsAllowed=!0,at(t)}#f(t){const e=this.#i._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ct,{signal:e}),!0)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#n?.shown(),this.#r?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#i,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",Re.#l[t]),this.#f(i)&&i.addEventListener("click",s=>{e.delete()},{signal:e._signal}),this.#s.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#f(e),this.#s.append(e,this.#g),this.#n=t}addComment(t,e=null){if(this.#r)return;const i=t.renderForToolbar();if(!i)return;this.#f(i);const s=this.#a=this.#g;e?(this.#s.insertBefore(i,e),this.#s.insertBefore(s,e)):this.#s.append(i,s),this.#r=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;const e=t.renderButton();this.#f(e),this.#s.append(e,this.#g)}async addEditSignatureButton(t){const e=this.#o=await t.renderEditButton(this.#i);this.#f(e),this.#s.append(e,this.#g)}removeButton(t){t==="comment"&&(this.#r?.removeToolbarCommentButton(),this.#r=null,this.#a?.remove(),this.#a=null)}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,i){if(!e&&t==="comment")return;const s=this.#s.querySelector(i);s&&t==="comment"&&this.addComment(e,s)}updateEditSignatureButton(t){this.#o&&(this.#o.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class Ba{#t=null;#e=null;#i;constructor(t){this.#i=t}#s(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=this.#i.direction;const e=this.#i._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Ct,{signal:e});const i=this.#t=document.createElement("div");return i.className="buttons",t.append(i),this.#i.hasCommentManager()&&this.#r("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#i.commentSelection("floating_button")}),this.#r("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#i.highlightSelection("floating_button")}),t}#n(t,e){let i=0,s=0;for(const n of t){const r=n.y+n.height;if(r<i)continue;const a=n.x+(e?n.width:0);if(r>i){s=a,i=r;continue}e?a>s&&(s=a):a<s&&(s=a)}return[e?1-s:s,i]}
2show(t,e,i){const[s,n]=this.#n(e,i),{style:r}=this.#e||=this.#s();t.append(this.#e),r.insetInlineEnd=`${100*s}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#r(t,e,i,s){const n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);const r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",i);const a=this.#i._signal;a instanceof AbortSignal&&!a.aborted&&(n.addEventListener("contextmenu",Ct,{signal:a}),n.addEventListener("click",s,{signal:a})),this.#t.append(n)}}const ja="59968104-cc61-4cf9-b570-014b35b3709c",Hi=Object.freeze({internal:ja});function Er(h,t,e){for(const i of e)t.addEventListener(i,h[i].bind(h))}class X{static#t=NaN;static#e=null;static#i=NaN;static#s=null;static initializeAndAddPointerId(t){(X.#e||=new Set).add(t)}static setPointer(t,e){X.#t||=e,X.#s??=t}static setTimeStamp(t){X.#i=t}static isSamePointerId(t){return X.#t===t}static isSamePointerIdOrRemove(t){return X.#t===t?!0:(X.#e?.delete(t),!1)}static isSamePointerType(t){return X.#s===t}static isInitializedAndDifferentPointerType(t){return X.#s!==null&&!X.isSamePointerType(t)}static isSameTimeStamp(t){return X.#i===t}static isUsingMultiplePointers(){return X.#e?.size>=1}static clearPointerType(){X.#s=null}static clearPointerIds(){X.#t=NaN,X.#e=null}static clearTimeStamp(){X.#i=NaN}}class $a{#t=0;get id(){return`${Ee}${this.#t++}`}}class Ds{#t=yr();#e=0;#i=null;static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${ut}"><rect width="1" height="1" style="fill:red;"/></svg>`,i=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),s=new Image;s.src=t;const n=s.decode().then(()=>(i.drawImage(s,0,0,1,1,0,0,1,3),new Uint32Array(i.getImageData(0,0,1,1).data.buffer)[0]===0));return F(this,"_isSVGFittingCanvas",n)}async#s(t,e){this.#i||=new Map;let i=this.#i.get(t);if(i===null)return null;if(i?.bitmap)return i.refCounter+=1,i;try{i||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let s;if(typeof e=="string"?(i.url=e,s=await Ms(e,"blob")):e instanceof File?s=i.file=e:e instanceof Blob&&(s=e),s.type==="image/svg+xml"){const n=Ds._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((l,c)=>{a.onload=()=>{i.bitmap=a,i.isSvg=!0,l()},r.onload=async()=>{const d=i.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(s),await o}else i.bitmap=await createImageBitmap(s);i.refCounter=1}catch(s){$(s),i=null}return this.#i.set(t,i),i&&this.#i.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#s(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#s(t,t)}async getFromBlob(t,e){const i=await e;return this.#s(t,i)}async getFromId(t){this.#i||=new Map;const e=this.#i.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:i}=e;return delete e.blobPromise,this.getFromBlob(e.id,i)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#i||=new Map;let i=this.#i.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#i.set(t,i),this.#i.set(i.id,i),i}getSvgUrl(t){const e=this.#i.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#i||=new Map;const e=this.#i.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:i}=e;if(!e.url&&!e.file){const s=new OffscreenCanvas(i.width,i.height);s.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=s.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class Ua{#t=[];#e=!1;#i;#s=-1;constructor(t=128){this.#i=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),this.#e)return;const o={cmd:t,undo:e,post:i,type:n};if(this.#s===-1){this.#t.length>0&&(this.#t.length=0),this.#s=0,this.#t.push(o);return}if(r&&this.#t[this.#s].type===n){a&&(o.undo=this.#t[this.#s].undo),this.#t[this.#s]=o;return}const l=this.#s+1;l===this.#i?this.#t.splice(0,1):(this.#s=l,l<this.#t.length&&this.#t.splice(l)),this.#t.push(o)}undo(){if(this.#s===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1,this.#s-=1}redo(){if(this.#s<this.#t.length-1){this.#s+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#t.length-1}cleanType(t){if(this.#s!==-1){for(let e=this.#s;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#s-e),this.#s=e;return}this.#t.length=0,this.#s=-1}}destroy(){this.#t=null}}class vt{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;const{isMac:e}=Y.platform;for(const[i,s,n={}]of t){const r=i.some(a=>a.startsWith("mac+"));for(const a of i){let o=a;if(r){const d=a.startsWith("mac+");if(e!==d)continue;d&&(o=a.slice(4))}const[l,c]=vt.#t(o);l!==null&&this.callbacks.getOrInsertComputed(l,_e).push({callback:s,options:n,modifiers:c})}}}static#t(t){let e=null,i=0;for(let s of t.split("+")){if(s=s.trim(),!s)continue;const n=s.toUpperCase(),r=vt[n];if(r){i|=r;continue}if(e!==null){$(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=n==="SPACE"?" ":s}return e===null&&$(`KeyboardManager: no key found in shortcut "${t}"`),[e,i]}static#e(t){const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?e[1]?.toLowerCase()??e[2]:null}exec(t,e){let i=this.callbacks.get(e.key);if(!i){if(/^[a-z]$/i.test(e.key))return;const c=vt.#e(e.code);
vendor: 4,304 bytes, line 2
2if(c===null||c===e.key||(i=this.callbacks.get(c),!i))return}const s=(e.altKey?vt.ALT:0)|(e.ctrlKey?vt.CTRL:0)|(e.metaKey?vt.META:0)|(e.shiftKey?vt.SHIFT:0),n=i.find(c=>c.modifiers===s);if(!n)return;const{callback:r,options:{bubbles:a=!1,args:o=[],checker:l=null}}=n;l&&!l(t,e)||(r.bind(t,...o,e)(),a||at(e))}}class Rs{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Da(t),F(this,"_colors",t)}convert(t){const e=Xe(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[i,s]of this._colors)if(s.every((n,r)=>n===e[r]))return Rs._colorsMapping.get(i);return e}getHexCode(t){const e=this._colors.get(t);return e?k.makeHexColor(...e):t}}let Be=class ds{#t=new AbortController;#e=null;#i=null;#s=new Map;#n=new Map;#r=null;#a=null;#o=null;#l=null;#h=null;#u=new Ua;#d=null;#f=null;#g=null;#m=0;#c=new Set;#p=null;#b=null;#y=new Set;_editorUndoBar=null;#w=!1;#v=!1;#E=!1;#A=null;#x=null;#S=null;#T=null;#k=!1;#P=null;#I=new $a;#M=!1;#D=!1;#V=!1;#R=null;#$=null;#B=null;#L=null;#N=null;#C=j.NONE;#_=new Set;#H=null;#W=null;#U=null;#X=null;#q=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#j=[0,0];#G=null;#O=null;#Z=null;#it=null;#z=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=ds.prototype,e=r=>r.#O.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),i=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return F(this,"_keyboardManager",new vt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["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:i}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#O.contains(a)&&!r.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#O.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,r,a,o,l,c,d,u,f,p,g,m){const b=this._signal=this.#t.signal;this.#O=t,this.#Z=e,this.#it=i,this.#o=s,this.#d=n,this.#W=r,this.#q=o,this._eventBus=a;const y={signal:b,...Hi};a.on("editingaction",this.onEditingAction.bind(this),y),a.on("pagechanging",this.onPageChanging.bind(this),y),a.on("scalechanging",this.onScaleChanging.bind(this),y),a.on("rotationchanging",this.onRotationChanging.bind(this),y),a.on("setpreference",this.onSetPreference.bind(this),y),a.on("switchannotationeditorparams",w=>this.updateParams(w.type,w.value),y),window.addEventListener("pointerdown",()=>{this.#D=!0},{capture:!0,signal:b}),window.addEventListener("pointerup",()=>{this.#D=!1},{capture:!0,signal:b}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:b}),this.#et(),this.#pt(),this.#ot(),this.#l=o.annotationStorage,this.#A=o.filterFactory,this.#U=l,this.#T=c||null,this.#w=d,this.#v=u,this.#E=f,this.#N=p||null,this.viewParameters={realScale:Se.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=m!==!1,n?.setSidebarUiManager(this)}destroy(){this.#z?.resolve(),this.#z=null,this.#t?.abort(),this.#t=null,this._signal=null;
2for(const t of this.#n.values())t.destroy();this.#n.clear(),this.#s.clear(),this.#y.clear(),this.#L?.clear(),this.#e=null,this.#_.clear(),this.#u.destroy(),this.#o?.destroy(),this.#d?.destroy(),this.#W?.destroy(),this.#P?.hide(),this.#P=null,this.#B?.destroy(),this.#B=null,this.#i=null,this.#x&&(clearTimeout(this.#x),this.#x=null),this.#G&&(clearTimeout(this.#G),this.#G=null),this._editorUndoBar?.destroy(),this.#q=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#N}get useNewAltTextFlow(){return this.#v}get useNewAltTextWhenAddingImage(){return this.#E}get hcmFilter(){return F(this,"hcmFilter",this.#U?this.#A.addHCMFilter(this.#U.foreground,this.#U.background):"none")}get direction(){return F(this,"direction",getComputedStyle(this.#O).direction)}get _highlightColors(){return F(this,"_highlightColors",this.#T?new Map(this.#T.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 F(this,"highlightColors",null);const e=new Map,i=!!this.#U;for(const[s,n]of t){const r=s.endsWith("_HCM");if(i&&r){e.set(s.replace("_HCM",""),n);continue}!i&&!r&&e.set(s,n)}return F(this,"highlightColors",e)}get highlightColorNames(){return F(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),this.#g=t}setMainHighlightColorPicker(t){this.#B=t}editAltText(t,e=!1){this.#o?.editAltText(this,t,e)}hasCommentManager(){return!!this.#d}editComment(t,e,i,s){this.#d?.showDialog(this,t,e,i,s)}selectComment(t,e){this.#n.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#d?.updateComment(t.getData())}updatePopupColor(t){this.#d?.updatePopupColor(t)}removeComment(t){this.#d?.removeComments([t.uid])}deleteComment(t,e){const i=()=>{t.comment=e},s=()=>{this._editorUndoBar?.show(i,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:s,undo:i,mustExec:!0})}toggleComment(t,e,i=void 0){this.#d?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#d?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#d?.dialogElement||null}async waitForEditorsRendered(t){if(this.#n.has(t-1))return;const{resolve:e,promise:i}=Promise.withResolvers(),s=n=>{n.pageNumber===t&&(this._eventBus.off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s,Hi),await i}getSignature(t){this.#W?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#W}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...Hi}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){t==="enableNewAltTextWhenAddingImage"&&(this.#E=e)}onPageChanging({pageNumber:t}){this.#m=t-1}deletePage(t){for(const e of this.getEditors(t))e.remove();this.#n.delete(t),this.#m===t&&(this.#m=0)}focusMainContainer(){this.#O.focus()}findParent(t,e){for(const i of this.#n.values()){const{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){this.#Z.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Se.PDF_TO_CSS_UNITS;for(const e of this.#y)e.onScaleChanging();this.#g?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#J({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#tt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const i of this.#n.values())if(i.hasTextLayer(t))return i;return null}highlightSelection(t="",e=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a}=i,o=i.toString(),c=this.#J(i).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;i.empty();const u=this.#tt(c),f=this.#C===j.NONE,p=()=>{const g=u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:a,text:o});f&&this.showAllEditors("highlight",!0,!0),e&&g?.editComment()};if(f){this.switchToMode(j.HIGHLIGHT,p);return}p()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#st(){const t=document.getSelection();if(!t||t.isCollapsed)return;const i=this.#J(t).closest(".textLayer"),s=this.getSelectionBoxes(i);s&&(this.#P||=new Ba(this),this.#P.show(i,s,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#l)return null;const e=`${Ee}${t}`,i=this.#l.getRawValue(e);return i&&this.#l.remove(e),i}addToAnnotationStorage(t){!t.isEmpty()&&this.#l&&!this.#l.has(t.id)&&this.#l.setValue(t.id,t)}a11yAlert(t,e=null){const i=this.#it;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#at(){const t=document.getSelection();if(!t||t.isCollapsed){this.#H&&(this.#P?.hide(),this.#H=null,this.#F({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#H)return;const s=this.#J(t).closest(".textLayer");if(!s){this.#H&&(this.#P?.hide(),this.#H=null,this.#F({hasSelectedText:!1}));return}if(this.#P?.hide(),this.#H=e,this.#F({hasSelectedText:!0}),!(this.#C!==j.HIGHLIGHT&&this.#C!==j.NONE)&&(this.#C===j.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#k=this.isShiftKeyDown,!this.isShiftKeyDown)){const n=this.#C===j.HIGHLIGHT?this.#tt(s):null;if(n?.toggleDrawing(),this.#D){const r=new AbortController,a=this.combinedSignal(r),o=l=>{l.type==="pointerup"&&l.button!==0||(r.abort(),n?.toggleDrawing(!0),l.type==="pointerup"&&this.#Q("main_toolbar"))};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}else n?.toggleDrawing(!0),this.#Q("main_toolbar")}}#Q(t=""){this.#C===j.HIGHLIGHT?this.highlightSelection(t):this.#w&&this.#st()}#et(){document.addEventListener("selectionchange",this.#at.bind(this),{signal:this._signal})}#nt(){if(this.#S)return;this.#S=new AbortController;const t=this.combinedSignal(this.#S);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ct(){this.#S?.abort(),this.#S=null}blur(){if(this.isShiftKeyDown=!1,this.#k&&(this.#k=!1,this.#Q("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#_)if(e.div.contains(t)){this.#$=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#$)return;const[t,e]=this.#$;this.#$=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#ot(){if(this.#R)return;this.#R=new AbortController;const t=this.combinedSignal(this.#R);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#dt(){this.#R?.abort(),this.#R=null}#ut(){if(this.#f)return;this.#f=new AbortController;const t=this.combinedSignal(this.#f);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#ft(){this.#f?.abort(),this.#f=null}#pt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#ot(),this.setEditingState(!0)}removeEditListeners(){this.#dt(),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#b)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#b)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of this.#_){const s=i.serialize(!0);s&&e.push(s)}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 n of e.items)for(const r of this.#b)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(n){$(`paste: "${n.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const n=[];for(const o of i){const l=await s.deserialize(o);if(!l)return;n.push(l)}const r=()=>{for(const o of n)this.#lt(o);this.#ht(n)},a=()=>{for(const o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){$(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==j.NONE&&!this.isEditorHandlingKeyboard&&ds._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#k&&(this.#k=!1,this.#Q("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(t,e){for(const s of this.#a.get(t)||[])s.pageIndex=e;const i=this.#r.get(t);i&&(i.pageIndex=e,this.#n.set(e,i),this.#M?i.enable():i.disable())}startUpdatePages(){this.#r=new Map(this.#n),this.#n.clear();const t=this.#a=new Map,e=i=>{t.getOrInsertComputed(i.pageIndex,_e).push(i)};for(const i of this.#s.values())e(i);for(const[i,s]of this.#l)i.startsWith(Ee)&&!this.#s.has(i)&&Number.isInteger(s?.pageIndex)&&e(s)}endUpdatePages(){this.#r=null,this.#a=null}clonePage(t,e){for(const i of this.getEditors(t)){const s=i.serialize(i.mode!==j.HIGHLIGHT);s&&(s.pageIndex=e,s.id=this.getId(),s.isClone=!0,delete s.popupRef,this.#l.setValue(s.id,s))}}findClonesForPage(t){const e=[],{pageIndex:i}=t;
2for(const[s,n]of this.#l)n.pageIndex===i&&n.isClone&&(this.#l.remove(s),e.push(t.deserialize(n).then(r=>{r&&(r.isClone=!0,t.addOrRebuild(r))})));return Promise.all(e)}#F(t){Object.entries(t).some(([i,s])=>this.#K[i]!==s)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#C===j.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#Y([[z.HIGHLIGHT_FREE,!0]]))}#Y(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#nt(),this.#ut(),this.#F({isEditing:this.#C!==j.NONE,isEmpty:this.#rt(),hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ct(),this.#ft(),this.#F({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#b){this.#b=t;for(const e of this.#b)this.#Y(e.defaultPropertiesToUpdate)}}getId(){return this.#I.id}get currentLayer(){return this.#n.get(this.#m)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#m}addLayer(t){this.#n.set(t.pageIndex,t),this.#M?t.enable():t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,n=!1,r=!1){if(this.#C!==t&&!(this.#z&&(await this.#z.promise,!this.#z))){if(this.#z=Promise.withResolvers(),this.#g?.commitOrRemove(),this.#C===j.POPUP&&this.#d?.hideSidebar(),this.#d?.destroyPopup(),this.#C=t,t===j.NONE){this.setEditingState(!1),this.#mt();for(const a of this.#s.values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#z.resolve();return}for(const a of this.#s.values())a.addStandaloneCommentButton();t===j.SIGNATURE&&await this.#W?.loadSignatures(),i&&X.clearPointerType(),this.setEditingState(!0),await this.#gt(),this.unselectAll();for(const a of this.#n.values())a.updateMode(t);if(t===j.POPUP){this.#i||=await this.#q.getAnnotationsByType(new Set(this.#b.map(l=>l._editorType)));const a=new Set,o=[];for(const l of this.#s.values()){const{annotationElementId:c,hasComment:d,deleted:u}=l;c&&a.add(c),d&&!u&&o.push(l.getData())}for(const l of this.#i){const{id:c,popupRef:d,contentsObj:u}=l;d&&u?.str&&!a.has(c)&&!this.#c.has(c)&&o.push(l)}this.#d?.showSidebar(o)}if(!e){s&&this.addNewEditorFromKeyboard(),this.#z.resolve();return}for(const a of this.#s.values())a.uid===e?(this.setSelected(a),r?a.editComment():n?a.enterInEditMode():a.focus()):a.unselect();this.#z.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#b){switch(t){case z.CREATE:this.currentLayer.addNewEditor(e);return;case z.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#X||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const i of this.#_)i.updateParams(t,e);else for(const i of this.#b)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const n of this.#s.values())n.editorType===t&&n.show(e);(this.#X?.get(z.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Y([[z.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#V!==t){this.#V=t;for(const e of this.#n.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#gt(){if(!this.#M){this.#M=!0;const t=[];for(const e of this.#n.values())t.push(e.enable());await Promise.all(t);for(const e of this.#s.values())e.enable()}}#mt(){if(this.unselectAll(),this.#M){this.#M=!1;for(const t of this.#n.values())t.disable();for(const t of this.#s.values())t.disable()}}*getEditors(t){for(const e of this.#s.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#x&&clearTimeout(this.#x),this.#x=setTimeout(()=>{this.focusMainContainer(),this.#x=null},0)),this.#s.delete(t.id),t.annotationElementId&&this.#L?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!this.#c.has(t.annotationElementId))&&this.#l?.remove(t.id)}addDeletedAnnotationElement(t){this.#c.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}
2isDeletedAnnotationElement(t){return this.#c.has(t)}removeDeletedAnnotationElement(t){this.#c.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#lt(t){const e=this.#n.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#Y(t.propertiesToUpdate))}get#bt(){let t=null;for(t of this.#_);return t}updateUI(t){this.#bt===t&&this.#Y(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Y(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#_.has(t)){this.#_.delete(t),t.unselect(),this.#F({hasSelectedEditor:this.hasSelection});return}this.#_.add(t),t.select(),this.#Y(t.propertiesToUpdate),this.#F({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#g?.commitOrRemove();for(const e of this.#_)e!==t&&e.unselect();this.#d?.destroyPopup(),this.#_.clear(),this.#_.add(t),t.select(),this.#Y(t.propertiesToUpdate),this.#F({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#_.values().next().value}unselect(t){t.unselect(),this.#_.delete(t),this.#F({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#_.size!==0}get isEnterHandled(){return this.#_.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#u.undo(),this.#F({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#rt()}),this._editorUndoBar?.hide()}redo(){this.#u.redo(),this.#F({hasSomethingToUndo:!0,hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#rt()})}addCommands(t){this.#u.add(t),this.#F({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#rt()})}cleanUndoStack(t){this.#u.cleanType(t)}#rt(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const t of this.#s.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#_],i=()=>{this._editorUndoBar?.show(s,e.length===1?e[0].editorType:e.length);for(const n of e)n.remove()},s=()=>{for(const n of e)this.#lt(n)};this.addCommands({cmd:i,undo:s,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#ht(t){for(const e of this.#_)e.unselect();this.#_.clear();for(const e of t)e.isEmpty()||(this.#_.add(e),e.select());this.#F({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#_)t.commit();this.#ht(this.#s.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==j.NONE))&&!this.#g?.commitOrRemove()&&(this.#d?.destroyPopup(),!!this.hasSelection)){for(const t of this.#_)t.unselect();this.#_.clear(),this.#F({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#j[0]+=t,this.#j[1]+=e;const[s,n]=this.#j,r=[...this.#_],a=1e3;this.#G&&clearTimeout(this.#G),this.#G=setTimeout(()=>{this.#G=null,this.#j[0]=this.#j[1]=0,this.addCommands({cmd:()=>{for(const o of r)this.#s.has(o.id)&&(o.translateInPage(s,n),o.translationDone())},undo:()=>{for(const o of r)this.#s.has(o.id)&&(o.translateInPage(-s,-n),o.translationDone())},mustExec:!1})},a);for(const o of r)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#p=new Map;for(const t of this.#_)this.#p.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#p)return!1;this.disableUserSelect(!1);const t=this.#p;this.#p=null;let e=!1;for(const[{x:s,y:n,pageIndex:r},a]of t)a.newX=s,a.newY=n,a.newPageIndex=r,e||=s!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const i=(s,n,r,a)=>{if(this.#s.has(s.id)){const o=this.#n.get(a);o?s._setParentAndPosition(o,n,r):(s.pageIndex=a,s.x=n,s.y=r)}};return this.addCommands({cmd:()=>{for(const[s,{newX:n,newY:r,newPageIndex:a}]of t)i(s,n,r,a)},undo:()=>{for(const[s,{savedX:n,savedY:r,savedPageIndex:a}]of t)i(s,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#p)for(const i of this.#p.keys())i.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(){return this.getActive()?.shouldGetKeyboardEvents()||this.#_.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}isEditingMode(){return this.#C!==j.NONE}get imageManager(){return F(this,"imageManager",new Ds)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,c=e.rangeCount;l<c;
2l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,c,d,u)=>({x:(c-s)/r,y:1-(l+d-i)/n,width:u/r,height:d/n});break;case"180":a=(l,c,d,u)=>({x:1-(l+d-i)/n,y:1-(c+u-s)/r,width:d/n,height:u/r});break;case"270":a=(l,c,d,u)=>({x:1-(c+u-s)/r,y:(l-i)/n,width:u/r,height:d/n});break;default:a=(l,c,d,u)=>({x:(l-i)/n,y:(c-s)/r,width:d/n,height:u/r});break}const o=[];for(let l=0,c=e.rangeCount;l<c;l++){const d=e.getRangeAt(l);if(!d.collapsed)for(const{x:u,y:f,width:p,height:g}of d.getClientRects())p===0||g===0||o.push(a(u,f,p,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#h||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#h?.delete(t)}renderAnnotationElement(t){const e=this.#h?.get(t.data.id);if(!e)return;const i=this.#l.getRawValue(e);i&&(this.#C===j.NONE&&!i.hasBeenModified||i.renderAnnotationElement(t))}setMissingCanvas(t,e,i){const s=this.#L?.get(t);s&&(s.setCanvas(e,i),this.#L.delete(t))}addMissingCanvas(t,e){(this.#L||=new Map).set(t,e)}};class Dt{#t=null;#e=!1;#i=null;#s=null;#n=null;#r=null;#a=!1;#o=null;#l=null;#h=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#l=t,this.#d=t._uiManager.useNewAltTextFlow,Dt.#f||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){Dt._l10n??=t}async render(){const t=this.#i=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#s=document.createElement("span");t.append(e),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",Dt.#f.missing),e.setAttribute("data-l10n-id",Dt.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#l._uiManager._signal;t.addEventListener("contextmenu",Ct,{signal:i}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:i});const s=n=>{n.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#d&&this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#g}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#a=!0,s(n))},{signal:i}),await this.#m(),t}get#g(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#i&&(this.#i.focus({focusVisible:this.#a}),this.#a=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#h:this.isEmpty()}get guessedText(){return this.#h}async setGuessedText(t){this.#t===null&&(this.#h=t,this.#u=await Dt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#m())}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){const e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#l.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#h===e&&(e=this.#u),{altText:e,decorative:this.#e,guessedText:this.#h,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#h=i,this.#u=s),!(this.#t===t&&this.#e===e)&&(n||(this.#t=t,this.#e=e),this.#m())}toggle(t=!1){this.#i&&(!t&&this.#r&&(clearTimeout(this.#r),this.#r=null),this.#i.disabled=!t)}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#g}})}destroy(){this.#i?.remove(),this.#i=null,this.#s=null,this.#n=null,this.#o?.remove(),this.#o=null}async#m(){const t=this.#i;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",Dt.#f[this.#g]),this.#s?.setAttribute("data-l10n-id",Dt.#f[`${this.#g}-label`]),!this.#t){this.#n?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#l.id}`;const s=100,n=this.#l._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#r),this.#r=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#r=setTimeout(()=>{this.#r=null,this.#n.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},s)},{signal:n}),t.addEventListener("mouseleave",()=>{this.#r&&(clearTimeout(this.#r),this.#r=null),this.#n?.classList.remove("show")},{signal:n})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#l.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class qe{#t=null;#e=null;#i=!1;#s=null;#n=null;#r=null;#a=null;#o=null;#l=!1;#h=null;constructor(t){this.#s=t}renderForToolbar(){const t=this.#e=document.createElement("button");
2return t.className="comment",this.#u(t,!1)}renderForStandalone(){const t=this.#t=document.createElement("button");t.className="annotationCommentButton";const e=this.#s.commentButtonPosition;if(e){const{style:i}=t;i.insetInlineEnd=`calc(${100*(this.#s._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const s=this.#s.commentButtonColor;s&&(i.backgroundColor=s)}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;const t=this.#s.commentButtonColor;t&&(this.#t.style.backgroundColor=t),this.#s._uiManager.updatePopupColor(this.#s)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#s.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#h)return this.#h;if(!this.#t)return null;const{x:t,y:e,height:i}=this.#t.getBoundingClientRect(),{x:s,y:n,width:r,height:a}=this.#s.parent.boundingClientRect;return[(t-s)/r,(e+i-n)/a]}set commentPopupPositionInLayer(t){this.#h=t}hasDefaultPopupPosition(){return this.#h===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t&&(this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e)}#u(t,e){if(!this.#s._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#s._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const i=this.#s._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",Ct,{signal:i}),e&&(t.addEventListener("focusin",n=>{this.#s._focusEventsAllowed=!1,at(n)},{capture:!0,signal:i}),t.addEventListener("focusout",n=>{this.#s._focusEventsAllowed=!0,at(n)},{capture:!0,signal:i})),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:i});const s=n=>{n.preventDefault(),t===this.#e?this.edit():this.#s.toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(this.#i=!0,s(n))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#s.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#s.toggleComment(!1,!1)},{signal:i}),t}edit(t){const e=this.commentPopupPositionInLayer;let i,s;if(e)[i,s]=e;else{[i,s]=this.#s.commentButtonPosition;const{width:c,height:d,x:u,y:f}=this.#s;i=u+i*c,s=f+s*d}const n=this.#s.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;this.#s._uiManager.editComment(this.#s,r+i*o,a+s*l,{...t,parentDimensions:n})}finish(){this.#e&&(this.#e.focus({focusVisible:this.#i}),this.#i=!1)}isDeleted(){return this.#l||this.#a===""}isEmpty(){return this.#a===null}hasBeenEdited(){return this.isDeleted()||this.#a!==this.#n}serialize(){return this.data}get data(){return{text:this.#a,richText:this.#r,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#a&&(this.#r=null),t===null){this.#a="",this.#l=!0;return}this.#a=t,this.#o=new Date,this.#l=!1}restoreData({text:t,richText:e,date:i}){this.#a=t,this.#r=e,this.#o=i,this.#l=!1}setInitialText(t,e=null){this.#n=t,this.data=t,this.#o=null,this.#r=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#a="",this.#r=null,this.#o=null,this.#s=null,this.#i=!1,this.#l=!1}}function an(h){h.preventDefault()}const on=1e-4;function zi(h){return h.cancelable?(at(h),!0):(h.stopPropagation(),!1)}let Sr=class{#t;#e=!1;#i=null;#s;#n;#r;#a;#o;#l=!1;#h=null;#u;#d=new Set;#f=null;#g;#m=null;#c=0;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,onPanning:a=null,signal:o}){this.#t=t,this.#i=i,this.#s=e,this.#n=s,this.#r=n,this.#a=r,this.#o=a,this.#g=new AbortController,this.#u=AbortSignal.any([o,this.#g.signal]),t.addEventListener("touchstart",this.#p.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Wt.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/Wt.pixelRatio}#p(t){if(this.#s?.())return;this.#y(t);const e=this.#d;for(const{identifier:i}of t.changedTouches)e.add(i);if(e.size===1){this.#b();return}if(!this.#m){this.#m=new AbortController;const i=AbortSignal.any([this.#u,this.#m.signal]),s=this.#t,n={signal:i,capture:!1,passive:!1};s.addEventListener("touchmove",this.#E.bind(this),n);const r=this.#A.bind(this);s.addEventListener("touchend",r,n),s.addEventListener("touchcancel",r,n),n.capture=!0,s.addEventListener("pointerdown",at,n),s.addEventListener("pointermove",at,n),s.addEventListener("pointercancel",an,n),s.addEventListener("pointerup",an,n),this.#n?.()}this.#l=zi(t),this.#v(t)}
2#b(){if(this.#h)return;const t=this.#h=new AbortController,e=AbortSignal.any([this.#u,t.signal]),i=this.#t,s={capture:!0,signal:e,passive:!1},n=r=>{r.pointerType==="touch"&&(this.#h?.abort(),this.#h=null)};i.addEventListener("pointerdown",r=>{r.pointerType==="touch"&&(at(r),n(r))},s),i.addEventListener("pointerup",n,s),i.addEventListener("pointercancel",n,s)}#y(t){const e=this.#d;if(e.size===0)return;const i=this.#d=new Set;for(const{identifier:s}of t.touches)e.has(s)&&i.add(s)}#w(t){const e=this.#d,i=[];for(const s of t.touches)e.has(s.identifier)&&i.push(s);return i}#v(t){const e=this.#w(t);if(e.length!==2||this.#i?.()){this.#f=null;return}const[i,s]=e;this.#f={touch0X:i.screenX,touch0Y:i.screenY,touch1X:s.screenX,touch1Y:s.screenY,panX:(i.clientX+s.clientX)/2,panY:(i.clientY+s.clientY)/2,screenPanX:(i.screenX+s.screenX)/2,screenPanY:(i.screenY+s.screenY)/2}}#E(t){if(!this.#f)return;const e=this.#w(t);if(e.length!==2)return;const i=this.#l;if(this.#l=zi(t),!this.#l)return;if(!i){this.#v(t);return}const[s,n]=e,{screenX:r,screenY:a}=s,{screenX:o,screenY:l}=n,c=this.#f,{touch0X:d,touch0Y:u,touch1X:f,touch1Y:p,panX:g,panY:m}=c,b=f-d,y=p-u,w=o-r,A=l-a,v=(s.clientX+n.clientX)/2,E=(s.clientY+n.clientY)/2;c.panX=v,c.panY=E;const _=v-g,C=E-m,S=(r+o)/2,P=(a+l)/2,T=Math.hypot(S-c.screenPanX,P-c.screenPanY);c.screenPanX=S,c.screenPanY=P;const M=Math.hypot(w,A),L=Math.hypot(b,y),D=this.#e?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*T;if(M<on||L<on||Math.abs(L-M)<=D){(_||C)&&this.#o?.(_,C);return}c.touch0X=r,c.touch0Y=a,c.touch1X=o,c.touch1Y=l;const U=Math.sign(M-L);if(!this.#e){this.#e=!0,this.#c=U,(_||C)&&this.#o?.(_,C);return}if(this.#c){const R=this.#c;if(this.#c=0,U!==R&&Math.abs(M-L)<=2*T){this.#e=!1,(_||C)&&this.#o?.(_,C);return}}this.#r?.([g,m],L,M,_,C)}#A(t){if(this.#y(t),this.#d.size>=2){this.#v(t);return}const e=!!this.#f;this.#x(),this.#d.size===1&&this.#b(),e&&zi(t)}#x(){this.#f=null,this.#e=!1,this.#c=0,this.#l=!1,this.#m&&(this.#m.abort(),this.#m=null,this.#a?.())}destroy(){this.#x(),this.#d.clear(),this.#g?.abort(),this.#g=null,this.#h?.abort(),this.#h=null}};class N{#t=null;#e=null;#i=null;#s=null;#n=null;#r=!1;#a=null;#o="";#l=null;#h=null;#u=null;#d=null;#f=null;#g="";#m=!1;#c=null;#p=!1;#b=!1;#y=!1;#w=null;#v=0;#E=0;#A=null;#x=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#S=!1;#T=N._zIndex++;static _borderLineWidth=-1;static _colorManager=new Rs;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=N.prototype._resizeWithKeyboard,e=Be.TRANSLATE_SMALL,i=Be.TRANSLATE_BIG;return F(this,"_resizerKeyboardManager",new vt([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape"],N.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return F(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Va({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(N._l10n??=t,N._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"}),N._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"}),N._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);N._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){W("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#S}set _isDraggable(t){this.#S=t,this.div?.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}
vendor: 4,576 bytes, line 2
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#T}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#j(),this.#d?.remove(),this.#d=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#k([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#k(this.parentDimensions,t,e)}translateInPage(t,e){this.#c||=[this.x,this.y,this.width,this.height],this.#k(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#c||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,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:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:c}=i;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#c&&(this.#c[0]!==this.x||this.#c[1]!==this.y)}get _hasBeenResized(){return!!this.#c&&(this.#c[2]!==this.width||this.#c[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=N,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=Q(n,0,i-a),r=Q(r,0,s-o);break;case 90:n=Q(n,0,i-o),r=Q(r,a,s);break;case 180:n=Q(n,a,i),r=Q(r,o,s);break;case 270:n=Q(n,o,i),r=Q(r,0,s-a);break}this.x=n/=i,this.y=r/=s;const[l,c]=this.getBaseTranslation();n+=l,r+=c,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#P(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return N.#P(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return N.#P(t,e,360-this.parentRotation)}#I(t){switch(t){case 90:{const[e,i]=this.pageDimensions;return[0,-e/i,i/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,i]=this.pageDimensions;return[0,e/i,-i/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){const{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#M(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.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 i of t){const s=document.createElement("div");this.#l.append(s),s.classList.add("resizer",i),s.setAttribute("data-resizer-name",i),s.addEventListener("pointerdown",this.#D.bind(this,i),{signal:e}),s.addEventListener("contextmenu",Ct,{signal:e}),s.tabIndex=-1}this.div.prepend(this.#l)}#D(t,e){e.preventDefault();const{isMac:i}=Y.platform;if(e.button!==0||e.ctrlKey&&i)return;this.#i?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#h=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#$.b
2ind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",at,{passive:!1,signal:r}),window.addEventListener("contextmenu",Ct,{signal:r}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#i?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#R()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#V(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#R(){if(!this.#u)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#u;this.#u=null;const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===i&&o===s||this.addCommands({cmd:this.#V.bind(this,n,r,a,o),undo:this.#V.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#$(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=N.MIN_SIZE/i,c=N.MIN_SIZE/s,d=this.#I(this.rotation),u=(R,O)=>[d[0]*R+d[2]*O,d[1]*R+d[3]*O],f=this.#I(360-this.rotation),p=(R,O)=>[f[0]*R+f[2]*O,f[1]*R+f[3]*O];let g,m,b=!1,y=!1;switch(t){case"topLeft":b=!0,g=(R,O)=>[0,0],m=(R,O)=>[R,O];break;case"topMiddle":g=(R,O)=>[R/2,0],m=(R,O)=>[R/2,O];break;case"topRight":b=!0,g=(R,O)=>[R,0],m=(R,O)=>[0,O];break;case"middleRight":y=!0,g=(R,O)=>[R,O/2],m=(R,O)=>[0,O/2];break;case"bottomRight":b=!0,g=(R,O)=>[R,O],m=(R,O)=>[0,0];break;case"bottomMiddle":g=(R,O)=>[R/2,O],m=(R,O)=>[R/2,0];break;case"bottomLeft":b=!0,g=(R,O)=>[0,O],m=(R,O)=>[R,0];break;case"middleLeft":y=!0,g=(R,O)=>[0,O/2],m=(R,O)=>[R,O/2];break}const w=g(a,o),A=m(a,o);let v=u(...A);const E=N._round(n+v[0]),_=N._round(r+v[1]);let C=1,S=1,P,T;if(e.fromKeyboard)({deltaX:P,deltaY:T}=e);else{const{screenX:R,screenY:O}=e,[ht,ct]=this.#h;[P,T]=this.screenToPageTranslation(R-ht,O-ct),this.#h[0]=R,this.#h[1]=O}if([P,T]=p(P/i,T/s),b){const R=Math.hypot(a,o);C=S=Math.max(Math.min(Math.hypot(A[0]-w[0]-P,A[1]-w[1]-T)/R,1/a,1/o),l/a,c/o)}else y?C=Q(Math.abs(A[0]-w[0]-P),l,1)/a:S=Q(Math.abs(A[1]-w[1]-T),c,1)/o;const M=N._round(a*C),L=N._round(o*S);v=u(...m(M,L));const D=E-v[0],U=_-v[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=M,this.height=L,this.x=D,this.y=U,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#i?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#b)return this._editToolbar;this._editToolbar=new Re(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#i?.destroy()}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#i||(Dt.initialize(N._l10n),this.#i=new Dt(this),this.#t&&(this.#i.data=this.#t,this.#t=null)),this.#i}get altTextData(){return this.#i?.data}set altTextData(t){this.#i&&(this.#i.data=t)}get guessedAltText(){return this.#i?.guessedText}async setGuessedAltText(t){await this.#i?.setGuessedText(t)}serializeAltText(t){return this.#i?.serialize(t)}hasAltText(){return!!this.#i&&!this.#i.isEmpty()}hasAltTextData(){return this.#i?.hasData()??!1}focusCommentButton(){this.#s?.focusButton()}addCommentButton(){return this.canAddComment?this.#s||=new qe(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#n){this._uiManager.isEditingMode()&&this.#n.classList.remove("hidden");return}this.hasComment&&(this.#n=this.#s.renderForStandalone(),this.div.append(this.#n))}}removeStandaloneCommentButton(){this.#s.removeStandaloneCommentButton(),this.#n=null}hideStandaloneCommentButton(){this.#n?.classList.add("hidden")}get comment(){if(!this.#s)return null;const{data:{richText:t,text:e,date:i,deleted:s}}=this.#s;return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#s||=new qe(this),typeof t=="object"&&t!==null?this.#s.restoreData(t):this.#s.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:i}){if(!e||(this.#s||=new qe(this),this.#s.setInitialText(t,i),!this.annotationElementId))return;const s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return this.#s?.hasBeenEdited()}get hasDeletedComment(){return this.#s?.isDeleted()}get hasComment(){return!!this.#s&&!this.#s.isEmpty()&&!this.#s.isDeleted()}async editComment(t){this.#s||=new qe(this),this.#s.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#s.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,s]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,a=r+n+1,o=s-100,l=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,s]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#s.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){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=this.#r?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#H();const[e,i]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[s,n]=this.getInitialTranslation();return this.translate(s,n),Er(this,t,["keydown","pointerdown","dblclick"]),this.#W(),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#B(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#i?.toggle(!1),this.parent.togglePointerEvents(!1)}#L(t,e,i){let n=.7*(i/e)+1-.7;
2if(n===1)return;const r=this.#I(this.rotation),a=(E,_)=>[r[0]*E+r[2]*_,r[1]*E+r[3]*_],[o,l]=this.parentDimensions,c=this.x,d=this.y,u=this.width,f=this.height,p=N.MIN_SIZE/o,g=N.MIN_SIZE/l;n=Math.max(Math.min(n,1/u,1/f),p/u,g/f);const m=N._round(u*n),b=N._round(f*n);if(m===u&&b===f)return;this.#c||=[c,d,u,f];const y=a(u/2,f/2),w=N._round(c+y[0]),A=N._round(d+y[1]),v=a(m/2,b/2);this.x=w-v[0],this.y=A-v[1],this.width=m,this.height=b,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#N(){this.#i?.toggle(!0),this.parent.togglePointerEvents(!0),this.#R()}pointerdown(t){const{isMac:e}=Y.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#_(t);return}this.#C(t)}#C(t){const{isMac:e}=Y.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#_(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=l=>{s.abort(),this.#a=null,this.#m=!1,this._uiManager.endDragSession()||this.#C(l),i&&this._onStopDragging()};e&&(this.#v=t.clientX,this.#E=t.clientY,this.#a=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",l=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:d,pointerId:u}=l;if(u!==this.#a){at(l);return}const[f,p]=this.screenToPageTranslation(c-this.#v,d-this.#E);this.#v=c,this.#E=d,this._uiManager.dragSelectedEditors(f,p),this.div.scrollIntoView({block:"nearest"})},r),window.addEventListener("touchmove",at,r),window.addEventListener("pointerdown",l=>{l.pointerType===this.#o&&(this.#x||l.isPrimary)&&a(l),at(l)},r));const o=l=>{if(!this.#a||this.#a===l.pointerId){a(l);return}at(l)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#w&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.#w=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,c=e/s,d=this.x*n,u=this.y*r,f=this.width*n,p=this.height*r;switch(i){case 0:return[d+l+a,r-u-c-p+o,d+l+f+a,r-u-c+o];case 90:return[d+c+a,r-u+l+o,d+c+p+a,r-u+l+f+o];case 180:return[d-l-f+a,r-u+c+o,d-l+a,r-u+c+p+o];case 270:return[d-c-p+a,r-u-l-f+o,d-c+a,r-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&N._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#s?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:i,opacity:s,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:c}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:i||c,popupRef:!n,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#b=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#b=!1,!0):!1}isInEditMode(){return this.#b}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#H(){if(this.#f||!this.div)return;this.#f=new AbortController;const t=this._uiManager.combinedSignal(this.#f);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}#W(){this.#x||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||(this.#x=new Sr({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#B.bind(this),onPinching:this.#L.bind(this),onPinchEnd:this.#N.bind(this),signal:this._uiManager._signal}))}rebuild(){this.#H(),this.#W()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:i.getId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,s.#t=t.accessibilityData,s._isCopy=t.isCopy||!1;const[n,r]=s.pageDimensions,[a,o,l,c]=s.getRectInCurrentCoords(t.rect,r);
vendor: 4,898 bytes, line 2
2return s.x=a/n,s.y=o/r,s.width=l/n,s.height=c/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.#x?.destroy(),this.#x=null,this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#w&&(clearTimeout(this.#w),this.#w=null),this.#j(),this.removeEditToolbar(),this.#A){for(const t of this.#A.values())clearTimeout(t);this.#A=null}this.parent=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#M(),this.#l.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,[i,s,n,r]=this.getPDFRect();return[N._round(i+(n-i)*t),N._round(s+(r-s)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#s.commentPopupPositionInLayer}set commentPopupPosition(t){this.#s.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#s.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#s.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#s?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#l.children;if(!this.#e){this.#e=Array.from(e);const r=this.#U.bind(this),a=this.#X.bind(this),o=this._uiManager._signal;for(const l of this.#e){const c=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#q.bind(this,c),{signal:o}),l.setAttribute("data-l10n-id",N._l10nResizer[c])}}const i=this.#e[0];let s=0;for(const r of e){if(r===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==s){if(n<s)for(let a=0;a<s-n;a++)this.#l.append(this.#l.firstElementChild);else if(n>s)for(let a=0;a<n-s;a++)this.#l.firstElementChild.before(this.#l.lastElementChild);let r=0;for(const a of e){const l=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",N._l10nResizer[l])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#U(t){N._resizerKeyboardManager.exec(this,t)}#X(t){this.#y&&t.relatedTarget?.parentNode!==this.#l&&this.#j()}#q(t){this.#g=this.#y?t:""}#K(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#y&&this.#$(this.#g,{deltaX:t,deltaY:e,fromKeyboard:!0})}#j(){this.#y=!1,this.#K(-1),this.#R()}_stopResizingWithKeyboard(){this.#j(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#i?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#i?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#A||=new Map;const{action:i}=t;let s=this.#A.get(i);s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(t),this.#A.delete(i),this.#A.size===0&&(this.#A=null)},N._telemetryTimeout),this.#A.set(i,s);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}
2show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#r=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#r=!0}updateFakeAnnotationElement(t){if(!this.#d&&!this.deleted){this.#d=t.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const i=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),i.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class Va extends N{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const ln=3285377520,Et=4294901760,Tt=65535;class us{constructor(t){this.h1=t?t&4294967295:ln,this.h2=t?t&4294967295:ln}update(t){let e,i;if(typeof t=="string"){e=new Uint8Array(t.length*2),i=0;for(let g=0,m=t.length;g<m;g++){const b=t.charCodeAt(g);b<=255?e[i++]=b:(e[i++]=b>>>8,e[i++]=b&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),i=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const s=i>>2,n=i-s*4,r=new Uint32Array(e.buffer,0,s);let a=0,o=0,l=this.h1,c=this.h2;const d=3432918353,u=461845907,f=d&Tt,p=u&Tt;for(let g=0;g<s;g++)g&1?(a=r[g],a=a*d&Et|a*f&Tt,a=a<<15|a>>>17,a=a*u&Et|a*p&Tt,l^=a,l=l<<13|l>>>19,l=l*5+3864292196):(o=r[g],o=o*d&Et|o*f&Tt,o=o<<15|o>>>17,o=o*u&Et|o*p&Tt,c^=o,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,n){case 3:a^=e[s*4+2]<<16;case 2:a^=e[s*4+1]<<8;case 1:a^=e[s*4],a=a*d&Et|a*f&Tt,a=a<<15|a>>>17,a=a*u&Et|a*p&Tt,s&1?l^=a:c^=a}this.h1=l,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Et|t*36045&Tt,e=e*4283543511&Et|((e<<16|t>>>16)*2950163797&Et)>>>16,t^=e>>>1,t=t*444984403&Et|t*60499&Tt,e=e*3301882366&Et|((e<<16|t>>>16)*3120437893&Et)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const je=Object.freeze({map:null,hash:"",transfer:void 0});class Ns{#t=!1;#e=null;#i=null;#s=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){const i=this.#s.get(t);return i===void 0?e:Object.assign(e,i)}getRawValue(t){return this.#s.get(t)}remove(t){const e=this.#s.get(t);e!==void 0&&(e instanceof N&&this.#i.delete(e.annotationElementId),this.#s.delete(t),this.#s.size===0&&this.resetModified(),!this.#s.values().some(i=>i instanceof N)&&this.onAnnotationEditor?.(null))}setValue(t,e){const i=this.#s.get(t);let s=!1;if(i!==void 0)for(const[n,r]of Object.entries(e))i[n]!==r&&(s=!0,i[n]=r);else s=!0,this.#s.set(t,e);s&&this.#n(),e instanceof N&&((this.#i||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#s.has(t)}get size(){return this.#s.size}#n(){this.#t||(this.#t=!0,this.onSetModified?.())}resetModified(){this.#t&&(this.#t=!1,this.onResetModified?.())}get print(){return new xr(this)}get serializable(){if(this.#s.size===0)return je;const t=new Map,e=new us,i=[],s=Object.create(null);let n=!1;for(const[r,a]of this.#s){const o=a instanceof N?a.serialize(!1,s):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const r of t.values())r.bitmap&&i.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:je}get editorStats(){let t=null;const e=new Map;let i=0,s=0;for(const n of this.#s.values()){if(!(n instanceof N)){n.popup&&(n.popup.deleted?s+=1:i+=1);continue}n.isCommentDeleted?s+=1:n.hasEditedComment&&(i+=1);const r=n.telemetryFinalData;if(!r)continue;const{type:a}=r;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(n).constructor),t||=Object.create(null);const o=t[a]||=new Map;for(const[l,c]of Object.entries(r)){if(l==="type")continue;const d=o.getOrInsertComputed(l,ks);d.set(c,(d.get(c)??0)+1)}}if((s>0||i>0)&&(t||=Object.create(null),t.comments={deleted:s,edited:i}),!t)return null;for(const[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){const i=this.#i?.get(t);return i?(i.updateFromAnnotationLayer(e),!0):!1}getEditor(t){return this.#i?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;
2const t=[];if(this.#i)for(const i of this.#i.values())i.serialize()&&t.push(i.annotationElementId);let e="";if(t.length){const i=new us;i.update(t.join(",")),e=i.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#s.entries()}}class xr extends Ns{#t=je;constructor(t){super();const{serializable:e}=t;if(e===je)return;const{map:i,hash:s,transfer:n}=e,r=structuredClone(i,n?{transfer:n}:null);this.#t={map:r,hash:s,transfer:[]}}get print(){W("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return F(this,"modifiedIds",{ids:new Set,hash:""})}}const ce="__forcedDependency",{floor:hn,ceil:cn}=Math;function dn(h,t,e,i,s,n){h[t*4+0]=Math.min(h[t*4+0],e),h[t*4+1]=Math.min(h[t*4+1],i),h[t*4+2]=Math.max(h[t*4+2],s),h[t*4+3]=Math.max(h[t*4+3],n)}function Ha(h,t,e,i,s){let n;h?(h<0&&(n=s[0],s[0]=s[2],s[2]=n),s[0]*=h,s[2]*=h,t<0&&(n=s[1],s[1]=s[3],s[3]=n),s[1]*=t,s[3]*=t):s.fill(0),s[0]+=e,s[1]+=i,s[2]+=e,s[3]+=i}const fs=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class za{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===fs}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}}const un=(h,t)=>h?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));class Wa{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#i=new Float64Array(Bt);_pendingBBoxIdx=-1;#s;#n;#r;#a;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#s=t.width,this.#n=t.height,this.#o(e)}growOperationsCount(t){t>=this.#a.length&&this.#o(t,this.#a)}#o(t,e){const i=new ArrayBuffer(t*4);this.#r=new Uint8ClampedArray(i),this.#a=new Uint32Array(i),e&&e.length>0?(this.#a.set(e),this.#a.fill(fs,e.length)):this.#a.fill(fs)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){const i=Object.getPrototypeOf(this.#e);if(i===null)return this;this.#e=i;const s=this._savesStack.pop();return s!==void 0&&(e?.(s,t),this.#a[t]=this.#a[s]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const i=this._savesStack.pop();return i!==void 0&&(e?.(i,t),this.#a[t]=this.#a[i]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const i=this._markedContentStack.pop();return i!==void 0&&(e?.(i,t),this.#a[t]=this.#a[i]),this}pushBaseTransform(t){return this.#t.push(k.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){return this.#t.length>1&&this.#t.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#i.set(Bt,0)),this}recordClipBox(t,e,i,s,n,r){const a=k.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=Bt.slice();k.axialAlignedBoundingBox([i,n,s,r],a,o);const l=k.intersect(this.#e,o);return l?(this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3]):(this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0),this}recordBBox(t,e,i,s,n,r){const a=this.#e;if(a[0]===1/0)return this;const o=k.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return k.axialAlignedBoundingBox([i,n,s,r],o,this.#i),this;const l=Bt.slice();return k.axialAlignedBoundingBox([i,n,s,r],o,l),this.#i[0]=Q(l[0],a[0],this.#i[0]),this.#i[1]=Q(l[1],a[1],this.#i[1]),this.#i[2]=Q(l[2],this.#i[2],a[2]),this.#i[3]=Q(l[3],this.#i[3],a[3]),this}recordFullPageBBox(t){return this.#i[0]=Math.max(0,this.#e[0]),this.#i[1]=Math.max(0,this.#e[1]),this.#i[2]=Math.min(this.#s,this.#e[2]),this.#i[3]=Math.min(this.#n,this.#e[3]),this}recordOperation(t,e=!1,i){if(this._pendingBBoxIdx!==t)return this;const s=hn(this.#i[0]*256/this.#s),n=hn(this.#i[1]*256/this.#n),r=cn(this.#i[2]*256/this.#s),a=cn(this.#i[3]*256/this.#n);if(dn(this.#r,t,s,n,r,a),i)for(const o of i)for(const l of o)l!==t&&dn(this.#r,l,s,n,r,a);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pe
2ndingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#i[0]),this.#e[1]=Math.max(this.#e[1],this.#i[1]),this.#e[2]=Math.min(this.#e[2],this.#i[2]),this.#e[3]=Math.min(this.#e[3],this.#i[3])),this}take(){return new za(this.#a,this.#r)}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,i){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,i,s=1,n=0,r=0,a){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class Ga{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[ce]:[]};#i=new Map;#s=new Set;#n=new Map;#r;#a;#o;constructor(t,e=!1){this.#o=t,e&&(this.#r=new Map,this.#a=(i,s)=>{un(this.#r,s).dependencies.add(i)})}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[ce]:{__proto__:this.#e[ce]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#a);const e=Object.getPrototypeOf(this.#t);return e===null?this:(this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this)}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#a),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#a),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#a),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#i.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#t[t]=this.#i.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ce,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#t&&this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#s)this.recordFutureForcedDependency(ce,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,i,s,n,r){return this.#o.recordClipBox(t,e,i,s,n,r),this}recordBBox(t,e,i,s,n,r){return this.#o.recordBBox(t,e,i,s,n,r),this}recordCharacterBBox(t,e,i,s=1,n=0,r=0,a){const o=i.bbox;let l,c;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#n.get(i),l!==!1&&(c=[0,0,0,0],k.axialAlignedBoundingBox(o,i.fontMatrix,c),(s!==1||n!==0||r!==0)&&Ha(s,-s,n,r,c),l)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!a)return this.recordFullPageBBox(t);const d=a();return o&&c&&l===void 0&&(l=c[0]<=n-d.actualBoundingBoxLeft&&c[2]>=n+d.actualBoundingBoxRight&&c[1]<=r-d.actualBoundingBoxAscent&&c[3]>=r+d.actualBoundingBoxDescent,this.#n.set(i,l),l)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,n-d.actualBoundingBoxLeft,n+d.actualBoundingBoxRight,r-d.actualBoundingBoxAscent,r+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){const i=this.#s,s=this.#t,n=this.#e;for(const r of e)r in this.#t?i.add(s[r]):r in n&&n[r].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#i.has(e)&&this.#s.add(this.#i.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[ce]),this.#r){const s=un(this.#r,t),{dependencies:n}=s;this.#s.forEach(n.add,n),this.#o._savesStack.forEach(n.add,n),this.#o._markedContentStack.forEach(n.add,n),n.delete(t),s.isRenderingOperation=!0}
2const i=!e&&t===this.#o._pendingBBoxIdx;return this.#o.recordOperation(t,e,[this.#s,this.#o._savesStack,this.#o._markedContentStack]),i&&this.#s.clear(),this}recordShowTextOperation(t,e=!1){const i=Array.from(this.#s);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const s of i)this.recordIncrementalData("sameLineText",s);return this}bboxToClipBoxDropOperation(t,e=!1){const i=!e&&t===this.#o._pendingBBoxIdx;return this.#o.bboxToClipBoxDropOperation(t),i&&this.#s.clear(),this}take(){return this.#n.clear(),this.#o.take()}takeDebugMetadata(){return this.#r}}class $e{#t;#e;#i;#s=0;#n=0;constructor(t,e,i){if(t instanceof $e&&t.#i===!!i)return t;this.#t=t,this.#e=e,this.#i=!!i}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#n++,this.#t.save(this.#e),this}restore(t){return this.#n>0&&(this.#t.restore(this.#e),this.#n--),this}recordOpenMarker(t){return this.#s++,this}getOpenMarker(){return this.#s>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#s--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#i||this.#t.resetBBox(this.#e),this}recordClipBox(t,e,i,s,n,r){return this.#i||this.#t.recordClipBox(this.#e,e,i,s,n,r),this}recordBBox(t,e,i,s,n,r){return this.#i||this.#t.recordBBox(this.#e,e,i,s,n,r),this}recordCharacterBBox(t,e,i,s,n,r,a){return this.#i||this.#t.recordCharacterBBox(this.#e,e,i,s,n,r,a),this}recordFullPageBBox(t){return this.#i||this.#t.recordFullPageBBox(this.#e),this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){return this.#i||this.#t.bboxToClipBoxDropOperation(this.#e,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const St={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};class pi{#t;#e;#i=4;#s=0;#n=new pi.#r(this.#i*6);static#r=Y.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,i,s){if(this.#s===this.#i){this.#i*=2;const a=new pi.#r(this.#i*6);a.set(this.#n),this.#n=a}const n=q(t);let r;if(s[0]!==1/0){const a=Bt.slice();k.axialAlignedBoundingBox([0,-i,e,0],n,a);const o=k.intersect(s,a);if(!o)return;const[l,c,d,u]=o;if(l!==a[0]||c!==a[1]||d!==a[2]||u!==a[3]){const f=Math.atan2(n[1],n[0]),p=Math.abs(Math.sin(f)),g=Math.abs(Math.cos(f));if(p<1e-6||g<1e-6||Math.abs(p-g)<1e-6)r=[l,c,l,u,d,c];else{const m=d-l,b=u-c,y=p*p,w=g*g,A=g*p,v=w-y,E=(b*w-m*A)/v,_=(b*A-m*y)/v;r=[l+_,c,l,c+E,d,u-E]}}}r||(r=[0,-i,0,0,e,-i],k.applyTransform(r,n,0),k.applyTransform(r,n,2),k.applyTransform(r,n,4)),r[0]/=this.#t,r[1]/=this.#e,r[2]/=this.#t,r[3]/=this.#e,r[4]/=this.#t,r[5]/=this.#e,this.#n.set(r,this.#s*6),this.#s++}take(){return this.#n.subarray(0,this.#s*6)}}const fn=new RegExp("\\p{Cc}","u");function Xa(h){const t=h[0];if(h.length<2||t!=='"'&&t!=="'"||h.at(-1)!==t)return!1;const e=h.length-1;for(let i=1;i<e;i++){const s=h[i];if(s===t||fn.test(s)||s==="\\"&&(++i>=e||fn.test(h[i])))return!1}return!0}function pn(h){return Xa(h)?h:`"${h.replaceAll(/["\\\p{Cc}]/gu,e=>e==='"'||e==="\\"?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}class Ya{#t=new Set;#e=null;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){const e=this.#i();e.insertRule(t,e.cssRules.length)}#i(){if(this.#e)return this.#e;
2const t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:e}=this._document;if(e){const i=new t;return e.push(i),this.#e=i}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),this.#e=this.styleElement.sheet}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),this.#t.clear(),this.#e){const{adoptedStyleSheets:t}=this._document;t?.includes(this.#e)&&(this._document.adoptedStyleSheets=t.filter(e=>e!==this.#e)),this.#e=null}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(!(!t||this.#t.has(t.loadedName))){if(et(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:n,style:r}=t,a=new FontFace(s,n,r);this.addNativeFontFace(a);try{await a.load(),this.#t.add(s),i?.(t)}catch{$(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}W("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 i=t.createNativeFontFace();if(i){this.addNativeFontFace(i);try{await i.loaded}catch(s){throw $(`Failed to load font '${i.family}': '${s}'.`),t.disableFontFace=!0,s}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(i=>{const s=this._queueLoadingCallback(i);this._prepareFontLoadEvent(t,s)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return F(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return F(this,"isSyncFontLoadingSupported",wt||Y.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(et(!s.done,"completeRequest() cannot be called twice."),s.done=!0;i.length>0&&i[0].done;){const n=i.shift();setTimeout(n.callback,0)}}const{loadingRequests:i}=this,s={done:!1,complete:e,callback:t};return i.push(s),s}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return F(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function i(v,E){return v.charCodeAt(E)<<24|v.charCodeAt(E+1)<<16|v.charCodeAt(E+2)<<8|v.charCodeAt(E+3)&255}function s(v){return String.fromCharCode(v>>24&255,v>>16&255,v>>8&255,v&255)}function n(v,E,_,C){const S=v.substring(0,E),P=v.substring(E+_);return S+C+P}let r,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let c=0;function d(v,E){if(++c>30){$("Load test font never loaded."),E();return}if(l.font="30px "+v,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){E();return}setTimeout(d.bind(null,v,E))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=n(f,976,u.length,u);const g=16,m=1482184792;let b=i(f,g);for(r=0,a=u.length-3;r<a;r+=4)b=b-m+i(u,r)|0;r<u.length&&(b=b-m+i(u+"XXX",r)|0),f=n(f,g,4,s(b));const y=`url(data:font/opentype;base64,${btoa(f)});`,w=`@font-face {font-family:"${u}";src:${y}}`;this.insertRule(w);const A=this._document.createElement("div");A.style.visibility="hidden",A.style.width=A.style.height="10px",A.style.position="absolute",A.style.top=A.style.left="0px";for(const v of[t.loadedName,u]){const E=this._document.createElement("span");E.textContent="Hi",E.style.fontFamily=v,A.append(E)}this._document.body.append(A),d(u,()=>{A.remove(),e.complete()})}}class qa{compiledGlyphs=Object.create(null);#t;constructor(t,e=null,i,s){this.#t=t,this._inspectFont=e,i&&(this.charProcOperatorList=i),s&&Object.assign(this,s)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(pn(this.cssFontInfo.fontFamily),this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){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:${pn(this.cssFontInfo.fontFamily)};${i}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(r){$(`getPathGenerator - ignoring character: "${r}".`)}const n=Ar(s?.path);return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}get black(){return this.#t.black}get bold(){return this.#t.bold}get disableFontFace(){return this.#t.disableFontFace}set disableFontFace(t){F(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#t.fontExtraProperties}get isInvalidPDFjsFont(){return this.#t.isInvalidPDFjsFont}get isType3Font(){return this.#t.isType3Font}get italic(){return this.#t.italic}get missingFile(){return this.#t.missingFile}get remeasure(){return this.#t.remeasure}get vertical(){return this.#t.vertical}get ascent(){return this.#t.ascent}get defaultWidth(){return this.#t.defaultWidth}
2get descent(){return this.#t.descent}get bbox(){return this.#t.bbox}get fontMatrix(){return this.#t.fontMatrix}get fallbackName(){return this.#t.fallbackName}get loadedName(){return this.#t.loadedName}get mimetype(){return this.#t.mimetype}get name(){return this.#t.name}get data(){return this.#t.data}clearData(){this.#t.clearData()}get cssFontInfo(){return this.#t.cssFontInfo}get systemFontInfo(){return this.#t.systemFontInfo}get defaultVMetrics(){return this.#t.defaultVMetrics}}class Ka{static strings=["fontFamily","fontWeight","italicAngle"]}class Qa{static strings=["css","loadedName","baseFontName","src"]}class xt{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class Yt{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class gi{static get decoder(){return F(this,"decoder",new TextDecoder)}static get encoder(){return F(this,"encoder",new TextEncoder)}}class Za{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#i(t){et(t<Ka.strings.length,"Invalid string index");const{decoder:e}=gi;let i=0;for(let n=0;n<t;n++)i+=this.#e.getUint32(i)+4;const s=this.#e.getUint32(i);return e.decode(new Uint8Array(this.#t,i+4,s))}get fontFamily(){return this.#i(0)}get fontWeight(){return this.#i(1)}get italicAngle(){return this.#i(2)}}class Ja{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}get guessFallback(){return this.#e.getUint8(0)!==0}#i(t){et(t<Qa.strings.length,"Invalid string index");const{decoder:e}=gi;let i=5;for(let n=0;n<t;n++)i+=this.#e.getUint32(i)+4;const s=this.#e.getUint32(i);return e.decode(new Uint8Array(this.#t,i+4,s))}get css(){return this.#i(0)}get loadedName(){return this.#i(1)}get baseFontName(){return this.#i(2)}get src(){return this.#i(3)}get style(){const{decoder:t}=gi;let e=1;e+=4+this.#e.getUint32(e);const i=this.#e.getUint32(e),s=t.decode(new Uint8Array(this.#t,e+4,i));e+=4+i;const n=this.#e.getUint32(e),r=t.decode(new Uint8Array(this.#t,e+4,n));return{style:s,weight:r}}}class to{#t;#e;constructor({buffer:t,extra:e}){this.#t=t,this.#e=new DataView(t),e&&Object.assign(this,e)}#i(t){et(t<xt.bools.length,"Invalid boolean index");const e=Math.floor(t/4),i=t*2%8,s=this.#e.getUint8(e)>>i&3;return s===0?void 0:s===2}get black(){return this.#i(0)}get bold(){return this.#i(1)}get disableFontFace(){return this.#i(2)}get fontExtraProperties(){return this.#i(3)}get isInvalidPDFjsFont(){return this.#i(4)}get isType3Font(){return this.#i(5)}get italic(){return this.#i(6)}get missingFile(){return this.#i(7)}get remeasure(){return this.#i(8)}get vertical(){return this.#i(9)}#s(t){return et(t<xt.numbers.length,"Invalid number index"),this.#e.getFloat64(xt.OFFSET_NUMBERS+t*8)}get ascent(){return this.#s(0)}get defaultWidth(){return this.#s(1)}get descent(){return this.#s(2)}#n(t,e,i,s){const n=this.#e.getUint8(t);if(n===0)return;et(n===e,"Invalid array length."),t+=1;const r=new Array(n);for(let a=0;a<n;a++)r[a]=this.#e[i](t,!0),t+=s;return r}get bbox(){return this.#n(xt.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#n(xt.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#n(xt.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#r(t){et(t<xt.strings.length,"Invalid string index");const{decoder:e}=gi;let i=xt.OFFSET_STRINGS+4;for(let n=0;n<t;n++)i+=this.#e.getUint32(i)+4;const s=this.#e.getUint32(i);return e.decode(new Uint8Array(this.#t,i+4,s))}get fallbackName(){return this.#r(0)}get loadedName(){return this.#r(1)}get mimetype(){return this.#r(2)}get name(){return this.#r(3)}#a(){let t=xt.OFFSET_STRINGS;const e=this.#e.getUint32(t);t+=4+e;const i=this.#e.getUint32(t);t+=4+i;const s=this.#e.getUint32(t);t+=4+s;const n=this.#e.getUint32(t);return{offset:t,length:n}}get data(){const{offset:t,length:e}=this.#a();return e===0?void 0:new Uint8Array(this.#t,t+4,e)}clearData(){const{offset:t,length:e}=this.#a();e!==0&&(this.#e.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#e=new DataView(this.#t))}get cssFontInfo(){let t=xt.OFFSET_STRINGS;const e=this.#e.getUint32(t);t+=4+e;const i=this.#e.getUint32(t);t+=4+i;const s=this.#e.getUint32(t);if(s===0)return null;const n=new Uint8Array(s);return n.set(new Uint8Array(this.#t,t+4,s)),new Za(n.buffer)}get systemFontInfo(){let t=xt.OFFSET_STRINGS;const e=this.#e.getUint32(t);t+=4+e;const i=this.#e.getUint32(t);if(i===0)return null;const s=new Uint8Array(i);return s.set(new Uint8Array(this.#t,t+4,i)),new Ja(s.buffer)}}class eo{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[Yt.KIND],i=!!this.data[Yt.HAS_BBOX],s=!!this.data[Yt.HAS_BACKGROUND],n=t.getUint32(Yt.N_COORD,!0),r=t.getUint32(Yt.N_COLOR,!0),a=t.getUint32(Yt.N_STOP,!0);let o=20;const l=new Float32Array(this.buffer,o,n*2);o+=n*8;const c=new Uint8Array(this.buffer,o,r*4);o+=r*4;const d=[];for(let p=0;p<a;++p){const g=t.getFloat32(o,!0);o+=4;const m=t.getUint32(o,!0);o+=4,d.push([g,`#${m.toString(16).padStart(6,"0")}`])}let u=null;if(i){u=[];for(let p=0;p<4;
2++p)u.push(t.getFloat32(o,!0)),o+=4}let f=null;if(s&&(f=new Uint8Array(this.buffer,o,3),o+=3),e===1)return["RadialAxial","axial",u,d,Array.from(l.slice(0,2)),Array.from(l.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",u,d,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(e===3){const p=this.data[Yt.SHADING_TYPE];let g=null;if(l.length>0){g=Bt.slice();for(let m=0,b=l.length;m<b;m+=2)k.pointBoundingBox(l[m],l[m+1],g)}return["Mesh",p,l,c,n,g,u,f]}throw new Error(`Unsupported pattern kind: ${e}`)}}class io{#t;constructor(t){this.#t=t}get path(){return Y.isFloat16ArraySupported?new Float16Array(this.#t):new Float32Array(this.#t)}}function so(h){if(h instanceof URL)return h;if(typeof h=="string"){if(wt){if(/^[a-z][a-z0-9\-+.]+:/i.test(h))return new URL(h);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(h))}const t=URL.parse(h,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function no(h){if(wt&&typeof Buffer<"u"&&h instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength)return h;if(typeof h=="string")return xi(h);if(h instanceof ArrayBuffer||ArrayBuffer.isView(h)||typeof h=="object"&&!isNaN(h?.length))return new Uint8Array(h);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Ke(h){if(typeof h!="string")return null;if(h.endsWith("/"))return h;throw new Error(`Invalid factory url: "${h}" must include trailing slash.`)}const ps=h=>typeof h=="object"&&Number.isInteger(h?.num)&&h.num>=0&&Number.isInteger(h?.gen)&&h.gen>=0,ro=h=>typeof h=="object"&&typeof h?.name=="string",ao=Pa.bind(null,ps,ro);class oo{#t=new Map;#e=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const[s]of this.#t)s.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted){$("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(e,s)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}const Qe={DATA:1,ERROR:2},it={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function gn(){}function gt(h){if(h instanceof zt||h instanceof ns||h instanceof ss||h instanceof fi||h instanceof Ui)return h;switch(h instanceof Error||typeof h=="object"&&h!==null||W('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),h.name){case"AbortException":return new zt(h.message);case"InvalidPDFException":return new ns(h.message);case"PasswordException":return new ss(h.message,h.code);case"ResponseException":return new fi(h.message,h.status,h.missing);case"UnknownErrorException":return new Ui(h.message,h.details)}return new Ui(h.message,h.toString())}class Ie{#t=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#s(t);return}if(t.callback){const i=t.callbackId,s=this.callbackCapabilities[i];if(!s)throw new Error(`Cannot resolve callback ${i}`);if(delete this.callbackCapabilities[i],t.callback===Qe.DATA)s.resolve(t.data);else if(t.callback===Qe.ERROR)s.reject(gt(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 i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:i,targetName:s,callback:Qe.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:i,targetName:s,callback:Qe.ERROR,callbackId:t.callbackId,reason:gt(r)})});return}if(t.streamId){this.#i(t);return}e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}
2sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:l=>{const c=Promise.withResolvers();return this.streamControllers[n]={controller:l,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:l.desiredSize},s),c.promise},pull:l=>{const c=Promise.withResolvers();return this.streamControllers[n].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:it.PULL,streamId:n,desiredSize:l.desiredSize}),c.promise},cancel:l=>{et(l instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[n].cancelCall=c,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:it.CANCEL,streamId:n,reason:gt(l)}),c.promise}},i)}#i(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(l,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),n.postMessage({sourceName:i,targetName:s,stream:it.ENQUEUE,streamId:e,chunk:l},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:it.CLOSE,streamId:e}),delete r.streamSinks[e])},error(l){et(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:it.ERROR,streamId:e,reason:gt(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:it.START_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:i,targetName:s,stream:it.START_COMPLETE,streamId:e,reason:gt(l)})})}#s(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case it.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(gt(t.reason));break;case it.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(gt(t.reason));break;case it.PULL:if(!a){n.postMessage({sourceName:i,targetName:s,stream:it.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||gn).then(function(){n.postMessage({sourceName:i,targetName:s,stream:it.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:i,targetName:s,stream:it.PULL_COMPLETE,streamId:e,reason:gt(l)})});break;case it.ENQUEUE:if(et(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case it.CLOSE:if(et(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#n(r,e);break;case it.ERROR:et(r,"error should have stream controller"),r.controller.error(gt(t.reason)),this.#n(r,e);break;case it.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(gt(t.reason)),this.#n(r,e);break;case it.CANCEL:if(!a)break;const o=gt(t.reason);Promise.try(a.onCancel||gn,o).then(function(){n.postMessage({sourceName:i,targetName:s,stream:it.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:i,targetName:s,stream:it.CANCEL_COMPLETE,streamId:e,reason:gt(l)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#n(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}}class _r{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:i=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=i}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:W(`Not implemented: ${t}`)}const i=this[t];if(!i)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const s=`${i}${e}`;return this._fetch(s,t).catch(n=>{throw new Error(`Unable to load ${this.#t[t]} data at: ${s}`)})}async _fetch(t,e){W("Abstract method `_fetch` called.")}}class mn extends _r{async _fetch(t,e){const i=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",s=await Ms(t,i);return s instanceof Uint8Array?s:xi(s)}}class Cr{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,i){if(!t)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.width=e,t.height=i}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){W("Abstract method `_createCanvas` called.")}}class lo extends Cr{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class Pr{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,i,s,n){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}class ho extends Pr{#t;#e;#i;#s;#n;#r;#a=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#s=t,this.#n=e}get#o(){return this.#e||=new Map}get#l(){return this.#r||=new Map}get#h(){if(!this.#i){const t=this.#n.createElement("div"),{style:e}=t;e.colorScheme="only light",e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#n.createElementNS(ut,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#i=this.#n.createElementNS(ut,"defs"),t.append(i),i.append(this.#i),this.#n.body.append(t)}return this.#i}#u(t){if(t.length===1){const o=t[0],l=new Array(256);for(let d=0;d<256;d++)l[d]=o[d]/255;const c=l.join(",");return[c,c,c]}const[e,i,s]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=i[o]/255,a[o]=s[o]/255;return[n.join(","),r.join(","),a.join(",")]}#d(t){if(this.#t===void 0){this.#t="";const e=this.#n.URL;e!==this.#n.baseURI&&(_i(e)?$('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=br(e,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;const[i,s,n]=this.#u(t),r=t.length===1?i:`${i}${s}${n}`;if(e=this.#o.get(r),e)return this.#o.set(t,e),e;const a=`g_${this.#s}_transfer_map_${this.#a++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(r,o);const l=this.#m(a);return this.#p(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#l.get(s);if(n?.key===i||(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#l.set(s,n)),!t||!e))return n.url;const r=this.#y(t);t=k.makeHexColor(...r);const a=this.#y(e);if(e=k.makeHexColor(...a),this.#v(),t==="#000000"&&e==="#ffffff"||t===e)return n.url;const l=Array.from({length:256},(f,p)=>cs(p/255)).join(","),c=`g_${this.#s}_hcm_filter`,d=n.filter=this.#m(c);this.#p(l,l,l,d),this.#g(d);const u=(f,p)=>{const g=r[f]/255,m=a[f]/255,b=new Array(p+1);for(let y=0;y<=p;y++)b[y]=g+y/p*(m-g);return b.join(",")};return this.#p(u(0,5),u(1,5),u(2,5),d),n.url=this.#d(c),n.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){const e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();return e==="none"||!Y.platform.isFirefox?null:{"backdrop-filter":e,"background-color":"transparent"}}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;const[i]=this.#u([t]),s=`alpha_${i}`;if(e=this.#o.get(s),e)return this.#o.set(t,e),e;const n=`g_${this.#s}_alpha_map_${this.#a++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(s,r);const a=this.#m(n);return this.#b(i,a),r}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let i,s;if(t?([i]=this.#u([t]),s=`luminosity_${i}`):s="luminosity",e=this.#o.get(s),e)return this.#o.set(t,e),e;const n=`g_${this.#s}_luminosity_map_${this.#a++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(s,r);const a=this.#m(n);return this.#f(a),t&&this.#b(i,a),r}addKnockoutFilter(t=0){const e=t>0?Math.min(1/t,1e6):1e6,i=`knockout_${e}`,s=this.#o.get(i);if(s)return s;const n=`g_${this.#s}_knockout_filter_${this.#a++}`,r=this.#d(n);this.#o.set(i,r);const a=this.#m(n),o=this.#n.createElementNS(ut,"feComponentTransfer");a.append(o);const l=this.#n.createElementNS(ut,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let a=this.#l.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#l.set(t,a)),!e||!i))return a.url;const[o,l]=[e,i].map(this.#y.bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[u,f]=[s,n].map(this.#E.bind(this));d<c&&([c,d,u,f]=[d,c,f,u]),this.#v();const p=(b,y,w)=>{const A=new Array(256),v=(d-c)/w,E=b/255,_=(y-b)/(255*w);let C=0;for(let S=0;S<=w;S++){const P=Math.round(c+S*v),T=E+S*_;for(let M=C;M<=P;M++)A[M]=T;C=P+1}for(let S=C;S<256;S++)A[S]=A[C-1];return A.join(",")},g=`g_${this.#s}_hcm_${t}_filter`,m=a.filter=this.#m(g);return this.#g(m),this.#p(p(u[0],f[0],5),p(u[1],f[1],5),p(u[2],f[2],5),m),a.url=this.#d(g),a.url}destroy(t=!1){t&&this.#r?.size||(this.#i?.parentNode.parentNode.remove(),this.#i=null,this.#e?.clear(),this.#e=null,this.#r?.clear(),this.#r=null,this.#a=0)}#f(t){const e=this.#n.createElementNS(ut,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#g(t){const e=this.#n.createElementNS(ut,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#m(t){const e=this.#n.createElementNS(ut,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#h.append(e),e}#c(t,e,i){const s=this.#n.createElementNS(ut,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#p(t,e,i,s){const n=this.#n.createElementNS(ut,"feComponentTransfer");
2s.append(n),this.#c(n,"feFuncR",t),this.#c(n,"feFuncG",e),this.#c(n,"feFuncB",i)}#b(t,e){const i=this.#n.createElementNS(ut,"feComponentTransfer");e.append(i),this.#c(i,"feFuncA",t)}#y(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,Xe(getComputedStyle(this.#h).getPropertyValue("background-color"))}#w(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,Ge(getComputedStyle(this.#h).getPropertyValue("background-color"))}#v(){this.#h.style.color="",this.#h.style.backgroundColor=""}#E(t){const[e,i,s,n]=this.#w(t);if(n===1)return[e,i,s];const[r,a,o]=this.#y("Canvas");return[Wi(e,r,n),Wi(i,a,n),Wi(s,o,n)]}}function Wi(h,t,e){return Math.round(e*h+(1-e)*t)}wt&&$("Please use the `legacy` build in Node.js environments.");async function co(h){const e=await process.getBuiltinModule("fs/promises").readFile(h);return new Uint8Array(e)}class uo extends Pr{}class fo extends Cr{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class po extends _r{async _fetch(t,e){return co(t)}}function Tr({src:h,srcPos:t=0,dest:e,width:i,height:s,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=Y.isLittleEndian?4278190080:255,[o,l]=r?[n,a]:[a,n],c=i>>3,d=i&7,u=o^l,f=h.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<s;++g){for(const b=t+c;t<b;++t,p+=8){const y=h[t];e[p]=o^-(y>>7&1)&u,e[p+1]=o^-(y>>6&1)&u,e[p+2]=o^-(y>>5&1)&u,e[p+3]=o^-(y>>4&1)&u,e[p+4]=o^-(y>>3&1)&u,e[p+5]=o^-(y>>2&1)&u,e[p+6]=o^-(y>>1&1)&u,e[p+7]=o^-(y&1)&u}if(d===0)continue;const m=t<f?h[t++]:255;for(let b=0;b<d;++b,++p)e[p]=o^-(m>>7-b&1)&u}return{srcPos:t,destPos:p}}function go({src:h,srcPos:t=0,dest:e,destPos:i=0,width:s,height:n}){let r=0;const a=s*n*3,o=a>>2,l=new Uint32Array(h.buffer,t,o),c=Y.isLittleEndian?4278190080:255;if(Y.isLittleEndian){for(;r<o-2;r+=3,i+=4){const d=l[r],u=l[r+1],f=l[r+2];e[i]=d|c,e[i+1]=d>>>24|u<<8|c,e[i+2]=u>>>16|f<<16|c,e[i+3]=f>>>8|c}for(let d=r*4,u=t+a;d<u;d+=3)e[i++]=h[d]|h[d+1]<<8|h[d+2]<<16|c}else{for(;r<o-2;r+=3,i+=4){const d=l[r],u=l[r+1],f=l[r+2];e[i]=d|c,e[i+1]=d<<24|u>>>8|c,e[i+2]=u<<16|f>>>16|c,e[i+3]=f<<8|c}for(let d=r*4,u=t+a;d<u;d+=3)e[i++]=h[d]<<24|h[d+1]<<16|h[d+2]<<8|c}return{srcPos:t+a,destPos:i}}const mo=` 3struct Uniforms { 4 offsetX : f32, 5 offsetY : f32, 6 scaleX : f32, 7 scaleY : f32, 8 paddedWidth : f32, 9 paddedHeight : f32, 10 borderSize : f32, 11 _pad : f32, 12}; 13 14@group(0) @binding(0) var<uniform> u : Uniforms; 15 16struct VertexInput { 17 @location(0) position : vec2<f32>, 18 @location(1) color : vec4<f32>, 19}; 20 21struct VertexOutput { 22 @builtin(position) position : vec4<f32>, 23 @location(0) color : vec3<f32>, 24}; 25 26@vertex 27fn vs_main(in : VertexInput) -> VertexOutput { 28 var out : VertexOutput; 29 let cx = (in.position.x + u.offsetX) * u.scaleX; 30 let cy = (in.position.y + u.offsetY) * u.scaleY; 31 out.position = vec4<f32>( 32 ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0, 33 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0, 34 0.0, 35 1.0 36 ); 37 out.color = in.color.rgb; 38 return out; 39} 40 41@fragment 42fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> { 43 return vec4<f32>(in.color, 1.0); 44} 45`;class bo{#t=null;#e=null;#i=null;#s=null;async#n(){if(!globalThis.navigator?.gpu)return!1;try{const t=await navigator.gpu.requestAdapter();return t?(this.#s=navigator.gpu.getPreferredCanvasFormat(),this.#e=await t.requestDevice(),!0):!1}catch{return!1}}init(){return this.#t||=this.#n()}get isReady(){return this.#e!==null}loadMeshShader(){if(!this.#e||this.#i)return;const t=this.#e.createShaderModule({code:mo});this.#i=this.#e.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#s}]},primitive:{topology:"triangle-list"}})}draw(t,e,i,s,n,r,a,o){this.loadMeshShader();const l=this.#e,{offsetX:c,offsetY:d,scaleX:u,scaleY:f}=s,p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);const g=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(g,0,e);const m=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(m,0,new Float32Array([c,d,u,f,r,a,o,0]));const b=l.createBindGroup({layout:this.#i.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:m}}]}),y=new OffscreenCanvas(r,a),w=y.getContext("webgpu");w.configure({device:l,format:this.#s,alphaMode:n?"opaque":"premultiplied"});const A=n?{r:n[0]/255,g:n[1]/255,b:n[2]/255,a:1}:{r:0,g:0,b:0,a:0},v=l.createCommandEncoder(),E=v.beginRenderPass({colorAttachments:[{view:w.getCurrentTexture().createView(),clearValue:A,loadOp:"clear",storeOp:"store"}]});return i>0&&(E.setPipeline(this.#i),E.setBindGroup(0,b),E.setVertexBuffer(0,p),E.setVertexBuffer(1,g),E.draw(i)),E.end(),l.queue.submit([v.finish()]),p.destroy(),g.destroy(),m.destroy(),y.transferToImageBitmap()}}const Ci=new bo;function yo(){return Ci.init()}function wo(){return Ci.isReady}function vo(){Ci.loadMeshShader()}function Ao(h,t,e,i,s,n,r,a){return Ci.draw(h,t,e,i,s,n,r,a)}const lt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function hi(h,t){if(!t)return;const e=t[2]-t[0],i=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],e,i),h.clip(s)}class Os{matrix=null;isModifyingCurrentTransform(){return!1}getPattern(){W("Abstract method `getPattern` called.")}}class Eo extends Os{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 i,s=this._p0,n=this._p1;
45if(e&&(s=s.slice(),n=n.slice(),k.applyTransform(s,e),k.applyTransform(n,e)),this._type==="axial")i=t.createLinearGradient(s[0],s[1],n[0],n[1]);else if(this._type==="radial"){let r=this._r0,a=this._r1;if(e){const o=new Float32Array(2);k.singularValueDecompose2dScale(e,o),r*=o[0],a*=o[0]}i=t.createRadialGradient(s[0],s[1],r,n[0],n[1],a)}for(const r of this._colorStops)i.addColorStop(r[0],r[1]);return i}_createReversedGradient(t,e=null){let i=this._p1,s=this._p0;e&&(i=i.slice(),s=s.slice(),k.applyTransform(i,e),k.applyTransform(s,e));let n=this._r1,r=this._r0;if(e){const l=new Float32Array(2);k.singularValueDecompose2dScale(e,l),n*=l[0],r*=l[0]}const a=t.createRadialGradient(i[0],i[1],n,s[0],s[1],r),o=this._colorStops.map(([l,c])=>[1-l,c]).reverse();for(const[l,c]of o)a.addColorStop(l,c);return a}getPattern(t,e,i,s){let n;if(s===lt.STROKE||s===lt.FILL){if(this.isOriginBased()){let u=k.transform(i,e.baseTransform);this.matrix&&(u=k.transform(u,this.matrix));const f=.001,p=Math.hypot(u[0],u[1]),g=Math.hypot(u[2],u[3]),m=(u[0]*u[2]+u[1]*u[3])/(p*g);if(Math.abs(m)<f)if(this.isRadial()){if(Math.abs(p-g)<f)return this._createGradient(t,u)}else return this._createGradient(t,u)}const r=e.current.getClippedPathBoundingBox(s,q(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.canvasFactory.create(a,o),c=l.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(-r[0],-r[1]),i=k.transform(i,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),hi(c,this._bbox),this.areConic()&&(c.fillStyle=this._createReversedGradient(c),c.fill()),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(l.canvas,"no-repeat"),e.canvasFactory.destroy(l);const d=new DOMMatrix(i);n.setTransform(d)}else this.areConic()&&(t.save(),hi(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),hi(t,this._bbox),n=this._createGradient(t);return n}}function So(h,t,e,i,s,n,r,a){const o=t.coords,l=t.colors,c=h.data,d=h.width*4;let u;o[e*2+1]>o[i*2+1]&&(u=e,e=i,i=u,u=n,n=r,r=u),o[i*2+1]>o[s*2+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),o[e*2+1]>o[i*2+1]&&(u=e,e=i,i=u,u=n,n=r,r=u);const f=(o[e*2]+t.offsetX)*t.scaleX,p=(o[e*2+1]+t.offsetY)*t.scaleY,g=(o[i*2]+t.offsetX)*t.scaleX,m=(o[i*2+1]+t.offsetY)*t.scaleY,b=(o[s*2]+t.offsetX)*t.scaleX,y=(o[s*2+1]+t.offsetY)*t.scaleY;if(p>=y)return;const w=l[n*4],A=l[n*4+1],v=l[n*4+2],E=l[r*4],_=l[r*4+1],C=l[r*4+2],S=l[a*4],P=l[a*4+1],T=l[a*4+2],M=Math.round(p),L=Math.round(y);let D,U,R,O,ht,ct,Ot,le;for(let K=M;K<=L;K++){if(K<m){const nt=K<p?0:(p-K)/(p-m);D=f-(f-g)*nt,U=w-(w-E)*nt,R=A-(A-_)*nt,O=v-(v-C)*nt}else{let nt;K>y?nt=1:m===y?nt=0:nt=(m-K)/(m-y),D=g-(g-b)*nt,U=E-(E-S)*nt,R=_-(_-P)*nt,O=C-(C-T)*nt}let Z;K<p?Z=0:K>y?Z=1:Z=(p-K)/(p-y),ht=f-(f-b)*Z,ct=w-(w-S)*Z,Ot=A-(A-P)*Z,le=v-(v-T)*Z;const Xt=Math.round(Math.min(D,ht)),Bi=Math.round(Math.max(D,ht));let he=d*K+Xt*4;for(let nt=Xt;nt<=Bi;nt++)Z=(D-nt)/(D-ht),Z<0?Z=0:Z>1&&(Z=1),c[he++]=U-(U-ct)*Z|0,c[he++]=R-(R-Ot)*Z|0,c[he++]=O-(O-le)*Z|0,c[he++]=255}}class xo extends Os{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],vo()}_createMeshCanvas(t,e,i){const a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),l=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,d=Math.min(Math.ceil(Math.abs(l*t[0]*1.1)),3e3)||1,u=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3)||1,f=l?l/d:1,p=c?c/u:1,g={coords:this._posData,colors:this._colData,offsetX:-a,offsetY:-o,scaleX:1/f,scaleY:1/p},m=d+4,b=u+4,y=i.create(m,b);if(wo()&&this._vertexCount>48)y.context.drawImage(Ao(this._posData,this._colData,this._vertexCount,g,e,m,b,2),0,0);else{const w=y.context.createImageData(d,u);if(e){const A=w.data;for(let v=0,E=A.length;v<E;v+=4)A[v]=e[0],A[v+1]=e[1],A[v+2]=e[2],A[v+3]=255}for(let A=0,v=this._vertexCount;A<v;A+=3)So(w,g,A,A+1,A+2,A,A+1,A+2);y.context.putImageData(w,2,2)}return{canvas:y.canvas,offsetX:a-2*f,offsetY:o-2*p,scaleX:f,scaleY:p}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){hi(t,this._bbox);const n=new Float32Array(2);if(s===lt.SHADING)k.singularValueDecompose2dScale(q(t),n);
45else if(this.matrix){k.singularValueDecompose2dScale(this.matrix,n);const[o,l]=n;k.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=o,n[1]*=l}else k.singularValueDecompose2dScale(e.baseTransform,n);const r=this._createMeshCanvas(n,s===lt.SHADING?null:this._background,e.canvasFactory);s!==lt.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY);const a=t.createPattern(r.canvas,"no-repeat");return e.canvasFactory.destroy(r),a}}class _o extends Os{getPattern(){return"hotpink"}}function Co(h){switch(h[0]){case"RadialAxial":return new Eo(h);case"Mesh":return new xo(h);case"Dummy":return new _o}throw new Error(`Unknown IR type: ${h[0]}`)}const bn={COLORED:1,UNCOLORED:2};class Ne{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){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=i,this.baseTransform=s,this.patternBaseMatrix=this.matrix?k.transform(s,this.matrix):s}canSkipPatternCanvas([t,e,i,s]){const[n,r,a,o]=this.bbox,l=Math.abs(this.xstep),c=Math.abs(this.ystep);if(t>l+1e-6||e>c+1e-6)return null;const d=Math.floor((i-a)/l)+1,u=Math.ceil((i+t-n)/l)-1,f=Math.floor((s-o)/c)+1,p=Math.ceil((s+e-r)/c)-1;return u<=d&&p<=f?[d,f]:null}updatePatternDims(t,e){const i=k.inverseTransform(this.patternBaseMatrix),s=[t[0],t[1]],n=[t[2],t[3]];k.applyTransform(s,i),k.applyTransform(n,i),e[0]=Math.abs(n[0]-s[0]),e[1]=Math.abs(n[1]-s[1]),e[2]=Math.min(s[0],n[0]),e[3]=Math.min(s[1],n[1])}_renderTileCanvas(t,e,i,s){const[n,r,a,o]=this.bbox,l=t.canvasFactory.create(i.size,s.size),c=l.context,d=this.canvasGraphicsFactory.createCanvasGraphics(c,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),c.translate(-i.scale*n,-s.scale*r),d.transform(0,i.scale,0,0,s.scale,0,0),c.save(),d.dependencyTracker?.save(),this.clipBbox(d,n,r,a,o),d.baseTransform=q(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),d.dependencyTracker?.restore(),c.restore(),l}_getCombinedScales(){const t=new Float32Array(2);k.singularValueDecompose2dScale(this.matrix,t);const[e,i]=t;return k.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],i*t[1]]}drawPattern(t,e,i=!1,[s,n],r){const[a,o,l,c]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new $e(d,r)),t.save(),i?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(s*this.xstep,n*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){const u=l-a,f=c-o,[p,g]=this._getCombinedScales(),m=this.getSizeAndScale(u,this.ctx.canvas.width,p),b=this.getSizeAndScale(f,this.ctx.canvas.height,g),y=this._renderTileCanvas(t,r,m,b);t.ctx.drawImage(y.canvas,a,o,u,f),t.canvasFactory.destroy(y)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,a,o,l,c),t.baseTransformStack.push(t.baseTransform),t.baseTransform=q(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[i,s,n,r]=this.bbox,a=n-i,o=r-s;let{xstep:l,ystep:c}=this;l=Math.abs(l),c=Math.abs(c),Si("TilingType: "+this.tilingType);const[d,u]=this._getCombinedScales();let f=a,p=o,g=!1,m=!1;Math.ceil(l*d)>=Math.ceil(a*d)?f=l:g=!0,Math.ceil(c*u)>=Math.ceil(o*u)?p=c:m=!0;const b=this.getSizeAndScale(f,this.ctx.canvas.width,d),y=this.getSizeAndScale(p,this.ctx.canvas.height,u),w=this._renderTileCanvas(t,e,b,y);if(g||m){const A=w.canvas;g&&(f=l),m&&(p=c);const v=this.getSizeAndScale(f,this.ctx.canvas.width,d),E=this.getSizeAndScale(p,this.ctx.canvas.height,u),_=v.size,C=E.size,S=t.canvasFactory.create(_,C),P=S.context,T=g?Math.floor(a/l):0,M=m?Math.floor(o/c):0;for(let L=0;L<=T;L++)for(let D=0;D<=M;D++)P.drawImage(A,_*L,C*D,_,C,0,0,_,C);return t.canvasFactory.destroy(w),{canvas:S.canvas,canvasEntry:S,scaleX:v.scale,scaleY:E.scale,offsetX:i,offsetY:s}}return{canvas:w.canvas,canvasEntry:w,scaleX:b.scale,scaleY:y.scale,offsetX:i,offsetY:s}}getSizeAndScale(t,e,i){const s=Math.max(Ne.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const r=s-e,a=n-i,o=new Path2D;o.rect(e,i,r,a),k.axialAlignedBoundingBox([e,i,s,n],q(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(n.patternFill=n.patternStroke=!1,e){case bn.COLORED:const{fillStyle:r,strokeStyle:a}=this.ctx;s.fillStyle=n.fillColor=r,s.strokeStyle=n.strokeColor=a;break;case bn.UNCOLORED:s.fillStyle=s.strokeStyle=i,n.fillColor=n.strokeColor=i;break;default:throw new Sa(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,n){const r=s!==lt.SHADING?k.transform(i,this.patternBaseMatrix):i,a=this.createPatternCanvas(e,n);let o=new DOMMatrix(r);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const l=t.createPattern(a.canvas,"repeat");return e.canvasFactory.destroy(a.canvasEntry),l.setTransform(o),l}}const Po=16,To=100,ko=15,yn=10,bt=16,At=new Float32Array(2);function wn(h,t){if(h._removeMirroring)throw new Error("Context is already forwarding operations.");const e=new Map;for(const i of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const s=h[i];typeof s!="function"||typeof t[i]!="function"||(e.set(i,s),h[i]=function(...n){return t[i](...n),s.apply(this,n)})}h._removeMirroring=()=>{for(const[i,s]of e)h[i]=s;delete h._removeMirroring}}function Ze(h,t,e,i,s,n,r,a,o,l){const[c,d,u,f,p,g]=q(h);if(d===0&&u===0){const y=r*c+p,w=Math.round(y),A=a*f+g,v=Math.round(A),E=(r+o)*c+p,_=Math.abs(Math.round(E)-w)||1,C=(a+l)*f+g,S=Math.abs(Math.round(C)-v)||1;return h.setTransform(Math.sign(c),0,0,Math.sign(f),w,v),h.drawImage(t,e,i,s,n,0,0,_,S),h.setTransform(c,d,u,f,p,g),[_,S]}if(c===0&&f===0){const y=a*u+p,w=Math.round(y),A=r*d+g,v=Math.round(A),E=(a+l)*u+p,_=Math.abs(Math.round(E)-w)||1,C=(r+o)*d+g,S=Math.abs(Math.round(C)-v)||1;return h.setTransform(0,Math.sign(d),Math.sign(u),0,w,v),h.drawImage(t,e,i,s,n,0,0,S,_),h.setTransform(c,d,u,f,p,g),[S,_]}h.drawImage(t,e,i,s,n,r,a,o,l);const m=Math.hypot(c,d),b=Math.hypot(u,f);return[m*o,b*l]}class vn{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=es;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=rt.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=ee.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=lt.FILL,e=null){const i=this.minMax.slice();if(t===lt.STROKE){e||W("Stroke bounding box must include transform."),k.singularValueDecompose2dScale(e,At);const s=At[0]*this.lineWidth/2,n=At[1]*this.lineWidth/2;i[0]-=s,i[1]-=n,i[2]+=s,i[3]+=n}return i}updateClipFromPath(){const t=k.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(ee,0)}getClippedPathBoundingBox(t=lt.FILL,e=null){return k.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function An(h,t){const{width:e,height:i,kind:s}=t,n=i%bt,r=(i-n)/bt,a=n===0?r:r+1,o=h.createImageData(e,bt);let l=0;const c=t.data,d=o.data;let u;if(s===li.GRAYSCALE_1BPP)for(u=0;
45u<a;u++)({srcPos:l}=Tr({src:c,srcPos:l,dest:d,width:e,height:u<r?bt:n})),h.putImageData(o,0,u*bt);else if(s===li.RGBA_32BPP){let f=0,p=e*bt*4;for(u=0;u<r;u++)d.set(c.subarray(l,l+p)),l+=p,h.putImageData(o,0,f),f+=bt;u<a&&(p=e*n*4,d.set(c.subarray(l,l+p)),h.putImageData(o,0,f))}else if(s===li.RGB_24BPP)for(u=0;u<a;u++)({srcPos:l}=go({src:c,srcPos:l,dest:new Uint32Array(d.buffer),width:e,height:u<r?bt:n})),h.putImageData(o,0,u*bt);else throw new Error(`bad image kind: ${s}`)}function En(h,t){if(t.bitmap){h.drawImage(t.bitmap,0,0);return}const{width:e,height:i}=t,s=i%bt,n=(i-s)/bt,r=s===0?n:n+1,a=h.createImageData(e,bt);let o=0;const l=t.data,c=a.data;for(let d=0;d<r;d++)({srcPos:o}=Tr({src:l,srcPos:o,dest:c,width:e,height:d<n?bt:s,nonBlackColor:0})),h.putImageData(a,0,d*bt)}function qt(h,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const i of e)h[i]!==void 0&&(t[i]=h[i]);h.setLineDash!==void 0&&(t.setLineDash(h.getLineDash()),t.lineDashOffset=h.lineDashOffset)}function Je(h){h.strokeStyle=h.fillStyle="#000000",h.fillRule="nonzero",h.globalAlpha=1,h.lineWidth=1,h.lineCap="butt",h.lineJoin="miter",h.miterLimit=10,h.globalCompositeOperation="source-over",h.font="10px sans-serif",h.setLineDash!==void 0&&(h.setLineDash([]),h.lineDashOffset=0);const{filter:t}=h;t!=="none"&&t!==""&&(h.filter="none")}function Sn(h,t){if(t)return!0;k.singularValueDecompose2dScale(h,At);const e=Math.fround(Wt.pixelRatio*Se.PDF_TO_CSS_UNITS);return At[0]<=e&&At[1]<=e}const Mo=["butt","round","square"],Io=["miter","round","bevel"],Lo={},xn={};class se{static#t=null;#e=0;#i=0;#s=null;#n=null;#r=null;#a=null;#o=1;#l;#h=null;#u=[];constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l,c,d){this.ctx=t,this.current=new vn(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,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=a||[],this.optionalContentConfig=r,this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=c??null,this.imagesTracker=d??null}getObject(t,e,i=null){return typeof e=="string"?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){const o=this.transparentCanvasEntry=this.canvasFactory.create(n,r);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=o,this.ctx.save(),this.ctx.transform(...q(this.compositeCtx))}this.ctx.save(),Je(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=q(this.ctx)}executeOperatorList(t,e,i,s,n){const r=t.argsArray,a=t.fnArray;let o=e||0;const l=r.length;if(l===o)return o;const c=l-o>yn&&typeof i=="function",d=c?Date.now()+ko:0;let u=0;const f=this.commonObjs,p=this.objs;let g,m;for(;;){if(s!==void 0){if(o===s.nextBreakPoint)return s.breakIt(o,i),o;if(s.shouldSkip(o)){if(++o===l)return o;continue}}if(!n||n(o))if(g=a[o],m=r[o]??null,g!==Lt.dependency)m===null?this[g](o):this[g](o,...m);else for(const b of m){this.dependencyTracker?.recordNamedData(b,o);const y=b.startsWith("g_")?f:p;if(!y.has(b))return y.get(b,i),o}if(o++,o===l)return o;if(c&&++u>yn){if(Date.now()>d)return i(),o;u=0}}}#d(){for(;this.stateStack.length||this.inSMaskMode;
45)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)}endDrawing(){this.#d();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 this.#u)this.#v(t);this.#u.length=0,this.#s=null,this.#n=null,this.#r=null,this.#a=null,this.#o=1,this.#h=null,this.#i=0,this.#e=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(),this.#f()}#f(){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}}}
45_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight,n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=[];let o=n,l=r,c=i,d=s;for(;o>2&&c>1||l>2&&d>1;){let b=c,y=d;o>2&&c>1&&(b=Math.ceil(c/2),o/=c/b),l>2&&d>1&&(y=Math.ceil(d/2),l/=d/y),a.push({newWidth:b,newHeight:y}),c=b,d=y}if(a.length===0)return{img:t,paintWidth:i,paintHeight:s,tmpCanvas:null};if(a.length===1){const{newWidth:b,newHeight:y}=a[0],w=this.canvasFactory.create(b,y);return w.context.drawImage(t,0,0,i,s,0,0,b,y),{img:w.canvas,paintWidth:b,paintHeight:y,tmpCanvas:w}}let u=this.canvasFactory.create(1,1),f=this.canvasFactory.create(1,1),p=i,g=s,m=t;for(const{newWidth:b,newHeight:y}of a)this.canvasFactory.reset(f,b,y),f.context.drawImage(m,0,0,p,g,0,0,b,y),[u,f]=[f,u],m=u.canvas,p=b,g=y;return this.canvasFactory.destroy(f),{img:u.canvas,paintWidth:p,paintHeight:g,tmpCanvas:u}}_createMaskCanvas(t,e){const i=this.ctx,{width:s,height:n}=e,r=this.current.fillColor,a=this.current.patternFill,o=q(i);let l,c,d,u;if((e.bitmap||e.data)&&e.count>1){const T=e.bitmap||e.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),r]),l=this._cachedBitmapsMap.getOrInsertComputed(T,ks);const M=l.get(c);if(M&&!a){const L=Math.round(Math.min(o[0],o[2])+o[4]),D=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,St.transformAndFill),{canvas:M,offsetX:L,offsetY:D}}d=M}d||(u=this.canvasFactory.create(s,n),En(u.context,e));let f=k.transform(o,[1/s,0,0,-1/n,0,0]);f=k.transform(f,[1,0,0,1,0,-n]);const p=ee.slice();k.axialAlignedBoundingBox([0,0,s,n],f,p);const[g,m,b,y]=p,w=Math.round(b-g)||1,A=Math.round(y-m)||1,v=this.canvasFactory.create(w,A),E=v.context,_=g,C=m;E.translate(-_,-C),E.transform(...f);let S=null;if(!d){const T=this._scaleImage(u.canvas,Pt(E));d=T.img,S=T.tmpCanvas,d!==u.canvas&&(this.canvasFactory.destroy(u),u=null),l&&a&&(l.set(c,d),S=null,u=null)}E.imageSmoothingEnabled=Sn(q(E),e.interpolate),Ze(E,d,0,0,d.width,d.height,0,0,s,n),S&&this.canvasFactory.destroy(S),u&&this.canvasFactory.destroy(u),E.globalCompositeOperation="source-in";const P=k.transform(Pt(E),[1,0,0,1,-_,-C]);return E.fillStyle=a?r.getPattern(i,this,P,lt.FILL,t):r,E.fillRect(0,0,s,n),l&&!a&&l.set(c,v.canvas),this.dependencyTracker?.recordDependencies(t,St.transformAndFill),{canvas:v.canvas,canvasEntry:l&&!a?null:v,offsetX:Math.round(_),offsetY:Math.round(C)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=Mo[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Io[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(e),s.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(const[i,s]of e)switch(i){case"LW":this.setLineWidth(t,s);break;case"LC":this.setLineCap(t,s);break;case"LJ":this.setLineJoin(t,s);break;case"ML":this.setMiterLimit(t,s);break;case"D":this.setDash(t,s[0],s[1]);break;case"RI":this.setRenderingIntent(t,s);break;case"FL":this.setFlatness(t,s);break;case"Font":this.setFont(t,s[0],s[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=s;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=s;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=s;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=s?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);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:i,backdrop:s,transferMap:n}=t,r=i==="Luminosity"||i==="Alpha"&&n;if(!r&&!(i==="Luminosity"&&s)){this.smaskPreparedFor=t;return}let a;if(i==="Luminosity"&&s){const[y,w,A]=Ge(s),v=Math.round(.3*y+.59*w+.11*A);a=n?.[v]??v}else a=n?.[0]??0;const o=4,{width:l,height:c}=this.ctx.canvas,d=e.width*e.height,u=l*c<o*d,f=r?{url:i==="Alpha"?this.filterFactory.addAlphaFilter(n):this.filterFactory.addLuminosityFilter(n),subtype:i,transferMap:n}:null,p=i==="Luminosity"?s:null;let g,m,b;u?(g=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,l,c,p,f),m=0,b=0):(g=this._bakeSMaskCanvas(e,0,0,e.width,e.height,p,f),m=t.offsetX,b=t.offsetY),this.smaskPreparedEntry=g,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=m,this.smaskPreparedOffsetY=b,this.smaskPreparedOOBAlpha=!u&&a!==0?a:null}_bakeSMaskCanvas(t,e,i,s,n,r,a){!r&&!a&&W("_bakeSMaskCanvas with
45neither backdrop nor filter");const o=this.canvasFactory.create(s,n),l=o.context;if(l.drawImage(t,e,i),r&&(l.globalCompositeOperation="destination-atop",l.fillStyle=r,l.fillRect(0,0,s,n)),!a)return o;const c=this.canvasFactory.create(s,n),d=c.context;d.filter=a.url;const u=Y.isCanvasFilterSupported&&d.filter!=="none"&&d.filter!=="";if(d.drawImage(o.canvas,0,0),Y.isCanvasFilterSupported&&(d.filter="none"),!u){const f=d.getImageData(0,0,s,n),{data:p}=f,{transferMap:g}=a;if(a.subtype==="Luminosity")for(let m=0,b=p.length;m<b;m+=4){const y=.3*p[m]+.59*p[m+1]+.11*p[m+2]+.5|0;p[m]=p[m+1]=p[m+2]=0,p[m+3]=g?.[y]??y}else for(let m=3,b=p.length;m<b;m+=4)p[m]=g[p[m]];d.putImageData(f,0,0)}return this.canvasFactory.destroy(o),c}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:e,height:i}=this.ctx.canvas,s=this.canvasFactory.create(e,i);this.smaskScratchCanvas=s,this.suspendedCtx=this.ctx;const n=this.ctx=s.context;n.setTransform(this.suspendedCtx.getTransform()),qt(this.suspendedCtx,n),wn(n,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(),qt(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#g(t,e=null,i=1){const{width:s,height:n}=t,r=e??this.canvasFactory.create(s,n),a=r.context;i=Math.round(i*255)/255;const o=i<1;o&&this.#l===void 0&&(this.#l=Y.isCanvasFilterSupported?new Map:"none");let l="none";if(o&&this.#l instanceof Map&&(l=this.#l.getOrInsertComputed(i,()=>this.filterFactory.addKnockoutFilter(i))),!o||l!=="none")return e&&(a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s,n),a.restore()),a.filter=l,a.drawImage(t,0,0),a.filter="none",r;const c=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,s,n),d=a.createImageData(s,n),u=c.data,f=d.data,p=i>0?1/i:1e6;for(let g=3,m=u.length;g<m;g+=4)f[g]=Math.min(Math.round(u[g]*p),255);return a.putImageData(d,0,0),r}#m(t,e,i,s){let n=t?.[e]??null;if(n&&(n.canvas.width!==i||n.canvas.height!==s)&&(this.canvasFactory.destroy(n),n=null),!n)return n=this.canvasFactory.create(i,s),t&&(t[e]=n),n;const r=n.context;return r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,i,s),r.restore(),n}#c(t,e,i={}){const{backdropCanvas:s=null,destTransform:n=[1,0,0,1,0,0],backdropOffset:r=[0,0],reuseMaskEntry:a=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:c="none",knockoutAlpha:d=1}=i,{width:u,height:f}=e,p=this.#g(e,a,d),g=t.globalCompositeOperation;if(t.save(),t.setTransform(...n),t.globalAlpha=1,Y.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(p.canvas,0,0),s){const[m,b]=r,y=this.#m(o,"knockoutBackdropEntry",u,f),w=y.context;w.drawImage(s,m,b,u,f,0,0,u,f),w.globalCompositeOperation="destination-in",w.drawImage(p.canvas,0,0),w.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(y.canvas,0,0),o||this.canvasFactory.destroy(y)}t.globalCompositeOperation=g,t.globalAlpha=l,Y.isCanvasFilterSupported&&(t.filter=c??"none"),t.drawImage(e,0,0),t.restore(),a||this.canvasFactory.destroy(p)}#p(t=1){if(this.#e===0||this.#i>0||!this.contentVisible)return!1;this.#i++,this.#o=t;const e=this.#u.at(-1),{canvas:i}=this.ctx,s=this.#m(e,"knockoutTempEntry",i.width,i.height);this.#s=s;const n=s.context;return n.save(),n.setTransform(this.ctx.getTransform()),qt(this.ctx,n),this.#a=n.globalCompositeOperation,n.globalCompositeOperation="source-over",wn(n,this.ctx),this.#h=e,this.#n=this.ctx,this.#r=this.suspendedCtx,this.ctx=n,this.inSMaskMode&&(this.suspendedCtx=n),!0}#b(t){if(!t)return;const e=this.#s,i=this.#n,s=this.#r,n=e.context;this.#s=null,this.#n=null,this.#r=null,this.inSMaskMode&&this.suspendedCtx===n&&this.ctx!==n&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=s),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#a,this.#a=null,qt(this.ctx,i),this.ctx=i;const r=this.#h;this.#h=null;const a=this.#o;this.#o=1;try{this.#c(s??i,e.canvas,{backdropCanvas:r?.backdropCtx?.canvas??null,backdropOffset:r?.backdropCtx?[r.offsetX,r.offsetY]:[0,0],reuseMaskEntry:r?.knockoutMaskEntry??null,poolMeta:r,knockoutAlpha:a})}
45finally{n.restore(),this.#i--,r||this.canvasFactory.destroy(e)}}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,i=this.suspendedCtx,s=this.#i>0&&i===this.ctx;this.composeSMask(s?null:i,e,this.ctx,t),!s&&(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,i,s){const n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;if(a===0||o===0)return;const l=this.smaskPreparedEntry;if(l){let c=n,d=r,u=a,f=o;const p=this.smaskPreparedOOBAlpha,g=p!==null;if(g){c=Math.max(n,e.offsetX),d=Math.max(r,e.offsetY);const m=Math.min(n+a,e.offsetX+e.canvas.width),b=Math.min(r+o,e.offsetY+e.canvas.height);u=m-c,f=b-d}if(u>0&&f>0){const m=c-this.smaskPreparedOffsetX,b=d-this.smaskPreparedOffsetY;i.save(),i.globalAlpha=1,i.setTransform(1,0,0,1,0,0);const y=new Path2D;y.rect(c,d,u,f),i.clip(y),i.globalCompositeOperation="destination-in",i.drawImage(l.canvas,m,b,u,f,c,d,u,f),i.restore()}g&&p<255&&this._applySMaskOOBAlpha(i,n,r,a,o,c,d,c+u,d+f,p)}else this.genericComposeSMask(e,i,a,o,n,r);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,n,r,a,o,n,r,a,o),t.restore())}_applySMaskOOBAlpha(t,e,i,s,n,r,a,o,l,c){const d=r<o&&a<l;if(d&&r===e&&a===i&&o===e+s&&l===i+n)return;const u=new Path2D;u.rect(e,i,s,n),d&&u.rect(r,a,o-r,l-a),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,i,s,n),t.restore()}genericComposeSMask(t,e,i,s,n,r){const{context:a,offsetX:o,offsetY:l}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const c=new Path2D;c.rect(n,r,i,s),e.clip(c),e.globalCompositeOperation="destination-in",e.drawImage(a.canvas,n-o,r-l,i,s,n,r,i,s),e.restore()}save(t){this.inSMaskMode&&qt(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(qt(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,i,s,n,r,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,n,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[n]=i;if(!s){n||=i[0]=new Path2D,e!==Lt.stroke&&e!==Lt.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,n);return}if(this.dependencyTracker!==null){const a=e===Lt.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-a,s[2]+a,s[1]-a,s[3]+a).recordDependencies(t,["transform"])}n instanceof Path2D||(n=i[0]=Ar(n)),k.axialAlignedBoundingBox(s,q(this.ctx),this.current.minMax);const r=this.current.tilingPatternDims;if(r&&e!==Lt.stroke&&e!==Lt.closeStroke&&this.current.fillColor instanceof Ne){const a=k.intersect(this.current.clipBox,this.current.minMax);a?this.current.fillColor.updatePatternDims(a,r):this.current.tilingPatternDims=null}this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){const s=i&&this.#p(this.current.strokeAlpha),n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&r?.getPattern){const a=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,Pt(n),lt.STROKE,t),a){const o=new Path2D;o.addPath(e,n.getTransform().invertSelf().multiplySelf(a)),e=o}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,St.stroke),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(lt.STROKE,q(this.ctx))),n.globalAlpha=this.current.fillAlpha,this.#b(s)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){const s=i&&this.#p(this.current.fillAlpha),n=this.ctx,r=this.current.fillColor,a=this.current.patternFill;let o=!1;const l=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,St.fill),a){const c=this.current.tilingPatternDims,d=c&&r.canSkipPatternCanvas(c);if(d){r.drawPattern(this,e,this.pendingEOFill,d,t),this.pendingEOFill=!1,i&&this.consumePath(t,e,l),this.current.tilingPatternDims=null,this.#b(s);return}const u=r.isModifyingCurrentTransform()?n.getTransform():null;if(this.dependencyTracker?.save(t),n.save(),n.fillStyle=r.getPattern(n,this,Pt(n),lt.FILL,t),u){const f=new Path2D;f.addPath(e,n.getTransform().invertSelf().multiplySelf(u)),e=f}o=!0}this.contentVisible&&l!==null&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),o&&(n.restore(
45),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,l),this.#b(s)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const i=this.#p(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),this.#b(i)}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){const i=this.#p(this.current.fillAlpha);this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,St.rawFillPath).recordOperation(t),this.#b(i)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Lo}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=xn}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:s}=this;e!==void 0&&s.recordFutureForcedDependency("textClip",s.getOpenMarker()).recordFutureForcedDependency("textClip",t),s.recordCloseMarker(t)}if(e!==void 0){const s=new Path2D,n=i.getTransform().invertSelf();for(const{transform:r,x:a,y:o,fontSize:l,path:c}of e)c&&s.addPath(c,new DOMMatrix(r).preMultiplySelf(n).translate(a,o).scale(l,-l));i.clip(s)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const s=this.commonObjs.get(e),n=this.current;if(!s)throw new Error(`Can't find font for ${e}`);if(n.fontMatrix=s.fontMatrix||es,(n.fontMatrix[0]===0||n.fontMatrix[3]===0)&&$("Invalid font matrix for font "+e),i<0?(i=-i,n.fontDirection=-1):n.fontDirection=1,this.current.font=s,this.current.fontSize=i,s.isType3Font)return;const r=s.loadedName||"sans-serif",a=s.systemFontInfo?.css||`"${r}", ${s.fallbackName}`;let o="normal";s.black?o="900":s.bold&&(o="bold");const l=s.italic?"italic":"normal",c=Q(i,Po,To);this.current.fontSizeScale=i/c,this.ctx.font=`${l} ${o} ${c}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#y(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n,r){const a=this.ctx,o=this.current,l=o.font,c=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,u=c&rt.FILL_STROKE_MASK,f=!!(c&rt.ADD_TO_PATH_FLAG),p=o.patternFill&&!l.missingFile,g=o.patternStroke&&!l.missingFile;let m;if((l.disableFontFace||f||p||g)&&!l.missingFile&&(m=l.getPathGenerator(this.commonObjs,e)),m&&(l.disableFontFace||p||g)){a.save(),a.translate(i,s),a.scale(d,-d),this.dependencyTracker?.recordCharacterBBox(t,a,l);let b;if(u===rt.FILL||u===rt.FILL_STROKE)if(n){b=a.getTransform(),a.setTransform(...n);const y=this.#y(m,b,n);a.fill(y)}else a.fill(m);if(u===rt.STROKE||u===rt.FILL_STROKE)if(r){b||=a.getTransform(),a.setTransform(...r);const{a:y,b:w,c:A,d:v}=b,E=k.inverseTransform(r),_=k.transform([y,w,A,v,0,0],E);k.singularValueDecompose2dScale(_,At),a.lineWidth*=Math.max(At[0],At[1])/d,a.stroke(this.#y(m,b,r))}else a.lineWidth/=d,a.stroke(m);
45a.restore()}else(u===rt.FILL||u===rt.FILL_STROKE)&&(a.fillText(e,i,s),this.dependencyTracker?.recordCharacterBBox(t,a,l,d,i,s,()=>a.measureText(e))),(u===rt.STROKE||u===rt.FILL_STROKE)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,a,l,d,i,s,()=>a.measureText(e)).recordDependencies(t,St.stroke),a.strokeText(e,i,s));f&&((this.pendingTextPaths||=[]).push({transform:q(a),x:i,y:s,fontSize:d,path:m}),this.dependencyTracker?.recordCharacterBBox(t,a,l,d,i,s))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const i=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let s=!1;for(let n=3;n<i.length;n+=4)if(i[n]>0&&i[n]<255){s=!0;break}return F(this,"isFontSubpixelAAEnabled",s)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,St.showText).resetBBox(t),this.current.textRenderingMode&rt.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const i=this.current,s=i.font;if(s.isType3Font){const M=this.#p(i.fillAlpha);this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t),this.#b(M);return}const n=i.fontSize;if(n===0){this.dependencyTracker?.recordOperation(t);return}const r=this.#p(i.fillAlpha),a=this.ctx,o=i.fontSizeScale,l=i.charSpacing,c=i.wordSpacing,d=i.fontDirection,u=i.textHScale*d,f=e.length,p=s.vertical,g=p?1:-1,m=s.defaultVMetrics,b=n*i.fontMatrix[0],y=i.textRenderingMode===rt.FILL&&!s.disableFontFace&&!i.patternFill;a.save(),i.textMatrix&&a.transform(...i.textMatrix),a.translate(i.x,i.y+i.textRise),d>0?a.scale(u,-1):a.scale(u,1);let w,A;const v=i.textRenderingMode&rt.FILL_STROKE_MASK,E=v===rt.FILL||v===rt.FILL_STROKE,_=v===rt.STROKE||v===rt.FILL_STROKE;let C=i.lineWidth;const S=i.textMatrixScale;if(S===0||C===0?_&&(C=this.getSinglePixelWidth()):C/=S,o!==1&&(a.scale(o,o),C/=o),a.lineWidth=C,E&&i.patternFill){a.save();const M=i.fillColor.getPattern(a,this,Pt(a),lt.FILL,t);w=q(a),a.restore(),a.fillStyle=M}if(_&&i.patternStroke){a.save();const M=i.strokeColor.getPattern(a,this,Pt(a),lt.STROKE,t);A=q(a),a.restore(),a.strokeStyle=M}if(s.isInvalidPDFjsFont){const M=[];let L=0;for(const U of e)M.push(U.unicode),L+=U.width;const D=M.join("");if(a.fillText(D,0,0),this.dependencyTracker!==null){const U=a.measureText(D);this.dependencyTracker.recordBBox(t,this.ctx,-U.actualBoundingBoxLeft,U.actualBoundingBoxRight,-U.actualBoundingBoxAscent,U.actualBoundingBoxDescent).recordShowTextOperation(t)}
45i.x+=L*b*u,a.restore(),this.compose(),this.#b(r);return}let P=0,T;for(T=0;T<f;++T){const M=e[T];if(typeof M=="number"){P+=g*M*n/1e3;continue}let L=!1;const D=(M.isSpace?c:0)+l,U=M.fontChar,R=M.accent;let O,ht,ct=M.width;if(p){const K=M.vmetric||m,Z=-(M.vmetric?K[1]:ct*.5)*b,Xt=K[2]*b;ct=K?-K[0]:ct,O=Z/o,ht=(P+Xt)/o}else O=P/o,ht=0;let Ot;if(s.remeasure&&ct>0){Ot=a.measureText(U);const K=Ot.width*1e3/n*o;if(ct<K&&this.isFontSubpixelAAEnabled){const Z=ct/K;L=!0,a.save(),a.scale(Z,1),O/=Z}else ct!==K&&(O+=(ct-K)/2e3*n/o)}if(this.contentVisible&&(M.isInFont||s.missingFile)){if(y&&!R)a.fillText(U,O,ht),this.dependencyTracker?.recordCharacterBBox(t,a,Ot?{bbox:null}:s,n/o,O,ht,()=>Ot??a.measureText(U));else if(this.paintChar(t,U,O,ht,w,A),R){const K=O+n*R.offset.x/o,Z=ht-n*R.offset.y/o;this.paintChar(t,R.fontChar,K,Z,w,A)}}const le=p?ct*b-D*d:ct*b+D*d;P+=le,L&&a.restore()}p?i.y-=P:i.x+=P*u,a.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t),this.#b(r)}showType3Text(t,e){const i=this.ctx,s=this.current,n=s.font,r=s.fontSize,a=s.fontDirection,o=n.vertical?1:-1,l=s.charSpacing,c=s.wordSpacing,d=s.textHScale*a,u=s.fontMatrix||es,f=e.length,p=s.textRenderingMode===rt.INVISIBLE;let g,m,b,y;if(p||r===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),s.textMatrix&&i.transform(...s.textMatrix),i.translate(s.x,s.y+s.textRise),i.scale(d,a);const w=this.dependencyTracker;for(this.dependencyTracker=w?new $e(w,t):null,g=0;g<f;++g){if(m=e[g],typeof m=="number"){y=o*m*r/1e3,this.ctx.translate(y,0),s.x+=y*d;continue}const A=(m.isSpace?c:0)+l,v=n.charProcOperatorList.get(m.operatorListId);v?this.contentVisible&&(this.save(),v.fnArray[0]===Lt.setCharWidth&&(s.fillAlpha=s.strokeAlpha=1,i.globalAlpha=1),i.scale(r,r),i.transform(...u),this.executeOperatorList(v),this.restore()):$(`Type3 character "${m.operatorListId}" is not available.`);const E=[m.width,0];k.applyTransform(E,u),b=E[0]*r+A,i.translate(b,0),s.x+=b*d}i.restore(),w&&(this.dependencyTracker=w)}setCharWidth(t,e,i){}
vendor: 1,194 bytes, line 45
45setCharWidthAndBounds(t,e,i,s,n,r,a){const o=new Path2D;o.rect(s,n,r-s,a-n),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,s,r,n,a).recordClipBox(t,this.ctx,s,r,n,a),this.endPath(t)}getColorN_Pattern(t,e){let i;if(e[0]==="TilingPattern"){const s=this.baseTransform||q(this.ctx),n={createCanvasGraphics:(r,a)=>new se(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new $e(this.dependencyTracker,a,!0):null)};i=new Ne(e,this.ctx,n,s)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);const i=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=i instanceof Ne?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
45setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,i=null){const s=this.cachedPatterns.getOrInsertComputed(e,()=>Co(this.getObject(t,e)));return i&&(s.matrix=i),s}shadingFill(t,e){if(!this.contentVisible)return;const i=this.#p(this.current.fillAlpha),s=this.ctx;this.save(t);const n=this._getPattern(t,e);s.fillStyle=n.getPattern(s,this,Pt(s),lt.SHADING,t);const r=Pt(s);if(r){const{width:a,height:o}=s.canvas,l=ee.slice();k.axialAlignedBoundingBox([0,0,a,o],r,l);const[c,d,u,f]=l;this.ctx.fillRect(c,d,u-c,f-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,St.transform).recordDependencies(t,St.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),this.#b(i)}beginInlineImage(){W("Should not call beginInlineImage")}beginImageData(){W("Should not call beginImageData")}
45paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=q(this.ctx),i)){k.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[s,n,r,a]=i,o=new Path2D;o.rect(s,n,r-s,a-n),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,s,r,n,a),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t);const{inSMaskMode:i}=this;i&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&this.#e===0&&s.globalAlpha===1&&s.globalCompositeOperation==="source-over"&&!i){if(e.bbox){let A=new Path2D;const[v,E,_,C]=e.bbox;if(A.rect(v,E,_-v,C-E),e.matrix){const S=new Path2D;S.addPath(A,new DOMMatrix(e.matrix)),A=S}s.clip(A)}this.groupStack.push(null),this.#u.push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&this.#e===0&&Si("TODO: Fully support non-isolated non-knockout groups.");const n=q(s);e.matrix&&s.transform(...e.matrix);const r=[0,0,s.canvas.width,s.canvas.height];let a;e.bbox?(a=ee.slice(),k.axialAlignedBoundingBox(e.bbox,q(s),a),a=k.intersect(a,r)||[0,0,0,0]):a=r;const o=Math.floor(a[0]),l=Math.floor(a[1]),c=Math.max(Math.ceil(a[2])-o,1),d=Math.max(Math.ceil(a[3])-l,1);this.current.startNewPathAndClipBox([0,0,c,d]);const u=this.canvasFactory.create(c,d);e.smask&&this.smaskGroupCanvases.push(u);const f=u.context,p=e.knockout&&!e.isolated?s:null,g=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#e>0,m=e.knockout?this.canvasFactory.create(c,d):null,b=this.#e;e.knockout?this.#e++:this.#e=0,f.translate(-o,-l),f.transform(...n);const y=!e.isolated&&!e.smask&&e.needsIsolation,w=y&&!i&&b===0&&!e.knockout&&!e.isGray&&e.hasSoftMask&&s.globalAlpha===1&&s.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none";if(y&&(i||w)&&(f.save(),f.setTransform(1,0,0,1,0,0),f.drawImage(s.canvas,-o,-l),f.restore()),e.bbox){let A=new Path2D;const[v,E,_,C]=e.bbox;if(A.rect(v,E,_-v,C-E),e.matrix){const S=new Path2D;S.addPath(A,new DOMMatrix(e.matrix)),A=S}f.clip(A)}e.smask&&this.smaskStack.push({canvas:u.canvas,context:f,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(s.setTransform(1,0,0,1,0,0),s.translate(o,l),s.save()),qt(s,f),this.ctx=f,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(s),this.#u.push({backdropCtx:p,savedKnockoutLevel:b,offsetX:o,offsetY:l,hasInnerBackdrop:g,replaceBackdrop:w,knockoutMaskEntry:m,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,s=this.groupStack.pop(),n=this.#u.pop();if(n&&(this.#e=n.savedKnockoutLevel),s===null){this.restore(t);return}if(e.isGray&&this.#w(i),this.ctx=s,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),this.#v(n);else{this.ctx.restore();const r=q(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...r);const a=ee.slice();k.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],r,a);const o=this.#u.at(-1);if(this.#e>0)if(n.hasInnerBackdrop){const{width:l,height:c}=i.canvas,d=this.canvasFactory.create(l,c),u=d.context;u.drawImage(s.canvas,n.offsetX,n.offsetY,l,c,0,0,l,c),u.globalCompositeOperation="source-over",u.drawImage(i.canvas,0,0);const f=this.#g(i.canvas);u.globalCompositeOperation="destination-in",u.drawImage(f.canvas,0,0);const p=this.ctx.globalCompositeOperation,g=this.ctx.globalAlpha,m=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...r),this.ctx.globalAlpha=1,Y.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(f.canvas,0,0),this.ctx.globalCompositeOperation=p,this.ctx.globalAlpha=g,Y.isCanvasFilterSupported&&(this.ctx.filter=m??"none"),this.ctx.drawImage(d.canvas,0,0),this.ctx.restore(
45),this.canvasFactory.destroy(f),this.canvasFactory.destroy(d)}else{const l=o?.backdropCtx??null;this.#c(this.ctx,i.canvas,{backdropCanvas:l?.canvas??null,destTransform:r,backdropOffset:l?[o.offsetX+n.offsetX,o.offsetY+n.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(n.replaceBackdrop){const l=new Path2D;l.rect(0,0,i.canvas.width,i.canvas.height),this.ctx.clip(l),this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(i.canvas,0,0)}this.ctx.restore(),this.canvasFactory.destroy({canvas:i.canvas,context:i}),this.#v(n),this.compose(a)}}#w(t){const{canvas:e}=t,{width:i,height:s}=e;if(Y.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 n=t.getImageData(0,0,i,s),{data:r}=n;for(let a=0,o=r.length;a<o;a+=4){const l=r[a]*.2126+r[a+1]*.7152+r[a+2]*.0722+.5|0;r[a]=r[a+1]=r[a+2]=l}t.putImageData(n,0,0)}#v(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))}beginAnnotation(t,e,i,s,n,r,a){if(this.#d(),Je(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const o=i[2]-i[0],l=i[3]-i[1];if(r&&this.annotationCanvasMap){s=s.slice(),s[4]-=i[0],s[5]-=i[1],k.singularValueDecompose2dScale(q(this.ctx),At);const{viewportScale:c}=this,d=Math.ceil(o*this.outputScaleX*c),u=Math.ceil(l*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:f,context:p}=this.annotationCanvas;if(a){const g=this.annotationCanvasMap.getOrInsertComputed(e,_e);f.setAttribute("data-canvas-name",a);const m=g.findIndex(b=>b.getAttribute("data-canvas-name")===a);m===-1?g.push(f):g[m]=f}else this.annotationCanvasMap.set(e,f);this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(At[0],0,0,-At[1],0,l*At[1]),Je(this.ctx)}else{Je(this.ctx),this.endPath(t);const c=new Path2D;c.rect(i[0],i[1],o,l),this.ctx.clip(c)}}this.current=new vn(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...s),this.transform(t,...n),this.baseTransform=q(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#f(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;const i=e.count;e=this.getObject(t,e.data,e),e.count=i;const s=this.#p(this.current.fillAlpha),n=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),n.restore(),r.canvasEntry&&this.canvasFactory.destroy(r.canvasEntry),this.compose(),this.#b(s)}paintImageMaskXObjectRepeat(t,e,i,s=0,n=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const o=this.#p(this.current.fillAlpha),l=this.ctx;l.save();const c=q(l);l.transform(i,s,n,r,0,0);const d=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,d.offsetX-c[4],d.offsetY-c[5]),this.dependencyTracker?.resetBBox(t);for(let u=0,f=a.length;u<f;u+=2){const p=k.transform(c,[i,s,n,r,a[u],a[u+1]]);l.drawImage(d.canvas,p[4],p[5]),this.dependencyTracker?.recordBBox(t,this.ctx,p[4],p[4]+d.canvas.width,p[5],p[5]+d.canvas.height)}l.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(t),this.#b(o)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.#p(this.current.fillAlpha),s=this.ctx,n=this.current.fillColor,r=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,St.transformAndFill);for(const a of e){const{data:o,width:l,height:c,transform:d}=a,u=this.canvasFactory.create(l,c),f=u.context;f.save();const p=this.getObject(t,o,a);En(f,p),f.globalCompositeOperation="source-in",f.fillStyle=r?n.getPattern(f,this,Pt(s),lt.FILL,t):n,f.fillRect(0,0,l,c),f.restore(
45),s.save(),s.transform(...d),s.scale(1,-1),Ze(s,u.canvas,0,0,l,c,0,-1,1,1),this.canvasFactory.destroy(u),this.dependencyTracker?.recordBBox(t,s,0,l,0,c),s.restore()}this.compose(),this.dependencyTracker?.recordOperation(t),this.#b(i)}paintImageXObject(t,e){if(!this.contentVisible)return;const i=this.getObject(t,e);if(!i){$("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,i)}paintImageXObjectRepeat(t,e,i,s,n){if(!this.contentVisible)return;const r=this.getObject(t,e);if(!r){$("Dependent image isn't ready yet");return}const a=r.width,o=r.height,l=[];for(let c=0,d=n.length;c<d;c+=2)l.push({transform:[i,0,0,s,n[c],n[c+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return{img:t.bitmap,canvasEntry:null};const{bitmap:e,width:i,height:s}=t,n=this.canvasFactory.create(i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",{img:n.canvas,canvasEntry:n}}paintInlineImageXObject(t,e){if(!this.contentVisible)return;const i=e.width,s=e.height,n=this.#p(this.current.fillAlpha),r=this.ctx;this.save(t);const{filter:a}=r;a!=="none"&&a!==""&&(r.filter="none"),r.scale(1/i,-1/s);let o,l=null;if(e.bitmap){const d=this.applyTransferMapsToBitmap(e);o=d.img,l=d.canvasEntry}else{const d=this.canvasFactory.create(i,s);An(d.context,e),o=this.applyTransferMapsToCanvas(d.context),l=d}const c=this._scaleImage(o,Pt(r));r.imageSmoothingEnabled=Sn(q(r),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,r,0,i,-s,0).recordDependencies(t,St.imageXObject).recordOperation(t),this.imagesTracker?.record(r,i,s,this.dependencyTracker.clipBox)),Ze(r,c.img,0,0,c.paintWidth,c.paintHeight,0,-s,i,s),c.tmpCanvas&&this.canvasFactory.destroy(c.tmpCanvas),l&&this.canvasFactory.destroy(l),this.compose(),this.restore(t),this.#b(n)}paintInlineImageXObjectGroup(t,e,i){if(!this.contentVisible)return;const s=this.#p(this.current.fillAlpha),n=this.ctx;let r,a=null;if(e.bitmap)r=e.bitmap;else{const o=e.width,l=e.height,c=this.canvasFactory.create(o,l);An(c.context,e),r=this.applyTransferMapsToCanvas(c.context),a=c}this.dependencyTracker?.resetBBox(t);for(const o of i)n.save(),n.transform(...o.transform),n.scale(1,-1),Ze(n,r,o.x,o.y,o.w,o.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();a&&this.canvasFactory.destroy(a),this.dependencyTracker?.recordOperation(t),this.compose(),this.#b(s)}paintSolidColorImageMask(t){if(!this.contentVisible)return;const e=this.#p(this.current.fillAlpha);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,St.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),this.#b(e)}markPoint(t,e){}
45markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){const s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const n=this.ctx;this.pendingClip?(s||(this.pendingClip===xn?n.clip(e,"evenodd"):n.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=q(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]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,a;if(i===0&&s===0){const o=Math.abs(e),l=Math.abs(n);if(o===l)if(t===0)r=a=1/o;else{const c=o*t;r=a=c<1?1/c:1}else if(t===0)r=1/o,a=1/l;else{const c=o*t,d=l*t;r=c<1?1/c:1,a=d<1?1/d:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),c=Math.hypot(s,n);if(t===0)r=c/o,a=l/o;else{const d=t*o;r=c>d?c/d:1,a=l>d?l/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:s}}=this,[n,r]=this.getScaleForStroking();if(n===r){i.lineWidth=(s||1)*n,i.stroke(t);return}const a=se.#t??=new DOMMatrix,o=i.getLineDash();e&&i.save(),i.scale(n,r),a.a=1/n,a.d=1/r;const l=new Path2D;if(l.addPath(t,a),o.length>0){const c=Math.max(n,r);i.setLineDash(o.map(d=>d/c)),i.lineDashOffset/=c}i.lineWidth=s||1,i.stroke(l),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const h in Lt)se.prototype[h]!==void 0&&(se.prototype[Lt[h]]=se.prototype[h]);class Pi{#t=null;#e=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,i){this._source=t,this.#t=e,this.#e=i}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return et(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#t(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new this.#e(this,t,e);return this._rangeReaders.add(i),i}cancelAllRequests(t){this._fullReader?.cancel(t);for(const e of new Set(this._rangeReaders))e.cancel(t)}}class Ti{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({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(){W("Abstract method `read` called")}cancel(t){W("Abstract method `cancel` called")}}class ki{_stream=null;constructor(t,e,i){this._stream=t}async read(){W("Abstract method `read` called")}cancel(t){W("Abstract method `cancel` called")}}function Do(h){let t=!0,e=i("filename\\*","i").exec(h);if(e){e=e[1];let c=a(e);return c=unescape(c),c=o(c),c=l(c),n(c)}if(e=r(h),e){const c=l(e);return n(c)}if(e=i("filename","i").exec(h),e){e=e[1];let c=a(e);return c=l(c),n(c)}function i(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function s(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(c,{fatal:!0}),f=xi(d);d=u.decode(f),t=!1}catch{}}return d}function n(c){return t&&/[\x80-\xff]/.test(c)&&(c=s("utf-8",c),t&&(c=s("iso-8859-1",c))),c}function r(c){const d=[];let u;const f=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=f.exec(c))!==null;){let[,g,m,b]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[m,b]}const p=[];for(let g=0;g<d.length&&g in d;++g){let[m,b]=d[g];b=a(b),m&&(b=unescape(b),g===0&&(b=o(b))),p.push(b)}return p.join("")}function a(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let u=0;u<d.length;++u){const f=d[u].indexOf('"');f!==-1&&(d[u]=d[u].slice(0,f),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function o(c){const d=c.indexOf("'");if(d===-1)return c;const u=c.slice(0,d),p=c.slice(d+1).replace(/^[^']*'/,"");return s(u,p)}function l(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,u,f,p){if(f==="q"||f==="Q")return p=p.replaceAll("_"," "),p=p.replaceAll(/=([0-9a-f]{2})/gi,function(g,m){return String.fromCharCode(parseInt(m,16))}),s(u,p);try{p=atob(p)}catch{}return s(u,p)})}return""}function kr(h,t){const e=new Headers;if(!h||!t||typeof t!="object")return e;for(const i in t){const s=t[i];s!==void 0&&e.append(i,s)}return e}function Ro(h){let t=h.length;for(;t>0&&h[t-1]!==" "&&/\s/.test(h[t-1]);)t--;return h.slice(0,t)}function Mi(h){return URL.parse(h)?.origin??null}function Mr({responseHeaders:h,isHttp:t,rangeChunkSize:e,disableRange:i}){const s={contentLength:0,isRangeSupported:!1},n=parseInt(h.get("Content-Length"),10);return!Number.isInteger(n)||(s.contentLength=n,n<=2*e)||i||!t||h.get("Accept-Ranges")!=="bytes"||(h.get("Content-Encoding")||"identity")==="identity"&&(s.isRangeSupported=!0),s}function Ir(h){const t=h.get("Content-Disposition");if(t){let e=Do(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ls(e))return e}return null}
45function Ii(h,t){return new fi(`Unexpected server response (${h}) while retrieving PDF "${t.href}".`,h,h===404||h===0&&t.protocol==="file:")}function Lr(h,t){if(h!==t)throw new Error(`Expected range response-origin "${h}" to match "${t}".`)}function Dr(h,t,e,i){return fetch(h,{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function Rr(h,t){if(h!==200&&h!==206)throw Ii(h,t)}function Li(h){if(h instanceof Uint8Array)return h.buffer;if(h instanceof ArrayBuffer)return h;throw new Error(`getArrayBuffer - unexpected data: ${h}`)}class No extends Pi{_responseOrigin=null;constructor(t){super(t,Oo,Fo);const{httpHeaders:e,url:i}=t;et(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=kr(!0,e)}}class Oo extends Ti{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,rangeChunkSize:s,url:n,withCredentials:r}=t._source;this._isStreamingSupported=!i;const a=new Headers(t.headers);Dr(n,a,r,this._abortController).then(o=>{t._responseOrigin=Mi(o.url),Rr(o.status,n),this._reader=o.body.getReader();const l=o.headers,{contentLength:c,isRangeSupported:d}=Mr({responseHeaders:l,isHttp:!0,rangeChunkSize:s,disableRange:e});this._contentLength=c,this._isRangeSupported=d,this._filename=Ir(l),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new zt("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:Li(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Fo extends ki{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:s,withCredentials:n}=t._source,r=new Headers(t.headers);r.append("Range",`bytes=${e}-${i-1}`),Dr(s,r,n,this._abortController).then(a=>{const o=Mi(a.url);Lr(o,t._responseOrigin),Rr(a.status,s),this._reader=a.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:Li(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function _n(h){return h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength?h.buffer:new Uint8Array(h).buffer}function Di(){for(const h of this._requests)h.resolve({value:void 0,done:!0});this._requests.length=0}class Bo extends Pi{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,jo,$o);const{pdfDataRangeTransport:e}=t,{initialData:i,progressiveDone:s}=e;if(i?.length>0){const r=_n(i);this._queuedChunks.push(r)}this._progressiveDone=s;const n=r=>{switch(r.type){case"range":case"progressiveRead":this.#t(r.begin,r.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0;break}};e.transportReady(n)}#t(t,e){const i=_n(e);if(t===void 0)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const s=this._rangeReaders.keys().find(n=>n._begin===t);et(s,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),s._enqueue(i)}}getFullReader(){const t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){const i=super.getRangeReader(t,e);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(t,e)),i}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class jo extends Ti{#t=Di.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:e,disableRange:i,disableStream:s}=t._source,{length:n,contentDispositionFilename:r}=e;this._queuedChunks=t._queuedChunks||[];for(const o of this._queuedChunks)this._loaded+=o.byteLength;this._done=t._progressiveDone,this._contentLength=n,this._isStreamingSupported=!s,this._isRangeSupported=!i,Ls(r)&&(this._filename=r),this._headersCapability.resolve();const a=this._loaded;Promise.resolve().then(()=>{a>0&&this._loaded===a&&this._callOnProgress()})}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.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 t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t()}progressiveDone(){this._done||=!0,this._queuedChunks.length===0&&this.#t()}}class $o extends ki{#t=Di.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,i){super(t,e,i),this._begin=e}_enqueue(t){this._done||(this._requests.length===0?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),this.#t()),this._done=!0,this.onDone?.())}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this.onDone?.()}}const Gi=200,Cn=206;function Uo(h){return typeof h!="string"?h:xi(h).buffer}class Vo extends Pi{#t=new WeakMap;_responseOrigin=null;constructor(t){super(t,Ho,zo);const{httpHeaders:e,url:i}=t;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=kr(this.isHttp,e)}_request(t){const e=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#t.set(e,i),e.open("GET",this.url),e.withCredentials=this._source.withCredentials;for(const[s,n]of this.headers)e.setRequestHeader(s,n);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.validateStatus=s=>s===Cn||s===Gi):i.validateStatus=s=>s===Gi,e.responseType="arraybuffer",et(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#i.bind(this,e),e.onprogress=this.#e.bind(this,e),e.send(null),e}#e(t,e){this.#t.get(t)?.onProgress?.(e)}#i(t,e){const i=this.#t.get(t);if(!i||(t.readyState>
45=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),t.readyState!==4)||!this.#t.has(t))return;if(this.#t.delete(t),t.status===0&&this.isHttp){i.onError(t.status);return}const s=t.status||Gi;if(!i.validateStatus(s)){i.onError(t.status);return}const n=Uo(t.response);if(s===Cn){const r=t.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(r)?i.onDone(n):($('Missing or invalid "Content-Range" header.'),i.onError(0))}else n?i.onDone(n):i.onError(t.status)}_abortRequest(t){this.#t.has(t)&&(this.#t.delete(t),t.abort())}getRangeReader(t,e){const i=super.getRangeReader(t,e);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}class Ho extends Ti{#t=Di.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t),this._fullRequestXhr=t._request({onHeadersReceived:this.#e.bind(this),onDone:this.#i.bind(this),onError:this.#s.bind(this),onProgress:this.#n.bind(this)})}#e(){const t=this._stream,{disableRange:e,rangeChunkSize:i}=t._source,s=this._fullRequestXhr;t._responseOrigin=Mi(s.responseURL);const n=s.getAllResponseHeaders(),r=new Headers(n?Ro(n.trimStart()).split(/[\r\n]+/).map(l=>{const[c,...d]=l.split(": ");return[c,d.join(": ")]}):[]),{contentLength:a,isRangeSupported:o}=Mr({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:i,disableRange:e});this._contentLength=a,this._isRangeSupported=o,this._filename=Ir(r),this._isRangeSupported&&t._abortRequest(s),this._headersCapability.resolve()}#i(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,this._cachedChunks.length===0&&this.#t()}#s(t){this._storedError=Ii(t,this._stream.url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#n(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}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 t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#t(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class zo extends ki{#t=Di.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,i){super(t,e,i),this._requestXhr=t._request({begin:e,end:i,onHeadersReceived:this.#e.bind(this),onDone:this.#i.bind(this),onError:this.#s.bind(this),onProgress:null})}#e(){const t=Mi(this._requestXhr?.responseURL);try{Lr(t,this._stream._responseOrigin)}catch(e){this._storedError=e,this.#s(0)}}#i(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this.#t(),this.onClosed?.()}#s(t){this._storedError??=Ii(t,this._stream.url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function Nr(h,t=null){const e=process.getBuiltinModule("fs"),{Readable:i}=process.getBuiltinModule("stream"),s=e.createReadStream(h,t);return i.toWeb(s)}class Wo extends Pi{constructor(t){super(t,Go,Xo);const{url:e}=t;et(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class Go extends Ti{_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,rangeChunkSize:s,url:n}=t._source;this._isStreamingSupported=!i,process.getBuiltinModule("fs/promises").lstat(n).then(a=>{const o=Nr(n);this._reader=o.getReader();const{size:l}=a;this._contentLength=l,this._isRangeSupported=!e&&l>2*s,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new zt("Streaming is disabled.")),this._headersCapability.resolve()}).catch(a=>{a.code==="ENOENT"&&(a=Ii(0,n)),this._headersCapability.reject(a)})}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:Li(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class Xo extends ki{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:s}=t._source;try{const n=Nr(s,{start:e,end:i-1});this._reader=n.getReader(),this._readCapability.resolve()}catch(n){this._readCapability.reject(n)}}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:Li(t),done:!1}}cancel(t){this._reader?.cancel(t)}}function Yo(h){return De(h)?No:wt?Wo:Vo}let ye=class{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}};class qo{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}[Symbol.iterator](){return this.#t.entries()}}const Qt=Symbol("INTERNAL");class Ko{#t=!1;#e=!1;#i=!1;#s=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#t=!!(t&yt.DISPLAY),this.#e=!!(t&yt.PRINT),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#i)return this.#s;if(!this.#s)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,i=!1){t!==Qt&&W("Internal method `_setVisible` called."),this.#i=i,this.#s=e}get serializable(){return{userSet:this.#i,visible:this.#s}}}class Fs{#t=null;#e=new Map;#i=null;#s=null;#n;creator=null;name=null;constructor(t,e=yt.DISPLAY,i=null){if(this.#n=t,this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,this.#s=t.order;
45for(const s of t.groups)this.#e.set(s.id,new Ko(e,s));if(i){i.size!==this.#e.size&&W("Incorrect serialized groupState.");for(const[s,n]of i)this.#e.get(s)._setVisible(Qt,n.visible,n.userSet)}else{if(t.baseState==="OFF")for(const s of this.#e.values())s._setVisible(Qt,!1);for(const s of t.on)this.#e.get(s)._setVisible(Qt,!0);for(const s of t.off)this.#e.get(s)._setVisible(Qt,!1)}this.#i=this.getHash()}}#r(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const n=t[s];let r;if(Array.isArray(n))r=this.#r(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return $(`Optional content group not found: ${n}`),!0;switch(i){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return i==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Si("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:($(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#r(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return $(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return $(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return $(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return $(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return $(`Unknown optional content policy ${t.policy}.`),!0}return $(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#e.get(t);if(!s){$(`Optional content group not found: ${t}`);return}if(i&&e&&s.rbGroups.length)for(const n of s.rbGroups)for(const r of n)r!==t&&this.#e.get(r)?._setVisible(Qt,!1,!0);s._setVisible(Qt,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const n=this.#e.get(s);if(n)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!n.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#i===null||this.getHash()===this.#i}getOrder(){return this.#e.size?this.#s?this.#s.slice():[...this.#e.keys()]:null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new us;for(const[e,i]of this.#e)t.update(`${e}:${i.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}get serializable(){const t=new Map;for(const[e,i]of this.#e)t.set(e,i.serializable);return{data:this.#n,renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:i}){return new Fs(t,e,i)}}class Qo{#t=null;#e=null;#i=0;#s=null;#n=null;get pagesNumber(){return this.#i}set pagesNumber(t){this.#i!==t&&(this.#i=t,this.#t=null,this.#e=null)}#r(){if(this.#t)return;const t=this.#i,e=this.#t=new Uint32Array(t);for(let i=0;i<t;i++)e[i]=i+1;this.#e=new Int32Array(e)}#a(){const t=new Map,e=this.#t;for(let i=0,s=this.#i;i<s;i++){const n=e[i],r=t.get(n);r?r.push(i+1):t.set(n,[i+1])}return t}movePages(t,e,i){this.#r();const s=this.#t,n=e.length,r=new Uint32Array(n);let a=0;for(let u=0;u<n;u++){const f=e[u]-1;r[u]=s[f],f<i&&a++}const o=this.#i,l=o-n,c=new Int32Array(o),d=Q(i-a,0,l);for(let u=0,f=0;u<o;u++)t.has(u+1)||(s[f]=s[u],c[f++]=u+1);s.copyWithin(d+n,d,l),s.set(r,d),c.copyWithin(d+n,d,l),c.set(e,d),this.#e=c,s.every((u,f)=>u===f+1)&&(this.#t=null)}deletePages(t){this.#r();const e=this.#t,i=this.#a();this.#n={pageNumberToId:e.slice(),pagesNumber:this.#i,prevPageNumbers:this.#e.slice()};const s=this.#i-t.length;this.#i=s;const n=this.#t=new Uint32Array(s);this.#e=new Int32Array(s);let r=0,a=0;for(const o of t){const l=o-1;l!==r&&(n.set(e.subarray(r,l),a),a+=l-r),r=l+1}r<e.length&&n.set(e.subarray(r),a),this.#o(i,new Set(t))}cancelDelete(){this.#n&&(this.#t=this.#n.pageNumberToId,this.#i=this.#n.pagesNumber,this.#e=this.#n.prevPageNumbers,this.#n=null)}cleanSavedData(){this.#n=null}copyPages(t){this.#r(),this.#s={pageNumbers:t,pageIds:t.map(e=>this.#t[e-1])}}cancelCopy(){this.#s=null}pastePages(t){this.#r();const e=this.#t,i=this.#a(),{pageNumbers:s,pageIds:n}=this.#s,r=this.#i+s.length;this.#i=r;const a=this.#t=new Uint32Array(r);this.#e=new Int32Array(r),a.set(e.subarray(0,t),0),a.set(n,t),a.set(e.subarray(t),t+s.length),this.#o(i,null,t,s),this.#s=null}#o(t,e=null,i=-1,s=null){const n=this.#e,r=this.#t,a=i+(s?.length??0),o=new Map;for(let l=0,c=this.#i;l<c;l++){if(l>=i&&l<a){n[l]=-s[l-i];continue}const d=r[l],u=t.get(d);let f=o.get(d)||0;if(e&&u)for(;f<u.length&&e.has(u[f]);)f++;n[l]=u?.[f],o.set(d,f+1)}}hasBeenAltered(){return this.#t!==null}#l(t=null){if(!this.#t)return null;const e=new Int32Array(this.#i).fill(-1),i=new Map;
45if(t)for(const s of t){const n=this.getPageId(s),r=i.get(n)??0;i.set(n,r+1),e[s-1]=r}else for(let s=0,n=this.#i;s<n;s++){const r=this.#t[s],a=i.get(r)??0;i.set(r,a+1),e[s]=a}return e}getPageMappingForSaving(t=null,e=this.#l()){t??=this.#a();let i=0;for(const n of t.values())i=Math.max(i,n.length);const s=new Array(i);for(let n=0;n<i;n++)s[n]={document:null,pageIndices:[],includePages:[]};for(const[n,r]of t)for(let a=0,o=r.length;a<o;a++)s[a].includePages.push([n-1,r[a]-1]);for(const{includePages:n,pageIndices:r}of s){n.sort((a,o)=>a[0]-o[0]);for(let a=0,o=n.length;a<o;a++)r.push(n[a][1]),n[a]=n[a][0]}return{pageInfos:s,copyLevels:e}}extractPages(t){t=Array.from(t).sort((i,s)=>i-s);const e=new Map;for(let i=0,s=t.length;i<s;i++){const n=this.getPageId(t[i]);e.getOrInsertComputed(n,_e).push(i+1)}return this.getPageMappingForSaving(e,this.#l(t))}getPrevPageNumber(t){return this.#e?.[t-1]??0}getPageNumber(t){if(!this.#t)return t;const e=this.#t;for(let i=0,s=this.#i;i<s;i++)if(e[i]===t)return i+1;return 0}getPageId(t){return this.#t?.[t-1]??t}getMapping(){return this.#t?.subarray(0,this.pagesNumber)}}const fe=Symbol("INITIAL_DATA"),Pn=()=>({...Promise.withResolvers(),data:fe});class Or{#t=new Map;get(t,e=null){if(e){const s=this.#t.getOrInsertComputed(t,Pn);return s.promise.then(()=>e(s.data)),null}const i=this.#t.get(t);if(!i||i.data===fe)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#t.get(t);return!!e&&e.data!==fe}delete(t){const e=this.#t.get(t);return!e||e.data===fe?!1:(this.#t.delete(t),!0)}resolve(t,e=null){const i=this.#t.getOrInsertComputed(t,Pn);if(i.data!==fe)throw new Error(`Object already resolved ${t}.`);i.data=e,i.resolve()}clear(){for(const{data:t}of this.#t.values())t?.bitmap?.close();this.#t.clear()}*[Symbol.iterator](){for(const[t,{data:e}]of this.#t)e!==fe&&(yield[t,e])}}const Zo=1e5,Tn=30;let mi=class kt{#t=Promise.withResolvers();#e=null;#i=!1;#s=!!globalThis.FontInspector?.enabled;#n=null;#r=null;#a=null;#o=0;#l=0;#h=null;#u=null;#d=0;#f=0;#g=Object.create(null);#m=[];#c=null;#p=[];#b=new WeakMap;#y=null;static#w=new Map;static#v=new Map;static#E=new WeakMap;static#A=null;static#x=new Set;constructor({textContentSource:t,images:e,container:i,viewport:s}){if(t instanceof ReadableStream)this.#c=t;else if(typeof t=="object")this.#c=new ReadableStream({start(l){l.enqueue(t),l.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#u=i,this.#n=e,this.#f=s.scale*Wt.pixelRatio,this.#d=s.rotation,this.#a={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=s.rawDims;this.#y=[1,0,0,-1,-a,o+r],this.#l=n,this.#o=r,kt.#M(),i.style.setProperty("--min-font-size",kt.#A),ne(i,s),this.#t.promise.finally(()=>{kt.#x.delete(this),this.#a=null,this.#g=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Y.platform;return F(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){this.#n&&this.#e.append(this.#n.render());const t=()=>{this.#h.read().then(({value:e,done:i})=>{if(i){this.#t.resolve();return}this.#r??=e.lang,Object.assign(this.#g,e.styles),this.#S(e.items),t()},this.#t.reject)};return this.#h=this.#c.getReader(),kt.#x.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*Wt.pixelRatio,s=t.rotation;if(s!==this.#d&&(e?.(),this.#d=s,ne(this.#u,{rotation:s})),i!==this.#f){e?.(),this.#f=i;const n={div:null,properties:null,ctx:kt.#P(this.#r)};for(const r of this.#p)n.properties=this.#b.get(r),n.div=r,this.#k(n)}}cancel(){const t=new zt("TextLayer task cancelled.");this.#h?.cancel(t).catch(()=>{}),this.#h=null,this.#t.reject(t)}get textDivs(){return this.#p}get textContentItemsStr(){return this.#m}#S(t){if(this.#i)return;this.#a.ctx??=kt.#P(this.#r);const e=this.#p,i=this.#m;for(const s of t){if(e.length>Zo){$("Ignoring additional textDivs for performance reasons."),this.#i=!0;return}if(s.str===void 0){if(s.type==="beginMarkedContentProps"||s.type==="beginMarkedContent"){const n=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),s.id&&this.#e.setAttribute("id",s.id),s.tag==="Artifact"&&(this.#e.ariaHidden=!0),n.append(this.#e)}else s.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}i.push(s.str),this.#T(s)}}#T(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#p.push(e);const s=k.transform(this.#y,t.transform);let n=Math.atan2(s[1],s[0]);const r=this.#g[t.fontName];r.vertical&&(n+=Math.PI/2);let a=this.#s&&r.fontSubstitution||r.fontFamily;a=kt.fontFamilyMap.get(a)||a;const o=Math.hypot(s[2],s[3]),l=o*kt.#D(a,r,this.#r);let c,d;n===0?(c=s[4],d=s[5]-l):(c=s[4]+l*Math.sin(n),d=s[5]-l*Math.cos(n));const u=e.style;u.left=`${(100*c/this.#l).toFixed(2)}%`,u.top=`${(100*d/this.#o).toFixed(2)}%`,u.setProperty("--font-height",`${o.toFixed(2)}px`),u.fontFamily=a,i.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#s&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(i.angle=n*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const p=Math.abs(t.transform[0]),g=Math.abs(t.transform[3]);p!==g&&Math.max(p,g)/Math.min(p,g)>1.5&&(f=!0)}if(f&&(i.canvasWidth=r.vertical?t.height:t.width),this.#b.set(e,i),this.#a.div=e,this.#a.properties=i,this.#k(this.#a),i.hasText&&this.#e.append(e),i.hasEOL){const p=document.createElement("br");p.setAttribute("role","presentation"),this.#e.append(p)}}#k(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;if(i.canvasWidth!==0&&i.hasText){const{fontFamily:r}=n,{canvasWidth:a,fontSize:o}=i;kt.#I(s,o*this.#f,r);const{width:l}=s.measureText(e.textContent);l>0&&n.setProperty("--scale-x",a*this.#f/l)}i.angle!==0&&n.setProperty("--rotate",`${i.angle}deg`)}static cleanup(){if(!(this.#x.size>0)){this.#w.clear();for(const{canvas:t}of this.#v.values())t.remove();this.#v.clear()}}static#P(t=null){let e=this.#v.get(t||="");if(!e){const i=document.createElement("canvas");i.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}
45),this.#v.set(t,e),this.#E.set(e,{size:0,family:""})}return e}static#I(t,e,i){const s=this.#E.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#M(){if(this.#A!==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),this.#A=t.getBoundingClientRect().height,t.remove()}static#D(t,e,i){const s=this.#w.get(t);if(s)return s;const n=this.#P(i);n.canvas.width=n.canvas.height=Tn,this.#I(n,Tn,t);const r=n.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return a?l=a/(a+o):(Y.platform.isFirefox&&$("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#w.set(t,l),l}};const Jo=100;function Fr(h={}){const t=new Bs,{docId:e}=t,i=h.url?so(h.url):null,s=h.data?no(h.data):null,n=h.httpHeaders||null,r=h.withCredentials===!0,a=h.password??null,o=h.range instanceof Br?h.range:null,l=Number.isInteger(h.rangeChunkSize)&&h.rangeChunkSize>0?h.rangeChunkSize:2**16;let c=h.worker instanceof gs?h.worker:null;const d=h.verbosity,u=typeof h.docBaseUrl=="string"&&!_i(h.docBaseUrl)?h.docBaseUrl:null,f=Ke(h.cMapUrl),p=h.cMapPacked!==!1,g=Ke(h.iccUrl),m=Ke(h.standardFontDataUrl),b=Ke(h.wasmUrl),y=h.stopAtErrors!==!0,w=Number.isInteger(h.maxImageSize)&&h.maxImageSize>-1?h.maxImageSize:-1,A=typeof h.isOffscreenCanvasSupported=="boolean"?h.isOffscreenCanvasSupported:!wt,v=typeof h.isImageDecoderSupported=="boolean"?h.isImageDecoderSupported:!wt,E=Number.isInteger(h.canvasMaxAreaInBytes)?h.canvasMaxAreaInBytes:-1,_=typeof h.disableFontFace=="boolean"?h.disableFontFace:wt,C=h.fontExtraProperties===!0,S=h.enableXfa===!0,P=h.ownerDocument||globalThis.document,T=h.disableRange===!0,M=h.disableStream===!0,L=h.disableAutoFetch===!0,D=h.pdfBug===!0,U=h.CanvasFactory||(wt?fo:lo),R=h.FilterFactory||(wt?uo:ho),O=h.BinaryDataFactory||(wt?po:mn),ht=h.enableHWA===!0,Ot=h.enableWebGPU===!0?yo():Promise.resolve(!1),le=h.useWasm!==!1,K=h.pagesMapper||new Qo,Z=typeof h.useSystemFonts=="boolean"?h.useSystemFonts:!wt&&!_,Xt=typeof h.useWorkerFetch=="boolean"?h.useWorkerFetch:!!(O===mn&&f&&p&&m&&b&&De(f,document.baseURI)&&De(m,document.baseURI)&&De(b,document.baseURI)),Bi=null;va(d);const he={canvasFactory:new U({ownerDocument:P,enableHWA:ht}),filterFactory:new R({docId:e,ownerDocument:P}),binaryDataFactory:Xt?null:new O({cMapUrl:f,standardFontDataUrl:m,wasmUrl:b})};c||(c=gs.create({verbosity:d,port:ye.workerPort}),t._worker=c);const nt={docId:e,apiVersion:"6.3.289",data:s,password:a,disableAutoFetch:L,rangeChunkSize:l,docBaseUrl:u,enableXfa:S,evaluatorOptions:{maxImageSize:w,disableFontFace:_,ignoreErrors:y,isOffscreenCanvasSupported:A,isImageDecoderSupported:v,canvasMaxAreaInBytes:E,fontExtraProperties:C,useSystemFonts:Z,useWasm:le,useWorkerFetch:Xt,cMapUrl:f,cMapPacked:p,iccUrl:g,standardFontDataUrl:m,wasmUrl:b,hasGPU:!1}},fa={ownerDocument:P,pdfBug:D,styleElement:Bi,enableHWA:ht,loadingParams:{disableAutoFetch:L,enableXfa:S}};return Promise.all([c.promise,Ot]).then(function([,pa]){if(c.destroyed)throw new Error("Worker was destroyed");nt.evaluatorOptions.hasGPU=pa;const ga=c.messageHandler.sendWithPromise("GetDocRequest",nt,s?[s.buffer]:null);let ji;if(!s)if(o)ji=new Bo({pdfDataRangeTransport:o,disableRange:T,disableStream:M});else if(i){const $i=Yo(i);ji=new $i({url:i,httpHeaders:n,withCredentials:r,rangeChunkSize:l,disableRange:T,disableStream:M})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return ga.then($i=>{if(c.destroyed)throw new Error("Worker was destroyed");const Js=new Ie(e,$i,c.port),ma=new el(Js,t,ji,fa,he,K);if(t._transport=ma,t.destroyed)throw new Error("Loading aborted");Js.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}class Bs{static#t=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${Bs.#t++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}let Br=class{#t=Promise.withResolvers();#e=null;constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}onDataRange(t,e){this.#e({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#t.promise.then(()=>{this.#e({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#t.promise.then(()=>{this.#e({type:"progressiveDone"})})}transportReady(t){this.#e=t,this.#t.resolve()}requestDataRange(t,e){W("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class tl{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 F(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}
vendor: 2,412 bytes, line 45
45=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()}}class js{#t=!1;#e=null;constructor(t,e,i,s,n=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=n?new en:null,this._pdfBug=n,this.commonObjs=i.commonObjs,this.objs=new Or,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#e=s,this.imageCoordinates=null}clone(t){const e=new js(t,this._pageInfo,this._transport,this.#e,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:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new We({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}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 F(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}
45render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:n=Ht.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:u=!1,recordImages:f=!1,recordOperations:p=!1,operationsFilter:g=null}){this._stats?.time("Overall");const m=this._transport.getRenderingIntent(s,n,d,u),{renderingIntent:b,cacheKey:y}=m;this.#t=!1,o||=this._transport.getOptionalContentConfig(b);const w=this._intentStates.getOrInsertComputed(y,rs);w.streamReaderCancelTimeout&&(clearTimeout(w.streamReaderCancelTimeout),w.streamReaderCancelTimeout=null);const A=!!(b&yt.PRINT);w.displayReadyCapability||(w.displayReadyCapability=Promise.withResolvers(),w.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(m));const v=!!(this._pdfBug&&globalThis.StepperManager?.enabled),E=!!e&&!this.recordedBBoxes&&(p||v),_=!!e&&!this.imageCoordinates&&f,C=L=>{if(w.renderTasks.delete(T),E){const D=T.gfx?.dependencyTracker.take();D&&(T.stepper?.setOperatorBBoxes(D,T.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=D))}_&&!L&&(this.imageCoordinates=T.gfx?.imagesTracker.take()),A&&(this.#t=!0),this.#i(),L?(T.capability.reject(L),this._abortOperatorList({intentState:w,reason:L instanceof Error?L:new Error(L)})):T.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let S=null,P=null;(E||_)&&(P=new Wa(e,w.operatorList.length)),E&&(S=new Ga(P,v));const T=new be({callback:C,params:{canvas:e,canvasContext:t,dependencyTracker:S??P,imagesTracker:_?new pi(e):null,viewport:i,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:w.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!A,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:g});(w.renderTasks||=new Set).add(T);const M=T.task;return Promise.all([w.displayReadyCapability.promise,o]).then(([L,D])=>{if(this.destroyed){C();return}if(this._stats?.time("Rendering"),!(D.renderingIntent&b))throw new Error("Mu
45st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");T.initializeGraphics({transparency:L,optionalContentConfig:D}),T.operatorListChanged()}).catch(C),M}getOperatorList({intent:t="display",annotationMode:e=Ht.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){function n(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o))}const r=this._transport.getRenderingIntent(t,e,i,s,!0),a=this._intentStates.getOrInsertComputed(r.cacheKey,rs);let o;return a.opListReadCapability||(o=Object.create(null),o.operatorListChanged=n,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(s){return s.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Fe.textContent(s));const e=this.streamTextContent(t),i={items:[],styles:Object.create(null),lang:null};for await(const s of e)i.lang??=s.lang,Object.assign(i.styles,s.styles),i.items.push(...s.items);return i}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 i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;const e=this.#i();return t&&e&&(this._stats&&=new en),e}#i(){if(!this.#t||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(),this.#t=!1,!0}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const i of e.renderTasks)i.operatorListChanged();t.lastChunk&&this.#i()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},void 0,r).getReader(),l=this._intentStates.get(e);l.streamReader=o;const c=()=>{o.read().then(({value:d,done:u})=>{if(u){l.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,l),c())},d=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const u of l.renderTasks)u.operatorListChanged();this.#i()}if(l.displayReadyCapability)l.displayReadyCapability.reject(d);else if(l.opListReadCapability)l.opListReadCapability.reject(d);else throw d}})};c()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof Is){let s=Jo;e.extraDelay>0&&e.extraDelay<1e3&&(s+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},s);return}}if(t.streamReader.cancel(new zt(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[s,n]of this._intentStates)if(n===t){this._intentStates.delete(s);break}this.cleanup()}}}get stats(){return this._stats}}let gs=class pt{#t=Promise.withResolvers();#e=null;#i=null;#s=null;static#n=0;static#r=!1;static#a=new WeakMap;static{wt&&(this.#r=!0,ye.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||i.origin==="null")return!1;const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:i=Aa()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(pt.#a.has(e))throw new Error("Cannot use more than one PDFWorker per port.");pt.#a.set(e,this),this.#l(e)}else this.#h()}get promise(){return this.#t.promise}#o(){this.#t.resolve(),this.#e.send("configure",{verbosity:this.verbosity})}get port(){return this.#i}get messageHandler(){return this.#e}#l(t){this.#i=t,this.#e=new Ie("main","worker",t),this.#e.on("ready",()=>{}),this.#o()}#h(){if(pt.#r||pt.#d){this.#u();return}let{workerSrc:t}=pt;try{pt._isSameOrigin(window.location,t)||(t=pt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new Ie("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this.#t.reject(new Error("Worker was destroyed")):this.#u()},n=new AbortController;e.addEventListener("error",()=>{this.#s||s()},{signal:n.signal}),i.on("test",a=>{if(n.abort(),this.destroyed||!a){s();return}this.#e=i,this.#i=e,this.#s=e,this.#o()}),i.on("ready",a=>{if(n.abort(),this.destroyed){s();return}try{r()}catch{this.#u()}});const r=()=>{const a=new Uint8Array;i.send("test",a,[a.buffer])};r();return}catch{Si("The worker has been disabled.")}this.#u()}#u(){pt.#r||($("Setting up fake worker."),pt.#r=!0),pt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this.#t.reject(new Error("Worker was destroyed"));return}const e=new oo;this.#i=e;const i=`fake${pt.#n++}`,s=new Ie(i+"_worker",i,e);t.setup(s,e),this.#e=new Ie(i,i+"_worker",e),this.#o()}).catch(t=>{this.#t.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#s?.terminate(),this.#s=null,pt.#a.delete(this.#i),this.#i=null,this.#e?.destroy(),this.#e=null}static create(t){const e=this.#a.get(t?.port);
45if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new pt(t)}static get workerSrc(){if(ye.workerSrc)return ye.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#d(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return F(this,"_setupFakeWorkerGlobal",(async()=>this.#d?this.#d:(await import(this.workerSrc)).WorkerMessageHandler)())}};class el{downloadInfoCapability=Promise.withResolvers();#t=null;#e=new Map;#i=null;#s=new Map;#n=new Map;#r=new Map;#a=null;constructor(t,e,i,s,n,r){this.messageHandler=t,this.loadingTask=e,this.#i=i,this.commonObjs=new Or,this.fontLoader=new Ya({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.enableHWA=s.enableHWA,this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.binaryDataFactory=n.binaryDataFactory,this.pagesMapper=r,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:e}=t;this.#s.set(e,t),this.#n.set(e,Promise.resolve(t))}#o(t,e=null){return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#l({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?Q(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return F(this,"annotationStorage",new Ns)}getRenderingIntent(t,e=Ht.ENABLE,i=null,s=!1,n=!1){let r=yt.DISPLAY,a=je;switch(t){case"any":r=yt.ANY;break;case"display":break;case"print":r=yt.PRINT;break;default:$(`getRenderingIntent - invalid intent: ${t}`)}const o=r&yt.PRINT&&i instanceof xr?i:this.annotationStorage;switch(e){case Ht.DISABLE:r+=yt.ANNOTATIONS_DISABLE;break;case Ht.ENABLE:break;case Ht.ENABLE_FORMS:r+=yt.ANNOTATIONS_FORMS;break;case Ht.ENABLE_STORAGE:r+=yt.ANNOTATIONS_STORAGE,a=o.serializable;break;default:$(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=yt.IS_EDITING),n&&(r+=yt.OPLIST);const{ids:l,hash:c}=o.modifiedIds,d=[r,a.hash,c];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#a?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of this.#s.values())t.push(i._destroy());this.#s.clear(),this.#n.clear(),this.#r.clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),mi.cleanup(),this.#i?.cancelAllRequests(new zt("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(i,s)=>{et(this.#i,"GetReader - no `BasePDFStream` instance available."),this.#t=this.#i.getFullReader(),this.#t.onProgress=n=>this.#l(n),s.onPull=()=>{this.#t.read().then(function({value:n,done:r}){if(r){s.close();return}et(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{s.error(n)})},s.onCancel=n=>{this.#t.cancel(n),s.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",async i=>{await this.#t.headersReady;const{isStreamingSupported:s,isRangeSupported:n,contentLength:r}=this.#t;return s&&n&&(this.#t.onProgress=null),{isStreamingSupported:s,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(i,s)=>{et(this.#i,"GetRangeReader - no `BasePDFStream` instance available.");const n=this.#i.getRangeReader(i.begin,i.end);if(!n){s.close();return}s.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){s.close();return}et(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{s.error(r)})},s.onCancel=r=>{n.cancel(r),s.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:i})=>{this.pagesMapper.pagesNumber=i.numPages,this._numPages=i.numPages,this._htmlForXfa=i.htmlForXfa,delete i.htmlForXfa,e._capability.resolve(new tl(i,this))}),t.on("DocException",i=>{e._capability.reject(gt(i))}),t.on("PasswordRequest",i=>{this.#a=Promise.withResolvers();try{if(!e.onPassword)throw gt(i);const s=n=>{n instanceof Error?this.#a.reject(n):this.#a.resolve({password:n})};e.onPassword(s,i.code)}catch(s){this.#a.reject(s)}return this.#a.promise}),t.on("DataLoaded",i=>{this.#l({loaded:i.length,total:i.length}),this.downloadInfoCapability.resolve(i)}),t.on("StartRenderPage",i=>{if(this.destroyed)return;this.#s.get(i.pageIndex)._startRenderPage(i.transparency,i.cacheKey)}),t.on("commonobj",([i,s,n])=>{if(this.destroyed||this.commonObjs.has(i))return null;switch(s){case"Font":if("error"in n){const d=n.error;$(`Error during font loading: ${d}`),this.commonObjs.resolve(i,d);break}const r=new to(n),a=this._params.pdfBug&&globalThis.FontInspector?.enabled?(d,u)=>globalThis.FontInspector.fontAdded(d,u):null,o=new qa(r,a,n.charProcOperatorList,n.extra);this.fontLoader.bind(o).catch(()=>
45t.sendWithPromise("FontFallback",{id:i})).finally(()=>{o.fontExtraProperties||o.clearData(),this.commonObjs.resolve(i,o)});break;case"CopyLocalImage":const{imageRef:l}=n;et(l,"The imageRef must be defined.");for(const d of this.#s.values())for(const[,u]of d.objs){if(u?.ref!==l)continue;if(!u.dataLen)return null;const f=structuredClone(u);return this.commonObjs.resolve(i,f),u.dataLen}break;case"FontPath":this.commonObjs.resolve(i,new io(n));break;case"Image":this.commonObjs.resolve(i,n);break;case"Pattern":const c=new eo(n);this.commonObjs.resolve(i,c.getIR());break;default:throw new Error(`Got unknown common object type ${s}`)}return null}),t.on("obj",([i,s,n,r])=>{if(this.destroyed)return;const a=this.#s.get(s);if(!a.objs.has(i)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":case"Pattern":a.objs.resolve(i,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",i=>{this.destroyed||this.#l(i)}),t.on("FetchBinaryData",async i=>{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(i)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&$("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:this.#t?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t,e=null){const i={pageInfos:t};let s;const n=globalThis.ImageBitmap;if(typeof n=="function"){const r=Array.isArray(t)?t:[t];for(const a of r)a?.image instanceof n&&(s||=[]).push(a.image)}if(this.annotationStorage.size>0){const r=this.annotationStorage.serializable;let{map:a}=r;r.transfer?.length&&(s?s.push(...r.transfer):s=r.transfer);const o=this.pagesMapper.getMapping();if(o){const l=new Map;for(const[c,d]of a){if(d?.pageIndex!==void 0&&d.pageIndex>=0&&d.pageIndex<o.length){const u=e?.[d.pageIndex]??0,f=o[d.pageIndex]-1;if(f!==d.pageIndex||u!==0){l.set(c,{...d,pageIndex:f,copyLevel:u});continue}}l.set(c,d)}a=l}i.annotationStorage=a}return this.messageHandler.sendWithPromise("ExtractPages",i,s).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.pagesMapper.getPageId(t)-1,s=this.#n.get(e);if(s)return s;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&this.#r.set(r.refStr,i);const a=new js(e,r,this,this.pagesMapper,this._params.pdfBug);return this.#s.set(e,a),a});return this.#n.set(e,n),n}async getPageIndex(t){if(!ps(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),i=this.pagesMapper.getPageNumber(e+1);if(i===0)throw new Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#o("GetFieldObjects")}getSignatures(){return this.#o("GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return this.#o("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)}
45getPageLayout(){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 this.#o("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 this.#o("GetOptionalContentConfig").then(e=>new Fs(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>({info:e[0],metadata:e[1]?new qo(e[1]):null,contentDispositionFilename:this.#t?.filename??null,contentLength:this.#t?.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 this.#s.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(!0),mi.cleanup()}}cachedPageNumber(t){if(!ps(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,i=this.#r.get(e);if(i>=0){const s=this.pagesMapper.getPageNumber(i+1);if(s!==0)return s}return null}}class il{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){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?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class be{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null,enableHWA:f=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,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 il(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=f,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(be.#e.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.");be.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:i,transform:s,background:n,dependencyTracker:r,imagesTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new se(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r,a),this.gfx.beginDrawing({transform:s,viewport:i,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),be.#e.delete(this._canvas),t||=new Is(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.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?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}
45):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),be.#e.delete(this._canvas),this.callback())))}}const sl="6.3.289",nl="1c8020a7d";let jr=class Mt{#t=null;#e=null;#i;#s=null;#n=!1;#r=!1;#a=null;#o;#l=null;#h=null;static#u=null;static get _keyboardManager(){return F(this,"_keyboardManager",new vt([[["Escape"],Mt.prototype._hideDropdownFromKeyboard],[["Space"],Mt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],Mt.prototype._moveToNext],[["ArrowUp","ArrowLeft"],Mt.prototype._moveToPrevious],[["Home"],Mt.prototype._moveToBeginning],[["End"],Mt.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#r=!1,this.#a=t):this.#r=!0,this.#h=t?._uiManager||e,this.#o=this.#h._eventBus,this.#i=t?.color?.toUpperCase()||this.#h?.highlightColors.values().next().value||"#FFFF98",Mt.#u||=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"})}renderButton(){const t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#a&&(t.ariaControls=`${this.#a.id}_colorpicker_dropdown`);const e=this.#h._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#g.bind(this),{signal:e});const i=this.#e=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#i,t.append(i),t}renderMainDropdown(){const t=this.#s=this.#d();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#d(){const t=document.createElement("div"),e=this.#h._signal;t.addEventListener("contextmenu",Ct,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#a&&(t.id=`${this.#a.id}_colorpicker_dropdown`);for(const[i,s]of this.#h.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",Mt.#u[i]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.ariaSelected=s===this.#i,n.addEventListener("click",this.#f.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#g.bind(this),{signal:e}),t}#f(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:z.HIGHLIGHT_COLOR,value:t}),this.update(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}const e=t.target.getAttribute("data-color");e&&this.#f(e,t)}_moveToNext(t){if(!this.#p){this.#m(t);return}if(t.target===this.#t){this.#s.firstElementChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#s?.firstElementChild||t.target===this.#t){this.#p&&this._hideDropdownFromKeyboard();return}this.#p||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#p){this.#m(t);return}this.#s.firstElementChild?.focus()}_moveToEnd(t){if(!this.#p){this.#m(t);return}this.#s.lastElementChild?.focus()}#g(t){Mt._keyboardManager.exec(this,t)}#m(t){if(this.#p){this.hideDropdown();return}if(this.#n=t.detail===0,this.#l||(this.#l=new AbortController,window.addEventListener("pointerdown",this.#c.bind(this),{signal:this.#h.combinedSignal(this.#l)})),this.#t.ariaExpanded="true",this.#s){this.#s.classList.remove("hidden");return}const e=this.#s=this.#d();this.#t.append(e)}#c(t){this.#s?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#l?.abort(),this.#l=null}get#p(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#r){if(!this.#p){this.#a?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#n})}}update(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#s)return;const e=this.#h.highlightColors.values();for(const i of this.#s.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#s?.remove(),this.#s=null}};class Ue{#t=null;#e=!1;#i=null;#s=null;static#n=null;constructor(t){this.#i=t,this.#s=t._uiManager,Ue.#n||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;const{editorType:t,colorType:e,colorAndOpacityType:i,opacityType:s,color:n,opacity:r}=this.#i,a=this.#e=Y.isAlphaColorInputSupported&&s!==void 0,o=this.#t=document.createElement("input");if(o.type="color",a){o.setAttribute("alpha","");const l=k.hexNums[Math.round((r??1)*255)];o.value=(n||"#000000")+l}else o.value=n||"#000000";return o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",Ue.#n[t]),o.addEventListener("input",()=>{if(a){const l=Ge(o.value);if(!l)return;const[c,d,u,f]=l,p=k.makeHexColor(c,d,u);i!==void 0?this.#s.updateParams(i,{color:p,opacity:f}):(this.#s.updateParams(e,p),this.#s.updateParams(s,f))}else this.#s.updateParams(e,o.value)},{signal:this.#s._signal}),o}update(t){if(this.#t)if(this.#e){const e=k.hexNums[Math.round(this.#i.opacity*255)];this.#t.value=t+e}else this.#t.value=t}updateOpacity(t){if(!this.#t||!this.#e)return;const e=k.hexNums[Math.round(t*255)];this.#t.value=this.#i.color+e}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}}
45function kn(h){return Math.floor(Q(h,0,1)*255).toString(16).padStart(2,"0")}function Pe(h){return Q(h,0,1)*255}class Mn{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}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=Pe(t),[t,t,t]}static G_HTML([t]){const e=kn(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Pe)}static RGB_HTML(t){return`#${t.map(kn).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[Pe(1-Math.min(1,t+s)),Pe(1-Math.min(1,i+s)),Pe(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i,a=Math.min(s,n,r);return["CMYK",s,n,r,a]}}class rl{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){W("Abstract method `_createSVG` called.")}}let bi=class extends rl{_createSVG(t){return document.createElementNS(ut,t)}};const al=9,re=new WeakSet,ol=new Date().getTimezoneOffset()*60*1e3;class Xi{static create(t){switch(t.data.annotationType){case tt.LINK:return new $s(t);case tt.TEXT:return new hl(t);case tt.WIDGET:switch(t.data.fieldType){case"Tx":return new cl(t);case"Btn":return t.data.radioButton?new fl(t):t.data.checkBox?new ul(t):new pl(t);case"Ch":return new gl(t);case"Sig":return new dl(t)}return new oe(t);case tt.POPUP:return new ms(t);case tt.FREETEXT:return new $r(t);case tt.LINE:return new bl(t);case tt.SQUARE:return new yl(t);case tt.CIRCLE:return new wl(t);case tt.POLYLINE:return new Ur(t);case tt.CARET:return new Al(t);case tt.INK:return new Us(t);case tt.POLYGON:return new vl(t);case tt.HIGHLIGHT:return new Vr(t);case tt.UNDERLINE:return new El(t);case tt.SQUIGGLY:return new Sl(t);case tt.STRIKEOUT:return new xl(t);case tt.STAMP:return new Hr(t);case tt.FILEATTACHMENT:return new _l(t);case tt.RICHMEDIA:case tt.SCREEN:case tt.SOUND:return new zr(t);default:return new J(t)}}}class J{#t=null;#e=!1;#i=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){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(i)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return J._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}
45get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:i,rect:s}=this.data;let n=-1/0,r=-1/0;if(e?.length>=8){for(let a=0;a<e.length;a+=8)e[a+1]>r?(r=e[a+1],n=e[a+2]):e[a+1]===r&&(n=Math.max(n,e[a+2]));return[n,r]}if(i?.length>=1){for(const a of i)for(let o=0,l=a.length;o<l;o+=2)a[o+1]>r?(r=a[o+1],n=a[o]):a[o+1]===r&&(n=Math.max(n,a[o]));if(n!==1/0)return[n,r]}return s?[s[2],s[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/i,t[1]=100*(t[1]-r)/s,t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${Ee}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${Ee}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#i?.popup||this.popup)?.remove(),this.#i=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#t||={rect:this.data.rect.slice(0)});const{rect:e,popup:i}=t;e&&this.#s(e);let s=this.#i?.popup||this.popup;!s&&i?.text&&(this._createPopup(i),s=this.#i.popup),s&&(s.updateEdited(t),i?.deleted&&(s.remove(),this.#i=null,this.popup=null))}resetEdited(){this.#t&&(this.#s(this.#t.rect),this.#i?.popup.resetEdited(),this.#t=null)}#s(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,s===0?(e.width=`${100*(t[2]-t[0])/n}%`,e.height=`${100*(t[3]-t[1])/r}%`):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),!(this instanceof oe)&&!(this instanceof $s)&&!(this instanceof zr)&&(n.tabIndex=0);const{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof ms){const{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,n),n}const{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const g=e.borderStyle.horizontalCornerRadius,m=e.borderStyle.verticalCornerRadius;if(g>0||m>0){const y=`calc(${g}px * var(--total-scale-factor)) / calc(${m}px * var(--total-scale-factor))`;r.borderRadius=y}switch(e.borderStyle.style){case ue.SOLID:r.borderStyle="solid";break;case ue.DASHED:r.borderStyle="dashed";break;case ue.BEVELED:$("Unimplemented border style: beveled");break;case ue.INSET:$("Unimplemented border style: inset");break;case ue.UNDERLINE:r.borderBottomStyle="solid";break}const b=e.borderColor||null;b?(this.#e=!0,r.borderColor=k.makeHexColor(...b)):r.borderWidth=0}const l=k.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:f}=s.rawDims;r.left=`${100*(l[0]-u)/c}%`,r.top=`${100*(l[1]-f)/d}%`;const{rotation:p}=e;return e.hasOwnCanvas||p===0?(r.width=`${100*a/c}%`,r.height=`${100*o/d}%`):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims;let{width:n,height:r}=this;t%180!==0&&([n,r]=[r,n]),e.style.width=`${100*n/i}%`,e.style.height=`${100*r/s}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,i,s)=>{const n=s.detail[e],r=n[0],a=n.slice(1);s.target.style[i]=Mn[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[i]:Mn[`${r}_rgb`](a)})};return F(this,"_commonActions",{display:e=>{const{display:i}=e.detail,s=i%2===1;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:i===1||i===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:i}=e.detail;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:i,noView:i})},focus:e=>{setTimeout(()=>
45e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const i=e.detail.rotation;this.setRotation(i),this.annotationStorage.setValue(this.data.id,{rotation:i})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail))(t[s]||i[s])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];if(r){const a={detail:{[s]:n},target:t};r(a),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map(Math.fround);if(t.length===8){const[g,m,b,y]=t.subarray(2,6);if(s===g&&n===m&&e===b&&i===y)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:g,borderWidth:m}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",`<svg xmlns="${ut}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${g}" stroke-width="${m}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{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 f=c.createElement("clipPath"),p=`clippath_${this.data.id}`;f.setAttribute("id",p),f.setAttribute("clipPathUnits","objectBoundingBox"),u.append(f);for(let g=2,m=t.length;g<m;g+=8){const b=t[g],y=t[g+1],w=t[g+2],A=t[g+3],v=c.createElement("rect"),E=(w-e)/o,_=(n-y)/l,C=(b-w)/o,S=(y-A)/l;v.setAttribute("x",E),v.setAttribute("y",_),v.setAttribute("width",C),v.setAttribute("height",S),f.append(v),a?.push(`<rect vector-effect="non-scaling-stroke" x="${E}" y="${_}" width="${C}" height="${S}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){const{data:e}=this;let i,s;t?(i={str:t.text},s=t.date):(i=e.contentsObj,s=e.modificationDate),this.#i=new ms({data:{color:e.color,titleObj:e.titleObj,modificationDate:s,contentsObj:i,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!!(this.#i||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#i}render(){W("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects.get(t)||[];for(const{page:n,id:r,exportValues:a}of s){if(n===-1||r===e)continue;const o=typeof a=="string"?a:null,l=document.querySelector(`[data-element-id="${r}"]`);if(l&&!re.has(l)){$(`_getElementsByName - element not allowed: ${r}`);continue}i.push({id:r,exportValue:o,domElement:l})}return i}for(const s of document.getElementsByName(t)){const{exportValue:n}=s,r=s.getAttribute("data-element-id");r!==e&&re.has(s)&&i.push({id:r,exportValue:n,domElement:s})}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.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",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;t.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}
45_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":k.makeHexColor(...e)}}class ll extends J{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class $s extends J{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),s=!0):t.attachment?(this.#e(i,t.attachmentId,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(this.#i(i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),s=!0):(t.actions&&(t.actions.has("Action")||t.actions.has("Mouse Up")||t.actions.has("Mouse Down"))&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&(this.contentElement=i,this.container.append(i)),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#t()}#e(t,e,i,s="",n=null){t.href=this.linkService.getAnchorUrl(""),i.description?t.title=i.description:s&&(t.title=s);const r=async()=>{const a=await this.linkService.getAttachmentContent(e);a&&this.downloadManager?.openOrDownloadData(a,i.filename,n)};t.onclick=()=>(r(),!1),this.#t()}#i(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#t()}_bindJSAction(t,{actions:e,id:i,overlaidText:s}){t.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of e.keys()){const a=n.get(r);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:r}}),!1))}s&&(t.title=s),t.onclick||=()=>!1,this.#t()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){$('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();const{fields:s,refs:n,include:r}=e,a=[];if(s.length!==0||n.length!==0){const c=new Set(n);for(const d of s){const u=this._fieldObjects.get(d)||[];for(const{id:f}of u)c.add(f)}for(const d of this._fieldObjects.values())for(const u of d)c.has(u.id)===r&&a.push(u)}else for(const c of this._fieldObjects.values())a.push(...c);const o=this.annotationStorage,l=[];for(const c of a){const{id:d}=c;switch(l.push(d),c.type){case"text":{const f=c.defaultValue||"";o.setValue(d,{value:f});break}case"checkbox":case"radiobutton":{const f=c.defaultValue===c.exportValues;o.setValue(d,{value:f});break}case"combobox":case"listbox":{const f=c.defaultValue||"";o.setValue(d,{value:f});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!re.has(u)){$(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}}),!1}}}class hl extends J{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}
45class oe extends J{render(){return this.container}_getKeyModifier(t){return Y.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(i,r=>{if(i==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(i==="focus"){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(r)}})})}_setEventListeners(t,e,i,s){const{actions:n}=this.data;for(const[r,a]of i)(a==="Action"||n?.has(a))&&((a==="Focus"||a==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,r,a,s),a==="Focus"&&!n?.has("Blur")?this._setEventListener(t,e,"blur","Blur",null):a==="Blur"&&!n?.has("Focus")&&this._setEventListener(t,e,"focus","Focus",null))}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||al,n=t.style;let r;const a=2,o=l=>Math.round(10*l)/10;if(this.data.multiLine){const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a),c=Math.round(l/(1.35*s))||1,d=l/c;r=Math.min(s,o(d/1.35))}else{const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(s,o(l/1.35))}n.fontSize=`calc(${r}px * var(--total-scale-factor))`,n.color=k.makeHexColor(...i),this.data.textAlignment!==null&&!this.data.comb&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class cl extends oe{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;
45for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join(` 46`)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),t.has(e)&&this.container.classList.add("sandboxModified")),re.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;const{datetimeFormat:l,datetimeType:c,timeStep:d}=this.data,u=!!c&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",p=>{t.setValue(e,{value:p.target.value}),this.setPropertyOnSiblings(i,"value",p.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",p=>{const g=this.data.defaultFieldValue??"";i.value=o.userValue=g,o.formattedValue=null});let f=p=>{const{formattedValue:g}=o;g!=null&&(p.target.value=g),p.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",g=>{if(o.focused)return;const{target:m}=g;if(u&&(m.type=c,d&&(m.step=d)),o.userValue){const b=o.userValue;if(u)if(c==="time"){const y=new Date(b),w=[y.getHours(),y.getMinutes(),y.getSeconds()];m.value=w.map(A=>A.toString().padStart(2,"0")).join(":")}else m.value=new Date(b-ol).toISOString().split(c==="date"?"T":".",1)[0];else m.value=b}o.lastCommittedValue=m.value,o.commitKey=1,this.data.actions?.has("Focus")||(o.focused=!0)}),i.addEventListener("updatefromsandbox",g=>{this.container.classList.add("sandboxModified");const m={value(b){o.userValue=b.detail.value??"",u||t.setValue(e,{value:o.userValue.toString()}),b.target.value=o.userValue},formattedValue(b){const{formattedValue:y}=b.detail;o.formattedValue=y,y!=null&&b.target!==document.activeElement&&(b.target.value=y);const w={formattedValue:y};u&&(w.value=y),t.setValue(e,w)},selRange(b){b.target.setSelectionRange(...b.detail.selRange)},charLimit:b=>{const{charLimit:y}=b.detail,{target:w}=b;if(y===0){w.removeAttribute("maxLength");return}w.setAttribute("maxLength",y);let A=o.userValue;!A||A.length<=y||(A=A.slice(0,y),w.value=o.userValue=A,t.setValue(e,{value:A}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:1,selStart:w.selectionStart,selEnd:w.selectionEnd}}))}};this._dispatchEventFromSandbox(m,g)}),i.addEventListener("keydown",g=>{o.commitKey=1;let m=-1;if(g.key==="Escape"?m=0:g.key==="Enter"&&!this.data.multiLine?m=2:g.key==="Tab"&&(o.commitKey=3),m===-1)return;const{value:b}=g.target;o.lastCommittedValue!==b&&(o.lastCommittedValue=b,o.userValue=b,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:m,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const p=f;f=null,i.addEventListener("blur",g=>{if(!o.focused||!g.relatedTarget)return;this.data.actions?.has("Blur")||(o.focused=!1);const{target:m}=g;let{value:b}=m;if(u){if(b&&c==="time"){const y=b.split(":").map(w=>parseInt(w,10));b=new Date(2e3,0,1,y[0],y[1],y[2]||0).valueOf(),m.step=""}else b.includes("T")||(b=`${b}T00:00`),b=new Date(b).valueOf();m.type="text"}o.userValue=b,o.lastCommittedValue!==b&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,
46commitKey:o.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}),p(g)}),this.data.actions?.has("Keystroke")&&i.addEventListener("beforeinput",g=>{o.lastCommittedValue=null;const{data:m,target:b}=g,{value:y,selectionStart:w,selectionEnd:A}=b;let v=w,E=A;switch(g.inputType){case"deleteWordBackward":{const _=/\w/;for(;v>0&&!_.test(y[v-1]);)v--;for(;v>0&&_.test(y[v-1]);)v--;break}case"deleteWordForward":{const _=y.substring(w).match(/^\W*\w*/);_&&(E+=_[0].length);break}case"deleteContentBackward":w===A&&(v-=1);break;case"deleteContentForward":w===A&&(E+=1);break}g.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:y,change:m||"",willCommit:!1,selStart:v,selEnd:E}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(f&&i.addEventListener("blur",f),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.setProperty("--comb-width",`calc(${g}px * var(--total-scale-factor))`);const m=this.data.textAlignment;if(m===1||m===2){const b=()=>{const y=r-i.value.length;i.style.setProperty("--comb-offset",`${m===1?y>>1:y}`)};b();for(const y of["input","blur","resetform","updatefromsandbox"])i.addEventListener(y,b)}}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class dl extends oe{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class ul extends oe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;typeof s=="string"&&(s=s!=="Off",t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return re.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=0,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const l of this._getElementsByName(a,i)){const c=o&&l.exportValue===e.exportValue;l.domElement&&(l.domElement.checked=c),t.setValue(l.id,{value:c})}t.setValue(i,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{const a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(i,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class fl extends oe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof s=="string"&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const r of this._getElementsByName(e.fieldName,i))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(re.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=0,n.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const l of this._getElementsByName(a,i))t.setValue(l.id,{value:!1});t.setValue(i,{value:o})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{const o={value:l=>{const c=r===l.detail.value;for(const d of this._getElementsByName(l.target.name)){const u=c&&d.id===i;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,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)}return this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}
vendor: 9,111 bytes, line 46
46class pl extends $s{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",i=>{this._dispatchEventFromSandbox({},i)})),t}}class gl extends oe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");re.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",d=>{const u=this.data.defaultFieldValue;for(const f of s.options)f.selected=f.value===u});const r=(d,u)=>{const f=u.replaceAll(" ","Â ");d.textContent=f,f!==u&&d.setAttribute("display-value",u)};for(const d of this.data.options){const u=document.createElement("option");r(u,d.displayValue),u.value=d.exportValue,i.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),n=!1),s.append(u)}let a=null;if(n){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),s.prepend(d),a=()=>{d.remove(),s.removeEventListener("input",a),a=null},s.addEventListener("input",a)}const o=d=>{const u=d?"value":"textContent",{options:f,multiple:p}=s;return p?Array.prototype.filter.call(f,g=>g.selected).map(g=>g[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let l=o(!1);const c=d=>{const u=d.target.options;return Array.prototype.map.call(u,f=>({displayValue:f.getAttribute("display-value")||f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",d=>{const u={value(f){a?.();const p=f.detail.value,g=new Set(Array.isArray(p)?p:[p]);for(const m of s.options)m.selected=g.has(m.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){s.multiple=!0},remove(f){const p=s.options,g=f.detail.remove;p[g].selected=!1,s.remove(g),p.length>0&&Array.prototype.findIndex.call(p,b=>b.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},clear(f){for(;s.length!==0;)s.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(f){const{index:p,displayValue:g,exportValue:m}=f.detail.insert,b=s.children[p],y=document.createElement("option");r(y,g),y.value=m,b?b.before(y):s.append(y),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},items(f){const{items:p}=f.detail;for(;s.length!==0;)s.remove(0);for(const g of p){const{displayValue:m,exportValue:b}=g,y=document.createElement("option");r(y,m),y.value=b,s.append(y)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},indices(f){const p=new Set(f.detail.indices);for(const g of f.target.options)g.selected=p.has(g.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(u,d)}),s.addEventListener("input",d=>{const u=o(!0),f=o(!1);t.setValue(e,{value:u}),d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:f,changeEx:u,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,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)):s.addEventListener("input",function(d){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class ms extends J{constructor(t){const{data:e,elements:i,parent:s}=t,n=!!s._commentManager;if(super(t,{isRenderable:!n&&J._hasPopupData(e)}),this.elements=i,n&&J._hasPopupData(e)){const r=this.popup=this.#t();for(const a of i)a.popup=r}else this.popup=null}#t(){return new ml({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})}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=this.#t(),i=[];for(const s of this.elements)s.popup=e,s.container.ariaHasPopup="dialog",i.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(s=>`${me}${s}`).join(",")),this.container}}class ml{#t=null;#e=this.#B.bind(this);#i=this.#_.bind(this);#s=this.#C.bind(this);#n=this.#N.bind(this);#r=null;#a=null;#o=null;#l=null;#h=null;#u=null;#d=null;#f=!1;#g=null;#m=null;#c=null;#p=null;#b=null;#y=null;#w=null;#v=null;#E=null;#A=null;#x=!1;#S=null;#T=null;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:c,open:d,commentManager:u=null}){this.#a=t,this.#E=s,this.#o=r,this.#v=a,this.#u=o,this.#r=e,this.#w=l,this.#d=c,this.#h=i,this.#t=u,this.#S=i[0],this.#l=as.toDateObject(n),this.trigger=i.flatMap(f=>f.getElementsToTriggerPopup()),u||(this.#k(),this.#a.hidden=!0,d&&this.#N())}#k(){if(this.#m)return;this.#m=new AbortController;const{signal:t}=this.#m;for(const e of this.trigger)e.addEventListener("click",this.#n,{signal:t}),e.addEventListener("pointerenter",this.#s,{signal:t}),e.addEventListener("pointerleave",this.#i,{signal:t}),e.classList.add("popupTriggerArea");for(const e of this.#h)e.container?.addEventListener("keydown",this.#e,{signal:t})}#P(){const t=this.#h.find(e=>e.hasCommentButton);t&&(this.#b=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#p){this.#p.parentNode||this.#S.container.after(this.#p);return}if(this.#b||this.#P(),!this.#b)return;const{signal:t}=this.#m=new AbortController,e=this.#S.hasOwnCommentButton,i=()=>{this.#t.toggleCommentPopup(this,!0,void 0,!e)},s=()=>{this.#t.toggleCommentPopup(this,!1,!0,!e)},n=()=>{this.#t.toggleCommentPopup(this,!1,!1)};if(e){this.#p=this.#S.container;for(const r of this.trigger)r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",i,{signal:t}),r.addEventListener("pointerenter",s,{signal:t}),r.addEventListener("pointerleave",n,{signal:t}),r.classList.add("popupTriggerArea")}else{const r=this.#p=document.createElement("button");r.className="annotationCommentButton";const a=this.#S.container;r.style.zIndex=parseInt(a.style.zIndex,10)+1,r.tabIndex=0,r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#M(),this.#I(),r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",i,{signal:t}),r.addEventListener("pointerenter",s,{signal:t}),r.addEventListener("pointerleave",n,{signal:t}),a.after(r)}}#I(){if(this.#S.extraPopupElement&&!this.#S.editor)return;this.#p||this.renderCommentButton();const[t,e]=this.#b,{style:i}=this.#p;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#M(){this.#S.extraPopupElement||(this.#p||this.renderCommentButton(),this.#p.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){const{color:t,opacity:e}=this.#S.commentData;return t?this.#u._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#p?.focus()},0)}getData(){const{richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}=this.#S.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}}get elementBeforePopup(){return this.#p}get comment(){return this.#T||=this.#S.commentText,this.#T}set comment(t){t!==this.comment&&(this.#S.commentText=this.#T=t)}focus(){this.#S.container?.focus()}get parentBoundingClientRect(){return this.#S.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#p&&(this.#p.classList.toggle("selected",t),this.#p.ariaExpanded=e)}setSelectedCommentButton(t){this.#p.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#y)return this.#y;const{x:t,y:e,height:i}=this.#p.getBoundingClientRect(),{x:s,y:n,width:r,height:a}=this.#S.layer.getBoundingClientRect();return[(t-s)/r,(e+i-n)/a]}set commentPopupPosition(t){this.#y=t}hasDefaultPopupPosition(){return this.#y===null}get commentButtonPosition(){return this.#b}get commentButtonWidth(){return this.#p.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,i]=this.#y||this.commentButtonPosition.map(l=>l/100),s=this.parentBoundingClientRect,{x:n,y:r,width:a,height:o}=s;this.#t.showDialog(null,this,n+e*a,r+i*o,{...t,parentDimensions:s})}
46render(){if(this.#g)return;const t=this.#g=document.createElement("div");if(t.className="popup",this.#r){const i=t.style.outlineColor=k.makeHexColor(...this.#r);t.style.backgroundColor=`color-mix(in srgb, ${i} 30%, white)`}const e=document.createElement("span");if(e.className="header",this.#E?.str){const i=document.createElement("span");i.className="title",e.append(i),{dir:i.dir,str:i.textContent}=this.#E}if(t.append(e),this.#l){const i=document.createElement("time");i.className="popupDate",i.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),i.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#l.valueOf()})),i.dateTime=this.#l.toISOString(),e.append(i)}vr({html:this.#D||this.#o.str,dir:this.#o?.dir,className:"popupContent"},t),this.#a.append(t)}get#D(){const t=this.#v,e=this.#o;return t?.str&&(!e?.str||e.str===t.str)&&this.#v.html||null}get#V(){return this.#D?.attributes?.style?.fontSize||0}get#R(){return this.#D?.attributes?.style?.color||null}#$(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}
46,s={style:{color:this.#R,fontSize:this.#V?`calc(${this.#V}px * var(--total-scale-factor))`:""}};for(const n of t.split(` 47`))e.push({name:"span",value:n,attributes:s});return i}#B(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#f)&&this.#N()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#t){i?(this.remove(),this.#T=null):e&&(e.deleted?this.remove():(this.#M(),this.#T=e.text)),t&&(this.#b=null,this.#P(),this.#I());return}if(i||e?.deleted){this.remove();return}this.#k(),this.#A||={contentsObj:this.#o,richText:this.#v},t&&(this.#c=null),e&&e.text&&(this.#v=this.#$(e.text),this.#l=as.toDateObject(e.date),this.#o=null),this.#g?.remove(),this.#g=null}resetEdited(){this.#A&&({contentsObj:this.#o,richText:this.#v}=this.#A,this.#A=null,this.#g?.remove(),this.#g=null,this.#c=null)}remove(){if(this.#m?.abort(),this.#m=null,this.#g?.remove(),this.#g=null,this.#x=!1,this.#f=!1,this.#p?.remove(),this.#p=null,this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#L(){if(this.#c!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#u;let r=!!this.#d,a=r?this.#d:this.#w;for(const p of this.#h)if(!a||k.intersect(p.data.rect,a)!==null){a=p.data.rect,r=!0;break}const o=k.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),c=r?a[2]-a[0]+5:0,d=o[0]+c,u=o[1];this.#c=[100*(d-s)/e,100*(u-n)/i];const{style:f}=this.#a;f.left=`${this.#c[0]}%`,f.top=`${this.#c[1]}%`}#N(){if(this.#t){this.#t.toggleCommentPopup(this,!1);return}this.#f=!this.#f,this.#f?(this.#C(),this.#a.addEventListener("click",this.#n),this.#a.addEventListener("keydown",this.#e)):(this.#_(),this.#a.removeEventListener("click",this.#n),this.#a.removeEventListener("keydown",this.#e))}#C(){this.#g||this.render(),this.isVisible?this.#f&&this.#a.classList.add("focused"):(this.#L(),this.#a.hidden=!1,this.#a.style.zIndex=parseInt(this.#a.style.zIndex,10)+1e3)}#_(){this.#a.classList.remove("focused"),!(this.#f||!this.isVisible)&&(this.#a.hidden=!0,this.#a.style.zIndex=parseInt(this.#a.style.zIndex,10)-1e3)}forceHide(){this.#x=this.isVisible,this.#x&&(this.#a.hidden=!0)}maybeShow(){this.#t||(this.#k(),this.#x&&(this.#g||this.#C(),this.#x=!1,this.#a.hidden=!1))}get isVisible(){return!this.#t&&this.#a.hidden===!1}}class $r extends J{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=j.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 i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class bl extends J{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=this.#t=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class yl extends J{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class wl extends J{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ur extends J{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:n,height:r}=this;if(!e)return this.container;const a=this.svgFactory.create(n,r,!0);let o=[];for(let c=0,d=e.length;c<d;c+=2){const u=e[c]-t[0],f=t[3]-e[c+1];o.push(`${u},${f}`)}o=o.join(" ");const l=this.#t=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class vl extends Ur{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Al extends J{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}}
vendor: 4,104 bytes, line 47
47class Us extends J{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?j.HIGHLIGHT:j.INK}#i(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#i(e,t),l=this.svgFactory.create(a,o,!0),c=this.#t=this.svgFactory.createElement("svg:g");l.append(c),c.setAttribute("stroke-width",s.width||1),c.setAttribute("stroke-linecap","round"),c.setAttribute("stroke-linejoin","round"),c.setAttribute("stroke-miterlimit",10),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),c.setAttribute("transform",r);for(const d of i){const u=this.svgFactory.createElement(this.svgElementName);this.#e.push(u),u.setAttribute("points",d.join(",")),c.append(u)}return!n&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#t;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let r=0,a=this.#e.length;r<a;r++)this.#e[r].setAttribute("points",i[r].join(","));if(s){const{transform:r,width:a,height:o}=this.#i(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),n.setAttribute("transform",r)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class Vr extends J{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=j.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 i=document.createElement("mark");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class El extends J{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 i=document.createElement("u");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class Sl extends J{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 i=document.createElement("u");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class xl extends J{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 i=document.createElement("s");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class Hr extends J{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=j.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}}
47class _l extends J{#t=null;constructor(t){super(t,{isRenderable:!0});const{fileId:e,file:i}=this.data;this.filename=i.filename,this.content=i.content,this.fileId=e,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||e.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),i.addEventListener("dblclick",this.#e.bind(this)),this.#t=i;const{isMac:s}=Y.platform;return t.addEventListener("keydown",n=>{n.key==="Enter"&&(s?n.metaKey:n.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}async#e(){const{fileId:t,filename:e,content:i}=this,s=await this.linkService.getAttachmentContent(t)||i;s&&this.downloadManager?.openOrDownloadData(s,e)}}class zr extends J{#t=new AbortController;#e=null;#i=null;constructor(t){super(t,{isRenderable:!!t.data.richMedia})}render(){this.container.classList.add("mediaAnnotation");const{filename:t}=this.data.richMedia,e=document.createElement("button");return e.className="mediaPlayButton",e.type="button",e.title=e.ariaLabel=t,e.addEventListener("click",()=>this.#s(e),{signal:this.#t.signal}),this.container.append(e),this.container}async#s(t){const{fileId:e,filename:i,contentType:s}=this.data.richMedia;t.disabled=!0;let n;try{n=await this.linkService.getAttachmentContent(e)}catch{return}finally{t.disabled=!1}if(!n||!t.isConnected)return;const{signal:r}=this.#t,a=URL.createObjectURL(new Blob([n],{type:s}));this.#e=a;const o=s.startsWith("audio/"),l=document.createElement(o?"audio":"video");if(this.#i=l,l.className="mediaContent",this._setBackgroundColor(l),l.src=a,l.title=i,l.controls=!0,l.autoplay=!0,l.tabIndex=0,o){let c=!1,d=!1;const u=()=>{l.controls=c||d};this.container.addEventListener("pointerenter",()=>{c=!0,u()},{signal:r}),this.container.addEventListener("pointerleave",()=>{c=!1,u()},{signal:r}),this.container.addEventListener("focusin",()=>{d=!0,u()},{signal:r}),this.container.addEventListener("focusout",()=>{d=!1,u()},{signal:r})}l.addEventListener("emptied",()=>this.#n(a),{once:!0,signal:r}),t.replaceWith(l),l.play().catch(()=>{})}#n(t=this.#e){t&&t===this.#e&&(URL.revokeObjectURL(t),this.#e=null)}destroy(){this.#t.abort(),this.#i&&(this.#i.pause(),this.#i.removeAttribute("src"),this.#i.load(),this.#i=null),this.#n()}}let Cl=class Wr{#t=null;#e=null;#i=null;#s=new Map;#n=null;#r=null;#a=[];#o=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:c}){this.div=t,this.#t=e,this.#e=i,this.#n=a||null,this.#r=l||null,this.#i=c||new Ns,this.page=n,this.viewport=r,this._annotationEditorUIManager=s,this._commentManager=o||null}hasEditableAnnotations(){return this.#s.size>0}async render(t){const{annotations:e,optionalContentConfig:i}=t,s=this.div;ne(s,this.viewport);const n=new Map,r=[],a={data:null,layer:s,linkService:this.#r,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new bi,annotationStorage:this.#i,enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const o of e){if(o.noHTML)continue;const l=o.annotationType===tt.POPUP;if(l){const u=n.get(o.id);if(!u)continue;if(!this._commentManager){r.push(o);continue}a.elements=u}else if(o.rect[2]===o.rect[0]||o.rect[3]===o.rect[1])continue;a.data=o;const c=Xi.create(a);if(!c.isRenderable)continue;l||(this.#a.push(c),o.popupRef&&n.getOrInsertComputed(o.popupRef,_e).push(c));const d=c.render();o.hidden&&(d.style.visibility="hidden"),c.updateOC(i),c._isEditable&&(this.#s.set(c.data.id,c),this._annotationEditorUIManager?.renderAnnotationElement(c))}await this.#l();for(const o of r){const l=a.elements=n.get(o.id);a.data=o;const c=Xi.create(a);if(!c.isRenderable)continue;const d=c.render();
47c.contentElement.id=`${me}${o.id}`,o.hidden&&(d.style.visibility="hidden"),l.at(-1).container.after(d)}this.#h()}async#l(){if(this.#a.length===0)return;this.div.replaceChildren();const t=[];if(!this.#o){this.#o=!0;for(const{contentElement:i,data:{hidden:s,id:n,oc:r}}of this.#a){const a=i.id=`${me}${n}`,o=i.localName==="a"&&!s&&!r;t.push(this.#n?.getAriaAttributes(a,{enableLinkOwnership:o}).then(l=>{if(l)for(const[c,d]of l)i.setAttribute(c,d)}))}}this.#a.sort(({data:{rect:[i,s,n,r]}},{data:{rect:[a,o,l,c]}})=>{if(i===n&&s===r)return 1;if(a===l&&o===c)return-1;const d=r,u=s,f=(s+r)/2,p=c,g=o,m=(o+c)/2;if(f>=p&&m<=u)return-1;if(m>=d&&f<=g)return 1;const b=(i+n)/2,y=(a+l)/2;return b-y});const e=document.createDocumentFragment();for(const i of this.#a)e.append(i.container),this._commentManager?(i.extraPopupElement?.popup||i.popup)?.renderCommentButton():i.extraPopupElement&&e.append(i.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#t){const i=await this.#n?.getAnnotationIds();for(const{contentElement:s}of this.#a)i?.has(s.id)||this.#t.addPointerInTextLayer(s,!1)}}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:this.#r,svgFactory:new bi,parent:this};for(const i of t){i.borderStyle||=Wr._defaultBorderStyle,e.data=i;const s=Xi.create(e);s.isRenderable&&(s.render(),s.contentElement.id=`${me}${i.id}`,this.#a.push(s))}await this.#l()}update({viewport:t,optionalContentConfig:e}){const i=this.div;this.viewport=t,ne(i,{rotation:t.rotation});for(const s of this.#a)s.updateOC(e);this.#h(),i.hidden=!1}destroy(){for(const t of this.#a)t.destroy?.(),this.#t?.removePointerInTextLayer(t.contentElement);this.#a.length=0,this.#s.clear(),this.div.replaceChildren()}#h(){if(!this.#e)return;const t=this.div;for(const[e,i]of this.#e){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;if(Array.isArray(i))for(const l of i)l.className="annotationContent",l.ariaHidden=!0;else i.className="annotationContent",i.ariaHidden=!0;const n=[];for(const l of s.children)l.nodeName==="CANVAS"&&n.push(l);for(const l of n)l.remove();const r=Array.isArray(i)?i[0]:i,{firstChild:a}=s;if(a?a.classList.contains("annotationContent")?a.after(r):a.before(r):s.append(r),Array.isArray(i)){let l=r;
47for(let c=1,d=i.length;c<d;c++)l.after(i[c]),l=i[c]}this.#e.delete(e);const o=this.#s.get(e);o&&(o._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),o._hasNoCanvas=!1):o.canvas=i)}}refreshCanvases(){this.#h()}getEditableAnnotations(){return this.#s.values()}getEditableAnnotation(t){return this.#s.get(t)}addFakeAnnotation(t){const{div:e}=this,{id:i,rotation:s}=t,n=new ll({data:{id:i,rect:t.getPDFRect(),rotation:s},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#r,annotationStorage:this.#i});return n.render(),n.contentElement.id=`${me}${i}`,n.createOrUpdatePopup(),this.#a.push(n),n}removeAnnotation(t){const e=this.#a.findIndex(s=>s.data.id===t);if(e<0)return;const[i]=this.#a.splice(e,1);this.#t?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);this.#l()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return F(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:ue.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};const ti=/\r\n?|\n/g;class ot extends N{#t="";#e=`${this.id}-editor`;#i=null;#s;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=ot.prototype,e=n=>n.isEmpty(),i=Be.TRANSLATE_SMALL,s=Be.TRANSLATE_BIG;return F(this,"_keyboardManager",new vt([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],t.commitOrRemove],[["Escape"],t.commitOrRemove],[["ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=j.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||ot._defaultColor||N._defaultLineColor,this.#s=t.fontSize||ot._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert(N._l10nAlert.freetext),this.canAddComment=!1}static initialize(t,e){N.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case z.FREETEXT_SIZE:ot._defaultFontSize=e;break;case z.FREETEXT_COLOR:ot._defaultColor=e;break}}updateParams(t,e){switch(t){case z.FREETEXT_SIZE:this.#n(e);break;case z.FREETEXT_COLOR:this.#r(e);break}}static get defaultPropertiesToUpdate(){return[[z.FREETEXT_SIZE,ot._defaultFontSize],[z.FREETEXT_COLOR,ot._defaultColor||N._defaultLineColor]]}get propertiesToUpdate(){return[[z.FREETEXT_SIZE,this.#s],[z.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new Ue(this),[["colorPicker",this._colorPicker]]}get colorType(){return z.FREETEXT_COLOR}#n(t){const e=s=>{this.editorDiv.style.fontSize=`calc(${s}px * var(--total-scale-factor))`,this.translate(0,-(s-this.#s)*this.parentScale),this.#s=s,this.#o()},i=this.#s;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:z.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#r(t){const e=s=>{this.color=s,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:z.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-ot._internalPadding*t,-(ot._internalPadding+this.#s)*t]}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"),this.#i=new AbortController;const t=this._uiManager.combinedSignal(this.#i);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#e),this._isDraggable=!0,this.#i?.abort(),this.#i=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.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()}#a(){const t=[];
47this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&i.nodeName==="BR"||(t.push(ot.#l(i)),e=i);return t.join(` 48`)}#o(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:s,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",s.div.append(this.div),i=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#t,e=this.#t=this.#a().trimEnd();if(t===e)return;const i=s=>{if(this.#t=s,!s){this.remove();return}this.#h(),this._uiManager.rebuild(this),this.#o()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#o()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){ot._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){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 t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#e),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(${this.#s}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[s,n]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this._initialData;let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[l,c]=this.pageDimensions,[d,u]=this.pageTranslation;let f,p;switch(this.rotation){case 0:f=t+(r[0]-d)/l,p=e+this.height-(r[1]-u)/c;break;case 90:f=t+(r[0]-d)/l,p=e-(r[1]-u)/c,[a,o]=[o,-a];break;case 180:f=t-this.width+(r[0]-d)/l,p=e-(r[1]-u)/c,[a,o]=[-a,-o];break;case 270:f=t+(r[0]-d-this.height*c)/l,p=e+(r[1]-u-this.width*l)/c,[a,o]=[-o,a];break}this.setAt(f*s,p*n,a,o)}else this._moveAfterPaste(t,e);this.#h(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(ti,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(i.length===1&&i[0]==="text/plain")return;t.preventDefault();const s=ot.#d(e.getData("text")||"").replaceAll(ti,` 49`);if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!s.includes(`
50`)){r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),n.collapseToStart();return}const{startContainer:a,startOffset:o}=r,l=[],c=[];if(a.nodeType===Node.TEXT_NODE){const f=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll(ti,"")),f!==this.editorDiv){let p=l;for(const g of this.editorDiv.childNodes){if(g===f){p=c;continue}p.push(ot.#l(g))}}l.push(a.nodeValue.slice(0,o).replaceAll(ti,""))}else if(a===this.editorDiv){let f=l,p=0;for(const g of this.editorDiv.childNodes)p++===o&&(f=c),f.push(ot.#l(g))}this.#t=`${l.join(` 51`)}${s}${c.join(` 52`)}`,this.#h();const d=new Range;let u=Math.sumPrecise(l.map(f=>f.length));for(const{firstChild:f}of this.editorDiv.childNodes)if(f.nodeType===Node.TEXT_NODE){const p=f.nodeValue.length;if(u<=p){d.setStart(f,u),d.setEnd(f,u);break}u-=p}n.removeAllRanges(),n.addRange(d)}#h(){if(this.editorDiv.replaceChildren(),!!this.#t)for(const t of this.#t.split(` 53`)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll("Â "," ")}static#d(t){return t.replaceAll(" ","Â ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=ot._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let s=null;if(t instanceof $r){const{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:l,id:c,popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},textContent:m,textPosition:b,parent:{page:{pageNumber:y}}}=t;if(!m?.length)return null;s=t={annotationType:j.FREETEXT,color:Array.from(a),fontSize:r,value:m.join(` 54`),position:b,pageIndex:y-1,rect:o.slice(0),rotation:l,annotationElementId:c,id:c,deleted:!1,popupRef:d,comment:f?.str||null,richText:u,creationDate:p,modificationDate:g}}const n=await super.deserialize(t,e,i);return n.#s=t.fontSize,n.color=k.makeHexColor(...t.color),n.#t=ot.#d(t.value),n._initialData=s,t.comment&&n.setCommentData(t),n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=N._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#s,value:this.#u()});return this.addComment(i),t?(i.isCopy=!0,i):this.annotationElementId&&!this.#f(i)?null:(i.id=this.annotationElementId,i)}#f(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((r,a)=>r!==s[a])||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:i}=e;i.fontSize=`calc(${this.#s}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren();for(const s of this.#t.split(` 55`)){const n=document.createElement("div");n.append(s?document.createTextNode(s):document.createElement("br")),e.append(n)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Vs{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){const t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){W("Not implemented")}}class V extends N{#t=null;#e;_clipPathId=null;_colorPicker=null;_drawId=null;_drawOutlines=null;_focusDrawId=null;static _currentDrawId=-1;static _currentParent=null;static#i=null;static#s=null;static#n=null;static#r=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#a(t),this.#m())}#a({drawOutlines:t,drawId:e,drawingOptions:i,clipPathId:s}){this._drawOutlines=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(N._l10nAlert[this.editorType]),e>=0?(this._drawId=e,this._clipPathId=s??null,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties),this.#l(this.parent)):this._drawId=this.#o(t,this.parent),this.#b(t.box)}#o(t,e){const{id:i,clipPathId:s}=e.drawLayer.draw(V._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,this.constructor._hasCl
55ipPath);return this.constructor._hasClipPath&&(this._clipPathId=s),this.#l(e),i}#l(t){const e=this._drawOutlines.getFocusSVGProperties(this.#f);e&&(this._focusDrawId=t.drawLayer.drawOutline(e,this._drawOutlines.focusMustRemoveSelfIntersections))}#h(t=this.#f){this._focusDrawId!==null&&this.parent?.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(t))}#u(t){this._focusDrawId!==null&&this.parent?.drawLayer.updateProperties(this._focusDrawId,{rootClass:t})}#d(){const{parent:t,_drawId:e,_focusDrawId:i,_isVisible:s}=this;if(!t||e===null)return;const n={hidden:!s};t.drawLayer.updateProperties(e,{rootClass:n}),i!==null&&t.drawLayer.updateProperties(i,{rootClass:n})}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){W("Not implemented")}static get typesMap(){W("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)}get#f(){return(this.parentRotation-this._drawRotation+360)%360}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(V.#i.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=a=>{s.updateProperty(e,a);const o=this._drawOutlines.updateProperty(e,a);o&&this.#b(o),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e,i=this.colorAndOpacityType){const s=this.constructor.typesMap.get(this.colorType),n=this._opacityName,r=this._drawingOptions,a=r[s],o=r[n],l=(c,d)=>{r.updateProperty(s,c),r.updateProperty(n,d),this._drawOutlines.updateProperty(s,c),this._drawOutlines.updateProperty(n,d),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:l.bind(this,t,e),undo:l.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,V._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(this.#p()),{bbox:this.#y()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,V._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(this.#p()),{bbox:this.#y()})),this.#h()}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#y()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,V._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#y()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.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(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this._uiManager.removeShouldRescale(this),this.#g(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#m(),this.#b(this._drawOutlines.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#g()):t&&(this._uiManager.addShouldRescale(this),this.#m(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.#d(),e&&this.select()}
55#g(){if(this._drawId===null||!this.parent)return;const{drawLayer:t}=this.parent;t.remove(this._drawId),this._drawId=null,this._focusDrawId!==null&&(t.remove(this._focusDrawId),this._focusDrawId=null),this._drawingOptions.reset()}#m(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){const{drawLayer:e}=this.parent;e.updateParent(this._drawId,t.drawLayer),this._focusDrawId!==null&&e.updateParent(this._focusDrawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#o(this._drawOutlines,t),this._clipPathId&&this.#t&&(this.#t.style.clipPath=this._clipPathId)}}#c([t,e,i,s]){const{parentDimensions:[n,r],_drawRotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}}#p(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],_drawRotation:a}=this;switch(a){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}}#b(t){[this.x,this.y,this.width,this.height]=this.#c(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#y(t=this.parentRotation){const{x:e,y:i,width:s,height:n,_drawRotation:r,parentDimensions:[a,o]}=this;switch((r*4+t)/90){case 1:return[1-i-n,e,n,s];case 2:return[1-e-s,1-i-n,s,n];case 3:return[i,1-e-s,n,s];case 4:return[e,i-s*(a/o),n*(o/a),s*(a/o)];case 5:return[1-i,e,s*(a/o),n*(o/a)];case 6:return[1-e-n*(o/a),1-i,n*(o/a),s*(a/o)];case 7:return[i-s*(a/o),1-e-n*(o/a),s*(a/o),n*(o/a)];case 8:return[e-s,i-n,s,n];case 9:return[1-i,e-s,n,s];case 10:return[1-e,1-i,s,n];case 11:return[i-n,1-e,n,s];case 12:return[e-n*(o/a),i,n*(o/a),s*(a/o)];case 13:return[1-i-s*(a/o),e-n*(o/a),s*(a/o),n*(o/a)];case 14:return[1-e,1-i-s*(a/o),n*(o/a),s*(a/o)];case 15:return[i,1-e,s*(a/o),n*(o/a)];default:return[e,i,s,n]}}rotate(t=this.parentRotation){if(!this.parent||this._drawId===null)return;const e=(t-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,V._mergeSVGProperties({bbox:this.#y(t)},this._drawOutlines.updateRotation(e))),this.#h(e)}show(t=this._isVisible){super.show(t),this.#d()}select(){super.select(),this.#u({hovered:!1,selected:!0})}unselect(){super.unselect(),this.#u({selected:!1})}pointerover(){this.isSelected||this.#u({hovered:!0})}pointerleave(){this.isSelected||this.#u({hovered:!1})}onScaleChanging(){if(!this.parent)return;const t=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);t&&this.#b(t)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const i=super.render();this.constructor._hasDrawClass&&i.classList.add("draw");const s=this.#t=document.createElement("div");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this._clipPathId&&(s.style.clipPath=this._clipPathId),Er(this,s,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t){W("Not implemented")}static _getDrawingTarget(t,{target:e}){return e}static _getPointerCoords({offsetX:t,offsetY:e,clientX:i,clientY:s},n=null){if(!n)return[t,e];let r=i-n.clientX,a=s-n.clientY;switch(this._currentParent.viewport.rotation){case 90:[r,a]=[a,-r];break;case 180:[r,a]=[-r,-a];break;case 270:[r,a]=[-a,r];break}return[n.offsetX+r,n.offsetY+a]}static _addDrawingListeners(t,e){}static _endDrawingSession(t=!1){return this._currentParent.endDrawingSession(t)}static startDrawing(t,e,i,s){const{pointerId:n,pointerType:r}=s;if(X.isInitializedAndDifferentPointerType(r))return;const a=this._getDrawingTarget(t,s),[o,l]=this._getPointerCoords(s),{viewport:{rotation:c}}=t,{x:d,y:u,width:f,height:p}=a.getBoundingClientRect(),g=V.#s=new AbortController,m=t.combinedSignal(g);if(X.setPointer(r,n),window.addEventListener("pointerup",w=>{X.isSamePointerIdOrRemove(w.pointerId)&&this._endDraw(w)},{signal:m}),window.addEventListener("pointercancel",w=>{X.isSamePointerIdOrRemove(w.pointerId)&&this._endDrawingSession()},{signal:m}),window.addEventListener("pointerdown",w=>{X.isSamePointerType(w.pointerType)&&(X.initializeAndAddPointerId(w.pointerId),V.#i.isCancellable()&&(V.#i.removeLastElement(),V.#i.isEmpty()?this._endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",Ct,{signal:m}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),a.addEventListener("touchmove",w=>{X.isSameTimeStamp(w.timeStamp)&&at(w)},{signal:m}),this._addDrawingListeners(a,m),t.toggleDrawing(),e._editorUndoBar?.hide(),V.#i){t.drawLayer.updateProperties(this._currentDrawId,V.#i.startNew(o,l,f,p,c));return}e.updateUIForDefaultProperties(this),V.#i=this.createDrawerInstance({x:o,y:l,box:[d,u,f,p],rotation:c,parent:t,isLTR:i}),V.#n=this.getDefaultDrawingOptions(),this._currentParent=t;
55const{id:b,clipPathId:y}=t.drawLayer.draw(this._mergeSVGProperties(V.#n.toSVGProperties(),V.#i.defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=b,V.#r=this._hasClipPath?y:null}static _drawMove(t){if(X.isSameTimeStamp(t.timeStamp),!V.#i||!X.isSamePointerId(t.pointerId))return;if(X.isUsingMultiplePointers()){this._endDraw(t);return}let e;const i=t.getCoalescedEvents?.();if(i?.length){const s=[];for(const n of i)s.push(...this._getPointerCoords(n,t));e=V.#i.addPoints(s)}else e=V.#i.add(...this._getPointerCoords(t));this._currentParent.drawLayer.updateProperties(this._currentDrawId,e),X.setTimeStamp(t.timeStamp),at(t)}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,V.#i=null,V.#n=null,V.#r=null,X.clearTimeStamp()),V.#s&&(V.#s.abort(),V.#s=null,X.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),e.drawLayer.updateProperties(this._currentDrawId,t?.target===e.div?V.#i.end(...this._getPointerCoords(t)):V.#i.end()),this.supportMultipleDrawings){const i=V.#i,s=this._currentDrawId,n=i.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(s,i.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(s,i.removeLastElement())},mustExec:!1,type:z.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(z.DRAW_STEP),!V.#i.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:V.#r,drawOutlines:V.#i.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:V.#n,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r,a){W("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,s,n,this._INNER_MARGIN,t,i),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#a({drawOutlines:o}),l.#m(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this._drawOutlines.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class I{static PRECISION=1e-4;focusOutline=null;toSVGPath(){W("Abstract method `toSVGPath` must be implemented.")}get box(){W("Abstract getter `box` must be implemented.")}serialize(t,e){W("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){W("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,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class ie{#t;#e=[];#i;#s;#n=[];#r=new Float32Array(18);#a;#o;#l;#h;#u;#d;#f=[];static#g=8;static#m=2;static#c=ie.#g+ie.#m;constructor(t,e,i,s,n,r,a=0){this.#t=i,this.#d=n*s,this.#s=r,this.#r.set([NaN,NaN,NaN,NaN,t,e],6),this.#i=a,this.#h=ie.#g*s,this.#l=ie.#c*s,this.#u=s,this.#f.push(t,e)}isEmpty(){return isNaN(this.#r[8])}isCancellable(){return this.#f.length<=10}removeLastElement(){return this.#r.fill(NaN),this.#n.length=this.#e.length=this.#f.length=0,{path:{d:""}}}#p(){const t=this.#r.subarray(4,6),e=this.#r.subarray(16,18),[i,s,n,r]=this.#t;return[(this.#a+(t[0]-e[0])/2-i)/n,(this.#o+(t[1]-e[1])/2-s)/r,(this.#a+(e[0]-t[0])/2-i)/n,(this.#o+(e[1]-t[1])/2-s)/r]}add(t,e){this.#a=t,this.#o=e;const[i,s,n,r]=this.#t;let[a,o,l,c]=this.#r.subarray(8,12);const d=t-l,u=e-c,f=Math.hypot(d,u);if(f<this.#l)return!1;const p=f-this.#h,g=p/f,m=g*d,b=g*u;let y=a,w=o;a=l,o=c,l+=m,c+=b,this.#f?.push(t,e);const A=-b/p,v=m/p,E=A*this.#d,_=v*this.#d;return this.#r.set(this.#r.subarray(2,8),0),this.#r.set([l+E,c+_],4),this.#r.set(this.#r.subarray(14,18),12),this.#r.set([l-E,c-_],16),isNaN(this.#r[6])?(this.#n.length===0&&(this.#r.set([a+E,o+_],2),this.#n.push(NaN,NaN,NaN,NaN,(a+E-i)/n,(o+_-s)/r),this.#r.set([a-E,o-_],14),this.#e.push(NaN,NaN,NaN,NaN,(a-E-i)/n,(o-_-s)/r)),this.#r.set([y,w,a,o,l,c],6),!this.isEmpty()):(this.#r.set([y,w,a,o,l,c],6),Math.abs(Math.atan2(w-o,y-a)-Math.atan2(b,m))<Math.PI/2?([a,o,l,c]=this.#r.subarray(2,6),this.#n.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/n,((o+c)/2-s)/r),[a,o,y,w]=this.#r.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((y+a)/2-i)/n,((w+o)/2-s)/r),!0):([y,w,a,o,l,c]=this.#r.subarray(0,6),this.#n.push(((y+5*a)/6-i)/n,((w+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+c)/6-s)/r,((a+l)/2-i)/n,((o+c)/2-s)/r),[l,c,a,o,y,w]=this.#r.subarray(12,18),this.#e.push(((y+5*a)/6-i)/n,((w+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+c)/6-s)/r,((a+l)/2-i)/n,((o+c)/2-s)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#n,e=this.#e;if(isNaN(this.#r[6])&&!this.isEmpty())return this.#b();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let s=6;s<t.length;s+=6)isNaN(t[s])?i.push(`L${t[s+4]} ${t[s+5]}`):i.push(`C${t[s]} ${t[s+1]} ${t[s+2]} ${t[s+3]} ${t[s+4]} ${t[s+5]}`);this.#w(i);for(let s=e.length-6;s>=6;s-=6)isNaN(e[s])?i.push(`L${e[s+4]} ${e[s+5]}`):i.push(`C${e[s]} ${e[s+1]} ${e[s+2]} ${e[s+3]} ${e[s+4]} ${e[s+5]}`);return this.#y(i),i.join(" ")}#b(){const[t,e,i,s]=this.#t,[n,r,a,o]=this.#p();return`M${(this.#r[2]-t)/i} ${(this.#r[3]-e)/s} L${(this.#r[4]-t)/i} ${(this.#r[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#r[16]-t)/i} ${(this.#r[17]-e)/s} L${(this.#r[14]-t)/i} ${(this.#r[15]-e)/s} Z`}#y(t){const e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#w(t){const[e,i,s,n]=this.#t,r=this.#r.subarray(4,6),a=this.#r.subarray(16,18),[o,l,c,d]=this.#p();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${c} ${d} L${(a[0]-e)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new Gr(t,e,i,s,n,r)}getOutlines(){const t=this.#n,e=this.#e,i=this.#r,[s,n,r,a]=this.#t,o=new Float32Array((this.#f?.length??0)+2);for(let d=0,u=o.length-2;d<u;d+=2)o[d]=(this.#f[d]-s)/r,o[d+1]=(this.#f[d+1]-n)/a;if(o[o.length-2]=(this.#a-s)/r,o[o.length-1]=(this.#o-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#v(o);const l=new Float32Array(this.#n.length+24+this.#e.length);let c=t.length;for(let d=0;d<c;d+=2){if(isNaN(t[d])){l[d]=l[d+1]=NaN;continue}l[d]=t[d],l[d+1]=t[d+1]}c=this.#A(l,c);for(let d=e.length-6;d>=6;d-=6)for(let u=0;u<6;u+=2){if(isNaN(e[d+u])){l[c]=l[c+1]=NaN,c+=2;continue}l[c]=e[d+u],l[c+1]=e[d+u+1],c+=2}return this.#E(l,c),this.newFreeDrawOutline(l,o,this.#t,this.#u,this.#i,this.#s)}#v(t){const e=this.#r,[i,s,n,r]=this.#t,[a,o,l,c]=this.#p(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(d,t,this.#t,this.#u,this.#i,this.#s)}#E(t,e){const i=this.#e;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#A(t,e){const i=this.#r.subarray(4,6),s=this.#r.subarray(16,18),[n,r,a,o]=this.#t,[l,c,d,u]=this.#p();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+=24}}class Gr extends I{#t;
55#e=new Float32Array(4);#i;#s;#n;#r;#a;constructor(t,e,i,s,n,r){super(),this.#a=t,this.#n=e,this.#t=i,this.#r=s,this.#i=n,this.#s=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(r);const[a,o,l,c]=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/l,t[d+1]=(t[d+1]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/l,e[d+1]=(e[d+1]-o)/c}toSVGPath(){const t=[`M${this.#a[4]} ${this.#a[5]}`];for(let e=6,i=this.#a.length;e<i;e+=6){if(isNaN(this.#a[e])){t.push(`L${this.#a[e+4]} ${this.#a[e+5]}`);continue}t.push(`C${this.#a[e]} ${this.#a[e+1]} ${this.#a[e+2]} ${this.#a[e+3]} ${this.#a[e+4]} ${this.#a[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,a=s-e;let o,l;switch(n){case 0:o=I._rescale(this.#a,t,s,r,-a),l=I._rescale(this.#n,t,s,r,-a);break;case 90:o=I._rescaleAndSwap(this.#a,t,e,r,a),l=I._rescaleAndSwap(this.#n,t,e,r,a);break;case 180:o=I._rescale(this.#a,i,e,-r,a),l=I._rescale(this.#n,i,e,-r,a);break;case 270:o=I._rescaleAndSwap(this.#a,i,s,-r,-a),l=I._rescaleAndSwap(this.#n,i,s,-r,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}#o(t){const e=this.#a;let i=e[4],s=e[5];const n=[i,s,i,s];let r=i,a=s,o=i,l=s;const c=t?Math.max:Math.min,d=new Float32Array(4);for(let f=6,p=e.length;f<p;f+=6){const g=e[f+4],m=e[f+5];isNaN(e[f])?(k.pointBoundingBox(g,m,n),a>m?(r=g,a=m):a===m&&(r=c(r,g)),l<m?(o=g,l=m):l===m&&(o=c(o,g))):(d.set(Bt,0),k.bezierBoundingBox(i,s,...e.slice(f,f+6),d),k.rectBoundingBox(...d,n),a>d[1]?(r=d[0],a=d[1]):a===d[1]&&(r=c(r,d[0])),l<d[3]?(o=d[2],l=d[3]):l===d[3]&&(o=c(o,d[2]))),i=g,s=m}const u=this.#e;u[0]=n[0]-this.#i,u[1]=n[1]-this.#i,u[2]=n[2]-n[0]+2*this.#i,u[3]=n[3]-n[1]+2*this.#i,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#e}newOutliner(t,e,i,s,n,r,a=0){return new ie(t,e,i,s,n,r,a)}updateThickness(t){const e=this.getNewOutline(t);return this.#a=e.#a,this.#n=e.#n,this.#e.set(e.#e),this.firstPoint=e.firstPoint,this.lastPoint=e.lastPoint,this.#e}getNewOutline(t,e){const[i,s,n,r]=this.#e,[a,o,l,c]=this.#t,d=n*l,u=r*c,f=i*l+a,p=s*c+o,g=this.#n,m=this.newOutliner(g[0]*d+f,g[1]*u+p,this.#t,this.#r,t,this.#s,e??this.#i);for(let b=2,y=g.length;b<y;b+=2)m.add(g[b]*d+f,g[b+1]*u+p);return m.getOutlines()}}function Xr(h){return{bbox:h.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:h.isFree},path:{d:h.toSVGPath()}}}function Yr(h,t){const{focusOutline:e}=h;return{bbox:I._rotateBox(e.box,t),root:{"data-main-rotation":t},rootClass:{highlightOutline:!0,free:h.isFree},path:{d:e.toSVGPath()}}}class bs{#t;#e;#i;#s=[];#n=[];constructor(t,e=0,i=0,s=!0){const n=Bt.slice(),r=10**-4;for(const{x:g,y:m,width:b,height:y}of t){const w=Math.floor((g-e)/r)*r,A=Math.ceil((g+b+e)/r)*r,v=Math.floor((m-e)/r)*r,E=Math.ceil((m+y+e)/r)*r,_=[w,v,E,!0],C=[A,v,E,!1];this.#s.push(_,C),k.rectBoundingBox(w,v,A,E,n)}const a=n[2]-n[0]+2*i,o=n[3]-n[1]+2*i,l=n[0]-i,c=n[1]-i;let d=s?-1/0:1/0,u=1/0;const f=this.#s.at(s?-1:-2),p=[f[0],f[2]];for(const g of this.#s){const[m,b,y,w]=g;!w&&s?b<u?(u=b,d=m):b===u&&(d=Math.max(d,m)):w&&!s&&(b<u?(u=b,d=m):b===u&&(d=Math.min(d,m))),g[0]=(m-l)/a,g[1]=(b-c)/o,g[2]=(y-c)/o}this.#t=new Float32Array([l,c,a,o]),this.#e=[d,u],this.#i=p}getOutlines(){this.#s.sort((e,i)=>e[0]-i[0]||e[1]-i[1]||e[2]-i[2]);const t=[];for(const e of this.#s)e[3]?(t.push(...this.#h(e)),this.#o(e)):(this.#l(e),t.push(...this.#h(e)));return this.#r(t)}#r(t){const e=[],i=new Set;for(const r of t){const[a,o,l]=r;e.push([a,o,r],[a,l,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],l=e[r+1][2];o.push(l),l.push(o),i.add(o),i.add(l)}const s=[];let n;for(;i.size>0;){const r=i.values().next().value;let[a,o,l,c,d]=r;i.delete(r);let u=a,f=o;for(n=[a,l],s.push(n);;){let p;if(i.has(c))p=c;else if(i.has(d))p=d;else break;i.delete(p),[a,o,l,c,d]=p,u!==a&&(n.push(u,f,a,f===o?o:l),u=a),f=f===o?l:o}n.push(u,f)}return new ys(s,this.#t,this.#e,this.#i)}#a(t){const e=this.#n;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#o([,t,e]){const i=this.#a(t);this.#n.splice(i,0,[t,e])}#l([,t,e]){const i=this.#a(t);for(let s=i;s<this.#n.length;s++){const[n,r]=this.#n[s];if(n!==t)break;
55if(n===t&&r===e){this.#n.splice(s,1);return}}for(let s=i-1;s>=0;s--){const[n,r]=this.#n[s];if(n!==t)break;if(n===t&&r===e){this.#n.splice(s,1);return}}}#h(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#a(s);for(let a=0;a<r;a++){const[o,l]=this.#n[a];for(let c=0,d=n.length;c<d;c++){const[,u,f]=n[c];if(!(l<=u||f<=o)){if(u>=o){if(f>l)n[c][1]=l;else{if(d===1)return[];n.splice(c,1),c--,d--}continue}n[c][2]=o,f>l&&n.push([e,l,f])}}}return n}}class ys extends I{#t;#e=null;#i;constructor(t,e,i,s){super(),this.#i=t,this.#t=e,this.firstPoint=i,this.lastPoint=s}static build(t,e){const i=new bs(t,.001).getOutlines();return i.#e=t,i.focusOutline=new bs(t,.0025,.001,e).getOutlines(),i}get isFree(){return!1}get defaultSVGProperties(){return Xr(this)}getFocusSVGProperties(t){return Yr(this,t)}updateRotation(t){return{root:{"data-main-rotation":t}}}serializeQuadPoints([t,e],[i,s]){const n=this.#e,r=new Float32Array(n.length*8);let a=0;for(const{x:o,y:l,width:c,height:d}of n){const u=o*i+t,f=(1-l)*s+e;r[a]=r[a+4]=u,r[a+1]=r[a+3]=f,r[a+2]=r[a+6]=u+c*i,r[a+5]=r[a+7]=f-d*s,a+=8}return r}toSVGPath(){const t=[];for(const e of this.#i){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],a=i-t,o=s-e;for(const l of this.#i){const c=new Array(l.length);for(let d=0;d<l.length;d+=2)c[d]=t+l[d]*a,c[d+1]=s-l[d+1]*o;r.push(c)}return r}get box(){return this.#t}}class Hs extends ie{newFreeDrawOutline(t,e,i,s,n,r){return new zs(t,e,i,s,n,r)}}class Pl{#t;#e;constructor(t,e,i,s,n,r,a){this.#t=new Hs(t,e,i,s,n,r,a),this.#e=n}add(t,e){return this.#t.add(t,e)?{path:{d:this.#t.toSVGPath()}}:null}addPoints(t){let e=!1;for(let i=0,s=t.length;i<s;i+=2)e=this.#t.add(t[i],t[i+1])||e;return e?{path:{d:this.#t.toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return this.#t.isEmpty()}isCancellable(){return this.#t.isCancellable()}removeLastElement(){return this.#t.removeLastElement()}updateProperty(t,e){return null}getOutlines(){const t=this.#t.getOutlines();return t.buildFocusOutline(2*this.#e),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:this.#t.toSVGPath()}}}}class zs extends Gr{static#t=1.5;newOutliner(t,e,i,s,n,r,a=0){return new Hs(t,e,i,s,n,r,a)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+zs.#t,.0025)}get defaultSVGProperties(){return Xr(this)}getFocusSVGProperties(t){return Yr(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;const i=this.updateThickness(e/2);return this.buildFocusOutline(e),i}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}}class Ws extends Vs{constructor(t=null){super(),super.updateProperties(t)}updateSVGProperty(t,e){t!=="thickness"&&super.updateSVGProperty(t,e)}clone(){const t=new Ws;return t.updateAll(this),t}}class _t extends V{#t=null;#e=0;#i=null;#s=0;#n="";#r="";static _DEFAULT_OPACITY=1;static _DEFAULT_THICKNESS=12;static _defaultDrawingOptions=null;static _type="highlight";static _editorType=j.HIGHLIGHT;static get _keyboardManager(){const t=_t.prototype;return F(this,"_keyboardManager",new vt([[["ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.#t=t.anchorNode||null,this.#e=t.anchorOffset||0,this.#i=t.focusNode||null,this.#s=t.focusOffset||0,this.#n=t.methodOfCreation||(this._drawOutlines?.isFree?"main_toolbar":""),this.#r=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static initialize(t,e){N.initialize(t,e),this._defaultDrawingOptions||=new Ws({fill:e.highlightColors?.values().next().value||"#fff066","fill-opacity":_t._DEFAULT_OPACITY,thickness:_t._DEFAULT_THICKNESS})}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get typesMap(){return F(this,"typesMap",new Map([[z.HIGHLIGHT_COLOR,"fill"],[z.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(t){const{boxes:e,drawOutlines:i}=t;!e&&!i||(this._drawingOptions||=t.drawingOptions||_t.getDefaultDrawingOptions(),e&&(t={...t,drawOutlines:ys.build(e,this._uiManager.direction==="ltr")}),super._addOutlines(t))}get colorType(){return z.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){return this._drawOutlines?.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){return!this._drawOutlines?.isFree}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:this.#n}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}translateInPage(t,e){}get toolbarPosition(){return this.#a(this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return this.#a(this._drawOutlines.firstPoint)}#a([t,e]){const[i,s,n,r]=this._drawOutlines.box;return[(t-i)/n,(e-s)/r]}updateParams(t,e){switch(t){case z.HIGHLIGHT_COLOR:this._updateColorAndOpacity(e,_t._DEFAULT_OPACITY,t),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0);break;case z.HIGHLIGHT_THICKNESS:super.updateParams(t,e),this._reportTelemetry({action:"thickness_changed",thickness:e},!0);break}}get propertiesToUpdate(){const t=super.propertiesToUpdate;return t.push([z.HIGHLIGHT_FREE,this._drawOutlines.isFree]),t}get toolbarButtons(){return this._uiManager.highlightColors?(this._colorPicker=new jr({editor:this}),[["colorPicker",this._colorPicker]]):super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(t,e){return super.getRect(t,e,this._drawRotation)}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}
55render(){if(this.div)return this.div;const t=super.render();return this.#r&&(t.setAttribute("aria-label",this.#r),t.setAttribute("role","mark")),this._drawOutlines.isFree?t.classList.add("free"):t.addEventListener("keydown",this.#o.bind(this),{signal:this._uiManager._signal}),this.enableEditing(),t}#o(t){_t._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#l(!0);break;case 1:case 3:this.#l(!1);break}}#l(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#i,this.#s)}unselect(){super.unselect(),this._drawOutlines.isFree||this.#l(!1)}static createDrawerInstance({x:t,y:e,box:i,parent:s,isLTR:n}){return new Pl(t,e,i,s.scale,this._defaultDrawingOptions.thickness/2,n,.001)}static _getDrawingTarget(t,{target:e}){return e.closest(".textLayer")}static _getPointerCoords({x:t,y:e}){return[t,e]}static _addDrawingListeners(t,e){t.classList.add("free"),e.addEventListener("abort",()=>t.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:e}),window.addEventListener("pointerdown",at,{capture:!0,passive:!1,signal:e})}static _endDrawingSession(t=!1){return this.endDrawing(t)}createDrawingOptions({color:t,opacity:e,thickness:i}){const{_defaultDrawingOptions:s,_DEFAULT_OPACITY:n}=_t;this._drawingOptions=_t.getDefaultDrawingOptions({fill:k.makeHexColor(...t),"fill-opacity":e||n,thickness:i||s.thickness})}static deserializeDraw(t,e,i,s,n,r,a){const{quadPoints:o}=r;if(o){const f=[];for(let p=0,g=o.length;p<g;p+=8)f.push({x:(o[p]-t)/i,y:1-(o[p+1]-e)/s,width:(o[p+2]-o[p])/i,height:(o[p+1]-o[p+5])/s});return ys.build(f,a.direction==="ltr")}const l=r.thickness||this._defaultDrawingOptions.thickness,c=(r.inkLists||r.outlines.points)[0],d=new Hs(c[0]-t,s-(c[1]-e),[0,0,i,s],1,l/2,!0,.001);for(let f=0,p=c.length;f<p;f+=2)d.add(c[f]-t,s-(c[f+1]-e));const u=d.getOutlines();return u.buildFocusOutline(l),u}static async deserialize(t,e,i){let s=null;if(t instanceof Vr){const{data:{quadPoints:r,rect:a,rotation:o,id:l,color:c,opacity:d,popupRef:u,richText:f,contentsObj:p,creationDate:g,modificationDate:m},parent:{page:{pageNumber:b}}}=t;s=t={annotationType:j.HIGHLIGHT,color:Array.from(c),opacity:d,quadPoints:r,pageIndex:b-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:u,richText:f,comment:p?.str||null,creationDate:g,modificationDate:m}}else if(t instanceof Us){const{data:{inkLists:r,rect:a,rotation:o,id:l,color:c,borderStyle:{rawWidth:d},popupRef:u,richText:f,contentsObj:p,creationDate:g,modificationDate:m},parent:{page:{pageNumber:b}}}=t;s=t={annotationType:j.HIGHLIGHT,color:Array.from(c),thickness:d,inkLists:r,pageIndex:b-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:u,richText:f,comment:p?.str||null,creationDate:g,modificationDate:m}}const n=await super.deserialize(t,e,i);return n._initialData=s,t.comment&&n.setCommentData(t),n}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=super.serialize(t);return Object.assign(e,{color:N._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(e.rect,this._drawRotation)}),this.addComment(e),this.annotationElementId&&!this.#h(e)?null:(e.id=this.annotationElementId,e)}#h(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((i,s)=>i!==e[s])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class Tl{#t=new Float64Array(6);#e=new Float64Array(2);#i;#s;#n;#r;#a;#o="";#l=0;#h=new Ye;#u;#d;constructor(t,e,i,s,n,r){this.#u=i,this.#d=s,this.#n=n,this.#r=r,[t,e]=this.#f(t,e);const a=this.#i=[NaN,NaN,NaN,NaN,t,e];this.#a=[t,e],this.#s=[{line:a,points:this.#a}],this.#t.set(a,0),this.#e.set([t,e],0)}updateProperty(t,e){t==="stroke-width"&&(this.#r=e)}#f(t,e){return I._normalizePoint(t,e,this.#u,this.#d,this.#n)}isEmpty(){return!this.#s?.length}isCancellable(){return this.#a.length<=10}add(t,e){return this.#g(t,e)&&this.toSVGPath(),{path:{d:this.#m()}}}addPoints(t){let e=!1;for(let i=0,s=t.length;i<s;i+=2)this.#g(t[i],t[i+1])&&(e=!0,this.#a.length<=6&&(this.toSVGPath(),e=!1));return e&&this.toSVGPath(),{path:{d:this.#m()}}}#g(t,e){[t,e]=this.#f(t,e),this.#e.set([t,e],0);const[i,s,n,r]=this.#t.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#u*a,this.#d*o)<=2?!1:(this.#a.push(t,e),isNaN(i)?(this.#t.set([n,r,t,e],2),this.#i.push(NaN,NaN,NaN,NaN,t,e),!0):(isNaN(this.#t[0])&&this.#i.splice(6,6),this.#t.set([i,s,n,r,t,e],0),this.#i.push(...I.createBezierPoints(i,s,n,r,t,e)),!0))}end(t,e){return t!==void 0&&this.#g(t,e)?{path:{d:this.toSVGPath()}}:this.#a.length===2?{path:{d:this.toSVGPath()}}:{path:{d:this.#o}}}startNew(t,e,i,s,n){this.#u=i,this.#d=s,this.#n=n,[t,e]=this.#f(t,e);const r=this.#i=[NaN,NaN,NaN,NaN,t,e];this.#a=[t,e],this.#e.set([t,e],0);const a=this.#s.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#s.push({line:r,points:this.#a}),this.#t.set(r,0),this.#l=0,this.toSVGPath(),null}getLastElement(){return this.#s.at(-1)}setLastElement(t){return this.#s?(this.#s.push(t),this.#i=t.line,this.#a=t.points,this.#l=0,{path:{d:this.toSVGPath()}}):this.#h.setLastElement(t)}removeLastElement(){if(!this.#s)return this.#h.removeLastElement();this.#s.pop(),this.#o="";for(let t=0,e=this.#s.length;t<e;t++){const{line:i,points:s}=this.#s[t];this.#i=i,this.#a=s,this.#l=0,this.toSVGPath()}return{path:{d:this.#o}}}#m(){const t=I.svgRound(this.#e[0]),e=I.svgRound(this.#e[1]);if(this.#a.length===2){const i=I.svgRound(this.#i[4]),s=I.svgRound(this.#i[5]);return`${this.#o} M ${i} ${s} L ${t} ${e}`}return`${this.#o} L ${t} ${e}`}toSVGPath(){const t=I.svgRound(this.#i[4]),e=I.svgRound(this.#i[5]);if(this.#a.length===2)return this.#o=`${this.#o} M ${t} ${e} Z`,this.#o;if(this.#a.length<=6){const s=this.#o.lastIndexOf("M");this.#o=`${this.#o.slice(0,s)} M ${t} ${e}`,this.#l=6}if(this.#a.length===4){const s=I.svgRound(this.#i[10]),n=I.svgRound(this.#i[11]);return this.#o=`${this.#o} L ${s} ${n}`,this.#l=12,this.#o}const i=[];this.#l===0&&(i.push(`M ${t} ${e}`),this.#l=6);for(let s=this.#l,n=this.#i.length;s<n;s+=6){const[r,a,o,l,c,d]=this.#i.slice(s,s+6).map(I.svgRound);i.push(`C${r} ${a} ${o} ${l} ${c} ${d}`)}return this.#o+=i.join(" "),this.#l=this.#i.length,this.#o}getOutlines(t,e,i,s){const n=this.#s.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#h.build(this.#s,t,e,i,this.#n,this.#r,s),this.#t=null,this.#i=null,this.#s=null,this.#o=null,this.#h}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Ye extends I{#t;#e=0;#i;#s;#n;#r;#a;#o;#l;build(t,e,i,s,n,r,a){this.#n=e,this.#r=i,this.#a=s,this.#o=n,this.#l=r,this.#i=a??0,this.#s=t,this.#d()}get thickness(){return this.#l}setLastElement(t){return this.#s.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#s.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#s){if(t.push(`M${I.svgRound(e[4])} ${I.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${I.svgRound(e[10])} ${I.svgRound(e[11])}`);continue}for(let i=6,s=e.length;i<s;i+=6){const[n,r,a,o,l,c]=e.subarray(i,i+6).map(I.svgRound);t.push(`C${n} ${r} ${a} ${o} ${l} ${c}`)}}return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,l,c,d]=this.#u();let u,f,p,g,m,b,y,w,A;switch(this.#o){case 0:A=I._rescale,u=t,f=e+s,p=i,g=-s,m=t+o*i,b=e+(1-l-d)*s,y=t+(o+c)*i,w=e+(1-l)*s;break;case 90:A=I._rescaleAndSwap,u=t,f=e,p=i,g=s,m=t+l*i,b=e+o*s,y=t+(l+d)*i,w=e+(o+c)*s;break;case 180:A=I._rescale,u=t+i,f=e,p=-i,g=s,m=t+(1-o-c)*i,b=e+l*s,y=t+(1-o)*i,w=e+(l+d)*s;break;case 270:A=I._rescaleAndSwap,u=t+i,f=e+s,p=-i,g=-s,m=t+(1-l-d)*i,b=e+(1-o-c)*s,y=t+(1-l)*i,w=e+(1-o)*s;break}for(const{line:v,points:E}of this.#s)r.push(A(v,u,f,p,g,n?new Array(v.length):null)),a.push(A(E,u,f,p,g,n?new Array(E.length):null));return{lines:r,points:a,rect:[m,b,y,w]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const c=[];let d,u,f,p,g;switch(o){case 0:g=I._rescale,d=-t/i,u=e/s+1,f=1/i,p=-1/s;break;case 90:g=I._rescaleAndSwap,d=-e/s,u=-t/i,f=1/s,p=1/i;break;case 180:g=I._rescale,d=t/i+1,u=-e/s,f=-1/i,p=1/s;break;case 270:g=I._rescaleAndSwap,d=e/s+1,u=t/i+1,f=-1/s,p=-1/i;break}if(!r){r=[];for(const b of a){const y=b.length;if(y===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,b[0],b[1]]));continue}if(y===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,b[0],b[1],NaN,NaN,NaN,NaN,b[2],b[3]]));continue}const w=new Float32Array(3*(y-2));
vendor: 8,952 bytes, line 55
55r.push(w);let[A,v,E,_]=b.subarray(0,4);w.set([NaN,NaN,NaN,NaN,A,v],0);for(let C=4;C<y;C+=2){const S=b[C],P=b[C+1];w.set(I.createBezierPoints(A,v,E,_,S,P),(C-2)*3),[A,v,E,_]=[E,_,S,P]}}}for(let b=0,y=r.length;b<y;b++)c.push({line:g(r[b].map(w=>w??NaN),d,u,f,p),points:g(a[b].map(w=>w??NaN),d,u,f,p)});const m=new this.prototype.constructor;return m.build(c,i,s,1,o,l,n),m}#h(t=this.#l){const e=this.#i+t/2*this.#a;return this.#o%180===0?[e/this.#n,e/this.#r]:[e/this.#r,e/this.#n]}#u(){const[t,e,i,s]=this.#t,[n,r]=this.#h(0);return[t+n,e+r,i-2*n,s-2*r]}#d(){const t=this.#t=ee.slice();for(const{line:s}of this.#s){if(s.length<=12){for(let a=4,o=s.length;a<o;a+=6)k.pointBoundingBox(s[a],s[a+1],t);continue}let n=s[4],r=s[5];for(let a=6,o=s.length;a<o;a+=6){const[l,c,d,u,f,p]=s.subarray(a,a+6);k.bezierBoundingBox(n,r,l,c,d,u,f,p,t),n=f,r=p}}const[e,i]=this.#h();t[0]=Q(t[0]-e,0,1),t[1]=Q(t[1]-i,0,1),t[2]=Q(t[2]+e,0,1),t[3]=Q(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){const[e,i]=this.#h();this.#l=t;const[s,n]=this.#h(),[r,a]=[s-e,n-i],o=this.#t;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[s,n]=this.#h();this.#n=t,this.#r=e,this.#a=i;const[r,a]=this.#h(),o=r-s,l=a-n,c=this.#t;return c[0]-=o,c[1]-=l,c[2]+=2*o,c[3]+=2*l,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(I.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${I.svgRound(t)} ${I.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#t;let i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#e){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${I.svgRound(a)} ${I.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#h(),[a,o,l,c]=this.#t;if(Math.abs(l-n)<=I.PRECISION||Math.abs(c-r)<=I.PRECISION){const g=t+i/2-(a+l/2),m=e+s/2-(o+c/2);return{path:{"transform-origin":`${I.svgRound(t)} ${I.svgRound(e)}`,transform:`${this.rotationTransform} translate(${g} ${m})`}}}const d=(i-2*n)/(l-2*n),u=(s-2*r)/(c-2*r),f=l/i,p=c/s;return{path:{"transform-origin":`${I.svgRound(a)} ${I.svgRound(o)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${I.svgRound(n)} ${I.svgRound(r)}) scale(${d} ${u}) translate(${I.svgRound(-n)} ${I.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#h(),a=this.#t,[o,l,c,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(c-n)<=I.PRECISION||Math.abs(d-r)<=I.PRECISION){const m=t+i/2-(o+c/2),b=e+s/2-(l+d/2);for(const{line:y,points:w}of this.#s)I._translate(y,m,b,y),I._translate(w,m,b,w);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${I.svgRound(t)} ${I.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(i-2*n)/(c-2*n),f=(s-2*r)/(d-2*r),p=-u*(o+n)+t+n,g=-f*(l+r)+e+r;if(u!==1||f!==1||p!==0||g!==0)for(const{line:m,points:b}of this.#s)I._rescale(m,p,g,u,f,m),I._rescale(b,p,g,u,f,b);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${I.svgRound(t)} ${I.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#t,a=t-r[0],o=e-r[1];if(this.#n===s&&this.#r===n)for(const{line:l,points:c}of this.#s)I._translate(l,a,o,l),I._translate(c,a,o,c);else{const l=this.#n/s,c=this.#r/n;this.#n=s,this.#r=n;for(const{line:d,points:u}of this.#s)I._rescale(d,a,o,l,c,d),I._rescale(u,a,o,l,c,u);r[2]*=l,r[3]*=c}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${I.svgRound(t)} ${I.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${I.svgRound(t[0])} ${I.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Ri extends Vs{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:N._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Ri(this._viewParameters);return t.updateAll(this),t}}class Gs extends V{static _type="ink";static _editorType=j.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){N.initialize(t,e),this._defaultDrawingOptions=new Ri(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return F(this,"typesMap",new Map([[z.INK_THICKNESS,"stroke-width"],[z.INK_COLOR,"stroke"],[z.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:t,y:e,box:[,,i,s],rotation:n}){return new Tl(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return Ye.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof Us){const{data:{inkLists:r,rect:a,rotation:o,id:l,color:c,opacity:d,borderStyle:{rawWidth:u},popupRef:f,richText:p,contentsObj:g,creationDate:m,modificationDate:b},parent:{page:{pageNumber:y}}}=t;s=t={annotationType:j.INK,color:Array.from(c),thickness:u,opacity:d,paths:{points:r},boxes:null,pageIndex:y-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:f,richText:p,comment:g?.str||null,creationDate:m,modificationDate:b}}const n=await super.deserialize(t,e,i);return n._initialData=s,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||=new Ue(this),[["colorPicker",this._colorPicker]]}get colorType(){return z.INK_COLOR}get colorAndOpacityType(){return z.INK_COLOR_AND_OPACITY}get opacityType(){return z.INK_OPACITY}updateParams(t,e){if(t===z.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===z.INK_COLOR_AND_OPACITY){super.updateDefaultParams(z.INK_COLOR,e.color),super.updateDefaultParams(z.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=Gs.getDefaultDrawingOptions({stroke:k.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:N._colorManager.convert(s),opacity:n,thickness:r,paths:{lines:e,points:i}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#t(a)?null:(a.id=this.annotationElementId,a)}#t(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class ws extends Ye{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const ei=8,Te=3;let pe=class{static#t={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#e(t,e,i,s){return i-=t,s-=e,i===0?s>0?0:4:i===1?s+6:2-s}static#i=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#s(t,e,i,s,n,r,a){const o=this.#e(i,s,n,r);for(let l=0;l<8;l++){const c=(-l+o-a+16)%8,d=this.#i[2*c],u=this.#i[2*c+1];if(t[(i+d)*e+(s+u)]!==0)return c}return-1}static#n(t,e,i,s,n,r,a){const o=this.#e(i,s,n,r);for(let l=0;l<8;l++){const c=(l+o+a+16)%8,d=this.#i[2*c],u=this.#i[2*c+1];if(t[(i+d)*e+(s+u)]!==0)return c}return-1}static#r(t,e,i,s){const n=t.length,r=new Int32Array(n);for(let c=0;c<n;c++)r[c]=t[c]<=s?1:0;for(let c=1;c<i-1;c++)r[c*e]=r[c*e+e-1]=0;for(let c=0;c<e;c++)r[c]=r[e*i-1-c]=0;let a=1,o;const l=[];for(let c=1;c<i-1;c++){o=1;for(let d=1;d<e-1;d++){const u=c*e+d,f=r[u];
55if(f===0)continue;let p=c,g=d;if(f===1&&r[u-1]===0)a+=1,g-=1;else if(f>=1&&r[u+1]===0)a+=1,g+=1,f>1&&(o=f);else{f!==1&&(o=Math.abs(f));continue}const m=[d,c],b=g===d+1,y={isHole:b,points:m,id:a,parent:0};l.push(y);let w;for(const T of l)if(T.id===o){w=T;break}w?w.isHole?y.parent=b?w.parent:o:y.parent=b?o:w.parent:y.parent=b?o:0;const A=this.#s(r,e,c,d,p,g,0);if(A===-1){r[u]=-a,r[u]!==1&&(o=Math.abs(r[u]));continue}let v=this.#i[2*A],E=this.#i[2*A+1];const _=c+v,C=d+E;p=_,g=C;let S=c,P=d;for(;;){const T=this.#n(r,e,S,P,p,g,1);v=this.#i[2*T],E=this.#i[2*T+1];const M=S+v,L=P+E;m.push(L,M);const D=S*e+P;if(r[D+1]===0?r[D]=-a:r[D]===1&&(r[D]=a),M===c&&L===d&&S===_&&P===C){r[u]!==1&&(o=Math.abs(r[u]));break}else p=S,g=P,S=M,P=L}}}return l}static#a(t,e,i,s){if(i-e<=4){for(let _=e;_<i-2;_+=2)s.push(t[_],t[_+1]);return}const n=t[e],r=t[e+1],a=t[i-4]-n,o=t[i-3]-r,l=Math.hypot(a,o),c=a/l,d=o/l,u=c*r-d*n,f=o/a,p=1/l,g=Math.atan(f),m=Math.cos(g),b=Math.sin(g),y=p*(Math.abs(m)+Math.abs(b)),w=p*(1-y+y**2),A=Math.max(Math.atan(Math.abs(b+m)*w),Math.atan(Math.abs(b-m)*w));let v=0,E=e;for(let _=e+2;_<i-2;_+=2){const C=Math.abs(u-c*t[_+1]+d*t[_]);C>v&&(E=_,v=C)}v>(l*A)**2?(this.#a(t,e,E+2,s),this.#a(t,E,i,s)):s.push(n,r)}static#o(t){const e=[],i=t.length;return this.#a(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#l(t,e,i,s,n,r){const a=new Float32Array(r**2),o=-2*s**2,l=r>>1;for(let g=0;g<r;g++){const m=(g-l)**2;for(let b=0;b<r;b++)a[g*r+b]=Math.exp((m+(b-l)**2)/o)}const c=new Float32Array(256),d=-2*n**2;for(let g=0;g<256;g++)c[g]=Math.exp(g**2/d);const u=t.length,f=new Uint8Array(u),p=new Uint32Array(256);for(let g=0;g<i;g++)for(let m=0;m<e;m++){const b=g*e+m,y=t[b];let w=0,A=0;for(let E=0;E<r;E++){const _=g+E-l;if(!(_<0||_>=i))for(let C=0;C<r;C++){const S=m+C-l;if(S<0||S>=e)continue;const P=t[_*e+S],T=a[E*r+C]*c[Math.abs(P-y)];w+=P*T,A+=T}}const v=f[b]=Math.round(w/A);p[v]++}return[f,p]}static#h(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#u(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let s=-1/0,n=1/0;for(let a=0,o=i.length;a<o;a++){const l=i[a]=t[a<<2];s=Math.max(s,l),n=Math.min(n,l)}const r=255/(s-n);for(let a=0,o=i.length;a<o;a++)i[a]=(i[a]-n)*r;return i}static#d(t){let e,i=-1/0,s=-1/0;const n=t.findIndex(o=>o!==0);let r=n,a=n;for(e=n;e<256;e++){const o=t[e];o>i&&(e-r>s&&(s=e-r,a=e-1),i=o,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#f(t){const e=t,{width:i,height:s}=t,{maxDim:n}=this.#t;let r=i,a=s;if(i>n||s>n){let u=i,f=s,p=Math.log2(Math.max(i,s)/n);const g=Math.floor(p);p=p===g?g-1:g;for(let b=0;b<p;b++){r=Math.ceil(u/2),a=Math.ceil(f/2);const y=new OffscreenCanvas(r,a);y.getContext("2d").drawImage(t,0,0,u,f,0,0,r,a),u=r,f=a,t!==e&&t.close(),t=y.transferToImageBitmap()}const m=Math.min(n/r,n/a);r=Math.round(r*m),a=Math.round(a*m)}const l=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});l.fillStyle="white",l.fillRect(0,0,r,a),l.filter="grayscale(1)",l.drawImage(t,0,0,t.width,t.height,0,0,r,a);const c=l.getImageData(0,0,r,a).data;return[this.#u(c),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,r,a,o){let l=new OffscreenCanvas(1,1),c=l.getContext("2d",{alpha:!1});const d=200,u=c.font=`${i} ${s} ${d}px ${e}`,{actualBoundingBoxLeft:f,actualBoundingBoxRight:p,actualBoundingBoxAscent:g,actualBoundingBoxDescent:m,fontBoundingBoxAscent:b,fontBoundingBoxDescent:y,width:w}=c.measureText(t),A=1.5,v=Math.ceil(Math.max(Math.abs(f)+Math.abs(p)||0,w)*A),E=Math.ceil(Math.max(Math.abs(g)+Math.abs(m)||d,Math.abs(b)+Math.abs(y)||d)*A);l=new OffscreenCanvas(v,E),c=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=u,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,v,E),c.fillStyle="black",c.fillText(t,v*(A-1)/2,E*(3-A)/2);const _=this.#u(c.getImageData(0,0,v,E).data),C=this.#h(_),S=this.#d(C),P=this.#r(_,v,E,S);return this.processDrawnLines({lines:{curves:P,width:v,height:E},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){const[r,a,o]=this.#f(t),[l,c]=this.#l(r,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),d=this.#d(c),u=this.#r(l,a,o,d);return this.processDrawnLines({lines:{curves:u,width:a,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:r,areContours:a}){s%180!==0&&([e,i]=[i,e]);const{curves:o,width:l,height:c}=t,d=t.thickness??0,u=[],f=Math.min(e/l,i/c),p=f/e,g=f/i,m=[];for(const{points:y}
55of o){const w=r?this.#o(y):y;if(!w)continue;m.push(w);const A=w.length,v=new Float32Array(A),E=new Float32Array(3*(A===2?2:A-2));if(u.push({line:E,points:v}),A===2){v[0]=w[0]*p,v[1]=w[1]*g,E.set([NaN,NaN,NaN,NaN,v[0],v[1]],0);continue}let[_,C,S,P]=w;_*=p,C*=g,S*=p,P*=g,v.set([_,C,S,P],0),E.set([NaN,NaN,NaN,NaN,_,C],0);for(let T=4;T<A;T+=2){const M=v[T]=w[T]*p,L=v[T+1]=w[T+1]*g;E.set(I.createBezierPoints(_,C,S,P,M,L),(T-2)*3),[_,C,S,P]=[S,P,M,L]}}if(u.length===0)return null;const b=a?new ws:new Ye;return b.build(u,e,i,1,s,a?0:d,n),{outline:b,newCurves:m,areContours:a,thickness:d,width:l,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let r=1/0,a=-1/0,o=0;for(const y of t){o+=y.length;for(let w=2,A=y.length;w<A;w++){const v=y[w]-y[w-2];r=Math.min(r,v),a=Math.max(a,v)}}let l;r>=-128&&a<=127?l=Int8Array:r>=-32768&&a<=32767?l=Int16Array:l=Int32Array;const c=t.length,d=ei+Te*c,u=new Uint32Array(d);let f=0;u[f++]=d*Uint32Array.BYTES_PER_ELEMENT+(o-2*c)*l.BYTES_PER_ELEMENT,u[f++]=0,u[f++]=s,u[f++]=n,u[f++]=e?0:1,u[f++]=Math.max(0,Math.floor(i??0)),u[f++]=c,u[f++]=l.BYTES_PER_ELEMENT;for(const y of t)u[f++]=y.length-2,u[f++]=y[0],u[f++]=y[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(u);const m=l.prototype.constructor;for(const y of t){const w=new m(y.length-2);for(let A=2,v=y.length;A<v;A++)w[A-2]=y[A]-y[A-2];g.write(w)}return g.close(),(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:i,writable:s}=new DecompressionStream("deflate-raw"),n=s.getWriter();await n.ready,n.write(e).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let r=null,a=0;for await(const w of i)r||=new Uint8Array(new Uint32Array(w.buffer,0,4)[0]),r.set(w,a),a+=w.length;const o=new Uint32Array(r.buffer,0,r.length>>2),l=o[1];if(l!==0)throw new Error(`Invalid version: ${l}`);const c=o[2],d=o[3],u=o[4]===0,f=o[5],p=o[6],g=o[7],m=[],b=(ei+Te*p)*Uint32Array.BYTES_PER_ELEMENT;let y;switch(g){case Int8Array.BYTES_PER_ELEMENT:y=new Int8Array(r.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:y=new Int16Array(r.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:y=new Int32Array(r.buffer,b);break}a=0;for(let w=0;w<p;w++){const A=o[Te*w+ei],v=new Float32Array(A+2);m.push(v);for(let E=0;E<Te-1;E++)v[E]=o[Te*w+ei+E+1];for(let E=0;E<A;E++)v[E+2]=v[E]+y[a++]}return{areContours:u,thickness:f,outlines:m,width:c,height:d}}catch(e){return $(`decompressSignature: ${e}`),null}}};class Xs extends Vs{constructor(){super(),super.updateProperties({fill:N._defaultLineColor,"stroke-width":0})}clone(){const t=new Xs;return t.updateAll(this),t}}class Ys extends Ri{constructor(t){super(t),super.updateProperties({stroke:N._defaultLineColor,"stroke-width":1})}clone(){const t=new Ys(this._viewParameters);return t.updateAll(this),t}}class It extends V{#t=!1;#e=null;#i=null;#s=null;static _type="signature";static _editorType=j.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#i=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){N.initialize(t,e),this._defaultDrawingOptions=new Xs,this._defaultDrawnSignatureOptions=new Ys(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return F(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(this.#i){const{lines:s,mustSmooth:n,areContours:r,description:a,uuid:o,heightInPage:l}=this.#i,{rawDims:{pageWidth:c,pageHeight:d},rotation:u}=this.parent.viewport,f=pe.processDrawnLines({lines:s,pageWidth:c,pageHeight:d,rotation:u,innerMargin:It._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(f,l,a,o)}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:this.#e||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#s=t,this.addEditToolbar()}getUuid(){return this.#s}get description(){return this.#e}set description(t){this.#e=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#i,r=Math.max(s,n),a=pe.processDrawnLines({lines:{curves:t.map(o=>({points:o})),thickness:i,width:s,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,s){const{x:n,y:r}=this,{outline:a}=this.#i=t;this.#t=a instanceof ws,this.description=i;let o;this.#t?o=It.getDefaultDrawingOptions():(o=It._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let c=e/l;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(),this.x=n,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;
55return pe.process(t,e,i,s,It._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return pe.extractContoursFromText(t,e,i,s,n,It._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return pe.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:It._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=It.getDefaultDrawingOptions():(this._drawingOptions=It._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:s});return this.addComment(n),t?(n.paths={lines:e,points:i},n.uuid=this.#s,n.isCopy=!0):n.lines=e,this.#e&&(n.accessibilityData={type:"Figure",alt:this.#e}),n}static deserializeDraw(t,e,i,s,n,r){return r.areContours?ws.deserialize(t,e,i,s,n,r):Ye.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){const s=await super.deserialize(t,e,i);return s.#t=t.areContours,s.description=t.accessibilityData?.alt||"",s.#s=t.uuid,s}}class kl extends N{#t=null;#e=null;#i=null;#s=null;#n=null;#r="";#a=null;#o=!1;#l=null;#h=!1;#u=!1;static _type="stamp";static _editorType=j.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#s=t.bitmapUrl,this.#n=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){N.initialize(t,e)}static isHandlingMimeForPasting(t){return ls.includes(t)}static paste(t,e){e.pasteEditor({mode:j.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#h=t.isSvg),t.file&&(this.#r=t.file.name),this.#m()}#f(){if(this.#i=null,this._uiManager.enableWaiting(!1),!!this.#a){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!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:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#g(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(i=>this.#d(i,!0)).finally(()=>this.#f());return}if(this.#s){const i=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromUrl(i).then(s=>this.#d(s)).finally(()=>this.#f());return}if(this.#n){const i=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromFile(i).then(s=>this.#d(s)).finally(()=>this.#f());return}const t=document.createElement("input");t.type="file",t.accept=ls.join(",");const e=this._uiManager._signal;this.#i=new Promise(i=>{t.addEventListener("change",async()=>
55{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const s=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(s)}i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#f()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#a?.remove(),this.#a=null,this.#l&&(clearTimeout(this.#l),this.#l=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#g();return}super.rebuild(),this.div!==null&&(this.#e&&this.#a===null&&this.#g(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#i||this.#t||this.#s||this.#n||this.#e||this.#o)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#o||(this.#t?this.#m():this.#g()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#e=i,s&&(this.#t=s),this.#o=!1,this.#m())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#l!==null&&clearTimeout(this.#l);const t=200;this.#l=setTimeout(()=>{this.#l=null,this.#p()},t)}#m(){const{div:t}=this;let{width:e,height:i}=this.#t;const[s,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>r*s||i>r*n){const o=Math.min(r*s/e,r*n/i);e*=o,i*=o}this._uiManager.enableWaiting(!1);const a=this.#a=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/s,this.height=i/n,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#p(),this.#u||(this.parent.addUndoableEditor(this),this.#u=!0),this._reportTelemetry({action:"inserted_image"}),this.#r&&this.div.setAttribute("aria-description",this.#r),this.annotationElementId||this._uiManager.a11yAlert(N._l10nAlert.stamp)}copyCanvas(t,e,i=!1){t||=224;const{width:s,height:n}=this.#t,r=new Wt;let a=this.#t,o=s,l=n,c=null;if(e){if(s>e||n>e){const E=Math.min(e/s,e/n);o=Math.floor(s*E),l=Math.floor(n*E)}c=document.createElement("canvas");const u=c.width=Math.ceil(o*r.sx),f=c.height=Math.ceil(l*r.sy);this.#h||(a=this.#c(u,f));const p=c.getContext("2d");p.filter=this._uiManager.hcmFilter;let g="white",m="#cfcfd8";this._uiManager.hcmFilter!=="none"?m="black":Ra.isDarkMode&&(g="#8f8f9d",m="#42414d");const b=15,y=b*r.sx,w=b*r.sy,A=new OffscreenCanvas(y*2,w*2),v=A.getContext("2d");v.fillStyle=g,v.fillRect(0,0,y*2,w*2),v.fillStyle=m,v.fillRect(0,0,y,w),v.fillRect(y,w,y,w),p.fillStyle=p.createPattern(A,"repeat"),p.fillRect(0,0,u,f),p.drawImage(a,0,0,a.width,a.height,0,0,u,f)}let d=null;if(i){let u,f;if(r.symmetric&&a.width<t&&a.height<t)u=a.width,f=a.height;else if(a=this.#t,s>t||n>t){const m=Math.min(t/s,t/n);u=Math.floor(s*m),f=Math.floor(n*m),this.#h||(a=this.#c(u,f))}const g=new OffscreenCanvas(u,f).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,u,f),d={width:u,height:f,data:g.getImageData(0,0,u,f).data}}return{canvas:c,width:o,height:l,imageData:d}}#c(t,e){const{width:i,height:s}=this.#t;let n=i,r=s,a=this.#t;for(;n>2*t||r>2*e;){const o=n,l=r;n>2*t&&(n=Math.ceil(n/2)),r>2*e&&(r=Math.ceil(r/2));const c=new OffscreenCanvas(n,r);c.getContext("2d").drawImage(a,0,0,o,l,0,0,n,r),a=c.transferToImageBitmap()}return a}#p(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Wt,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=this.#a;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#h?this.#t:this.#c(r,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#b(t){if(t){if(this.#h){const s=this._uiManager.imageManager.getSvgUrl(this.#e);if(s)return s}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#h){const[e,i]=this.pageDimensions,s=Math.round(this.width*e*Se.PDF_TO_CSS_UNITS),n=Math.round(this.height*i*Se.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(s,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.he
55ight,0,0,s,n),r.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,i){let s=null,n=!1;if(t instanceof Hr){const{data:{rect:g,rotation:m,id:b,structParent:y,popupRef:w,richText:A,contentsObj:v,creationDate:E,modificationDate:_},container:C,parent:{page:{pageNumber:S}},canvas:P}=t;let T,M;P?(delete t.canvas,{id:T,bitmap:M}=i.imageManager.getFromCanvas(C.id,P),P.remove()):(n=!0,t._hasNoCanvas=!0);const L=(await e._structTree.getAriaAttributes(`${me}${b}`))?.get("aria-label")||"";s=t={annotationType:j.STAMP,bitmapId:T,bitmap:M,pageIndex:S-1,rect:g.slice(0),rotation:m,annotationElementId:b,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:L},isSvg:!1,structParent:y,popupRef:w,richText:A,comment:v?.str||null,creationDate:E,modificationDate:_}}const r=await super.deserialize(t,e,i),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:c,isSvg:d,accessibilityData:u}=t;n?(i.addMissingCanvas(t.id,r),r.#o=!0):c&&i.imageManager.isValidId(c)?(r.#e=c,o&&(r.#t=o)):r.#s=l,r.#h=d;const[f,p]=r.pageDimensions;return r.width=(a[2]-a[0])/f,r.height=(a[3]-a[1])/p,u&&(r.altTextData=u),r._initialData=s,t.comment&&r.setCommentData(t),r.#u=!!s,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#h});if(this.addComment(i),t)return i.bitmapUrl=this.#b(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const a=this.#y(i);return a.isSame?null:(a.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(e===null)return i;e.stamps||=new Map;const r=this.#h?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:i}),i.bitmap=this.#b(!1);else if(this.#h){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#b(!1))}return i}#y(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}let Ml=class Ut{#t;#e=!1;#i=null;#s=null;#n=null;#r=new Map;#a=!1;#o=!1;#l=!1;#h=null;#u=null;#d=null;#f=null;#g=null;#m=-1;#c;static _initialized=!1;static#p=new Map([ot,Gs,kl,_t,It].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:c}){const d=[...Ut.#p.values()];if(!Ut._initialized){Ut._initialized=!0;for(const u of d)u.initialize(c,t)}t.registerEditorTypes(d),this.#c=t,this.pageIndex=e,this.div=i,this.#t=n,this.#i=r,this.viewport=l,this.#d=o,this.drawLayer=a,this._structTree=s,this.#c.addLayer(this)}get isEmpty(){return this.#r.size===0}get isInvisible(){return this.isEmpty&&this.#c.getMode()===j.NONE}updateToolbar(t){this.#c.updateToolbar(t)}updateMode(t=this.#c.getMode()){switch(this.#A(),t){case j.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case j.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case j.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===j.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const i of Ut.#p.values())e.toggle(`${i._type}Editing`,t===i._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#c.setEditingState(t)}addCommands(t){this.#c.addCommands(t)}cleanUndoStack(t){this.#c.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#i?.togglePointerEvents(t)}get#b(){return this.#r.size!==0?this.#r.values():this.#c.getEditors(this.pageIndex)}async enable(){this.#l=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#g?.abort(),this.#g=null;const t=new Set;for(const i of this.#b)i.enableEditing(),i.show(!0),i.annotationElementId&&(this.#c.removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=this.#i;if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),this.#c.isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const s=await this.deserialize(i);s&&(this.addOrRebuild(s),s.enableEditing())}this.#l=!1,this.#c._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#d&&!this.#g){this.#g=new AbortController;const s=this.#c.combinedSignal(this.#g);this.#d.div.addEventListener("pointerdown",n=>{const{clientX:a,clientY:o,timeStamp:l}=n,c=this.#m;if(l-c>500){this.#m=l;return}this.#m=-1;const{classList:d}=this.div;d.toggle("getElements",!0);const u=document.elementsFromPoint(a,o);if(d.toggle("getElements",!1),!this.div.contains(u[0]))return;let f;const p=new RegExp(`^${Ee}[0-9]+$`);for(const m of u)if(p.test(m.id)){f=m.id;break}if(!f)return;const g=this.#r.get(f);g?.annotationElementId===null&&(at(n),g.dblclick(n))},{signal:s,capture:!0})}const t=this.#i,e=[];
55if(t){const s=new Map,n=new Map;for(const r of this.#b){if(r.disableEditing(),!r.annotationElementId){e.push(r);continue}if(r.serialize()!==null){s.set(r.annotationElementId,r);continue}else n.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}for(const r of t.getEditableAnnotations()){const{id:a}=r.data;if(this.#c.isDeletedAnnotationElement(a)){r.updateEdited({deleted:!0});continue}let o=n.get(a);if(o){o.resetAnnotationElement(r),o.show(!1),r.show();continue}o=s.get(a),o&&(this.#c.addChangedExistingAnnotation(o),o.renderAnnotationElement(r)&&o.show(!1)),r.show()}}this.#A(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const s of Ut.#p.values())i.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o=!1}getEditableAnnotation(t){return this.#i?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#c.getActive()!==t&&this.#c.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;const t=this.#c.combinedSignal(this.#f);this.#d.div.addEventListener("pointerdown",this.#y.bind(this),{signal:t}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#d.div.classList.remove("highlighting"))}#y(t){this.#c.unselectAll();const{target:e}=t;if(e===this.#d.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#d.div.contains(e)){const{isMac:i}=Y.platform;if(t.button!==0||t.ctrlKey&&i)return;this.#c.showAllEditors("highlight",!0,!0),_t.startDrawing(this,this.#c,this.#c.direction==="ltr",t),t.preventDefault()}}enableClick(){if(this.#s)return;this.#s=new AbortController;const t=this.#c.combinedSignal(this.#s);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(){this.#s?.abort(),this.#s=null}attach(t){this.#r.set(t.id,t);const{annotationElementId:e}=t;e&&this.#c.isDeletedAnnotationElement(e)&&this.#c.removeDeletedAnnotationElement(t)}detach(t){this.#r.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId&&this.#c.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#c.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#c.addDeletedAnnotationElement(t),N.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.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),this.#c.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#l),this.#c.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#n&&(t._focusEventsAllowed=!1,this.#n=setTimeout(()=>{this.#n=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#c._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),i=()=>{t.remove()};this.addCommands({cmd:e,undo:i,mustExec:!1})}getEditorByUID(t){for(const e of this.#r.values())if(e.uid===t)return e;return null}get#w(){return Ut.#p.get(this.#c.getMode())}combinedSignal(t){return this.#c.combinedSignal(t)}#v(t){const e=this.#w;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#w?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#c.updateMode(t.mode);const{offsetX:i,offsetY:s}=this.#E(),n=this.#c.getId(),r=this.#v({parent:this,id:n,x:i,y:s,uiManager:this.#c,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await Ut.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#c)||null}createAndAddNewEditor(t,e,i={}){const s=this.#c.getId(),n=this.#v({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#c,isCentered:e,...i});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}#E(){const{x:t,y:e,width:i,height:s}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+s),l=(n+a)/2-t,c=(r+o)/2-e,[d,u]=this.viewport.rotation%180===0?[l,c]:[c,l];return{offsetX:d,offsetY:u}}addNewEditor(t={}){this.createAndAddNewEditor(this.#E(),!0,t)}setSelected(t){this.#c.setSelected(t)}toggleSelected(t){this.#c.toggleSelected(t)}unselect(t){this.#c.unselect(t)}pointerup(t){const{isMac:e}=Y.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!this.#a||(this.#a=!1,this.#w?.isDrawer&&this.#w.supportMultipleDrawings))return;if(!this.#e){this.#e=!0;return}const i=this.#c.getMode();if(i===j.STAMP||i===j.POPUP||i===j.SIGNATURE){this.#c.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#c.getMode()===j.HIGHLIGHT&&this.enableTextSelection(),this.#a){this.#a=!1;return}const{isMac:e}=Y.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#a=!0,this.#w?.isDrawer){this.startDrawingSession(t);return}const i=this.#c.getActive();this.#e=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#h){this.#w.startDrawing(this,this.#c,!1,t);return}this.#c.setCurrentDrawingSession(this),this.#h=new AbortController;const e=this.#c.combinedSignal(this.#h);this.div.addEventListener("blur",({relatedTarget:i})=>{i&&!this.div.contains(i)&&(this.#u=null,this.commitOrRemove())},{signal:e}),this.#w.startDrawing(this,this.#c,!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){return this.#h?(this.#c.setCurrentDrawingSession(null),this.#h.abort(),this.#h=null,this.#u=null,this.#w.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#c.findParent(e,i);return s===null||s===this?!1:(s.changeParent(t),!0)}commitOrRemove(){return this.#h?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#h&&this.#w.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#c.getActive()?.parent===this&&(this.#c.commitOrRemove(),this.#c.setActiveEditor(null)),this.#n&&(clearTimeout(this.#n),this.#n=null);for(const t of this.#r.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#r.clear(),this.#c.removeLayer(this)}#A(){for(const t of this.#r.values())t.isEmpty()&&t.remove()}async render({viewport:t}){this.viewport=t,ne(this.div,t);for(const e of this.#c.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#c.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#c.commitOrRemove(),this.#A();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,ne(this.div,{rotation:i}),e!==i)for(const s of this.#r.values())s.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#c.viewParameters.realScale}};function Il(h,t){return h===t?0:h.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function ii(h){return h?h.nodeType===Node.ELEMENT_NODE?h.closest(".textLayer"):h.parentElement?.closest(".textLayer")||null:null}function Ll(h,t,e,i){if(h===e)return t<=i;const s=h.compareDocumentPosition(e);return s&Node.DOCUMENT_POSITION_FOLLOWING?!0:s&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function In(h,t,e){if(h.nodeType!==Node.ELEMENT_NODE||!h.classList.contains("textLayer")||t!==h.childNodes.length)return{container:h,offset:t};let i=h.lastChild;return i?.nodeType===Node.ELEMENT_NODE&&i.classList.contains("endOfContent")&&(i=i.previousSibling),!i||!e.contains(i)?null:i.nodeType===Node.TEXT_NODE?{container:i,offset:i.textContent.length}:{container:i,offset:i.childNodes.length}}let Dl=class B{#t=null;#e=new Map;#i=null;#s=null;#n=null;#r=null;#a=new Map;static#o=0;static#l=0;static#h=null;static#u=new Set;static#d=!1;static#f=new Set;static#g=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:i,textLayer:s=null}){if(this.pageIndex=i,this.#s=t,this.#n=e,s){const n=B.#g.get(s);if(n?.selectionDiv&&(n.selectionDiv.remove(),B.#u.delete(n.selectionDiv)),B.#g.set(s,{drawLayer:this}),B.#f.add(s),this.#i=s,this.#r=new MutationObserver(r=>{if(!(!this.#t||!this.#i?.isConnected||!B.#c())){for(const{addedNodes:a}of r)for(const o of a)if(o.nodeType===Node.ELEMENT_NODE&&o.classList.contains("endOfContent")){B.#b();return}}}),this.#r.observe(s,{childList:!0}),B.#h===null){B.#h=new AbortController;const{signal:r}=B.#h;document.addEventListener("selectionchange",B.#b.bind(B),{signal:r}),document.addEventListener("pointerdown",()=>{B.#d=!0},{signal:r}),document.addEventListener("pointerup",()=>{B.#d=!1},{signal:r}),window.addEventListener("blur",()=>{B.#d=!1},{signal:r})}}}setParent(t){if(!this.#t){this.#t=t,this.#i?.isConnected&&B.#c()&&B.#b();return}if(this.#t!==t){if(this.#e.size>0)for(const e of this.#e.values())e.remove(),t.append(e);this.#t=t}}static#m(t){const e=this.#g.get(t);e?.selectionDiv&&(e.selectionDiv.remove(),this.#u.delete(e.selectionDiv),e.selectionDiv=null,e.path=null)}static#c(){const t=document.getSelection();return!!t&&!t.isCollapsed}static#p(){return this.#f.keys().filter(t=>t.isConnected).toArray().sort(Il)}static#b(){const t=document.getSelection();if(!t||t.isCollapsed){for(const r of this.#u)r.remove();this.#u.clear();return}const e=new WeakMap,i=this.#p(),s=[];for(let r=0,a=t.rangeCount;r<a;r++){const o=t.getRangeAt(r);if(o.collapsed)continue;let{startContainer:l,startOffset:c,endContainer:d,endOffset:u}=o,f=ii(l),p=ii(d);const g=f===null,m=p===null;if(this.#d&&g!==m)return;if(t.rangeCount===1){const{anchorNode:w,anchorOffset:A,focusNode:v,focusOffset:E}=t,_=ii(w),C=ii(v),S=Ll(w,A,v,E);_&&C&&S!==null&&(S?(l=w,c=A,f=_,d=v,u=E,p=C):(l=v,c=E,f=C,d=w,u=A,p=_))}const b=i.filter(w=>o.intersectsNode(w));if(b.length===0)continue;let y=!1;if(f||(f=b[0],l=f,c=0,y=!0),p||(p=b.at(-1),d=p,u=p.childNodes.length,y=!0),d.nodeType===Node.ELEMENT_NODE){if(d.classList.contains("endOfContent")){const w=d.previousSibling;if(!w)continue;d=w,u=w.nodeType===Node.TEXT_NODE?w.textContent.length:w.childNodes.length}else if(d.classList.contains("textLayer")&&d.childNodes.length===u){const w=In(d,u,p);if(!w)continue;d=w.container,u=w.offset}}if(l.nodeType===Node.ELEMENT_NODE){const w=In(l,c,f);if(!w)continue;l=w.container,c=w.offset}if(f===p&&!y&&b.includes(f)){s.push([o,f]);continue}for(const w of b){const A=w.firstChild;if(!A)continue;const v=document.createRange();if(w===f?v.setStart(l,c):v.setStartBefore(A),w===p)v.setEnd(d,u);else{const E=w.lastChild;if(!E)continue;if(E.nodeType===Node.ELEMENT_NODE&&E.classList.contains("endOfContent")){const _=E.previousSibling;if(!_)continue;v.setEndAfter(_)}else v.setEndAfter(E)}v.collapsed||s.push([v,w])}}const n=new Set(s.map(r=>r[1]));for(const r of this.#f)n.has(r)||this.#m(r);for(const[r,a]of s){const o=B.#g.get(a);if(!o)continue;let l=e.get(a);if(!l){const p=a.getBoundingClientRect();l=(g,m,b,y)=>({x:(g-p.x)/p.width,y:(m-p.y)/p.height,width:b/p.width,height:y/p.height}),e.set(a,l)}const c=[];for(let{x:p,y:g,width:m,height:b}of r.getClientRects())m===0||b===0||({x:p,y:g,width:m,height:b}=l(p,g,m,b),!(m===1&&b===1)&&c.push(`M${p} ${g} h${m} v${b} h-${m} Z`));if(c.length===0)continue;const d=o.drawLayer;let u=o.selectionDiv,f=o.path;if(!u){const p=`clip_selection_${B.#l++}`;u=document.createElement("div"),u.className="selection",u.style.clipPath=`url(#${p})`;const g=d.#s?.createSelectionStyle(d.#n);if(g)for(const[y,w]of Object.entries(g))u.style.setProperty(y,w);
55const m=B._svgFactory.create(1,1,!0);m.setAttribute("aria-hidden","true"),m.setAttribute("width","100%"),m.setAttribute("height","100%");const b=B._svgFactory.createElement("clipPath");b.setAttribute("id",p),b.setAttribute("clipPathUnits","objectBoundingBox"),f=B._svgFactory.createElement("path"),b.append(f),m.append(b),u.append(m),o.path=f,o.selectionDiv=u}d.#t&&u.parentNode!==d.#t&&(d.#t.append(u),this.#u.add(u)),f.setAttribute("d",c.join(" "))}}static get _svgFactory(){return F(this,"_svgFactory",new bi)}static#y(t,[e,i,s,n]){const{style:r}=t;r.top=`${100*i}%`,r.left=`${100*e}%`,r.width=`${100*s}%`,r.height=`${100*n}%`}#w(){const t=B._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden","true"),t}#v(t,e){const i=B._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=B._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#E(t,e){for(const[i,s]of Object.entries(e))s===null?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){const s=B.#o++,n=this.#w(),r=B._svgFactory.createElement("defs");n.append(r);const a=B._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#a.set(s,a);const l=i?this.#v(r,o):null,c=B._svgFactory.createElement("use");return n.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#e.set(s,n),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){const i=B.#o++,s=this.#w(),n=B._svgFactory.createElement("defs");s.append(n);const r=B._svgFactory.createElement("path");n.append(r);const a=`path_${i}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const d=B._svgFactory.createElement("mask");n.append(d),o=`mask_${i}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=B._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=B._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const l=B._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const c=l.cloneNode();return s.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(s,t),this.#e.set(i,s),i}finalizeDraw(t,e){this.#a.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:s,rootClass:n,path:r}=e,a=typeof t=="number"?this.#e.get(t):t;if(a){if(i&&this.#E(a,i),s&&B.#y(a,s),n){const{classList:o}=a;for(const[l,c]of Object.entries(n))o.toggle(l,c)}if(r){const l=a.firstElementChild.firstElementChild;this.#E(l,r)}}}updateParent(t,e){if(e===this)return;const i=this.#e.get(t);i&&(e.#t.append(i),this.#e.delete(t),e.#e.set(t,i))}remove(t){this.#a.delete(t),this.#t!==null&&(this.#e.get(t).remove(),this.#e.delete(t))}destroy(){this.#t=null;for(const t of this.#e.values())t.remove();this.#e.clear(),this.#a.clear(),this.#r?.disconnect(),this.#r=null,this.#i&&(B.#g.get(this.#i)?.drawLayer===this&&(B.#m(this.#i),B.#g.delete(this.#i),B.#f.delete(this.#i),B.#f.size===0&&(B.#h?.abort(),B.#h=null,B.#d=!1)),this.#i=null)}};function si(h){return`${(h*100).toFixed(2)}%`}let Rl=class vs{#t=[];#e=new Map;#i=null;#s=0;#n=0;#r=0;static#a=null;constructor(t,e,i,s){this.#s=t,this.#t=e,this.#n=i.rawDims.pageWidth,this.#r=i.rawDims.pageHeight,this.#i=s}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#t.length;e+=6){const i=this.#o(this.#t.subarray(e,e+6));i&&t.append(i)}return t.addEventListener("contextmenu",e=>{if(!(e.target instanceof HTMLCanvasElement))return;const i=e.target,s=this.#e.get(i);if(!s)return;const n=vs.#a?.deref();if(n===i)return;n&&(n.width=0,n.height=0),vs.#a=new WeakRef(i);const{inverseTransform:r,x1:a,y1:o,width:l,height:c}=s,d=this.#i(),u=Math.ceil(a*d.width),f=Math.ceil(o*d.height),p=Math.floor((a+l/this.#n)*d.width),g=Math.floor((o+c/this.#r)*d.height);i.width=p-u,i.height=g-f;const m=i.getContext("2d");m.setTransform(...r),m.translate(-u,-f),m.drawImage(d,0,0)}),t}#o([t,e,i,s,n,r]){const a=Math.hypot((n-t)*this.#n,(r-e)*this.#r),o=Math.hypot((i-t)*this.#n,(s-e)*this.#r);
55if(a<this.#s||o<this.#s)return null;const l=[(n-t)*this.#n/a,(r-e)*this.#r/a,(i-t)*this.#n/o,(s-e)*this.#r/o,0,0],c=k.inverseTransform(l),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:si(t),top:si(e),width:si(a/this.#n),height:si(o/this.#r),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#e.set(d,{inverseTransform:c,width:a,height:o,x1:t,y1:e}),d}};globalThis._pdfjsTestingUtils={HighlightOutliner:bs};globalThis.pdfjsLib={AbortException:zt,AnnotationEditorLayer:Ml,AnnotationEditorParamsType:z,AnnotationEditorType:j,AnnotationEditorUIManager:Be,AnnotationLayer:Cl,AnnotationMode:Ht,AnnotationType:tt,applyOpacity:Oa,build:nl,ColorPicker:jr,createValidAbsoluteUrl:mr,CSSConstants:Na,DOMSVGFactory:bi,DrawLayer:Dl,FeatureTest:Y,fetchData:Ms,findContrastColor:Fa,getDocument:Fr,getFilenameFromUrl:Ia,getPdfFilenameFromUrl:La,getRGB:Xe,getRGBA:Ge,getUuid:yr,GlobalWorkerOptions:ye,ImageKind:li,InvalidPDFException:ns,isDataScheme:_i,isPdfFile:Ls,isValidExplicitDest:ao,makeArr:_e,makeMap:ks,makeObj:rs,makeSet:Ta,MathClamp:Q,noContextMenu:Ct,normalizeUnicode:Ca,OPS:Lt,OutputScale:Wt,PasswordException:ss,PasswordResponses:wa,PDFDataRangeTransport:Br,PDFDateString:as,PDFWorker:gs,PermissionFlag:ya,PixelsPerInch:Se,RenderingCancelledException:Is,renderRichText:vr,ResponseException:fi,setLayerDimensions:ne,shadow:F,SignatureExtractor:pe,stopEvent:at,SupportedImageMimeTypes:ls,TextLayer:mi,TextLayerImages:Rl,TouchManager:Sr,updateUrlHash:br,Util:k,VerbosityLevel:Ai,version:sl,XfaLayer:wr};const Nl=async h=>{const e=await(await fetch("/document-viewer",{method:"POST",headers:ba(),body:JSON.stringify({src:h.data.pdf,totalPages:h.totalPages})})).json();if(!(e?.success??!1)){h.data=null;return}h.data=e.data},Ol=async h=>{const t="/build/pdfjs/";ye.workerSrc=`${t}pdf.worker.min.js`,h.pdfInstance=await Fr({url:h.data.pdf,enableHWA:!0,isImageDecoderSupported:!1,cMapUrl:`${t}cmaps/`,cMapPacked:!0,standardFontDataUrl:`${t}standard_fonts/`,wasmUrl:`${t}wasm/`,iccUrl:`${t}iccs/`}).promise,h.totalPages=h.pdfInstance.numPages},yi=h=>document.getElementById("documentViewer_"+h).content.cloneNode(!0).children[0],{AbortException:Fl,AnnotationEditorLayer:Bl,AnnotationEditorParamsType:gd,AnnotationEditorType:mt,AnnotationEditorUIManager:jl,AnnotationLayer:$l,AnnotationMode:Nt,AnnotationType:qr,applyOpacity:md,build:bd,ColorPicker:yd,createValidAbsoluteUrl:Kr,CSSConstants:wd,DOMSVGFactory:vd,DrawLayer:Ul,FeatureTest:qs,fetchData:Ln,findContrastColor:Ad,getDocument:Ed,getFilenameFromUrl:Sd,getPdfFilenameFromUrl:Vl,getRGB:xd,getRGBA:_d,getUuid:Hl,GlobalWorkerOptions:Cd,ImageKind:Pd,InvalidPDFException:Td,isDataScheme:kd,isPdfFile:zl,isValidExplicitDest:Wl,makeArr:Gl,makeMap:Dn,makeObj:Md,makeSet:Xl,MathClamp:Yl,noContextMenu:Id,normalizeUnicode:ql,OPS:Ld,OutputScale:ci,PasswordException:Kl,PasswordResponses:Dd,PDFDataRangeTransport:Rd,PDFDateString:Nd,PDFWorker:Od,PermissionFlag:de,PixelsPerInch:Ft,RenderingCancelledException:As,renderRichText:Fd,ResponseException:Bd,setLayerDimensions:Qr,shadow:Ve,SignatureExtractor:jd,stopEvent:Es,SupportedImageMimeTypes:$d,TextLayer:Ql,TextLayerImages:Zl,TouchManager:Ud,updateUrlHash:Jl,Util:Ks,
vendor: 25,195 bytes, lines 55-57
55VerbosityLevel:Vd,version:Rn,XfaLayer:Nn}=globalThis.pdfjsLib;let On=null,Fn=null;function Bn(h,t){Fn||=new Intl.Segmenter(void 0,{granularity:"grapheme"});const e=Fn.segment(h),i=e.containing(t);if(i.index!==t)return!1;On||=new Intl.Segmenter(void 0,{granularity:"word"});const s=e.containing(t-1).segment;return On.segment(s+i.segment).containing(s.length).index===s.length}function th(h,t,e){const i=t+e;return(t===0||Bn(h,t))&&(i===h.length||Bn(h,i))}let Kt;function eh(){if(!Kt){const h=[],t=[],e=new RegExp("^\\p{M}$","u");for(let s=0;s<65536;s++){if(s>=55296&&s<=57343)continue;const n=String.fromCharCode(s);if(n.normalize("NFKC")!==n&&!e.test(n)){if(t.length!==2){t[0]=t[1]=s;continue}t[1]+1!==s?(t[0]===t[1]?h.push(String.fromCharCode(t[0])):h.push(`${String.fromCharCode(t[0])}-${String.fromCharCode(t[1])}`),t[0]=t[1]=s):t[1]=s}}const i=h.join("");if(!Kt)Kt=i;else if(i!==Kt){for(let s=1;s<i.length;s++)if(i[s]!==Kt[s]){console.log(`Difference at index ${s}: U+${i.charCodeAt(s).toString(16).toUpperCase().padStart(4,"0")}!== U+${Kt.charCodeAt(s).toString(16).toUpperCase().padStart(4,"0")}`);break}throw new Error("getNormalizeWithNFKC - update the `NormalizeWithNFKC` string.")}}return Kt}const we={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},Rt={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},H={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},dt={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function ih(h,t){let e=h.offsetParent;if(!e){console.error("offsetParent is not set -- cannot scroll");return}let i=h.offsetTop+h.clientTop,s=h.offsetLeft+h.clientLeft;for(;e.clientHeight===e.scrollHeight&&e.clientWidth===e.scrollWidth;)if(i+=e.offsetTop,s+=e.offsetLeft,e=e.offsetParent,!e)return;t&&(t.top!==void 0&&(i+=t.top),t.left!==void 0&&(s+=t.left,e.scrollLeft=s)),e.scrollTop=i}function sh(h,t,e=void 0){function i(){n=null;const r=h.scrollLeft,a=s.lastX;r!==a&&(s.right=r>a),s.lastX=r;const o=h.scrollTop,l=s.lastY;o!==l&&(s.down=o>l),s.lastY=o,t(s)}const s={right:!0,down:!0,lastX:h.scrollLeft,lastY:h.scrollTop};let n=null;return h.addEventListener("scroll",()=>{n??=window.requestAnimationFrame(i)},{useCapture:!0,signal:e}),e?.addEventListener("abort",()=>window.cancelAnimationFrame(n),{once:!0}),s}function Ni(h){const t=new Map;for(const[e,i]of new URLSearchParams(h))t.set(e.toLowerCase(),i);return t}const jn=/[\x00-\x1F]/g;function te(h,t=!1){return jn.test(h)?t?h.replaceAll(jn,e=>e==="\0"?"":" "):h.replaceAll("\0",""):h}function He(h,t,e=0){let i=e,s=h.length-1;if(s<0||!t(h[s]))return h.length;if(t(h[i]))return i;for(;i<s;){const n=i+s>>1,r=h[n];t(r)?s=n:i=n+1}return i}function $n(h){if(Math.floor(h)===h)return[h,1];const t=1/h,e=8;if(t>e)return[1,e];if(Math.floor(t)===t)return[1,t];const i=h>1?t:h;let s=0,n=1,r=1,a=1;for(;;){const o=s+r,l=n+a;if(l>e)break;i<=o/l?(r=o,a=l):(s=o,n=l)}return i-s/n<r/a-i?i===h?[s,n]:[n,s]:i===h?[r,a]:[a,r]}function ni(h,t){return h-h%t}function nh(h,t,e){if(h<2)return h;let i=t[h].div,s=i.offsetTop+i.clientTop;s>=e&&(i=t[h-1].div,s=i.offsetTop+i.clientTop);for(let n=h-2;n>=0&&(i=t[n].div,!(i.offsetTop+i.clientTop+i.clientHeight<=s));--n)h=n;return h}function rh(h,t){const e=h.percent-t.percent;return Math.abs(e)>.001?-e:h.id-t.id}function ah({scrollEl:h,views:t,sortByVisibility:e=!1,horizontal:i=!1,rtl:s=!1}){const n=h.scrollTop,r=n+h.clientHeight,a=h.scrollLeft,o=a+h.clientWidth;function l(y){const w=y.div;return w.offsetTop+w.clientTop+w.clientHeight>n}function c(y){const w=y.div,A=w.offsetLeft+w.clientLeft,v=A+w.clientWidth;return s?A<o:v>a}const d=[],u=new Set,f=t.length;let p=He(t,i?c:l);p>0&&p<f&&!i&&(p=nh(p,t,n));let g=i?o:-1;for(let y=p;y<f;y++){const w=t[y],A=w.div,v=A.offsetLeft+A.clientLeft,E=A.offsetTop+A.clientTop,_=A.clientWidth,C=A.clientHeight,S=v+_,P=E+C;if(g===-1)P>=r&&(g=P);else if((i?v:E)>g)break;if(P<=n||E>=r||S<=a||v>=o)continue;const T=Math.max(0,n-E),M=Math.max(0,a-v),L=T+Math.max(0,P-r),D=M+Math.max(0,S-o),U=(C-L)/C,R=(_-D)/_,O=U*R*100|0;d.push({id:w.id,x:v,y:E,visibleArea:O===100?null:{minX:M,minY:T,maxX:Math.min(S,o)-v,maxY:Math.min(P,r)-E},view:w,percent:O,widthPercent:R*100|0}),u.add(w.id)}const m=d[0],b=d.at(-1);return e&&d.sort(rh),{first:m,last:b,views:d,ids:u}}function Zr(h){return Number.isInteger(h)&&h%90===0}function oh(h){return Number.isInteger(h)&&Object.values(H).includes(h)&&h!==H.UNKNOWN}function lh(h){return Number.isInteger(h)&&Object.values(dt).includes(h)&&h!==dt.UNKNOWN}function Un(h){return h.width<=h.height}new Promise(function(h){window.requestAnimationFrame(h)});const hh=document.documentElement.style;class ch{#t=null;#e=null;#i=0;#s=null;#n=!0;constructor(t){this.#t=t.classList,this.#s=t.style}get percent(){return this.#i}set percent(t){if(this.#i=t,isNaN(t)){this.#t.add("indeterminate");return}this.#t.remove("indeterminate"),this.#s.setProperty("--progressBar-percent",`${this.#i}%`)}setWidth(t){if(!t)return;const i=t.parentNode.offsetWidth-t.offsetWidth;i>0&&this.#s.setProperty("--progressBar-end-offset",`${i}px`)}setDisableAutoFetch(t=5e3){this.#i===100||isNaN(this.#i)||(this.#e&&clearTimeout(this.#e),this.show(),this.#e=setTimeout(()=>{this.#e=null,this.hide()},t))}hide(){this.#n&&(this.#n=!1,this.#t.add("hidden"))}show(){this.#n||(this.#n=!0,this.#t.remove("hidden"))}}function dh(h){let t=H.VERTICAL,e=dt.NONE;switch(h){case"SinglePage":t=H.PAGE;break;case"OneColumn":break;case"TwoPageLeft":t=H.PAGE;case"TwoColumnLeft":e=dt.ODD;break;case"TwoPageRight":t=H.PAGE;case"TwoColumnRight":e=dt.EVEN;break}return{scrollMode:t,spreadMode:e}}const ri=(function(){const h=document.createElement("div");return h.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)",h.style.width==="calc(1320px)"?Math.fround:t=>t})(),Jr="59968104-cc61-4cf9-b570-014b35b3709c",ft=Object.freeze({internal:Jr}),Vt={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},Vn=new Map([["â","-"],["â","'"],["â","'"],["â","'"],["â","'"],["â",'"'],["â",'"'],["â",'"'],["â",'"'],["¼","1/4"],["½","1/2"],["¾","3/4"]]),Hn=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]);let zn;const uh=new RegExp("\\p{M}+","gu"),fh=new RegExp("([+^$|])|(\\p{P}+)|(\\s+)|(\\p{M})|(\\p{L})","gu"),ph=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,Wn=new Map,gh="[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]",mh=new Map;let Yi=null,qi=null;function di(h,t={}){const e=[];let i;for(;(i=ph.exec(h))!==null;){let{index:y}=i;for(const w of i[0]){let A=Wn.get(w);A||(A=w.normalize("NFD").length,Wn.set(w,A)),e.push([A,y++])}}const s=e.length>0,n=t.ignoreDashEOL??!1;let r;if(!s&&Yi)r=Yi;else if(s&&qi)r=qi;else{const y=Vn.keys().join(""),w=eh(),_=[`[${y}]`,`[${w}]`,"(?:ã|ã)\\n","\\p{M}+(?:-\\n)?","\\p{Ll}-\\n(?=\\p{Ll})|\\p{Lu}-\\n(?=\\p{L})","\\S-\\n","(?:\\p{Ideographic}|[ã-ã¿])\\n","\\n",s?gh:"\\u0000"];r=new RegExp(_.map(C=>`(${C})`).join("|"),"gmu"),s?qi=r:Yi=r}const a=[];for(;(i=uh.exec(h))!==null;)a.push([i[0].length,i.index]);let o=h.normalize("NFD");const l=[0,0];let c=0,d=0,u=0,f=0,p=0,g=!1;o=o.replace(r,(y,w,A,v,E,_,C,S,P,T,M)=>{if(M-=f,w){const L=Vn.get(w),D=L.length;for(let U=1;U<D;U++)l.push(M-u+U,u-U);return u-=D-1,L}if(A){const L=mh.getOrInsertComputed(A,()=>A.normalize("NFKC")),D=L.length;for(let U=1;U<D;U++)l.push(M-u+U,u-U);return u-=D-1,L}if(v)return g=!0,M+p===a[c]?.[1]?++c:(l.push(M-1-u+1,u-1),u-=1,f+=1),l.push(M-u+1,u),f+=1,p+=1,v.charAt(0);if(E){const L=E.endsWith(` 56`),D=L?E.length-2:E.length;g=!0;let U=D;M+p===a[c]?.[1]&&(U-=a[c][0],++c);for(let R=1;R<=U;R++)l.push(M-1-u+R,u-R);return u-=U,f+=U,L?(M+=D-1,l.push(M-u+1,1+u),u+=1,f+=1,p+=1,E.slice(0,D)):E}if(_){if(n)return f+=1,p+=1,_.slice(0,-1);const L=_.length-2;return l.push(M-u+L,1+u),u+=1,f+=1,p+=1,_.slice(0,-2)}if(C)return f+=1,p+=1,C.slice(0,-1);if(S){const L=S.length-1;return l.push(M-u+L,u),f+=1,p+=1,S.slice(0,-1)}if(P)return l.push(M-u+1,u-1),u-=1,f+=1,p+=1," ";if(M+p===e[d]?.[1]){const L=e[d][0]-1;++d;for(let D=1;D<=L;D++)l.push(M-(u-D),u-D);u-=L,f+=L}return T}),l.push(o.length,u);const m=new Uint32Array(l.length>>1),b=new Int32Array(l.length>>1);for(let y=0,w=l.length;y<w;y+=2)m[y>>1]=l[y],b[y>>1]=l[y+1];return[o,[m,b],g]}function ta(h,t,e){if(!h)return[t,e];const[i,s]=h,n=t,r=t+e-1;let a=He(i,u=>u>=n);i[a]>n&&--a;let o=He(i,u=>u>=r,a);i[o]>r&&--o;const l=n+s[a],d=r+s[o]+1-l;return[l,d]}class bh{#t=null;#e=!0;#i=0;#s=0;#n=null;#r=null;constructor({linkService:t,eventBus:e,delay:i=250,updateMatchesCountOnProgress:s=!0}){this._linkService=t,this._eventBus=e,this.#e=s,this.#i=i,this.onIsPageVisible=null,this.#o(),e.on("find",this.#a.bind(this),ft),e.on("findbarclose",this.#E.bind(this),ft),e.on("pagesedited",this.#v.bind(this),ft)}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#t}setDocument(t){this._pdfDocument&&this.#o(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#a(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(this.#t===null||this.#h(t))&&(this._dirtyMatch=!0),this.#t=t,i!=="highlightallchange"&&this.#S(Vt.PENDING),this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#f();const s=!this._highlightMatches,n=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#c():i==="again"?(this.#c(),s&&this.#t.highlightAll&&this.#m()):i==="highlightallchange"?(n?this.#c():this._highlightMatches=!0,this.#m()):this.#c():this._findTimeout=setTimeout(()=>{this.#c(),this._findTimeout=null},this.#i)})}scrollMatchIntoView({element:t=null,pageIndex:e=-1,matchIndex:i=-1}){if(!(!this._scrollMatches||!t)){{if(i===-1||i!==this._selected.matchIdx)return;if(e===-1||e!==this._selected.pageIdx)return}this._scrollMatches=!1,t.scrollIntoView({block:"start",inline:"center"})}}#o(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#s=0,this.#t=null,this._selected={pageIdx:-1,matchIdx:-1},this._offset={pageIdx:null,matchIdx:null,wrapped:!1},this._extractTextPromises=[],this._pageContents=[],this._pageDiffs=[],this._hasDiacritics=[],this._matchesCountTotal=0,this._pagesToSearch=null,this._pendingFindMatches=new Set,this._resumePageIdx=null,this._dirtyMatch=!1,clearTimeout(this._findTimeout),this._findTimeout=null,this.#n=null,this._firstPageCapability=Promise.withResolvers()}get#l(){const{query:t}=this.#t;return typeof t=="string"?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=di(t)),this._normalizedQuery):(t||[]).filter(Boolean).map(e=>di(e)[0])}#h(t){const e=t.query,i=this.#t.query,s=typeof e;if(s!==typeof i)return!0;if(s==="string"){if(e!==i)return!0}else if(JSON.stringify(e)!==JSON.stringify(i))return!0;switch(t.type){case"again":const r=this._selected.pageIdx+1,a=this._linkService;return r>=1&&r<=a.pagesCount&&r!==a.page&&!(this.onIsPageVisible?.(r)??!0);case"highlightallchange":return!1}return!0}#u(t,e){const{matchDiacritics:i}=this.#t;let s=!1;const n=(a,o)=>a===t?o:t.startsWith(a)?`${o}[ ]*`:t.endsWith(a)?`[ ]*${o}`:`[ ]*${o}[ ]*`;t=t.replaceAll(fh,(a,o,l,c,d,u)=>o?n(o,RegExp.escape(o)):l?n(l,RegExp.escape(l)):c?"[ ]+":i?d||u:d?Hn.has(d.charCodeAt(0))?d:"":e?(s=!0,`${u}\\p{M}*`):u);const r="[ ]*";return t.endsWith(r)&&(t=t.slice(0,t.length-r.length)),i&&e&&(zn||=String.fromCharCode(...Hn),s=!0,t=`${t}(?=[${zn}]|[^\\p{M}]|$)`),[s,t]}#d(t){if(!this.#t)return;const e=this.#l;if(e.length===0)return;const i=this._pageContents[t],s=this.match(e,i,t),n=this._pageMatches[t]=[],r=this._pageMatchesLength[t]=[],a=this._pageDiffs[t];s?.forEach(({index:l,length:c})=>{const[d,u]=ta(a,l,c);u&&(n.push(d),r.push(u))}),this.#t.highlightAll&&this.#g(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#b());const o=n.length;this._matchesCountTotal+=o,this.#e?o>0&&this.#x():++this.#s===this._linkService.pagesCount&&this.#x()}match(t,e,i){const s=this._hasDiacritics[i];let n=!1;if(typeof t=="string"?[n,t]=this.#u(t,s):t=t.sort().reverse().map(d=>{const[u,f]=this.#u(d,s);return n||=u,`(${f})`}).join("|"),!t)return;const{caseSensitive:r,entireWord:a}=this.#t,o=`g${n?"u":""}${r?"":"i"}`;t=new RegExp(t,o);const l=[];let c;for(;(c=t.exec(e))!==null;)a&&!th(e,c.index,c[0].length)||l.push({index:c.index,length:c[0].length});return l}#f(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0},i=this._pdfDocument;for(let s=0,n=this._linkService.pagesCount;s<n;s++){const{promise:r,resolve:a}=Promise.withResolvers();this._extractTextPromises[s]=r,t=t.then(async()=>{if(i!==this._pdfDocument){a();return}try{const l=await(await i.getPage(s+1)).getTextContent(e);if(i!==this._pdfDocument){a();return}const c=[];for(const d of l.items)c.push(d.str),d.hasEOL&&c.push(` 57`);[this._pageContents[s],this._pageDiffs[s],this._hasDiacritics[s]]=di(c.join(""))}catch(o){if(i!==this._pdfDocument){a();return}console.error(`Unable to get text content for page ${s+1}`,o),[this._pageContents[s],this._pageDiffs[s],this._hasDiacritics[s]]=["",null,!1]}a()})}}#g(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#m(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#c(){const t=this.#t.findPrevious,e=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=e,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#s=0,this._matchesCountTotal=0,this.#m();for(let r=0;r<i;r++)this._pendingFindMatches.has(r)||(this._pendingFindMatches.add(r),this._extractTextPromises[r].then(()=>{this._pendingFindMatches.delete(r),this.#d(r)}))}if(this.#l.length===0){this.#S(Vt.FOUND);return}if(this._resumePageIdx)return;const n=this._offset;if(this._pagesToSearch=i,n.matchIdx!==null){const r=this._pageMatches[n.pageIdx].length;if(!t&&n.matchIdx+1<r||t&&n.matchIdx>0){n.matchIdx=t?n.matchIdx-1:n.matchIdx+1,this.#w(!0);return}this.#y(t)}this.#b()}#p(t){const e=this._offset,i=t.length,s=this.#t.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#w(!0),!0):(this.#y(s),e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0)?(this.#w(!1),!0):!1)}#b(){this._resumePageIdx!==null&&console.error("There can only be one pending page.");let t=null;do{const e=this._offset.pageIdx;if(t=this._pageMatches[e],!t){this._resumePageIdx=e;break}}while(!this.#p(t))}#y(t){const e=this._offset,i=this._linkService.pagesCount;e.pageIdx=t?e.pageIdx-1:e.pageIdx+1,e.matchIdx=null,this._pagesToSearch--,(e.pageIdx>=i||e.pageIdx<0)&&(e.pageIdx=t?i-1:0,e.wrapped=!0)}#w(t=!1){let e=Vt.NOT_FOUND;const i=this._offset.wrapped;if(this._offset.wrapped=!1,t){const s=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx,this._selected.matchIdx=this._offset.matchIdx,e=i?Vt.WRAPPED:Vt.FOUND,s!==-1&&s!==this._selected.pageIdx&&this.#g(s)}this.#S(e,this.#t.findPrevious),this._selected.pageIdx!==-1&&(this._scrollMatches=!0,this.#g(this._selected.pageIdx))}#v({pagesMapper:t,type:e,pageNumbers:i}){if(this._extractTextPromises.length===0)return;if(e==="copy"){const u=new Map,f=new Map,p=new Map,g=new Map;for(const m of i)u.set(m,this._extractTextPromises[m-1]),f.set(m,this._pageContents[m-1]),p.set(m,this._pageDiffs[m-1]),g.set(m,this._hasDiacritics[m-1]);this.#n={promises:u,contents:f,diffs:p,diacritics:g};return}if(e==="cancelCopy"){this.#n=null;return}if(e==="delete"&&(this.#r={promises:this._extractTextPromises,contents:this._pageContents,diffs:this._pageDiffs,diacritics:this._hasDiacritics}),e==="cancelDelete"){this._extractTextPromises=this.#r.promises,this._pageContents=this.#r.contents,this._pageDiffs=this.#r.diffs,this._hasDiacritics=this.#r.diacritics;return}if(e==="cleanSavedData"){this.#r=null;return}this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx=null,this._dirtyMatch=!0;const s=this._extractTextPromises,n=this._pageContents,r=this._pageDiffs,a=this._hasDiacritics,o=this._extractTextPromises=[],l=this._pageContents=[],c=this._pageDiffs=[],d=this._hasDiacritics=[];for(let u=1,f=t.pagesNumber;u<=f;u++){const p=t.getPrevPageNumber(u);if(p<0){const g=-p;o.push(this.#n?.promises.get(g)||Promise.resolve()),l.push(this.#n?.contents.get(g)??""),c.push(this.#n?.diffs.get(g)??null),d.push(this.#n?.diacritics.get(g)??!1);continue}o.push(s[p-1]||Promise.resolve()),l.push(n[p-1]??""),c.push(r[p-1]??null),d.push(a[p-1]??!1)}this.#t&&this.#c()}#E(t){const e=this._pdfDocument;this._firstPageCapability.promise.then(()=>{!this._pdfDocument||e&&this._pdfDocument!==e||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#S(Vt.FOUND),this._highlightMatches=!1,this.#m())})}#A(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,s=this._matchesCountTotal;if(e!==-1){for(let n=0;n<t;n++)i+=this._pageMatches[n]?.length||0;i+=e+1}return(i<1||i>s)&&(i=s=0),{current:i,total:s}}#x(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#A()})}#S(t,e=!1){!this.#e&&(this.#s!==this._linkService.pagesCount||t===Vt.PENDING)||this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#t?.entireWord??null,matchesCount:this.#A(),rawQuery:this.#t?.query??null})}}const yh="noopener noreferrer nofollow",Zt={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class ea{externalLinkEnabled=!0;constructor({eventBus:t,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:s=!1}={}){this.eventBus=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=s,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(t,e=null){this.baseUrl=e,this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setHistory(t){this.pdfHistory=t}get pagesCount(){return this.pdfDocument?.pagesMapper.pagesNumber||0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(t){this.pdfDocument&&(this.pdfViewer.currentPageNumber=t)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(t){this.pdfDocument&&(this.pdfViewer.pagesRotation=t)}get isInPresentationMode(){return this.pdfDocument?this.pdfViewer.isInPresentationMode:!1}async goToDestination(t){if(!this.pdfDocument)return;let e,i,s;if(typeof t=="string"?(e=t,i=await this.pdfDocument.getDestination(t)):(e=null,i=await t),!Array.isArray(i)){console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${t}".`);return}const[n]=i;if(n&&typeof n=="object"){if(s=this.pdfDocument.cachedPageNumber(n),!s)try{s=await this.pdfDocument.getPageIndex(n)+1}catch{console.error(`goToDestination: "${n}" is not a valid page reference, for dest="${t}".`);return}}else Number.isInteger(n)&&(s=n+1);if(!s||s<1||s>this.pagesCount){console.error(`goToDestination: "${s}" is not a valid page number, for dest="${t}".`);return}this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:e,explicitDest:i,pageNumber:s})),this.pdfViewer.scrollPageIntoView({pageNumber:s,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom});const r=new AbortController;this.eventBus.on("textlayerrendered",a=>{a.pageNumber===s&&(a.source.textLayer.div.focus(),r.abort())},{signal:r.signal,...ft})}goToPage(t){if(!this.pdfDocument)return;const e=typeof t=="string"&&this.pdfViewer.pageLabelToPageNumber(t)||t|0;if(!(Number.isInteger(e)&&e>0&&e<=this.pagesCount)){console.error(`PDFLinkService.goToPage: "${t}" is not a valid page.`);return}this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(e)),this.pdfViewer.scrollPageIntoView({pageNumber:e})}goToXY(t,e,i,s={}){this.pdfViewer.scrollPageIntoView({pageNumber:t,destArray:[null,{name:"XYZ"},e,i],ignoreDestinationZoom:!0,...s})}async getAttachmentContent(t){try{return await this.pdfDocument?.getAttachmentContent(t)}catch(e){e instanceof Kl||console.warn(`Unable to load attachment content: ${e}`)}return null}addLinkAttributes(t,e,i=!1){if(!e||typeof e!="string")throw new Error('A valid "url" parameter must provided.');const s=i?Zt.BLANK:this.externalLinkTarget,n=this.externalLinkRel;let r=e;const a=URL.parse(e);(a?.username||a?.password)&&(a.username=a.password="",r=a.href),this.externalLinkEnabled?(t.href=e,t.title=r):(t.href="",t.title=`Disabled: ${r}`,t.onclick=()=>!1);let o="";switch(s){case Zt.NONE:break;case Zt.SELF:o="_self";break;case Zt.BLANK:o="_blank";break;case Zt.PARENT:o="_parent";break;case Zt.TOP:o="_top";break}t.target=o,t.rel=typeof n=="string"?n:yh}getDestinationHash(t){if(typeof t=="string"){if(t.length>0)return this.getAnchorUrl("#"+escape(t))}else if(Array.isArray(t)){const e=JSON.stringify(t);if(e.length>0)return this.getAnchorUrl("#"+escape(e))}return this.getAnchorUrl("")}getAnchorUrl(t){return this.baseUrl?this.baseUrl+t:t}setHash(t){if(!this.pdfDocument)return;let e,i;if(t.includes("=")){const s=Ni(t);if(s.has("search")){const n=s.get("search").replaceAll('"',""),r=s.get("phrase")==="true";this.eventBus.dispatch("findfromurlhash",{source:this,query:r?n:n.match(/\S+/g)})}if(s.has("page")&&(e=s.get("page")|0||1),s.has("zoom")){const n=s.get("zoom").split(","),r=n[0],a=parseFloat(r);r.includes("Fit")?r==="Fit"||r==="FitB"?i=[null,{name:r}]:r==="FitH"||r==="FitBH"||r==="FitV"||r==="FitBV"?i=[null,{name:r},n.length>1?n[1]|0:null]:r==="FitR"?n.length!==5?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:r},n[1]|0,n[2]|0,n[3]|0,n[4]|0]:console.error(`PDFLinkService.setHash: "${r}" is not a valid zoom value.`):i=[null,{name:"XYZ"},n.length>1?n[1]|0:null,n.length>2?n[2]|0:null,a?a/100:r]}i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),s.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:s.get("pagemode")}),s.has("nameddest")&&this.goToDestination(s.get("nameddest"));return}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}if(typeof i=="string"||Wl(i)){this.goToDestination(i);return}console.error(`PDFLinkService.setHash: "${unescape(t)}" is not a valid destination.`)}executeNamedAction(t){if(this.pdfDocument){switch(t){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1;break}this.eventBus.dispatch("namedaction",{source:this,action:t})}}async executeSetOCGState(t){if(!this.pdfDocument)return;const e=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;e===this.pdfDocument&&(i.setOCGState(t),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}}class Qs extends ea{setDocument(t,e=null){}}class ia{#t=null;#e=null;#i=null;#s=null;#n=!1;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:s=null,imageResourcesPath:n="",renderForms:r=!0,enableComment:a=!1,commentManager:o=null,enableScripting:l=!1,hasJSActionsPromise:c=null,fieldObjectsPromise:d=null,annotationCanvasMap:u=null,accessibilityManager:f=null,annotationEditorUIManager:p=null,onAppend:g=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=n,this.renderForms=r,this.annotationStorage=s,this.enableComment=a,this.#e=o,this.enableScripting=l,this._hasJSActionsPromise=c||Promise.resolve(!1),this._fieldObjectsPromise=d||Promise.resolve(null),this._annotationCanvasMap=u,this._accessibilityManager=f,this._annotationEditorUIManager=p,this.#i=g,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render({viewport:t,intent:e="display",structTreeLayer:i=null,optionalContentConfigPromise:s=null}){if(this.div){const c=await s;if(this._cancelled||!this.annotationLayer)return;this.annotationLayer.update({viewport:t.clone({dontFlip:!0}),optionalContentConfig:c});return}const[n,r,a,o]=await Promise.all([this.pdfPage.getAnnotations({intent:e}),this._hasJSActionsPromise,this._fieldObjectsPromise,s]);if(this._cancelled)return;const l=this.div=document.createElement("div");if(l.className="annotationLayer",this.#i?.(l),this.#r(t,i),n.length===0){this.#t=n,Qr(this.div,t);return}await this.annotationLayer.render({annotations:n,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,downloadManager:this.downloadManager,enableComment:this.enableComment,enableScripting:this.enableScripting,hasJSActions:r,fieldObjects:a,optionalContentConfig:o}),this.#t=n,this.linkService.isInPresentationMode&&this.#a(we.FULLSCREEN),this.#s||(this.#s=new AbortController,this._eventBus?.on("presentationmodechanged",c=>{this.#a(c.state)},{signal:this.#s.signal,...ft}))}
57#r(t,e){this.annotationLayer=new $l({div:this.div,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,annotationStorage:this.annotationStorage,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e,commentManager:this.#e,linkService:this.linkService})}cancel(){this._cancelled=!0,this.#s?.abort(),this.#s=null,this.annotationLayer?.destroy()}refreshCanvases(){this.annotationLayer?.refreshCanvases()}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}async injectLinkAnnotations(t){if(this.#t===null)throw new Error("`render` method must be called before `injectLinkAnnotations`.");if(this._cancelled||this.#n)return;this.#n=!0;const e=this.#t.length?this.#o(t):t;e.length&&await this.annotationLayer.addLinkAnnotations(e)}#a(t){if(!this.div)return;let e=!1;switch(t){case we.FULLSCREEN:e=!0;break;case we.NORMAL:break;default:return}for(const i of this.div.childNodes)i.hasAttribute("data-internal-link")||i.classList.contains("mediaAnnotation")||(i.inert=e)}#o(t){function e(n){if(!n.quadPoints)return[n.rect];const r=[];for(let a=2,o=n.quadPoints.length;a<o;a+=8){const l=n.quadPoints[a],c=n.quadPoints[a+1],d=n.quadPoints[a+2],u=n.quadPoints[a+3];r.push([d,u,l,c])}return r}function i(n,r){const a=[],o=e(n),l=e(r);for(const c of o)for(const d of l){const u=Ks.intersect(c,d);u&&a.push(u)}return a}function s(n){let r=0;for(const a of n)r+=Math.abs((a[2]-a[0])*(a[3]-a[1]));return r}return t.filter(n=>{let r;for(const a of this.#t){if(a.annotationType!==qr.LINK)continue;const o=i(a,n);if(o.length!==0&&(r??=s(e(n)),s(o)/r>.5))return!1}return!0})}}class wh{#t=new WeakMap;_triggerDownload(t,e,i,s=!1){throw new Error("Not implemented: _triggerDownload")}_getOpenDataUrl(t,e,i=null){throw new Error("Not implemented: _getOpenDataUrl")}downloadData(t,e,i){const s=URL.createObjectURL(new Blob([t],{type:i}));this._triggerDownload(s,s,e,!0)}openOrDownloadData(t,e,i=null){const s=zl(e),n=s?"application/pdf":"";if(s){const r=this.#t.getOrInsertComputed(t,()=>URL.createObjectURL(new Blob([t],{type:n})));try{const a=this._getOpenDataUrl(r,e,i);return window.open(a),!0}catch(a){console.error("openOrDownloadData:",a),URL.revokeObjectURL(r),this.#t.delete(t)}}return this.downloadData(t,e,n),!1}download(t,e,i){const s=t?URL.createObjectURL(new Blob([t],{type:"application/pdf"})):null;this._triggerDownload(s,e,i)}}class vh extends wh{_triggerDownload(t,e,i,s=!1){if(!t&&!s){if(!Kr(e,"http://example.com"))throw new Error(`_triggerDownload - not a valid URL: ${e}`);t=e+"#pdfjs.action=download"}const n=document.createElement("a");n.href=t,n.target="_parent","download"in n&&(n.download=i),(document.body||document.documentElement).append(n),n.click(),n.remove()}_getOpenDataUrl(t,e,i=null){throw new Error("Opening data is not supported in `COMPONENTS` builds.")}}const Gn={EVENT:"event",TIMEOUT:"timeout"};async function Ah({target:h,name:t,delay:e=0}){if(typeof h!="object"||!(Number.isInteger(e)&&e>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:i,resolve:s}=Promise.withResolvers(),n=new AbortController;function r(c){n.abort(),clearTimeout(l),s(c)}const a=h instanceof Ss?"on":"addEventListener",o=h instanceof Ss?{signal:n.signal,...ft}:{signal:n.signal};h[a](t,r.bind(null,Gn.EVENT),o);const l=setTimeout(r.bind(null,Gn.TIMEOUT),e);return i}class Ss{#t=new Map;constructor(){Object.seal(this)}on(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted){console.error("Cannot use an `aborted` signal.");return}const r=()=>this.off(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.getOrInsertComputed(t,Xl).add({listener:e,internal:i?.internal===Jr,once:i?.once===!0,rmAbort:s})}off(t,e,i=null){const s=this.#t.get(t),n=s?.keys().find(r=>r.listener===e);n&&(n.rmAbort?.(),s.delete(n))}dispatch(t,e){const i=this.#t.get(t);if(!i?.size)return;let s;for(const{listener:n,internal:r,once:a}of new Set(i)){if(a&&this.off(t,n),!r){(s??=[]).push(n);continue}n(e)}if(s)for(const n of s)n(e)}}class ve{constructor(t){this.value=t}valueOf(){return this.value}}class st extends ve{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class $t extends ve{constructor(t,e={}){super(t),this.opts=e}
vendor: 21,732 bytes, lines 57-61
57toString(t){if(t)try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return this.value.toString(10)}}class Gt extends ve{static supportsValue(t){if(typeof t=="number"||t instanceof Date)return!0;if(t instanceof ve)return Gt.supportsValue(t.valueOf());if("Temporal"in globalThis){const e=globalThis.Temporal;if(t instanceof e.Instant||t instanceof e.PlainDateTime||t instanceof e.PlainDate||t instanceof e.PlainMonthDay||t instanceof e.PlainTime||t instanceof e.PlainYearMonth)return!0}return!1}constructor(t,e={}){t instanceof Gt?(e={...t.opts,...e},t=t.value):t instanceof ve&&(t=t.valueOf()),typeof t=="object"&&"calendarId"in t&&e.calendar===void 0&&(e={...e,calendar:t.calendarId}),super(t),this.opts=e}[Symbol.toPrimitive](t){return t==="string"?this.toString():this.toNumber()}toNumber(){const t=this.value;if(typeof t=="number")return t;if(t instanceof Date)return t.getTime();if("epochMilliseconds"in t)return t.epochMilliseconds;if("toZonedDateTime"in t)return t.toZonedDateTime("UTC").epochMilliseconds;throw new TypeError("Unwrapping a non-number value as a number")}toString(t){if(t)try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return typeof this.value=="number"||this.value instanceof Date?new Date(this.value).toISOString():this.value.toString()}}const Xn=100,Eh="â¨",Sh="â©";function xh(h,t,e){if(e===t||e instanceof $t&&t instanceof $t&&e.value===t.value)return!0;if(t instanceof $t&&typeof e=="string"){let i=h.memoizeIntlObject(Intl.PluralRules,t.opts).select(t.value);if(e===i)return!0}return!1}function Yn(h,t,e){return t[e]?xe(h,t[e].value):(h.reportError(new RangeError("No default")),new st)}function xs(h,t){const e=[],i=Object.create(null);for(const s of t)s.type==="narg"?i[s.name]=ze(h,s.value):e.push(ze(h,s));return{positional:e,named:i}}function ze(h,t){switch(t.type){case"str":return t.value;case"num":return new $t(t.value,{minimumFractionDigits:t.precision});case"var":return _h(h,t);case"mesg":return Ch(h,t);case"term":return Ph(h,t);case"func":return Th(h,t);case"select":return kh(h,t);default:return new st}}function _h(h,{name:t}){let e;if(h.params)if(Object.prototype.hasOwnProperty.call(h.params,t))e=h.params[t];else return new st(`$${t}`);else if(h.args&&Object.prototype.hasOwnProperty.call(h.args,t))e=h.args[t];else return h.reportError(new ReferenceError(`Unknown variable: $${t}`)),new st(`$${t}`);if(e instanceof ve)return e;switch(typeof e){case"string":return e;case"number":return new $t(e);case"object":if(Gt.supportsValue(e))return new Gt(e);default:return h.reportError(new TypeError(`Variable type not supported: $${t}, ${typeof e}`)),new st(`$${t}`)}}function Ch(h,{name:t,attr:e}){const i=h.bundle._messages.get(t);if(!i)return h.reportError(new ReferenceError(`Unknown message: ${t}`)),new st(t);if(e){const s=i.attributes[e];return s?xe(h,s):(h.reportError(new ReferenceError(`Unknown attribute: ${e}`)),new st(`${t}.${e}`))}return i.value?xe(h,i.value):(h.reportError(new ReferenceError(`No value: ${t}`)),new st(t))}function Ph(h,{name:t,attr:e,args:i}){const s=`-${t}`,n=h.bundle._terms.get(s);if(!n)return h.reportError(new ReferenceError(`Unknown term: ${s}`)),new st(s);if(e){const a=n.attributes[e];if(a){h.params=xs(h,i).named;const o=xe(h,a);return h.params=null,o}return h.reportError(new ReferenceError(`Unknown attribute: ${e}`)),new st(`${s}.${e}`)}h.params=xs(h,i).named;const r=xe(h,n.value);return h.params=null,r}function Th(h,{name:t,args:e}){let i=h.bundle._functions[t];if(!i)return h.reportError(new ReferenceError(`Unknown function: ${t}()`)),new st(`${t}()`);if(typeof i!="function")return h.reportError(new TypeError(`Function ${t}() is not callable`)),new st(`${t}()`);try{let s=xs(h,e);return i(s.positional,s.named)}catch(s){return h.reportError(s),new st(`${t}()`)}}function kh(h,{selector:t,variants:e,star:i}){let s=ze(h,t);if(s instanceof st)return Yn(h,e,i);for(const n of e){const r=ze(h,n.key);if(xh(h,s,r))return xe(h,n.value)}return Yn(h,e,i)}function sa(h,t){if(h.dirty.has(t))return h.reportError(new RangeError("Cyclic reference")),new st;h.dirty.add(t);const e=[],i=h.bundle._useIsolating&&t.length>1;for(const s of t){if(typeof s=="string"){e.push(h.bundle._transform(s));continue}if(h.placeables++,h.placeables>Xn)throw h.dirty.delete(t),new RangeError(`Too many placeables expanded: ${h.placeables}, max allowed is ${Xn}`);i&&e.push(Eh),e.push(ze(h,s).toString(h)),i&&e.push(Sh)}return h.dirty.delete(t),e.join("")}function xe(h,t){return typeof t=="string"?h.bundle._transform(t):sa(h,t)}class Mh{constructor(t,e,i){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=t,this.errors=e,this.args=i}reportError(t){if(!this.errors||!(t instanceof Error))throw t;this.errors.push(t)}memoizeIntlObject(t,e){let i=this.bundle._intls.get(t);i||(i={},this.bundle._intls.set(t,i));let s=JSON.stringify(e);return i[s]||(i[s]=new t(this.bundle.locales,e)),i[s]}}function _s(h,t){const e=Object.create(null);for(const[i,s]of Object.entries(h))t.includes(i)&&(e[i]=s.valueOf());return e}const qn=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Ih(h,t){let e=h[0];if(e instanceof st)return new st(`NUMBER(${e.valueOf()})`);if(e instanceof $t)return new $t(e.valueOf(),{...e.opts,..._s(t,qn)});if(e instanceof Gt)return new $t(e.toNumber(),{..._s(t,qn)});throw new TypeError("Invalid argument to NUMBER")}const Lh=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function Dh(h,t){let e=h[0];if(e instanceof st)return new st(`DATETIME(${e.valueOf()})`);if(e instanceof Gt||e instanceof $t)return new Gt(e,_s(t,Lh));throw new TypeError("Invalid argument to DATETIME")}const Kn=new Map;function Rh(h){const t=Array.isArray(h)?h.join(" "):h;let e=Kn.get(t);return e===void 0&&(e=new Map,Kn.set(t,e)),e}class Nh{constructor(t,{functions:e,useIsolating:i=!0,transform:s=n=>n}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:Ih,DATETIME:Dh,...e},this._useIsolating=i,this._transform=s,this._intls=Rh(t)}hasMessage(t){return this._messages.has(t)}getMessage(t){return this._messages.get(t)}addResource(t,{allowOverrides:e=!1}={}){const i=[];for(let s=0;s<t.body.length;s++){let n=t.body[s];if(n.id.startsWith("-")){if(e===!1&&this._terms.has(n.id)){i.push(new Error(`Attempt to override an existing term: "${n.id}"`));continue}this._terms.set(n.id,n)}else{if(e===!1&&this._messages.has(n.id)){i.push(new Error(`Attempt to override an existing message: "${n.id}"`));continue}this._messages.set(n.id,n)}}return i}formatPattern(t,e=null,i=null){if(typeof t=="string")return this._transform(t);let s=new Mh(this,i,e);try{return sa(s,t).toString(s)}catch(n){if(s.errors&&n instanceof Error)return s.errors.push(n),new st().toString(s);throw n}}}const Ki=/^(-?[a-zA-Z][\w-]*) *= */gm,Qn=/\.([a-zA-Z][\w-]*) *= */y,Oh=/\*?\[/y,Qi=/(-?[0-9]+(?:\.([0-9]+))?)/y,Fh=/([a-zA-Z][\w-]*)/y,Zn=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Bh=/^[A-Z][A-Z0-9_-]*$/,ai=/([^{}\n\r]+)/y,jh=/([^\\"\n\r]*)/y,Jn=/\\([\\"])/y,tr=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,$h=/^\n+/,er=/ +$/,Uh=/ *\r?\n/g,Vh=/( *)$/,Hh=/{\s*/y,ir=/\s*}/y,zh=/\[\s*/y,Wh=/\s*] */y,Gh=/\s*\(\s*/y,Xh=/\s*->\s*/y,Yh=/\s*:\s*/y,qh=/\s*,?\s*/y,Kh=/\s+/y;class Qh{constructor(t){this.body=[],Ki.lastIndex=0;let e=0;for(;;){let S=Ki.exec(t);if(S===null)break;e=Ki.lastIndex;try{this.body.push(o(S[1]))}catch(P){if(P instanceof SyntaxError)continue;throw P}}function i(S){return S.lastIndex=e,S.test(t)}function s(S,P){if(t[e]===S)return e++,!0;if(P)throw new P(`Expected ${S}`);return!1}function n(S,P){if(i(S))return e=S.lastIndex,!0;if(P)throw new P(`Expected ${S.toString()}`);return!1}function r(S){S.lastIndex=e;let P=S.exec(t);if(P===null)throw new SyntaxError(`Expected ${S.toString()}`);return e=S.lastIndex,P}function a(S){return r(S)[1]}function o(S){let P=c(),T=l();if(P===null&&Object.keys(T).length===0)throw new SyntaxError("Expected message value or attributes");return{id:S,value:P,attributes:T}}function l(){let S=Object.create(null);for(;i(Qn);){let P=a(Qn),T=c();if(T===null)throw new SyntaxError("Expected attribute value");S[P]=T}return S}function c(){let S;if(i(ai)&&(S=a(ai)),t[e]==="{"||t[e]==="}")return d(S?[S]:[],1/0);let P=E();return P?S?d([S,P],P.length):(P.value=_(P.value,$h),d([P],P.length)):S?_(S,er):null}function d(S=[],P){for(;;){if(i(ai)){S.push(a(ai));continue}if(t[e]==="{"){S.push(u());continue}if(t[e]==="}")throw new SyntaxError("Unbalanced closing brace");let D=E();if(D){S.push(D),P=Math.min(P,D.length);continue}break}let T=S.length-1,M=S[T];typeof M=="string"&&(S[T]=_(M,er));let L=[];for(let D of S)D instanceof sr&&(D=D.value.slice(0,D.value.length-P)),D&&L.push(D);return L}function u(){n(Hh,SyntaxError);let S=f();if(n(ir))return S;if(n(Xh)){let P=m();return n(ir,SyntaxError),{type:"select",selector:S,...P}}throw new SyntaxError("Unclosed placeable")}function f(){if(t[e]==="{")return u();if(i(Zn)){let[,S,P,T=null]=r(Zn);if(S==="$")return{type:"var",name:P};if(n(Gh)){let M=p();if(S==="-")return{type:"term",name:P,attr:T,args:M};if(Bh.test(P))return{type:"func",name:P,args:M};throw new SyntaxError("Function names must be all upper-case")}return S==="-"?{type:"term",name:P,attr:T,args:[]}:{type:"mesg",name:P,attr:T}}return y()}function p(){let S=[];for(;;){switch(t[e]){case")":return e++,S;case void 0:throw new SyntaxError("Unclosed argument list")}S.push(g()),n(qh)}}function g(){let S=f();return S.type!=="mesg"?S:n(Yh)?{type:"narg",name:S.name,value:y()}:S}function m(){let S=[],P=0,T;for(;i(Oh);){s("*")&&(T=P);let M=b(),L=c();if(L===null)throw new SyntaxError("Expected variant value");S[P++]={key:M,value:L}}if(P===0)return null;if(T===void 0)throw new SyntaxError("Expected default variant");return{variants:S,star:T}}function b(){n(zh,SyntaxError);let S;return i(Qi)?S=w():S={type:"str",value:a(Fh)},n(Wh,SyntaxError),S}function y(){if(i(Qi))return w();if(t[e]==='"')return A();throw new SyntaxError("Invalid expression")}function w(){let[,S,P=""]=r(Qi),T=P.length;return{type:"num",value:parseFloat(S),precision:T}}function A(){s('"',SyntaxError);let S="";for(;;){if(S+=a(jh),t[e]==="\\"){S+=v();continue}if(s('"'))return{type:"str",value:S};throw new SyntaxError("Unclosed string literal")}}function v(){if(i(Jn))return a(Jn);if(i(tr)){let[,S,P]=r(tr),T=parseInt(S||P,16);return T<=55295||57344<=T?String.fromCodePoint(T):"�"}throw new SyntaxError("Unknown escape sequence")}function E(){let S=e;switch(n(Kh),t[e]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return C(t.slice(S,e))}return t[e-1]===" "?C(t.slice(S,e)):!1}function _(S,P){return S.replace(P,"")}function C(S){let P=S.replace(Uh,` 58`),T=Vh.exec(S)[1].length;return new sr(P,T)}}}class sr{constructor(t,e){this.value=t,this.length=e}}const Zh=/<|&#?\w+;/,Jh={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},tc={"http://www.w3.org/1999/xhtml":{global:["title","aria-description","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function ec(h,t){const{value:e}=t;if(typeof e=="string")if(h.localName==="title"&&h.namespaceURI==="http://www.w3.org/1999/xhtml")h.textContent=e;else if(!Zh.test(e))h.textContent=e;else{const i=h.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");i.innerHTML=e,ic(i.content,h)}na(t,h)}function ic(h,t){for(const e of h.childNodes)if(e.nodeType!==e.TEXT_NODE){if(e.hasAttribute("data-l10n-name")){const i=nc(t,e);h.replaceChild(i,e);continue}if(ac(e)){const i=rc(e);h.replaceChild(i,e);continue}console.warn(`An element of forbidden type "${e.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`),h.replaceChild(Cs(e),e)}t.textContent="",t.appendChild(h)}function sc(h,t){if(!h)return!1;for(let e of h)if(e.name===t)return!0;return!1}function na(h,t){const e=t.hasAttribute("data-l10n-attrs")?t.getAttribute("data-l10n-attrs").split(",").map(i=>i.trim()):null;for(const i of Array.from(t.attributes))nr(i.name,t,e)&&!sc(h.attributes,i.name)&&t.removeAttribute(i.name);if(h.attributes)for(const i of Array.from(h.attributes))nr(i.name,t,e)&&t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}function nc(h,t){const e=t.getAttribute("data-l10n-name"),i=h.querySelector(`[data-l10n-name="${e}"]`);if(!i)return console.warn(`An element named "${e}" wasn't found in the source.`),Cs(t);if(i.localName!==t.localName)return console.warn(`An element named "${e}" was found in the translation but its type ${t.localName} didn't match the element found in the source (${i.localName}).`),Cs(t);h.removeChild(i);const s=i.cloneNode(!1);return ra(t,s)}function rc(h){const t=h.ownerDocument.createElement(h.localName);return ra(h,t)}function Cs(h){return h.ownerDocument.createTextNode(h.textContent)}function ac(h){const t=Jh[h.namespaceURI];return t&&t.includes(h.localName)}function nr(h,t,e=null){if(e&&e.includes(h))return!0;const i=tc[t.namespaceURI];if(!i)return!1;const s=h.toLowerCase(),n=t.localName;if(i.global.includes(s))return!0;if(!i[n])return!1;if(i[n].includes(s))return!0;if(t.namespaceURI==="http://www.w3.org/1999/xhtml"&&n==="input"&&s==="value"){const r=t.type.toLowerCase();if(r==="submit"||r==="button"||r==="reset")return!0}return!1}function ra(h,t){return t.textContent=h.textContent,na(h,t),t}class oc extends Array{static from(t){return t instanceof this?t:new this(t)}}class lc extends oc{constructor(t){if(super(),Symbol.asyncIterator in Object(t))this.iterator=t[Symbol.asyncIterator]();else if(Symbol.iterator in Object(t))this.iterator=t[Symbol.iterator]();else throw new TypeError("Argument must implement the iteration protocol.")}[Symbol.asyncIterator](){const t=this;let e=0;return{async next(){return t.length<=e&&t.push(t.iterator.next()),t[e++]}}}async touchNext(t=1){let e=0;for(;e++<t;){const i=this[this.length-1];if(i&&(await i).done)break;this.push(this.iterator.next())}return this[this.length-1]}}class hc{constructor(t=[],e){this.resourceIds=t,this.generateBundles=e,this.onChange(!0)}addResourceIds(t,e=!1){return this.resourceIds.push(...t),this.onChange(e),this.resourceIds.length}removeResourceIds(t){return this.resourceIds=this.resourceIds.filter(e=>!t.includes(e)),this.onChange(),this.resourceIds.length}async formatWithFallback(t,e){const i=[];let s=!1;for await(const n of this.bundles){s=!0;const r=uc(e,n,t,i);if(r.size===0)break;if(typeof console<"u"){const a=n.locales[0],o=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${a}: ${o}`)}}return!s&&typeof console<"u"&&console.warn(`[fluent] Request for keys failed because no resource bundles got generated. 59 keys: ${JSON.stringify(t)}. 60 resourceIds: ${JSON.stringify(this.resourceIds)}.`),i}formatMessages(t){return this.formatWithFallback(t,dc)}formatValues(t){return this.formatWithFallback(t,cc)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=lc.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function cc(h,t,e,i){return e.value?h.formatPattern(e.value,i,t):null}function dc(h,t,e,i){const s={value:null,attributes:null};e.value&&(s.value=h.formatPattern(e.value,i,t));let n=Object.keys(e.attributes);if(n.length>0){s.attributes=new Array(n.length);for(let[r,a]of n.entries()){let o=h.formatPattern(e.attributes[a],i,t);s.attributes[r]={name:a,value:o}}}return s}function uc(h,t,e,i){const s=[],n=new Set;return e.forEach(({id:r,args:a},o)=>{if(i[o]!==void 0)return;let l=t.getMessage(r);if(l){if(s.length=0,i[o]=h(t,s,l,a),s.length>0&&typeof console<"u"){const c=t.locales[0],d=s.join(", ");console.warn(`[fluent][resolver] errors in ${c}/${r}: ${d}.`)}}else n.add(r)}),n}const Jt="data-l10n-id",ke="data-l10n-args",fc=`[${Jt}]`;class pc extends hc{constructor(t,e){super(t,e),this.roots=new Set,this.pendingrAF=null,this.pendingElements=new Set,this.windowElement=null,this.mutationObserver=null,this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[Jt,ke]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Jt,e),i?t.setAttribute(ke,JSON.stringify(i)):t.removeAttribute(ke),t}getAttributes(t){return{id:t.getAttribute(Jt),args:JSON.parse(t.getAttribute(ke)||null)}}connectRoot(t){for(const e of this.roots)if(e===t||e.contains(t)||t.contains(e))throw new Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==t.ownerDocument.defaultView)throw new Error(`Cannot connect a root: 61 DOMLocalization already has a root from a different window.`)}else this.windowElement=t.ownerDocument.defaultView,this.mutationObserver=new this.windowElement.MutationObserver(e=>this.translateMutations(e));this.roots.add(t),this.mutationObserver.observe(t,this.observerConfig)}disconnectRoot(t){return this.roots.delete(t),this.pauseObserving(),this.roots.size===0?(this.mutationObserver=null,this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF),this.windowElement=null,this.pendingrAF=null,this.pendingElements.clear(),!0):(this.resumeObserving(),!1)}translateRoots(){const t=Array.from(this.roots);return Promise.all(t.map(e=>this.translateFragment(e)))}pauseObserving(){this.mutationObserver&&(this.translateMutations(this.mutationObserver.takeRecords()),this.mutationObserver.disconnect())}resumeObserving(){if(this.mutationObserver)for(const t of this.roots)this.mutationObserver.observe(t,this.observerConfig)}translateMutations(t){for(const e of t)switch(e.type){case"attributes":e.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(e.target);break;case"childList":for(const i of e.addedNodes)if(i.nodeType===i.ELEMENT_NODE)if(i.childElementCount)for(const s of this.getTranslatables(i))this.pendingElements.add(s);else i.hasAttribute(Jt)&&this.pendingElements.add(i);break}this.pendingElements.size>0&&this.pendingrAF===null&&(this.pendingrAF=this.windowElement.requestAnimationFrame(()=>{this.translateElements(Array.from(this.pendingElements)),this.pendingElements.clear(),this.pendingrAF=null}))}translateFragment(t){return this.translateElements(this.getTranslatables(t))}async translateElements(t){if(!t.length)return;const e=t.map(this.getKeysForElement),i=await this.formatMessages(e);return this.applyTranslations(t,i)}applyTranslations(t,e){this.pauseObserving();for(let i=0;i<t.length;i++)e[i]!==void 0&&ec(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(fc));return typeof t.hasAttribute=="function"&&t.hasAttribute(Jt)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Jt),args:JSON.parse(t.getAttribute(ke)||null)}}}class wi{#t;#e;#i;#s;constructor({lang:t,isRTL:e},i=null){this.#i=wi.#n(t),this.#s=i,this.#t=e??wi.#r(this.#i)?"rtl":"ltr"}_setL10n(t){this.#s=t}getLanguage(){return this.#i}getDirection(){return this.#t}async get(t,e=null,i){return Array.isArray(t)?(t=t.map(r=>({id:r})),(await this.#s.formatMessages(t)).map(r=>r.value)):(await this.#s.formatMessages([{id:t,args:e}]))[0]?.value||i}async translate(t){(this.#e||=new Set).add(t);try{this.#s.connectRoot(t),await this.#s.translateRoots()}catch{}}async translateOnce(t){try{await this.#s.translateElements([t])}catch(e){console.error("translateOnce:",e)}}async destroy(){if(this.#e){for(const t of this.#e)this.#s.disconnectRoot(t);this.#e.clear(),this.#e=null}this.#s.pauseObserving()}pause(){this.#s.pauseObserving()}resume(){this.#s.resumeObserving()}static#n(t){return t=t?.toLowerCase()||"en-us",{en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"}[t]||t}static#r(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function gc(){const{isAndroid:h,isLinux:t,isMac:e,isWindows:i}=qs.platform;return t?"linux":i?"windows":e?"macos":h?"android":"other"}function rr(h,t){const e=new Qh(t),i=new Nh(h,{functions:{PLATFORM:gc}}),s=i.addResource(e);return s.length&&console.error("L10n errors",s),i}class jt extends wi{constructor(t){super({lang:t});const e=t?jt.#t.bind(jt,"en-us",this.getLanguage()):jt.#s.bind(jt,this.getLanguage());this._setL10n(new pc([],e))}static async*#t(t,e){const{baseURL:i,paths:s}=await this.#i(),n=[e];if(t!==e){const a=e.split("-",1)[0];a!==e&&n.push(a),n.push(t)}const r=n.map(a=>[a,this.#e(a,i,s)]);for(const[a,o]of r){const l=await o;l?yield l:a==="en-us"&&(yield this.#n(a))}}static async#e(t,e,i){const s=i[t];if(!s)return null;const n=new URL(s,e),r=await Ln(n,"text");return rr(t,r)}static async#i(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await Ln(t,"json");return{baseURL:t.substring(0,t.lastIndexOf("/")+1)||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#s(t){yield this.#n(t)}static async#n(t){return rr(t
vendor: 24,954 bytes, lines 61-596
61,`pdfjs-previous-button = 62 .title = Previous Page 63pdfjs-previous-button-label = Previous 64pdfjs-next-button = 65 .title = Next Page 66pdfjs-next-button-label = Next 67pdfjs-page-input = 68 .title = Page 69pdfjs-of-pages = of { $pagesCount } 70pdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount }) 71pdfjs-zoom-out-button = 72 .title = Zoom Out 73pdfjs-zoom-out-button-label = Zoom Out 74pdfjs-zoom-in-button = 75 .title = Zoom In 76pdfjs-zoom-in-button-label = Zoom In 77pdfjs-zoom-select = 78 .title = Zoom 79pdfjs-presentation-mode-button = 80 .title = Switch to Presentation Mode 81pdfjs-presentation-mode-button-label = Presentation Mode 82pdfjs-open-file-button = 83 .title = Open File 84pdfjs-open-file-button-label = Open 85pdfjs-print-button = 86 .title = Print 87pdfjs-print-button-label = Print 88pdfjs-save-button = 89 .title = Save 90pdfjs-save-button-label = Save 91pdfjs-download-button = 92 .title = Download 93pdfjs-download-button-label = Download 94pdfjs-bookmark-button = 95 .title = Current Page (View URL from Current Page) 96pdfjs-bookmark-button-label = Current Page 97pdfjs-tools-button = 98 .title = Tools 99pdfjs-tools-button-label = Tools 100pdfjs-first-page-button = 101 .title = Go to First Page 102pdfjs-first-page-button-label = Go to First Page 103pdfjs-last-page-button = 104 .title = Go to Last Page 105pdfjs-last-page-button-label = Go to Last Page 106pdfjs-page-rotate-cw-button = 107 .title = Rotate Clockwise 108pdfjs-page-rotate-cw-button-label = Rotate Clockwise 109pdfjs-page-rotate-ccw-button = 110 .title = Rotate Counterclockwise 111pdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise 112pdfjs-cursor-text-select-tool-button = 113 .title = Enable Text Selection Tool 114pdfjs-cursor-text-select-tool-button-label = Text Selection Tool 115pdfjs-cursor-hand-tool-button = 116 .title = Enable Hand Tool 117pdfjs-cursor-hand-tool-button-label = Hand Tool 118pdfjs-scroll-page-button = 119 .title = Use Page Scrolling 120pdfjs-scroll-page-button-label = Page Scrolling 121pdfjs-scroll-vertical-button = 122 .title = Use Vertical Scrolling 123pdfjs-scroll-vertical-button-label = Vertical Scrolling 124pdfjs-scroll-horizontal-button = 125 .title = Use Horizontal Scrolling 126pdfjs-scroll-horizontal-button-label = Horizontal Scrolling 127pdfjs-scroll-wrapped-button = 128 .title = Use Wrapped Scrolling 129pdfjs-scroll-wrapped-button-label = Wrapped Scrolling 130pdfjs-spread-none-button = 131 .title = Do not join page spreads 132pdfjs-spread-none-button-label = No Spreads 133pdfjs-spread-odd-button = 134 .title = Join page spreads starting with odd-numbered pages 135pdfjs-spread-odd-button-label = Odd Spreads 136pdfjs-spread-even-button = 137 .title = Join page spreads starting with even-numbered pages 138pdfjs-spread-even-button-label = Even Spreads 139pdfjs-document-properties-button = 140 .title = Document Properties⦠141pdfjs-document-properties-button-label = Document Properties⦠142pdfjs-document-properties-file-name = File name: 143pdfjs-document-properties-file-size = File size: 144pdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes) 145pdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes) 146pdfjs-document-properties-title = Title: 147pdfjs-document-properties-author = Author: 148pdfjs-document-properties-subject = Subject: 149pdfjs-document-properties-keywords = Keywords: 150pdfjs-document-properties-creation-date = Creation Date: 151pdfjs-document-properties-modification-date = Modification Date: 152pdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") } 153pdfjs-document-properties-creator = Creator: 154pdfjs-document-properties-producer = PDF Producer: 155pdfjs-document-properties-version = PDF Version: 156pdfjs-document-properties-page-count = Page Count: 157pdfjs-document-properties-page-size = Page Size: 158pdfjs-document-properties-page-size-unit-inches = in 159pdfjs-document-properties-page-size-unit-millimeters = mm 160pdfjs-document-properties-page-size-orientation-portrait = portrait 161pdfjs-document-properties-page-size-orientation-landscape = landscape 162pdfjs-document-properties-page-size-name-a-three = A3 163pdfjs-document-properties-page-size-name-a-four = A4 164pdfjs-document-properties-page-size-name-letter = Letter 165pdfjs-document-properties-page-size-name-legal = Legal 166pdfjs-document-properties-page-size-dimension-string = { $width } à { $height } { $unit } ({ $orientation }) 167pdfjs-document-properties-page-size-dimension-name-string = { $width } à { $height } { $unit } ({ $name }, { $orientation }) 168pdfjs-document-properties-linearized = Fast Web View: 169pdfjs-document-properties-linearized-yes = Yes 170pdfjs-document-properties-linearized-no = No 171pdfjs-document-properties-close-button = Close 172pdfjs-print-progress-message = Preparing document for printing⦠173pdfjs-print-progress-percent = { $progress }% 174pdfjs-print-progress-close-button = Cancel 175pdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser. 176pdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing. 177pdfjs-current-outline-item-button = 178 .title = Find Current Outline Item 179pdfjs-current-outline-item-button-label = Current Outline Item 180pdfjs-findbar-button = 181 .title = Find in Document 182pdfjs-findbar-button-label = Find 183pdfjs-additional-layers = Additional Layers 184pdfjs-thumb-page-title1 = 185 .title = Page { $page } of { $total } 186pdfjs-thumb-page-canvas = 187 .aria-label = Thumbnail of Page { $page } 188pdfjs-thumb-page-checkbox1 = 189 .title = Select page { $page } 190pdfjs-find-input = 191 .title = Find 192 .placeholder = Find in document⦠193pdfjs-find-previous-button = 194 .title = Find the previous occurrence of the phrase 195pdfjs-find-previous-button-label = Previous 196pdfjs-find-next-button = 197 .title = Find the next occurrence of the phrase 198pdfjs-find-next-button-label = Next 199pdfjs-find-highlight-checkbox = Highlight All 200pdfjs-find-match-case-checkbox-label = Match Case 201pdfjs-find-match-diacritics-checkbox-label = Match Diacritics 202pdfjs-find-entire-word-checkbox-label = Whole Words 203pdfjs-find-reached-top = Reached top of document, continued from bottom 204pdfjs-find-reached-bottom = Reached end of document, continued from top 205pdfjs-find-match-count = 206 { $total -> 207 [one] { $current } of { $total } match 208 *[other] { $current } of { $total } matches 209 } 210pdfjs-find-match-count-limit = 211 { $limit -> 212 [one] More than { $limit } match 213 *[other] More than { $limit } matches 214 } 215pdfjs-find-not-found = Phrase not found 216pdfjs-page-scale-width = Page Width 217pdfjs-page-scale-fit = Page Fit 218pdfjs-page-scale-auto = Automatic Zoom 219pdfjs-page-scale-actual = Actual Size 220pdfjs-page-scale-percent = { $scale }% 221pdfjs-page-landmark = 222 .aria-label = Page { $page } 223pdfjs-loading-error = An error occurred while loading the PDF. 224pdfjs-invalid-file-error = Invalid or corrupted PDF file. 225pdfjs-missing-file-error = Missing PDF file. 226pdfjs-unexpected-response-error = Unexpected server response. 227pdfjs-rendering-error = An error occurred while rendering the page. 228pdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") } 229pdfjs-text-annotation-type = 230 .alt = [{ $type } Annotation] 231pdfjs-password-label = Enter the password to open this PDF file. 232pdfjs-password-invalid = Invalid password. Please try again. 233pdfjs-password-ok-button = OK 234pdfjs-password-cancel-button = Cancel 235pdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts. 236pdfjs-editor-free-text-button = 237 .title = Text 238pdfjs-editor-color-picker-free-text-input = 239 .title = Change text color 240pdfjs-editor-free-text-button-label = Text 241pdfjs-editor-ink-button = 242 .title = Draw 243pdfjs-editor-color-picker-ink-input = 244 .title = Change drawing color 245pdfjs-editor-ink-button-label = Draw 246pdfjs-editor-stamp-button = 247 .title = Add or edit images 248pdfjs-editor-stamp-button-label = Add or edit images 249pdfjs-editor-highlight-button = 250 .title = Highlight 251pdfjs-editor-highlight-button-label = Highlight 252pdfjs-highlight-floating-button1 = 253 .title = Highlight 254 .aria-label = Highlight 255pdfjs-highlight-floating-button-label = Highlight 256pdfjs-comment-floating-button = 257 .title = Comment 258 .aria-label = Comment 259pdfjs-comment-floating-button-label = Comment 260pdfjs-editor-comment-button = 261 .title = Comment 262 .aria-label = Comment 263pdfjs-editor-comment-button-label = Comment 264pdfjs-editor-signature-button = 265 .title = Add signature 266pdfjs-editor-signature-button-label = Add signature 267pdfjs-editor-highlight-editor = 268 .aria-label = Highlight editor 269pdfjs-editor-ink-editor = 270 .aria-label = Drawing editor 271pdfjs-editor-signature-editor1 = 272 .aria-description = Signature editor: { $description } 273pdfjs-editor-stamp-editor = 274 .aria-label = Image editor 275pdfjs-editor-remove-ink-button = 276 .title = Remove drawing 277pdfjs-editor-remove-freetext-button = 278 .title = Remove text 279pdfjs-editor-remove-stamp-button = 280 .title = Remove image 281pdfjs-editor-remove-highlight-button = 282 .title = Remove highlight 283pdfjs-editor-remove-signature-button = 284 .title = Remove signature 285pdfjs-editor-free-text-color-input = Color 286pdfjs-editor-free-text-size-input = Size 287pdfjs-editor-ink-color-input = Color 288pdfjs-editor-ink-thickness-input = Thickness 289pdfjs-editor-ink-opacity-input = Opacity 290pdfjs-editor-stamp-add-image-button = 291 .title = Add image 292pdfjs-editor-stamp-add-image-button-label = Add image 293pdfjs-editor-free-highlight-thickness-input = Thickness 294pdfjs-editor-free-highlight-thickness-title = 295 .title = Change thickness when highlighting items other than text 296pdfjs-editor-add-signature-container = 297 .aria-label = Signature controls and saved signatures 298pdfjs-editor-signature-add-signature-button = 299 .title = Add new signature 300pdfjs-editor-signature-add-signature-button-label = Add new signature 301pdfjs-editor-add-saved-signature-button = 302 .title = Saved signature: { $description } 303pdfjs-free-text2 = 304 .aria-label = Text Editor 305 .default-content = Start typing⦠306pdfjs-editor-comments-sidebar-title = 307 { $count -> 308 [one] Comment 309 *[other] Comments 310 } 311pdfjs-editor-comments-sidebar-close-button = 312 .title = Close the sidebar 313 .aria-label = Close the sidebar 314pdfjs-editor-comments-sidebar-close-button-label = Close the sidebar 315pdfjs-editor-comments-sidebar-no-comments1 = See something noteworthy? Highlight it and leave a comment. 316pdfjs-editor-comments-sidebar-no-comments-link = Learn more 317pdfjs-editor-alt-text-button = 318 .aria-label = Alt text 319pdfjs-editor-alt-text-button-label = Alt text 320pdfjs-editor-alt-text-edit-button = 321 .aria-label = Edit alt text 322pdfjs-editor-alt-text-dialog-label = Choose an option 323pdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people canât see the image or when it doesnât load. 324pdfjs-editor-alt-text-add-description-label = Add a description 325pdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions. 326pdfjs-editor-alt-text-mark-decorative-label = Mark as decorative 327pdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks. 328pdfjs-editor-alt-text-cancel-button = Cancel 329pdfjs-editor-alt-text-save-button = Save 330pdfjs-editor-alt-text-decorative-tooltip = Marked as decorative 331pdfjs-editor-alt-text-textarea = 332 .placeholder = For example, âA young man sits down at a table to eat a mealâ 333pdfjs-editor-resizer-top-left = 334 .aria-label = Top left corner â resize 335pdfjs-editor-resizer-top-middle = 336 .aria-label = Top middle â resize 337pdfjs-editor-resizer-top-right = 338 .aria-label = Top right corner â resize 339pdfjs-editor-resizer-middle-right = 340 .aria-label = Middle right â resize 341pdfjs-editor-resizer-bottom-right = 342 .aria-label = Bottom right corner â resize 343pdfjs-editor-resizer-bottom-middle = 344 .aria-label = Bottom middle â resize 345pdfjs-editor-resizer-bottom-left = 346 .aria-label = Bottom left corner â resize 347pdfjs-editor-resizer-middle-left = 348 .aria-label = Middle left â resize 349pdfjs-editor-highlight-colorpicker-label = Highlight color 350pdfjs-editor-colorpicker-button = 351 .title = Change color 352pdfjs-editor-colorpicker-dropdown = 353 .aria-label = Color choices 354pdfjs-editor-colorpicker-yellow = 355 .title = Yellow 356pdfjs-editor-colorpicker-green = 357 .title = Green 358pdfjs-editor-colorpicker-blue = 359 .title = Blue 360pdfjs-editor-colorpicker-pink = 361 .title = Pink 362pdfjs-editor-colorpicker-red = 363 .title = Red 364pdfjs-editor-highlight-show-all-button-label = Show all 365pdfjs-editor-highlight-show-all-button = 366 .title = Show all 367pdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description) 368pdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description) 369pdfjs-editor-new-alt-text-textarea = 370 .placeholder = Write your description here⦠371pdfjs-editor-new-alt-text-description = Short description for people who canât see the image or when the image doesnât load. 372pdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate. 373pdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more 374pdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically 375pdfjs-editor-new-alt-text-not-now-button = Not now 376pdfjs-editor-new-alt-text-error-title = Couldnât create alt text automatically 377pdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later. 378pdfjs-editor-new-alt-text-error-close-button = Close 379pdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB) 380 .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB) 381pdfjs-editor-new-alt-text-added-button = 382 .aria-label = Alt text added 383pdfjs-editor-new-alt-text-added-button-label = Alt text added 384pdfjs-editor-new-alt-text-missing-button = 385 .aria-label = Missing alt text 386pdfjs-editor-new-alt-text-missing-button-label = Missing alt text 387pdfjs-editor-new-alt-text-to-review-button = 388 .aria-label = Review alt text 389pdfjs-editor-new-alt-text-to-review-button-label = Review alt text 390pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText } 391pdfjs-image-alt-text-settings-button = 392 .title = Image alt text settings 393pdfjs-image-alt-text-settings-button-label = Image alt text settings 394pdfjs-editor-alt-text-settings-dialog-label = Image alt text settings 395pdfjs-editor-alt-text-settings-automatic-title = Automatic alt text 396pdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically 397pdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who canât see the image or when the image doesnât load. 398pdfjs-editor-alt-text-settings-editor-title = Alt text editor 399pdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image 400pdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text. 401pdfjs-editor-alt-text-settings-close-button = Close 402pdfjs-editor-highlight-added-alert = Highlight added 403pdfjs-editor-freetext-added-alert = Text added 404pdfjs-editor-ink-added-alert = Drawing added 405pdfjs-editor-stamp-added-alert = Image added 406pdfjs-editor-signature-added-alert = Signature added 407pdfjs-editor-undo-bar-message-highlight = Highlight removed 408pdfjs-editor-undo-bar-message-freetext = Text removed 409pdfjs-editor-undo-bar-message-ink = Drawing removed 410pdfjs-editor-undo-bar-message-stamp = Image removed 411pdfjs-editor-undo-bar-message-signature = Signature removed 412pdfjs-editor-undo-bar-message-comment = Comment removed 413pdfjs-editor-undo-bar-message-multiple = 414 { $count -> 415 [one] { $count } annotation removed 416 *[other] { $count } annotations removed 417 } 418pdfjs-editor-undo-bar-undo-button = 419 .title = Undo 420pdfjs-editor-undo-bar-undo-button-label = Undo 421pdfjs-editor-undo-bar-close-button = 422 .title = Close 423pdfjs-editor-undo-bar-close-button-label = Close 424pdfjs-editor-add-signature-dialog-label = This modal allows the user to create a signature to add to a PDF document. The user can edit the name (which also serves as the alt text), and optionally save the signature for repeated use. 425pdfjs-editor-add-signature-dialog-title = Add a signature 426pdfjs-editor-add-signature-type-button = Type 427 .title = Type 428pdfjs-editor-add-signature-draw-button = Draw 429 .title = Draw 430pdfjs-editor-add-signature-image-button = Image 431 .title = Image 432pdfjs-editor-add-signature-type-input = 433 .aria-label = Type your signature 434 .placeholder = Type your signature 435pdfjs-editor-add-signature-draw-placeholder = Draw your signature 436pdfjs-editor-add-signature-draw-thickness-range-label = Thickness 437pdfjs-editor-add-signature-draw-thickness-range = 438 .title = Drawing thickness: { $thickness } 439pdfjs-editor-add-signature-image-placeholder = Drag a file here to upload 440pdfjs-editor-add-signature-image-browse-link = 441 { PLATFORM() -> 442 [macos] Or choose image files 443 *[other] Or browse image files 444 } 445pdfjs-editor-add-signature-description-label = Description (alt text) 446pdfjs-editor-add-signature-description-input = 447 .title = Description (alt text) 448pdfjs-editor-add-signature-description-default-when-drawing = Signature 449pdfjs-editor-add-signature-clear-button-label = Clear signature 450pdfjs-editor-add-signature-clear-button = 451 .title = Clear signature 452pdfjs-editor-add-signature-save-checkbox = Save signature 453pdfjs-editor-add-signature-save-warning-message = Youâve reached the limit of 5 saved signatures. Remove one to save more. 454pdfjs-editor-add-signature-image-upload-error-title = Couldnât upload image 455pdfjs-editor-add-signature-image-upload-error-description = Check your network connection or try another image. 456pdfjs-editor-add-signature-image-no-data-error-title = Canât convert this image into a signature 457pdfjs-editor-add-signature-image-no-data-error-description = Please try uploading a different image. 458pdfjs-editor-add-signature-error-close-button = Close 459pdfjs-editor-add-signature-cancel-button = Cancel 460pdfjs-editor-add-signature-add-button = Add 461pdfjs-editor-delete-signature-button1 = 462 .title = Remove saved signature 463pdfjs-editor-delete-signature-button-label1 = Remove saved signature 464pdfjs-editor-add-signature-edit-button-label = Edit description 465pdfjs-editor-edit-signature-dialog-title = Edit description 466pdfjs-editor-edit-signature-update-button = Update 467pdfjs-show-comment-button = 468 .title = Show comment 469pdfjs-editor-edit-comment-popup-button-label = Edit comment 470pdfjs-editor-edit-comment-popup-button = 471 .title = Edit comment 472pdfjs-editor-delete-comment-popup-button-label = Remove comment 473pdfjs-editor-delete-comment-popup-button = 474 .title = Remove comment 475pdfjs-editor-edit-comment-dialog-title-when-editing = Edit comment 476pdfjs-editor-edit-comment-dialog-save-button-when-editing = Update 477pdfjs-editor-edit-comment-dialog-title-when-adding = Add comment 478pdfjs-editor-edit-comment-dialog-save-button-when-adding = Add 479pdfjs-editor-edit-comment-dialog-text-input = 480 .placeholder = Start typing⦠481pdfjs-editor-edit-comment-dialog-cancel-button = Cancel 482pdfjs-editor-add-comment-button = 483 .title = Add comment 484pdfjs-toggle-views-manager-button1 = 485 .title = Manage pages 486pdfjs-toggle-views-manager-notification-button = 487 .title = Toggle Sidebar (document contains thumbnails/outline/attachments/layers) 488pdfjs-toggle-views-manager-button1-label = Manage pages 489pdfjs-views-manager-sidebar = 490 .aria-label = Sidebar 491pdfjs-views-manager-sidebar-resizer = 492 .aria-label = Sidebar resizer 493pdfjs-views-manager-view-selector-button = 494 .title = Views 495pdfjs-views-manager-view-selector-button-label = Views 496pdfjs-views-manager-pages-title = Pages 497pdfjs-views-manager-outlines-title1 = Document outline 498 .title = Document outline (double-click to expand/collapse all items) 499pdfjs-views-manager-attachments-title = Attachments 500pdfjs-views-manager-layers-title1 = Layers 501 .title = Layers (double-click to reset all layers to the default state) 502pdfjs-views-manager-pages-option-label = Pages 503pdfjs-views-manager-outlines-option-label = Document outline 504pdfjs-views-manager-attachments-option-label = Attachments 505pdfjs-views-manager-layers-option-label = Layers 506pdfjs-views-manager-add-file-button = 507 .title = Add file 508pdfjs-views-manager-add-file-button-label = Add file 509pdfjs-views-manager-pages-status-action-label = 510 { $count -> 511 [one] { $count } selected 512 *[other] { $count } selected 513 } 514pdfjs-views-manager-pages-status-none-action-label = Select pages 515pdfjs-views-manager-pages-status-action-button-label = Manage 516pdfjs-views-manager-pages-status-copy-button-label = Copy 517pdfjs-views-manager-pages-status-cut-button-label = Cut 518pdfjs-views-manager-pages-status-delete-button-label = Delete 519pdfjs-views-manager-pages-status-export-selected-button-label = Export selected⦠520pdfjs-views-manager-status-undo-cut-label = 521 { $count -> 522 [one] 1 page cut 523 *[other] { $count } pages cut 524 } 525pdfjs-views-manager-pages-status-undo-copy-label = 526 { $count -> 527 [one] 1 page copied 528 *[other] { $count } pages copied 529 } 530pdfjs-views-manager-pages-status-undo-delete-label = 531 { $count -> 532 [one] 1 page deleted 533 *[other] { $count } pages deleted 534 } 535pdfjs-views-manager-status-undo-button-label = Undo 536pdfjs-views-manager-status-done-button-label = Done 537pdfjs-views-manager-status-close-button = 538 .title = Close 539pdfjs-views-manager-status-close-button-label = Close 540pdfjs-views-manager-paste-button-label = Paste 541pdfjs-views-manager-paste-button-before = 542 .title = Paste before the first page 543pdfjs-views-manager-paste-button-after = 544 .title = Paste after page { $page } 545pdfjs-new-badge-content = NEW 546pdfjs-views-manager-waiting-for-file = Uploading file⦠547pdfjs-digital-signature-properties-button = 548 .title = Digital signature properties 549 .aria-label = Digital signature properties 550pdfjs-digital-signature-properties-button-label = Digital signature properties 551pdfjs-digital-signature-properties-banner-verified = Document was signed with a valid digital signature 552pdfjs-digital-signature-properties-banner-unknown = 553 { $count -> 554 [one] Document signed but { $count } digital signature could not be verified 555 *[other] Document signed but { $count } digital signatures could not be verified 556 } 557pdfjs-digital-signature-properties-banner-untrusted = 558 { $count -> 559 [one] Document signed with { $count } certificate that is not trusted 560 *[other] Document signed with { $count } certificates that are not trusted 561 } 562pdfjs-digital-signature-properties-banner-expired = 563 { $count -> 564 [one] Document signed with { $count } expired certificate 565 *[other] Document signed with { $count } expired certificates 566 } 567pdfjs-digital-signature-properties-banner-invalid = 568 { $count -> 569 [one] Document has { $count } invalid digital signature 570 *[other] Document has { $count } invalid digital signatures 571 } 572pdfjs-digital-signature-properties-banner-revoked = 573 { $count -> 574 [one] Document signed with { $count } revoked certificate 575 *[other] Document signed with { $count } revoked certificates 576 } 577pdfjs-digital-signature-properties-status-verified = Status: Signature verified 578pdfjs-digital-signature-properties-status-invalid = Status: Signature invalid 579pdfjs-digital-signature-properties-status-unknown = Status: Unable to verify (unsupported) 580pdfjs-digital-signature-properties-certificate-trusted = Certificate: Trusted ({ $issuer }) 581pdfjs-digital-signature-properties-certificate-unknown = Certificate: Unavailable 582pdfjs-digital-signature-properties-certificate-untrusted = Certificate: Untrusted 583pdfjs-digital-signature-properties-certificate-untrusted-unknown-issuer = Certificate: Unknown issuer ({ $issuer }) 584pdfjs-digital-signature-properties-certificate-untrusted-self-signed = Certificate: Self-signed ({ $issuer }) 585pdfjs-digital-signature-properties-certificate-untrusted-untrusted-issuer = Certificate: Untrusted issuer ({ $issuer }) 586pdfjs-digital-signature-properties-certificate-expired = Certificate: Expired 587pdfjs-digital-signature-properties-certificate-expired-with-date = Certificate: Expired ({ DATETIME($dateObj, dateStyle: "medium") }) 588pdfjs-digital-signature-properties-certificate-revoked = Certificate: Revoked 589pdfjs-digital-signature-properties-view-certificate = View certificate 590pdfjs-digital-signature-properties-reason = Reason: { $reason } 591pdfjs-digital-signature-properties-timestamp = Timestamp: { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") } 592pdfjs-digital-signature-properties-sub-signatures = 593 { $count -> 594 [one] Sub-signature ({ $count }) 595 *[other] Sub-signatures ({ $count }) 596 }`)}}
vendor: 23,720 bytes, lines 596-597
596const mc=1e3,bc=50,yc=1e3;function Zi(){return document.location.hash}class wc{#t=null;constructor({linkService:t,eventBus:e}){this.linkService=t,this.eventBus=e,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus.on("pagesinit",()=>{this._isPagesLoaded=!1,this.eventBus.on("pagesloaded",i=>{this._isPagesLoaded=!!i.pagesCount},{once:!0,...ft})},ft)}initialize({fingerprint:t,resetHistory:e=!1,updateUrl:i=!1}){if(!t||typeof t!="string"){console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');return}this._initialized&&this.reset();const s=this._fingerprint!==""&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=i===!0,this._initialized=!0,this.#u();const n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=Zi(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#n(n,!0)||e){const{hash:a,page:o,rotation:l}=this.#a(!0);if(!a||s||e){this.#e(null,!0);return}this.#e({hash:a,page:o,rotation:l},!0);return}const r=n.destination;this.#r(r,n.uid,!0),r.rotation!==void 0&&(this._initialRotation=r.rotation),r.dest?(this._initialBookmark=JSON.stringify(r.dest),this._destination.page=null):r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){this._initialized&&(this.#h(),this._initialized=!1,this.#d()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:t=null,explicitDest:e,pageNumber:i}){if(!this._initialized)return;if(t&&typeof t!="string"){console.error(`PDFHistory.push: "${t}" is not a valid namedDest parameter.`);return}else if(Array.isArray(e)){if(!this.#s(i)&&(i!==null||this._destination)){console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);return}}else{console.error(`PDFHistory.push: "${e}" is not a valid explicitDest parameter.`);return}const s=t||JSON.stringify(e);if(!s)return;let n=!1;if(this._destination&&(vc(this._destination.hash,s)||Ac(this._destination.dest,e))){if(this._destination.page)return;n=!0}this._popStateInProgress&&!n||(this.#e({dest:e,hash:s,page:i,rotation:this.linkService.rotation},n),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1})))}pushPage(t){if(this._initialized){if(!this.#s(t)){console.error(`PDFHistory.pushPage: "${t}" is not a valid page number.`);return}this._destination?.page!==t&&(this._popStateInProgress||(this.#e({dest:null,hash:`page=${t}`,page:t,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1}))))}}pushCurrentPosition(){!this._initialized||this._popStateInProgress||this.#i()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#n(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#n(t)&&t.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}#e(t,e=!1){const i=e||!this._destination,s={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};this.#r(t,s.uid);let n;if(this._updateUrl&&t?.hash){const{href:r,protocol:a}=document.location;a!=="file:"&&(n=Jl(r,t.hash))}i?window.history.replaceState(s,"",n):window.history.pushState(s,"",n)}#i(t=!1){if(!this._position)return;let e=this._position;if(t&&(e=Object.assign(Object.create(null),this._position),e.temporary=!0),!this._destination){this.#e(e);return}if(this._destination.temporary){this.#e(e,!0);return}if(this._destination.hash===e.hash||!this._destination.page&&this._numPositionUpdates<=bc)return;let i=!1;if(this._destination.page>=e.first&&this._destination.page<=e.page){if(this._destination.dest!==void 0||!this._destination.first)return;i=!0}this.#e(e,i)}#s(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#n(t,e=!1){if(!t)return!1;if(t.fingerprint!==this._fingerprint)if(e){if(typeof t.fingerprint!="string"||t.fingerprint.length!==this._fingerprint.length)return!1;const[i]=performance.getEntriesByType("navigation");if(i?.type!=="reload")return!1}else return!1;return!(!Number.isInteger(t.uid)||t.uid<0||t.destination===null||typeof t.destination!="object")}#r(t,e,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&t?.temporary&&delete t.temporary,this._destination=t,this._uid=e,this._maxUid=Math.max(this._maxUid,e),this._numPositionUpdates=0}#a(t=!1){const e=unescape(Zi()).substring(1),i=Ni(e),s=i.get("nameddest")||"";let n=i.get("page")|0;return(!this.#s(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#o({location:t}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation},!this._popStateInProgress&&(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout(()=>{this._popStateInProgress||this.#i(!0),this._updateViewareaTimeout=null},yc))}#l({state:t}){const e=Zi(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:n,page:r,rotation:a}=this.#a();this.#e({hash:n,page:r,rotation:a},!0);return}if(!this.#n(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,Ah({target:window,name:"hashchange",delay:mc}).then(()=>{this._blockHashChange--}));const s=t.destination;this.#r(s,t.uid,!0),Zr(s.rotation)&&(this.linkService.rotation=s.rotation),s.dest?this.linkService.goToDestination(s.dest):s.hash?this.linkService.setHash(s.hash):s.page&&(this.linkService.page=s.page),Promise.resolve().then(()=>{this._popStateInProgress=!1})}#h(){(!this._destination||this._destination.temporary)&&this.#i()}#u(){if(this.#t)return;this.#t=new AbortController;const{signal:t}=this.#t;this.eventBus.on("updateviewarea",this.#o.bind(this),{signal:t,...ft}),window.addEventListener("popstate",this.#l.bind(this),{signal:t}),window.addEventListener("pagehide",this.#h.bind(this),{signal:t})}#d(){this.#t?.abort(),this.#t=null}}function vc(h,t){return typeof h!="string"||typeof t!="string"?!1:h===t||Ni(h).get("nameddest")===t}function Ac(h,t){function e(i,s){if(typeof i!=typeof s||Array.isArray(i)||Array.isArray(s))return!1;if(i!==null&&typeof i=="object"&&s!==null){if(Object.keys(i).length!==Object.keys(s).length)return!1;for(const n in i)if(!e(i[n],s[n]))return!1;return!0}return i===s||Number.isNaN(i)&&Number.isNaN(s)}if(!(Array.isArray(h)&&Array.isArray(t))||h.length!==t.length)return!1;for(let i=0,s=h.length;i<s;i++)if(!e(h[i],t[i]))return!1;return!0}class Ec{#t=null;#e=null;#i=null;#s=null;#n=null;#r;constructor(t){this.pageIndex=t.pageIndex,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new jt,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#r=t.uiManager,this.#t=t.annotationLayer||null,this.#n=t.textLayer||null,this.#e=t.drawLayer||null,this.#i=t.onAppend||null,this.#s=t.structTreeLayer||null}updatePageIndex(t){this.pageIndex=t,this.annotationEditorLayer?.updatePageIndex(t)}async render({viewport:t,intent:e="display"}){if(e!=="display"||this._cancelled)return;const i=t.clone({dontFlip:!0});if(this.div){this.annotationEditorLayer.update({viewport:i}),this.show();return}const s=this.div=document.createElement("div");s.className="annotationEditorLayer",s.hidden=!0,s.dir=this.#r.direction,this.#i?.(s),this.annotationEditorLayer=new Bl({uiManager:this.#r,div:s,structTreeLayer:this.#s,accessibilityManager:this.accessibilityManager,pageIndex:this.pageIndex,l10n:this.l10n,viewport:i,annotationLayer:this.#t,textLayer:this.#n,drawLayer:this.#e});const n={viewport:i,div:s,annotations:null,intent:e};await this.annotationEditorLayer.render(n),this.show()}update(t){this.div&&this.annotationEditorLayer.update({viewport:t.clone({dontFlip:!0})})}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){!this.div||this.annotationEditorLayer.isInvisible||(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var Ps=new Map;const{maxTouchPoints:h,platform:t,userAgent:e}=navigator,i=/Android/.test(e);(/\b(?:iPad|iPhone|iPod)(?=;)/.test(e)||t==="MacIntel"&&h>1||i)&&Ps.set("maxCanvasPixels",5242880),i&&Ps.set("useSystemFonts",!1)}const x={BROWSER:1,VIEWER:2,API:4,WORKER:8,EVENT_DISPATCH:16,PREFERENCE:128},Ts={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},Ji=new Map([["allowedGlobalEvents",{value:null,kind:x.BROWSER}],["canvasMaxAreaInBytes",{value:-1,kind:x.BROWSER+x.API}],["isInAutomation",{value:!1,kind:x.BROWSER}],["localeProperties",{value:{lang:navigator.language||"en-US"},kind:x.BROWSER}],["maxCanvasDim",{value:32767,kind:x.BROWSER+x.VIEWER}],["nimbusDataStr",{value:"",kind:x.BROWSER}],["supportsCaretBrowsingMode",{value:!1,kind:x.BROWSER}],["supportsDocumentFonts",{value:!0,kind:x.BROWSER}],["supportsDownloading",{value:!0,kind:x.BROWSER}],["supportsIntegratedFind",{value:!1,kind:x.BROWSER}],["supportsMouseWheelZoomCtrlKey",{value:!0,kind:x.BROWSER}],["supportsMouseWheelZoomMetaKey",{value:!0,kind:x.BROWSER}],["supportsPinchToZoom",{value:!0,kind:x.BROWSER}],["supportsPrinting",{value:!0,kind:x.BROWSER}],["toolbarDensity",{value:0,kind:x.BROWSER+x.EVENT_DISPATCH}],["altTextLearnMoreUrl",{value:"",kind:x.VIEWER+x.PREFERENCE}],["annotationEditorMode",{value:0,kind:x.VIEWER+x.PREFERENCE}],["annotationMode",{value:2,kind:x.VIEWER+x.PREFERENCE}],["capCanvasAreaFactor",{value:200,kind:x.VIEWER+x.PREFERENCE}],["commentLearnMoreUrl",{value:"",kind:x.VIEWER+x.PREFERENCE}],["cursorToolOnLoad",{value:0,kind:x.VIEWER+x.PREFERENCE}],["debuggerSrc",{value:"./debugger.mjs",kind:x.VIEWER}],["defaultUrl",{value:"compressed.tracemonkey-pldi-09.pdf",kind:x.VIEWER}],["defaultZoomDelay",{value:400,kind:x.VIEWER+x.PREFERENCE}],["defaultZoomValue",{value:"",kind:x.VIEWER+x.PREFERENCE}],["disableHistory",{value:!1,kind:x.VIEWER}],["disablePageLabels",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["disablePreferences",{value:!1,kind:x.VIEWER}],["enableAltText",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enableAltTextModelDownload",{value:!0,kind:x.VIEWER+x.PREFERENCE+x.EVENT_DISPATCH}],["enableAutoLinking",{value:!0,kind:x.VIEWER+x.PREFERENCE}],["enableComment",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enableDetailCanvas",{value:!0,kind:x.VIEWER}],["enableGuessAltText",{value:!0,kind:x.VIEWER+x.PREFERENCE+x.EVENT_DISPATCH}],["enableHighlightFloatingButton",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enableMerge",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enableNewAltTextWhenAddingImage",{value:!0,kind:x.VIEWER+x.PREFERENCE}],["enableNewBadge",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enableNova",{value:!0,kind:x.VIEWER+x.PREFERENCE}],["enableOptimizedPartialRendering",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enablePermissions",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enablePrintAutoRotate",{value:!0,kind:x.VIEWER+x.PREFERENCE}],["enableScripting",{value:!0,kind:x.VIEWER+x.PREFERENCE}],["enableSelectionRendering",{value:!0,kind:x.VIEWER+x.PREFERENCE}],["enableSignatureEditor",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enableSignatureVerification",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enableSplitMerge",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["enableUpdatedAddImage",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["externalLinkRel",{value:"noopener noreferrer nofollow",kind:x.VIEWER}],["externalLinkTarget",{value:0,kind:x.VIEWER+x.PREFERENCE}],["highlightEditorColors",{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F,yellow_HCM=#FFFFCC,green_HCM=#53FFBC,blue_HCM=#80EBFF,pink_HCM=#F6B8FF,red_HCM=#C50043",kind:x.VIEWER+x.PREFERENCE}],["historyUpdateUrl",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["ignoreDestinationZoom",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["imageResourcesPath",{value:"./images/",kind:x.VIEWER}],["imagesRightClickMinSize",{value:-1,kind:x.VIEWER+x.PREFERENCE}],["maxCanvasPixels",{value:2**25,kind:x.VIEWER}],["minDurationToUpdateCanvas",{value:500,kind:x.VIEWER}],["forcePageColors",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["pageColorsBackground",{value:"Canvas",kind:x.VIEWER+x.PREFERENCE}],["pageColorsForeground",{value:"CanvasText",kind:x.VIEWER+x.PREFERENCE}],["pdfBugEnabled",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["postMessageAfterPrintCallback",{value:!1,kind:x.VIEWER+x.PREFERENCE}],["printResolution",{value:150,kind:x.VIEWER}],["sandboxBundleSrc",{value:"../build/pdf.sandbox.mjs",kind:x.VIEWER}],["sidebarViewOnLoad",{value:-1,kind:x.VIEWER+x.PREFERENCE}],["scrollModeOnLoad",{value:-1,kind:x.VIEWER+x.PREFERENCE}],["spreadModeOnLoad",{value:-1,kind:x.VIEWER+x.PREFERENCE}],["textLayerMode",{value:1,kind:x.VIEWER+x.PREFERENCE}],["viewerCssTheme",{value:0,kind:x.VIEWER+x.PREFERENCE}],["viewOnLoad",{value:0,kind:x.VIEWER+x.PREFERENCE}],["cMapPacked",{value:!0,kind:x.API}],["cMapUrl",{value:"../web/cmaps/",kind:x.API}],["disableAutoFetch",{value:!1,kind:x.API+x.PREFERENCE}],["disableFontFace",{value:!1,kind:x.API+x.PREFERENCE}],["disableRange",{value:!1,kind:x.API+x.PREFERENCE}],["disableStream",{value:!1,kind:x.API+x.PREFERENCE}],["docBaseUrl",{value:"",kind:x.API}],["enableHWA",{value:!0,kind:x.API+x.PREFERENCE}],["enableWebGPU",{value:!0,kind:x.API+x.PREFERENCE}],["enableXfa",{value:!0,kind:x.API+x.PREFERENCE}],["fontExtraProperties",{value:!1,kind:x.API}],["iccUrl",{value:"../web/iccs/",kind:x.API}],["isOffscreenCanvasSupported",{value:!0,kind:x.API}],["maxImageSize",{value:-1,kind:x.API}],["pdfBug",{value:!1,kind:x.API}],["standardFontDataUrl",{value:"../web/standard_fonts/",kind:x.API}],["useSystemFonts",{value:void 0,kind:x.API,type:Ts.BOOLEAN+Ts.UNDEFINED}],["verbosity",{value:1,kind:x.API}],["wasmUrl",{value:"../web/wasm/",kind:x.API}],["workerPort",{value:null,kind:x.WORKER}],["workerSrc",{value:"../build/pdf.worker.mjs",kind:x.WORKER}]]);class ts{static eventBus;static#t=new Map;static{for(const[t,e]of Ji)this.#t.set(t,e.value);for(const[t,e]of Ps)this.#t.set(t,e);this._hasInvokedSet=!1,this._checkDisablePreferences=()=>this.get("disablePreferences")?!0:(this._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.'),!1)}static get(t){return this.#t.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const[s,n]of Ji)t&&!(t&n.kind)||(i[s]=e?n.value:this.#t.get(s));return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){this._hasInvokedSet||=!0;let i;for(const s in t){const n=Ji.get(s),r=t[s];if(!n||!(typeof r==typeof n.value||Ts[(typeof r).toUpperCase()]&n.type))continue;const{kind:a}=n;e&&!(a&x.BROWSER||a&x.PREFERENCE)||(this.eventBus&&a&x.EVENT_DISPATCH&&(i??=new Map).set(s,r),this.#t.set(s,r))}i?.forEach((s,n)=>{this.eventBus.dispatch(n.toLowerCase(),{source:this,value:s})})}}function ar({width:h,height:t,left:e,top:i},s){if(h===0||t===0)return null;const n=s.textLayer.div.getBoundingClientRect(),r=s.getPagePoint(e-n.left,i-n.top),a=s.getPagePoint(e-n.left+h,i-n.top+t);return Ks.normalizeRect([r[0],r[1],a[0],a[1]])}function Sc(h,t){const e=h.getClientRects();if(e.length===1)return{rect:ar(e[0],t)};const i=[1/0,1/0,-1/0,-1/0],s=[];let n=0;for(const r of e){const a=ar(r,t);a!==null&&(s[n]=s[n+4]=a[0],s[n+1]=s[n+3]=a[3],s[n+2]=s[n+6]=a[2],s[n+5]=s[n+7]=a[1],Ks.rectBoundingBox(...a,i),n+=8)}return{quadPoints:s,rect:i}}function or(h,t){let e=h;do{if(e.nodeType===Node.TEXT_NODE){const i=e.textContent.length;if(t<=i)return[e,t];t-=i}else if(e.firstChild){e=e.firstChild;continue}for(;!e.nextSibling&&e!==h;)e=e.parentNode;e!==h&&(e=e.nextSibling)}while(e!==h);throw new Error("Offset is bigger than container's contents length.")}function xc({url:h,index:t,length:e},i,s){const n=i._textHighlighter,[{begin:r,end:a}]=n._convertMatches([t],[e]),o=new Range;return o.setStart(...or(n.textDivs[r.divIdx],r.offset)),o.setEnd(...or(n.textDivs[a.divIdx],a.offset)),{id:`inferred_link_${s}`,unsafeUrl:h,url:h,annotationType:qr.LINK,rotation:0,...Sc(o,i),borderStyle:null}}class _c{static#t=0;static#e;static#i;static findLinks(t){this.#e??=new RegExp("\\b(?:https?:\\/\\/|mailto:|www\\.)(?:[\\S--[\\p{P}<>]]|\\/|[\\S--[\\[\\]]]+[\\S--[\\p{P}<>]])+|(?=\\p{L})[\\S--[@\\p{Ps}\\p{Pe}<>]]{1,64}@([\\S--[[\\p{P}--\\-]<>]]{1,63}(?:\\.[\\S--[[\\p{P}--\\-]<>]]{1,63})+)","gv");const[e,i]=di(t,{ignoreDashEOL:!0}),s=e.matchAll(this.#e),n=[];for(const r of s){const[a,o]=r;let l;if(a.startsWith("www.")||a.startsWith("http://")||a.startsWith("https://"))l=a;else if(o){const d=URL.parse(`http://${o}`)?.hostname;if(!d||(this.#i??=/\.\d+$/,this.#i.test(d)))continue}l??=a.startsWith("mailto:")?a:`mailto:${a}`;const c=Kr(l,null,{addDefaultProtocol:!0});if(c){const[d,u]=ta(i,r.index,a.length);n.push({url:c.href,index:d,length:u})}}return n}static processLinks(t){return this.findLinks(t._textHighlighter.textContentItemsStr.join(` 597`)).map(e=>xc(e,t,this.#t++))}}const G={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3};class Cc{renderingId="";renderTask=null;resume=null;get renderingState(){throw new Error("Abstract getter `renderingState` accessed")}set renderingState(t){throw new Error("Abstract setter `renderingState` accessed")}async draw(){throw new Error("Not implemented: draw")}}class aa extends Cc{#t=null;#e=null;#i=G.INITIAL;#s=null;#n=0;#r=null;canvas=null;div=null;enableOptimizedPartialRendering=!1;enableSelectionRendering=!0;imagesRightClickMinSize=-1;eventBus=null;id=null;imageCoordinates=null;pageColors=null;recordedBBoxes=null;renderingQueue=null;constructor(t){super(),this.eventBus=t.eventBus,this.id=t.id,this.pageColors=t.pageColors||null,this.renderingQueue=t.renderingQueue,this.enableOptimizedPartialRendering=t.enableOptimizedPartialRendering??!1,this.enableSelectionRendering=t.enableSelectionRendering!==!1&&qs.isBackdropFilterSupported,this.imagesRightClickMinSize=t.imagesRightClickMinSize??-1,this.minDurationToUpdateCanvas=t.minDurationToUpdateCanvas??500}get renderingState(){return this.#i}set renderingState(t){if(t!==this.#i)switch(this.#i=t,this.#t&&(clearTimeout(this.#t),this.#t=null),t){case G.PAUSED:this.div.classList.remove("loading"),this.#n=0,this.#s?.(!1);break;case G.RUNNING:this.div.classList.add("loadingIcon"),this.#t=setTimeout(()=>{this.div.classList.add("loading"),this.#t=null},0),this.#n=Date.now();break;case G.INITIAL:case G.FINISHED:this.div.classList.remove("loadingIcon","loading"),this.#n=0;break}}_createCanvas(t,e=!1){const{pageColors:i}=this,s=!!(i?.background&&i?.foreground),n=this.canvas,r=!n&&!s&&!e;let a=this.canvas=document.createElement("canvas");return this.#s=o=>{if(r){let l=this.#r;if(!o&&this.minDurationToUpdateCanvas>0){if(Date.now()-this.#n<this.minDurationToUpdateCanvas)return;l||(l=this.#r=a,a=this.canvas=a.cloneNode(!1),t(a))}if(l){a.getContext("2d",{alpha:!1}).drawImage(l,0,0),o?this.#o():this.#n=Date.now();return}t(a),this.#s=null;return}o&&(n?(n.replaceWith(a),n.width=n.height=0):t(a))},{canvas:a,prevCanvas:n}}#a=t=>{if(this.#s?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this)){this.renderingState=G.PAUSED,this.resume=()=>{this.renderingState=G.RUNNING,t()};return}t()};_resetCanvas(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#o())}#o(){this.#r&&(this.#r.width=this.#r.height=0,this.#r=null)}async _drawCanvas(t,e,i){const s=this.renderTask=this.pdfPage.render(t);s.onContinue=this.#a,s.onError=r=>{r instanceof As&&(e(),this.#e=null)};let n=null;try{await s.promise,this.#s?.(!0)}catch(r){if(r instanceof As)return;n=r,this.#s?.(!0)}finally{this.#e=n,s===this.renderTask&&(this.renderTask=null,this.enableOptimizedPartialRendering&&(this.recordedBBoxes??=s.recordedBBoxes),this.imagesRightClickMinSize!==-1&&(this.imageCoordinates??=this.pdfPage.imageCoordinates))}if(this.renderingState=G.FINISHED,i(s),n)throw n}cancelRendering({cancelExtraDelay:t=0}={}){this.renderTask&&(this.renderTask.cancel(t),this.renderTask=null),this.resume=null}dispatchPageRender(){this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id})}dispatchPageRendered(t,e){this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:t,isDetailView:e,timestamp:performance.now(),error:this.#e})}}class Pc{#t=null;constructor(t){this.pageIndex=t.pageIndex,this.textLayer=t.textLayer||null,this.filterFactory=t.filterFactory||null,this.pageColors=t.pageColors||null}async render({intent:t="display"}){t!=="display"||this.#t||this._cancelled||(this.#t=new Ul({pageIndex:this.pageIndex,textLayer:this.textLayer,filterFactory:this.filterFactory,pageColors:this.pageColors}))}cancel(){this._cancelled=!0,this.#t?.destroy(),this.#t=null}setParent(t){this.#t?.setParent(t)}getDrawLayer(){return this.#t}}class Tc extends aa{#t=null;renderingCancelled=!1;constructor({pageView:t}){super(t),this.pageView=t,this.renderingId="detail"+this.id,this.div=t.div}setPdfPage(t){this.pageView.setPdfPage(t)}get pdfPage(){return this.pageView.pdfPage}get renderingState(){return super.renderingState}set renderingState(t){this.renderingCancelled=!1,super.renderingState=t}reset({keepCanvas:t=!1}={}){const e=this.renderingCancelled||this.renderingState===G.RUNNING||this.renderingState===G.PAUSED;this.cancelRendering(),this.renderingState=G.INITIAL,this.renderingCancelled=e,t||this._resetCanvas()}#e(t){if(!this.#t)return!0;const e=this.#t.minX,i=this.#t.minY,s=this.#t.width+e,n=this.#t.height+i;if(t.minX<e||t.minY<i||t.maxX>s||t.maxY>n)return!0;const{width:r,height:a,scale:o}=this.pageView.viewport;if(this.#t.scale!==o)return!0;const l=t.minX-e,c=s-t.maxX,d=t.minY-i,u=n-t.maxY,f=.5,p=(1+f)/f;return e>0&&c/l>p||s<r&&l/c>p||i>0&&u/d>p||n<a&&d/u>p}update({visibleArea:t=null,underlyingViewUpdated:e=!1}={}){if(e){this.cancelRendering(),this.renderingState=G.INITIAL;return}if(!this.#e(t))return;const{viewport:i,maxCanvasPixels:s,capCanvasAreaFactor:n}=this.pageView,r=t.maxX-t.minX,a=t.maxY-t.minY,o=r*a*ci.pixelRatio**2,c=(Math.sqrt(ci.capPixels(s,n)/o)-1)/2;let d=Math.min(1,c);d<0&&(d=0);const u=r*d,f=a*d,p=Math.max(0,t.minX-u),g=Math.min(i.width,t.maxX+u),m=Math.max(0,t.minY-f),b=Math.min(i.height,t.maxY+f),y=g-p,w=b-m;this.#t={minX:p,minY:m,width:y,height:w,scale:i.scale},this.reset({keepCanvas:!0})}_getRenderingContext(t,e){const i=this.pageView._getRenderingContext(t,e,!1),s=this.pdfPage.recordedBBoxes;if(!s||!this.enableOptimizedPartialRendering)return i;const{viewport:{width:n,height:r}}=this.pageView,{width:a,height:o,minX:l,minY:c}=this.#t,d=l/n,u=c/r,f=(l+a)/n,p=(c+o)/r;return{...i,operationsFilter(g){return s.isEmpty(g)?!1:s.minX(g)<=f&&s.maxX(g)>=d&&s.minY(g)<=p&&s.maxY(g)>=u}}}async draw(){if(this.pageView.detailView!==this)return;const t=this.pageView.renderingState===G.FINISHED||this.renderingState===G.FINISHED;this.renderingState!==G.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:e,pdfPage:i,viewport:s}=this.pageView;if(!i)throw this.renderingState=G.FINISHED,new Error("pdfPage is not loaded");this.renderingState=G.RUNNING;const n=this.pageView._ensureCanvasWrapper(),{canvas:r,prevCanvas:a}=this._createCanvas(g=>{n.firstElementChild?.tagName==="CANVAS"?n.firstElementChild.after(g):n.prepend(g)},t);r.ariaHidden=!0,this.enableOptimizedPartialRendering&&(r.className="detailVie
597w");const{width:o,height:l}=s,c=this.#t,{pixelRatio:d}=ci,u=[d,0,0,d,-c.minX*d,-c.minY*d];r.width=c.width*d,r.height=c.height*d;const{style:f}=r;f.width=`${c.width*100/o}%`,f.height=`${c.height*100/l}%`,f.top=`${c.minY*100/l}%`,f.left=`${c.minX*100/o}%`;const p=this._drawCanvas(this._getRenderingContext(r,u),()=>{this.canvas?.remove(),this.canvas=a},()=>{this.pageView._refreshAnnotationLayer(),this.dispatchPageRendered(!1,!0)});return e.setAttribute("data-loaded",!0),this.dispatchPageRender(),p}}const lr={Document:null,DocumentFragment:null,Part:"group",Art:"article",Sect:"group",Div:"group",BlockQuote:"blockquote",Aside:"note",NonStruct:"none",P:"paragraph",H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:"emphasis",Strong:"strong",Note:"note",Code:"code",Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"rowgroup",TBody:"rowgroup",TFoot:"rowgroup",Caption:"caption",Figure:"figure",Formula:null,Artifact:null},kc=new Set(["caption","code","emphasis","generic","none","paragraph","strong"]),oa=new Set(["math","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics"]),vi="http://www.w3.org/1998/Math/MathML";class hr{static get sanitizer(){return Ve(this,"sanitizer",qs.isSanitizerSupported?new Sanitizer({elements:Array.from(oa.keys(),t=>({name:t,namespace:vi})),replaceWithChildrenElements:[{name:"maction",namespace:vi}],attributes:["dir","displaystyle","mathbackground","mathcolor","mathsize","scriptlevel","encoding","display","linethickness","intent","arg","form","fence","separator","lspace","rspace","stretchy","symmetric","maxsize","minsize","largeop","movablelimits","width","height","depth","voffset","accent","accentunder","columnspan","rowspan"],comments:!1}):null)}}const Mc=/^H(\d+)$/;class Zs{#t;#e=null;#i;#s=new Set;#n=new Map;#r=new Map;#a=0;#o=`pdfjs_internal_struct_${Hl()}_`;#l=new Map;#h=new Map;#u;#d=null;#f=null;#g=null;constructor(t,e){this.#t=t.getStructTree(),this.#u=e}async render(){if(this.#i)return this.#i;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#i=t;try{const s=await this.#t;this.#m(s),this.#c(s),this.#e=this.#E(s)}catch(s){i(s)}return this.#t=null,this.#e?.classList.add("structTree"),e(this.#e),t}async getAriaAttributes(t,{enableLinkOwnership:e=!1}={}){try{await this.render();const i=this.#r.get(t);if(i&&e){const{element:s,ids:n}=i;s.removeAttribute("role"),n.length>0&&this.#n.getOrInsertComputed(t,Dn).set("aria-owns",n.join(" ")),this.#r.delete(t)}return this.#n.get(t)}catch{}return null}async getAnnotationIds(){try{return await this.render(),this.#s}catch{}return null}hide(){this.#e&&!this.#e.hidden&&(this.#e.hidden=!0)}show(){this.#e?.hidden&&(this.#e.hidden=!1)}#m(t){if(t){t.structId&&this.#h.getOrInsert(t.structId,t);for(const e of t.children||[])this.#m(e)}}#c(t){if(t){if(t.type==="annotation"){this.#s.add(t.id);return}for(const e of t.children||[])this.#c(e)}}#p(t){return this.#l.getOrInsertComputed(t,()=>`${this.#o}${this.#l.size}`)}#b(t){const e=[],i=new Set,s=t.toReversed();for(;s.length>0;){const n=s.pop();if(i.has(n))continue;i.add(n);const r=this.#h.get(n);if(r?.role==="TH"&&(e.push(this.#p(n)),r.headers))for(let a=r.headers.length-1;a>=0;a--)s.push(r.headers[a])}return e}#y(t,e){const{alt:i,colSpan:s,headers:n,id:r,lang:a,rowSpan:o,short:l,structId:c,summary:d}=t;if(i!==void 0){let u=!1;const f=te(i);for(const g of t.children)g.type==="annotation"&&(this.#n.getOrInsertComputed(g.id,Dn).set("aria-label",f),u=!0);const p=e.getAttribute("role")||(e.localName==="span"?"generic":null);!u&&p!=="none"&&e.setAttribute(kc.has(p)?"aria-description":"aria-label",f)}if(r!==void 0&&e.setAttribute("aria-owns",r),c!==void 0&&this.#h.get(c)===t){const u=this.#p(c);if(l!==void 0){const f=document.createElement("span");f.setAttribute("id",u),f.setAttribute("aria-hidden","true"),f.textContent=te(l),e.append(f)}else e.setAttribute("id",u)}if(a!==void 0&&e.setAttribute("lang",te(a,!0)),o!==void 0&&e.setAttribute("aria-rowspan",o),s!==void 0&&e.setAttribute("aria-colspan",s),n?.length>0){const u=this.#b(n);u.length>0&&e.setAttribute("aria-describedby",u.join(" "))}d!==void 0&&e.setAttribute("aria-description",te(d))}#w(t,e){const{alt:i,bbox:s,children:n}=t,r=n?.[0];if(!this.#u||!i||!s||r?.type!=="content")return!1;const{id:a}=r;if(!a)return!1;e.setAttribute("aria-owns",a);const o=document.createElement("span");(this.#d||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",te(i));const{pageHeight:l,pageX:c,pageY:d}=this.#u,u="calc(var(--total-scale-factor) *",{style:f}=o;return f.width=`${u}${s[2]-s[0]}
597px)`,f.height=`${u}${s[3]-s[1]}px)`,f.left=`${u}${s[0]-c}px)`,f.top=`${u}${l-s[3]+d}px)`,!0}updateTextLayer(){if(this.#d){for(const[t,e]of this.#d)document.getElementById(t)?.append(e);this.#d.clear(),this.#d=null}if(this.#f){for(const t of this.#f){const e=document.getElementById(t);e&&(e.ariaHidden=!0)}this.#f.length=0,this.#f=null}if(this.#g){for(let t=0,e=this.#g.length;t<e;t+=2){const i=this.#g[t],s=this.#g[t+1];let n="";for(const r of s){const a=document.getElementById(r);a&&(n+=a.textContent.trim()||"",a.ariaHidden="true")}n&&(i.textContent=n)}this.#g.length=0,this.#g=null}}#v(t,e){if(t){"id"in t&&e.push(t.id);for(const i of t.children||[])this.#v(i,e)}}#E(t,e=[]){if(!t)return null;let i,s=!0;if("role"in t){const{role:n}=t;if(oa.has(n)){i=document.createElementNS(vi,n);const a=[];(this.#g||=[]).push(i,a);for(const{type:o,id:l}of t.children||[])o==="content"&&l&&a.push(l)}else i=document.createElement("span");const r=n.match(Mc);if(r)i.setAttribute("role","heading"),i.setAttribute("aria-level",r[1]);else if(lr[n]){let a=lr[n];if(n==="TH")t.scope==="Row"?a="rowheader":t.scope==="Column"?a="columnheader":e.at(-1)?.role==="TR"&&e.at(-2)?.role==="TBody"&&(a="rowheader");else if(n==="Caption"){const o=e.at(-1)?.role;o!=="Table"&&o!=="Figure"&&(a=null)}a&&i.setAttribute("role",a)}if(n==="Figure"&&this.#w(t,i))return i;n==="Formula"&&(t.mathML&&hr.sanitizer&&(s=!1,i.setHTML(t.mathML,{sanitizer:hr.sanitizer}),this.#v(t,this.#f||=[]),delete t.alt),!t.mathML&&t.children.length===1&&t.children[0].role!=="math"&&(i=document.createElementNS(vi,"math"),delete t.alt))}if(i||=document.createElement("span"),this.#y(t,i),t.children){if(t.children.length===1&&!("role"in t.children[0])&&"id"in t.children[0]&&i.getAttribute("role")!=="none")this.#y(t.children[0],i);else if(s){e.push(t);for(const n of t.children)i.append(this.#E(n,e));e.pop()}}if(t.role==="Link"){const n=t.children?.filter(r=>r.type==="annotation");if(n?.length===1){const r=n[0],a=[];for(const o of i.children)o.getAttribute("aria-owns")!==r.id&&(o.id||=`${this.#o}link_${this.#a++}`,a.push(o.id));this.#r.set(r.id,{element:i,ids:a})}}return i}}class Oe{#t=!1;#e=null;#i=new Map;#s=new Map;setTextMapping(t){this.#e=t}static#n(t,e){const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(i.width===0&&i.height===0)return 1;if(s.width===0&&s.height===0)return-1;const n=i.y,r=i.y+i.height,a=i.y+i.height/2,o=s.y,l=s.y+s.height,c=s.y+s.height/2;if(a<=o&&c>=r)return-1;if(c<=n&&a>=l)return 1;const d=i.x+i.width/2,u=s.x+s.width/2;return d-u}enable(){if(this.#t)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#e)throw new Error("Text divs and strings have not been set.");if(this.#t=!0,this.#e=this.#e.slice(),this.#e.sort(Oe.#n),this.#i.size>0){const t=this.#e;for(const[e,i]of this.#i){if(!document.getElementById(e)){this.#i.delete(e);continue}this.#r(e,t[i])}}for(const[t,e]of this.#s)this.addPointerInTextLayer(t,e);this.#s.clear()}disable(){this.#t&&(this.#s.clear(),this.#e=null,this.#t=!1)}removePointerInTextLayer(t){if(!this.#t){this.#s.delete(t);return}const e=this.#e;if(!e?.length)return;const{id:i}=t,s=this.#i.get(i);if(s===void 0)return;const n=e[s];this.#i.delete(i);let r=n.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter(a=>a!==i).join(" "),r?n.setAttribute("aria-owns",r):(n.removeAttribute("aria-owns"),n.setAttribute("role","presentation")))}#r(t,e){const i=e.getAttribute("aria-owns");i?.includes(t)||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")}addPointerInTextLayer(t,e){const{id:i}=t;if(!i)return null;if(!this.#t)return this.#s.set(t,e),null;e&&this.removePointerInTextLayer(t);const s=this.#e;if(!s?.length)return null;const n=He(s,l=>Oe.#n(t,l)<0),r=Math.max(0,n-1),a=s[r];this.#r(i,a),this.#i.set(i,r);const o=a.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(t,e,i,s){const n=this.addPointerInTextLayer(i,s);if(!t.hasChildNodes())return t.append(e),n;const r=Array.from(t.childNodes).filter(o=>o!==e);if(r.length===0)return n;const a=He(r,o=>Oe.#n(e,o)<0);return a===0?r[0].before(e):r[a-1].after(e),n}}class Ic{#t=null;constructor({findController:t,eventBus:e,pageIndex:i}){this.findController=t,this.matches=[],this.eventBus=e,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(t,e){this.textDivs=t,this.textContentItemsStr=e}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(this.enabled)throw new Error("TextHighlighter is already enabled.");this.enabled=!0,this.#t||(this.#t=new AbortController,this.eventBus.on("updatetextlayermatches",t=>{(t.pageIndex===this.pageIdx||t.pageIndex===-1)&&this._updateMatches()},{signal:this.#t.signal,...ft})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#t?.abort(),this.#t=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let s=0,n=0;const r=i.length-1,a=[];for(let o=0,l=t.length;o<l;o++){let c=t[o];for(;s!==r&&c>=n+i[s].length;)n+=i[s].length,s++;s===i.length&&console.error("Could not find a matching mapping");const d={begin:{divIdx:s,offset:c-n}};for(c+=e[o];s!==r&&c>n+i[s].length;)n+=i[s].length,s++;d.end={divIdx:s,offset:c-n},a.push(d)}return a}_renderMatches(t){if(t.length===0)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:s,textDivs:n}=this,r=i===e.selected.pageIdx,a=e.selected.matchIdx,o=e.state.highlightAll;let l=null;const c={offset:void 0};function d(b,y){const w=b.divIdx;return n[w].textContent="",u(w,0,b.offset,y)}function u(b,y,w,A){let v=n[b];if(v.nodeType===Node.TEXT_NODE){const C=document.createElement("span");v.before(C),C.append(v),n[b]=C,v=C}const E=s[b].substring(y,w),_=document.createTextNode(E);if(A){const C=document.createElement("span");return C.className=`${A} appended`,C.append(_),v.append(C),A.includes("selected")?C:null}return v.append(_),0}
vendor: 58,161 bytes, lines 597-599
597let f=a,p=f+1;if(o)f=0,p=t.length;else if(!r)return;let g=-1,m=-1;for(let b=f;b<p;b++){const y=t[b],w=y.begin;if(w.divIdx===g&&w.offset===m)continue;g=w.divIdx,m=w.offset;const A=y.end,v=r&&b===a,E=v?" selected":"";let _=null;if(!l||w.divIdx!==l.divIdx?(l!==null&&u(l.divIdx,l.offset,c.offset),d(w)):u(l.divIdx,l.offset,w.offset),w.divIdx===A.divIdx)_=u(w.divIdx,w.offset,A.offset,"highlight"+E);else{_=u(w.divIdx,w.offset,c.offset,"highlight begin"+E);for(let C=w.divIdx+1,S=A.divIdx;C<S;C++)n[C].className="highlight middle"+E;d(A,"highlight end"+E)}l=A,v&&e.scrollMatchIntoView({element:_,pageIndex:i,matchIndex:a})}l&&u(l.divIdx,l.offset,c.offset)}_updateMatches(t=!1){if(!this.enabled&&!t)return;const{findController:e,matches:i,pageIdx:s}=this,{textContentItemsStr:n,textDivs:r}=this;let a=-1;for(const c of i){const d=Math.max(a,c.begin.divIdx);for(let u=d,f=c.end.divIdx;u<=f;u++){const p=r[u];p.textContent=n[u],p.className=""}a=c.end.divIdx+1}if(!e?.highlightMatches||t)return;const o=e.pageMatches[s]||null,l=e.pageMatchesLength[s]||null;this.matches=this._convertMatches(o,l),this._renderMatches(this.matches)}}class Ae{#t=null;#e=!1;#i=null;#s=!1;#n=null;static#r=new Map;static#a=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:s=!1,onAppend:n=null,abortSignal:r=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#e=s===!0,this.#i=n,this.#t=r,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render({viewport:t,images:e,textContentParams:i=null}){if(this.#s&&this.#n){this.#n.update({viewport:t,onBefore:this.hide.bind(this)}),this.show();return}this.cancel(),this.#n=new Ql({textContentSource:this.pdfPage.streamTextContent(i||{includeMarkedContent:!0,disableNormalization:!0}),images:e,container:this.div,viewport:t});const{textDivs:s,textContentItemsStr:n}=this.#n;this.highlighter?.setTextMapping(s,n),this.accessibilityManager?.setTextMapping(s),await this.#n.render(),this.#s=!0;const r=document.createElement("div");r.className="endOfContent",this.div.append(r),this.#o(r),this.#i?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#s&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#s&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#n?.cancel(),this.#n=null,this.#s=!1,this.div.replaceChildren(),this.highlighter?.disable(),this.accessibilityManager?.disable(),Ae.#l(this.div)}#o(t){const{div:e}=this,i=this.#t,s=i?{signal:i}:null;e.addEventListener("mousedown",()=>{e.classList.add("selecting")},s),e.addEventListener("copy",n=>{if(!this.#e){const r=document.getSelection();n.clipboardData.setData("text/plain",te(ql(r.toString())))}Es(n)},s),Ae.#r.set(e,t),Ae.#h(i)}static#l(t){this.#r.delete(t),this.#r.size===0&&(this.#a?.abort(),this.#a=null)}static#h(t){if(this.#a)return;this.#a=new AbortController;const e=t?AbortSignal.any([this.#a.signal,t]):this.#a.signal,i=(a,o)=>{o.append(a),a.style.width="",a.style.height="",o.classList.remove("selecting")};let s=!1;document.addEventListener("pointerdown",()=>{s=!0},{signal:e}),document.addEventListener("pointerup",()=>{s=!1,this.#r.forEach(i)},{signal:e}),window.addEventListener("blur",()=>{s=!1,this.#r.forEach(i)},{signal:e}),document.addEventListener("keyup",()=>{s||this.#r.forEach(i)},{signal:e});var n,r;document.addEventListener("selectionchange",()=>{const a=document.getSelection();if(a.rangeCount===0){this.#r.forEach(i);return}const o=new Set;for(let p=0;p<a.rangeCount;p++){const g=a.getRangeAt(p);for(const m of this.#r.keys())!o.has(m)&&g.intersectsNode(m)&&o.add(m)}for(const[p,g]of this.#r)o.has(p)?p.classList.add("selecting"):i(g,p);if(n===void 0&&(n=getComputedStyle(this.#r.values().next().value).getPropertyValue("-moz-user-select")==="none",!n)){const p=navigator.userAgentData?navigator.userAgentData.brands.find(({brand:g})=>g==="Chromium")?.version:/\bChrome\/(\d+)\b/.exec(navigator.userAgent)?.[1];n=!!p&&parseInt(p,10)>=148}if(n)return;const l=a.getRangeAt(0),c=r&&(l.compareBoundaryPoints(Range.END_TO_END,r)===0||l.compareBoundaryPoints(Range.START_TO_END,r)===0);let d=c?l.startContainer:l.endContainer;if(d.nodeType===Node.TEXT_NODE&&(d=d.parentNode),d.classList?.contains("highlight")&&(d=d.parentNode),!c&&l.endOffset===0)do{for(;!d.previousSibling;)d=d.parentNode;d=d.previousSibling}while(!d.childNodes.length);const u=d.parentElement?.closest(".textLayer"),f=this.#r.get(u);f&&(f.style.width=u.style.width,f.style.height=u.style.height,f.style.userSelect="text",d.parentElement.insertBefore(f,c?d:d.nextSibling)),r=l.cloneRange()},{signal:e})}}class la{#t=!1;div=null;constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:s=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=s}async render({viewport:t,intent:e="display"}){let i;if(e==="print")i=this.xfaHtml;else if(i=await this.pdfPage.getXfa(),this.#t||!i)return{textDivs:[]};const s=!!this.div,n={viewport:t.clone({dontFlip:!0}),div:this.div??=document.createElement("div"),xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return s?Nn.update(n):Nn.render(n)}cancel(){this.#t=!0}hide(){this.div&&(this.div.hidden=!0)}}const Lc={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new Qs}},Dc=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class Oi extends aa{#t=null;#e=Nt.ENABLE_FORMS;#i=null;#s=null;#n=!0;#r=!1;#a=!1;#o=null;#l=!1;#h=null;#u=null;#d=1;#f=1;#g=Rt.ENABLE;#m=1;#c={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#p=[null,null,null,null];constructor(t){super(t);const{container:e,defaultViewport:i}=t;this.renderingId="page"+this.id,this.#o=t.layerProperties||Lc,this.#t=t.abortSignal||null,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=t.scale||1,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=t.optionalContentConfigPromise||null,this.#g=t.textLayerMode??Rt.ENABLE,this.#e=t.annotationMode??Nt.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.enableDetailCanvas=t.enableDetailCanvas??!0,this.maxCanvasPixels=t.maxCanvasPixels??ts.get("maxCanvasPixels"),this.maxCanvasDim=t.maxCanvasDim||ts.get("maxCanvasDim"),this.capCanvasAreaFactor=t.capCanvasAreaFactor??ts.get("capCanvasAreaFactor"),this.#n=t.enableAutoLinking!==!1,this.#s=t.commentManager||null,this.l10n=t.l10n,this.l10n||=new jt,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null,this.detailView=null;const s=document.createElement("div");if(s.className="page",s.setAttribute("data-page-number",this.id),s.setAttribute("role","region"),s.setAttribute("data-l10n-id","pdfjs-page-landmark"),s.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=s,this.#y(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*Ft.PDF_TO_CSS_UNITS),this.pageColors?.background&&e?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:n}=t;n&&n.then(r=>{n===this._optionalContentConfigPromise&&(this.#c.initialOptionalContent=r.hasInitialVisibility)}),t.l10n||this.l10n.translate(this.div)}}clone(t){const e=new Oi({container:null,eventBus:this.eventBus,pagesColors:this.pageColors,renderingQueue:this.renderingQueue,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,minDurationToUpdateCanvas:this.minDurationToUpdateCanvas,defaultViewport:this.viewport,id:t,layerProperties:this.#o,abortSignal:this.#t,scale:this.scale,optionalContentConfigPromise:this._optionalContentConfigPromise,textLayerMode:this.#g,annotationMode:this.#e,imageResourcesPath:this.imageResourcesPath,enableDetailCanvas:this.enableDetailCanvas,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableAutoLinking:this.#n,commentManager:this.#s,l10n:this.l10n});return e.setPdfPage(this.pdfPage.clone(t-1)),e}#b(t,e){const i=Dc.get(e),s=this.#p[i];if(this.#p[i]=t,s){s.replaceWith(t);return}for(let n=i-1;n>=0;n--){const r=this.#p[n];if(r){r.after(t);return}}this.div.prepend(t)}#y(){const{div:t,viewport:e}=this;if(e.userUnit!==this.#m&&(e.userUnit!==1?t.style.setProperty("--user-unit",e.userUnit):t.style.removeProperty("--user-unit"),this.#m=e.userUnit),this.pdfPage){if(this.#u===e.rotation)return;this.#u=e.rotation}Qr(t,e,!0,!1)}updatePageNumber(t){const e=this.id;if(e!==t){this.id=t,this.renderingId=`page${t}`,this.pdfPage&&(this.pdfPage.pageNumber=t),this.setPageLabel(this.pageLabel);const{div:i}=this;i.setAttribute("data-page-number",t),i.setAttribute("data-l10n-args",JSON.stringify({page:t})),this._textHighlighter.pageIdx=t-1}this.#o.annotationEditorUIManager?.updatePageIndex(e-1,t-1)}setPdfPage(t){this._isStandalone&&(this.pageColors?.foreground==="CanvasText"||this.pageColors?.background==="Canvas")&&(this._container?.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:this.scale*Ft.PDF_TO_CSS_UNITS,rotation:e}),this.#y(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}deleteMe(t){if(t){this.div.remove();return}this.destroy(),this.#o.annotationEditorUIManager?.deletePage(this.id)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return Ve(this,"_textHighlighter",new Ic({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#o.findController}))}#w(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#v(t=null){const{annotationLayer:e,textLayer:i}=this;let s=null;try{await this.annotationLayer.render({viewport:this.viewport,intent:"display",structTreeLayer:this.structTreeLayer,optionalContentConfigPromise:this._optionalContentConfigPromise})}catch(n){console.error("#renderAnnotationLayer:",n),s=n}finally{this.#w("annotationlayerrendered",s)}this.#n&&t&&this.#P(t,e,i)}_refreshAnnotationLayer(){this._annotationCanvasMap?.size&&this.annotationLayer?.refreshCanvases()}async#E(){let t=null;try{await this.annotationEditorLayer.render({viewport:this.viewport,intent:"display"})}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#w("annotationeditorlayerrendered",t)}}async#A(){try{await this.drawLayer.render({intent:"display"})}catch(t){console.error("#renderDrawLayer:",t)}}async#x(){let t=null;try{const e=await this.xfaLayer.render({viewport:this.viewport,intent:"display"});e?.textDivs&&this._textHighlighter&&this.#k(e.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#b(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#w("xfalayerrendered",t)}}async#S(){let t=null;try{await this.textLayer.render({viewport:this.viewport,images:this.imageCoordinates?new Zl(this.imagesRightClickMinSize,this.imageCoordinates,this.viewport,()=>this.canvas):null})}catch(e){if(e instanceof Fl)return;console.error("#renderTextLayer:",e),t=e}this.#w("textlayerrendered",t),this.#T()}async#T(){const t=await this.structTreeLayer?.render();t&&(this.l10n.pause(),this.structTreeLayer?.updateTextLayer(),this.canvas&&t.parentNode!==this.canvas&&this.canvas.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async#k(t){const e=await this.pdfPage.getTextContent(),i=[];for(const s of e.items)i.push(s.str);this._textHighlighter.setTextMapping(t,i),this._textHighlighter.enable()}async#P(t,e,i){let s=null;try{if(await t,e!==this.annotationLayer||i!==this.textLayer)return;await e.injectLinkAnnotations(_c.processLinks(this))}catch(n){console.error("#injectLinkAnnotations:",n),s=n}this.#w("linkannotationsadded",s)}_resetCanvas(){super._resetCanvas(),this.#h=null}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,keepCanvasWrapper:n=!1,preserveDetailViewState:r=!1}={}){const a=this.pdfPage?._pdfBug??!1;this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:s}),this.renderingState=G.INITIAL;const o=this.div,l=o.childNodes,c=t&&this.annotationLayer?.div||null,d=e&&this.annotationEditorLayer?.div||null,u=i&&this.xfaLayer?.div||null,f=s&&this.textLayer?.div||null,p=n&&this.#i||null;for(let g=l.length-1;g>=0;g--){const m=l[g];switch(m){case c:case d:case u:case f:case p:continue}if(a&&m.classList.contains("pdfBugGroupsLayer"))continue;m.remove();const b=this.#p.indexOf(m);b>=0&&(this.#p[b]=null)}o.removeAttribute("data-loaded"),c&&this.annotationLayer.hide(),d&&this.annotationEditorLayer.hide(),u&&this.xfaLayer.hide(),f&&this.textLayer.hide(),this.structTreeLayer?.hide(),!n&&this.#i&&(this.#i=null,this._resetCanvas()),r||(this.detailView?.reset({keepCanvas:n}),n||(this.detailView=null))}toggleEditingMode(t){this.#a=t,this.hasEditableAnnotations()&&this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}updateVisibleArea(t){this.enableDetailCanvas&&(this.#l&&this.maxCanvasPixels>0&&t?(this.detailView??=new Tc({pageView:this,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,imagesRightClickMinSize:-1}),this.detailView.update({visibleArea:t})):this.detailView&&(this.detailView.reset(),this.detailView=null))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:s=-1}){this.scale=t||this.scale,typeof e=="number"&&(this.rotation=e),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then(r=>{i===this._optionalContentConfigPromise&&(this.#c.initialOptionalContent=r.hasInitialVisibility)})),this.#c.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*Ft.PDF_TO_CSS_UNITS,rotation:n}),this.#y(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.#I(),this.canvas){const r=this.#r&&this.#l,a=s>=0&&s<1e3;if(a||r){a&&!r&&this.renderingState!==G.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=G.FINISHED,this.#c.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!a,hideTextLayer:a}),a||(this.detailView?.update({underlyingViewUpdated:!0}),this.dispatchPageRendered(!0,!1));return}}this.cssTransform({}),this.annotationEditorLayer?.update(this.viewport),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0,preserveDetailViewState:!0}),this.detailView?.update({underlyingViewUpdated:!0})}#I(){const{width:t,height:e}=this.viewport,i=this.outputScale=new ci;if(this.maxCanvasPixels===0){const s=1/this.scale;i.sx*=s,i.sy*=s,this.#l=!0}else if(this.#l=i.limitCanvas(t,e,this.maxCanvasPixels,this.maxCanvasDim,this.capCanvasAreaFactor),this.#l&&this.enableDetailCanvas){const s=this.enableOptimizedPartialRendering?4:2;i.sx/=s,i.sy/=s}}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,cancelExtraDelay:n=0}={}){super.cancelRendering({cancelExtraDelay:n}),this.textLayer&&(!s||!this.textLayer.div)&&(this.textLayer.cancel(),this.textLayer=null),this.annotationLayer&&(!t||!this.annotationLayer.div)&&(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),this.annotationEditorLayer&&(!e||!this.annotationEditorLayer.div||!this.textLayer)&&(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),this.drawLayer&&!this.textLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.xfaLayer&&(!i||!this.xfaLayer.div)&&(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:s=!1,hideTextLayer:n=!1}){const{canvas:r}=this;if(!r)return;const a=this.#h;if(this.viewport!==a){const o=(360+this.viewport.rotation-a.rotation)%360;if(o===90||o===270){const{width:l,height:c}=this.viewport,d=c/l,u=l/c;r.style.transform=`rotate(${o}deg) scale(${d},${u})`}else r.style.transform=o===0?"":`rotate(${o}deg)`}t&&this.annotationLayer&&this.#v(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#A(),this.#E()),i&&this.xfaLayer&&this.#x(),this.textLayer&&(n?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#S())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}_ensureCanvasWrapper(){let t=this.#i;return t||(t=this.#i=document.createElement("div"),t.classList.add("canvasWrapper"),this.#b(t,"canvasWrapper")),t}_getRenderingContext(t,e,i,s){return{canvas:t,transform:e,viewport:this.viewport,annotationMode:this.#e,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:this.pageColors,isEditing:this.#a,recordOperations:i,recordImages:s}}async draw(){this.renderingState!==G.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pdfPage:i,viewport:s}=this;if(!i)throw this.renderingState=G.FINISHED,new Error("pdfPage is not loaded");this.renderingState=G.RUNNING;const n=this._ensureCanvasWrapper();if(!this.textLayer&&this.#g!==Rt.DISABLE&&!i.isPureXfa&&(this._accessibilityManager||=new Oe,this.textLayer=new Ae({pdfPage:i,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#g===Rt.ENABLE_PERMISSIONS,onAppend:v=>{this.l10n.pause(),this.#b(v,"textLayer"),this.l10n.resume()},abortSignal:this.#t}),this.enableSelectionRendering&&this.textLayer.div.classList.add("selectionRendering")),!this.annotationLayer&&this.#e!==Nt.DISABLE){const{annotationStorage:v,annotationEditorUIManager:E,downloadManager:_,enableComment:C,enableScripting:S,fieldObjectsPromise:P,hasJSActionsPromise:T,linkService:M}=this.#o;this._annotationCanvasMap||=new Map,this.annotationLayer=new ia({pdfPage:i,annotationStorage:v,imageResourcesPath:this.imageResourcesPath,renderForms:this.#e===Nt.ENABLE_FORMS,linkService:M,downloadManager:_,enableComment:C,enableScripting:S,hasJSActionsPromise:T,fieldObjectsPromise:P,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:E,commentManager:this.#s,onAppend:L=>{this.#b(L,"annotationLayer")}})}const{width:r,height:a}=s;this.#h=s;const{canvas:o,prevCanvas:l}=this._createCanvas(v=>{n.prepend(v)});o.setAttribute("role","presentation"),this.outputScale||this.#I();const{outputScale:c}=this;this.#r=this.#l;const d=$n(c.sx),u=$n(c.sy),f=o.width=ni(ri(r*c.sx),d[0]),p=o.height=ni(ri(a*c.sy),u[0]),g=ni(ri(r),d[1]),m=ni(ri(a),u[1]);c.sx=f/g,c.sy=p/m,this.#d!==d[1]&&(t.style.setProperty("--scale-round-x",`${d[1]}px`),this.#d=d[1]),this.#f!==u[1]&&(t.style.setProperty("--scale-round-y",`${u[1]}px`),this.#f=u[1]);const b=this.enableOptimizedPartialRendering&&this.#r&&!this.recordedBBoxes,y=this.imagesRightClickMinSize!==-1&&!this.imageCoordinates,w=c.scaled?[c.sx,0,0,c.sy,0,0]:null,A=this._drawCanvas(this._getRenderingContext(o,w,b,y),()=>{l?.remove(),this._resetCanvas()},v=>{this.#c.regularAnnotations=!v.separateAnnots,this.dispatchPageRendered(!1,!1)}).then(async()=>{if(this.renderingState!==G.FINISHED)return;this.structTreeLayer||=new Zs(i,s.rawDims);const v=this.textLayer?this.#S():null;this.annotationLayer&&await this.#v(v),this.drawLayer||=new Pc({pageIndex:this.id,textLayer:this.enableSelectionRendering?this.textLayer?.div:null,filterFactory:this.pdfPage?.filterFactory,pageColors:this.pageColors}),await this.#A(),this.drawLayer.setParent(n);const{annotationEditorUIManager:E}=this.#o;E&&(this.annotationLayer||this.#e===Nt.DISABLE)&&(this.annotationEditorLayer||=new Ec({uiManager:E,pageIndex:this.id-1,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:_=>{this.#b(_,"annotationEditorLayer")}}),this.#E())});if(i.isPureXfa){if(!this.xfaLayer){const{annotationStorage:v,linkService:E}=this.#o;this.xfaLayer=new la({pdfPage:i,annotationStorage:v,linkService:E})}this.#x()}return t.setAttribute("data-loaded",!0),this.dispatchPageRender(),A}setPageLabel(t){this.pageLabel=typeof t=="string"?t:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),this.pageLabel!==null?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:t,initialOptionalContent:e,regularAnnotations:i}=this.#c;return t&&e&&i?this.canvas:null}}async function Rc(h){const{info:i,metadata:s,contentDispositionFilename:n,contentLength:r}=await h.getMetadata();return{...i,baseURL:"",filesize:r||(await h.getDownloadInfo()).length,filename:n||Vl(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:h.numPages,URL:""}}class Nc{constructor(t,e){this._ready=new Promise((i,s)=>{import(t).then(r=>{i(r.QuickJSSandbox(new URL(e,location.href).href))}).catch(s)})}async createSandbox(t){(await this._ready).create(t)}async dispatchEventInSandbox(t){const e=await this._ready;setTimeout(()=>e.dispatchEvent(t),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}class Oc{#t=null;#e=null;#i=null;#s=null;#n=null;#r=null;#a=null;#o=null;#l=null;#h=!1;#u=null;#d=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#n=t,this.#r=e,this.#i=i}setViewer(t){this.#l=t}async setDocument(t){if(this.#o&&await this.#p(),this.#o=t,!t)return;const[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s){await this.#p();return}if(t!==this.#o)return;if(e){this.#a=new Set;for(const a of e.values())for(const{id:o}of a)this.#a.add(o)}try{this.#u=this.#c()}catch(a){console.error("setDocument:",a),await this.#p();return}const n=this.#n;this.#s=new AbortController;const r={signal:this.#s.signal,...ft};n.on("updatefromsandbox",a=>{a?.source===window&&this.#f(a.detail)},r),n.on("dispatcheventinsandbox",a=>{this.#u?.dispatchEventInSandbox(a.detail)},r),n.on("pagechanging",({pageNumber:a,previous:o})=>{a!==o&&(this.#m(o),this.#g(a))},r),n.on("pagerendered",({pageNumber:a})=>{this._pageOpenPending.has(a)&&a===this.#l.currentPageNumber&&this.#g(a)},r),n.on("pagesdestroy",async()=>{await this.#m(this.#l.currentPageNumber),await this.#u?.dispatchEventInSandbox({id:"doc",name:"WillClose"}),this.#t?.resolve()},r);try{const a=await this.#i(t);if(t!==this.#o)return;await this.#u.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...a,actions:s}}),n.dispatch("sandboxcreated",{source:this})}catch(a){console.error("setDocument:",a),await this.#p();return}await this.#u?.dispatchEventInSandbox({id:"doc",name:"Open"}),await this.#g(this.#l.currentPageNumber,!0),Promise.resolve().then(()=>{t===this.#o&&(this.#h=!0)})}async dispatchWillSave(){return this.#u?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#u?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#u){await this.#d?.promise,this.#d=Promise.withResolvers();try{await this.#u.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#d.resolve(),this.#d=null,t}await this.#d.promise}}async dispatchDidPrint(){return this.#u?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#e?.promise||null}get ready(){return this.#h}get _pageOpenPending(){return Ve(this,"_pageOpenPending",new Set)}get _visitedPages(){return Ve(this,"_visitedPages",new Map)}async#f(t){const e=this.#l,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:s,siblings:n,command:r,value:a}=t;if(!s){switch(r){case"clear":console.clear();break;case"error":console.error(a);break;case"layout":if(!i){const l=dh(a);e.spreadMode=l.spreadMode}break;case"page-num":e.currentPageNumber=a+1;break;case"print":await e.pagesPromise,this.#n.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(e.currentScaleValue=a);break;case"SaveAs":this.#n.dispatch("download",{source:this});break;case"FirstPage":e.currentPageNumber=1;break;case"LastPage":e.currentPageNumber=e.pagesCount;break;case"NextPage":e.nextPage();break;case"PrevPage":e.previousPage();break;case"ZoomViewIn":i||e.increaseScale();break;case"ZoomViewOut":i||e.decreaseScale();break;case"WillPrintFinished":this.#d?.resolve(),this.#d=null;break}return}if(i&&t.focus)return;delete t.id,delete t.siblings;const o=n?[s,...n]:[s];for(const l of o){if(!this.#a?.has(l))continue;const c=document.querySelector(`[data-element-id="${l}"]`);c?c.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#o?.annotationStorage.setValue(l,t)}}async#g(t,e=!1){const i=this.#o,s=this._visitedPages;if(e&&(this.#t=Promise.withResolvers()),!this.#t)return;const n=this.#l.getPageView(t-1);if(n?.renderingState!==G.FINISHED){this._pageOpenPending.add(t);return}this._pageOpenPending.delete(t);const r=(async()=>{const a=await(s.has(t)?null:n.pdfPage?.getJSActions());i===this.#o&&await this.#u?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:a})})();s.set(t,r)}async#m(t){const e=this.#o,i=this._visitedPages;if(!this.#t||this._pageOpenPending.has(t))return;const s=i.get(t);s&&(i.set(t,null),await s,e===this.#o&&await this.#u?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t}))}#c(){if(this.#e=Promise.withResolvers(),this.#u)throw new Error("#initScripting: Scripting already exists.");return this.#r.createScripting()}async#p(){if(this.#a=null,!this.#u){this.#o=null,this.#e?.resolve();return}this.#t&&(await Promise.race([this.#t.promise,new Promise(t=>{setTimeout(t,1e3)})]).catch(()=>{}),this.#t=null),this.#o=null;try{await this.#u.destroySandbox()}catch{}this.#d?.reject(new Error("Scripting destroyed.")),this.#d=null,this.#s?.abort(),this.#s=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#u=null,this.#h=!1,this.#e?.resolve()}}class Fc extends Oc{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})}),t.externalServices||={createScripting:()=>new Nc(t.sandboxBundleSrc,t.wasmUrl)},t.docProperties||=e=>Rc(e),super(t)}}const Bc=3e4;class jc{#t=null;#e=null;#i=null;#s=null;isThumbnailViewEnabled=!1;onIdle=null;printing=!1;constructor(){Object.defineProperty(this,"hasViewer",{value:()=>!!this.#s})}setViewer(t){this.#s=t}setThumbnailViewer(t){this.#i=t}isHighestPriority(t){return this.#t===t.renderingId}renderHighestPriority(t){this.#e&&(clearTimeout(this.#e),this.#e=null),!this.#s.forceRendering(t)&&(this.isThumbnailViewEnabled&&this.#i?.forceRendering()||this.printing||this.onIdle&&(this.#e=setTimeout(this.onIdle.bind(this),Bc)))}getHighestPriority(t,e,i,s=!1,n=!1){const r=t.views,a=r.length;if(a===0)return null;for(let u=0;u<a;u++){const f=r[u].view;if(!this.isViewFinished(f))return f}if(!n)for(let u=0;u<a;u++){const{detailView:f}=r[u].view;if(f&&!this.isViewFinished(f))return f}const o=t.first.id,l=t.last.id;if(l-o+1>a){const u=t.ids;for(let f=1,p=l-o;f<p;f++){const g=i?o+f:l-f;if(u.has(g))continue;const m=e[g-1];if(!this.isViewFinished(m))return m}}let c=i?l:o-2,d=e[c];return d&&!this.isViewFinished(d)||s&&(c+=i?1:-1,d=e[c],d&&!this.isViewFinished(d))?d:null}isViewFinished(t){return t.renderingState===G.FINISHED}renderView(t){switch(t.renderingState){case G.FINISHED:return!1;case G.PAUSED:this.#t=t.renderingId,t.resume();break;case G.RUNNING:this.#t=t.renderingId;break;case G.INITIAL:this.#t=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(e=>{e instanceof As||console.error("renderView:",e)});break}return!0}}const cr=10,oi={FORCE_SCROLL_MODE_PAGE:1e4,FORCE_LAZY_PAGE_INIT:5e3,PAUSE_EAGER_PAGE_INIT:250};function dr(h){return Object.values(mt).includes(h)&&h!==mt.DISABLE}class $c{#t=new Set;#e=0;constructor(t){this.#e=t}push(t){const e=this.#t;e.has(t)&&e.delete(t),e.add(t),e.size>this.#e&&this.#i()}resize(t,e=null){this.#e=t;const i=this.#t;if(e){const s=i.size;let n=1;for(const r of i)if(e.has(r.id)&&(i.delete(r),i.add(r)),++n>s)break}for(;i.size>this.#e;)this.#i()}has(t){return this.#t.has(t)}[Symbol.iterator](){return this.#t.keys()}#i(){const t=this.#t.keys().next().value;t?.destroy(),this.#t.delete(t)}}class ha{#t=null;#e=null;#i=null;#s=mt.NONE;#n=null;#r=Nt.ENABLE_FORMS;#a=null;#o=null;#l=null;#h=!1;#u=!1;#d=!1;#f=!1;#g=!0;#m=null;#c=null;#p=0;#b=null;#y=[NaN,NaN];#w=!0;#v=null;#E=!1;#A=null;#x=null;#S=!1;#T=null;#k=0;#P=new ResizeObserver(this.#at.bind(this));#I=null;#M=null;#D=null;#V=!0;#R=Rt.ENABLE;#$=null;#B=null;#L=null;#N=null;constructor(t){const e="6.3.289";if(Rn!==e)throw new Error(`The API version "${Rn}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,this.#$=t.viewerAlert||null,this.container?.tagName!=="DIV"||this.viewer?.tagName!=="DIV")throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&getComputedStyle(this.container).position!=="absolute")throw new Error("The `container` must be absolutely positioned.");this.#P.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new Qs,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#e=t.altTextManager||null,this.#a=t.commentManager||null,this.#D=t.signatureManager||null,this.#l=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=s=>this._getVisiblePages().ids.has(s)),this._scriptingManager=t.scriptingManager||null,this.#R=t.textLayerMode??Rt.ENABLE,this.#r=t.annotationMode??Nt.ENABLE_FORMS,this.#s=t.annotationEditorMode??mt.NONE,this.#i=t.annotationEditorHighlightColors||null,this.#h=t.enableHighlightFloatingButton===!0,this.#d=t.enableUpdatedAddImage===!0,this.#f=t.enableNewAltTextWhenAddingImage===!0,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.maxCanvasDim=t.maxCanvasDim,this.capCanvasAreaFactor=t.capCanvasAreaFactor,this.enableDetailCanvas=t.enableDetailCanvas??!0,this.enableOptimizedPartialRendering=t.enableOptimizedPartialRendering??!1,this.enableSelectionRendering=t.enableSelectionRendering!==!1,this.imagesRightClickMinSize=t.imagesRightClickMinSize??-1,this.l10n=t.l10n,this.l10n||=new jt,this.#u=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#b=t.mlManager||null,this.#V=t.supportsPinchToZoom!==!1,this.#g=t.enableAutoLinking!==!1,this.#p=t.minDurationToUpdateCanvas??500,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new jc,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;this.#m=i||null,i?.addEventListener("abort",()=>{this.#P.disconnect(),this.#P=null},{once:!0}),this.scroll=sh(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=we.UNKNOWN,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#st(),this.eventBus.on("thumbnailrendered",({pageNumber:s,pdfPage:n})=>{const r=this._pages[s-1];this.#t.has(r)||n?.cleanup()},ft),t.l10n||this.l10n.translate(this.container)}get printingAllowed(){return this.#w}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#t)}get pageViewsReady(){return this._pages.every(t=>t?.pdfPage)}clearSelection(){const t=document.getSelection();if(!(!t||t.isCollapsed)){for(let e=0,i=t.rangeCount;e<i;e++)if(t.getRangeAt(e).intersectsNode(this.viewer)){t.removeAllRanges?.(),t.empty?.();return}}}get renderForms(){return this.#r===Nt.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(t){if(!Number.isInteger(t))throw new Error("Invalid page number.");this.pdfDocument&&(this._currentPageNumber!==t&&this.clearSelection(),this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#Z(),!0;if(!(0<t&&t<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,pageLabel:this._pageLabels?.[t-1]??null,previous:i}),e&&this.#Z(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(t){if(!this.pdfDocument)return;let e=t|0;if(this._pageLabels){const i=this._pageLabels.indexOf(t);i>=0&&(e=i+1)}this._currentPageNumber!==e&&this.clearSelection(),this._setCurrentPageNumber(e,!0)||console.error(`currentPageLabel: "${t}" is not a valid page.`)}get currentScale(){return this._currentScale!==0?this._currentScale:1}set currentScale(t){if(isNaN(t))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#O(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#O(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Zr(t))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument||(t%=360,t<0&&(t+=360),this._pagesRotation===t))return;this.clearSelection(),this._pagesRotation=t;const e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#O(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:t,pageNumber:e}),this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){const t=this;return Ve(this,"_layerProperties",{get annotationEditorUIManager(){return t.#n},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableComment(){return!!t.#a},get enableScripting(){return!!t._scriptingManager},get fieldObjectsPromise(){return t.pdfDocument?.getFieldObjects()},get findController(){return t.findController},get hasJSActionsPromise(){return t.pdfDocument?.hasJSActions()},get linkService(){return t.linkService}})}#C(t){this.#w=t,this.eventBus.dispatch("printingallowed",{source:this,isAllowed:t})}#_(t){const e={annotationEditorMode:this.#s,annotationMode:this.#r,textLayerMode:this.#R};return t?(this.#C(t.has(de.PRINT_HIGH_QUALITY)||t.has(de.PRINT)),!t.has(de.COPY)&&this.#R===Rt.ENABLE&&(e.textLayerMode=Rt.ENABLE_PERMISSIONS),t.has(de.MODIFY_CONTENTS)||(e.annotationEditorMode=mt.DISABLE),!t.has(de.MODIFY_ANNOTATIONS)&&!t.has(de.FILL_INTERACTIVE_FORMS)&&this.#r===Nt.ENABLE_FORMS&&(e.annotationMode=Nt.ENABLE),e):(this.#C(!0),e)}async#H(t){if(document.visibilityState==="hidden"||!this.container.offsetParent||this._getVisiblePages().views.length===0)return;const e=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&e.resolve()},{signal:AbortSignal.any([t,i.signal])}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(t=null){const e=[],i=[];for(let s=1,n=this.pdfDocument.numPages;s<=n;++s){if(t?.aborted)return null;i.length=0;const r=await this.pdfDocument.getPage(s),{items:a}=await r.getTextContent();for(const o of a)o.str&&i.push(o.str),o.hasEOL&&i.push(` 598`);e.push(te(i.join("")))}return e.join(` 599`)}#W(t,e){const i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#T)){if(this.#S||t===Rt.ENABLE_PERMISSIONS){Es(e);return}this.#S=!0;const{classList:r}=this.viewer;r.add("copyAll");const a=new AbortController,o=new AbortController;window.addEventListener("keydown",l=>{l.key==="Escape"&&o.abort()},{signal:a.signal}),this.getAllText(o.signal).then(async l=>{l!==null&&await navigator.clipboard.writeText(l)}).catch(l=>{console.warn(`Something goes wrong when extracting the text: ${l.message}`)}).finally(()=>{this.#S=!1,a.abort(),r.remove("copyAll")}),Es(e)}}setDocument(t){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#n?.destroy(),this.#n=null,this.#s=mt.NONE,this.#w=!0),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#u?t.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#c=new AbortController;const{signal:l}=this.#c,c={signal:l,...ft};if(e>oi.FORCE_SCROLL_MODE_PAGE){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const f=this._scrollMode=H.PAGE;r.dispatch("scrollmodechanged",{source:this,mode:f})}this._pagesCapability.promise.then(()=>{r.dispatch("pagesloaded",{source:this,pagesCount:e})},()=>{});const d=f=>{const p=this._pages[f.pageNumber-1];p&&this.#t.push(p)};r.on("pagerender",d,c);const u=f=>{f.cssTransform||f.isDetailView||(this._onePageRenderedCapability.resolve({timestamp:f.timestamp}),r.off("pagerendered",u))};r.on("pagerendered",u,c),Promise.all([i,n]).then(([f,p])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(f),this._optionalContentConfigPromise=s;const{annotationEditorMode:g,annotationMode:m,textLayerMode:b}=this.#_(p);if(b!==Rt.DISABLE){const v=this.#T=document.createElement("div");v.id="hiddenCopyElement",v.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none",o.before(v)}if(g!==mt.DISABLE){const v=g;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):dr(v)?(this.#n=new jl(this.container,o,this.#$,this.#e,this.#a,this.#D,r,t,a,this.#i,this.#h,this.#d,this.#f,this.#b,this.#l,this.#V),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#n}),v!==mt.NONE&&(this.#nt(v),this.#n.updateMode(v))):console.error(`Invalid AnnotationEditor mode: ${v}`)}const y=this._scrollMode===H.PAGE?null:o,w=this.currentScale,A=f.getViewport({scale:w*Ft.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",A.scale),a?.background&&o.style.setProperty("--page-bg-color",a.background),(a?.foreground==="CanvasText"||a?.background==="Canvas")&&(o.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),o.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText")));for(let v=1;v<=e;++v){const E=new Oi({container:y,eventBus:r,id:v,scale:w,defaultViewport:A.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:b,annotationMode:m,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,enableSelectionRendering:this.enableSelectionRendering,imagesRightClickMinSize:this.imagesRightClickMinSize,pageColors:a,l10n:this.l10n,layerProperties:this._layerProperties,enableAutoLinking:this.#g,minDurationToUpdateCanvas:this.#p,commentManager:this.#a,abortSignal:this.#m});this._pages.push(E)}this._pages[0]?.setPdfPage(f),this._scrollMode===H.PAGE?this.#U():this._spreadMode!==dt.NONE&&this._updateSpreadMode(),r.on("annotationeditorlayerrendered",v=>{this.#n&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#s})},{once:!0,signal:l,...ft}),this.#H(l).then(async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#T&&document.addEventListener("copy",this.#W.bind(this,b),{signal:l}),t.loadingParams.disableAutoFetch||e>oi.FORCE_LAZY_PAGE_INIT){this._pagesCapability.resolve();return}let v=e-1;if(v<=0){this._pagesCapability.resolve();return}for(let E=2;E<=e;++E){const _=t.getPage(E).then(C=>{const S=this._pages[E-1];S.pdfPage||S.setPdfPage(C),--v===0&&this._pagesCapability.resolve()},C=>{console.error(`Unable to get page ${E} to initialize viewer`,C),--v===0&&this._pagesCapability.resolve()});E%oi.PAUSE_EAGER_PAGE_INIT===0&&await _}}),r.dispatch("pagesinit",{source:this}),t.getMetadata().then(({info:v})=>{t===this.pdfDocument&&v.Language&&(o.lang=v.Language)}),this.defaultRenderingQueue&&this.update()}).catch(f=>{console.error("Unable to initialize viewer",f),this._pagesCapability.reject(f)})}onPagesEdited({pagesMapper:t,type:e,hasBeenCut:i,pageNumbers:s}){if(e==="copy"){this.#B=new Map;for(const l of s)this.#B.set(l,this._pages[l-1]);return}if(e==="cancelCopy"){this.#B=null;return}if((e==="cut"||e==="delete")&&(this.#L=this._pages,this.#N=s),e==="cancelDelete"){if(this.#N=null,!this.#L)return;const l=this._scrollMode===H.PAGE?null:this.viewer;if(l){this.#n?.startUpdatePages();const c=document.createDocumentFragment();for(let d=0,u=this.#L.length;d<u;d++){const f=this.#L[d];f.updatePageNumber(d+1),c.append(f.div)}l.replaceChildren(c),this.#n?.endUpdatePages()}this._pages=this.#L,this.#L=null;return}if(e==="cleanSavedData"){if(this.#N){if(this.#L){for(const l of this.#N)this.#L[l-1].deleteMe();this.#L=null}this.#N=null}return}this._currentPageNumber=0;const r=this._pages,a=this._pages=[];this.#n?.startUpdatePages();for(let l=1,c=t.pagesNumber;l<=c;l++){const d=t.getPrevPageNumber(l);if(d<0){let f=this.#B.get(-d);i?f.updatePageNumber(l):(this.#n?.clonePage(-d-1,l-1),f=f.clone(l)),a.push(f);continue}const u=r[d-1];a.push(u),u.updatePageNumber(l)}this.#n?.endUpdatePages(),e==="paste"&&(this.#B=null);const o=this._scrollMode===H.PAGE?null:this.viewer;if(o){const l=document.createDocumentFragment();for(const{div:c}of a)l.append(c);o.replaceChildren(l)}setTimeout(()=>{this.forceRendering()})}setPageLabels(t){if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let e=0,i=this._pages.length;e<i;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#t=new $c(cr),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=H.VERTICAL,this._previousScrollMode=H.UNKNOWN,this._spreadMode=dt.NONE,this.#I={previousPageNumber:1,scrollDown:!0,pages:[]},this.#c?.abort(),this.#c=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#T?.remove(),this.#T=null,this.#Q(),this.#et()}#U(){if(this._scrollMode!==H.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#I,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode===dt.NONE&&!this.isInPresentationMode){const s=this._pages[t-1];i.append(s.div),e.pages.push(s)}else{const s=new Set,n=this._spreadMode-1;n===-1?s.add(t-1):t%2!==n?(s.add(t-1),s.add(t)):(s.add(t-2),s.add(t-1));const r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){const a=document.createElement("div");a.className="dummyPage",r.append(a)}for(const a of s){const o=this._pages[a];o&&(r.append(o.div),e.pages.push(o))}i.append(r)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){this.pagesCount!==0&&(this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,this.update()},100),this.update())}#X(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===H.PAGE&&(this.#U(),this.update()),!e&&!this.isInPresentationMode){const n=i.offsetLeft+i.clientLeft,r=n+i.clientWidth,{scrollLeft:a,clientWidth:o}=this.container;(this._scrollMode===H.HORIZONTAL||n<a||r>a+o)&&(e={left:0,top:0})}ih(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#q(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}panBy(t,e){const{container:i}=this,s=this.#y,{scrollLeft:n,scrollTop:r}=i,a=(Math.abs(n-s[0])<1?s[0]:n)-t,o=(Math.abs(r-s[1])<1?s[1]:r)-e;s[0]=a,s[1]=o,i.scrollLeft=a,i.scrollTop=o,this.#E=!0}#K(){if(!this.#E)return;const{first:t}=this._getVisiblePages();t&&this._updateLocation(t)}#j(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:r=null,pan:a=null}){if(this._currentScaleValue=e.toString(),this.#q(t)){a&&!i&&this.panBy(a[0],a[1]),s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e});return}this.clearSelection(),this.viewer.style.setProperty("--scale-factor",t*Ft.PDF_TO_CSS_UNITS);const o=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:o?n:-1}),o&&(this.#M=setTimeout(()=>{this.#M=null,this.refresh()},n));const l=this._currentScale;if(this._currentScale=t,!i){this.#K();let c=this._currentPageNumber,d;this._location&&!(this.isInPresentationMode||this.isChangingPresentationMode)&&(c=this._location.pageNumber,d=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:c,destArray:d,allowNegativeOffset:!0});let u=a?.[0]??0,f=a?.[1]??0;if(Array.isArray(r)){const p=t/l-1,[g,m]=this.containerTopLeft;u-=(r[0]-m)*p,f-=(r[1]-g)*p}(u||f)&&this.panBy(u,f)}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:s?e:void 0}),this.defaultRenderingQueue&&this.update()}get#G(){return this._spreadMode!==dt.NONE&&this._scrollMode!==H.HORIZONTAL?2:1}#O(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#j(i,t,e);else{const s=this._pages[this._currentPageNumber-1];if(!s)return;let n=40,r=5;this.isInPresentationMode?(n=r=4,this._spreadMode!==dt.NONE&&(n*=2)):this.removePageBorders?n=r=0:this._scrollMode===H.HORIZONTAL&&([n,r]=[r,n]);const a=(this.container.clientWidth-n)/s.width*s.scale/this.#G,o=(this.container.clientHeight-r)/s.height*s.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=o;break;case"page-fit":i=Math.min(a,o);break;case"auto":const l=Un(s)?a:Math.min(o,a);i=Math.min(1.25,l);break;default:console.error(`#setScale: "${t}" is an unknown zoom value.`);return}e.preset=!0,this.#j(i,t,e)}}#Z(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#O(this._currentScaleValue,{noScroll:!0}),this.#X(t)}pageLabelToPageNumber(t){if(!this._pageLabels)return null;const e=this._pageLabels.indexOf(t);return e<0?null:e+1}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1,center:n=null}){if(!this.pdfDocument)return;const r=Number.isInteger(t)&&this._pages[t-1];if(!r){console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);return}if(this.isInPresentationMode||!e){this._setCurrentPageNumber(t,!0);return}let a=0,o=0,l=0,c=0,d,u;const f=r.rotation%180!==0,p=(f?r.height:r.width)/r.scale/Ft.PDF_TO_CSS_UNITS,g=(f?r.width:r.height)/r.scale/Ft.PDF_TO_CSS_UNITS;let m=0;switch(e[1].name){case"XYZ":a=e[2],o=e[3],m=e[4],a=a!==null?a:0,o=o!==null?o:g;break;case"Fit":case"FitB":m="page-fit";break;case"FitH":case"FitBH":o=e[2],m="page-width",o===null&&this._location?(a=this._location.left,o=this._location.top):(typeof o!="number"||o<0)&&(o=g);break;case"FitV":case"FitBV":a=e[2],l=p,c=g,m="page-height";break;case"FitR":a=e[2],o=e[3],l=e[4]-a,c=e[5]-o;let A=40,v=5;this.removePageBorders&&(A=v=0),d=(this.container.clientWidth-A)/l/Ft.PDF_TO_CSS_UNITS,u=(this.container.clientHeight-v)/c/Ft.PDF_TO_CSS_UNITS,m=Math.min(Math.abs(d),Math.abs(u));break;default:console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`);return}if(s||(m&&m!==this._currentScale?this.currentScaleValue=m:this._currentScale===0&&(this.currentScaleValue="auto")),m==="page-fit"&&!e[4]){this.#X(r);return}const b=[r.viewport.convertToViewportPoint(a,o),r.viewport.convertToViewportPoint(a+l,o+c)];let y=Math.min(b[0][0],b[1][0]),w=Math.min(b[0][1],b[1][1]);n?((n==="both"||n==="vertical")&&(w-=(this.container.clientHeight-Math.abs(b[1][1]-b[0][1]))/2),(n==="both"||n==="horizontal")&&(y-=(this.container.clientWidth-Math.abs(b[1][0]-b[0][0]))/2)):i||(y=Math.max(y,0),w=Math.max(w,0)),this.#X(r,{left:y,top:w})}_updateLocation(t){this.#E=!1;const e=this._currentScale,i=this._currentScaleValue,s=parseFloat(i)===e?Math.round(e*1e4)/100:i,n=t.id,r=this._pages[n-1],a=this.container,o=r.getPagePoint(a.scrollLeft-t.x,a.scrollTop-t.y),[l,c]=o;let d=`#page=${n}`;this.isInPresentationMode||(d+=`&zoom=${s},${Math.round(l)},${Math.round(c)}`),this._location={pageNumber:n,scale:s,top:c,left:l,rotation:this._pagesRotation,pdfOpenParams:d}}update(){const t=this._getVisiblePages(),e=t.views,i=e.length;if(i===0)return;const s=Math.max(cr,2*i+1);this.#t.resize(s,t.ids);for(const{view:o,visibleArea:l}of e)o.updateVisibleArea(l);for(const o of this.#t)t.ids.has(o.id)||o.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===dt.NONE&&(this._scrollMode===H.PAGE||this._scrollMode===H.VERTICAL),r=this._currentPageNumber;let a=!1;for(const o of e){if(o.percent<100)break;if(o.id===r&&n){a=!0;break}}this._setCurrentPageNumber(a?this._currentPageNumber:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#it(){const t=this._getVisiblePages(),e=[],{ids:i,views:s}=t;for(const n of s){const{view:r}=n;if(!r.hasEditableAnnotations()){i.delete(r.id);continue}e.push(n)}return e.length===0?null:(this.renderingQueue.renderHighestPriority({first:e[0],last:e.at(-1),views:e,ids:i}),i)}containsElement(t){return this.container.contains(t)}focus(){this.container.focus()}get _isContainerRtl(){return getComputedStyle(this.container).direction==="rtl"}get isInPresentationMode(){return this.presentationModeState===we.FULLSCREEN}get isChangingPresentationMode(){return this.presentationModeState===we.CHANGING}get isHorizontalScrollbarEnabled(){return this.isInPresentationMode?!1:this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return this.isInPresentationMode?!1:this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const t=this._scrollMode===H.PAGE?this.#I.pages:this._pages,e=this._scrollMode===H.HORIZONTAL,i=e&&this._isContainerRtl;return ah({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(const t of this._pages)t.renderingState!==G.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#z(t){if(t.pdfPage)return t.pdfPage;try{const e=await this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(e){return console.error("Unable to get page for page view",e),null}}#J(t){if(t.first?.id===1)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case H.PAGE:return this.#I.scrollDown;case H.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#J(e),s=this._spreadMode!==dt.NONE&&this._scrollMode!==H.HORIZONTAL,n=this.#M!==null||this.#v!==null&&e.views.some(a=>a.detailView?.renderingCancelled),r=this.renderingQueue.getHighestPriority(e,this._pages,i,s,n);return r?(this.#z(r).then(()=>{this.renderingQueue.renderView(r)}),!0):!1}get hasEqualPageSizes(){const t=this._pages[0];for(let e=1,i=this._pages.length;e<i;++e){const s=this._pages[e];if(s.width!==t.width||s.height!==t.height)return!1}return!0}getPagesOverview(){let t;return this._pages.map(e=>{const i=e.pdfPage.getViewport({scale:1}),s=Un(i);if(t===void 0)t=s;else if(this.enablePrintAutoRotate&&s!==t)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}})}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error("optionalContentConfigPromise: Not initialized yet."),this.pdfDocument.getOptionalContentConfig({intent:"display"})):Promise.resolve(null)}set optionalContentConfigPromise(t){if(!(t instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${t}`);this.pdfDocument&&this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=t,this.refresh(!1,{optionalContentConfigPromise:t}),this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:t}))}get scrollMode(){return this._scrollMode}set scrollMode(t){if(this._scrollMode!==t){if(!oh(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>oi.FORCE_SCROLL_MODE_PAGE||(this._previousScrollMode=this._scrollMode,this.clearSelection(),this._scrollMode=t,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:t}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(t=null){const e=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",e===H.HORIZONTAL),i.classList.toggle("scrollWrapped",e===H.WRAPPED),!(!this.pdfDocument||!t)&&(e===H.PAGE?this.#U():this._previousScrollMode===H.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#O(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(t){if(this._spreadMode!==t){if(!lh(t))throw new Error(`Invalid spread mode: ${t}`);this.clearSelection(),this._spreadMode=t,this.eventBus.dispatch("spreadmodechanged",{source:this,mode:t}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(t=null){if(!this.pdfDocument)return;const e=this.viewer,i=this._pages;if(this._scrollMode===H.PAGE)this.#U();else if(e.textContent="",this._spreadMode===dt.NONE)for(const s of this._pages)e.append(s.div);else{const s=this._spreadMode-1;let n=null;for(let r=0,a=i.length;r<a;++r)n===null?(n=document.createElement("div"),n.className="spread",e.append(n)):r%2===s&&(n=n.cloneNode(!1),e.append(n)),n.append(i[r].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#O(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}#tt(t,e=!1){switch(this._scrollMode){case H.WRAPPED:{const{views:i}=this._getVisiblePages(),s=new Map;for(const{id:n,y:r,percent:a,widthPercent:o}of i)a===0||o<100||s.getOrInsertComputed(r,Gl).push(n);for(const n of s.values()){const r=n.indexOf(t);if(r===-1)continue;const a=n.length;if(a===1)break;if(e)for(let o=r-1,l=0;o>=l;o--){const c=n[o],d=n[o+1]-1;if(c<d)return t-d}else for(let o=r+1,l=a;o<l;o++){const c=n[o],d=n[o-1]+1;if(c>d)return d-t}if(e){const o=n[0];if(o<t)return t-o+1}else{const o=n[a-1];if(o>t)return o-t+1}break}break}case H.HORIZONTAL:break;case H.PAGE:case H.VERTICAL:{if(this._spreadMode===dt.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:s}=this._getVisiblePages(),n=e?t-1:t+1;for(const{id:r,percent:a,widthPercent:o}of s)if(r===n){if(a>0&&o===100)return 2;break}break}}return 1}nextPage(){const t=this._currentPageNumber,e=this.pagesCount;if(t>=e)return!1;const i=this.#tt(t,!1)||1;return this.currentPageNumber=Math.min(t+i,e),!0}previousPage(){const t=this._currentPageNumber;if(t<=1)return!1;const e=this.#tt(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:s,pan:n=null}){if(i===null&&e===null)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let r=this._currentScale;if(e>0&&e!==1)r=Math.round(r*e*100)/100;else if(i){const a=i>0?1.1:.9090909090909091,o=i>0?Math.ceil:Math.floor;i=Math.abs(i);do r=o((r*a).toFixed(2)*10)/10;while(--i>0)}r=Yl(r,.1,25),this.#O(r,{noScroll:!1,drawingDelay:t,origin:s,pan:n})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#st(t=this.container.clientHeight){t!==this.#k&&(this.#k=t,hh.setProperty("--viewer-container-height",`${t}px`))}#at(t){for(const e of t)if(e.target===this.container){this.#st(Math.floor(e.borderBoxSize[0].blockSize)),this.#o=null;break}}get containerTopLeft(){return this.#o||=[this.container.offsetTop,this.container.offsetLeft]}#Q(){this.#M!==null&&(clearTimeout(this.#M),this.#M=null),this.#v!==null&&(clearTimeout(this.#v),this.#v=null)}#et(){this.#A?.abort(),this.#A=null,this.#x!==null&&(clearTimeout(this.#x),this.#x=null)}#nt(t){switch(t){case mt.STAMP:this.#b?.loadModel("altText");break;case mt.SIGNATURE:this.#D?.loadSignatures();break}}get annotationEditorMode(){return this.#n?this.#s:mt.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1,mustEnterInEditMode:s=!1,editComment:n=!1}){if(!this.#n)throw new Error("The AnnotationEditor is not enabled.");
599if(this.#s===t)return;if(!dr(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;this.#nt(t);const{eventBus:r,pdfDocument:a}=this,o=async()=>{this.#et(),this.#s=t,await this.#n.updateMode(t,e,!0,i,s,n),!(t!==this.#s||a!==this.pdfDocument)&&r.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===mt.NONE||this.#s===mt.NONE){const l=t!==mt.NONE;l||this.pdfDocument.annotationStorage.resetModifiedIds(),this.cleanup();for(const d of this._pages)d.toggleEditingMode(l);const c=this.#it();if(l&&c){this.#et(),this.#A=new AbortController;const d=AbortSignal.any([this.#c.signal,this.#A.signal]);r.on("pagerendered",({pageNumber:u})=>{c.delete(u),c.size===0&&(this.#x=setTimeout(o,0))},{signal:d,...ft});return}}o()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const i of this._pages)i.update(e);this.#Q(),t||this.update()}}}class Uc extends ha{_resetView(){super._resetView(),this._scrollMode=H.PAGE,this._spreadMode=dt.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}globalThis.pdfjsViewer={AnnotationLayerBuilder:ia,DownloadManager:vh,EventBus:Ss,FindState:Vt,GenericL10n:jt,LinkTarget:Zt,parseQueryString:Ni,PDFFindController:bh,PDFHistory:wc,PDFLinkService:ea,PDFPageView:Oi,PDFScriptingManager:Fc,PDFSinglePageViewer:Uc,PDFViewer:ha,ProgressBar:ch,RenderingStates:G,ScrollMode:H,SimpleLinkService:Qs,SpreadMode:dt,StructTreeLayerBuilder:Zs,TextLayerBuilder:Ae,XfaLayerBuilder:la};const Fi=async h=>{if(h.rendering)return;h.rendering=!0;const t=h.currentPage,e=await h.pdfInstance.getPage(t),i=h.root.querySelector("[data-document-viewer-page]"),s=i.querySelector("canvas");s.dataset.page=t.toString();let n=e.getViewport({scale:1});const r=i.clientWidth,a=i.clientHeight,o=Math.min(r/n.width,a/n.height);n=e.getViewport({scale:o*h.scale}),s.width=Math.floor(n.width),s.height=Math.floor(n.height),s.style.left=`${Math.round((r-s.width)/2)}px`,s.style.top=`${Math.round((a-s.height)/2)}px`,s.style.transform="none";const l={canvas:s,canvasContext:s.getContext("2d"),viewport:n};await e.render(l).promise,i.appendChild(s);try{await Vc(h,i,e,n,s)}finally{h.rendering=!1,h.currentPage!==t&&Fi(h)}},Vc=async(h,t,e,i,s)=>{t.style.setProperty("--total-scale-factor",i.scale.toString());const n=document.createElement("article");n.classList.add(h.mode),n.setAttribute("aria-label",`${h.title}, ${h.currentPage} / ${h.totalPages}`);const r=new mi({textContentSource:e.streamTextContent(),container:n,viewport:i});n.style.width=`${s.width}px`,n.style.height=`${s.height}px`,n.style.left=s.style.left,n.style.top=s.style.top,n.style.transform=`rotate(${i.rotation}deg)`,await r.render(),t.querySelector("article").replaceWith(n);const a=new Zs(e,i.rawDims),o=await a.render();o&&(a.updateTextLayer(),n.append(o))},ca=async(h,t,e,i=null)=>{i=i||h;for(const s in e){if((e[s].dest?.[0]??null)===null)continue;const r=await t.pdfInstance.getPageIndex(e[s].dest[0]),a=yi("outlineItem");if(a.querySelector("[data-document-viewer-title]").innerText=e[s].title,a.querySelector("[data-document-viewer-page-number]").innerText=`${r+1}`,a.querySelector('[data-event="document-viewer:set-page"]').dataset.value=`${r+1}`,e[s].bold&&a.classList.add("font-bold"),e[s].italic&&a.classList.add("italic"),e[s].items.length>0){a.querySelector('[data-event="document-viewer:outline-toggle"]').classList.remove("hidden"),a.classList.add("parent");const o=yi("outline");a.append(o),await ca(h,t,e[s].items,o)}i.append(a)}},Hc=h=>{h.root.querySelector("[data-title]").textContent=h.title,h.root.querySelector("[data-file-size]").textContent=h.fileSize,h.root.setAttribute("aria-label",h.title)},zc=h=>{h.root.querySelector("[data-current-page]").textContent=h.currentPage.toString(),h.root.querySelector("[data-total-pages]").textContent=h.totalPages.toString()},da=h=>{h.root.querySelector("[data-scale]").textContent=`${h.scale*100}%`},Wc=h=>{document.body.appendChild(h.root)},Gc=async h=>{const t=yi("thumbnail");h.data.thumbnails.forEach((e,i)=>{const s=t.cloneNode(!0);s.querySelector("[data-thumbnail]").src=e,s.querySelector("[data-thumbnail]").alt=`${i+1}`,s.querySelector("[data-page-number]").innerText=`${i+1}`,s.querySelector("[data-event]").dataset.value=`${i+1}`,h.root.querySelector("[data-sidebar-previews]").appendChild(s)}),h.root.querySelector(`[data-event="document-viewer:set-page"][data-value="${h.currentPage}"]`).parentElement.classList.add("active")},Xc=async h=>{const t=await h.pdfInstance.getOutline(),e=h.root.querySelector("[data-sidebar-outline]");await ca(e,h,t),h.root.querySelector('[data-event="document-viewer:sidebar-tab"][data-value="outline"]').classList.toggle("hidden",!e.children.length)},Yc=(h,t)=>{h.root.addEventListener("click",i=>{if(i.target.closest('[data-event="document-viewer:close"]')){t.close();return}if(i.target.closest('[data-event="document-viewer:download"]')){ur(h);return}if(i.target.closest('[data-event="document-viewer:zoom-in"]')){Me(.25,h);return}if(i.target.closest('[data-event="document-viewer:zoom-out"]')){Me(-.25,h);return}if(i.target.closest('[data-event="document-viewer:move"]')){Le("move",h);return}if(i.target.closest('[data-event="document-viewer:select"]')){Le("select",h);return}if(i.target.closest('[data-event="document-viewer:page-previous"]')){ge(h.currentPage-1,h);return}if(i.target.closest('[data-event="document-viewer:page-next"]')){ge(h.currentPage+1,h);return}if(i.target.closest('[data-event="document-viewer:set-page"]')){const s=i.target.closest("button");ge(parseInt(s.dataset.value),h);return}if(i.target.closest('[data-event="document-viewer:sidebar-tab"]')){qc(i.target.closest("button"),h);return}if(i.target.closest('[data-event="document-viewer:outline-toggle"]')){Kc(i.target.closest("button"));return}});const e=h.root.querySelector("[data-document-viewer-page]");e.addEventListener("wheel",i=>{Me(i.wheelDelta<0?-.25:.25,h)}),e.addEventListener("mousedown",i=>fr(i,h)),e.addEventListener("touchstart",i=>fr(i,h)),e.addEventListener("mousemove",i=>pr(i,h)),e.addEventListener("touchmove",i=>pr(i,h)),document.addEventListener("mouseup",()=>gr(h)),document.addEventListener("touchend",()=>gr(h)),h.root.addEventListener("keydown",i=>{if(h.mode==="move"&&h.scale>1){const a=i.key==="ArrowLeft"?40:i.key==="ArrowRight"?-40:0,o=i.key==="ArrowUp"?40:i.key==="ArrowDown"?-40:0;if(a||o){ua(a,o,h),i.preventDefault(),i.stopPropagation();return}}if(i.key!=="Tab"||!h.opened)return;const s=h.root.querySelectorAll('button:not([disabled]), [href], input
599:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),n=s[0],r=s[s.length-1];i.shiftKey?(document.activeElement===n||document.activeElement===h.root)&&(r.focus(),i.preventDefault()):document.activeElement===r&&(n.focus(),i.preventDefault())}),h.root.addEventListener("keyup",i=>{h.mode==="move"&&h.scale>1&&i.key.startsWith("Arrow")&&(i.preventDefault(),i.stopPropagation())}),document.addEventListener("document-viewer:page-previous",()=>{h.opened&&ge(h.currentPage-1,h)}),document.addEventListener("document-viewer:page-next",()=>{h.opened&&ge(h.currentPage+1,h)}),document.addEventListener("document-viewer:close",()=>{h.opened&&t.close()}),document.addEventListener("document-viewer:zoom-in",()=>{h.opened&&Me(.25,h)}),document.addEventListener("document-viewer:zoom-out",()=>{h.opened&&Me(-.25,h)}),document.addEventListener("document-viewer:move",()=>{h.opened&&Le("move",h)}),document.addEventListener("document-viewer:select",()=>{h.opened&&Le("select",h)}),document.addEventListener("document-viewer:download",()=>{h.opened&&ur(h)}),Qc(e,h)},Me=(h,t)=>{if(t.scale+=h,t.scale=Math.min(t.scale,3),t.scale=Math.max(t.scale,.25),t.scale>1)Le("move",t);else{const e=t.root.querySelector("[data-document-viewer-page]");e.dataset.x="0",e.dataset.y="0",e.style.transform=""}t.scale===.25?t.root.querySelector('[data-event="document-viewer:zoom-out"]').setAttribute("disabled","disabled"):t.root.querySelector('[data-event="document-viewer:zoom-out"]').removeAttribute("disabled"),t.scale===3?t.root.querySelector('[data-event="document-viewer:zoom-in"]').setAttribute("disabled","disabled"):t.root.querySelector('[data-event="document-viewer:zoom-in"]').removeAttribute("disabled"),da(t),Fi(t)},ge=(h,t)=>{t.currentPage=h,t.currentPage=Math.max(t.currentPage,1),t.currentPage=Math.min(t.currentPage,t.totalPages),t.currentPage===1?t.root.querySelector('[data-event="document-viewer:page-previous"]').setAttribute("disabled","disabled"):t.root.querySelector('[data-event="document-viewer:page-previous"]').removeAttribute("disabled"),t.currentPage===t.totalPages?t.root.querySelector('[data-event="document-viewer:page-next"]').setAttribute("disabled","disabled"):t.root.querySelector('[data-event="document-viewer:page-next"]').removeAttribute("disabled"),zc(t),Fi(t);const e=t.root.querySelector("[data-sidebar-previews] .active");e.classList.remove("active"),e.removeAttribute("aria-current"),t.root.querySelectorAll("[data-sidebar-outline] .active").forEach(n=>{n.classList.remove("active"),n.removeAttribute("aria-current")}),t.root.querySelectorAll(`[data-event="document-viewer:set-page"][data-value="${t.currentPage}"]`).forEach(n=>{if(n=n.parentElement,n.classList.add("active"),n.setAttribute("aria-current","page"),n.scrollIntoView({behavior:"smooth",block:"center"}),n.classList.contains("group/title")&&n.nextElementSibling){n.nextElementSibling.classList.remove("hidden");const r=n.querySelector('[data-event="document-viewer:outline-toggle"]');r.classList.add("open"),r.setAttribute("aria-expanded","true")}})},Le=(h,t)=>{t.mode=h;const e=t.root.querySelector("[data-document-viewer-page]"),i=e.querySelector("article");e.classList.remove("moving"),t.moving=!1,i.classList.remove("move","select"),i.classList.add(h),h==="move"&&window.getSelection().removeAllRanges(),t.root.querySelectorAll('[data-event="document-viewer:move"], [data-event="document-viewer:select"]').forEach(n=>{n.classList.remove("active"),n.setAttribute("aria-pressed","false")});const s=t.root.querySelector(`[data-event="document-viewer:${h}"]`);s.classList.add("active"),s.setAttribute("aria-pressed","true")},ur=h=>{const t=document.createElement("a");t.href=h.data.pdf,t.target="_blank",t.download=h.title,t.click()},qc=(h,t)=>{const e=h.dataset.value,i=e==="previews"?t.root.querySelector("[data-sidebar-previews]"):t.root.querySelector("[data-sidebar-outline]");(e==="previews"?t.root.querySelector("[data-sidebar-outline]"):t.root.querySelector("[data-sidebar-previews]")).classList.remove("active"),i.classList.add("active");const n=h,r=e==="previews"?t.root.querySelector('[data-event="document-viewer:sidebar-tab"][data-value="outline"]'):t.root.querySelector('[data-event="document-viewer:sidebar-tab"][data-value="previews"]');n.classList.add("active"),n.setAttribute("aria-pressed","true"),r.classList.remove("active"),r.setAttribute("aria-pressed","fal
599se")},Kc=h=>{h.classList.toggle("open"),h.setAttribute("aria-expanded",h.classList.contains("open").toString()),h.parentElement.nextElementSibling.classList.toggle("hidden"),h.parentElement.nextElementSibling.classList.toggle("manual")},Qc=(h,t)=>{let e=null;new ResizeObserver(()=>{t.pdfInstance!==null&&(e&&clearTimeout(e),e=setTimeout(()=>{Fi(t)},500))}).observe(h)};let ui={x:0,y:0};const fr=(h,t)=>{t.moving=!0,t.root.querySelector("[data-document-viewer-page]").classList.add("moving"),h.changedTouches&&(ui={x:h.changedTouches[0].clientX,y:h.changedTouches[0].clientY})},pr=(h,t)=>{if(!t.moving||t.mode!=="move"||t.scale<=1)return;const e=h.movementX??h.changedTouches[0].clientX-ui.x,i=h.movementY??h.changedTouches[0].clientY-ui.y;h.changedTouches&&(ui={x:h.changedTouches[0].clientX,y:h.changedTouches[0].clientY}),ua(e,i,t)},ua=(h,t,e)=>{const i=e.root.querySelector("[data-document-viewer-page]"),s=+(i.dataset.x||0)+h,n=+(i.dataset.y||0)+t;i.dataset.x=s.toString(),i.dataset.y=n.toString(),i.style.transform=`translate(${s}px, ${n}px)`},gr=h=>{h.moving=!1,h.root.querySelector("[data-document-viewer-page]").classList.remove("moving")};async function Hd(h,t,e,i){const s={opened:!0,title:t,fileSize:e,currentPage:1,scale:1,data:{pdf:h,thumbnails:[]},rendering:!1,mode:"move",moving:!1,triggeringElement:i},n={open(a){a&&(s.triggeringElement=a),s.opened=!0,s.root.classList.add("opened"),document.documentElement.style.overflow="hidden",ge(s.currentPage,s),setTimeout(()=>{s.root.focus()},50)},close(){s.opened=!1,s.root.classList.remove("opened"),document.documentElement.style.overflow="",s.triggeringElement?.focus()}};s.root=yi("modal"),Wc(s),s.root.classList.add("opened"),document.documentElement.style.overflow="hidden";const r=Ol(s);return Hc(s),da(s),await r,Yc(s,n),await Nl(s),await Gc(s),await Xc(s),n}export{Hd as Viewer};
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.