@component-hook/pdf-canvas 1.0.5-alpha.4 → 1.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/pdf-canvas.es.js +686 -686
- package/dist/react/pdf-canvas.umd.js +6 -6
- package/dist/vue/pdf-canvas.es.d.ts +9 -1
- package/dist/vue/pdf-canvas.es.js +2116 -2110
- package/dist/vue/pdf-canvas.umd.js +49 -49
- package/package.json +1 -1
|
@@ -524,15 +524,15 @@ void main() {
|
|
|
524
524
|
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
525
525
|
gl_FragColor = color;
|
|
526
526
|
}
|
|
527
|
-
`}applyTo2d(t){let{imageData:{data:e}}=t;const s=-this.vibrance;for(let i=0;i<e.length;i+=4){const n=e[i],r=e[i+1],a=e[i+2],h=Math.max(n,r,a),c=(n+r+a)/3,u=2*Math.abs(h-c)/255*s;e[i]+=h!==n?(h-n)*u:0,e[i+1]+=h!==r?(h-r)*u:0,e[i+2]+=h!==a?(h-a)*u:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}E(rd,"type","Vibrance"),E(rd,"defaults",{vibrance:0}),E(rd,"uniformLocations",["uVibrance"]),G.setClass(rd);const jx="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='20'%20cy='20'%20r='10.75'%20stroke='currentColor'%20stroke-width='2.5'/%3e%3cpath%20d='M16%2024L23.7782%2016.2218'%20stroke='currentColor'%20stroke-width='2.5'%20stroke-linecap='round'/%3e%3cpath%20d='M24%2024L16.2218%2016.2218'%20stroke='currentColor'%20stroke-width='2.5'%20stroke-linecap='round'/%3e%3c/svg%3e";function Nx(o){return new URL(Object.assign({"../assets/close.svg":jx})[`../assets/${o}`],typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Mt&&Mt.tagName.toUpperCase()==="SCRIPT"&&Mt.src||new URL("pdf-canvas.umd.js",document.baseURI).href).href}function Bx(o){return new Promise((t,e)=>{const s=window.URL.createObjectURL(o),i=new Image;i.src=s,i.addEventListener("load",async()=>{window.URL.revokeObjectURL(s),t(await Hx(i))}),i.addEventListener("error",n=>{window.URL.revokeObjectURL(s),e(n)})})}function Hx(o){return new Promise(t=>{const e=document.createElement("canvas"),s=e.getContext("2d"),{naturalWidth:i,naturalHeight:n}=o;e.width=i,e.height=n,s==null||s.drawImage(o,0,0,i,n),t(e.toDataURL("image/jpeg",.8))})}let Sv=null;function Gx(){const o=document.createElement("div");o.style.width="1in",document.body.append(o);const t=o.offsetWidth;return o.remove(),t}function Vx(){const o=Sv??Gx();return Sv=o,o/72}function Wx(o,t=500){if(typeof o!="function")throw new TypeError("The first argument is not a function.");let e=null;return function(...s){e&&clearTimeout(e),e=setTimeout(()=>{e=null,o.apply(this,s)},t)}}const Rs=new Map;function zx(o){const t=new fg(o);return Rs.set(o,t),t}function Xx(o,t){const e=Date.now();return{PDFId:`${o.name}-${e}`,name:o.name.replace(/.pdf/,""),updateDate:e,PDFBase64:t}}function Ux(o,t){const e=o.getViewport({scale:t}),s=document.createElement("canvas"),i=s.getContext("2d"),n=Vx()/window.devicePixelRatio;s.width=Math.floor(e.width*n),s.height=Math.floor(e.height*n);const r={canvasContext:i,viewport:e,transform:[n,0,0,n,0,0]},a=o.render(r);return{canvas:s,renderTask:a}}async function Yx(o,t,e){const s=o||Nx("close.svg"),{objects:i,options:n}=await Tx(s),r=i.filter(h=>h!==null),a=Hw.groupSVGElements(r,n);return r.forEach(h=>{h.stroke=t}),a.hoverCursor="pointer",a.stroke=`${t}-${e}`,a}function $x(o,t){if(!Rs.get(o))return;const s=1/3,i=tS(t,s);Av(o,i,s)}async function qx(o,t){const e=await Bx(t),s=Date.now(),n={PDFId:`${t.name}${s}`,name:t.name.replace(/.png|.jpg|.jpeg/,""),updateDate:s,PDFBase64:e};return Cv(o,{url:e}),{...n,pages:1}}async function Cv(o,{url:t,scale:e=.5}){if(!Rs.get(o))return;const i=await ke.fromURL(t);i.scale(e),Av(o,i,e)}function Av(o,t,e){const s=Rs.get(o);s&&(s.setWidth(t.width*e),s.setHeight(t.height*e),s.backgroundImage=t,s.renderAll())}function nl(o,t){if(!t)return;const{oCoords:e}=o;if(!e)return;const{x:s,y:i}=e.tl.touchCorner.tl,{height:n,width:r,scaleY:a,scaleX:h}=t;t.top=i-n*a/2,t.left=s-r*h/2,t.setCoords()}function Kx(o,t,e){!e||!o||(e.scale(1/t),nl(o,e))}function Jx(o,t,e){o&&(o.borderScaleFactor=1/t,o.cornerSize=6*(1/t),o.touchCornerSize=24*(1/t),o.cornerStrokeColor=e.stroke,o.setCoords())}function Qx(o){const t=Rs.get(o);t&&(t.discardActiveObject(),t.renderAll())}function Zx(o){const t=Rs.get(o);t&&(t.clear(),Rs.delete(o))}function tS(o,t){return new ke(o,{scaleX:t,scaleY:t})}var rl={};rl.d=(o,t)=>{for(var e in t)rl.o(t,e)&&!rl.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:t[e]})},rl.o=(o,t)=>Object.prototype.hasOwnProperty.call(o,t);var Z=globalThis.pdfjsLib={};rl.d(Z,{AbortException:()=>qn,AnnotationEditorLayer:()=>hp,AnnotationEditorParamsType:()=>dt,AnnotationEditorType:()=>nt,AnnotationEditorUIManager:()=>Xr,AnnotationLayer:()=>qC,AnnotationMode:()=>Yn,ColorPicker:()=>Cd,DOMSVGFactory:()=>Qg,DrawLayer:()=>lp,FeatureTest:()=>ze,GlobalWorkerOptions:()=>rn,ImageKind:()=>ad,InvalidPDFException:()=>Pg,MissingPDFException:()=>ol,OPS:()=>si,OutputScale:()=>Ng,PDFDataRangeTransport:()=>ab,PDFDateString:()=>Ig,PDFWorker:()=>Co,PasswordResponses:()=>nS,PermissionFlag:()=>iS,PixelsPerInch:()=>Kn,RenderingCancelledException:()=>Lg,TextLayer:()=>fl,TouchManager:()=>md,UnexpectedResponseException:()=>cd,Util:()=>q,VerbosityLevel:()=>od,XfaLayer:()=>cb,build:()=>PC,createValidAbsoluteUrl:()=>hS,fetchData:()=>dd,getDocument:()=>_C,getFilenameFromUrl:()=>vS,getPdfFilenameFromUrl:()=>bS,getXfaPageViewport:()=>yS,isDataScheme:()=>fd,isPdfFile:()=>Fg,noContextMenu:()=>ii,normalizeUnicode:()=>gS,setLayerDimensions:()=>zr,shadow:()=>ht,stopEvent:()=>gs,version:()=>kC});const Pe=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Tv=[1,0,0,1,0,0],Tg=[.001,0,0,.001,0,0],eS=1e7,Eg=1.35,fs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Yn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},sS="pdfjs_internal_editor_",nt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},dt={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_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},iS={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Me={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},ad={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},oe={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,WIDGET:20},al={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},od={ERRORS:0,WARNINGS:1,INFOS:5},si={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},nS={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let hd=od.WARNINGS;function rS(o){Number.isInteger(o)&&(hd=o)}function aS(){return hd}function ld(o){hd>=od.INFOS&&console.log(`Info: ${o}`)}function rt(o){hd>=od.WARNINGS&&console.log(`Warning: ${o}`)}function Et(o){throw new Error(o)}function ee(o,t){o||Et(t)}function oS(o){switch(o==null?void 0:o.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function hS(o,t=null,e=null){if(!o)return null;try{if(e&&typeof o=="string"){if(e.addDefaultProtocol&&o.startsWith("www.")){const i=o.match(/\./g);(i==null?void 0:i.length)>=2&&(o=`http://${o}`)}if(e.tryConvertEncoding)try{o=fS(o)}catch{}}const s=t?new URL(o,t):new URL(o);if(oS(s))return s}catch{}return null}function ht(o,t,e,s=!1){return Object.defineProperty(o,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const $n=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class Ev extends $n{constructor(t,e){super(t,"PasswordException"),this.code=e}}class kg extends $n{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Pg extends $n{constructor(t){super(t,"InvalidPDFException")}}class ol extends $n{constructor(t){super(t,"MissingPDFException")}}class cd extends $n{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class lS extends $n{constructor(t){super(t,"FormatError")}}class qn extends $n{constructor(t){super(t,"AbortException")}}function kv(o){(typeof o!="object"||(o==null?void 0:o.length)===void 0)&&Et("Invalid argument for bytesToString");const t=o.length,e=8192;if(t<e)return String.fromCharCode.apply(null,o);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=o.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function ud(o){typeof o!="string"&&Et("Invalid argument for stringToBytes");const t=o.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=o.charCodeAt(s)&255;return e}function cS(o){return String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,o&255)}function Mg(o){const t=Object.create(null);for(const[e,s]of o)t[e]=s;return t}function uS(){const o=new Uint8Array(4);return o[0]=1,new Uint32Array(o.buffer,0,1)[0]===1}function dS(){try{return new Function(""),!0}catch{return!1}}class ze{static get isLittleEndian(){return ht(this,"isLittleEndian",uS())}static get isEvalSupported(){return ht(this,"isEvalSupported",dS())}static get isOffscreenCanvasSupported(){return ht(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return ht(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?ht(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):ht(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return ht(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Og=Array.from(Array(256).keys(),o=>o.toString(16).padStart(2,"0"));class q{static makeHexColor(t,e,s){return`#${Og[t]}${Og[e]}${Og[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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 applyTransform(t,e){const s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2],i=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,n]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(s+r)/2,h=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,c=a+h||1,u=a-h||1;return[Math.sqrt(c),Math.sqrt(u)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[s,n,i,r]}static bezierBoundingBox(t,e,s,i,n,r,a,h,c){return c?(c[0]=Math.min(c[0],t,a),c[1]=Math.min(c[1],e,h),c[2]=Math.max(c[2],t,a),c[3]=Math.max(c[3],e,h)):c=[Math.min(t,a),Math.min(e,h),Math.max(t,a),Math.max(e,h)],w(this,an,xp).call(this,t,s,n,a,e,i,r,h,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),c),w(this,an,xp).call(this,t,s,n,a,e,i,r,h,3*(-e+3*(i-r)+h),6*(e-2*i+r),3*(i-e),c),c}}an=new WeakSet,qd=function(t,e,s,i,n,r,a,h,c,u){if(c<=0||c>=1)return;const d=1-c,f=c*c,g=f*c,p=d*(d*(d*t+3*c*e)+3*f*s)+g*i,v=d*(d*(d*n+3*c*r)+3*f*a)+g*h;u[0]=Math.min(u[0],p),u[1]=Math.min(u[1],v),u[2]=Math.max(u[2],p),u[3]=Math.max(u[3],v)},xp=function(t,e,s,i,n,r,a,h,c,u,d,f){if(Math.abs(c)<1e-12){Math.abs(u)>=1e-12&&w(this,an,qd).call(this,t,e,s,i,n,r,a,h,-d/u,f);return}const g=u**2-4*d*c;if(g<0)return;const p=Math.sqrt(g),v=2*c;w(this,an,qd).call(this,t,e,s,i,n,r,a,h,(-u+p)/v,f),w(this,an,qd).call(this,t,e,s,i,n,r,a,h,(-u-p)/v,f)},y(q,an);function fS(o){return decodeURIComponent(escape(o))}let Dg=null,Pv=null;function gS(o){return Dg||(Dg=/([\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,Pv=new Map([["ſt","ſt"]])),o.replaceAll(Dg,(t,e,s)=>e?e.normalize("NFKC"):Pv.get(s))}function pS(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const o=new Uint8Array(32);return crypto.getRandomValues(o),kv(o)}const Rg="pdfjs_internal_id_";function mS(o){return Uint8Array.prototype.toBase64?o.toBase64():btoa(kv(o))}typeof Promise.try!="function"&&(Promise.try=function(o,...t){return new Promise(e=>{e(o(...t))})});const nn="http://www.w3.org/2000/svg",$r=class $r{};J($r,"CSS",96),J($r,"PDF",72),J($r,"PDF_TO_CSS_UNITS",$r.CSS/$r.PDF);let Kn=$r;async function dd(o,t="text"){if(ll(o,document.baseURI)){const e=await fetch(o);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",o,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class hl{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;const h=(t[2]+t[0])/2,c=(t[3]+t[1])/2;let u,d,f,g;switch(i%=360,i<0&&(i+=360),i){case 180:u=-1,d=0,f=0,g=1;break;case 90:u=0,d=1,f=1,g=0;break;case 270:u=0,d=-1,f=-1,g=0;break;case 0:u=1,d=0,f=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(f=-f,g=-g);let p,v,_,b;u===0?(p=Math.abs(c-t[1])*s+n,v=Math.abs(h-t[0])*s+r,_=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(p=Math.abs(h-t[0])*s+n,v=Math.abs(c-t[1])*s+r,_=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[u*s,d*s,f*s,g*s,p-u*s*h-f*s*c,v-d*s*h-g*s*c],this.width=_,this.height=b}get rawDims(){const{userUnit:t,viewBox:e}=this,s=e.map(i=>i*t);return ht(this,"rawDims",{pageWidth:s[2]-s[0],pageHeight:s[3]-s[1],pageX:s[0],pageY:s[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new hl({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return q.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=q.applyTransform([t[0],t[1]],this.transform),s=q.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return q.applyInverseTransform([t,e],this.transform)}}class Lg extends $n{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function fd(o){const t=o.length;let e=0;for(;e<t&&o[e].trim()==="";)e++;return o.substring(e,e+5).toLowerCase()==="data:"}function Fg(o){return typeof o=="string"&&/\.pdf$/i.test(o)}function vS(o){return[o]=o.split(/[#?]/,1),o.substring(o.lastIndexOf("/")+1)}function bS(o,t="document.pdf"){if(typeof o!="string")return t;if(fd(o))return rt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(o);let n=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(n&&(n=n[0],n.includes("%")))try{n=s.exec(decodeURIComponent(n))[0]}catch{}return n||t}class Mv{constructor(){J(this,"started",Object.create(null));J(this,"times",[])}time(t){t in this.started&&rt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||rt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
|
|
528
|
-
`);return t.join("")}}function ll(o,t){try{const{protocol:e}=t?new URL(o,t):new URL(o);return e==="http:"||e==="https:"}catch{return!1}}function ii(o){o.preventDefault()}function gs(o){o.preventDefault(),o.stopPropagation()}class Ig{static toDateObject(t){if(!t||typeof t!="string")return null;l(this,bl)||m(this,bl,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=l(this,bl).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let h=parseInt(e[6],10);h=h>=0&&h<=59?h:0;const c=e[7]||"Z";let u=parseInt(e[8],10);u=u>=0&&u<=23?u:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,c==="-"?(r+=u,a+=d):c==="+"&&(r-=u,a-=d),new Date(Date.UTC(s,i,n,r,a,h))}}bl=new WeakMap,y(Ig,bl);function yS(o,{scale:t=1,rotation:e=0}){const{width:s,height:i}=o.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new hl({viewBox:n,userUnit:1,scale:t,rotation:e})}function jg(o){if(o.startsWith("#")){const t=parseInt(o.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return o.startsWith("rgb(")?o.slice(4,-1).split(",").map(t=>parseInt(t)):o.startsWith("rgba(")?o.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(rt(`Not a valid color format: "${o}"`),[0,0,0])}function _S(o){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of o.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;o.set(e,jg(s))}t.remove()}function It(o){const{a:t,b:e,c:s,d:i,e:n,f:r}=o.getTransform();return[t,e,s,i,n,r]}function Ai(o){const{a:t,b:e,c:s,d:i,e:n,f:r}=o.getTransform().invertSelf();return[t,e,s,i,n,r]}function zr(o,t,e=!1,s=!0){if(t instanceof hl){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=o,a=ze.isCSSRoundSupported,h=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${n}px`,u=a?`round(down, ${h}, var(--scale-round-x, 1px))`:`calc(${h})`,d=a?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!e||t.rotation%180===0?(r.width=u,r.height=d):(r.width=d,r.height=u)}s&&o.setAttribute("data-main-rotation",t.rotation)}class Ng{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}}const on=class on{constructor(t){y(this,Xe);y(this,Qn,null);y(this,qr,null);y(this,ni);y(this,Kr,null);y(this,yl,null);m(this,ni,t),l(on,_l)||m(on,_l,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){const t=m(this,Qn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=l(this,ni)._uiManager._signal;t.addEventListener("contextmenu",ii,{signal:e}),t.addEventListener("pointerdown",w(on,Ed,Ib),{signal:e});const s=m(this,Kr,document.createElement("div"));s.className="buttons",t.append(s);const i=l(this,ni).toolbarPosition;if(i){const{style:n}=t,r=l(this,ni)._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return w(this,Xe,Bb).call(this),t}get div(){return l(this,Qn)}hide(){var t;l(this,Qn).classList.add("hidden"),(t=l(this,qr))==null||t.hideDropdown()}show(){var t;l(this,Qn).classList.remove("hidden"),(t=l(this,yl))==null||t.shown()}async addAltText(t){const e=await t.render();w(this,Xe,Kd).call(this,e),l(this,Kr).prepend(e,l(this,Xe,Sp)),m(this,yl,t)}addColorPicker(t){m(this,qr,t);const e=t.renderButton();w(this,Xe,Kd).call(this,e),l(this,Kr).prepend(e,l(this,Xe,Sp))}remove(){var t;l(this,Qn).remove(),(t=l(this,qr))==null||t.destroy(),m(this,qr,null)}};Qn=new WeakMap,qr=new WeakMap,ni=new WeakMap,Kr=new WeakMap,yl=new WeakMap,_l=new WeakMap,Ed=new WeakSet,Ib=function(t){t.stopPropagation()},Xe=new WeakSet,jb=function(t){l(this,ni)._focusEventsAllowed=!1,gs(t)},Nb=function(t){l(this,ni)._focusEventsAllowed=!0,gs(t)},Kd=function(t){const e=l(this,ni)._uiManager._signal;t.addEventListener("focusin",w(this,Xe,jb).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",w(this,Xe,Nb).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ii,{signal:e})},Bb=function(){const{editorType:t,_uiManager:e}=l(this,ni),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",l(on,_l)[t]),w(this,Xe,Kd).call(this,s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),l(this,Kr).append(s)},Sp=function(){const t=document.createElement("div");return t.className="divider",t},y(on,Ed),y(on,_l,null);let Bg=on;class wS{constructor(t){y(this,Zn);y(this,wl,null);y(this,Jr,null);y(this,Qr);m(this,Qr,t)}show(t,e,s){const[i,n]=w(this,Zn,Gb).call(this,e,s),{style:r}=l(this,Jr)||m(this,Jr,w(this,Zn,Hb).call(this));t.append(l(this,Jr)),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){l(this,Jr).remove()}}wl=new WeakMap,Jr=new WeakMap,Qr=new WeakMap,Zn=new WeakSet,Hb=function(){const t=m(this,Jr,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",ii,{signal:l(this,Qr)._signal});const e=m(this,wl,document.createElement("div"));return e.className="buttons",t.append(e),w(this,Zn,Vb).call(this),t},Gb=function(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]},Vb=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=l(this,Qr)._signal;t.addEventListener("contextmenu",ii,{signal:s}),t.addEventListener("click",()=>{l(this,Qr).highlightSelection("floating_button")},{signal:s}),l(this,wl).append(t)};function gd(o,t,e){for(const s of e)t.addEventListener(s,o[s].bind(o))}class xS{constructor(){y(this,kd,0)}get id(){return`${sS}${Ze(this,kd)._++}`}}kd=new WeakMap;const cp=class cp{constructor(){y(this,To);y(this,Ao,pS());y(this,xl,0);y(this,De,null)}static get _isSVGFittingCanvas(){const t='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=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return ht(this,"_isSVGFittingCanvas",n)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return w(this,To,Jd).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return w(this,To,Jd).call(this,t,t)}async getFromBlob(t,e){const s=await e;return w(this,To,Jd).call(this,t,s)}async getFromId(t){l(this,De)||m(this,De,new Map);const e=l(this,De).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){l(this,De)||m(this,De,new Map);let s=l(this,De).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${l(this,Ao)}_${Ze(this,xl)._++}`,refCounter:1,isSvg:!1},l(this,De).set(t,s),l(this,De).set(s.id,s),s}getSvgUrl(t){const e=l(this,De).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;l(this,De)||m(this,De,new Map);const e=l(this,De).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const n=new OffscreenCanvas(s.width,s.height);n.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=n.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${l(this,Ao)}_`)}};Ao=new WeakMap,xl=new WeakMap,De=new WeakMap,To=new WeakSet,Jd=async function(t,e){l(this,De)||m(this,De,new Map);let s=l(this,De).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${l(this,Ao)}_${Ze(this,xl)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await dd(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=cp._isSVGFittingCanvas,r=new FileReader,a=new Image,h=new Promise((c,u)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,c()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=u});r.readAsDataURL(i),await h}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){rt(i),s=null}return l(this,De).set(t,s),s&&l(this,De).set(s.id,s),s};let Hg=cp;class SS{constructor(t=128){y(this,Kt,[]);y(this,tr,!1);y(this,Sl);y(this,Gt,-1);m(this,Sl,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),l(this,tr))return;const h={cmd:t,undo:e,post:s,type:n};if(l(this,Gt)===-1){l(this,Kt).length>0&&(l(this,Kt).length=0),m(this,Gt,0),l(this,Kt).push(h);return}if(r&&l(this,Kt)[l(this,Gt)].type===n){a&&(h.undo=l(this,Kt)[l(this,Gt)].undo),l(this,Kt)[l(this,Gt)]=h;return}const c=l(this,Gt)+1;c===l(this,Sl)?l(this,Kt).splice(0,1):(m(this,Gt,c),c<l(this,Kt).length&&l(this,Kt).splice(c)),l(this,Kt).push(h)}undo(){if(l(this,Gt)===-1)return;m(this,tr,!0);const{undo:t,post:e}=l(this,Kt)[l(this,Gt)];t(),e==null||e(),m(this,tr,!1),m(this,Gt,l(this,Gt)-1)}redo(){if(l(this,Gt)<l(this,Kt).length-1){m(this,Gt,l(this,Gt)+1),m(this,tr,!0);const{cmd:t,post:e}=l(this,Kt)[l(this,Gt)];t(),e==null||e(),m(this,tr,!1)}}hasSomethingToUndo(){return l(this,Gt)!==-1}hasSomethingToRedo(){return l(this,Gt)<l(this,Kt).length-1}cleanType(t){if(l(this,Gt)!==-1){for(let e=l(this,Gt);e>=0;e--)if(l(this,Kt)[e].type!==t){l(this,Kt).splice(e+1,l(this,Gt)-e),m(this,Gt,e);return}l(this,Kt).length=0,m(this,Gt,-1)}}destroy(){m(this,Kt,null)}}Kt=new WeakMap,tr=new WeakMap,Sl=new WeakMap,Gt=new WeakMap;class cl{constructor(t){y(this,Pd);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ze.platform;for(const[s,i,n={}]of t)for(const r of s){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(w(this,Pd,Wb).call(this,e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||gs(e))}}Pd=new WeakSet,Wb=function(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);const e=this.buffer.join("+");return this.buffer.length=0,e};const Md=class Md{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return _S(t),ht(this,"_colors",t)}convert(t){const e=jg(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return Md._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?q.makeHexColor(...e):t}};J(Md,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Gg=Md;const Ro=class Ro{constructor(t,e,s,i,n,r,a,h,c,u,d,f,g){y(this,B);y(this,Eo,new AbortController);y(this,ps,null);y(this,he,new Map);y(this,be,new Map);y(this,ko,null);y(this,hn,null);y(this,Po,null);y(this,Fs,new SS);y(this,er,null);y(this,Zr,null);y(this,Mo,0);y(this,ta,new Set);y(this,Ei,null);y(this,ri,null);y(this,ea,new Set);J(this,"_editorUndoBar",null);y(this,Cl,!1);y(this,Al,!1);y(this,Oo,!1);y(this,Tl,null);y(this,ki,null);y(this,sr,null);y(this,Do,null);y(this,ir,!1);y(this,Pi,null);y(this,Od,new xS);y(this,nr,!1);y(this,El,!1);y(this,rr,null);y(this,sa,null);y(this,kl,null);y(this,Pl,null);y(this,de,nt.NONE);y(this,xt,new Set);y(this,ln,null);y(this,ia,null);y(this,Ml,null);y(this,Ol,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});y(this,ar,[0,0]);y(this,Mi,null);y(this,cn,null);y(this,Dl,null);y(this,Is,null);const p=this._signal=l(this,Eo).signal;m(this,cn,t),m(this,Dl,e),m(this,ko,s),this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:p}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),i._on("setpreference",this.onSetPreference.bind(this),{signal:p}),i._on("switchannotationeditorparams",v=>this.updateParams(v.type,v.value),{signal:p}),w(this,B,Ub).call(this),w(this,B,Kb).call(this),w(this,B,Ap).call(this),m(this,hn,n.annotationStorage),m(this,Tl,n.filterFactory),m(this,ia,r),m(this,Do,a||null),m(this,Cl,h),m(this,Al,c),m(this,Oo,u),m(this,Pl,d||null),this.viewParameters={realScale:Kn.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=f||null,this._supportsPinchToZoom=g!==!1}static get _keyboardManager(){const t=Ro.prototype,e=r=>l(r,cn).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:h}=a;return h!=="text"&&h!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return ht(this,"_keyboardManager",new cl([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&l(r,cn).contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&l(r,cn).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}destroy(){var t,e,s,i,n;(t=l(this,Is))==null||t.resolve(),m(this,Is,null),(e=l(this,Eo))==null||e.abort(),m(this,Eo,null),this._signal=null;for(const r of l(this,be).values())r.destroy();l(this,be).clear(),l(this,he).clear(),l(this,ea).clear(),m(this,ps,null),l(this,xt).clear(),l(this,Fs).destroy(),(s=l(this,ko))==null||s.destroy(),(i=l(this,Pi))==null||i.hide(),m(this,Pi,null),l(this,ki)&&(clearTimeout(l(this,ki)),m(this,ki,null)),l(this,Mi)&&(clearTimeout(l(this,Mi)),m(this,Mi,null)),(n=this._editorUndoBar)==null||n.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return l(this,Pl)}get useNewAltTextFlow(){return l(this,Al)}get useNewAltTextWhenAddingImage(){return l(this,Oo)}get hcmFilter(){return ht(this,"hcmFilter",l(this,ia)?l(this,Tl).addHCMFilter(l(this,ia).foreground,l(this,ia).background):"none")}get direction(){return ht(this,"direction",getComputedStyle(l(this,cn)).direction)}get highlightColors(){return ht(this,"highlightColors",l(this,Do)?new Map(l(this,Do).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return ht(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),m(this,Zr,t)}setMainHighlightColorPicker(t){m(this,kl,t)}editAltText(t,e=!1){var s;(s=l(this,ko))==null||s.editAltText(this,t,e)}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}){switch(t){case"enableNewAltTextWhenAddingImage":m(this,Oo,e);break}}onPageChanging({pageNumber:t}){m(this,Mo,t-1)}focusMainContainer(){l(this,cn).focus()}findParent(t,e){for(const s of l(this,be).values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){l(this,Dl).classList.toggle("noUserSelect",t)}addShouldRescale(t){l(this,ea).add(t)}removeShouldRescale(t){l(this,ea).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Kn.PDF_TO_CSS_UNITS;for(const s of l(this,ea))s.onScaleChanging();(e=l(this,Zr))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=e,a=e.toString(),c=w(this,B,Qd).call(this,e).closest(".textLayer"),u=this.getSelectionBoxes(c);if(!u)return;e.empty();const d=w(this,B,Cp).call(this,c),f=l(this,de)===nt.NONE,g=()=>{d==null||d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a}),f&&this.showAllEditors("highlight",!0,!0)};if(f){this.switchToMode(nt.HIGHLIGHT,g);return}g()}addToAnnotationStorage(t){!t.isEmpty()&&l(this,hn)&&!l(this,hn).has(t.id)&&l(this,hn).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,l(this,ir)&&(m(this,ir,!1),w(this,B,Zd).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of l(this,xt))if(e.div.contains(t)){m(this,sa,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!l(this,sa))return;const[t,e]=l(this,sa);m(this,sa,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){w(this,B,Ap).call(this),w(this,B,Tp).call(this)}removeEditListeners(){w(this,B,qb).call(this),w(this,B,Ep).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of l(this,ri))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of l(this,ri))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=l(this,ps))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of l(this,xt)){const n=i.serialize(!0);n&&e.push(n)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of l(this,ri))if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){rt(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const h of s){const c=await i.deserialize(h);if(!c)return;n.push(c)}const r=()=>{for(const h of n)w(this,B,kp).call(this,h);w(this,B,Pp).call(this,n)},a=()=>{for(const h of n)h.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){rt(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),l(this,de)!==nt.NONE&&!this.isEditorHandlingKeyboard&&Ro._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,l(this,ir)&&(m(this,ir,!1),w(this,B,Zd).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}setEditingState(t){t?(w(this,B,Yb).call(this),w(this,B,Tp).call(this),w(this,B,ts).call(this,{isEditing:l(this,de)!==nt.NONE,isEmpty:w(this,B,Xc).call(this),hasSomethingToUndo:l(this,Fs).hasSomethingToUndo(),hasSomethingToRedo:l(this,Fs).hasSomethingToRedo(),hasSelectedEditor:!1})):(w(this,B,$b).call(this),w(this,B,Ep).call(this),w(this,B,ts).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!l(this,ri)){m(this,ri,t);for(const e of l(this,ri))w(this,B,jn).call(this,e.defaultPropertiesToUpdate)}}getId(){return l(this,Od).id}get currentLayer(){return l(this,be).get(l(this,Mo))}getLayer(t){return l(this,be).get(t)}get currentPageIndex(){return l(this,Mo)}addLayer(t){l(this,be).set(t.pageIndex,t),l(this,nr)?t.enable():t.disable()}removeLayer(t){l(this,be).delete(t.pageIndex)}async updateMode(t,e=null,s=!1){var i;if(l(this,de)!==t&&!(l(this,Is)&&(await l(this,Is).promise,!l(this,Is)))){if(m(this,Is,Promise.withResolvers()),m(this,de,t),t===nt.NONE){this.setEditingState(!1),w(this,B,Qb).call(this),(i=this._editorUndoBar)==null||i.hide(),l(this,Is).resolve();return}this.setEditingState(!0),await w(this,B,Jb).call(this),this.unselectAll();for(const n of l(this,be).values())n.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),l(this,Is).resolve();return}for(const n of l(this,he).values())n.annotationElementId===e?(this.setSelected(n),n.enterInEditMode()):n.unselect();l(this,Is).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==l(this,de)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(l(this,ri)){switch(t){case dt.CREATE:this.currentLayer.addNewEditor();return;case dt.HIGHLIGHT_DEFAULT_COLOR:(s=l(this,kl))==null||s.updateColor(e);break;case dt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(l(this,Ml)||m(this,Ml,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of l(this,xt))i.updateParams(t,e);for(const i of l(this,ri))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const r of l(this,he).values())r.editorType===t&&r.show(e);(((n=l(this,Ml))==null?void 0:n.get(dt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&w(this,B,jn).call(this,[[dt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(l(this,El)!==t){m(this,El,t);for(const e of l(this,be).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of l(this,he).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return l(this,he).get(t)}addEditor(t){l(this,he).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(l(this,ki)&&clearTimeout(l(this,ki)),m(this,ki,setTimeout(()=>{this.focusMainContainer(),m(this,ki,null)},0))),l(this,he).delete(t.id),this.unselect(t),(!t.annotationElementId||!l(this,ta).has(t.annotationElementId))&&((e=l(this,hn))==null||e.remove(t.id))}addDeletedAnnotationElement(t){l(this,ta).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return l(this,ta).has(t)}removeDeletedAnnotationElement(t){l(this,ta).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){l(this,ps)!==t&&(m(this,ps,t),t&&w(this,B,jn).call(this,t.propertiesToUpdate))}updateUI(t){l(this,B,Zb)===t&&w(this,B,jn).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){w(this,B,jn).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(l(this,xt).has(t)){l(this,xt).delete(t),t.unselect(),w(this,B,ts).call(this,{hasSelectedEditor:this.hasSelection});return}l(this,xt).add(t),t.select(),w(this,B,jn).call(this,t.propertiesToUpdate),w(this,B,ts).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;(e=l(this,Zr))==null||e.commitOrRemove();for(const s of l(this,xt))s!==t&&s.unselect();l(this,xt).clear(),l(this,xt).add(t),t.select(),w(this,B,jn).call(this,t.propertiesToUpdate),w(this,B,ts).call(this,{hasSelectedEditor:!0})}isSelected(t){return l(this,xt).has(t)}get firstSelectedEditor(){return l(this,xt).values().next().value}unselect(t){t.unselect(),l(this,xt).delete(t),w(this,B,ts).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return l(this,xt).size!==0}get isEnterHandled(){return l(this,xt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;l(this,Fs).undo(),w(this,B,ts).call(this,{hasSomethingToUndo:l(this,Fs).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:w(this,B,Xc).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){l(this,Fs).redo(),w(this,B,ts).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:l(this,Fs).hasSomethingToRedo(),isEmpty:w(this,B,Xc).call(this)})}addCommands(t){l(this,Fs).add(t),w(this,B,ts).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:w(this,B,Xc).call(this)})}cleanUndoStack(t){l(this,Fs).cleanType(t)}delete(){var n;this.commitOrRemove();const t=(n=this.currentLayer)==null?void 0:n.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...l(this,xt)],s=()=>{var r;(r=this._editorUndoBar)==null||r.show(i,e.length===1?e[0].editorType:e.length);for(const a of e)a.remove()},i=()=>{for(const r of e)w(this,B,kp).call(this,r)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=l(this,ps))==null||t.commitOrRemove()}hasSomethingToControl(){return l(this,ps)||this.hasSelection}selectAll(){for(const t of l(this,xt))t.commit();w(this,B,Pp).call(this,l(this,he).values())}unselectAll(){var t;if(!(l(this,ps)&&(l(this,ps).commitOrRemove(),l(this,de)!==nt.NONE))&&!((t=l(this,Zr))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of l(this,xt))e.unselect();l(this,xt).clear(),w(this,B,ts).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;l(this,ar)[0]+=t,l(this,ar)[1]+=e;const[i,n]=l(this,ar),r=[...l(this,xt)],a=1e3;l(this,Mi)&&clearTimeout(l(this,Mi)),m(this,Mi,setTimeout(()=>{m(this,Mi,null),l(this,ar)[0]=l(this,ar)[1]=0,this.addCommands({cmd:()=>{for(const h of r)l(this,he).has(h.id)&&h.translateInPage(i,n)},undo:()=>{for(const h of r)l(this,he).has(h.id)&&h.translateInPage(-i,-n)},mustExec:!1})},a));for(const h of r)h.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),m(this,Ei,new Map);for(const t of l(this,xt))l(this,Ei).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!l(this,Ei))return!1;this.disableUserSelect(!1);const t=l(this,Ei);m(this,Ei,null);let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||(e=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex);if(!e)return!1;const s=(i,n,r,a)=>{if(l(this,he).has(i.id)){const h=l(this,be).get(a);h?i._setParentAndPosition(h,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(l(this,Ei))for(const s of l(this,Ei).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||l(this,xt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return l(this,ps)===t}getActive(){return l(this,ps)}getMode(){return l(this,de)}get imageManager(){return ht(this,"imageManager",new Hg)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,u=e.rangeCount;c<u;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(c,u,d,f)=>({x:(u-i)/r,y:1-(c+d-s)/n,width:f/r,height:d/n});break;case"180":a=(c,u,d,f)=>({x:1-(c+d-s)/n,y:1-(u+f-i)/r,width:d/n,height:f/r});break;case"270":a=(c,u,d,f)=>({x:1-(u+f-i)/r,y:(c-s)/n,width:f/r,height:d/n});break;default:a=(c,u,d,f)=>({x:(c-s)/n,y:(u-i)/r,width:d/n,height:f/r});break}const h=[];for(let c=0,u=e.rangeCount;c<u;c++){const d=e.getRangeAt(c);if(!d.collapsed)for(const{x:f,y:g,width:p,height:v}of d.getClientRects())p===0||v===0||h.push(a(f,g,p,v))}return h.length===0?null:h}addChangedExistingAnnotation({annotationElementId:t,id:e}){(l(this,Po)||m(this,Po,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=l(this,Po))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=l(this,Po))==null?void 0:i.get(t.data.id);if(!e)return;const s=l(this,hn).getRawValue(e);s&&(l(this,de)===nt.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}};Eo=new WeakMap,ps=new WeakMap,he=new WeakMap,be=new WeakMap,ko=new WeakMap,hn=new WeakMap,Po=new WeakMap,Fs=new WeakMap,er=new WeakMap,Zr=new WeakMap,Mo=new WeakMap,ta=new WeakMap,Ei=new WeakMap,ri=new WeakMap,ea=new WeakMap,Cl=new WeakMap,Al=new WeakMap,Oo=new WeakMap,Tl=new WeakMap,ki=new WeakMap,sr=new WeakMap,Do=new WeakMap,ir=new WeakMap,Pi=new WeakMap,Od=new WeakMap,nr=new WeakMap,El=new WeakMap,rr=new WeakMap,sa=new WeakMap,kl=new WeakMap,Pl=new WeakMap,de=new WeakMap,xt=new WeakMap,ln=new WeakMap,ia=new WeakMap,Ml=new WeakMap,Ol=new WeakMap,ar=new WeakMap,Mi=new WeakMap,cn=new WeakMap,Dl=new WeakMap,Is=new WeakMap,B=new WeakSet,Qd=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Cp=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of l(this,be).values())if(s.hasTextLayer(t))return s;return null},zb=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=w(this,B,Qd).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(l(this,Pi)||m(this,Pi,new wS(this)),l(this,Pi).show(s,i,this.direction==="ltr"))},Xb=function(){var n,r,a;const t=document.getSelection();if(!t||t.isCollapsed){l(this,ln)&&((n=l(this,Pi))==null||n.hide(),m(this,ln,null),w(this,B,ts).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===l(this,ln))return;const i=w(this,B,Qd).call(this,t).closest(".textLayer");if(!i){l(this,ln)&&((r=l(this,Pi))==null||r.hide(),m(this,ln,null),w(this,B,ts).call(this,{hasSelectedText:!1}));return}if((a=l(this,Pi))==null||a.hide(),m(this,ln,e),w(this,B,ts).call(this,{hasSelectedText:!0}),!(l(this,de)!==nt.HIGHLIGHT&&l(this,de)!==nt.NONE)&&(l(this,de)===nt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),m(this,ir,this.isShiftKeyDown),!this.isShiftKeyDown)){const h=l(this,de)===nt.HIGHLIGHT?w(this,B,Cp).call(this,i):null;h==null||h.toggleDrawing();const c=new AbortController,u=this.combinedSignal(c),d=f=>{f.type==="pointerup"&&f.button!==0||(c.abort(),h==null||h.toggleDrawing(!0),f.type==="pointerup"&&w(this,B,Zd).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:u}),window.addEventListener("blur",d,{signal:u})}},Zd=function(t=""){l(this,de)===nt.HIGHLIGHT?this.highlightSelection(t):l(this,Cl)&&w(this,B,zb).call(this)},Ub=function(){document.addEventListener("selectionchange",w(this,B,Xb).bind(this),{signal:this._signal})},Yb=function(){if(l(this,sr))return;m(this,sr,new AbortController);const t=this.combinedSignal(l(this,sr));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},$b=function(){var t;(t=l(this,sr))==null||t.abort(),m(this,sr,null)},Ap=function(){if(l(this,rr))return;m(this,rr,new AbortController);const t=this.combinedSignal(l(this,rr));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},qb=function(){var t;(t=l(this,rr))==null||t.abort(),m(this,rr,null)},Tp=function(){if(l(this,er))return;m(this,er,new AbortController);const t=this.combinedSignal(l(this,er));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})},Ep=function(){var t;(t=l(this,er))==null||t.abort(),m(this,er,null)},Kb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},ts=function(t){Object.entries(t).some(([s,i])=>l(this,Ol)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(l(this,Ol),t)}),l(this,de)===nt.HIGHLIGHT&&t.hasSelectedEditor===!1&&w(this,B,jn).call(this,[[dt.HIGHLIGHT_FREE,!0]]))},jn=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Jb=async function(){if(!l(this,nr)){m(this,nr,!0);const t=[];for(const e of l(this,be).values())t.push(e.enable());await Promise.all(t);for(const e of l(this,he).values())e.enable()}},Qb=function(){if(this.unselectAll(),l(this,nr)){m(this,nr,!1);for(const t of l(this,be).values())t.disable();for(const t of l(this,he).values())t.disable()}},kp=function(t){const e=l(this,be).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Zb=function(){let t=null;for(t of l(this,xt));return t},Xc=function(){if(l(this,he).size===0)return!0;if(l(this,he).size===1)for(const t of l(this,he).values())return t.isEmpty();return!1},Pp=function(t){for(const e of l(this,xt))e.unselect();l(this,xt).clear();for(const e of t)e.isEmpty()||(l(this,xt).add(e),e.select());w(this,B,ts).call(this,{hasSelectedEditor:this.hasSelection})},J(Ro,"TRANSLATE_SMALL",1),J(Ro,"TRANSLATE_BIG",10);let Xr=Ro;const Ue=class Ue{constructor(t){y(this,oi);y(this,fe,null);y(this,Oi,!1);y(this,ai,null);y(this,Lo,null);y(this,Di,null);y(this,ms,null);y(this,Fo,!1);y(this,Ri,null);y(this,as,null);y(this,un,null);y(this,na,null);y(this,Li,!1);m(this,as,t),m(this,Li,t._uiManager.useNewAltTextFlow),l(Ue,or)||m(Ue,or,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){Ue._l10n??(Ue._l10n=t)}async render(){const t=m(this,ai,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=m(this,Lo,document.createElement("span"));t.append(e),l(this,Li)?(t.classList.add("new"),t.setAttribute("data-l10n-id",l(Ue,or).missing),e.setAttribute("data-l10n-id",l(Ue,or)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=l(this,as)._uiManager._signal;t.addEventListener("contextmenu",ii,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),l(this,as)._uiManager.editAltText(l(this,as)),l(this,Li)&&l(this,as)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:l(this,oi,Uc)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(m(this,Fo,!0),i(n))},{signal:s}),await w(this,oi,tf).call(this),t}finish(){l(this,ai)&&(l(this,ai).focus({focusVisible:l(this,Fo)}),m(this,Fo,!1))}isEmpty(){return l(this,Li)?l(this,fe)===null:!l(this,fe)&&!l(this,Oi)}hasData(){return l(this,Li)?l(this,fe)!==null||!!l(this,un):this.isEmpty()}get guessedText(){return l(this,un)}async setGuessedText(t){l(this,fe)===null&&(m(this,un,t),m(this,na,await Ue._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),w(this,oi,tf).call(this))}toggleAltTextBadge(t=!1){var e;if(!l(this,Li)||l(this,fe)){(e=l(this,Ri))==null||e.remove(),m(this,Ri,null);return}if(!l(this,Ri)){const s=m(this,Ri,document.createElement("div"));s.className="noAltTextBadge",l(this,as).div.append(s)}l(this,Ri).classList.toggle("hidden",!t)}serialize(t){let e=l(this,fe);return!t&&l(this,un)===e&&(e=l(this,na)),{altText:e,decorative:l(this,Oi),guessedText:l(this,un),textWithDisclaimer:l(this,na)}}get data(){return{altText:l(this,fe),decorative:l(this,Oi)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(m(this,un,s),m(this,na,i)),!(l(this,fe)===t&&l(this,Oi)===e)&&(n||(m(this,fe,t),m(this,Oi,e)),w(this,oi,tf).call(this))}toggle(t=!1){l(this,ai)&&(!t&&l(this,ms)&&(clearTimeout(l(this,ms)),m(this,ms,null)),l(this,ai).disabled=!t)}shown(){l(this,as)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:l(this,oi,Uc)}})}destroy(){var t,e;(t=l(this,ai))==null||t.remove(),m(this,ai,null),m(this,Lo,null),m(this,Di,null),(e=l(this,Ri))==null||e.remove(),m(this,Ri,null)}};fe=new WeakMap,Oi=new WeakMap,ai=new WeakMap,Lo=new WeakMap,Di=new WeakMap,ms=new WeakMap,Fo=new WeakMap,Ri=new WeakMap,as=new WeakMap,un=new WeakMap,na=new WeakMap,Li=new WeakMap,or=new WeakMap,oi=new WeakSet,Uc=function(){return l(this,fe)&&"added"||l(this,fe)===null&&this.guessedText&&"review"||"missing"},tf=async function(){var i,n,r;const t=l(this,ai);if(!t)return;if(l(this,Li)){if(t.classList.toggle("done",!!l(this,fe)),t.setAttribute("data-l10n-id",l(Ue,or)[l(this,oi,Uc)]),(i=l(this,Lo))==null||i.setAttribute("data-l10n-id",l(Ue,or)[`${l(this,oi,Uc)}-label`]),!l(this,fe)){(n=l(this,Di))==null||n.remove();return}}else{if(!l(this,fe)&&!l(this,Oi)){t.classList.remove("done"),(r=l(this,Di))==null||r.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=l(this,Di);if(!e){m(this,Di,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${l(this,as).id}`;const a=100,h=l(this,as)._uiManager._signal;h.addEventListener("abort",()=>{clearTimeout(l(this,ms)),m(this,ms,null)},{once:!0}),t.addEventListener("mouseenter",()=>{m(this,ms,setTimeout(()=>{m(this,ms,null),l(this,Di).classList.add("show"),l(this,as)._reportTelemetry({action:"alt_text_tooltip"})},a))},{signal:h}),t.addEventListener("mouseleave",()=>{var c;l(this,ms)&&(clearTimeout(l(this,ms)),m(this,ms,null)),(c=l(this,Di))==null||c.classList.remove("show")},{signal:h})}l(this,Oi)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=l(this,fe)),e.parentNode||t.append(e);const s=l(this,as).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},y(Ue,or,null),J(Ue,"_l10n",null);let pd=Ue;const up=class up{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){y(this,fn);y(this,Rl);y(this,ra,!1);y(this,Ll,null);y(this,Fl);y(this,Il);y(this,jl);y(this,Nl);y(this,Io);y(this,dn,null);y(this,aa);y(this,hr,null);m(this,Rl,t),m(this,Ll,s),m(this,Fl,e),m(this,Il,i),m(this,jl,n),m(this,Nl,r),m(this,aa,new AbortController),m(this,Io,AbortSignal.any([a,l(this,aa).signal])),t.addEventListener("touchstart",w(this,fn,ty).bind(this),{passive:!1,signal:l(this,Io)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return ht(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var t;(t=l(this,aa))==null||t.abort(),m(this,aa,null)}};Rl=new WeakMap,ra=new WeakMap,Ll=new WeakMap,Fl=new WeakMap,Il=new WeakMap,jl=new WeakMap,Nl=new WeakMap,Io=new WeakMap,dn=new WeakMap,aa=new WeakMap,hr=new WeakMap,fn=new WeakSet,ty=function(t){var i,n,r;if((i=l(this,Fl))!=null&&i.call(this)||t.touches.length<2)return;if(!l(this,hr)){m(this,hr,new AbortController);const a=AbortSignal.any([l(this,Io),l(this,hr).signal]),h=l(this,Rl),c={signal:a,passive:!1};h.addEventListener("touchmove",w(this,fn,ey).bind(this),c),h.addEventListener("touchend",w(this,fn,Mp).bind(this),c),h.addEventListener("touchcancel",w(this,fn,Mp).bind(this),c),(n=l(this,Il))==null||n.call(this)}if(gs(t),t.touches.length!==2||(r=l(this,Ll))!=null&&r.call(this)){m(this,dn,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),m(this,dn,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},ey=function(t){var A;if(!l(this,dn)||t.touches.length!==2)return;let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:n}=e,{screenX:r,screenY:a}=s,h=l(this,dn),{touch0X:c,touch0Y:u,touch1X:d,touch1Y:f}=h,g=d-c,p=f-u,v=r-i,_=a-n,b=Math.hypot(v,_)||1,x=Math.hypot(g,p)||1;if(!l(this,ra)&&Math.abs(x-b)<=up.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(h.touch0X=i,h.touch0Y=n,h.touch1X=r,h.touch1Y=a,t.preventDefault(),!l(this,ra)){m(this,ra,!0);return}const C=[(i+r)/2,(n+a)/2];(A=l(this,jl))==null||A.call(this,C,x,b)},Mp=function(t){var e;l(this,hr).abort(),m(this,hr,null),(e=l(this,Nl))==null||e.call(this),l(this,dn)&&(t.preventDefault(),m(this,dn,null),m(this,ra,!1))};let md=up;const ot=class ot{constructor(t){y(this,K);y(this,oa,null);y(this,hi,null);y(this,Rt,null);y(this,jo,!1);y(this,lr,null);y(this,Bl,"");y(this,ha,!1);y(this,ye,null);y(this,la,null);y(this,gn,null);y(this,cr,null);y(this,Hl,"");y(this,ca,!1);y(this,vs,null);y(this,Gl,!1);y(this,ua,!1);y(this,pn,!1);y(this,Fi,null);y(this,No,0);y(this,Bo,0);y(this,js,null);y(this,da,null);J(this,"_editToolbar",null);J(this,"_initialOptions",Object.create(null));J(this,"_initialData",null);J(this,"_isVisible",!0);J(this,"_uiManager",null);J(this,"_focusEventsAllowed",!0);y(this,Vl,!1);y(this,Dd,ot._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];const[a,h]=this.parentDimensions;this.x=t.x/a,this.y=t.y/h,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=ot.prototype._resizeWithKeyboard,e=Xr.TRANSLATE_SMALL,s=Xr.TRANSLATE_BIG;return ht(this,"_resizerKeyboardManager",new cl([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],ot.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return ht(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new CS({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(ot._l10n??(ot._l10n=t),ot._l10nResizer||(ot._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"})),ot._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);ot._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Et("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return l(this,Vl)}set _isDraggable(t){var e;m(this,Vl,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=l(this,Dd)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):w(this,K,Yc).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(l(this,ca)?m(this,ca,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}translate(t,e){w(this,K,Op).call(this,this.parentDimensions,t,e)}translateInPage(t,e){l(this,vs)||m(this,vs,[this.x,this.y,this.width,this.height]),w(this,K,Op).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){l(this,vs)||m(this,vs,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[h,c]=this.getBaseTranslation();r+=h,a+=c;const{style:u}=s;u.left=`${(100*r).toFixed(2)}%`,u.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!l(this,vs)&&(l(this,vs)[0]!==this.x||l(this,vs)[1]!==this.y)}get _hasBeenResized(){return!!l(this,vs)&&(l(this,vs)[2]!==this.width||l(this,vs)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=ot,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:n,y:r,width:a,height:h}=this;if(a*=s,h*=i,n*=s,r*=i,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(s-a,n)),r=Math.max(0,Math.min(i-h,r));break;case 90:n=Math.max(0,Math.min(s-h,n)),r=Math.min(i,Math.max(a,r));break;case 180:n=Math.min(s,Math.max(a,n)),r=Math.min(i,Math.max(h,r));break;case 270:n=Math.min(s,Math.max(h,n)),r=Math.max(0,Math.min(i-a,r));break}this.x=n/=s,this.y=r/=i;const[c,u]=this.getBaseTranslation();n+=c,r+=u,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return w(s=ot,Wl,Dp).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return w(s=ot,Wl,Dp).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(t,e){const[s,i]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/s).toFixed(2)}%`,l(this,ha)||(n.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!l(this,ha)&&e.endsWith("%");if(i&&n)return;const[r,a]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),!l(this,ha)&&!n&&(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=l(this,Rt))==null||t.finish()}async addEditToolbar(){return this._editToolbar||l(this,ua)?this._editToolbar:(this._editToolbar=new Bg(this),this.div.append(this._editToolbar.render()),l(this,Rt)&&await this._editToolbar.addAltText(l(this,Rt)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=l(this,Rt))==null||t.destroy())}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){l(this,Rt)||(pd.initialize(ot._l10n),m(this,Rt,new pd(this)),l(this,oa)&&(l(this,Rt).data=l(this,oa),m(this,oa,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=l(this,Rt))==null?void 0:t.data}set altTextData(t){l(this,Rt)&&(l(this,Rt).data=t)}get guessedAltText(){var t;return(t=l(this,Rt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=l(this,Rt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=l(this,Rt))==null?void 0:e.serialize(t)}hasAltText(){return!!l(this,Rt)&&!l(this,Rt).isEmpty()}hasAltTextData(){var t;return((t=l(this,Rt))==null?void 0:t.hasData())??!1}render(){var n;this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=l(this,jo)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),w(this,K,Ip).call(this);const[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[s,i]=this.getInitialTranslation();return this.translate(s,i),gd(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(l(this,da)||m(this,da,new md({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:w(this,K,ny).bind(this),onPinching:w(this,K,ry).bind(this),onPinchEnd:w(this,K,ay).bind(this),signal:this._uiManager._signal}))),(n=this._uiManager._editorUndoBar)==null||n.hide(),this.div}pointerdown(t){const{isMac:e}=ze.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(m(this,ca,!0),this._isDraggable){w(this,K,oy).call(this,t);return}w(this,K,Fp).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){l(this,Fi)&&clearTimeout(l(this,Fi)),m(this,Fi,setTimeout(()=>{var t;m(this,Fi,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,r]=this.pageDimensions,[a,h]=this.pageTranslation,c=t/i,u=e/i,d=this.x*n,f=this.y*r,g=this.width*n,p=this.height*r;switch(s){case 0:return[d+c+a,r-f-u-p+h,d+c+g+a,r-f-u+h];case 90:return[d+u+a,r-f+c+h,d+u+p+a,r-f+c+g+h];case 180:return[d-c-g+a,r-f+u+h,d-c+a,r-f+u+p+h];case 270:return[d-u-p+a,r-f-c-g+h,d-u+a,r-f-c+h];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,h=r-i;switch(this.rotation){case 0:return[s,e-r,a,h];case 90:return[s,e-i,h,a];case 180:return[n,e-i,a,h];case 270:return[n,e-r,h,a];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){m(this,ua,!0)}disableEditMode(){m(this,ua,!1)}isInEditMode(){return l(this,ua)}shouldGetKeyboardEvents(){return l(this,pn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}rebuild(){w(this,K,Ip).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){Et("An editor must be serializable")}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,m(i,oa,t.accessibilityData);const[n,r]=i.pageDimensions,[a,h,c,u]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=h/r,i.width=c/n,i.height=u/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e;if((t=l(this,cr))==null||t.abort(),m(this,cr,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),l(this,Fi)&&(clearTimeout(l(this,Fi)),m(this,Fi,null)),w(this,K,Yc).call(this),this.removeEditToolbar(),l(this,js)){for(const s of l(this,js).values())clearTimeout(s);m(this,js,null)}this.parent=null,(e=l(this,da))==null||e.destroy(),m(this,da,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(w(this,K,sy).call(this),l(this,ye).classList.remove("hidden"),gd(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),m(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=l(this,ye).children;if(!l(this,hi)){m(this,hi,Array.from(e));const r=w(this,K,hy).bind(this),a=w(this,K,ly).bind(this),h=this._uiManager._signal;for(const c of l(this,hi)){const u=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",r,{signal:h}),c.addEventListener("blur",a,{signal:h}),c.addEventListener("focus",w(this,K,cy).bind(this,u),{signal:h}),c.setAttribute("data-l10n-id",ot._l10nResizer[u])}}const s=l(this,hi)[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(l(this,hi).length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)l(this,ye).append(l(this,ye).firstChild);else if(n>i)for(let a=0;a<n-i;a++)l(this,ye).firstChild.before(l(this,ye).lastChild);let r=0;for(const a of e){const c=l(this,hi)[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",ot._l10nResizer[c])}}w(this,K,jp).call(this,0),m(this,pn,!0),l(this,ye).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){l(this,pn)&&w(this,K,Lp).call(this,l(this,Hl),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){w(this,K,Yc).call(this),this.div.focus()}select(){var t,e,s;if(this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,n;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((n=this._editToolbar)==null||n.show())});return}(e=this._editToolbar)==null||e.show(),(s=l(this,Rt))==null||s.toggleAltTextBadge(!1)}unselect(){var t,e,s,i,n;(t=l(this,ye))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(n=l(this,Rt))==null||n.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return l(this,Gl)}set isEditing(t){m(this,Gl,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){m(this,ha,!0);const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}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){l(this,js)||m(this,js,new Map);const{action:s}=t;let i=l(this,js).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),l(this,js).delete(s),l(this,js).size===0&&m(this,js,null)},ot._telemetryTimeout),l(this,js).set(s,i);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),m(this,jo,!1)}disable(){this.div&&(this.div.tabIndex=-1),m(this,jo,!0)}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};oa=new WeakMap,hi=new WeakMap,Rt=new WeakMap,jo=new WeakMap,lr=new WeakMap,Bl=new WeakMap,ha=new WeakMap,ye=new WeakMap,la=new WeakMap,gn=new WeakMap,cr=new WeakMap,Hl=new WeakMap,ca=new WeakMap,vs=new WeakMap,Gl=new WeakMap,ua=new WeakMap,pn=new WeakMap,Fi=new WeakMap,No=new WeakMap,Bo=new WeakMap,js=new WeakMap,da=new WeakMap,Vl=new WeakMap,Dd=new WeakMap,K=new WeakSet,Op=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Wl=new WeakSet,Dp=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},ef=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},sy=function(){if(l(this,ye))return;m(this,ye,document.createElement("div")),l(this,ye).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");l(this,ye).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",w(this,K,iy).bind(this,s),{signal:e}),i.addEventListener("contextmenu",ii,{signal:e}),i.tabIndex=-1}this.div.prepend(l(this,ye))},iy=function(t,e){var u;e.preventDefault();const{isMac:s}=ze.platform;if(e.button!==0||e.ctrlKey&&s)return;(u=l(this,Rt))==null||u.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,m(this,la,[e.screenX,e.screenY]);const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",w(this,K,Lp).bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",gs,{passive:!1,signal:r}),window.addEventListener("contextmenu",ii,{signal:r}),m(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const a=this.parent.div.style.cursor,h=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const c=()=>{var d;n.abort(),this.parent.togglePointerEvents(!0),(d=l(this,Rt))==null||d.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=h,w(this,K,sf).call(this)};window.addEventListener("pointerup",c,{signal:r}),window.addEventListener("blur",c,{signal:r})},Rp=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*s,r*i),this.fixAndSetPosition(),this._onResized()},sf=function(){if(!l(this,gn))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=l(this,gn);m(this,gn,null);const n=this.x,r=this.y,a=this.width,h=this.height;n===t&&r===e&&a===s&&h===i||this.addCommands({cmd:w(this,K,Rp).bind(this,n,r,a,h),undo:w(this,K,Rp).bind(this,t,e,s,i),mustExec:!0})},Lp=function(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,h=this.height,c=ot.MIN_SIZE/s,u=ot.MIN_SIZE/i,d=w(this,K,ef).call(this,this.rotation),f=(j,W)=>[d[0]*j+d[2]*W,d[1]*j+d[3]*W],g=w(this,K,ef).call(this,360-this.rotation),p=(j,W)=>[g[0]*j+g[2]*W,g[1]*j+g[3]*W];let v,_,b=!1,x=!1;switch(t){case"topLeft":b=!0,v=(j,W)=>[0,0],_=(j,W)=>[j,W];break;case"topMiddle":v=(j,W)=>[j/2,0],_=(j,W)=>[j/2,W];break;case"topRight":b=!0,v=(j,W)=>[j,0],_=(j,W)=>[0,W];break;case"middleRight":x=!0,v=(j,W)=>[j,W/2],_=(j,W)=>[0,W/2];break;case"bottomRight":b=!0,v=(j,W)=>[j,W],_=(j,W)=>[0,0];break;case"bottomMiddle":v=(j,W)=>[j/2,W],_=(j,W)=>[j/2,0];break;case"bottomLeft":b=!0,v=(j,W)=>[0,W],_=(j,W)=>[j,0];break;case"middleLeft":x=!0,v=(j,W)=>[0,W/2],_=(j,W)=>[j,W/2];break}const C=v(a,h),A=_(a,h);let P=f(...A);const D=ot._round(n+P[0]),k=ot._round(r+P[1]);let M=1,R=1,F,I;if(e.fromKeyboard)({deltaX:F,deltaY:I}=e);else{const{screenX:j,screenY:W}=e,[it,kt]=l(this,la);[F,I]=this.screenToPageTranslation(j-it,W-kt),l(this,la)[0]=j,l(this,la)[1]=W}if([F,I]=p(F/s,I/i),b){const j=Math.hypot(a,h);M=R=Math.max(Math.min(Math.hypot(A[0]-C[0]-F,A[1]-C[1]-I)/j,1/a,1/h),c/a,u/h)}else x?M=Math.max(c,Math.min(1,Math.abs(A[0]-C[0]-F)))/a:R=Math.max(u,Math.min(1,Math.abs(A[1]-C[1]-I)))/h;const Y=ot._round(a*M),N=ot._round(h*R);P=f(..._(Y,N));const H=D-P[0],at=k-P[1];l(this,vs)||m(this,vs,[this.x,this.y,this.width,this.height]),this.width=Y,this.height=N,this.x=H,this.y=at,this.setDims(s*Y,i*N),this.fixAndSetPosition(),this._onResizing()},ny=function(){var t;m(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=l(this,Rt))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},ry=function(t,e,s){let n=.7*(s/e)+1-.7;if(n===1)return;const r=w(this,K,ef).call(this,this.rotation),a=(D,k)=>[r[0]*D+r[2]*k,r[1]*D+r[3]*k],[h,c]=this.parentDimensions,u=this.x,d=this.y,f=this.width,g=this.height,p=ot.MIN_SIZE/h,v=ot.MIN_SIZE/c;n=Math.max(Math.min(n,1/f,1/g),p/f,v/g);const _=ot._round(f*n),b=ot._round(g*n);if(_===f&&b===g)return;l(this,vs)||m(this,vs,[u,d,f,g]);const x=a(f/2,g/2),C=ot._round(u+x[0]),A=ot._round(d+x[1]),P=a(_/2,b/2);this.x=C-P[0],this.y=A-P[1],this.width=_,this.height=b,this.setDims(h*_,c*b),this.fixAndSetPosition(),this._onResizing()},ay=function(){var t;(t=l(this,Rt))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),w(this,K,sf).call(this)},Fp=function(t){const{isMac:e}=ze.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},oy=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,n=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:n},a=c=>{i.abort(),m(this,lr,null),m(this,ca,!1),this._uiManager.endDragSession()||w(this,K,Fp).call(this,c),s&&this._onStopDragging()};e&&(m(this,No,t.clientX),m(this,Bo,t.clientY),m(this,lr,t.pointerId),m(this,Bl,t.pointerType),window.addEventListener("pointermove",c=>{s||(s=!0,this._onStartDragging());const{clientX:u,clientY:d,pointerId:f}=c;if(f!==l(this,lr)){gs(c);return}const[g,p]=this.screenToPageTranslation(u-l(this,No),d-l(this,Bo));m(this,No,u),m(this,Bo,d),this._uiManager.dragSelectedEditors(g,p)},r),window.addEventListener("touchmove",gs,r),window.addEventListener("pointerdown",c=>{c.pointerType===l(this,Bl)&&(l(this,da)||c.isPrimary)&&a(c),gs(c)},r));const h=c=>{if(!l(this,lr)||l(this,lr)===c.pointerId){a(c);return}gs(c)};window.addEventListener("pointerup",h,{signal:n}),window.addEventListener("blur",h,{signal:n})},Ip=function(){if(l(this,cr)||!this.div)return;m(this,cr,new AbortController);const t=this._uiManager.combinedSignal(l(this,cr));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},hy=function(t){ot._resizerKeyboardManager.exec(this,t)},ly=function(t){var e;l(this,pn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==l(this,ye)&&w(this,K,Yc).call(this)},cy=function(t){m(this,Hl,l(this,pn)?t:"")},jp=function(t){if(l(this,hi))for(const e of l(this,hi))e.tabIndex=t},Yc=function(){m(this,pn,!1),w(this,K,jp).call(this,-1),w(this,K,sf).call(this)},y(ot,Wl),J(ot,"_l10n",null),J(ot,"_l10nResizer",null),J(ot,"_borderLineWidth",-1),J(ot,"_colorManager",new Gg),J(ot,"_zIndex",1),J(ot,"_telemetryTimeout",1e3);let Ht=ot;class CS extends Ht{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ov=3285377520,Ls=4294901760,Ti=65535;class Dv{constructor(t){this.h1=t?t&4294967295:Ov,this.h2=t?t&4294967295:Ov}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let v=0,_=t.length;v<_;v++){const b=t.charCodeAt(v);b<=255?e[s++]=b:(e[s++]=b>>>8,e[s++]=b&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i);let a=0,h=0,c=this.h1,u=this.h2;const d=3432918353,f=461845907,g=d&Ti,p=f&Ti;for(let v=0;v<i;v++)v&1?(a=r[v],a=a*d&Ls|a*g&Ti,a=a<<15|a>>>17,a=a*f&Ls|a*p&Ti,c^=a,c=c<<13|c>>>19,c=c*5+3864292196):(h=r[v],h=h*d&Ls|h*g&Ti,h=h<<15|h>>>17,h=h*f&Ls|h*p&Ti,u^=h,u=u<<13|u>>>19,u=u*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&Ls|a*g&Ti,a=a<<15|a>>>17,a=a*f&Ls|a*p&Ti,i&1?c^=a:u^=a}this.h1=c,this.h2=u}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Ls|t*36045&Ti,e=e*4283543511&Ls|((e<<16|t>>>16)*2950163797&Ls)>>>16,t^=e>>>1,t=t*444984403&Ls|t*60499&Ti,e=e*3301882366&Ls|((e<<16|t>>>16)*3120437893&Ls)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Vg=Object.freeze({map:null,hash:"",transfer:void 0});class Wg{constructor(){y(this,Rd);y(this,fa,!1);y(this,ga,null);y(this,ge,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=l(this,ge).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return l(this,ge).get(t)}remove(t){if(l(this,ge).delete(t),l(this,ge).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of l(this,ge).values())if(e instanceof Ht)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=l(this,ge).get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,l(this,ge).set(t,e);i&&w(this,Rd,uy).call(this),e instanceof Ht&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return l(this,ge).has(t)}getAll(){return l(this,ge).size>0?Mg(l(this,ge)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return l(this,ge).size}resetModified(){l(this,fa)&&(m(this,fa,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Rv(this)}get serializable(){if(l(this,ge).size===0)return Vg;const t=new Map,e=new Dv,s=[],i=Object.create(null);let n=!1;for(const[r,a]of l(this,ge)){const h=a instanceof Ht?a.serialize(!1,i):a;h&&(t.set(r,h),e.update(`${r}:${JSON.stringify(h)}`),n||(n=!!h.bitmap))}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Vg}get editorStats(){let t=null;const e=new Map;for(const s of l(this,ge).values()){if(!(s instanceof Ht))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const r=t[n]||(t[n]=new Map);for(const[a,h]of Object.entries(i)){if(a==="type")continue;let c=r.get(a);c||(c=new Map,r.set(a,c));const u=c.get(h)??0;c.set(h,u+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){m(this,ga,null)}get modifiedIds(){if(l(this,ga))return l(this,ga);const t=[];for(const e of l(this,ge).values())!(e instanceof Ht)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return m(this,ga,{ids:new Set(t),hash:t.join(",")})}}fa=new WeakMap,ga=new WeakMap,ge=new WeakMap,Rd=new WeakSet,uy=function(){l(this,fa)||(m(this,fa,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class Rv extends Wg{constructor(e){super();y(this,zl);const{map:s,hash:i,transfer:n}=e.serializable,r=structuredClone(s,n?{transfer:n}:null);m(this,zl,{map:r,hash:i,transfer:n})}get print(){Et("Should not call PrintAnnotationStorage.print")}get serializable(){return l(this,zl)}get modifiedIds(){return ht(this,"modifiedIds",{ids:new Set,hash:""})}}zl=new WeakMap;class AS{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){y(this,Ho,new Set);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));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),l(this,Ho).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||l(this,Ho).has(t.loadedName))){if(ee(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),l(this,Ho).add(s),e==null||e(t)}catch{rt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}Et("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw rt(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return ht(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(Pe||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),ht(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(ee(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return ht(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(A,P){return A.charCodeAt(P)<<24|A.charCodeAt(P+1)<<16|A.charCodeAt(P+2)<<8|A.charCodeAt(P+3)&255}function i(A,P,D,k){const M=A.substring(0,P),R=A.substring(P+D);return M+k+R}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const h=a.getContext("2d");let c=0;function u(A,P){if(++c>30){rt("Load test font never loaded."),P();return}if(h.font="30px "+A,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0){P();return}setTimeout(u.bind(null,A,P))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,d.length,d);const p=16,v=1482184792;let _=s(f,p);for(n=0,r=d.length-3;n<r;n+=4)_=_-v+s(d,n)|0;n<d.length&&(_=_-v+s(d+"XXX",n)|0),f=i(f,p,4,cS(_));const b=`url(data:font/opentype;base64,${btoa(f)});`,x=`@font-face {font-family:"${d}";src:${b}}`;this.insertRule(x);const C=this._document.createElement("div");C.style.visibility="hidden",C.style.width=C.style.height="10px",C.style.position="absolute",C.style.top=C.style.left="0px";for(const A of[t.loadedName,d]){const P=this._document.createElement("span");P.textContent="Hi",P.style.fontFamily=A,C.append(P)}this._document.body.append(C),u(d,()=>{C.remove(),e.complete()})}}Ho=new WeakMap;class TS{constructor(t,{disableFontFace:e=!1,fontExtraProperties:s=!1,inspectFont:i=null}){this.compiledGlyphs=Object.create(null);for(const n in t)this[n]=t[n];this.disableFontFace=e===!0,this.fontExtraProperties=s===!0,this._inspectFont=i}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${mS(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(r){rt(`getPathGenerator - ignoring character: "${r}".`)}const n=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}}const vd={DATA:1,ERROR:2},se={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Lv(){}function is(o){if(o instanceof qn||o instanceof Pg||o instanceof ol||o instanceof Ev||o instanceof cd||o instanceof kg)return o;switch(o instanceof Error||typeof o=="object"&&o!==null||Et('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),o.name){case"AbortException":return new qn(o.message);case"InvalidPDFException":return new Pg(o.message);case"MissingPDFException":return new ol(o.message);case"PasswordException":return new Ev(o.message,o.code);case"UnexpectedResponseException":return new cd(o.message,o.status);case"UnknownErrorException":return new kg(o.message,o.details)}return new kg(o.message,o.toString())}class ul{constructor(t,e,s){y(this,Ns);y(this,Go,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",w(this,Ns,dy).bind(this),{signal:l(this,Go).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,h=this.comObj;return new ReadableStream({start:c=>{const u=Promise.withResolvers();return this.streamControllers[n]={controller:c,startCall:u,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:c.desiredSize},i),u.promise},pull:c=>{const u=Promise.withResolvers();return this.streamControllers[n].pullCall=u,h.postMessage({sourceName:r,targetName:a,stream:se.PULL,streamId:n,desiredSize:c.desiredSize}),u.promise},cancel:c=>{ee(c instanceof Error,"cancel must have a valid reason");const u=Promise.withResolvers();return this.streamControllers[n].cancelCall=u,this.streamControllers[n].isClosed=!0,h.postMessage({sourceName:r,targetName:a,stream:se.CANCEL,streamId:n,reason:is(c)}),u.promise}},s)}destroy(){var t;(t=l(this,Go))==null||t.abort(),m(this,Go,null)}}Go=new WeakMap,Ns=new WeakSet,dy=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){w(this,Ns,gy).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===vd.DATA)i.resolve(t.data);else if(t.callback===vd.ERROR)i.reject(is(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:s,targetName:i,callback:vd.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:s,targetName:i,callback:vd.ERROR,callbackId:t.callbackId,reason:is(r)})});return}if(t.streamId){w(this,Ns,fy).call(this,t);return}e(t.data)},fy=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],h={enqueue(c,u=1,d){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=u,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:se.ENQUEUE,streamId:e,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:se.CLOSE,streamId:e}),delete r.streamSinks[e])},error(c){ee(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:se.ERROR,streamId:e,reason:is(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};h.sinkCapability.resolve(),h.ready=h.sinkCapability.promise,this.streamSinks[e]=h,Promise.try(a,t.data,h).then(function(){n.postMessage({sourceName:s,targetName:i,stream:se.START_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:se.START_COMPLETE,streamId:e,reason:is(c)})})},gy=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case se.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(is(t.reason));break;case se.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(is(t.reason));break;case se.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:se.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Lv).then(function(){n.postMessage({sourceName:s,targetName:i,stream:se.PULL_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:se.PULL_COMPLETE,streamId:e,reason:is(c)})});break;case se.ENQUEUE:if(ee(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case se.CLOSE:if(ee(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),w(this,Ns,nf).call(this,r,e);break;case se.ERROR:ee(r,"error should have stream controller"),r.controller.error(is(t.reason)),w(this,Ns,nf).call(this,r,e);break;case se.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(is(t.reason)),w(this,Ns,nf).call(this,r,e);break;case se.CANCEL:if(!a)break;const h=is(t.reason);Promise.try(a.onCancel||Lv,h).then(function(){n.postMessage({sourceName:s,targetName:i,stream:se.CANCEL_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:se.CANCEL_COMPLETE,streamId:e,reason:is(c)})}),a.sinkCapability.reject(h),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},nf=async function(t,e){var s,i,n;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(n=t.cancelCall)==null?void 0:n.promise]),delete this.streamControllers[e]};class Fv{constructor({enableHWA:t=!1}){y(this,Xl,!1);m(this,Xl,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!l(this,Xl)})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Et("Abstract method `_createCanvas` called.")}}Xl=new WeakMap;class ES extends Fv{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Iv{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){Et("Abstract method `_fetch` called.")}}class jv extends Iv{async _fetch(t){const e=await dd(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):ud(e)}}class Nv{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class kS extends Nv{constructor({docId:e,ownerDocument:s=globalThis.document}){super();y(this,V);y(this,pa);y(this,Vo);y(this,mn);y(this,vn);y(this,Re);y(this,ma);y(this,va,0);m(this,vn,e),m(this,Re,s)}addFilter(e){if(!e)return"none";let s=l(this,V,je).get(e);if(s)return s;const[i,n,r]=w(this,V,rf).call(this,e),a=e.length===1?i:`${i}${n}${r}`;if(s=l(this,V,je).get(a),s)return l(this,V,je).set(e,s),s;const h=`g_${l(this,vn)}_transfer_map_${Ze(this,va)._++}`,c=w(this,V,Fh).call(this,h);l(this,V,je).set(e,c),l(this,V,je).set(a,c);const u=w(this,V,Ih).call(this,h);return w(this,V,Kc).call(this,i,n,r,u),c}addHCMFilter(e,s){var p;const i=`${e}-${s}`,n="base";let r=l(this,V,$c).get(n);if((r==null?void 0:r.key)===i||(r?((p=r.filter)==null||p.remove(),r.key=i,r.url="none",r.filter=null):(r={key:i,url:"none",filter:null},l(this,V,$c).set(n,r)),!e||!s))return r.url;const a=w(this,V,Jc).call(this,e);e=q.makeHexColor(...a);const h=w(this,V,Jc).call(this,s);if(s=q.makeHexColor(...h),l(this,V,Lh).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return r.url;const c=new Array(256);for(let v=0;v<=255;v++){const _=v/255;c[v]=_<=.03928?_/12.92:((_+.055)/1.055)**2.4}const u=c.join(","),d=`g_${l(this,vn)}_hcm_filter`,f=r.filter=w(this,V,Ih).call(this,d);w(this,V,Kc).call(this,u,u,u,f),w(this,V,Np).call(this,f);const g=(v,_)=>{const b=a[v]/255,x=h[v]/255,C=new Array(_+1);for(let A=0;A<=_;A++)C[A]=b+A/_*(x-b);return C.join(",")};return w(this,V,Kc).call(this,g(0,5),g(1,5),g(2,5),f),r.url=w(this,V,Fh).call(this,d),r.url}addAlphaFilter(e){let s=l(this,V,je).get(e);if(s)return s;const[i]=w(this,V,rf).call(this,[e]),n=`alpha_${i}`;if(s=l(this,V,je).get(n),s)return l(this,V,je).set(e,s),s;const r=`g_${l(this,vn)}_alpha_map_${Ze(this,va)._++}`,a=w(this,V,Fh).call(this,r);l(this,V,je).set(e,a),l(this,V,je).set(n,a);const h=w(this,V,Ih).call(this,r);return w(this,V,Bp).call(this,i,h),a}addLuminosityFilter(e){let s=l(this,V,je).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=w(this,V,rf).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=l(this,V,je).get(n),s)return l(this,V,je).set(e,s),s;const r=`g_${l(this,vn)}_luminosity_map_${Ze(this,va)._++}`,a=w(this,V,Fh).call(this,r);l(this,V,je).set(e,a),l(this,V,je).set(n,a);const h=w(this,V,Ih).call(this,r);return w(this,V,py).call(this,h),e&&w(this,V,Bp).call(this,i,h),a}addHighlightHCMFilter(e,s,i,n,r){var x;const a=`${s}-${i}-${n}-${r}`;let h=l(this,V,$c).get(e);if((h==null?void 0:h.key)===a||(h?((x=h.filter)==null||x.remove(),h.key=a,h.url="none",h.filter=null):(h={key:a,url:"none",filter:null},l(this,V,$c).set(e,h)),!s||!i))return h.url;const[c,u]=[s,i].map(w(this,V,Jc).bind(this));let d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),[g,p]=[n,r].map(w(this,V,Jc).bind(this));f<d&&([d,f,g,p]=[f,d,p,g]),l(this,V,Lh).style.color="";const v=(C,A,P)=>{const D=new Array(256),k=(f-d)/P,M=C/255,R=(A-C)/(255*P);let F=0;for(let I=0;I<=P;I++){const Y=Math.round(d+I*k),N=M+I*R;for(let H=F;H<=Y;H++)D[H]=N;F=Y+1}for(let I=F;I<256;I++)D[I]=D[F-1];return D.join(",")},_=`g_${l(this,vn)}_hcm_${e}_filter`,b=h.filter=w(this,V,Ih).call(this,_);return w(this,V,Np).call(this,b),w(this,V,Kc).call(this,v(g[0],p[0],5),v(g[1],p[1],5),v(g[2],p[2],5),b),h.url=w(this,V,Fh).call(this,_),h.url}destroy(e=!1){var s,i,n,r;e&&((s=l(this,ma))!=null&&s.size)||((i=l(this,mn))==null||i.parentNode.parentNode.remove(),m(this,mn,null),(n=l(this,Vo))==null||n.clear(),m(this,Vo,null),(r=l(this,ma))==null||r.clear(),m(this,ma,null),m(this,va,0))}}pa=new WeakMap,Vo=new WeakMap,mn=new WeakMap,vn=new WeakMap,Re=new WeakMap,ma=new WeakMap,va=new WeakMap,V=new WeakSet,je=function(){return l(this,Vo)||m(this,Vo,new Map)},$c=function(){return l(this,ma)||m(this,ma,new Map)},Lh=function(){if(!l(this,mn)){const e=l(this,Re).createElement("div"),{style:s}=e;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=l(this,Re).createElementNS(nn,"svg");i.setAttribute("width",0),i.setAttribute("height",0),m(this,mn,l(this,Re).createElementNS(nn,"defs")),e.append(i),i.append(l(this,mn)),l(this,Re).body.append(e)}return l(this,mn)},rf=function(e){if(e.length===1){const c=e[0],u=new Array(256);for(let f=0;f<256;f++)u[f]=c[f]/255;const d=u.join(",");return[d,d,d]}const[s,i,n]=e,r=new Array(256),a=new Array(256),h=new Array(256);for(let c=0;c<256;c++)r[c]=s[c]/255,a[c]=i[c]/255,h[c]=n[c]/255;return[r.join(","),a.join(","),h.join(",")]},Fh=function(e){if(l(this,pa)===void 0){m(this,pa,"");const s=l(this,Re).URL;s!==l(this,Re).baseURI&&(fd(s)?rt('#createUrl: ignore "data:"-URL for performance reasons.'):m(this,pa,s.split("#",1)[0]))}return`url(${l(this,pa)}#${e})`},py=function(e){const s=l(this,Re).createElementNS(nn,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(s)},Np=function(e){const s=l(this,Re).createElementNS(nn,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(s)},Ih=function(e){const s=l(this,Re).createElementNS(nn,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),l(this,V,Lh).append(s),s},qc=function(e,s,i){const n=l(this,Re).createElementNS(nn,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},Kc=function(e,s,i,n){const r=l(this,Re).createElementNS(nn,"feComponentTransfer");n.append(r),w(this,V,qc).call(this,r,"feFuncR",e),w(this,V,qc).call(this,r,"feFuncG",s),w(this,V,qc).call(this,r,"feFuncB",i)},Bp=function(e,s){const i=l(this,Re).createElementNS(nn,"feComponentTransfer");s.append(i),w(this,V,qc).call(this,i,"feFuncA",e)},Jc=function(e){return l(this,V,Lh).style.color=e,jg(getComputedStyle(l(this,V,Lh)).getPropertyValue("color"))};class Bv{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){Et("Abstract method `_fetch` called.")}}class Hv extends Bv{async _fetch(t){const e=await dd(t,"arraybuffer");return new Uint8Array(e)}}Pe&&rt("Please use the `legacy` build in Node.js environments.");async function Gv(o){const e=await process.getBuiltinModule("fs").promises.readFile(o);return new Uint8Array(e)}class PS extends Nv{}class MS extends Fv{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Mt&&Mt.tagName.toUpperCase()==="SCRIPT"&&Mt.src||new URL("pdf-canvas.umd.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class OS extends Iv{async _fetch(t){return Gv(t)}}class DS extends Bv{async _fetch(t){return Gv(t)}}const Oe={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function zg(o,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),o.clip(i)}class Xg{getPattern(){Et("Abstract method `getPattern` called.")}}class RS extends Xg{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===Oe.STROKE||i===Oe.FILL){const r=e.current.getClippedPathBoundingBox(i,It(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,h=Math.ceil(r[3]-r[1])||1,c=e.cachedCanvases.getCanvas("pattern",a,h),u=c.context;u.clearRect(0,0,u.canvas.width,u.canvas.height),u.beginPath(),u.rect(0,0,u.canvas.width,u.canvas.height),u.translate(-r[0],-r[1]),s=q.transform(s,[1,0,0,1,r[0],r[1]]),u.transform(...e.baseTransform),this.matrix&&u.transform(...this.matrix),zg(u,this._bbox),u.fillStyle=this._createGradient(u),u.fill(),n=t.createPattern(c.canvas,"no-repeat");const d=new DOMMatrix(s);n.setTransform(d)}else zg(t,this._bbox),n=this._createGradient(t);return n}}function Ug(o,t,e,s,i,n,r,a){const h=t.coords,c=t.colors,u=o.data,d=o.width*4;let f;h[e+1]>h[s+1]&&(f=e,e=s,s=f,f=n,n=r,r=f),h[s+1]>h[i+1]&&(f=s,s=i,i=f,f=r,r=a,a=f),h[e+1]>h[s+1]&&(f=e,e=s,s=f,f=n,n=r,r=f);const g=(h[e]+t.offsetX)*t.scaleX,p=(h[e+1]+t.offsetY)*t.scaleY,v=(h[s]+t.offsetX)*t.scaleX,_=(h[s+1]+t.offsetY)*t.scaleY,b=(h[i]+t.offsetX)*t.scaleX,x=(h[i+1]+t.offsetY)*t.scaleY;if(p>=x)return;const C=c[n],A=c[n+1],P=c[n+2],D=c[r],k=c[r+1],M=c[r+2],R=c[a],F=c[a+1],I=c[a+2],Y=Math.round(p),N=Math.round(x);let H,at,j,W,it,kt,Ut,ne;for(let Wt=Y;Wt<=N;Wt++){if(Wt<_){const ft=Wt<p?0:(p-Wt)/(p-_);H=g-(g-v)*ft,at=C-(C-D)*ft,j=A-(A-k)*ft,W=P-(P-M)*ft}else{let ft;Wt>x?ft=1:_===x?ft=0:ft=(_-Wt)/(_-x),H=v-(v-b)*ft,at=D-(D-R)*ft,j=k-(k-F)*ft,W=M-(M-I)*ft}let Tt;Wt<p?Tt=0:Wt>x?Tt=1:Tt=(p-Wt)/(p-x),it=g-(g-b)*Tt,kt=C-(C-R)*Tt,Ut=A-(A-F)*Tt,ne=P-(P-I)*Tt;const Ce=Math.round(Math.min(H,it)),Xs=Math.round(Math.max(H,it));let Dt=d*Wt+Ce*4;for(let ft=Ce;ft<=Xs;ft++)Tt=(H-ft)/(H-it),Tt<0?Tt=0:Tt>1&&(Tt=1),u[Dt++]=at-(at-kt)*Tt|0,u[Dt++]=j-(j-Ut)*Tt|0,u[Dt++]=W-(W-ne)*Tt|0,u[Dt++]=255}}function LS(o,t,e){const s=t.coords,i=t.colors;let n,r;switch(t.type){case"lattice":const a=t.verticesPerRow,h=Math.floor(s.length/a)-1,c=a-1;for(n=0;n<h;n++){let u=n*a;for(let d=0;d<c;d++,u++)Ug(o,e,s[u],s[u+1],s[u+a],i[u],i[u+1],i[u+a]),Ug(o,e,s[u+a+1],s[u+1],s[u+a],i[u+a+1],i[u+1],i[u+a])}break;case"triangles":for(n=0,r=s.length;n<r;n+=3)Ug(o,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}class FS extends Xg{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const a=Math.floor(this._bounds[0]),h=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-a,u=Math.ceil(this._bounds[3])-h,d=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(u*t[1]*1.1)),3e3),g=c/d,p=u/f,v={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-h,scaleX:1/g,scaleY:1/p},_=d+2*2,b=f+2*2,x=s.getCanvas("mesh",_,b),C=x.context,A=C.createImageData(d,f);if(e){const D=A.data;for(let k=0,M=D.length;k<M;k+=4)D[k]=e[0],D[k+1]=e[1],D[k+2]=e[2],D[k+3]=255}for(const D of this._figures)LS(A,D,v);return C.putImageData(A,2,2),{canvas:x.canvas,offsetX:a-2*g,offsetY:h-2*p,scaleX:g,scaleY:p}}getPattern(t,e,s,i){zg(t,this._bbox);let n;if(i===Oe.SHADING)n=q.singularValueDecompose2dScale(It(t));else if(n=q.singularValueDecompose2dScale(e.baseTransform),this.matrix){const a=q.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}const r=this._createMeshCanvas(n,i===Oe.SHADING?null:this._background,e.cachedCanvases);return i!==Oe.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class IS extends Xg{getPattern(){return"hotpink"}}function jS(o){switch(o[0]){case"RadialAxial":return new RS(o);case"Mesh":return new FS(o);case"Dummy":return new IS}throw new Error(`Unknown IR type: ${o[0]}`)}const Vv={COLORED:1,UNCOLORED:2},Ld=class Ld{constructor(t,e,s,i,n){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.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:s,paintType:i,tilingType:n,color:r,canvasGraphicsFactory:a}=this;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),ld("TilingType: "+n);const u=e[0],d=e[1],f=e[2],g=e[3],p=f-u,v=g-d,_=q.singularValueDecompose2dScale(this.matrix),b=q.singularValueDecompose2dScale(this.baseTransform),x=_[0]*b[0],C=_[1]*b[1];let A=p,P=v,D=!1,k=!1;const M=Math.ceil(h*x),R=Math.ceil(c*C),F=Math.ceil(p*x),I=Math.ceil(v*C);M>=F?A=h:D=!0,R>=I?P=c:k=!0;const Y=this.getSizeAndScale(A,this.ctx.canvas.width,x),N=this.getSizeAndScale(P,this.ctx.canvas.height,C),H=t.cachedCanvases.getCanvas("pattern",Y.size,N.size),at=H.context,j=a.createCanvasGraphics(at);if(j.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(j,i,r),at.translate(-Y.scale*u,-N.scale*d),j.transform(Y.scale,0,0,N.scale,0,0),at.save(),this.clipBbox(j,u,d,f,g),j.baseTransform=It(j.ctx),j.executeOperatorList(s),j.endDrawing(),at.restore(),D||k){const W=H.canvas;D&&(A=h),k&&(P=c);const it=this.getSizeAndScale(A,this.ctx.canvas.width,x),kt=this.getSizeAndScale(P,this.ctx.canvas.height,C),Ut=it.size,ne=kt.size,Wt=t.cachedCanvases.getCanvas("pattern-workaround",Ut,ne),Tt=Wt.context,Ce=D?Math.floor(p/h):0,Xs=k?Math.floor(v/c):0;for(let Dt=0;Dt<=Ce;Dt++)for(let ft=0;ft<=Xs;ft++)Tt.drawImage(W,Ut*Dt,ne*ft,Ut,ne,0,0,Ut,ne);return{canvas:Wt.canvas,scaleX:it.scale,scaleY:kt.scale,offsetX:u,offsetY:d}}return{canvas:H.canvas,scaleX:Y.scale,scaleY:N.scale,offsetX:u,offsetY:d}}getSizeAndScale(t,e,s){const i=Math.max(Ld.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const r=i-e,a=n-s;t.ctx.rect(e,s,r,a),t.current.updateRectMinMax(It(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case Vv.COLORED:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case Vv.UNCOLORED:const a=q.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new lS(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==Oe.SHADING&&(n=q.transform(n,e.baseTransform),this.matrix&&(n=q.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const h=t.createPattern(r.canvas,"repeat");return h.setTransform(a),h}};J(Ld,"MAX_PATTERN_SIZE",3e3);let Yg=Ld;function NS({src:o,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=ze.isLittleEndian?4278190080:255,[h,c]=r?[n,a]:[a,n],u=s>>3,d=s&7,f=o.length;e=new Uint32Array(e.buffer);let g=0;for(let p=0;p<i;p++){for(const _=t+u;t<_;t++){const b=t<f?o[t]:255;e[g++]=b&128?c:h,e[g++]=b&64?c:h,e[g++]=b&32?c:h,e[g++]=b&16?c:h,e[g++]=b&8?c:h,e[g++]=b&4?c:h,e[g++]=b&2?c:h,e[g++]=b&1?c:h}if(d===0)continue;const v=t<f?o[t++]:255;for(let _=0;_<d;_++)e[g++]=v&1<<7-_?c:h}return{srcPos:t,destPos:g}}const Wv=16,zv=100,BS=15,Xv=10,Uv=1e3,ns=16;function HS(o,t){if(o._removeMirroring)throw new Error("Context is already forwarding operations.");o.__originalSave=o.save,o.__originalRestore=o.restore,o.__originalRotate=o.rotate,o.__originalScale=o.scale,o.__originalTranslate=o.translate,o.__originalTransform=o.transform,o.__originalSetTransform=o.setTransform,o.__originalResetTransform=o.resetTransform,o.__originalClip=o.clip,o.__originalMoveTo=o.moveTo,o.__originalLineTo=o.lineTo,o.__originalBezierCurveTo=o.bezierCurveTo,o.__originalRect=o.rect,o.__originalClosePath=o.closePath,o.__originalBeginPath=o.beginPath,o._removeMirroring=()=>{o.save=o.__originalSave,o.restore=o.__originalRestore,o.rotate=o.__originalRotate,o.scale=o.__originalScale,o.translate=o.__originalTranslate,o.transform=o.__originalTransform,o.setTransform=o.__originalSetTransform,o.resetTransform=o.__originalResetTransform,o.clip=o.__originalClip,o.moveTo=o.__originalMoveTo,o.lineTo=o.__originalLineTo,o.bezierCurveTo=o.__originalBezierCurveTo,o.rect=o.__originalRect,o.closePath=o.__originalClosePath,o.beginPath=o.__originalBeginPath,delete o._removeMirroring},o.save=function(){t.save(),this.__originalSave()},o.restore=function(){t.restore(),this.__originalRestore()},o.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},o.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},o.transform=function(s,i,n,r,a,h){t.transform(s,i,n,r,a,h),this.__originalTransform(s,i,n,r,a,h)},o.setTransform=function(s,i,n,r,a,h){t.setTransform(s,i,n,r,a,h),this.__originalSetTransform(s,i,n,r,a,h)},o.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},o.rotate=function(s){t.rotate(s),this.__originalRotate(s)},o.clip=function(s){t.clip(s),this.__originalClip(s)},o.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},o.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},o.bezierCurveTo=function(e,s,i,n,r,a){t.bezierCurveTo(e,s,i,n,r,a),this.__originalBezierCurveTo(e,s,i,n,r,a)},o.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},o.closePath=function(){t.closePath(),this.__originalClosePath()},o.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class GS{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function bd(o,t,e,s,i,n,r,a,h,c){const[u,d,f,g,p,v]=It(o);if(d===0&&f===0){const x=r*u+p,C=Math.round(x),A=a*g+v,P=Math.round(A),D=(r+h)*u+p,k=Math.abs(Math.round(D)-C)||1,M=(a+c)*g+v,R=Math.abs(Math.round(M)-P)||1;return o.setTransform(Math.sign(u),0,0,Math.sign(g),C,P),o.drawImage(t,e,s,i,n,0,0,k,R),o.setTransform(u,d,f,g,p,v),[k,R]}if(u===0&&g===0){const x=a*f+p,C=Math.round(x),A=r*d+v,P=Math.round(A),D=(a+c)*f+p,k=Math.abs(Math.round(D)-C)||1,M=(r+h)*d+v,R=Math.abs(Math.round(M)-P)||1;return o.setTransform(0,Math.sign(d),Math.sign(f),0,C,P),o.drawImage(t,e,s,i,n,0,0,R,k),o.setTransform(u,d,f,g,p,v),[R,k]}o.drawImage(t,e,s,i,n,r,a,h,c);const _=Math.hypot(u,d),b=Math.hypot(f,g);return[_*h,b*c]}function VS(o){const{width:t,height:e}=o;if(t>Uv||e>Uv)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let r=new Uint8Array(n*(e+1)),a,h,c;const u=t+7&-8;let d=new Uint8Array(u*e),f=0;for(const b of o.data){let x=128;for(;x>0;)d[f++]=b&x?0:255,x>>=1}let g=0;for(f=0,d[f]!==0&&(r[0]=1,++g),h=1;h<t;h++)d[f]!==d[f+1]&&(r[h]=d[f]?2:1,++g),f++;for(d[f]!==0&&(r[h]=2,++g),a=1;a<e;a++){f=a*u,c=a*n,d[f-u]!==d[f]&&(r[c]=d[f]?1:8,++g);let b=(d[f]?4:0)+(d[f-u]?8:0);for(h=1;h<t;h++)b=(b>>2)+(d[f+1]?4:0)+(d[f-u+1]?8:0),i[b]&&(r[c+h]=i[b],++g),f++;if(d[f-u]!==d[f]&&(r[c+h]=d[f]?2:4,++g),g>s)return null}for(f=u*(e-1),c=a*n,d[f]!==0&&(r[c]=8,++g),h=1;h<t;h++)d[f]!==d[f+1]&&(r[c+h]=d[f]?4:8,++g),f++;if(d[f]!==0&&(r[c+h]=4,++g),g>s)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),v=new Path2D;for(a=0;g&&a<=e;a++){let b=a*n;const x=b+t;for(;b<x&&!r[b];)b++;if(b===x)continue;v.moveTo(b%n,a);const C=b;let A=r[b];do{const P=p[A];do b+=P;while(!r[b]);const D=r[b];D!==5&&D!==10?(A=D,r[b]=0):(A=D&51*A>>4,r[b]&=A>>2|A<<2),v.lineTo(b%n,b/n|0),r[b]||--g}while(C!==b);--a}return d=null,r=null,function(b){b.save(),b.scale(1/t,-1/e),b.translate(0,-e),b.fill(v),b.beginPath(),b.restore()}}class Yv{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Tv,this.textMatrixScale=1,this.fontMatrix=Tg,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Me.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=q.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=q.applyTransform(e,t),i=q.applyTransform(e.slice(2),t),n=q.applyTransform([e[0],e[3]],t),r=q.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(t,e){q.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,i,n,r,a,h,c,u){const d=q.bezierBoundingBox(e,s,i,n,r,a,h,c,u);u||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Oe.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Oe.STROKE){e||Et("Stroke bounding box must include transform.");const i=q.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=q.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Oe.FILL,e=null){return q.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function $v(o,t){if(t instanceof ImageData){o.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%ns,n=(e-i)/ns,r=i===0?n:n+1,a=o.createImageData(s,ns);let h=0,c;const u=t.data,d=a.data;let f,g,p,v;if(t.kind===ad.GRAYSCALE_1BPP){const _=u.byteLength,b=new Uint32Array(d.buffer,0,d.byteLength>>2),x=b.length,C=s+7>>3,A=4294967295,P=ze.isLittleEndian?4278190080:255;for(f=0;f<r;f++){for(p=f<n?ns:i,c=0,g=0;g<p;g++){const D=_-h;let k=0;const M=D>C?s:D*8-7,R=M&-8;let F=0,I=0;for(;k<R;k+=8)I=u[h++],b[c++]=I&128?A:P,b[c++]=I&64?A:P,b[c++]=I&32?A:P,b[c++]=I&16?A:P,b[c++]=I&8?A:P,b[c++]=I&4?A:P,b[c++]=I&2?A:P,b[c++]=I&1?A:P;for(;k<M;k++)F===0&&(I=u[h++],F=128),b[c++]=I&F?A:P,F>>=1}for(;c<x;)b[c++]=0;o.putImageData(a,0,f*ns)}}else if(t.kind===ad.RGBA_32BPP){for(g=0,v=s*ns*4,f=0;f<n;f++)d.set(u.subarray(h,h+v)),h+=v,o.putImageData(a,0,g),g+=ns;f<r&&(v=s*i*4,d.set(u.subarray(h,h+v)),o.putImageData(a,0,g))}else if(t.kind===ad.RGB_24BPP)for(p=ns,v=s*p,f=0;f<r;f++){for(f>=n&&(p=i,v=s*p),c=0,g=v;g--;)d[c++]=u[h++],d[c++]=u[h++],d[c++]=u[h++],d[c++]=255;o.putImageData(a,0,f*ns)}else throw new Error(`bad image kind: ${t.kind}`)}function qv(o,t){if(t.bitmap){o.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%ns,n=(e-i)/ns,r=i===0?n:n+1,a=o.createImageData(s,ns);let h=0;const c=t.data,u=a.data;for(let d=0;d<r;d++){const f=d<n?ns:i;({srcPos:h}=NS({src:c,srcPos:h,dest:u,width:s,height:f,nonBlackColor:0})),o.putImageData(a,0,d*ns)}}function dl(o,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)o[s]!==void 0&&(t[s]=o[s]);o.setLineDash!==void 0&&(t.setLineDash(o.getLineDash()),t.lineDashOffset=o.lineDashOffset)}function yd(o){if(o.strokeStyle=o.fillStyle="#000000",o.fillRule="nonzero",o.globalAlpha=1,o.lineWidth=1,o.lineCap="butt",o.lineJoin="miter",o.miterLimit=10,o.globalCompositeOperation="source-over",o.font="10px sans-serif",o.setLineDash!==void 0&&(o.setLineDash([]),o.lineDashOffset=0),!Pe){const{filter:t}=o;t!=="none"&&t!==""&&(o.filter="none")}}function Kv(o,t){if(t)return!0;const e=q.singularValueDecompose2dScale(o);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Kn.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const WS=["butt","round","square"],zS=["miter","round","bevel"],XS={},Jv={},dp=class dp{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},h,c){y(this,li);this.ctx=t,this.current=new Yv(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=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.processingType3=null,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=r,this.cachedCanvases=new GS(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=h,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){const h=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=h.canvas,this.ctx=h.context,this.ctx.save(),this.ctx.transform(...It(this.compositeCtx))}this.ctx.save(),yd(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=It(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,r=t.fnArray;let a=e||0;const h=n.length;if(h===a)return a;const c=h-a>Xv&&typeof s=="function",u=c?Date.now()+BS:0;let d=0;const f=this.commonObjs,g=this.objs;let p;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(p=r[a],p!==si.dependency)this[p].apply(this,n[a]);else for(const v of n[a]){const _=v.startsWith("g_")?f:g;if(!_.has(v))return _.get(v,s),a}if(a++,a===h)return a;if(c&&++d>Xv){if(Date.now()>u)return s(),a;d=0}}}endDrawing(){w(this,li,Hp).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),w(this,li,Gp).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=s,h=i,c="prescale1",u,d;for(;n>2&&a>1||r>2&&h>1;){let f=a,g=h;n>2&&a>1&&(f=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/f),r>2&&h>1&&(g=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,r/=h/g),u=this.cachedCanvases.getCanvas(c,f,g),d=u.context,d.clearRect(0,0,f,g),d.drawImage(t,0,0,a,h,0,0,f,g),t=u.canvas,a=f,h=g,c=c==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,r=this.current.patternFill,a=It(e);let h,c,u,d;if((t.bitmap||t.data)&&t.count>1){const M=t.bitmap||t.data.buffer;c=JSON.stringify(r?a:[a.slice(0,4),n]),h=this._cachedBitmapsMap.get(M),h||(h=new Map,this._cachedBitmapsMap.set(M,h));const R=h.get(c);if(R&&!r){const F=Math.round(Math.min(a[0],a[2])+a[4]),I=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:R,offsetX:F,offsetY:I}}u=R}u||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),qv(d.context,t));let f=q.transform(a,[1/s,0,0,-1/i,0,0]);f=q.transform(f,[1,0,0,1,0,-i]);const[g,p,v,_]=q.getAxialAlignedBoundingBox([0,0,s,i],f),b=Math.round(v-g)||1,x=Math.round(_-p)||1,C=this.cachedCanvases.getCanvas("fillCanvas",b,x),A=C.context,P=g,D=p;A.translate(-P,-D),A.transform(...f),u||(u=this._scaleImage(d.canvas,Ai(A)),u=u.img,h&&r&&h.set(c,u)),A.imageSmoothingEnabled=Kv(It(A),t.interpolate),bd(A,u,0,0,u.width,u.height,0,0,s,i),A.globalCompositeOperation="source-in";const k=q.transform(Ai(A),[1,0,0,1,-P,-D]);return A.fillStyle=r?n.getPattern(e,this,k,Oe.FILL):n,A.fillRect(0,0,s,i),h&&!r&&(this.cachedCanvases.delete("fillCanvas"),h.set(c,C.canvas)),{canvas:C.canvas,offsetX:Math.round(P),offsetY:Math.round(D)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=WS[t]}setLineJoin(t){this.ctx.lineJoin=zS[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...It(this.suspendedCtx)),dl(this.suspendedCtx,n),HS(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),dl(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];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,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()}composeSMask(t,e,s,i){const n=i[0],r=i[1],a=i[2]-n,h=i[3]-r;a===0||h===0||(this.genericComposeSMask(e.context,s,a,h,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,r,a,h,c,u,d){let f=t.canvas,g=h-u,p=c-d;if(r){const _=q.makeHexColor(...r);if(g<0||p<0||g+s>f.width||p+i>f.height){const b=this.cachedCanvases.getCanvas("maskExtension",s,i),x=b.context;x.drawImage(f,-g,-p),x.globalCompositeOperation="destination-atop",x.fillStyle=_,x.fillRect(0,0,s,i),x.globalCompositeOperation="source-over",f=b.canvas,g=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const b=new Path2D;b.rect(g,p,s,i),t.clip(b),t.globalCompositeOperation="destination-atop",t.fillStyle=_,t.fillRect(g,p,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const v=new Path2D;v.rect(h,c,s,i),e.clip(v),e.globalCompositeOperation="destination-in",e.drawImage(f,g,p,s,i,h,c,s,i),e.restore()}save(){this.inSMaskMode?(dl(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),dl(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let r=n.x,a=n.y,h,c;const u=It(i),d=u[0]===0&&u[3]===0||u[1]===0&&u[2]===0,f=d?s.slice(0):null;for(let g=0,p=0,v=t.length;g<v;g++)switch(t[g]|0){case si.rectangle:r=e[p++],a=e[p++];const _=e[p++],b=e[p++],x=r+_,C=a+b;i.moveTo(r,a),_===0||b===0?i.lineTo(x,C):(i.lineTo(x,a),i.lineTo(x,C),i.lineTo(r,C)),d||n.updateRectMinMax(u,[r,a,x,C]),i.closePath();break;case si.moveTo:r=e[p++],a=e[p++],i.moveTo(r,a),d||n.updatePathMinMax(u,r,a);break;case si.lineTo:r=e[p++],a=e[p++],i.lineTo(r,a),d||n.updatePathMinMax(u,r,a);break;case si.curveTo:h=r,c=a,r=e[p+4],a=e[p+5],i.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],r,a),n.updateCurvePathMinMax(u,h,c,e[p],e[p+1],e[p+2],e[p+3],r,a,f),p+=6;break;case si.curveTo2:h=r,c=a,i.bezierCurveTo(r,a,e[p],e[p+1],e[p+2],e[p+3]),n.updateCurvePathMinMax(u,h,c,r,a,e[p],e[p+1],e[p+2],e[p+3],f),r=e[p+2],a=e[p+3],p+=4;break;case si.curveTo3:h=r,c=a,r=e[p+2],a=e[p+3],i.bezierCurveTo(e[p],e[p+1],r,a,r,a),n.updateCurvePathMinMax(u,h,c,e[p],e[p+1],r,a,r,a,f),p+=4;break;case si.closePath:i.closePath();break}d&&n.updateScalingPathMinMax(u,f),n.setCurrentPoint(r,a)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&(s!=null&&s.getPattern)?(e.save(),e.strokeStyle=s.getPattern(e,this,Ai(e),Oe.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;let n=!1;i&&(e.save(),e.fillStyle=s.getPattern(e,this,Ai(e),Oe.FILL),n=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&r!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=XS}eoClip(){this.pendingClip=Jv}beginText(){this.current.textMatrix=Tv,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}const s=new Path2D,i=e.getTransform().invertSelf();for(const{transform:n,x:r,y:a,fontSize:h,path:c}of t)s.addPath(c,new DOMMatrix(n).preMultiplySelf(i).translate(r,a).scale(h,-h));e.clip(s),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var u;const s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||Tg,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&rt("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const n=s.loadedName||"sans-serif",r=((u=s.systemFontInfo)==null?void 0:u.css)||`"${n}", ${s.fallbackName}`;let a="normal";s.black?a="900":s.bold&&(a="bold");const h=s.italic?"italic":"normal";let c=e;e<Wv?c=Wv:e>zv&&(c=zv),this.current.fontSizeScale=e/c,this.ctx.font=`${h} ${a} ${c}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,r){this.current.textMatrix=[t,e,s,i,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i,n){const r=this.ctx,a=this.current,h=a.font,c=a.textRenderingMode,u=a.fontSize/a.fontSizeScale,d=c&Me.FILL_STROKE_MASK,f=!!(c&Me.ADD_TO_PATH_FLAG),g=a.patternFill&&!h.missingFile,p=a.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||f||g||p)&&(v=h.getPathGenerator(this.commonObjs,t)),h.disableFontFace||g||p){if(r.save(),r.translate(e,s),r.scale(u,-u),d===Me.FILL||d===Me.FILL_STROKE)if(i){const _=r.getTransform();r.setTransform(...i),r.fill(w(this,li,Vp).call(this,v,_,i))}else r.fill(v);if(d===Me.STROKE||d===Me.FILL_STROKE)if(n){const _=r.getTransform();r.setTransform(...n),r.stroke(w(this,li,Vp).call(this,v,_,n))}else r.lineWidth/=u,r.stroke(v);r.restore()}else(d===Me.FILL||d===Me.FILL_STROKE)&&r.fillText(t,e,s),(d===Me.STROKE||d===Me.FILL_STROKE)&&r.strokeText(t,e,s);f&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:It(r),x:e,y:s,fontSize:u,path:v})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return ht(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,h=e.wordSpacing,c=e.fontDirection,u=e.textHScale*c,d=t.length,f=s.vertical,g=f?1:-1,p=s.defaultVMetrics,v=i*e.fontMatrix[0],_=e.textRenderingMode===Me.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),c>0?n.scale(u,-1):n.scale(u,1);let b,x;if(e.patternFill){n.save();const k=e.fillColor.getPattern(n,this,Ai(n),Oe.FILL);b=It(n),n.restore(),n.fillStyle=k}if(e.patternStroke){n.save();const k=e.strokeColor.getPattern(n,this,Ai(n),Oe.STROKE);x=It(n),n.restore(),n.strokeStyle=k}let C=e.lineWidth;const A=e.textMatrixScale;if(A===0||C===0){const k=e.textRenderingMode&Me.FILL_STROKE_MASK;(k===Me.STROKE||k===Me.FILL_STROKE)&&(C=this.getSinglePixelWidth())}else C/=A;if(r!==1&&(n.scale(r,r),C/=r),n.lineWidth=C,s.isInvalidPDFjsFont){const k=[];let M=0;for(const R of t)k.push(R.unicode),M+=R.width;n.fillText(k.join(""),0,0),e.x+=M*v*u,n.restore(),this.compose();return}let P=0,D;for(D=0;D<d;++D){const k=t[D];if(typeof k=="number"){P+=g*k*i/1e3;continue}let M=!1;const R=(k.isSpace?h:0)+a,F=k.fontChar,I=k.accent;let Y,N,H=k.width;if(f){const j=k.vmetric||p,W=-(k.vmetric?j[1]:H*.5)*v,it=j[2]*v;H=j?-j[0]:H,Y=W/r,N=(P+it)/r}else Y=P/r,N=0;if(s.remeasure&&H>0){const j=n.measureText(F).width*1e3/i*r;if(H<j&&this.isFontSubpixelAAEnabled){const W=H/j;M=!0,n.save(),n.scale(W,1),Y/=W}else H!==j&&(Y+=(H-j)/2e3*i/r)}if(this.contentVisible&&(k.isInFont||s.missingFile)){if(_&&!I)n.fillText(F,Y,N);else if(this.paintChar(F,Y,N,b,x),I){const j=Y+i*I.offset.x/r,W=N-i*I.offset.y/r;this.paintChar(I.fontChar,j,W,b,x)}}const at=f?H*v-R*c:H*v+R*c;P+=at,M&&n.restore()}f?e.y-=P:e.x+=P*u,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,r=s.fontDirection,a=i.vertical?1:-1,h=s.charSpacing,c=s.wordSpacing,u=s.textHScale*r,d=s.fontMatrix||Tg,f=t.length,g=s.textRenderingMode===Me.INVISIBLE;let p,v,_,b;if(!(g||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(u,r),p=0;p<f;++p){if(v=t[p],typeof v=="number"){b=a*v*n/1e3,this.ctx.translate(b,0),s.x+=b*u;continue}const x=(v.isSpace?c:0)+h,C=i.charProcOperatorList[v.operatorListId];if(!C){rt(`Type3 character "${v.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=v,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(C),this.restore()),_=q.applyTransform([v.width,0],d)[0]*n+x,e.translate(_,0),s.x+=_*u}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||It(this.ctx),n={createCanvasGraphics:r=>new dp(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Yg(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){this.ctx.strokeStyle=this.current.strokeColor=q.makeHexColor(t,e,s),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=q.makeHexColor(t,e,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=jS(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Ai(e),Oe.SHADING);const i=Ai(e);if(i){const{width:n,height:r}=e.canvas,[a,h,c,u]=q.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,h,c-a,u-h)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Et("Should not call beginInlineImage")}beginImageData(){Et("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=It(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(It(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||ld("TODO: Support non-isolated groups."),t.knockout&&rt("Knockout groups not supported.");const s=It(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=q.getAxialAlignedBoundingBox(t.bbox,It(e));const n=[0,0,e.canvas.width,e.canvas.height];i=q.intersect(i,n)||[0,0,0,0];const r=Math.floor(i[0]),a=Math.floor(i[1]),h=Math.max(Math.ceil(i[2])-r,1),c=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,h,c]);let u="groupAt"+this.groupLevel;t.smask&&(u+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(u,h,c),f=d.context;f.translate(-r,-a),f.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:f,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),dl(e,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=It(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=q.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(w(this,li,Hp).call(this),yd(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=r,e[3]=a;const[h,c]=q.singularValueDecompose2dScale(It(this.ctx)),{viewportScale:u}=this,d=Math.ceil(r*this.outputScaleX*u),f=Math.ceil(a*this.outputScaleY*u);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:g,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(h,0,0,-c,0,a*c),yd(this.ctx)}else yd(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new Yv(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),w(this,li,Gp).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;t=this.getObject(t.data,t),t.count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=VS(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const h=It(a);a.transform(e,s,i,n,0,0);const c=this._createMaskCanvas(t);a.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]);for(let u=0,d=r.length;u<d;u+=2){const f=q.transform(h,[e,s,i,n,r[u],r[u+1]]),[g,p]=q.applyTransform([0,0],f);a.drawImage(c.canvas,g,p)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:r,width:a,height:h,transform:c}=n,u=this.cachedCanvases.getCanvas("maskCanvas",a,h),d=u.context;d.save();const f=this.getObject(r,n);qv(d,f),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,Ai(e),Oe.FILL):s,d.fillRect(0,0,a,h),d.restore(),e.save(),e.transform(...c),e.scale(1,-1),bd(e,u.canvas,0,0,a,h,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){rt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n){rt("Dependent image isn't ready yet");return}const r=n.width,a=n.height,h=[];for(let c=0,u=i.length;c<u;c+=2)h.push({transform:[e,0,0,s,i[c],i[c+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!Pe){const{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}i.scale(1/e,-1/s);let n;if(t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const h=this.cachedCanvases.getCanvas("inlineImage",e,s).context;$v(h,t),n=this.applyTransferMapsToCanvas(h)}const r=this._scaleImage(n,Ai(i));i.imageSmoothingEnabled=Kv(It(i),t.interpolate),bd(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,r=t.height,h=this.cachedCanvases.getCanvas("inlineImage",n,r).context;$v(h,t),i=this.applyTransferMapsToCanvas(h)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),bd(s,i,n.x,n.y,n.w,n.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===Jv?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=It(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let r,a;if(s===0&&i===0){const h=Math.abs(e),c=Math.abs(n);if(h===c)if(t===0)r=a=1/h;else{const u=h*t;r=a=u<1?1/u:1}else if(t===0)r=1/h,a=1/c;else{const u=h*t,d=c*t;r=u<1?1/u:1,a=d<1?1/d:1}}else{const h=Math.abs(e*n-s*i),c=Math.hypot(e,s),u=Math.hypot(i,n);if(t===0)r=u/h,a=c/h;else{const d=t*h;r=u>d?u/d:1,a=c>d?c/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}const r=e.getLineDash();if(t&&e.save(),e.scale(i,n),r.length>0){const a=Math.max(i,n);e.setLineDash(r.map(h=>h/a)),e.lineDashOffset/=a}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};li=new WeakSet,Hp=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},Gp=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Vp=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i};let xo=dp;for(const o in si)xo.prototype[o]!==void 0&&(xo.prototype[si[o]]=xo.prototype[o]);class rn{static get workerPort(){return l(this,Ul)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");m(this,Ul,t)}static get workerSrc(){return l(this,Yl)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");m(this,Yl,t)}}Ul=new WeakMap,Yl=new WeakMap,y(rn,Ul,null),y(rn,Yl,"");class US{constructor({parsedData:t,rawData:e}){y(this,ba);y(this,$l);m(this,ba,t),m(this,$l,e)}getRaw(){return l(this,$l)}get(t){return l(this,ba).get(t)??null}getAll(){return Mg(l(this,ba))}has(t){return l(this,ba).has(t)}}ba=new WeakMap,$l=new WeakMap;const So=Symbol("INTERNAL");class YS{constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){y(this,ql,!1);y(this,Kl,!1);y(this,Jl,!1);y(this,Wo,!0);m(this,ql,!!(t&fs.DISPLAY)),m(this,Kl,!!(t&fs.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(l(this,Jl))return l(this,Wo);if(!l(this,Wo))return!1;const{print:t,view:e}=this.usage;return l(this,ql)?(e==null?void 0:e.viewState)!=="OFF":l(this,Kl)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==So&&Et("Internal method `_setVisible` called."),m(this,Jl,s),m(this,Wo,e)}}ql=new WeakMap,Kl=new WeakMap,Jl=new WeakMap,Wo=new WeakMap;class $S{constructor(t,e=fs.DISPLAY){y(this,Ql);y(this,ur,null);y(this,St,new Map);y(this,zo,null);y(this,Xo,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,m(this,Xo,t.order);for(const s of t.groups)l(this,St).set(s.id,new YS(e,s));if(t.baseState==="OFF")for(const s of l(this,St).values())s._setVisible(So,!1);for(const s of t.on)l(this,St).get(s)._setVisible(So,!0);for(const s of t.off)l(this,St).get(s)._setVisible(So,!1);m(this,zo,this.getHash())}}isVisible(t){if(l(this,St).size===0)return!0;if(!t)return ld("Optional content group not defined."),!0;if(t.type==="OCG")return l(this,St).has(t.id)?l(this,St).get(t.id).visible:(rt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return w(this,Ql,Wp).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!l(this,St).has(e))return rt(`Optional content group not found: ${e}`),!0;if(l(this,St).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!l(this,St).has(e))return rt(`Optional content group not found: ${e}`),!0;if(!l(this,St).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!l(this,St).has(e))return rt(`Optional content group not found: ${e}`),!0;if(!l(this,St).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!l(this,St).has(e))return rt(`Optional content group not found: ${e}`),!0;if(l(this,St).get(e).visible)return!1}return!0}return rt(`Unknown optional content policy ${t.policy}.`),!0}return rt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var n;const i=l(this,St).get(t);if(!i){rt(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const r of i.rbGroups)for(const a of r)a!==t&&((n=l(this,St).get(a))==null||n._setVisible(So,!1,!0));i._setVisible(So,!!e,!0),m(this,ur,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=l(this,St).get(i);if(n)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!n.visible,e);break}}m(this,ur,null)}get hasInitialVisibility(){return l(this,zo)===null||this.getHash()===l(this,zo)}getOrder(){return l(this,St).size?l(this,Xo)?l(this,Xo).slice():[...l(this,St).keys()]:null}getGroups(){return l(this,St).size>0?Mg(l(this,St)):null}getGroup(t){return l(this,St).get(t)||null}getHash(){if(l(this,ur)!==null)return l(this,ur);const t=new Dv;for(const[e,s]of l(this,St))t.update(`${e}:${s.visible}`);return m(this,ur,t.hexdigest())}}ur=new WeakMap,St=new WeakMap,zo=new WeakMap,Xo=new WeakMap,Ql=new WeakSet,Wp=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let r;if(Array.isArray(n))r=w(this,Ql,Wp).call(this,n);else if(l(this,St).has(n))r=l(this,St).get(n).visible;else return rt(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"};class qS{constructor(t,{disableRange:e=!1,disableStream:s=!1}){ee(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,(n==null?void 0:n.length)>0){const h=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(h)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((h,c)=>{this._onReceiveData({begin:h,chunk:c})}),t.addProgressListener((h,c)=>{this._onProgress({loaded:h,total:c})}),t.addProgressiveReadListener(h=>{this._onReceiveData({chunk:h})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(s),!0)});ee(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,s,i,n;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(n=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||n.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){ee(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new KS(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new JS(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class KS{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Fg(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class JS{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.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){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function QS(o){let t=!0,e=s("filename\\*","i").exec(o);if(e){e=e[1];let u=a(e);return u=unescape(u),u=h(u),u=c(u),n(u)}if(e=r(o),e){const u=c(e);return n(u)}if(e=s("filename","i").exec(o),e){e=e[1];let u=a(e);return u=c(u),n(u)}function s(u,d){return new RegExp("(?:^|;)\\s*"+u+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(u,d){if(u){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const f=new TextDecoder(u,{fatal:!0}),g=ud(d);d=f.decode(g),t=!1}catch{}}return d}function n(u){return t&&/[\x80-\xff]/.test(u)&&(u=i("utf-8",u),t&&(u=i("iso-8859-1",u))),u}function r(u){const d=[];let f;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=g.exec(u))!==null;){let[,v,_,b]=f;if(v=parseInt(v,10),v in d){if(v===0)break;continue}d[v]=[_,b]}const p=[];for(let v=0;v<d.length&&v in d;++v){let[_,b]=d[v];b=a(b),_&&(b=unescape(b),v===0&&(b=h(b))),p.push(b)}return p.join("")}function a(u){if(u.startsWith('"')){const d=u.slice(1).split('\\"');for(let f=0;f<d.length;++f){const g=d[f].indexOf('"');g!==-1&&(d[f]=d[f].slice(0,g),d.length=f+1),d[f]=d[f].replaceAll(/\\(.)/g,"$1")}u=d.join('"')}return u}function h(u){const d=u.indexOf("'");if(d===-1)return u;const f=u.slice(0,d),p=u.slice(d+1).replace(/^[^']*'/,"");return i(f,p)}function c(u){return!u.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(u)?u:u.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,f,g,p){if(g==="q"||g==="Q")return p=p.replaceAll("_"," "),p=p.replaceAll(/=([0-9a-fA-F]{2})/g,function(v,_){return String.fromCharCode(parseInt(_,16))}),i(f,p);try{p=atob(p)}catch{}return i(f,p)})}return""}function Qv(o,t){const e=new Headers;if(!o||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function _d(o){try{return new URL(o).origin}catch{}return null}function Zv({responseHeaders:o,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(o.get("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||o.get("Accept-Ranges")!=="bytes"||(o.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function tb(o){const t=o.get("Content-Disposition");if(t){let e=QS(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Fg(e))return e}return null}function wd(o,t){return o===404||o===0&&t.startsWith("file:")?new ol('Missing PDF "'+t+'".'):new cd(`Unexpected server response (${o}) while retrieving PDF "${t}".`,o)}function eb(o){return o===200||o===206}function sb(o,t,e){return{method:"GET",headers:o,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function ib(o){return o instanceof Uint8Array?o.buffer:o instanceof ArrayBuffer?o:(rt(`getArrayBuffer - unexpected data format: ${o}`),new Uint8Array(o).buffer)}class nb{constructor(t){J(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Qv(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return ee(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ZS(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new tC(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class ZS{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 s=new Headers(t.headers),i=e.url;fetch(i,sb(s,this._withCredentials,this._abortController)).then(n=>{if(t._responseOrigin=_d(n.url),!eb(n.status))throw wd(n.status,i);this._reader=n.body.getReader(),this._headersCapability.resolve();const r=n.headers,{allowRangeRequests:a,suggestedLength:h}=Zv({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=h||this._contentLength,this._filename=tb(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new qn("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(){var s;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:ib(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class tC{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${s-1}`);const r=i.url;fetch(r,sb(n,this._withCredentials,this._abortController)).then(a=>{const h=_d(a.url);if(h!==t._responseOrigin)throw new Error(`Expected range response-origin "${h}" to match "${t._responseOrigin}".`);if(!eb(a.status))throw wd(a.status,r);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:ib(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const $g=200,qg=206;function eC(o){const t=o.response;return typeof t!="string"?t:ud(t).buffer}class sC{constructor({url:t,httpHeaders:e,withCredentials:s}){J(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Qv(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[n,r]of this.headers)e.setRequestHeader(n,r);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=qg):i.expectedStatus=$g,e.responseType="arraybuffer",ee(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&((i=s.onProgress)==null||i.call(s,e))}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError(i.status);return}const n=i.status||$g;if(!(n===$g&&s.expectedStatus===qg)&&n!==s.expectedStatus){s.onError(i.status);return}const a=eC(i);if(n===qg){const h=i.getResponseHeader("Content-Range"),c=/bytes (\d+)-(\d+)\/(\d+)/.exec(h);c?s.onDone({begin:parseInt(c[1],10),chunk:a}):(rt('Missing or invalid "Content-Range" header.'),s.onError(0))}else a?s.onDone({begin:0,chunk:a}):s.onError(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class iC{constructor(t){this._source=t,this._manager=new sC(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return ee(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new nC(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new rC(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class nC{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(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=_d(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(a=>{const[h,...c]=a.split(": ");return[h,c.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:r}=Zv({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=tb(i),this._isRangeSupported&&this._manager.abortRequest(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(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=wd(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of 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 rC{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,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(){var e;const t=_d((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=wd(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const aC=/^[a-z][a-z0-9\-+.]+:/i;function oC(o){if(aC.test(o))return new URL(o);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(o))}class hC{constructor(t){this.source=t,this.url=oC(t.url),ee(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return ee(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new lC(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new cC(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class lC{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 s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new ol(`Missing PDF "${this._url}".`)),this._storedError=i,this._headersCapability.reject(i)})}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(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new qn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class cC{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const i=t.source;this._isStreamingSupported=!i.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const uC=1e5,rs=30,dC=.8,le=class le{constructor({textContentSource:t,container:e,viewport:s}){y(this,yn);y(this,dr,Promise.withResolvers());y(this,os,null);y(this,Zl,!1);y(this,tc,!!((yb=globalThis.FontInspector)!=null&&yb.enabled));y(this,ya,null);y(this,bn,null);y(this,ec,0);y(this,sc,0);y(this,_a,null);y(this,Uo,null);y(this,Yo,0);y(this,fr,0);y(this,$o,Object.create(null));y(this,ic,[]);y(this,qo,null);y(this,wa,[]);y(this,nc,new WeakMap);y(this,rc,null);var h;if(t instanceof ReadableStream)m(this,qo,t);else if(typeof t=="object")m(this,qo,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');m(this,os,m(this,Uo,e)),m(this,fr,s.scale*(globalThis.devicePixelRatio||1)),m(this,Yo,s.rotation),m(this,bn,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;m(this,rc,[1,0,0,-1,-r,a+n]),m(this,sc,i),m(this,ec,n),w(h=le,bs,by).call(h),zr(e,s),l(this,dr).promise.finally(()=>{l(le,Ko).delete(this),m(this,bn,null),m(this,$o,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ze.platform;return ht(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{l(this,_a).read().then(({value:e,done:s})=>{if(s){l(this,dr).resolve();return}l(this,ya)??m(this,ya,e.lang),Object.assign(l(this,$o),e.styles),w(this,yn,my).call(this,e.items),t()},l(this,dr).reject)};return m(this,_a,l(this,qo).getReader()),l(le,Ko).add(this),t(),l(this,dr).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==l(this,Yo)&&(e==null||e(),m(this,Yo,i),zr(l(this,Uo),{rotation:i})),s!==l(this,fr)){e==null||e(),m(this,fr,s);const r={div:null,properties:null,ctx:w(n=le,bs,af).call(n,l(this,ya))};for(const a of l(this,wa))r.properties=l(this,nc).get(a),r.div=a,w(this,yn,zp).call(this,r)}}cancel(){var e;const t=new qn("TextLayer task cancelled.");(e=l(this,_a))==null||e.cancel(t).catch(()=>{}),m(this,_a,null),l(this,dr).reject(t)}get textDivs(){return l(this,wa)}get textContentItemsStr(){return l(this,ic)}static cleanup(){if(!(l(this,Ko).size>0)){l(this,xa).clear();for(const{canvas:t}of l(this,Sa).values())t.remove();l(this,Sa).clear()}}};dr=new WeakMap,os=new WeakMap,Zl=new WeakMap,tc=new WeakMap,ya=new WeakMap,bn=new WeakMap,ec=new WeakMap,sc=new WeakMap,_a=new WeakMap,Uo=new WeakMap,Yo=new WeakMap,fr=new WeakMap,$o=new WeakMap,ic=new WeakMap,qo=new WeakMap,wa=new WeakMap,nc=new WeakMap,rc=new WeakMap,xa=new WeakMap,Sa=new WeakMap,ac=new WeakMap,gr=new WeakMap,Ko=new WeakMap,yn=new WeakSet,my=function(t){var i,n;if(l(this,Zl))return;(n=l(this,bn)).ctx??(n.ctx=w(i=le,bs,af).call(i,l(this,ya)));const e=l(this,wa),s=l(this,ic);for(const r of t){if(e.length>uC){rt("Ignoring additional textDivs for performance reasons."),m(this,Zl,!0);return}if(r.str===void 0){if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){const a=l(this,os);m(this,os,document.createElement("span")),l(this,os).classList.add("markedContent"),r.id!==null&&l(this,os).setAttribute("id",`${r.id}`),a.append(l(this,os))}else r.type==="endMarkedContent"&&m(this,os,l(this,os).parentNode);continue}s.push(r.str),w(this,yn,vy).call(this,r)}},vy=function(t){var v;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};l(this,wa).push(e);const i=q.transform(l(this,rc),t.transform);let n=Math.atan2(i[1],i[0]);const r=l(this,$o)[t.fontName];r.vertical&&(n+=Math.PI/2);let a=l(this,tc)&&r.fontSubstitution||r.fontFamily;a=le.fontFamilyMap.get(a)||a;const h=Math.hypot(i[2],i[3]),c=h*w(v=le,bs,yy).call(v,a,l(this,ya));let u,d;n===0?(u=i[4],d=i[5]-c):(u=i[4]+c*Math.sin(n),d=i[5]-c*Math.cos(n));const f="calc(var(--scale-factor)*",g=e.style;l(this,os)===l(this,Uo)?(g.left=`${(100*u/l(this,sc)).toFixed(2)}%`,g.top=`${(100*d/l(this,ec)).toFixed(2)}%`):(g.left=`${f}${u.toFixed(2)}px)`,g.top=`${f}${d.toFixed(2)}px)`),g.fontSize=`${f}${(l(le,gr)*h).toFixed(2)}px)`,g.fontFamily=a,s.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,l(this,tc)&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const _=Math.abs(t.transform[0]),b=Math.abs(t.transform[3]);_!==b&&Math.max(_,b)/Math.min(_,b)>1.5&&(p=!0)}if(p&&(s.canvasWidth=r.vertical?t.height:t.width),l(this,nc).set(e,s),l(this,bn).div=e,l(this,bn).properties=s,w(this,yn,zp).call(this,l(this,bn)),s.hasText&&l(this,os).append(e),s.hasEOL){const _=document.createElement("br");_.setAttribute("role","presentation"),l(this,os).append(_)}},zp=function(t){var a;const{div:e,properties:s,ctx:i}=t,{style:n}=e;let r="";if(l(le,gr)>1&&(r=`scale(${1/l(le,gr)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:h}=n,{canvasWidth:c,fontSize:u}=s;w(a=le,bs,Xp).call(a,i,u*l(this,fr),h);const{width:d}=i.measureText(e.textContent);d>0&&(r=`scaleX(${c*l(this,fr)/d}) ${r}`)}s.angle!==0&&(r=`rotate(${s.angle}deg) ${r}`),r.length>0&&(n.transform=r)},bs=new WeakSet,af=function(t=null){let e=l(this,Sa).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),l(this,Sa).set(t,e),l(this,ac).set(e,{size:0,family:""})}return e},Xp=function(t,e,s){const i=l(this,ac).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},by=function(){if(l(this,gr)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),m(this,gr,t.getBoundingClientRect().height),t.remove()},yy=function(t,e){const s=l(this,xa).get(t);if(s)return s;const i=w(this,bs,af).call(this,e);i.canvas.width=i.canvas.height=rs,w(this,bs,Xp).call(this,i,rs,t);const n=i.measureText("");let r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){const u=r/(r+a);return l(this,xa).set(t,u),i.canvas.width=i.canvas.height=0,u}i.strokeStyle="red",i.clearRect(0,0,rs,rs),i.strokeText("g",0,0);let h=i.getImageData(0,0,rs,rs).data;a=0;for(let u=h.length-1-3;u>=0;u-=4)if(h[u]>0){a=Math.ceil(u/4/rs);break}i.clearRect(0,0,rs,rs),i.strokeText("A",0,rs),h=i.getImageData(0,0,rs,rs).data,r=0;for(let u=0,d=h.length;u<d;u+=4)if(h[u]>0){r=rs-Math.floor(u/4/rs);break}i.canvas.width=i.canvas.height=0;const c=r?r/(r+a):dC;return l(this,xa).set(t,c),c},y(le,bs),y(le,xa,new Map),y(le,Sa,new Map),y(le,ac,new WeakMap),y(le,gr,null),y(le,Ko,new Set);let fl=le;class gl{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){var h;if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(gl.shouldBuildText(a))(h=n==null?void 0:n.attributes)!=null&&h.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const c of n.children)i(c)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const fC=65536,gC=100,pC=5e3,mC=Pe?MS:ES,vC=Pe?OS:jv,bC=Pe?PS:kS,yC=Pe?DS:Hv;function _C(o={}){typeof o=="string"||o instanceof URL?o={url:o}:(o instanceof ArrayBuffer||ArrayBuffer.isView(o))&&(o={data:o});const t=new Kg,{docId:e}=t,s=o.url?wC(o.url):null,i=o.data?xC(o.data):null,n=o.httpHeaders||null,r=o.withCredentials===!0,a=o.password??null,h=o.range instanceof ab?o.range:null,c=Number.isInteger(o.rangeChunkSize)&&o.rangeChunkSize>0?o.rangeChunkSize:fC;let u=o.worker instanceof Co?o.worker:null;const d=o.verbosity,f=typeof o.docBaseUrl=="string"&&!fd(o.docBaseUrl)?o.docBaseUrl:null,g=typeof o.cMapUrl=="string"?o.cMapUrl:null,p=o.cMapPacked!==!1,v=o.CMapReaderFactory||vC,_=typeof o.standardFontDataUrl=="string"?o.standardFontDataUrl:null,b=o.StandardFontDataFactory||yC,x=o.stopAtErrors!==!0,C=Number.isInteger(o.maxImageSize)&&o.maxImageSize>-1?o.maxImageSize:-1,A=o.isEvalSupported!==!1,P=typeof o.isOffscreenCanvasSupported=="boolean"?o.isOffscreenCanvasSupported:!Pe,D=typeof o.isImageDecoderSupported=="boolean"?o.isImageDecoderSupported:!Pe&&(ze.platform.isFirefox||!globalThis.chrome),k=Number.isInteger(o.canvasMaxAreaInBytes)?o.canvasMaxAreaInBytes:-1,M=typeof o.disableFontFace=="boolean"?o.disableFontFace:Pe,R=o.fontExtraProperties===!0,F=o.enableXfa===!0,I=o.ownerDocument||globalThis.document,Y=o.disableRange===!0,N=o.disableStream===!0,H=o.disableAutoFetch===!0,at=o.pdfBug===!0,j=o.CanvasFactory||mC,W=o.FilterFactory||bC,it=o.enableHWA===!0,kt=h?h.length:o.length??NaN,Ut=typeof o.useSystemFonts=="boolean"?o.useSystemFonts:!Pe&&!M,ne=typeof o.useWorkerFetch=="boolean"?o.useWorkerFetch:v===jv&&b===Hv&&g&&_&&ll(g,document.baseURI)&&ll(_,document.baseURI),Wt=null;rS(d);const Tt={canvasFactory:new j({ownerDocument:I,enableHWA:it}),filterFactory:new W({docId:e,ownerDocument:I}),cMapReaderFactory:ne?null:new v({baseUrl:g,isCompressed:p}),standardFontDataFactory:ne?null:new b({baseUrl:_})};if(!u){const Dt={verbosity:d,port:rn.workerPort};u=Dt.port?Co.fromPort(Dt):new Co(Dt),t._worker=u}const Ce={docId:e,apiVersion:"4.10.38",data:i,password:a,disableAutoFetch:H,rangeChunkSize:c,length:kt,docBaseUrl:f,enableXfa:F,evaluatorOptions:{maxImageSize:C,disableFontFace:M,ignoreErrors:x,isEvalSupported:A,isOffscreenCanvasSupported:P,isImageDecoderSupported:D,canvasMaxAreaInBytes:k,fontExtraProperties:R,useSystemFonts:Ut,cMapUrl:ne?g:null,standardFontDataUrl:ne?_:null}},Xs={disableFontFace:M,fontExtraProperties:R,ownerDocument:I,pdfBug:at,styleElement:Wt,loadingParams:{disableAutoFetch:H,enableXfa:F}};return u.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const Dt=u.messageHandler.sendWithPromise("GetDocRequest",Ce,i?[i.buffer]:null);let ft;if(h)ft=new qS(h,{disableRange:Y,disableStream:N});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let Ps;if(Pe)if(ll(s)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");Ps=nb}else Ps=hC;else Ps=ll(s)?nb:iC;ft=new Ps({url:s,length:kt,httpHeaders:n,withCredentials:r,rangeChunkSize:c,disableRange:Y,disableStream:N})}return Dt.then(Ps=>{if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const Xi=new ul(e,Ps,u.port),Je=new TC(Xi,t,ft,Xs,Tt);t._transport=Je,Xi.send("Ready",null)})}).catch(t._capability.reject),t}function wC(o){if(o instanceof URL)return o.href;try{return new URL(o,window.location).href}catch{if(Pe&&typeof o=="string")return o}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function xC(o){if(Pe&&typeof Buffer<"u"&&o instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(o instanceof Uint8Array&&o.byteLength===o.buffer.byteLength)return o;if(typeof o=="string")return ud(o);if(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||typeof o=="object"&&!isNaN(o==null?void 0:o.length))return new Uint8Array(o);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function rb(o){return typeof o=="object"&&Number.isInteger(o==null?void 0:o.num)&&o.num>=0&&Number.isInteger(o==null?void 0:o.gen)&&o.gen>=0}const Id=class Id{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Ze(Id,Fd)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(n){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,n}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}};Fd=new WeakMap,y(Id,Fd,0);let Kg=Id;class ab{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Et("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class SC{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 ht(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()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}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 CC{constructor(t,e,s,i=!1){y(this,Bs);y(this,pr,null);y(this,_n,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Mv:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new ob,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}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:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new hl({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return ht(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=Yn.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:u=null,isEditing:d=!1}){var A,P;(A=this._stats)==null||A.time("Overall");const f=this._transport.getRenderingIntent(s,i,u,d),{renderingIntent:g,cacheKey:p}=f;m(this,_n,!1),w(this,Bs,of).call(this),a||(a=this._transport.getOptionalContentConfig(g));let v=this._intentStates.get(p);v||(v=Object.create(null),this._intentStates.set(p,v)),v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);const _=!!(g&fs.PRINT);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(P=this._stats)==null||P.time("Page Request"),this._pumpOperatorList(f));const b=D=>{var k;v.renderTasks.delete(x),(this._maybeCleanupAfterRender||_)&&m(this,_n,!0),w(this,Bs,jh).call(this,!_),D?(x.capability.reject(D),this._abortOperatorList({intentState:v,reason:D instanceof Error?D:new Error(D)})):x.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(k=globalThis.Stats)!=null&&k.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},x=new Jg({callback:b,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:c});(v.renderTasks||(v.renderTasks=new Set)).add(x);const C=x.task;return Promise.all([v.displayReadyCapability.promise,a]).then(([D,k])=>{var M;if(this.destroyed){b();return}if((M=this._stats)==null||M.time("Rendering"),!(k.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");x.initializeGraphics({transparency:D,optionalContentConfig:k}),x.operatorListChanged()}).catch(b),C}getOperatorList({intent:t="display",annotationMode:e=Yn.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;function n(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(h))}const r=this._transport.getRenderingIntent(t,e,s,i,!0);let a=this._intentStates.get(r.cacheKey);a||(a=Object.create(null),this._intentStates.set(r.cacheKey,a));let h;return a.opListReadCapability||(h=Object.create(null),h.operatorListChanged=n,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||(a.renderTasks=new Set)).add(h),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>gl.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){r.read().then(function({value:h,done:c}){if(c){s(a);return}a.lang??(a.lang=h.lang),Object.assign(a.styles,h.styles),a.items.push(...h.items),n()},i)}const r=e.getReader(),a={items:[],styles:Object.create(null),lang:null};n()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),m(this,_n,!1),w(this,Bs,of).call(this),Promise.all(t)}cleanup(t=!1){m(this,_n,!0);const e=w(this,Bs,jh).call(this,!1);return t&&e&&this._stats&&(this._stats=new Mv),e}_startRenderPage(t,e){var i,n;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(n=s.displayReadyCapability)==null||n.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&w(this,Bs,jh).call(this,!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:n,transfer:r}=s,h=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},r).getReader(),c=this._intentStates.get(e);c.streamReader=h;const u=()=>{h.read().then(({value:d,done:f})=>{if(f){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,c),u())},d=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();w(this,Bs,jh).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(d);else if(c.opListReadCapability)c.opListReadCapability.reject(d);else throw d}})};u()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Lg){let i=gC;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 qn(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}pr=new WeakMap,_n=new WeakMap,Bs=new WeakSet,jh=function(t=!1){if(w(this,Bs,of).call(this),!l(this,_n)||this.destroyed)return!1;if(t)return m(this,pr,setTimeout(()=>{m(this,pr,null),w(this,Bs,jh).call(this,!1)},pC)),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),m(this,_n,!1),!0},of=function(){l(this,pr)&&(clearTimeout(l(this,pr)),m(this,pr,null))};class AC{constructor(){y(this,wn,new Map);y(this,jd,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};l(this,jd).then(()=>{for(const[i]of l(this,wn))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:n}=s;if(n.aborted){rt("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}l(this,wn).set(e,i)}removeEventListener(t,e){const s=l(this,wn).get(e);s==null||s(),l(this,wn).delete(e)}terminate(){for(const[,t]of l(this,wn))t==null||t();l(this,wn).clear()}}wn=new WeakMap,jd=new WeakMap;const jt=class jt{constructor({name:t=null,port:e=null,verbosity:s=aS()}={}){y(this,Jo);var i;if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if((i=l(jt,Aa))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(l(jt,Aa)||m(jt,Aa,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new ul("main","worker",t),this._messageHandler.on("ready",function(){}),w(this,Jo,hf).call(this)}_initialize(){if(l(jt,Ca)||l(jt,Qo,lf)){this._setupFakeWorker();return}let{workerSrc:t}=jt;try{jt._isSameOrigin(window.location.href,t)||(t=jt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new ul("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{if(n.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,w(this,Jo,hf).call(this)}),s.on("ready",a=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{ld("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){l(jt,Ca)||(rt("Setting up fake worker."),m(jt,Ca,!0)),jt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new AC;this._port=e;const s=`fake${Ze(jt,Nd)._++}`,i=new ul(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new ul(s,s+"_worker",e),w(this,Jo,hf).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t,e,s;this.destroyed=!0,(t=this._webWorker)==null||t.terminate(),this._webWorker=null,(e=l(jt,Aa))==null||e.delete(this._port),this._port=null,(s=this._messageHandler)==null||s.destroy(),this._messageHandler=null}static fromPort(t){var s;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const e=(s=l(this,Aa))==null?void 0:s.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new jt(t)}static get workerSrc(){if(rn.workerSrc)return rn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return ht(this,"_setupFakeWorkerGlobal",(async()=>l(this,Qo,lf)?l(this,Qo,lf):(await import(this.workerSrc)).WorkerMessageHandler)())}};Nd=new WeakMap,Ca=new WeakMap,Aa=new WeakMap,Jo=new WeakSet,hf=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Qo=new WeakSet,lf=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},y(jt,Qo),y(jt,Nd,0),y(jt,Ca,!1),y(jt,Aa),Pe&&(m(jt,Ca,!0),rn.workerSrc||(rn.workerSrc="./pdf.worker.mjs")),jt._isSameOrigin=(t,e)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch{return!1}const i=new URL(e,s);return s.origin===i.origin},jt._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let Co=jt;class TC{constructor(t,e,s,i,n){y(this,Ta);y(this,xn,new Map);y(this,Ii,new Map);y(this,Zo,new Map);y(this,th,new Map);y(this,Sn,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new ob,this.fontLoader=new AS({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return ht(this,"annotationStorage",new Wg)}getRenderingIntent(t,e=Yn.ENABLE,s=null,i=!1,n=!1){let r=fs.DISPLAY,a=Vg;switch(t){case"any":r=fs.ANY;break;case"display":break;case"print":r=fs.PRINT;break;default:rt(`getRenderingIntent - invalid intent: ${t}`)}const h=r&fs.PRINT&&s instanceof Rv?s:this.annotationStorage;switch(e){case Yn.DISABLE:r+=fs.ANNOTATIONS_DISABLE;break;case Yn.ENABLE:break;case Yn.ENABLE_FORMS:r+=fs.ANNOTATIONS_FORMS;break;case Yn.ENABLE_STORAGE:r+=fs.ANNOTATIONS_STORAGE,a=h.serializable;break;default:rt(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(r+=fs.IS_EDITING),n&&(r+=fs.OPLIST);const{ids:c,hash:u}=h.modifiedIds,d=[r,a.hash,u];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=l(this,Sn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of l(this,Ii).values())t.push(i._destroy());l(this,Ii).clear(),l(this,Zo).clear(),l(this,th).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,n;this.commonObjs.clear(),this.fontLoader.clear(),l(this,xn).clear(),this.filterFactory.destroy(),fl.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new qn("Worker was terminated.")),(n=this.messageHandler)==null||n.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{ee(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){i.close();return}ee(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",async s=>{var a;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:n,contentLength:r}=this._fullReader;return(!i||!n)&&(this._lastProgress&&((a=e.onProgress)==null||a.call(e,this._lastProgress)),this._fullReader.onProgress=h=>{var c;(c=e.onProgress)==null||c.call(e,{loaded:h.loaded,total:h.total})}),{isStreamingSupported:i,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(s,i)=>{ee(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}ee(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new SC(s,this))}),t.on("DocException",s=>{e._capability.reject(is(s))}),t.on("PasswordRequest",s=>{m(this,Sn,Promise.withResolvers());try{if(!e.onPassword)throw is(s);const i=n=>{n instanceof Error?l(this,Sn).reject(n):l(this,Sn).resolve({password:n})};e.onPassword(i,s.code)}catch(i){l(this,Sn).reject(i)}return l(this,Sn).promise}),t.on("DataLoaded",s=>{var i;(i=e.onProgress)==null||i.call(e,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;l(this,Ii).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{var r;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:a,fontExtraProperties:h,pdfBug:c}=this._params;if("error"in n){const g=n.error;rt(`Error during font loading: ${g}`),this.commonObjs.resolve(s,g);break}const u=c&&((r=globalThis.FontInspector)!=null&&r.enabled)?(g,p)=>globalThis.FontInspector.fontAdded(g,p):null,d=new TS(n,{disableFontFace:a,fontExtraProperties:h,inspectFont:u});this.fontLoader.bind(d).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!h&&d.data&&(d.data=null),this.commonObjs.resolve(s,d)});break;case"CopyLocalImage":const{imageRef:f}=n;ee(f,"The imageRef must be defined.");for(const g of l(this,Ii).values())for(const[,p]of g.objs)if((p==null?void 0:p.ref)===f)return p.dataLen?(this.commonObjs.resolve(s,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{var h;if(this.destroyed)return;const a=l(this,Ii).get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){(h=r==null?void 0:r.bitmap)==null||h.close();return}switch(n){case"Image":a.objs.resolve(s,r),(r==null?void 0:r.dataLen)>eS&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(s)}),t.on("FetchStandardFontData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&rt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=this._fullReader)==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=l(this,Zo).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&l(this,th).set(n.refStr,t);const r=new CC(e,n,this,this._params.pdfBug);return l(this,Ii).set(e,r),r});return l(this,Zo).set(e,i),i}getPageIndex(t){return rb(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return w(this,Ta,Qc).call(this,"GetFieldObjects")}hasJSActions(){return w(this,Ta,Qc).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return w(this,Ta,Qc).call(this,"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 w(this,Ta,Qc).call(this,"GetOptionalContentConfig").then(e=>new $S(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=l(this,xn).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var n,r;return{info:i[0],metadata:i[1]?new US(i[1]):null,contentDispositionFilename:((n=this._fullReader)==null?void 0:n.filename)??null,contentLength:((r=this._fullReader)==null?void 0:r.contentLength)??null}});return l(this,xn).set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of l(this,Ii).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),l(this,xn).clear(),this.filterFactory.destroy(!0),fl.cleanup()}}cachedPageNumber(t){if(!rb(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return l(this,th).get(e)??null}}xn=new WeakMap,Ii=new WeakMap,Zo=new WeakMap,th=new WeakMap,Sn=new WeakMap,Ta=new WeakSet,Qc=function(t,e=null){const s=l(this,xn).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return l(this,xn).set(t,i),i};const pl=Symbol("INITIAL_DATA");class ob{constructor(){y(this,oc);y(this,ys,Object.create(null))}get(t,e=null){if(e){const i=w(this,oc,Up).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=l(this,ys)[t];if(!s||s.data===pl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=l(this,ys)[t];return!!e&&e.data!==pl}delete(t){const e=l(this,ys)[t];return!e||e.data===pl?!1:(delete l(this,ys)[t],!0)}resolve(t,e=null){const s=w(this,oc,Up).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in l(this,ys)){const{data:s}=l(this,ys)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}m(this,ys,Object.create(null))}*[Symbol.iterator](){for(const t in l(this,ys)){const{data:e}=l(this,ys)[t];e!==pl&&(yield[t,e])}}}ys=new WeakMap,oc=new WeakSet,Up=function(t){var e;return(e=l(this,ys))[t]||(e[t]={...Promise.withResolvers(),data:pl})};class EC{constructor(t){y(this,mr,null);m(this,mr,t),this.onContinue=null}get promise(){return l(this,mr).capability.promise}cancel(t=0){l(this,mr).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=l(this,mr).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=l(this,mr);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}mr=new WeakMap;const ka=class ka{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:h,filterFactory:c,useRequestAnimationFrame:u=!1,pdfBug:d=!1,pageColors:f=null}){y(this,vr,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=h,this.filterFactory=c,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=u===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new EC(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.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var a,h;if(this.cancelled)return;if(this._canvas){if(l(ka,Ea).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");l(ka,Ea).add(this._canvas)}this._pdfBug&&((a=globalThis.StepperManager)!=null&&a.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new xo(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),l(this,vr)&&(window.cancelAnimationFrame(l(this,vr)),m(this,vr,null)),l(ka,Ea).delete(this._canvas),this.callback(t||new Lg(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){var t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.stepper)==null||t.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?m(this,vr,window.requestAnimationFrame(()=>{m(this,vr,null),this._nextBound().catch(this._cancelBound)})):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.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),l(ka,Ea).delete(this._canvas),this.callback())))}};vr=new WeakMap,Ea=new WeakMap,y(ka,Ea,new WeakSet);let Jg=ka;const kC="4.10.38",PC="f9bea397f";function hb(o){return Math.floor(Math.max(0,Math.min(1,o))*255).toString(16).padStart(2,"0")}function ml(o){return Math.max(0,Math.min(255,255*o))}class lb{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=ml(t),[t,t,t]}static G_HTML([t]){const e=hb(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(ml)}static RGB_HTML(t){return`#${t.map(hb).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[ml(1-Math.min(1,t+i)),ml(1-Math.min(1,s+i)),ml(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}}class MC{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Et("Abstract method `_createSVG` called.")}}class Qg extends MC{_createSVG(t){return document.createElementNS(nn,t)}}class cb{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const h=a.target.options,c=h.selectedIndex===-1?"":h[h.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[h,c]of Object.entries(r))if(c!=null)switch(h){case"class":c.length&&t.setAttribute(h,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!a||h!=="href"&&h!=="newWindow")&&t.setAttribute(h,c)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){var d,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",h=t.div;if(h.append(r),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=g}a&&h.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);r.append(g),a&&gl.shouldBuildText(i.name)&&c.push(g)}return{textDivs:c}}const u=[[i,-1,r]];for(;u.length>0;){const[g,p,v]=u.at(-1);if(p+1===g.children.length){u.pop();continue}const _=g.children[++u.at(-1)[1]];if(_===null)continue;const{name:b}=_;if(b==="#text"){const C=document.createTextNode(_.value);c.push(C),v.append(C);continue}const x=(d=_==null?void 0:_.attributes)!=null&&d.xmlns?document.createElementNS(_.attributes.xmlns,b):document.createElement(b);if(v.append(x),_.attributes&&this.setAttributes({html:x,element:_,storage:e,intent:n,linkService:s}),((f=_.children)==null?void 0:f.length)>0)u.push([_,-1,x]);else if(_.value){const C=document.createTextNode(_.value);a&&gl.shouldBuildText(b)&&c.push(C),x.append(C)}}for(const g of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const vl=1e3,OC=9,Ur=new WeakSet;function Jn(o){return{width:o[2]-o[0],height:o[3]-o[1]}}class DC{static create(t){switch(t.data.annotationType){case oe.LINK:return new ub(t);case oe.TEXT:return new RC(t);case oe.WIDGET:switch(t.data.fieldType){case"Tx":return new LC(t);case"Btn":return t.data.radioButton?new db(t):t.data.checkBox?new IC(t):new jC(t);case"Ch":return new NC(t);case"Sig":return new FC(t)}return new Yr(t);case oe.POPUP:return new Zg(t);case oe.FREETEXT:return new fb(t);case oe.LINE:return new HC(t);case oe.SQUARE:return new GC(t);case oe.CIRCLE:return new VC(t);case oe.POLYLINE:return new gb(t);case oe.CARET:return new zC(t);case oe.INK:return new tp(t);case oe.POLYGON:return new WC(t);case oe.HIGHLIGHT:return new pb(t);case oe.UNDERLINE:return new XC(t);case oe.SQUIGGLY:return new UC(t);case oe.STRIKEOUT:return new YC(t);case oe.STAMP:return new mb(t);case oe.FILEATTACHMENT:return new $C(t);default:return new qt(t)}}}const fp=class fp{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){y(this,hc);y(this,Pa,null);y(this,eh,!1);y(this,sh,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t!=null&&t.str||e!=null&&e.str||s!=null&&s.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return fp._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;l(this,Pa)||m(this,Pa,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&w(this,hc,Yp).call(this,e),(s=l(this,sh))==null||s.popup.updateEdited(t)}resetEdited(){var t;l(this,Pa)&&(w(this,hc,Yp).call(this,l(this,Pa).rect),(t=l(this,sh))==null||t.popup.resetEdited(),m(this,Pa,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Yr||(n.tabIndex=vl);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Zg){const{rotation:v}=e;return!e.hasOwnCanvas&&v!==0&&this.setRotation(v,n),n}const{width:a,height:h}=Jn(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const v=e.borderStyle.horizontalCornerRadius,_=e.borderStyle.verticalCornerRadius;if(v>0||_>0){const x=`calc(${v}px * var(--scale-factor)) / calc(${_}px * var(--scale-factor))`;r.borderRadius=x}else if(this instanceof db){const x=`calc(${a}px * var(--scale-factor)) / calc(${h}px * var(--scale-factor))`;r.borderRadius=x}switch(e.borderStyle.style){case al.SOLID:r.borderStyle="solid";break;case al.DASHED:r.borderStyle="dashed";break;case al.BEVELED:rt("Unimplemented border style: beveled");break;case al.INSET:rt("Unimplemented border style: inset");break;case al.UNDERLINE:r.borderBottomStyle="solid";break}const b=e.borderColor||null;b?(m(this,eh,!0),r.borderColor=q.makeHexColor(b[0]|0,b[1]|0,b[2]|0)):r.borderWidth=0}const c=q.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:u,pageHeight:d,pageX:f,pageY:g}=i.rawDims;r.left=`${100*(c[0]-f)/u}%`,r.top=`${100*(c[1]-g)/d}%`;const{rotation:p}=e;return e.hasOwnCanvas||p===0?(r.width=`${100*a/u}%`,r.height=`${100*h/d}%`):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=Jn(this.data.rect);let a,h;t%180===0?(a=100*n/s,h=100*r/i):(a=100*r/s,h=100*n/i),e.style.width=`${a}%`,e.style.height=`${h}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=lb[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:lb[`${r}_rgb`](a)})};return ht(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];n==null||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const r=s[i];if(r){const a={detail:{[i]:n},target:t};r(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(v=>Math.fround(v));if(t.length===8){const[v,_,b,x]=t.subarray(2,6);if(i===v&&n===_&&e===b&&s===x)return}const{style:r}=this.container;let a;if(l(this,eh)){const{borderColor:v,borderWidth:_}=r;r.borderWidth=0,a=["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="${v}" stroke-width="${_}">`],this.container.classList.add("hasBorder")}const h=i-e,c=n-s,{svgFactory:u}=this,d=u.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const f=u.createElement("defs");d.append(f);const g=u.createElement("clipPath"),p=`clippath_${this.data.id}`;g.setAttribute("id",p),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let v=2,_=t.length;v<_;v+=8){const b=t[v],x=t[v+1],C=t[v+2],A=t[v+3],P=u.createElement("rect"),D=(C-e)/h,k=(n-x)/c,M=(b-C)/h,R=(x-A)/c;P.setAttribute("x",D),P.setAttribute("y",k),P.setAttribute("width",M),P.setAttribute("height",R),g.append(P),a==null||a.push(`<rect vector-effect="non-scaling-stroke" x="${D}" y="${k}" width="${M}" height="${R}"/>`)}l(this,eh)&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=m(this,sh,new Zg({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){Et("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:r,exportValues:a}of i){if(n===-1||r===e)continue;const h=typeof a=="string"?a:null,c=document.querySelector(`[data-element-id="${r}"]`);if(c&&!Ur.has(c)){rt(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:h,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==e&&Ur.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}};Pa=new WeakMap,eh=new WeakMap,sh=new WeakMap,hc=new WeakSet,Yp=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:h}}}}=this;s==null||s.splice(0,4,...t);const{width:c,height:u}=Jn(t);e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+h)/r}%`,i===0?(e.width=`${100*c/n}%`,e.height=`${100*u/r}%`):this.setRotation(i)};let qt=fp;class ub extends qt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});y(this,_s);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let n=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),n=!0):e.action?(this._bindNamedAction(i,e.action),n=!0):e.attachment?(w(this,_s,_y).call(this,i,e.attachment,e.attachmentDest),n=!0):e.setOCGState?(w(this,_s,wy).call(this,i,e.setOCGState),n=!0):e.dest?(this._bindLink(i,e.dest),n=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),n=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(i),this.container}_bindLink(e,s){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&w(this,_s,so).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),w(this,_s,so).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(s.actions)){const r=i.get(n);r&&(e[r]=()=>{var a;return(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:n}}),!1})}e.onclick||(e.onclick=()=>!1),w(this,_s,so).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),w(this,_s,so).call(this),!this._fieldObjects){rt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var d;i==null||i();const{fields:n,refs:r,include:a}=s,h=[];if(n.length!==0||r.length!==0){const f=new Set(r);for(const g of n){const p=this._fieldObjects[g]||[];for(const{id:v}of p)f.add(v)}for(const g of Object.values(this._fieldObjects))for(const p of g)f.has(p.id)===a&&h.push(p)}else for(const f of Object.values(this._fieldObjects))h.push(...f);const c=this.annotationStorage,u=[];for(const f of h){const{id:g}=f;switch(u.push(g),f.type){case"text":{const v=f.defaultValue||"";c.setValue(g,{value:v});break}case"checkbox":case"radiobutton":{const v=f.defaultValue===f.exportValues;c.setValue(g,{value:v});break}case"combobox":case"listbox":{const v=f.defaultValue||"";c.setValue(g,{value:v});break}default:continue}const p=document.querySelector(`[data-element-id="${g}"]`);if(p){if(!Ur.has(p)){rt(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;p.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:u,name:"ResetForm"}})),!1}}}_s=new WeakSet,so=function(){this.container.setAttribute("data-internal-link","")},_y=function(e,s,i=null){e.href=this.linkService.getAnchorUrl(""),s.description&&(e.title=s.description),e.onclick=()=>{var n;return(n=this.downloadManager)==null||n.openOrDownloadData(s.content,s.filename,i),!1},w(this,_s,so).call(this)},wy=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),w(this,_s,so).call(this)};class RC extends qt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Yr extends qt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ze.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,r=>{var a;(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{var a;if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&((a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}}))})}_setEventListeners(t,e,s,i){var n,r,a;for(const[h,c]of s)(c==="Action"||(n=this.data.actions)!=null&&n[c])&&((c==="Focus"||c==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,h,c,i),c==="Focus"&&!((r=this.data.actions)!=null&&r.Blur)?this._setEventListener(t,e,"blur","Blur",null):c==="Blur"&&!((a=this.data.actions)!=null&&a.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":q.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||OC,n=t.style;let r;const a=2,h=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a),u=Math.round(c/(Eg*i))||1,d=c/u;r=Math.min(i,h(d/Eg))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(i,h(c/Eg))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=q.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class LC extends Yr{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){var i,n;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const r=t.getValue(e,{value:this.data.fieldValue});let a=r.value||"";const h=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;h&&a.length>h&&(a=a.slice(0,h));let c=r.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
|
|
529
|
-
`))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const u={userValue:a,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??a,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",c??a),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Ur.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=vl,this._setRequired(s,this.data.required),h&&(s.maxLength=h),s.addEventListener("input",f=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),u.formattedValue=null}),s.addEventListener("resetform",f=>{const g=this.data.defaultFieldValue??"";s.value=u.userValue=g,u.formattedValue=null});let d=f=>{const{formattedValue:g}=u;g!=null&&(f.target.value=g),f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{var v;if(u.focused)return;const{target:p}=g;u.userValue&&(p.value=u.userValue),u.lastCommittedValue=p.value,u.commitKey=1,(v=this.data.actions)!=null&&v.Focus||(u.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);const p={value(v){u.userValue=v.detail.value??"",t.setValue(e,{value:u.userValue.toString()}),v.target.value=u.userValue},formattedValue(v){const{formattedValue:_}=v.detail;u.formattedValue=_,_!=null&&v.target!==document.activeElement&&(v.target.value=_),t.setValue(e,{formattedValue:_})},selRange(v){v.target.setSelectionRange(...v.detail.selRange)},charLimit:v=>{var C;const{charLimit:_}=v.detail,{target:b}=v;if(_===0){b.removeAttribute("maxLength");return}b.setAttribute("maxLength",_);let x=u.userValue;!x||x.length<=_||(x=x.slice(0,_),b.value=u.userValue=x,t.setValue(e,{value:x}),(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:x,willCommit:!0,commitKey:1,selStart:b.selectionStart,selEnd:b.selectionEnd}}))}};this._dispatchEventFromSandbox(p,g)}),s.addEventListener("keydown",g=>{var _;u.commitKey=1;let p=-1;if(g.key==="Escape"?p=0:g.key==="Enter"&&!this.data.multiLine?p=2:g.key==="Tab"&&(u.commitKey=3),p===-1)return;const{value:v}=g.target;u.lastCommittedValue!==v&&(u.lastCommittedValue=v,u.userValue=v,(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:p,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const f=d;d=null,s.addEventListener("blur",g=>{var v,_;if(!u.focused||!g.relatedTarget)return;(v=this.data.actions)!=null&&v.Blur||(u.focused=!1);const{value:p}=g.target;u.userValue=p,u.lastCommittedValue!==p&&((_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:p,willCommit:!0,commitKey:u.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}})),f(g)}),(n=this.data.actions)!=null&&n.Keystroke&&s.addEventListener("beforeinput",g=>{var P;u.lastCommittedValue=null;const{data:p,target:v}=g,{value:_,selectionStart:b,selectionEnd:x}=v;let C=b,A=x;switch(g.inputType){case"deleteWordBackward":{const D=_.substring(0,b).match(/\w*[^\w]*$/);D&&(C-=D[0].length);break}case"deleteWordForward":{const D=_.substring(b).match(/^[^\w]*\w*/);D&&(A+=D[0].length);break}case"deleteContentBackward":b===x&&(C-=1);break;case"deleteContentForward":b===x&&(A+=1);break}g.preventDefault(),(P=this.linkService.eventBus)==null||P.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:p||"",willCommit:!1,selStart:C,selEnd:A}})}),this._setEventListeners(s,u,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(d&&s.addEventListener("blur",d),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/h;s.classList.add("comb"),s.style.letterSpacing=`calc(${g}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class FC extends Yr{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class IC extends Yr{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ur.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=vl,n.addEventListener("change",r=>{const{name:a,checked:h}=r.target;for(const c of this._getElementsByName(a,s)){const u=h&&c.exportValue===e.exportValue;c.domElement&&(c.domElement.checked=u),t.setValue(c.id,{value:u})}t.setValue(s,{value:h})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{const a={value(h){h.target.checked=h.detail.value!=="Off",t.setValue(s,{value:h.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class db extends Yr{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(Ur.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=vl,n.addEventListener("change",r=>{const{name:a,checked:h}=r.target;for(const c of this._getElementsByName(a,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:h})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{const h={value:c=>{const u=r===c.detail.value;for(const d of this._getElementsByName(c.target.name)){const f=u&&d.id===s;d.domElement&&(d.domElement.checked=f),t.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(h,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class jC extends ub{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class NC extends Yr{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Ur.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=vl;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",u=>{const d=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===d});for(const u of this.data.options){const d=document.createElement("option");d.textContent=u.displayValue,d.value=u.exportValue,s.value.includes(u.exportValue)&&(d.setAttribute("selected",!0),n=!1),i.append(d)}let r=null;if(n){const u=document.createElement("option");u.value=" ",u.setAttribute("hidden",!0),u.setAttribute("selected",!0),i.prepend(u),r=()=>{u.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}const a=u=>{const d=u?"value":"textContent",{options:f,multiple:g}=i;return g?Array.prototype.filter.call(f,p=>p.selected).map(p=>p[d]):f.selectedIndex===-1?null:f[f.selectedIndex][d]};let h=a(!1);const c=u=>{const d=u.target.options;return Array.prototype.map.call(d,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",u=>{const d={value(f){r==null||r();const g=f.detail.value,p=new Set(Array.isArray(g)?g:[g]);for(const v of i.options)v.selected=p.has(v.value);t.setValue(e,{value:a(!0)}),h=a(!1)},multipleSelection(f){i.multiple=!0},remove(f){const g=i.options,p=f.detail.remove;g[p].selected=!1,i.remove(p),g.length>0&&Array.prototype.findIndex.call(g,_=>_.selected)===-1&&(g[0].selected=!0),t.setValue(e,{value:a(!0),items:c(f)}),h=a(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),h=a(!1)},insert(f){const{index:g,displayValue:p,exportValue:v}=f.detail.insert,_=i.children[g],b=document.createElement("option");b.textContent=p,b.value=v,_?_.before(b):i.append(b),t.setValue(e,{value:a(!0),items:c(f)}),h=a(!1)},items(f){const{items:g}=f.detail;for(;i.length!==0;)i.remove(0);for(const p of g){const{displayValue:v,exportValue:_}=p,b=document.createElement("option");b.textContent=v,b.value=_,i.append(b)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:c(f)}),h=a(!1)},indices(f){const g=new Set(f.detail.indices);for(const p of f.target.options)p.selected=g.has(p.index);t.setValue(e,{value:a(!0)}),h=a(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(d,u)}),i.addEventListener("input",u=>{var g;const d=a(!0),f=a(!1);t.setValue(e,{value:d}),u.preventDefault(),(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:h,change:f,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],u=>u.target.value)):i.addEventListener("input",function(u){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Zg extends qt{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:qt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new BC({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,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}),e=[];for(const s of this.elements)s.popup=t,s.container.ariaHasPopup="dialog",e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${Rg}${s}`).join(",")),this.container}}class BC{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:h,rect:c,parentRect:u,open:d}){y(this,Ct);y(this,ih,w(this,Ct,Cy).bind(this));y(this,Bd,w(this,Ct,qp).bind(this));y(this,Hd,w(this,Ct,df).bind(this));y(this,nh,w(this,Ct,uf).bind(this));y(this,Ma,null);y(this,Xt,null);y(this,Cn,null);y(this,rh,null);y(this,lc,null);y(this,cc,null);y(this,ah,null);y(this,An,!1);y(this,ci,null);y(this,Tn,null);y(this,uc,null);y(this,En,null);y(this,dc,null);y(this,Oa,null);y(this,Da,!1);var f;m(this,Xt,t),m(this,dc,i),m(this,Cn,r),m(this,En,a),m(this,cc,h),m(this,Ma,e),m(this,uc,c),m(this,ah,u),m(this,lc,s),m(this,rh,Ig.toDateObject(n)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",l(this,nh)),g.addEventListener("mouseenter",l(this,Hd)),g.addEventListener("mouseleave",l(this,Bd)),g.classList.add("popupTriggerArea");for(const g of s)(f=g.container)==null||f.addEventListener("keydown",l(this,ih));l(this,Xt).hidden=!0,d&&w(this,Ct,uf).call(this)}render(){if(l(this,ci))return;const t=m(this,ci,document.createElement("div"));if(t.className="popup",l(this,Ma)){const n=t.style.outlineColor=q.makeHexColor(...l(this,Ma));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=q.makeHexColor(...l(this,Ma).map(a=>Math.floor(.7*(255-a)+a)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=l(this,dc),t.append(e),l(this,rh)){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),n.setAttribute("data-l10n-args",JSON.stringify({dateObj:l(this,rh).valueOf()})),e.append(n)}const i=l(this,Ct,cf);if(i)cb.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(l(this,Cn));t.append(n)}l(this,Xt).append(t)}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let n=0,r=i.length;n<r;++n){const a=i[n];s.append(document.createTextNode(a)),n<r-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:t,popupContent:e}){var s;l(this,Oa)||m(this,Oa,{contentsObj:l(this,Cn),richText:l(this,En)}),t&&m(this,Tn,null),e&&(m(this,En,w(this,Ct,Sy).call(this,e)),m(this,Cn,null)),(s=l(this,ci))==null||s.remove(),m(this,ci,null)}resetEdited(){var t;l(this,Oa)&&({contentsObj:Ze(this,Cn)._,richText:Ze(this,En)._}=l(this,Oa),m(this,Oa,null),(t=l(this,ci))==null||t.remove(),m(this,ci,null),m(this,Tn,null))}forceHide(){m(this,Da,this.isVisible),l(this,Da)&&(l(this,Xt).hidden=!0)}maybeShow(){l(this,Da)&&(l(this,ci)||w(this,Ct,df).call(this),m(this,Da,!1),l(this,Xt).hidden=!1)}get isVisible(){return l(this,Xt).hidden===!1}}ih=new WeakMap,Bd=new WeakMap,Hd=new WeakMap,nh=new WeakMap,Ma=new WeakMap,Xt=new WeakMap,Cn=new WeakMap,rh=new WeakMap,lc=new WeakMap,cc=new WeakMap,ah=new WeakMap,An=new WeakMap,ci=new WeakMap,Tn=new WeakMap,uc=new WeakMap,En=new WeakMap,dc=new WeakMap,Oa=new WeakMap,Da=new WeakMap,Ct=new WeakSet,cf=function(){const t=l(this,En),e=l(this,Cn);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&l(this,En).html||null},$p=function(){var t,e,s;return((s=(e=(t=l(this,Ct,cf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},xy=function(){var t,e,s;return((s=(e=(t=l(this,Ct,cf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},Sy=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:l(this,Ct,xy),fontSize:l(this,Ct,$p)?`calc(${l(this,Ct,$p)}px * var(--scale-factor))`:""}};for(const n of t.split(`
|
|
530
|
-
`))e.push({name:"span",value:n,attributes:i});return s},Cy=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&l(this,An))&&w(this,Ct,uf).call(this)},Ay=function(){if(l(this,Tn)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=l(this,cc);let r=!!l(this,ah),a=r?l(this,ah):l(this,uc);for(const p of l(this,lc))if(!a||q.intersect(p.data.rect,a)!==null){a=p.data.rect,r=!0;break}const h=q.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),u=r?a[2]-a[0]+5:0,d=h[0]+u,f=h[1];m(this,Tn,[100*(d-i)/e,100*(f-n)/s]);const{style:g}=l(this,Xt);g.left=`${l(this,Tn)[0]}%`,g.top=`${l(this,Tn)[1]}%`},uf=function(){m(this,An,!l(this,An)),l(this,An)?(w(this,Ct,df).call(this),l(this,Xt).addEventListener("click",l(this,nh)),l(this,Xt).addEventListener("keydown",l(this,ih))):(w(this,Ct,qp).call(this),l(this,Xt).removeEventListener("click",l(this,nh)),l(this,Xt).removeEventListener("keydown",l(this,ih)))},df=function(){l(this,ci)||this.render(),this.isVisible?l(this,An)&&l(this,Xt).classList.add("focused"):(w(this,Ct,Ay).call(this),l(this,Xt).hidden=!1,l(this,Xt).style.zIndex=parseInt(l(this,Xt).style.zIndex)+1e3)},qp=function(){l(this,Xt).classList.remove("focused"),!(l(this,An)||!this.isVisible)&&(l(this,Xt).hidden=!0,l(this,Xt).style.zIndex=parseInt(l(this,Xt).style.zIndex)-1e3)};class fb extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=nt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class HC extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,fc,null)}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:s,height:i}=Jn(e.rect),n=this.svgFactory.create(s,i,!0),r=m(this,fc,this.svgFactory.createElement("svg:line"));return r.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),r.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),r.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),r.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),r.setAttribute("stroke-width",e.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),n.append(r),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return l(this,fc)}addHighlightArea(){this.container.classList.add("highlightArea")}}fc=new WeakMap;class GC extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,gc,null)}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:s,height:i}=Jn(e.rect),n=this.svgFactory.create(s,i,!0),r=e.borderStyle.width,a=m(this,gc,this.svgFactory.createElement("svg:rect"));return a.setAttribute("x",r/2),a.setAttribute("y",r/2),a.setAttribute("width",s-r),a.setAttribute("height",i-r),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return l(this,gc)}addHighlightArea(){this.container.classList.add("highlightArea")}}gc=new WeakMap;class VC extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,pc,null)}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:s,height:i}=Jn(e.rect),n=this.svgFactory.create(s,i,!0),r=e.borderStyle.width,a=m(this,pc,this.svgFactory.createElement("svg:ellipse"));return a.setAttribute("cx",s/2),a.setAttribute("cy",i/2),a.setAttribute("rx",s/2-r/2),a.setAttribute("ry",i/2-r/2),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return l(this,pc)}addHighlightArea(){this.container.classList.add("highlightArea")}}pc=new WeakMap;class gb extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,mc,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:n}}=this;if(!s)return this.container;const{width:r,height:a}=Jn(e),h=this.svgFactory.create(r,a,!0);let c=[];for(let d=0,f=s.length;d<f;d+=2){const g=s[d]-e[0],p=e[3]-s[d+1];c.push(`${g},${p}`)}c=c.join(" ");const u=m(this,mc,this.svgFactory.createElement(this.svgElementName));return u.setAttribute("points",c),u.setAttribute("stroke-width",i.width||1),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),h.append(u),this.container.append(h),!n&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return l(this,mc)}addHighlightArea(){this.container.classList.add("highlightArea")}}mc=new WeakMap;class WC extends gb{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class zC extends qt{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 tp extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,bc);y(this,vc,null);y(this,Ra,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?nt.HIGHLIGHT:nt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:i,borderStyle:n,popupRef:r}}=this,{transform:a,width:h,height:c}=w(this,bc,Kp).call(this,s,e),u=this.svgFactory.create(h,c,!0),d=m(this,vc,this.svgFactory.createElement("svg:g"));u.append(d),d.setAttribute("stroke-width",n.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",a);for(let f=0,g=i.length;f<g;f++){const p=this.svgFactory.createElement(this.svgElementName);l(this,Ra).push(p),p.setAttribute("points",i[f].join(",")),d.append(p)}return!r&&this.hasPopupData&&this._createPopup(),this.container.append(u),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:i,rect:n}=e,r=l(this,vc);if(s>=0&&r.setAttribute("stroke-width",s||1),i)for(let a=0,h=l(this,Ra).length;a<h;a++)l(this,Ra)[a].setAttribute("points",i[a].join(","));if(n){const{transform:a,width:h,height:c}=w(this,bc,Kp).call(this,this.data.rotation,n);r.parentElement.setAttribute("viewBox",`0 0 ${h} ${c}`),r.setAttribute("transform",a)}}getElementsToTriggerPopup(){return l(this,Ra)}addHighlightArea(){this.container.classList.add("highlightArea")}}vc=new WeakMap,Ra=new WeakMap,bc=new WeakSet,Kp=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class pb extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=nt.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class XC extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class UC extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class YC extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class mb extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=nt.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 $C extends qt{constructor(e){var i;super(e,{isRenderable:!0});y(this,_c);y(this,yc,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(i=this.linkService.eventBus)==null||i.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",w(this,_c,Jp).bind(this)),m(this,yc,i);const{isMac:n}=ze.platform;return e.addEventListener("keydown",r=>{r.key==="Enter"&&(n?r.metaKey:r.ctrlKey)&&w(this,_c,Jp).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return l(this,yc)}addHighlightArea(){this.container.classList.add("highlightArea")}}yc=new WeakMap,_c=new WeakSet,Jp=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};class qC{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r,structTreeLayer:a}){y(this,Ia);y(this,wc,null);y(this,La,null);y(this,Fa,new Map);y(this,xc,null);this.div=t,m(this,wc,e),m(this,La,s),m(this,xc,a||null),this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return l(this,Fa).size>0}async render(t){var r;const{annotations:e}=t,s=this.div;zr(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Qg,annotationStorage:t.annotationStorage||new Wg,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const a of e){if(a.noHTML)continue;const h=a.annotationType===oe.POPUP;if(h){const d=i.get(a.id);if(!d)continue;n.elements=d}else{const{width:d,height:f}=Jn(a.rect);if(d<=0||f<=0)continue}n.data=a;const c=DC.create(n);if(!c.isRenderable)continue;if(!h&&a.popupRef){const d=i.get(a.popupRef);d?d.push(c):i.set(a.popupRef,[c])}const u=c.render();a.hidden&&(u.style.visibility="hidden"),await w(this,Ia,Ty).call(this,u,a.id),c._isEditable&&(l(this,Fa).set(c.data.id,c),(r=this._annotationEditorUIManager)==null||r.renderAnnotationElement(c))}w(this,Ia,Qp).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,zr(e,{rotation:t.rotation}),w(this,Ia,Qp).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(l(this,Fa).values())}getEditableAnnotation(t){return l(this,Fa).get(t)}}wc=new WeakMap,La=new WeakMap,Fa=new WeakMap,xc=new WeakMap,Ia=new WeakSet,Ty=async function(t,e){var r,a;const s=t.firstChild||t,i=s.id=`${Rg}${e}`,n=await((r=l(this,xc))==null?void 0:r.getAriaAttributes(i));if(n)for(const[h,c]of n)s.setAttribute(h,c);this.div.append(t),(a=l(this,wc))==null||a.moveElementInDOM(this.div,t,s,!1)},Qp=function(){if(!l(this,La))return;const t=this.div;for(const[e,s]of l(this,La)){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}l(this,La).clear()};const xd=/\r\n?|\n/g,Ot=class Ot extends Ht{constructor(e){super({...e,name:"freeTextEditor"});y(this,ie);y(this,ui);y(this,ws,"");y(this,Sc,`${this.id}-editor`);y(this,ja,null);y(this,xs);m(this,ui,e.color||Ot._defaultColor||Ht._defaultLineColor),m(this,xs,e.fontSize||Ot._defaultFontSize)}static get _keyboardManager(){const e=Ot.prototype,s=r=>r.isEmpty(),i=Xr.TRANSLATE_SMALL,n=Xr.TRANSLATE_BIG;return ht(this,"_keyboardManager",new cl([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:s}]]))}static initialize(e,s){Ht.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case dt.FREETEXT_SIZE:Ot._defaultFontSize=s;break;case dt.FREETEXT_COLOR:Ot._defaultColor=s;break}}updateParams(e,s){switch(e){case dt.FREETEXT_SIZE:w(this,ie,Ey).call(this,s);break;case dt.FREETEXT_COLOR:w(this,ie,ky).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[dt.FREETEXT_SIZE,Ot._defaultFontSize],[dt.FREETEXT_COLOR,Ot._defaultColor||Ht._defaultLineColor]]}get propertiesToUpdate(){return[[dt.FREETEXT_SIZE,l(this,xs)],[dt.FREETEXT_COLOR,l(this,ui)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-Ot._internalPadding*e,-(Ot._internalPadding+l(this,xs))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(nt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),m(this,ja,new AbortController);const e=this._uiManager.combinedSignal(l(this,ja));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){var e;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",l(this,Sc)),this._isDraggable=!0,(e=l(this,ja))==null||e.abort(),m(this,ja,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=l(this,ws),s=m(this,ws,w(this,ie,Py).call(this).trimEnd());if(e===s)return;const i=n=>{if(m(this,ws,n),!n){this.remove();return}w(this,ie,pf).call(this),this._uiManager.rebuild(this),w(this,ie,ff).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),w(this,ie,ff).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){Ot._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",l(this,Sc)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${l(this,xs)}px * var(--scale-factor))`,i.color=l(this,ui),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),gd(this,this.div,["dblclick","keydown"]),this.width){const[n,r]=this.parentDimensions;if(this.annotationElementId){const{position:a}=this._initialData;let[h,c]=this.getInitialTranslation();[h,c]=this.pageTranslationToScreen(h,c);const[u,d]=this.pageDimensions,[f,g]=this.pageTranslation;let p,v;switch(this.rotation){case 0:p=e+(a[0]-f)/u,v=s+this.height-(a[1]-g)/d;break;case 90:p=e+(a[0]-f)/u,v=s-(a[1]-g)/d,[h,c]=[c,-h];break;case 180:p=e-this.width+(a[0]-f)/u,v=s-(a[1]-g)/d,[h,c]=[-h,-c];break;case 270:p=e+(a[0]-f-this.height*d)/u,v=s+(a[1]-g-this.width*u)/d,[h,c]=[-c,h];break}this.setAt(p*n,v*r,h,c)}else this.setAt(e*n,s*r,this.width*n,this.height*r);w(this,ie,pf).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var p,v,_;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const n=w(p=Ot,kn,Zp).call(p,s.getData("text")||"").replaceAll(xd,`
|
|
527
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const s=-this.vibrance;for(let i=0;i<e.length;i+=4){const n=e[i],r=e[i+1],a=e[i+2],h=Math.max(n,r,a),c=(n+r+a)/3,u=2*Math.abs(h-c)/255*s;e[i]+=h!==n?(h-n)*u:0,e[i+1]+=h!==r?(h-r)*u:0,e[i+2]+=h!==a?(h-a)*u:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}E(rd,"type","Vibrance"),E(rd,"defaults",{vibrance:0}),E(rd,"uniformLocations",["uVibrance"]),G.setClass(rd);var nl={};nl.d=(o,t)=>{for(var e in t)nl.o(t,e)&&!nl.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:t[e]})},nl.o=(o,t)=>Object.prototype.hasOwnProperty.call(o,t);var Z=globalThis.pdfjsLib={};nl.d(Z,{AbortException:()=>qn,AnnotationEditorLayer:()=>hp,AnnotationEditorParamsType:()=>dt,AnnotationEditorType:()=>nt,AnnotationEditorUIManager:()=>Xr,AnnotationLayer:()=>OC,AnnotationMode:()=>Yn,ColorPicker:()=>Cd,DOMSVGFactory:()=>Qg,DrawLayer:()=>lp,FeatureTest:()=>ze,GlobalWorkerOptions:()=>rn,ImageKind:()=>ad,InvalidPDFException:()=>Pg,MissingPDFException:()=>al,OPS:()=>si,OutputScale:()=>Ng,PDFDataRangeTransport:()=>ib,PDFDateString:()=>Ig,PDFWorker:()=>Co,PasswordResponses:()=>Hx,PermissionFlag:()=>Bx,PixelsPerInch:()=>Kn,RenderingCancelledException:()=>Lg,TextLayer:()=>dl,TouchManager:()=>md,UnexpectedResponseException:()=>cd,Util:()=>q,VerbosityLevel:()=>od,XfaLayer:()=>ob,build:()=>uC,createValidAbsoluteUrl:()=>zx,fetchData:()=>dd,getDocument:()=>sC,getFilenameFromUrl:()=>Zx,getPdfFilenameFromUrl:()=>tS,getXfaPageViewport:()=>eS,isDataScheme:()=>fd,isPdfFile:()=>Fg,noContextMenu:()=>ii,normalizeUnicode:()=>Kx,setLayerDimensions:()=>zr,shadow:()=>ht,stopEvent:()=>gs,version:()=>cC});const Pe=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Sv=[1,0,0,1,0,0],Tg=[.001,0,0,.001,0,0],jx=1e7,Eg=1.35,fs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Yn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Nx="pdfjs_internal_editor_",nt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},dt={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_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Bx={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Me={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},ad={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},oe={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,WIDGET:20},rl={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},od={ERRORS:0,WARNINGS:1,INFOS:5},si={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},Hx={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let hd=od.WARNINGS;function Gx(o){Number.isInteger(o)&&(hd=o)}function Vx(){return hd}function ld(o){hd>=od.INFOS&&console.log(`Info: ${o}`)}function rt(o){hd>=od.WARNINGS&&console.log(`Warning: ${o}`)}function Et(o){throw new Error(o)}function ee(o,t){o||Et(t)}function Wx(o){switch(o==null?void 0:o.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function zx(o,t=null,e=null){if(!o)return null;try{if(e&&typeof o=="string"){if(e.addDefaultProtocol&&o.startsWith("www.")){const i=o.match(/\./g);(i==null?void 0:i.length)>=2&&(o=`http://${o}`)}if(e.tryConvertEncoding)try{o=qx(o)}catch{}}const s=t?new URL(o,t):new URL(o);if(Wx(s))return s}catch{}return null}function ht(o,t,e,s=!1){return Object.defineProperty(o,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const $n=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class Cv extends $n{constructor(t,e){super(t,"PasswordException"),this.code=e}}class kg extends $n{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Pg extends $n{constructor(t){super(t,"InvalidPDFException")}}class al extends $n{constructor(t){super(t,"MissingPDFException")}}class cd extends $n{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class Xx extends $n{constructor(t){super(t,"FormatError")}}class qn extends $n{constructor(t){super(t,"AbortException")}}function Av(o){(typeof o!="object"||(o==null?void 0:o.length)===void 0)&&Et("Invalid argument for bytesToString");const t=o.length,e=8192;if(t<e)return String.fromCharCode.apply(null,o);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),r=o.subarray(i,n);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function ud(o){typeof o!="string"&&Et("Invalid argument for stringToBytes");const t=o.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=o.charCodeAt(s)&255;return e}function Ux(o){return String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,o&255)}function Mg(o){const t=Object.create(null);for(const[e,s]of o)t[e]=s;return t}function Yx(){const o=new Uint8Array(4);return o[0]=1,new Uint32Array(o.buffer,0,1)[0]===1}function $x(){try{return new Function(""),!0}catch{return!1}}class ze{static get isLittleEndian(){return ht(this,"isLittleEndian",Yx())}static get isEvalSupported(){return ht(this,"isEvalSupported",$x())}static get isOffscreenCanvasSupported(){return ht(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return ht(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?ht(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):ht(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return ht(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Og=Array.from(Array(256).keys(),o=>o.toString(16).padStart(2,"0"));class q{static makeHexColor(t,e,s){return`#${Og[t]}${Og[e]}${Og[s]}`}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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 applyTransform(t,e){const s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2],i=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,n]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],r[0]),Math.min(s[1],i[1],n[1],r[1]),Math.max(s[0],i[0],n[0],r[0]),Math.max(s[1],i[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(s+r)/2,h=Math.sqrt((s+r)**2-4*(s*r-n*i))/2,c=a+h||1,u=a-h||1;return[Math.sqrt(c),Math.sqrt(u)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[s,n,i,r]}static bezierBoundingBox(t,e,s,i,n,r,a,h,c){return c?(c[0]=Math.min(c[0],t,a),c[1]=Math.min(c[1],e,h),c[2]=Math.max(c[2],t,a),c[3]=Math.max(c[3],e,h)):c=[Math.min(t,a),Math.min(e,h),Math.max(t,a),Math.max(e,h)],w(this,an,xp).call(this,t,s,n,a,e,i,r,h,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),c),w(this,an,xp).call(this,t,s,n,a,e,i,r,h,3*(-e+3*(i-r)+h),6*(e-2*i+r),3*(i-e),c),c}}an=new WeakSet,qd=function(t,e,s,i,n,r,a,h,c,u){if(c<=0||c>=1)return;const d=1-c,f=c*c,g=f*c,p=d*(d*(d*t+3*c*e)+3*f*s)+g*i,v=d*(d*(d*n+3*c*r)+3*f*a)+g*h;u[0]=Math.min(u[0],p),u[1]=Math.min(u[1],v),u[2]=Math.max(u[2],p),u[3]=Math.max(u[3],v)},xp=function(t,e,s,i,n,r,a,h,c,u,d,f){if(Math.abs(c)<1e-12){Math.abs(u)>=1e-12&&w(this,an,qd).call(this,t,e,s,i,n,r,a,h,-d/u,f);return}const g=u**2-4*d*c;if(g<0)return;const p=Math.sqrt(g),v=2*c;w(this,an,qd).call(this,t,e,s,i,n,r,a,h,(-u+p)/v,f),w(this,an,qd).call(this,t,e,s,i,n,r,a,h,(-u-p)/v,f)},y(q,an);function qx(o){return decodeURIComponent(escape(o))}let Dg=null,Tv=null;function Kx(o){return Dg||(Dg=/([\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,Tv=new Map([["ſt","ſt"]])),o.replaceAll(Dg,(t,e,s)=>e?e.normalize("NFKC"):Tv.get(s))}function Jx(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const o=new Uint8Array(32);return crypto.getRandomValues(o),Av(o)}const Rg="pdfjs_internal_id_";function Qx(o){return Uint8Array.prototype.toBase64?o.toBase64():btoa(Av(o))}typeof Promise.try!="function"&&(Promise.try=function(o,...t){return new Promise(e=>{e(o(...t))})});const nn="http://www.w3.org/2000/svg",$r=class $r{};J($r,"CSS",96),J($r,"PDF",72),J($r,"PDF_TO_CSS_UNITS",$r.CSS/$r.PDF);let Kn=$r;async function dd(o,t="text"){if(hl(o,document.baseURI)){const e=await fetch(o);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",o,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class ol{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;const h=(t[2]+t[0])/2,c=(t[3]+t[1])/2;let u,d,f,g;switch(i%=360,i<0&&(i+=360),i){case 180:u=-1,d=0,f=0,g=1;break;case 90:u=0,d=1,f=1,g=0;break;case 270:u=0,d=-1,f=-1,g=0;break;case 0:u=1,d=0,f=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(f=-f,g=-g);let p,v,_,b;u===0?(p=Math.abs(c-t[1])*s+n,v=Math.abs(h-t[0])*s+r,_=(t[3]-t[1])*s,b=(t[2]-t[0])*s):(p=Math.abs(h-t[0])*s+n,v=Math.abs(c-t[1])*s+r,_=(t[2]-t[0])*s,b=(t[3]-t[1])*s),this.transform=[u*s,d*s,f*s,g*s,p-u*s*h-f*s*c,v-d*s*h-g*s*c],this.width=_,this.height=b}get rawDims(){const{userUnit:t,viewBox:e}=this,s=e.map(i=>i*t);return ht(this,"rawDims",{pageWidth:s[2]-s[0],pageHeight:s[3]-s[1],pageX:s[0],pageY:s[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new ol({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return q.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=q.applyTransform([t[0],t[1]],this.transform),s=q.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return q.applyInverseTransform([t,e],this.transform)}}class Lg extends $n{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function fd(o){const t=o.length;let e=0;for(;e<t&&o[e].trim()==="";)e++;return o.substring(e,e+5).toLowerCase()==="data:"}function Fg(o){return typeof o=="string"&&/\.pdf$/i.test(o)}function Zx(o){return[o]=o.split(/[#?]/,1),o.substring(o.lastIndexOf("/")+1)}function tS(o,t="document.pdf"){if(typeof o!="string")return t;if(fd(o))return rt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=e.exec(o);let n=s.exec(i[1])||s.exec(i[2])||s.exec(i[3]);if(n&&(n=n[0],n.includes("%")))try{n=s.exec(decodeURIComponent(n))[0]}catch{}return n||t}class Ev{constructor(){J(this,"started",Object.create(null));J(this,"times",[])}time(t){t in this.started&&rt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||rt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms
|
|
528
|
+
`);return t.join("")}}function hl(o,t){try{const{protocol:e}=t?new URL(o,t):new URL(o);return e==="http:"||e==="https:"}catch{return!1}}function ii(o){o.preventDefault()}function gs(o){o.preventDefault(),o.stopPropagation()}class Ig{static toDateObject(t){if(!t||typeof t!="string")return null;l(this,bl)||m(this,bl,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=l(this,bl).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let h=parseInt(e[6],10);h=h>=0&&h<=59?h:0;const c=e[7]||"Z";let u=parseInt(e[8],10);u=u>=0&&u<=23?u:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,c==="-"?(r+=u,a+=d):c==="+"&&(r-=u,a-=d),new Date(Date.UTC(s,i,n,r,a,h))}}bl=new WeakMap,y(Ig,bl);function eS(o,{scale:t=1,rotation:e=0}){const{width:s,height:i}=o.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new ol({viewBox:n,userUnit:1,scale:t,rotation:e})}function jg(o){if(o.startsWith("#")){const t=parseInt(o.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return o.startsWith("rgb(")?o.slice(4,-1).split(",").map(t=>parseInt(t)):o.startsWith("rgba(")?o.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(rt(`Not a valid color format: "${o}"`),[0,0,0])}function sS(o){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of o.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;o.set(e,jg(s))}t.remove()}function It(o){const{a:t,b:e,c:s,d:i,e:n,f:r}=o.getTransform();return[t,e,s,i,n,r]}function Ai(o){const{a:t,b:e,c:s,d:i,e:n,f:r}=o.getTransform().invertSelf();return[t,e,s,i,n,r]}function zr(o,t,e=!1,s=!0){if(t instanceof ol){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:r}=o,a=ze.isCSSRoundSupported,h=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${n}px`,u=a?`round(down, ${h}, var(--scale-round-x, 1px))`:`calc(${h})`,d=a?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!e||t.rotation%180===0?(r.width=u,r.height=d):(r.width=d,r.height=u)}s&&o.setAttribute("data-main-rotation",t.rotation)}class Ng{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}}const on=class on{constructor(t){y(this,Xe);y(this,Qn,null);y(this,qr,null);y(this,ni);y(this,Kr,null);y(this,yl,null);m(this,ni,t),l(on,_l)||m(on,_l,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){const t=m(this,Qn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=l(this,ni)._uiManager._signal;t.addEventListener("contextmenu",ii,{signal:e}),t.addEventListener("pointerdown",w(on,Ed,Ib),{signal:e});const s=m(this,Kr,document.createElement("div"));s.className="buttons",t.append(s);const i=l(this,ni).toolbarPosition;if(i){const{style:n}=t,r=l(this,ni)._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return w(this,Xe,Bb).call(this),t}get div(){return l(this,Qn)}hide(){var t;l(this,Qn).classList.add("hidden"),(t=l(this,qr))==null||t.hideDropdown()}show(){var t;l(this,Qn).classList.remove("hidden"),(t=l(this,yl))==null||t.shown()}async addAltText(t){const e=await t.render();w(this,Xe,Kd).call(this,e),l(this,Kr).prepend(e,l(this,Xe,Sp)),m(this,yl,t)}addColorPicker(t){m(this,qr,t);const e=t.renderButton();w(this,Xe,Kd).call(this,e),l(this,Kr).prepend(e,l(this,Xe,Sp))}remove(){var t;l(this,Qn).remove(),(t=l(this,qr))==null||t.destroy(),m(this,qr,null)}};Qn=new WeakMap,qr=new WeakMap,ni=new WeakMap,Kr=new WeakMap,yl=new WeakMap,_l=new WeakMap,Ed=new WeakSet,Ib=function(t){t.stopPropagation()},Xe=new WeakSet,jb=function(t){l(this,ni)._focusEventsAllowed=!1,gs(t)},Nb=function(t){l(this,ni)._focusEventsAllowed=!0,gs(t)},Kd=function(t){const e=l(this,ni)._uiManager._signal;t.addEventListener("focusin",w(this,Xe,jb).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",w(this,Xe,Nb).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ii,{signal:e})},Bb=function(){const{editorType:t,_uiManager:e}=l(this,ni),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",l(on,_l)[t]),w(this,Xe,Kd).call(this,s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),l(this,Kr).append(s)},Sp=function(){const t=document.createElement("div");return t.className="divider",t},y(on,Ed),y(on,_l,null);let Bg=on;class iS{constructor(t){y(this,Zn);y(this,wl,null);y(this,Jr,null);y(this,Qr);m(this,Qr,t)}show(t,e,s){const[i,n]=w(this,Zn,Gb).call(this,e,s),{style:r}=l(this,Jr)||m(this,Jr,w(this,Zn,Hb).call(this));t.append(l(this,Jr)),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){l(this,Jr).remove()}}wl=new WeakMap,Jr=new WeakMap,Qr=new WeakMap,Zn=new WeakSet,Hb=function(){const t=m(this,Jr,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",ii,{signal:l(this,Qr)._signal});const e=m(this,wl,document.createElement("div"));return e.className="buttons",t.append(e),w(this,Zn,Vb).call(this),t},Gb=function(t,e){let s=0,i=0;for(const n of t){const r=n.y+n.height;if(r<s)continue;const a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]},Vb=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=l(this,Qr)._signal;t.addEventListener("contextmenu",ii,{signal:s}),t.addEventListener("click",()=>{l(this,Qr).highlightSelection("floating_button")},{signal:s}),l(this,wl).append(t)};function gd(o,t,e){for(const s of e)t.addEventListener(s,o[s].bind(o))}class nS{constructor(){y(this,kd,0)}get id(){return`${Nx}${Ze(this,kd)._++}`}}kd=new WeakMap;const cp=class cp{constructor(){y(this,To);y(this,Ao,Jx());y(this,xl,0);y(this,De,null)}static get _isSVGFittingCanvas(){const t='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=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return ht(this,"_isSVGFittingCanvas",n)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return w(this,To,Jd).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return w(this,To,Jd).call(this,t,t)}async getFromBlob(t,e){const s=await e;return w(this,To,Jd).call(this,t,s)}async getFromId(t){l(this,De)||m(this,De,new Map);const e=l(this,De).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){l(this,De)||m(this,De,new Map);let s=l(this,De).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${l(this,Ao)}_${Ze(this,xl)._++}`,refCounter:1,isSvg:!1},l(this,De).set(t,s),l(this,De).set(s.id,s),s}getSvgUrl(t){const e=l(this,De).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;l(this,De)||m(this,De,new Map);const e=l(this,De).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const n=new OffscreenCanvas(s.width,s.height);n.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=n.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${l(this,Ao)}_`)}};Ao=new WeakMap,xl=new WeakMap,De=new WeakMap,To=new WeakSet,Jd=async function(t,e){l(this,De)||m(this,De,new Map);let s=l(this,De).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${l(this,Ao)}_${Ze(this,xl)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await dd(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=cp._isSVGFittingCanvas,r=new FileReader,a=new Image,h=new Promise((c,u)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,c()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=u});r.readAsDataURL(i),await h}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){rt(i),s=null}return l(this,De).set(t,s),s&&l(this,De).set(s.id,s),s};let Hg=cp;class rS{constructor(t=128){y(this,Kt,[]);y(this,tr,!1);y(this,Sl);y(this,Gt,-1);m(this,Sl,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i&&t(),l(this,tr))return;const h={cmd:t,undo:e,post:s,type:n};if(l(this,Gt)===-1){l(this,Kt).length>0&&(l(this,Kt).length=0),m(this,Gt,0),l(this,Kt).push(h);return}if(r&&l(this,Kt)[l(this,Gt)].type===n){a&&(h.undo=l(this,Kt)[l(this,Gt)].undo),l(this,Kt)[l(this,Gt)]=h;return}const c=l(this,Gt)+1;c===l(this,Sl)?l(this,Kt).splice(0,1):(m(this,Gt,c),c<l(this,Kt).length&&l(this,Kt).splice(c)),l(this,Kt).push(h)}undo(){if(l(this,Gt)===-1)return;m(this,tr,!0);const{undo:t,post:e}=l(this,Kt)[l(this,Gt)];t(),e==null||e(),m(this,tr,!1),m(this,Gt,l(this,Gt)-1)}redo(){if(l(this,Gt)<l(this,Kt).length-1){m(this,Gt,l(this,Gt)+1),m(this,tr,!0);const{cmd:t,post:e}=l(this,Kt)[l(this,Gt)];t(),e==null||e(),m(this,tr,!1)}}hasSomethingToUndo(){return l(this,Gt)!==-1}hasSomethingToRedo(){return l(this,Gt)<l(this,Kt).length-1}cleanType(t){if(l(this,Gt)!==-1){for(let e=l(this,Gt);e>=0;e--)if(l(this,Kt)[e].type!==t){l(this,Kt).splice(e+1,l(this,Gt)-e),m(this,Gt,e);return}l(this,Kt).length=0,m(this,Gt,-1)}}destroy(){m(this,Kt,null)}}Kt=new WeakMap,tr=new WeakMap,Sl=new WeakMap,Gt=new WeakMap;class ll{constructor(t){y(this,Pd);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ze.platform;for(const[s,i,n={}]of t)for(const r of s){const a=r.startsWith("mac+");e&&a?(this.callbacks.set(r.slice(4),{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1))):!e&&!a&&(this.callbacks.set(r,{callback:i,options:n}),this.allKeys.add(r.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(w(this,Pd,Wb).call(this,e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:r=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...r,e)(),n||gs(e))}}Pd=new WeakSet,Wb=function(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);const e=this.buffer.join("+");return this.buffer.length=0,e};const Md=class Md{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return sS(t),ht(this,"_colors",t)}convert(t){const e=jg(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return Md._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?q.makeHexColor(...e):t}};J(Md,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Gg=Md;const Ro=class Ro{constructor(t,e,s,i,n,r,a,h,c,u,d,f,g){y(this,B);y(this,Eo,new AbortController);y(this,ps,null);y(this,he,new Map);y(this,be,new Map);y(this,ko,null);y(this,hn,null);y(this,Po,null);y(this,Fs,new rS);y(this,er,null);y(this,Zr,null);y(this,Mo,0);y(this,ta,new Set);y(this,Ei,null);y(this,ri,null);y(this,ea,new Set);J(this,"_editorUndoBar",null);y(this,Cl,!1);y(this,Al,!1);y(this,Oo,!1);y(this,Tl,null);y(this,ki,null);y(this,sr,null);y(this,Do,null);y(this,ir,!1);y(this,Pi,null);y(this,Od,new nS);y(this,nr,!1);y(this,El,!1);y(this,rr,null);y(this,sa,null);y(this,kl,null);y(this,Pl,null);y(this,de,nt.NONE);y(this,xt,new Set);y(this,ln,null);y(this,ia,null);y(this,Ml,null);y(this,Ol,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});y(this,ar,[0,0]);y(this,Mi,null);y(this,cn,null);y(this,Dl,null);y(this,Is,null);const p=this._signal=l(this,Eo).signal;m(this,cn,t),m(this,Dl,e),m(this,ko,s),this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:p}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),i._on("setpreference",this.onSetPreference.bind(this),{signal:p}),i._on("switchannotationeditorparams",v=>this.updateParams(v.type,v.value),{signal:p}),w(this,B,Ub).call(this),w(this,B,Kb).call(this),w(this,B,Ap).call(this),m(this,hn,n.annotationStorage),m(this,Tl,n.filterFactory),m(this,ia,r),m(this,Do,a||null),m(this,Cl,h),m(this,Al,c),m(this,Oo,u),m(this,Pl,d||null),this.viewParameters={realScale:Kn.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=f||null,this._supportsPinchToZoom=g!==!1}static get _keyboardManager(){const t=Ro.prototype,e=r=>l(r,cn).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:h}=a;return h!=="text"&&h!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return ht(this,"_keyboardManager",new ll([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&l(r,cn).contains(a)&&!r.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&l(r,cn).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}destroy(){var t,e,s,i,n;(t=l(this,Is))==null||t.resolve(),m(this,Is,null),(e=l(this,Eo))==null||e.abort(),m(this,Eo,null),this._signal=null;for(const r of l(this,be).values())r.destroy();l(this,be).clear(),l(this,he).clear(),l(this,ea).clear(),m(this,ps,null),l(this,xt).clear(),l(this,Fs).destroy(),(s=l(this,ko))==null||s.destroy(),(i=l(this,Pi))==null||i.hide(),m(this,Pi,null),l(this,ki)&&(clearTimeout(l(this,ki)),m(this,ki,null)),l(this,Mi)&&(clearTimeout(l(this,Mi)),m(this,Mi,null)),(n=this._editorUndoBar)==null||n.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return l(this,Pl)}get useNewAltTextFlow(){return l(this,Al)}get useNewAltTextWhenAddingImage(){return l(this,Oo)}get hcmFilter(){return ht(this,"hcmFilter",l(this,ia)?l(this,Tl).addHCMFilter(l(this,ia).foreground,l(this,ia).background):"none")}get direction(){return ht(this,"direction",getComputedStyle(l(this,cn)).direction)}get highlightColors(){return ht(this,"highlightColors",l(this,Do)?new Map(l(this,Do).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return ht(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),m(this,Zr,t)}setMainHighlightColorPicker(t){m(this,kl,t)}editAltText(t,e=!1){var s;(s=l(this,ko))==null||s.editAltText(this,t,e)}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}){switch(t){case"enableNewAltTextWhenAddingImage":m(this,Oo,e);break}}onPageChanging({pageNumber:t}){m(this,Mo,t-1)}focusMainContainer(){l(this,cn).focus()}findParent(t,e){for(const s of l(this,be).values()){const{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){l(this,Dl).classList.toggle("noUserSelect",t)}addShouldRescale(t){l(this,ea).add(t)}removeShouldRescale(t){l(this,ea).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Kn.PDF_TO_CSS_UNITS;for(const s of l(this,ea))s.onScaleChanging();(e=l(this,Zr))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r}=e,a=e.toString(),c=w(this,B,Qd).call(this,e).closest(".textLayer"),u=this.getSelectionBoxes(c);if(!u)return;e.empty();const d=w(this,B,Cp).call(this,c),f=l(this,de)===nt.NONE,g=()=>{d==null||d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:r,text:a}),f&&this.showAllEditors("highlight",!0,!0)};if(f){this.switchToMode(nt.HIGHLIGHT,g);return}g()}addToAnnotationStorage(t){!t.isEmpty()&&l(this,hn)&&!l(this,hn).has(t.id)&&l(this,hn).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,l(this,ir)&&(m(this,ir,!1),w(this,B,Zd).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of l(this,xt))if(e.div.contains(t)){m(this,sa,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!l(this,sa))return;const[t,e]=l(this,sa);m(this,sa,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){w(this,B,Ap).call(this),w(this,B,Tp).call(this)}removeEditListeners(){w(this,B,qb).call(this),w(this,B,Ep).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of l(this,ri))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of l(this,ri))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=l(this,ps))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of l(this,xt)){const n=i.serialize(!0);n&&e.push(n)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const r of l(this,ri))if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){rt(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const h of s){const c=await i.deserialize(h);if(!c)return;n.push(c)}const r=()=>{for(const h of n)w(this,B,kp).call(this,h);w(this,B,Pp).call(this,n)},a=()=>{for(const h of n)h.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){rt(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),l(this,de)!==nt.NONE&&!this.isEditorHandlingKeyboard&&Ro._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,l(this,ir)&&(m(this,ir,!1),w(this,B,Zd).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}setEditingState(t){t?(w(this,B,Yb).call(this),w(this,B,Tp).call(this),w(this,B,ts).call(this,{isEditing:l(this,de)!==nt.NONE,isEmpty:w(this,B,Xc).call(this),hasSomethingToUndo:l(this,Fs).hasSomethingToUndo(),hasSomethingToRedo:l(this,Fs).hasSomethingToRedo(),hasSelectedEditor:!1})):(w(this,B,$b).call(this),w(this,B,Ep).call(this),w(this,B,ts).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!l(this,ri)){m(this,ri,t);for(const e of l(this,ri))w(this,B,jn).call(this,e.defaultPropertiesToUpdate)}}getId(){return l(this,Od).id}get currentLayer(){return l(this,be).get(l(this,Mo))}getLayer(t){return l(this,be).get(t)}get currentPageIndex(){return l(this,Mo)}addLayer(t){l(this,be).set(t.pageIndex,t),l(this,nr)?t.enable():t.disable()}removeLayer(t){l(this,be).delete(t.pageIndex)}async updateMode(t,e=null,s=!1){var i;if(l(this,de)!==t&&!(l(this,Is)&&(await l(this,Is).promise,!l(this,Is)))){if(m(this,Is,Promise.withResolvers()),m(this,de,t),t===nt.NONE){this.setEditingState(!1),w(this,B,Qb).call(this),(i=this._editorUndoBar)==null||i.hide(),l(this,Is).resolve();return}this.setEditingState(!0),await w(this,B,Jb).call(this),this.unselectAll();for(const n of l(this,be).values())n.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),l(this,Is).resolve();return}for(const n of l(this,he).values())n.annotationElementId===e?(this.setSelected(n),n.enterInEditMode()):n.unselect();l(this,Is).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==l(this,de)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(l(this,ri)){switch(t){case dt.CREATE:this.currentLayer.addNewEditor();return;case dt.HIGHLIGHT_DEFAULT_COLOR:(s=l(this,kl))==null||s.updateColor(e);break;case dt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(l(this,Ml)||m(this,Ml,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of l(this,xt))i.updateParams(t,e);for(const i of l(this,ri))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const r of l(this,he).values())r.editorType===t&&r.show(e);(((n=l(this,Ml))==null?void 0:n.get(dt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&w(this,B,jn).call(this,[[dt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(l(this,El)!==t){m(this,El,t);for(const e of l(this,be).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of l(this,he).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return l(this,he).get(t)}addEditor(t){l(this,he).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(l(this,ki)&&clearTimeout(l(this,ki)),m(this,ki,setTimeout(()=>{this.focusMainContainer(),m(this,ki,null)},0))),l(this,he).delete(t.id),this.unselect(t),(!t.annotationElementId||!l(this,ta).has(t.annotationElementId))&&((e=l(this,hn))==null||e.remove(t.id))}addDeletedAnnotationElement(t){l(this,ta).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return l(this,ta).has(t)}removeDeletedAnnotationElement(t){l(this,ta).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){l(this,ps)!==t&&(m(this,ps,t),t&&w(this,B,jn).call(this,t.propertiesToUpdate))}updateUI(t){l(this,B,Zb)===t&&w(this,B,jn).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){w(this,B,jn).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(l(this,xt).has(t)){l(this,xt).delete(t),t.unselect(),w(this,B,ts).call(this,{hasSelectedEditor:this.hasSelection});return}l(this,xt).add(t),t.select(),w(this,B,jn).call(this,t.propertiesToUpdate),w(this,B,ts).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;(e=l(this,Zr))==null||e.commitOrRemove();for(const s of l(this,xt))s!==t&&s.unselect();l(this,xt).clear(),l(this,xt).add(t),t.select(),w(this,B,jn).call(this,t.propertiesToUpdate),w(this,B,ts).call(this,{hasSelectedEditor:!0})}isSelected(t){return l(this,xt).has(t)}get firstSelectedEditor(){return l(this,xt).values().next().value}unselect(t){t.unselect(),l(this,xt).delete(t),w(this,B,ts).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return l(this,xt).size!==0}get isEnterHandled(){return l(this,xt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;l(this,Fs).undo(),w(this,B,ts).call(this,{hasSomethingToUndo:l(this,Fs).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:w(this,B,Xc).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){l(this,Fs).redo(),w(this,B,ts).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:l(this,Fs).hasSomethingToRedo(),isEmpty:w(this,B,Xc).call(this)})}addCommands(t){l(this,Fs).add(t),w(this,B,ts).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:w(this,B,Xc).call(this)})}cleanUndoStack(t){l(this,Fs).cleanType(t)}delete(){var n;this.commitOrRemove();const t=(n=this.currentLayer)==null?void 0:n.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...l(this,xt)],s=()=>{var r;(r=this._editorUndoBar)==null||r.show(i,e.length===1?e[0].editorType:e.length);for(const a of e)a.remove()},i=()=>{for(const r of e)w(this,B,kp).call(this,r)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=l(this,ps))==null||t.commitOrRemove()}hasSomethingToControl(){return l(this,ps)||this.hasSelection}selectAll(){for(const t of l(this,xt))t.commit();w(this,B,Pp).call(this,l(this,he).values())}unselectAll(){var t;if(!(l(this,ps)&&(l(this,ps).commitOrRemove(),l(this,de)!==nt.NONE))&&!((t=l(this,Zr))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of l(this,xt))e.unselect();l(this,xt).clear(),w(this,B,ts).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;l(this,ar)[0]+=t,l(this,ar)[1]+=e;const[i,n]=l(this,ar),r=[...l(this,xt)],a=1e3;l(this,Mi)&&clearTimeout(l(this,Mi)),m(this,Mi,setTimeout(()=>{m(this,Mi,null),l(this,ar)[0]=l(this,ar)[1]=0,this.addCommands({cmd:()=>{for(const h of r)l(this,he).has(h.id)&&h.translateInPage(i,n)},undo:()=>{for(const h of r)l(this,he).has(h.id)&&h.translateInPage(-i,-n)},mustExec:!1})},a));for(const h of r)h.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),m(this,Ei,new Map);for(const t of l(this,xt))l(this,Ei).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!l(this,Ei))return!1;this.disableUserSelect(!1);const t=l(this,Ei);m(this,Ei,null);let e=!1;for(const[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||(e=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex);if(!e)return!1;const s=(i,n,r,a)=>{if(l(this,he).has(i.id)){const h=l(this,be).get(a);h?i._setParentAndPosition(h,n,r):(i.pageIndex=a,i.x=n,i.y=r)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(const[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(l(this,Ei))for(const s of l(this,Ei).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||l(this,xt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return l(this,ps)===t}getActive(){return l(this,ps)}getMode(){return l(this,de)}get imageManager(){return ht(this,"imageManager",new Hg)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,u=e.rangeCount;c<u;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(c,u,d,f)=>({x:(u-i)/r,y:1-(c+d-s)/n,width:f/r,height:d/n});break;case"180":a=(c,u,d,f)=>({x:1-(c+d-s)/n,y:1-(u+f-i)/r,width:d/n,height:f/r});break;case"270":a=(c,u,d,f)=>({x:1-(u+f-i)/r,y:(c-s)/n,width:f/r,height:d/n});break;default:a=(c,u,d,f)=>({x:(c-s)/n,y:(u-i)/r,width:d/n,height:f/r});break}const h=[];for(let c=0,u=e.rangeCount;c<u;c++){const d=e.getRangeAt(c);if(!d.collapsed)for(const{x:f,y:g,width:p,height:v}of d.getClientRects())p===0||v===0||h.push(a(f,g,p,v))}return h.length===0?null:h}addChangedExistingAnnotation({annotationElementId:t,id:e}){(l(this,Po)||m(this,Po,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=l(this,Po))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=l(this,Po))==null?void 0:i.get(t.data.id);if(!e)return;const s=l(this,hn).getRawValue(e);s&&(l(this,de)===nt.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}};Eo=new WeakMap,ps=new WeakMap,he=new WeakMap,be=new WeakMap,ko=new WeakMap,hn=new WeakMap,Po=new WeakMap,Fs=new WeakMap,er=new WeakMap,Zr=new WeakMap,Mo=new WeakMap,ta=new WeakMap,Ei=new WeakMap,ri=new WeakMap,ea=new WeakMap,Cl=new WeakMap,Al=new WeakMap,Oo=new WeakMap,Tl=new WeakMap,ki=new WeakMap,sr=new WeakMap,Do=new WeakMap,ir=new WeakMap,Pi=new WeakMap,Od=new WeakMap,nr=new WeakMap,El=new WeakMap,rr=new WeakMap,sa=new WeakMap,kl=new WeakMap,Pl=new WeakMap,de=new WeakMap,xt=new WeakMap,ln=new WeakMap,ia=new WeakMap,Ml=new WeakMap,Ol=new WeakMap,ar=new WeakMap,Mi=new WeakMap,cn=new WeakMap,Dl=new WeakMap,Is=new WeakMap,B=new WeakSet,Qd=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Cp=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of l(this,be).values())if(s.hasTextLayer(t))return s;return null},zb=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=w(this,B,Qd).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(l(this,Pi)||m(this,Pi,new iS(this)),l(this,Pi).show(s,i,this.direction==="ltr"))},Xb=function(){var n,r,a;const t=document.getSelection();if(!t||t.isCollapsed){l(this,ln)&&((n=l(this,Pi))==null||n.hide(),m(this,ln,null),w(this,B,ts).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===l(this,ln))return;const i=w(this,B,Qd).call(this,t).closest(".textLayer");if(!i){l(this,ln)&&((r=l(this,Pi))==null||r.hide(),m(this,ln,null),w(this,B,ts).call(this,{hasSelectedText:!1}));return}if((a=l(this,Pi))==null||a.hide(),m(this,ln,e),w(this,B,ts).call(this,{hasSelectedText:!0}),!(l(this,de)!==nt.HIGHLIGHT&&l(this,de)!==nt.NONE)&&(l(this,de)===nt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),m(this,ir,this.isShiftKeyDown),!this.isShiftKeyDown)){const h=l(this,de)===nt.HIGHLIGHT?w(this,B,Cp).call(this,i):null;h==null||h.toggleDrawing();const c=new AbortController,u=this.combinedSignal(c),d=f=>{f.type==="pointerup"&&f.button!==0||(c.abort(),h==null||h.toggleDrawing(!0),f.type==="pointerup"&&w(this,B,Zd).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:u}),window.addEventListener("blur",d,{signal:u})}},Zd=function(t=""){l(this,de)===nt.HIGHLIGHT?this.highlightSelection(t):l(this,Cl)&&w(this,B,zb).call(this)},Ub=function(){document.addEventListener("selectionchange",w(this,B,Xb).bind(this),{signal:this._signal})},Yb=function(){if(l(this,sr))return;m(this,sr,new AbortController);const t=this.combinedSignal(l(this,sr));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},$b=function(){var t;(t=l(this,sr))==null||t.abort(),m(this,sr,null)},Ap=function(){if(l(this,rr))return;m(this,rr,new AbortController);const t=this.combinedSignal(l(this,rr));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},qb=function(){var t;(t=l(this,rr))==null||t.abort(),m(this,rr,null)},Tp=function(){if(l(this,er))return;m(this,er,new AbortController);const t=this.combinedSignal(l(this,er));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})},Ep=function(){var t;(t=l(this,er))==null||t.abort(),m(this,er,null)},Kb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},ts=function(t){Object.entries(t).some(([s,i])=>l(this,Ol)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(l(this,Ol),t)}),l(this,de)===nt.HIGHLIGHT&&t.hasSelectedEditor===!1&&w(this,B,jn).call(this,[[dt.HIGHLIGHT_FREE,!0]]))},jn=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Jb=async function(){if(!l(this,nr)){m(this,nr,!0);const t=[];for(const e of l(this,be).values())t.push(e.enable());await Promise.all(t);for(const e of l(this,he).values())e.enable()}},Qb=function(){if(this.unselectAll(),l(this,nr)){m(this,nr,!1);for(const t of l(this,be).values())t.disable();for(const t of l(this,he).values())t.disable()}},kp=function(t){const e=l(this,be).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Zb=function(){let t=null;for(t of l(this,xt));return t},Xc=function(){if(l(this,he).size===0)return!0;if(l(this,he).size===1)for(const t of l(this,he).values())return t.isEmpty();return!1},Pp=function(t){for(const e of l(this,xt))e.unselect();l(this,xt).clear();for(const e of t)e.isEmpty()||(l(this,xt).add(e),e.select());w(this,B,ts).call(this,{hasSelectedEditor:this.hasSelection})},J(Ro,"TRANSLATE_SMALL",1),J(Ro,"TRANSLATE_BIG",10);let Xr=Ro;const Ue=class Ue{constructor(t){y(this,oi);y(this,fe,null);y(this,Oi,!1);y(this,ai,null);y(this,Lo,null);y(this,Di,null);y(this,ms,null);y(this,Fo,!1);y(this,Ri,null);y(this,as,null);y(this,un,null);y(this,na,null);y(this,Li,!1);m(this,as,t),m(this,Li,t._uiManager.useNewAltTextFlow),l(Ue,or)||m(Ue,or,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){Ue._l10n??(Ue._l10n=t)}async render(){const t=m(this,ai,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=m(this,Lo,document.createElement("span"));t.append(e),l(this,Li)?(t.classList.add("new"),t.setAttribute("data-l10n-id",l(Ue,or).missing),e.setAttribute("data-l10n-id",l(Ue,or)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=l(this,as)._uiManager._signal;t.addEventListener("contextmenu",ii,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),l(this,as)._uiManager.editAltText(l(this,as)),l(this,Li)&&l(this,as)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:l(this,oi,Uc)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(m(this,Fo,!0),i(n))},{signal:s}),await w(this,oi,tf).call(this),t}finish(){l(this,ai)&&(l(this,ai).focus({focusVisible:l(this,Fo)}),m(this,Fo,!1))}isEmpty(){return l(this,Li)?l(this,fe)===null:!l(this,fe)&&!l(this,Oi)}hasData(){return l(this,Li)?l(this,fe)!==null||!!l(this,un):this.isEmpty()}get guessedText(){return l(this,un)}async setGuessedText(t){l(this,fe)===null&&(m(this,un,t),m(this,na,await Ue._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),w(this,oi,tf).call(this))}toggleAltTextBadge(t=!1){var e;if(!l(this,Li)||l(this,fe)){(e=l(this,Ri))==null||e.remove(),m(this,Ri,null);return}if(!l(this,Ri)){const s=m(this,Ri,document.createElement("div"));s.className="noAltTextBadge",l(this,as).div.append(s)}l(this,Ri).classList.toggle("hidden",!t)}serialize(t){let e=l(this,fe);return!t&&l(this,un)===e&&(e=l(this,na)),{altText:e,decorative:l(this,Oi),guessedText:l(this,un),textWithDisclaimer:l(this,na)}}get data(){return{altText:l(this,fe),decorative:l(this,Oi)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(m(this,un,s),m(this,na,i)),!(l(this,fe)===t&&l(this,Oi)===e)&&(n||(m(this,fe,t),m(this,Oi,e)),w(this,oi,tf).call(this))}toggle(t=!1){l(this,ai)&&(!t&&l(this,ms)&&(clearTimeout(l(this,ms)),m(this,ms,null)),l(this,ai).disabled=!t)}shown(){l(this,as)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:l(this,oi,Uc)}})}destroy(){var t,e;(t=l(this,ai))==null||t.remove(),m(this,ai,null),m(this,Lo,null),m(this,Di,null),(e=l(this,Ri))==null||e.remove(),m(this,Ri,null)}};fe=new WeakMap,Oi=new WeakMap,ai=new WeakMap,Lo=new WeakMap,Di=new WeakMap,ms=new WeakMap,Fo=new WeakMap,Ri=new WeakMap,as=new WeakMap,un=new WeakMap,na=new WeakMap,Li=new WeakMap,or=new WeakMap,oi=new WeakSet,Uc=function(){return l(this,fe)&&"added"||l(this,fe)===null&&this.guessedText&&"review"||"missing"},tf=async function(){var i,n,r;const t=l(this,ai);if(!t)return;if(l(this,Li)){if(t.classList.toggle("done",!!l(this,fe)),t.setAttribute("data-l10n-id",l(Ue,or)[l(this,oi,Uc)]),(i=l(this,Lo))==null||i.setAttribute("data-l10n-id",l(Ue,or)[`${l(this,oi,Uc)}-label`]),!l(this,fe)){(n=l(this,Di))==null||n.remove();return}}else{if(!l(this,fe)&&!l(this,Oi)){t.classList.remove("done"),(r=l(this,Di))==null||r.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=l(this,Di);if(!e){m(this,Di,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${l(this,as).id}`;const a=100,h=l(this,as)._uiManager._signal;h.addEventListener("abort",()=>{clearTimeout(l(this,ms)),m(this,ms,null)},{once:!0}),t.addEventListener("mouseenter",()=>{m(this,ms,setTimeout(()=>{m(this,ms,null),l(this,Di).classList.add("show"),l(this,as)._reportTelemetry({action:"alt_text_tooltip"})},a))},{signal:h}),t.addEventListener("mouseleave",()=>{var c;l(this,ms)&&(clearTimeout(l(this,ms)),m(this,ms,null)),(c=l(this,Di))==null||c.classList.remove("show")},{signal:h})}l(this,Oi)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=l(this,fe)),e.parentNode||t.append(e);const s=l(this,as).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},y(Ue,or,null),J(Ue,"_l10n",null);let pd=Ue;const up=class up{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){y(this,fn);y(this,Rl);y(this,ra,!1);y(this,Ll,null);y(this,Fl);y(this,Il);y(this,jl);y(this,Nl);y(this,Io);y(this,dn,null);y(this,aa);y(this,hr,null);m(this,Rl,t),m(this,Ll,s),m(this,Fl,e),m(this,Il,i),m(this,jl,n),m(this,Nl,r),m(this,aa,new AbortController),m(this,Io,AbortSignal.any([a,l(this,aa).signal])),t.addEventListener("touchstart",w(this,fn,ty).bind(this),{passive:!1,signal:l(this,Io)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return ht(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var t;(t=l(this,aa))==null||t.abort(),m(this,aa,null)}};Rl=new WeakMap,ra=new WeakMap,Ll=new WeakMap,Fl=new WeakMap,Il=new WeakMap,jl=new WeakMap,Nl=new WeakMap,Io=new WeakMap,dn=new WeakMap,aa=new WeakMap,hr=new WeakMap,fn=new WeakSet,ty=function(t){var i,n,r;if((i=l(this,Fl))!=null&&i.call(this)||t.touches.length<2)return;if(!l(this,hr)){m(this,hr,new AbortController);const a=AbortSignal.any([l(this,Io),l(this,hr).signal]),h=l(this,Rl),c={signal:a,passive:!1};h.addEventListener("touchmove",w(this,fn,ey).bind(this),c),h.addEventListener("touchend",w(this,fn,Mp).bind(this),c),h.addEventListener("touchcancel",w(this,fn,Mp).bind(this),c),(n=l(this,Il))==null||n.call(this)}if(gs(t),t.touches.length!==2||(r=l(this,Ll))!=null&&r.call(this)){m(this,dn,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),m(this,dn,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},ey=function(t){var A;if(!l(this,dn)||t.touches.length!==2)return;let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:n}=e,{screenX:r,screenY:a}=s,h=l(this,dn),{touch0X:c,touch0Y:u,touch1X:d,touch1Y:f}=h,g=d-c,p=f-u,v=r-i,_=a-n,b=Math.hypot(v,_)||1,x=Math.hypot(g,p)||1;if(!l(this,ra)&&Math.abs(x-b)<=up.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(h.touch0X=i,h.touch0Y=n,h.touch1X=r,h.touch1Y=a,t.preventDefault(),!l(this,ra)){m(this,ra,!0);return}const C=[(i+r)/2,(n+a)/2];(A=l(this,jl))==null||A.call(this,C,x,b)},Mp=function(t){var e;l(this,hr).abort(),m(this,hr,null),(e=l(this,Nl))==null||e.call(this),l(this,dn)&&(t.preventDefault(),m(this,dn,null),m(this,ra,!1))};let md=up;const ot=class ot{constructor(t){y(this,K);y(this,oa,null);y(this,hi,null);y(this,Rt,null);y(this,jo,!1);y(this,lr,null);y(this,Bl,"");y(this,ha,!1);y(this,ye,null);y(this,la,null);y(this,gn,null);y(this,cr,null);y(this,Hl,"");y(this,ca,!1);y(this,vs,null);y(this,Gl,!1);y(this,ua,!1);y(this,pn,!1);y(this,Fi,null);y(this,No,0);y(this,Bo,0);y(this,js,null);y(this,da,null);J(this,"_editToolbar",null);J(this,"_initialOptions",Object.create(null));J(this,"_initialData",null);J(this,"_isVisible",!0);J(this,"_uiManager",null);J(this,"_focusEventsAllowed",!0);y(this,Vl,!1);y(this,Dd,ot._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];const[a,h]=this.parentDimensions;this.x=t.x/a,this.y=t.y/h,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=ot.prototype._resizeWithKeyboard,e=Xr.TRANSLATE_SMALL,s=Xr.TRANSLATE_BIG;return ht(this,"_resizerKeyboardManager",new ll([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],ot.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return ht(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new aS({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(ot._l10n??(ot._l10n=t),ot._l10nResizer||(ot._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"})),ot._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);ot._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Et("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return l(this,Vl)}set _isDraggable(t){var e;m(this,Vl,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=l(this,Dd)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):w(this,K,Yc).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(l(this,ca)?m(this,ca,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}translate(t,e){w(this,K,Op).call(this,this.parentDimensions,t,e)}translateInPage(t,e){l(this,vs)||m(this,vs,[this.x,this.y,this.width,this.height]),w(this,K,Op).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){l(this,vs)||m(this,vs,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[h,c]=this.getBaseTranslation();r+=h,a+=c;const{style:u}=s;u.left=`${(100*r).toFixed(2)}%`,u.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!l(this,vs)&&(l(this,vs)[0]!==this.x||l(this,vs)[1]!==this.y)}get _hasBeenResized(){return!!l(this,vs)&&(l(this,vs)[2]!==this.width||l(this,vs)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=ot,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:n,y:r,width:a,height:h}=this;if(a*=s,h*=i,n*=s,r*=i,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(s-a,n)),r=Math.max(0,Math.min(i-h,r));break;case 90:n=Math.max(0,Math.min(s-h,n)),r=Math.min(i,Math.max(a,r));break;case 180:n=Math.min(s,Math.max(a,n)),r=Math.min(i,Math.max(h,r));break;case 270:n=Math.min(s,Math.max(h,n)),r=Math.max(0,Math.min(i-a,r));break}this.x=n/=s,this.y=r/=i;const[c,u]=this.getBaseTranslation();n+=c,r+=u,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return w(s=ot,Wl,Dp).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return w(s=ot,Wl,Dp).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(t,e){const[s,i]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/s).toFixed(2)}%`,l(this,ha)||(n.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!l(this,ha)&&e.endsWith("%");if(i&&n)return;const[r,a]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/r).toFixed(2)}%`),!l(this,ha)&&!n&&(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=l(this,Rt))==null||t.finish()}async addEditToolbar(){return this._editToolbar||l(this,ua)?this._editToolbar:(this._editToolbar=new Bg(this),this.div.append(this._editToolbar.render()),l(this,Rt)&&await this._editToolbar.addAltText(l(this,Rt)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=l(this,Rt))==null||t.destroy())}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){l(this,Rt)||(pd.initialize(ot._l10n),m(this,Rt,new pd(this)),l(this,oa)&&(l(this,Rt).data=l(this,oa),m(this,oa,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=l(this,Rt))==null?void 0:t.data}set altTextData(t){l(this,Rt)&&(l(this,Rt).data=t)}get guessedAltText(){var t;return(t=l(this,Rt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=l(this,Rt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=l(this,Rt))==null?void 0:e.serialize(t)}hasAltText(){return!!l(this,Rt)&&!l(this,Rt).isEmpty()}hasAltTextData(){var t;return((t=l(this,Rt))==null?void 0:t.hasData())??!1}render(){var n;this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=l(this,jo)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),w(this,K,Ip).call(this);const[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[s,i]=this.getInitialTranslation();return this.translate(s,i),gd(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(l(this,da)||m(this,da,new md({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:w(this,K,ny).bind(this),onPinching:w(this,K,ry).bind(this),onPinchEnd:w(this,K,ay).bind(this),signal:this._uiManager._signal}))),(n=this._uiManager._editorUndoBar)==null||n.hide(),this.div}pointerdown(t){const{isMac:e}=ze.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(m(this,ca,!0),this._isDraggable){w(this,K,oy).call(this,t);return}w(this,K,Fp).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){l(this,Fi)&&clearTimeout(l(this,Fi)),m(this,Fi,setTimeout(()=>{var t;m(this,Fi,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,r]=this.pageDimensions,[a,h]=this.pageTranslation,c=t/i,u=e/i,d=this.x*n,f=this.y*r,g=this.width*n,p=this.height*r;switch(s){case 0:return[d+c+a,r-f-u-p+h,d+c+g+a,r-f-u+h];case 90:return[d+u+a,r-f+c+h,d+u+p+a,r-f+c+g+h];case 180:return[d-c-g+a,r-f+u+h,d-c+a,r-f+u+p+h];case 270:return[d-u-p+a,r-f-c-g+h,d-u+a,r-f-c+h];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,r]=t,a=n-s,h=r-i;switch(this.rotation){case 0:return[s,e-r,a,h];case 90:return[s,e-i,h,a];case 180:return[n,e-i,a,h];case 270:return[n,e-r,h,a];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){m(this,ua,!0)}disableEditMode(){m(this,ua,!1)}isInEditMode(){return l(this,ua)}shouldGetKeyboardEvents(){return l(this,pn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}rebuild(){w(this,K,Ip).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){Et("An editor must be serializable")}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,m(i,oa,t.accessibilityData);const[n,r]=i.pageDimensions,[a,h,c,u]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=h/r,i.width=c/n,i.height=u/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e;if((t=l(this,cr))==null||t.abort(),m(this,cr,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),l(this,Fi)&&(clearTimeout(l(this,Fi)),m(this,Fi,null)),w(this,K,Yc).call(this),this.removeEditToolbar(),l(this,js)){for(const s of l(this,js).values())clearTimeout(s);m(this,js,null)}this.parent=null,(e=l(this,da))==null||e.destroy(),m(this,da,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(w(this,K,sy).call(this),l(this,ye).classList.remove("hidden"),gd(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),m(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=l(this,ye).children;if(!l(this,hi)){m(this,hi,Array.from(e));const r=w(this,K,hy).bind(this),a=w(this,K,ly).bind(this),h=this._uiManager._signal;for(const c of l(this,hi)){const u=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",r,{signal:h}),c.addEventListener("blur",a,{signal:h}),c.addEventListener("focus",w(this,K,cy).bind(this,u),{signal:h}),c.setAttribute("data-l10n-id",ot._l10nResizer[u])}}const s=l(this,hi)[0];let i=0;for(const r of e){if(r===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(l(this,hi).length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)l(this,ye).append(l(this,ye).firstChild);else if(n>i)for(let a=0;a<n-i;a++)l(this,ye).firstChild.before(l(this,ye).lastChild);let r=0;for(const a of e){const c=l(this,hi)[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",ot._l10nResizer[c])}}w(this,K,jp).call(this,0),m(this,pn,!0),l(this,ye).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){l(this,pn)&&w(this,K,Lp).call(this,l(this,Hl),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){w(this,K,Yc).call(this),this.div.focus()}select(){var t,e,s;if(this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,n;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((n=this._editToolbar)==null||n.show())});return}(e=this._editToolbar)==null||e.show(),(s=l(this,Rt))==null||s.toggleAltTextBadge(!1)}unselect(){var t,e,s,i,n;(t=l(this,ye))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(n=l(this,Rt))==null||n.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return l(this,Gl)}set isEditing(t){m(this,Gl,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){m(this,ha,!0);const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.height="auto"}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){l(this,js)||m(this,js,new Map);const{action:s}=t;let i=l(this,js).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),l(this,js).delete(s),l(this,js).size===0&&m(this,js,null)},ot._telemetryTimeout),l(this,js).set(s,i);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),m(this,jo,!1)}disable(){this.div&&(this.div.tabIndex=-1),m(this,jo,!0)}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};oa=new WeakMap,hi=new WeakMap,Rt=new WeakMap,jo=new WeakMap,lr=new WeakMap,Bl=new WeakMap,ha=new WeakMap,ye=new WeakMap,la=new WeakMap,gn=new WeakMap,cr=new WeakMap,Hl=new WeakMap,ca=new WeakMap,vs=new WeakMap,Gl=new WeakMap,ua=new WeakMap,pn=new WeakMap,Fi=new WeakMap,No=new WeakMap,Bo=new WeakMap,js=new WeakMap,da=new WeakMap,Vl=new WeakMap,Dd=new WeakMap,K=new WeakSet,Op=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Wl=new WeakSet,Dp=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},ef=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},sy=function(){if(l(this,ye))return;m(this,ye,document.createElement("div")),l(this,ye).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");l(this,ye).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",w(this,K,iy).bind(this,s),{signal:e}),i.addEventListener("contextmenu",ii,{signal:e}),i.tabIndex=-1}this.div.prepend(l(this,ye))},iy=function(t,e){var u;e.preventDefault();const{isMac:s}=ze.platform;if(e.button!==0||e.ctrlKey&&s)return;(u=l(this,Rt))==null||u.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,m(this,la,[e.screenX,e.screenY]);const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",w(this,K,Lp).bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",gs,{passive:!1,signal:r}),window.addEventListener("contextmenu",ii,{signal:r}),m(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const a=this.parent.div.style.cursor,h=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const c=()=>{var d;n.abort(),this.parent.togglePointerEvents(!0),(d=l(this,Rt))==null||d.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=h,w(this,K,sf).call(this)};window.addEventListener("pointerup",c,{signal:r}),window.addEventListener("blur",c,{signal:r})},Rp=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*s,r*i),this.fixAndSetPosition(),this._onResized()},sf=function(){if(!l(this,gn))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=l(this,gn);m(this,gn,null);const n=this.x,r=this.y,a=this.width,h=this.height;n===t&&r===e&&a===s&&h===i||this.addCommands({cmd:w(this,K,Rp).bind(this,n,r,a,h),undo:w(this,K,Rp).bind(this,t,e,s,i),mustExec:!0})},Lp=function(t,e){const[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,h=this.height,c=ot.MIN_SIZE/s,u=ot.MIN_SIZE/i,d=w(this,K,ef).call(this,this.rotation),f=(j,W)=>[d[0]*j+d[2]*W,d[1]*j+d[3]*W],g=w(this,K,ef).call(this,360-this.rotation),p=(j,W)=>[g[0]*j+g[2]*W,g[1]*j+g[3]*W];let v,_,b=!1,x=!1;switch(t){case"topLeft":b=!0,v=(j,W)=>[0,0],_=(j,W)=>[j,W];break;case"topMiddle":v=(j,W)=>[j/2,0],_=(j,W)=>[j/2,W];break;case"topRight":b=!0,v=(j,W)=>[j,0],_=(j,W)=>[0,W];break;case"middleRight":x=!0,v=(j,W)=>[j,W/2],_=(j,W)=>[0,W/2];break;case"bottomRight":b=!0,v=(j,W)=>[j,W],_=(j,W)=>[0,0];break;case"bottomMiddle":v=(j,W)=>[j/2,W],_=(j,W)=>[j/2,0];break;case"bottomLeft":b=!0,v=(j,W)=>[0,W],_=(j,W)=>[j,0];break;case"middleLeft":x=!0,v=(j,W)=>[0,W/2],_=(j,W)=>[j,W/2];break}const C=v(a,h),A=_(a,h);let P=f(...A);const D=ot._round(n+P[0]),k=ot._round(r+P[1]);let M=1,R=1,F,I;if(e.fromKeyboard)({deltaX:F,deltaY:I}=e);else{const{screenX:j,screenY:W}=e,[it,kt]=l(this,la);[F,I]=this.screenToPageTranslation(j-it,W-kt),l(this,la)[0]=j,l(this,la)[1]=W}if([F,I]=p(F/s,I/i),b){const j=Math.hypot(a,h);M=R=Math.max(Math.min(Math.hypot(A[0]-C[0]-F,A[1]-C[1]-I)/j,1/a,1/h),c/a,u/h)}else x?M=Math.max(c,Math.min(1,Math.abs(A[0]-C[0]-F)))/a:R=Math.max(u,Math.min(1,Math.abs(A[1]-C[1]-I)))/h;const Y=ot._round(a*M),N=ot._round(h*R);P=f(..._(Y,N));const H=D-P[0],at=k-P[1];l(this,vs)||m(this,vs,[this.x,this.y,this.width,this.height]),this.width=Y,this.height=N,this.x=H,this.y=at,this.setDims(s*Y,i*N),this.fixAndSetPosition(),this._onResizing()},ny=function(){var t;m(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=l(this,Rt))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},ry=function(t,e,s){let n=.7*(s/e)+1-.7;if(n===1)return;const r=w(this,K,ef).call(this,this.rotation),a=(D,k)=>[r[0]*D+r[2]*k,r[1]*D+r[3]*k],[h,c]=this.parentDimensions,u=this.x,d=this.y,f=this.width,g=this.height,p=ot.MIN_SIZE/h,v=ot.MIN_SIZE/c;n=Math.max(Math.min(n,1/f,1/g),p/f,v/g);const _=ot._round(f*n),b=ot._round(g*n);if(_===f&&b===g)return;l(this,vs)||m(this,vs,[u,d,f,g]);const x=a(f/2,g/2),C=ot._round(u+x[0]),A=ot._round(d+x[1]),P=a(_/2,b/2);this.x=C-P[0],this.y=A-P[1],this.width=_,this.height=b,this.setDims(h*_,c*b),this.fixAndSetPosition(),this._onResizing()},ay=function(){var t;(t=l(this,Rt))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),w(this,K,sf).call(this)},Fp=function(t){const{isMac:e}=ze.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},oy=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,n=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:n},a=c=>{i.abort(),m(this,lr,null),m(this,ca,!1),this._uiManager.endDragSession()||w(this,K,Fp).call(this,c),s&&this._onStopDragging()};e&&(m(this,No,t.clientX),m(this,Bo,t.clientY),m(this,lr,t.pointerId),m(this,Bl,t.pointerType),window.addEventListener("pointermove",c=>{s||(s=!0,this._onStartDragging());const{clientX:u,clientY:d,pointerId:f}=c;if(f!==l(this,lr)){gs(c);return}const[g,p]=this.screenToPageTranslation(u-l(this,No),d-l(this,Bo));m(this,No,u),m(this,Bo,d),this._uiManager.dragSelectedEditors(g,p)},r),window.addEventListener("touchmove",gs,r),window.addEventListener("pointerdown",c=>{c.pointerType===l(this,Bl)&&(l(this,da)||c.isPrimary)&&a(c),gs(c)},r));const h=c=>{if(!l(this,lr)||l(this,lr)===c.pointerId){a(c);return}gs(c)};window.addEventListener("pointerup",h,{signal:n}),window.addEventListener("blur",h,{signal:n})},Ip=function(){if(l(this,cr)||!this.div)return;m(this,cr,new AbortController);const t=this._uiManager.combinedSignal(l(this,cr));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},hy=function(t){ot._resizerKeyboardManager.exec(this,t)},ly=function(t){var e;l(this,pn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==l(this,ye)&&w(this,K,Yc).call(this)},cy=function(t){m(this,Hl,l(this,pn)?t:"")},jp=function(t){if(l(this,hi))for(const e of l(this,hi))e.tabIndex=t},Yc=function(){m(this,pn,!1),w(this,K,jp).call(this,-1),w(this,K,sf).call(this)},y(ot,Wl),J(ot,"_l10n",null),J(ot,"_l10nResizer",null),J(ot,"_borderLineWidth",-1),J(ot,"_colorManager",new Gg),J(ot,"_zIndex",1),J(ot,"_telemetryTimeout",1e3);let Ht=ot;class aS extends Ht{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const kv=3285377520,Rs=4294901760,Ti=65535;class Pv{constructor(t){this.h1=t?t&4294967295:kv,this.h2=t?t&4294967295:kv}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let v=0,_=t.length;v<_;v++){const b=t.charCodeAt(v);b<=255?e[s++]=b:(e[s++]=b>>>8,e[s++]=b&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i);let a=0,h=0,c=this.h1,u=this.h2;const d=3432918353,f=461845907,g=d&Ti,p=f&Ti;for(let v=0;v<i;v++)v&1?(a=r[v],a=a*d&Rs|a*g&Ti,a=a<<15|a>>>17,a=a*f&Rs|a*p&Ti,c^=a,c=c<<13|c>>>19,c=c*5+3864292196):(h=r[v],h=h*d&Rs|h*g&Ti,h=h<<15|h>>>17,h=h*f&Rs|h*p&Ti,u^=h,u=u<<13|u>>>19,u=u*5+3864292196);switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&Rs|a*g&Ti,a=a<<15|a>>>17,a=a*f&Rs|a*p&Ti,i&1?c^=a:u^=a}this.h1=c,this.h2=u}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Rs|t*36045&Ti,e=e*4283543511&Rs|((e<<16|t>>>16)*2950163797&Rs)>>>16,t^=e>>>1,t=t*444984403&Rs|t*60499&Ti,e=e*3301882366&Rs|((e<<16|t>>>16)*3120437893&Rs)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Vg=Object.freeze({map:null,hash:"",transfer:void 0});class Wg{constructor(){y(this,Rd);y(this,fa,!1);y(this,ga,null);y(this,ge,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=l(this,ge).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return l(this,ge).get(t)}remove(t){if(l(this,ge).delete(t),l(this,ge).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of l(this,ge).values())if(e instanceof Ht)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=l(this,ge).get(t);let i=!1;if(s!==void 0)for(const[n,r]of Object.entries(e))s[n]!==r&&(i=!0,s[n]=r);else i=!0,l(this,ge).set(t,e);i&&w(this,Rd,uy).call(this),e instanceof Ht&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return l(this,ge).has(t)}getAll(){return l(this,ge).size>0?Mg(l(this,ge)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return l(this,ge).size}resetModified(){l(this,fa)&&(m(this,fa,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Mv(this)}get serializable(){if(l(this,ge).size===0)return Vg;const t=new Map,e=new Pv,s=[],i=Object.create(null);let n=!1;for(const[r,a]of l(this,ge)){const h=a instanceof Ht?a.serialize(!1,i):a;h&&(t.set(r,h),e.update(`${r}:${JSON.stringify(h)}`),n||(n=!!h.bitmap))}if(n)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Vg}get editorStats(){let t=null;const e=new Map;for(const s of l(this,ge).values()){if(!(s instanceof Ht))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const r=t[n]||(t[n]=new Map);for(const[a,h]of Object.entries(i)){if(a==="type")continue;let c=r.get(a);c||(c=new Map,r.set(a,c));const u=c.get(h)??0;c.set(h,u+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){m(this,ga,null)}get modifiedIds(){if(l(this,ga))return l(this,ga);const t=[];for(const e of l(this,ge).values())!(e instanceof Ht)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return m(this,ga,{ids:new Set(t),hash:t.join(",")})}}fa=new WeakMap,ga=new WeakMap,ge=new WeakMap,Rd=new WeakSet,uy=function(){l(this,fa)||(m(this,fa,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class Mv extends Wg{constructor(e){super();y(this,zl);const{map:s,hash:i,transfer:n}=e.serializable,r=structuredClone(s,n?{transfer:n}:null);m(this,zl,{map:r,hash:i,transfer:n})}get print(){Et("Should not call PrintAnnotationStorage.print")}get serializable(){return l(this,zl)}get modifiedIds(){return ht(this,"modifiedIds",{ids:new Set,hash:""})}}zl=new WeakMap;class oS{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){y(this,Ho,new Set);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));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),l(this,Ho).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||l(this,Ho).has(t.loadedName))){if(ee(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,r=new FontFace(s,i,n);this.addNativeFontFace(r);try{await r.load(),l(this,Ho).add(s),e==null||e(t)}catch{rt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}Et("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw rt(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return ht(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(Pe||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),ht(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(ee(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return ht(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(A,P){return A.charCodeAt(P)<<24|A.charCodeAt(P+1)<<16|A.charCodeAt(P+2)<<8|A.charCodeAt(P+3)&255}function i(A,P,D,k){const M=A.substring(0,P),R=A.substring(P+D);return M+k+R}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const h=a.getContext("2d");let c=0;function u(A,P){if(++c>30){rt("Load test font never loaded."),P();return}if(h.font="30px "+A,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0){P();return}setTimeout(u.bind(null,A,P))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,d.length,d);const p=16,v=1482184792;let _=s(f,p);for(n=0,r=d.length-3;n<r;n+=4)_=_-v+s(d,n)|0;n<d.length&&(_=_-v+s(d+"XXX",n)|0),f=i(f,p,4,Ux(_));const b=`url(data:font/opentype;base64,${btoa(f)});`,x=`@font-face {font-family:"${d}";src:${b}}`;this.insertRule(x);const C=this._document.createElement("div");C.style.visibility="hidden",C.style.width=C.style.height="10px",C.style.position="absolute",C.style.top=C.style.left="0px";for(const A of[t.loadedName,d]){const P=this._document.createElement("span");P.textContent="Hi",P.style.fontFamily=A,C.append(P)}this._document.body.append(C),u(d,()=>{C.remove(),e.complete()})}}Ho=new WeakMap;class hS{constructor(t,{disableFontFace:e=!1,fontExtraProperties:s=!1,inspectFont:i=null}){this.compiledGlyphs=Object.create(null);for(const n in t)this[n]=t[n];this.disableFontFace=e===!0,this.fontExtraProperties=s===!0,this._inspectFont=i}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Qx(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(r){rt(`getPathGenerator - ignoring character: "${r}".`)}const n=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}}const vd={DATA:1,ERROR:2},se={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Ov(){}function is(o){if(o instanceof qn||o instanceof Pg||o instanceof al||o instanceof Cv||o instanceof cd||o instanceof kg)return o;switch(o instanceof Error||typeof o=="object"&&o!==null||Et('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),o.name){case"AbortException":return new qn(o.message);case"InvalidPDFException":return new Pg(o.message);case"MissingPDFException":return new al(o.message);case"PasswordException":return new Cv(o.message,o.code);case"UnexpectedResponseException":return new cd(o.message,o.status);case"UnknownErrorException":return new kg(o.message,o.details)}return new kg(o.message,o.toString())}class cl{constructor(t,e,s){y(this,Ns);y(this,Go,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",w(this,Ns,dy).bind(this),{signal:l(this,Go).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,r=this.sourceName,a=this.targetName,h=this.comObj;return new ReadableStream({start:c=>{const u=Promise.withResolvers();return this.streamControllers[n]={controller:c,startCall:u,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:c.desiredSize},i),u.promise},pull:c=>{const u=Promise.withResolvers();return this.streamControllers[n].pullCall=u,h.postMessage({sourceName:r,targetName:a,stream:se.PULL,streamId:n,desiredSize:c.desiredSize}),u.promise},cancel:c=>{ee(c instanceof Error,"cancel must have a valid reason");const u=Promise.withResolvers();return this.streamControllers[n].cancelCall=u,this.streamControllers[n].isClosed=!0,h.postMessage({sourceName:r,targetName:a,stream:se.CANCEL,streamId:n,reason:is(c)}),u.promise}},s)}destroy(){var t;(t=l(this,Go))==null||t.abort(),m(this,Go,null)}}Go=new WeakMap,Ns=new WeakSet,dy=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){w(this,Ns,gy).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===vd.DATA)i.resolve(t.data);else if(t.callback===vd.ERROR)i.reject(is(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:s,targetName:i,callback:vd.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:s,targetName:i,callback:vd.ERROR,callbackId:t.callbackId,reason:is(r)})});return}if(t.streamId){w(this,Ns,fy).call(this,t);return}e(t.data)},fy=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],h={enqueue(c,u=1,d){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=u,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:se.ENQUEUE,streamId:e,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:se.CLOSE,streamId:e}),delete r.streamSinks[e])},error(c){ee(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:se.ERROR,streamId:e,reason:is(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};h.sinkCapability.resolve(),h.ready=h.sinkCapability.promise,this.streamSinks[e]=h,Promise.try(a,t.data,h).then(function(){n.postMessage({sourceName:s,targetName:i,stream:se.START_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:se.START_COMPLETE,streamId:e,reason:is(c)})})},gy=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case se.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(is(t.reason));break;case se.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(is(t.reason));break;case se.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:se.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Ov).then(function(){n.postMessage({sourceName:s,targetName:i,stream:se.PULL_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:se.PULL_COMPLETE,streamId:e,reason:is(c)})});break;case se.ENQUEUE:if(ee(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case se.CLOSE:if(ee(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),w(this,Ns,nf).call(this,r,e);break;case se.ERROR:ee(r,"error should have stream controller"),r.controller.error(is(t.reason)),w(this,Ns,nf).call(this,r,e);break;case se.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(is(t.reason)),w(this,Ns,nf).call(this,r,e);break;case se.CANCEL:if(!a)break;const h=is(t.reason);Promise.try(a.onCancel||Ov,h).then(function(){n.postMessage({sourceName:s,targetName:i,stream:se.CANCEL_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:se.CANCEL_COMPLETE,streamId:e,reason:is(c)})}),a.sinkCapability.reject(h),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},nf=async function(t,e){var s,i,n;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(n=t.cancelCall)==null?void 0:n.promise]),delete this.streamControllers[e]};class Dv{constructor({enableHWA:t=!1}){y(this,Xl,!1);m(this,Xl,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!l(this,Xl)})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Et("Abstract method `_createCanvas` called.")}}Xl=new WeakMap;class lS extends Dv{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Rv{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){Et("Abstract method `_fetch` called.")}}class Lv extends Rv{async _fetch(t){const e=await dd(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):ud(e)}}class Fv{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}class cS extends Fv{constructor({docId:e,ownerDocument:s=globalThis.document}){super();y(this,V);y(this,pa);y(this,Vo);y(this,mn);y(this,vn);y(this,Re);y(this,ma);y(this,va,0);m(this,vn,e),m(this,Re,s)}addFilter(e){if(!e)return"none";let s=l(this,V,je).get(e);if(s)return s;const[i,n,r]=w(this,V,rf).call(this,e),a=e.length===1?i:`${i}${n}${r}`;if(s=l(this,V,je).get(a),s)return l(this,V,je).set(e,s),s;const h=`g_${l(this,vn)}_transfer_map_${Ze(this,va)._++}`,c=w(this,V,Fh).call(this,h);l(this,V,je).set(e,c),l(this,V,je).set(a,c);const u=w(this,V,Ih).call(this,h);return w(this,V,Kc).call(this,i,n,r,u),c}addHCMFilter(e,s){var p;const i=`${e}-${s}`,n="base";let r=l(this,V,$c).get(n);if((r==null?void 0:r.key)===i||(r?((p=r.filter)==null||p.remove(),r.key=i,r.url="none",r.filter=null):(r={key:i,url:"none",filter:null},l(this,V,$c).set(n,r)),!e||!s))return r.url;const a=w(this,V,Jc).call(this,e);e=q.makeHexColor(...a);const h=w(this,V,Jc).call(this,s);if(s=q.makeHexColor(...h),l(this,V,Lh).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return r.url;const c=new Array(256);for(let v=0;v<=255;v++){const _=v/255;c[v]=_<=.03928?_/12.92:((_+.055)/1.055)**2.4}const u=c.join(","),d=`g_${l(this,vn)}_hcm_filter`,f=r.filter=w(this,V,Ih).call(this,d);w(this,V,Kc).call(this,u,u,u,f),w(this,V,Np).call(this,f);const g=(v,_)=>{const b=a[v]/255,x=h[v]/255,C=new Array(_+1);for(let A=0;A<=_;A++)C[A]=b+A/_*(x-b);return C.join(",")};return w(this,V,Kc).call(this,g(0,5),g(1,5),g(2,5),f),r.url=w(this,V,Fh).call(this,d),r.url}addAlphaFilter(e){let s=l(this,V,je).get(e);if(s)return s;const[i]=w(this,V,rf).call(this,[e]),n=`alpha_${i}`;if(s=l(this,V,je).get(n),s)return l(this,V,je).set(e,s),s;const r=`g_${l(this,vn)}_alpha_map_${Ze(this,va)._++}`,a=w(this,V,Fh).call(this,r);l(this,V,je).set(e,a),l(this,V,je).set(n,a);const h=w(this,V,Ih).call(this,r);return w(this,V,Bp).call(this,i,h),a}addLuminosityFilter(e){let s=l(this,V,je).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=w(this,V,rf).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=l(this,V,je).get(n),s)return l(this,V,je).set(e,s),s;const r=`g_${l(this,vn)}_luminosity_map_${Ze(this,va)._++}`,a=w(this,V,Fh).call(this,r);l(this,V,je).set(e,a),l(this,V,je).set(n,a);const h=w(this,V,Ih).call(this,r);return w(this,V,py).call(this,h),e&&w(this,V,Bp).call(this,i,h),a}addHighlightHCMFilter(e,s,i,n,r){var x;const a=`${s}-${i}-${n}-${r}`;let h=l(this,V,$c).get(e);if((h==null?void 0:h.key)===a||(h?((x=h.filter)==null||x.remove(),h.key=a,h.url="none",h.filter=null):(h={key:a,url:"none",filter:null},l(this,V,$c).set(e,h)),!s||!i))return h.url;const[c,u]=[s,i].map(w(this,V,Jc).bind(this));let d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),[g,p]=[n,r].map(w(this,V,Jc).bind(this));f<d&&([d,f,g,p]=[f,d,p,g]),l(this,V,Lh).style.color="";const v=(C,A,P)=>{const D=new Array(256),k=(f-d)/P,M=C/255,R=(A-C)/(255*P);let F=0;for(let I=0;I<=P;I++){const Y=Math.round(d+I*k),N=M+I*R;for(let H=F;H<=Y;H++)D[H]=N;F=Y+1}for(let I=F;I<256;I++)D[I]=D[F-1];return D.join(",")},_=`g_${l(this,vn)}_hcm_${e}_filter`,b=h.filter=w(this,V,Ih).call(this,_);return w(this,V,Np).call(this,b),w(this,V,Kc).call(this,v(g[0],p[0],5),v(g[1],p[1],5),v(g[2],p[2],5),b),h.url=w(this,V,Fh).call(this,_),h.url}destroy(e=!1){var s,i,n,r;e&&((s=l(this,ma))!=null&&s.size)||((i=l(this,mn))==null||i.parentNode.parentNode.remove(),m(this,mn,null),(n=l(this,Vo))==null||n.clear(),m(this,Vo,null),(r=l(this,ma))==null||r.clear(),m(this,ma,null),m(this,va,0))}}pa=new WeakMap,Vo=new WeakMap,mn=new WeakMap,vn=new WeakMap,Re=new WeakMap,ma=new WeakMap,va=new WeakMap,V=new WeakSet,je=function(){return l(this,Vo)||m(this,Vo,new Map)},$c=function(){return l(this,ma)||m(this,ma,new Map)},Lh=function(){if(!l(this,mn)){const e=l(this,Re).createElement("div"),{style:s}=e;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=l(this,Re).createElementNS(nn,"svg");i.setAttribute("width",0),i.setAttribute("height",0),m(this,mn,l(this,Re).createElementNS(nn,"defs")),e.append(i),i.append(l(this,mn)),l(this,Re).body.append(e)}return l(this,mn)},rf=function(e){if(e.length===1){const c=e[0],u=new Array(256);for(let f=0;f<256;f++)u[f]=c[f]/255;const d=u.join(",");return[d,d,d]}const[s,i,n]=e,r=new Array(256),a=new Array(256),h=new Array(256);for(let c=0;c<256;c++)r[c]=s[c]/255,a[c]=i[c]/255,h[c]=n[c]/255;return[r.join(","),a.join(","),h.join(",")]},Fh=function(e){if(l(this,pa)===void 0){m(this,pa,"");const s=l(this,Re).URL;s!==l(this,Re).baseURI&&(fd(s)?rt('#createUrl: ignore "data:"-URL for performance reasons.'):m(this,pa,s.split("#",1)[0]))}return`url(${l(this,pa)}#${e})`},py=function(e){const s=l(this,Re).createElementNS(nn,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(s)},Np=function(e){const s=l(this,Re).createElementNS(nn,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(s)},Ih=function(e){const s=l(this,Re).createElementNS(nn,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),l(this,V,Lh).append(s),s},qc=function(e,s,i){const n=l(this,Re).createElementNS(nn,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},Kc=function(e,s,i,n){const r=l(this,Re).createElementNS(nn,"feComponentTransfer");n.append(r),w(this,V,qc).call(this,r,"feFuncR",e),w(this,V,qc).call(this,r,"feFuncG",s),w(this,V,qc).call(this,r,"feFuncB",i)},Bp=function(e,s){const i=l(this,Re).createElementNS(nn,"feComponentTransfer");s.append(i),w(this,V,qc).call(this,i,"feFuncA",e)},Jc=function(e){return l(this,V,Lh).style.color=e,jg(getComputedStyle(l(this,V,Lh)).getPropertyValue("color"))};class Iv{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){Et("Abstract method `_fetch` called.")}}class jv extends Iv{async _fetch(t){const e=await dd(t,"arraybuffer");return new Uint8Array(e)}}Pe&&rt("Please use the `legacy` build in Node.js environments.");async function Nv(o){const e=await process.getBuiltinModule("fs").promises.readFile(o);return new Uint8Array(e)}class uS extends Fv{}class dS extends Dv{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Mt&&Mt.tagName.toUpperCase()==="SCRIPT"&&Mt.src||new URL("pdf-canvas.umd.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class fS extends Rv{async _fetch(t){return Nv(t)}}class gS extends Iv{async _fetch(t){return Nv(t)}}const Oe={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function zg(o,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),o.clip(i)}class Xg{getPattern(){Et("Abstract method `getPattern` called.")}}class pS extends Xg{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===Oe.STROKE||i===Oe.FILL){const r=e.current.getClippedPathBoundingBox(i,It(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,h=Math.ceil(r[3]-r[1])||1,c=e.cachedCanvases.getCanvas("pattern",a,h),u=c.context;u.clearRect(0,0,u.canvas.width,u.canvas.height),u.beginPath(),u.rect(0,0,u.canvas.width,u.canvas.height),u.translate(-r[0],-r[1]),s=q.transform(s,[1,0,0,1,r[0],r[1]]),u.transform(...e.baseTransform),this.matrix&&u.transform(...this.matrix),zg(u,this._bbox),u.fillStyle=this._createGradient(u),u.fill(),n=t.createPattern(c.canvas,"no-repeat");const d=new DOMMatrix(s);n.setTransform(d)}else zg(t,this._bbox),n=this._createGradient(t);return n}}function Ug(o,t,e,s,i,n,r,a){const h=t.coords,c=t.colors,u=o.data,d=o.width*4;let f;h[e+1]>h[s+1]&&(f=e,e=s,s=f,f=n,n=r,r=f),h[s+1]>h[i+1]&&(f=s,s=i,i=f,f=r,r=a,a=f),h[e+1]>h[s+1]&&(f=e,e=s,s=f,f=n,n=r,r=f);const g=(h[e]+t.offsetX)*t.scaleX,p=(h[e+1]+t.offsetY)*t.scaleY,v=(h[s]+t.offsetX)*t.scaleX,_=(h[s+1]+t.offsetY)*t.scaleY,b=(h[i]+t.offsetX)*t.scaleX,x=(h[i+1]+t.offsetY)*t.scaleY;if(p>=x)return;const C=c[n],A=c[n+1],P=c[n+2],D=c[r],k=c[r+1],M=c[r+2],R=c[a],F=c[a+1],I=c[a+2],Y=Math.round(p),N=Math.round(x);let H,at,j,W,it,kt,Ut,ne;for(let Wt=Y;Wt<=N;Wt++){if(Wt<_){const ft=Wt<p?0:(p-Wt)/(p-_);H=g-(g-v)*ft,at=C-(C-D)*ft,j=A-(A-k)*ft,W=P-(P-M)*ft}else{let ft;Wt>x?ft=1:_===x?ft=0:ft=(_-Wt)/(_-x),H=v-(v-b)*ft,at=D-(D-R)*ft,j=k-(k-F)*ft,W=M-(M-I)*ft}let Tt;Wt<p?Tt=0:Wt>x?Tt=1:Tt=(p-Wt)/(p-x),it=g-(g-b)*Tt,kt=C-(C-R)*Tt,Ut=A-(A-F)*Tt,ne=P-(P-I)*Tt;const Ce=Math.round(Math.min(H,it)),Xs=Math.round(Math.max(H,it));let Dt=d*Wt+Ce*4;for(let ft=Ce;ft<=Xs;ft++)Tt=(H-ft)/(H-it),Tt<0?Tt=0:Tt>1&&(Tt=1),u[Dt++]=at-(at-kt)*Tt|0,u[Dt++]=j-(j-Ut)*Tt|0,u[Dt++]=W-(W-ne)*Tt|0,u[Dt++]=255}}function mS(o,t,e){const s=t.coords,i=t.colors;let n,r;switch(t.type){case"lattice":const a=t.verticesPerRow,h=Math.floor(s.length/a)-1,c=a-1;for(n=0;n<h;n++){let u=n*a;for(let d=0;d<c;d++,u++)Ug(o,e,s[u],s[u+1],s[u+a],i[u],i[u+1],i[u+a]),Ug(o,e,s[u+a+1],s[u+1],s[u+a],i[u+a+1],i[u+1],i[u+a])}break;case"triangles":for(n=0,r=s.length;n<r;n+=3)Ug(o,e,s[n],s[n+1],s[n+2],i[n],i[n+1],i[n+2]);break;default:throw new Error("illegal figure")}}class vS extends Xg{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,s){const a=Math.floor(this._bounds[0]),h=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-a,u=Math.ceil(this._bounds[3])-h,d=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(u*t[1]*1.1)),3e3),g=c/d,p=u/f,v={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-h,scaleX:1/g,scaleY:1/p},_=d+2*2,b=f+2*2,x=s.getCanvas("mesh",_,b),C=x.context,A=C.createImageData(d,f);if(e){const D=A.data;for(let k=0,M=D.length;k<M;k+=4)D[k]=e[0],D[k+1]=e[1],D[k+2]=e[2],D[k+3]=255}for(const D of this._figures)mS(A,D,v);return C.putImageData(A,2,2),{canvas:x.canvas,offsetX:a-2*g,offsetY:h-2*p,scaleX:g,scaleY:p}}getPattern(t,e,s,i){zg(t,this._bbox);let n;if(i===Oe.SHADING)n=q.singularValueDecompose2dScale(It(t));else if(n=q.singularValueDecompose2dScale(e.baseTransform),this.matrix){const a=q.singularValueDecompose2dScale(this.matrix);n=[n[0]*a[0],n[1]*a[1]]}const r=this._createMeshCanvas(n,i===Oe.SHADING?null:this._background,e.cachedCanvases);return i!==Oe.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class bS extends Xg{getPattern(){return"hotpink"}}function yS(o){switch(o[0]){case"RadialAxial":return new pS(o);case"Mesh":return new vS(o);case"Dummy":return new bS}throw new Error(`Unknown IR type: ${o[0]}`)}const Bv={COLORED:1,UNCOLORED:2},Ld=class Ld{constructor(t,e,s,i,n){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.color=e,this.ctx=s,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:s,paintType:i,tilingType:n,color:r,canvasGraphicsFactory:a}=this;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),ld("TilingType: "+n);const u=e[0],d=e[1],f=e[2],g=e[3],p=f-u,v=g-d,_=q.singularValueDecompose2dScale(this.matrix),b=q.singularValueDecompose2dScale(this.baseTransform),x=_[0]*b[0],C=_[1]*b[1];let A=p,P=v,D=!1,k=!1;const M=Math.ceil(h*x),R=Math.ceil(c*C),F=Math.ceil(p*x),I=Math.ceil(v*C);M>=F?A=h:D=!0,R>=I?P=c:k=!0;const Y=this.getSizeAndScale(A,this.ctx.canvas.width,x),N=this.getSizeAndScale(P,this.ctx.canvas.height,C),H=t.cachedCanvases.getCanvas("pattern",Y.size,N.size),at=H.context,j=a.createCanvasGraphics(at);if(j.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(j,i,r),at.translate(-Y.scale*u,-N.scale*d),j.transform(Y.scale,0,0,N.scale,0,0),at.save(),this.clipBbox(j,u,d,f,g),j.baseTransform=It(j.ctx),j.executeOperatorList(s),j.endDrawing(),at.restore(),D||k){const W=H.canvas;D&&(A=h),k&&(P=c);const it=this.getSizeAndScale(A,this.ctx.canvas.width,x),kt=this.getSizeAndScale(P,this.ctx.canvas.height,C),Ut=it.size,ne=kt.size,Wt=t.cachedCanvases.getCanvas("pattern-workaround",Ut,ne),Tt=Wt.context,Ce=D?Math.floor(p/h):0,Xs=k?Math.floor(v/c):0;for(let Dt=0;Dt<=Ce;Dt++)for(let ft=0;ft<=Xs;ft++)Tt.drawImage(W,Ut*Dt,ne*ft,Ut,ne,0,0,Ut,ne);return{canvas:Wt.canvas,scaleX:it.scale,scaleY:kt.scale,offsetX:u,offsetY:d}}return{canvas:H.canvas,scaleX:Y.scale,scaleY:N.scale,offsetX:u,offsetY:d}}getSizeAndScale(t,e,s){const i=Math.max(Ld.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const r=i-e,a=n-s;t.ctx.rect(e,s,r,a),t.current.updateRectMinMax(It(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case Bv.COLORED:const r=this.ctx;i.fillStyle=r.fillStyle,i.strokeStyle=r.strokeStyle,n.fillColor=r.fillStyle,n.strokeColor=r.strokeStyle;break;case Bv.UNCOLORED:const a=q.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new Xx(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==Oe.SHADING&&(n=q.transform(n,e.baseTransform),this.matrix&&(n=q.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const h=t.createPattern(r.canvas,"repeat");return h.setTransform(a),h}};J(Ld,"MAX_PATTERN_SIZE",3e3);let Yg=Ld;function _S({src:o,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const a=ze.isLittleEndian?4278190080:255,[h,c]=r?[n,a]:[a,n],u=s>>3,d=s&7,f=o.length;e=new Uint32Array(e.buffer);let g=0;for(let p=0;p<i;p++){for(const _=t+u;t<_;t++){const b=t<f?o[t]:255;e[g++]=b&128?c:h,e[g++]=b&64?c:h,e[g++]=b&32?c:h,e[g++]=b&16?c:h,e[g++]=b&8?c:h,e[g++]=b&4?c:h,e[g++]=b&2?c:h,e[g++]=b&1?c:h}if(d===0)continue;const v=t<f?o[t++]:255;for(let _=0;_<d;_++)e[g++]=v&1<<7-_?c:h}return{srcPos:t,destPos:g}}const Hv=16,Gv=100,wS=15,Vv=10,Wv=1e3,ns=16;function xS(o,t){if(o._removeMirroring)throw new Error("Context is already forwarding operations.");o.__originalSave=o.save,o.__originalRestore=o.restore,o.__originalRotate=o.rotate,o.__originalScale=o.scale,o.__originalTranslate=o.translate,o.__originalTransform=o.transform,o.__originalSetTransform=o.setTransform,o.__originalResetTransform=o.resetTransform,o.__originalClip=o.clip,o.__originalMoveTo=o.moveTo,o.__originalLineTo=o.lineTo,o.__originalBezierCurveTo=o.bezierCurveTo,o.__originalRect=o.rect,o.__originalClosePath=o.closePath,o.__originalBeginPath=o.beginPath,o._removeMirroring=()=>{o.save=o.__originalSave,o.restore=o.__originalRestore,o.rotate=o.__originalRotate,o.scale=o.__originalScale,o.translate=o.__originalTranslate,o.transform=o.__originalTransform,o.setTransform=o.__originalSetTransform,o.resetTransform=o.__originalResetTransform,o.clip=o.__originalClip,o.moveTo=o.__originalMoveTo,o.lineTo=o.__originalLineTo,o.bezierCurveTo=o.__originalBezierCurveTo,o.rect=o.__originalRect,o.closePath=o.__originalClosePath,o.beginPath=o.__originalBeginPath,delete o._removeMirroring},o.save=function(){t.save(),this.__originalSave()},o.restore=function(){t.restore(),this.__originalRestore()},o.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},o.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},o.transform=function(s,i,n,r,a,h){t.transform(s,i,n,r,a,h),this.__originalTransform(s,i,n,r,a,h)},o.setTransform=function(s,i,n,r,a,h){t.setTransform(s,i,n,r,a,h),this.__originalSetTransform(s,i,n,r,a,h)},o.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},o.rotate=function(s){t.rotate(s),this.__originalRotate(s)},o.clip=function(s){t.clip(s),this.__originalClip(s)},o.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},o.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},o.bezierCurveTo=function(e,s,i,n,r,a){t.bezierCurveTo(e,s,i,n,r,a),this.__originalBezierCurveTo(e,s,i,n,r,a)},o.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},o.closePath=function(){t.closePath(),this.__originalClosePath()},o.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class SS{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function bd(o,t,e,s,i,n,r,a,h,c){const[u,d,f,g,p,v]=It(o);if(d===0&&f===0){const x=r*u+p,C=Math.round(x),A=a*g+v,P=Math.round(A),D=(r+h)*u+p,k=Math.abs(Math.round(D)-C)||1,M=(a+c)*g+v,R=Math.abs(Math.round(M)-P)||1;return o.setTransform(Math.sign(u),0,0,Math.sign(g),C,P),o.drawImage(t,e,s,i,n,0,0,k,R),o.setTransform(u,d,f,g,p,v),[k,R]}if(u===0&&g===0){const x=a*f+p,C=Math.round(x),A=r*d+v,P=Math.round(A),D=(a+c)*f+p,k=Math.abs(Math.round(D)-C)||1,M=(r+h)*d+v,R=Math.abs(Math.round(M)-P)||1;return o.setTransform(0,Math.sign(d),Math.sign(f),0,C,P),o.drawImage(t,e,s,i,n,0,0,R,k),o.setTransform(u,d,f,g,p,v),[R,k]}o.drawImage(t,e,s,i,n,r,a,h,c);const _=Math.hypot(u,d),b=Math.hypot(f,g);return[_*h,b*c]}function CS(o){const{width:t,height:e}=o;if(t>Wv||e>Wv)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let r=new Uint8Array(n*(e+1)),a,h,c;const u=t+7&-8;let d=new Uint8Array(u*e),f=0;for(const b of o.data){let x=128;for(;x>0;)d[f++]=b&x?0:255,x>>=1}let g=0;for(f=0,d[f]!==0&&(r[0]=1,++g),h=1;h<t;h++)d[f]!==d[f+1]&&(r[h]=d[f]?2:1,++g),f++;for(d[f]!==0&&(r[h]=2,++g),a=1;a<e;a++){f=a*u,c=a*n,d[f-u]!==d[f]&&(r[c]=d[f]?1:8,++g);let b=(d[f]?4:0)+(d[f-u]?8:0);for(h=1;h<t;h++)b=(b>>2)+(d[f+1]?4:0)+(d[f-u+1]?8:0),i[b]&&(r[c+h]=i[b],++g),f++;if(d[f-u]!==d[f]&&(r[c+h]=d[f]?2:4,++g),g>s)return null}for(f=u*(e-1),c=a*n,d[f]!==0&&(r[c]=8,++g),h=1;h<t;h++)d[f]!==d[f+1]&&(r[c+h]=d[f]?4:8,++g),f++;if(d[f]!==0&&(r[c+h]=4,++g),g>s)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),v=new Path2D;for(a=0;g&&a<=e;a++){let b=a*n;const x=b+t;for(;b<x&&!r[b];)b++;if(b===x)continue;v.moveTo(b%n,a);const C=b;let A=r[b];do{const P=p[A];do b+=P;while(!r[b]);const D=r[b];D!==5&&D!==10?(A=D,r[b]=0):(A=D&51*A>>4,r[b]&=A>>2|A<<2),v.lineTo(b%n,b/n|0),r[b]||--g}while(C!==b);--a}return d=null,r=null,function(b){b.save(),b.scale(1/t,-1/e),b.translate(0,-e),b.fill(v),b.beginPath(),b.restore()}}class zv{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Sv,this.textMatrixScale=1,this.fontMatrix=Tg,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Me.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=q.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=q.applyTransform(e,t),i=q.applyTransform(e.slice(2),t),n=q.applyTransform([e[0],e[3]],t),r=q.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],r[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],r[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],r[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],r[1])}updateScalingPathMinMax(t,e){q.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,i,n,r,a,h,c,u){const d=q.bezierBoundingBox(e,s,i,n,r,a,h,c,u);u||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Oe.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Oe.STROKE){e||Et("Stroke bounding box must include transform.");const i=q.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,r=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=r,s[2]+=n,s[3]+=r}return s}updateClipFromPath(){const t=q.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Oe.FILL,e=null){return q.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Xv(o,t){if(t instanceof ImageData){o.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%ns,n=(e-i)/ns,r=i===0?n:n+1,a=o.createImageData(s,ns);let h=0,c;const u=t.data,d=a.data;let f,g,p,v;if(t.kind===ad.GRAYSCALE_1BPP){const _=u.byteLength,b=new Uint32Array(d.buffer,0,d.byteLength>>2),x=b.length,C=s+7>>3,A=4294967295,P=ze.isLittleEndian?4278190080:255;for(f=0;f<r;f++){for(p=f<n?ns:i,c=0,g=0;g<p;g++){const D=_-h;let k=0;const M=D>C?s:D*8-7,R=M&-8;let F=0,I=0;for(;k<R;k+=8)I=u[h++],b[c++]=I&128?A:P,b[c++]=I&64?A:P,b[c++]=I&32?A:P,b[c++]=I&16?A:P,b[c++]=I&8?A:P,b[c++]=I&4?A:P,b[c++]=I&2?A:P,b[c++]=I&1?A:P;for(;k<M;k++)F===0&&(I=u[h++],F=128),b[c++]=I&F?A:P,F>>=1}for(;c<x;)b[c++]=0;o.putImageData(a,0,f*ns)}}else if(t.kind===ad.RGBA_32BPP){for(g=0,v=s*ns*4,f=0;f<n;f++)d.set(u.subarray(h,h+v)),h+=v,o.putImageData(a,0,g),g+=ns;f<r&&(v=s*i*4,d.set(u.subarray(h,h+v)),o.putImageData(a,0,g))}else if(t.kind===ad.RGB_24BPP)for(p=ns,v=s*p,f=0;f<r;f++){for(f>=n&&(p=i,v=s*p),c=0,g=v;g--;)d[c++]=u[h++],d[c++]=u[h++],d[c++]=u[h++],d[c++]=255;o.putImageData(a,0,f*ns)}else throw new Error(`bad image kind: ${t.kind}`)}function Uv(o,t){if(t.bitmap){o.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%ns,n=(e-i)/ns,r=i===0?n:n+1,a=o.createImageData(s,ns);let h=0;const c=t.data,u=a.data;for(let d=0;d<r;d++){const f=d<n?ns:i;({srcPos:h}=_S({src:c,srcPos:h,dest:u,width:s,height:f,nonBlackColor:0})),o.putImageData(a,0,d*ns)}}function ul(o,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)o[s]!==void 0&&(t[s]=o[s]);o.setLineDash!==void 0&&(t.setLineDash(o.getLineDash()),t.lineDashOffset=o.lineDashOffset)}function yd(o){if(o.strokeStyle=o.fillStyle="#000000",o.fillRule="nonzero",o.globalAlpha=1,o.lineWidth=1,o.lineCap="butt",o.lineJoin="miter",o.miterLimit=10,o.globalCompositeOperation="source-over",o.font="10px sans-serif",o.setLineDash!==void 0&&(o.setLineDash([]),o.lineDashOffset=0),!Pe){const{filter:t}=o;t!=="none"&&t!==""&&(o.filter="none")}}function Yv(o,t){if(t)return!0;const e=q.singularValueDecompose2dScale(o);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Kn.PDF_TO_CSS_UNITS);return e[0]<=s&&e[1]<=s}const AS=["butt","round","square"],TS=["miter","round","bevel"],ES={},$v={},dp=class dp{constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},h,c){y(this,li);this.ctx=t,this.current=new zv(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=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.processingType3=null,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=r,this.cachedCanvases=new SS(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=h,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){const h=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=h.canvas,this.ctx=h.context,this.ctx.save(),this.ctx.transform(...It(this.compositeCtx))}this.ctx.save(),yd(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=It(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,r=t.fnArray;let a=e||0;const h=n.length;if(h===a)return a;const c=h-a>Vv&&typeof s=="function",u=c?Date.now()+wS:0;let d=0;const f=this.commonObjs,g=this.objs;let p;for(;;){if(i!==void 0&&a===i.nextBreakPoint)return i.breakIt(a,s),a;if(p=r[a],p!==si.dependency)this[p].apply(this,n[a]);else for(const v of n[a]){const _=v.startsWith("g_")?f:g;if(!_.has(v))return _.get(v,s),a}if(a++,a===h)return a;if(c&&++d>Vv){if(Date.now()>u)return s(),a;d=0}}}endDrawing(){w(this,li,Hp).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),w(this,li,Gp).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=s,h=i,c="prescale1",u,d;for(;n>2&&a>1||r>2&&h>1;){let f=a,g=h;n>2&&a>1&&(f=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),n/=a/f),r>2&&h>1&&(g=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,r/=h/g),u=this.cachedCanvases.getCanvas(c,f,g),d=u.context,d.clearRect(0,0,f,g),d.drawImage(t,0,0,a,h,0,0,f,g),t=u.canvas,a=f,h=g,c=c==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,r=this.current.patternFill,a=It(e);let h,c,u,d;if((t.bitmap||t.data)&&t.count>1){const M=t.bitmap||t.data.buffer;c=JSON.stringify(r?a:[a.slice(0,4),n]),h=this._cachedBitmapsMap.get(M),h||(h=new Map,this._cachedBitmapsMap.set(M,h));const R=h.get(c);if(R&&!r){const F=Math.round(Math.min(a[0],a[2])+a[4]),I=Math.round(Math.min(a[1],a[3])+a[5]);return{canvas:R,offsetX:F,offsetY:I}}u=R}u||(d=this.cachedCanvases.getCanvas("maskCanvas",s,i),Uv(d.context,t));let f=q.transform(a,[1/s,0,0,-1/i,0,0]);f=q.transform(f,[1,0,0,1,0,-i]);const[g,p,v,_]=q.getAxialAlignedBoundingBox([0,0,s,i],f),b=Math.round(v-g)||1,x=Math.round(_-p)||1,C=this.cachedCanvases.getCanvas("fillCanvas",b,x),A=C.context,P=g,D=p;A.translate(-P,-D),A.transform(...f),u||(u=this._scaleImage(d.canvas,Ai(A)),u=u.img,h&&r&&h.set(c,u)),A.imageSmoothingEnabled=Yv(It(A),t.interpolate),bd(A,u,0,0,u.width,u.height,0,0,s,i),A.globalCompositeOperation="source-in";const k=q.transform(Ai(A),[1,0,0,1,-P,-D]);return A.fillStyle=r?n.getPattern(e,this,k,Oe.FILL):n,A.fillRect(0,0,s,i),h&&!r&&(this.cachedCanvases.delete("fillCanvas"),h.set(c,C.canvas)),{canvas:C.canvas,offsetX:Math.round(P),offsetY:Math.round(D)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=AS[t]}setLineJoin(t){this.ctx.lineJoin=TS[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...It(this.suspendedCtx)),ul(this.suspendedCtx,n),xS(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),ul(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];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,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()}composeSMask(t,e,s,i){const n=i[0],r=i[1],a=i[2]-n,h=i[3]-r;a===0||h===0||(this.genericComposeSMask(e.context,s,a,h,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,r,a,h,c,u,d){let f=t.canvas,g=h-u,p=c-d;if(r){const _=q.makeHexColor(...r);if(g<0||p<0||g+s>f.width||p+i>f.height){const b=this.cachedCanvases.getCanvas("maskExtension",s,i),x=b.context;x.drawImage(f,-g,-p),x.globalCompositeOperation="destination-atop",x.fillStyle=_,x.fillRect(0,0,s,i),x.globalCompositeOperation="source-over",f=b.canvas,g=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const b=new Path2D;b.rect(g,p,s,i),t.clip(b),t.globalCompositeOperation="destination-atop",t.fillStyle=_,t.fillRect(g,p,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):n==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const v=new Path2D;v.rect(h,c,s,i),e.clip(v),e.globalCompositeOperation="destination-in",e.drawImage(f,g,p,s,i,h,c,s,i),e.restore()}save(){this.inSMaskMode?(ul(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),ul(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,r){this.ctx.transform(t,e,s,i,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let r=n.x,a=n.y,h,c;const u=It(i),d=u[0]===0&&u[3]===0||u[1]===0&&u[2]===0,f=d?s.slice(0):null;for(let g=0,p=0,v=t.length;g<v;g++)switch(t[g]|0){case si.rectangle:r=e[p++],a=e[p++];const _=e[p++],b=e[p++],x=r+_,C=a+b;i.moveTo(r,a),_===0||b===0?i.lineTo(x,C):(i.lineTo(x,a),i.lineTo(x,C),i.lineTo(r,C)),d||n.updateRectMinMax(u,[r,a,x,C]),i.closePath();break;case si.moveTo:r=e[p++],a=e[p++],i.moveTo(r,a),d||n.updatePathMinMax(u,r,a);break;case si.lineTo:r=e[p++],a=e[p++],i.lineTo(r,a),d||n.updatePathMinMax(u,r,a);break;case si.curveTo:h=r,c=a,r=e[p+4],a=e[p+5],i.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],r,a),n.updateCurvePathMinMax(u,h,c,e[p],e[p+1],e[p+2],e[p+3],r,a,f),p+=6;break;case si.curveTo2:h=r,c=a,i.bezierCurveTo(r,a,e[p],e[p+1],e[p+2],e[p+3]),n.updateCurvePathMinMax(u,h,c,r,a,e[p],e[p+1],e[p+2],e[p+3],f),r=e[p+2],a=e[p+3],p+=4;break;case si.curveTo3:h=r,c=a,r=e[p+2],a=e[p+3],i.bezierCurveTo(e[p],e[p+1],r,a,r,a),n.updateCurvePathMinMax(u,h,c,e[p],e[p+1],r,a,r,a,f),p+=4;break;case si.closePath:i.closePath();break}d&&n.updateScalingPathMinMax(u,f),n.setCurrentPoint(r,a)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof s=="object"&&(s!=null&&s.getPattern)?(e.save(),e.strokeStyle=s.getPattern(e,this,Ai(e),Oe.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;let n=!1;i&&(e.save(),e.fillStyle=s.getPattern(e,this,Ai(e),Oe.FILL),n=!0);const r=this.current.getClippedPathBoundingBox();this.contentVisible&&r!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=ES}eoClip(){this.pendingClip=$v}beginText(){this.current.textMatrix=Sv,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}const s=new Path2D,i=e.getTransform().invertSelf();for(const{transform:n,x:r,y:a,fontSize:h,path:c}of t)s.addPath(c,new DOMMatrix(n).preMultiplySelf(i).translate(r,a).scale(h,-h));e.clip(s),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var u;const s=this.commonObjs.get(t),i=this.current;if(!s)throw new Error(`Can't find font for ${t}`);if(i.fontMatrix=s.fontMatrix||Tg,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&rt("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const n=s.loadedName||"sans-serif",r=((u=s.systemFontInfo)==null?void 0:u.css)||`"${n}", ${s.fallbackName}`;let a="normal";s.black?a="900":s.bold&&(a="bold");const h=s.italic?"italic":"normal";let c=e;e<Hv?c=Hv:e>Gv&&(c=Gv),this.current.fontSizeScale=e/c,this.ctx.font=`${h} ${a} ${c}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,r){this.current.textMatrix=[t,e,s,i,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i,n){const r=this.ctx,a=this.current,h=a.font,c=a.textRenderingMode,u=a.fontSize/a.fontSizeScale,d=c&Me.FILL_STROKE_MASK,f=!!(c&Me.ADD_TO_PATH_FLAG),g=a.patternFill&&!h.missingFile,p=a.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||f||g||p)&&(v=h.getPathGenerator(this.commonObjs,t)),h.disableFontFace||g||p){if(r.save(),r.translate(e,s),r.scale(u,-u),d===Me.FILL||d===Me.FILL_STROKE)if(i){const _=r.getTransform();r.setTransform(...i),r.fill(w(this,li,Vp).call(this,v,_,i))}else r.fill(v);if(d===Me.STROKE||d===Me.FILL_STROKE)if(n){const _=r.getTransform();r.setTransform(...n),r.stroke(w(this,li,Vp).call(this,v,_,n))}else r.lineWidth/=u,r.stroke(v);r.restore()}else(d===Me.FILL||d===Me.FILL_STROKE)&&r.fillText(t,e,s),(d===Me.STROKE||d===Me.FILL_STROKE)&&r.strokeText(t,e,s);f&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:It(r),x:e,y:s,fontSize:u,path:v})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return ht(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,h=e.wordSpacing,c=e.fontDirection,u=e.textHScale*c,d=t.length,f=s.vertical,g=f?1:-1,p=s.defaultVMetrics,v=i*e.fontMatrix[0],_=e.textRenderingMode===Me.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),c>0?n.scale(u,-1):n.scale(u,1);let b,x;if(e.patternFill){n.save();const k=e.fillColor.getPattern(n,this,Ai(n),Oe.FILL);b=It(n),n.restore(),n.fillStyle=k}if(e.patternStroke){n.save();const k=e.strokeColor.getPattern(n,this,Ai(n),Oe.STROKE);x=It(n),n.restore(),n.strokeStyle=k}let C=e.lineWidth;const A=e.textMatrixScale;if(A===0||C===0){const k=e.textRenderingMode&Me.FILL_STROKE_MASK;(k===Me.STROKE||k===Me.FILL_STROKE)&&(C=this.getSinglePixelWidth())}else C/=A;if(r!==1&&(n.scale(r,r),C/=r),n.lineWidth=C,s.isInvalidPDFjsFont){const k=[];let M=0;for(const R of t)k.push(R.unicode),M+=R.width;n.fillText(k.join(""),0,0),e.x+=M*v*u,n.restore(),this.compose();return}let P=0,D;for(D=0;D<d;++D){const k=t[D];if(typeof k=="number"){P+=g*k*i/1e3;continue}let M=!1;const R=(k.isSpace?h:0)+a,F=k.fontChar,I=k.accent;let Y,N,H=k.width;if(f){const j=k.vmetric||p,W=-(k.vmetric?j[1]:H*.5)*v,it=j[2]*v;H=j?-j[0]:H,Y=W/r,N=(P+it)/r}else Y=P/r,N=0;if(s.remeasure&&H>0){const j=n.measureText(F).width*1e3/i*r;if(H<j&&this.isFontSubpixelAAEnabled){const W=H/j;M=!0,n.save(),n.scale(W,1),Y/=W}else H!==j&&(Y+=(H-j)/2e3*i/r)}if(this.contentVisible&&(k.isInFont||s.missingFile)){if(_&&!I)n.fillText(F,Y,N);else if(this.paintChar(F,Y,N,b,x),I){const j=Y+i*I.offset.x/r,W=N-i*I.offset.y/r;this.paintChar(I.fontChar,j,W,b,x)}}const at=f?H*v-R*c:H*v+R*c;P+=at,M&&n.restore()}f?e.y-=P:e.x+=P*u,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,r=s.fontDirection,a=i.vertical?1:-1,h=s.charSpacing,c=s.wordSpacing,u=s.textHScale*r,d=s.fontMatrix||Tg,f=t.length,g=s.textRenderingMode===Me.INVISIBLE;let p,v,_,b;if(!(g||n===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y),e.scale(u,r),p=0;p<f;++p){if(v=t[p],typeof v=="number"){b=a*v*n/1e3,this.ctx.translate(b,0),s.x+=b*u;continue}const x=(v.isSpace?c:0)+h,C=i.charProcOperatorList[v.operatorListId];if(!C){rt(`Type3 character "${v.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=v,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(C),this.restore()),_=q.applyTransform([v.width,0],d)[0]*n+x,e.translate(_,0),s.x+=_*u}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,r){this.ctx.rect(s,i,n-s,r-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){const s=t[1],i=this.baseTransform||It(this.ctx),n={createCanvasGraphics:r=>new dp(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Yg(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){this.ctx.strokeStyle=this.current.strokeColor=q.makeHexColor(t,e,s),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=q.makeHexColor(t,e,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=yS(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Ai(e),Oe.SHADING);const i=Ai(e);if(i){const{width:n,height:r}=e.canvas,[a,h,c,u]=q.getAxialAlignedBoundingBox([0,0,n,r],i);this.ctx.fillRect(a,h,c-a,u-h)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Et("Should not call beginInlineImage")}beginImageData(){Et("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=It(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(It(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||ld("TODO: Support non-isolated groups."),t.knockout&&rt("Knockout groups not supported.");const s=It(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=q.getAxialAlignedBoundingBox(t.bbox,It(e));const n=[0,0,e.canvas.width,e.canvas.height];i=q.intersect(i,n)||[0,0,0,0];const r=Math.floor(i[0]),a=Math.floor(i[1]),h=Math.max(Math.ceil(i[2])-r,1),c=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,h,c]);let u="groupAt"+this.groupLevel;t.smask&&(u+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(u,h,c),f=d.context;f.translate(-r,-a),f.transform(...s),t.smask?this.smaskStack.push({canvas:d.canvas,context:f,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),ul(e,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=It(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=q.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(w(this,li,Hp).call(this),yd(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const r=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=r,e[3]=a;const[h,c]=q.singularValueDecompose2dScale(It(this.ctx)),{viewportScale:u}=this,d=Math.ceil(r*this.outputScaleX*u),f=Math.ceil(a*this.outputScaleY*u);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:g,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(h,0,0,-c,0,a*c),yd(this.ctx)}else yd(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],r,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new zv(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),w(this,li,Gp).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;t=this.getObject(t.data,t),t.count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=CS(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const h=It(a);a.transform(e,s,i,n,0,0);const c=this._createMaskCanvas(t);a.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]);for(let u=0,d=r.length;u<d;u+=2){const f=q.transform(h,[e,s,i,n,r[u],r[u+1]]),[g,p]=q.applyTransform([0,0],f);a.drawImage(c.canvas,g,p)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:r,width:a,height:h,transform:c}=n,u=this.cachedCanvases.getCanvas("maskCanvas",a,h),d=u.context;d.save();const f=this.getObject(r,n);Uv(d,f),d.globalCompositeOperation="source-in",d.fillStyle=i?s.getPattern(d,this,Ai(e),Oe.FILL):s,d.fillRect(0,0,a,h),d.restore(),e.save(),e.transform(...c),e.scale(1,-1),bd(e,u.canvas,0,0,a,h,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);if(!e){rt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n){rt("Dependent image isn't ready yet");return}const r=n.width,a=n.height,h=[];for(let c=0,u=i.length;c<u;c+=2)h.push({transform:[e,0,0,s,i[c],i[c+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!Pe){const{filter:a}=i;a!=="none"&&a!==""&&(i.filter="none")}i.scale(1/e,-1/s);let n;if(t.bitmap)n=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)n=t;else{const h=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Xv(h,t),n=this.applyTransferMapsToCanvas(h)}const r=this._scaleImage(n,Ai(i));i.imageSmoothingEnabled=Yv(It(i),t.interpolate),bd(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const n=t.width,r=t.height,h=this.cachedCanvases.getCanvas("inlineImage",n,r).context;Xv(h,t),i=this.applyTransferMapsToCanvas(h)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),bd(s,i,n.x,n.y,n.w,n.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const s=this.ctx;this.pendingClip&&(e||(this.pendingClip===$v?s.clip("evenodd"):s.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=It(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let r,a;if(s===0&&i===0){const h=Math.abs(e),c=Math.abs(n);if(h===c)if(t===0)r=a=1/h;else{const u=h*t;r=a=u<1?1/u:1}else if(t===0)r=1/h,a=1/c;else{const u=h*t,d=c*t;r=u<1?1/u:1,a=d<1?1/d:1}}else{const h=Math.abs(e*n-s*i),c=Math.hypot(e,s),u=Math.hypot(i,n);if(t===0)r=u/h,a=c/h;else{const d=t*h;r=u>d?u/d:1,a=c>d?c/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}const r=e.getLineDash();if(t&&e.save(),e.scale(i,n),r.length>0){const a=Math.max(i,n);e.setLineDash(r.map(h=>h/a)),e.lineDashOffset/=a}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};li=new WeakSet,Hp=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},Gp=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Vp=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i};let xo=dp;for(const o in si)xo.prototype[o]!==void 0&&(xo.prototype[si[o]]=xo.prototype[o]);class rn{static get workerPort(){return l(this,Ul)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");m(this,Ul,t)}static get workerSrc(){return l(this,Yl)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");m(this,Yl,t)}}Ul=new WeakMap,Yl=new WeakMap,y(rn,Ul,null),y(rn,Yl,"");class kS{constructor({parsedData:t,rawData:e}){y(this,ba);y(this,$l);m(this,ba,t),m(this,$l,e)}getRaw(){return l(this,$l)}get(t){return l(this,ba).get(t)??null}getAll(){return Mg(l(this,ba))}has(t){return l(this,ba).has(t)}}ba=new WeakMap,$l=new WeakMap;const So=Symbol("INTERNAL");class PS{constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){y(this,ql,!1);y(this,Kl,!1);y(this,Jl,!1);y(this,Wo,!0);m(this,ql,!!(t&fs.DISPLAY)),m(this,Kl,!!(t&fs.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(l(this,Jl))return l(this,Wo);if(!l(this,Wo))return!1;const{print:t,view:e}=this.usage;return l(this,ql)?(e==null?void 0:e.viewState)!=="OFF":l(this,Kl)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==So&&Et("Internal method `_setVisible` called."),m(this,Jl,s),m(this,Wo,e)}}ql=new WeakMap,Kl=new WeakMap,Jl=new WeakMap,Wo=new WeakMap;class MS{constructor(t,e=fs.DISPLAY){y(this,Ql);y(this,ur,null);y(this,St,new Map);y(this,zo,null);y(this,Xo,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,m(this,Xo,t.order);for(const s of t.groups)l(this,St).set(s.id,new PS(e,s));if(t.baseState==="OFF")for(const s of l(this,St).values())s._setVisible(So,!1);for(const s of t.on)l(this,St).get(s)._setVisible(So,!0);for(const s of t.off)l(this,St).get(s)._setVisible(So,!1);m(this,zo,this.getHash())}}isVisible(t){if(l(this,St).size===0)return!0;if(!t)return ld("Optional content group not defined."),!0;if(t.type==="OCG")return l(this,St).has(t.id)?l(this,St).get(t.id).visible:(rt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return w(this,Ql,Wp).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!l(this,St).has(e))return rt(`Optional content group not found: ${e}`),!0;if(l(this,St).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!l(this,St).has(e))return rt(`Optional content group not found: ${e}`),!0;if(!l(this,St).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!l(this,St).has(e))return rt(`Optional content group not found: ${e}`),!0;if(!l(this,St).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!l(this,St).has(e))return rt(`Optional content group not found: ${e}`),!0;if(l(this,St).get(e).visible)return!1}return!0}return rt(`Unknown optional content policy ${t.policy}.`),!0}return rt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var n;const i=l(this,St).get(t);if(!i){rt(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const r of i.rbGroups)for(const a of r)a!==t&&((n=l(this,St).get(a))==null||n._setVisible(So,!1,!0));i._setVisible(So,!!e,!0),m(this,ur,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=l(this,St).get(i);if(n)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!n.visible,e);break}}m(this,ur,null)}get hasInitialVisibility(){return l(this,zo)===null||this.getHash()===l(this,zo)}getOrder(){return l(this,St).size?l(this,Xo)?l(this,Xo).slice():[...l(this,St).keys()]:null}getGroups(){return l(this,St).size>0?Mg(l(this,St)):null}getGroup(t){return l(this,St).get(t)||null}getHash(){if(l(this,ur)!==null)return l(this,ur);const t=new Pv;for(const[e,s]of l(this,St))t.update(`${e}:${s.visible}`);return m(this,ur,t.hexdigest())}}ur=new WeakMap,St=new WeakMap,zo=new WeakMap,Xo=new WeakMap,Ql=new WeakSet,Wp=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let r;if(Array.isArray(n))r=w(this,Ql,Wp).call(this,n);else if(l(this,St).has(n))r=l(this,St).get(n).visible;else return rt(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"};class OS{constructor(t,{disableRange:e=!1,disableStream:s=!1}){ee(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,(n==null?void 0:n.length)>0){const h=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(h)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((h,c)=>{this._onReceiveData({begin:h,chunk:c})}),t.addProgressListener((h,c)=>{this._onProgress({loaded:h,total:c})}),t.addProgressiveReadListener(h=>{this._onReceiveData({chunk:h})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(n){return n._begin!==t?!1:(n._enqueue(s),!0)});ee(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,s,i,n;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(n=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||n.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){ee(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new DS(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new RS(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class DS{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Fg(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class RS{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.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){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function LS(o){let t=!0,e=s("filename\\*","i").exec(o);if(e){e=e[1];let u=a(e);return u=unescape(u),u=h(u),u=c(u),n(u)}if(e=r(o),e){const u=c(e);return n(u)}if(e=s("filename","i").exec(o),e){e=e[1];let u=a(e);return u=c(u),n(u)}function s(u,d){return new RegExp("(?:^|;)\\s*"+u+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(u,d){if(u){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const f=new TextDecoder(u,{fatal:!0}),g=ud(d);d=f.decode(g),t=!1}catch{}}return d}function n(u){return t&&/[\x80-\xff]/.test(u)&&(u=i("utf-8",u),t&&(u=i("iso-8859-1",u))),u}function r(u){const d=[];let f;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=g.exec(u))!==null;){let[,v,_,b]=f;if(v=parseInt(v,10),v in d){if(v===0)break;continue}d[v]=[_,b]}const p=[];for(let v=0;v<d.length&&v in d;++v){let[_,b]=d[v];b=a(b),_&&(b=unescape(b),v===0&&(b=h(b))),p.push(b)}return p.join("")}function a(u){if(u.startsWith('"')){const d=u.slice(1).split('\\"');for(let f=0;f<d.length;++f){const g=d[f].indexOf('"');g!==-1&&(d[f]=d[f].slice(0,g),d.length=f+1),d[f]=d[f].replaceAll(/\\(.)/g,"$1")}u=d.join('"')}return u}function h(u){const d=u.indexOf("'");if(d===-1)return u;const f=u.slice(0,d),p=u.slice(d+1).replace(/^[^']*'/,"");return i(f,p)}function c(u){return!u.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(u)?u:u.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,f,g,p){if(g==="q"||g==="Q")return p=p.replaceAll("_"," "),p=p.replaceAll(/=([0-9a-fA-F]{2})/g,function(v,_){return String.fromCharCode(parseInt(_,16))}),i(f,p);try{p=atob(p)}catch{}return i(f,p)})}return""}function qv(o,t){const e=new Headers;if(!o||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function _d(o){try{return new URL(o).origin}catch{}return null}function Kv({responseHeaders:o,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(o.get("Content-Length"),10);return!Number.isInteger(n)||(i.suggestedLength=n,n<=2*e)||s||!t||o.get("Accept-Ranges")!=="bytes"||(o.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function Jv(o){const t=o.get("Content-Disposition");if(t){let e=LS(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Fg(e))return e}return null}function wd(o,t){return o===404||o===0&&t.startsWith("file:")?new al('Missing PDF "'+t+'".'):new cd(`Unexpected server response (${o}) while retrieving PDF "${t}".`,o)}function Qv(o){return o===200||o===206}function Zv(o,t,e){return{method:"GET",headers:o,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function tb(o){return o instanceof Uint8Array?o.buffer:o instanceof ArrayBuffer?o:(rt(`getArrayBuffer - unexpected data format: ${o}`),new Uint8Array(o).buffer)}class eb{constructor(t){J(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=qv(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return ee(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new FS(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new IS(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class FS{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 s=new Headers(t.headers),i=e.url;fetch(i,Zv(s,this._withCredentials,this._abortController)).then(n=>{if(t._responseOrigin=_d(n.url),!Qv(n.status))throw wd(n.status,i);this._reader=n.body.getReader(),this._headersCapability.resolve();const r=n.headers,{allowRangeRequests:a,suggestedLength:h}=Kv({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=h||this._contentLength,this._filename=Jv(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new qn("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(){var s;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:tb(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class IS{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${s-1}`);const r=i.url;fetch(r,Zv(n,this._withCredentials,this._abortController)).then(a=>{const h=_d(a.url);if(h!==t._responseOrigin)throw new Error(`Expected range response-origin "${h}" to match "${t._responseOrigin}".`);if(!Qv(a.status))throw wd(a.status,r);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:tb(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const $g=200,qg=206;function jS(o){const t=o.response;return typeof t!="string"?t:ud(t).buffer}class NS{constructor({url:t,httpHeaders:e,withCredentials:s}){J(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=qv(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[n,r]of this.headers)e.setRequestHeader(n,r);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=qg):i.expectedStatus=$g,e.responseType="arraybuffer",ee(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&((i=s.onProgress)==null||i.call(s,e))}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError(i.status);return}const n=i.status||$g;if(!(n===$g&&s.expectedStatus===qg)&&n!==s.expectedStatus){s.onError(i.status);return}const a=jS(i);if(n===qg){const h=i.getResponseHeader("Content-Range"),c=/bytes (\d+)-(\d+)\/(\d+)/.exec(h);c?s.onDone({begin:parseInt(c[1],10),chunk:a}):(rt('Missing or invalid "Content-Range" header.'),s.onError(0))}else a?s.onDone({begin:0,chunk:a}):s.onError(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class BS{constructor(t){this._source=t,this._manager=new NS(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return ee(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new HS(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new GS(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class HS{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(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=_d(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(a=>{const[h,...c]=a.split(": ");return[h,c.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:r}=Kv({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Jv(i),this._isRangeSupported&&this._manager.abortRequest(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(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=wd(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of 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 GS{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,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(){var e;const t=_d((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=wd(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const VS=/^[a-z][a-z0-9\-+.]+:/i;function WS(o){if(VS.test(o))return new URL(o);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(o))}class zS{constructor(t){this.source=t,this.url=WS(t.url),ee(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return ee(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new XS(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new US(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class XS{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 s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=new al(`Missing PDF "${this._url}".`)),this._storedError=i,this._headersCapability.reject(i)})}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(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new qn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class US{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const i=t.source;this._isStreamingSupported=!i.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const YS=1e5,rs=30,$S=.8,le=class le{constructor({textContentSource:t,container:e,viewport:s}){y(this,yn);y(this,dr,Promise.withResolvers());y(this,os,null);y(this,Zl,!1);y(this,tc,!!((yb=globalThis.FontInspector)!=null&&yb.enabled));y(this,ya,null);y(this,bn,null);y(this,ec,0);y(this,sc,0);y(this,_a,null);y(this,Uo,null);y(this,Yo,0);y(this,fr,0);y(this,$o,Object.create(null));y(this,ic,[]);y(this,qo,null);y(this,wa,[]);y(this,nc,new WeakMap);y(this,rc,null);var h;if(t instanceof ReadableStream)m(this,qo,t);else if(typeof t=="object")m(this,qo,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');m(this,os,m(this,Uo,e)),m(this,fr,s.scale*(globalThis.devicePixelRatio||1)),m(this,Yo,s.rotation),m(this,bn,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:r,pageY:a}=s.rawDims;m(this,rc,[1,0,0,-1,-r,a+n]),m(this,sc,i),m(this,ec,n),w(h=le,bs,by).call(h),zr(e,s),l(this,dr).promise.finally(()=>{l(le,Ko).delete(this),m(this,bn,null),m(this,$o,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ze.platform;return ht(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{l(this,_a).read().then(({value:e,done:s})=>{if(s){l(this,dr).resolve();return}l(this,ya)??m(this,ya,e.lang),Object.assign(l(this,$o),e.styles),w(this,yn,my).call(this,e.items),t()},l(this,dr).reject)};return m(this,_a,l(this,qo).getReader()),l(le,Ko).add(this),t(),l(this,dr).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==l(this,Yo)&&(e==null||e(),m(this,Yo,i),zr(l(this,Uo),{rotation:i})),s!==l(this,fr)){e==null||e(),m(this,fr,s);const r={div:null,properties:null,ctx:w(n=le,bs,af).call(n,l(this,ya))};for(const a of l(this,wa))r.properties=l(this,nc).get(a),r.div=a,w(this,yn,zp).call(this,r)}}cancel(){var e;const t=new qn("TextLayer task cancelled.");(e=l(this,_a))==null||e.cancel(t).catch(()=>{}),m(this,_a,null),l(this,dr).reject(t)}get textDivs(){return l(this,wa)}get textContentItemsStr(){return l(this,ic)}static cleanup(){if(!(l(this,Ko).size>0)){l(this,xa).clear();for(const{canvas:t}of l(this,Sa).values())t.remove();l(this,Sa).clear()}}};dr=new WeakMap,os=new WeakMap,Zl=new WeakMap,tc=new WeakMap,ya=new WeakMap,bn=new WeakMap,ec=new WeakMap,sc=new WeakMap,_a=new WeakMap,Uo=new WeakMap,Yo=new WeakMap,fr=new WeakMap,$o=new WeakMap,ic=new WeakMap,qo=new WeakMap,wa=new WeakMap,nc=new WeakMap,rc=new WeakMap,xa=new WeakMap,Sa=new WeakMap,ac=new WeakMap,gr=new WeakMap,Ko=new WeakMap,yn=new WeakSet,my=function(t){var i,n;if(l(this,Zl))return;(n=l(this,bn)).ctx??(n.ctx=w(i=le,bs,af).call(i,l(this,ya)));const e=l(this,wa),s=l(this,ic);for(const r of t){if(e.length>YS){rt("Ignoring additional textDivs for performance reasons."),m(this,Zl,!0);return}if(r.str===void 0){if(r.type==="beginMarkedContentProps"||r.type==="beginMarkedContent"){const a=l(this,os);m(this,os,document.createElement("span")),l(this,os).classList.add("markedContent"),r.id!==null&&l(this,os).setAttribute("id",`${r.id}`),a.append(l(this,os))}else r.type==="endMarkedContent"&&m(this,os,l(this,os).parentNode);continue}s.push(r.str),w(this,yn,vy).call(this,r)}},vy=function(t){var v;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};l(this,wa).push(e);const i=q.transform(l(this,rc),t.transform);let n=Math.atan2(i[1],i[0]);const r=l(this,$o)[t.fontName];r.vertical&&(n+=Math.PI/2);let a=l(this,tc)&&r.fontSubstitution||r.fontFamily;a=le.fontFamilyMap.get(a)||a;const h=Math.hypot(i[2],i[3]),c=h*w(v=le,bs,yy).call(v,a,l(this,ya));let u,d;n===0?(u=i[4],d=i[5]-c):(u=i[4]+c*Math.sin(n),d=i[5]-c*Math.cos(n));const f="calc(var(--scale-factor)*",g=e.style;l(this,os)===l(this,Uo)?(g.left=`${(100*u/l(this,sc)).toFixed(2)}%`,g.top=`${(100*d/l(this,ec)).toFixed(2)}%`):(g.left=`${f}${u.toFixed(2)}px)`,g.top=`${f}${d.toFixed(2)}px)`),g.fontSize=`${f}${(l(le,gr)*h).toFixed(2)}px)`,g.fontFamily=a,s.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,l(this,tc)&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const _=Math.abs(t.transform[0]),b=Math.abs(t.transform[3]);_!==b&&Math.max(_,b)/Math.min(_,b)>1.5&&(p=!0)}if(p&&(s.canvasWidth=r.vertical?t.height:t.width),l(this,nc).set(e,s),l(this,bn).div=e,l(this,bn).properties=s,w(this,yn,zp).call(this,l(this,bn)),s.hasText&&l(this,os).append(e),s.hasEOL){const _=document.createElement("br");_.setAttribute("role","presentation"),l(this,os).append(_)}},zp=function(t){var a;const{div:e,properties:s,ctx:i}=t,{style:n}=e;let r="";if(l(le,gr)>1&&(r=`scale(${1/l(le,gr)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:h}=n,{canvasWidth:c,fontSize:u}=s;w(a=le,bs,Xp).call(a,i,u*l(this,fr),h);const{width:d}=i.measureText(e.textContent);d>0&&(r=`scaleX(${c*l(this,fr)/d}) ${r}`)}s.angle!==0&&(r=`rotate(${s.angle}deg) ${r}`),r.length>0&&(n.transform=r)},bs=new WeakSet,af=function(t=null){let e=l(this,Sa).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),l(this,Sa).set(t,e),l(this,ac).set(e,{size:0,family:""})}return e},Xp=function(t,e,s){const i=l(this,ac).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},by=function(){if(l(this,gr)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),m(this,gr,t.getBoundingClientRect().height),t.remove()},yy=function(t,e){const s=l(this,xa).get(t);if(s)return s;const i=w(this,bs,af).call(this,e);i.canvas.width=i.canvas.height=rs,w(this,bs,Xp).call(this,i,rs,t);const n=i.measureText("");let r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){const u=r/(r+a);return l(this,xa).set(t,u),i.canvas.width=i.canvas.height=0,u}i.strokeStyle="red",i.clearRect(0,0,rs,rs),i.strokeText("g",0,0);let h=i.getImageData(0,0,rs,rs).data;a=0;for(let u=h.length-1-3;u>=0;u-=4)if(h[u]>0){a=Math.ceil(u/4/rs);break}i.clearRect(0,0,rs,rs),i.strokeText("A",0,rs),h=i.getImageData(0,0,rs,rs).data,r=0;for(let u=0,d=h.length;u<d;u+=4)if(h[u]>0){r=rs-Math.floor(u/4/rs);break}i.canvas.width=i.canvas.height=0;const c=r?r/(r+a):$S;return l(this,xa).set(t,c),c},y(le,bs),y(le,xa,new Map),y(le,Sa,new Map),y(le,ac,new WeakMap),y(le,gr,null),y(le,Ko,new Set);let dl=le;class fl{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){var h;if(!n)return;let r=null;const a=n.name;if(a==="#text")r=n.value;else if(fl.shouldBuildText(a))(h=n==null?void 0:n.attributes)!=null&&h.textContent?r=n.attributes.textContent:n.value&&(r=n.value);else return;if(r!==null&&e.push({str:r}),!!n.children)for(const c of n.children)i(c)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const qS=65536,KS=100,JS=5e3,QS=Pe?dS:lS,ZS=Pe?fS:Lv,tC=Pe?uS:cS,eC=Pe?gS:jv;function sC(o={}){typeof o=="string"||o instanceof URL?o={url:o}:(o instanceof ArrayBuffer||ArrayBuffer.isView(o))&&(o={data:o});const t=new Kg,{docId:e}=t,s=o.url?iC(o.url):null,i=o.data?nC(o.data):null,n=o.httpHeaders||null,r=o.withCredentials===!0,a=o.password??null,h=o.range instanceof ib?o.range:null,c=Number.isInteger(o.rangeChunkSize)&&o.rangeChunkSize>0?o.rangeChunkSize:qS;let u=o.worker instanceof Co?o.worker:null;const d=o.verbosity,f=typeof o.docBaseUrl=="string"&&!fd(o.docBaseUrl)?o.docBaseUrl:null,g=typeof o.cMapUrl=="string"?o.cMapUrl:null,p=o.cMapPacked!==!1,v=o.CMapReaderFactory||ZS,_=typeof o.standardFontDataUrl=="string"?o.standardFontDataUrl:null,b=o.StandardFontDataFactory||eC,x=o.stopAtErrors!==!0,C=Number.isInteger(o.maxImageSize)&&o.maxImageSize>-1?o.maxImageSize:-1,A=o.isEvalSupported!==!1,P=typeof o.isOffscreenCanvasSupported=="boolean"?o.isOffscreenCanvasSupported:!Pe,D=typeof o.isImageDecoderSupported=="boolean"?o.isImageDecoderSupported:!Pe&&(ze.platform.isFirefox||!globalThis.chrome),k=Number.isInteger(o.canvasMaxAreaInBytes)?o.canvasMaxAreaInBytes:-1,M=typeof o.disableFontFace=="boolean"?o.disableFontFace:Pe,R=o.fontExtraProperties===!0,F=o.enableXfa===!0,I=o.ownerDocument||globalThis.document,Y=o.disableRange===!0,N=o.disableStream===!0,H=o.disableAutoFetch===!0,at=o.pdfBug===!0,j=o.CanvasFactory||QS,W=o.FilterFactory||tC,it=o.enableHWA===!0,kt=h?h.length:o.length??NaN,Ut=typeof o.useSystemFonts=="boolean"?o.useSystemFonts:!Pe&&!M,ne=typeof o.useWorkerFetch=="boolean"?o.useWorkerFetch:v===Lv&&b===jv&&g&&_&&hl(g,document.baseURI)&&hl(_,document.baseURI),Wt=null;Gx(d);const Tt={canvasFactory:new j({ownerDocument:I,enableHWA:it}),filterFactory:new W({docId:e,ownerDocument:I}),cMapReaderFactory:ne?null:new v({baseUrl:g,isCompressed:p}),standardFontDataFactory:ne?null:new b({baseUrl:_})};if(!u){const Dt={verbosity:d,port:rn.workerPort};u=Dt.port?Co.fromPort(Dt):new Co(Dt),t._worker=u}const Ce={docId:e,apiVersion:"4.10.38",data:i,password:a,disableAutoFetch:H,rangeChunkSize:c,length:kt,docBaseUrl:f,enableXfa:F,evaluatorOptions:{maxImageSize:C,disableFontFace:M,ignoreErrors:x,isEvalSupported:A,isOffscreenCanvasSupported:P,isImageDecoderSupported:D,canvasMaxAreaInBytes:k,fontExtraProperties:R,useSystemFonts:Ut,cMapUrl:ne?g:null,standardFontDataUrl:ne?_:null}},Xs={disableFontFace:M,fontExtraProperties:R,ownerDocument:I,pdfBug:at,styleElement:Wt,loadingParams:{disableAutoFetch:H,enableXfa:F}};return u.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const Dt=u.messageHandler.sendWithPromise("GetDocRequest",Ce,i?[i.buffer]:null);let ft;if(h)ft=new OS(h,{disableRange:Y,disableStream:N});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let Ps;if(Pe)if(hl(s)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");Ps=eb}else Ps=zS;else Ps=hl(s)?eb:BS;ft=new Ps({url:s,length:kt,httpHeaders:n,withCredentials:r,rangeChunkSize:c,disableRange:Y,disableStream:N})}return Dt.then(Ps=>{if(t.destroyed)throw new Error("Loading aborted");if(u.destroyed)throw new Error("Worker was destroyed");const Xi=new cl(e,Ps,u.port),Je=new hC(Xi,t,ft,Xs,Tt);t._transport=Je,Xi.send("Ready",null)})}).catch(t._capability.reject),t}function iC(o){if(o instanceof URL)return o.href;try{return new URL(o,window.location).href}catch{if(Pe&&typeof o=="string")return o}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function nC(o){if(Pe&&typeof Buffer<"u"&&o instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(o instanceof Uint8Array&&o.byteLength===o.buffer.byteLength)return o;if(typeof o=="string")return ud(o);if(o instanceof ArrayBuffer||ArrayBuffer.isView(o)||typeof o=="object"&&!isNaN(o==null?void 0:o.length))return new Uint8Array(o);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function sb(o){return typeof o=="object"&&Number.isInteger(o==null?void 0:o.num)&&o.num>=0&&Number.isInteger(o==null?void 0:o.gen)&&o.gen>=0}const Id=class Id{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${Ze(Id,Fd)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(n){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,n}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}};Fd=new WeakMap,y(Id,Fd,0);let Kg=Id;class ib{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Et("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class rC{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 ht(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()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}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 aC{constructor(t,e,s,i=!1){y(this,Bs);y(this,pr,null);y(this,_n,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Ev:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new nb,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}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:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new ol({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return ht(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:i=Yn.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:u=null,isEditing:d=!1}){var A,P;(A=this._stats)==null||A.time("Overall");const f=this._transport.getRenderingIntent(s,i,u,d),{renderingIntent:g,cacheKey:p}=f;m(this,_n,!1),w(this,Bs,of).call(this),a||(a=this._transport.getOptionalContentConfig(g));let v=this._intentStates.get(p);v||(v=Object.create(null),this._intentStates.set(p,v)),v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);const _=!!(g&fs.PRINT);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(P=this._stats)==null||P.time("Page Request"),this._pumpOperatorList(f));const b=D=>{var k;v.renderTasks.delete(x),(this._maybeCleanupAfterRender||_)&&m(this,_n,!0),w(this,Bs,jh).call(this,!_),D?(x.capability.reject(D),this._abortOperatorList({intentState:v,reason:D instanceof Error?D:new Error(D)})):x.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(k=globalThis.Stats)!=null&&k.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},x=new Jg({callback:b,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:c});(v.renderTasks||(v.renderTasks=new Set)).add(x);const C=x.task;return Promise.all([v.displayReadyCapability.promise,a]).then(([D,k])=>{var M;if(this.destroyed){b();return}if((M=this._stats)==null||M.time("Rendering"),!(k.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");x.initializeGraphics({transparency:D,optionalContentConfig:k}),x.operatorListChanged()}).catch(b),C}getOperatorList({intent:t="display",annotationMode:e=Yn.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;function n(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(h))}const r=this._transport.getRenderingIntent(t,e,s,i,!0);let a=this._intentStates.get(r.cacheKey);a||(a=Object.create(null),this._intentStates.set(r.cacheKey,a));let h;return a.opListReadCapability||(h=Object.create(null),h.operatorListChanged=n,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||(a.renderTasks=new Set)).add(h),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>fl.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){r.read().then(function({value:h,done:c}){if(c){s(a);return}a.lang??(a.lang=h.lang),Object.assign(a.styles,h.styles),a.items.push(...h.items),n()},i)}const r=e.getReader(),a={items:[],styles:Object.create(null),lang:null};n()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),m(this,_n,!1),w(this,Bs,of).call(this),Promise.all(t)}cleanup(t=!1){m(this,_n,!0);const e=w(this,Bs,jh).call(this,!1);return t&&e&&this._stats&&(this._stats=new Ev),e}_startRenderPage(t,e){var i,n;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(n=s.displayReadyCapability)==null||n.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&w(this,Bs,jh).call(this,!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:n,transfer:r}=s,h=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},r).getReader(),c=this._intentStates.get(e);c.streamReader=h;const u=()=>{h.read().then(({value:d,done:f})=>{if(f){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,c),u())},d=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();w(this,Bs,jh).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(d);else if(c.opListReadCapability)c.opListReadCapability.reject(d);else throw d}})};u()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Lg){let i=KS;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 qn(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}pr=new WeakMap,_n=new WeakMap,Bs=new WeakSet,jh=function(t=!1){if(w(this,Bs,of).call(this),!l(this,_n)||this.destroyed)return!1;if(t)return m(this,pr,setTimeout(()=>{m(this,pr,null),w(this,Bs,jh).call(this,!1)},JS)),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),m(this,_n,!1),!0},of=function(){l(this,pr)&&(clearTimeout(l(this,pr)),m(this,pr,null))};class oC{constructor(){y(this,wn,new Map);y(this,jd,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};l(this,jd).then(()=>{for(const[i]of l(this,wn))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:n}=s;if(n.aborted){rt("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}l(this,wn).set(e,i)}removeEventListener(t,e){const s=l(this,wn).get(e);s==null||s(),l(this,wn).delete(e)}terminate(){for(const[,t]of l(this,wn))t==null||t();l(this,wn).clear()}}wn=new WeakMap,jd=new WeakMap;const jt=class jt{constructor({name:t=null,port:e=null,verbosity:s=Vx()}={}){y(this,Jo);var i;if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if((i=l(jt,Aa))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(l(jt,Aa)||m(jt,Aa,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new cl("main","worker",t),this._messageHandler.on("ready",function(){}),w(this,Jo,hf).call(this)}_initialize(){if(l(jt,Ca)||l(jt,Qo,lf)){this._setupFakeWorker();return}let{workerSrc:t}=jt;try{jt._isSameOrigin(window.location.href,t)||(t=jt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new cl("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",a=>{if(n.abort(),this.destroyed||!a){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,w(this,Jo,hf).call(this)}),s.on("ready",a=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this._setupFakeWorker()}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{ld("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){l(jt,Ca)||(rt("Setting up fake worker."),m(jt,Ca,!0)),jt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new oC;this._port=e;const s=`fake${Ze(jt,Nd)._++}`,i=new cl(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new cl(s,s+"_worker",e),w(this,Jo,hf).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t,e,s;this.destroyed=!0,(t=this._webWorker)==null||t.terminate(),this._webWorker=null,(e=l(jt,Aa))==null||e.delete(this._port),this._port=null,(s=this._messageHandler)==null||s.destroy(),this._messageHandler=null}static fromPort(t){var s;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const e=(s=l(this,Aa))==null?void 0:s.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new jt(t)}static get workerSrc(){if(rn.workerSrc)return rn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return ht(this,"_setupFakeWorkerGlobal",(async()=>l(this,Qo,lf)?l(this,Qo,lf):(await import(this.workerSrc)).WorkerMessageHandler)())}};Nd=new WeakMap,Ca=new WeakMap,Aa=new WeakMap,Jo=new WeakSet,hf=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Qo=new WeakSet,lf=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},y(jt,Qo),y(jt,Nd,0),y(jt,Ca,!1),y(jt,Aa),Pe&&(m(jt,Ca,!0),rn.workerSrc||(rn.workerSrc="./pdf.worker.mjs")),jt._isSameOrigin=(t,e)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch{return!1}const i=new URL(e,s);return s.origin===i.origin},jt._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let Co=jt;class hC{constructor(t,e,s,i,n){y(this,Ta);y(this,xn,new Map);y(this,Ii,new Map);y(this,Zo,new Map);y(this,th,new Map);y(this,Sn,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new nb,this.fontLoader=new oS({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return ht(this,"annotationStorage",new Wg)}getRenderingIntent(t,e=Yn.ENABLE,s=null,i=!1,n=!1){let r=fs.DISPLAY,a=Vg;switch(t){case"any":r=fs.ANY;break;case"display":break;case"print":r=fs.PRINT;break;default:rt(`getRenderingIntent - invalid intent: ${t}`)}const h=r&fs.PRINT&&s instanceof Mv?s:this.annotationStorage;switch(e){case Yn.DISABLE:r+=fs.ANNOTATIONS_DISABLE;break;case Yn.ENABLE:break;case Yn.ENABLE_FORMS:r+=fs.ANNOTATIONS_FORMS;break;case Yn.ENABLE_STORAGE:r+=fs.ANNOTATIONS_STORAGE,a=h.serializable;break;default:rt(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(r+=fs.IS_EDITING),n&&(r+=fs.OPLIST);const{ids:c,hash:u}=h.modifiedIds,d=[r,a.hash,u];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=l(this,Sn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of l(this,Ii).values())t.push(i._destroy());l(this,Ii).clear(),l(this,Zo).clear(),l(this,th).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,n;this.commonObjs.clear(),this.fontLoader.clear(),l(this,xn).clear(),this.filterFactory.destroy(),dl.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new qn("Worker was terminated.")),(n=this.messageHandler)==null||n.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{ee(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:r}){if(r){i.close();return}ee(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",async s=>{var a;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:n,contentLength:r}=this._fullReader;return(!i||!n)&&(this._lastProgress&&((a=e.onProgress)==null||a.call(e,this._lastProgress)),this._fullReader.onProgress=h=>{var c;(c=e.onProgress)==null||c.call(e,{loaded:h.loaded,total:h.total})}),{isStreamingSupported:i,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(s,i)=>{ee(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}ee(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new rC(s,this))}),t.on("DocException",s=>{e._capability.reject(is(s))}),t.on("PasswordRequest",s=>{m(this,Sn,Promise.withResolvers());try{if(!e.onPassword)throw is(s);const i=n=>{n instanceof Error?l(this,Sn).reject(n):l(this,Sn).resolve({password:n})};e.onPassword(i,s.code)}catch(i){l(this,Sn).reject(i)}return l(this,Sn).promise}),t.on("DataLoaded",s=>{var i;(i=e.onProgress)==null||i.call(e,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;l(this,Ii).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{var r;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:a,fontExtraProperties:h,pdfBug:c}=this._params;if("error"in n){const g=n.error;rt(`Error during font loading: ${g}`),this.commonObjs.resolve(s,g);break}const u=c&&((r=globalThis.FontInspector)!=null&&r.enabled)?(g,p)=>globalThis.FontInspector.fontAdded(g,p):null,d=new hS(n,{disableFontFace:a,fontExtraProperties:h,inspectFont:u});this.fontLoader.bind(d).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!h&&d.data&&(d.data=null),this.commonObjs.resolve(s,d)});break;case"CopyLocalImage":const{imageRef:f}=n;ee(f,"The imageRef must be defined.");for(const g of l(this,Ii).values())for(const[,p]of g.objs)if((p==null?void 0:p.ref)===f)return p.dataLen?(this.commonObjs.resolve(s,structuredClone(p)),p.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{var h;if(this.destroyed)return;const a=l(this,Ii).get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){(h=r==null?void 0:r.bitmap)==null||h.close();return}switch(n){case"Image":a.objs.resolve(s,r),(r==null?void 0:r.dataLen)>jx&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(s)}),t.on("FetchStandardFontData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&rt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=this._fullReader)==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=l(this,Zo).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&l(this,th).set(n.refStr,t);const r=new aC(e,n,this,this._params.pdfBug);return l(this,Ii).set(e,r),r});return l(this,Zo).set(e,i),i}getPageIndex(t){return sb(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return w(this,Ta,Qc).call(this,"GetFieldObjects")}hasJSActions(){return w(this,Ta,Qc).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return w(this,Ta,Qc).call(this,"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 w(this,Ta,Qc).call(this,"GetOptionalContentConfig").then(e=>new MS(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=l(this,xn).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var n,r;return{info:i[0],metadata:i[1]?new kS(i[1]):null,contentDispositionFilename:((n=this._fullReader)==null?void 0:n.filename)??null,contentLength:((r=this._fullReader)==null?void 0:r.contentLength)??null}});return l(this,xn).set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of l(this,Ii).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),l(this,xn).clear(),this.filterFactory.destroy(!0),dl.cleanup()}}cachedPageNumber(t){if(!sb(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return l(this,th).get(e)??null}}xn=new WeakMap,Ii=new WeakMap,Zo=new WeakMap,th=new WeakMap,Sn=new WeakMap,Ta=new WeakSet,Qc=function(t,e=null){const s=l(this,xn).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return l(this,xn).set(t,i),i};const gl=Symbol("INITIAL_DATA");class nb{constructor(){y(this,oc);y(this,ys,Object.create(null))}get(t,e=null){if(e){const i=w(this,oc,Up).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=l(this,ys)[t];if(!s||s.data===gl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=l(this,ys)[t];return!!e&&e.data!==gl}delete(t){const e=l(this,ys)[t];return!e||e.data===gl?!1:(delete l(this,ys)[t],!0)}resolve(t,e=null){const s=w(this,oc,Up).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in l(this,ys)){const{data:s}=l(this,ys)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}m(this,ys,Object.create(null))}*[Symbol.iterator](){for(const t in l(this,ys)){const{data:e}=l(this,ys)[t];e!==gl&&(yield[t,e])}}}ys=new WeakMap,oc=new WeakSet,Up=function(t){var e;return(e=l(this,ys))[t]||(e[t]={...Promise.withResolvers(),data:gl})};class lC{constructor(t){y(this,mr,null);m(this,mr,t),this.onContinue=null}get promise(){return l(this,mr).capability.promise}cancel(t=0){l(this,mr).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=l(this,mr).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=l(this,mr);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}mr=new WeakMap;const ka=class ka{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:h,filterFactory:c,useRequestAnimationFrame:u=!1,pdfBug:d=!1,pageColors:f=null}){y(this,vr,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=h,this.filterFactory=c,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=u===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new lC(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.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var a,h;if(this.cancelled)return;if(this._canvas){if(l(ka,Ea).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");l(ka,Ea).add(this._canvas)}this._pdfBug&&((a=globalThis.StepperManager)!=null&&a.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:r}=this.params;this.gfx=new xo(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),l(this,vr)&&(window.cancelAnimationFrame(l(this,vr)),m(this,vr,null)),l(ka,Ea).delete(this._canvas),this.callback(t||new Lg(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){var t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.stepper)==null||t.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?m(this,vr,window.requestAnimationFrame(()=>{m(this,vr,null),this._nextBound().catch(this._cancelBound)})):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.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),l(ka,Ea).delete(this._canvas),this.callback())))}};vr=new WeakMap,Ea=new WeakMap,y(ka,Ea,new WeakSet);let Jg=ka;const cC="4.10.38",uC="f9bea397f";function rb(o){return Math.floor(Math.max(0,Math.min(1,o))*255).toString(16).padStart(2,"0")}function pl(o){return Math.max(0,Math.min(255,255*o))}class ab{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=pl(t),[t,t,t]}static G_HTML([t]){const e=rb(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(pl)}static RGB_HTML(t){return`#${t.map(rb).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[pl(1-Math.min(1,t+i)),pl(1-Math.min(1,s+i)),pl(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}}class dC{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Et("Abstract method `_createSVG` called.")}}class Qg extends dC{_createSVG(t){return document.createElementNS(nn,t)}}class ob{static setupStorage(t,e,s,i,n){const r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),n==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const h=a.target.options,c=h.selectedIndex===-1?"":h[h.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${i}`);for(const[h,c]of Object.entries(r))if(c!=null)switch(h){case"class":c.length&&t.setAttribute(h,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!a||h!=="href"&&h!=="newWindow")&&t.setAttribute(h,c)}a&&n.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static render(t){var d,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",r=document.createElement(i.name);i.attributes&&this.setAttributes({html:r,element:i,intent:n,linkService:s});const a=n!=="richText",h=t.div;if(h.append(r),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=g}a&&h.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);r.append(g),a&&fl.shouldBuildText(i.name)&&c.push(g)}return{textDivs:c}}const u=[[i,-1,r]];for(;u.length>0;){const[g,p,v]=u.at(-1);if(p+1===g.children.length){u.pop();continue}const _=g.children[++u.at(-1)[1]];if(_===null)continue;const{name:b}=_;if(b==="#text"){const C=document.createTextNode(_.value);c.push(C),v.append(C);continue}const x=(d=_==null?void 0:_.attributes)!=null&&d.xmlns?document.createElementNS(_.attributes.xmlns,b):document.createElement(b);if(v.append(x),_.attributes&&this.setAttributes({html:x,element:_,storage:e,intent:n,linkService:s}),((f=_.children)==null?void 0:f.length)>0)u.push([_,-1,x]);else if(_.value){const C=document.createTextNode(_.value);a&&fl.shouldBuildText(b)&&c.push(C),x.append(C)}}for(const g of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const ml=1e3,fC=9,Ur=new WeakSet;function Jn(o){return{width:o[2]-o[0],height:o[3]-o[1]}}class gC{static create(t){switch(t.data.annotationType){case oe.LINK:return new hb(t);case oe.TEXT:return new pC(t);case oe.WIDGET:switch(t.data.fieldType){case"Tx":return new mC(t);case"Btn":return t.data.radioButton?new lb(t):t.data.checkBox?new bC(t):new yC(t);case"Ch":return new _C(t);case"Sig":return new vC(t)}return new Yr(t);case oe.POPUP:return new Zg(t);case oe.FREETEXT:return new cb(t);case oe.LINE:return new xC(t);case oe.SQUARE:return new SC(t);case oe.CIRCLE:return new CC(t);case oe.POLYLINE:return new ub(t);case oe.CARET:return new TC(t);case oe.INK:return new tp(t);case oe.POLYGON:return new AC(t);case oe.HIGHLIGHT:return new db(t);case oe.UNDERLINE:return new EC(t);case oe.SQUIGGLY:return new kC(t);case oe.STRIKEOUT:return new PC(t);case oe.STAMP:return new fb(t);case oe.FILEATTACHMENT:return new MC(t);default:return new qt(t)}}}const fp=class fp{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){y(this,hc);y(this,Pa,null);y(this,eh,!1);y(this,sh,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:s}){return!!(t!=null&&t.str||e!=null&&e.str||s!=null&&s.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return fp._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;l(this,Pa)||m(this,Pa,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&w(this,hc,Yp).call(this,e),(s=l(this,sh))==null||s.popup.updateEdited(t)}resetEdited(){var t;l(this,Pa)&&(w(this,hc,Yp).call(this,l(this,Pa).rect),(t=l(this,sh))==null||t.popup.resetEdited(),m(this,Pa,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Yr||(n.tabIndex=ml);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Zg){const{rotation:v}=e;return!e.hasOwnCanvas&&v!==0&&this.setRotation(v,n),n}const{width:a,height:h}=Jn(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const v=e.borderStyle.horizontalCornerRadius,_=e.borderStyle.verticalCornerRadius;if(v>0||_>0){const x=`calc(${v}px * var(--scale-factor)) / calc(${_}px * var(--scale-factor))`;r.borderRadius=x}else if(this instanceof lb){const x=`calc(${a}px * var(--scale-factor)) / calc(${h}px * var(--scale-factor))`;r.borderRadius=x}switch(e.borderStyle.style){case rl.SOLID:r.borderStyle="solid";break;case rl.DASHED:r.borderStyle="dashed";break;case rl.BEVELED:rt("Unimplemented border style: beveled");break;case rl.INSET:rt("Unimplemented border style: inset");break;case rl.UNDERLINE:r.borderBottomStyle="solid";break}const b=e.borderColor||null;b?(m(this,eh,!0),r.borderColor=q.makeHexColor(b[0]|0,b[1]|0,b[2]|0)):r.borderWidth=0}const c=q.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:u,pageHeight:d,pageX:f,pageY:g}=i.rawDims;r.left=`${100*(c[0]-f)/u}%`,r.top=`${100*(c[1]-g)/d}%`;const{rotation:p}=e;return e.hasOwnCanvas||p===0?(r.width=`${100*a/u}%`,r.height=`${100*h/d}%`):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=Jn(this.data.rect);let a,h;t%180===0?(a=100*n/s,h=100*r/i):(a=100*r/s,h=100*n/i),e.style.width=`${a}%`,e.style.height=`${h}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=ab[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:ab[`${r}_rgb`](a)})};return ht(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];n==null||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const r=s[i];if(r){const a={detail:{[i]:n},target:t};r(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(v=>Math.fround(v));if(t.length===8){const[v,_,b,x]=t.subarray(2,6);if(i===v&&n===_&&e===b&&s===x)return}const{style:r}=this.container;let a;if(l(this,eh)){const{borderColor:v,borderWidth:_}=r;r.borderWidth=0,a=["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="${v}" stroke-width="${_}">`],this.container.classList.add("hasBorder")}const h=i-e,c=n-s,{svgFactory:u}=this,d=u.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const f=u.createElement("defs");d.append(f);const g=u.createElement("clipPath"),p=`clippath_${this.data.id}`;g.setAttribute("id",p),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let v=2,_=t.length;v<_;v+=8){const b=t[v],x=t[v+1],C=t[v+2],A=t[v+3],P=u.createElement("rect"),D=(C-e)/h,k=(n-x)/c,M=(b-C)/h,R=(x-A)/c;P.setAttribute("x",D),P.setAttribute("y",k),P.setAttribute("width",M),P.setAttribute("height",R),g.append(P),a==null||a.push(`<rect vector-effect="non-scaling-stroke" x="${D}" y="${k}" width="${M}" height="${R}"/>`)}l(this,eh)&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=m(this,sh,new Zg({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){Et("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:r,exportValues:a}of i){if(n===-1||r===e)continue;const h=typeof a=="string"?a:null,c=document.querySelector(`[data-element-id="${r}"]`);if(c&&!Ur.has(c)){rt(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:h,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,r=i.getAttribute("data-element-id");r!==e&&Ur.has(i)&&s.push({id:r,exportValue:n,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}};Pa=new WeakMap,eh=new WeakMap,sh=new WeakMap,hc=new WeakSet,Yp=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:h}}}}=this;s==null||s.splice(0,4,...t);const{width:c,height:u}=Jn(t);e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+h)/r}%`,i===0?(e.width=`${100*c/n}%`,e.height=`${100*u/r}%`):this.setRotation(i)};let qt=fp;class hb extends qt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});y(this,_s);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let n=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),n=!0):e.action?(this._bindNamedAction(i,e.action),n=!0):e.attachment?(w(this,_s,_y).call(this,i,e.attachment,e.attachmentDest),n=!0):e.setOCGState?(w(this,_s,wy).call(this,i,e.setOCGState),n=!0):e.dest?(this._bindLink(i,e.dest),n=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),n=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(i),this.container}_bindLink(e,s){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&w(this,_s,so).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),w(this,_s,so).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(s.actions)){const r=i.get(n);r&&(e[r]=()=>{var a;return(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:n}}),!1})}e.onclick||(e.onclick=()=>!1),w(this,_s,so).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),w(this,_s,so).call(this),!this._fieldObjects){rt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var d;i==null||i();const{fields:n,refs:r,include:a}=s,h=[];if(n.length!==0||r.length!==0){const f=new Set(r);for(const g of n){const p=this._fieldObjects[g]||[];for(const{id:v}of p)f.add(v)}for(const g of Object.values(this._fieldObjects))for(const p of g)f.has(p.id)===a&&h.push(p)}else for(const f of Object.values(this._fieldObjects))h.push(...f);const c=this.annotationStorage,u=[];for(const f of h){const{id:g}=f;switch(u.push(g),f.type){case"text":{const v=f.defaultValue||"";c.setValue(g,{value:v});break}case"checkbox":case"radiobutton":{const v=f.defaultValue===f.exportValues;c.setValue(g,{value:v});break}case"combobox":case"listbox":{const v=f.defaultValue||"";c.setValue(g,{value:v});break}default:continue}const p=document.querySelector(`[data-element-id="${g}"]`);if(p){if(!Ur.has(p)){rt(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;p.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:u,name:"ResetForm"}})),!1}}}_s=new WeakSet,so=function(){this.container.setAttribute("data-internal-link","")},_y=function(e,s,i=null){e.href=this.linkService.getAnchorUrl(""),s.description&&(e.title=s.description),e.onclick=()=>{var n;return(n=this.downloadManager)==null||n.openOrDownloadData(s.content,s.filename,i),!1},w(this,_s,so).call(this)},wy=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),w(this,_s,so).call(this)};class pC extends qt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Yr extends qt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ze.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,r=>{var a;(a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{var a;if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&((a=this.linkService.eventBus)==null||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}}))})}_setEventListeners(t,e,s,i){var n,r,a;for(const[h,c]of s)(c==="Action"||(n=this.data.actions)!=null&&n[c])&&((c==="Focus"||c==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,h,c,i),c==="Focus"&&!((r=this.data.actions)!=null&&r.Blur)?this._setEventListener(t,e,"blur","Blur",null):c==="Blur"&&!((a=this.data.actions)!=null&&a.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":q.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||fC,n=t.style;let r;const a=2,h=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a),u=Math.round(c/(Eg*i))||1,d=c/u;r=Math.min(i,h(d/Eg))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(i,h(c/Eg))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=q.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class mC extends Yr{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),n.setValue(r.id,{[i]:s})}render(){var i,n;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const r=t.getValue(e,{value:this.data.fieldValue});let a=r.value||"";const h=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;h&&a.length>h&&(a=a.slice(0,h));let c=r.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
|
|
529
|
+
`))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const u={userValue:a,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??a,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",c??a),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),Ur.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=ml,this._setRequired(s,this.data.required),h&&(s.maxLength=h),s.addEventListener("input",f=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),u.formattedValue=null}),s.addEventListener("resetform",f=>{const g=this.data.defaultFieldValue??"";s.value=u.userValue=g,u.formattedValue=null});let d=f=>{const{formattedValue:g}=u;g!=null&&(f.target.value=g),f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{var v;if(u.focused)return;const{target:p}=g;u.userValue&&(p.value=u.userValue),u.lastCommittedValue=p.value,u.commitKey=1,(v=this.data.actions)!=null&&v.Focus||(u.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);const p={value(v){u.userValue=v.detail.value??"",t.setValue(e,{value:u.userValue.toString()}),v.target.value=u.userValue},formattedValue(v){const{formattedValue:_}=v.detail;u.formattedValue=_,_!=null&&v.target!==document.activeElement&&(v.target.value=_),t.setValue(e,{formattedValue:_})},selRange(v){v.target.setSelectionRange(...v.detail.selRange)},charLimit:v=>{var C;const{charLimit:_}=v.detail,{target:b}=v;if(_===0){b.removeAttribute("maxLength");return}b.setAttribute("maxLength",_);let x=u.userValue;!x||x.length<=_||(x=x.slice(0,_),b.value=u.userValue=x,t.setValue(e,{value:x}),(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:x,willCommit:!0,commitKey:1,selStart:b.selectionStart,selEnd:b.selectionEnd}}))}};this._dispatchEventFromSandbox(p,g)}),s.addEventListener("keydown",g=>{var _;u.commitKey=1;let p=-1;if(g.key==="Escape"?p=0:g.key==="Enter"&&!this.data.multiLine?p=2:g.key==="Tab"&&(u.commitKey=3),p===-1)return;const{value:v}=g.target;u.lastCommittedValue!==v&&(u.lastCommittedValue=v,u.userValue=v,(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:p,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const f=d;d=null,s.addEventListener("blur",g=>{var v,_;if(!u.focused||!g.relatedTarget)return;(v=this.data.actions)!=null&&v.Blur||(u.focused=!1);const{value:p}=g.target;u.userValue=p,u.lastCommittedValue!==p&&((_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:p,willCommit:!0,commitKey:u.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}})),f(g)}),(n=this.data.actions)!=null&&n.Keystroke&&s.addEventListener("beforeinput",g=>{var P;u.lastCommittedValue=null;const{data:p,target:v}=g,{value:_,selectionStart:b,selectionEnd:x}=v;let C=b,A=x;switch(g.inputType){case"deleteWordBackward":{const D=_.substring(0,b).match(/\w*[^\w]*$/);D&&(C-=D[0].length);break}case"deleteWordForward":{const D=_.substring(b).match(/^[^\w]*\w*/);D&&(A+=D[0].length);break}case"deleteContentBackward":b===x&&(C-=1);break;case"deleteContentForward":b===x&&(A+=1);break}g.preventDefault(),(P=this.linkService.eventBus)==null||P.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:p||"",willCommit:!1,selStart:C,selEnd:A}})}),this._setEventListeners(s,u,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(d&&s.addEventListener("blur",d),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/h;s.classList.add("comb"),s.style.letterSpacing=`calc(${g}px * var(--scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class vC extends Yr{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class bC extends Yr{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ur.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=ml,n.addEventListener("change",r=>{const{name:a,checked:h}=r.target;for(const c of this._getElementsByName(a,s)){const u=h&&c.exportValue===e.exportValue;c.domElement&&(c.domElement.checked=u),t.setValue(c.id,{value:u})}t.setValue(s,{value:h})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",r=>{const a={value(h){h.target.checked=h.detail.value!=="Off",t.setValue(s,{value:h.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class lb extends Yr{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});const n=document.createElement("input");if(Ur.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=ml,n.addEventListener("change",r=>{const{name:a,checked:h}=r.target;for(const c of this._getElementsByName(a,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:h})}),n.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;n.addEventListener("updatefromsandbox",a=>{const h={value:c=>{const u=r===c.detail.value;for(const d of this._getElementsByName(c.target.name)){const f=u&&d.id===s;d.domElement&&(d.domElement.checked=f),t.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(h,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class yC extends hb{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class _C extends Yr{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");Ur.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=ml;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",u=>{const d=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===d});for(const u of this.data.options){const d=document.createElement("option");d.textContent=u.displayValue,d.value=u.exportValue,s.value.includes(u.exportValue)&&(d.setAttribute("selected",!0),n=!1),i.append(d)}let r=null;if(n){const u=document.createElement("option");u.value=" ",u.setAttribute("hidden",!0),u.setAttribute("selected",!0),i.prepend(u),r=()=>{u.remove(),i.removeEventListener("input",r),r=null},i.addEventListener("input",r)}const a=u=>{const d=u?"value":"textContent",{options:f,multiple:g}=i;return g?Array.prototype.filter.call(f,p=>p.selected).map(p=>p[d]):f.selectedIndex===-1?null:f[f.selectedIndex][d]};let h=a(!1);const c=u=>{const d=u.target.options;return Array.prototype.map.call(d,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",u=>{const d={value(f){r==null||r();const g=f.detail.value,p=new Set(Array.isArray(g)?g:[g]);for(const v of i.options)v.selected=p.has(v.value);t.setValue(e,{value:a(!0)}),h=a(!1)},multipleSelection(f){i.multiple=!0},remove(f){const g=i.options,p=f.detail.remove;g[p].selected=!1,i.remove(p),g.length>0&&Array.prototype.findIndex.call(g,_=>_.selected)===-1&&(g[0].selected=!0),t.setValue(e,{value:a(!0),items:c(f)}),h=a(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),h=a(!1)},insert(f){const{index:g,displayValue:p,exportValue:v}=f.detail.insert,_=i.children[g],b=document.createElement("option");b.textContent=p,b.value=v,_?_.before(b):i.append(b),t.setValue(e,{value:a(!0),items:c(f)}),h=a(!1)},items(f){const{items:g}=f.detail;for(;i.length!==0;)i.remove(0);for(const p of g){const{displayValue:v,exportValue:_}=p,b=document.createElement("option");b.textContent=v,b.value=_,i.append(b)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:c(f)}),h=a(!1)},indices(f){const g=new Set(f.detail.indices);for(const p of f.target.options)p.selected=g.has(p.index);t.setValue(e,{value:a(!0)}),h=a(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(d,u)}),i.addEventListener("input",u=>{var g;const d=a(!0),f=a(!1);t.setValue(e,{value:d}),u.preventDefault(),(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:h,change:f,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],u=>u.target.value)):i.addEventListener("input",function(u){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Zg extends qt{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:qt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new wC({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,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}),e=[];for(const s of this.elements)s.popup=t,s.container.ariaHasPopup="dialog",e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${Rg}${s}`).join(",")),this.container}}class wC{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:h,rect:c,parentRect:u,open:d}){y(this,Ct);y(this,ih,w(this,Ct,Cy).bind(this));y(this,Bd,w(this,Ct,qp).bind(this));y(this,Hd,w(this,Ct,df).bind(this));y(this,nh,w(this,Ct,uf).bind(this));y(this,Ma,null);y(this,Xt,null);y(this,Cn,null);y(this,rh,null);y(this,lc,null);y(this,cc,null);y(this,ah,null);y(this,An,!1);y(this,ci,null);y(this,Tn,null);y(this,uc,null);y(this,En,null);y(this,dc,null);y(this,Oa,null);y(this,Da,!1);var f;m(this,Xt,t),m(this,dc,i),m(this,Cn,r),m(this,En,a),m(this,cc,h),m(this,Ma,e),m(this,uc,c),m(this,ah,u),m(this,lc,s),m(this,rh,Ig.toDateObject(n)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",l(this,nh)),g.addEventListener("mouseenter",l(this,Hd)),g.addEventListener("mouseleave",l(this,Bd)),g.classList.add("popupTriggerArea");for(const g of s)(f=g.container)==null||f.addEventListener("keydown",l(this,ih));l(this,Xt).hidden=!0,d&&w(this,Ct,uf).call(this)}render(){if(l(this,ci))return;const t=m(this,ci,document.createElement("div"));if(t.className="popup",l(this,Ma)){const n=t.style.outlineColor=q.makeHexColor(...l(this,Ma));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=q.makeHexColor(...l(this,Ma).map(a=>Math.floor(.7*(255-a)+a)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=l(this,dc),t.append(e),l(this,rh)){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),n.setAttribute("data-l10n-args",JSON.stringify({dateObj:l(this,rh).valueOf()})),e.append(n)}const i=l(this,Ct,cf);if(i)ob.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(l(this,Cn));t.append(n)}l(this,Xt).append(t)}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let n=0,r=i.length;n<r;++n){const a=i[n];s.append(document.createTextNode(a)),n<r-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:t,popupContent:e}){var s;l(this,Oa)||m(this,Oa,{contentsObj:l(this,Cn),richText:l(this,En)}),t&&m(this,Tn,null),e&&(m(this,En,w(this,Ct,Sy).call(this,e)),m(this,Cn,null)),(s=l(this,ci))==null||s.remove(),m(this,ci,null)}resetEdited(){var t;l(this,Oa)&&({contentsObj:Ze(this,Cn)._,richText:Ze(this,En)._}=l(this,Oa),m(this,Oa,null),(t=l(this,ci))==null||t.remove(),m(this,ci,null),m(this,Tn,null))}forceHide(){m(this,Da,this.isVisible),l(this,Da)&&(l(this,Xt).hidden=!0)}maybeShow(){l(this,Da)&&(l(this,ci)||w(this,Ct,df).call(this),m(this,Da,!1),l(this,Xt).hidden=!1)}get isVisible(){return l(this,Xt).hidden===!1}}ih=new WeakMap,Bd=new WeakMap,Hd=new WeakMap,nh=new WeakMap,Ma=new WeakMap,Xt=new WeakMap,Cn=new WeakMap,rh=new WeakMap,lc=new WeakMap,cc=new WeakMap,ah=new WeakMap,An=new WeakMap,ci=new WeakMap,Tn=new WeakMap,uc=new WeakMap,En=new WeakMap,dc=new WeakMap,Oa=new WeakMap,Da=new WeakMap,Ct=new WeakSet,cf=function(){const t=l(this,En),e=l(this,Cn);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&l(this,En).html||null},$p=function(){var t,e,s;return((s=(e=(t=l(this,Ct,cf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},xy=function(){var t,e,s;return((s=(e=(t=l(this,Ct,cf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},Sy=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:l(this,Ct,xy),fontSize:l(this,Ct,$p)?`calc(${l(this,Ct,$p)}px * var(--scale-factor))`:""}};for(const n of t.split(`
|
|
530
|
+
`))e.push({name:"span",value:n,attributes:i});return s},Cy=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&l(this,An))&&w(this,Ct,uf).call(this)},Ay=function(){if(l(this,Tn)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=l(this,cc);let r=!!l(this,ah),a=r?l(this,ah):l(this,uc);for(const p of l(this,lc))if(!a||q.intersect(p.data.rect,a)!==null){a=p.data.rect,r=!0;break}const h=q.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),u=r?a[2]-a[0]+5:0,d=h[0]+u,f=h[1];m(this,Tn,[100*(d-i)/e,100*(f-n)/s]);const{style:g}=l(this,Xt);g.left=`${l(this,Tn)[0]}%`,g.top=`${l(this,Tn)[1]}%`},uf=function(){m(this,An,!l(this,An)),l(this,An)?(w(this,Ct,df).call(this),l(this,Xt).addEventListener("click",l(this,nh)),l(this,Xt).addEventListener("keydown",l(this,ih))):(w(this,Ct,qp).call(this),l(this,Xt).removeEventListener("click",l(this,nh)),l(this,Xt).removeEventListener("keydown",l(this,ih)))},df=function(){l(this,ci)||this.render(),this.isVisible?l(this,An)&&l(this,Xt).classList.add("focused"):(w(this,Ct,Ay).call(this),l(this,Xt).hidden=!1,l(this,Xt).style.zIndex=parseInt(l(this,Xt).style.zIndex)+1e3)},qp=function(){l(this,Xt).classList.remove("focused"),!(l(this,An)||!this.isVisible)&&(l(this,Xt).hidden=!0,l(this,Xt).style.zIndex=parseInt(l(this,Xt).style.zIndex)-1e3)};class cb extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=nt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class xC extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,fc,null)}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:s,height:i}=Jn(e.rect),n=this.svgFactory.create(s,i,!0),r=m(this,fc,this.svgFactory.createElement("svg:line"));return r.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),r.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),r.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),r.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),r.setAttribute("stroke-width",e.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),n.append(r),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return l(this,fc)}addHighlightArea(){this.container.classList.add("highlightArea")}}fc=new WeakMap;class SC extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,gc,null)}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:s,height:i}=Jn(e.rect),n=this.svgFactory.create(s,i,!0),r=e.borderStyle.width,a=m(this,gc,this.svgFactory.createElement("svg:rect"));return a.setAttribute("x",r/2),a.setAttribute("y",r/2),a.setAttribute("width",s-r),a.setAttribute("height",i-r),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return l(this,gc)}addHighlightArea(){this.container.classList.add("highlightArea")}}gc=new WeakMap;class CC extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,pc,null)}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:s,height:i}=Jn(e.rect),n=this.svgFactory.create(s,i,!0),r=e.borderStyle.width,a=m(this,pc,this.svgFactory.createElement("svg:ellipse"));return a.setAttribute("cx",s/2),a.setAttribute("cy",i/2),a.setAttribute("rx",s/2-r/2),a.setAttribute("ry",i/2-r/2),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return l(this,pc)}addHighlightArea(){this.container.classList.add("highlightArea")}}pc=new WeakMap;class ub extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,mc,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:n}}=this;if(!s)return this.container;const{width:r,height:a}=Jn(e),h=this.svgFactory.create(r,a,!0);let c=[];for(let d=0,f=s.length;d<f;d+=2){const g=s[d]-e[0],p=e[3]-s[d+1];c.push(`${g},${p}`)}c=c.join(" ");const u=m(this,mc,this.svgFactory.createElement(this.svgElementName));return u.setAttribute("points",c),u.setAttribute("stroke-width",i.width||1),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),h.append(u),this.container.append(h),!n&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return l(this,mc)}addHighlightArea(){this.container.classList.add("highlightArea")}}mc=new WeakMap;class AC extends ub{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class TC extends qt{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 tp extends qt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,bc);y(this,vc,null);y(this,Ra,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?nt.HIGHLIGHT:nt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:i,borderStyle:n,popupRef:r}}=this,{transform:a,width:h,height:c}=w(this,bc,Kp).call(this,s,e),u=this.svgFactory.create(h,c,!0),d=m(this,vc,this.svgFactory.createElement("svg:g"));u.append(d),d.setAttribute("stroke-width",n.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",a);for(let f=0,g=i.length;f<g;f++){const p=this.svgFactory.createElement(this.svgElementName);l(this,Ra).push(p),p.setAttribute("points",i[f].join(",")),d.append(p)}return!r&&this.hasPopupData&&this._createPopup(),this.container.append(u),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:i,rect:n}=e,r=l(this,vc);if(s>=0&&r.setAttribute("stroke-width",s||1),i)for(let a=0,h=l(this,Ra).length;a<h;a++)l(this,Ra)[a].setAttribute("points",i[a].join(","));if(n){const{transform:a,width:h,height:c}=w(this,bc,Kp).call(this,this.data.rotation,n);r.parentElement.setAttribute("viewBox",`0 0 ${h} ${c}`),r.setAttribute("transform",a)}}getElementsToTriggerPopup(){return l(this,Ra)}addHighlightArea(){this.container.classList.add("highlightArea")}}vc=new WeakMap,Ra=new WeakMap,bc=new WeakSet,Kp=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class db extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=nt.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class EC extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class kC extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class PC extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class fb extends qt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=nt.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 MC extends qt{constructor(e){var i;super(e,{isRenderable:!0});y(this,_c);y(this,yc,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(i=this.linkService.eventBus)==null||i.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",w(this,_c,Jp).bind(this)),m(this,yc,i);const{isMac:n}=ze.platform;return e.addEventListener("keydown",r=>{r.key==="Enter"&&(n?r.metaKey:r.ctrlKey)&&w(this,_c,Jp).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return l(this,yc)}addHighlightArea(){this.container.classList.add("highlightArea")}}yc=new WeakMap,_c=new WeakSet,Jp=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};class OC{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r,structTreeLayer:a}){y(this,Ia);y(this,wc,null);y(this,La,null);y(this,Fa,new Map);y(this,xc,null);this.div=t,m(this,wc,e),m(this,La,s),m(this,xc,a||null),this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return l(this,Fa).size>0}async render(t){var r;const{annotations:e}=t,s=this.div;zr(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Qg,annotationStorage:t.annotationStorage||new Wg,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const a of e){if(a.noHTML)continue;const h=a.annotationType===oe.POPUP;if(h){const d=i.get(a.id);if(!d)continue;n.elements=d}else{const{width:d,height:f}=Jn(a.rect);if(d<=0||f<=0)continue}n.data=a;const c=gC.create(n);if(!c.isRenderable)continue;if(!h&&a.popupRef){const d=i.get(a.popupRef);d?d.push(c):i.set(a.popupRef,[c])}const u=c.render();a.hidden&&(u.style.visibility="hidden"),await w(this,Ia,Ty).call(this,u,a.id),c._isEditable&&(l(this,Fa).set(c.data.id,c),(r=this._annotationEditorUIManager)==null||r.renderAnnotationElement(c))}w(this,Ia,Qp).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,zr(e,{rotation:t.rotation}),w(this,Ia,Qp).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(l(this,Fa).values())}getEditableAnnotation(t){return l(this,Fa).get(t)}}wc=new WeakMap,La=new WeakMap,Fa=new WeakMap,xc=new WeakMap,Ia=new WeakSet,Ty=async function(t,e){var r,a;const s=t.firstChild||t,i=s.id=`${Rg}${e}`,n=await((r=l(this,xc))==null?void 0:r.getAriaAttributes(i));if(n)for(const[h,c]of n)s.setAttribute(h,c);this.div.append(t),(a=l(this,wc))==null||a.moveElementInDOM(this.div,t,s,!1)},Qp=function(){if(!l(this,La))return;const t=this.div;for(const[e,s]of l(this,La)){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}l(this,La).clear()};const xd=/\r\n?|\n/g,Ot=class Ot extends Ht{constructor(e){super({...e,name:"freeTextEditor"});y(this,ie);y(this,ui);y(this,ws,"");y(this,Sc,`${this.id}-editor`);y(this,ja,null);y(this,xs);m(this,ui,e.color||Ot._defaultColor||Ht._defaultLineColor),m(this,xs,e.fontSize||Ot._defaultFontSize)}static get _keyboardManager(){const e=Ot.prototype,s=r=>r.isEmpty(),i=Xr.TRANSLATE_SMALL,n=Xr.TRANSLATE_BIG;return ht(this,"_keyboardManager",new ll([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:s}]]))}static initialize(e,s){Ht.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case dt.FREETEXT_SIZE:Ot._defaultFontSize=s;break;case dt.FREETEXT_COLOR:Ot._defaultColor=s;break}}updateParams(e,s){switch(e){case dt.FREETEXT_SIZE:w(this,ie,Ey).call(this,s);break;case dt.FREETEXT_COLOR:w(this,ie,ky).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[dt.FREETEXT_SIZE,Ot._defaultFontSize],[dt.FREETEXT_COLOR,Ot._defaultColor||Ht._defaultLineColor]]}get propertiesToUpdate(){return[[dt.FREETEXT_SIZE,l(this,xs)],[dt.FREETEXT_COLOR,l(this,ui)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-Ot._internalPadding*e,-(Ot._internalPadding+l(this,xs))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(nt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),m(this,ja,new AbortController);const e=this._uiManager.combinedSignal(l(this,ja));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){var e;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",l(this,Sc)),this._isDraggable=!0,(e=l(this,ja))==null||e.abort(),m(this,ja,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=l(this,ws),s=m(this,ws,w(this,ie,Py).call(this).trimEnd());if(e===s)return;const i=n=>{if(m(this,ws,n),!n){this.remove();return}w(this,ie,pf).call(this),this._uiManager.rebuild(this),w(this,ie,ff).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),w(this,ie,ff).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){Ot._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",l(this,Sc)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${l(this,xs)}px * var(--scale-factor))`,i.color=l(this,ui),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),gd(this,this.div,["dblclick","keydown"]),this.width){const[n,r]=this.parentDimensions;if(this.annotationElementId){const{position:a}=this._initialData;let[h,c]=this.getInitialTranslation();[h,c]=this.pageTranslationToScreen(h,c);const[u,d]=this.pageDimensions,[f,g]=this.pageTranslation;let p,v;switch(this.rotation){case 0:p=e+(a[0]-f)/u,v=s+this.height-(a[1]-g)/d;break;case 90:p=e+(a[0]-f)/u,v=s-(a[1]-g)/d,[h,c]=[c,-h];break;case 180:p=e-this.width+(a[0]-f)/u,v=s-(a[1]-g)/d,[h,c]=[-h,-c];break;case 270:p=e+(a[0]-f-this.height*d)/u,v=s+(a[1]-g-this.width*u)/d,[h,c]=[-c,h];break}this.setAt(p*n,v*r,h,c)}else this.setAt(e*n,s*r,this.width*n,this.height*r);w(this,ie,pf).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var p,v,_;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const n=w(p=Ot,kn,Zp).call(p,s.getData("text")||"").replaceAll(xd,`
|
|
531
531
|
`);if(!n)return;const r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();const a=r.getRangeAt(0);if(!n.includes(`
|
|
532
532
|
`)){a.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),r.collapseToStart();return}const{startContainer:h,startOffset:c}=a,u=[],d=[];if(h.nodeType===Node.TEXT_NODE){const b=h.parentElement;if(d.push(h.nodeValue.slice(c).replaceAll(xd,"")),b!==this.editorDiv){let x=u;for(const C of this.editorDiv.childNodes){if(C===b){x=d;continue}x.push(w(v=Ot,kn,gf).call(v,C))}}u.push(h.nodeValue.slice(0,c).replaceAll(xd,""))}else if(h===this.editorDiv){let b=u,x=0;for(const C of this.editorDiv.childNodes)x++===c&&(b=d),b.push(w(_=Ot,kn,gf).call(_,C))}m(this,ws,`${u.join(`
|
|
533
533
|
`)}${n}${d.join(`
|
|
534
|
-
`)}`),w(this,ie,pf).call(this);const f=new Range;let g=u.reduce((b,x)=>b+x.length,0);for(const{firstChild:b}of this.editorDiv.childNodes)if(b.nodeType===Node.TEXT_NODE){const x=b.nodeValue.length;if(g<=x){f.setStart(b,g),f.setEnd(b,g);break}g-=x}r.removeAllRanges(),r.addRange(f)}get contentDiv(){return this.editorDiv}static async deserialize(e,s,i){var a;let n=null;if(e instanceof
|
|
534
|
+
`)}`),w(this,ie,pf).call(this);const f=new Range;let g=u.reduce((b,x)=>b+x.length,0);for(const{firstChild:b}of this.editorDiv.childNodes)if(b.nodeType===Node.TEXT_NODE){const x=b.nodeValue.length;if(g<=x){f.setStart(b,g),f.setEnd(b,g);break}g-=x}r.removeAllRanges(),r.addRange(f)}get contentDiv(){return this.editorDiv}static async deserialize(e,s,i){var a;let n=null;if(e instanceof cb){const{data:{defaultAppearanceData:{fontSize:h,fontColor:c},rect:u,rotation:d,id:f,popupRef:g},textContent:p,textPosition:v,parent:{page:{pageNumber:_}}}=e;if(!p||p.length===0)return null;n=e={annotationType:nt.FREETEXT,color:Array.from(c),fontSize:h,value:p.join(`
|
|
535
535
|
`),position:v,pageIndex:_-1,rect:u.slice(0),rotation:d,id:f,deleted:!1,popupRef:g}}const r=await super.deserialize(e,s,i);return m(r,xs,e.fontSize),m(r,ui,q.makeHexColor(...e.color)),m(r,ws,w(a=Ot,kn,Zp).call(a,e.value)),r.annotationElementId=e.id||null,r._initialData=n,r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Ot._internalPadding*this.parentScale,i=this.getRect(s,s),n=Ht._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:l(this,ui)),r={annotationType:nt.FREETEXT,color:n,fontSize:l(this,xs),value:w(this,ie,My).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?r:this.annotationElementId&&!w(this,ie,Oy).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${l(this,xs)}px * var(--scale-factor))`,i.color=l(this,ui),s.replaceChildren();for(const r of l(this,ws).split(`
|
|
536
536
|
`)){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),s.append(a)}const n=Ot._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(n,n),popupContent:l(this,ws)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};ui=new WeakMap,ws=new WeakMap,Sc=new WeakMap,ja=new WeakMap,xs=new WeakMap,ie=new WeakSet,Ey=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-l(this,xs))*this.parentScale),m(this,xs,n),w(this,ie,ff).call(this)},i=l(this,xs);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},ky=function(e){const s=n=>{m(this,ui,this.editorDiv.style.color=n)},i=l(this,ui);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Py=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const n of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&n.nodeName==="BR"||(e.push(w(i=Ot,kn,gf).call(i,n)),s=n);return e.join(`
|
|
537
537
|
`)},ff=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:n,div:r}=this,a=r.style.display,h=r.classList.contains("hidden");r.classList.remove("hidden"),r.style.display="hidden",n.div.append(this.div),i=r.getBoundingClientRect(),r.remove(),r.style.display=a,r.classList.toggle("hidden",h)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},kn=new WeakSet,gf=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(xd,"")},pf=function(){if(this.editorDiv.replaceChildren(),!!l(this,ws))for(const e of l(this,ws).split(`
|
|
538
|
-
`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},My=function(){return l(this,ws).replaceAll(" "," ")},Zp=function(e){return e.replaceAll(" "," ")},Oy=function(e){const{value:s,fontSize:i,color:n,pageIndex:r}=this._initialData;return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((a,h)=>a!==n[h])||e.pageIndex!==r},y(Ot,kn),J(Ot,"_freeTextDefaultContent",""),J(Ot,"_internalPadding",0),J(Ot,"_defaultColor",null),J(Ot,"_defaultFontSize",10),J(Ot,"_type","freetext"),J(Ot,"_editorType",nt.FREETEXT);let ep=Ot;class X{toSVGPath(){Et("Abstract method `toSVGPath` must be implemented.")}get box(){Et("Abstract getter `box` must be implemented.")}serialize(t,e){Et("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,n,r){r||(r=new Float32Array(t.length));for(let a=0,h=t.length;a<h;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}static _rescaleAndSwap(t,e,s,i,n,r){r||(r=new Float32Array(t.length));for(let a=0,h=t.length;a<h;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let n=0,r=t.length;n<r;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,n){switch(n){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){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,s,i,n,r){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+r)/6,(s+n)/2,(i+r)/2]}}J(X,"PRECISION",1e-4);const Pn=class Pn{constructor({x:t,y:e},s,i,n,r,a=0){y(this,ce);y(this,Ss);y(this,di,[]);y(this,oh);y(this,hh);y(this,ji,[]);y(this,lt,new Float32Array(18));y(this,Na);y(this,Ba);y(this,Cc);y(this,Ac);y(this,lh);y(this,ch);y(this,br,[]);m(this,Ss,s),m(this,ch,n*i),m(this,hh,r),l(this,lt).set([NaN,NaN,NaN,NaN,t,e],6),m(this,oh,a),m(this,Ac,l(Pn,Tc)*i),m(this,Cc,l(Pn,Vd)*i),m(this,lh,i),l(this,br).push(t,e)}isEmpty(){return isNaN(l(this,lt)[8])}add({x:t,y:e}){var R;m(this,Na,t),m(this,Ba,e);const[s,i,n,r]=l(this,Ss);let[a,h,c,u]=l(this,lt).subarray(8,12);const d=t-c,f=e-u,g=Math.hypot(d,f);if(g<l(this,Cc))return!1;const p=g-l(this,Ac),v=p/g,_=v*d,b=v*f;let x=a,C=h;a=c,h=u,c+=_,u+=b,(R=l(this,br))==null||R.push(t,e);const A=-b/p,P=_/p,D=A*l(this,ch),k=P*l(this,ch);return l(this,lt).set(l(this,lt).subarray(2,8),0),l(this,lt).set([c+D,u+k],4),l(this,lt).set(l(this,lt).subarray(14,18),12),l(this,lt).set([c-D,u-k],16),isNaN(l(this,lt)[6])?(l(this,ji).length===0&&(l(this,lt).set([a+D,h+k],2),l(this,ji).push(NaN,NaN,NaN,NaN,(a+D-s)/n,(h+k-i)/r),l(this,lt).set([a-D,h-k],14),l(this,di).push(NaN,NaN,NaN,NaN,(a-D-s)/n,(h-k-i)/r)),l(this,lt).set([x,C,a,h,c,u],6),!this.isEmpty()):(l(this,lt).set([x,C,a,h,c,u],6),Math.abs(Math.atan2(C-h,x-a)-Math.atan2(b,_))<Math.PI/2?([a,h,c,u]=l(this,lt).subarray(2,6),l(this,ji).push(NaN,NaN,NaN,NaN,((a+c)/2-s)/n,((h+u)/2-i)/r),[a,h,x,C]=l(this,lt).subarray(14,18),l(this,di).push(NaN,NaN,NaN,NaN,((x+a)/2-s)/n,((C+h)/2-i)/r),!0):([x,C,a,h,c,u]=l(this,lt).subarray(0,6),l(this,ji).push(((x+5*a)/6-s)/n,((C+5*h)/6-i)/r,((5*a+c)/6-s)/n,((5*h+u)/6-i)/r,((a+c)/2-s)/n,((h+u)/2-i)/r),[c,u,a,h,x,C]=l(this,lt).subarray(12,18),l(this,di).push(((x+5*a)/6-s)/n,((C+5*h)/6-i)/r,((5*a+c)/6-s)/n,((5*h+u)/6-i)/r,((a+c)/2-s)/n,((h+u)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=l(this,ji),e=l(this,di);if(isNaN(l(this,lt)[6])&&!this.isEmpty())return w(this,ce,Dy).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);w(this,ce,Ly).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return w(this,ce,Ry).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,r){return new vb(t,e,s,i,n,r)}getOutlines(){var d;const t=l(this,ji),e=l(this,di),s=l(this,lt),[i,n,r,a]=l(this,Ss),h=new Float32Array((((d=l(this,br))==null?void 0:d.length)??0)+2);for(let f=0,g=h.length-2;f<g;f+=2)h[f]=(l(this,br)[f]-i)/r,h[f+1]=(l(this,br)[f+1]-n)/a;if(h[h.length-2]=(l(this,Na)-i)/r,h[h.length-1]=(l(this,Ba)-n)/a,isNaN(s[6])&&!this.isEmpty())return w(this,ce,Fy).call(this,h);const c=new Float32Array(l(this,ji).length+24+l(this,di).length);let u=t.length;for(let f=0;f<u;f+=2){if(isNaN(t[f])){c[f]=c[f+1]=NaN;continue}c[f]=t[f],c[f+1]=t[f+1]}u=w(this,ce,jy).call(this,c,u);for(let f=e.length-6;f>=6;f-=6)for(let g=0;g<6;g+=2){if(isNaN(e[f+g])){c[u]=c[u+1]=NaN,u+=2;continue}c[u]=e[f+g],c[u+1]=e[f+g+1],u+=2}return w(this,ce,Iy).call(this,c,u),this.newFreeDrawOutline(c,h,l(this,Ss),l(this,lh),l(this,oh),l(this,hh))}};Ss=new WeakMap,di=new WeakMap,oh=new WeakMap,hh=new WeakMap,ji=new WeakMap,lt=new WeakMap,Na=new WeakMap,Ba=new WeakMap,Cc=new WeakMap,Ac=new WeakMap,lh=new WeakMap,ch=new WeakMap,br=new WeakMap,Tc=new WeakMap,Gd=new WeakMap,Vd=new WeakMap,ce=new WeakSet,Zc=function(){const t=l(this,lt).subarray(4,6),e=l(this,lt).subarray(16,18),[s,i,n,r]=l(this,Ss);return[(l(this,Na)+(t[0]-e[0])/2-s)/n,(l(this,Ba)+(t[1]-e[1])/2-i)/r,(l(this,Na)+(e[0]-t[0])/2-s)/n,(l(this,Ba)+(e[1]-t[1])/2-i)/r]},Dy=function(){const[t,e,s,i]=l(this,Ss),[n,r,a,h]=w(this,ce,Zc).call(this);return`M${(l(this,lt)[2]-t)/s} ${(l(this,lt)[3]-e)/i} L${(l(this,lt)[4]-t)/s} ${(l(this,lt)[5]-e)/i} L${n} ${r} L${a} ${h} L${(l(this,lt)[16]-t)/s} ${(l(this,lt)[17]-e)/i} L${(l(this,lt)[14]-t)/s} ${(l(this,lt)[15]-e)/i} Z`},Ry=function(t){const e=l(this,di);t.push(`L${e[4]} ${e[5]} Z`)},Ly=function(t){const[e,s,i,n]=l(this,Ss),r=l(this,lt).subarray(4,6),a=l(this,lt).subarray(16,18),[h,c,u,d]=w(this,ce,Zc).call(this);t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${h} ${c} L${u} ${d} L${(a[0]-e)/i} ${(a[1]-s)/n}`)},Fy=function(t){const e=l(this,lt),[s,i,n,r]=l(this,Ss),[a,h,c,u]=w(this,ce,Zc).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,a,h,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(d,t,l(this,Ss),l(this,lh),l(this,oh),l(this,hh))},Iy=function(t,e){const s=l(this,di);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},jy=function(t,e){const s=l(this,lt).subarray(4,6),i=l(this,lt).subarray(16,18),[n,r,a,h]=l(this,Ss),[c,u,d,f]=w(this,ce,Zc).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/h,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,d,f,NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/h],e),e+=24},y(Pn,Tc,8),y(Pn,Gd,2),y(Pn,Vd,l(Pn,Tc)+l(Pn,Gd));let Sd=Pn;class vb extends X{constructor(e,s,i,n,r,a){super();y(this,Wd);y(this,uh);y(this,Ha,new Float32Array(4));y(this,Mn);y(this,Ec);y(this,Cs);y(this,kc);y(this,Jt);m(this,Jt,e),m(this,Cs,s),m(this,uh,i),m(this,kc,n),m(this,Mn,r),m(this,Ec,a),this.lastPoint=[NaN,NaN],w(this,Wd,Ny).call(this,a);const[h,c,u,d]=l(this,Ha);for(let f=0,g=e.length;f<g;f+=2)e[f]=(e[f]-h)/u,e[f+1]=(e[f+1]-c)/d;for(let f=0,g=s.length;f<g;f+=2)s[f]=(s[f]-h)/u,s[f+1]=(s[f+1]-c)/d}toSVGPath(){const e=[`M${l(this,Jt)[4]} ${l(this,Jt)[5]}`];for(let s=6,i=l(this,Jt).length;s<i;s+=6){if(isNaN(l(this,Jt)[s])){e.push(`L${l(this,Jt)[s+4]} ${l(this,Jt)[s+5]}`);continue}e.push(`C${l(this,Jt)[s]} ${l(this,Jt)[s+1]} ${l(this,Jt)[s+2]} ${l(this,Jt)[s+3]} ${l(this,Jt)[s+4]} ${l(this,Jt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,n],r){const a=i-e,h=n-s;let c,u;switch(r){case 0:c=X._rescale(l(this,Jt),e,n,a,-h),u=X._rescale(l(this,Cs),e,n,a,-h);break;case 90:c=X._rescaleAndSwap(l(this,Jt),e,s,a,h),u=X._rescaleAndSwap(l(this,Cs),e,s,a,h);break;case 180:c=X._rescale(l(this,Jt),i,s,-a,h),u=X._rescale(l(this,Cs),i,s,-a,h);break;case 270:c=X._rescaleAndSwap(l(this,Jt),i,n,-a,-h),u=X._rescaleAndSwap(l(this,Cs),i,n,-a,-h);break}return{outline:Array.from(c),points:[Array.from(u)]}}get box(){return l(this,Ha)}newOutliner(e,s,i,n,r,a=0){return new Sd(e,s,i,n,r,a)}getNewOutline(e,s){const[i,n,r,a]=l(this,Ha),[h,c,u,d]=l(this,uh),f=r*u,g=a*d,p=i*u+h,v=n*d+c,_=this.newOutliner({x:l(this,Cs)[0]*f+p,y:l(this,Cs)[1]*g+v},l(this,uh),l(this,kc),e,l(this,Ec),s??l(this,Mn));for(let b=2;b<l(this,Cs).length;b+=2)_.add({x:l(this,Cs)[b]*f+p,y:l(this,Cs)[b+1]*g+v});return _.getOutlines()}}uh=new WeakMap,Ha=new WeakMap,Mn=new WeakMap,Ec=new WeakMap,Cs=new WeakMap,kc=new WeakMap,Jt=new WeakMap,Wd=new WeakSet,Ny=function(e){const s=l(this,Jt);let i=s[4],n=s[5],r=i,a=n,h=i,c=n,u=i,d=n;const f=e?Math.max:Math.min;for(let p=6,v=s.length;p<v;p+=6){if(isNaN(s[p]))r=Math.min(r,s[p+4]),a=Math.min(a,s[p+5]),h=Math.max(h,s[p+4]),c=Math.max(c,s[p+5]),d<s[p+5]?(u=s[p+4],d=s[p+5]):d===s[p+5]&&(u=f(u,s[p+4]));else{const _=q.bezierBoundingBox(i,n,...s.slice(p,p+6));r=Math.min(r,_[0]),a=Math.min(a,_[1]),h=Math.max(h,_[2]),c=Math.max(c,_[3]),d<_[3]?(u=_[2],d=_[3]):d===_[3]&&(u=f(u,_[2]))}i=s[p+4],n=s[p+5]}const g=l(this,Ha);g[0]=r-l(this,Mn),g[1]=a-l(this,Mn),g[2]=h-r+2*l(this,Mn),g[3]=c-a+2*l(this,Mn),this.lastPoint=[u,d]};class sp{constructor(t,e=0,s=0,i=!0){y(this,Ye);y(this,Pc);y(this,Mc);y(this,yr,[]);y(this,fi,[]);let n=1/0,r=-1/0,a=1/0,h=-1/0;const c=10**-4;for(const{x:_,y:b,width:x,height:C}of t){const A=Math.floor((_-e)/c)*c,P=Math.ceil((_+x+e)/c)*c,D=Math.floor((b-e)/c)*c,k=Math.ceil((b+C+e)/c)*c,M=[A,D,k,!0],R=[P,D,k,!1];l(this,yr).push(M,R),n=Math.min(n,A),r=Math.max(r,P),a=Math.min(a,D),h=Math.max(h,k)}const u=r-n+2*s,d=h-a+2*s,f=n-s,g=a-s,p=l(this,yr).at(i?-1:-2),v=[p[0],p[2]];for(const _ of l(this,yr)){const[b,x,C]=_;_[0]=(b-f)/u,_[1]=(x-g)/d,_[2]=(C-g)/d}m(this,Pc,new Float32Array([f,g,u,d])),m(this,Mc,v)}getOutlines(){l(this,yr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of l(this,yr))e[3]?(t.push(...w(this,Ye,tm).call(this,e)),w(this,Ye,Hy).call(this,e)):(w(this,Ye,Gy).call(this,e),t.push(...w(this,Ye,tm).call(this,e)));return w(this,Ye,By).call(this,t)}}Pc=new WeakMap,Mc=new WeakMap,yr=new WeakMap,fi=new WeakMap,Ye=new WeakSet,By=function(t){const e=[],s=new Set;for(const r of t){const[a,h,c]=r;e.push([a,h,r],[a,c,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const h=e[r][2],c=e[r+1][2];h.push(c),c.push(h),s.add(h),s.add(c)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[a,h,c,u,d]=r;s.delete(r);let f=a,g=h;for(n=[a,c],i.push(n);;){let p;if(s.has(u))p=u;else if(s.has(d))p=d;else break;s.delete(p),[a,h,c,u,d]=p,f!==a&&(n.push(f,g,a,g===h?h:c),f=a),g=g===h?c:h}n.push(f,g)}return new KC(i,l(this,Pc),l(this,Mc))},mf=function(t){const e=l(this,fi);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1},Hy=function([,t,e]){const s=w(this,Ye,mf).call(this,t);l(this,fi).splice(s,0,[t,e])},Gy=function([,t,e]){const s=w(this,Ye,mf).call(this,t);for(let i=s;i<l(this,fi).length;i++){const[n,r]=l(this,fi)[i];if(n!==t)break;if(n===t&&r===e){l(this,fi).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,r]=l(this,fi)[i];if(n!==t)break;if(n===t&&r===e){l(this,fi).splice(i,1);return}}},tm=function(t){const[e,s,i]=t,n=[[e,s,i]],r=w(this,Ye,mf).call(this,i);for(let a=0;a<r;a++){const[h,c]=l(this,fi)[a];for(let u=0,d=n.length;u<d;u++){const[,f,g]=n[u];if(!(c<=f||g<=h)){if(f>=h){if(g>c)n[u][1]=c;else{if(d===1)return[];n.splice(u,1),u--,d--}continue}n[u][2]=h,g>c&&n.push([e,c,g])}}}return n};class KC extends X{constructor(e,s,i){super();y(this,Oc);y(this,dh);m(this,dh,e),m(this,Oc,s),this.lastPoint=i}toSVGPath(){const e=[];for(const s of l(this,dh)){let[i,n]=s;e.push(`M${i} ${n}`);for(let r=2;r<s.length;r+=2){const a=s[r],h=s[r+1];a===i?(e.push(`V${h}`),n=h):h===n&&(e.push(`H${a}`),i=a)}e.push("Z")}return e.join(" ")}serialize([e,s,i,n],r){const a=[],h=i-e,c=n-s;for(const u of l(this,dh)){const d=new Array(u.length);for(let f=0;f<u.length;f+=2)d[f]=e+u[f]*h,d[f+1]=n-u[f+1]*c;a.push(d)}return a}get box(){return l(this,Oc)}get classNamesForOutlining(){return["highlightOutline"]}}Oc=new WeakMap,dh=new WeakMap;class ip extends Sd{newFreeDrawOutline(t,e,s,i,n,r){return new JC(t,e,s,i,n,r)}}class JC extends vb{newOutliner(t,e,s,i,n,r=0){return new ip(t,e,s,i,n,r)}}const hs=class hs{constructor({editor:t=null,uiManager:e=null}){y(this,At);y(this,gi,null);y(this,Ga,null);y(this,fh);y(this,ue,null);y(this,Dc,!1);y(this,gh,!1);y(this,Rc,null);y(this,Lc);y(this,_r,null);y(this,pi,null);y(this,ph);var s;t?(m(this,gh,!1),m(this,ph,dt.HIGHLIGHT_COLOR),m(this,Rc,t)):(m(this,gh,!0),m(this,ph,dt.HIGHLIGHT_DEFAULT_COLOR)),m(this,pi,(t==null?void 0:t._uiManager)||e),m(this,Lc,l(this,pi)._eventBus),m(this,fh,(t==null?void 0:t.color)||((s=l(this,pi))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),l(hs,Fc)||m(hs,Fc,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return ht(this,"_keyboardManager",new cl([[["Escape","mac+Escape"],hs.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],hs.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],hs.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],hs.prototype._moveToPrevious],[["Home","mac+Home"],hs.prototype._moveToBeginning],[["End","mac+End"],hs.prototype._moveToEnd]]))}renderButton(){const t=m(this,gi,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=l(this,pi)._signal;t.addEventListener("click",w(this,At,io).bind(this),{signal:e}),t.addEventListener("keydown",w(this,At,im).bind(this),{signal:e});const s=m(this,Ga,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=l(this,fh),t.append(s),t}renderMainDropdown(){const t=m(this,ue,w(this,At,em).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===l(this,gi)){w(this,At,io).call(this,t);return}const e=t.target.getAttribute("data-color");e&&w(this,At,sm).call(this,e,t)}_moveToNext(t){var e,s;if(!l(this,At,Pr)){w(this,At,io).call(this,t);return}if(t.target===l(this,gi)){(e=l(this,ue).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=l(this,ue))==null?void 0:e.firstChild)||t.target===l(this,gi)){l(this,At,Pr)&&this._hideDropdownFromKeyboard();return}l(this,At,Pr)||w(this,At,io).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!l(this,At,Pr)){w(this,At,io).call(this,t);return}(e=l(this,ue).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!l(this,At,Pr)){w(this,At,io).call(this,t);return}(e=l(this,ue).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=l(this,ue))==null||t.classList.add("hidden"),(e=l(this,_r))==null||e.abort(),m(this,_r,null)}_hideDropdownFromKeyboard(){var t;if(!l(this,gh)){if(!l(this,At,Pr)){(t=l(this,Rc))==null||t.unselect();return}this.hideDropdown(),l(this,gi).focus({preventScroll:!0,focusVisible:l(this,Dc)})}}updateColor(t){if(l(this,Ga)&&(l(this,Ga).style.backgroundColor=t),!l(this,ue))return;const e=l(this,pi).highlightColors.values();for(const s of l(this,ue).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){var t,e;(t=l(this,gi))==null||t.remove(),m(this,gi,null),m(this,Ga,null),(e=l(this,ue))==null||e.remove(),m(this,ue,null)}};gi=new WeakMap,Ga=new WeakMap,fh=new WeakMap,ue=new WeakMap,Dc=new WeakMap,gh=new WeakMap,Rc=new WeakMap,Lc=new WeakMap,_r=new WeakMap,pi=new WeakMap,ph=new WeakMap,Fc=new WeakMap,At=new WeakSet,em=function(){const t=document.createElement("div"),e=l(this,pi)._signal;t.addEventListener("contextmenu",ii,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,i]of l(this,pi).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",l(hs,Fc)[s]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.setAttribute("aria-selected",i===l(this,fh)),n.addEventListener("click",w(this,At,sm).bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",w(this,At,im).bind(this),{signal:e}),t},sm=function(t,e){e.stopPropagation(),l(this,Lc).dispatch("switchannotationeditorparams",{source:this,type:l(this,ph),value:t})},im=function(t){hs._keyboardManager.exec(this,t)},io=function(t){if(l(this,At,Pr)){this.hideDropdown();return}if(m(this,Dc,t.detail===0),l(this,_r)||(m(this,_r,new AbortController),window.addEventListener("pointerdown",w(this,At,Vy).bind(this),{signal:l(this,pi).combinedSignal(l(this,_r))})),l(this,ue)){l(this,ue).classList.remove("hidden");return}const e=m(this,ue,w(this,At,em).call(this));l(this,gi).append(e)},Vy=function(t){var e;(e=l(this,ue))!=null&&e.contains(t.target)||this.hideDropdown()},Pr=function(){return l(this,ue)&&!l(this,ue).classList.contains("hidden")},y(hs,Fc,null);let Cd=hs;const bt=class bt extends Ht{constructor(e){super({...e,name:"highlightEditor"});y(this,st);y(this,mh,null);y(this,Ic,0);y(this,On);y(this,Va,null);y(this,vh,null);y(this,ls,null);y(this,jc,null);y(this,Nc,0);y(this,Wa,null);y(this,Hs,null);y(this,As,null);y(this,_e,!1);y(this,bh,null);y(this,Dn);y(this,Le,null);y(this,yh,"");y(this,Gs);y(this,Bc,"");this.color=e.color||bt._defaultColor,m(this,Gs,e.thickness||bt._defaultThickness),m(this,Dn,e.opacity||bt._defaultOpacity),m(this,On,e.boxes||null),m(this,Bc,e.methodOfCreation||""),m(this,yh,e.text||""),this._isDraggable=!1,e.highlightId>-1?(m(this,_e,!0),w(this,st,vf).call(this,e),w(this,st,no).call(this)):l(this,On)&&(m(this,mh,e.anchorNode),m(this,Ic,e.anchorOffset),m(this,jc,e.focusNode),m(this,Nc,e.focusOffset),w(this,st,nm).call(this),w(this,st,no).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=bt.prototype;return ht(this,"_keyboardManager",new cl([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:l(this,_e)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:l(this,Gs),methodOfCreation:l(this,Bc)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;Ht.initialize(e,s),bt._defaultColor||(bt._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case dt.HIGHLIGHT_DEFAULT_COLOR:bt._defaultColor=s;break;case dt.HIGHLIGHT_THICKNESS:bt._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return l(this,bh)}updateParams(e,s){switch(e){case dt.HIGHLIGHT_COLOR:w(this,st,Wy).call(this,s);break;case dt.HIGHLIGHT_THICKNESS:w(this,st,zy).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[dt.HIGHLIGHT_DEFAULT_COLOR,bt._defaultColor],[dt.HIGHLIGHT_THICKNESS,bt._defaultThickness]]}get propertiesToUpdate(){return[[dt.HIGHLIGHT_COLOR,this.color||bt._defaultColor],[dt.HIGHLIGHT_THICKNESS,l(this,Gs)||bt._defaultThickness],[dt.HIGHLIGHT_FREE,l(this,_e)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(m(this,vh,new Cd({editor:this})),e.addColorPicker(l(this,vh))),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(w(this,st,tu).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,w(this,st,tu).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){w(this,st,rm).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(w(this,st,no).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?w(this,st,rm).call(this):e&&(w(this,st,no).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var n,r,a;const{drawLayer:s}=this.parent;let i;l(this,_e)?(e=(e-this.rotation+360)%360,i=w(n=bt,Vs,Nh).call(n,l(this,Hs).box,e)):i=w(r=bt,Vs,Nh).call(r,[this.x,this.y,this.width,this.height],e),s.updateProperties(l(this,As),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(l(this,Le),{bbox:w(a=bt,Vs,Nh).call(a,l(this,ls).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();l(this,yh)&&(e.setAttribute("aria-label",l(this,yh)),e.setAttribute("role","mark")),l(this,_e)?e.classList.add("free"):this.div.addEventListener("keydown",w(this,st,Uy).bind(this),{signal:this._uiManager._signal});const s=m(this,Wa,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=l(this,Va);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),gd(this,l(this,Wa),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(l(this,Le),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(l(this,Le),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:w(this,st,bf).call(this,!0);break;case 1:case 3:w(this,st,bf).call(this,!1);break}}select(){var e;super.select(),l(this,Le)&&((e=this.parent)==null||e.drawLayer.updateProperties(l(this,Le),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),l(this,Le)&&((e=this.parent)==null||e.drawLayer.updateProperties(l(this,Le),{rootClass:{selected:!1}}),l(this,_e)||w(this,st,bf).call(this,!1))}get _mustFixPosition(){return!l(this,_e)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(l(this,As),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(l(this,Le),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:n,y:r}){const{x:a,y:h,width:c,height:u}=i.getBoundingClientRect(),d=new AbortController,f=e.combinedSignal(d),g=p=>{d.abort(),w(this,Vs,Ky).call(this,e,p)};window.addEventListener("blur",g,{signal:f}),window.addEventListener("pointerup",g,{signal:f}),window.addEventListener("pointerdown",gs,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",ii,{signal:f}),i.addEventListener("pointermove",w(this,Vs,qy).bind(this,e),{signal:f}),this._freeHighlight=new ip({x:n,y:r},[a,h,c,u],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,s,i){var v,_,b,x;let n=null;if(e instanceof pb){const{data:{quadPoints:C,rect:A,rotation:P,id:D,color:k,opacity:M,popupRef:R},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:nt.HIGHLIGHT,color:Array.from(k),opacity:M,quadPoints:C,boxes:null,pageIndex:F-1,rect:A.slice(0),rotation:P,id:D,deleted:!1,popupRef:R}}else if(e instanceof tp){const{data:{inkLists:C,rect:A,rotation:P,id:D,color:k,borderStyle:{rawWidth:M},popupRef:R},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:nt.HIGHLIGHT,color:Array.from(k),thickness:M,inkLists:C,boxes:null,pageIndex:F-1,rect:A.slice(0),rotation:P,id:D,deleted:!1,popupRef:R}}const{color:r,quadPoints:a,inkLists:h,opacity:c}=e,u=await super.deserialize(e,s,i);u.color=q.makeHexColor(...r),m(u,Dn,c||1),h&&m(u,Gs,e.thickness),u.annotationElementId=e.id||null,u._initialData=n;const[d,f]=u.pageDimensions,[g,p]=u.pageTranslation;if(a){const C=m(u,On,[]);for(let A=0;A<a.length;A+=8)C.push({x:(a[A]-g)/d,y:1-(a[A+1]-p)/f,width:(a[A+2]-a[A])/d,height:(a[A+1]-a[A+5])/f});w(v=u,st,nm).call(v),w(_=u,st,no).call(_),u.rotate(u.rotation)}else if(h){m(u,_e,!0);const C=h[0],A={x:C[0]-g,y:f-(C[1]-p)},P=new ip(A,[0,0,d,f],1,l(u,Gs)/2,!0,.001);for(let M=0,R=C.length;M<R;M+=2)A.x=C[M]-g,A.y=f-(C[M+1]-p),P.add(A);const{id:D,clipPathId:k}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:P.toSVGPath()}},!0,!0);w(b=u,st,vf).call(b,{highlightOutlines:P.getOutlines(),highlightId:D,clipPathId:k}),w(x=u,st,no).call(x)}return u}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=this.getRect(0,0),i=Ht._colorManager.convert(this.color),n={annotationType:nt.HIGHLIGHT,color:i,opacity:l(this,Dn),thickness:l(this,Gs),quadPoints:w(this,st,Yy).call(this),outlines:w(this,st,$y).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:w(this,st,tu).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!w(this,st,Jy).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};mh=new WeakMap,Ic=new WeakMap,On=new WeakMap,Va=new WeakMap,vh=new WeakMap,ls=new WeakMap,jc=new WeakMap,Nc=new WeakMap,Wa=new WeakMap,Hs=new WeakMap,As=new WeakMap,_e=new WeakMap,bh=new WeakMap,Dn=new WeakMap,Le=new WeakMap,yh=new WeakMap,Gs=new WeakMap,Bc=new WeakMap,st=new WeakSet,nm=function(){const e=new sp(l(this,On),.001);m(this,Hs,e.getOutlines()),[this.x,this.y,this.width,this.height]=l(this,Hs).box;const s=new sp(l(this,On),.0025,.001,this._uiManager.direction==="ltr");m(this,ls,s.getOutlines());const{lastPoint:i}=l(this,ls);m(this,bh,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},vf=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var d,f;if(m(this,Hs,e),m(this,ls,e.getNewOutline(l(this,Gs)/2+1.5,.0025)),s>=0)m(this,As,s),m(this,Va,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),m(this,Le,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:l(this,ls).box,path:{d:l(this,ls).toSVGPath()}},!0));else if(this.parent){const g=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(l(this,As),{bbox:w(d=bt,Vs,Nh).call(d,l(this,Hs).box,(g-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(l(this,Le),{bbox:w(f=bt,Vs,Nh).call(f,l(this,ls).box,g),path:{d:l(this,ls).toSVGPath()}})}const[r,a,h,c]=e.box;switch(this.rotation){case 0:this.x=r,this.y=a,this.width=h,this.height=c;break;case 90:{const[g,p]=this.parentDimensions;this.x=a,this.y=1-r,this.width=h*p/g,this.height=c*g/p;break}case 180:this.x=1-r,this.y=1-a,this.width=h,this.height=c;break;case 270:{const[g,p]=this.parentDimensions;this.x=1-a,this.y=r,this.width=h*p/g,this.height=c*g/p;break}}const{lastPoint:u}=l(this,ls);m(this,bh,[(u[0]-r)/h,(u[1]-a)/c])},Wy=function(e){const s=(r,a)=>{var h,c;this.color=r,m(this,Dn,a),(h=this.parent)==null||h.drawLayer.updateProperties(l(this,As),{root:{fill:r,"fill-opacity":a}}),(c=l(this,vh))==null||c.updateColor(r)},i=this.color,n=l(this,Dn);this.addCommands({cmd:s.bind(this,e,bt._defaultOpacity),undo:s.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},zy=function(e){const s=l(this,Gs),i=n=>{m(this,Gs,n),w(this,st,Xy).call(this,n)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Xy=function(e){if(!l(this,_e))return;w(this,st,vf).call(this,{highlightOutlines:l(this,Hs).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},rm=function(){l(this,As)===null||!this.parent||(this.parent.drawLayer.remove(l(this,As)),m(this,As,null),this.parent.drawLayer.remove(l(this,Le)),m(this,Le,null))},no=function(e=this.parent){l(this,As)===null&&({id:Ze(this,As)._,clipPathId:Ze(this,Va)._}=e.drawLayer.draw({bbox:l(this,Hs).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":l(this,Dn)},rootClass:{highlight:!0,free:l(this,_e)},path:{d:l(this,Hs).toSVGPath()}},!1,!0),m(this,Le,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:l(this,_e)},bbox:l(this,ls).box,path:{d:l(this,ls).toSVGPath()}},l(this,_e))),l(this,Wa)&&(l(this,Wa).style.clipPath=l(this,Va)))},Vs=new WeakSet,Nh=function([e,s,i,n],r){switch(r){case 90:return[1-s-n,e,n,i];case 180:return[1-e-i,1-s-n,i,n];case 270:return[s,1-e-i,n,i]}return[e,s,i,n]},Uy=function(e){bt._keyboardManager.exec(this,e)},bf=function(e){if(!l(this,mh))return;const s=window.getSelection();e?s.setPosition(l(this,mh),l(this,Ic)):s.setPosition(l(this,jc),l(this,Nc))},tu=function(){return l(this,_e)?this.rotation:0},Yy=function(){if(l(this,_e))return null;const[e,s]=this.pageDimensions,[i,n]=this.pageTranslation,r=l(this,On),a=new Float32Array(r.length*8);let h=0;for(const{x:c,y:u,width:d,height:f}of r){const g=c*e+i,p=(1-u)*s+n;a[h]=a[h+4]=g,a[h+1]=a[h+3]=p,a[h+2]=a[h+6]=g+d*e,a[h+5]=a[h+7]=p-f*s,h+=8}return a},$y=function(e){return l(this,Hs).serialize(e,w(this,st,tu).call(this))},qy=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Ky=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Jy=function(e){const{color:s}=this._initialData;return e.color.some((i,n)=>i!==s[n])},y(bt,Vs),J(bt,"_defaultColor",null),J(bt,"_defaultOpacity",1),J(bt,"_defaultThickness",12),J(bt,"_type","highlight"),J(bt,"_editorType",nt.HIGHLIGHT),J(bt,"_freeHighlightId",-1),J(bt,"_freeHighlight",null),J(bt,"_freeHighlightClipId","");let Ad=bt;class QC{constructor(){y(this,za,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))this.updateProperty(e,s)}updateSVGProperty(t,e){l(this,za)[t]=e}toSVGProperties(){const t=l(this,za);return m(this,za,Object.create(null)),{root:t}}reset(){m(this,za,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Et("Not implemented")}}za=new WeakMap;const U=class U extends Ht{constructor(e){super(e);y(this,mt);y(this,Ts,null);y(this,_h);J(this,"_drawId",null);m(this,_h,e.mustBeCommitted||!1),e.drawOutlines&&(w(this,mt,am).call(this,e),w(this,mt,eu).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[n,r]of Object.entries(s))i.has(n)?Object.assign(e[n],r):e[n]=r;return e}static getDefaultDrawingOptions(e){Et("Not implemented")}static get typesMap(){Et("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(l(U,pe).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,n]of this.typesMap)e.push([i,s[n]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,n]of this.constructor.typesMap)e.push([i,s[n]]);return e}_updateProperty(e,s,i){const n=this._drawingOptions,r=n[s],a=h=>{var u;n.updateProperty(s,h);const c=l(this,Ts).updateProperty(s,h);c&&w(this,mt,su).call(this,c),(u=this.parent)==null||u.drawLayer.updateProperties(this._drawId,n.toSVGProperties())};this.addCommands({cmd:a.bind(this,i),undo:a.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,U._mergeSVGProperties(l(this,Ts).getPathResizingSVGProperties(w(this,mt,yf).call(this)),{bbox:w(this,mt,Bh).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,U._mergeSVGProperties(l(this,Ts).getPathResizedSVGProperties(w(this,mt,yf).call(this)),{bbox:w(this,mt,Bh).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:w(this,mt,Bh).call(this,e,s)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,U._mergeSVGProperties(l(this,Ts).getPathTranslatedSVGProperties(w(this,mt,yf).call(this),this.parentDimensions),{bbox:w(this,mt,Bh).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,l(this,_h)&&(m(this,_h,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){w(this,mt,hm).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(w(this,mt,eu).call(this),w(this,mt,su).call(this,l(this,Ts).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),w(this,mt,hm).call(this)):e&&(this._uiManager.addShouldRescale(this),w(this,mt,eu).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,U._mergeSVGProperties({bbox:w(this,mt,Bh).call(this)},l(this,Ts).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&w(this,mt,su).call(this,l(this,Ts).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const e=super.render();e.classList.add("draw");const s=document.createElement("div");e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,s,i,n,r){Et("Not implemented")}static startDrawing(e,s,i,n){var _;const{target:r,offsetX:a,offsetY:h,pointerId:c,pointerType:u}=n;if(l(U,xr)&&l(U,xr)!==u)return;const{viewport:{rotation:d}}=e,{width:f,height:g}=r.getBoundingClientRect(),p=m(U,Xa,new AbortController),v=e.combinedSignal(p);if(l(U,wr)||m(U,wr,c),l(U,xr)??m(U,xr,u),window.addEventListener("pointerup",b=>{var x;l(U,wr)===b.pointerId?this._endDraw(b):(x=l(U,Sr))==null||x.delete(b.pointerId)},{signal:v}),window.addEventListener("pointercancel",b=>{var x;l(U,wr)===b.pointerId?this._currentParent.endDrawingSession():(x=l(U,Sr))==null||x.delete(b.pointerId)},{signal:v}),window.addEventListener("pointerdown",b=>{l(U,xr)===b.pointerType&&((l(U,Sr)||m(U,Sr,new Set)).add(b.pointerId),l(U,pe).isCancellable()&&(l(U,pe).removeLastElement(),l(U,pe).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:v}),window.addEventListener("contextmenu",ii,{signal:v}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:v}),r.addEventListener("touchmove",b=>{b.timeStamp===l(U,Ya)&&gs(b)},{signal:v}),e.toggleDrawing(),(_=s._editorUndoBar)==null||_.hide(),l(U,pe)){e.drawLayer.updateProperties(this._currentDrawId,l(U,pe).startNew(a,h,f,g,d));return}s.updateUIForDefaultProperties(this),m(U,pe,this.createDrawerInstance(a,h,f,g,d)),m(U,Ua,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(l(U,Ua).toSVGProperties(),l(U,pe).defaultSVGProperties),!0,!1)}static _drawMove(e){var r;if(m(U,Ya,-1),!l(U,pe))return;const{offsetX:s,offsetY:i,pointerId:n}=e;if(l(U,wr)===n){if(((r=l(U,Sr))==null?void 0:r.size)>=1){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,l(U,pe).add(s,i)),m(U,Ya,e.timeStamp),gs(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,m(U,pe,null),m(U,Ua,null),m(U,xr,null),m(U,Ya,NaN)),l(U,Xa)&&(l(U,Xa).abort(),m(U,Xa,null),m(U,wr,NaN),m(U,Sr,null))}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),e&&s.drawLayer.updateProperties(this._currentDrawId,l(U,pe).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=l(U,pe),n=this._currentDrawId,r=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(n,i.setLastElement(r))},undo:()=>{s.drawLayer.updateProperties(n,i.removeLastElement())},mustExec:!1,type:dt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(dt.DRAW_STEP),!l(U,pe).isEmpty()){const{pageDimensions:[i,n],scale:r}=s,a=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:l(U,pe).getOutlines(i*r,n*r,r,this._INNER_MARGIN),drawingOptions:l(U,Ua),mustBeCommitted:!e});return this._cleanup(!0),a}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,n,r,a){Et("Not implemented")}static async deserialize(e,s,i){var d,f;const{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:h}}=s.viewport,c=this.deserializeDraw(a,h,n,r,this._INNER_MARGIN,e),u=await super.deserialize(e,s,i);return u.createDrawingOptions(e),w(d=u,mt,am).call(d,{drawOutlines:c}),w(f=u,mt,eu).call(f),u.onScaleChanging(),u.rotate(),u}serializeDraw(e){const[s,i]=this.pageTranslation,[n,r]=this.pageDimensions;return l(this,Ts).serialize([s,i,n,r],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Ts=new WeakMap,_h=new WeakMap,pe=new WeakMap,Xa=new WeakMap,Ua=new WeakMap,wr=new WeakMap,xr=new WeakMap,Sr=new WeakMap,Ya=new WeakMap,mt=new WeakSet,am=function({drawOutlines:e,drawId:s,drawingOptions:i}){m(this,Ts,e),this._drawingOptions||(this._drawingOptions=i),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=w(this,mt,om).call(this,e,this.parent),w(this,mt,su).call(this,e.box)},om=function(e,s){const{id:i}=s.drawLayer.draw(U._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},hm=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},eu=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=w(this,mt,om).call(this,l(this,Ts),e)}},Qy=function([e,s,i,n]){const{parentDimensions:[r,a],rotation:h}=this;switch(h){case 90:return[s,1-e,i*(a/r),n*(r/a)];case 180:return[1-e,1-s,i,n];case 270:return[1-s,e,i*(a/r),n*(r/a)];default:return[e,s,i,n]}},yf=function(){const{x:e,y:s,width:i,height:n,parentDimensions:[r,a],rotation:h}=this;switch(h){case 90:return[1-s,e,i*(r/a),n*(a/r)];case 180:return[1-e,1-s,i,n];case 270:return[s,1-e,i*(r/a),n*(a/r)];default:return[e,s,i,n]}},su=function(e){if([this.x,this.y,this.width,this.height]=w(this,mt,Qy).call(this,e),this.div){this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)}this._onResized()},Bh=function(){const{x:e,y:s,width:i,height:n,rotation:r,parentRotation:a,parentDimensions:[h,c]}=this;switch((r*4+a)/90){case 1:return[1-s-n,e,n,i];case 2:return[1-e-i,1-s-n,i,n];case 3:return[s,1-e-i,n,i];case 4:return[e,s-i*(h/c),n*(c/h),i*(h/c)];case 5:return[1-s,e,i*(h/c),n*(c/h)];case 6:return[1-e-n*(c/h),1-s,n*(c/h),i*(h/c)];case 7:return[s-i*(h/c),1-e-n*(c/h),i*(h/c),n*(c/h)];case 8:return[e-i,s-n,i,n];case 9:return[1-s,e-i,n,i];case 10:return[1-e,1-s,i,n];case 11:return[s-n,1-e,n,i];case 12:return[e-n*(c/h),s,n*(c/h),i*(h/c)];case 13:return[1-s-i*(h/c),e-n*(c/h),i*(h/c),n*(c/h)];case 14:return[1-e,1-s-i*(h/c),n*(c/h),i*(h/c)];case 15:return[s,1-e,i*(h/c),n*(c/h)];default:return[e,s,i,n]}},J(U,"_currentDrawId",-1),J(U,"_currentParent",null),y(U,pe,null),y(U,Xa,null),y(U,Ua,null),y(U,wr,NaN),y(U,xr,null),y(U,Sr,null),y(U,Ya,NaN),J(U,"_INNER_MARGIN",3);let np=U;class ZC{constructor(t,e,s,i,n,r){y(this,xh);y(this,Ni,new Float64Array(6));y(this,me);y(this,ve);y(this,$a);y(this,wh);y(this,$e);y(this,we,"");y(this,Ws,0);y(this,qa,new Td);y(this,Ka);y(this,Ja);m(this,Ka,s),m(this,Ja,i),m(this,$a,n),m(this,wh,r),[t,e]=w(this,xh,_f).call(this,t,e);const a=m(this,me,[NaN,NaN,NaN,NaN,t,e]);m(this,$e,[t,e]),m(this,ve,[{line:a,points:l(this,$e)}]),l(this,Ni).set(a,0)}updateProperty(t,e){t==="stroke-width"&&m(this,wh,e)}isEmpty(){return!l(this,ve)||l(this,ve).length===0}isCancellable(){return l(this,$e).length<=10}add(t,e){[t,e]=w(this,xh,_f).call(this,t,e);const[s,i,n,r]=l(this,Ni).subarray(2,6),a=t-n,h=e-r;return Math.hypot(l(this,Ka)*a,l(this,Ja)*h)<=2?null:(l(this,$e).push(t,e),isNaN(s)?(l(this,Ni).set([n,r,t,e],2),l(this,me).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(l(this,Ni)[0])&&l(this,me).splice(6,6),l(this,Ni).set([s,i,n,r,t,e],0),l(this,me).push(...X.createBezierPoints(s,i,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(l(this,$e).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,n){m(this,Ka,s),m(this,Ja,i),m(this,$a,n),[t,e]=w(this,xh,_f).call(this,t,e);const r=m(this,me,[NaN,NaN,NaN,NaN,t,e]);m(this,$e,[t,e]);const a=l(this,ve).at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),l(this,ve).push({line:r,points:l(this,$e)}),l(this,Ni).set(r,0),m(this,Ws,0),this.toSVGPath(),null}getLastElement(){return l(this,ve).at(-1)}setLastElement(t){return l(this,ve)?(l(this,ve).push(t),m(this,me,t.line),m(this,$e,t.points),m(this,Ws,0),{path:{d:this.toSVGPath()}}):l(this,qa).setLastElement(t)}removeLastElement(){if(!l(this,ve))return l(this,qa).removeLastElement();l(this,ve).pop(),m(this,we,"");for(let t=0,e=l(this,ve).length;t<e;t++){const{line:s,points:i}=l(this,ve)[t];m(this,me,s),m(this,$e,i),m(this,Ws,0),this.toSVGPath()}return{path:{d:l(this,we)}}}toSVGPath(){const t=X.svgRound(l(this,me)[4]),e=X.svgRound(l(this,me)[5]);if(l(this,$e).length===2)return m(this,we,`${l(this,we)} M ${t} ${e} Z`),l(this,we);if(l(this,$e).length<=6){const i=l(this,we).lastIndexOf("M");m(this,we,`${l(this,we).slice(0,i)} M ${t} ${e}`),m(this,Ws,6)}if(l(this,$e).length===4){const i=X.svgRound(l(this,me)[10]),n=X.svgRound(l(this,me)[11]);return m(this,we,`${l(this,we)} L ${i} ${n}`),m(this,Ws,12),l(this,we)}const s=[];l(this,Ws)===0&&(s.push(`M ${t} ${e}`),m(this,Ws,6));for(let i=l(this,Ws),n=l(this,me).length;i<n;i+=6){const[r,a,h,c,u,d]=l(this,me).slice(i,i+6).map(X.svgRound);s.push(`C${r} ${a} ${h} ${c} ${u} ${d}`)}return m(this,we,l(this,we)+s.join(" ")),m(this,Ws,l(this,me).length),l(this,we)}getOutlines(t,e,s,i){const n=l(this,ve).at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),l(this,qa).build(l(this,ve),t,e,s,l(this,$a),l(this,wh),i),m(this,Ni,null),m(this,me,null),m(this,ve,null),m(this,we,null),l(this,qa)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Ni=new WeakMap,me=new WeakMap,ve=new WeakMap,$a=new WeakMap,wh=new WeakMap,$e=new WeakMap,we=new WeakMap,Ws=new WeakMap,qa=new WeakMap,Ka=new WeakMap,Ja=new WeakMap,xh=new WeakSet,_f=function(t,e){return X._normalizePoint(t,e,l(this,Ka),l(this,Ja),l(this,$a))};const gp=class gp extends X{constructor(){super(...arguments);y(this,xe);y(this,qe);y(this,Hc,0);y(this,Gc);y(this,Es);y(this,Bi);y(this,Hi);y(this,Sh);y(this,Ch);y(this,Ah)}build(e,s,i,n,r,a,h){m(this,Bi,s),m(this,Hi,i),m(this,Sh,n),m(this,Ch,r),m(this,Ah,a),m(this,Gc,h??0),m(this,Es,e),w(this,xe,t_).call(this)}setLastElement(e){return l(this,Es).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return l(this,Es).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of l(this,Es)){if(e.push(`M${X.svgRound(s[4])} ${X.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12){e.push(`L${X.svgRound(s[10])} ${X.svgRound(s[11])}`);continue}for(let i=6,n=s.length;i<n;i+=6){const[r,a,h,c,u,d]=s.subarray(i,i+6).map(X.svgRound);e.push(`C${r} ${a} ${h} ${c} ${u} ${d}`)}}return e.join("")}serialize([e,s,i,n],r){const a=[],h=[],[c,u,d,f]=w(this,xe,Zy).call(this);let g,p,v,_,b,x,C,A,P;switch(l(this,Ch)){case 0:P=X._rescale,g=e,p=s+n,v=i,_=-n,b=e+c*i,x=s+(1-u-f)*n,C=e+(c+d)*i,A=s+(1-u)*n;break;case 90:P=X._rescaleAndSwap,g=e,p=s,v=i,_=n,b=e+u*i,x=s+c*n,C=e+(u+f)*i,A=s+(c+d)*n;break;case 180:P=X._rescale,g=e+i,p=s,v=-i,_=n,b=e+(1-c-d)*i,x=s+u*n,C=e+(1-c)*i,A=s+(u+f)*n;break;case 270:P=X._rescaleAndSwap,g=e+i,p=s+n,v=-i,_=-n,b=e+(1-u-f)*i,x=s+(1-c-d)*n,C=e+(1-u)*i,A=s+(1-c)*n;break}for(const{line:D,points:k}of l(this,Es))a.push(P(D,g,p,v,_,r?new Array(D.length):null)),h.push(P(k,g,p,v,_,r?new Array(k.length):null));return{lines:a,points:h,rect:[b,x,C,A]}}static deserialize(e,s,i,n,r,{paths:{lines:a,points:h},rotation:c,thickness:u}){const d=[];let f,g,p,v,_;switch(c){case 0:_=X._rescale,f=-e/i,g=s/n+1,p=1/i,v=-1/n;break;case 90:_=X._rescaleAndSwap,f=-s/n,g=-e/i,p=1/n,v=1/i;break;case 180:_=X._rescale,f=e/i+1,g=-s/n,p=-1/i,v=1/n;break;case 270:_=X._rescaleAndSwap,f=s/n+1,g=e/i+1,p=-1/n,v=-1/i;break}if(!a){a=[];for(const x of h){const C=x.length;if(C===2){a.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1]]));continue}if(C===4){a.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1],NaN,NaN,NaN,NaN,x[2],x[3]]));continue}const A=new Float32Array(3*(C-2));a.push(A);let[P,D,k,M]=x.subarray(0,4);A.set([NaN,NaN,NaN,NaN,P,D],0);for(let R=4;R<C;R+=2){const F=x[R],I=x[R+1];A.set(X.createBezierPoints(P,D,k,M,F,I),(R-2)*3),[P,D,k,M]=[k,M,F,I]}}}for(let x=0,C=a.length;x<C;x++)d.push({line:_(a[x].map(A=>A??NaN),f,g,p,v),points:_(h[x].map(A=>A??NaN),f,g,p,v)});const b=new gp;return b.build(d,i,n,1,c,u,r),b}get box(){return l(this,qe)}updateProperty(e,s){return e==="stroke-width"?w(this,xe,e_).call(this,s):null}updateParentDimensions([e,s],i){const[n,r]=w(this,xe,Nn).call(this);m(this,Bi,e),m(this,Hi,s),m(this,Sh,i);const[a,h]=w(this,xe,Nn).call(this),c=a-n,u=h-r,d=l(this,qe);return d[0]-=c,d[1]-=u,d[2]+=2*c,d[3]+=2*u,d}updateRotation(e){return m(this,Hc,e),{path:{transform:this.rotationTransform}}}get viewBox(){return l(this,qe).map(X.svgRound).join(" ")}get defaultProperties(){const[e,s]=l(this,qe);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=l(this,qe);let i=0,n=0,r=0,a=0,h=0,c=0;switch(l(this,Hc)){case 90:n=s/e,r=-e/s,h=e;break;case 180:i=-1,a=-1,h=e,c=s;break;case 270:n=-s/e,r=e/s,c=s;break;default:return""}return`matrix(${i} ${n} ${r} ${a} ${X.svgRound(h)} ${X.svgRound(c)})`}getPathResizingSVGProperties([e,s,i,n]){const[r,a]=w(this,xe,Nn).call(this),[h,c,u,d]=l(this,qe);if(Math.abs(u-r)<=X.PRECISION||Math.abs(d-a)<=X.PRECISION){const _=e+i/2-(h+u/2),b=s+n/2-(c+d/2);return{path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:`${this.rotationTransform} translate(${_} ${b})`}}}const f=(i-2*r)/(u-2*r),g=(n-2*a)/(d-2*a),p=u/i,v=d/n;return{path:{"transform-origin":`${X.svgRound(h)} ${X.svgRound(c)}`,transform:`${this.rotationTransform} scale(${p} ${v}) translate(${X.svgRound(r)} ${X.svgRound(a)}) scale(${f} ${g}) translate(${X.svgRound(-r)} ${X.svgRound(-a)})`}}}getPathResizedSVGProperties([e,s,i,n]){const[r,a]=w(this,xe,Nn).call(this),h=l(this,qe),[c,u,d,f]=h;if(h[0]=e,h[1]=s,h[2]=i,h[3]=n,Math.abs(d-r)<=X.PRECISION||Math.abs(f-a)<=X.PRECISION){const b=e+i/2-(c+d/2),x=s+n/2-(u+f/2);for(const{line:C,points:A}of l(this,Es))X._translate(C,b,x,C),X._translate(A,b,x,A);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(i-2*r)/(d-2*r),p=(n-2*a)/(f-2*a),v=-g*(c+r)+e+r,_=-p*(u+a)+s+a;if(g!==1||p!==1||v!==0||_!==0)for(const{line:b,points:x}of l(this,Es))X._rescale(b,v,_,g,p,b),X._rescale(x,v,_,g,p,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[n,r]=i,a=l(this,qe),h=e-a[0],c=s-a[1];if(l(this,Bi)===n&&l(this,Hi)===r)for(const{line:u,points:d}of l(this,Es))X._translate(u,h,c,u),X._translate(d,h,c,d);else{const u=l(this,Bi)/n,d=l(this,Hi)/r;m(this,Bi,n),m(this,Hi,r);for(const{line:f,points:g}of l(this,Es))X._rescale(f,h,c,u,d,f),X._rescale(g,h,c,u,d,g);a[2]*=u,a[3]*=d}return a[0]=e,a[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`}}}get defaultSVGProperties(){const e=l(this,qe);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e[0])} ${X.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}};qe=new WeakMap,Hc=new WeakMap,Gc=new WeakMap,Es=new WeakMap,Bi=new WeakMap,Hi=new WeakMap,Sh=new WeakMap,Ch=new WeakMap,Ah=new WeakMap,xe=new WeakSet,Nn=function(e=l(this,Ah)){const s=l(this,Gc)+e/2*l(this,Sh);return l(this,Ch)%180===0?[s/l(this,Bi),s/l(this,Hi)]:[s/l(this,Hi),s/l(this,Bi)]},Zy=function(){const[e,s,i,n]=l(this,qe),[r,a]=w(this,xe,Nn).call(this,0);return[e+r,s+a,i-2*r,n-2*a]},t_=function(){const e=m(this,qe,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:n}of l(this,Es)){if(n.length<=12){for(let h=4,c=n.length;h<c;h+=6){const[u,d]=n.subarray(h,h+2);e[0]=Math.min(e[0],u),e[1]=Math.min(e[1],d),e[2]=Math.max(e[2],u),e[3]=Math.max(e[3],d)}continue}let r=n[4],a=n[5];for(let h=6,c=n.length;h<c;h+=6){const[u,d,f,g,p,v]=n.subarray(h,h+6);q.bezierBoundingBox(r,a,u,d,f,g,p,v,e),r=p,a=v}}const[s,i]=w(this,xe,Nn).call(this);e[0]=Math.min(1,Math.max(0,e[0]-s)),e[1]=Math.min(1,Math.max(0,e[1]-i)),e[2]=Math.min(1,Math.max(0,e[2]+s)),e[3]=Math.min(1,Math.max(0,e[3]+i)),e[2]-=e[0],e[3]-=e[1]},e_=function(e){const[s,i]=w(this,xe,Nn).call(this);m(this,Ah,e);const[n,r]=w(this,xe,Nn).call(this),[a,h]=[n-s,r-i],c=l(this,qe);return c[0]-=a,c[1]-=h,c[2]+=2*a,c[3]+=2*h,c};let Td=gp;const pp=class pp extends QC{constructor(e){super();y(this,Th);m(this,Th,e),super.updateProperties({fill:"none",stroke:Ht._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,s){e==="stroke-width"&&(s??(s=this["stroke-width"]),s*=l(this,Th).realScale),super.updateSVGProperty(e,s)}clone(){const e=new pp(l(this,Th));return e.updateAll(this),e}};Th=new WeakMap;let rp=pp;const Eh=class Eh extends np{constructor(e){super({...e,name:"inkEditor"});y(this,zd);this._willKeepAspectRatio=!0}static initialize(e,s){Ht.initialize(e,s),this._defaultDrawingOptions=new rp(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return ht(this,"typesMap",new Map([[dt.INK_THICKNESS,"stroke-width"],[dt.INK_COLOR,"stroke"],[dt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,i,n,r){return new ZC(e,s,i,n,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,n,r,a){return Td.deserialize(e,s,i,n,r,a)}static async deserialize(e,s,i){let n=null;if(e instanceof tp){const{data:{inkLists:a,rect:h,rotation:c,id:u,color:d,opacity:f,borderStyle:{rawWidth:g},popupRef:p},parent:{page:{pageNumber:v}}}=e;n=e={annotationType:nt.INK,color:Array.from(d),thickness:g,opacity:f,paths:{points:a},boxes:null,pageIndex:v-1,rect:h.slice(0),rotation:c,id:u,deleted:!1,popupRef:p}}const r=await super.deserialize(e,s,i);return r.annotationElementId=e.id||null,r._initialData=n,r}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=Eh.getDefaultDrawingOptions({stroke:q.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i,rect:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":h}}=this,c={annotationType:nt.INK,color:Ht._colorManager.convert(r),opacity:a,thickness:h,paths:{lines:s,points:i},pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?c:this.annotationElementId&&!w(this,zd,s_).call(this,c)?null:(c.id=this.annotationElementId,c)}renderAnnotationElement(e){const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s}),null}};zd=new WeakSet,s_=function(e){const{color:s,thickness:i,opacity:n,pageIndex:r}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some((a,h)=>a!==s[h])||e.thickness!==i||e.opacity!==n||e.pageIndex!==r},J(Eh,"_type","ink"),J(Eh,"_editorType",nt.INK),J(Eh,"_defaultDrawingOptions",null);let ap=Eh;const Vc=class Vc extends Ht{constructor(e){super({...e,name:"stampEditor"});y(this,vt);y(this,Vt,null);y(this,Se,null);y(this,Cr,null);y(this,Rn,null);y(this,Ar,null);y(this,kh,"");y(this,Gi,null);y(this,Vi,null);y(this,ks,!1);y(this,Ph,!1);m(this,Rn,e.bitmapUrl),m(this,Ar,e.bitmapFile)}static initialize(e,s){Ht.initialize(e,s)}static get supportedTypes(){return ht(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return ht(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(nt.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:r,height:a}=e||this.copyCanvas(null,null,!0).imageData,h=await i.guess({name:"altText",request:{data:n,width:r,height:a,channels:n.length/(r*a)}});if(!h)throw new Error("No response from the AI service.");if(h.error)throw new Error("Error from the AI service.");if(h.cancel)return null;if(!h.output)throw new Error("No valid response from the AI service.");const c=h.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var e;l(this,Se)&&(m(this,Vt,null),this._uiManager.imageManager.deleteId(l(this,Se)),(e=l(this,Gi))==null||e.remove(),m(this,Gi,null),l(this,Vi)&&(clearTimeout(l(this,Vi)),m(this,Vi,null))),super.remove()}rebuild(){if(!this.parent){l(this,Se)&&w(this,vt,wf).call(this);return}super.rebuild(),this.div!==null&&(l(this,Se)&&l(this,Gi)===null&&w(this,vt,wf).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(l(this,Cr)||l(this,Vt)||l(this,Rn)||l(this,Ar)||l(this,Se))}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;if(this.width&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),l(this,Vt)?w(this,vt,lm).call(this):w(this,vt,wf).call(this),this.width&&!this.annotationElementId){const[i,n]=this.parentDimensions;this.setAt(e*i,s*n,this.width*i,this.height*n)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;l(this,Vi)!==null&&clearTimeout(l(this,Vi)),m(this,Vi,setTimeout(()=>{m(this,Vi,null),w(this,vt,cm).call(this)},200))}copyCanvas(e,s,i=!1){var g;e||(e=224);const{width:n,height:r}=l(this,Vt),a=new Ng;let h=l(this,Vt),c=n,u=r,d=null;if(s){if(n>s||r>s){const M=Math.min(s/n,s/r);c=Math.floor(n*M),u=Math.floor(r*M)}d=document.createElement("canvas");const p=d.width=Math.ceil(c*a.sx),v=d.height=Math.ceil(u*a.sy);l(this,ks)||(h=w(this,vt,xf).call(this,p,v));const _=d.getContext("2d");_.filter=this._uiManager.hcmFilter;let b="white",x="#cfcfd8";this._uiManager.hcmFilter!=="none"?x="black":(g=window.matchMedia)!=null&&g.call(window,"(prefers-color-scheme: dark)").matches&&(b="#8f8f9d",x="#42414d");const C=15,A=C*a.sx,P=C*a.sy,D=new OffscreenCanvas(A*2,P*2),k=D.getContext("2d");k.fillStyle=b,k.fillRect(0,0,A*2,P*2),k.fillStyle=x,k.fillRect(0,0,A,P),k.fillRect(A,P,A,P),_.fillStyle=_.createPattern(D,"repeat"),_.fillRect(0,0,p,v),_.drawImage(h,0,0,h.width,h.height,0,0,p,v)}let f=null;if(i){let p,v;if(a.symmetric&&h.width<e&&h.height<e)p=h.width,v=h.height;else if(h=l(this,Vt),n>e||r>e){const x=Math.min(e/n,e/r);p=Math.floor(n*x),v=Math.floor(r*x),l(this,ks)||(h=w(this,vt,xf).call(this,p,v))}const b=new OffscreenCanvas(p,v).getContext("2d",{willReadFrequently:!0});b.drawImage(h,0,0,h.width,h.height,0,0,p,v),f={width:p,height:v,data:b.getImageData(0,0,p,v).data}}return{canvas:d,width:c,height:u,imageData:f}}getImageForAltText(){return l(this,Gi)}static async deserialize(e,s,i){var v;let n=null;if(e instanceof mb){const{data:{rect:_,rotation:b,id:x,structParent:C,popupRef:A},container:P,parent:{page:{pageNumber:D}}}=e,k=P.querySelector("canvas"),M=i.imageManager.getFromCanvas(P.id,k);k.remove();const R=((v=await s._structTree.getAriaAttributes(`${Rg}${x}`))==null?void 0:v.get("aria-label"))||"";n=e={annotationType:nt.STAMP,bitmapId:M.id,bitmap:M.bitmap,pageIndex:D-1,rect:_.slice(0),rotation:b,id:x,deleted:!1,accessibilityData:{decorative:!1,altText:R},isSvg:!1,structParent:C,popupRef:A}}const r=await super.deserialize(e,s,i),{rect:a,bitmap:h,bitmapUrl:c,bitmapId:u,isSvg:d,accessibilityData:f}=e;u&&i.imageManager.isValidId(u)?(m(r,Se,u),h&&m(r,Vt,h)):m(r,Rn,c),m(r,ks,d);const[g,p]=r.pageDimensions;return r.width=(a[2]-a[0])/g,r.height=(a[3]-a[1])/p,r.annotationElementId=e.id||null,f&&(r.altTextData=f),r._initialData=n,m(r,Ph,!!n),r}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:nt.STAMP,bitmapId:l(this,Se),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:l(this,ks),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=w(this,vt,Sf).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:n,altText:r}=this.serializeAltText(!1);if(!n&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const h=w(this,vt,i_).call(this,i);if(h.isSame)return null;h.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const a=l(this,ks)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(l(this,Se)))s.stamps.set(l(this,Se),{area:a,serialized:i}),i.bitmap=w(this,vt,Sf).call(this,!1);else if(l(this,ks)){const h=s.stamps.get(l(this,Se));a>h.area&&(h.area=a,h.serialized.bitmap.close(),h.serialized.bitmap=w(this,vt,Sf).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};Vt=new WeakMap,Se=new WeakMap,Cr=new WeakMap,Rn=new WeakMap,Ar=new WeakMap,kh=new WeakMap,Gi=new WeakMap,Vi=new WeakMap,ks=new WeakMap,Ph=new WeakMap,vt=new WeakSet,iu=function(e,s=!1){if(!e){this.remove();return}m(this,Vt,e.bitmap),s||(m(this,Se,e.id),m(this,ks,e.isSvg)),e.file&&m(this,kh,e.file.name),w(this,vt,lm).call(this)},nu=function(){if(m(this,Cr,null),this._uiManager.enableWaiting(!1),!!l(this,Gi)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&l(this,Vt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&l(this,Vt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},wf=function(){if(l(this,Se)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(l(this,Se)).then(i=>w(this,vt,iu).call(this,i,!0)).finally(()=>w(this,vt,nu).call(this));return}if(l(this,Rn)){const i=l(this,Rn);m(this,Rn,null),this._uiManager.enableWaiting(!0),m(this,Cr,this._uiManager.imageManager.getFromUrl(i).then(n=>w(this,vt,iu).call(this,n)).finally(()=>w(this,vt,nu).call(this)));return}if(l(this,Ar)){const i=l(this,Ar);m(this,Ar,null),this._uiManager.enableWaiting(!0),m(this,Cr,this._uiManager.imageManager.getFromFile(i).then(n=>w(this,vt,iu).call(this,n)).finally(()=>w(this,vt,nu).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Vc.supportedTypesStr;const s=this._uiManager._signal;m(this,Cr,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),w(this,vt,iu).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>w(this,vt,nu).call(this))),e.click()},lm=function(){var d;const{div:e}=this;let{width:s,height:i}=l(this,Vt);const[n,r]=this.pageDimensions,a=.75;if(this.width)s=this.width*n,i=this.height*r;else if(s>a*n||i>a*r){const f=Math.min(a*n/s,a*r/i);s*=f,i*=f}const[h,c]=this.parentDimensions;this.setDims(s*h/n,i*c/r),this._uiManager.enableWaiting(!1);const u=m(this,Gi,document.createElement("canvas"));u.setAttribute("role","img"),this.addContainer(u),this.width=s/n,this.height=i/r,(d=this._initialOptions)!=null&&d.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),w(this,vt,cm).call(this),l(this,Ph)||(this.parent.addUndoableEditor(this),m(this,Ph,!0)),this._reportTelemetry({action:"inserted_image"}),l(this,kh)&&u.setAttribute("aria-label",l(this,kh))},xf=function(e,s){const{width:i,height:n}=l(this,Vt);let r=i,a=n,h=l(this,Vt);for(;r>2*e||a>2*s;){const c=r,u=a;r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),a>2*s&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const d=new OffscreenCanvas(r,a);d.getContext("2d").drawImage(h,0,0,c,u,0,0,r,a),h=d.transferToImageBitmap()}return h},cm=function(){const[e,s]=this.parentDimensions,{width:i,height:n}=this,r=new Ng,a=Math.ceil(i*e*r.sx),h=Math.ceil(n*s*r.sy),c=l(this,Gi);if(!c||c.width===a&&c.height===h)return;c.width=a,c.height=h;const u=l(this,ks)?l(this,Vt):w(this,vt,xf).call(this,a,h),d=c.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(u,0,0,u.width,u.height,0,0,a,h)},Sf=function(e){if(e){if(l(this,ks)){const n=this._uiManager.imageManager.getSvgUrl(l(this,Se));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=l(this,Vt),s.getContext("2d").drawImage(l(this,Vt),0,0),s.toDataURL()}if(l(this,ks)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*Kn.PDF_TO_CSS_UNITS),r=Math.round(this.height*i*Kn.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(n,r);return a.getContext("2d").drawImage(l(this,Vt),0,0,l(this,Vt).width,l(this,Vt).height,0,0,n,r),a.transferToImageBitmap()}return structuredClone(l(this,Vt))},i_=function(e){var a;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,n=e.pageIndex===s,r=(((a=e.accessibilityData)==null?void 0:a.alt)||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&n&&r,isSameAltText:r}},J(Vc,"_type","stamp"),J(Vc,"_editorType",nt.STAMP);let op=Vc;const vi=class vi{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:h,viewport:c,l10n:u}){y(this,Nt);y(this,Qa);y(this,Mh,!1);y(this,Wi,null);y(this,Tr,null);y(this,Ln,null);y(this,zs,new Map);y(this,Er,!1);y(this,Oh,!1);y(this,Za,!1);y(this,mi,null);y(this,Fn,null);y(this,Fe,null);y(this,In,null);y(this,$);const d=[...l(vi,kr).values()];if(!vi._initialized){vi._initialized=!0;for(const f of d)f.initialize(u,t)}t.registerEditorTypes(d),m(this,$,t),this.pageIndex=e,this.div=s,m(this,Qa,n),m(this,Wi,r),this.viewport=c,m(this,Fe,h),this.drawLayer=a,this._structTree=i,l(this,$).addLayer(this)}get isEmpty(){return l(this,zs).size===0}get isInvisible(){return this.isEmpty&&l(this,$).getMode()===nt.NONE}updateToolbar(t){l(this,$).updateToolbar(t)}updateMode(t=l(this,$).getMode()){switch(w(this,Nt,Cf).call(this),t){case nt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case nt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case nt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of l(vi,kr).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=l(this,Fe))==null?void 0:e.div)}setEditingState(t){l(this,$).setEditingState(t)}addCommands(t){l(this,$).addCommands(t)}cleanUndoStack(t){l(this,$).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=l(this,Wi))==null||e.div.classList.toggle("disabled",!t)}async enable(){m(this,Za,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of l(this,zs).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(l(this,$).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!l(this,Wi)){m(this,Za,!1);return}const e=l(this,Wi).getEditableAnnotations();for(const s of e){if(s.hide(),l(this,$).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}m(this,Za,!1)}disable(){var i;m(this,Oh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of l(this,zs).values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){t.set(n.annotationElementId,n);continue}else e.set(n.annotationElementId,n);(i=this.getEditableAnnotation(n.annotationElementId))==null||i.show(),n.remove()}if(l(this,Wi)){const n=l(this,Wi).getEditableAnnotations();for(const r of n){const{id:a}=r.data;if(l(this,$).isDeletedAnnotationElement(a))continue;let h=e.get(a);if(h){h.resetAnnotationElement(r),h.show(!1),r.show();continue}h=t.get(a),h&&(l(this,$).addChangedExistingAnnotation(h),h.renderAnnotationElement(r)&&h.show(!1)),r.show()}}w(this,Nt,Cf).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of l(vi,kr).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),m(this,Oh,!1)}getEditableAnnotation(t){var e;return((e=l(this,Wi))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){l(this,$).getActive()!==t&&l(this,$).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=l(this,Fe))!=null&&t.div&&!l(this,In)){m(this,In,new AbortController);const e=l(this,$).combinedSignal(l(this,In));l(this,Fe).div.addEventListener("pointerdown",w(this,Nt,n_).bind(this),{signal:e}),l(this,Fe).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=l(this,Fe))!=null&&t.div&&l(this,In)&&(l(this,In).abort(),m(this,In,null),l(this,Fe).div.classList.remove("highlighting"))}enableClick(){if(l(this,Tr))return;m(this,Tr,new AbortController);const t=l(this,$).combinedSignal(l(this,Tr));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=l(this,Tr))==null||t.abort(),m(this,Tr,null)}attach(t){l(this,zs).set(t.id,t);const{annotationElementId:e}=t;e&&l(this,$).isDeletedAnnotationElement(e)&&l(this,$).removeDeletedAnnotationElement(t)}detach(t){var e;l(this,zs).delete(t.id),(e=l(this,Qa))==null||e.removePointerInTextLayer(t.contentDiv),!l(this,Oh)&&t.annotationElementId&&l(this,$).addDeletedAnnotationElement(t)}remove(t){this.detach(t),l(this,$).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(l(this,$).addDeletedAnnotationElement(t.annotationElementId),Ht.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),l(this,$).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!l(this,Za)),l(this,$).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!l(this,Ln)&&(t._focusEventsAllowed=!1,m(this,Ln,setTimeout(()=>{m(this,Ln,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:l(this,$)._signal}),e.focus())},0))),t._structTreeParentId=(s=l(this,Qa))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return l(this,$).getId()}combinedSignal(t){return l(this,$).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=l(this,Nt,Ui))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){l(this,$).updateToolbar(t),l(this,$).updateMode(t);const{offsetX:s,offsetY:i}=w(this,Nt,dm).call(this),n=this.getNextId(),r=w(this,Nt,um).call(this,{parent:this,id:n,x:s,y:i,uiManager:l(this,$),isCentered:!0,...e});r&&this.add(r)}async deserialize(t){var e;return await((e=l(vi,kr).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,l(this,$)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=w(this,Nt,um).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:l(this,$),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(w(this,Nt,dm).call(this),!0)}setSelected(t){l(this,$).setSelected(t)}toggleSelected(t){l(this,$).toggleSelected(t)}unselect(t){l(this,$).unselect(t)}pointerup(t){var s;const{isMac:e}=ze.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&l(this,Er)&&(m(this,Er,!1),!((s=l(this,Nt,Ui))!=null&&s.isDrawer&&l(this,Nt,Ui).supportMultipleDrawings))){if(!l(this,Mh)){m(this,Mh,!0);return}if(l(this,$).getMode()===nt.STAMP){l(this,$).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){var i;if(l(this,$).getMode()===nt.HIGHLIGHT&&this.enableTextSelection(),l(this,Er)){m(this,Er,!1);return}const{isMac:e}=ze.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(m(this,Er,!0),(i=l(this,Nt,Ui))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=l(this,$).getActive();m(this,Mh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus(),l(this,mi)){l(this,Nt,Ui).startDrawing(this,l(this,$),!1,t);return}l(this,$).setCurrentDrawingSession(this),m(this,mi,new AbortController);const e=l(this,$).combinedSignal(l(this,mi));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(m(this,Fn,null),this.commitOrRemove())},{signal:e}),l(this,Nt,Ui).startDrawing(this,l(this,$),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&m(this,Fn,e);return}l(this,Fn)&&setTimeout(()=>{var e;(e=l(this,Fn))==null||e.focus(),m(this,Fn,null)},0)}endDrawingSession(t=!1){return l(this,mi)?(l(this,$).setCurrentDrawingSession(null),l(this,mi).abort(),m(this,mi,null),m(this,Fn,null),l(this,Nt,Ui).endDrawing(t)):null}findNewParent(t,e,s){const i=l(this,$).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return l(this,mi)?(this.endDrawingSession(),!0):!1}onScaleChanging(){l(this,mi)&&l(this,Nt,Ui).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=l(this,$).getActive())==null?void 0:t.parent)===this&&(l(this,$).commitOrRemove(),l(this,$).setActiveEditor(null)),l(this,Ln)&&(clearTimeout(l(this,Ln)),m(this,Ln,null));for(const s of l(this,zs).values())(e=l(this,Qa))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,l(this,zs).clear(),l(this,$).removeLayer(this)}render({viewport:t}){this.viewport=t,zr(this.div,t);for(const e of l(this,$).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){l(this,$).commitOrRemove(),w(this,Nt,Cf).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,zr(this.div,{rotation:s}),e!==s)for(const i of l(this,zs).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return l(this,$).viewParameters.realScale}};Qa=new WeakMap,Mh=new WeakMap,Wi=new WeakMap,Tr=new WeakMap,Ln=new WeakMap,zs=new WeakMap,Er=new WeakMap,Oh=new WeakMap,Za=new WeakMap,mi=new WeakMap,Fn=new WeakMap,Fe=new WeakMap,In=new WeakMap,$=new WeakMap,kr=new WeakMap,Nt=new WeakSet,n_=function(t){l(this,$).unselectAll();const{target:e}=t;if(e===l(this,Fe).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&l(this,Fe).div.contains(e)){const{isMac:s}=ze.platform;if(t.button!==0||t.ctrlKey&&s)return;l(this,$).showAllEditors("highlight",!0,!0),l(this,Fe).div.classList.add("free"),this.toggleDrawing(),Ad.startHighlighting(this,l(this,$).direction==="ltr",{target:l(this,Fe).div,x:t.x,y:t.y}),l(this,Fe).div.addEventListener("pointerup",()=>{l(this,Fe).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:l(this,$)._signal}),t.preventDefault()}},Ui=function(){return l(vi,kr).get(l(this,$).getMode())},um=function(t){const e=l(this,Nt,Ui);return e?new e.prototype.constructor(t):null},dm=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),h=Math.min(window.innerHeight,e+i),c=(n+a)/2-t,u=(r+h)/2-e,[d,f]=this.viewport.rotation%180===0?[c,u]:[u,c];return{offsetX:d,offsetY:f}},Cf=function(){for(const t of l(this,zs).values())t.isEmpty()&&t.remove()},J(vi,"_initialized",!1),y(vi,kr,new Map([ep,ap,op,Ad].map(t=>[t._editorType,t])));let hp=vi;const Ie=class Ie{constructor({pageIndex:t}){y(this,zi);y(this,bi,null);y(this,Wc,0);y(this,Ke,new Map);y(this,to,new Map);this.pageIndex=t}setParent(t){if(!l(this,bi)){m(this,bi,t);return}if(l(this,bi)!==t){if(l(this,Ke).size>0)for(const e of l(this,Ke).values())e.remove(),t.append(e);m(this,bi,t)}}static get _svgFactory(){return ht(this,"_svgFactory",new Qg)}draw(t,e=!1,s=!1){const i=Ze(this,Wc)._++,n=w(this,zi,fm).call(this),r=Ie._svgFactory.createElement("defs");n.append(r);const a=Ie._svgFactory.createElement("path");r.append(a);const h=`path_p${this.pageIndex}_${i}`;a.setAttribute("id",h),a.setAttribute("vector-effect","non-scaling-stroke"),e&&l(this,to).set(i,a);const c=s?w(this,zi,a_).call(this,r,h):null,u=Ie._svgFactory.createElement("use");return n.append(u),u.setAttribute("href",`#${h}`),this.updateProperties(n,t),l(this,Ke).set(i,n),{id:i,clipPathId:`url(#${c})`}}drawOutline(t,e){const s=Ze(this,Wc)._++,i=w(this,zi,fm).call(this),n=Ie._svgFactory.createElement("defs");i.append(n);const r=Ie._svgFactory.createElement("path");n.append(r);const a=`path_p${this.pageIndex}_${s}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let h;if(e){const d=Ie._svgFactory.createElement("mask");n.append(d),h=`mask_p${this.pageIndex}_${s}`,d.setAttribute("id",h),d.setAttribute("maskUnits","objectBoundingBox");const f=Ie._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const g=Ie._svgFactory.createElement("use");d.append(g),g.setAttribute("href",`#${a}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const c=Ie._svgFactory.createElement("use");i.append(c),c.setAttribute("href",`#${a}`),h&&c.setAttribute("mask",`url(#${h})`);const u=c.cloneNode();return i.append(u),c.classList.add("mainOutline"),u.classList.add("secondaryOutline"),this.updateProperties(i,t),l(this,Ke).set(s,i),s}finalizeDraw(t,e){l(this,to).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var h;if(!e)return;const{root:s,bbox:i,rootClass:n,path:r}=e,a=typeof t=="number"?l(this,Ke).get(t):t;if(a){if(s&&w(this,zi,gm).call(this,a,s),i&&w(h=Ie,Xd,r_).call(h,a,i),n){const{classList:c}=a;for(const[u,d]of Object.entries(n))c.toggle(u,d)}if(r){const u=a.firstChild.firstChild;w(this,zi,gm).call(this,u,r)}}}updateParent(t,e){if(e===this)return;const s=l(this,Ke).get(t);s&&(l(e,bi).append(s),l(this,Ke).delete(t),l(e,Ke).set(t,s))}remove(t){l(this,to).delete(t),l(this,bi)!==null&&(l(this,Ke).get(t).remove(),l(this,Ke).delete(t))}destroy(){m(this,bi,null);for(const t of l(this,Ke).values())t.remove();l(this,Ke).clear(),l(this,to).clear()}};bi=new WeakMap,Wc=new WeakMap,Ke=new WeakMap,to=new WeakMap,Xd=new WeakSet,r_=function(t,[e,s,i,n]){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`},zi=new WeakSet,fm=function(){const t=Ie._svgFactory.create(1,1,!0);return l(this,bi).append(t),t.setAttribute("aria-hidden",!0),t},a_=function(t,e){const s=Ie._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=Ie._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},gm=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},y(Ie,Xd);let lp=Ie;globalThis.pdfjsTestingUtils={HighlightOutliner:sp},Z.AbortException,Z.AnnotationEditorLayer,Z.AnnotationEditorParamsType,Z.AnnotationEditorType,Z.AnnotationEditorUIManager,Z.AnnotationLayer,Z.AnnotationMode,Z.ColorPicker,Z.DOMSVGFactory,Z.DrawLayer,Z.FeatureTest;var tA=Z.GlobalWorkerOptions;Z.ImageKind,Z.InvalidPDFException,Z.MissingPDFException,Z.OPS,Z.OutputScale,Z.PDFDataRangeTransport,Z.PDFDateString,Z.PDFWorker,Z.PasswordResponses,Z.PermissionFlag,Z.PixelsPerInch,Z.RenderingCancelledException,Z.TextLayer,Z.TouchManager,Z.UnexpectedResponseException,Z.Util,Z.VerbosityLevel,Z.XfaLayer,Z.build,Z.createValidAbsoluteUrl,Z.fetchData;var eA=Z.getDocument;Z.getFilenameFromUrl,Z.getPdfFilenameFromUrl,Z.getXfaPageViewport,Z.isDataScheme,Z.isPdfFile,Z.noContextMenu,Z.normalizeUnicode,Z.setLayerDimensions,Z.shadow,Z.stopEvent,Z.version;const sA={"pdfjs-dist":"4.10.38"};function iA(o){return new Promise((t,e)=>{const s=new FileReader;s.addEventListener("load",()=>t(s.result)),s.addEventListener("error",e),s.readAsDataURL(o)})}const nA=sA["pdfjs-dist"].replace("^","");tA.workerSrc=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${nA}/pdf.worker.min.mjs`;async function rA(o){const t="data:application/pdf;base64,",e=await iA(o);if(typeof e=="string")return window.atob(e.slice(t.length))}function aA(o,t){return eA({data:o,password:t}).promise}const oA={top:100,left:50,scaleX:.5,scaleY:.5,borderColor:"black",cornerStrokeColor:"black",cornerSize:8,selectionBackgroundColor:"rgba(245, 245, 245, 0.8)"},hA={top:100,left:50,fontFamily:"helvetica",borderColor:"black",cornerStrokeColor:"black",scaleX:.7,scaleY:.7,cornerSize:8,selectionBackgroundColor:"rgba(245, 245, 245, 0.8)"},lA={stroke:"#000",hoverStroke:"#B7EC5D",src:""};function bb(o=""){const t=Q.useRef(0),e=Q.useRef(null),s=Q.useRef(null),i=Q.useRef(1),n=Q.useRef({...lA});function r(){if(!o||Rs.has(o))return;const k=zx(o);return k.on("selection:cleared",()=>A(k)),k}function a(k,M){var I;const R=k.type,F={"application/pdf":h,"image/png":d,"image/jpeg":d};return((I=F[R])==null?void 0:I.call(F,k,M))??Promise.reject(new Error(`Unsupported ${R} file type.`))}async function h(k,M){const R=await rA(k);if(!R)return;const F=Xx(k,R);try{return await c({page:1,PDFBase64:R,scale:.8,password:M}),{...F,pages:t.current}}catch(I){return Promise.reject(I)}}async function c({page:k,PDFBase64:M,scale:R,password:F}){try{const I=await aA(M,F),Y=await I.getPage(k),{renderTask:N,canvas:H}=Ux(Y,R);return t.current=I.numPages,N.promise.then(()=>u(H))}catch(I){return Promise.reject(I)}}function u(k){$x(o,k)}async function d(k){return await qx(o,k)}async function f({url:k,scale:M=.5}){await Cv(o,{url:k,scale:M})}async function g(k,M){const R=Rs.get(o);if(!R)return;const F=await ke.fromURL(k,{},{...oA,...M});R.add(F),v(R,F)}function p(k,M){const R=Rs.get(o);if(!R)return;const F=new Ee(k,{...hA,...M});R.add(F),v(R,F)}function v(k,M){M.on("selected",R=>_({canvas:k,target:R.target})),M.on("modified",R=>nl(R.target,e.current)),M.on("scaling",R=>nl(R.transform.target,e.current)),M.on("moving",R=>nl(R.transform.target,e.current)),M.on("rotating",R=>nl(R.transform.target,e.current))}async function _({canvas:k,target:M,stroke:R=n.current.stroke,uuid:F=Date.now()}){var Y;if(((Y=e.current)==null?void 0:Y.stroke)===`${R}-${F}`)return;const I=await Yx(n.current.src,R,F);A(k),e.current=I,s.current=M,b(k,M,F),x(i.current,!0),k.add(I)}function b(k,M,R){e.current&&(e.current.on("selected",()=>{k.remove(M),A(k)}),e.current.on("mouseover",()=>{_({canvas:k,target:M,stroke:n.current.hoverStroke,uuid:R})}),e.current.on("mouseout",()=>{_({canvas:k,target:M,stroke:n.current.stroke,uuid:R})}))}function x(k,M=!1){const R=Rs.get(o);i.current=k,R&&(Jx(s.current,k,n.current),Kx(s.current,k,e.current),!M&&R.renderAll())}function C(k){if(!k)return;n.current={...n.current,...k};const M=Rs.get(o);!e||!s.current||!M||_({target:s.current,canvas:M})}function A(k){e.current&&(k.remove(e.current),e.current=s.current=null)}function P(){Qx(o)}function D(){Zx(o)}return{createCanvas:r,loadFile:a,specifyPage:c,renderImage:f,addFabric:g,addTextFabric:p,clearActive:P,deleteCanvas:D,scaleFabric:x,setCloseSvgOptions:C}}function cA(o){let t=0;const e=Wx(()=>{t!==window.innerWidth&&(t=window.innerWidth,o())});Q.useEffect(()=>(window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)),[])}const uA=Q.forwardRef(dA);function dA({file:o,page:t=1,canvasId:e="PDF-canvas",fileZoom:s=1,fileScale:i=1,canvasScale:n=1,canvasClass:r="",isDrop:a=!1,password:h,dropTextOptions:c,dropImageOptions:u,closeSvgOptions:d},f){const g=Q.useRef(null),p=`${e}-${t-1}`,v=Q.useMemo(()=>s*n,[s,n]),{createCanvas:_,specifyPage:b,addFabric:x,addTextFabric:C,renderImage:A,clearActive:P,deleteCanvas:D,scaleFabric:k,setCloseSvgOptions:M}=bb(p);cA(R);async function R(){window.requestAnimationFrame(async()=>{if(_(),o.PDFBase64.startsWith("data:image")||o.canvas){const{canvas:N}=o,H=N?7:3,at=N!=null&&N.length?N[t-1]:o.PDFBase64;A({url:at,scale:i/H});return}await b({page:t,PDFBase64:o.PDFBase64,scale:i,password:h})})}function F(N){if(N.preventDefault(),N.stopPropagation(),!a||!N.dataTransfer)return;const{dataTransfer:H,clientX:at,clientY:j}=N,W=H.getData("text/plain"),it=H.getData("text/uri-list"),kt={left:at-71,top:j-55};it?I(it,kt):W&&Y(W,kt)}function I(N,H){x(N,{...H,...u})}function Y(N,H){C(N,{...H,...c})}return Q.useImperativeHandle(f,()=>({addImage:I,addText:Y,clearActive:P,deleteCanvas:D,canvasRef:g})),Q.useEffect(()=>{R()},[i,t,o,h]),Q.useEffect(()=>{k(v)},[v]),Q.useEffect(()=>{M(d)},[d]),Q.useEffect(()=>()=>D(),[]),vm.jsx("div",{style:{transform:`scale(${v})`},onDragOver:N=>N.preventDefault(),onDragEnter:N=>N.preventDefault(),onDrop:F,children:vm.jsx("canvas",{id:p,ref:g,className:r})})}ut.default=uA,ut.useFabric=bb,Object.defineProperties(ut,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
538
|
+
`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},My=function(){return l(this,ws).replaceAll(" "," ")},Zp=function(e){return e.replaceAll(" "," ")},Oy=function(e){const{value:s,fontSize:i,color:n,pageIndex:r}=this._initialData;return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((a,h)=>a!==n[h])||e.pageIndex!==r},y(Ot,kn),J(Ot,"_freeTextDefaultContent",""),J(Ot,"_internalPadding",0),J(Ot,"_defaultColor",null),J(Ot,"_defaultFontSize",10),J(Ot,"_type","freetext"),J(Ot,"_editorType",nt.FREETEXT);let ep=Ot;class X{toSVGPath(){Et("Abstract method `toSVGPath` must be implemented.")}get box(){Et("Abstract getter `box` must be implemented.")}serialize(t,e){Et("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,n,r){r||(r=new Float32Array(t.length));for(let a=0,h=t.length;a<h;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}static _rescaleAndSwap(t,e,s,i,n,r){r||(r=new Float32Array(t.length));for(let a=0,h=t.length;a<h;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let n=0,r=t.length;n<r;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,n){switch(n){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){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,s,i,n,r){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+r)/6,(s+n)/2,(i+r)/2]}}J(X,"PRECISION",1e-4);const Pn=class Pn{constructor({x:t,y:e},s,i,n,r,a=0){y(this,ce);y(this,Ss);y(this,di,[]);y(this,oh);y(this,hh);y(this,ji,[]);y(this,lt,new Float32Array(18));y(this,Na);y(this,Ba);y(this,Cc);y(this,Ac);y(this,lh);y(this,ch);y(this,br,[]);m(this,Ss,s),m(this,ch,n*i),m(this,hh,r),l(this,lt).set([NaN,NaN,NaN,NaN,t,e],6),m(this,oh,a),m(this,Ac,l(Pn,Tc)*i),m(this,Cc,l(Pn,Vd)*i),m(this,lh,i),l(this,br).push(t,e)}isEmpty(){return isNaN(l(this,lt)[8])}add({x:t,y:e}){var R;m(this,Na,t),m(this,Ba,e);const[s,i,n,r]=l(this,Ss);let[a,h,c,u]=l(this,lt).subarray(8,12);const d=t-c,f=e-u,g=Math.hypot(d,f);if(g<l(this,Cc))return!1;const p=g-l(this,Ac),v=p/g,_=v*d,b=v*f;let x=a,C=h;a=c,h=u,c+=_,u+=b,(R=l(this,br))==null||R.push(t,e);const A=-b/p,P=_/p,D=A*l(this,ch),k=P*l(this,ch);return l(this,lt).set(l(this,lt).subarray(2,8),0),l(this,lt).set([c+D,u+k],4),l(this,lt).set(l(this,lt).subarray(14,18),12),l(this,lt).set([c-D,u-k],16),isNaN(l(this,lt)[6])?(l(this,ji).length===0&&(l(this,lt).set([a+D,h+k],2),l(this,ji).push(NaN,NaN,NaN,NaN,(a+D-s)/n,(h+k-i)/r),l(this,lt).set([a-D,h-k],14),l(this,di).push(NaN,NaN,NaN,NaN,(a-D-s)/n,(h-k-i)/r)),l(this,lt).set([x,C,a,h,c,u],6),!this.isEmpty()):(l(this,lt).set([x,C,a,h,c,u],6),Math.abs(Math.atan2(C-h,x-a)-Math.atan2(b,_))<Math.PI/2?([a,h,c,u]=l(this,lt).subarray(2,6),l(this,ji).push(NaN,NaN,NaN,NaN,((a+c)/2-s)/n,((h+u)/2-i)/r),[a,h,x,C]=l(this,lt).subarray(14,18),l(this,di).push(NaN,NaN,NaN,NaN,((x+a)/2-s)/n,((C+h)/2-i)/r),!0):([x,C,a,h,c,u]=l(this,lt).subarray(0,6),l(this,ji).push(((x+5*a)/6-s)/n,((C+5*h)/6-i)/r,((5*a+c)/6-s)/n,((5*h+u)/6-i)/r,((a+c)/2-s)/n,((h+u)/2-i)/r),[c,u,a,h,x,C]=l(this,lt).subarray(12,18),l(this,di).push(((x+5*a)/6-s)/n,((C+5*h)/6-i)/r,((5*a+c)/6-s)/n,((5*h+u)/6-i)/r,((a+c)/2-s)/n,((h+u)/2-i)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=l(this,ji),e=l(this,di);if(isNaN(l(this,lt)[6])&&!this.isEmpty())return w(this,ce,Dy).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);w(this,ce,Ly).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return w(this,ce,Ry).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,r){return new gb(t,e,s,i,n,r)}getOutlines(){var d;const t=l(this,ji),e=l(this,di),s=l(this,lt),[i,n,r,a]=l(this,Ss),h=new Float32Array((((d=l(this,br))==null?void 0:d.length)??0)+2);for(let f=0,g=h.length-2;f<g;f+=2)h[f]=(l(this,br)[f]-i)/r,h[f+1]=(l(this,br)[f+1]-n)/a;if(h[h.length-2]=(l(this,Na)-i)/r,h[h.length-1]=(l(this,Ba)-n)/a,isNaN(s[6])&&!this.isEmpty())return w(this,ce,Fy).call(this,h);const c=new Float32Array(l(this,ji).length+24+l(this,di).length);let u=t.length;for(let f=0;f<u;f+=2){if(isNaN(t[f])){c[f]=c[f+1]=NaN;continue}c[f]=t[f],c[f+1]=t[f+1]}u=w(this,ce,jy).call(this,c,u);for(let f=e.length-6;f>=6;f-=6)for(let g=0;g<6;g+=2){if(isNaN(e[f+g])){c[u]=c[u+1]=NaN,u+=2;continue}c[u]=e[f+g],c[u+1]=e[f+g+1],u+=2}return w(this,ce,Iy).call(this,c,u),this.newFreeDrawOutline(c,h,l(this,Ss),l(this,lh),l(this,oh),l(this,hh))}};Ss=new WeakMap,di=new WeakMap,oh=new WeakMap,hh=new WeakMap,ji=new WeakMap,lt=new WeakMap,Na=new WeakMap,Ba=new WeakMap,Cc=new WeakMap,Ac=new WeakMap,lh=new WeakMap,ch=new WeakMap,br=new WeakMap,Tc=new WeakMap,Gd=new WeakMap,Vd=new WeakMap,ce=new WeakSet,Zc=function(){const t=l(this,lt).subarray(4,6),e=l(this,lt).subarray(16,18),[s,i,n,r]=l(this,Ss);return[(l(this,Na)+(t[0]-e[0])/2-s)/n,(l(this,Ba)+(t[1]-e[1])/2-i)/r,(l(this,Na)+(e[0]-t[0])/2-s)/n,(l(this,Ba)+(e[1]-t[1])/2-i)/r]},Dy=function(){const[t,e,s,i]=l(this,Ss),[n,r,a,h]=w(this,ce,Zc).call(this);return`M${(l(this,lt)[2]-t)/s} ${(l(this,lt)[3]-e)/i} L${(l(this,lt)[4]-t)/s} ${(l(this,lt)[5]-e)/i} L${n} ${r} L${a} ${h} L${(l(this,lt)[16]-t)/s} ${(l(this,lt)[17]-e)/i} L${(l(this,lt)[14]-t)/s} ${(l(this,lt)[15]-e)/i} Z`},Ry=function(t){const e=l(this,di);t.push(`L${e[4]} ${e[5]} Z`)},Ly=function(t){const[e,s,i,n]=l(this,Ss),r=l(this,lt).subarray(4,6),a=l(this,lt).subarray(16,18),[h,c,u,d]=w(this,ce,Zc).call(this);t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${h} ${c} L${u} ${d} L${(a[0]-e)/i} ${(a[1]-s)/n}`)},Fy=function(t){const e=l(this,lt),[s,i,n,r]=l(this,Ss),[a,h,c,u]=w(this,ce,Zc).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,a,h,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(d,t,l(this,Ss),l(this,lh),l(this,oh),l(this,hh))},Iy=function(t,e){const s=l(this,di);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},jy=function(t,e){const s=l(this,lt).subarray(4,6),i=l(this,lt).subarray(16,18),[n,r,a,h]=l(this,Ss),[c,u,d,f]=w(this,ce,Zc).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/h,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,d,f,NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/h],e),e+=24},y(Pn,Tc,8),y(Pn,Gd,2),y(Pn,Vd,l(Pn,Tc)+l(Pn,Gd));let Sd=Pn;class gb extends X{constructor(e,s,i,n,r,a){super();y(this,Wd);y(this,uh);y(this,Ha,new Float32Array(4));y(this,Mn);y(this,Ec);y(this,Cs);y(this,kc);y(this,Jt);m(this,Jt,e),m(this,Cs,s),m(this,uh,i),m(this,kc,n),m(this,Mn,r),m(this,Ec,a),this.lastPoint=[NaN,NaN],w(this,Wd,Ny).call(this,a);const[h,c,u,d]=l(this,Ha);for(let f=0,g=e.length;f<g;f+=2)e[f]=(e[f]-h)/u,e[f+1]=(e[f+1]-c)/d;for(let f=0,g=s.length;f<g;f+=2)s[f]=(s[f]-h)/u,s[f+1]=(s[f+1]-c)/d}toSVGPath(){const e=[`M${l(this,Jt)[4]} ${l(this,Jt)[5]}`];for(let s=6,i=l(this,Jt).length;s<i;s+=6){if(isNaN(l(this,Jt)[s])){e.push(`L${l(this,Jt)[s+4]} ${l(this,Jt)[s+5]}`);continue}e.push(`C${l(this,Jt)[s]} ${l(this,Jt)[s+1]} ${l(this,Jt)[s+2]} ${l(this,Jt)[s+3]} ${l(this,Jt)[s+4]} ${l(this,Jt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,n],r){const a=i-e,h=n-s;let c,u;switch(r){case 0:c=X._rescale(l(this,Jt),e,n,a,-h),u=X._rescale(l(this,Cs),e,n,a,-h);break;case 90:c=X._rescaleAndSwap(l(this,Jt),e,s,a,h),u=X._rescaleAndSwap(l(this,Cs),e,s,a,h);break;case 180:c=X._rescale(l(this,Jt),i,s,-a,h),u=X._rescale(l(this,Cs),i,s,-a,h);break;case 270:c=X._rescaleAndSwap(l(this,Jt),i,n,-a,-h),u=X._rescaleAndSwap(l(this,Cs),i,n,-a,-h);break}return{outline:Array.from(c),points:[Array.from(u)]}}get box(){return l(this,Ha)}newOutliner(e,s,i,n,r,a=0){return new Sd(e,s,i,n,r,a)}getNewOutline(e,s){const[i,n,r,a]=l(this,Ha),[h,c,u,d]=l(this,uh),f=r*u,g=a*d,p=i*u+h,v=n*d+c,_=this.newOutliner({x:l(this,Cs)[0]*f+p,y:l(this,Cs)[1]*g+v},l(this,uh),l(this,kc),e,l(this,Ec),s??l(this,Mn));for(let b=2;b<l(this,Cs).length;b+=2)_.add({x:l(this,Cs)[b]*f+p,y:l(this,Cs)[b+1]*g+v});return _.getOutlines()}}uh=new WeakMap,Ha=new WeakMap,Mn=new WeakMap,Ec=new WeakMap,Cs=new WeakMap,kc=new WeakMap,Jt=new WeakMap,Wd=new WeakSet,Ny=function(e){const s=l(this,Jt);let i=s[4],n=s[5],r=i,a=n,h=i,c=n,u=i,d=n;const f=e?Math.max:Math.min;for(let p=6,v=s.length;p<v;p+=6){if(isNaN(s[p]))r=Math.min(r,s[p+4]),a=Math.min(a,s[p+5]),h=Math.max(h,s[p+4]),c=Math.max(c,s[p+5]),d<s[p+5]?(u=s[p+4],d=s[p+5]):d===s[p+5]&&(u=f(u,s[p+4]));else{const _=q.bezierBoundingBox(i,n,...s.slice(p,p+6));r=Math.min(r,_[0]),a=Math.min(a,_[1]),h=Math.max(h,_[2]),c=Math.max(c,_[3]),d<_[3]?(u=_[2],d=_[3]):d===_[3]&&(u=f(u,_[2]))}i=s[p+4],n=s[p+5]}const g=l(this,Ha);g[0]=r-l(this,Mn),g[1]=a-l(this,Mn),g[2]=h-r+2*l(this,Mn),g[3]=c-a+2*l(this,Mn),this.lastPoint=[u,d]};class sp{constructor(t,e=0,s=0,i=!0){y(this,Ye);y(this,Pc);y(this,Mc);y(this,yr,[]);y(this,fi,[]);let n=1/0,r=-1/0,a=1/0,h=-1/0;const c=10**-4;for(const{x:_,y:b,width:x,height:C}of t){const A=Math.floor((_-e)/c)*c,P=Math.ceil((_+x+e)/c)*c,D=Math.floor((b-e)/c)*c,k=Math.ceil((b+C+e)/c)*c,M=[A,D,k,!0],R=[P,D,k,!1];l(this,yr).push(M,R),n=Math.min(n,A),r=Math.max(r,P),a=Math.min(a,D),h=Math.max(h,k)}const u=r-n+2*s,d=h-a+2*s,f=n-s,g=a-s,p=l(this,yr).at(i?-1:-2),v=[p[0],p[2]];for(const _ of l(this,yr)){const[b,x,C]=_;_[0]=(b-f)/u,_[1]=(x-g)/d,_[2]=(C-g)/d}m(this,Pc,new Float32Array([f,g,u,d])),m(this,Mc,v)}getOutlines(){l(this,yr).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of l(this,yr))e[3]?(t.push(...w(this,Ye,tm).call(this,e)),w(this,Ye,Hy).call(this,e)):(w(this,Ye,Gy).call(this,e),t.push(...w(this,Ye,tm).call(this,e)));return w(this,Ye,By).call(this,t)}}Pc=new WeakMap,Mc=new WeakMap,yr=new WeakMap,fi=new WeakMap,Ye=new WeakSet,By=function(t){const e=[],s=new Set;for(const r of t){const[a,h,c]=r;e.push([a,h,r],[a,c,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const h=e[r][2],c=e[r+1][2];h.push(c),c.push(h),s.add(h),s.add(c)}const i=[];let n;for(;s.size>0;){const r=s.values().next().value;let[a,h,c,u,d]=r;s.delete(r);let f=a,g=h;for(n=[a,c],i.push(n);;){let p;if(s.has(u))p=u;else if(s.has(d))p=d;else break;s.delete(p),[a,h,c,u,d]=p,f!==a&&(n.push(f,g,a,g===h?h:c),f=a),g=g===h?c:h}n.push(f,g)}return new DC(i,l(this,Pc),l(this,Mc))},mf=function(t){const e=l(this,fi);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,r=e[n][0];if(r===t)return n;r<t?s=n+1:i=n-1}return i+1},Hy=function([,t,e]){const s=w(this,Ye,mf).call(this,t);l(this,fi).splice(s,0,[t,e])},Gy=function([,t,e]){const s=w(this,Ye,mf).call(this,t);for(let i=s;i<l(this,fi).length;i++){const[n,r]=l(this,fi)[i];if(n!==t)break;if(n===t&&r===e){l(this,fi).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,r]=l(this,fi)[i];if(n!==t)break;if(n===t&&r===e){l(this,fi).splice(i,1);return}}},tm=function(t){const[e,s,i]=t,n=[[e,s,i]],r=w(this,Ye,mf).call(this,i);for(let a=0;a<r;a++){const[h,c]=l(this,fi)[a];for(let u=0,d=n.length;u<d;u++){const[,f,g]=n[u];if(!(c<=f||g<=h)){if(f>=h){if(g>c)n[u][1]=c;else{if(d===1)return[];n.splice(u,1),u--,d--}continue}n[u][2]=h,g>c&&n.push([e,c,g])}}}return n};class DC extends X{constructor(e,s,i){super();y(this,Oc);y(this,dh);m(this,dh,e),m(this,Oc,s),this.lastPoint=i}toSVGPath(){const e=[];for(const s of l(this,dh)){let[i,n]=s;e.push(`M${i} ${n}`);for(let r=2;r<s.length;r+=2){const a=s[r],h=s[r+1];a===i?(e.push(`V${h}`),n=h):h===n&&(e.push(`H${a}`),i=a)}e.push("Z")}return e.join(" ")}serialize([e,s,i,n],r){const a=[],h=i-e,c=n-s;for(const u of l(this,dh)){const d=new Array(u.length);for(let f=0;f<u.length;f+=2)d[f]=e+u[f]*h,d[f+1]=n-u[f+1]*c;a.push(d)}return a}get box(){return l(this,Oc)}get classNamesForOutlining(){return["highlightOutline"]}}Oc=new WeakMap,dh=new WeakMap;class ip extends Sd{newFreeDrawOutline(t,e,s,i,n,r){return new RC(t,e,s,i,n,r)}}class RC extends gb{newOutliner(t,e,s,i,n,r=0){return new ip(t,e,s,i,n,r)}}const hs=class hs{constructor({editor:t=null,uiManager:e=null}){y(this,At);y(this,gi,null);y(this,Ga,null);y(this,fh);y(this,ue,null);y(this,Dc,!1);y(this,gh,!1);y(this,Rc,null);y(this,Lc);y(this,_r,null);y(this,pi,null);y(this,ph);var s;t?(m(this,gh,!1),m(this,ph,dt.HIGHLIGHT_COLOR),m(this,Rc,t)):(m(this,gh,!0),m(this,ph,dt.HIGHLIGHT_DEFAULT_COLOR)),m(this,pi,(t==null?void 0:t._uiManager)||e),m(this,Lc,l(this,pi)._eventBus),m(this,fh,(t==null?void 0:t.color)||((s=l(this,pi))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),l(hs,Fc)||m(hs,Fc,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return ht(this,"_keyboardManager",new ll([[["Escape","mac+Escape"],hs.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],hs.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],hs.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],hs.prototype._moveToPrevious],[["Home","mac+Home"],hs.prototype._moveToBeginning],[["End","mac+End"],hs.prototype._moveToEnd]]))}renderButton(){const t=m(this,gi,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=l(this,pi)._signal;t.addEventListener("click",w(this,At,io).bind(this),{signal:e}),t.addEventListener("keydown",w(this,At,im).bind(this),{signal:e});const s=m(this,Ga,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=l(this,fh),t.append(s),t}renderMainDropdown(){const t=m(this,ue,w(this,At,em).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===l(this,gi)){w(this,At,io).call(this,t);return}const e=t.target.getAttribute("data-color");e&&w(this,At,sm).call(this,e,t)}_moveToNext(t){var e,s;if(!l(this,At,Pr)){w(this,At,io).call(this,t);return}if(t.target===l(this,gi)){(e=l(this,ue).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=l(this,ue))==null?void 0:e.firstChild)||t.target===l(this,gi)){l(this,At,Pr)&&this._hideDropdownFromKeyboard();return}l(this,At,Pr)||w(this,At,io).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!l(this,At,Pr)){w(this,At,io).call(this,t);return}(e=l(this,ue).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!l(this,At,Pr)){w(this,At,io).call(this,t);return}(e=l(this,ue).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=l(this,ue))==null||t.classList.add("hidden"),(e=l(this,_r))==null||e.abort(),m(this,_r,null)}_hideDropdownFromKeyboard(){var t;if(!l(this,gh)){if(!l(this,At,Pr)){(t=l(this,Rc))==null||t.unselect();return}this.hideDropdown(),l(this,gi).focus({preventScroll:!0,focusVisible:l(this,Dc)})}}updateColor(t){if(l(this,Ga)&&(l(this,Ga).style.backgroundColor=t),!l(this,ue))return;const e=l(this,pi).highlightColors.values();for(const s of l(this,ue).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){var t,e;(t=l(this,gi))==null||t.remove(),m(this,gi,null),m(this,Ga,null),(e=l(this,ue))==null||e.remove(),m(this,ue,null)}};gi=new WeakMap,Ga=new WeakMap,fh=new WeakMap,ue=new WeakMap,Dc=new WeakMap,gh=new WeakMap,Rc=new WeakMap,Lc=new WeakMap,_r=new WeakMap,pi=new WeakMap,ph=new WeakMap,Fc=new WeakMap,At=new WeakSet,em=function(){const t=document.createElement("div"),e=l(this,pi)._signal;t.addEventListener("contextmenu",ii,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,i]of l(this,pi).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",l(hs,Fc)[s]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.setAttribute("aria-selected",i===l(this,fh)),n.addEventListener("click",w(this,At,sm).bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",w(this,At,im).bind(this),{signal:e}),t},sm=function(t,e){e.stopPropagation(),l(this,Lc).dispatch("switchannotationeditorparams",{source:this,type:l(this,ph),value:t})},im=function(t){hs._keyboardManager.exec(this,t)},io=function(t){if(l(this,At,Pr)){this.hideDropdown();return}if(m(this,Dc,t.detail===0),l(this,_r)||(m(this,_r,new AbortController),window.addEventListener("pointerdown",w(this,At,Vy).bind(this),{signal:l(this,pi).combinedSignal(l(this,_r))})),l(this,ue)){l(this,ue).classList.remove("hidden");return}const e=m(this,ue,w(this,At,em).call(this));l(this,gi).append(e)},Vy=function(t){var e;(e=l(this,ue))!=null&&e.contains(t.target)||this.hideDropdown()},Pr=function(){return l(this,ue)&&!l(this,ue).classList.contains("hidden")},y(hs,Fc,null);let Cd=hs;const bt=class bt extends Ht{constructor(e){super({...e,name:"highlightEditor"});y(this,st);y(this,mh,null);y(this,Ic,0);y(this,On);y(this,Va,null);y(this,vh,null);y(this,ls,null);y(this,jc,null);y(this,Nc,0);y(this,Wa,null);y(this,Hs,null);y(this,As,null);y(this,_e,!1);y(this,bh,null);y(this,Dn);y(this,Le,null);y(this,yh,"");y(this,Gs);y(this,Bc,"");this.color=e.color||bt._defaultColor,m(this,Gs,e.thickness||bt._defaultThickness),m(this,Dn,e.opacity||bt._defaultOpacity),m(this,On,e.boxes||null),m(this,Bc,e.methodOfCreation||""),m(this,yh,e.text||""),this._isDraggable=!1,e.highlightId>-1?(m(this,_e,!0),w(this,st,vf).call(this,e),w(this,st,no).call(this)):l(this,On)&&(m(this,mh,e.anchorNode),m(this,Ic,e.anchorOffset),m(this,jc,e.focusNode),m(this,Nc,e.focusOffset),w(this,st,nm).call(this),w(this,st,no).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=bt.prototype;return ht(this,"_keyboardManager",new ll([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:l(this,_e)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:l(this,Gs),methodOfCreation:l(this,Bc)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;Ht.initialize(e,s),bt._defaultColor||(bt._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case dt.HIGHLIGHT_DEFAULT_COLOR:bt._defaultColor=s;break;case dt.HIGHLIGHT_THICKNESS:bt._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return l(this,bh)}updateParams(e,s){switch(e){case dt.HIGHLIGHT_COLOR:w(this,st,Wy).call(this,s);break;case dt.HIGHLIGHT_THICKNESS:w(this,st,zy).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[dt.HIGHLIGHT_DEFAULT_COLOR,bt._defaultColor],[dt.HIGHLIGHT_THICKNESS,bt._defaultThickness]]}get propertiesToUpdate(){return[[dt.HIGHLIGHT_COLOR,this.color||bt._defaultColor],[dt.HIGHLIGHT_THICKNESS,l(this,Gs)||bt._defaultThickness],[dt.HIGHLIGHT_FREE,l(this,_e)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(m(this,vh,new Cd({editor:this})),e.addColorPicker(l(this,vh))),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(w(this,st,tu).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,w(this,st,tu).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){w(this,st,rm).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(w(this,st,no).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?w(this,st,rm).call(this):e&&(w(this,st,no).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var n,r,a;const{drawLayer:s}=this.parent;let i;l(this,_e)?(e=(e-this.rotation+360)%360,i=w(n=bt,Vs,Nh).call(n,l(this,Hs).box,e)):i=w(r=bt,Vs,Nh).call(r,[this.x,this.y,this.width,this.height],e),s.updateProperties(l(this,As),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(l(this,Le),{bbox:w(a=bt,Vs,Nh).call(a,l(this,ls).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();l(this,yh)&&(e.setAttribute("aria-label",l(this,yh)),e.setAttribute("role","mark")),l(this,_e)?e.classList.add("free"):this.div.addEventListener("keydown",w(this,st,Uy).bind(this),{signal:this._uiManager._signal});const s=m(this,Wa,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=l(this,Va);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),gd(this,l(this,Wa),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(l(this,Le),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(l(this,Le),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:w(this,st,bf).call(this,!0);break;case 1:case 3:w(this,st,bf).call(this,!1);break}}select(){var e;super.select(),l(this,Le)&&((e=this.parent)==null||e.drawLayer.updateProperties(l(this,Le),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),l(this,Le)&&((e=this.parent)==null||e.drawLayer.updateProperties(l(this,Le),{rootClass:{selected:!1}}),l(this,_e)||w(this,st,bf).call(this,!1))}get _mustFixPosition(){return!l(this,_e)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(l(this,As),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(l(this,Le),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:n,y:r}){const{x:a,y:h,width:c,height:u}=i.getBoundingClientRect(),d=new AbortController,f=e.combinedSignal(d),g=p=>{d.abort(),w(this,Vs,Ky).call(this,e,p)};window.addEventListener("blur",g,{signal:f}),window.addEventListener("pointerup",g,{signal:f}),window.addEventListener("pointerdown",gs,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",ii,{signal:f}),i.addEventListener("pointermove",w(this,Vs,qy).bind(this,e),{signal:f}),this._freeHighlight=new ip({x:n,y:r},[a,h,c,u],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,s,i){var v,_,b,x;let n=null;if(e instanceof db){const{data:{quadPoints:C,rect:A,rotation:P,id:D,color:k,opacity:M,popupRef:R},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:nt.HIGHLIGHT,color:Array.from(k),opacity:M,quadPoints:C,boxes:null,pageIndex:F-1,rect:A.slice(0),rotation:P,id:D,deleted:!1,popupRef:R}}else if(e instanceof tp){const{data:{inkLists:C,rect:A,rotation:P,id:D,color:k,borderStyle:{rawWidth:M},popupRef:R},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:nt.HIGHLIGHT,color:Array.from(k),thickness:M,inkLists:C,boxes:null,pageIndex:F-1,rect:A.slice(0),rotation:P,id:D,deleted:!1,popupRef:R}}const{color:r,quadPoints:a,inkLists:h,opacity:c}=e,u=await super.deserialize(e,s,i);u.color=q.makeHexColor(...r),m(u,Dn,c||1),h&&m(u,Gs,e.thickness),u.annotationElementId=e.id||null,u._initialData=n;const[d,f]=u.pageDimensions,[g,p]=u.pageTranslation;if(a){const C=m(u,On,[]);for(let A=0;A<a.length;A+=8)C.push({x:(a[A]-g)/d,y:1-(a[A+1]-p)/f,width:(a[A+2]-a[A])/d,height:(a[A+1]-a[A+5])/f});w(v=u,st,nm).call(v),w(_=u,st,no).call(_),u.rotate(u.rotation)}else if(h){m(u,_e,!0);const C=h[0],A={x:C[0]-g,y:f-(C[1]-p)},P=new ip(A,[0,0,d,f],1,l(u,Gs)/2,!0,.001);for(let M=0,R=C.length;M<R;M+=2)A.x=C[M]-g,A.y=f-(C[M+1]-p),P.add(A);const{id:D,clipPathId:k}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:P.toSVGPath()}},!0,!0);w(b=u,st,vf).call(b,{highlightOutlines:P.getOutlines(),highlightId:D,clipPathId:k}),w(x=u,st,no).call(x)}return u}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=this.getRect(0,0),i=Ht._colorManager.convert(this.color),n={annotationType:nt.HIGHLIGHT,color:i,opacity:l(this,Dn),thickness:l(this,Gs),quadPoints:w(this,st,Yy).call(this),outlines:w(this,st,$y).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:w(this,st,tu).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!w(this,st,Jy).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};mh=new WeakMap,Ic=new WeakMap,On=new WeakMap,Va=new WeakMap,vh=new WeakMap,ls=new WeakMap,jc=new WeakMap,Nc=new WeakMap,Wa=new WeakMap,Hs=new WeakMap,As=new WeakMap,_e=new WeakMap,bh=new WeakMap,Dn=new WeakMap,Le=new WeakMap,yh=new WeakMap,Gs=new WeakMap,Bc=new WeakMap,st=new WeakSet,nm=function(){const e=new sp(l(this,On),.001);m(this,Hs,e.getOutlines()),[this.x,this.y,this.width,this.height]=l(this,Hs).box;const s=new sp(l(this,On),.0025,.001,this._uiManager.direction==="ltr");m(this,ls,s.getOutlines());const{lastPoint:i}=l(this,ls);m(this,bh,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},vf=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var d,f;if(m(this,Hs,e),m(this,ls,e.getNewOutline(l(this,Gs)/2+1.5,.0025)),s>=0)m(this,As,s),m(this,Va,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),m(this,Le,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:l(this,ls).box,path:{d:l(this,ls).toSVGPath()}},!0));else if(this.parent){const g=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(l(this,As),{bbox:w(d=bt,Vs,Nh).call(d,l(this,Hs).box,(g-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(l(this,Le),{bbox:w(f=bt,Vs,Nh).call(f,l(this,ls).box,g),path:{d:l(this,ls).toSVGPath()}})}const[r,a,h,c]=e.box;switch(this.rotation){case 0:this.x=r,this.y=a,this.width=h,this.height=c;break;case 90:{const[g,p]=this.parentDimensions;this.x=a,this.y=1-r,this.width=h*p/g,this.height=c*g/p;break}case 180:this.x=1-r,this.y=1-a,this.width=h,this.height=c;break;case 270:{const[g,p]=this.parentDimensions;this.x=1-a,this.y=r,this.width=h*p/g,this.height=c*g/p;break}}const{lastPoint:u}=l(this,ls);m(this,bh,[(u[0]-r)/h,(u[1]-a)/c])},Wy=function(e){const s=(r,a)=>{var h,c;this.color=r,m(this,Dn,a),(h=this.parent)==null||h.drawLayer.updateProperties(l(this,As),{root:{fill:r,"fill-opacity":a}}),(c=l(this,vh))==null||c.updateColor(r)},i=this.color,n=l(this,Dn);this.addCommands({cmd:s.bind(this,e,bt._defaultOpacity),undo:s.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},zy=function(e){const s=l(this,Gs),i=n=>{m(this,Gs,n),w(this,st,Xy).call(this,n)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Xy=function(e){if(!l(this,_e))return;w(this,st,vf).call(this,{highlightOutlines:l(this,Hs).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},rm=function(){l(this,As)===null||!this.parent||(this.parent.drawLayer.remove(l(this,As)),m(this,As,null),this.parent.drawLayer.remove(l(this,Le)),m(this,Le,null))},no=function(e=this.parent){l(this,As)===null&&({id:Ze(this,As)._,clipPathId:Ze(this,Va)._}=e.drawLayer.draw({bbox:l(this,Hs).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":l(this,Dn)},rootClass:{highlight:!0,free:l(this,_e)},path:{d:l(this,Hs).toSVGPath()}},!1,!0),m(this,Le,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:l(this,_e)},bbox:l(this,ls).box,path:{d:l(this,ls).toSVGPath()}},l(this,_e))),l(this,Wa)&&(l(this,Wa).style.clipPath=l(this,Va)))},Vs=new WeakSet,Nh=function([e,s,i,n],r){switch(r){case 90:return[1-s-n,e,n,i];case 180:return[1-e-i,1-s-n,i,n];case 270:return[s,1-e-i,n,i]}return[e,s,i,n]},Uy=function(e){bt._keyboardManager.exec(this,e)},bf=function(e){if(!l(this,mh))return;const s=window.getSelection();e?s.setPosition(l(this,mh),l(this,Ic)):s.setPosition(l(this,jc),l(this,Nc))},tu=function(){return l(this,_e)?this.rotation:0},Yy=function(){if(l(this,_e))return null;const[e,s]=this.pageDimensions,[i,n]=this.pageTranslation,r=l(this,On),a=new Float32Array(r.length*8);let h=0;for(const{x:c,y:u,width:d,height:f}of r){const g=c*e+i,p=(1-u)*s+n;a[h]=a[h+4]=g,a[h+1]=a[h+3]=p,a[h+2]=a[h+6]=g+d*e,a[h+5]=a[h+7]=p-f*s,h+=8}return a},$y=function(e){return l(this,Hs).serialize(e,w(this,st,tu).call(this))},qy=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Ky=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Jy=function(e){const{color:s}=this._initialData;return e.color.some((i,n)=>i!==s[n])},y(bt,Vs),J(bt,"_defaultColor",null),J(bt,"_defaultOpacity",1),J(bt,"_defaultThickness",12),J(bt,"_type","highlight"),J(bt,"_editorType",nt.HIGHLIGHT),J(bt,"_freeHighlightId",-1),J(bt,"_freeHighlight",null),J(bt,"_freeHighlightClipId","");let Ad=bt;class LC{constructor(){y(this,za,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))this.updateProperty(e,s)}updateSVGProperty(t,e){l(this,za)[t]=e}toSVGProperties(){const t=l(this,za);return m(this,za,Object.create(null)),{root:t}}reset(){m(this,za,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Et("Not implemented")}}za=new WeakMap;const U=class U extends Ht{constructor(e){super(e);y(this,mt);y(this,Ts,null);y(this,_h);J(this,"_drawId",null);m(this,_h,e.mustBeCommitted||!1),e.drawOutlines&&(w(this,mt,am).call(this,e),w(this,mt,eu).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[n,r]of Object.entries(s))i.has(n)?Object.assign(e[n],r):e[n]=r;return e}static getDefaultDrawingOptions(e){Et("Not implemented")}static get typesMap(){Et("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(l(U,pe).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,n]of this.typesMap)e.push([i,s[n]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,n]of this.constructor.typesMap)e.push([i,s[n]]);return e}_updateProperty(e,s,i){const n=this._drawingOptions,r=n[s],a=h=>{var u;n.updateProperty(s,h);const c=l(this,Ts).updateProperty(s,h);c&&w(this,mt,su).call(this,c),(u=this.parent)==null||u.drawLayer.updateProperties(this._drawId,n.toSVGProperties())};this.addCommands({cmd:a.bind(this,i),undo:a.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,U._mergeSVGProperties(l(this,Ts).getPathResizingSVGProperties(w(this,mt,yf).call(this)),{bbox:w(this,mt,Bh).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,U._mergeSVGProperties(l(this,Ts).getPathResizedSVGProperties(w(this,mt,yf).call(this)),{bbox:w(this,mt,Bh).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:w(this,mt,Bh).call(this,e,s)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,U._mergeSVGProperties(l(this,Ts).getPathTranslatedSVGProperties(w(this,mt,yf).call(this),this.parentDimensions),{bbox:w(this,mt,Bh).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,l(this,_h)&&(m(this,_h,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){w(this,mt,hm).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(w(this,mt,eu).call(this),w(this,mt,su).call(this,l(this,Ts).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),w(this,mt,hm).call(this)):e&&(this._uiManager.addShouldRescale(this),w(this,mt,eu).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,U._mergeSVGProperties({bbox:w(this,mt,Bh).call(this)},l(this,Ts).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&w(this,mt,su).call(this,l(this,Ts).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const e=super.render();e.classList.add("draw");const s=document.createElement("div");e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,s,i,n,r){Et("Not implemented")}static startDrawing(e,s,i,n){var _;const{target:r,offsetX:a,offsetY:h,pointerId:c,pointerType:u}=n;if(l(U,xr)&&l(U,xr)!==u)return;const{viewport:{rotation:d}}=e,{width:f,height:g}=r.getBoundingClientRect(),p=m(U,Xa,new AbortController),v=e.combinedSignal(p);if(l(U,wr)||m(U,wr,c),l(U,xr)??m(U,xr,u),window.addEventListener("pointerup",b=>{var x;l(U,wr)===b.pointerId?this._endDraw(b):(x=l(U,Sr))==null||x.delete(b.pointerId)},{signal:v}),window.addEventListener("pointercancel",b=>{var x;l(U,wr)===b.pointerId?this._currentParent.endDrawingSession():(x=l(U,Sr))==null||x.delete(b.pointerId)},{signal:v}),window.addEventListener("pointerdown",b=>{l(U,xr)===b.pointerType&&((l(U,Sr)||m(U,Sr,new Set)).add(b.pointerId),l(U,pe).isCancellable()&&(l(U,pe).removeLastElement(),l(U,pe).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:v}),window.addEventListener("contextmenu",ii,{signal:v}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:v}),r.addEventListener("touchmove",b=>{b.timeStamp===l(U,Ya)&&gs(b)},{signal:v}),e.toggleDrawing(),(_=s._editorUndoBar)==null||_.hide(),l(U,pe)){e.drawLayer.updateProperties(this._currentDrawId,l(U,pe).startNew(a,h,f,g,d));return}s.updateUIForDefaultProperties(this),m(U,pe,this.createDrawerInstance(a,h,f,g,d)),m(U,Ua,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(l(U,Ua).toSVGProperties(),l(U,pe).defaultSVGProperties),!0,!1)}static _drawMove(e){var r;if(m(U,Ya,-1),!l(U,pe))return;const{offsetX:s,offsetY:i,pointerId:n}=e;if(l(U,wr)===n){if(((r=l(U,Sr))==null?void 0:r.size)>=1){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,l(U,pe).add(s,i)),m(U,Ya,e.timeStamp),gs(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,m(U,pe,null),m(U,Ua,null),m(U,xr,null),m(U,Ya,NaN)),l(U,Xa)&&(l(U,Xa).abort(),m(U,Xa,null),m(U,wr,NaN),m(U,Sr,null))}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),e&&s.drawLayer.updateProperties(this._currentDrawId,l(U,pe).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=l(U,pe),n=this._currentDrawId,r=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(n,i.setLastElement(r))},undo:()=>{s.drawLayer.updateProperties(n,i.removeLastElement())},mustExec:!1,type:dt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(dt.DRAW_STEP),!l(U,pe).isEmpty()){const{pageDimensions:[i,n],scale:r}=s,a=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:l(U,pe).getOutlines(i*r,n*r,r,this._INNER_MARGIN),drawingOptions:l(U,Ua),mustBeCommitted:!e});return this._cleanup(!0),a}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,n,r,a){Et("Not implemented")}static async deserialize(e,s,i){var d,f;const{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:h}}=s.viewport,c=this.deserializeDraw(a,h,n,r,this._INNER_MARGIN,e),u=await super.deserialize(e,s,i);return u.createDrawingOptions(e),w(d=u,mt,am).call(d,{drawOutlines:c}),w(f=u,mt,eu).call(f),u.onScaleChanging(),u.rotate(),u}serializeDraw(e){const[s,i]=this.pageTranslation,[n,r]=this.pageDimensions;return l(this,Ts).serialize([s,i,n,r],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};Ts=new WeakMap,_h=new WeakMap,pe=new WeakMap,Xa=new WeakMap,Ua=new WeakMap,wr=new WeakMap,xr=new WeakMap,Sr=new WeakMap,Ya=new WeakMap,mt=new WeakSet,am=function({drawOutlines:e,drawId:s,drawingOptions:i}){m(this,Ts,e),this._drawingOptions||(this._drawingOptions=i),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=w(this,mt,om).call(this,e,this.parent),w(this,mt,su).call(this,e.box)},om=function(e,s){const{id:i}=s.drawLayer.draw(U._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},hm=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},eu=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=w(this,mt,om).call(this,l(this,Ts),e)}},Qy=function([e,s,i,n]){const{parentDimensions:[r,a],rotation:h}=this;switch(h){case 90:return[s,1-e,i*(a/r),n*(r/a)];case 180:return[1-e,1-s,i,n];case 270:return[1-s,e,i*(a/r),n*(r/a)];default:return[e,s,i,n]}},yf=function(){const{x:e,y:s,width:i,height:n,parentDimensions:[r,a],rotation:h}=this;switch(h){case 90:return[1-s,e,i*(r/a),n*(a/r)];case 180:return[1-e,1-s,i,n];case 270:return[s,1-e,i*(r/a),n*(a/r)];default:return[e,s,i,n]}},su=function(e){if([this.x,this.y,this.width,this.height]=w(this,mt,Qy).call(this,e),this.div){this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)}this._onResized()},Bh=function(){const{x:e,y:s,width:i,height:n,rotation:r,parentRotation:a,parentDimensions:[h,c]}=this;switch((r*4+a)/90){case 1:return[1-s-n,e,n,i];case 2:return[1-e-i,1-s-n,i,n];case 3:return[s,1-e-i,n,i];case 4:return[e,s-i*(h/c),n*(c/h),i*(h/c)];case 5:return[1-s,e,i*(h/c),n*(c/h)];case 6:return[1-e-n*(c/h),1-s,n*(c/h),i*(h/c)];case 7:return[s-i*(h/c),1-e-n*(c/h),i*(h/c),n*(c/h)];case 8:return[e-i,s-n,i,n];case 9:return[1-s,e-i,n,i];case 10:return[1-e,1-s,i,n];case 11:return[s-n,1-e,n,i];case 12:return[e-n*(c/h),s,n*(c/h),i*(h/c)];case 13:return[1-s-i*(h/c),e-n*(c/h),i*(h/c),n*(c/h)];case 14:return[1-e,1-s-i*(h/c),n*(c/h),i*(h/c)];case 15:return[s,1-e,i*(h/c),n*(c/h)];default:return[e,s,i,n]}},J(U,"_currentDrawId",-1),J(U,"_currentParent",null),y(U,pe,null),y(U,Xa,null),y(U,Ua,null),y(U,wr,NaN),y(U,xr,null),y(U,Sr,null),y(U,Ya,NaN),J(U,"_INNER_MARGIN",3);let np=U;class FC{constructor(t,e,s,i,n,r){y(this,xh);y(this,Ni,new Float64Array(6));y(this,me);y(this,ve);y(this,$a);y(this,wh);y(this,$e);y(this,we,"");y(this,Ws,0);y(this,qa,new Td);y(this,Ka);y(this,Ja);m(this,Ka,s),m(this,Ja,i),m(this,$a,n),m(this,wh,r),[t,e]=w(this,xh,_f).call(this,t,e);const a=m(this,me,[NaN,NaN,NaN,NaN,t,e]);m(this,$e,[t,e]),m(this,ve,[{line:a,points:l(this,$e)}]),l(this,Ni).set(a,0)}updateProperty(t,e){t==="stroke-width"&&m(this,wh,e)}isEmpty(){return!l(this,ve)||l(this,ve).length===0}isCancellable(){return l(this,$e).length<=10}add(t,e){[t,e]=w(this,xh,_f).call(this,t,e);const[s,i,n,r]=l(this,Ni).subarray(2,6),a=t-n,h=e-r;return Math.hypot(l(this,Ka)*a,l(this,Ja)*h)<=2?null:(l(this,$e).push(t,e),isNaN(s)?(l(this,Ni).set([n,r,t,e],2),l(this,me).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(l(this,Ni)[0])&&l(this,me).splice(6,6),l(this,Ni).set([s,i,n,r,t,e],0),l(this,me).push(...X.createBezierPoints(s,i,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(l(this,$e).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,n){m(this,Ka,s),m(this,Ja,i),m(this,$a,n),[t,e]=w(this,xh,_f).call(this,t,e);const r=m(this,me,[NaN,NaN,NaN,NaN,t,e]);m(this,$e,[t,e]);const a=l(this,ve).at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),l(this,ve).push({line:r,points:l(this,$e)}),l(this,Ni).set(r,0),m(this,Ws,0),this.toSVGPath(),null}getLastElement(){return l(this,ve).at(-1)}setLastElement(t){return l(this,ve)?(l(this,ve).push(t),m(this,me,t.line),m(this,$e,t.points),m(this,Ws,0),{path:{d:this.toSVGPath()}}):l(this,qa).setLastElement(t)}removeLastElement(){if(!l(this,ve))return l(this,qa).removeLastElement();l(this,ve).pop(),m(this,we,"");for(let t=0,e=l(this,ve).length;t<e;t++){const{line:s,points:i}=l(this,ve)[t];m(this,me,s),m(this,$e,i),m(this,Ws,0),this.toSVGPath()}return{path:{d:l(this,we)}}}toSVGPath(){const t=X.svgRound(l(this,me)[4]),e=X.svgRound(l(this,me)[5]);if(l(this,$e).length===2)return m(this,we,`${l(this,we)} M ${t} ${e} Z`),l(this,we);if(l(this,$e).length<=6){const i=l(this,we).lastIndexOf("M");m(this,we,`${l(this,we).slice(0,i)} M ${t} ${e}`),m(this,Ws,6)}if(l(this,$e).length===4){const i=X.svgRound(l(this,me)[10]),n=X.svgRound(l(this,me)[11]);return m(this,we,`${l(this,we)} L ${i} ${n}`),m(this,Ws,12),l(this,we)}const s=[];l(this,Ws)===0&&(s.push(`M ${t} ${e}`),m(this,Ws,6));for(let i=l(this,Ws),n=l(this,me).length;i<n;i+=6){const[r,a,h,c,u,d]=l(this,me).slice(i,i+6).map(X.svgRound);s.push(`C${r} ${a} ${h} ${c} ${u} ${d}`)}return m(this,we,l(this,we)+s.join(" ")),m(this,Ws,l(this,me).length),l(this,we)}getOutlines(t,e,s,i){const n=l(this,ve).at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),l(this,qa).build(l(this,ve),t,e,s,l(this,$a),l(this,wh),i),m(this,Ni,null),m(this,me,null),m(this,ve,null),m(this,we,null),l(this,qa)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Ni=new WeakMap,me=new WeakMap,ve=new WeakMap,$a=new WeakMap,wh=new WeakMap,$e=new WeakMap,we=new WeakMap,Ws=new WeakMap,qa=new WeakMap,Ka=new WeakMap,Ja=new WeakMap,xh=new WeakSet,_f=function(t,e){return X._normalizePoint(t,e,l(this,Ka),l(this,Ja),l(this,$a))};const gp=class gp extends X{constructor(){super(...arguments);y(this,xe);y(this,qe);y(this,Hc,0);y(this,Gc);y(this,Es);y(this,Bi);y(this,Hi);y(this,Sh);y(this,Ch);y(this,Ah)}build(e,s,i,n,r,a,h){m(this,Bi,s),m(this,Hi,i),m(this,Sh,n),m(this,Ch,r),m(this,Ah,a),m(this,Gc,h??0),m(this,Es,e),w(this,xe,t_).call(this)}setLastElement(e){return l(this,Es).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return l(this,Es).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of l(this,Es)){if(e.push(`M${X.svgRound(s[4])} ${X.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12){e.push(`L${X.svgRound(s[10])} ${X.svgRound(s[11])}`);continue}for(let i=6,n=s.length;i<n;i+=6){const[r,a,h,c,u,d]=s.subarray(i,i+6).map(X.svgRound);e.push(`C${r} ${a} ${h} ${c} ${u} ${d}`)}}return e.join("")}serialize([e,s,i,n],r){const a=[],h=[],[c,u,d,f]=w(this,xe,Zy).call(this);let g,p,v,_,b,x,C,A,P;switch(l(this,Ch)){case 0:P=X._rescale,g=e,p=s+n,v=i,_=-n,b=e+c*i,x=s+(1-u-f)*n,C=e+(c+d)*i,A=s+(1-u)*n;break;case 90:P=X._rescaleAndSwap,g=e,p=s,v=i,_=n,b=e+u*i,x=s+c*n,C=e+(u+f)*i,A=s+(c+d)*n;break;case 180:P=X._rescale,g=e+i,p=s,v=-i,_=n,b=e+(1-c-d)*i,x=s+u*n,C=e+(1-c)*i,A=s+(u+f)*n;break;case 270:P=X._rescaleAndSwap,g=e+i,p=s+n,v=-i,_=-n,b=e+(1-u-f)*i,x=s+(1-c-d)*n,C=e+(1-u)*i,A=s+(1-c)*n;break}for(const{line:D,points:k}of l(this,Es))a.push(P(D,g,p,v,_,r?new Array(D.length):null)),h.push(P(k,g,p,v,_,r?new Array(k.length):null));return{lines:a,points:h,rect:[b,x,C,A]}}static deserialize(e,s,i,n,r,{paths:{lines:a,points:h},rotation:c,thickness:u}){const d=[];let f,g,p,v,_;switch(c){case 0:_=X._rescale,f=-e/i,g=s/n+1,p=1/i,v=-1/n;break;case 90:_=X._rescaleAndSwap,f=-s/n,g=-e/i,p=1/n,v=1/i;break;case 180:_=X._rescale,f=e/i+1,g=-s/n,p=-1/i,v=1/n;break;case 270:_=X._rescaleAndSwap,f=s/n+1,g=e/i+1,p=-1/n,v=-1/i;break}if(!a){a=[];for(const x of h){const C=x.length;if(C===2){a.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1]]));continue}if(C===4){a.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1],NaN,NaN,NaN,NaN,x[2],x[3]]));continue}const A=new Float32Array(3*(C-2));a.push(A);let[P,D,k,M]=x.subarray(0,4);A.set([NaN,NaN,NaN,NaN,P,D],0);for(let R=4;R<C;R+=2){const F=x[R],I=x[R+1];A.set(X.createBezierPoints(P,D,k,M,F,I),(R-2)*3),[P,D,k,M]=[k,M,F,I]}}}for(let x=0,C=a.length;x<C;x++)d.push({line:_(a[x].map(A=>A??NaN),f,g,p,v),points:_(h[x].map(A=>A??NaN),f,g,p,v)});const b=new gp;return b.build(d,i,n,1,c,u,r),b}get box(){return l(this,qe)}updateProperty(e,s){return e==="stroke-width"?w(this,xe,e_).call(this,s):null}updateParentDimensions([e,s],i){const[n,r]=w(this,xe,Nn).call(this);m(this,Bi,e),m(this,Hi,s),m(this,Sh,i);const[a,h]=w(this,xe,Nn).call(this),c=a-n,u=h-r,d=l(this,qe);return d[0]-=c,d[1]-=u,d[2]+=2*c,d[3]+=2*u,d}updateRotation(e){return m(this,Hc,e),{path:{transform:this.rotationTransform}}}get viewBox(){return l(this,qe).map(X.svgRound).join(" ")}get defaultProperties(){const[e,s]=l(this,qe);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=l(this,qe);let i=0,n=0,r=0,a=0,h=0,c=0;switch(l(this,Hc)){case 90:n=s/e,r=-e/s,h=e;break;case 180:i=-1,a=-1,h=e,c=s;break;case 270:n=-s/e,r=e/s,c=s;break;default:return""}return`matrix(${i} ${n} ${r} ${a} ${X.svgRound(h)} ${X.svgRound(c)})`}getPathResizingSVGProperties([e,s,i,n]){const[r,a]=w(this,xe,Nn).call(this),[h,c,u,d]=l(this,qe);if(Math.abs(u-r)<=X.PRECISION||Math.abs(d-a)<=X.PRECISION){const _=e+i/2-(h+u/2),b=s+n/2-(c+d/2);return{path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:`${this.rotationTransform} translate(${_} ${b})`}}}const f=(i-2*r)/(u-2*r),g=(n-2*a)/(d-2*a),p=u/i,v=d/n;return{path:{"transform-origin":`${X.svgRound(h)} ${X.svgRound(c)}`,transform:`${this.rotationTransform} scale(${p} ${v}) translate(${X.svgRound(r)} ${X.svgRound(a)}) scale(${f} ${g}) translate(${X.svgRound(-r)} ${X.svgRound(-a)})`}}}getPathResizedSVGProperties([e,s,i,n]){const[r,a]=w(this,xe,Nn).call(this),h=l(this,qe),[c,u,d,f]=h;if(h[0]=e,h[1]=s,h[2]=i,h[3]=n,Math.abs(d-r)<=X.PRECISION||Math.abs(f-a)<=X.PRECISION){const b=e+i/2-(c+d/2),x=s+n/2-(u+f/2);for(const{line:C,points:A}of l(this,Es))X._translate(C,b,x,C),X._translate(A,b,x,A);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(i-2*r)/(d-2*r),p=(n-2*a)/(f-2*a),v=-g*(c+r)+e+r,_=-p*(u+a)+s+a;if(g!==1||p!==1||v!==0||_!==0)for(const{line:b,points:x}of l(this,Es))X._rescale(b,v,_,g,p,b),X._rescale(x,v,_,g,p,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[n,r]=i,a=l(this,qe),h=e-a[0],c=s-a[1];if(l(this,Bi)===n&&l(this,Hi)===r)for(const{line:u,points:d}of l(this,Es))X._translate(u,h,c,u),X._translate(d,h,c,d);else{const u=l(this,Bi)/n,d=l(this,Hi)/r;m(this,Bi,n),m(this,Hi,r);for(const{line:f,points:g}of l(this,Es))X._rescale(f,h,c,u,d,f),X._rescale(g,h,c,u,d,g);a[2]*=u,a[3]*=d}return a[0]=e,a[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`}}}get defaultSVGProperties(){const e=l(this,qe);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e[0])} ${X.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}};qe=new WeakMap,Hc=new WeakMap,Gc=new WeakMap,Es=new WeakMap,Bi=new WeakMap,Hi=new WeakMap,Sh=new WeakMap,Ch=new WeakMap,Ah=new WeakMap,xe=new WeakSet,Nn=function(e=l(this,Ah)){const s=l(this,Gc)+e/2*l(this,Sh);return l(this,Ch)%180===0?[s/l(this,Bi),s/l(this,Hi)]:[s/l(this,Hi),s/l(this,Bi)]},Zy=function(){const[e,s,i,n]=l(this,qe),[r,a]=w(this,xe,Nn).call(this,0);return[e+r,s+a,i-2*r,n-2*a]},t_=function(){const e=m(this,qe,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:n}of l(this,Es)){if(n.length<=12){for(let h=4,c=n.length;h<c;h+=6){const[u,d]=n.subarray(h,h+2);e[0]=Math.min(e[0],u),e[1]=Math.min(e[1],d),e[2]=Math.max(e[2],u),e[3]=Math.max(e[3],d)}continue}let r=n[4],a=n[5];for(let h=6,c=n.length;h<c;h+=6){const[u,d,f,g,p,v]=n.subarray(h,h+6);q.bezierBoundingBox(r,a,u,d,f,g,p,v,e),r=p,a=v}}const[s,i]=w(this,xe,Nn).call(this);e[0]=Math.min(1,Math.max(0,e[0]-s)),e[1]=Math.min(1,Math.max(0,e[1]-i)),e[2]=Math.min(1,Math.max(0,e[2]+s)),e[3]=Math.min(1,Math.max(0,e[3]+i)),e[2]-=e[0],e[3]-=e[1]},e_=function(e){const[s,i]=w(this,xe,Nn).call(this);m(this,Ah,e);const[n,r]=w(this,xe,Nn).call(this),[a,h]=[n-s,r-i],c=l(this,qe);return c[0]-=a,c[1]-=h,c[2]+=2*a,c[3]+=2*h,c};let Td=gp;const pp=class pp extends LC{constructor(e){super();y(this,Th);m(this,Th,e),super.updateProperties({fill:"none",stroke:Ht._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,s){e==="stroke-width"&&(s??(s=this["stroke-width"]),s*=l(this,Th).realScale),super.updateSVGProperty(e,s)}clone(){const e=new pp(l(this,Th));return e.updateAll(this),e}};Th=new WeakMap;let rp=pp;const Eh=class Eh extends np{constructor(e){super({...e,name:"inkEditor"});y(this,zd);this._willKeepAspectRatio=!0}static initialize(e,s){Ht.initialize(e,s),this._defaultDrawingOptions=new rp(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return ht(this,"typesMap",new Map([[dt.INK_THICKNESS,"stroke-width"],[dt.INK_COLOR,"stroke"],[dt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,i,n,r){return new FC(e,s,i,n,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,n,r,a){return Td.deserialize(e,s,i,n,r,a)}static async deserialize(e,s,i){let n=null;if(e instanceof tp){const{data:{inkLists:a,rect:h,rotation:c,id:u,color:d,opacity:f,borderStyle:{rawWidth:g},popupRef:p},parent:{page:{pageNumber:v}}}=e;n=e={annotationType:nt.INK,color:Array.from(d),thickness:g,opacity:f,paths:{points:a},boxes:null,pageIndex:v-1,rect:h.slice(0),rotation:c,id:u,deleted:!1,popupRef:p}}const r=await super.deserialize(e,s,i);return r.annotationElementId=e.id||null,r._initialData=n,r}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=Eh.getDefaultDrawingOptions({stroke:q.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i,rect:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":h}}=this,c={annotationType:nt.INK,color:Ht._colorManager.convert(r),opacity:a,thickness:h,paths:{lines:s,points:i},pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?c:this.annotationElementId&&!w(this,zd,s_).call(this,c)?null:(c.id=this.annotationElementId,c)}renderAnnotationElement(e){const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s}),null}};zd=new WeakSet,s_=function(e){const{color:s,thickness:i,opacity:n,pageIndex:r}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some((a,h)=>a!==s[h])||e.thickness!==i||e.opacity!==n||e.pageIndex!==r},J(Eh,"_type","ink"),J(Eh,"_editorType",nt.INK),J(Eh,"_defaultDrawingOptions",null);let ap=Eh;const Vc=class Vc extends Ht{constructor(e){super({...e,name:"stampEditor"});y(this,vt);y(this,Vt,null);y(this,Se,null);y(this,Cr,null);y(this,Rn,null);y(this,Ar,null);y(this,kh,"");y(this,Gi,null);y(this,Vi,null);y(this,ks,!1);y(this,Ph,!1);m(this,Rn,e.bitmapUrl),m(this,Ar,e.bitmapFile)}static initialize(e,s){Ht.initialize(e,s)}static get supportedTypes(){return ht(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(s=>`image/${s}`))}static get supportedTypesStr(){return ht(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(nt.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:r,height:a}=e||this.copyCanvas(null,null,!0).imageData,h=await i.guess({name:"altText",request:{data:n,width:r,height:a,channels:n.length/(r*a)}});if(!h)throw new Error("No response from the AI service.");if(h.error)throw new Error("Error from the AI service.");if(h.cancel)return null;if(!h.output)throw new Error("No valid response from the AI service.");const c=h.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var e;l(this,Se)&&(m(this,Vt,null),this._uiManager.imageManager.deleteId(l(this,Se)),(e=l(this,Gi))==null||e.remove(),m(this,Gi,null),l(this,Vi)&&(clearTimeout(l(this,Vi)),m(this,Vi,null))),super.remove()}rebuild(){if(!this.parent){l(this,Se)&&w(this,vt,wf).call(this);return}super.rebuild(),this.div!==null&&(l(this,Se)&&l(this,Gi)===null&&w(this,vt,wf).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(l(this,Cr)||l(this,Vt)||l(this,Rn)||l(this,Ar)||l(this,Se))}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;if(this.width&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),l(this,Vt)?w(this,vt,lm).call(this):w(this,vt,wf).call(this),this.width&&!this.annotationElementId){const[i,n]=this.parentDimensions;this.setAt(e*i,s*n,this.width*i,this.height*n)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;l(this,Vi)!==null&&clearTimeout(l(this,Vi)),m(this,Vi,setTimeout(()=>{m(this,Vi,null),w(this,vt,cm).call(this)},200))}copyCanvas(e,s,i=!1){var g;e||(e=224);const{width:n,height:r}=l(this,Vt),a=new Ng;let h=l(this,Vt),c=n,u=r,d=null;if(s){if(n>s||r>s){const M=Math.min(s/n,s/r);c=Math.floor(n*M),u=Math.floor(r*M)}d=document.createElement("canvas");const p=d.width=Math.ceil(c*a.sx),v=d.height=Math.ceil(u*a.sy);l(this,ks)||(h=w(this,vt,xf).call(this,p,v));const _=d.getContext("2d");_.filter=this._uiManager.hcmFilter;let b="white",x="#cfcfd8";this._uiManager.hcmFilter!=="none"?x="black":(g=window.matchMedia)!=null&&g.call(window,"(prefers-color-scheme: dark)").matches&&(b="#8f8f9d",x="#42414d");const C=15,A=C*a.sx,P=C*a.sy,D=new OffscreenCanvas(A*2,P*2),k=D.getContext("2d");k.fillStyle=b,k.fillRect(0,0,A*2,P*2),k.fillStyle=x,k.fillRect(0,0,A,P),k.fillRect(A,P,A,P),_.fillStyle=_.createPattern(D,"repeat"),_.fillRect(0,0,p,v),_.drawImage(h,0,0,h.width,h.height,0,0,p,v)}let f=null;if(i){let p,v;if(a.symmetric&&h.width<e&&h.height<e)p=h.width,v=h.height;else if(h=l(this,Vt),n>e||r>e){const x=Math.min(e/n,e/r);p=Math.floor(n*x),v=Math.floor(r*x),l(this,ks)||(h=w(this,vt,xf).call(this,p,v))}const b=new OffscreenCanvas(p,v).getContext("2d",{willReadFrequently:!0});b.drawImage(h,0,0,h.width,h.height,0,0,p,v),f={width:p,height:v,data:b.getImageData(0,0,p,v).data}}return{canvas:d,width:c,height:u,imageData:f}}getImageForAltText(){return l(this,Gi)}static async deserialize(e,s,i){var v;let n=null;if(e instanceof fb){const{data:{rect:_,rotation:b,id:x,structParent:C,popupRef:A},container:P,parent:{page:{pageNumber:D}}}=e,k=P.querySelector("canvas"),M=i.imageManager.getFromCanvas(P.id,k);k.remove();const R=((v=await s._structTree.getAriaAttributes(`${Rg}${x}`))==null?void 0:v.get("aria-label"))||"";n=e={annotationType:nt.STAMP,bitmapId:M.id,bitmap:M.bitmap,pageIndex:D-1,rect:_.slice(0),rotation:b,id:x,deleted:!1,accessibilityData:{decorative:!1,altText:R},isSvg:!1,structParent:C,popupRef:A}}const r=await super.deserialize(e,s,i),{rect:a,bitmap:h,bitmapUrl:c,bitmapId:u,isSvg:d,accessibilityData:f}=e;u&&i.imageManager.isValidId(u)?(m(r,Se,u),h&&m(r,Vt,h)):m(r,Rn,c),m(r,ks,d);const[g,p]=r.pageDimensions;return r.width=(a[2]-a[0])/g,r.height=(a[3]-a[1])/p,r.annotationElementId=e.id||null,f&&(r.altTextData=f),r._initialData=n,m(r,Ph,!!n),r}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:nt.STAMP,bitmapId:l(this,Se),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:l(this,ks),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=w(this,vt,Sf).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:n,altText:r}=this.serializeAltText(!1);if(!n&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const h=w(this,vt,i_).call(this,i);if(h.isSame)return null;h.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const a=l(this,ks)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(l(this,Se)))s.stamps.set(l(this,Se),{area:a,serialized:i}),i.bitmap=w(this,vt,Sf).call(this,!1);else if(l(this,ks)){const h=s.stamps.get(l(this,Se));a>h.area&&(h.area=a,h.serialized.bitmap.close(),h.serialized.bitmap=w(this,vt,Sf).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};Vt=new WeakMap,Se=new WeakMap,Cr=new WeakMap,Rn=new WeakMap,Ar=new WeakMap,kh=new WeakMap,Gi=new WeakMap,Vi=new WeakMap,ks=new WeakMap,Ph=new WeakMap,vt=new WeakSet,iu=function(e,s=!1){if(!e){this.remove();return}m(this,Vt,e.bitmap),s||(m(this,Se,e.id),m(this,ks,e.isSvg)),e.file&&m(this,kh,e.file.name),w(this,vt,lm).call(this)},nu=function(){if(m(this,Cr,null),this._uiManager.enableWaiting(!1),!!l(this,Gi)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&l(this,Vt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&l(this,Vt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},wf=function(){if(l(this,Se)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(l(this,Se)).then(i=>w(this,vt,iu).call(this,i,!0)).finally(()=>w(this,vt,nu).call(this));return}if(l(this,Rn)){const i=l(this,Rn);m(this,Rn,null),this._uiManager.enableWaiting(!0),m(this,Cr,this._uiManager.imageManager.getFromUrl(i).then(n=>w(this,vt,iu).call(this,n)).finally(()=>w(this,vt,nu).call(this)));return}if(l(this,Ar)){const i=l(this,Ar);m(this,Ar,null),this._uiManager.enableWaiting(!0),m(this,Cr,this._uiManager.imageManager.getFromFile(i).then(n=>w(this,vt,iu).call(this,n)).finally(()=>w(this,vt,nu).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Vc.supportedTypesStr;const s=this._uiManager._signal;m(this,Cr,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),w(this,vt,iu).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>w(this,vt,nu).call(this))),e.click()},lm=function(){var d;const{div:e}=this;let{width:s,height:i}=l(this,Vt);const[n,r]=this.pageDimensions,a=.75;if(this.width)s=this.width*n,i=this.height*r;else if(s>a*n||i>a*r){const f=Math.min(a*n/s,a*r/i);s*=f,i*=f}const[h,c]=this.parentDimensions;this.setDims(s*h/n,i*c/r),this._uiManager.enableWaiting(!1);const u=m(this,Gi,document.createElement("canvas"));u.setAttribute("role","img"),this.addContainer(u),this.width=s/n,this.height=i/r,(d=this._initialOptions)!=null&&d.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),w(this,vt,cm).call(this),l(this,Ph)||(this.parent.addUndoableEditor(this),m(this,Ph,!0)),this._reportTelemetry({action:"inserted_image"}),l(this,kh)&&u.setAttribute("aria-label",l(this,kh))},xf=function(e,s){const{width:i,height:n}=l(this,Vt);let r=i,a=n,h=l(this,Vt);for(;r>2*e||a>2*s;){const c=r,u=a;r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),a>2*s&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const d=new OffscreenCanvas(r,a);d.getContext("2d").drawImage(h,0,0,c,u,0,0,r,a),h=d.transferToImageBitmap()}return h},cm=function(){const[e,s]=this.parentDimensions,{width:i,height:n}=this,r=new Ng,a=Math.ceil(i*e*r.sx),h=Math.ceil(n*s*r.sy),c=l(this,Gi);if(!c||c.width===a&&c.height===h)return;c.width=a,c.height=h;const u=l(this,ks)?l(this,Vt):w(this,vt,xf).call(this,a,h),d=c.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(u,0,0,u.width,u.height,0,0,a,h)},Sf=function(e){if(e){if(l(this,ks)){const n=this._uiManager.imageManager.getSvgUrl(l(this,Se));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=l(this,Vt),s.getContext("2d").drawImage(l(this,Vt),0,0),s.toDataURL()}if(l(this,ks)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*Kn.PDF_TO_CSS_UNITS),r=Math.round(this.height*i*Kn.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(n,r);return a.getContext("2d").drawImage(l(this,Vt),0,0,l(this,Vt).width,l(this,Vt).height,0,0,n,r),a.transferToImageBitmap()}return structuredClone(l(this,Vt))},i_=function(e){var a;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,n=e.pageIndex===s,r=(((a=e.accessibilityData)==null?void 0:a.alt)||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&n&&r,isSameAltText:r}},J(Vc,"_type","stamp"),J(Vc,"_editorType",nt.STAMP);let op=Vc;const vi=class vi{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:h,viewport:c,l10n:u}){y(this,Nt);y(this,Qa);y(this,Mh,!1);y(this,Wi,null);y(this,Tr,null);y(this,Ln,null);y(this,zs,new Map);y(this,Er,!1);y(this,Oh,!1);y(this,Za,!1);y(this,mi,null);y(this,Fn,null);y(this,Fe,null);y(this,In,null);y(this,$);const d=[...l(vi,kr).values()];if(!vi._initialized){vi._initialized=!0;for(const f of d)f.initialize(u,t)}t.registerEditorTypes(d),m(this,$,t),this.pageIndex=e,this.div=s,m(this,Qa,n),m(this,Wi,r),this.viewport=c,m(this,Fe,h),this.drawLayer=a,this._structTree=i,l(this,$).addLayer(this)}get isEmpty(){return l(this,zs).size===0}get isInvisible(){return this.isEmpty&&l(this,$).getMode()===nt.NONE}updateToolbar(t){l(this,$).updateToolbar(t)}updateMode(t=l(this,$).getMode()){switch(w(this,Nt,Cf).call(this),t){case nt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case nt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case nt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of l(vi,kr).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=l(this,Fe))==null?void 0:e.div)}setEditingState(t){l(this,$).setEditingState(t)}addCommands(t){l(this,$).addCommands(t)}cleanUndoStack(t){l(this,$).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=l(this,Wi))==null||e.div.classList.toggle("disabled",!t)}async enable(){m(this,Za,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of l(this,zs).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(l(this,$).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!l(this,Wi)){m(this,Za,!1);return}const e=l(this,Wi).getEditableAnnotations();for(const s of e){if(s.hide(),l(this,$).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}m(this,Za,!1)}disable(){var i;m(this,Oh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of l(this,zs).values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){t.set(n.annotationElementId,n);continue}else e.set(n.annotationElementId,n);(i=this.getEditableAnnotation(n.annotationElementId))==null||i.show(),n.remove()}if(l(this,Wi)){const n=l(this,Wi).getEditableAnnotations();for(const r of n){const{id:a}=r.data;if(l(this,$).isDeletedAnnotationElement(a))continue;let h=e.get(a);if(h){h.resetAnnotationElement(r),h.show(!1),r.show();continue}h=t.get(a),h&&(l(this,$).addChangedExistingAnnotation(h),h.renderAnnotationElement(r)&&h.show(!1)),r.show()}}w(this,Nt,Cf).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of l(vi,kr).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),m(this,Oh,!1)}getEditableAnnotation(t){var e;return((e=l(this,Wi))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){l(this,$).getActive()!==t&&l(this,$).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=l(this,Fe))!=null&&t.div&&!l(this,In)){m(this,In,new AbortController);const e=l(this,$).combinedSignal(l(this,In));l(this,Fe).div.addEventListener("pointerdown",w(this,Nt,n_).bind(this),{signal:e}),l(this,Fe).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=l(this,Fe))!=null&&t.div&&l(this,In)&&(l(this,In).abort(),m(this,In,null),l(this,Fe).div.classList.remove("highlighting"))}enableClick(){if(l(this,Tr))return;m(this,Tr,new AbortController);const t=l(this,$).combinedSignal(l(this,Tr));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=l(this,Tr))==null||t.abort(),m(this,Tr,null)}attach(t){l(this,zs).set(t.id,t);const{annotationElementId:e}=t;e&&l(this,$).isDeletedAnnotationElement(e)&&l(this,$).removeDeletedAnnotationElement(t)}detach(t){var e;l(this,zs).delete(t.id),(e=l(this,Qa))==null||e.removePointerInTextLayer(t.contentDiv),!l(this,Oh)&&t.annotationElementId&&l(this,$).addDeletedAnnotationElement(t)}remove(t){this.detach(t),l(this,$).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(l(this,$).addDeletedAnnotationElement(t.annotationElementId),Ht.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),l(this,$).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!l(this,Za)),l(this,$).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!l(this,Ln)&&(t._focusEventsAllowed=!1,m(this,Ln,setTimeout(()=>{m(this,Ln,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:l(this,$)._signal}),e.focus())},0))),t._structTreeParentId=(s=l(this,Qa))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return l(this,$).getId()}combinedSignal(t){return l(this,$).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=l(this,Nt,Ui))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){l(this,$).updateToolbar(t),l(this,$).updateMode(t);const{offsetX:s,offsetY:i}=w(this,Nt,dm).call(this),n=this.getNextId(),r=w(this,Nt,um).call(this,{parent:this,id:n,x:s,y:i,uiManager:l(this,$),isCentered:!0,...e});r&&this.add(r)}async deserialize(t){var e;return await((e=l(vi,kr).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,l(this,$)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=w(this,Nt,um).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:l(this,$),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(w(this,Nt,dm).call(this),!0)}setSelected(t){l(this,$).setSelected(t)}toggleSelected(t){l(this,$).toggleSelected(t)}unselect(t){l(this,$).unselect(t)}pointerup(t){var s;const{isMac:e}=ze.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&l(this,Er)&&(m(this,Er,!1),!((s=l(this,Nt,Ui))!=null&&s.isDrawer&&l(this,Nt,Ui).supportMultipleDrawings))){if(!l(this,Mh)){m(this,Mh,!0);return}if(l(this,$).getMode()===nt.STAMP){l(this,$).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){var i;if(l(this,$).getMode()===nt.HIGHLIGHT&&this.enableTextSelection(),l(this,Er)){m(this,Er,!1);return}const{isMac:e}=ze.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(m(this,Er,!0),(i=l(this,Nt,Ui))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=l(this,$).getActive();m(this,Mh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus(),l(this,mi)){l(this,Nt,Ui).startDrawing(this,l(this,$),!1,t);return}l(this,$).setCurrentDrawingSession(this),m(this,mi,new AbortController);const e=l(this,$).combinedSignal(l(this,mi));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(m(this,Fn,null),this.commitOrRemove())},{signal:e}),l(this,Nt,Ui).startDrawing(this,l(this,$),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&m(this,Fn,e);return}l(this,Fn)&&setTimeout(()=>{var e;(e=l(this,Fn))==null||e.focus(),m(this,Fn,null)},0)}endDrawingSession(t=!1){return l(this,mi)?(l(this,$).setCurrentDrawingSession(null),l(this,mi).abort(),m(this,mi,null),m(this,Fn,null),l(this,Nt,Ui).endDrawing(t)):null}findNewParent(t,e,s){const i=l(this,$).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return l(this,mi)?(this.endDrawingSession(),!0):!1}onScaleChanging(){l(this,mi)&&l(this,Nt,Ui).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=l(this,$).getActive())==null?void 0:t.parent)===this&&(l(this,$).commitOrRemove(),l(this,$).setActiveEditor(null)),l(this,Ln)&&(clearTimeout(l(this,Ln)),m(this,Ln,null));for(const s of l(this,zs).values())(e=l(this,Qa))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,l(this,zs).clear(),l(this,$).removeLayer(this)}render({viewport:t}){this.viewport=t,zr(this.div,t);for(const e of l(this,$).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){l(this,$).commitOrRemove(),w(this,Nt,Cf).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,zr(this.div,{rotation:s}),e!==s)for(const i of l(this,zs).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return l(this,$).viewParameters.realScale}};Qa=new WeakMap,Mh=new WeakMap,Wi=new WeakMap,Tr=new WeakMap,Ln=new WeakMap,zs=new WeakMap,Er=new WeakMap,Oh=new WeakMap,Za=new WeakMap,mi=new WeakMap,Fn=new WeakMap,Fe=new WeakMap,In=new WeakMap,$=new WeakMap,kr=new WeakMap,Nt=new WeakSet,n_=function(t){l(this,$).unselectAll();const{target:e}=t;if(e===l(this,Fe).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&l(this,Fe).div.contains(e)){const{isMac:s}=ze.platform;if(t.button!==0||t.ctrlKey&&s)return;l(this,$).showAllEditors("highlight",!0,!0),l(this,Fe).div.classList.add("free"),this.toggleDrawing(),Ad.startHighlighting(this,l(this,$).direction==="ltr",{target:l(this,Fe).div,x:t.x,y:t.y}),l(this,Fe).div.addEventListener("pointerup",()=>{l(this,Fe).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:l(this,$)._signal}),t.preventDefault()}},Ui=function(){return l(vi,kr).get(l(this,$).getMode())},um=function(t){const e=l(this,Nt,Ui);return e?new e.prototype.constructor(t):null},dm=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),h=Math.min(window.innerHeight,e+i),c=(n+a)/2-t,u=(r+h)/2-e,[d,f]=this.viewport.rotation%180===0?[c,u]:[u,c];return{offsetX:d,offsetY:f}},Cf=function(){for(const t of l(this,zs).values())t.isEmpty()&&t.remove()},J(vi,"_initialized",!1),y(vi,kr,new Map([ep,ap,op,Ad].map(t=>[t._editorType,t])));let hp=vi;const Ie=class Ie{constructor({pageIndex:t}){y(this,zi);y(this,bi,null);y(this,Wc,0);y(this,Ke,new Map);y(this,to,new Map);this.pageIndex=t}setParent(t){if(!l(this,bi)){m(this,bi,t);return}if(l(this,bi)!==t){if(l(this,Ke).size>0)for(const e of l(this,Ke).values())e.remove(),t.append(e);m(this,bi,t)}}static get _svgFactory(){return ht(this,"_svgFactory",new Qg)}draw(t,e=!1,s=!1){const i=Ze(this,Wc)._++,n=w(this,zi,fm).call(this),r=Ie._svgFactory.createElement("defs");n.append(r);const a=Ie._svgFactory.createElement("path");r.append(a);const h=`path_p${this.pageIndex}_${i}`;a.setAttribute("id",h),a.setAttribute("vector-effect","non-scaling-stroke"),e&&l(this,to).set(i,a);const c=s?w(this,zi,a_).call(this,r,h):null,u=Ie._svgFactory.createElement("use");return n.append(u),u.setAttribute("href",`#${h}`),this.updateProperties(n,t),l(this,Ke).set(i,n),{id:i,clipPathId:`url(#${c})`}}drawOutline(t,e){const s=Ze(this,Wc)._++,i=w(this,zi,fm).call(this),n=Ie._svgFactory.createElement("defs");i.append(n);const r=Ie._svgFactory.createElement("path");n.append(r);const a=`path_p${this.pageIndex}_${s}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let h;if(e){const d=Ie._svgFactory.createElement("mask");n.append(d),h=`mask_p${this.pageIndex}_${s}`,d.setAttribute("id",h),d.setAttribute("maskUnits","objectBoundingBox");const f=Ie._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const g=Ie._svgFactory.createElement("use");d.append(g),g.setAttribute("href",`#${a}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const c=Ie._svgFactory.createElement("use");i.append(c),c.setAttribute("href",`#${a}`),h&&c.setAttribute("mask",`url(#${h})`);const u=c.cloneNode();return i.append(u),c.classList.add("mainOutline"),u.classList.add("secondaryOutline"),this.updateProperties(i,t),l(this,Ke).set(s,i),s}finalizeDraw(t,e){l(this,to).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var h;if(!e)return;const{root:s,bbox:i,rootClass:n,path:r}=e,a=typeof t=="number"?l(this,Ke).get(t):t;if(a){if(s&&w(this,zi,gm).call(this,a,s),i&&w(h=Ie,Xd,r_).call(h,a,i),n){const{classList:c}=a;for(const[u,d]of Object.entries(n))c.toggle(u,d)}if(r){const u=a.firstChild.firstChild;w(this,zi,gm).call(this,u,r)}}}updateParent(t,e){if(e===this)return;const s=l(this,Ke).get(t);s&&(l(e,bi).append(s),l(this,Ke).delete(t),l(e,Ke).set(t,s))}remove(t){l(this,to).delete(t),l(this,bi)!==null&&(l(this,Ke).get(t).remove(),l(this,Ke).delete(t))}destroy(){m(this,bi,null);for(const t of l(this,Ke).values())t.remove();l(this,Ke).clear(),l(this,to).clear()}};bi=new WeakMap,Wc=new WeakMap,Ke=new WeakMap,to=new WeakMap,Xd=new WeakSet,r_=function(t,[e,s,i,n]){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`},zi=new WeakSet,fm=function(){const t=Ie._svgFactory.create(1,1,!0);return l(this,bi).append(t),t.setAttribute("aria-hidden",!0),t},a_=function(t,e){const s=Ie._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=Ie._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},gm=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},y(Ie,Xd);let lp=Ie;globalThis.pdfjsTestingUtils={HighlightOutliner:sp},Z.AbortException,Z.AnnotationEditorLayer,Z.AnnotationEditorParamsType,Z.AnnotationEditorType,Z.AnnotationEditorUIManager,Z.AnnotationLayer,Z.AnnotationMode,Z.ColorPicker,Z.DOMSVGFactory,Z.DrawLayer,Z.FeatureTest;var IC=Z.GlobalWorkerOptions;Z.ImageKind,Z.InvalidPDFException,Z.MissingPDFException,Z.OPS,Z.OutputScale,Z.PDFDataRangeTransport,Z.PDFDateString,Z.PDFWorker,Z.PasswordResponses,Z.PermissionFlag,Z.PixelsPerInch,Z.RenderingCancelledException,Z.TextLayer,Z.TouchManager,Z.UnexpectedResponseException,Z.Util,Z.VerbosityLevel,Z.XfaLayer,Z.build,Z.createValidAbsoluteUrl,Z.fetchData;var jC=Z.getDocument;Z.getFilenameFromUrl,Z.getPdfFilenameFromUrl,Z.getXfaPageViewport,Z.isDataScheme,Z.isPdfFile,Z.noContextMenu,Z.normalizeUnicode,Z.setLayerDimensions,Z.shadow,Z.stopEvent,Z.version;const NC={"pdfjs-dist":"4.10.38"};function BC(o){return new Promise((t,e)=>{const s=new FileReader;s.addEventListener("load",()=>t(s.result)),s.addEventListener("error",e),s.readAsDataURL(o)})}const HC=NC["pdfjs-dist"].replace("^","");IC.workerSrc=`https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${HC}/pdf.worker.min.mjs`;async function GC(o){const t="data:application/pdf;base64,",e=await BC(o);if(typeof e=="string")return window.atob(e.slice(t.length))}function VC(o,t){return jC({data:o,password:t}).promise}const WC="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='20'%20cy='20'%20r='10.75'%20stroke='currentColor'%20stroke-width='2.5'/%3e%3cpath%20d='M16%2024L23.7782%2016.2218'%20stroke='currentColor'%20stroke-width='2.5'%20stroke-linecap='round'/%3e%3cpath%20d='M24%2024L16.2218%2016.2218'%20stroke='currentColor'%20stroke-width='2.5'%20stroke-linecap='round'/%3e%3c/svg%3e";function zC(o){return new URL(Object.assign({"../assets/close.svg":WC})[`../assets/${o}`],typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Mt&&Mt.tagName.toUpperCase()==="SCRIPT"&&Mt.src||new URL("pdf-canvas.umd.js",document.baseURI).href).href}function XC(o){return new Promise((t,e)=>{const s=window.URL.createObjectURL(o),i=new Image;i.src=s,i.addEventListener("load",async()=>{window.URL.revokeObjectURL(s),t(await UC(i))}),i.addEventListener("error",n=>{window.URL.revokeObjectURL(s),e(n)})})}function UC(o){return new Promise(t=>{const e=document.createElement("canvas"),s=e.getContext("2d"),{naturalWidth:i,naturalHeight:n}=o;e.width=i,e.height=n,s==null||s.drawImage(o,0,0,i,n),t(e.toDataURL("image/jpeg",.8))})}let pb=null;function YC(){const o=document.createElement("div");o.style.width="1in",document.body.append(o);const t=o.offsetWidth;return o.remove(),t}function $C(){const o=pb??YC();return pb=o,o/72}function qC(o,t=500){if(typeof o!="function")throw new TypeError("The first argument is not a function.");let e=null;return function(...s){e&&clearTimeout(e),e=setTimeout(()=>{e=null,o.apply(this,s)},t)}}const Ls=new Map;function KC(o){const t=new fg(o);return Ls.set(o,t),t}function JC(o,t){const e=Date.now();return{PDFId:`${o.name}-${e}`,name:o.name.replace(/.pdf/,""),updateDate:e,PDFBase64:t}}function QC(o,t){const e=o.getViewport({scale:t}),s=document.createElement("canvas"),i=s.getContext("2d"),n=$C()/window.devicePixelRatio;s.width=Math.floor(e.width*n),s.height=Math.floor(e.height*n);const r={canvasContext:i,viewport:e,transform:[n,0,0,n,0,0]},a=o.render(r);return{canvas:s,renderTask:a}}async function ZC(o,t,e){const s=o||zC("close.svg"),{objects:i,options:n}=await Tx(s),r=i.filter(h=>h!==null),a=Hw.groupSVGElements(r,n);return r.forEach(h=>{h.stroke=t}),a.hoverCursor="pointer",a.stroke=`${t}-${e}`,a}function tA(o,t){if(!Ls.get(o))return;const s=1/3,i=aA(t,s);vb(o,i,s)}async function eA(o,t){const e=await XC(t),s=Date.now(),n={PDFId:`${t.name}${s}`,name:t.name.replace(/.png|.jpg|.jpeg/,""),updateDate:s,PDFBase64:e};return mb(o,{url:e}),{...n,pages:1}}async function mb(o,{url:t,scale:e=.5}){if(!Ls.get(o))return;const i=await ke.fromURL(t);i.scale(e),vb(o,i,e)}function vb(o,t,e){const s=Ls.get(o);s&&(s.setWidth(t.width*e),s.setHeight(t.height*e),s.backgroundImage=t,s.renderAll())}function vl(o,t){if(!t)return;const{oCoords:e}=o;if(!e)return;const{x:s,y:i}=e.tl.touchCorner.tl,{height:n,width:r,scaleY:a,scaleX:h}=t;t.top=i-n*a/2,t.left=s-r*h/2,t.setCoords()}function sA(o,t,e){!e||!o||(e.scale(1/t),vl(o,e))}function iA(o,t,e){o&&(o.borderScaleFactor=1/t,o.cornerSize=6*(1/t),o.touchCornerSize=24*(1/t),o.cornerStrokeColor=e.stroke,o.setCoords())}function nA(o){const t=Ls.get(o);t&&(t.discardActiveObject(),t.renderAll())}function rA(o){const t=Ls.get(o);t&&(t.clear(),Ls.delete(o))}function aA(o,t){return new ke(o,{scaleX:t,scaleY:t})}const oA={top:100,left:50,scaleX:.5,scaleY:.5,borderColor:"black",cornerStrokeColor:"black",cornerSize:8,selectionBackgroundColor:"rgba(245, 245, 245, 0.8)"},hA={top:100,left:50,fontFamily:"helvetica",borderColor:"black",cornerStrokeColor:"black",scaleX:.7,scaleY:.7,cornerSize:8,selectionBackgroundColor:"rgba(245, 245, 245, 0.8)"},lA={stroke:"#000",hoverStroke:"#B7EC5D",src:""};function bb(o=""){const t=Q.useRef(0),e=Q.useRef(null),s=Q.useRef(null),i=Q.useRef(1),n=Q.useRef({...lA});function r(){if(!o||Ls.has(o))return;const k=KC(o);return k.on("selection:cleared",()=>A(k)),k}function a(k,M){var I;const R=k.type,F={"application/pdf":h,"image/png":d,"image/jpeg":d};return((I=F[R])==null?void 0:I.call(F,k,M))??Promise.reject(new Error(`Unsupported ${R} file type.`))}async function h(k,M){const R=await GC(k);if(!R)return;const F=JC(k,R);try{return await c({page:1,PDFBase64:R,scale:.8,password:M}),{...F,pages:t.current}}catch(I){return Promise.reject(I)}}async function c({page:k,PDFBase64:M,scale:R,password:F}){try{const I=await VC(M,F),Y=await I.getPage(k),{renderTask:N,canvas:H}=QC(Y,R);return t.current=I.numPages,N.promise.then(()=>u(H))}catch(I){return Promise.reject(I)}}function u(k){tA(o,k)}async function d(k){return await eA(o,k)}async function f({url:k,scale:M=.5}){await mb(o,{url:k,scale:M})}async function g(k,M){const R=Ls.get(o);if(!R)return;const F=await ke.fromURL(k,{},{...oA,...M});R.add(F),v(R,F)}function p(k,M){const R=Ls.get(o);if(!R)return;const F=new Ee(k,{...hA,...M});R.add(F),v(R,F)}function v(k,M){M.on("selected",R=>_({canvas:k,target:R.target})),M.on("modified",R=>vl(R.target,e.current)),M.on("scaling",R=>vl(R.transform.target,e.current)),M.on("moving",R=>vl(R.transform.target,e.current)),M.on("rotating",R=>vl(R.transform.target,e.current))}async function _({canvas:k,target:M,stroke:R=n.current.stroke,uuid:F=Date.now()}){var Y;if(((Y=e.current)==null?void 0:Y.stroke)===`${R}-${F}`)return;const I=await ZC(n.current.src,R,F);A(k),e.current=I,s.current=M,b(k,M,F),x(i.current,!0),k.add(I)}function b(k,M,R){e.current&&(e.current.on("selected",()=>{k.remove(M),A(k)}),e.current.on("mouseover",()=>{_({canvas:k,target:M,stroke:n.current.hoverStroke,uuid:R})}),e.current.on("mouseout",()=>{_({canvas:k,target:M,stroke:n.current.stroke,uuid:R})}))}function x(k,M=!1){const R=Ls.get(o);i.current=k,R&&(iA(s.current,k,n.current),sA(s.current,k,e.current),!M&&R.renderAll())}function C(k){if(!k)return;n.current={...n.current,...k};const M=Ls.get(o);!e||!s.current||!M||_({target:s.current,canvas:M})}function A(k){e.current&&(k.remove(e.current),e.current=s.current=null)}function P(){nA(o)}function D(){rA(o)}return{createCanvas:r,loadFile:a,specifyPage:c,renderImage:f,addFabric:g,addTextFabric:p,clearActive:P,deleteCanvas:D,scaleFabric:x,setCloseSvgOptions:C}}function cA(o){let t=0;const e=qC(()=>{t!==window.innerWidth&&(t=window.innerWidth,o())});Q.useEffect(()=>(window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)),[])}const uA=Q.forwardRef(dA);function dA({file:o,page:t=1,canvasId:e="PDF-canvas",fileZoom:s=1,fileScale:i=1,canvasScale:n=1,canvasClass:r="",isDrop:a=!1,password:h,dropTextOptions:c,dropImageOptions:u,closeSvgOptions:d},f){const g=Q.useRef(null),p=`${e}-${t-1}`,v=Q.useMemo(()=>s*n,[s,n]),{createCanvas:_,specifyPage:b,addFabric:x,addTextFabric:C,renderImage:A,clearActive:P,deleteCanvas:D,scaleFabric:k,setCloseSvgOptions:M}=bb(p);cA(R);async function R(){window.requestAnimationFrame(async()=>{if(_(),o.PDFBase64.startsWith("data:image")||o.canvas){const{canvas:N}=o,H=N?7:3,at=N!=null&&N.length?N[t-1]:o.PDFBase64;A({url:at,scale:i/H});return}await b({page:t,PDFBase64:o.PDFBase64,scale:i,password:h})})}function F(N){if(N.preventDefault(),N.stopPropagation(),!a||!N.dataTransfer)return;const{dataTransfer:H,clientX:at,clientY:j}=N,W=H.getData("text/plain"),it=H.getData("text/uri-list"),kt={left:at-71,top:j-55};it?I(it,kt):W&&Y(W,kt)}function I(N,H){x(N,{...H,...u})}function Y(N,H){C(N,{...H,...c})}return Q.useImperativeHandle(f,()=>({addImage:I,addText:Y,clearActive:P,deleteCanvas:D,canvasRef:g})),Q.useEffect(()=>{R()},[i,t,o,h]),Q.useEffect(()=>{k(v)},[v]),Q.useEffect(()=>{M(d)},[d]),Q.useEffect(()=>()=>D(),[]),vm.jsx("div",{style:{transform:`scale(${v})`},onDragOver:N=>N.preventDefault(),onDragEnter:N=>N.preventDefault(),onDrop:F,children:vm.jsx("canvas",{id:p,ref:g,className:r})})}ut.default=uA,ut.useFabric=bb,Object.defineProperties(ut,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|