PageSourceSearch

https://www.airhelp.fr/_next/static/chunks/0b621803.7c02838b257faa37.js

js airhelp.fr collected 2026-10-04 15:00:33 UTC 396,087 bytes, 2 lines download raw bytes

1!function(){try{var t="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},e=(new t.Error).stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="38aee649-6090-4abe-9d21-fd70c1d0adbe",t._sentryDebugIdIdentifier="sentry-dbid-38aee649-6090-4abe-9d21-fd70c1d0adbe")}catch(t){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3093],{88735:(t,e,i)=>{i.r(e),i.d(e,{AbortException:()=>I,AnnotationEditorLayer:()=>s_,AnnotationEditorParamsType:()=>c,AnnotationEditorType:()=>d,AnnotationEditorUIManager:()=>tI,AnnotationLayer:()=>st,AnnotationMode:()=>l,AnnotationType:()=>g,CSSConstants:()=>tm,ColorPicker:()=>iT,DOMSVGFactory:()=>iR,DrawLayer:()=>sC,FeatureTest:()=>F,GlobalWorkerOptions:()=>eX,ImageKind:()=>p,InvalidPDFException:()=>D,MathClamp:()=>j,OPS:()=>f,OutputScale:()=>tu,PDFDataRangeTransport:()=>iv,PDFDateString:()=>ta,PDFWorker:()=>iw,PasswordResponses:()=>b,PermissionFlag:()=>u,PixelsPerInch:()=>X,RenderingCancelledException:()=>Q,ResponseException:()=>k,SignatureExtractor:()=>sv,SupportedImageMimeTypes:()=>tp,TextLayer:()=>ig,TouchManager:()=>tF,Util:()=>N,VerbosityLevel:()=>m,XfaLayer:()=>W,applyOpacity:()=>tf,build:()=>iE,createValidAbsoluteUrl:()=>_,fetchData:()=>K,findContrastColor:()=>tx,getDocument:()=>im,getFilenameFromUrl:()=>tt,getPdfFilenameFromUrl:()=>te,getRGB:()=>tl,getUuid:()=>H,getXfaPageViewport:()=>to,isDataScheme:()=>J,isPdfFile:()=>Z,isValidExplicitDest:()=>tW,noContextMenu:()=>tr,normalizeUnicode:()=>z,renderRichText:()=>t_,setLayerDimensions:()=>tc,shadow:()=>S,stopEvent:()=>tn,updateUrlHash:()=>C,version:()=>iS});var s=i(95425),r=i(81949).Buffer,n={};n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var e={};let a="object"==typeof s&&s+""=="[object process]"&&!s.versions.nw&&!(s.versions.electron&&s.type&&"browser"!==s.type),o=[.001,0,0,.001,0,0],l={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},h="pdfjs_internal_editor_",d={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},c={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},u={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},p={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},g={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},m={ERRORS:0,WARNINGS:1,INFOS:5},f={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},b={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},v=m.WARNINGS;function y(t){v>=m.INFOS&&console.info(`Info: ${t}`)}function A(t){v>=m.WARNINGS&&console.warn(`Warning: ${t}`)}function w(t){throw Error(t)}function x(t,e){t||w(e)}function _(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){let e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{var s;s=t,t=decodeURIComponent(escape(s))}catch{}}let r=e?URL.parse(t,e):URL.parse(t);return!function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r)?null:r}function C(t,e,i=!1){let s=URL.parse(t);return s?(s.hash=e,s.href):i&&_(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function S(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}let E=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();
1class T extends E{constructor(t,e){super(t,"PasswordException"),this.code=e}}class M extends E{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class D extends E{constructor(t){super(t,"InvalidPDFException")}}class k extends E{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class P extends E{constructor(t){super(t,"FormatError")}}class I extends E{constructor(t){super(t,"AbortException")}}function R(t){("object"!=typeof t||t?.length===void 0)&&w("Invalid argument for bytesToString");let e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);let i=[];for(let s=0;s<e;s+=8192){let r=Math.min(s+8192,e),n=t.subarray(s,r);i.push(String.fromCharCode.apply(null,n))}return i.join("")}function L(t){"string"!=typeof t&&w("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class F{static get isLittleEndian(){let t;return S(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]))}static get isEvalSupported(){return S(this,"isEvalSupported",function(){try{return Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return S(this,"isOffscreenCanvasSupported","u">typeof OffscreenCanvas)}static get isImageDecoderSupported(){return S(this,"isImageDecoderSupported","u">typeof ImageDecoder)}static get platform(){let{platform:t,userAgent:e}=navigator;return S(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return S(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}let B=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class N{static makeHexColor(t,e,i){return`#${B[t]}${B[e]}${B[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}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){let s=t[i],r=t[i+1];t[i]=s*e[0]+r*e[2]+e[4],t[i+1]=s*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){let h=t[i+e],d=t[i+e+1];t[i+e]=h*s+d*n+o,t[i+e+1]=h*r+d*a+l}}static applyInverseTransform(t,e){let i=t[0],s=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,i){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3],p=s*h+o,g=p,m=s*c+o,f=m,b=a*d+l,v=b,y=a*u+l,A=y;if(0!==r||0!==n){let t=r*h,e=r*c,i=n*d,s=n*u;p+=i,f+=i,m+=s,g+=s,b+=t,A+=t,y+=e,v+=e}i[0]=Math.min(i[0],p,m,g,f),i[1]=Math.min(i[1],b,y,v,A),i[2]=Math.max(i[2],p,m,g,f),i[3]=Math.max(i[3],b,y,v,A)}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){let i=t[0],s=t[1],r=t[2],n=t[3],a=i**2+s**2,o=r**2+n**2,l=(a+o)/2,h=Math.sqrt(l**2-(a*o-(i*r+s*n)**2));e[0]=Math.sqrt(l+h||1),e[1]=Math.sqrt(l-h||1)}static normalizeRect(t){let e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){let 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;let r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),n=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>n?null:[i,r,s,n]}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,r){r[0]=Math.min(r[0],t,i),r[1]=Math.min(r[1],e,s),r[2]=Math.max(r[2],t,i),r[3]=Math.max(r[3],e,s)}static #t(t,e,i,s,r,n,a,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*r+3*l*n)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static #e(t,e,i,s,r,n,a,o,l,h,d,c){if(1e-12>Math.abs(l)){Math.abs(h)>=1e-12&&this.#t(t,e,i,s,r,n,a,o,-d/h,c);return}let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,r,n,a,o,(-h+p)/g,c),this.#t(t,e,i,s,r,n,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,r,n,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,r,a,e,
1s,n,o,3*(-t+3*(i-r)+a),6*(t-2*i+r),3*(i-t),l),this.#e(t,i,r,a,e,s,n,o,3*(-e+3*(s-n)+o),6*(e-2*s+n),3*(s-e),l)}}let O=null,U=null;function z(t){return O||(O=/([\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,U=new Map([["ſt","ſt"]])),t.replaceAll(O,(t,e,i)=>e?e.normalize("NFKC"):U.get(i))}function H(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),R(t)}let $="pdfjs_internal_id_";function j(t,e,i){return Math.min(Math.max(t,e),i)}function G(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(R(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(i=>{i(t(...e))})}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});class V{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return!function t(i){if(!i)return;let s=null,r=i.name;if("#text"===r)s=i.value;else{if(!V.shouldBuildText(r))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return"textarea"!==t&&"input"!==t&&"option"!==t&&"select"!==t}}class W{static setupStorage(t,e,i,s,r){let n=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==n.value&&(t.textContent=n.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(n.value===i.attributes.xfaOn?t.setAttribute("checked",!0):n.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===r)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==n.value&&t.setAttribute("value",n.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==n.value)for(let e of(t.setAttribute("value",n.value),i.children))e.attributes.value===n.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected;t.addEventListener("input",t=>{let i=t.target.options,r=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:r})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:r}){let{attributes:n}=e,a=t instanceof HTMLAnchorElement;for(let[e,i]of("radio"===n.type&&(n.name=`${n.name}-${s}`),Object.entries(n)))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:a&&("href"===e||"newWindow"===e)||t.setAttribute(e,i)}a&&r.addLinkAttributes(t,n.href,n.newWindow),i&&n.dataId&&this.setupStorage(t,n.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,r=t.intent||"display",n=document.createElement(s.name);s.attributes&&this.setAttributes({html:n,element:s,intent:r,linkService:i});let a="richText"!==r,o=t.div;if(o.append(n),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===s.children.length){if(s.value){let t=document.createTextNode(s.value);n.append(t),a&&V.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}let h=[[s,-1,n]];for(;h.length>0;){let[t,s,n]=h.at(-1);if(s+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),n.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(n.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:r,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);a&&V.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}let q="http://www.w3.org/2000/svg";class X{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function K(t,e="text"){if(ts(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType=e,r.onreadystatechange=()=>
1{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){switch(e){case"arraybuffer":case"blob":case"json":i(r.response);return}i(r.responseText);return}s(Error(r.statusText))}},r.send(null)})}class Y{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:r=0,offsetY:n=0,dontFlip:a=!1}){let o,l,h,d,c,u,p,g;this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=r,this.offsetY=n,i*=e;const m=(t[2]+t[0])/2,f=(t[3]+t[1])/2;switch((s%=360)<0&&(s+=360),s){case 180:o=-1,l=0,h=0,d=1;break;case 90:o=0,l=1,h=1,d=0;break;case 270:o=0,l=-1,h=-1,d=0;break;case 0:o=1,l=0,h=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(h=-h,d=-d),0===o?(c=Math.abs(f-t[1])*i+r,u=Math.abs(m-t[0])*i+n,p=(t[3]-t[1])*i,g=(t[2]-t[0])*i):(c=Math.abs(m-t[0])*i+r,u=Math.abs(f-t[1])*i+n,p=(t[2]-t[0])*i,g=(t[3]-t[1])*i),this.transform=[o*i,l*i,h*i,d*i,c-o*i*m-h*i*f,u-l*i*m-d*i*f],this.width=p,this.height=g}get rawDims(){let t=this.viewBox;return S(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:r=!1}={}){return new Y({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}convertToViewportPoint(t,e){let i=[t,e];return N.applyTransform(i,this.transform),i}convertToViewportRectangle(t){let e=[t[0],t[1]];N.applyTransform(e,this.transform);let i=[t[2],t[3]];return N.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){let i=[t,e];return N.applyInverseTransform(i,this.transform),i}}class Q extends E{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function J(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Z(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function tt(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function te(t,e="document.pdf"){if("string"!=typeof t)return e;if(J(t))return A('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!i)return e;let s=t=>{try{let e=decodeURIComponent(t);if(e.includes("/")){if((e=e.split("/").at(-1)).test(/^\.pdf$/i))return e;return t}return e}catch{return t}}
1,r=/\.pdf$/i,n=i.pathname.split("/").at(-1);if(r.test(n))return s(n);if(i.searchParams.size>0){for(let t of Array.from(i.searchParams.values()).reverse())if(r.test(t))return s(t);for(let t of Array.from(i.searchParams.keys()).reverse())if(r.test(t))return s(t)}if(i.hash){let t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return s(t[0])}return e}class ti{started=Object.create(null);times=[];time(t){t in this.started&&A(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||A(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:t}of this.times)e=Math.max(t.length,e);for(let{name:i,start:s,end:r}of this.times)t.push(`${i.padEnd(e)} ${r-s}ms
2`);return t.join("")}}function ts(t,e){let i=e?URL.parse(t,e):URL.parse(t);return i?.protocol==="http:"||i?.protocol==="https:"}function tr(t){t.preventDefault()}function tn(t){t.preventDefault(),t.stopPropagation()}class ta{static #i;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#i||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#i.exec(t);if(!e)return null;let i=parseInt(e[1],10),s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let n=parseInt(e[4],10);n=n>=0&&n<=23?n:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(n+=h,a+=d):"+"===l&&(n-=h,a-=d),new Date(Date.UTC(i,s,r,n,a,o))}}function to(t,{scale:e=1,rotation:i=0}){let{width:s,height:r}=t.attributes.style;return new Y({viewBox:[0,0,parseInt(s),parseInt(r)],userUnit:1,scale:e,rotation:i})}function tl(t){if(t.startsWith("#")){let e=parseInt(t.slice(1),16);return[(0xff0000&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(A(`Not a valid color format: "${t}"`),[0,0,0])}function th(t){let{a:e,b:i,c:s,d:r,e:n,f:a}=t.getTransform();return[e,i,s,r,n,a]}function td(t){let{a:e,b:i,c:s,d:r,e:n,f:a}=t.getTransform().invertSelf();return[e,i,s,r,n,a]}function tc(t,e,i=!1,s=!0){if(e instanceof Y){let{pageWidth:s,pageHeight:r}=e.rawDims,{style:n}=t,a=F.isCSSRoundSupported,o=`var(--total-scale-factor) * ${s}px`,l=`var(--total-scale-factor) * ${r}px`,h=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(n.width=d,n.height=h):(n.width=h,n.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}class tu{constructor(){const{pixelRatio:t}=tu;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,r=-1){let n=1/0,a=1/0,o=1/0;(i=tu.capPixels(i,r))>0&&(n=Math.sqrt(i/(t*e))),-1!==s&&(a=s/t,o=s/e);let l=Math.min(n,a,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let 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}}let tp=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class tg{static get isDarkMode(){return S(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class tm{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:i}=window.getComputedStyle(t);return t.remove(),S(this,"commentForegroundColor",tl(i))}}function tf(t,e,i,s){let r=255*(1-(s=Math.min(Math.max(s??1,0),1)));return[t=Math.round(t*s+r),e=Math.round(e*s+r),i=Math.round(i*s+r)]}function tb(t,e){let i=t[0]/255,s=t[1]/255,r=t[2]/255,n=Math.max(i,s,r),a=Math.min(i,s,r),o=(n+a)/2;if(n===a)e[0]=e[1]=0;else{let t=n-a;switch(e[1]=o<.5?t/(n+a):t/(2-n-a),n){case i:e[0]=((s-r)/t+6*(s<r))*60;break;case s:e[0]=((r-i)/t+2)*60;break;case r:e[0]=((i-s)/t+4)*60}}e[2]=o}function tv(t,e){let i=t[0],s=t[1],r=t[2],n=(1-Math.abs(2*r-1))*s,a=n*(1-Math.abs(i/60%2-1)),o=r-n/2;switch(Math.floor(i/60)){case 0:e[0]=n+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=n+o,e[2]=o;break;case 2:e[0]=o,e[1]=n+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=n+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=n+o;break;
2case 5:case 6:e[0]=n+o,e[1]=o,e[2]=a+o}}function ty(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function tA(t,e,i){tv(t,i),i.map(ty);let s=.2126*i[0]+.7152*i[1]+.0722*i[2];tv(e,i),i.map(ty);let r=.2126*i[0]+.7152*i[1]+.0722*i[2];return s>r?(s+.05)/(r+.05):(r+.05)/(s+.05)}let tw=new Map;function tx(t,e){let i=t[0]+256*t[1]+65536*t[2]+0x1000000*e[0]+0x100000000*e[1]+0x10000000000*e[2],s=tw.get(i);if(s)return s;let r=new Float32Array(9),n=r.subarray(0,3),a=r.subarray(3,6);tb(t,a);let o=r.subarray(6,9);tb(e,o);let l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),tA(a,o,n)<h){let t,e;for(l?(t=a[2],e=1):(t=0,e=a[2]);e-t>.005;){let i=a[2]=(t+e)/2;l===tA(a,o,n)<h?t=i:e=i}a[2]=l?e:t}return tv(a,n),s=N.makeHexColor(Math.round(255*n[0]),Math.round(255*n[1]),Math.round(255*n[2])),tw.set(i,s),s}function t_({html:t,dir:e,className:i},s){let r=document.createDocumentFragment();if("string"==typeof t){let i=document.createElement("p");i.dir=e||"auto";let s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){let r=s[t];i.append(document.createTextNode(r)),t<e-1&&i.append(document.createElement("br"))}r.append(i)}else W.render({xfaHtml:t,div:r,intent:"richText"});r.firstChild.classList.add("richText",i),s.append(r)}class tC{#s=null;#r=null;#n;#a=null;#o=null;#l=null;#h=null;#d=null;static #c=null;constructor(t){this.#n=t,tC.#c||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#n._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",tr,{signal:e}),t.addEventListener("pointerdown",tC.#u,{signal:e}));let i=this.#a=document.createElement("div");i.className="buttons",t.append(i);let s=this.#n.toolbarPosition;if(s){let{style:e}=t,i="ltr"===this.#n._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=`${100*i}%`,e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#s}static #u(t){t.stopPropagation()}#p(t){this.#n._focusEventsAllowed=!1,tn(t)}#g(t){this.#n._focusEventsAllowed=!0,tn(t)}#m(t){let e=this.#n._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#p.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#g.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",tr,{signal:e}),!0)}hide(){this.#s.classList.add("hidden"),this.#r?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown(),this.#l?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#n,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",tC.#c[t]),this.#m(i)&&i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#a.append(i)}get #f(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#m(e),this.#a.append(e,this.#f),this.#o=t}addComment(t,e=null){if(this.#l)return;let i=t.renderForToolbar();if(!i)return;this.#m(i);let s=this.#h=this.#f;e?(this.#a.insertBefore(i,e),this.#a.insertBefore(s,e)):this.#a.append(i,s),this.#l=t,t.toolbar=this}addColorPicker(t){if(this.#r)return;this.#r=t;let e=t.renderButton();this.#m(e),this.#a.append(e,this.#f)}async addEditSignatureButton(t){let e=this.#d=await t.renderEditButton(this.#n);this.#m(e),this.#a.append(e,this.#f)}removeButton(t){"comment"===t&&(this.#l?.removeToolbarCommentButton(),this.#l=null,this.#h?.remove(),this.#h=null)}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e)}}async addButtonBefore(t,e,i){let s=this.#a.querySelector(i);s&&"comment"===t&&this.addComment(e,s)}updateEditSignatureButton(t){this.#d&&(this.#d.title=t)}remove(){this.#s.remove(),this.#r?.destroy(),this.#r=null}}class tS{#a=null;#s=null;#b;constructor(t){this.#b=t}#v(){let t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");let e=this.#b._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",tr,{signal:e});let i=this.#a=document.createElement("div");return i.className="buttons",t.append(i),this.#b.hasCommentManager()&&this.#y("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#b.commentSelection("floating_button")}),this.#y("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#b.highlightSelection("floating_button")}),t}#A(t,e){let i=0,s=0;for(let r of t){let t=r.y+r.height;if(t<i)continue;let n=r.x+(e?r.width:0);if(t>i){s=n,i=t;continue}e?n>s&&(s=n):n<s&&(s=n)}return[e?1-s:s,i]}
2show(t,e,i){let[s,r]=this.#A(e,i),{style:n}=this.#s||=this.#v();t.append(this.#s),n.insetInlineEnd=`${100*s}%`,n.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#y(t,e,i,s){let r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);let n=document.createElement("span");r.append(n),n.className="visuallyHidden",n.setAttribute("data-l10n-id",i);let a=this.#b._signal;a instanceof AbortSignal&&!a.aborted&&(r.addEventListener("contextmenu",tr,{signal:a}),r.addEventListener("click",s,{signal:a})),this.#a.append(r)}}function tE(t,e,i){for(let s of i)e.addEventListener(s,t[s].bind(t))}class tT{#w=0;get id(){return`${h}${this.#w++}`}}class tM{#x=H();#w=0;#_=null;static get _isSVGFittingCanvas(){let t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',S(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async #C(t,e){this.#_||=new Map;let i=this.#_.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#x}_${this.#w++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await K(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){let e=tM._isSVGFittingCanvas,s=new FileReader,r=new Image,n=new Promise((t,n)=>{r.onload=()=>{i.bitmap=r,i.isSvg=!0,t()},s.onload=async()=>{let t=i.svgUrl=s.result;r.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},r.onerror=s.onerror=n});s.readAsDataURL(t),await n}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){A(t),i=null}return this.#_.set(t,i),i&&this.#_.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:s,type:r}=t;return this.#C(`${e}_${i}_${s}_${r}`,t)}async getFromUrl(t){return this.#C(t,t)}async getFromBlob(t,e){let i=await e;return this.#C(t,i)}async getFromId(t){this.#_||=new Map;let e=this.#_.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#_||=new Map;let i=this.#_.get(t);if(i?.bitmap)return i.refCounter+=1,i;let s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#x}_${this.#w++}`,refCounter:1,isSvg:!1},this.#_.set(t,i),this.#_.set(i.id,i),i}getSvgUrl(t){let e=this.#_.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#_||=new Map;let e=this.#_.get(t);if(!e||(e.refCounter-=1,0!==e.refCounter))return;let{bitmap:i}=e;if(!e.url&&!e.file){let t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#x}_`)}}class tD{#S=[];#E=!1;#T;#M=-1;constructor(t=128){this.#T=t}add({cmd:t,undo:e,post:i,mustExec:s,type:r=NaN,overwriteIfSameType:n=!1,keepUndo:a=!1}){if(s&&t(),this.#E)return;let o={cmd:t,undo:e,post:i,type:r};if(-1===this.#M){this.#S.length>0&&(this.#S.length=0),this.#M=0,this.#S.push(o);return}if(n&&this.#S[this.#M].type===r){a&&(o.undo=this.#S[this.#M].undo),this.#S[this.#M]=o;return}let l=this.#M+1;l===this.#T?this.#S.splice(0,1):(this.#M=l,l<this.#S.length&&this.#S.splice(l)),this.#S.push(o)}undo(){if(-1===this.#M)return;this.#E=!0;let{undo:t,post:e}=this.#S[this.#M];t(),e?.(),this.#E=!1,this.#M-=1}redo(){if(this.#M<this.#S.length-1){this.#M+=1,this.#E=!0;let{cmd:t,post:e}=this.#S[this.#M];t(),e?.(),this.#E=!1}}hasSomethingToUndo(){return -1!==this.#M}hasSomethingToRedo(){return this.#M<this.#S.length-1}cleanType(t){if(-1!==this.#M){for(let e=this.#M;e>=0;e--)if(this.#S[e].type!==t){this.#S.splice(e+1,this.#M-e),this.#M=e;return}this.#S.length=0,this.#M=-1}}destroy(){this.#S=null}}class tk{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=F.platform;for(const[i,s,r={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:r}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:r}),this.allKeys.add(t.split("+").at(-1)))}}#D(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let i=this.callbacks.get(this.#D(e));if(!i)return;let{callback:s,options:{bubbles:r=!1,args:n=[],checker:a=null}}=i;(!a||a(t,e))&&(s.bind(t,...n,e)(),r||tn(e))}}class tP{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]),e=document.createElement("span");for(let i of(e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e),t.keys())){e.style.color=i;let s=window.getComputedStyle(e).color;t.set(i,tl(s))}return e.remove(),S(this,"_colors",t)}convert(t){let e=tl(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return tP._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?N.makeHexColor(...e):t}}class tI{#k=new AbortController;#P=null;#I=null;#R=new Map;#L=new Map;#F=null;#B=null;#N=null;#O=new tD;#U=null;#z=null;#H=null;#$=0;#j=new Set;#G=null;#V=null;#W=new Set;_editorUndoBar=null;#q=!1;#X=!1;#K=!1;#Y=null;#Q=null;#J=null;#Z=null;#tt=!1;#te=null;#ti=new tT;#ts=!1;#tr=!1;#tn=!1;#ta=null;#to=null;#tl=null;#th=null;#td=null;#tc=d.NONE;#tu=new Set;#tp=null;#tg=null;#tm=null;#tf=null;#tb=null;#tv={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ty=[0,0];#tA=null;#tw=null;#tx=null;#t_=null;#tC=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=tI.prototype,e=t=>t.#tw.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>
vendor: 4,856 bytes, line 2
2{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return S(this,"_keyboardManager",new tk([[["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","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tw.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tw.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}constructor(t,e,i,s,r,n,a,o,l,h,d,c,u,p,g,m){const f=this._signal=this.#k.signal;this.#tw=t,this.#tx=e,this.#t_=i,this.#F=s,this.#U=r,this.#tg=n,this.#tb=o,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:f}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),a._on("setpreference",this.onSetPreference.bind(this),{signal:f}),a._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:f}),window.addEventListener("pointerdown",()=>{this.#tr=!0},{capture:!0,signal:f}),window.addEventListener("pointerup",()=>{this.#tr=!1},{capture:!0,signal:f}),this.#tS(),this.#tE(),this.#tT(),this.#B=o.annotationStorage,this.#Y=o.filterFactory,this.#tm=l,this.#Z=h||null,this.#q=d,this.#X=c,this.#K=u,this.#td=p||null,this.viewParameters={realScale:X.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==m,r?.setSidebarUiManager(this)}destroy(){for(let t of(this.#tC?.resolve(),this.#tC=null,this.#k?.abort(),this.#k=null,this._signal=null,this.#L.values()))t.destroy();this.#L.clear(),this.#R.clear(),this.#W.clear(),this.#th?.clear(),this.#P=null,this.#tu.clear(),this.#O.destroy(),this.#F?.destroy(),this.#U?.destroy(),this.#tg?.destroy(),this.#te?.hide(),this.#te=null,this.#tl?.destroy(),this.#tl=null,this.#I=null,this.#Q&&(clearTimeout(this.#Q),this.#Q=null),this.#tA&&(clearTimeout(this.#tA),this.#tA=null),this._editorUndoBar?.destroy(),this.#tb=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#td}get useNewAltTextFlow(){return this.#X}get useNewAltTextWhenAddingImage(){return this.#K}get hcmFilter(){return S(this,"hcmFilter",this.#tm?this.#Y.addHCMFilter(this.#tm.foreground,this.#tm.background):"none")}get direction(){return S(this,"direction",getComputedStyle(this.#tw).direction)}get _highlightColors(){return S(this,"_highlightColors",this.#Z?new Map(this.#Z.split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return S(this,"highlightColors",null);let e=new Map,i=!!this.#tm;for(let[s,r]of t){let t=s.endsWith("_HCM");if(i&&t){e.set(s.replace("_HCM",""),r);continue}i||t||e.set(s,r)}return S(this,"highlightColors",e)}get highlightColorNames(){return S(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#H=t}setMainHighlightColorPicker(t){this.#tl=t}editAltText(t,e=!1){this.#F?.editAltText(this,t,e)}hasCommentManager(){return!!this.#U}editComment(t,e,i,s){this.#U?.showDialog(this,t,e,i,s)}selectComment(t,e){let i=this.#L.get(t),s=i?.getEditorByUID(e);s?.toggleComment(!0,!0)}updateComment(t){this.#U?.updateComment(t.getData())}updatePopupColor(t){this.#U?.updatePopupColor(t)}
2removeComment(t){this.#U?.removeComments([t.uid])}toggleComment(t,e,i){this.#U?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#U?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#U?.dialogElement||null}async waitForEditorsRendered(t){if(this.#L.has(t-1))return;let{resolve:e,promise:i}=Promise.withResolvers(),s=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s),await i}getSignature(t){this.#tg?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#tg}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),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}){"enableNewAltTextWhenAddingImage"===t&&(this.#K=e)}onPageChanging({pageNumber:t}){this.#$=t-1}focusMainContainer(){this.#tw.focus()}findParent(t,e){for(let i of this.#L.values()){let{x:s,y:r,width:n,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+n&&e>=r&&e<=r+a)return i}return null}disableUserSelect(t=!1){this.#tx.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#W.add(t)}removeShouldRescale(t){this.#W.delete(t)}onScaleChanging({scale:t}){for(let e of(this.commitOrRemove(),this.viewParameters.realScale=t*X.PDF_TO_CSS_UNITS,this.#W))e.onScaleChanging();this.#H?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tM({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#tD(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let e of this.#L.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){let i=document.getSelection();if(!i||i.isCollapsed)return;let{anchorNode:s,anchorOffset:r,focusNode:n,focusOffset:a}=i,o=i.toString(),l=this.#tM(i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();let c=this.#tD(l),u=this.#tc===d.NONE,p=()=>{let i=c?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:r,focusNode:n,focusOffset:a,text:o});u&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};u?this.switchToMode(d.HIGHLIGHT,p):p()}commentSelection(t=""){this.highlightSelection(t,!0)}#tk(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tM(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#te||=new tS(this),this.#te.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#B)return null;let e=`${h}${t}`,i=this.#B.getRawValue(e);return i&&this.#B.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#B||this.#B.has(t.id)||this.#B.setValue(t.id,t)}a11yAlert(t,e=null){let i=this.#t_;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#tP(){let t=document.getSelection();if(!t||t.isCollapsed){this.#tp&&(this.#te?.hide(),this.#tp=null,this.#tI({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#tp)return;let i=this.#tM(t).closest(".textLayer");if(!i){this.#tp&&(this.#te?.hide(),this.#tp=null,this.#tI({hasSelectedText:!1}));return}if(this.#te?.hide(),this.#tp=e,this.#tI({hasSelectedText:!0}),(this.#tc===d.HIGHLIGHT||this.#tc===d.NONE)&&(this.#tc===d.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#tt=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=this.#tc===d.HIGHLIGHT?this.#tD(i):null;if(t?.toggleDrawing(),this.#tr){let e=new AbortController,i=this.combinedSignal(e),s=i=>{("pointerup"!==i.type||0===i.button)&&(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#tR("main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else t?.toggleDrawing(!0),this.#tR("main_toolbar")}}#tR(t=""){this.#tc===d.HIGHLIGHT?this.highlightSelection(t):this.#q&&this.#tk()}#tS(){document.addEventListener("selectionchange",this.#tP.bind(this),{signal:this._signal})}#tL(){if(this.#J)return;this.#J=new AbortController;let t=this.combinedSignal(this.#J);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#tF(){this.#J?.abort(),this.#J=null}blur(){if(this.isShiftKeyDown=!1,this.#tt&&(this.#tt=!1,this.#tR("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#tu)if(e.div.contains(t)){this.#to=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#to)return;let[t,e]=this.#to;this.#to=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#tT(){if(this.#ta)return;this.#ta=new AbortController;let t=this.combinedSignal(this.#ta);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#tB(){this.#ta?.abort(),this.#ta=null}#tN(){if(this.#z)return;this.#z=new AbortController;let t=this.combinedSignal(this.#z);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})}#tO(){this.#z?.abort(),this.#z=null}#tE(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#tT(),this.#tN()}removeEditListeners(){this.#tB(),this.#tO()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#V)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#V)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#P?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#tu){let i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let t of e.items)for(let e of this.#V)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){A(`paste: "${t.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let t=[];for(let e of i){let i=await s.deserialize(e);if(!i)return;t.push(i)}let e=()=>{for(let e of t)this.#tU(e);this.#tz(t)};this.addCommands({cmd:e,undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){A(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#tc===d.NONE||this.isEditorHandlingKeyboard||tI._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#tt&&(this.#tt=!1,this.#tR("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")}}#tI(t){Object.entries(t).some(([t,e])=>this.#tv[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#tv,t)}),this.#tc===d.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#tH([[c.HIGHLIGHT_FREE,!0]]))}#tH(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#tL(),this.#tN(),this.#tI({isEditing:this.#tc!==d.NONE,isEmpty:this.#t$(),hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:this.#O.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#tF(),this.#tO(),this.#tI({isEditing:!1}),this.disableUserSelect(!1))}
2registerEditorTypes(t){if(!this.#V)for(let e of(this.#V=t,this.#V))this.#tH(e.defaultPropertiesToUpdate)}getId(){return this.#ti.id}get currentLayer(){return this.#L.get(this.#$)}getLayer(t){return this.#L.get(t)}get currentPageIndex(){return this.#$}addLayer(t){this.#L.set(t.pageIndex,t),this.#ts?t.enable():t.disable()}removeLayer(t){this.#L.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,r=!1){if(this.#tc!==t&&(!this.#tC||(await this.#tC.promise,this.#tC))){if(this.#tC=Promise.withResolvers(),this.#H?.commitOrRemove(),this.#tc===d.POPUP&&this.#U?.hideSidebar(),this.#U?.destroyPopup(),this.#tc=t,t===d.NONE){for(let t of(this.setEditingState(!1),this.#tj(),this.#R.values()))t.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#tC.resolve();return}for(let t of this.#R.values())t.addStandaloneCommentButton();for(let e of(t===d.SIGNATURE&&await this.#tg?.loadSignatures(),this.setEditingState(!0),await this.#tG(),this.unselectAll(),this.#L.values()))e.updateMode(t);if(t===d.POPUP){this.#I||=await this.#tb.getAnnotationsByType(new Set(this.#V.map(t=>t._editorType)));let t=new Set,e=[];for(let i of this.#R.values()){let{annotationElementId:s,hasComment:r,deleted:n}=i;s&&t.add(s),r&&!n&&e.push(i.getData())}for(let i of this.#I){let{id:s,popupRef:r,contentsObj:n}=i;r&&n?.str&&!t.has(s)&&!this.#j.has(s)&&e.push(i)}this.#U?.showSidebar(e)}if(!e){i&&this.addNewEditorFromKeyboard(),this.#tC.resolve();return}for(let t of this.#R.values())t.uid===e?(this.setSelected(t),r?t.editComment():s?t.enterInEditMode():t.focus()):t.unselect();this.#tC.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#tc&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#V){switch(t){case c.CREATE:this.currentLayer.addNewEditor(e);return;case c.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#tf||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(let i of this.#tu)i.updateParams(t,e);else for(let i of this.#V)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#R.values())i.editorType===t&&i.show(e);(this.#tf?.get(c.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#tH([[c.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tn!==t)for(let e of(this.#tn=t,this.#L.values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}async #tG(){if(!this.#ts){this.#ts=!0;let t=[];for(let e of this.#L.values())t.push(e.enable());for(let e of(await Promise.all(t),this.#R.values()))e.enable()}}#tj(){if(this.unselectAll(),this.#ts){for(let t of(this.#ts=!1,this.#L.values()))t.disable();for(let t of this.#R.values())t.disable()}}*getEditors(t){for(let e of this.#R.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#R.get(t)}addEditor(t){this.#R.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#Q&&clearTimeout(this.#Q),this.#Q=setTimeout(()=>{this.focusMainContainer(),this.#Q=null},0)),this.#R.delete(t.id),t.annotationElementId&&this.#th?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#j.has(t.annotationElementId)||this.#B?.remove(t.id)}addDeletedAnnotationElement(t){this.#j.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#j.has(t)}removeDeletedAnnotationElement(t){this.#j.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tU(t){let e=this.#L.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#P!==t&&(this.#P=t,t&&this.#tH(t.propertiesToUpdate))}get #tV(){let t=null;for(t of this.#tu);return t}updateUI(t){this.#tV===t&&this.#tH(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#tH(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#tu.has(t)){this.#tu.delete(t),t.unselect(),this.#tI({hasSelectedEditor:this.hasSelection});return}this.#tu.add(t),t.select(),this.#tH(t.propertiesToUpdate),this.#tI({hasSelectedEditor:!0})}setSelected(t){for(let e of(this.updateToolbar({mode:t.mode,editId:t.id}),this.#H?.commitOrRemove(),this.#tu))e!==t&&e.unselect();this.#tu.clear(),this.#tu.add(t),t.select(),this.#tH(t.propertiesToUpdate),this.#tI({hasSelectedEditor:!0})}isSelected(t){return this.#tu.has(t)}get firstSelectedEditor(){return this.#tu.values().next().value}unselect(t){t.unselect(),this.#tu.delete(t),this.#tI({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#tu.size}get isEnterHandled(){return 1===this.#tu.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#O.undo(),this.#tI({hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#t$()}),this._editorUndoBar?.hide()}redo(){this.#O.redo(),this.#tI({hasSomethingToUndo:!0,hasSomethingToRedo:this.#O.hasSomethingToRedo(),isEmpty:this.#t$()})}addCommands(t){this.#O.add(t),this.#tI({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#t$()})}cleanUndoStack(t){this.#O.cleanType(t)}#t$(){if(0===this.#R.size)return!0;
2if(1===this.#R.size)for(let t of this.#R.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#tu],i=()=>{for(let t of(this._editorUndoBar?.show(s,1===e.length?e[0].editorType:e.length),e))t.remove()},s=()=>{for(let t of e)this.#tU(t)};this.addCommands({cmd:i,undo:s,mustExec:!0})}commitOrRemove(){this.#P?.commitOrRemove()}hasSomethingToControl(){return this.#P||this.hasSelection}#tz(t){for(let t of this.#tu)t.unselect();for(let e of(this.#tu.clear(),t))e.isEmpty()||(this.#tu.add(e),e.select());this.#tI({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#tu)t.commit();this.#tz(this.#R.values())}unselectAll(){if(!this.#P||(this.#P.commitOrRemove(),this.#tc===d.NONE)){if(!this.#H?.commitOrRemove()&&this.hasSelection){for(let t of this.#tu)t.unselect();this.#tu.clear(),this.#tI({hasSelectedEditor:!1})}}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#ty[0]+=t,this.#ty[1]+=e;let[s,r]=this.#ty,n=[...this.#tu];for(let i of(this.#tA&&clearTimeout(this.#tA),this.#tA=setTimeout(()=>{this.#tA=null,this.#ty[0]=this.#ty[1]=0,this.addCommands({cmd:()=>{for(let t of n)this.#R.has(t.id)&&(t.translateInPage(s,r),t.translationDone())},undo:()=>{for(let t of n)this.#R.has(t.id)&&(t.translateInPage(-s,-r),t.translationDone())},mustExec:!1})},1e3),n))i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection)for(let t of(this.disableUserSelect(!0),this.#G=new Map,this.#tu))this.#G.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#G)return!1;this.disableUserSelect(!1);let t=this.#G;this.#G=null;let e=!1;for(let[{x:i,y:s,pageIndex:r},n]of t)n.newX=i,n.newY=s,n.newPageIndex=r,e||=i!==n.savedX||s!==n.savedY||r!==n.savedPageIndex;if(!e)return!1;let i=(t,e,i,s)=>{if(this.#R.has(t.id)){let r=this.#L.get(s);r?t._setParentAndPosition(r,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:s,newY:r,newPageIndex:n}]of t)i(e,s,r,n)},undo:()=>{for(let[e,{savedX:s,savedY:r,savedPageIndex:n}]of t)i(e,s,r,n)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#G)for(let i of this.#G.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){let e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#tu.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#P===t}getActive(){return this.#P}getMode(){return this.#tc}isEditingMode(){return this.#tc!==d.NONE}get imageManager(){return S(this,"imageManager",new tM)}getSelectionBoxes(t){let e;if(!t)return null;let i=document.getSelection();for(let e=0,s=i.rangeCount;e<s;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;let{x:s,y:r,width:n,height:a}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":e=(t,e,i,o)=>({x:(e-r)/a,y:1-(t+i-s)/n,width:o/a,height:i/n});break;case"180":e=(t,e,i,o)=>({x:1-(t+i-s)/n,y:1-(e+o-r)/a,width:i/n,height:o/a});break;case"270":e=(t,e,i,o)=>({x:1-(e+o-r)/a,y:(t-s)/n,width:o/a,height:i/n});break;default:e=(t,e,i,o)=>({x:(t-s)/n,y:(e-r)/a,width:i/n,height:o/a})}let o=[];for(let t=0,s=i.rangeCount;t<s;t++){let s=i.getRangeAt(t);if(!s.collapsed)for(let{x:t,y:i,width:r,height:n}of s.getClientRects())0!==r&&0!==n&&o.push(e(t,i,r,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#N||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#N?.delete(t)}renderAnnotationElement(t){let e=this.#N?.get(t.data.id);if(!e)return;let i=this.#B.getRawValue(e);!i||(this.#tc!==d.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){let s=this.#th?.get(t);s&&(s.setCanvas(e,i),this.#th.delete(t))}addMissingCanvas(t,e){(this.#th||=new Map).set(t,e)}}class tR{#o=null;#tW=!1;#tq=null;#tX=null;#tK=null;#tY=null;#tQ=!1;#tJ=null;#n=null;#tZ=null;#t0=null;#t1=!1;static #t2=null;static _l10n=null;constructor(t){this.#n=t,this.#t1=t._uiManager.useNewAltTextFlow,tR.#t2||=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){tR._l10n??=t}async render(){let t=this.#tq=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#tX=document.createElement("span");t.append(e),this.#t1?(t.classList.add("new"),t.setAttribute("data-l10n-id",tR.#t2.missing),e.setAttribute("data-l10n-id",tR.#t2["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#n._uiManager._signal;t.addEventListener("contextmenu",tr,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=t=>{t.preventDefault(),this.#n._uiManager.editAltText(this.#n),this.#t1&&this.#n._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#t3}})};
2return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#tQ=!0,s(e))},{signal:i}),await this.#t5(),t}get #t3(){return this.#o&&"added"||null===this.#o&&this.guessedText&&"review"||"missing"}finish(){this.#tq&&(this.#tq.focus({focusVisible:this.#tQ}),this.#tQ=!1)}isEmpty(){return this.#t1?null===this.#o:!this.#o&&!this.#tW}hasData(){return this.#t1?null!==this.#o||!!this.#tZ:this.isEmpty()}get guessedText(){return this.#tZ}async setGuessedText(t){null===this.#o&&(this.#tZ=t,this.#t0=await tR._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#t5())}toggleAltTextBadge(t=!1){if(!this.#t1||this.#o){this.#tJ?.remove(),this.#tJ=null;return}if(!this.#tJ){let t=this.#tJ=document.createElement("div");t.className="noAltTextBadge",this.#n.div.append(t)}this.#tJ.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#tZ!==e||(e=this.#t0),{altText:e,decorative:this.#tW,guessedText:this.#tZ,textWithDisclaimer:this.#t0}}get data(){return{altText:this.#o,decorative:this.#tW}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:r=!1}){i&&(this.#tZ=i,this.#t0=s),(this.#o!==t||this.#tW!==e)&&(r||(this.#o=t,this.#tW=e),this.#t5())}toggle(t=!1){this.#tq&&(!t&&this.#tY&&(clearTimeout(this.#tY),this.#tY=null),this.#tq.disabled=!t)}shown(){this.#n._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#t3}})}destroy(){this.#tq?.remove(),this.#tq=null,this.#tX=null,this.#tK=null,this.#tJ?.remove(),this.#tJ=null}async #t5(){let t=this.#tq;if(!t)return;if(this.#t1){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",tR.#t2[this.#t3]),this.#tX?.setAttribute("data-l10n-id",tR.#t2[`${this.#t3}-label`]),!this.#o)return void this.#tK?.remove()}else{if(!this.#o&&!this.#tW){t.classList.remove("done"),this.#tK?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#tK;if(!e){this.#tK=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#n.id}`;let i=this.#n._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#tY),this.#tY=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#tY=setTimeout(()=>{this.#tY=null,this.#tK.classList.add("show"),this.#n._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#tY&&(clearTimeout(this.#tY),this.#tY=null),this.#tK?.classList.remove("show")},{signal:i})}this.#tW?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);let i=this.#n.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class tL{#t4=null;#t6=null;#t8=!1;#n=null;#t7=null;#t9=null;#et=null;#ee=null;#ei=!1;#es=null;constructor(t){this.#n=t}renderForToolbar(){let t=this.#t6=document.createElement("button");return t.className="comment",this.#v(t,!1)}renderForStandalone(){let t=this.#t4=document.createElement("button");t.className="annotationCommentButton";let e=this.#n.commentButtonPosition;if(e){let{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#n._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let s=this.#n.commentButtonColor;s&&(i.backgroundColor=s)}return this.#v(t,!0)}focusButton(){setTimeout(()=>{(this.#t4??this.#t6)?.focus()},0)}onUpdatedColor(){if(!this.#t4)return;let t=this.#n.commentButtonColor;t&&(this.#t4.style.backgroundColor=t),this.#n._uiManager.updatePopupColor(this.#n)}get commentButtonWidth(){return(this.#t4?.getBoundingClientRect().width??0)/this.#n.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#es)return this.#es;if(!this.#t4)return null;let{x:t,y:e,height:i}=this.#t4.getBoundingClientRect(),{x:s,y:r,width:n,height:a}=this.#n.parent.boundingClientRect;return[(t-s)/n,(e+i-r)/a]}set commentPopupPositionInLayer(t){this.#es=t}hasDefaultPopupPosition(){return null===this.#es}removeStandaloneCommentButton(){this.#t4?.remove(),this.#t4=null}removeToolbarCommentButton(){this.#t6?.remove(),this.#t6=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t4&&(this.#t4.classList.toggle("selected",t),this.#t4.ariaExpanded=e)}#v(t,e){if(!this.#n._uiManager.hasCommentManager())return null;
vendor: 8,194 bytes, line 2
2t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#n._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));let i=this.#n._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",tr,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#n._focusEventsAllowed=!1,tn(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#n._focusEventsAllowed=!0,tn(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=e=>{e.preventDefault(),t===this.#t6?this.edit():this.#n.toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#t8=!0,s(e))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#n.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#n.toggleComment(!1,!1)},{signal:i}),t}edit(t){let e,i,s=this.commentPopupPositionInLayer;if(s)[e,i]=s;else{[e,i]=this.#n.commentButtonPosition;let{width:t,height:s,x:r,y:n}=this.#n;e=r+e*t,i=n+i*s}let r=this.#n.parent.boundingClientRect,{x:n,y:a,width:o,height:l}=r;this.#n._uiManager.editComment(this.#n,n+e*o,a+i*l,{...t,parentDimensions:r})}finish(){this.#t6&&(this.#t6.focus({focusVisible:this.#t8}),this.#t8=!1)}isDeleted(){return this.#ei||""===this.#et}isEmpty(){return null===this.#et}hasBeenEdited(){return this.isDeleted()||this.#et!==this.#t7}serialize(){return this.data}get data(){return{text:this.#et,richText:this.#t9,date:this.#ee,deleted:this.isDeleted()}}set data(t){if(t!==this.#et&&(this.#t9=null),null===t){this.#et="",this.#ei=!0;return}this.#et=t,this.#ee=new Date,this.#ei=!1}setInitialText(t,e=null){this.#t7=t,this.data=t,this.#ee=null,this.#t9=e}shown(){}destroy(){this.#t6?.remove(),this.#t6=null,this.#t4?.remove(),this.#t4=null,this.#et="",this.#t9=null,this.#ee=null,this.#n=null,this.#t8=!1,this.#ei=!1}}class tF{#tw;#er=!1;#en=null;#ea;#eo;#el;#eh;#ed=null;#ec;#eu=null;#ep;#eg=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:r=null,onPinchEnd:n=null,signal:a}){this.#tw=t,this.#en=i,this.#ea=e,this.#eo=s,this.#el=r,this.#eh=n,this.#ep=new AbortController,this.#ec=AbortSignal.any([a,this.#ep.signal]),t.addEventListener("touchstart",this.#em.bind(this),{passive:!1,signal:this.#ec})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/tu.pixelRatio}#em(t){if(this.#ea?.())return;if(1===t.touches.length){if(this.#ed)return;let t=this.#ed=new AbortController,e=AbortSignal.any([this.#ec,t.signal]),i=this.#tw,s={capture:!0,signal:e,passive:!1},r=t=>{"touch"===t.pointerType&&(this.#ed?.abort(),this.#ed=null)};i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(tn(t),r(t))},s),i.addEventListener("pointerup",r,s),i.addEventListener("pointercancel",r,s);return}if(!this.#eg){this.#eg=new AbortController;let t=AbortSignal.any([this.#ec,this.#eg.signal]),e=this.#tw,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#ef.bind(this),i);let s=this.#eb.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",tn,i),e.addEventListener("pointermove",tn,i),e.addEventListener("pointercancel",tn,i),e.addEventListener("pointerup",tn,i),this.#eo?.()}if(tn(t),2!==t.touches.length||this.#en?.()){this.#eu=null;return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#eu={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#ef(t){if(!this.#eu||2!==t.touches.length)return;tn(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);let{screenX:s,screenY:r}=e,{screenX:n,screenY:a}=i,o=this.#eu,{touch0X:l,touch0Y:h,touch1X:d,touch1Y:c}=o,u=Math.hypot(n-s,a-r)||1,p=Math.hypot(d-l,c-h)||1;if(!this.#er&&Math.abs(p-u)<=tF.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=r,o.touch1X=n,o.touch1Y=a,!this.#er){this.#er=!0;return}let g=[(s+n)/2,(r+a)/2];this.#el?.(g,p,u)}#eb(t){t.touches.length>=2||(this.#eg&&(this.#eg.abort(),this.#eg=null,this.#eh?.()),this.#eu&&(tn(t),this.#eu=null,this.#er=!1))}destroy(){this.#ep?.abort(),this.#ep=null,this.#ed?.abort(),this.#ed=null}}class tB{#ev=null;#ey=null;#o=null;#l=null;#t4=null;#eA=!1;#ew=null;#ex="";#e_=null;#eC=null;#eS=null;#eE=null;#eT=null;#eM="";#eD=!1;#ek=null;#eP=!1;#eI=!1;#eR=!1;#eL=null;#eF=0;#eB=0;#eN=null;#eO=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#eU=!1;#ez=tB._zIndex++;static _borderLineWidth=-1;static _colorManager=new tP;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=tB.prototype._resizeWithKeyboard,e=tI.TRANSLATE_SMALL,i=tI.TRANSLATE_BIG;return S(this,"_resizerKeyboardManager",new tk([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],tB.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;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:r,pageY:n}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[r,n];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}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 S(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new tN({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(tB._l10n??=t,tB._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"}),-1!==tB._borderLineWidth)return;let i=getComputedStyle(document.documentElement);tB._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.#eU}set _isDraggable(t){this.#eU=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
vendor: 4,730 bytes, line 2
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#ez}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#eH(),this.#eE?.remove(),this.#eE=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#eD?this.#eD=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let e=t.relatedTarget;!e?.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){let[r,n]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/r,this.y=(e+s)/n,this.fixAndSetPosition()}_moveAfterPaste(t,e){let[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#e$([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.#e$(this.parentDimensions,t,e)}translateInPage(t,e){this.#ek||=[this.x,this.y,this.width,this.height],this.#e$(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#ek||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[s,r]}=this;if(this.x+=t/s,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this,[o,l]=this.getBaseTranslation();n+=o,a+=l;let{style:h}=i;h.left=`${(100*n).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(n,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#ek&&(this.#ek[0]!==this.x||this.#ek[1]!==this.y)}get _hasBeenResized(){return!!this.#ek&&(this.#ek[2]!==this.width||this.#ek[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=tB,s=i/t,r=i/e;switch(this.rotation){case 90:return[-s,r];case 180:return[s,r];case 270:return[s,-r];default:return[-s,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[i,s]}=this,{x:r,y:n,width:a,height:o}=this;if(a*=i,o*=s,r*=i,n*=s,this._mustFixPosition)switch(t){case 0:r=j(r,0,i-a),n=j(n,0,s-o);break;case 90:r=j(r,0,i-o),n=j(n,a,s);break;case 180:r=j(r,a,i),n=j(n,o,s);break;case 270:r=j(r,o,i),n=j(n,0,s-a)}this.x=r/=i,this.y=n/=s;let[l,h]=this.getBaseTranslation();r+=l,n+=h,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static #ej(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 tB.#ej(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return tB.#ej(t,e,360-this.parentRotation)}#eG(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){let{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#eV(){if(this.#e_)return;this.#e_=document.createElement("div"),this.#e_.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#e_.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#eW.bind(this,i),{signal:e}),t.addEventListener("contextmenu",tr,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#e_)}#eW(t,e){e.preventDefault();let{isMac:i}=F.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#eC=[e.screenX,e.screenY];let r=new AbortController,n=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#eq.bind(this,t),{passive:!0,capture:!0,signal:n}),window.addEventListener("touchmove",tn,{passive:!1,signal:n}),window.addEventListener("contextmenu",tr,{signal:n}
2),this.#eS={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#eX()};window.addEventListener("pointerup",l,{signal:n}),window.addEventListener("blur",l,{signal:n})}#eK(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#eX(){if(!this.#eS)return;let{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#eS;this.#eS=null;let r=this.x,n=this.y,a=this.width,o=this.height;(r!==t||n!==e||a!==i||o!==s)&&this.addCommands({cmd:this.#eK.bind(this,r,n,a,o),undo:this.#eK.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#eq(t,e){let i,s,r,n,a,o,[l,h]=this.parentDimensions,d=this.x,c=this.y,u=this.width,p=this.height,g=tB.MIN_SIZE/l,m=tB.MIN_SIZE/h,f=this.#eG(this.rotation),b=(t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e],v=this.#eG(360-this.rotation),y=!1,A=!1;switch(t){case"topLeft":y=!0,i=(t,e)=>[0,0],s=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],s=(t,e)=>[t/2,e];break;case"topRight":y=!0,i=(t,e)=>[t,0],s=(t,e)=>[0,e];break;case"middleRight":A=!0,i=(t,e)=>[t,e/2],s=(t,e)=>[0,e/2];break;case"bottomRight":y=!0,i=(t,e)=>[t,e],s=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],s=(t,e)=>[t/2,0];break;case"bottomLeft":y=!0,i=(t,e)=>[0,e],s=(t,e)=>[t,0];break;case"middleLeft":A=!0,i=(t,e)=>[0,e/2],s=(t,e)=>[t,e/2]}let w=i(u,p),x=s(u,p),_=b(...x),C=tB._round(d+_[0]),S=tB._round(c+_[1]),E=1,T=1;if(e.fromKeyboard)({deltaX:r,deltaY:n}=e);else{let{screenX:t,screenY:i}=e,[s,a]=this.#eC;[r,n]=this.screenToPageTranslation(t-s,i-a),this.#eC[0]=t,this.#eC[1]=i}if([r,n]=(a=r/l,o=n/h,[v[0]*a+v[2]*o,v[1]*a+v[3]*o]),y){let t=Math.hypot(u,p);E=T=Math.max(Math.min(Math.hypot(x[0]-w[0]-r,x[1]-w[1]-n)/t,1/u,1/p),g/u,m/p)}else A?E=j(Math.abs(x[0]-w[0]-r),g,1)/u:T=j(Math.abs(x[1]-w[1]-n),m,1)/p;let M=tB._round(u*E),D=tB._round(p*T),k=C-(_=b(...s(M,D)))[0],P=S-_[1];this.#ek||=[this.x,this.y,this.width,this.height],this.width=M,this.height=D,this.x=k,this.y=P,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#eI)return this._editToolbar;this._editToolbar=new tC(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[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.#o?.destroy()}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return!this.#o&&(tR.initialize(tB._l10n),this.#o=new tR(this),this.#ev&&(this.#o.data=this.#ev,this.#ev=null)),this.#o}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await this.#o?.setGuessedText(t)}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}focusCommentButton(){this.#l?.focusButton()}addCommentButton(){return this.#l||=new tL(this)}addStandaloneCommentButton(){if(this.#t4){this._uiManager.isEditingMode()&&this.#t4.classList.remove("hidden");return}this.hasComment&&(this.#t4=this.#l.renderForStandalone(),this.div.append(this.#t4))}removeStandaloneCommentButton(){this.#l.removeStandaloneCommentButton(),this.#t4=null}hideStandaloneCommentButton(){this.#t4?.classList.add("hidden")}get comment(){let{data:{richText:t,text:e,date:i,deleted:s}}=this.#l;return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#l||=new tL(this),this.#l.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.#l||=new tL(this),this.#l.setInitialText(t,i),!this.annotationElementId))return;let s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return this.#l?.hasBeenEdited()}get hasDeletedComment(){return this.#l?.isDeleted()}get hasComment(){return!!this.#l&&!this.#l.isEmpty()&&!this.#l.isDeleted()}async editComment(t){this.#l||=new tL(this),this.#l.edit(t)}toggleComment(t,e){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#l.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,e]=t.rect,[i]=this.pageDimensions,[s]=this.pageTranslation,r=s+i+1;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[r,e-100,r+180,e]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#l.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#eA?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#eY();let[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);let[s,r]=this.getInitialTranslation();return this.translate(s,r),tE(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#eO||=new tF({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#eQ.bind(this),onPinching:this.#eJ.bind(this),onPinchEnd:this.#eZ.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}
2#eQ(){this.#eS={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#eJ(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;let r=this.#eG(this.rotation),n=(t,e)=>[r[0]*t+r[2]*e,r[1]*t+r[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height;s=Math.max(Math.min(s,1/d,1/c),tB.MIN_SIZE/a/d,tB.MIN_SIZE/o/c);let u=tB._round(d*s),p=tB._round(c*s);if(u===d&&p===c)return;this.#ek||=[l,h,d,c];let g=n(d/2,c/2),m=tB._round(l+g[0]),f=tB._round(h+g[1]),b=n(u/2,p/2);this.x=m-b[0],this.y=f-b[1],this.width=u,this.height=p,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#eZ(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#eX()}pointerdown(t){let{isMac:e}=F.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#eD=!0,this._isDraggable)?this.#e0(t):this.#e1(t)}#e1(t){let{isMac:e}=F.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#e0(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1,s=new AbortController,r=this._uiManager.combinedSignal(s),n={capture:!0,passive:!1,signal:r},a=t=>{s.abort(),this.#ew=null,this.#eD=!1,this._uiManager.endDragSession()||this.#e1(t),i&&this._onStopDragging()};e&&(this.#eF=t.clientX,this.#eB=t.clientY,this.#ew=t.pointerId,this.#ex=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:e,clientY:s,pointerId:r}=t;if(r!==this.#ew)return void tn(t);let[n,a]=this.screenToPageTranslation(e-this.#eF,s-this.#eB);this.#eF=e,this.#eB=s,this._uiManager.dragSelectedEditors(n,a)},n),window.addEventListener("touchmove",tn,n),window.addEventListener("pointerdown",t=>{t.pointerType===this.#ex&&(this.#eO||t.isPrimary)&&a(t),tn(t)},n));let o=t=>{this.#ew&&this.#ew!==t.pointerId?tn(t):a(t)};window.addEventListener("pointerup",o,{signal:r}),window.addEventListener("blur",o,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#eL&&clearTimeout(this.#eL),this.#eL=setTimeout(()=>{this.#eL=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){let s=this.parentScale,[r,n]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*r,c=this.y*n,u=this.width*r,p=this.height*n;switch(i){case 0:return[d+l+a,n-c-h-p+o,d+l+u+a,n-c-h+o];case 90:return[d+h+a,n-c+l+o,d+h+p+a,n-c+l+u+o];case 180:return[d-l-u+a,n-c+h+o,d-l+a,n-c+h+p+o];case 270:return[d-h-p+a,n-c-l-u+o,d-h+a,n-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,s,r,n]=t,a=r-i,o=n-s;switch(this.rotation){case 0:return[i,e-n,a,o];case 90:return[i,e-s,o,a];case 180:return[r,e-s,a,o];case 270:return[r,e-n,o,a];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&tB._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#l?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:i,opacity:s,deleted:r,richText:n},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:n,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!r,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#eI=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#eI=!1,!0)}isInEditMode(){return this.#eI}shouldGetKeyboardEvents(){return this.#eR}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:r,innerWidth:n}=window;return e<n&&s>0&&t<r&&i>0}#eY(){if(this.#eT||!this.div)return;this.#eT=new AbortController;let t=this._uiManager.combinedSignal(this.#eT);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#eY()}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){let s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,s.#ev=t.accessibilityData,s._isCopy=t.isCopy||!1;let[r,n]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,n);return s.x=a/r,s.y=o/n,s.width=l/r,s.height=h/n,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#eT?.abort(),this.#eT=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#eL&&(clearTimeout(this.#eL),this.#eL=null),this.#eH(),this.removeEditToolbar(),this.#eN){for(let t of this.#eN.values())clearTimeout(t);this.#eN=null}this.parent=null,this.#eO?.destroy(),this.#eO=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#eV(),this.#e_.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[i,s,r,n]=this.getPDFRect();return[tB._round(i+(r-i)*t),tB._round(s+(n-s)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#l.commentPopupPositionInLayer}set commentPopupPosition(t){this.#l.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#l.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#l.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#l.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;
2this._uiManager.setSelected(this),this.#eS={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#e_.children;if(!this.#ey){this.#ey=Array.from(e);let t=this.#e2.bind(this),i=this.#e3.bind(this),s=this._uiManager._signal;for(let e of this.#ey){let r=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#e5.bind(this,r),{signal:s}),e.setAttribute("data-l10n-id",tB._l10nResizer[r])}}let i=this.#ey[0],s=0;for(let t of e){if(t===i)break;s++}let r=(360-this.rotation+this.parentRotation)%360/90*(this.#ey.length/4);if(r!==s){if(r<s)for(let t=0;t<s-r;t++)this.#e_.append(this.#e_.firstChild);else if(r>s)for(let t=0;t<r-s;t++)this.#e_.firstChild.before(this.#e_.lastChild);let t=0;for(let i of e){let e=this.#ey[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",tB._l10nResizer[e])}}this.#e4(0),this.#eR=!0,this.#e_.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#e2(t){tB._resizerKeyboardManager.exec(this,t)}#e3(t){this.#eR&&t.relatedTarget?.parentNode!==this.#e_&&this.#eH()}#e5(t){this.#eM=this.#eR?t:""}#e4(t){if(this.#ey)for(let e of this.#ey)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#eR&&this.#eq(this.#eM,{deltaX:t,deltaY:e,fromKeyboard:!0})}#eH(){this.#eR=!1,this.#e4(-1),this.#eX()}_stopResizingWithKeyboard(){this.#eH(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar)?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#e_?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#eP}set isEditing(t){this.#eP=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.#eN||=new Map;let{action:e}=t,i=this.#eN.get(e);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#eN.delete(e),0===this.#eN.size&&(this.#eN=null)},tB._telemetryTimeout),this.#eN.set(e,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#eA=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#eA=!0}updateFakeAnnotationElement(t){if(!this.#eE&&!this.deleted){this.#eE=t.addFakeAnnotation(this);return}if(this.deleted){this.#eE.remove(),this.#eE=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#eE.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class tN extends tB{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}
2serialize(){return this.serializeDeleted()}}class tO{constructor(t){this.h1=t?0|t:0xc3d2e1f0,this.h2=t?0|t:0xc3d2e1f0}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,r=t.length;s<r;s++){let r=t.charCodeAt(s);r<=255?e[i++]=r:(e[i++]=r>>>8,e[i++]=255&r)}}else if(ArrayBuffer.isView(t))i=(e=t.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let s=i>>2,r=i-4*s,n=new Uint32Array(e.buffer,0,s),a=0,o=0,l=this.h1,h=this.h2;for(let t=0;t<s;t++)1&t?(l^=a=0x1b873593*(a=(a=0xcc9e2d51*(a=n[t])&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(h^=o=0x1b873593*(o=(o=0xcc9e2d51*(o=n[t])&0xffff0000|11601*o&65535)<<15|o>>>17)&0xffff0000|13715*o&65535,h=5*(h=h<<13|h>>>19)+0xe6546b64);switch(a=0,r){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=0x1b873593*(a=(a=0xcc9e2d51*a&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,e=0xff51afd7*e&0xffff0000|((e<<16|(t=0xed558ccd*t&0xffff0000|36045*t&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,t^=e>>>1,e=0xc4ceb9fe*e&0xffff0000|((e<<16|(t=0x1a85ec53*t&0xffff0000|60499*t&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((t^=e>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}let tU=Object.freeze({map:null,hash:"",transfer:void 0});class tz{#e6=!1;#e8=null;#e7=null;#e9=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let i=this.#e9.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#e9.get(t)}remove(t){let e=this.#e9.get(t);if(void 0!==e&&(e instanceof tB&&this.#e7.delete(e.annotationElementId),this.#e9.delete(t),0===this.#e9.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor)){for(let t of this.#e9.values())if(t instanceof tB)return;this.onAnnotationEditor(null)}}setValue(t,e){let i=this.#e9.get(t),s=!1;if(void 0!==i)for(let[t,r]of Object.entries(e))i[t]!==r&&(s=!0,i[t]=r);else s=!0,this.#e9.set(t,e);s&&this.#it(),e instanceof tB&&((this.#e7||=new Map).set(e.annotationElementId,e),"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type))}has(t){return this.#e9.has(t)}get size(){return this.#e9.size}#it(){this.#e6||(this.#e6=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#e6&&(this.#e6=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new tH(this)}get serializable(){if(0===this.#e9.size)return tU;let t=new Map,e=new tO,i=[],s=Object.create(null),r=!1;for(let[i,n]of this.#e9){let a=n instanceof tB?n.serialize(!1,s):n;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),r||=!!a.bitmap)}if(r)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:tU}get editorStats(){let t=null,e=new Map,i=0,s=0;for(let r of this.#e9.values()){if(!(r instanceof tB)){r.popup&&(r.popup.deleted?s+=1:i+=1);continue}r.isCommentDeleted?s+=1:r.hasEditedComment&&(i+=1);let n=r.telemetryFinalData;if(!n)continue;let{type:a}=n;e.has(a)||e.set(a,Object.getPrototypeOf(r).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[t,e]of Object.entries(n)){if("type"===t)continue;let i=o.get(t);i||(i=new Map,o.set(t,i));let s=i.get(e)??0;i.set(e,s+1)}}if((s>0||i>0)&&((t||=Object.create(null)).comments={deleted:s,edited:i}),!t)return null;for(let[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#e8=null}updateEditor(t,e){let i=this.#e7?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#e7?.get(t)||null}get modifiedIds(){if(this.#e8)return this.#e8;let t=[];if(this.#e7)for(let e of this.#e7.values())e.serialize()&&t.push(e.annotationElementId);return this.#e8={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#e9.entries()}}class tH extends tz{#ie;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,r=structuredClone(e,s?{transfer:s}:null);this.#ie={map:r,hash:i,transfer:s}}get print(){w("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ie}get modifiedIds(){return S(this,"modifiedIds",{ids:new Set,hash:""})}}class t${#ii=new Set;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){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ii.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}
2){if(!(!t||this.#ii.has(t.loadedName))){if(x(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:e,src:s,style:r}=t,n=new FontFace(e,s,r);this.addNativeFontFace(n);try{await n.load(),this.#ii.add(e),i?.(t)}catch{A(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(n)}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)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw A(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return S(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return S(this,"isSyncFontLoadingSupported",a||F.platform.isFirefox)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(x(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;)setTimeout(e.shift().callback,0)},callback:t};return e.push(i),i}get _loadTestFont(){return S(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){var i;let s,r;function n(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function a(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,d=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont,u=n(c=a(c,976,d.length,d),16);for(s=0,r=d.length-3;s<r;s+=4)u=u-0x58585858+n(d,s)|0;s<d.length&&(u=u-0x58585858+n(d+"XXX",s)|0),c=a(c,16,4,String.fromCharCode((i=u)>>24&255,i>>16&255,i>>8&255,255&i));let p=`url(data:font/opentype;base64,${btoa(c)});`,g=`@font-face {font-family:"${d}";src:${p}}`;this.insertRule(g);let m=this._document.createElement("div");for(let e of(m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px",[t.loadedName,d])){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++h>30){A("Load test font never loaded."),i();return}(l.font="30px "+e,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0)?i():setTimeout(t.bind(null,e,i))}(d,()=>{m.remove(),e.complete()})}}class tj{#is;constructor(t,e=null,i,s){this.compiledGlyphs=Object.create(null),this.#is=t,this._inspectFont=e,i&&Object.assign(this,i),s&&(this.charProcOperatorList=s)}createNativeFontFace(){let t;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){let t;if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${G(this.data)});`;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),t}getPathGenerator(t,e){let i;if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e;try{i=t.get(s)}catch(t){A(`getPathGenerator - ignoring character: "${t}".`)}let r=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return this.#is.black}get bold(){return this.#is.bold}get disableFontFace(){return this.#is.disableFontFace??!1}get fontExtraProperties(){return this.#is.fontExtraProperties??!1}get isInvalidPDFjsFont(){return this.#is.isInvalidPDFjsFont}get isType3Font(){return this.#is.isType3Font}get italic(){return this.#is.italic}get missingFile(){return this.#is.missingFile}get remeasure(){return this.#is.remeasure}get vertical(){return this.#is.vertical}get ascent(){return this.#is.ascent}get defaultWidth(){return this.#is.defaultWidth}get descent(){return this.#is.descent}get bbox(){return this.#is.bbox}get fontMatrix(){return this.#is.fontMatrix}get fallbackName(){return this.#is.fallbackName}get loadedName(){return this.#is.loadedName}get mimetype(){return this.#is.mimetype}get name(){return this.#is.name}get data(){return this.#is.data}clearData(){this.#is.clearData()}get cssFontInfo(){return this.#is.cssFontInfo}get systemFontInfo(){return this.#is.systemFontInfo}get defaultVMetrics(){return this.#is.defaultVMetrics}}function tG(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}let tV=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>
2=0,tW=(function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;let[s,r,...n]=i;if(!t(s)&&!Number.isInteger(s)||!e(r))return!1;let a=n.length,o=!0;switch(r.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(let t of n)if("number"!=typeof t&&(!o||null!==t))return!1;return!0}).bind(null,tV,t=>"object"==typeof t&&"string"==typeof t?.name);class tq{#ir=new Map;#ia=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#ia.then(()=>{for(let[t]of this.#ir)t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:r}=i;if(r.aborted)return void A("LoopbackPort - cannot use an `aborted` signal.");let n=()=>this.removeEventListener(t,e);s=()=>r.removeEventListener("abort",n),r.addEventListener("abort",n)}this.#ir.set(e,s)}removeEventListener(t,e){let i=this.#ir.get(e);i?.(),this.#ir.delete(e)}terminate(){for(let[,t]of this.#ir)t?.();this.#ir.clear()}}function tX(){}function tK(t){if(t instanceof I||t instanceof D||t instanceof T||t instanceof k||t instanceof M)return t;switch(!(t instanceof Error||"object"==typeof t&&null!==t)&&w('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new I(t.message);case"InvalidPDFException":return new D(t.message);case"PasswordException":return new T(t.message,t.code);case"ResponseException":return new k(t.message,t.status,t.missing);case"UnknownErrorException":return new M(t.message,t.details)}return new M(t.message,t.toString())}class tY{#io=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.#il.bind(this),{signal:this.#io.signal})}#il({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ih(t);if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else if(2===t.callback)i.reject(tK(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let i=this.sourceName,s=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(e){r.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})},function(e){r.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:tK(e)})});return}t.streamId?this.#id(t):e(t.data)}on(t,e){let i=this.actionHandler;if(i[t])throw 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)}sendWithPromise(t,e,i){let s=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[s]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){r.reject(t)}return r.promise}sendWithStream(t,e,i,s){let r=this.streamId++,n=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[r]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:n,targetName:a,action:t,streamId:r,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[r].pullCall=e,o.postMessage({sourceName:n,targetName:a,stream:6,streamId:r,desiredSize:t.desiredSize}),e.promise},cancel:t=>{x(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[r].cancelCall=e,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:n,targetName:a,stream:1,streamId:r,reason:tK(t)}),e.promise}},i)}#id(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,n=this,a=this.actionHandler[t.action],o={enqueue(t,n=1,a){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=n,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:i,targetName:s,stream:4,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:3,streamId:e}),delete n.streamSinks[e])},error(t){x(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:5,streamId:e,reason:tK(t)}))},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(){r.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,reason:tK(t)})})}#ih(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,n=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case 8:t.success?n.startCall.resolve():n.startCall.reject(tK(t.reason));break;case 7:t.success?n.pullCall.resolve():n.pullCall.reject(tK(t.reason));break;case 6:if(!a){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||tX).then(function(){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,reason:tK(t)})});break;case 4:if(x(n,"enqueue should have stream controller"),n.isClosed)break;n.controller.enqueue(t.chunk);break;case 3:if(x(n,"close should have stream controller"),n.isClosed)break;n.isClosed=!0,n.controller.close(),this.#ic(n,e);break;case 5:x(n,"error should have stream controller"),n.controller.error(tK(t.reason)),this.#ic(n,e);break;case 2:t.success?n.cancelCall.resolve():n.cancelCall.reject(tK(t.reason)),this.#ic(n,e);break;case 1:if(!a)break;let o=tK(t.reason);Promise.try(a.onCancel||tX,o).then(function(){r.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,reason:tK(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async #ic(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#io?.abort(),this.#io=null}}class tQ{#iu=!1;constructor({enableHWA:t=!1}){this.#iu=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#iu})}}reset(t,e,i){if(!t.canvas)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){w("Abstract method `_createCanvas` called.")}}class tJ extends tQ{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class tZ{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){w("Abstract method `_fetch` called.")}}class t0 extends tZ{async _fetch(t){let e=await K(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):L(e)}}class t1{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,r){return"none"}destroy(t=!1){}}class t2 extends t1{#ip;#ig;#im;#ib;#iv;#iy;#w=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ib=t,this.#iv=e}get #_(){return this.#ig||=new Map}get #iA(){return this.#iy||=new Map}get #iw(){if(!this.#im){let t=this.#iv.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let i=this.#iv.createElementNS(q,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#im=this.#iv.createElementNS(q,"defs"),t.append(i),i.append(this.#im),this.#iv.body.append(t)}return this.#im}#ix(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let s=i.join(",");return[s,s,s]}let[e,i,s]=t,r=Array(256),n=Array(256),a=Array(256);for(let t=0;t<256;t++)r[t]=e[t]/255,n[t]=i[t]/255,a[t]=s[t]/255;return[r.join(","),n.join(","),a.join(",")]}#i_(t){if(void 0===this.#ip){this.#ip="";
2let t=this.#iv.URL;t!==this.#iv.baseURI&&(J(t)?A('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ip=C(t,""))}return`url(${this.#ip}#${t})`}addFilter(t){if(!t)return"none";let e=this.#_.get(t);if(e)return e;let[i,s,r]=this.#ix(t),n=1===t.length?i:`${i}${s}${r}`;if(e=this.#_.get(n))return this.#_.set(t,e),e;let a=`g_${this.#ib}_transfer_map_${this.#w++}`,o=this.#i_(a);this.#_.set(t,o),this.#_.set(n,o);let l=this.#iC(a);return this.#iS(i,s,r,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,s="base",r=this.#iA.get(s);if(r?.key===i||(r?(r.filter?.remove(),r.key=i,r.url="none",r.filter=null):(r={key:i,url:"none",filter:null},this.#iA.set(s,r)),!t||!e))return r.url;let n=this.#iE(t);t=N.makeHexColor(...n);let a=this.#iE(e);if(e=N.makeHexColor(...a),this.#iw.style.color="","#000000"===t&&"#ffffff"===e||t===e)return r.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#ib}_hcm_filter`,d=r.filter=this.#iC(h);this.#iS(l,l,l,d),this.#iT(d);let c=(t,e)=>{let i=n[t]/255,s=a[t]/255,r=Array(e+1);for(let t=0;t<=e;t++)r[t]=i+t/e*(s-i);return r.join(",")};return this.#iS(c(0,5),c(1,5),c(2,5),d),r.url=this.#i_(h),r.url}addAlphaFilter(t){let e=this.#_.get(t);if(e)return e;let[i]=this.#ix([t]),s=`alpha_${i}`;if(e=this.#_.get(s))return this.#_.set(t,e),e;let r=`g_${this.#ib}_alpha_map_${this.#w++}`,n=this.#i_(r);this.#_.set(t,n),this.#_.set(s,n);let a=this.#iC(r);return this.#iM(i,a),n}addLuminosityFilter(t){let e,i,s=this.#_.get(t||"luminosity");if(s)return s;if(t?([e]=this.#ix([t]),i=`luminosity_${e}`):i="luminosity",s=this.#_.get(i))return this.#_.set(t,s),s;let r=`g_${this.#ib}_luminosity_map_${this.#w++}`,n=this.#i_(r);this.#_.set(t,n),this.#_.set(i,n);let a=this.#iC(r);return this.#iD(a),t&&this.#iM(e,a),n}addHighlightHCMFilter(t,e,i,s,r){let n=`${e}-${i}-${s}-${r}`,a=this.#iA.get(t);if(a?.key===n||(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#iA.set(t,a)),!e||!i))return a.url;let[o,l]=[e,i].map(this.#iE.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,r].map(this.#iE.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#iw.style.color="";let p=(t,e,i)=>{let s=Array(256),r=(d-h)/i,n=t/255,a=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*r),i=n+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#ib}_hcm_${t}_filter`,m=a.filter=this.#iC(g);return this.#iT(m),this.#iS(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),m),a.url=this.#i_(g),a.url}destroy(t=!1){t&&this.#iy?.size||(this.#im?.parentNode.parentNode.remove(),this.#im=null,this.#ig?.clear(),this.#ig=null,this.#iy?.clear(),this.#iy=null,this.#w=0)}#iD(t){let e=this.#iv.createElementNS(q,"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)}#iT(t){let e=this.#iv.createElementNS(q,"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)}#iC(t){let e=this.#iv.createElementNS(q,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#iw.append(e),e}#ik(t,e,i){let s=this.#iv.createElementNS(q,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#iS(t,e,i,s){let r=this.#iv.createElementNS(q,"feComponentTransfer");
2s.append(r),this.#ik(r,"feFuncR",t),this.#ik(r,"feFuncG",e),this.#ik(r,"feFuncB",i)}#iM(t,e){let i=this.#iv.createElementNS(q,"feComponentTransfer");e.append(i),this.#ik(i,"feFuncA",t)}#iE(t){return this.#iw.style.color=t,tl(getComputedStyle(this.#iw).getPropertyValue("color"))}}class t3{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load font data at: ${e}`)})}async _fetch(t){w("Abstract method `_fetch` called.")}}class t5 extends t3{async _fetch(t){return new Uint8Array(await K(t,"arraybuffer"))}}class t4{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw Error("Wasm filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){w("Abstract method `_fetch` called.")}}class t6 extends t4{async _fetch(t){return new Uint8Array(await K(t,"arraybuffer"))}}async function t8(t){let e=s.getBuiltinModule("fs");return new Uint8Array(await e.promises.readFile(t))}a&&A("Please use the `legacy` build in Node.js environments.");class t7 extends t1{}class t9 extends tQ{_createCanvas(t,e){return s.getBuiltinModule("module").createRequire("file:///usr/src/app/node_modules/.pnpm/[email protected]/node_modules/pdfjs-dist/build/pdf.mjs")("@napi-rs/canvas").createCanvas(t,e)}}class et extends tZ{async _fetch(t){return t8(t)}}class ee extends t3{async _fetch(t){return t8(t)}}class ei extends t4{async _fetch(t){return t8(t)}}let es="__forcedDependency",{floor:er,ceil:en}=Math;function ea(t,e,i,s,r,n){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],s),t[4*e+2]=Math.max(t[4*e+2],r),t[4*e+3]=Math.max(t[4*e+3],n)}let eo=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class el{#iP;#iI;constructor(t,e){this.#iP=t,this.#iI=e}get length(){return this.#iP.length}isEmpty(t){return this.#iP[t]===eo}minX(t){return this.#iI[4*t+0]/256}minY(t){return this.#iI[4*t+1]/256}maxX(t){return(this.#iI[4*t+2]+1)/256}maxY(t){return(this.#iI[4*t+3]+1)/256}}let eh=(t,e)=>{if(!t)return;let i=t.get(e);return i||(i={dependencies:new Set,isRenderingOperation:!1},t.set(e,i)),i};class ed{#iR={__proto__:null};#iL={__proto__:null,transform:[],moveText:[],sameLineText:[],[es]:[]};#iF=new Map;#iB=[];#iN=[];#iO=[[1,0,0,1,0,0]];#iU=[-1/0,-1/0,1/0,1/0];#iz=new Float64Array([1/0,1/0,-1/0,-1/0]);#iH=-1;#i$=new Set;#ij=new Map;#iG=new Map;#iV;#iW;#iq;#iP;#iX;constructor(t,e,i=!1){this.#iV=t.width,this.#iW=t.height,this.#iK(e),i&&(this.#iX=new Map)}growOperationsCount(t){t>=this.#iP.length&&this.#iK(t,this.#iP)}#iK(t,e){let i=new ArrayBuffer(4*t);this.#iq=new Uint8ClampedArray(i),this.#iP=new Uint32Array(i),e&&e.length>0?(this.#iP.set(e),this.#iP.fill(eo,e.length)):this.#iP.fill(eo)}save(t){return this.#iR={__proto__:this.#iR},this.#iL={__proto__:this.#iL,transform:{__proto__:this.#iL.transform},moveText:{__proto__:this.#iL.moveText},sameLineText:{__proto__:this.#iL.sameLineText},[es]:{__proto__:this.#iL[es]}},this.#iU={__proto__:this.#iU},this.#iB.push(t),this}restore(t){let e=Object.getPrototypeOf(this.#iR);if(null===e)return this;this.#iR=e,this.#iL=Object.getPrototypeOf(this.#iL),this.#iU=Object.getPrototypeOf(this.#iU);let i=this.#iB.pop();return void 0!==i&&(eh(this.#iX,t)?.dependencies.add(i),this.#iP[t]=this.#iP[i]),this}recordOpenMarker(t){return this.#iB.push(t),this}getOpenMarker(){return 0===this.#iB.length?null:this.#iB.at(-1)}recordCloseMarker(t){let e=this.#iB.pop();return void 0!==e&&(eh(this.#iX,t)?.dependencies.add(e),this.#iP[t]=this.#iP[e]),this}beginMarkedContent(t){return this.#iN.push(t),this}endMarkedContent(t){let e=this.#iN.pop();return void 0!==e&&(eh(this.#iX,t)?.dependencies.add(e),this.#iP[t]=this.#iP[e]),this}pushBaseTransform(t){return this.#iO.push(N.multiplyByDOMMatrix(this.#iO.at(-1),t.getTransform())),this}popBaseTransform(){return this.#iO.length>1&&this.#iO.pop(),this}recordSimpleData(t,e){return this.#iR[t]=e,this}recordIncrementalData(t,e){return this.#iL[t].push(e),this}resetIncrementalData(t,e){return this.#iL[t].length=0,this}recordNamedData(t,e){return this.#iF.set(t,e),this}
2recordSimpleDataFromNamed(t,e,i){this.#iR[t]=this.#iF.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(es,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)e in this.#iR&&this.recordFutureForcedDependency(e,this.#iR[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#i$)this.recordFutureForcedDependency(es,t);return this}resetBBox(t){return this.#iH!==t&&(this.#iH=t,this.#iz[0]=1/0,this.#iz[1]=1/0,this.#iz[2]=-1/0,this.#iz[3]=-1/0),this}recordClipBox(t,e,i,s,r,n){let a=N.multiplyByDOMMatrix(this.#iO.at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];N.axialAlignedBoundingBox([i,r,s,n],a,o);let l=N.intersect(this.#iU,o);return l?(this.#iU[0]=l[0],this.#iU[1]=l[1],this.#iU[2]=l[2],this.#iU[3]=l[3]):(this.#iU[0]=this.#iU[1]=1/0,this.#iU[2]=this.#iU[3]=-1/0),this}recordBBox(t,e,i,s,r,n){let a=this.#iU;if(a[0]===1/0)return this;let o=N.multiplyByDOMMatrix(this.#iO.at(-1),e.getTransform());if(a[0]===-1/0)return N.axialAlignedBoundingBox([i,r,s,n],o,this.#iz),this;let l=[1/0,1/0,-1/0,-1/0];return N.axialAlignedBoundingBox([i,r,s,n],o,l),this.#iz[0]=Math.min(this.#iz[0],Math.max(l[0],a[0])),this.#iz[1]=Math.min(this.#iz[1],Math.max(l[1],a[1])),this.#iz[2]=Math.max(this.#iz[2],Math.min(l[2],a[2])),this.#iz[3]=Math.max(this.#iz[3],Math.min(l[3],a[3])),this}recordCharacterBBox(t,e,i,s=1,r=0,n=0,a){let o,l,h=i.bbox;if(h&&!1!==(o=h[2]!==h[0]&&h[3]!==h[1]&&this.#iG.get(i))&&(l=[0,0,0,0],N.axialAlignedBoundingBox(h,i.fontMatrix,l),(1!==s||0!==r||0!==n)&&N.scaleMinMax([s,0,0,-s,r,n],l),o))return this.recordBBox(t,e,l[0],l[2],l[1],l[3]);if(!a)return this.recordFullPageBBox(t);let d=a();return h&&l&&void 0===o&&(o=l[0]<=r-d.actualBoundingBoxLeft&&l[2]>=r+d.actualBoundingBoxRight&&l[1]<=n-d.actualBoundingBoxAscent&&l[3]>=n+d.actualBoundingBoxDescent,this.#iG.set(i,o),o)?this.recordBBox(t,e,l[0],l[2],l[1],l[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,n-d.actualBoundingBoxAscent,n+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#iz[0]=Math.max(0,this.#iU[0]),this.#iz[1]=Math.max(0,this.#iU[1]),this.#iz[2]=Math.min(this.#iV,this.#iU[2]),this.#iz[3]=Math.min(this.#iW,this.#iU[3]),this}getSimpleIndex(t){return this.#iR[t]}recordDependencies(t,e){let i=this.#i$,s=this.#iR,r=this.#iL;for(let t of e)t in this.#iR?i.add(s[t]):t in r&&r[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#iF.has(e)&&this.#i$.add(this.#iF.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[es]),this.#iX){let e=eh(this.#iX,t),{dependencies:i}=e;this.#i$.forEach(i.add,i),this.#iB.forEach(i.add,i),this.#iN.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}if(this.#iH===t){let i=er(256*this.#iz[0]/this.#iV),s=er(256*this.#iz[1]/this.#iW),r=en(256*this.#iz[2]/this.#iV),n=en(256*this.#iz[3]/this.#iW);for(let e of(ea(this.#iq,t,i,s,r,n),this.#i$))e!==t&&ea(this.#iq,e,i,s,r,n);for(let e of this.#iB)e!==t&&ea(this.#iq,e,i,s,r,n);for(let e of this.#iN)e!==t&&ea(this.#iq,e,i,s,r,n);e||(this.#i$.clear(),this.#iH=-1)}return this}recordShowTextOperation(t,e=!1){let i=Array.from(this.#i$);for(let s of(this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t),i))this.recordIncrementalData("sameLineText",s);return this}bboxToClipBoxDropOperation(t,e=!1){return this.#iH===t&&(this.#iH=-1,this.#iU[0]=Math.max(this.#iU[0],this.#iz[0]),this.#iU[1]=Math.max(this.#iU[1],this.#iz[1]),this.#iU[2]=Math.min(this.#iU[2],this.#iz[2]),this.#iU[3]=Math.min(this.#iU[3],this.#iz[3]),e||this.#i$.clear()),this}_takePendingDependencies(){let t=this.#i$;return this.#i$=new Set,t}_extractOperation(t){let e=this.#ij.get(t);return this.#ij.delete(t),e}_pushPendingDependencies(t){for(let e of t)this.#i$.add(e)}take(){return this.#iG.clear(),new el(this.#iP,this.#iq)}takeDebugMetadata(){return this.#iX}}class ec{#iY;#iQ;#iJ;#iZ=0;#i0=0;constructor(t,e,i){if(t instanceof ec&&!!i===t.#iJ)return t;this.#iY=t,this.#iQ=e,this.#iJ=!!i}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#i0++,this.#iY.save(this.#iQ),this}restore(t){return this.#i0>0&&(this.#iY.restore(this.#iQ),this.#i0--),this}recordOpenMarker(t){return this.#iZ++,this}getOpenMarker(){return this.#iZ>0?this.#iQ:this.#iY.getOpenMarker()}recordCloseMarker(t){return this.#iZ--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#iY.pushBaseTransform(t),this}popBaseTransform(){return this.#iY.popBaseTransform(),this}recordSimpleData(t,e){return this.#iY.recordSimpleData(t,this.#iQ),this}recordIncrementalData(t,e){return this.#iY.recordIncrementalData(t,this.#iQ),this}resetIncrementalData(t,e){return this.#iY.resetIncrementalData(t,this.#iQ),this}recordNamedData(t,e){return this}
2recordSimpleDataFromNamed(t,e,i){return this.#iY.recordSimpleDataFromNamed(t,e,this.#iQ),this}recordFutureForcedDependency(t,e){return this.#iY.recordFutureForcedDependency(t,this.#iQ),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#iY.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#iY.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#iJ||this.#iY.resetBBox(this.#iQ),this}recordClipBox(t,e,i,s,r,n){return this.#iJ||this.#iY.recordClipBox(this.#iQ,e,i,s,r,n),this}recordBBox(t,e,i,s,r,n){return this.#iJ||this.#iY.recordBBox(this.#iQ,e,i,s,r,n),this}recordCharacterBBox(t,e,i,s,r,n,a){return this.#iJ||this.#iY.recordCharacterBBox(this.#iQ,e,i,s,r,n,a),this}recordFullPageBBox(t){return this.#iJ||this.#iY.recordFullPageBBox(this.#iQ),this}getSimpleIndex(t){return this.#iY.getSimpleIndex(t)}recordDependencies(t,e){return this.#iY.recordDependencies(this.#iQ,e),this}recordNamedDependency(t,e){return this.#iY.recordNamedDependency(this.#iQ,e),this}recordOperation(t){return this.#iY.recordOperation(this.#iQ,!0),this}recordShowTextOperation(t){return this.#iY.recordShowTextOperation(this.#iQ,!0),this}bboxToClipBoxDropOperation(t){return this.#iJ||this.#iY.bboxToClipBoxDropOperation(this.#iQ,!0),this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}let eu=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],ep=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],eg=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],em=["filter","fillColor","fillAlpha"],ef=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],eb=["transform"],ev=["transform","fillColor"],ey="Fill",eA="Stroke",ew="Shading";function ex(t,e){if(!e)return;let i=e[2]-e[0],s=e[3]-e[1],r=new Path2D;r.rect(e[0],e[1],i,s),t.clip(r)}class e_{isModifyingCurrentTransform(){return!1}getPattern(){w("Abstract method `getPattern` called.")}}class eC extends e_{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],this.matrix=null}_createGradient(t){let e;for(let i of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,s){let r;if(s===eA||s===ey){let n=e.current.getClippedPathBoundingBox(s,th(t))||[0,0,0,0],a=Math.ceil(n[2]-n[0])||1,o=Math.ceil(n[3]-n[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-n[0],-n[1]),i=N.transform(i,[1,0,0,1,n[0],n[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),ex(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),r=t.createPattern(l.canvas,"no-repeat");let d=new DOMMatrix(i);r.setTransform(d)}else ex(t,this._bbox),r=this._createGradient(t);return r}}function eS(t,e,i,s,r,n,a,o){let l,h,d,c,u,p,g,m,f,b=e.coords,v=e.colors,y=t.data,A=4*t.width;b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=n,n=a,a=l),b[s+1]>b[r+1]&&(l=s,s=r,r=l,l=a,a=o,o=l),b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=n,n=a,a=l);let w=(b[i]+e.offsetX)*e.scaleX,x=(b[i+1]+e.offsetY)*e.scaleY,_=(b[s]+e.offsetX)*e.scaleX,C=(b[s+1]+e.offsetY)*e.scaleY,S=(b[r]+e.offsetX)*e.scaleX,E=(b[r+1]+e.offsetY)*e.scaleY;if(x>=E)return;let T=v[n],M=v[n+1],D=v[n+2],k=v[a],P=v[a+1],I=v[a+2],R=v[o],L=v[o+1],F=v[o+2],B=Math.round(x),N=Math.round(E);for(let t=B;t<=N;t++){let e;if(t<C){let e=t<x?0:(x-t)/(x-C);h=w-(w-_)*e,d=T-(T-k)*e,c=M-(M-P)*e,u=D-(D-I)*e}else{let e;h=_-(_-S)*(e=t>E?1:C===E?0:(C-t)/(C-E)),d=k-(k-R)*e,c=P-(P-L)*e,u=I-(I-F)*e}p=w-(w-S)*(e=t<x?0:t>E?1:(x-t)/(x-E)),g=T-(T-R)*e,m=M-(M-L)*e,f=D-(D-F)*e;let i=Math.round(Math.min(h,p)),s=Math.round(Math.max(h,p)),r=A*t+4*i;for(let t=i;t<=s;t++)(e=(h-t)/(h-p))<0?e=0:e>1&&(e=1),y[r++]=d-(d-g)*e|0,y[r++]=c-(c-m)*e|0,y[r++]=u-(u-f)*e|0,y[r++]=255}}class eE extends e_{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){let s=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),n=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-r,o=Math.min(Math.ceil(Math.abs(n*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=n/o,d=a/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-r,scaleX:1/h,scaleY:1/d}
2,u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),m=g.context,f=m.createImageData(o,l);if(e){let t=f.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(let t of this._figures)!function(t,e,i){let s,r,n=e.coords,a=e.colors;switch(e.type){case"lattice":let o=e.verticesPerRow,l=Math.floor(n.length/o)-1,h=o-1;for(s=0;s<l;s++){let e=s*o;for(let s=0;s<h;s++,e++)eS(t,i,n[e],n[e+1],n[e+o],a[e],a[e+1],a[e+o]),eS(t,i,n[e+o+1],n[e+1],n[e+o],a[e+o+1],a[e+1],a[e+o])}break;case"triangles":for(s=0,r=n.length;s<r;s+=3)eS(t,i,n[s],n[s+1],n[s+2],a[s],a[s+1],a[s+2]);break;default:throw Error("illegal figure")}}(f,t,c);return m.putImageData(f,2,2),{canvas:g.canvas,offsetX:s-2*h,offsetY:r-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){ex(t,this._bbox);let r=new Float32Array(2);if(s===ew)N.singularValueDecompose2dScale(th(t),r);else if(this.matrix){N.singularValueDecompose2dScale(this.matrix,r);let[t,i]=r;N.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=t,r[1]*=i}else N.singularValueDecompose2dScale(e.baseTransform,r);let n=this._createMeshCanvas(r,s===ew?null:this._background,e.cachedCanvases);return s!==ew&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(n.offsetX,n.offsetY),t.scale(n.scaleX,n.scaleY),t.createPattern(n.canvas,"no-repeat")}}class eT extends e_{getPattern(){return"hotpink"}}class eM{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.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t,e){let{bbox:i,operatorList:s,paintType:r,tilingType:n,color:a,canvasGraphicsFactory:o}=this,{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),y("TilingType: "+n);let d=i[0],c=i[1],u=i[2],p=i[3],g=u-d,m=p-c,f=new Float32Array(2);N.singularValueDecompose2dScale(this.matrix,f);let[b,v]=f;N.singularValueDecompose2dScale(this.baseTransform,f);let A=b*f[0],w=v*f[1],x=g,_=m,C=!1,S=!1,E=Math.ceil(h*w),T=Math.ceil(m*w);Math.ceil(l*A)>=Math.ceil(g*A)?x=l:C=!0,E>=T?_=h:S=!0;let M=this.getSizeAndScale(x,this.ctx.canvas.width,A),D=this.getSizeAndScale(_,this.ctx.canvas.height,w),k=t.cachedCanvases.getCanvas("pattern",M.size,D.size),P=k.context,I=o.createCanvasGraphics(P,e);if(I.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(I,r,a),P.translate(-M.scale*d,-D.scale*c),I.transform(0,M.scale,0,0,D.scale,0,0),P.save(),I.dependencyTracker?.save(),this.clipBbox(I,d,c,u,p),I.baseTransform=th(I.ctx),I.executeOperatorList(s),I.endDrawing(),I.dependencyTracker?.restore(),P.restore(),C||S){let e=k.canvas;C&&(x=l),S&&(_=h);let i=this.getSizeAndScale(x,this.ctx.canvas.width,A),s=this.getSizeAndScale(_,this.ctx.canvas.height,w),r=i.size,n=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",r,n),o=a.context,u=C?Math.floor(g/l):0,p=S?Math.floor(m/h):0;for(let t=0;t<=u;t++)for(let i=0;i<=p;i++)o.drawImage(e,r*t,n*i,r,n,0,0,r,n);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:d,offsetY:c}}return{canvas:k.canvas,scaleX:M.scale,scaleY:D.scale,offsetX:d,offsetY:c}}getSizeAndScale(t,e,i){let s=Math.max(eM.MAX_PATTERN_SIZE,e),r=Math.ceil(t*i);return r>=s?r=s:i=r/t,{scale:i,size:r}}clipBbox(t,e,i,s,r){let n=s-e,a=r-i;t.ctx.rect(e,i,n,a),N.axialAlignedBoundingBox([e,i,s,r],th(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){let s=t.ctx,r=t.current;switch(e){case 1:let{fillStyle:n,strokeStyle:a}=this.ctx;s.fillStyle=r.fillColor=n,s.strokeStyle=r.strokeColor=a;break;case 2:s.fillStyle=s.strokeStyle=i,r.fillColor=r.strokeColor=i;break;default:throw new P(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,r){let n=i;s!==ew&&(n=N.transform(n,e.baseTransform),this.matrix&&(n=N.transform(n,this.matrix)));let a=this.createPatternCanvas(e,r),o=new DOMMatrix(n);o=(o=o.translate(a.offsetX,a.offsetY)).scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}}let eD=new DOMMatrix,ek=new Float32Array(2),eP=new Float32Array([1/0,1/0,-1/0,-1/0]);class eI{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}
2function eR(t,e,i,s,r,n,a,o,l,h){let[d,c,u,p,g,m]=th(t);if(0===c&&0===u){let f=Math.round(a*d+g),b=Math.round(o*p+m),v=Math.abs(Math.round((a+l)*d+g)-f)||1,y=Math.abs(Math.round((o+h)*p+m)-b)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),f,b),t.drawImage(e,i,s,r,n,0,0,v,y),t.setTransform(d,c,u,p,g,m),[v,y]}if(0===d&&0===p){let f=Math.round(o*u+g),b=Math.round(a*c+m),v=Math.abs(Math.round((o+h)*u+g)-f)||1,y=Math.abs(Math.round((a+l)*c+m)-b)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,f,b),t.drawImage(e,i,s,r,n,0,0,y,v),t.setTransform(d,c,u,p,g,m),[y,v]}return t.drawImage(e,i,s,r,n,a,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class eL{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=o;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e,i){i?.(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=eP.slice()}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=ey,e=null){let i=this.minMax.slice();if(t===eA){e||w("Stroke bounding box must include transform."),N.singularValueDecompose2dScale(e,ek);let t=ek[0]*this.lineWidth/2,s=ek[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){let t=N.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(eP,0)}getClippedPathBoundingBox(t=ey,e=null){return N.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function eF(t,e){let i,s,r,n;if(e instanceof ImageData)return void t.putImageData(e,0,0);let a=e.height,o=e.width,l=a%16,h=(a-l)/16,d=0===l?h:h+1,c=t.createImageData(o,16),u=0,g,m=e.data,f=c.data;if(e.kind===p.GRAYSCALE_1BPP){let e=m.byteLength,n=new Uint32Array(f.buffer,0,f.byteLength>>2),a=n.length,p=o+7>>3,b=F.isLittleEndian?0xff000000:255;for(i=0;i<d;i++){for(r=i<h?16:l,g=0,s=0;s<r;s++){let t=e-u,i=0,s=t>p?o:8*t-7,r=-8&s,a=0,l=0;for(;i<r;i+=8)l=m[u++],n[g++]=128&l?0xffffffff:b,n[g++]=64&l?0xffffffff:b,n[g++]=32&l?0xffffffff:b,n[g++]=16&l?0xffffffff:b,n[g++]=8&l?0xffffffff:b,n[g++]=4&l?0xffffffff:b,n[g++]=2&l?0xffffffff:b,n[g++]=1&l?0xffffffff:b;for(;i<s;i++)0===a&&(l=m[u++],a=128),n[g++]=l&a?0xffffffff:b,a>>=1}for(;g<a;)n[g++]=0;t.putImageData(c,0,16*i)}}else if(e.kind===p.RGBA_32BPP){for(s=0,n=16*o*4,i=0;i<h;i++)f.set(m.subarray(u,u+n)),u+=n,t.putImageData(c,0,s),s+=16;i<d&&(n=o*l*4,f.set(m.subarray(u,u+n)),t.putImageData(c,0,s))}else if(e.kind===p.RGB_24BPP)for(n=o*(r=16),i=0;i<d;i++){for(i>=h&&(n=o*(r=l)),g=0,s=n;s--;)f[g++]=m[u++],f[g++]=m[u++],f[g++]=m[u++],f[g++]=255;t.putImageData(c,0,16*i)}else throw Error(`bad image kind: ${e.kind}`)}function eB(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);let i=e.height,s=e.width,r=i%16,n=(i-r)/16,a=0===r?n:n+1,o=t.createImageData(s,16),l=0,h=e.data,d=o.data;for(let e=0;e<a;e++){let i=e<n?16:r;({srcPos:l}=function({src:t,srcPos:e=0,dest:i,width:s,height:r,nonBlackColor:n=0xffffffff,inverseDecode:a=!1}){let o=F.isLittleEndian?0xff000000:255,[l,h]=a?[n,o]:[o,n],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<r;s++){for(let s=e+d;e<s;e++){let s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;let s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,16*e)}}function eN(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function eO(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miter
2Limit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function eU(t,e){if(e)return!0;N.singularValueDecompose2dScale(t,ek);let i=Math.fround(tu.pixelRatio*X.PDF_TO_CSS_UNITS);return ek[0]<=i&&ek[1]<=i}let ez=["butt","round","square"],eH=["miter","round","bevel"],e$={},ej={};class eG{constructor(t,e,i,s,r,{optionalContentConfig:n,markedContentStack:a=null},o,l,h){this.ctx=t,this.current=new eL(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=n,this.cachedCanvases=new eI(this.canvasFactory),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=h??null}getObject(t,e,i=null){return"string"==typeof e?(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}){let r=this.ctx.canvas.width,n=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,r,n),this.ctx.fillStyle=a,i){let t=this.cachedCanvases.getCanvas("transparent",r,n);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...th(this.compositeCtx))}this.ctx.save(),eO(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=th(this.ctx)}executeOperatorList(t,e,i,s,r){let n,a,o=t.argsArray,l=t.fnArray,h=e||0,d=o.length;if(d===h)return h;let c=d-h>10&&"function"==typeof i,u=c?Date.now()+15:0,p=0,g=this.commonObjs,m=this.objs;for(;;){if(void 0!==s&&h===s.nextBreakPoint)return s.breakIt(h,i),h;if(!r||r(h))if(n=l[h],a=o[h]??null,n!==f.dependency)null===a?this[n](h):this[n](h,...a);else for(let t of a){this.dependencyTracker?.recordNamedData(t,h);let e=t.startsWith("g_")?g:m;if(!e.has(t))return e.get(t,i),h}if(++h===d)return h;if(c&&++p>10){if(Date.now()>u)return i(),h;p=0}}}#i1(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){for(let t of(this.#i1(),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let e of t.values())"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#i2()}#i2(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let i,s,r=t.width??t.displayWidth,n=t.height??t.displayHeight,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=r,h=n,d="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,r=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(r=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/r),(s=(i=this.cachedCanvases.getCanvas(d,e,r)).context).clearRect(0,0,e,r),s.drawImage(t,0,0,l,h,0,0,e,r),t=i.canvas,l=e,h=r,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t,e){let i,s,r,n,a=this.ctx,{width:o,height:l}=e,h=this.current.fillColor,d=this.current.patternFill,c=th(a);if((e.bitmap||e.data)&&e.count>1){let n=e.bitmap||e.data.buffer;s=JSON.stringify(d?c:[c.slice(0,4),h]),(i=this._cachedBitmapsMap.get(n))||(i=new Map,this._cachedBitmapsMap.set(n,i));let a=i.get(s);if(a&&!d){let e=Math.round(Math.min(c[0],c[2])+c[4]),i=Math.round(Math.min(c[1],c[3])+c[5]);return this.dependencyTracker?.recordDependencies(t,ev),{canvas:a,offsetX:e,offsetY:i}}r=a}r||eB((n=this.cachedCanvases.getCanvas("maskCanvas",o,l)).context,e);let u=N.transform(c,[1/o,0,0,-1/l,0,0]);u=N.transform(u,[1,0,0,1,0,-l]);let p=eP.slice();N.axialAlignedBoundingBox([0,0,o,l],u,p);let[g,m,f,b]=p,v=Math.round(f-g)||1,y=Math.round(b-m)||1,A=this.cachedCanvases.getCanvas("fillCanvas",v,y),w=A.context;w.translate(-g,-m),w.transform(...u),!r&&(r=(r=this._scaleImage(n.canvas,td(w))).img,i&&d&&i.set(s,r)),w.imageSmoothingEnabled=eU(th(w),e.interpolate),eR(w,r,0,0,r.width,r.height,0,0,o,l),w.globalCompositeOperation="source-in";let x=N.transform(td(w),[1,0,0,1,-g,-m]);return w.fillStyle=d?h.getPattern(a,this,x,ey,t):h,w.fillRect(0,0,o,l),i&&!d&&(this.cachedCanvases.delete("fillCanvas"),i.set(s,A.canvas)),this.dependencyTracker?.recordDependencies(t,ev),{canvas:A.canvas,offsetX:Math.round(g),offsetY:Math.round(m)}}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=ez[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=eH[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);let s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(e),s.lineDashOffset=i)}
2setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[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.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,i=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(s,e,i);this.suspendedCtx=this.ctx;let n=this.ctx=r.context;n.setTransform(this.suspendedCtx.getTransform()),eN(this.suspendedCtx,n);var a=this.suspendedCtx;if(n._removeMirroring)throw Error("Context is already forwarding operations.");n.__originalSave=n.save,n.__originalRestore=n.restore,n.__originalRotate=n.rotate,n.__originalScale=n.scale,n.__originalTranslate=n.translate,n.__originalTransform=n.transform,n.__originalSetTransform=n.setTransform,n.__originalResetTransform=n.resetTransform,n.__originalClip=n.clip,n.__originalMoveTo=n.moveTo,n.__originalLineTo=n.lineTo,n.__originalBezierCurveTo=n.bezierCurveTo,n.__originalRect=n.rect,n.__originalClosePath=n.closePath,n.__originalBeginPath=n.beginPath,n._removeMirroring=()=>{n.save=n.__originalSave,n.restore=n.__originalRestore,n.rotate=n.__originalRotate,n.scale=n.__originalScale,n.translate=n.__originalTranslate,n.transform=n.__originalTransform,n.setTransform=n.__originalSetTransform,n.resetTransform=n.__originalResetTransform,n.clip=n.__originalClip,n.moveTo=n.__originalMoveTo,n.lineTo=n.__originalLineTo,n.bezierCurveTo=n.__originalBezierCurveTo,n.rect=n.__originalRect,n.closePath=n.__originalClosePath,n.beginPath=n.__originalBeginPath,delete n._removeMirroring},n.save=function(){a.save(),this.__originalSave()},n.restore=function(){a.restore(),this.__originalRestore()},n.translate=function(t,e){a.translate(t,e),this.__originalTranslate(t,e)},n.scale=function(t,e){a.scale(t,e),this.__originalScale(t,e)},n.transform=function(t,e,i,s,r,n){a.transform(t,e,i,s,r,n),this.__originalTransform(t,e,i,s,r,n)},n.setTransform=function(t,e,i,s,r,n){a.setTransform(t,e,i,s,r,n),this.__originalSetTransform(t,e,i,s,r,n)},n.resetTransform=function(){a.resetTransform(),this.__originalResetTransform()},n.rotate=function(t){a.rotate(t),this.__originalRotate(t)},n.clip=function(t){a.clip(t),this.__originalClip(t)},n.moveTo=function(t,e){a.moveTo(t,e),this.__originalMoveTo(t,e)},n.lineTo=function(t,e){a.lineTo(t,e),this.__originalLineTo(t,e)},n.bezierCurveTo=function(t,e,i,s,r,n){a.bezierCurveTo(t,e,i,s,r,n),this.__originalBezierCurveTo(t,e,i,s,r,n)},n.rect=function(t,e,i,s){a.rect(t,e,i,s),this.__originalRect(t,e,i,s)},n.closePath=function(){a.closePath(),this.__originalClosePath()},n.beginPath=function(){a.beginPath(),this.__originalBeginPath()},this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),eN(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),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(
2)}composeSMask(t,e,i,s){let r=s[0],n=s[1],a=s[2]-r,o=s[3]-n;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,r,n,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,r,n,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(n)if(u<0||p<0||u+i>c.width||p+s>c.height){let t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(c,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=n,e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let e=new Path2D;e.rect(u,p,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=n,t.fillRect(u,p,i,s),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===r&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===r&&(e.filter=this.filterFactory.addLuminosityFilter(a));let g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(t){this.inSMaskMode&&eN(this.ctx,this.suspendedCtx),this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),0===this.stateStack.length){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&eN(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,i,s,r,n,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,r,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[r]=i;if(!s){r||=i[0]=new Path2D,this[e](t,r);return}if(null!==this.dependencyTracker){let i=e===f.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-i,s[2]+i,s[1]-i,s[3]+i).recordDependencies(t,["transform"])}if(!(r instanceof Path2D)){let t=i[0]=new Path2D;for(let e=0,i=r.length;e<i;)switch(r[e++]){case 0:t.moveTo(r[e++],r[e++]);break;case 1:t.lineTo(r[e++],r[e++]);break;case 2:t.bezierCurveTo(r[e++],r[e++],r[e++],r[e++],r[e++],r[e++]);break;case 3:t.closePath();break;default:A(`Unrecognized drawing path operator: ${r[e-1]}`)}r=t}N.axialAlignedBoundingBox(s,th(this.ctx),this.current.minMax),this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){let s=this.ctx,r=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof r&&r?.getPattern){let i=r.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=r.getPattern(s,this,td(s),eA,t),i){let t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),s.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,eu),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(eA,th(this.ctx))),s.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){let s=this.ctx,r=this.current.fillColor,n=this.current.patternFill,a=!1;if(n){let i=r.isModifyingCurrentTransform()?s.getTransform():null;if(this.dependencyTracker?.save(t),s.save(),s.fillStyle=r.getPattern(s,this,td(s),ey,t),i){let t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(i)),e=t}a=!0}let o=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==o&&(this.pendingEOFill?(s.fill(e,"evenodd"),this.pendingEOFill=!1):s.fill(e)),this.dependencyTracker?.recordDependencies(t,ep),a&&(s.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,o)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}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){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,em).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=e$}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=ej}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){let e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){let t=new Path2D,s=i.getTransform().invertSelf();for(let{transform:i,x:r,y:n,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(s).translate(r,n).scale(a,-a));i.clip(t)}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);let s=this.commonObjs.get(e),r=this.current;if(!s)throw Error(`Can't find font for ${e}`);if(r.fontMatrix=s.fontMatrix||o,(0===r.fontMatrix[0]||0===r.fontMatrix[3])&&A("Invalid font matrix for font "+e),i<0?(i=-i,r.fontDirection=-1):r.fontDirection=1,this.current.font=s,this.current.fontSize=i,s.isType3Font)return;let n=s.loadedName||"sans-serif",a=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`,l="normal";s.black?l="900":s.bold&&(l="bold");let h=s.italic?"italic":"normal",d=i;i<16?d=16:i>100&&(d=100),this.current.fontSizeScale=i/d,this.ctx.font=`${h} ${l} ${d}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?.recordSimpleData("textMatrix",t);let{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)}#i3(t,e,i){let s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,r,n){let a,o=this.ctx,l=this.current,h=l.font,d=l.textRenderingMode,c=l.fontSize/l.fontSizeScale,u=3&d,p=!!(4&d),g=l.patternFill&&!h.missingFile,m=l.patternStroke&&!h.missingFile;if((h.disableFontFace||p||g||m)&&!h.missingFile&&(a=h.getPathGenerator(this.commonObjs,e)),a&&(h.disableFontFace||g||m)){let e;if(o.save(),o.translate(i,s),o.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,o,h),0===u||2===u)if(r){e=o.getTransform(),o.setTransform(...r);let t=this.#i3(a,e,r);o.fill(t)}else o.fill(a);if(1===u||2===u)if(n){e||=o.getTransform(),o.setTransform(...n);let{a:t,b:i,c:s,d:r}=e,l=N.inverseTransform(n),h=N.transform([t,i,s,r,0,0],l);N.singularValueDecompose2dScale(h,ek),o.lineWidth*=Math.max(ek[0],ek[1])/c,o.stroke(this.#i3(a,e,n))}else o.lineWidth/=c,o.stroke(a);
2o.restore()}else(0===u||2===u)&&(o.fillText(e,i,s),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e))),(1===u||2===u)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e)).recordDependencies(t,eu),o.strokeText(e,i,s));p&&((this.pendingTextPaths||=[]).push({transform:th(o),x:i,y:s,fontSize:c,path:a}),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s))}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return S(this,"isFontSubpixelAAEnabled",i)}showText(t,e){let i,s;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,ef).resetBBox(t),4&this.current.textRenderingMode&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());let r=this.current,n=r.font;if(n.isType3Font){this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t);return}let a=r.fontSize;if(0===a)return void this.dependencyTracker?.recordOperation(t);let o=this.ctx,l=r.fontSizeScale,h=r.charSpacing,d=r.wordSpacing,c=r.fontDirection,u=r.textHScale*c,p=e.length,g=n.vertical,m=g?1:-1,f=n.defaultVMetrics,b=a*r.fontMatrix[0],v=0===r.textRenderingMode&&!n.disableFontFace&&!r.patternFill;if(o.save(),r.textMatrix&&o.transform(...r.textMatrix),o.translate(r.x,r.y+r.textRise),c>0?o.scale(u,-1):o.scale(u,1),r.patternFill){o.save();let e=r.fillColor.getPattern(o,this,td(o),ey,t);i=th(o),o.restore(),o.fillStyle=e}if(r.patternStroke){o.save();let e=r.strokeColor.getPattern(o,this,td(o),eA,t);s=th(o),o.restore(),o.strokeStyle=e}let y=r.lineWidth,A=r.textMatrixScale;if(0===A||0===y){let t=3&r.textRenderingMode;(1===t||2===t)&&(y=this.getSinglePixelWidth())}else y/=A;if(1!==l&&(o.scale(l,l),y/=l),o.lineWidth=y,n.isInvalidPDFjsFont){let i=[],s=0;for(let t of e)i.push(t.unicode),s+=t.width;let n=i.join("");if(o.fillText(n,0,0),null!==this.dependencyTracker){let e=o.measureText(n);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}
2r.x+=s*b*u,o.restore(),this.compose();return}let w=0,x;for(x=0;x<p;++x){let r,u,p,y=e[x];if("number"==typeof y){w+=m*y*a/1e3;continue}let A=!1,_=(y.isSpace?d:0)+h,C=y.fontChar,S=y.accent,E=y.width;if(g){let t=y.vmetric||f,e=-(y.vmetric?t[1]:.5*E)*b,i=t[2]*b;E=t?-t[0]:E,r=e/l,u=(w+i)/l}else r=w/l,u=0;if(n.remeasure&&E>0){let t=1e3*(p=o.measureText(C)).width/a*l;if(E<t&&this.isFontSubpixelAAEnabled){let e=E/t;A=!0,o.save(),o.scale(e,1),r/=e}else E!==t&&(r+=(E-t)/2e3*a/l)}if(this.contentVisible&&(y.isInFont||n.missingFile)){if(v&&!S)o.fillText(C,r,u),this.dependencyTracker?.recordCharacterBBox(t,o,p?{bbox:null}:n,a/l,r,u,()=>p??o.measureText(C));else if(this.paintChar(t,C,r,u,i,s),S){let e=r+a*S.offset.x/l,n=u-a*S.offset.y/l;this.paintChar(t,S.fontChar,e,n,i,s)}}w+=g?E*b-_*c:E*b+_*c,A&&o.restore()}g?r.y-=w:r.x+=w*u,o.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){let i,s,r,n,a=this.ctx,l=this.current,h=l.font,d=l.fontSize,c=l.fontDirection,u=h.vertical?1:-1,p=l.charSpacing,g=l.wordSpacing,m=l.textHScale*c,f=l.fontMatrix||o,b=e.length;if(3===l.textRenderingMode||0===d)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),l.textMatrix&&a.transform(...l.textMatrix),a.translate(l.x,l.y+l.textRise),a.scale(m,c);let v=this.dependencyTracker;for(this.dependencyTracker=v?new ec(v,t):null,i=0;i<b;++i){if("number"==typeof(s=e[i])){n=u*s*d/1e3,this.ctx.translate(n,0),l.x+=n*m;continue}let t=(s.isSpace?g:0)+p,o=h.charProcOperatorList[s.operatorListId];o?this.contentVisible&&(this.save(),a.scale(d,d),a.transform(...f),this.executeOperatorList(o),this.restore()):A(`Type3 character "${s.operatorListId}" is not available.`);let c=[s.width,0];N.applyTransform(c,f),r=c[0]*d+t,a.translate(r,0),l.x+=r*m}a.restore(),v&&(this.dependencyTracker=v)}setCharWidth(t,e,i){}
2setCharWidthAndBounds(t,e,i,s,r,n,a){let o=new Path2D;o.rect(s,r,n-s,a-r),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,s,n,r,a).recordClipBox(t,this.ctx,s,n,r,a),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){let t=this.baseTransform||th(this.ctx);i=new eM(e,this.ctx,{createCanvasGraphics:(t,e)=>new eG(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new ec(this.dependencyTracker,e,!0):null)},t)}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),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
2setStrokeTransparent(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}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=function(t){switch(t[0]){case"RadialAxial":return new eC(t);case"Mesh":return new eE(t);case"Dummy":return new eT}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,s)),i&&(s.matrix=i),s}shadingFill(t,e){if(!this.contentVisible)return;let i=this.ctx;this.save(t),i.fillStyle=this._getPattern(t,e).getPattern(i,this,td(i),ew,t);let s=td(i);if(s){let{width:t,height:e}=i.canvas,r=eP.slice();N.axialAlignedBoundingBox([0,0,t,e],s,r);let[n,a,o,l]=r;this.ctx.fillRect(n,a,o-n,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,eb).recordDependencies(t,ep).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){w("Should not call beginInlineImage")}beginImageData(){w("Should not call beginImageData")}
2paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=th(this.ctx),i)){N.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);let[e,s,r,n]=i,a=new Path2D;a.rect(e,s,r-e,n-s),this.ctx.clip(a),this.dependencyTracker?.recordClipBox(t,this.ctx,e,r,s,n),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),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let i=this.ctx;e.isolated||y("TODO: Support non-isolated groups."),e.knockout&&A("Knockout groups not supported.");let s=th(i);if(e.matrix&&i.transform(...e.matrix),!e.bbox)throw Error("Bounding box is required.");let r=eP.slice();N.axialAlignedBoundingBox(e.bbox,th(i),r);let n=[0,0,i.canvas.width,i.canvas.height],a=Math.floor((r=N.intersect(r,n)||[0,0,0,0])[0]),o=Math.floor(r[1]),l=Math.max(Math.ceil(r[2])-a,1),h=Math.max(Math.ceil(r[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,h]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);let c=this.cachedCanvases.getCanvas(d,l,h),u=c.context;u.translate(-a,-o),u.transform(...s);let p=new Path2D,[g,m,f,b]=e.bbox;if(p.rect(g,m,f-g,b-m),e.matrix){let t=new Path2D;t.addPath(p,new DOMMatrix(e.matrix)),p=t}u.clip(p),e.smask&&this.smaskStack.push({canvas:c.canvas,context:u,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(a,o),i.save()),eN(i,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(i),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let i=this.ctx,s=this.groupStack.pop();if(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();else{this.ctx.restore();let e=th(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);let s=eP.slice();N.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,s),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotation(t,e,i,s,r,n){if(this.#i1(),eO(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){let r=i[2]-i[0],a=i[3]-i[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=i[0],s[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=r,i[3]=a,N.singularValueDecompose2dScale(th(this.ctx),ek);let{viewportScale:t}=this,n=Math.ceil(r*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(n,o);let{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(ek[0],0,0,-ek[1],0,a*ek[1]),eO(this.ctx)}else{eO(this.ctx),this.endPath(t);let e=new Path2D;e.rect(i[0],i[1],r,a),this.ctx.clip(e)}}this.current=new eL(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...s),this.transform(t,...r)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#i2(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let i=e.count;(e=this.getObject(t,e.data,e)).count=i;let s=this.ctx,r=this._createMaskCanvas(t,e),n=r.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(n,r.offsetX,r.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+n.width,r.offsetY,r.offsetY+n.height).recordOperation(t),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,s=0,r=0,n,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.ctx;o.save();let l=th(o);o.transform(i,s,r,n,0,0);let h=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,d=a.length;e<d;e+=2){let d=N.transform(l,[i,s,r,n,a[e],a[e+1]]);o.drawImage(h.canvas,d[4],d[5]),this.dependencyTracker?.recordBBox(t,this.ctx,d[4],d[4]+h.canvas.width,d[5],d[5]+h.canvas.height)}
2o.restore(),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let i=this.ctx,s=this.current.fillColor,r=this.current.patternFill;for(let n of(this.dependencyTracker?.resetBBox(t).recordDependencies(t,ev),e)){let{data:e,width:a,height:o,transform:l}=n,h=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=h.context;d.save(),eB(d,this.getObject(t,e,n)),d.globalCompositeOperation="source-in",d.fillStyle=r?s.getPattern(d,this,td(i),ey,t):s,d.fillRect(0,0,a,o),d.restore(),i.save(),i.transform(...l),i.scale(1,-1),eR(i,h.canvas,0,0,a,o,0,-1,1,1),this.dependencyTracker?.recordBBox(t,i,0,a,0,o),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;let i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):A("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s,r){if(!this.contentVisible)return;let n=this.getObject(t,e);if(!n)return void A("Dependent image isn't ready yet");let a=n.width,o=n.height,l=[];for(let t=0,e=r.length;t<e;t+=2)l.push({transform:[i,0,0,s,r[t],r[t+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,n,l)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;let{bitmap:e,width:i,height:s}=t,r=this.cachedCanvases.getCanvas("inlineImage",i,s),n=r.context;return n.filter=this.current.transferMaps,n.drawImage(e,0,0),n.filter="none",r.canvas}paintInlineImageXObject(t,e){let i;if(!this.contentVisible)return;let s=e.width,r=e.height,n=this.ctx;this.save(t);let{filter:a}=n;if("none"!==a&&""!==a&&(n.filter="none"),n.scale(1/s,-1/r),e.bitmap)i=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)i=e;else{let t=this.cachedCanvases.getCanvas("inlineImage",s,r).context;eF(t,e),i=this.applyTransferMapsToCanvas(t)}let o=this._scaleImage(i,td(n));n.imageSmoothingEnabled=eU(th(n),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,n,0,s,-r,0).recordDependencies(t,eg).recordOperation(t),eR(n,o.img,0,0,o.paintWidth,o.paintHeight,0,-r,s,r),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){let s;if(!this.contentVisible)return;let r=this.ctx;if(e.bitmap)s=e.bitmap;else{let t=e.width,i=e.height,r=this.cachedCanvases.getCanvas("inlineImage",t,i).context;eF(r,e),s=this.applyTransferMapsToCanvas(r)}for(let e of(this.dependencyTracker?.resetBBox(t),i))r.save(),r.transform(...e.transform),r.scale(1,-1),eR(r,s,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,r,0,1,-1,0),r.restore();this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,ep).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}
2markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?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){let s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);let r=this.ctx;this.pendingClip?(s||(this.pendingClip===ej?r.clip(e,"evenodd"):r.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){let t=th(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let 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(-1===this._cachedScaleForStroking[0]){let t,e,{lineWidth:i}=this.current,{a:s,b:r,c:n,d:a}=this.ctx.getTransform();if(0===r&&0===n){let r=Math.abs(s),n=Math.abs(a);if(r===n)if(0===i)t=e=1/r;else{let s=r*i;t=e=s<1?1/s:1}else if(0===i)t=1/r,e=1/n;else{let s=r*i,a=n*i;t=s<1?1/s:1,e=a<1?1/a:1}}else{let o=Math.abs(s*a-r*n),l=Math.hypot(s,r),h=Math.hypot(n,a);if(0===i)t=h/o,e=l/o;else{let s=i*o;t=h>s?h/s:1,e=l>s?l/s:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:i,current:{lineWidth:s}}=this,[r,n]=this.getScaleForStroking();if(r===n){i.lineWidth=(s||1)*r,i.stroke(t);return}let a=i.getLineDash();e&&i.save(),i.scale(r,n),eD.a=1/r,eD.d=1/n;let o=new Path2D;if(o.addPath(t,eD),a.length>0){let t=Math.max(r,n);i.setLineDash(a.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in f)void 0!==eG.prototype[t]&&(eG.prototype[f[t]]=eG.prototype[t]);class eV{#i5;#i4;#i6;static strings=["fontFamily","fontWeight","italicAngle"];static write(t){let e=new TextEncoder,i={},s=0;for(let r of eV.strings){let n=e.encode(t[r]);i[r]=n,s+=4+n.length}let r=new ArrayBuffer(s),n=new Uint8Array(r),a=new DataView(r),o=0;for(let t of eV.strings){let e=i[t],s=e.length;a.setUint32(o,s),n.set(e,o+4),o+=4+s}return x(o===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}constructor(t){this.#i5=t,this.#i4=new DataView(this.#i5),this.#i6=new TextDecoder}#i8(t){x(t<eV.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#i4.getUint32(e)+4;let i=this.#i4.getUint32(e);return this.#i6.decode(new Uint8Array(this.#i5,e+4,i))}get fontFamily(){return this.#i8(0)}get fontWeight(){return this.#i8(1)}get italicAngle(){return this.#i8(2)}}class eW{#i5;#i4;#i6;static strings=["css","loadedName","baseFontName","src"];static write(t){let e=new TextEncoder,i={},s=0;for(let r of eW.strings){let n=e.encode(t[r]);i[r]=n,s+=4+n.length}let r,n,a=1+(s+=4);t.style&&(r=e.encode(t.style.style),n=e.encode(t.style.weight),a+=4+r.length+4+n.length);let o=new ArrayBuffer(a),l=new Uint8Array(o),h=new DataView(o),d=0;for(let e of(h.setUint8(d++,+!!t.guessFallback),h.setUint32(d,0),d+=4,s=0,eW.strings)){let t=i[e],r=t.length;s+=4+r,h.setUint32(d,r),l.set(t,d+4),d+=4+r}return h.setUint32(d-s-4,s),t.style&&(h.setUint32(d,r.length),l.set(r,d+4),d+=4+r.length,h.setUint32(d,n.length),l.set(n,d+4),d+=4+n.length),x(d<=o.byteLength,"SubstitionInfo.write: Buffer overflow"),o.transferToFixedLength(d)}constructor(t){this.#i5=t,this.#i4=new DataView(this.#i5),this.#i6=new TextDecoder}get guessFallback(){return 0!==this.#i4.getUint8(0)}#i8(t){x(t<eW.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#i4.getUint32(e)+4;let i=this.#i4.getUint32(e);return this.#i6.decode(new Uint8Array(this.#i5,e+4,i))}get css(){return this.#i8(0)}get loadedName(){return this.#i8(1)}get baseFontName(){return this.#i8(2)}get src(){return this.#i8(3)}get style(){let t=1;t+=4+this.#i4.getUint32(t);let e=this.#i4.getUint32(t),i=this.#i6.decode(new Uint8Array(this.#i5,t+4,e));t+=4+e;let s=this.#i4.getUint32(t),r=this.#i6.decode(new Uint8Array(this.#i5,t+4,s));return{style:i,weight:r}}}
2class eq{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static #i7=Math.ceil(2*this.bools.length/8);static #i9=this.#i7+8*this.numbers.length;static #st=this.#i9+1+8;static #se=this.#st+1+48;static #si=this.#se+1+6;#i5;#i6;#i4;constructor({data:t,extra:e}){this.#i5=t,this.#i6=new TextDecoder,this.#i4=new DataView(this.#i5),e&&Object.assign(this,e)}#ss(t){x(t<eq.bools.length,"Invalid boolean index");let e=Math.floor(t/4),i=this.#i4.getUint8(e)>>2*t%8&3;return 0===i?void 0:2===i}get black(){return this.#ss(0)}get bold(){return this.#ss(1)}get disableFontFace(){return this.#ss(2)}get fontExtraProperties(){return this.#ss(3)}get isInvalidPDFjsFont(){return this.#ss(4)}get isType3Font(){return this.#ss(5)}get italic(){return this.#ss(6)}get missingFile(){return this.#ss(7)}get remeasure(){return this.#ss(8)}get vertical(){return this.#ss(9)}#sr(t){return x(t<eq.numbers.length,"Invalid number index"),this.#i4.getFloat64(eq.#i7+8*t)}get ascent(){return this.#sr(0)}get defaultWidth(){return this.#sr(1)}get descent(){return this.#sr(2)}get bbox(){let t=eq.#i9;if(0===this.#i4.getUint8(t))return;t+=1;let e=[];for(let i=0;i<4;i++)e.push(this.#i4.getInt16(t,!0)),t+=2;return e}get fontMatrix(){let t=eq.#st;if(0===this.#i4.getUint8(t))return;t+=1;let e=[];for(let i=0;i<6;i++)e.push(this.#i4.getFloat64(t,!0)),t+=8;return e}get defaultVMetrics(){let t=eq.#se;if(0===this.#i4.getUint8(t))return;t+=1;let e=[];for(let i=0;i<3;i++)e.push(this.#i4.getInt16(t,!0)),t+=2;return e}#i8(t){x(t<eq.strings.length,"Invalid string index");let e=eq.#si+4;for(let i=0;i<t;i++)e+=this.#i4.getUint32(e)+4;let i=this.#i4.getUint32(e),s=new Uint8Array(i);return s.set(new Uint8Array(this.#i5,e+4,i)),this.#i6.decode(s)}get fallbackName(){return this.#i8(0)}get loadedName(){return this.#i8(1)}get mimetype(){return this.#i8(2)}get name(){return this.#i8(3)}get data(){let t=eq.#si,e=this.#i4.getUint32(t);t+=4+e;let i=this.#i4.getUint32(t);t+=4+i;let s=this.#i4.getUint32(t);t+=4+s;let r=this.#i4.getUint32(t);if(0!==r)return new Uint8Array(this.#i5,t+4,r)}clearData(){let t=eq.#si,e=this.#i4.getUint32(t);t+=4+e;let i=this.#i4.getUint32(t);t+=4+i;let s=this.#i4.getUint32(t);t+=4+s;let r=this.#i4.getUint32(t);new Uint8Array(this.#i5,t+4,r).fill(0),this.#i4.setUint32(t,0)}get cssFontInfo(){let t=eq.#si,e=this.#i4.getUint32(t);t+=4+e;let i=this.#i4.getUint32(t);t+=4+i;let s=this.#i4.getUint32(t);if(0===s)return null;let r=new Uint8Array(s);return r.set(new Uint8Array(this.#i5,t+4,s)),new eV(r.buffer)}get systemFontInfo(){let t=eq.#si,e=this.#i4.getUint32(t);t+=4+e;let i=this.#i4.getUint32(t);if(0===i)return null;let s=new Uint8Array(i);return s.set(new Uint8Array(this.#i5,t+4,i)),new eW(s.buffer)}static write(t){let e=t.systemFontInfo?eW.write(t.systemFontInfo):null,i=t.cssFontInfo?eV.write(t.cssFontInfo):null,s=new TextEncoder,r={},n=0;for(let e of eq.strings)r[e]=s.encode(t[e]),n+=4+r[e].length;let a=new ArrayBuffer(eq.#si+4+n+4+(e?e.byteLength:0)+4+(i?i.byteLength:0)+4+(t.data?t.data.length:0)),o=new Uint8Array(a),l=new DataView(a),h=0,d=eq.bools.length,c=0,u=0;for(let e=0;e<d;e++){let i=t[eq.bools[e]];c|=(void 0===i?0:i?2:1)<<u,(8===(u+=2)||e===d-1)&&(l.setUint8(h++,c),c=0,u=0)}for(let e of(x(h===eq.#i7,"FontInfo.write: Boolean properties offset mismatch"),eq.numbers))l.setFloat64(h,t[e]),h+=8;if(x(h===eq.#i9,"FontInfo.write: Number properties offset mismatch"),t.bbox)for(let e of(l.setUint8(h++,4),t.bbox))l.setInt16(h,e,!0),h+=2;else l.setUint8(h++,0),h+=8;if(x(h===eq.#st,"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix)for(let e of(l.setUint8(h++,6),t.fontMatrix))l.setFloat64(h,e,!0),h+=8;else l.setUint8(h++,0),h+=48;if(x(h===eq.#se,"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics)for(let e of(l.setUint8(h++,1),t.defaultVMetrics))l.setInt16(h,e,!0),h+=2;else l.setUint8(h++,0),h+=6;for(let t of(x(h===eq.#si,"FontInfo.write: DefaultVMetrics properties offset mismatch"),l.setUint32(eq.#si,0),h+=4,eq.strings)){let e=r[t],i=e.length;l.setUint32(h,i),o.set(e,h+4),h+=4+i}if(l.setUint32(eq.#si,h-eq.#si-4),e){let t=e.byteLength;l.setUint32(h,t),x(h+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),o.set(new Uint8Array(e),h+4),h+=4+t}else l.setUint32(h,0),h+=4;if(i){let t=i.byteLength;l.setUint32(h,t),x(h+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),o.set(new Uint8Array(i),h+4),h+=4+t}else l.setUint32(h,0),h+=4;return void 0===t.data?(l.setUint32(h,0),h+=4):(l.setUint32(h,t.data.length),o.set(t.data,h+4),h+=4+t.data.length),x(h<=a.byteLength,"FontInfo.write: Buffer overflow"),a.transferTo
2FixedLength(h)}}class eX{static #sn=null;static #sa="";static get workerPort(){return this.#sn}static set workerPort(t){if(!("u">typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#sn=t}static get workerSrc(){return this.#sa}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#sa=t}}class eK{#so;#sl;constructor({parsedData:t,rawData:e}){this.#so=t,this.#sl=e}getRaw(){return this.#sl}get(t){return this.#so.get(t)??null}[Symbol.iterator](){return this.#so.entries()}}let eY=Symbol("INTERNAL");class eQ{#sh=!1;#sd=!1;#sc=!1;#su=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:r}){this.#sh=!!(2&t),this.#sd=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=r}get visible(){if(this.#sc)return this.#su;if(!this.#su)return!1;let{print:t,view:e}=this.usage;return this.#sh?e?.viewState!=="OFF":!this.#sd||t?.printState!=="OFF"}_setVisible(t,e,i=!1){t!==eY&&w("Internal method `_setVisible` called."),this.#sc=i,this.#su=e}}class eJ{#sp=null;#sg=new Map;#sm=null;#sf=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null===t)return;for(const i of(this.name=t.name,this.creator=t.creator,this.#sf=t.order,t.groups))this.#sg.set(i.id,new eQ(e,i));if("OFF"===t.baseState)for(const t of this.#sg.values())t._setVisible(eY,!1);for(const e of t.on)this.#sg.get(e)._setVisible(eY,!0);for(const e of t.off)this.#sg.get(e)._setVisible(eY,!1);this.#sm=this.getHash()}#sb(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let s=1;s<e;s++){let e,r=t[s];if(Array.isArray(r))e=this.#sb(r);else{if(!this.#sg.has(r))return A(`Optional content group not found: ${r}`),!0;e=this.#sg.get(r).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#sg.size)return!0;if(!t)return y("Optional content group not defined."),!0;if("OCG"===t.type)return this.#sg.has(t.id)?this.#sg.get(t.id).visible:(A(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#sb(t.expression);if(t.policy&&"AnyOn"!==t.policy){if("AllOn"===t.policy){for(let e of t.ids){if(!this.#sg.has(e)){A(`Optional content group not found: ${e}`);break}if(!this.#sg.get(e).visible)return!1}return!0}else if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#sg.has(e))return A(`Optional content group not found: ${e}`),!0;if(!this.#sg.get(e).visible)return!0}return!1}else if("AllOff"===t.policy){for(let e of t.ids){if(!this.#sg.has(e)){A(`Optional content group not found: ${e}`);break}if(this.#sg.get(e).visible)return!1}return!0}}else{for(let e of t.ids){if(!this.#sg.has(e))return A(`Optional content group not found: ${e}`),!0;if(this.#sg.get(e).visible)return!0}return!1}return A(`Unknown optional content policy ${t.policy}.`),!0}return A(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){let s=this.#sg.get(t);if(!s)return void A(`Optional content group not found: ${t}`);if(i&&e&&s.rbGroups.length)for(let e of s.rbGroups)for(let i of e)i!==t&&this.#sg.get(i)?._setVisible(eY,!1,!0);s._setVisible(eY,!!e,!0),this.#sp=null}setOCGState({state:t,preserveRB:e}){let i;for(let s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}let t=this.#sg.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#sp=null}get hasInitialVisibility(){return null===this.#sm||this.getHash()===this.#sm}getOrder(){return this.#sg.size?this.#sf?this.#sf.slice():[...this.#sg.keys()]:null}getGroup(t){return this.#sg.get(t)||null}getHash(){if(null!==this.#sp)return this.#sp;let t=new tO;for(let[e,i]of this.#sg)t.update(`${e}:${i.visible}`);return this.#sp=t.hexdigest()}[Symbol.iterator](){return this.#sg.entries()}}class eZ{constructor(t,{disableRange:e=!1,disableStream:i=!1}){x(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:r,progressiveDone:n,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=n,this._contentDispositionFilename=a,r?.length>0){const t=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i):x(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){x(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new e0(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new e1(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeReaders.slice(0)))e.cancel(t);this._pdfDataRangeTransport.abort()}}class e0{constructor(t,e,i=!1,s=null){for(const r of(this._stream=t,this._done=i||!1,this._filename=Z(s)?s:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=r.byteLength;
2this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class e1{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{for(let e of(this._requests.shift().resolve({value:t,done:!1}),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function e2(t,e){let i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(let t in e){let s=e[t];void 0!==s&&i.append(t,s)}return i}function e3(t){return URL.parse(t)?.origin??null}function e5({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){let r={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(t.get("Content-Length"),10);return Number.isInteger(n)&&(r.suggestedLength=n,n<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"!==(t.get("Content-Encoding")||"identity")||(r.allowRangeRequests=!0)),r}function e4(t){let e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){let t=a(i=i[1]);return n(t=l(t=o(t=unescape(t))))}if(i=function(t){let e,i=[],r=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=r.exec(t));){let[,t,s,r]=e;if((t=parseInt(t,10))in i){if(0===t)break;continue}i[t]=[s,r]}let n=[];for(let t=0;t<i.length&&t in i;++t){let[e,s]=i[t];s=a(s),e&&(s=unescape(s),0===t&&(s=o(s))),n.push(s)}return n.join("")}(t))return n(l(i));if(i=s("filename","i").exec(t)){let t=a(i=i[1]);return n(t=l(t))}function s(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function r(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let s=new TextDecoder(t,{fatal:!0}),r=L(i);i=s.decode(r),e=!1}catch{}}return i}function n(t){return e&&/[\x80-\xff]/.test(t)&&(t=r("utf-8",t),e&&(t=r("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){let e=t.indexOf("'");return -1===e?t:r(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return r(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return r(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Z(t))return t}return null}function e6(t,e){return new k(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function e8(t){return 200===t||206===t}function e7(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function e9(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(A(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class it{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=e2(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return x(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ie(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new ii(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class ie{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,e7(i,this._withCredentials,this._abortController)).then(e=>
2{if(t._responseOrigin=e3(e.url),!e8(e.status))throw e6(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();let i=e.headers,{allowRangeRequests:r,suggestedLength:n}=e5({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=n||this._contentLength,this._filename=e4(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new I("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}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(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:e9(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ii{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const r=new Headers(t.headers);r.append("Range",`bytes=${e}-${i-1}`);const n=s.url;fetch(n,e7(r,this._withCredentials,this._abortController)).then(e=>{let i=e3(e.url);if(i!==t._responseOrigin)throw Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!e8(e.status))throw e6(e.status,n);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:e9(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class is{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=e2(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};for(let[t,i]of(e.open("GET",this.url),e.withCredentials=this.withCredentials,this.headers))e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",x(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){let i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){let i,s=this.pendingRequests[t];if(!s)return;let r=s.xhr;if(r.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==r.readyState||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===r.status&&this.isHttp)return void s.onError(r.status);let n=r.status||200;if((200!==n||206!==s.expectedStatus)&&n!==s.expectedStatus)return void s.onError(r.status);let a="string"!=typeof(i=r.response)?i:L(i).buffer;if(206===n){let t=r.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?s.onDone({begin:parseInt(e[1],10),chunk:a}):(A('Missing or invalid "Content-Range" header.'),s.onError(0))}else a?s.onDone({begin:0,chunk:a}):s.onError(r.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class ir{constructor(t){this._source=t,this._manager=new is(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return x(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new ia(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let i=new io(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class ia{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=e3(e.responseURL);let i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{let[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:n}=e5({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=e4(s),this._isRangeSupported&&this._manager.abortRequest
2(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(let e of(this._storedError=e6(t,this._url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class io{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=e3(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;for(let t of(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){for(let e of(this._storedError??=e6(t,this._url),this._requests))e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}let il=/^[a-z][a-z0-9\-+.]+:/i;class ih{constructor(t){this.source=t,this.url=function(t){return new URL(il.test(t)?t:s.getBuiltinModule("url").pathToFileURL(t))}(t.url),x("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return x(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new id(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new ic(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class id{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=s.getBuiltinModule("fs");i.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=e6(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)})}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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new I("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class ic{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const r=t.source;this._isStreamingSupported=!r.disableStream;const n=s.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}let iu=Symbol("INITIAL_DATA");class ip{#sv=Object.create(null);#sy(t){return this.#sv[t]||={...Promise.withResolvers(),data:iu}}get(t,e=null){if(e){let i=this.#sy(t);return i.promise.then(()=>e(i.data)),null}let i=this.#sv[t];if(!i||i.data===iu)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#sv[t];return!!e&&e.data!==iu}delete(t){let e=this.#sv[t];return!!e&&e.data!==iu&&(delete this.#sv[t],!0)}resolve(t,e=null){let i=this.#sy(t);i.data=e,i.resolve()}clear(){for(let t in this.#sv){let{data:e}=this.#sv[t];e?.bitmap?.close()}this.#sv=Object.create(null)}*[Symbol.iterator](){for(let t in this.#sv){let{data:e}=this.#sv[t];e!==iu&&(yield[t,e])}}}class ig{#sA=Promise.withResolvers();#tw=null;#sw=!1;#sx=!!globalThis.FontInspector?.enabled;#s_=null;#sC=null;#sS=0;#sE=0;#sT=null;#sM=null;#sD=0;#sk=0;#sP=Object.create(null);#sI=[];#sR=null;#sL=[];#sF=new WeakMap;#sB=null;static #sN=new Map;static #sO=new Map;static #sU=new WeakMap;static #sz=null;static #sH=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#sR=t;else if("object"==typeof t)this.#sR=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error('No "textContentSource" parameter specified.');
2this.#tw=this.#sM=e,this.#sk=i.scale*tu.pixelRatio,this.#sD=i.rotation,this.#sC={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:r,pageX:n,pageY:a}=i.rawDims;this.#sB=[1,0,0,-1,-n,a+r],this.#sE=s,this.#sS=r,ig.#s$(),tc(e,i),this.#sA.promise.finally(()=>{ig.#sH.delete(this),this.#sC=null,this.#sP=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=F.platform;return S(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#sT.read().then(({value:e,done:i})=>{i?this.#sA.resolve():(this.#s_??=e.lang,Object.assign(this.#sP,e.styles),this.#sj(e.items),t())},this.#sA.reject)};return this.#sT=this.#sR.getReader(),ig.#sH.add(this),t(),this.#sA.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*tu.pixelRatio,s=t.rotation;if(s!==this.#sD&&(e?.(),this.#sD=s,tc(this.#sM,{rotation:s})),i!==this.#sk){e?.(),this.#sk=i;let t={div:null,properties:null,ctx:ig.#sG(this.#s_)};for(let e of this.#sL)t.properties=this.#sF.get(e),t.div=e,this.#sV(t)}}cancel(){let t=new I("TextLayer task cancelled.");this.#sT?.cancel(t).catch(()=>{}),this.#sT=null,this.#sA.reject(t)}get textDivs(){return this.#sL}get textContentItemsStr(){return this.#sI}#sj(t){if(this.#sw)return;this.#sC.ctx??=ig.#sG(this.#s_);let e=this.#sL,i=this.#sI;for(let s of t){if(e.length>1e5){A("Ignoring additional textDivs for performance reasons."),this.#sw=!0;return}if(void 0===s.str){if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){let t=this.#tw;this.#tw=document.createElement("span"),this.#tw.classList.add("markedContent"),s.id&&this.#tw.setAttribute("id",`${s.id}`),t.append(this.#tw)}else"endMarkedContent"===s.type&&(this.#tw=this.#tw.parentNode);continue}i.push(s.str),this.#sW(s)}}#sW(t){let e,i,s=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#sL.push(s);let n=N.transform(this.#sB,t.transform),a=Math.atan2(n[1],n[0]),o=this.#sP[t.fontName];o.vertical&&(a+=Math.PI/2);let l=this.#sx&&o.fontSubstitution||o.fontFamily;l=ig.fontFamilyMap.get(l)||l;let h=Math.hypot(n[2],n[3]),d=h*ig.#sq(l,o,this.#s_);0===a?(e=n[4],i=n[5]-d):(e=n[4]+d*Math.sin(a),i=n[5]-d*Math.cos(a));let c="calc(var(--total-scale-factor) *",u=s.style;this.#tw===this.#sM?(u.left=`${(100*e/this.#sE).toFixed(2)}%`,u.top=`${(100*i/this.#sS).toFixed(2)}%`):(u.left=`${c}${e.toFixed(2)}px)`,u.top=`${c}${i.toFixed(2)}px)`),u.fontSize=`${c}${(ig.#sz*h).toFixed(2)}px)`,u.fontFamily=l,r.fontSize=h,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,this.#sx&&(s.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),0!==a&&(r.angle=180/Math.PI*a);let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(r.canvasWidth=o.vertical?t.height:t.width),this.#sF.set(s,r),this.#sC.div=s,this.#sC.properties=r,this.#sV(this.#sC),r.hasText&&this.#tw.append(s),r.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#tw.append(t)}}#sV(t){let{div:e,properties:i,ctx:s}=t,{style:r}=e,n="";if(ig.#sz>1&&(n=`scale(${1/ig.#sz})`),0!==i.canvasWidth&&i.hasText){let{fontFamily:t}=r,{canvasWidth:a,fontSize:o}=i;ig.#sX(s,o*this.#sk,t);let{width:l}=s.measureText(e.textContent);l>0&&(n=`scaleX(${a*this.#sk/l}) ${n}`)}0!==i.angle&&(n=`rotate(${i.angle}deg) ${n}`),n.length>0&&(r.transform=n)}static cleanup(){if(!(this.#sH.size>0)){for(let{canvas:t}
2of(this.#sN.clear(),this.#sO.values()))t.remove();this.#sO.clear()}}static #sG(t=null){let e=this.#sO.get(t||="");if(!e){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#sO.set(t,e),this.#sU.set(e,{size:0,family:""})}return e}static #sX(t,e,i){let s=this.#sU.get(t);(e!==s.size||i!==s.family)&&(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static #s$(){if(null!==this.#sz)return;let 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.#sz=t.getBoundingClientRect().height,t.remove()}static #sq(t,e,i){let s=this.#sN.get(t);if(s)return s;let r=this.#sG(i);r.canvas.width=r.canvas.height=30,this.#sX(r,30,t);let n=r.measureText(""),a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let l=.8;return a?l=a/(a+o):(F.platform.isFirefox&&A("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.desce
2nt)),this.#sN.set(t,l),l}}function im(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e=new ib,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(a)return t;let e=URL.parse(t,window.location);if(e)return e.href}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(a&&void 0!==r&&t instanceof r)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return L(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,o=t.httpHeaders||null,l=!0===t.withCredentials,h=t.password??null,d=t.range instanceof iv?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,u=t.worker instanceof iw?t.worker:null,p=t.verbosity,g="string"!=typeof t.docBaseUrl||J(t.docBaseUrl)?null:t.docBaseUrl,m=tG(t.cMapUrl),f=!1!==t.cMapPacked,b=t.CMapReaderFactory||(a?et:t0),y=tG(t.iccUrl),A=tG(t.standardFontDataUrl),w=t.StandardFontDataFactory||(a?ee:t5),x=tG(t.wasmUrl),_=t.WasmFactory||(a?ei:t6),C=!0!==t.stopAtErrors,S=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,E=!1!==t.isEvalSupported,T="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!a,M="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!a&&(F.platform.isFirefox||!globalThis.chrome),D=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,k="boolean"==typeof t.disableFontFace?t.disableFontFace:a,P=!0===t.fontExtraProperties,I=!0===t.enableXfa,R=t.ownerDocument||globalThis.document,B=!0===t.disableRange,N=!0===t.disableStream,O=!0===t.disableAutoFetch,U=!0===t.pdfBug,z=t.CanvasFactory||(a?t9:tJ),H=t.FilterFactory||(a?t7:t2),$=!0===t.enableHWA,j=!1!==t.useWasm,G=d?d.length:t.length??NaN,V="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!a&&!k,W="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(b===t0&&w===t5&&_===t6&&m&&A&&x&&ts(m,document.baseURI)&&ts(A,document.baseURI)&&ts(x,document.baseURI));Number.isInteger(p)&&(v=p);let q={canvasFactory:new z({ownerDocument:R,enableHWA:$}),filterFactory:new H({docId:i,ownerDocument:R}),cMapReaderFactory:W?null:new b({baseUrl:m,isCompressed:f}),standardFontDataFactory:W?null:new w({baseUrl:A}),wasmFactory:W?null:new _({baseUrl:x})};u||(e._worker=u=iw.create({verbosity:p,port:eX.workerPort}));let X={docId:i,apiVersion:"5.4.296",data:n,password:h,disableAutoFetch:O,rangeChunkSize:c,length:G,docBaseUrl:g,enableXfa:I,evaluatorOptions:{maxImageSize:S,disableFontFace:k,ignoreErrors:C,isEvalSupported:E,isOffscreenCanvasSupported:T,isImageDecoderSupported:M,canvasMaxAreaInBytes:D,fontExtraProperties:P,useSystemFonts:V,useWasm:j,useWorkerFetch:W,cMapUrl:m,iccUrl:y,standardFontDataUrl:A,wasmUrl:x}},K={ownerDocument:R,pdfBug:U,styleElement:null,loadingParams:{disableAutoFetch:O,enableXfa:I}};return u.promise.then(function(){let t;if(e.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let r=u.messageHandler.sendWithPromise("GetDocRequest",X,n?[n.buffer]:null);if(d)t=new eZ(d,{disableRange:B,disableStream:N});else if(!n){if(!s)throw Error("getDocument - no `url` parameter provided.");t=new(ts(s)?it:a?ih:ir)({url:s,length:G,httpHeaders:o,withCredentials:l,rangeChunkSize:c,disableRange:B,disableStream:N})}return r.then(s=>{if(e.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let r=new tY(i,s,u.port),n=new ix(r,e,t,K,q,$);e._transport=n,r.send("Ready",null)})}).catch(e._capability.reject),e}class ib{static #ib=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${ib.#ib++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),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()}}class iv{#sA=Promise.withResolvers();#sK=[];#sY=[];#sQ=[];#sJ=[];constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}
2addRangeListener(t){this.#sJ.push(t)}addProgressListener(t){this.#sQ.push(t)}addProgressiveReadListener(t){this.#sY.push(t)}addProgressiveDoneListener(t){this.#sK.push(t)}onDataRange(t,e){for(let i of this.#sJ)i(t,e)}onDataProgress(t,e){this.#sA.promise.then(()=>{for(let i of this.#sQ)i(t,e)})}onDataProgressiveRead(t){this.#sA.promise.then(()=>{for(let e of this.#sY)e(t)})}onDataProgressiveDone(){this.#sA.promise.then(()=>{for(let t of this.#sK)t()})}transportReady(){this.#sA.resolve()}requestDataRange(t,e){w("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class iy{constructor(t,e){this._pdfInfo=t,this._transport=e}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 S(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class iA{#sZ=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new ti:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new ip,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}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:r=!1}={}){return new Y({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}getAnnotations({intent:t="display"}={}){let{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 S(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}
2render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:r=l.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:h=null,pageColors:d=null,printAnnotationStorage:c=null,isEditing:u=!1,recordOperations:p=!1,operationsFilter:g=null}){this._stats?.time("Overall");let m=this._transport.getRenderingIntent(s,r,c,u),{renderingIntent:f,cacheKey:b}=m;this.#sZ=!1,o||=this._transport.getOptionalContentConfig(f);let v=this._intentStates.get(b);v||(v=Object.create(null),this._intentStates.set(b,v)),v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);let y=!!(4&f);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(m));let A=!!(this._pdfBug&&globalThis.StepperManager?.enabled),w=!this.recordedBBoxes&&(p||A),x=t=>{if(v.renderTasks.delete(_),w){let t=_.gfx?.dependencyTracker.take();t&&(_.stepper&&_.stepper.setOperatorBBoxes(t,_.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=t))}y&&(this.#sZ=!0),this.#s0(),t?(_.capability.reject(t),this._abortOperatorList({intentState:v,reason:t instanceof Error?t:Error(t)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new iC({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:w?new ed(e,v.operatorList.length,A):null,viewport:i,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!y,pdfBug:this._pdfBug,pageColors:d,enableHWA:this._transport.enableHWA,operationsFilter:g});(v.renderTasks||=new Set).add(_);let C=_.task;return Promise.all([v.displayReadyCapability.promise,o]).then(([t,e])=>{if(this.destroyed)return void x();if(this._stats?.time("Rendering"),!(e.renderingIntent&f))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:t,optionalContentConfig:e}),_.operatorListChanged()}).catch(x),C}getOperatorList({intent:t="display",annotationMode:e=l.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){let r,n=this._transport.getRenderingIntent(t,e,i,s,!0),a=this._intentStates.get(n.cacheKey);return a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a)),a.opListReadCapability||((r=Object.create(null)).operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(r))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(r),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>V.textContent(t));let e=this.streamTextContent(t);return new Promise(function(t,i){let s=e.getReader(),r={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then(function({value:i,done:s}){s?t(r):(r.lang??=i.lang,Object.assign(r.styles,i.styles),r.items.push(...i.items),e())},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#sZ=!1,Promise.all(t)}cleanup(t=!1){this.#sZ=!0;let e=this.#s0();
2return t&&e&&(this._stats&&=new ti),e}#s0(){if(!this.#sZ||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#sZ=!1,!0}_startRenderPage(t,e){let 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]);for(let i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&this.#s0()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){let{map:r,transfer:n}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:s},n).getReader(),o=this._intentStates.get(e);o.streamReader=a;let l=()=>{a.read().then(({value:t,done:e})=>{if(e){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){for(let t of(o.operatorList.lastChunk=!0,o.renderTasks))t.operatorListChanged();this.#s0()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else if(o.opListReadCapability)o.opListReadCapability.reject(t);else throw t}})};l()}_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 Q){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new I(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class iw{#sA=Promise.withResolvers();#s1=null;#sn=null;#s2=null;static #s3=0;static #s5=!1;static #s4=new WeakMap;static{a&&(this.#s5=!0,eX.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;let s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},this.fromPort=t=>{if(console.log("Deprecated API usage: `PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:i=v}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(iw.#s4.has(e))throw Error("Cannot use more than one PDFWorker per port.");iw.#s4.set(e,this),this.#s6(e)}else this.#s8()}get promise(){return this.#sA.promise}#s7(){this.#sA.resolve(),this.#s1.send("configure",{verbosity:this.verbosity})}get port(){return this.#sn}get messageHandler(){return this.#s1}#s6(t){this.#sn=t,this.#s1=new tY("main","worker",t),this.#s1.on("ready",()=>{}),this.#s7()}#s8(){if(iw.#s5||iw.#s9)return void this.#rt();let{workerSrc:t}=iw;try{iw._isSameOrigin(window.location,t)||(t=iw._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new tY("main","worker",e),s=()=>{r.abort(),i.destroy(),e.terminate(),this.destroyed?this.#sA.reject(Error("Worker was destroyed")):this.#rt()},r=new AbortController;e.addEventListener("error",()=>{this.#s2||s()},{signal:r.signal}),i.on("test",t=>{(r.abort(),this.destroyed||!t)?s():(this.#s1=i,this.#sn=e,this.#s2=e,this.#s7())}),i.on("ready",t=>{if(r.abort(),this.destroyed)return void s();try{n()}catch{this.#rt()}});let n=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};n();return}catch{y("The worker has been disabled.")}this.#rt()}#rt(){iw.#s5||(A("Setting up fake worker."),iw.#s5=!0),iw._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this.#sA.reject(Error("Worker was destroyed"));let e=new tq;this.#sn=e;let i=`fake${iw.#s3++}`,s=new tY(i+"_worker",i,e);t.setup(s,e),this.#s1=new tY(i,i+"_worker",e),this.#s7()}).catch(t=>{this.#sA.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#s2?.terminate(),this.#s2=null,iw.#s4.delete(this.#sn),this.#sn=null,this.#s1?.destroy(),this.#s1=null}static create(t){let e=this.#s4.get(t?.port);
2if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new iw(t)}static get workerSrc(){if(eX.workerSrc)return eX.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #s9(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return S(this,"_setupFakeWorkerGlobal",(async()=>this.#s9?this.#s9:(await import(this.workerSrc)).WorkerMessageHandler)())}}class ix{#re=new Map;#ri=new Map;#rs=new Map;#rr=new Map;#rn=null;constructor(t,e,i,s,r,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new ip,this.fontLoader=new t$({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.wasmFactory=r.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=n,this.setupMessageHandler()}#ra(t,e=null){let i=this.#re.get(t);if(i)return i;let s=this.messageHandler.sendWithPromise(t,e);return this.#re.set(t,s),s}get annotationStorage(){return S(this,"annotationStorage",new tz)}getRenderingIntent(t,e=l.ENABLE,i=null,s=!1,r=!1){let n=2,a=tU;switch(t){case"any":n=1;break;case"display":break;case"print":n=4;break;default:A(`getRenderingIntent - invalid intent: ${t}`)}let o=4&n&&i instanceof tH?i:this.annotationStorage;switch(e){case l.DISABLE:n+=64;break;case l.ENABLE:break;case l.ENABLE_FORMS:n+=16;break;case l.ENABLE_STORAGE:n+=32,a=o.serializable;break;default:A(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(n+=128),r&&(n+=256);let{ids:h,hash:d}=o.modifiedIds,c=[n,a.hash,d];return{renderingIntent:n,cacheKey:c.join("_"),annotationStorageSerializable:a,modifiedIds:h}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#rn?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#ri.values())t.push(e._destroy());this.#ri.clear(),this.#rs.clear(),this.#rr.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#re.clear(),this.filterFactory.destroy(),ig.cleanup(),this._networkStream?.cancelAllRequests(new I("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{x(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:i}){i?e.close():(x(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this._fullReader.headersReady;let{isStreamingSupported:i,isRangeSupported:s,contentLength:r}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:r}}),t.on("GetRangeReader",(t,e)=>{x(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(x(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new iy(t,this))}),t.on("DocException",t=>{e._capability.reject(tK(t))}
2),t.on("PasswordRequest",t=>{this.#rn=Promise.withResolvers();try{if(!e.onPassword)throw tK(t);let i=t=>{t instanceof Error?this.#rn.reject(t):this.#rn.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#rn.reject(t)}return this.#rn.promise}),t.on("DataLoaded",t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#ri.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){let t=s.error;A(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let r=new tj(new eq(s),this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,s.extra,s.charProcOperatorList);this.fontLoader.bind(r).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!r.fontExtraProperties&&r.data&&r.clearData(),this.commonObjs.resolve(e,r)});break;case"CopyLocalImage":let{imageRef:n}=s;for(let t of(x(n,"The imageRef must be defined."),this.#ri.values()))for(let[,i]of t.objs)if(i?.ref===n){if(!i.dataLen)return null;return this.commonObjs.resolve(e,structuredClone(i)),i.dataLen}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;let r=this.#ri.get(e);if(!r.objs.has(t)){if(0===r._intentStates.size)return void s?.bitmap?.close();switch(i){case"Image":case"Pattern":r.objs.resolve(t,s);break;default:throw Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");let e=this[t.type];if(!e)throw Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&A("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.#rs.get(e);if(i)return i;let s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw Error("Transport destroyed");i.refStr&&this.#rr.set(i.refStr,t);let s=new iA(e,i,this,this._params.pdfBug);return this.#ri.set(e,s),s});return this.#rs.set(e,s),s}getPageIndex(t){return tV(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#ra("GetFieldObjects")}hasJSActions(){return this.#ra("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithProm
2ise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#ra("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#ra("GetOptionalContentConfig").then(e=>new eJ(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#re.get(t);if(e)return e;let i=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new eK(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#re.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){for(let t of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#ri.values()))if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#re.clear(),this.filterFactory.destroy(!0),ig.cleanup()}}cachedPageNumber(t){if(!tV(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#rr.get(e)??null}}class i_{#ro=null;onContinue=null;onError=null;constructor(t){this.#ro=t}get promise(){return this.#ro.capability.promise}cancel(t=0){this.#ro.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#ro.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#ro;return t.form||t.canvas&&e?.size>0}}class iC{#rl=null;static #rh=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:r,operatorList:n,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null,enableHWA:u=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"u">typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new i_(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=u,this._dependencyTracker=e.dependencyTracker,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(iC.#rh.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");iC.#rh.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());let{viewport:i,transform:s,background:r,dependencyTracker:n}=this.params,a=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new eG(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,n),this.gfx.beginDrawing({transform:s,viewport:i,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#rl&&(window.cancelAnimationFrame(this.#rl),this.#rl=null),iC.#rh.delete(this._canvas),t||=new Q(`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.#rl=window.requestAnimationFrame(()=>{this.#rl=null,this._nextBound().catch(this._cancelBound)}
2):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(),iC.#rh.delete(this._canvas),this.callback())))}}let iS="5.4.296",iE="f56dc8601";class iT{#rd=null;#rc=null;#ru;#rp=null;#rg=!1;#rm=!1;#n=null;#rf;#rb=null;#b=null;static #rv=null;static get _keyboardManager(){return S(this,"_keyboardManager",new tk([[["Escape","mac+Escape"],iT.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],iT.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],iT.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],iT.prototype._moveToPrevious],[["Home","mac+Home"],iT.prototype._moveToBeginning],[["End","mac+End"],iT.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#rm=!1,this.#n=t):this.#rm=!0,this.#b=t?._uiManager||e,this.#rf=this.#b._eventBus,this.#ru=t?.color?.toUpperCase()||this.#b?.highlightColors.values().next().value||"#FFFF98",iT.#rv||=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(){let t=this.#rd=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#n&&(t.ariaControls=`${this.#n.id}_colorpicker_dropdown`);let e=this.#b._signal;t.addEventListener("click",this.#ry.bind(this),{signal:e}),t.addEventListener("keydown",this.#rA.bind(this),{signal:e});let i=this.#rc=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#ru,t.append(i),t}renderMainDropdown(){let t=this.#rp=this.#rw();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#rw(){let t=document.createElement("div"),e=this.#b._signal;for(let[i,s]of(t.addEventListener("contextmenu",tr,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#n&&(t.id=`${this.#n.id}_colorpicker_dropdown`),this.#b.highlightColors)){let r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",s),r.title=i,r.setAttribute("data-l10n-id",iT.#rv[i]);let n=document.createElement("span");r.append(n),n.className="swatch",n.style.backgroundColor=s,r.ariaSelected=s===this.#ru,r.addEventListener("click",this.#rx.bind(this,s),{signal:e}),t.append(r)}return t.addEventListener("keydown",this.#rA.bind(this),{signal:e}),t}#rx(t,e){e.stopPropagation(),this.#rf.dispatch("switchannotationeditorparams",{source:this,type:c.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#rd)return void this.#ry(t);let e=t.target.getAttribute("data-color");e&&this.#rx(e,t)}_moveToNext(t){this.#r_?t.target===this.#rd?this.#rp.firstChild?.focus():t.target.nextSibling?.focus():this.#ry(t)}_moveToPrevious(t){if(t.target===this.#rp?.firstChild||t.target===this.#rd){this.#r_&&this._hideDropdownFromKeyboard();return}this.#r_||this.#ry(t),t.target.previousSibling?.focus()}_moveToBeginning(t){this.#r_?this.#rp.firstChild?.focus():this.#ry(t)}_moveToEnd(t){this.#r_?this.#rp.lastChild?.focus():this.#ry(t)}#rA(t){iT._keyboardManager.exec(this,t)}#ry(t){if(this.#r_)return void this.hideDropdown();if(this.#rg=0===t.detail,this.#rb||(this.#rb=new AbortController,window.addEventListener("pointerdown",this.#u.bind(this),{signal:this.#b.combinedSignal(this.#rb)})),this.#rd.ariaExpanded="true",this.#rp)return void this.#rp.classList.remove("hidden");let e=this.#rp=this.#rw();this.#rd.append(e)}#u(t){this.#rp?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#rp?.classList.add("hidden"),this.#rd.ariaExpanded="false",this.#rb?.abort(),this.#rb=null}get #r_(){return this.#rp&&!this.#rp.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#rm){if(!this.#r_)return void this.#n?.unselect();this.hideDropdown(),this.#rd.focus({preventScroll:!0,focusVisible:this.#rg})}}updateColor(t){if(this.#rc&&(this.#rc.style.backgroundColor=t),!this.#rp)return;let e=this.#b.highlightColors.values();for(let i of this.#rp.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#rd?.remove(),this.#rd=null,this.#rc=null,this.#rp?.remove(),this.#rp=null}}class iM{#rC=null;#n=null;
2#b=null;static #rv=null;constructor(t){this.#n=t,this.#b=t._uiManager,iM.#rv||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#rC)return this.#rC;let{editorType:t,colorType:e,colorValue:i}=this.#n,s=this.#rC=document.createElement("input");return s.type="color",s.value=i||"#000000",s.className="basicColorPicker",s.tabIndex=0,s.setAttribute("data-l10n-id",iM.#rv[t]),s.addEventListener("input",()=>{this.#b.updateParams(e,s.value)},{signal:this.#b._signal}),s}update(t){this.#rC&&(this.#rC.value=t)}destroy(){this.#rC?.remove(),this.#rC=null}hideDropdown(){}}function iD(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function ik(t){return Math.max(0,Math.min(255,255*t))}class iP{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=ik(t),t,t]}static G_HTML([t]){let e=iD(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(ik)}static RGB_HTML(t){return`#${t.map(iD).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[ik(1-Math.min(1,t+s)),ik(1-Math.min(1,i+s)),ik(1-Math.min(1,e+s))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){let s=1-t,r=1-e,n=1-i,a=Math.min(s,r,n);return["CMYK",s,r,n,a]}}class iI{create(t,e,i=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let 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("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){w("Abstract method `_createSVG` called.")}}class iR extends iI{_createSVG(t){return document.createElementNS(q,t)}}let iL=new WeakSet,iF=60*new Date().getTimezoneOffset()*1e3;class iB{static create(t){switch(t.data.annotationType){case g.LINK:return new iU(t);case g.TEXT:return new iz(t);case g.WIDGET:switch(t.data.fieldType){case"Tx":return new i$(t);case"Btn":if(t.data.radioButton)return new iV(t);if(t.data.checkBox)return new iG(t);return new iW(t);case"Ch":return new iq(t);case"Sig":return new ij(t)}return new iH(t);case g.POPUP:return new iX(t);case g.FREETEXT:return new iY(t);case g.LINE:return new iQ(t);case g.SQUARE:return new iJ(t);case g.CIRCLE:return new iZ(t);case g.POLYLINE:return new i0(t);case g.CARET:return new i2(t);case g.INK:return new i3(t);case g.POLYGON:return new i1(t);case g.HIGHLIGHT:return new i5(t);case g.UNDERLINE:return new i4(t);case g.SQUIGGLY:return new i6(t);case g.STRIKEOUT:return new i8(t);case g.STAMP:return new i7(t);case g.FILEATTACHMENT:return new i9(t);default:return new iN(t)}}}class iN{#rS=null;#rE=!1;#rT=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,e&&(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 iN._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}
2get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:i,rect:s}=this.data,r=-1/0,n=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>n?(n=e[t+1],r=e[t+2]):e[t+1]===n&&(r=Math.max(r,e[t+2]));return[r,n]}if(i?.length>=1){for(let t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>n?(n=t[e+1],r=t[e]):t[e+1]===n&&(r=Math.max(r,t[e]));if(r!==1/0)return[r,n]}return s?[s[2],s[3]]:null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:r,pageY:n}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/i,t[1]=100*(t[1]-n)/s,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${h}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${h}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#rT?.popup||this.popup)?.remove(),this.#rT=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#rS||={rect:this.data.rect.slice(0)});let{rect:e,popup:i}=t;e&&this.#rM(e);let s=this.#rT?.popup||this.popup;!s&&i?.text&&(this._createPopup(i),s=this.#rT.popup),s&&(s.updateEdited(t),i?.deleted&&(s.remove(),this.#rT=null,this.popup=null))}resetEdited(){this.#rS&&(this.#rM(this.#rS.rect),this.#rT?.popup.resetEdited(),this.#rS=null)}#rM(t){let{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=`${100*(t[0]-a)/r}%`,e.top=`${100*(n-t[3]+o)/n}%`,0===s?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/n}%`):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:i,viewport:s}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),this instanceof iH||this instanceof iU||(r.tabIndex=0);let{style:n}=r;if(n.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof iX){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,r),r}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch(t>0||i>0?n.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`:this instanceof iV&&(n.borderRadius=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`),e.borderStyle.style){case 1:n.borderStyle="solid";break;case 2:n.borderStyle="dashed";break;case 3:A("Unimplemented border style: beveled");break;case 4:A("Unimplemented border style: inset");break;case 5:n.borderBottomStyle="solid"}let s=e.borderColor||null;s?(this.#rE=!0,n.borderColor=N.makeHexColor(0|s[0],0|s[1],0|s[2])):n.borderWidth=0}let l=N.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:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;n.left=`${100*(l[0]-c)/h}%`,n.top=`${100*(l[1]-u)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||0===p?(n.width=`${100*a/h}%`,n.height=`${100*o/d}%`):this.setRotation(p,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:r,height:n}=this;t%180!=0&&([r,n]=[n,r]),e.style.width=`${100*r/i}%`,e.style.height=`${100*n/s}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let s=i.detail[t],r=s[0],n=s.slice(1);i.target.style[e]=iP[`${r}_HTML`](n),this.annotationStorage.setValue(this.data.id,{[e]:iP[`${r}_rgb`](n)})};return S(this,"_commonActions",{display:t=>{let{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>
2t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.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:t=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let s of Object.keys(e.detail)){let r=t[s]||i[s];r?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[s,r]of Object.entries(e)){let n=i[s];n&&(n({detail:{[s]:r},target:t}),delete e[s])}}_createQuadrilaterals(){let t;if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[i,s,r,n]=this.data.rect.map(t=>Math.fround(t));if(8===e.length){let[t,a,o,l]=e.subarray(2,6);if(r===t&&n===a&&i===o&&s===l)return}let{style:a}=this.container;if(this.#rE){let{borderColor:e,borderWidth:i}=a;a.borderWidth=0,t=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${e}" stroke-width="${i}">`],this.container.classList.add("hasBorder")}let o=r-i,l=n-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";let c=h.createElement("defs");d.append(c);let u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let s=2,r=e.length;s<r;
2s+=8){let r=e[s],a=e[s+1],d=e[s+2],c=e[s+3],p=h.createElement("rect"),g=(d-i)/o,m=(n-a)/l,f=(r-d)/o,b=(a-c)/l;p.setAttribute("x",g),p.setAttribute("y",m),p.setAttribute("width",f),p.setAttribute("height",b),u.append(p),t?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#rE&&(t.push("</g></svg>')"),a.backgroundImage=t.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){let e,i,{data:s}=this;t?(e={str:t.text},i=t.date):(e=s.contentsObj,i=s.modificationDate);let r=this.#rT=new iX({data:{color:s.color,titleObj:s.titleObj,modificationDate:i,contentsObj:e,richText:s.richText,parentRect:s.rect,borderStyle:0,id:`popup_${s.id}`,rotation:s.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]});this.parent._commentManager||this.parent.div.append(r.render())}get hasPopupElement(){return!!(this.#rT||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#rT}render(){w("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:t,id:r,exportValues:n}of s){if(-1===t||r===e)continue;let s="string"==typeof n?n:null,a=document.querySelector(`[data-element-id="${r}"]`);if(a&&!iL.has(a)){A(`_getElementsByName - element not allowed: ${r}`);continue}i.push({id:r,exportValue:s,domElement:a})}return i}for(let s of document.getElementsByName(t)){let{exportValue:t}=s,r=s.getAttribute("data-element-id");r!==e&&iL.has(s)&&i.push({id:r,exportValue:t,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(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class iO extends iN{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;t.hasComment&&(this._createPopup(t.comment),this.extraPopupElement.popup.renderCommentButton())}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.container.remove(),this.container=null,this.removePopup()}}class iU extends iN{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{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.#rD(i,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(this.#rk(i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["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.container.append(i),this.container}#rP(){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.#rP(),i&&(t.title=i)}
2_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#rP()}#rD(t,e,i="",s=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#rP()}#rk(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#rP()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let r=i.get(s);r&&(t[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#rP()}_bindResetFormAction(t,e){let i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#rP(),!this._fieldObjects){A('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();let{fields:t,refs:s,include:r}=e,n=[];if(0!==t.length||0!==s.length){let e=new Set(s);for(let i of t)for(let{id:t}of this._fieldObjects[i]||[])e.add(t);for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===r&&n.push(i)}else for(let t of Object.values(this._fieldObjects))n.push(...t);let a=this.annotationStorage,o=[];for(let t of n){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);if(i){if(!iL.has(i)){A(`_bindResetFormAction - element not allowed: ${e}`);continue}i.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class iz extends iN{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let 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._createPopup(),this.container.append(t),this.container}}class iH extends iN{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return F.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,r){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t)}})})}_setEventListeners(t,e,i,s){for(let[r,n]of i)("Action"===n||this.data.actions?.[n])&&(("Focus"===n||"Blur"===n)&&(e||={focused:!1}),this._setEventListener(t,e,r,n,s),"Focus"!==n||this.data.actions?.Blur?"Blur"!==n||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":N.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e,{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,r=t.style,n=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),i=Math.round(t/(1.35*s))||1;e=Math.min(s,n(t/i/1.35))}else e=Math.min(s,n(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));r.fontSize=`calc(${e}px * var(--total-scale-factor))`,r.color=N.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class i$ extends iH{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,s){let r=this.annotationStorage;
2for(let n of this._getElementsByName(t.name,t.id))n.domElement&&(n.domElement[e]=i),r.setValue(n.id,{[s]:i})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let s=t.getValue(e,{value:this.data.fieldValue}),r=s.value||"",n=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;n&&r.length>n&&(r=r.slice(0,n));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));let o={userValue:r,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((i=document.createElement("textarea")).textContent=a??r,this.data.doNotScroll&&(i.style.overflowY="hidden")):((i=document.createElement("input")).type=this.data.password?"password":"text",i.setAttribute("value",a??r),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),iL.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;let{datetimeFormat:l,datetimeType:h,timeStep:d}=this.data,c=!!h&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),n&&(i.maxLength=n),i.addEventListener("input",s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let u=t=>{let{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;let{target:e}=t;if(c&&(e.type=h,d&&(e.step=d)),o.userValue){let t=o.userValue;if(c)if("time"===h){let i=new Date(t);e.value=[i.getHours(),i.getMinutes(),i.getSeconds()].map(t=>t.toString().padStart(2,"0")).join(":")}else e.value=new Date(t-iF).toISOString().split("date"===h?"T":".",1)[0];else e.value=t}o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){o.userValue=i.detail.value??"",c||t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){let{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s);let r={formattedValue:s};c&&(r.value=s),t.setValue(e,r)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{let{charLimit:s}=i.detail,{target:r}=i;if(0===s)return void r.removeAttribute("maxLength");r.setAttribute("maxLength",s);let n=o.userValue;n&&!(n.length<=s)&&(r.value=o.userValue=n=n.slice(0,s),t.setValue(e,{value:n}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}}))}},i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;let{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});let s=u;u=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{target:i}=t,{value:r}=i;if(c){if(r&&"time"===h){let t=r.split(":").map(t=>parseInt(t,10));r=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else r.includes("T")||(r=`${r}T00:00`),r=new Date(r).valueOf();i.type="text"}o.userValue=r,o.lastCommittedValue!==r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;let{data:i,target:s}=t,{value:r,selectionStart:n,selectionEnd:a}=s,l=n,h=a;switch(t.inputType){case"deleteWordBackward":{let t=r.substring(0,n).match(/\w*[^\
2w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{let t=r.substring(n).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":n===a&&(l-=1);break;case"deleteContentForward":n===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(u&&i.addEventListener("blur",u),this.data.comb){let t=(this.data.rect[2]-this.data.rect[0])/n;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else(i=document.createElement("div")).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 ij extends iH{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class iG extends iH{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return iL.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,s&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",s=>{let{name:r,checked:n}=s.target;for(let s of this._getElementsByName(r,i)){let i=n&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:n})}),r.addEventListener("resetform",t=>{let i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class iV extends iH{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(let s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});let r=document.createElement("input");if(iL.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,s&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",e=>{let{name:s,checked:r}=e.target;for(let e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:r})}),r.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let s=e.buttonValue;r.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let r=s===e.detail.value;for(let s of this._getElementsByName(e.target.name)){let e=r&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}
2return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class iW extends iU{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class iq extends iH{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");iL.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 r=this.data.combo&&this.data.options.length>0;for(let t of(!this.data.combo&&(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue;for(let t of s.options)t.selected=t.value===e}),this.data.options)){let e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),r=!1),s.append(e)}let n=null;if(r){let t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),n=()=>{t.remove(),s.removeEventListener("input",n),n=null},s.addEventListener("input",n)}let a=t=>{let e=t?"value":"textContent",{options:i,multiple:r}=s;return r?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]},o=a(!1),l=t=>{let e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({value(i){n?.();let r=i.detail.value,l=new Set(Array.isArray(r)?r:[r]);for(let t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){let r=s.options,n=i.detail.remove;r[n].selected=!1,s.remove(n),r.length>0&&-1===Array.prototype.findIndex.call(r,t=>t.selected)&&(r[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){let{index:r,displayValue:n,exportValue:h}=i.detail.insert,d=s.children[r],c=document.createElement("option");c.textContent=n,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){let{items:r}=i.detail;for(;0!==s.length;)s.remove(0);for(let t of r){let{displayValue:e,exportValue:i}=t,r=document.createElement("option");r.textContent=e,r.value=i,s.append(r)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){let s=new Set(i.detail.indices);for(let t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)}),s.addEventListener("input",i=>{let s=a(!0),r=a(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:r,changeEx:s,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"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class iX extends iN{constructor(t){const{data:e,elements:i,parent:s}=t,r=!!s._commentManager;if(super(t,{isRenderable:!r&&iN._hasPopupData(e)}),this.elements=i,r&&iN._hasPopupData(e)){const t=this.popup=this.#rI();for(const e of i)e.popup=t}else this.popup=null}#rI(){return new iK({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,c
2ommentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#rI(),i=[];for(let t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${$}${t}`).join(",")),this.container}}class iK{#U=null;#rR=this.#rA.bind(this);#rL=this.#rF.bind(this);#rB=this.#rN.bind(this);#rO=this.#rU.bind(this);#rz=null;#tw=null;#rH=null;#r$=null;#rj=null;#rG=null;#rV=null;#rW=!1;#rq=null;#rX=null;#M=null;#rK=null;#rY=null;#es=null;#rQ=null;#t9=null;#rJ=null;#rS=null;#rZ=!1;#r0=null;#r1=null;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:r,contentsObj:n,richText:a,parent:o,rect:l,parentRect:h,open:d,commentManager:c=null}){this.#tw=t,this.#rJ=s,this.#rH=n,this.#t9=a,this.#rG=o,this.#rz=e,this.#rQ=l,this.#rV=h,this.#rj=i,this.#U=c,this.#r0=i[0],this.#r$=ta.toDateObject(r),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),c?this.renderCommentButton():(this.#r2(),this.#tw.hidden=!0,d&&this.#rU())}#r2(){if(this.#rX)return;this.#rX=new AbortController;let{signal:t}=this.#rX;for(let e of this.trigger)e.addEventListener("click",this.#rO,{signal:t}),e.addEventListener("pointerenter",this.#rB,{signal:t}),e.addEventListener("pointerleave",this.#rL,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#rj)e.container?.addEventListener("keydown",this.#rR,{signal:t})}#r3(){let t=this.#rj.find(t=>t.hasCommentButton);t&&(this.#rY=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#rK||(this.#rY||this.#r3(),!this.#rY))return;let{signal:t}=this.#rX=new AbortController,e=!!this.#r0.extraPopupElement,i=()=>{this.#U.toggleCommentPopup(this,!0,void 0,!e)},s=()=>{this.#U.toggleCommentPopup(this,!1,!0,!e)},r=()=>{this.#U.toggleCommentPopup(this,!1,!1)};if(e)for(let e of(this.#rK=this.#r0.container,this.trigger))e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#rR,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",r,{signal:t}),e.classList.add("popupTriggerArea");else{let e=this.#rK=document.createElement("button");e.className="annotationCommentButton";let n=this.#r0.container;e.style.zIndex=n.style.zIndex+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#r5(),this.#r4(),e.addEventListener("keydown",this.#rR,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",r,{signal:t}),n.after(e)}}#r4(){if(this.#r0.extraPopupElement&&!this.#r0.editor)return;this.renderCommentButton();let[t,e]=this.#rY,{style:i}=this.#rK;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#r5(){this.#r0.extraPopupElement||(this.renderCommentButton(),this.#rK.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){let{color:t,opacity:e}=this.#r0.commentData;return t?this.#rG._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#rK?.focus()},0)}getData(){let{richText:t,color:e,opacity:i,creationDate:s,modificationDate:r}=this.#r0.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:r}}get elementBeforePopup(){return this.#rK}get comment(){return this.#r1||=this.#r0.commentText,this.#r1}set comment(t){t!==this.comment&&(this.#r0.commentText=this.#r1=t)}get parentBoundingClientRect(){return this.#r0.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#rK&&(this.#rK.classList.toggle("selected",t),this.#rK.ariaExpanded=e)}setSelectedCommentButton(t){this.#rK.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#es)return this.#es;let{x:t,y:e,height:i}=this.#rK.getBoundingClientRect(),{x:s,y:r,width:n,height:a}=this.#r0.layer.getBoundingClientRect();return[(t-s)/n,(e+i-r)/a]}set commentPopupPosition(t){this.#es=t}hasDefaultPopupPosition(){return null===this.#es}get commentButtonPosition(){return this.#rY}get commentButtonWidth(){return this.#rK.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,i]=this.#es||this.commentButtonPosition.map(t=>t/100),s=this.parentBoundingClientRect,{x:r,y:n,width:a,height:o}=s;this.#U.showDialog(null,this,r+e*a,n+i*o,{...t,parentDimensions:s})}
2render(){if(this.#rq)return;let t=this.#rq=document.createElement("div");if(t.className="popup",this.#rz){let e=t.style.outlineColor=N.makeHexColor(...this.#rz);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#rJ?.str){let t=document.createElement("span");t.className="title",e.append(t),{dir:t.dir,str:t.textContent}=this.#rJ}if(t.append(e),this.#r$){let t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#r$.valueOf()})),t.dateTime=this.#r$.toISOString(),e.append(t)}t_({html:this.#r6||this.#rH.str,dir:this.#rH?.dir,className:"popupContent"},t),this.#tw.append(t)}get #r6(){let t=this.#t9,e=this.#rH;return t?.str&&(!e?.str||e.str===t.str)&&this.#t9.html||null}get #r8(){return this.#r6?.attributes?.style?.fontSize||0}get #r7(){return this.#r6?.attributes?.style?.color||null}#r9(t){let e=[],i={style:{color:this.#r7,fontSize:this.#r8?`calc(${this.#r8}px * var(--total-scale-factor))`:""}};for(let s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return{str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}}#rA(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#rW)&&this.#rU()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#U){i?(this.remove(),this.#r1=null):e&&(e.deleted?this.remove():(this.#r5(),this.#r1=e.text)),t&&(this.#rY=null,this.#r3(),this.#r4());return}i||e?.deleted?this.remove():(this.#r2(),this.#rS||={contentsObj:this.#rH,richText:this.#t9},t&&(this.#M=null),e&&e.text&&(this.#t9=this.#r9(e.text),this.#r$=ta.toDateObject(e.date),this.#rH=null),this.#rq?.remove(),this.#rq=null)}resetEdited(){this.#rS&&({contentsObj:this.#rH,richText:this.#t9}=this.#rS,this.#rS=null,this.#rq?.remove(),this.#rq=null,this.#M=null)}remove(){if(this.#rX?.abort(),this.#rX=null,this.#rq?.remove(),this.#rq=null,this.#rZ=!1,this.#rW=!1,this.#rK?.remove(),this.#rK=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#nt(){if(null!==this.#M)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:r}}}=this.#rG,n=!!this.#rV,a=n?this.#rV:this.#rQ;for(let t of this.#rj)if(!a||null!==N.intersect(t.data.rect,a)){a=t.data.rect,n=!0;break}let o=N.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=n?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#M=[100*(h-s)/e,100*(d-r)/i];let{style:c}=this.#tw;c.left=`${this.#M[0]}%`,c.top=`${this.#M[1]}%`}#rU(){this.#U?this.#U.toggleCommentPopup(this,!1):(this.#rW=!this.#rW,this.#rW?(this.#rN(),this.#tw.addEventListener("click",this.#rO),this.#tw.addEventListener("keydown",this.#rR)):(this.#rF(),this.#tw.removeEventListener("click",this.#rO),this.#tw.removeEventListener("keydown",this.#rR)))}#rN(){this.#rq||this.render(),this.isVisible?this.#rW&&this.#tw.classList.add("focused"):(this.#nt(),this.#tw.hidden=!1,this.#tw.style.zIndex=parseInt(this.#tw.style.zIndex)+1e3)}#rF(){this.#tw.classList.remove("focused"),!this.#rW&&this.isVisible&&(this.#tw.hidden=!0,this.#tw.style.zIndex=parseInt(this.#tw.style.zIndex)-1e3)}forceHide(){this.#rZ=this.isVisible,this.#rZ&&(this.#tw.hidden=!0)}maybeShow(){this.#U||(this.#r2(),this.#rZ&&(this.#rq||this.#rN(),this.#rZ=!1,this.#tw.hidden=!1))}get isVisible(){return!this.#U&&!1===this.#tw.hidden}}class iY extends iN{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=d.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");for(let e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class iQ extends iN{#ne=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),r=this.#ne=this.svgFactory.createElement("svg:line");return r.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),r.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),r.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),r.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),r.setAttribute("stroke-width",t.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ne}addHighlightArea(){this.container.classList.add("highlightArea")}}class iJ extends iN{#ni=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),r=t.borderStyle.width,n=this.#ni=this.svgFactory.createElement("svg:rect");return n.setAttribute("x",r/2),n.setAttribute("y",r/2),n.setAttribute("width",e-r),n.setAttribute("height",i-r),n.setAttribute("stroke-width",r||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ni}addHighlightArea(){this.container.classList.add("highlightArea")}}class iZ extends iN{#ns=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),r=t.borderStyle.width,n=this.#ns=this.svgFactory.createElement("svg:ellipse");return n.setAttribute("cx",e/2),n.setAttribute("cy",i/2),n.setAttribute("rx",e/2-r/2),n.setAttribute("ry",i/2-r/2),n.setAttribute("stroke-width",r||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ns}
2addHighlightArea(){this.container.classList.add("highlightArea")}}class i0 extends iN{#nr=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:r,height:n}=this;if(!e)return this.container;let a=this.svgFactory.create(r,n,!0),o=[];for(let i=0,s=e.length;i<s;i+=2){let s=e[i]-t[0],r=t[3]-e[i+1];o.push(`${s},${r}`)}o=o.join(" ");let l=this.#nr=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._createPopup(),this.container}getElementsToTriggerPopup(){return this.#nr}addHighlightArea(){this.container.classList.add("highlightArea")}}class i1 extends i0{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class i2 extends iN{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class i3 extends iN{#nn=null;#na=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?d.HIGHLIGHT:d.INK}#no(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);let{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:r}}=this,{transform:n,width:a,height:o}=this.#no(e,t),l=this.svgFactory.create(a,o,!0),h=this.#nn=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",n);for(let t=0,e=i.length;t<e;t++){let e=this.svgFactory.createElement(this.svgElementName);this.#na.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!r&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:i,rect:s}=t,r=this.#nn;if(e>=0&&r.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#na.length;t<e;t++)this.#na[t].setAttribute("points",i[t].join(","));if(s){let{transform:t,width:e,height:i}=this.#no(this.data.rotation,s);r.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),r.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#na}addHighlightArea(){this.container.classList.add("highlightArea")}}class i5 extends iN{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=d.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class i4 extends iN{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}
2class i6 extends iN{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class i8 extends iN{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){let e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class i7 extends iN{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=d.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class i9 extends iN{#nl=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){let t;this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:i}=this;i.hasAppearance||0===i.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(t.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),t.addEventListener("dblclick",this.#nh.bind(this)),this.#nl=t;let{isMac:s}=F.platform;return e.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#nh()}),!i.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return this.#nl}addHighlightArea(){this.container.classList.add("highlightArea")}#nh(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class st{#nd=null;#nc=null;#B=null;#nu=new Map;#np=null;#ng=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:r,viewport:n,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#nd=e,this.#nc=i,this.#np=a||null,this.#ng=l||null,this.#B=h||new tz,this.page=r,this.viewport=n,this.zIndex=0,this._annotationEditorUIManager=s,this._commentManager=o||null}hasEditableAnnotations(){return this.#nu.size>0}async #nm(t,e,i){let s=t.firstChild||t,r=s.id=`${$}${e}`,n=await this.#np?.getAriaAttributes(r);if(n)for(let[t,e]of n)s.setAttribute(t,e);i?i.at(-1).container.after(t):(this.div.append(t),this.#nd?.moveElementInDOM(this.div,t,s,!1))}async render(t){let{annotations:e}=t,i=this.div;tc(i,this.viewport);let s=new Map,r={data:null,layer:i,linkService:this.#ng,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new iR,annotationStorage:this.#B,enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let t of e){if(t.noHTML)continue;let e=t.annotationType===g.POPUP;if(e){let e=s.get(t.id);if(!e)continue;r.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;r.data=t;let i=iB.create(r);if(!i.isRenderable)continue;if(!e&&t.popupRef){let e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}let n=i.render();t.hidden&&(n.style.visibility="hidden"),await this.#nm(n,t.id,r.elements),i.extraPopupElement?.popup?.renderCommentButton(),i._isEditable&&(this.#nu.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#nf()}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#ng,svgFactory:new iR,parent:this};for(let i of t){i.borderStyle||=st._defaultBorderStyle,e.data=i;let t=iB.create(e);if(!t.isRenderable)continue;let s=t.render();await this.#nm(s,i.id,null)}}update({viewport:t}){let e=this.div;this.viewport=t,tc(e,{rotation:t.rotation}),this.#nf(),e.hidden=!1}#nf(){if(!this.#nc)return;let t=this.div;for(let[e,i]of this.#nc){let s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";let{firstChild:r}=s;r?"CANVAS"===r.nodeName?r.replaceWith(i):r.classList.contains("annotationContent")?r.after(i):r.before(i):s.append(i);let n=this.#nu.get(e);n&&(n._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),n._hasNoCanvas=!1):n.canvas=i)}this.#nc.clear()}getEditableAnnotations(){return Array.from(this.#nu.values())}getEditableAnnotation(t){return this.#nu.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:i,rotation:s}=t,r=new iO({data:{id:i,rect:t.getPDFRect(),rotation:s},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#ng,annotationStorage:this.#B}),n=r.render();return e.append(n),this.#nd?.moveElementInDOM(e,n,n,!1),r.createOrUpdatePopup(),r}static get _defaultBorderStyle(){return S(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}let se=/\r\n?|\n/g;class si extends tB{#nb="";#nv=`${this.id}-editor`;#ny=null;#r8;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=si.prototype,e=t=>t.isEmpty(),i=tI.TRANSLATE_SMALL,s=tI.TRANSLATE_BIG;return S(this,"_keyboardManager",new tk([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+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=d.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||si._defaultColor||tB._defaultLineColor,this.#r8=t.fontSize||si._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static initialize(t,e){tB.initialize(t,e);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}
2static updateDefaultParams(t,e){switch(t){case c.FREETEXT_SIZE:si._defaultFontSize=e;break;case c.FREETEXT_COLOR:si._defaultColor=e}}updateParams(t,e){switch(t){case c.FREETEXT_SIZE:this.#nA(e);break;case c.FREETEXT_COLOR:this.#r5(e)}}static get defaultPropertiesToUpdate(){return[[c.FREETEXT_SIZE,si._defaultFontSize],[c.FREETEXT_COLOR,si._defaultColor||tB._defaultLineColor]]}get propertiesToUpdate(){return[[c.FREETEXT_SIZE,this.#r8],[c.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new iM(this),[["colorPicker",this._colorPicker]]}get colorType(){return c.FREETEXT_COLOR}#nA(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#r8)*this.parentScale),this.#r8=t,this.#nw()},i=this.#r8;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:c.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#r5(t){let e=t=>{this.color=t,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:c.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-si._internalPadding*t,-(si._internalPadding+this.#r8)*t]}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(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.#ny=new AbortController;let t=this._uiManager.combinedSignal(this.#ny);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.#nv),this._isDraggable=!0,this.#ny?.abort(),this.#ny=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}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()}#nx(){let t=[];this.editorDiv.normalize();let e=null;for(let i of this.editorDiv.childNodes)(e?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName)&&(t.push(si.#n_(i)),e=i);return t.join("\n")}#nw(){let t,[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,s=i.style.display,r=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#nb,e=this.#nb=this.#nx().trimEnd();if(t===e)return;let i=t=>{(this.#nb=t,t)?(this.#nC(),this._uiManager.rebuild(this),this.#nw()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#nw()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){si._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(){let t,e;if(this.div)return this.div;(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.#nv),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#r8}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){let[i,s]=this.parentDimensions;
2if(this.annotationElementId){let r,n,{position:a}=this._initialData,[o,l]=this.getInitialTranslation();[o,l]=this.pageTranslationToScreen(o,l);let[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:r=t+(a[0]-c)/h,n=e+this.height-(a[1]-u)/d;break;case 90:r=t+(a[0]-c)/h,n=e-(a[1]-u)/d,[o,l]=[l,-o];break;case 180:r=t-this.width+(a[0]-c)/h,n=e-(a[1]-u)/d,[o,l]=[-o,-l];break;case 270:r=t+(a[0]-c-this.height*d)/h,n=e+(a[1]-u-this.width*h)/d,[o,l]=[-l,o]}this.setAt(r*i,n*s,o,l)}else this._moveAfterPaste(t,e);this.#nC(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #n_(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(se,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let s=si.#nS(e.getData("text")||"").replaceAll(se,"\n");if(!s)return;let r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();let n=r.getRangeAt(0);if(!s.includes("\n")){n.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),r.collapseToStart();return}let{startContainer:a,startOffset:o}=n,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){let t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(se,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes){if(i===t){e=h;continue}e.push(si.#n_(i))}}l.push(a.nodeValue.slice(0,o).replaceAll(se,""))}else if(a===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(si.#n_(i))}this.#nb=`${l.join("\n")}${s}${h.join("\n")}`,this.#nC();let d=new Range,c=Math.sumPrecise(l.map(t=>t.length));for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}r.removeAllRanges(),r.addRange(d)}#nC(){if(this.editorDiv.replaceChildren(),this.#nb)for(let t of this.#nb.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#nE(){return this.#nb.replaceAll("\xa0"," ")}static #nS(t){return t.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=si._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let s=null;if(t instanceof iY){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:r,rotation:n,id:a,popupRef:o,richText:l,contentsObj:h,creationDate:c,modificationDate:u},textContent:p,textPosition:g,parent:{page:{pageNumber:m}}}=t;if(!p||0===p.length)return null;s=t={annotationType:d.FREETEXT,color:Array.from(i),fontSize:e,value:p.join("\n"),position:g,pageIndex:m-1,rect:r.slice(0),rotation:n,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:h?.str||null,richText:l,creationDate:c,modificationDate:u}}let r=await super.deserialize(t,e,i);return r.#r8=t.fontSize,r.color=N.makeHexColor(...t.color),r.#nb=si.#nS(t.value),r._initialData=s,t.comment&&r.setCommentData(t),r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=tB._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#r8,value:this.#nE()});return(this.addComment(i),t)?(i.isCopy=!0,i):this.annotationElementId&&!this.#nT(i)?null:(i.id=this.annotationElementId,i)}#nT(t){let{value:e,fontSize:i,color:s,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==r}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:i}=e;for(let t of(i.fontSize=`calc(${this.#r8}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren(),this.#nb.split("\n"))){let i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#nb}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class ss{static PRECISION=1e-4;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.")}static _rescale(t,e,i,s,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a]*s,n[a+1]=i+t[a+1]*r;return n}static _rescaleAndSwap(t,e,i,s,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a+1]*s,n[a+1]=i+t[a]*r;return n}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r+=2)s[r]=e+t[r],s[r+1]=i+t[r+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,r){switch(r){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 _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,r,n){return[(t+5*i)/6,(e+5*s)/6,(5*i+r)/6,(5*s+n)/6,(i+r)/2,(s+n)/2]}}class sr{#nM;#nD=[];#nk;#nP;#nI=[];#nR=new Float32Array(18);#nL;#nF;#nB;#nN;#nO;#nU;#nz=[];static #nH=8;static #n$=2;static #nj=sr.#nH+sr.#n$;constructor({x:t,y:e},i,s,r,n,a=0){this.#nM=i,this.#nU=r*s,this.#nP=n,this.#nR.set([NaN,NaN,NaN,NaN,t,e],6),this.#nk=a,this.#nN=sr.#nH*s,this.#nB=sr.#nj*s,this.#nO=s,this.#nz.push(t,e)}isEmpty(){return isNaN(this.#nR[8])}#nG(){let t=this.#nR.subarray(4,6),e=this.#nR.subarray(16,18),[i,s,r,n]=this.#nM;return[(this.#nL+(t[0]-e[0])/2-i)/r,(this.#nF+(t[1]-e[1])/2-s)/n,(this.#nL+(e[0]-t[0])/2-i)/r,(this.#nF+(e[1]-t[1])/2-s)/n]}add({x:t,y:e}){this.#nL=t,this.#nF=e;let[i,s,r,n]=this.#nM,[a,o,l,h]=this.#nR.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#nB)return!1;let p=u-this.#nN,g=p/u,m=g*d,f=g*c,b=a,v=o;a=l,o=h,l+=m,h+=f,this.#nz?.push(t,e);let y=-f/p*this.#nU,A=m/p*this.#nU;return(this.#nR.set(this.#nR.subarray(2,8),0),this.#nR.set([l+y,h+A],4),this.#nR.set(this.#nR.subarray(14,18),12),this.#nR.set([l-y,h-A],16),isNaN(this.#nR[6]))?(0===this.#nI.length&&(this.#nR.set([a+y,o+A],2),this.#nI.push(NaN,NaN,NaN,NaN,(a+y-i)/r,(o+A-s)/n),this.#nR.set([a-y,o-A],14),this.#nD.push(NaN,NaN,NaN,NaN,(a-y-i)/r,(o-A-s)/n)),this.#nR.set([b,v,a,o,l,h],6),!this.isEmpty()):((this.#nR.set([b,v,a,o,l,h],6),Math.abs(Math.atan2(v-o,b-a)-Math.atan2(f,m))<Math.PI/2)?([a,o,l,h]=this.#nR.subarray(2,6),this.#nI.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/r,((o+h)/2-s)/n),[a,o,b,v]=this.#nR.subarray(14,18),this.#nD.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/r,((v+o)/2-s)/n)):([b,v,a,o,l,h]=this.#nR.subarray(0,6),this.#nI.push(((b+5*a)/6-i)/r,((v+5*o)/6-s)/n,((5*a+l)/6-i)/r,((5*o+h)/6-s)/n,((a+l)/2-i)/r,((o+h)/2-s)/n),[l,h,a,o,b,v]=this.#nR.subarray(12,18),this.#nD.push(((b+5*a)/6-i)/r,((v+5*o)/6-s)/n,((5*a+l)/6-i)/r,((5*o+h)/6-s)/n,((a+l)/2-i)/r,((o+h)/2-s)/n)),!0)}toSVGPath(){if(this.isEmpty())return"";let t=this.#nI,e=this.#nD;if(isNaN(this.#nR[6])&&!this.isEmpty())return this.#nV();let i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);
2this.#nW(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#nq(i),i.join(" ")}#nV(){let[t,e,i,s]=this.#nM,[r,n,a,o]=this.#nG();return`M${(this.#nR[2]-t)/i} ${(this.#nR[3]-e)/s} L${(this.#nR[4]-t)/i} ${(this.#nR[5]-e)/s} L${r} ${n} L${a} ${o} L${(this.#nR[16]-t)/i} ${(this.#nR[17]-e)/s} L${(this.#nR[14]-t)/i} ${(this.#nR[15]-e)/s} Z`}#nq(t){let e=this.#nD;t.push(`L${e[4]} ${e[5]} Z`)}#nW(t){let[e,i,s,r]=this.#nM,n=this.#nR.subarray(4,6),a=this.#nR.subarray(16,18),[o,l,h,d]=this.#nG();t.push(`L${(n[0]-e)/s} ${(n[1]-i)/r} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/r}`)}newFreeDrawOutline(t,e,i,s,r,n){return new sn(t,e,i,s,r,n)}getOutlines(){let t=this.#nI,e=this.#nD,i=this.#nR,[s,r,n,a]=this.#nM,o=new Float32Array((this.#nz?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#nz[t]-s)/n,o[t+1]=(this.#nz[t+1]-r)/a;if(o[o.length-2]=(this.#nL-s)/n,o[o.length-1]=(this.#nF-r)/a,isNaN(i[6])&&!this.isEmpty())return this.#nX(o);let l=new Float32Array(this.#nI.length+24+this.#nD.length),h=t.length;for(let e=0;e<h;e+=2){if(isNaN(t[e])){l[e]=l[e+1]=NaN;continue}l[e]=t[e],l[e+1]=t[e+1]}h=this.#nK(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2){if(isNaN(e[t+i])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2}return this.#nY(l,h),this.newFreeDrawOutline(l,o,this.#nM,this.#nO,this.#nk,this.#nP)}#nX(t){let e=this.#nR,[i,s,r,n]=this.#nM,[a,o,l,h]=this.#nG(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/r,(e[3]-s)/n,NaN,NaN,NaN,NaN,(e[4]-i)/r,(e[5]-s)/n,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/r,(e[17]-s)/n,NaN,NaN,NaN,NaN,(e[14]-i)/r,(e[15]-s)/n],0),this.newFreeDrawOutline(d,t,this.#nM,this.#nO,this.#nk,this.#nP)}#nY(t,e){let i=this.#nD;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#nK(t,e){let i=this.#nR.subarray(4,6),s=this.#nR.subarray(16,18),[r,n,a,o]=this.#nM,[l,h,d,c]=this.#nG();return t.set([NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-n)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-r)/a,(s[1]-n)/o],e),e+=24}}class sn extends ss{#nM;#nQ=new Float32Array(4);#nk;#nP;#nz;#nO;#nJ;constructor(t,e,i,s,r,n){super(),this.#nJ=t,this.#nz=e,this.#nM=i,this.#nO=s,this.#nk=r,this.#nP=n,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#nZ(n);const[a,o,l,h]=this.#nQ;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#nJ[4]} ${this.#nJ[5]}`];for(let e=6,i=this.#nJ.length;e<i;e+=6){if(isNaN(this.#nJ[e])){t.push(`L${this.#nJ[e+4]} ${this.#nJ[e+5]}`);continue}t.push(`C${this.#nJ[e]} ${this.#nJ[e+1]} ${this.#nJ[e+2]} ${this.#nJ[e+3]} ${this.#nJ[e+4]} ${this.#nJ[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],r){let n,a,o=i-t,l=s-e;switch(r){case 0:n=ss._rescale(this.#nJ,t,s,o,-l),a=ss._rescale(this.#nz,t,s,o,-l);break;case 90:n=ss._rescaleAndSwap(this.#nJ,t,e,o,l),a=ss._rescaleAndSwap(this.#nz,t,e,o,l);break;case 180:n=ss._rescale(this.#nJ,i,e,-o,l),a=ss._rescale(this.#nz,i,e,-o,l);break;case 270:n=ss._rescaleAndSwap(this.#nJ,i,s,-o,-l),a=ss._rescaleAndSwap(this.#nz,i,s,-o,-l)}return{outline:Array.from(n),points:[Array.from(a)]}}#nZ(t){let e=this.#nJ,i=e[4],s=e[5],r=[i,s,i,s],n=i,a=s,o=i,l=s,h=t?Math.max:Math.min,d=new Float32Array(4);for(let t=6,c=e.length;t<c;t+=6){let c=e[t+4],u=e[t+5];isNaN(e[t])?(N.pointBoundingBox(c,u,r),a>u?(n=c,a=u):a===u&&(n=h(n,c)),l<u?(o=c,l=u):l===u&&(o=h(o,c))):(d[0]=d[1]=1/0,d[2]=d[3]=-1/0,N.bezierBoundingBox(i,s,...e.slice(t,t+6),d),N.rectBoundingBox(d[0],d[1],d[2],d[3],r),a>d[1]?(n=d[0],a=d[1]):a===d[1]&&(n=h(n,d[0])),l<d[3]?(o=d[2],l=d[3]):l===d[3]&&(o=h(o,d[2]))),i=c,s=u}let c=this.#nQ;c[0]=r[0]-this.#nk,c[1]=r[1]-this.#nk,c[2]=r[2]-r[0]+2*this.#nk,c[3]=r[3]-r[1]+2*this.#nk,this.firstPoint=[n,a],this.lastPoint=[o,l]}get box(){return this.#nQ}newOutliner(t,e,i,s,r,n=0){return new sr(t,e,i,s,r,n)}getNewOutline(t,e){let[i,s,r,n]=this.#nQ,[a,o,l,h]=this.#nM,d=r*l,c=n*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#nz[0]*d+u,y:this.#nz[1]*c+p},this.#nM,this.#nO,t,this.#nP,e??this.#nk);for(let t=2;t<this.#nz.length;t+=2)g.add({x:this.#nz[t]*d+u,y:this.#nz[t+1]*c+p});return g.getOutlines()}}class sa{#nM;#n0;#n1;#n2=[];#n3=[];constructor(t,e=0,i=0,s=!0){const r=[1/0,1/0,-1/0,-1/0];for(const{x:i,y:s,width:n,height:a}of t){const t=1e-4*Math.floor((i-e)/1e-4),o=1e-4*Math.ceil((i+n+e)/1e-4),l=1e-4*Math.floor((s-e)/1e-4),h=1e-4*Math.ceil((s+a+e)/1e-4),d=[t,l,h,!0],c=[o,l,h,!1];this.#n2.push(d,c),N.rectBoundingBox(t,l,o,h,r)}const n=r[2]-r[0]+2*i,a=r[3]-r[1]+2*i,o=r[0]-i,l=r[1]-i;let h=s?-1/0:1/0,d=1/0;const c=this.#n2.at(s?-1:-2),u=[c[0],c[2]];for(const t of this.#n2){const[e,i,r,c]=t;!c&&s?i<d?(d=i,h=e):i===d&&(h=Math.max(h,e)):c&&!s&&(i<d?(d=i,h=e):i===d&&(h=Math.min(h,e))),t[0]=(e-o)/n,t[1]=(i-l)/a,t[2]=(r-l)/a}
2this.#nM=new Float32Array([o,l,n,a]),this.#n0=[h,d],this.#n1=u}getOutlines(){this.#n2.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#n2)e[3]?(t.push(...this.#n5(e)),this.#n4(e)):(this.#n6(e),t.push(...this.#n5(e)));return this.#n8(t)}#n8(t){let e,i=[],s=new Set;for(let e of t){let[t,s,r]=e;i.push([t,s,e],[t,r,e])}i.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,e=i.length;t<e;t+=2){let e=i[t][2],r=i[t+1][2];e.push(r),r.push(e),s.add(e),s.add(r)}let r=[];for(;s.size>0;){let t=s.values().next().value,[i,n,a,o,l]=t;s.delete(t);let h=i,d=n;for(e=[i,a],r.push(e);;){let t;if(s.has(o))t=o;else if(s.has(l))t=l;else break;s.delete(t),[i,n,a,o,l]=t,h!==i&&(e.push(h,d,i,d===n?n:a),h=i),d=d===n?a:n}e.push(h,d)}return new so(r,this.#nM,this.#n0,this.#n1)}#n7(t){let e=this.#n3,i=0,s=e.length-1;for(;i<=s;){let r=i+s>>1,n=e[r][0];if(n===t)return r;n<t?i=r+1:s=r-1}return s+1}#n4([,t,e]){let i=this.#n7(t);this.#n3.splice(i,0,[t,e])}#n6([,t,e]){let i=this.#n7(t);for(let s=i;s<this.#n3.length;s++){let[i,r]=this.#n3[s];if(i!==t)break;if(i===t&&r===e)return void this.#n3.splice(s,1)}for(let s=i-1;s>=0;
2s--){let[i,r]=this.#n3[s];if(i!==t)break;if(i===t&&r===e)return void this.#n3.splice(s,1)}}#n5(t){let[e,i,s]=t,r=[[e,i,s]],n=this.#n7(s);for(let t=0;t<n;t++){let[i,s]=this.#n3[t];for(let t=0,n=r.length;t<n;t++){let[,a,o]=r[t];if(!(s<=a)&&!(o<=i)){if(a>=i){if(o>s)r[t][1]=s;else{if(1===n)return[];r.splice(t,1),t--,n--}continue}r[t][2]=i,o>s&&r.push([e,s,o])}}}return r}}class so extends ss{#nM;#n9;constructor(t,e,i,s){super(),this.#n9=t,this.#nM=e,this.firstPoint=i,this.lastPoint=s}toSVGPath(){let t=[];for(let e of this.#n9){let[i,s]=e;t.push(`M${i} ${s}`);for(let r=2;r<e.length;r+=2){let n=e[r],a=e[r+1];n===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${n}`),i=n)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],r){let n=[],a=i-t,o=s-e;for(let e of this.#n9){let i=Array(e.length);for(let r=0;r<e.length;r+=2)i[r]=t+e[r]*a,i[r+1]=s-e[r+1]*o;n.push(i)}return n}get box(){return this.#nM}get classNamesForOutlining(){return["highlightOutline"]}}class sl extends sr{newFreeDrawOutline(t,e,i,s,r,n){return new sh(t,e,i,s,r,n)}}class sh extends sn{newOutliner(t,e,i,s,r,n=0){return new sl(t,e,i,s,r,n)}}class sd extends tB{#at=null;#ae=0;#ai;#as=null;#r=null;#ar=null;#an=null;#aa=0;#ao=null;#al=null;#w=null;#ah=!1;#n0=null;#n1=null;#ad=null;#et="";#nU;#ac="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=d.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=sd.prototype;return S(this,"_keyboardManager",new tk([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||sd._defaultColor,this.#nU=t.thickness||sd._defaultThickness,this.opacity=t.opacity||sd._defaultOpacity,this.#ai=t.boxes||null,this.#ac=t.methodOfCreation||"",this.#et=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#ah=!0,this.#au(t),this.#ap()):this.#ai&&(this.#at=t.anchorNode,this.#ae=t.anchorOffset,this.#an=t.focusNode,this.#aa=t.focusOffset,this.#ag(),this.#a
vendor: 5,433 bytes, line 2
2p(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#ah?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#nU,methodOfCreation:this.#ac}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ag(){let t=new sa(this.#ai,.001);this.#al=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#al.box;let e=new sa(this.#ai,.0025,.001,"ltr"===this._uiManager.direction);this.#ar=e.getOutlines();let{firstPoint:i}=this.#al;this.#n0=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];let{lastPoint:s}=this.#ar;this.#n1=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#au({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#al=t,this.#ar=t.getNewOutline(this.#nU/2+1.5,.0025),e>=0)this.#w=e,this.#as=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#ad=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#ar.box,path:{d:this.#ar.toSVGPath()}},!0);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#w,{bbox:sd.#am(this.#al.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#ad,{bbox:sd.#am(this.#ar.box,e),path:{d:this.#ar.toSVGPath()}})}let[s,r,n,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=r,this.width=n,this.height=a;break;case 90:{let[t,e]=this.parentDimensions;this.x=r,this.y=1-s,this.width=n*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-r,this.width=n,this.height=a;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-r,this.y=s,this.width=n*e/t,this.height=a*t/e}}let{firstPoint:o}=t;this.#n0=[(o[0]-s)/n,(o[1]-r)/a];let{lastPoint:l}=this.#ar;this.#n1=[(l[0]-s)/n,(l[1]-r)/a]}static initialize(t,e){tB.initialize(t,e),sd._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case c.HIGHLIGHT_COLOR:sd._defaultColor=e;break;case c.HIGHLIGHT_THICKNESS:sd._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#n1}get commentButtonPosition(){return this.#n0}updateParams(t,e){switch(t){case c.HIGHLIGHT_COLOR:this.#r5(e);break;case c.HIGHLIGHT_THICKNESS:this.#af(e)}}static get defaultPropertiesToUpdate(){return[[c.HIGHLIGHT_COLOR,sd._defaultColor],[c.HIGHLIGHT_THICKNESS,sd._defaultThickness]]}get propertiesToUpdate(){return[[c.HIGHLIGHT_COLOR,this.color||sd._defaultColor],[c.HIGHLIGHT_THICKNESS,this.#nU||sd._defaultThickness],[c.HIGHLIGHT_FREE,this.#ah]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#w,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#r?.updateColor(this.color),super.onUpdatedColor()}#r5(t){let e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,s=this.opacity;this.addCommands({cmd:e.bind(this,t,sd._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:c.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#af(t){let e=this.#nU,i=t=>{this.#nU=t,this.#ab(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:c.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#r=new iT({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#av())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#av())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#ay(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#ap(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#ay():t&&(this.#ap(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#ab(t){this.#ah&&(this.#au({highlightOutlines:this.#al.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height))}#ay(){null!==this.#w&&this.parent&&(this.parent.drawLayer.remove(this.#w),this.#w=null,this.parent.drawLayer.remove(this.#ad),this.#ad=null)}#ap(t=this.parent){null===this.#w&&({id:this.#w,clipPathId:this.#as}=t.drawLayer.draw({bbox:this.#al.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#ah},path:{d:this.#al.toSVGPath()}},!1,!0),this.#ad=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#ah},bbox:this.#ar.box,path:{d:this.#ar.toSVGPath()}},this.#ah),this.#ao&&(this.#ao.style.clipPath=this.#as))}static #am([t,e,i,s],r){switch(r){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]}rotate(t){let e,{drawLayer:i}
2=this.parent;this.#ah?(t=(t-this.rotation+360)%360,e=sd.#am(this.#al.box,t)):e=sd.#am([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#w,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#ad,{bbox:sd.#am(this.#ar.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#et&&(t.setAttribute("aria-label",this.#et),t.setAttribute("role","mark")),this.#ah?t.classList.add("free"):this.div.addEventListener("keydown",this.#aA.bind(this),{signal:this._uiManager._signal});let e=this.#ao=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#as,this.setDims(this.width,this.height),tE(this,this.#ao,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{hovered:!1}})}#aA(t){sd._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#aw(!0);break;case 1:case 3:this.#aw(!1)}}#aw(t){if(!this.#at)return;let e=window.getSelection();t?e.setPosition(this.#at,this.#ae):e.setPosition(this.#an,this.#aa)}select(){super.select(),this.#ad&&this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#ad&&(this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{selected:!1}}),this.#ah||this.#aw(!1))}get _mustFixPosition(){return!this.#ah}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#w,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#ad,{rootClass:{hidden:!t}}))}#av(){return this.#ah?this.rotation:0}#ax(){if(this.#ah)return null;let[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,r=this.#ai,n=new Float32Array(8*r.length),a=0;for(let{x:o,y:l,width:h,height:d}of r){let r=o*t+i,c=(1-l)*e+s;n[a]=n[a+4]=r,n[a+1]=n[a+3]=c,n[a+2]=n[a+6]=r+h*t,n[a+5]=n[a+7]=c-d*e,a+=8}return n}#a_(t){return this.#al.serialize(t,this.#av())}static startHighlighting(t,e,{target:i,x:s,y:r}){let{x:n,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#aC(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",tn,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",tr,{signal:d}),i.addEventListener("pointermove",this.#aS.bind(this,t),{signal:d}),this._freeHighlight=new sl({x:s,y:r},[n,a,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static #aS(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static #aC(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof i5){let{data:{quadPoints:e,rect:i,rotation:r,id:n,color:a,opacity:o,popupRef:l,richText:h,contentsObj:c,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:d.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:c?.str||null,creationDate:u,modificationDate:p}}else if(t instanceof i3){let{data:{inkLists:e,rect:i,rotation:r,id:n,color:a,borderStyle:{rawWidth:o},popupRef:l,richText:h,contentsObj:c,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:d.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:c?.str||null,creationDate:u,modificationDate:p}}let{color:r,quadPoints:n,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=N.makeHexColor(...r),l.opacity=o||1,a&&(l.#nU=t.thickness),l._initialData=s,t.comment&&l.setCommentData(t);let[h,c]=l.pageDimensions,[u,p]=l.pageTranslation;if(n){let t=l.#ai=[];for(let e=0;e<n.length;e+=8)t.push({x:(n[e]-u)/h,y:1-(n[e+1]-p)/c,width:(n[e+2]-n[e])/h,height:(n[e+1]-n[e+5])/c});l.#ag(),l.#ap(),l.rotate(l.rotation)}else if(a){l.#ah=!0;let t=a[0],i={x:t[0]-u,y:c-(t[1]-p)},s=new sl(i,[0,0,h,c],1,l.#nU/2,!0,.001);for(let e=0,r=t.length;e<r;e+=2)i.x=t[e]-u,i.y=c-(t[e+1]-p),s.add(i);let{id:r,clipPathId:n}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#au({highlightOutlines:s.getOutlines(),highlightId:r,clipPathId:n}),l.#ap(),l.rotate(l.parentRotation)}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=tB._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return(Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#nU,quadPoints:this.#ax(),outlines:this.#a_(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#nT(i))?null:(i.id=this.annotationElementId,i)}#nT(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}static canCreateNewEmptyEditor(){return!1}}class sc{#aE=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#aE[t]=e}toSVGProperties(){let t=this.#aE;return this.#aE=Object.create(null),{root:t}}reset(){this.#aE=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){w("Not implemented")}}class su extends tB{#aT=null;#aM;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static #aD=null;static #ak=null;static #aP=null;static #aI=NaN;static #aR=null;static #aL=null;static #aF=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#aM=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}
2_addOutlines(t){t.drawOutlines&&(this.#aB(t),this.#ap())}#aB({drawOutlines:t,drawId:e,drawingOptions:i}){this.#aT=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#aN(t,this.parent),this.#aO(t.box)}#aN(t,e){let{id:i}=e.drawLayer.draw(su._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){let i=new Set(Object.keys(t));for(let[s,r]of Object.entries(e))i.has(s)?Object.assign(t[s],r):t[s]=r;return t}static getDefaultDrawingOptions(t){w("Not implemented")}static get typesMap(){w("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(su.#aD.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){let s=this._drawingOptions,r=s[e],n=i=>{s.updateProperty(e,i);let r=this.#aT.updateProperty(e,i);r&&this.#aO(r),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:n.bind(this,i),undo:n.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,su._mergeSVGProperties(this.#aT.getPathResizingSVGProperties(this.#aU()),{bbox:this.#az()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,su._mergeSVGProperties(this.#aT.getPathResizedSVGProperties(this.#aU()),{bbox:this.#az()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#az()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,su._mergeSVGProperties(this.#aT.getPathTranslatedSVGProperties(this.#aU(),this.parentDimensions),{bbox:this.#az()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#aM&&(this.#aM=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#ay(),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#ap(),this.#aO(this.#aT.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#ay()):t&&(this._uiManager.addShouldRescale(this),this.#ap(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#ay(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ap(t=this.parent){if(null===this._drawId||this.parent!==t){if(null!==this._drawId)return void this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);this._drawingOptions.updateAll(),this._drawId=this.#aN(this.#aT,t)}}#aH([t,e,i,s]){let{parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[e,1-t,n/r*i,r/n*s];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,n/r*i,r/n*s];default:return[t,e,i,s]}}#aU(){let{x:t,y:e,width:i,height:s,parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[1-e,t,r/n*i,n/r*s];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,r/n*i,n/r*s];default:return[t,e,i,s]}}#aO(t){[this.x,this.y,this.width,this.height]=this.#aH(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#az(){let{x:t,y:e,width:i,height:s,rotation:r,parentRotation:n,parentDimensions:[a,o]}=this;switch((4*r+n)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-a/o*i,o/a*s,a/o*i];case 5:return[1-e,t,a/o*i,o/a*s];case 6:return[1-t-o/a*s,1-e,o/a*s,a/o*i];case 7:return[e-a/o*i,1-t-o/a*s,a/o*i,o/a*s];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-o/a*s,e,o/a*s,a/o*i];case 13:return[1-e-a/o*i,t-o/a*s,a/o*i,o/a*s];case 14:return[1-t,1-e-a/o*i,o/a*s,a/o*i];case 15:return[e,1-t,a/o*i,o/a*s];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,su._mergeSVGProperties({bbox:this.#az()},this.#aT.updateRotation((this.parentRotation-this.rotation+360)%360)))}
2onScaleChanging(){this.parent&&this.#aO(this.#aT.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){let t,e;if(this.div)return this.div;this._isCopy&&(t=this.x,e=this.y);let i=super.render();i.classList.add("draw");let s=document.createElement("div");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,r){w("Not implemented")}static startDrawing(t,e,i,s){let{target:r,offsetX:n,offsetY:a,pointerId:o,pointerType:l}=s;if(su.#aR&&su.#aR!==l)return;let{viewport:{rotation:h}}=t,{width:d,height:c}=r.getBoundingClientRect(),u=su.#ak=new AbortController,p=t.combinedSignal(u);(su.#aI||=o,su.#aR??=l,window.addEventListener("pointerup",t=>{su.#aI===t.pointerId?this._endDraw(t):su.#aL?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointercancel",t=>{su.#aI===t.pointerId?this._currentParent.endDrawingSession():su.#aL?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointerdown",t=>{su.#aR===t.pointerType&&((su.#aL||=new Set).add(t.pointerId),su.#aD.isCancellable()&&(su.#aD.removeLastElement(),su.#aD.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",tr,{signal:p}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),r.addEventListener("touchmove",t=>{t.timeStamp===su.#aF&&tn(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),su.#aD)?t.drawLayer.updateProperties(this._currentDrawId,su.#aD.startNew(n,a,d,c,h)):(e.updateUIForDefaultProperties(this),su.#aD=this.createDrawerInstance(n,a,d,c,h),su.#aP=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(su.#aP.toSVGProperties(),su.#aD.defaultSVGProperties),!0,!1))}static _drawMove(t){if(su.#aF=-1,!su.#aD)return;let{offsetX:e,offsetY:i,pointerId:s}=t;if(su.#aI===s){if(su.#aL?.size>=1)return void this._endDraw(t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,su.#aD.add(e,i)),su.#aF=t.timeStamp,tn(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,su.#aD=null,su.#aP=null,su.#aR=null,su.#aF=NaN),su.#ak&&(su.#ak.abort(),su.#ak=null,su.#aI=NaN,su.#aL=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,su.#aD.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=su.#aD,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:c.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(c.DRAW_STEP),!su.#aD.isEmpty()){let{pageDimensions:[i,s],scale:r}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:su.#aD.getOutlines(i*r,s*r,r,this._INNER_MARGIN),drawingOptions:su.#aP,mustBeCommitted:!t});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,r,n){w("Not implemented")}static async deserialize(t,e,i){let{rawDims:{pageWidth:s,pageHeight:r,pageX:n,pageY:a}}=e.viewport,o=this.deserializeDraw(n,a,s,r,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#aB({drawOutlines:o}),l.#ap(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,i]=this.pageTranslation,[s,r]=this.pageDimensions;return this.#aT.serialize([e,i,s,r],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class sp{#nR=new Float64Array(6);#ne;#a$;#sD;#nU;#nz;#aj="";#aG=0;#n9=new sg;#aV;#aW;constructor(t,e,i,s,r,n){this.#aV=i,this.#aW=s,this.#sD=r,this.#nU=n,[t,e]=this.#aq(t,e);const a=this.#ne=[NaN,NaN,NaN,NaN,t,e];this.#nz=[t,e],this.#a$=[{line:a,points:this.#nz}],this.#nR.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#nU=e)}#aq(t,e){return ss._normalizePoint(t,e,this.#aV,this.#aW,this.#sD)}isEmpty(){return!this.#a$||0===this.#a$.length}isCancellable(){return this.#nz.length<=10}add(t,e){[t,e]=this.#aq(t,e);let[i,s,r,n]=this.#nR.subarray(2,6),a=t-r,o=e-n;return 2>=Math.hypot(this.#aV*a,this.#aW*o)?null:((this.#nz.push(t,e),isNaN(i))?(this.#nR.set([r,n,t,e],2),this.#ne.push(NaN,NaN,NaN,NaN,t,e)):(isNaN(this.#nR[0])&&this.#ne.splice(6,6),this.#nR.set([i,s,r,n,t,e],0),this.#ne.push(...ss.createBezierPoints(i,s,r,n,t,e))),{path:{d:this.toSVGPath()}})}end(t,e){let i=this.add(t,e);
2return i||(2===this.#nz.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,r){this.#aV=i,this.#aW=s,this.#sD=r,[t,e]=this.#aq(t,e);let n=this.#ne=[NaN,NaN,NaN,NaN,t,e];this.#nz=[t,e];let a=this.#a$.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#a$.push({line:n,points:this.#nz}),this.#nR.set(n,0),this.#aG=0,this.toSVGPath(),null}getLastElement(){return this.#a$.at(-1)}setLastElement(t){return this.#a$?(this.#a$.push(t),this.#ne=t.line,this.#nz=t.points,this.#aG=0,{path:{d:this.toSVGPath()}}):this.#n9.setLastElement(t)}removeLastElement(){if(!this.#a$)return this.#n9.removeLastElement();this.#a$.pop(),this.#aj="";for(let t=0,e=this.#a$.length;t<e;t++){let{line:e,points:i}=this.#a$[t];this.#ne=e,this.#nz=i,this.#aG=0,this.toSVGPath()}return{path:{d:this.#aj}}}toSVGPath(){let t=ss.svgRound(this.#ne[4]),e=ss.svgRound(this.#ne[5]);if(2===this.#nz.length)return this.#aj=`${this.#aj} M ${t} ${e} Z`,this.#aj;if(this.#nz.length<=6){let i=this.#aj.lastIndexOf("M");this.#aj=`${this.#aj.slice(0,i)} M ${t} ${e}`,this.#aG=6}if(4===this.#nz.length){let t=ss.svgRound(this.#ne[10]),e=ss.svgRound(this.#ne[11]);return this.#aj=`${this.#aj} L ${t} ${e}`,this.#aG=12,this.#aj}let i=[];0===this.#aG&&(i.push(`M ${t} ${e}`),this.#aG=6);for(let t=this.#aG,e=this.#ne.length;t<e;t+=6){let[e,s,r,n,a,o]=this.#ne.slice(t,t+6).map(ss.svgRound);i.push(`C${e} ${s} ${r} ${n} ${a} ${o}`)}return this.#aj+=i.join(" "),this.#aG=this.#ne.length,this.#aj}getOutlines(t,e,i,s){let r=this.#a$.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#n9.build(this.#a$,t,e,i,this.#sD,this.#nU,s),this.#nR=null,this.#ne=null,this.#a$=null,this.#aj=null,this.#n9}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class sg extends ss{#nQ;#aX=0;#nk;#a$;#aV;#aW;#aK;#sD;#nU;build(t,e,i,s,r,n,a){this.#aV=e,this.#aW=i,this.#aK=s,this.#sD=r,this.#nU=n,this.#nk=a??0,this.#a$=t,this.#aY()}get thickness(){return this.#nU}setLastElement(t){return this.#a$.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#a$.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#a$){if(t.push(`M${ss.svgRound(e[4])} ${ss.svgRound(e[5])}`),6===e.length){t.push("Z");continue}if(12===e.length&&isNaN(e[6])){t.push(`L${ss.svgRound(e[10])} ${ss.svgRound(e[11])}`);continue}for(let i=6,s=e.length;i<s;i+=6){let[s,r,n,a,o,l]=e.subarray(i,i+6).map(ss.svgRound);t.push(`C${s} ${r} ${n} ${a} ${o} ${l}`)}}return t.join("")}serialize([t,e,i,s],r){let n,a,o,l,h,d,c,u,p,g=[],m=[],[f,b,v,y]=this.#aQ();switch(this.#sD){case 0:p=ss._rescale,n=t,a=e+s,o=i,l=-s,h=t+f*i,d=e+(1-b-y)*s,c=t+(f+v)*i,u=e+(1-b)*s;break;case 90:p=ss._rescaleAndSwap,n=t,a=e,o=i,l=s,h=t+b*i,d=e+f*s,c=t+(b+y)*i,u=e+(f+v)*s;break;case 180:p=ss._rescale,n=t+i,a=e,o=-i,l=s,h=t+(1-f-v)*i,d=e+b*s,c=t+(1-f)*i,u=e+(b+y)*s;break;case 270:p=ss._rescaleAndSwap,n=t+i,a=e+s,o=-i,l=-s,h=t+(1-b-y)*i,d=e+(1-f-v)*s,c=t+(1-b)*i,u=e+(1-f)*s}for(let{line:t,points:e}of this.#a$)g.push(p(t,n,a,o,l,r?Array(t.length):null)),m.push(p(e,n,a,o,l,r?Array(e.length):null));return{lines:g,points:m,rect:[h,d,c,u]}}static deserialize(t,e,i,s,r,{paths:{lines:n,points:a},rotation:o,thickness:l}){let h,d,c,u,p,g=[];switch(o){case 0:p=ss._rescale,h=-t/i,d=e/s+1,c=1/i,u=-1/s;break;case 90:p=ss._rescaleAndSwap,h=-e/s,d=-t/i,c=1/s,u=1/i;break;case 180:p=ss._rescale,h=t/i+1,d=-e/s,c=-1/i,u=1/s;break;case 270:p=ss._rescaleAndSwap,h=e/s+1,d=t/i+1,c=-1/s,u=-1/i}if(!n)for(let t of(n=[],a)){let e=t.length;if(2===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}let i=new Float32Array(3*(e-2));n.push(i);let[s,r,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,r],0);for(let n=4;n<e;n+=2){let e=t[n],l=t[n+1];i.set(ss.createBezierPoints(s,r,a,o,e,l),(n-2)*3),[s,r,a,o]=[a,o,e,l]}}for(let t=0,e=n.length;t<e;t++)g.push({line:p(n[t].map(t=>t??NaN),h,d,c,u),points:p(a[t].map(t=>t??NaN),h,d,c,u)});let m=new this.prototype.constructor;return m.build(g,i,s,1,o,l,r),m}#aJ(t=this.#nU){let e=this.#nk+t/2*this.#aK;return this.#sD%180==0?[e/this.#aV,e/this.#aW]:[e/this.#aW,e/this.#aV]}#aQ(){let[t,e,i,s]=this.#nQ,[r,n]=this.#aJ(0);return[t+r,e+n,i-2*r,s-2*n]}#aY(){let t=this.#nQ=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:e}of this.#a$){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)N.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let r=6,n=e.length;r<n;r+=6){let[n,a,o,l,h,d]=e.subarray(r,r+6);N.bezierBoundingBox(i,s,n,a,o,l,h,d,t),i=h,s=d}}let[e,i]=this.#aJ();t[0]=j(t[0]-e,0,1),t[1]=j(t[1]-i,0,1),t[2]=j(t[2]+e,0,1),t[3]=j(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#nQ}updateProperty(t,e){return"stroke-width"===t?this.#af(e):null}#af(t){let[e,i]=this.#aJ();this.#nU=t;let[s,r]=this.#aJ(),[n,a]=[s-e,r-i],o=this.#nQ;return o[0]-=n,o[1]-=a,o[2]+=2*n,o[3]+=2*a,o}updateParentDimensions([t,e],i){let[s,r]=this.#aJ();this.#aV=t,this.#aW=e,this.#aK=i;
2let[n,a]=this.#aJ(),o=n-s,l=a-r,h=this.#nQ;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#aX=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#nQ.map(ss.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#nQ;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ss.svgRound(t)} ${ss.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#nQ,i=0,s=0,r=0,n=0,a=0,o=0;switch(this.#aX){case 90:s=e/t,r=-t/e,a=t;break;case 180:i=-1,n=-1,a=t,o=e;break;case 270:s=-e/t,r=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${r} ${n} ${ss.svgRound(a)} ${ss.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){let[r,n]=this.#aJ(),[a,o,l,h]=this.#nQ;if(Math.abs(l-r)<=ss.PRECISION||Math.abs(h-n)<=ss.PRECISION){let r=t+i/2-(a+l/2),n=e+s/2-(o+h/2);return{path:{"transform-origin":`${ss.svgRound(t)} ${ss.svgRound(e)}`,transform:`${this.rotationTransform} translate(${r} ${n})`}}}let d=(i-2*r)/(l-2*r),c=(s-2*n)/(h-2*n);return{path:{"transform-origin":`${ss.svgRound(a)} ${ss.svgRound(o)}`,transform:`${this.rotationTransform} scale(${l/i} ${h/s}) translate(${ss.svgRound(r)} ${ss.svgRound(n)}) scale(${d} ${c}) translate(${ss.svgRound(-r)} ${ss.svgRound(-n)})`}}}getPathResizedSVGProperties([t,e,i,s]){let[r,n]=this.#aJ(),a=this.#nQ,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-r)<=ss.PRECISION||Math.abs(d-n)<=ss.PRECISION){let r=t+i/2-(o+h/2),n=e+s/2-(l+d/2);for(let{line:t,points:e}of this.#a$)ss._translate(t,r,n,t),ss._translate(e,r,n,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ss.svgRound(t)} ${ss.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let c=(i-2*r)/(h-2*r),u=(s-2*n)/(d-2*n),p=-c*(o+r)+t+r,g=-u*(l+n)+e+n;if(1!==c||1!==u||0!==p||0!==g)for(let{line:t,points:e}of this.#a$)ss._rescale(t,p,g,c,u,t),ss._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ss.svgRound(t)} ${ss.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){let[s,r]=i,n=this.#nQ,a=t-n[0],o=e-n[1];if(this.#aV===s&&this.#aW===r)for(let{line:t,points:e}of this.#a$)ss._translate(t,a,o,t),ss._translate(e,a,o,e);else{let t=this.#aV/s,e=this.#aW/r;for(let{line:i,points:n}of(this.#aV=s,this.#aW=r,this.#a$))ss._rescale(i,a,o,t,e,i),ss._rescale(n,a,o,t,e,n);n[2]*=t,n[3]*=e}return n[0]=t,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${ss.svgRound(t)} ${ss.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#nQ;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ss.svgRound(t[0])} ${ss.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class sm extends sc{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:tB._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){let t=new sm(this._viewParameters);return t.updateAll(this),t}}class sf extends su{static _type="ink";static _editorType=d.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){tB.initialize(t,e),this._defaultDrawingOptions=new sm(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return S(this,"typesMap",new Map([[c.INK_THICKNESS,"stroke-width"],[c.INK_COLOR,"stroke"],[c.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,r){return new sp(t,e,i,s,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,r,n){return sg.deserialize(t,e,i,s,r,n)}static async deserialize(t,e,i){let s=null;if(t instanceof i3){let{data:{inkLists:e,rect:i,rotation:r,id:n,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:c,contentsObj:u,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;s=t={annotationType:d.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:m-1,rect:i.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:h,richText:c,comment:u?.str||null,creationDate:p,modificationDate:g}}let r=await super.deserialize(t,e,i);return r._initialData=s,t.comment&&r.setCommentData(t),r}get toolbarButtons(){return this._colorPicker||=new iM(this),[["colorPicker",this._colorPicker]]}get colorType(){return c.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let 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=sf.getDefaultDrawingOptions({stroke:N.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":r,"stroke-width":n}}=this,a=Object.assign(super.serialize(t),{color:tB._colorManager.convert(s),opacity:r,thickness:n,paths:{lines:e,points:i}});return(this.addComment(a),t)?(a.isCopy=!0,a):this.annotationElementId&&!this.#nT(a)?null:(a.id=this.annotationElementId,a)}#nT(t){let{color:e,thickness:i,opacity:s,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==r}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class sb extends sg{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class sv{static #aZ={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static #a0(t,e,i,s){return(i-=t,s-=e,0===i)?s>0?0:4:1===i?s+6:2-s}static #a1=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);
2static #a2(t,e,i,s,r,n,a){let o=this.#a0(i,s,r,n);for(let r=0;r<8;r++){let n=(-r+o-a+16)%8;if(0!==t[(i+this.#a1[2*n])*e+(s+this.#a1[2*n+1])])return n}return -1}static #a3(t,e,i,s,r,n,a){let o=this.#a0(i,s,r,n);for(let r=0;r<8;r++){let n=(r+o+a+16)%8;if(0!==t[(i+this.#a1[2*n])*e+(s+this.#a1[2*n+1])])return n}return -1}static #a5(t,e,i,s){let r,n=t.length,a=new Int32Array(n);for(let e=0;e<n;e++)a[e]=+(t[e]<=s);for(let t=1;t<i-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*i-1-t]=0;let o=1,l=[];for(let t=1;t<i-1;t++){r=1;for(let i=1;i<e-1;i++){let s,n=t*e+i,h=a[n];if(0===h)continue;let d=t,c=i;if(1===h&&0===a[n-1])o+=1,c-=1;else if(h>=1&&0===a[n+1])o+=1,c+=1,h>1&&(r=h);else{1!==h&&(r=Math.abs(h));continue}let u=[i,t],p=c===i+1,g={isHole:p,points:u,id:o,parent:0};for(let t of(l.push(g),l))if(t.id===r){s=t;break}s?s.isHole?g.parent=p?s.parent:r:g.parent=p?r:s.parent:g.parent=p?r:0;let m=this.#a2(a,e,t,i,d,c,0);if(-1===m){a[n]=-o,1!==a[n]&&(r=Math.abs(a[n]));continue}let f=this.#a1[2*m],b=this.#a1[2*m+1],v=t+f,y=i+b;d=v,c=y;let A=t,w=i;for(;;){let s=this.#a3(a,e,A,w,d,c,1);f=this.#a1[2*s],b=this.#a1[2*s+1];let l=A+f,h=w+b;u.push(h,l);let p=A*e+w;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===t&&h===i&&A===v&&w===y){1!==a[n]&&(r=Math.abs(a[n]));break}d=A,c=w,A=l,w=h}}}return l}static #a4(t,e,i,s){if(i-e<=4){for(let r=e;r<i-2;r+=2)s.push(t[r],t[r+1]);return}let r=t[e],n=t[e+1],a=t[i-4]-r,o=t[i-3]-n,l=Math.hypot(a,o),h=a/l,d=o/l,c=h*n-d*r,u=1/l,p=Math.atan(o/a),g=Math.cos(p),m=Math.sin(p),f=u*(Math.abs(g)+Math.abs(m)),b=u*(1-f+f**2),v=Math.max(Math.atan(Math.abs(m+g)*b),Math.atan(Math.abs(m-g)*b)),y=0,A=e;for(let s=e+2;s<i-2;s+=2){let e=Math.abs(c-h*t[s+1]+d*t[s]);e>y&&(A=s,y=e)}y>(l*v)**2?(this.#a4(t,e,A+2,s),this.#a4(t,A,i,s)):s.push(r,n)}static #a6(t){let e=[],i=t.length;return this.#a4(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static #a8(t,e,i,s,r,n){let a=new Float32Array(n**2),o=-2*s**2,l=n>>1;for(let t=0;t<n;t++){let e=(t-l)**2;for(let i=0;i<n;i++)a[t*n+i]=Math.exp((e+(i-l)**2)/o)}let h=new Float32Array(256),d=-2*r**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);let c=new Uint8Array(t.length),u=new Uint32Array(256);for(let s=0;s<i;s++)for(let r=0;r<e;r++){let o=s*e+r,d=t[o],p=0,g=0;for(let o=0;o<n;o++){let c=s+o-l;if(!(c<0)&&!(c>=i))for(let i=0;i<n;i++){let s=r+i-l;if(s<0||s>=e)continue;let u=t[c*e+s],m=a[o*n+i]*h[Math.abs(u-d)];p+=u*m,g+=m}}let m=c[o]=Math.round(p/g);u[m]++}return[c,u]}static #a7(t){let e=new Uint32Array(256);for(let i of t)e[i]++;return e}static #a9(t){let e=new Uint8ClampedArray(t.length>>2),i=-1/0,s=1/0;for(let r=0,n=e.length;r<n;r++){let n=e[r]=t[r<<2];i=Math.max(i,n),s=Math.min(s,n)}let r=255/(i-s);for(let t=0,i=e.length;t<i;t++)e[t]=(e[t]-s)*r;return e}static #ot(t){let e,i=-1/0,s=-1/0,r=t.findIndex(t=>0!==t),n=r,a=r;for(e=r;e<256;e++){let r=t[e];r>i&&(e-n>s&&(s=e-n,a=e-1),i=r,n=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static #oe(t){let e=t,{width:i,height:s}=t,{maxDim:r}=this.#aZ,n=i,a=s;if(i>r||s>r){let o=i,l=s,h=Math.log2(Math.max(i,s)/r),d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){let i=new OffscreenCanvas(n=Math.ceil(o/2),a=Math.ceil(l/2));i.getContext("2d").drawImage(t,0,0,o,l,0,0,n,a),o=n,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}let c=Math.min(r/n,r/a);n=Math.round(n*c),a=Math.round(a*c)}let o=new OffscreenCanvas(n,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,n,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,n,a);let l=o.getImageData(0,0,n,a).data;return[this.#a9(l),n,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},r,n,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1}),d=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:f,width:b}=h.measureText(t),v=Math.ceil(1.5*Math.max(Math.abs(c)+Math.abs(u)||0,b)),y=Math.ceil(1.5*Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(m)+Math.abs(f)||200));(h=(l=new OffscreenCanvas(v,y)).getContext("2d",{alpha:!0,willReadFrequently:!0})).font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,v,y),h.fillStyle="black",h.fillText(t,.5*v/2,1.5*y/2);let A=this.#a9(h.getImageData(0,0,v,y).data),w=this.#a7(A),x=this.#ot(w),_=this.#a5(A,v,y,x);return this.processDrawnLines({lines:{curves:_,width:v,height:y},pageWidth:r,pageHeight:n,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}
2static process(t,e,i,s,r){let[n,a,o]=this.#oe(t),[l,h]=this.#a8(n,a,o,Math.hypot(a,o)*this.#aZ.sigmaSFactor,this.#aZ.sigmaR,this.#aZ.kernelSize),d=this.#ot(h),c=this.#a5(l,a,o,d);return this.processDrawnLines({lines:{curves:c,width:a,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:r,mustSmooth:n,areContours:a}){s%180!=0&&([e,i]=[i,e]);let{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,m=[];for(let{points:t}of o){let e=n?this.#a6(t):t;if(!e)continue;m.push(e);let i=e.length,s=new Float32Array(i),r=new Float32Array(3*(2===i?2:i-2));if(c.push({line:r,points:s}),2===i){s[0]=e[0]*p,s[1]=e[1]*g,r.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[a,o,l,h]=e;a*=p,o*=g,l*=p,h*=g,s.set([a,o,l,h],0),r.set([NaN,NaN,NaN,NaN,a,o],0);for(let t=4;t<i;t+=2){let i=s[t]=e[t]*p,n=s[t+1]=e[t+1]*g;r.set(ss.createBezierPoints(a,o,l,h,i,n),(t-2)*3),[a,o,l,h]=[l,h,i,n]}}if(0===c.length)return null;let f=a?new sb:new sg;return f.build(c,e,i,1,s,a?0:d,r),{outline:f,newCurves:m,areContours:a,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:r}){let n,a=1/0,o=-1/0,l=0;for(let e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){let i=e[t]-e[t-2];a=Math.min(a,i),o=Math.max(o,i)}}n=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;let h=t.length,d=8+3*h,c=new Uint32Array(d),u=0;for(let a of(c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*n.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=s,c[u++]=r,c[u++]=+!e,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=n.BYTES_PER_ELEMENT,t))c[u++]=a.length-2,c[u++]=a[0],c[u++]=a[1];let p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);let m=n.prototype.constructor;for(let e of t){let t=new m(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];g.write(t)}return g.close(),G(new Uint8Array(await new Response(p.readable).arrayBuffer()))}static async decompressSignature(t){try{let e,i=Uint8Array.fromBase64?Uint8Array.fromBase64(t):L(atob(t)),{readable:s,writable:r}=new DecompressionStream("deflate-raw"),n=r.getWriter();await n.ready,n.write(i).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let a=null,o=0;for await(let t of s)(a||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])).set(t,o),o+=t.length;let l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(0!==h)throw Error(`Invalid version: ${h}`);let d=l[2],c=l[3],u=0===l[4],p=l[5],g=l[6],m=l[7],f=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;switch(m){case Int8Array.BYTES_PER_ELEMENT:e=new Int8Array(a.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:e=new Int16Array(a.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:e=new Int32Array(a.buffer,b)}o=0;for(let t=0;t<g;t++){let i=l[3*t+8],s=new Float32Array(i+2);f.push(s);for(let e=0;e<2;e++)s[e]=l[3*t+8+e+1];for(let t=0;t<i;t++)s[t+2]=s[t]+e[o++]}return{areContours:u,thickness:p,outlines:f,width:d,height:c}}catch(t){return A(`decompressSignature: ${t}`),null}}}class sy extends sc{constructor(){super(),super.updateProperties({fill:tB._defaultLineColor,"stroke-width":0})}clone(){let t=new sy;return t.updateAll(this),t}}class sA extends sm{constructor(t){super(t),super.updateProperties({stroke:tB._defaultLineColor,"stroke-width":1})}clone(){let t=new sA(this._viewParameters);return t.updateAll(this),t}}class sw extends su{#oi=!1;#os=null;#or=null;#on=null;static _type="signature";static _editorType=d.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#or=t.signatureData||null,this.#os=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){tB.initialize(t,e),this._defaultDrawingOptions=new sy,this._defaultDrawnSignatureOptions=new sA(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return S(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#os}}static computeTelemetryFinalData(t){let e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){let t,e;if(this.div)return this.div;let{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#or){let{lines:t,mustSmooth:e,areContours:i,description:s,uuid:r,heightInPage:n}=this.#or,{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,h=sv.processDrawnLines({lines:t,pageWidth:a,pageHeight:o,rotation:l,innerMargin:sw._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,n,s,r)}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.#os||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#on=t,this.addEditToolbar()}getUuid(){return this.#on}get description(){return this.#os}set description(t){this.#os=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:i,width:s,height:r}=this.#or,n=Math.max(s,r),a=sv.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:s,height:r},pageWidth:n,pageHeight:n,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){let r,{x:n,y:a}=this,{outline:o}=this.#or=t;this.#oi=o instanceof sb,this.description=i,this.#oi?r=sw.getDefaultDrawingOptions():(r=sw._defaultDrawnSignatureOptions.clone()).updateProperties({"stroke-width":o.thickness}),this._addOutlines({drawOutlines:o,drawingOptions:r});let[,l]=this.pageDimensions,h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=n,this.y=a,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){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;
2return sv.process(t,e,i,s,sw._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:i,pageHeight:s},rotation:r}=this.parent.viewport;return sv.extractContoursFromText(t,e,i,s,r,sw._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return sv.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:sw._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=sw.getDefaultDrawingOptions():(this._drawingOptions=sw._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,r=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#oi,color:[0,0,0],thickness:this.#oi?0:s});return this.addComment(r),t?(r.paths={lines:e,points:i},r.uuid=this.#on,r.isCopy=!0):r.lines=e,this.#os&&(r.accessibilityData={type:"Figure",alt:this.#os}),r}static deserializeDraw(t,e,i,s,r,n){return n.areContours?sb.deserialize(t,e,i,s,r,n):sg.deserialize(t,e,i,s,r,n)}static async deserialize(t,e,i){let s=await super.deserialize(t,e,i);return s.#oi=t.areContours,s.description=t.accessibilityData?.alt||"",s.#on=t.uuid,s}}class sx extends tB{#oa=null;#oo=null;#ol=null;#oh=null;#od=null;#oc="";#ou=null;#op=!1;#og=null;#om=!1;#of=!1;static _type="stamp";static _editorType=d.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#oh=t.bitmapUrl,this.#od=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){tB.initialize(t,e)}static isHandlingMimeForPasting(t){return tp.includes(t)}static paste(t,e){e.pasteEditor({mode:d.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){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#ob(t,e=!1){t?(this.#oa=t.bitmap,e||(this.#oo=t.id,this.#om=t.isSvg),t.file&&(this.#oc=t.file.name),this.#ov()):this.remove()}#oy(){if(this.#ol=null,this._uiManager.enableWaiting(!1),this.#ou){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oa)return void this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oa){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;let{mlManager:i}=this._uiManager;if(!i)throw Error("No ML.");if(!await i.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:s,width:r,height:n}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:r,height:n,channels:s.length/(r*n)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#oA(){if(this.#oo){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#oo).then(t=>this.#ob(t,!0)).finally(()=>this.#oy());return}if(this.#oh){let t=this.#oh;this.#oh=null,this._uiManager.enableWaiting(!0),this.#ol=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#ob(t)).finally(()=>this.#oy());return}if(this.#od){let t=this.#od;this.#od=null,this._uiManager.enableWaiting(!0),this.#ol=this._uiManager.imageManager.getFromFile(t).then(t=>this.#ob(t)).finally(()=>this.#oy());return}let t=document.createElement("input");t.type="file",t.accept=tp.join(",");let e=this._uiManager._signal;this.#ol=new Promise(i=>{t.addEventListener("change",async()=>
2{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#ob(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#oy()),t.click()}remove(){this.#oo&&(this.#oa=null,this._uiManager.imageManager.deleteId(this.#oo),this.#ou?.remove(),this.#ou=null,this.#og&&(clearTimeout(this.#og),this.#og=null)),super.remove()}rebuild(){if(!this.parent){this.#oo&&this.#oA();return}super.rebuild(),null!==this.div&&(this.#oo&&null===this.#ou&&this.#oA(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#ol||this.#oa||this.#oh||this.#od||this.#oo||this.#op)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){let t,e;return this.div||(this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#op||(this.#oa?this.#ov():this.#oA()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this)),this.div}setCanvas(t,e){let{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#oo=i,s&&(this.#oa=s),this.#op=!1,this.#ov())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#og&&clearTimeout(this.#og),this.#og=setTimeout(()=>{this.#og=null,this.#ow()},200))}#ov(){let{div:t}=this,{width:e,height:i}=this.#oa,[s,r]=this.pageDimensions;if(this.width)e=this.width*s,i=this.height*r;else if(e>.75*s||i>.75*r){let t=Math.min(.75*s/e,.75*r/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);let n=this.#ou=document.createElement("canvas");n.setAttribute("role","img"),this.addContainer(n),this.width=e/s,this.height=i/r,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#ow(),this.#of||(this.parent.addUndoableEditor(this),this.#of=!0),this._reportTelemetry({action:"inserted_image"}),this.#oc&&this.div.setAttribute("aria-description",this.#oc),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,i=!1){t||(t=224);let{width:s,height:r}=this.#oa,n=new tu,a=this.#oa,o=s,l=r,h=null;if(e){if(s>e||r>e){let t=Math.min(e/s,e/r);o=Math.floor(s*t),l=Math.floor(r*t)}let t=(h=document.createElement("canvas")).width=Math.ceil(o*n.sx),i=h.height=Math.ceil(l*n.sy);this.#om||(a=this.#ox(t,i));let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":tg.isDarkMode&&(c="#8f8f9d",u="#42414d");let p=15*n.sx,g=15*n.sy,m=new OffscreenCanvas(2*p,2*g),f=m.getContext("2d");f.fillStyle=c,f.fillRect(0,0,2*p,2*g),f.fillStyle=u,f.fillRect(0,0,p,g),f.fillRect(p,g,p,g),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(n.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#oa,s>t||r>t){let n=Math.min(t/s,t/r);e=Math.floor(s*n),i=Math.floor(r*n),this.#om||(a=this.#ox(e,i))}let o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#ox(t,e){let{width:i,height:s}=this.#oa,r=i,n=s,a=this.#oa;for(;r>2*t||n>2*e;){let i=r,s=n;r>2*t&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),n>2*e&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2));let o=new OffscreenCanvas(r,n);o.getContext("2d").drawImage(a,0,0,i,s,0,0,r,n),a=o.transferToImageBitmap()}return a}#ow(){let[t,e]=this.parentDimensions,{width:i,height:s}=this,r=new tu,n=Math.ceil(i*t*r.sx),a=Math.ceil(s*e*r.sy),o=this.#ou;if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;let l=this.#om?this.#oa:this.#ox(n,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,n,a)}#o_(t){if(t){if(this.#om){let t=this._uiManager.imageManager.getSvgUrl(this.#oo);if(t)return t}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#oa,t.getContext("2d").drawImage(this.#oa,0,0),t.toDataURL()}if(this.#om){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*X.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*X.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,s);return r.getContext("2d").drawImage(this.#oa,0,0,this.#oa.width,this.#oa.height,0,0,i,s),r.transferToImageBitmap()}return structuredClone(this.#oa)}static async deserialize(t,e,i){let s=null,r=!1;if(t instanceof i7){let n,a,{data:{rect:o,rotation:l,id:h,structParent:c,popupRef:u,richText:p,contentsObj:g,creationDate:m,modificationDate:f},container:b,parent:{page:{pageNumber:v}},canvas:y}=t;y?(delete t.canvas,{id:n,bitmap:a}=i.imageManager.getFromCanvas(b.id,y),y.remove()):(r=!0,t._hasNoCanvas=!0);let A=(await e._structTree.getAriaAttributes(`${$}${h}`))?.get("aria-label")||"";s=t={annotationType:d.STAMP,bitmapId:n,bitmap:a,pageIndex:v-1,rect:o.slice(0),rotation:l,annotationElementId:h,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:A},isSvg:!1,structParent:c,popupRef:u,richText:p,comment:g?.str||null,creationDate:m,modificationDate:f}}let n=await super.deserialize(t,e,i),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:c,accessibilityData:u}=t;r?(i.addMissingCanvas(t.id,n),n.#op=!0):h&&i.imageManager.isValidId(h)?(n.#oo=h,o&&(n.#oa=o)):n.#oh=l,n.#om=c;let[p,g]=n.pageDimensions;return n.width=(a[2]-a[0])/p,n.height=(a[3]-a[1])/g,u&&(n.altTextData=u),n._initialData=s,t.comment&&n.setCommentData(t),n.#of=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i=Object.assign(super.serialize(t),{bitmapId:this.#oo,isSvg:this.#om});if(this.addComment(i),t)return i.bitmapUrl=this.#o_(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;let{decorative:s,altText:r}=this.serializeAltText(!1);if(!s&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){let t=this.#nT(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;let n=this.#om?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#oo)){if(this.#om){let t=e.stamps.get(this.#oo);n>t.area&&(t.area=n,t.serialized.bitmap.close(),t.serialized.bitmap=this.#o_(!1))}}else e.stamps.set(this.#oo,{area:n,serialized:i}),i.bitmap=this.#o_(!1);return i}#nT(t){let{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,r=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&r,isSameAltText:r}}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}
2class s_{#nd;#oC=!1;#oS=null;#oE=null;#oT=null;#oM=new Map;#oD=!1;#ok=!1;#oP=!1;#oI=null;#oR=null;#oL=null;#oF=null;#oB=null;#oN=-1;#b;static _initialized=!1;static #V=new Map([si,sf,sx,sd,sw].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:r,annotationLayer:n,drawLayer:a,textLayer:o,viewport:l,l10n:h}){const d=[...s_.#V.values()];if(!s_._initialized)for(const e of(s_._initialized=!0,d))e.initialize(h,t);t.registerEditorTypes(d),this.#b=t,this.pageIndex=e,this.div=i,this.#nd=r,this.#oS=n,this.viewport=l,this.#oL=o,this.drawLayer=a,this._structTree=s,this.#b.addLayer(this)}get isEmpty(){return 0===this.#oM.size}get isInvisible(){return this.isEmpty&&this.#b.getMode()===d.NONE}updateToolbar(t){this.#b.updateToolbar(t)}updateMode(t=this.#b.getMode()){switch(this.#oO(),t){case d.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case d.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case d.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===d.POPUP)e.toggle("commentEditing",!0);else for(let i of(e.toggle("commentEditing",!1),s_.#V.values()))e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#oL?.div}setEditingState(t){this.#b.setEditingState(t)}addCommands(t){this.#b.addCommands(t)}cleanUndoStack(t){this.#b.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#oS?.div.classList.toggle("disabled",!t)}get #oU(){return 0!==this.#oM.size?this.#oM.values():this.#b.getEditors(this.pageIndex)}async enable(){this.#oP=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#oB?.abort(),this.#oB=null;let t=new Set;for(let e of this.#oU)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#b.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));let e=this.#oS;if(e)for(let i of e.getEditableAnnotations()){if(i.hide(),this.#b.isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;let e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#oP=!1,this.#b._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#ok=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#oL&&!this.#oB){this.#oB=new AbortController;let t=this.#b.combinedSignal(this.#oB);this.#oL.div.addEventListener("pointerdown",t=>{let e,{clientX:i,clientY:s,timeStamp:r}=t;if(r-this.#oN>500){this.#oN=r;return}this.#oN=-1;let{classList:n}=this.div;n.toggle("getElements",!0);let a=document.elementsFromPoint(i,s);if(n.toggle("getElements",!1),!this.div.contains(a[0]))return;let o=RegExp(`^${h}[0-9]+$`);for(let t of a)if(o.test(t.id)){e=t.id;break}if(!e)return;let l=this.#oM.get(e);l?.annotationElementId===null&&(t.stopPropagation(),t.preventDefault(),l.dblclick(t))},{signal:t,capture:!0})}let t=this.#oS;if(t){let e=new Map,i=new Map;for(let s of this.#oU){if(s.disableEditing(),!s.annotationElementId){s.updateFakeAnnotationElement(t);continue}if(null!==s.serialize()){e.set(s.annotationElementId,s);continue}i.set(s.annotationElementId,s),this.getEditableAnnotation(s.annotationElementId)?.show(),s.remove()}for(let s of t.getEditableAnnotations()){let{id:t}=s.data;if(this.#b.isDeletedAnnotationElement(t)){s.updateEdited({deleted:!0});continue}let r=i.get(t);if(r){r.resetAnnotationElement(s),r.show(!1),s.show();continue}(r=e.get(t))&&(this.#b.addChangedExistingAnnotation(r),r.renderAnnotationElement(s)&&r.show(!1)),s.show()}}this.#oO(),this.isEmpty&&(this.div.hidden=!0);let{classList:e}=this.div;for(let t of s_.#V.values())e.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#ok=!1}getEditableAnnotation(t){return this.#oS?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#b.getActive()!==t&&this.#b.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#oL?.div&&!this.#oF){this.#oF=new AbortController;let t=this.#b.combinedSignal(this.#oF);this.#oL.div.addEventListener("pointerdown",this.#oz.bind(this),{signal:t}),this.#oL.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#oL?.div&&this.#oF&&(this.#oF.abort(),this.#oF=null,this.#oL.div.classList.remove("highlighting"))}#oz(t){this.#b.unselectAll();let{target:e}=t;if(e===this.#oL.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#oL.div.contains(e)){let{isMac:e}=F.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#b.showAllEditors("highlight",!0,!0),this.#oL.div.classList.add("free"),this.toggleDrawing(),sd.startHighlighting(this,"ltr"===this.#b.direction,{target:this.#oL.div,x:t.x,y:t.y}),this.#oL.div.addEventListener("pointerup",()=>{this.#oL.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#b._signal}),t.preventDefault()}}enableClick(){if(this.#oE)return;this.#oE=new AbortController;let t=this.#b.combinedSignal(this.#oE);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#oE?.abort(),this.#oE=null}attach(t){this.#oM.set(t.id,t);let{annotationElementId:e}=t;e&&this.#b.isDeletedAnnotationElement(e)&&this.#b.removeDeletedAnnotationElement(t)}detach(t){this.#oM.delete(t.id),this.#nd?.removePointerInTextLayer(t.contentDiv),!this.#ok&&t.annotationElementId&&this.#b.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#b.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#b.addDeletedAnnotationElement(t.annotationElementId),tB.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.#b.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#oP),this.#b.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#oT&&(t._focusEventsAllowed=!1,this.#oT=setTimeout(()=>{this.#oT=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#b._signal}),e.focus())},0)),t._structTreeParentId=this.#nd?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getEditorByUID(t){for(let e of this.#oM.values())if(e.uid===t)return e;return null}getNextId(){return this.#b.getId()}get #oH(){return s_.#V.get(this.#b.getMode())}combinedSignal(t){return this.#b.combinedSignal(t)}#o$(t){let e=this.#oH;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#oH?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#b.updateMode(t.mode);let{offsetX:i,offsetY:s}=this.#oj(),r=this.getNextId(),n=this.#o$({parent:this,id:r,x:i,y:s,uiManager:this.#b,isCentered:!0,...e});n&&this.add(n)}async deserialize(t){return await s_.#V.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#b)||null}createAndAddNewEditor(t,e,i={}){let s=this.getNextId(),r=this.#o$({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#b,isCentered:e,...i});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}#oj(){let{x:t,y:e,width:i,height:s}=this.boundingClientRect,r=Math.max(0,t),n=Math.max(0,e),a=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+s),l=(r+a)/2-t,h=(n+o)/2-e,[d,c]=this.viewport.rotation%180==0?[l,h]:[h,l];return{offsetX:d,offsetY:c}}addNewEditor(t={}){this.createAndAddNewEditor(this.#oj(),!0,t)}setSelected(t){this.#b.setSelected(t)}toggleSelected(t){this.#b.toggleSelected(t)}unselect(t){this.#b.unselect(t)}pointerup(t){let{isMac:e}=F.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div||!this.#oD||(this.#oD=!1,this.#oH?.isDrawer&&this.#oH.supportMultipleDrawings))return;if(!this.#oC){this.#oC=!0;return}let i=this.#b.getMode();i===d.STAMP||i===d.SIGNATURE?this.#b.unselectAll():this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#b.getMode()===d.HIGHLIGHT&&this.enableTextSelection(),this.#oD){this.#oD=!1;return}let{isMac:e}=F.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div)return;if(this.#oD=!0,this.#oH?.isDrawer)return void this.startDrawingSession(t);let i=this.#b.getActive();this.#oC=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#oI)return void this.#oH.startDrawing(this,this.#b,!1,t);this.#b.setCurrentDrawingSession(this),this.#oI=new AbortController;let e=this.#b.combinedSignal(this.#oI);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#oR=null,this.commitOrRemove())},{signal:e}),this.#oH.startDrawing(this,this.#b,!1,t)}pause(t){if(t){let{activeElement:t}=document;this.div.contains(t)&&(this.#oR=t);return}this.#oR&&setTimeout(()=>
2{this.#oR?.focus(),this.#oR=null},0)}endDrawingSession(t=!1){return this.#oI?(this.#b.setCurrentDrawingSession(null),this.#oI.abort(),this.#oI=null,this.#oR=null,this.#oH.endDrawing(t)):null}findNewParent(t,e,i){let s=this.#b.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#oI&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#oI&&this.#oH.onScaleChangingWhenDrawing(this)}destroy(){for(let t of(this.commitOrRemove(),this.#b.getActive()?.parent===this&&(this.#b.commitOrRemove(),this.#b.setActiveEditor(null)),this.#oT&&(clearTimeout(this.#oT),this.#oT=null),this.#oM.values()))this.#nd?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#oM.clear(),this.#b.removeLayer(this)}#oO(){for(let t of this.#oM.values())t.isEmpty()&&t.remove()}render({viewport:t}){for(let e of(this.viewport=t,tc(this.div,t),this.#b.getEditors(this.pageIndex)))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#b.commitOrRemove(),this.#oO();let e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,tc(this.div,{rotation:i}),e!==i)for(let t of this.#oM.values())t.rotate(i)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#b.viewParameters.realScale}}class sC{#rG=null;#oG=new Map;#oV=new Map;static #w=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#rG){this.#rG=t;return}if(this.#rG!==t){if(this.#oG.size>0)for(let e of this.#oG.values())e.remove(),t.append(e);this.#rG=t}}static get _svgFactory(){return S(this,"_svgFactory",new iR)}static #oW(t,[e,i,s,r]){let{style:n}=t;n.top=`${100*i}%`,n.left=`${100*e}%`,n.width=`${100*s}%`,n.height=`${100*r}%`}#oq(){let t=sC._svgFactory.create(1,1,!0);return this.#rG.append(t),t.setAttribute("aria-hidden",!0),t}#oX(t,e){let i=sC._svgFactory.createElement("clipPath");t.append(i);let s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");let r=sC._svgFactory.createElement("use");return i.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),s}#oK(t,e){for(let[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){let s=sC.#w++,r=this.#oq(),n=sC._svgFactory.createElement("defs");r.append(n);let a=sC._svgFactory.createElement("path");n.append(a);let o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#oV.set(s,a);let l=i?this.#oX(n,o):null,h=sC._svgFactory.createElement("use");return r.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(r,t),this.#oG.set(s,r),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){let i,s=sC.#w++,r=this.#oq(),n=sC._svgFactory.createElement("defs");r.append(n);let a=sC._svgFactory.createElement("path");n.append(a);let o=`path_p${this.pageIndex}_${s}`;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e){let t=sC._svgFactory.createElement("mask");n.append(t),i=`mask_p${this.pageIndex}_${s}`,t.setAttribute("id",i),t.setAttribute("maskUnits","objectBoundingBox");let e=sC._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");let r=sC._svgFactory.createElement("use");t.append(r),r.setAttribute("href",`#${o}`),r.setAttribute("stroke","none"),r.setAttribute("fill","black"),r.setAttribute("fill-rule","nonzero"),r.classList.add("mask")}let l=sC._svgFactory.createElement("use");r.append(l),l.setAttribute("href",`#${o}`),i&&l.setAttribute("mask",`url(#${i})`);let h=l.cloneNode();return r.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(r,t),this.#oG.set(s,r),s}finalizeDraw(t,e){this.#oV.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:i,bbox:s,rootClass:r,path:n}=e,a="number"==typeof t?this.#oG.get(t):t;if(a){if(i&&this.#oK(a,i),s&&sC.#oW(a,s),r){let{classList:t}=a;for(let[e,i]of Object.entries(r))t.toggle(e,i)}if(n){let t=a.firstChild.firstChild;this.#oK(t,n)}}}updateParent(t,e){if(e===this)return;let i=this.#oG.get(t);i&&(e.#rG.append(i),this.#oG.delete(t),e.#oG.set(t,i))}remove(t){this.#oV.delete(t),null!==this.#rG&&(this.#oG.get(t).remove(),this.#oG.delete(t))}
2destroy(){for(let t of(this.#rG=null,this.#oG.values()))t.remove();this.#oG.clear(),this.#oV.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:sa},globalThis.pdfjsLib={AbortException:I,AnnotationEditorLayer:s_,AnnotationEditorParamsType:c,AnnotationEditorType:d,AnnotationEditorUIManager:tI,AnnotationLayer:st,AnnotationMode:l,AnnotationType:g,applyOpacity:tf,build:iE,ColorPicker:iT,createValidAbsoluteUrl:_,CSSConstants:tm,DOMSVGFactory:iR,DrawLayer:sC,FeatureTest:F,fetchData:K,findContrastColor:tx,getDocument:im,getFilenameFromUrl:tt,getPdfFilenameFromUrl:te,getRGB:tl,getUuid:H,getXfaPageViewport:to,GlobalWorkerOptions:eX,ImageKind:p,InvalidPDFException:D,isDataScheme:J,isPdfFile:Z,isValidExplicitDest:tW,MathClamp:j,noContextMenu:tr,normalizeUnicode:z,OPS:f,OutputScale:tu,PasswordResponses:b,PDFDataRangeTransport:iv,PDFDateString:ta,PDFWorker:iw,PermissionFlag:u,PixelsPerInch:X,RenderingCancelledException:Q,renderRichText:t_,ResponseException:k,setLayerDimensions:tc,shadow:S,SignatureExtractor:sv,stopEvent:tn,SupportedImageMimeTypes:tp,TextLayer:ig,TouchManager:tF,updateUrlHash:C,Util:N,VerbosityLevel:m,version:iS,XfaLayer:W}}}]);

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.