PageSourceSearch

https://emu8883outlookcom-latex.hf.space/js/3892-ede2543f5dc57c51fadb.js

js emu8883outlookcom-latex.hf.space collected 2026-10-03 16:52:09 UTC 388,171 bytes, 2 lines download raw bytes

1/*! For license information please see 3892-ede2543f5dc57c51fadb.js.LICENSE.txt */
2"use strict";(self.webpackChunk_overleaf_web=self.webpackChunk_overleaf_web||[]).push([[3892],{23113:(t,e,s)=>{var i=s(39944),n=s(74418),a=s(4578),r=s(72306),o=s(34932),h=RegExp.prototype;t.exports=r.correct?function(t){return t.flags}:function(t){return r.correct||!a(h,t)||n(t,"flags")?t.flags:i(o,t)}},34932:(t,e,s)=>{var i=s(3770);t.exports=function(){var t=i(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e}},52573:(t,e,s)=>{var i=s(5613),n=s(16881),a=s(38873),r=RangeError,o=TypeError,h=1/0,l=Math.abs,c=Math.pow,d=n([].push),u=c(2,1023),p=c(2,53)-1,g=Number.MAX_VALUE,f=c(2,971),m={},b={},w={},v={},A={},_=function(t,e){var s=t+e;return{hi:s,lo:e-(s-t)}};i({target:"Math",stat:!0},{sumPrecise:function(t){var e=[],s=0,i=v;switch(a(t,(function(t){if(++s>=p)throw new r("Maximum allowed index exceeded");if("number"!=typeof t)throw new o("Value is not a number");i!==m&&(t!=t?i=m:t===h?i=i===b?m:w:t===-1/0?i=i===w?m:b:0===t&&1/t!==h||i!==v&&i!==A||(i=A,d(e,t)))})),i){case m:return NaN;case b:return-1/0;case w:return h;case v:return-0}for(var n,c,y,x,E,S,k=[],M=0,C=0;C<e.length;C++){n=e[C];for(var T=0,R=0;R<k.length;R++){if(c=k[R],l(n)<l(c)&&(S=n,n=c,c=S),x=(y=_(n,c)).hi,E=y.lo,l(x)===h){var P=x===h?1:-1;M+=P,l(n=n-P*u-P*u)<l(c)&&(S=n,n=c,c=S),x=(y=_(n,c)).hi,E=y.lo}0!==E&&(k[T++]=E),n=x}k.length=T,0!==n&&d(k,n)}var I=k.length-1;if(x=0,E=0,0!==M){var L=I>=0?k[I]:0;if(I--,l(M)>1||M>0&&L>0||M<0&&L<0)return M>0?h:-1/0;if(x=(y=_(M*u,L/2)).hi,E=y.lo,E*=2,l(2*x)===h)return x>0?x===u&&E===-f/2&&I>=0&&k[I]<0?g:h:x===-u&&E===f/2&&I>=0&&k[I]>0?-g:-1/0;0!==E&&(k[++I]=E,E=0),x*=2}for(;I>=0&&(x=(y=_(x,k[I--])).hi,0===(E=y.lo)););return I>=0&&(E<0&&k[I]<0||E>0&&k[I]>0)&&(c=2*E)===(n=x+c)-x&&(x=n),x}})},53892:(t,e,s)=>{s.d(e,{EA:()=>bg,J0:()=>Ag,Tm:()=>wg,YE:()=>_g,bw:()=>vg,ng:()=>mg,vP:()=>fg});var i,n,a,r,o,h,l,c,d,u,p,g,f;s(97107),s(37002),s(32482),s(27067),s(34147),s(82438),s(42521),s(2989),s(12266),s(91020),s(50020),s(74786),s(34840),s(64727),s(85178),s(99817),s(69033),s(68903),s(21018),s(1415),s(4448),s(58871),s(56539),s(70950),s(10785),s(46196),s(50821),s(37404),s(95803),s(33912),s(82738),s(99990),s(97015),s(90382),s(85320),s(44304),s(12954),s(57182),s(62053),s(70784),s(61412),s(91883),s(70286);function m(t,e,s){e||(e=[]);var i=e.length++;return Object.defineProperty({},"_",{set:function(n){e[i]=n,t.apply(s,e)}})}function b(t,e){v(t,e),e.add(t)}function w(t,e,s){v(t,e),e.set(t,s)}function v(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function A(t,e,s){return s(E(t,e))}function _(t,e){return t.get(E(t,e))}function y(t,e,s){return t.set(E(t,e),s),s}function x(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function E(t,e,s){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:s;throw new TypeError("Private element is not present on this object")}var S={d:(t,e)=>{for(var s in e)S.o(e,s)&&!S.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},k=globalThis.pdfjsLib={};S.d(k,{AbortException:()=>AbortException,AnnotationEditorLayer:()=>Jp,AnnotationEditorParamsType:()=>$,AnnotationEditorType:()=>H,AnnotationEditorUIManager:()=>Ms,AnnotationLayer:()=>Fl,AnnotationMode:()=>B,AnnotationType:()=>K,ColorPicker:()=>ld,DOMSVGFactory:()=>lh,DrawLayer:()=>lg,FeatureTest:()=>yt,GlobalWorkerOptions:()=>lr,ImageKind:()=>Y,InvalidPDFException:()=>InvalidPDFException,MathClamp:()=>It,OPS:()=>it,OutputScale:()=>Jt,PDFDataRangeTransport:()=>Co,PDFDateString:()=>Vt,PDFWorker:()=>Fo,PasswordResponses:()=>ht,PermissionFlag:()=>U,PixelsPerInch:()=>Nt,RenderingCancelledException:()=>RenderingCancelledException,ResponseException:()=>ResponseException,SignatureExtractor:()=>Zu,SupportedImageMimeTypes:()=>Zt,TextLayer:()=>oo,TouchManager:()=>Si,Util:()=>Et,VerbosityLevel:()=>st,XfaLayer:()=>ch,build:()=>nh,createValidAbsoluteUrl:()=>mt,fetchData:()=>Ft,getDocument:()=>xo,getFilenameFromUrl:()=>Ht,getPdfFilenameFromUrl:()=>$t,getUuid:()=>Rt,getXfaPageViewport:()=>qt,isDataScheme:()=>Wt,isPdfFile:()=>Bt,isValidExplicitDest:()=>ko,noContextMenu:()=>jt,normalizeUnicode:()=>Tt,setLayerDimensions:()=>Qt,shadow:()=>bt,stopEvent:()=>Gt,version:()=>ih});const M=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),C=[1,0,0,1,0,0],T=[.001,0,0,.001,0,0],R=1.35,P=1,I=2,L=4,D=16,N=32,F=64,O=128,W=256,B={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},H={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101}
2,$={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},U={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},z=0,j=1,G=2,V=3,q=3,X=4,Y={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},K={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Q=1,J=2,Z=3,tt=4,et=5,st={ERRORS:0,WARNINGS:1,INFOS:5},it={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},nt=0,at=1,rt=2,ot=3,ht={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let lt=st.WARNINGS;function ct(t){Number.isInteger(t)&&(lt=t)}function dt(){return lt}function ut(t){lt>=st.INFOS&&console.log(`Info: ${t}`)}function pt(t){lt>=st.WARNINGS&&console.log(`Warning: ${t}`)}function gt(t){throw new Error(t)}function ft(t,e){t||gt(e)}function mt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!t)return null;if(s&&"string"==typeof t){if(s.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(s.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const i=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i)?i:null}function bt(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return Object.defineProperty(t,e,{value:s,enumerable:!i,configurable:!0,writable:!1}),s}const wt=function(){function BaseException(t,e){this.message=t,this.name=e}return BaseException.prototype=new Error,BaseException.constructor=BaseException,BaseException}();class PasswordException extends wt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class UnknownErrorException extends wt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class InvalidPDFException extends wt{constructor(t){super(t,"InvalidPDFException")}}class ResponseException extends wt{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class FormatError extends wt{constructor(t){super(t,"FormatError")}}class AbortException extends wt{constructor(t){super(t,"AbortException")}}function vt(t){"object"==typeof t&&void 0!==t?.length||gt("Invalid argument for bytesToString");const e=t.length,s=8192;if(e<s)return String.fromCharCode.apply(null,t);const i=[];for(let n=0;n<e;n+=s){const a=Math.min(n+s,e),r=t.subarray(n,a);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function At(t){"string"!=typeof t&&gt("Invalid argument for stringToBytes");const e=t.length,s=new Uint8Array(e);for(let i=0;i<e;++i)s[i]=255&t.charCodeAt(i);return s}function _t(t){const e=Object.create(null);for(const[s,i]of t)e[s]=i;return e}class yt{static get isLittleEndian(){return bt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return bt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return bt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return bt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){if("undefined"!=typeof navigator&&"string"==typeof navigator?.platform&&"string"==typeof navigator?.userAgent){const{platform:t,userAgent:e}=navigator;return bt(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}return bt(this,"platform",{isAndroid:!1,isLinux:!1,isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return bt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const xt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class Et{static makeHexColor(t,e,s){return`#${xt[t]}${xt[e]}${xt[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s]}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),a=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],a[0]),Math.min(s[1],i[1],n[1],a[1]),Math.max(s[0],i[0],n[0],a[0]),Math.max(s[1],i[1],n[1],a[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],a=t[2]*e[1]+t[3]*e[3],r=(s+a)/2,o=Math.sqrt((s+a)**2-4*(s*a-n*i))/2,h=r+o||1,l=r-o||1;return[Math.sqrt(h),Math.sqrt(l)]}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])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[s,n,i,a]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static bezierBoundingBox(t,e,s,i,n,a,r,o,h){h[0]=Math.min(h[0],t,r),h[1]=Math.min(h[1],e,o),h[2]=Math.max(h[2],t,r),h[3]=Math.max(h[3],e,o),E(Et,this,kt).call(this,t,s,n,r,e,i,a,o,3*(3*(s-n)-t+r),6*(t-2*s+n),3*(s-t),h),E(Et,this,kt).call(this,t,s,n,r,e,i,a,o,3*(3*(i-a)-e+o),6*(e-2*i+a),3*(i-e),h)}}function St(t,e,s,i,n,a,r,o,h,l){if(h<=0||h>=1)return;const c=1-h,d=h*h,u=d*h,p=c*(c*(c*t+3*h*e)+3*d*s)+u*i,g=c*(c*(c*n+3*h*a)+3*d*r)+u*o;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],g),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],g)}function kt(t,e,s,n,a,r,o,h,l,c,d,u){if(Math.abs(l)<1e-12)return void(Math.abs(c)>=1e-12&&E(i,this,St).call(this,t,e,s,n,a,r,o,h,-d/c,u));const p=c**2-4*d*l;if(p<0)return;const g=Math.sqrt(p),f=2*l;E(i,this,St).call(this,t,e,s,n,a,r,o,h,(-c+g)/f,u),E(i,this,St).call(this,t,e,s,n,a,r,o,h,(-c-g)/f,u)}
2i=Et;let Mt=null,Ct=null;function Tt(t){return Mt||(Mt=/([\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,Ct=new Map([["ſt","ſt"]])),t.replaceAll(Mt,((t,e,s)=>e?e.normalize("NFKC"):Ct.get(s)))}function Rt(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),vt(t)}const Pt="pdfjs_internal_id_";function It(t,e,s){return Math.min(Math.max(t,e),s)}function Lt(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(vt(t))}"function"!=typeof Promise.try&&(Promise.try=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];return new Promise((e=>{e(t(...s))}))}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce(((t,e)=>t+e),0)});const Dt="http://www.w3.org/2000/svg";class Nt{}async function Ft(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";if(zt(t,document.baseURI)){const s=await fetch(t);if(!s.ok)throw new Error(s.statusText);switch(e){case"arraybuffer":return s.arrayBuffer();case"blob":return s.blob();case"json":return s.json()}return s.text()}return new Promise(((s,i)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)i(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void s(n.response)}s(n.responseText)}},n.send(null)}))}n=Nt,x(Nt,"CSS",96),x(Nt,"PDF",72),x(n,"PDF_TO_CSS_UNITS",n.CSS/n.PDF);class Ot{constructor(t){let{viewBox:e,userUnit:s,scale:i,rotation:n,offsetX:a=0,offsetY:r=0,dontFlip:o=!1}=t;this.viewBox=e,this.userUnit=s,this.scale=i,this.rotation=n,this.offsetX=a,this.offsetY=r,i*=s;const h=(e[2]+e[0])/2,l=(e[3]+e[1])/2;let c,d,u,p,g,f,m,b;switch(n%=360,n<0&&(n+=360),n){case 180:c=-1,d=0,u=0,p=1;break;case 90:c=0,d=1,u=1,p=0;break;case 270:c=0,d=-1,u=-1,p=0;break;case 0:c=1,d=0,u=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(u=-u,p=-p),0===c?(g=Math.abs(l-e[1])*i+a,f=Math.abs(h-e[0])*i+r,m=(e[3]-e[1])*i,b=(e[2]-e[0])*i):(g=Math.abs(h-e[0])*i+a,f=Math.abs(l-e[1])*i+r,m=(e[2]-e[0])*i,b=(e[3]-e[1])*i),this.transform=[c*i,d*i,u*i,p*i,g-c*i*h-u*i*l,f-d*i*h-p*i*l],this.width=m,this.height=b}get rawDims(){const t=this.viewBox;return bt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone(){let{scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ot({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return Et.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=Et.applyTransform([t[0],t[1]],this.transform),s=Et.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return Et.applyInverseTransform([t,e],this.transform)}}class RenderingCancelledException extends wt{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;super(t,"RenderingCancelledException"),this.extraDelay=e}}function Wt(t){const e=t.length;let s=0;for(;s<e&&""===t[s].trim();)s++;return"data:"===t.substring(s,s+5).toLowerCase()}function Bt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Ht(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function $t(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"document.pdf";if("string"!=typeof t)return e;if(Wt(t))return pt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);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||e}class Ut{started=(()=>Object.create(null))();times=[];time(t){t in this.started&&pt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||pt(`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:t}of this.times)e=Math.max(t.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms\n`);return t.join("")}}function zt(t,e){const s=e?URL.parse(t,e):URL.parse(t);return"http:"===s?.protocol||"https:"===s?.protocol}function jt(t){t.preventDefault()}function Gt(t){t.preventDefault(),t.stopPropagation()}class Vt{static#t;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.exec(t);if(!e)return null;const 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 a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let r=parseInt(e[5],10);r=r>=0&&r<=59?r:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const h=e[7]||"Z";let l=parseInt(e[8],10);l=l>=0&&l<=23?l:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===h?(a+=l,r+=c):"+"===h&&(a-=l,r-=c),new Date(Date.UTC(s,i,n,a,r,o))}}function qt(t,e){let{scale:s=1,rotation:i=0}=e;const{width:n,height:a}=t.attributes.style,r=[0,0,parseInt(n),parseInt(a)];return new Ot({viewBox:r,userUnit:1,scale:s,rotation:i})}function Xt(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(pt(`Not a valid color format: "${t}"`),[0,0,0])}function Yt(t){const{a:e,b:s,c:i,d:n,e:a,f:r}=t.getTransform();return[e,s,i,n,a,r]}function Kt(t){const{a:e,b:s,c:i,d:n,e:a,f:r}=t.getTransform().invertSelf();return[e,s,i,n,a,r]}function Qt(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(e instanceof Ot){const{pageWidth:i,pageHeight:n}=e.rawDims,{style:a}=t,r=yt.isCSSRoundSupported,o=`var(--total-scale-factor) * ${i}px`,h=`var(--total-scale-factor) * ${n}px`,l=r?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,c=r?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;s&&e.rotation%180!=0?(a.width=c,a.height=l):(a.width=l,a.height=c)}i&&t.setAttribute("data-main-rotation",e.rotation)}class Jt{constructor(){const{pixelRatio:t}=Jt;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i){let n=1/0,a=1/0,r=1/0;s>0&&(n=Math.sqrt(s/(t*e))),-1!==i&&(a=i/t,r=i/e);const o=Math.min(n,a,r);return(this.sx>o||this.sy>o)&&(this.sx=o,this.sy=o,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}}
2const Zt=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];var te=new WeakMap,ee=new WeakMap,se=new WeakMap,ie=new WeakMap,ne=new WeakMap,ae=new WeakMap,re=new WeakSet;class oe{constructor(t){b(this,re),w(this,te,null),w(this,ee,null),w(this,se,void 0),w(this,ie,null),w(this,ne,null),w(this,ae,null),y(se,this,t),ge._||(ge._=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const t=y(te,this,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=_(se,this)._uiManager._signal;t.addEventListener("contextmenu",jt,{signal:e}),t.addEventListener("pointerdown",he,{signal:e});const s=y(ie,this,document.createElement("div"));s.className="buttons",t.append(s);const i=_(se,this).toolbarPosition;if(i){const{style:e}=t,s="ltr"===_(se,this)._uiManager.direction?1-i[0]:i[0];e.insetInlineEnd=100*s+"%",e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return E(re,this,ue).call(this),t}get div(){return _(te,this)}hide(){_(te,this).classList.add("hidden"),_(ee,this)?.hideDropdown()}show(){_(te,this).classList.remove("hidden"),_(ne,this)?.shown()}async addAltText(t){const e=await t.render();E(re,this,de).call(this,e),_(ie,this).prepend(e,A(re,this,pe)),y(ne,this,t)}addColorPicker(t){y(ee,this,t);const e=t.renderButton();E(re,this,de).call(this,e),_(ie,this).prepend(e,A(re,this,pe))}async addEditSignatureButton(t){const e=y(ae,this,await t.renderEditButton(_(se,this)));E(re,this,de).call(this,e),_(ie,this).prepend(e,A(re,this,pe))}updateEditSignatureButton(t){_(ae,this)&&(_(ae,this).title=t)}remove(){_(te,this).remove(),_(ee,this)?.destroy(),y(ee,this,null)}}function he(t){t.stopPropagation()}function le(t){_(se,this)._focusEventsAllowed=!1,Gt(t)}function ce(t){_(se,this)._focusEventsAllowed=!0,Gt(t)}function de(t){const e=_(se,this)._uiManager._signal;t.addEventListener("focusin",E(re,this,le).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",E(re,this,ce).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",jt,{signal:e})}function ue(){const{editorType:t,_uiManager:e}=_(se,this),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",ge._[t]),E(re,this,de).call(this,s),s.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),_(ie,this).append(s)}function pe(t){const e=document.createElement("div");return e.className="divider",e}var ge={_:null},fe=new WeakMap,me=new WeakMap,be=new WeakMap,we=new WeakSet;class ve{constructor(t){b(this,we),w(this,fe,null),w(this,me,null),w(this,be,void 0),y(be,this,t)}show(t,e,s){const[i,n]=E(we,this,_e).call(this,e,s),{style:a}=_(me,this)||y(me,this,E(we,this,Ae).call(this));t.append(_(me,this)),a.insetInlineEnd=100*i+"%",a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){_(me,this).remove()}}function Ae(){const t=y(me,this,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",jt,{signal:_(be,this)._signal});const e=y(fe,this,document.createElement("div"));return e.className="buttons",t.append(e),E(we,this,ye).call(this),t}function _e(t,e){let s=0,i=0;for(const n of t){const t=n.y+n.height;if(t<s)continue;const a=n.x+(e?n.width:0);t>s?(i=a,s=t):e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}function ye(){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=_(be,this)._signal;t.addEventListener("contextmenu",jt,{signal:s}),t.addEventListener("click",(()=>{_(be,this).highlightSelection("floating_button")}),{signal:s}),_(fe,this).append(t)}function xe(t,e,s){for(const i of s)e.addEventListener(i,t[i].bind(t))}class Ee{#e=0;get id(){return"pdfjs_internal_editor_"+this.#e++}}var Se=new WeakMap,ke=new WeakMap,Me=new WeakMap,Ce=new WeakSet;class Te{constructor(){b(this,Ce),w(this,Se,Rt()),w(this,ke,0),w(this,Me,null)}static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return bt(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return E(Ce,this,Re).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return E(Ce,this,Re).call(this,t,t)}async getFromBlob(t,e){const s=await e;return E(Ce,this,Re).call(this,t,s)}async getFromId(t){_(Me,this)||y(Me,this,new Map);const e=_(Me,this).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){var s,i;_(Me,this)||y(Me,this,new Map);let n=_(Me,this).get(t);if(n?.bitmap)return n.refCounter+=1,n;const a=new OffscreenCanvas(e.width,e.height);return a.getContext("2d").drawImage(e,0,0),n={bitmap:a.transferToImageBitmap(),id:`image_${_(Se,this)}_${y(ke,this,(s=_(ke,this),i=s++,s)),i}`,refCounter:1,isSvg:!1},_(Me,this).set(t,n),_(Me,this).set(n.id,n),n}getSvgUrl(t){const e=_(Me,this).get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){_(Me,this)||y(Me,this,new Map);const e=_(Me,this).get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:s}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(s.width,s.height);t.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=t.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${_(Se,this)}_`)}}async function Re(t,e){_(Me,this)||y(Me,this,new Map);let s=_(Me,this).get(t);if(null===s)return null;if(s?.bitmap)return s.refCounter+=1,s;try{var i,n;let t;if(s||={bitmap:null,id:`image_${_(Se,this)}_${y(ke,this,(i=_(ke,this),n=i++,i)),n}`,refCounter:0,isSvg:!1},"string"==typeof e?(s.url=e,t=await Ft(e,"blob")):e instanceof File?t=s.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=a._isSVGFittingCanvas,i=new FileReader,n=new Image,r=new Promise(((t,a)=>{n.onload=()=>
2{s.bitmap=n,s.isSvg=!0,t()},i.onload=async()=>{const t=s.svgUrl=i.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=i.onerror=a}));i.readAsDataURL(t),await r}else s.bitmap=await createImageBitmap(t);s.refCounter=1}catch(t){pt(t),s=null}return _(Me,this).set(t,s),s&&_(Me,this).set(s.id,s),s}a=Te;class Pe{#s=[];#i=!1;#n;#a=-1;constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128;this.#n=t}add(t){let{cmd:e,undo:s,post:i,mustExec:n,type:a=NaN,overwriteIfSameType:r=!1,keepUndo:o=!1}=t;if(n&&e(),this.#i)return;const h={cmd:e,undo:s,post:i,type:a};if(-1===this.#a)return this.#s.length>0&&(this.#s.length=0),this.#a=0,void this.#s.push(h);if(r&&this.#s[this.#a].type===a)return o&&(h.undo=this.#s[this.#a].undo),void(this.#s[this.#a]=h);const l=this.#a+1;l===this.#n?this.#s.splice(0,1):(this.#a=l,l<this.#s.length&&this.#s.splice(l)),this.#s.push(h)}undo(){if(-1===this.#a)return;this.#i=!0;const{undo:t,post:e}=this.#s[this.#a];t(),e?.(),this.#i=!1,this.#a-=1}redo(){if(this.#a<this.#s.length-1){this.#a+=1,this.#i=!0;const{cmd:t,post:e}=this.#s[this.#a];t(),e?.(),this.#i=!1}}hasSomethingToUndo(){return-1!==this.#a}hasSomethingToRedo(){return this.#a<this.#s.length-1}cleanType(t){if(-1!==this.#a){for(let e=this.#a;e>=0;e--)if(this.#s[e].type!==t)return this.#s.splice(e+1,this.#a-e),void(this.#a=e);this.#s.length=0,this.#a=-1}}destroy(){this.#s=null}}var Ie=new WeakSet;class Le{constructor(t){b(this,Ie),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=yt.platform;for(const[s,i,n={}]of t)for(const t of s){const s=t.startsWith("mac+");e&&s?(this.callbacks.set(t.slice(4),{callback:i,options:n}),this.allKeys.add(t.split("+").at(-1))):e||s||(this.callbacks.set(t,{callback:i,options:n}),this.allKeys.add(t.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(E(Ie,this,De).call(this,e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:a=[],checker:r=null}}=s;r&&!r(t,e)||(i.bind(t,...a,e)(),n||Gt(e))}}function De(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}class Ne{static _colorsMapping=(()=>new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]))();get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const s of t.keys()){e.style.color=s;const i=window.getComputedStyle(e).color;t.set(s,Xt(i))}e.remove()}(t),bt(this,"_colors",t)}convert(t){const e=Xt(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,s]of this._colors)if(s.every(((t,s)=>t===e[s])))return Ne._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?Et.makeHexColor(...e):t}}var Fe=new WeakMap,Oe=new WeakMap,We=new WeakMap,Be=new WeakMap,He=new WeakMap,$e=new WeakMap,Ue=new WeakMap,ze=new WeakMap,je=new WeakMap,Ge=new WeakMap,Ve=new WeakMap,qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,Ke=new WeakMap,Qe=new WeakMap,Je=new WeakMap,Ze=new WeakMap,ts=new WeakMap,es=new WeakMap,ss=new WeakMap,is=new WeakMap,ns=new WeakMap,as=new WeakMap,rs=new WeakMap,os=new WeakMap,hs=new WeakMap,ls=new WeakMap,cs=new WeakMap,ds=new WeakMap,us=new WeakMap,ps=new WeakMap,gs=new WeakMap,fs=new WeakMap,ms=new WeakMap,bs=new WeakMap,ws=new WeakMap,vs=new WeakMap,As=new WeakMap,_s=new WeakMap,ys=new WeakMap,xs=new WeakMap,Es=new WeakMap,Ss=new WeakMap,ks=new WeakSet;class Ms{static get _keyboardManager(){const t=Ms.prototype,e=t=>_(xs,t).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),s=(t,e)=>{let{target:s}=e;if(s instanceof HTMLInputElement){const{type:t}=s;return"text"!==t&&"number"!==t}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return bt(this,"_keyboardManager",new Le([[["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:(t,e)=>{let{target:s}=e;return!(s instanceof HTMLButtonElement)&&_(xs,t).contains(s)&&!t.isEnterHandled}}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,e)=>{let{target:s}=e;return!(s instanceof HTMLButtonElement)&&_(xs,t).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}]]))}constructor(t,e,s,i,n,a,r,o,h,l,c,d,u,p){b(this,ks),w(this,Fe,new AbortController),w(this,Oe,null),w(this,We,new Map),w(this,Be,new Map),w(this,He,null),w(this,$e,null),w(this,Ue,null),w(this,ze,new Pe),w(this,je,null),w(this,Ge,null),w(this,Ve,0),w(this,qe,new Set),w(this,Xe,null),w(this,Ye,null),w(this,Ke,new Set),x(this,"_editorUndoBar",null),w(this,Qe,!1),w(this,Je,!1),w(this,Ze,!1),w(this,ts,null),w(this,es,null),w(this,ss,null),w(this,is,null),w(this,ns,!1),w(this,as,null),w(this,rs,new Ee),w(this,os,!1),w(this,hs,!1),w(this,ls,null),w(this,cs,null),w(this,ds,null),w(this,us,null),w(this,ps,null),w(this,gs,H.NONE),w(this,fs,new Set),w(this,ms,null),w(this,bs,null),w(this,ws,null),w(this,vs,null),w(this,As,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),w(this,_s,[0,0]),w(this,ys,null),w(this,xs,null),w(this,Es,null),w(this,Ss,null);const g=this._signal=_(Fe,this).signal;y(xs,this,t),y(Es,this,e),y(He,this,s),y(bs,this,i),this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:g}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:g}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:g}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:g}),n._on("setpreference",this.onSetPreference.bind(this),{signal:g}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:g}),E(ks,this,Ls).call(this),E(ks,this,Hs).call(this),E(ks,this,Fs).call(this),y($e,this,a.annotationStorage),y(ts,this,a.filterFactory),y(ws,this,r),y(is,this,o||null),y(Qe,this,h),y(Je,this,l),y(Ze,this,c),y(ps,this,d||null),this.viewParameters={realScale:Nt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=!1!==p}destroy(){_(Ss,this)?.resolve(),y(Ss,this,null),_(Fe,this)?.abort(),y(Fe,this,null),this._signal=null;
2for(const t of _(Be,this).values())t.destroy();_(Be,this).clear(),_(We,this).clear(),_(Ke,this).clear(),_(us,this)?.clear(),y(Oe,this,null),_(fs,this).clear(),_(ze,this).destroy(),_(He,this)?.destroy(),_(bs,this)?.destroy(),_(as,this)?.hide(),y(as,this,null),_(ds,this)?.destroy(),y(ds,this,null),_(es,this)&&(clearTimeout(_(es,this)),y(es,this,null)),_(ys,this)&&(clearTimeout(_(ys,this)),y(ys,this,null)),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return _(ps,this)}get useNewAltTextFlow(){return _(Je,this)}get useNewAltTextWhenAddingImage(){return _(Ze,this)}get hcmFilter(){return bt(this,"hcmFilter",_(ws,this)?_(ts,this).addHCMFilter(_(ws,this).foreground,_(ws,this).background):"none")}get direction(){return bt(this,"direction",getComputedStyle(_(xs,this)).direction)}get highlightColors(){return bt(this,"highlightColors",_(is,this)?new Map(_(is,this).split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return bt(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),y(Ge,this,t)}setMainHighlightColorPicker(t){y(ds,this,t)}editAltText(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];_(He,this)?.editAltText(this,t,e)}getSignature(t){_(bs,this)?.getSignature({uiManager:this,editor:t})}get signatureManager(){return _(bs,this)}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(t){let{name:e,value:s}=t;if("enableNewAltTextWhenAddingImage"===e)y(Ze,this,s)}onPageChanging(t){let{pageNumber:e}=t;y(Ve,this,e-1)}focusMainContainer(){_(xs,this).focus()}findParent(t,e){for(const s of _(Be,this).values()){const{x:i,y:n,width:a,height:r}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=n&&e<=n+r)return s}return null}disableUserSelect(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];_(Es,this).classList.toggle("noUserSelect",t)}addShouldRescale(t){_(Ke,this).add(t)}removeShouldRescale(t){_(Ke,this).delete(t)}onScaleChanging(t){let{scale:e}=t;this.commitOrRemove(),this.viewParameters.realScale=e*Nt.PDF_TO_CSS_UNITS;for(const t of _(Ke,this))t.onScaleChanging();_(Ge,this)?.onScaleChanging()}onRotationChanging(t){let{pagesRotation:e}=t;this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a}=e,r=e.toString(),o=E(ks,this,Cs).call(this,e).closest(".textLayer"),h=this.getSelectionBoxes(o);if(!h)return;e.empty();const l=E(ks,this,Ts).call(this,o),c=_(gs,this)===H.NONE,d=()=>{l?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a,text:r}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(H.HIGHLIGHT,d):d()}addToAnnotationStorage(t){t.isEmpty()||!_($e,this)||_($e,this).has(t.id)||_($e,this).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,_(ns,this)&&(y(ns,this,!1),E(ks,this,Is).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of _(fs,this))if(e.div.contains(t)){y(cs,this,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!_(cs,this))return;const[t,e]=_(cs,this);y(cs,this,null),e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}addEditListeners(){E(ks,this,Fs).call(this),E(ks,this,Ws).call(this)}removeEditListeners(){E(ks,this,Os).call(this),E(ks,this,Bs).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of _(Ye,this))if(s.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const s of _(Ye,this))if(s.isHandlingMimeForPasting(e.type))return s.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),_(Oe,this)?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of _(fs,this)){const s=t.serialize(!0);s&&e.push(s)}0!==e.length&&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 t of e.items)for(const e of _(Ye,this))if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(t){return void pt(`paste: "${t.message}".`)}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const t=[];for(const e of s){const s=await i.deserialize(e);if(!s)return;t.push(s)}const e=()=>{for(const e of t)E(ks,this,Gs).call(this,e);E(ks,this,Xs).call(this,t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){pt(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),_(gs,this)===H.NONE||this.isEditorHandlingKeyboard||Ms._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,_(ns,this)&&(y(ns,this,!1),E(ks,this,Is).call(this,"main_toolbar")))}onEditingAction(t){let{name:e}=t;switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(t){t?(E(ks,this,Ds).call(this),E(ks,this,Ws).call(this),E(ks,this,$s).call(this,{isEditing:_(gs,this)!==H.NONE,isEmpty:E(ks,this,qs).call(this),hasSomethingToUndo:_(ze,this).hasSomethingToUndo(),hasSomethingToRedo:_(ze,this).hasSomethingToRedo(),hasSelectedEditor:!1})):(E(ks,this,Ns).call(this),E(ks,this,Bs).call(this),E(ks,this,$s).call(this,{isEditing:!1}),this.disableUserSelect(!1))}
2registerEditorTypes(t){if(!_(Ye,this)){y(Ye,this,t);for(const t of _(Ye,this))E(ks,this,Us).call(this,t.defaultPropertiesToUpdate)}}getId(){return _(rs,this).id}get currentLayer(){return _(Be,this).get(_(Ve,this))}getLayer(t){return _(Be,this).get(t)}get currentPageIndex(){return _(Ve,this)}addLayer(t){_(Be,this).set(t.pageIndex,t),_(os,this)?t.enable():t.disable()}removeLayer(t){_(Be,this).delete(t.pageIndex)}async updateMode(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(_(gs,this)!==t&&(!_(Ss,this)||(await _(Ss,this).promise,_(Ss,this)))){if(y(Ss,this,Promise.withResolvers()),y(gs,this,t),t===H.NONE)return this.setEditingState(!1),E(ks,this,js).call(this),this._editorUndoBar?.hide(),void _(Ss,this).resolve();t===H.SIGNATURE&&await(_(bs,this)?.loadSignatures()),this.setEditingState(!0),await E(ks,this,zs).call(this),this.unselectAll();for(const e of _(Be,this).values())e.updateMode(t);if(!e)return s&&this.addNewEditorFromKeyboard(),void _(Ss,this).resolve();for(const t of _(We,this).values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();_(Ss,this).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==_(gs,this)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(_(Ye,this)){switch(t){case $.CREATE:return void this.currentLayer.addNewEditor(e);case $.HIGHLIGHT_DEFAULT_COLOR:_(ds,this)?.updateColor(e);break;case $.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(_(vs,this)||y(vs,this,new Map)).set(t,e),this.showAllEditors("highlight",e)}for(const s of _(fs,this))s.updateParams(t,e);for(const s of _(Ye,this))s.updateDefaultParams(t,e)}}showAllEditors(t,e){for(const s of _(We,this).values())s.editorType===t&&s.show(e);(_(vs,this)?.get($.HIGHLIGHT_SHOW_ALL)??!0)!==e&&E(ks,this,Us).call(this,[[$.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(_(hs,this)!==t){y(hs,this,t);for(const e of _(Be,this).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of _(We,this).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return _(We,this).get(t)}addEditor(t){_(We,this).set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(_(es,this)&&clearTimeout(_(es,this)),y(es,this,setTimeout((()=>{this.focusMainContainer(),y(es,this,null)}),0))),_(We,this).delete(t.id),t.annotationElementId&&_(us,this)?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&_(qe,this).has(t.annotationElementId)||_($e,this)?.remove(t.id)}addDeletedAnnotationElement(t){_(qe,this).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return _(qe,this).has(t)}removeDeletedAnnotationElement(t){_(qe,this).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){_(Oe,this)!==t&&(y(Oe,this,t),t&&E(ks,this,Us).call(this,t.propertiesToUpdate))}updateUI(t){A(ks,this,Vs)===t&&E(ks,this,Us).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){E(ks,this,Us).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(_(fs,this).has(t))return _(fs,this).delete(t),t.unselect(),void E(ks,this,$s).call(this,{hasSelectedEditor:this.hasSelection});_(fs,this).add(t),t.select(),E(ks,this,Us).call(this,t.propertiesToUpdate),E(ks,this,$s).call(this,{hasSelectedEditor:!0})}setSelected(t){_(Ge,this)?.commitOrRemove();for(const e of _(fs,this))e!==t&&e.unselect();_(fs,this).clear(),_(fs,this).add(t),t.select(),E(ks,this,Us).call(this,t.propertiesToUpdate),E(ks,this,$s).call(this,{hasSelectedEditor:!0})}isSelected(t){return _(fs,this).has(t)}get firstSelectedEditor(){return _(fs,this).values().next().value}unselect(t){t.unselect(),_(fs,this).delete(t),E(ks,this,$s).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==_(fs,this).size}get isEnterHandled(){return 1===_(fs,this).size&&this.firstSelectedEditor.isEnterHandled}
2undo(){_(ze,this).undo(),E(ks,this,$s).call(this,{hasSomethingToUndo:_(ze,this).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:E(ks,this,qs).call(this)}),this._editorUndoBar?.hide()}redo(){_(ze,this).redo(),E(ks,this,$s).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:_(ze,this).hasSomethingToRedo(),isEmpty:E(ks,this,qs).call(this)})}addCommands(t){_(ze,this).add(t),E(ks,this,$s).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:E(ks,this,qs).call(this)})}cleanUndoStack(t){_(ze,this).cleanType(t)}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[..._(fs,this)],s=()=>{for(const t of e)E(ks,this,Gs).call(this,t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(s,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:s,mustExec:!0})}commitOrRemove(){_(Oe,this)?.commitOrRemove()}hasSomethingToControl(){return _(Oe,this)||this.hasSelection}selectAll(){for(const t of _(fs,this))t.commit();E(ks,this,Xs).call(this,_(We,this).values())}unselectAll(){if((!_(Oe,this)||(_(Oe,this).commitOrRemove(),_(gs,this)===H.NONE))&&!_(Ge,this)?.commitOrRemove()&&this.hasSelection){for(const t of _(fs,this))t.unselect();_(fs,this).clear(),E(ks,this,$s).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||this.commitOrRemove(),!this.hasSelection)return;_(_s,this)[0]+=t,_(_s,this)[1]+=e;const[s,i]=_(_s,this),n=[..._(fs,this)];_(ys,this)&&clearTimeout(_(ys,this)),y(ys,this,setTimeout((()=>{y(ys,this,null),_(_s,this)[0]=_(_s,this)[1]=0,this.addCommands({cmd:()=>{for(const t of n)_(We,this).has(t.id)&&(t.translateInPage(s,i),t.translationDone())},undo:()=>{for(const t of n)_(We,this).has(t.id)&&(t.translateInPage(-s,-i),t.translationDone())},mustExec:!1})}),1e3));for(const s of n)s.translateInPage(t,e),s.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),y(Xe,this,new Map);for(const t of _(fs,this))_(Xe,this).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!_(Xe,this))return!1;this.disableUserSelect(!1);const t=_(Xe,this);y(Xe,this,null);let e=!1;for(const[{x:s,y:i,pageIndex:n},a]of t)a.newX=s,a.newY=i,a.newPageIndex=n,e||=s!==a.savedX||i!==a.savedY||n!==a.savedPageIndex;if(!e)return!1;const s=(t,e,s,i)=>{if(_(We,this).has(t.id)){const n=_(Be,this).get(i);n?t._setParentAndPosition(n,e,s):(t.pageIndex=i,t.x=e,t.y=s)}};return this.addCommands({cmd:()=>{for(const[e,{newX:i,newY:n,newPageIndex:a}]of t)s(e,i,n,a)},undo:()=>{for(const[e,{savedX:i,savedY:n,savedPageIndex:a}]of t)s(e,i,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(_(Xe,this))for(const s of _(Xe,this).keys())s.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===_(fs,this).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return _(Oe,this)===t}getActive(){return _(Oe,this)}getMode(){return _(gs,this)}get imageManager(){return bt(this,"imageManager",new Te)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let s=0,i=e.rangeCount;s<i;s++)if(!t.contains(e.getRangeAt(s).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:a}=t.getBoundingClientRect();let r;switch(t.getAttribute("data-main-rotation")){case"90":r=(t,e,r,o)=>({x:(e-i)/a,y:1-(t+r-s)/n,width:o/a,height:r/n});break;case"180":r=(t,e,r,o)=>({x:1-(t+r-s)/n,y:1-(e+o-i)/a,width:r/n,height:o/a});break;case"270":r=(t,e,r,o)=>({x:1-(e+o-i)/a,y:(t-s)/n,width:o/a,height:r/n});break;default:r=(t,e,r,o)=>({x:(t-s)/n,y:(e-i)/a,width:r/n,height:o/a})}const o=[];for(let t=0,s=e.rangeCount;t<s;t++){const s=e.getRangeAt(t);if(!s.collapsed)for(const{x:t,y:e,width:i,height:n}of s.getClientRects())0!==i&&0!==n&&o.push(r(t,e,i,n))}return 0===o.length?null:o}addChangedExistingAnnotation(t){let{annotationElementId:e,id:s}=t;(_(Ue,this)||y(Ue,this,new Map)).set(e,s)}removeChangedExistingAnnotation(t){let{annotationElementId:e}=t;_(Ue,this)?.delete(e)}renderAnnotationElement(t){const e=_(Ue,this)?.get(t.data.id);if(!e)return;const s=_($e,this).getRawValue(e);s&&(_(gs,this)!==H.NONE||s.hasBeenModified)&&s.renderAnnotationElement(t)}setMissingCanvas(t,e,s){const i=_(us,this)?.get(t);i&&(i.setCanvas(e,s),_(us,this).delete(t))}addMissingCanvas(t,e){(_(us,this)||y(us,this,new Map)).set(t,e)}}function Cs(t){let{anchorNode:e}=t;
2return e.nodeType===Node.TEXT_NODE?e.parentElement:e}function Ts(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of _(Be,this).values())if(e.hasTextLayer(t))return e;return null}function Rs(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=E(ks,this,Cs).call(this,t).closest(".textLayer"),s=this.getSelectionBoxes(e);s&&(_(as,this)||y(as,this,new ve(this)),_(as,this).show(e,s,"ltr"===this.direction))}function Ps(){const t=document.getSelection();if(!t||t.isCollapsed)return void(_(ms,this)&&(_(as,this)?.hide(),y(ms,this,null),E(ks,this,$s).call(this,{hasSelectedText:!1})));const{anchorNode:e}=t;if(e===_(ms,this))return;const s=E(ks,this,Cs).call(this,t).closest(".textLayer");if(s){if(_(as,this)?.hide(),y(ms,this,e),E(ks,this,$s).call(this,{hasSelectedText:!0}),(_(gs,this)===H.HIGHLIGHT||_(gs,this)===H.NONE)&&(_(gs,this)===H.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),y(ns,this,this.isShiftKeyDown),!this.isShiftKeyDown)){const t=_(gs,this)===H.HIGHLIGHT?E(ks,this,Ts).call(this,s):null;t?.toggleDrawing();const e=new AbortController,i=this.combinedSignal(e),n=s=>{"pointerup"===s.type&&0!==s.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===s.type&&E(ks,this,Is).call(this,"main_toolbar"))};window.addEventListener("pointerup",n,{signal:i}),window.addEventListener("blur",n,{signal:i})}}else _(ms,this)&&(_(as,this)?.hide(),y(ms,this,null),E(ks,this,$s).call(this,{hasSelectedText:!1}))}function Is(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";_(gs,this)===H.HIGHLIGHT?this.highlightSelection(t):_(Qe,this)&&E(ks,this,Rs).call(this)}function Ls(){document.addEventListener("selectionchange",E(ks,this,Ps).bind(this),{signal:this._signal})}function Ds(){if(_(ss,this))return;y(ss,this,new AbortController);const t=this.combinedSignal(_(ss,this));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}function Ns(){_(ss,this)?.abort(),y(ss,this,null)}function Fs(){if(_(ls,this))return;y(ls,this,new AbortController);const t=this.combinedSignal(_(ls,this));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}function Os(){_(ls,this)?.abort(),y(ls,this,null)}function Ws(){if(_(je,this))return;y(je,this,new AbortController);const t=this.combinedSignal(_(je,this));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})}function Bs(){_(je,this)?.abort(),y(je,this,null)}function Hs(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}function $s(t){Object.entries(t).some((t=>{let[e,s]=t;return _(As,this)[e]!==s}))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(_(As,this),t)}),_(gs,this)===H.HIGHLIGHT&&!1===t.hasSelectedEditor&&E(ks,this,Us).call(this,[[$.HIGHLIGHT_FREE,!0]]))}function Us(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}async function zs(){if(!_(os,this)){y(os,this,!0);const t=[];for(const e of _(Be,this).values())t.push(e.enable());await Promise.all(t);for(const t of _(We,this).values())t.enable()}}function js(){if(this.unselectAll(),_(os,this)){y(os,this,!1);for(const t of _(Be,this).values())t.disable();for(const t of _(We,this).values())t.disable()}}function Gs(t){const e=_(Be,this).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}function Vs(t){let e=null;for(e of _(fs,t));return e}function qs(){if(0===_(We,this).size)return!0;if(1===_(We,this).size)for(const t of _(We,this).values())return t.isEmpty();return!1}function Xs(t){for(const t of _(fs,this))t.unselect();_(fs,this).clear();for(const e of t)e.isEmpty()||(_(fs,this).add(e),e.select());E(ks,this,$s).call(this,{hasSelectedEditor:this.hasSelection})}x(Ms,"TRANSLATE_SMALL",1),x(Ms,"TRANSLATE_BIG",10);var Ys=new WeakMap,Ks=new WeakMap,Qs=new WeakMap,Js=new WeakMap,Zs=new WeakMap,ti=new WeakMap,ei=new WeakMap,si=new WeakMap,ii=new WeakMap,ni=new WeakMap,ai=new WeakMap,ri=new WeakMap,oi=new WeakSet;class hi{constructor(t){b(this,oi),w(this,Ys,null),w(this,Ks,!1),w(this,Qs,null),w(this,Js,null),w(this,Zs,null),w(this,ti,null),w(this,ei,!1),w(this,si,null),w(this,ii,null),w(this,ni,null),w(this,ai,null),w(this,ri,!1),y(ii,this,t),y(ri,this,t._uiManager.useNewAltTextFlow),di._||(di._=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){hi._l10n??=t}async render(){const t=y(Qs,this,document.createElement("button"));t.className="altText",t.tabIndex="0";
2const e=y(Js,this,document.createElement("span"));t.append(e),_(ri,this)?(t.classList.add("new"),t.setAttribute("data-l10n-id",di._.missing),e.setAttribute("data-l10n-id",di._["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=_(ii,this)._uiManager._signal;t.addEventListener("contextmenu",jt,{signal:s}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:s});const i=t=>{t.preventDefault(),_(ii,this)._uiManager.editAltText(_(ii,this)),_(ri,this)&&_(ii,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:A(oi,this,li)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(y(ei,this,!0),i(e))}),{signal:s}),await E(oi,this,ci).call(this),t}finish(){_(Qs,this)&&(_(Qs,this).focus({focusVisible:_(ei,this)}),y(ei,this,!1))}isEmpty(){return _(ri,this)?null===_(Ys,this):!_(Ys,this)&&!_(Ks,this)}hasData(){return _(ri,this)?null!==_(Ys,this)||!!_(ni,this):this.isEmpty()}get guessedText(){return _(ni,this)}async setGuessedText(t){null===_(Ys,this)&&(y(ni,this,t),y(ai,this,await hi._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),E(oi,this,ci).call(this))}toggleAltTextBadge(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!_(ri,this)||_(Ys,this))return _(si,this)?.remove(),void y(si,this,null);if(!_(si,this)){const t=y(si,this,document.createElement("div"));t.className="noAltTextBadge",_(ii,this).div.append(t)}_(si,this).classList.toggle("hidden",!t)}serialize(t){let e=_(Ys,this);return t||_(ni,this)!==e||(e=_(ai,this)),{altText:e,decorative:_(Ks,this),guessedText:_(ni,this),textWithDisclaimer:_(ai,this)}}get data(){return{altText:_(Ys,this),decorative:_(Ks,this)}}set data(t){let{altText:e,decorative:s,guessedText:i,textWithDisclaimer:n,cancel:a=!1}=t;i&&(y(ni,this,i),y(ai,this,n)),_(Ys,this)===e&&_(Ks,this)===s||(a||(y(Ys,this,e),y(Ks,this,s)),E(oi,this,ci).call(this))}toggle(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];_(Qs,this)&&(!t&&_(ti,this)&&(clearTimeout(_(ti,this)),y(ti,this,null)),_(Qs,this).disabled=!t)}shown(){_(ii,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:A(oi,this,li)}})}destroy(){_(Qs,this)?.remove(),y(Qs,this,null),y(Js,this,null),y(Zs,this,null),_(si,this)?.remove(),y(si,this,null)}}function li(t){return(_(Ys,t)?"added":null===_(Ys,t)&&t.guessedText&&"review")||"missing"}async function ci(){const t=_(Qs,this);if(!t)return;if(_(ri,this)){if(t.classList.toggle("done",!!_(Ys,this)),t.setAttribute("data-l10n-id",di._[A(oi,this,li)]),_(Js,this)?.setAttribute("data-l10n-id",di._[`${A(oi,this,li)}-label`]),!_(Ys,this))return void _(Zs,this)?.remove()}else{if(!_(Ys,this)&&!_(Ks,this))return t.classList.remove("done"),void _(Zs,this)?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=_(Zs,this);if(!e){y(Zs,this,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${_(ii,this).id}`;const s=100,i=_(ii,this)._uiManager._signal;i.addEventListener("abort",(()=>{clearTimeout(_(ti,this)),y(ti,this,null)}),{once:!0}),t.addEventListener("mouseenter",(()=>{y(ti,this,setTimeout((()=>{y(ti,this,null),_(Zs,this).classList.add("show"),_(ii,this)._reportTelemetry({action:"alt_text_tooltip"})}),s))}),{signal:i}),t.addEventListener("mouseleave",(()=>{_(ti,this)&&(clearTimeout(_(ti,this)),y(ti,this,null)),_(Zs,this)?.classList.remove("show")}),{signal:i})}_(Ks,this)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=_(Ys,this)),e.parentNode||t.append(e);const s=_(ii,this).getElementForAltText();s?.setAttribute("aria-describedby",e.id)}var di={_:null};x(hi,"_l10n",null);var ui=new WeakMap,pi=new WeakMap,gi=new WeakMap,fi=new WeakMap,mi=new WeakMap,bi=new WeakMap,wi=new WeakMap,vi=new WeakMap,Ai=new WeakMap,_i=new WeakMap,yi=new WeakMap,xi=new WeakMap,Ei=new WeakSet;class Si{constructor(t){let{container:e,isPinchingDisabled:s=null,isPinchingStopped:i=null,onPinchStart:n=null,onPinching:a=null,onPinchEnd:r=null,signal:o}=t;b(this,Ei),w(this,ui,void 0),w(this,pi,!1),w(this,gi,null),w(this,fi,void 0),w(this,mi,void 0),w(this,bi,void 0),w(this,wi,void 0),w(this,vi,null),w(this,Ai,void 0),w(this,_i,null),w(this,yi,void 0),w(this,xi,null),y(ui,this,e),y(gi,this,i),y(fi,this,s),y(mi,this,n),y(bi,this,a),y(wi,this,r),y(yi,this,new AbortController),y(Ai,this,AbortSignal.any([o,_(yi,this).signal])),e.addEventListener("touchstart",E(Ei,this,ki).bind(this),{passive:!1,signal:_(Ai,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Jt.pixelRatio}destroy(){_(yi,this)?.abort(),y(yi,this,null),_(vi,this)?.abort(),y(vi,this,null)}}function ki(t){if(_(fi,this)?.call(this))return;if(1===t.touches.length){if(_(vi,this))return;const t=y(vi,this,new AbortController),e=AbortSignal.any([_(Ai,this),t.signal]),s=_(ui,this),i={capture:!0,signal:e,passive:!1},n=t=>{"touch"===t.pointerType&&(_(vi,this)?.abort(),y(vi,this,null))};return s.addEventListener("pointerdown",(t=>{"touch"===t.pointerType&&(Gt(t),n(t))}),i),s.addEventListener("pointerup",n,i),void s.addEventListener("pointercancel",n,i)}if(!_(xi,this)){y(xi,this,new AbortController);const t=AbortSignal.any([_(Ai,this),_(xi,this).signal]),e=_(ui,this),s={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",E(Ei,this,Mi).bind(this),s);const i=E(Ei,this,Ci).bind(this);e.addEventListener("touchend",i,s),e.addEventListener("touchcancel",i,s),s.capture=!0,e.addEventListener("pointerdown",Gt,s),e.addEventListener("pointermove",Gt,s),e.addEventListener("pointercancel",Gt,s),e.addEventListener("pointerup",Gt,s),_(mi,this)?.call(this)}if(Gt(t),2!==t.touches.length||_(gi,this)?.call(this))return void y(_i,this,null);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),y(_i,this,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})}function Mi(t){if(!_(_i,this)||2!==t.touches.length)return;Gt(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:n}=e,{screenX:a,screenY:o}=s,h=_(_i,this),{touch0X:l,touch0Y:c,touch1X:d,touch1Y:u}=h,p=d-l,g=u-c,f=a-i,m=o-n,b=Math.hypot(f,m)||1,w=Math.hypot(p,g)||1;if(!_(pi,this)&&Math.abs(w-b)<=r.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(h.touch0X=i,h.touch0Y=n,h.touch1X=a,h.touch1Y=o,!_(pi,this))return void y(pi,this,!0);const v=[(i+a)/2,(n+o)/2];_(bi,this)?.call(this,v,w,b)}function Ci(t){t.touches.length>=2||(_(xi,this).abort(),y(xi,this,null),_(wi,this)?.call(this),_(_i,this)&&(Gt(t),y(_i,this,null),y(pi,this,!1)))}r=Si;var Ti=new WeakMap,Ri=new WeakMap,Pi=new WeakMap,Ii=new WeakMap,Li=new WeakMap,Di=new WeakMap,Ni=new WeakMap,Fi=new WeakMap,Oi=new WeakMap,Wi=new WeakMap,Bi=new WeakMap,Hi=new WeakMap,$i=new WeakMap,Ui=new WeakMap,zi=new WeakMap,ji=new WeakMap,Gi=new WeakMap,Vi=new WeakMap,qi=new WeakMap,Xi=new WeakMap,Yi=new WeakMap,Ki=new WeakMap,Qi=new WeakMap,Ji=new WeakMap,Zi=new WeakSet;class tn{static get _resizerKeyboardManager(){const t=tn.prototype._resizeWithKeyboard,e=Ms.TRANSLATE_SMALL,s=Ms.TRANSLATE_BIG;return bt(this,"_resizerKeyboardManager",new Le([[["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"],tn.prototype._stopResizingWithKeyboard]]))}constructor(t){b(this,Zi),w(this,Ti,null),w(this,Ri,null),w(this,Pi,null),w(this,Ii,!1),w(this,Li,null),w(this,Di,""),w(this,Ni,!1),w(this,Fi,null),w(this,Oi,null),w(this,Wi,null),w(this,Bi,null),w(this,Hi,""),w(this,$i,!1),w(this,Ui,null),w(this,zi,!1),w(this,ji,!1),w(this,Gi,!1),w(this,Vi,null),w(this,qi,0),w(this,Xi,0),w(this,Yi,null),w(this,Ki,null),x(this,"_isCopy",!1),x(this,"_editToolbar",null),x(this,"_initialOptions",Object.create(null)),x(this,"_initialData",null),x(this,"_isVisible",!0),x(this,"_uiManager",null),x(this,"_focusEventsAllowed",!0),w(this,Qi,!1),w(this,Ji,tn._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:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,a];const[r,o]=this.parentDimensions;this.x=t.x/r,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return bt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new _n({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(tn._l10n??=t,tn._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==tn._borderLineWidth)return;const s=getComputedStyle(document.documentElement);tn._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){gt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return _(Qi,this)}set _isDraggable(t){y(Qi,this,t),this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=_(Ji,this)}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):E(Zi,this,An).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(_($i,this)?y($i,this,!1):this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.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,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){E(Zi,this,en).call(this,this.parentDimensions,t,e)}translateInPage(t,e){_(Ui,this)||y(Ui,this,[this.x,this.y,this.width,this.height]),E(Zi,this,en).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){_(Ui,this)||y(Ui,this,[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:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:r}=this;const[o,h]=this.getBaseTranslation();a+=o,r+=h;const{style:l}=s;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*r).toFixed(2)}%`,this._onTranslating(a,r),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!_(Ui,this)&&(_(Ui,this)[0]!==this.x||_(Ui,this)[1]!==this.y)}get _hasBeenResized(){return!!_(Ui,this)&&(_(Ui,this)[2]!==this.width||_(Ui,this)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=tn,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(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.rotation;const{div:{style:e},pageDimensions:[s,i]}=this;let{x:n,y:a,width:r,height:o}=this;if(r*=s,o*=i,n*=s,a*=i,this._mustFixPosition)switch(t){case 0:n=It(n,0,s-r),a=It(a,0,i-o);break;case 90:n=It(n,0,s-o),a=It(a,r,i);break;case 180:n=It(n,r,s),a=It(a,o,i);break;case 270:n=It(n,o,s),a=It(a,0,i-r)}this.x=n/=s,this.y=a/=i;const[h,l]=this.getBaseTranslation();n+=h,a+=l,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){return sn.call(tn,t,e,this.parentRotation)}pageTranslationToScreen(t,e){return sn.call(tn,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)}%`,_(Ni,this)||(n.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!_(Ni,this)&&e.endsWith("%");if(i&&n)return;const[a,r]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),_(Ni,this)||n||(t.height=`${(100*parseFloat(e)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){_(Pi,this)?.finish()}async addEditToolbar(){return this._editToolbar||_(ji,this)||(this._editToolbar=new oe(this),this.div.append(this._editToolbar.render()),_(Pi,this)&&await this._editToolbar.addAltText(_(Pi,this))),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,_(Pi,this)?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){_(Pi,this)||(hi.initialize(tn._l10n),y(Pi,this,new hi(this)),_(Ti,this)&&(_(Pi,this).data=_(Ti,this),y(Ti,this,null)),await this.addEditToolbar())}get altTextData(){return _(Pi,this)?.data}set altTextData(t){_(Pi,this)&&(_(Pi,this).data=t)}get guessedAltText(){return _(Pi,this)?.guessedText}async setGuessedAltText(t){await(_(Pi,this)?.setGuessedText(t))}serializeAltText(t){return _(Pi,this)?.serialize(t)}hasAltText(){return!!_(Pi,this)&&!_(Pi,this).isEmpty()}hasAltTextData(){return _(Pi,this)?.hasData()??!1}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=_(Ii,this)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),E(Zi,this,fn).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),xe(this,t,["keydown","pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(_(Ki,this)||y(Ki,this,new Si({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:E(Zi,this,cn).bind(this),onPinching:E(Zi,this,dn).bind(this),onPinchEnd:E(Zi,this,un).bind(this),signal:this._uiManager._signal}))),this._uiManager._editorUndoBar?.hide(),t}pointerdown(t){const{isMac:e}=yt.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(y($i,this,!0),this._isDraggable?E(Zi,this,gn).call(this,t):E(Zi,this,pn).call(this,t))}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){_(Vi,this)&&clearTimeout(_(Vi,this)),y(Vi,this,setTimeout((()=>{y(Vi,this,null),this.parent?.moveEditorInDOM(this)}),0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.rotation;const i=this.parentScale,[n,a]=this.pageDimensions,[r,o]=this.pageTranslation,h=t/i,l=e/i,c=this.x*n,d=this.y*a,u=this.width*n,p=this.height*a;switch(s){case 0:return[c+h+r,a-d-l-p+o,c+h+u+r,a-d-l+o];case 90:return[c+l+r,a-d+h+o,c+l+p+r,a-d+h+u+o];case 180:return[c-h-u+r,a-d+l+o,c-h+r,a-d+l+p+o];case 270:return[c-l-p+r,a-d-h-u+o,c-l+r,a-d-h+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,a]=t,r=n-s,o=a-i;switch(this.rotation){case 0:return[s,e-a,r,o];case 90:return[s,e-i,o,r];case 180:return[n,e-i,r,o];case 270:return[n,e-a,o,r];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){y(ji,this,!0)}disableEditMode(){y(ji,this,!1)}isInEditMode(){return _(ji,this)}shouldGetKeyboardEvents(){return _(Gi,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:a}=window;return e<a&&i>0&&t<n&&s>0}rebuild(){E(Zi,this,fn).call(this)}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(){gt("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,y(Ti,i,t.accessibilityData),i._isCopy=t.isCopy||!1;const[n,a]=i.pageDimensions,[r,o,h,l]=i.getRectInCurrentCoords(t.rect,a);return i.x=r/n,i.y=o/a,i.width=h/n,i.height=l/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(_(Bi,this)?.abort(),y(Bi,this,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),_(Vi,this)&&(clearTimeout(_(Vi,this)),y(Vi,this,null)),E(Zi,this,An).call(this),this.removeEditToolbar(),_(Yi,this)){for(const t of _(Yi,this).values())clearTimeout(t);y(Yi,this,null)}
2this.parent=null,_(Ki,this)?.destroy(),y(Ki,this,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(E(Zi,this,an).call(this),_(Fi,this).classList.remove("hidden"))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),y(Wi,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=_(Fi,this).children;if(!_(Ri,this)){y(Ri,this,Array.from(e));const t=E(Zi,this,mn).bind(this),s=E(Zi,this,bn).bind(this),i=this._uiManager._signal;for(const e of _(Ri,this)){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:i}),e.addEventListener("blur",s,{signal:i}),e.addEventListener("focus",E(Zi,this,wn).bind(this,n),{signal:i}),e.setAttribute("data-l10n-id",tn._l10nResizer[n])}}const s=_(Ri,this)[0];let i=0;for(const t of e){if(t===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(_(Ri,this).length/4);if(n!==i){if(n<i)for(let t=0;t<i-n;t++)_(Fi,this).append(_(Fi,this).firstChild);else if(n>i)for(let t=0;t<n-i;t++)_(Fi,this).firstChild.before(_(Fi,this).lastChild);let t=0;for(const s of e){const e=_(Ri,this)[t++].getAttribute("data-resizer-name");s.setAttribute("data-l10n-id",tn._l10nResizer[e])}}E(Zi,this,vn).call(this,0),y(Gi,this,!0),_(Fi,this).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){_(Gi,this)&&E(Zi,this,ln).call(this,_(Hi,this),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){E(Zi,this,An).call(this),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),_(Pi,this)?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){_(Fi,this)?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),_(Pi,this)?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return _(zi,this)}set isEditing(t){y(zi,this,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){y(Ni,this,!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){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){_(Yi,this)||y(Yi,this,new Map);const{action:e}=t;let s=_(Yi,this).get(e);return s&&clearTimeout(s),s=setTimeout((()=>{this._reportTelemetry(t),_(Yi,this).delete(e),0===_(Yi,this).size&&y(Yi,this,null)}),tn._telemetryTimeout),void _(Yi,this).set(e,s)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),y(Ii,this,!1)}disable(){this.div&&(this.div.tabIndex=-1),y(Ii,this,!0)}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}function en(t,e,s){let[i,n]=t;[e,s]=this.screenToPageTranslation(e,s),this.x+=e/i,this.y+=s/n,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}function sn(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}function nn(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}function an(){if(_(Fi,this))return;y(Fi,this,document.createElement("div")),_(Fi,this).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 t=document.createElement("div");_(Fi,this).append(t),t.classList.add("resizer",s),t.setAttribute("data-resizer-name",s),t.addEventListener("pointerdown",E(Zi,this,rn).bind(this,s),{signal:e}),t.addEventListener("contextmenu",jt,{signal:e}),t.tabIndex=-1}this.div.prepend(_(Fi,this))}function rn(t,e){e.preventDefault();const{isMac:s}=yt.platform;if(0!==e.button||e.ctrlKey&&s)return;_(Pi,this)?.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,y(Oi,this,[e.screenX,e.screenY]);const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",E(Zi,this,ln).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Gt,{passive:!1,signal:a}),window.addEventListener("contextmenu",jt,{signal:a}),y(Wi,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const r=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{n.abort(),this.parent.togglePointerEvents(!0),_(Pi,this)?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=r,this.div.style.cursor=o,E(Zi,this,hn).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})}function on(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e;const[n,a]=this.parentDimensions;this.setDims(n*s,a*i),this.fixAndSetPosition(),this._onResized()}function hn(){if(!_(Wi,this))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=_(Wi,this);y(Wi,this,null);const n=this.x,a=this.y,r=this.width,o=this.height;n===t&&a===e&&r===s&&o===i||this.addCommands({cmd:E(Zi,this,on).bind(this,n,a,r,o),undo:E(Zi,this,on).bind(this,t,e,s,i),mustExec:!0})}function ln(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,r=this.width,h=this.height,l=o.MIN_SIZE/s,c=o.MIN_SIZE/i,d=E(Zi,this,nn).call(this,this.rotation),u=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],p=E(Zi,this,nn).call(this,360-this.rotation);let g,f,m=!1,b=!1;switch(t){case"topLeft":m=!0,g=(t,e)=>
2[0,0],f=(t,e)=>[t,e];break;case"topMiddle":g=(t,e)=>[t/2,0],f=(t,e)=>[t/2,e];break;case"topRight":m=!0,g=(t,e)=>[t,0],f=(t,e)=>[0,e];break;case"middleRight":b=!0,g=(t,e)=>[t,e/2],f=(t,e)=>[0,e/2];break;case"bottomRight":m=!0,g=(t,e)=>[t,e],f=(t,e)=>[0,0];break;case"bottomMiddle":g=(t,e)=>[t/2,e],f=(t,e)=>[t/2,0];break;case"bottomLeft":m=!0,g=(t,e)=>[0,e],f=(t,e)=>[t,0];break;case"middleLeft":b=!0,g=(t,e)=>[0,e/2],f=(t,e)=>[t,e/2]}const w=g(r,h),v=f(r,h);let A=u(...v);const x=o._round(n+A[0]),S=o._round(a+A[1]);let k,M,C=1,T=1;if(e.fromKeyboard)({deltaX:k,deltaY:M}=e);else{const{screenX:t,screenY:s}=e,[i,n]=_(Oi,this);[k,M]=this.screenToPageTranslation(t-i,s-n),_(Oi,this)[0]=t,_(Oi,this)[1]=s}var R,P;if([k,M]=(R=k/s,P=M/i,[p[0]*R+p[2]*P,p[1]*R+p[3]*P]),m){const t=Math.hypot(r,h);C=T=Math.max(Math.min(Math.hypot(v[0]-w[0]-k,v[1]-w[1]-M)/t,1/r,1/h),l/r,c/h)}else b?C=It(Math.abs(v[0]-w[0]-k),l,1)/r:T=It(Math.abs(v[1]-w[1]-M),c,1)/h;const I=o._round(r*C),L=o._round(h*T);A=u(...f(I,L));const D=x-A[0],N=S-A[1];_(Ui,this)||y(Ui,this,[this.x,this.y,this.width,this.height]),this.width=I,this.height=L,this.x=D,this.y=N,this.setDims(s*I,i*L),this.fixAndSetPosition(),this._onResizing()}function cn(){y(Wi,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),_(Pi,this)?.toggle(!1),this.parent.togglePointerEvents(!1)}function dn(t,e,s){let i=s/e*.7+1-.7;if(1===i)return;const n=E(Zi,this,nn).call(this,this.rotation),a=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[r,h]=this.parentDimensions,l=this.x,c=this.y,d=this.width,u=this.height,p=o.MIN_SIZE/r,g=o.MIN_SIZE/h;i=Math.max(Math.min(i,1/d,1/u),p/d,g/u);const f=o._round(d*i),m=o._round(u*i);if(f===d&&m===u)return;_(Ui,this)||y(Ui,this,[l,c,d,u]);const b=a(d/2,u/2),w=o._round(l+b[0]),v=o._round(c+b[1]),A=a(f/2,m/2);this.x=w-A[0],this.y=v-A[1],this.width=f,this.height=m,this.setDims(r*f,h*m),this.fixAndSetPosition(),this._onResizing()}function un(){_(Pi,this)?.toggle(!0),this.parent.togglePointerEvents(!0),E(Zi,this,hn).call(this)}function pn(t){const{isMac:e}=yt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}function gn(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,n=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:n},r=t=>{i.abort(),y(Li,this,null),y($i,this,!1),this._uiManager.endDragSession()||E(Zi,this,pn).call(this,t),s&&this._onStopDragging()};e&&(y(qi,this,t.clientX),y(Xi,this,t.clientY),y(Li,this,t.pointerId),y(Di,this,t.pointerType),window.addEventListener("pointermove",(t=>{s||(s=!0,this._onStartDragging());const{clientX:e,clientY:i,pointerId:n}=t;if(n!==_(Li,this))return void Gt(t);const[a,r]=this.screenToPageTranslation(e-_(qi,this),i-_(Xi,this));y(qi,this,e),y(Xi,this,i),this._uiManager.dragSelectedEditors(a,r)}),a),window.addEventListener("touchmove",Gt,a),window.addEventListener("pointerdown",(t=>{t.pointerType===_(Di,this)&&(_(Ki,this)||t.isPrimary)&&r(t),Gt(t)}),a));const o=t=>{_(Li,this)&&_(Li,this)!==t.pointerId?Gt(t):r(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}function fn(){if(_(Bi,this)||!this.div)return;y(Bi,this,new AbortController);const t=this._uiManager.combinedSignal(_(Bi,this));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}function mn(t){o._resizerKeyboardManager.exec(this,t)}function bn(t){_(Gi,this)&&t.relatedTarget?.parentNode!==_(Fi,this)&&E(Zi,this,An).call(this)}function wn(t){y(Hi,this,_(Gi,this)?t:"")}function vn(t){if(_(Ri,this))for(const e of _(Ri,this))e.tabIndex=t}function An(){y(Gi,this,!1),E(Zi,this,vn).call(this,-1),E(Zi,this,hn).call(this)}o=tn,x(tn,"_l10n",null),x(tn,"_l10nResizer",null),x(tn,"_borderLineWidth",-1),x(tn,"_colorManager",new Ne),x(tn,"_zIndex",1),x(tn,"_telemetryTimeout",1e3);class _n extends tn{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const yn=3285377520,xn=4294901760,En=65535;class Sn{constructor(t){this.h1=t?4294967295&t:yn,this.h2=t?4294967295&t:yn}update(t){let e,s;if("string"==typeof t){e=new Uint8Array(2*t.length),s=0;for(let i=0,n=t.length;i<n;i++){const n=t.charCodeAt(i);n<=255?e[s++]=n:(e[s++]=n>>>8,e[s++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),s=e.byteLength}const i=s>>2,n=s-4*i,a=new Uint32Array(e.buffer,0,i);let r=0,o=0,h=this.h1,l=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let t=0;t<i;t++)1&t?(r=a[t],r=r*c&xn|r*u&En,r=r<<15|r>>>17,r=r*d&xn|r*p&En,h^=r,h=h<<13|h>>>19,h=5*h+3864292196):(o=a[t],o=o*c&xn|o*u&En,o=o<<15|o>>>17,o=o*d&xn|o*p&En,l^=o,l=l<<13|l>>>19,l=5*l+3864292196);switch(r=0,n){case 3:r^=e[4*i+2]<<16;case 2:r^=e[4*i+1]<<8;case 1:r^=e[4*i],r=r*c&xn|r*u&En,r=r<<15|r>>>17,r=r*d&xn|r*p&En,1&i?h^=r:l^=r}this.h1=h,this.h2=l}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&xn|36045*t&En,e=4283543511*e&xn|(2950163797*(e<<16|t>>>16)&xn)>>>16,t^=e>>>1,t=444984403*t&xn|60499*t&En,e=3301882366*e&xn|(3120437893*(e<<16|t>>>16)&xn)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const kn=Object.freeze({map:null,hash:"",transfer:void 0});var Mn=new WeakMap,Cn=new WeakMap,Tn=new WeakMap,Rn=new WeakSet;class Pn{constructor(){b(this,Rn),w(this,Mn,!1),w(this,Cn,null),w(this,Tn,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=_(Tn,this).get(t);return void 0===s?e:Object.assign(e,s)}getRawValue(t){return _(Tn,this).get(t)}remove(t){if(_(Tn,this).delete(t),0===_(Tn,this).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of _(Tn,this).values())if(t instanceof tn)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=_(Tn,this).get(t);let i=!1;if(void 0!==s)for(const[t,n]of Object.entries(e))s[t]!==n&&(i=!0,s[t]=n);else i=!0,_(Tn,this).set(t,e);i&&E(Rn,this,In).call(this),e instanceof tn&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return _(Tn,this).has(t)}getAll(){return _(Tn,this).size>0?_t(_(Tn,this)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return _(Tn,this).size}resetModified(){_(Mn,this)&&(y(Mn,this,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Ln(this)}get serializable(){if(0===_(Tn,this).size)return kn;const t=new Map,e=new Sn,s=[],i=Object.create(null);let n=!1;for(const[s,a]of _(Tn,this)){const r=a instanceof tn?a.serialize(!1,i):a;r&&(t.set(s,r),e.update(`${s}:${JSON.stringify(r)}`),n||=!!r.bitmap)}if(n)for(const e of t.values())e.bitmap&&s.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:kn}get editorStats(){let t=null;const e=new Map;for(const s of _(Tn,this).values()){if(!(s instanceof tn))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||=Object.create(null);
2const a=t[n]||=new Map;for(const[t,e]of Object.entries(i)){if("type"===t)continue;let s=a.get(t);s||(s=new Map,a.set(t,s));const i=s.get(e)??0;s.set(e,i+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){y(Cn,this,null)}get modifiedIds(){if(_(Cn,this))return _(Cn,this);const t=[];for(const e of _(Tn,this).values())e instanceof tn&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return y(Cn,this,{ids:new Set(t),hash:t.join(",")})}}function In(){_(Mn,this)||(y(Mn,this,!0),"function"==typeof this.onSetModified&&this.onSetModified())}class Ln extends Pn{#r;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);this.#r={map:n,hash:s,transfer:i}}get print(){gt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#r}get modifiedIds(){return bt(this,"modifiedIds",{ids:new Set,hash:""})}}class Dn{#o=(()=>new Set)();constructor(t){let{ownerDocument:e=globalThis.document,styleElement:s=null}=t;this._document=e,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(),this.#o.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont(t){let{systemFontInfo:e,disableFontFace:s,_inspectFont:i}=t;if(e&&!this.#o.has(e.loadedName))if(ft(!s,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:t,src:s,style:n}=e,a=new FontFace(t,s,n);this.addNativeFontFace(a);try{await a.load(),this.#o.add(t),i?.(e)}catch{pt(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else gt("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(s){throw pt(`Failed to load font '${e.family}': '${s}'.`),t.disableFontFace=!0,s}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const s=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,s)}))}}get isFontLoadingAPISupported(){return bt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return bt(this,"isSyncFontLoadingSupported",M||yt.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,s={done:!1,complete:function(){for(ft(!s.done,"completeRequest() cannot be called twice."),s.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(s),s}get _loadTestFont(){return bt(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function s(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function i(t,e,s,i){return t.substring(0,e)+i+t.substring(e+s)}let n,a;const r=this._document.createElement("canvas");r.width=1,r.height=1;const o=r.getContext("2d");let h=0;const l=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=i(c,976,l.length,l);const d=1482184792;let u=s(c,16);for(n=0,a=l.length-3;n<a;n+=4)u=u-d+s(l,n)|0;var p;n<l.length&&(u=u-d+s(l+"XXX",n)|0),c=i(c,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${l}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const e of[t.loadedName,l]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,s){if(++h>30)return pt("Load test font never loaded."),void s();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?s():setTimeout(t.bind(null,e,s))}(l,(()=>{f.remove(),e.complete()}
2))}}class Nn{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this._inspectFont=e}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Lt(this.data)});`;let e;if(this.cssFontInfo){let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(t){pt(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}}const Fn=1,On=2,Wn={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Bn(){}function Hn(t){if(t instanceof AbortException||t instanceof InvalidPDFException||t instanceof PasswordException||t instanceof ResponseException||t instanceof UnknownErrorException)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||gt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new AbortException(t.message);case"InvalidPDFException":return new InvalidPDFException(t.message);case"PasswordException":return new PasswordException(t.message,t.code);case"ResponseException":return new ResponseException(t.message,t.status,t.missing);case"UnknownErrorException":return new UnknownErrorException(t.message,t.details)}return new UnknownErrorException(t.message,t.toString())}var $n=new WeakMap,Un=new WeakSet;class zn{constructor(t,e,s){b(this,Un),w(this,$n,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",E(Un,this,jn).bind(this),{signal:_($n,this).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(t){n.reject(t)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,a=this.sourceName,r=this.targetName,o=this.comObj;return new ReadableStream({start:s=>{const h=Promise.withResolvers();return this.streamControllers[n]={controller:s,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:r,action:t,streamId:n,data:e,desiredSize:s.desiredSize},i),h.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:a,targetName:r,stream:Wn.PULL,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{ft(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:a,targetName:r,stream:Wn.CANCEL,streamId:n,reason:Hn(t)}),e.promise}},s)}destroy(){_($n,this)?.abort(),y($n,this,null)}}function jn(t){let{data:e}=t;if(e.targetName!==this.sourceName)return;if(e.stream)return void E(Un,this,Vn).call(this,e);if(e.callback){const t=e.callbackId,s=this.callbackCapabilities[t];if(!s)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===Fn)s.resolve(e.data);else{if(e.callback!==On)throw new Error("Unexpected callback case");s.reject(Hn(e.reason))}return}const s=this.actionHandler[e.action];if(!s)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const t=this.sourceName,i=e.sourceName,n=this.comObj;Promise.try(s,e.data).then((function(s){n.postMessage({sourceName:t,targetName:i,callback:Fn,callbackId:e.callbackId,data:s})}),(function(s){n.postMessage({sourceName:t,targetName:i,callback:On,c
2allbackId:e.callbackId,reason:Hn(s)})}))}else e.streamId?E(Un,this,Gn).call(this,e):s(e.data)}function Gn(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this,r=this.actionHandler[t.action],o={enqueue(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2?arguments[2]:void 0;if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:Wn.ENQUEUE,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Wn.CLOSE,streamId:e}),delete a.streamSinks[e])},error(t){ft(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Wn.ERROR,streamId:e,reason:Hn(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(r,t.data,o).then((function(){n.postMessage({sourceName:s,targetName:i,stream:Wn.START_COMPLETE,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:s,targetName:i,stream:Wn.START_COMPLETE,streamId:e,reason:Hn(t)})}))}function Vn(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this.streamControllers[e],r=this.streamSinks[e];switch(t.stream){case Wn.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(Hn(t.reason));break;case Wn.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(Hn(t.reason));break;case Wn.PULL:if(!r){n.postMessage({sourceName:s,targetName:i,stream:Wn.PULL_COMPLETE,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,Promise.try(r.onPull||Bn).then((function(){n.postMessage({sourceName:s,targetName:i,stream:Wn.PULL_COMPLETE,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:s,targetName:i,stream:Wn.PULL_COMPLETE,streamId:e,reason:Hn(t)})}));break;case Wn.ENQUEUE:if(ft(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Wn.CLOSE:if(ft(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),E(Un,this,qn).call(this,a,e);break;case Wn.ERROR:ft(a,"error should have stream controller"),a.controller.error(Hn(t.reason)),E(Un,this,qn).call(this,a,e);break;case Wn.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(Hn(t.reason)),E(Un,this,qn).call(this,a,e);break;case Wn.CANCEL:if(!r)break;const o=Hn(t.reason);Promise.try(r.onCancel||Bn,o).then((function(){n.postMessage({sourceName:s,targetName:i,stream:Wn.CANCEL_COMPLETE,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:s,targetName:i,stream:Wn.CANCEL_COMPLETE,streamId:e,reason:Hn(t)})})),r.sinkCapability.reject(o),r.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async function qn(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}class Xn{#h=!1;constructor(t){let{enableHWA:e=!1}=t;this.#h=e}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:!this.#h})}}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){gt("Abstract method `_createCanvas` called.")}}class Yn extends Xn{constructor(t){let{ownerDocument:e=globalThis.document,enableHWA:s=!1}=t;super({enableHWA:s}),this._document=e}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Kn{constructor(t){let{baseUrl:e=null,isCompressed:s=!0}=t;this.baseUrl=e,this.isCompressed=s}async fetch(t){let{name:e}=t;if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const s=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(s).then((t=>({cMapData:t,isCompressed:this.isCompressed}
2))).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${s}`)}))}async _fetch(t){gt("Abstract method `_fetch` called.")}}class Qn extends Kn{async _fetch(t){const e=await Ft(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):At(e)}}class Jn{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(){}}var Zn=new WeakMap,ta=new WeakMap,ea=new WeakMap,sa=new WeakMap,ia=new WeakMap,na=new WeakMap,aa=new WeakMap,ra=new WeakSet;class oa extends Jn{constructor(t){let{docId:e,ownerDocument:s=globalThis.document}=t;super(),b(this,ra),w(this,Zn,void 0),w(this,ta,void 0),w(this,ea,void 0),w(this,sa,void 0),w(this,ia,void 0),w(this,na,void 0),w(this,aa,0),y(sa,this,e),y(ia,this,s)}addFilter(t){var e,s;if(!t)return"none";let i=A(ra,this,ha).get(t);if(i)return i;const[n,a,r]=E(ra,this,da).call(this,t),o=1===t.length?n:`${n}${a}${r}`;if(i=A(ra,this,ha).get(o),i)return A(ra,this,ha).set(t,i),i;const h=`g_${_(sa,this)}_transfer_map_${y(aa,this,(e=_(aa,this),s=e++,e)),s}`,l=E(ra,this,ua).call(this,h);A(ra,this,ha).set(t,l),A(ra,this,ha).set(o,l);const c=E(ra,this,fa).call(this,h);return E(ra,this,ba).call(this,n,a,r,c),l}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let n=A(ra,this,la).get(i);if(n?.key===s)return n.url;if(n?(n.filter?.remove(),n.key=s,n.url="none",n.filter=null):(n={key:s,url:"none",filter:null},A(ra,this,la).set(i,n)),!t||!e)return n.url;const a=E(ra,this,va).call(this,t);t=Et.makeHexColor(...a);const r=E(ra,this,va).call(this,e);if(e=Et.makeHexColor(...r),A(ra,this,ca).style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const h=o.join(","),l=`g_${_(sa,this)}_hcm_filter`,c=n.filter=E(ra,this,fa).call(this,l);E(ra,this,ba).call(this,h,h,h,c),E(ra,this,ga).call(this,c);const d=(t,e)=>{const s=a[t]/255,i=r[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=s+t/e*(i-s);return n.join(",")};return E(ra,this,ba).call(this,d(0,5),d(1,5),d(2,5),c),n.url=E(ra,this,ua).call(this,l),n.url}addAlphaFilter(t){var e,s;let i=A(ra,this,ha).get(t);if(i)return i;const[n]=E(ra,this,da).call(this,[t]),a=`alpha_${n}`;if(i=A(ra,this,ha).get(a),i)return A(ra,this,ha).set(t,i),i;const r=`g_${_(sa,this)}_alpha_map_${y(aa,this,(e=_(aa,this),s=e++,e)),s}`,o=E(ra,this,ua).call(this,r);A(ra,this,ha).set(t,o),A(ra,this,ha).set(a,o);const h=E(ra,this,fa).call(this,r);return E(ra,this,wa).call(this,n,h),o}addLuminosityFilter(t){var e,s;let i,n,a=A(ra,this,ha).get(t||"luminosity");if(a)return a;if(t?([i]=E(ra,this,da).call(this,[t]),n=`luminosity_${i}`):n="luminosity",a=A(ra,this,ha).get(n),a)return A(ra,this,ha).set(t,a),a;const r=`g_${_(sa,this)}_luminosity_map_${y(aa,this,(e=_(aa,this),s=e++,e)),s}`,o=E(ra,this,ua).call(this,r);A(ra,this,ha).set(t,o),A(ra,this,ha).set(n,o);const h=E(ra,this,fa).call(this,r);return E(ra,this,pa).call(this,h),t&&E(ra,this,wa).call(this,i,h),o}addHighlightHCMFilter(t,e,s,i,n){const a=`${e}-${s}-${i}-${n}`;let r=A(ra,this,la).get(t);if(r?.key===a)return r.url;if(r?(r.filter?.remove(),r.key=a,r.url="none",r.filter=null):(r={key:a,url:"none",filter:null},A(ra,this,la).set(t,r)),!e||!s)return r.url;const[o,h]=[e,s].map(E(ra,this,va).bind(this));let l=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[d,u]=[i,n].map(E(ra,this,va).bind(this));c<l&&([l,c,d,u]=[c,l,u,d]),A(ra,this,ca).style.color="";const p=(t,e,s)=>{const i=new Array(256),n=(c-l)/s,a=t/255,r=(e-t)/(255*s);let o=0;for(let t=0;t<=s;t++){const e=Math.round(l+t*n),s=a+t*r;for(let t=o;t<=e;t++)i[t]=s;o=e+1}for(let t=o;t<256;t++)i[t]=i[o-1];return i.join(",")},g=`g_${_(sa,this)}_hcm_${t}_filter`,f=r.filter=E(ra,this,fa).call(this,g);return E(ra,this,ga).call(this,f),E(ra,this,ba).call(this,p(d[0],u[0],5),p(d[1],u[1],5),p(d[2],u[2],5),f),r.url=E(ra,this,ua).call(this,g),r.url}destroy(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&_(na,this)?.size||(_(ea,this)?.parentNode.parentNode.remove(),y(ea,this,null),_(ta,this)?.clear(),y(ta,this,null),_(na,this)?.clear(),y(na,this,null),y(aa,this,0))}}function ha(t){return _(ta,t)||y(ta,t,new Map)}function la(t){return _(na,t)||y(na,t,new Map)}function ca(t){if(!_(ea,t)){const e=_(ia,t).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=_(ia,t).createElementNS(Dt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),y(ea,t,_(ia,t).createElementNS(Dt,"defs")),e.append(i),i.append(_(ea,t)),_(ia,t).body.append(e)}return _(ea,t)}function da(t){if(1===t.length){const e=t[0],s=new Array(256);for(let t=0;t<256;t++)s[t]=e[t]/255;const i=s.join(",");return[i,i,i]}const[e,s,i]=t,n=new Array(256),a=new Array(256),r=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,a[t]=s[t]/255,r[t]=i[t]/255;return[n.join(","),a.join(","),r.join(",")]}function ua(t){if(void 0===_(Zn,this)){y(Zn,this,"");const t=_(ia,this).URL;t!==_(ia,this).baseURI&&(Wt(t)?pt('#createUrl: ignore "data:"-URL for performance reasons.'):y(Zn,this,t.split("#",1)[0]))}return`url(${_(Zn,this)}#${t})`}function pa(t){const e=_(ia,this).createElementNS(Dt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}function ga(t){const e=_(ia,this).createElementNS(Dt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}function fa(t){const e=_(ia,this).createElementNS(Dt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),A(ra,this,ca).append(e),e}function ma(t,e,s){const i=_(ia,this).createElementNS(Dt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}function ba(t,e,s,i){const n=_(ia,this).createElementNS(Dt,"feComponentTransfer");i.append(n),E(ra,this,ma).call(this,n,"feFuncR",t),E(ra,this,ma).call(this,n,"feFuncG",e),E(ra,this,ma).call(this,n,"feFuncB",s)}function wa(t,e){const s=_(ia,this).createElementNS(Dt,"feComponentTransfer");e.append(s),E(ra,this,ma).call(this,s,"feFuncA",t)}function va(t){return A(ra,this,ca).style.color=t,Xt(getComputedStyle(A(ra,this,ca)).getPropertyValue("color"))}class Aa{constructor(t){let{baseUrl:e=null}=t;this.baseUrl=e}async fetch(t){let{filename:e}=t;if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const s=`${this.baseUrl}${e}`;return this._fetch(s).catch((t=>{throw new Error(`Unable to load font data at: ${s}`)}))}async _fetch(t){gt("Abstract method `_fetch` called.")}}class _a extends Aa{async _fetch(t){const e=await Ft(t,"arraybuffer");return new Uint8Array(e)}}class ya{constructor(t){let{baseUrl:e=null}=t;this.baseUrl=e}async fetch(t){let{filename:e}=t;if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!e)throw new Error("Wasm filename must be specified.");const s=`${this.baseUrl}${e}`;return this._fetch(s).catch((t=>{throw new Error(`Unable to load wasm data at: ${s}`)}))}async _fetch(t){gt("Abstract method `_fetch` called.")}}class xa extends ya{async _fetch(t){const e=await Ft(t,"arraybuffer");return new Uint8Array(e)}}async function Ea(t){const e=process.getBuiltinModule("fs"),s=await e.promises.readFile(t);return new Uint8Array(s)}M&&pt("Please use the `legacy` build in Node.js environments.");class Sa extends Jn{}class ka extends Xn{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("file:///overleaf/node_modules/pdfjs-dist/build/pdf.mjs")("@napi-rs/canvas").createCanvas(t,e)}}class Ma extends Kn{async _fetch(t){return Ea(t)}}class Ca extends Aa{async _fetch(t){return Ea(t)}}class Ta extends ya{async _fetch(t){return Ea(t)}}const Ra="Fill",Pa="Stroke",Ia="Shading";function La(t,e){if(!e)return;const s=e[2]-e[0],i=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],s,i),t.clip(n)}class Da{isModifyingCurrentTransform(){return!1}getPattern(){gt("Abstract method `getPattern` called.")}}class Na extends Da{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;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,s,i){let n;if(i===Pa||i===Ra){const a=e.current.getClippedPathBoundingBox(i,Yt(t))||[0,0,0,0],r=M
vendor: 4,635 bytes, line 2
2ath.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,h=e.cachedCanvases.getCanvas("pattern",r,o),l=h.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-a[0],-a[1]),s=Et.transform(s,[1,0,0,1,a[0],a[1]]),l.transform(...e.baseTransform),this.matrix&&l.transform(...this.matrix),La(l,this._bbox),l.fillStyle=this._createGradient(l),l.fill(),n=t.createPattern(h.canvas,"no-repeat");const c=new DOMMatrix(s);n.setTransform(c)}else La(t,this._bbox),n=this._createGradient(t);return n}}function Fa(t,e,s,i,n,a,r,o){const h=e.coords,l=e.colors,c=t.data,d=4*t.width;let u;h[s+1]>h[i+1]&&(u=s,s=i,i=u,u=a,a=r,r=u),h[i+1]>h[n+1]&&(u=i,i=n,n=u,u=r,r=o,o=u),h[s+1]>h[i+1]&&(u=s,s=i,i=u,u=a,a=r,r=u);const p=(h[s]+e.offsetX)*e.scaleX,g=(h[s+1]+e.offsetY)*e.scaleY,f=(h[i]+e.offsetX)*e.scaleX,m=(h[i+1]+e.offsetY)*e.scaleY,b=(h[n]+e.offsetX)*e.scaleX,w=(h[n+1]+e.offsetY)*e.scaleY;if(g>=w)return;const v=l[a],A=l[a+1],_=l[a+2],y=l[r],x=l[r+1],E=l[r+2],S=l[o],k=l[o+1],M=l[o+2],C=Math.round(g),T=Math.round(w);let R,P,I,L,D,N,F,O;for(let t=C;t<=T;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);R=p-(p-f)*e,P=v-(v-y)*e,I=A-(A-x)*e,L=_-(_-E)*e}else{let e;e=t>w?1:m===w?0:(m-t)/(m-w),R=f-(f-b)*e,P=y-(y-S)*e,I=x-(x-k)*e,L=E-(E-M)*e}let e;e=t<g?0:t>w?1:(g-t)/(g-w),D=p-(p-b)*e,N=v-(v-S)*e,F=A-(A-k)*e,O=_-(_-M)*e;const s=Math.round(Math.min(R,D)),i=Math.round(Math.max(R,D));let n=d*t+4*s;for(let t=s;t<=i;t++)e=(R-t)/(R-D),e<0?e=0:e>1&&(e=1),c[n++]=P-(P-N)*e|0,c[n++]=I-(I-F)*e|0,c[n++]=L-(L-O)*e|0,c[n++]=255}}function Oa(t,e,s){const i=e.coords,n=e.colors;let a,r;switch(e.type){case"lattice":const o=e.verticesPerRow,h=Math.floor(i.length/o)-1,l=o-1;for(a=0;a<h;a++){let e=a*o;for(let a=0;a<l;a++,e++)Fa(t,s,i[e],i[e+1],i[e+o],n[e],n[e+1],n[e+o]),Fa(t,s,i[e+o+1],i[e+1],i[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(a=0,r=i.length;a<r;a+=3)Fa(t,s,i[a],i[a+1],i[a+2],n[a],n[a+1],n[a+2]);break;default:throw new Error("illegal figure")}}class Wa extends Da{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-i,r=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),h=Math.min(Math.ceil(Math.abs(r*t[1]*1.1)),3e3),l=a/o,c=r/h,d={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-n,scaleX:1/l,scaleY:1/c},u=o+4,p=h+4,g=s.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,h);if(e){const t=m.data;for(let s=0,i=t.length;s<i;s+=4)t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=255}for(const t of this._figures)Oa(m,t,d);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:i-2*l,offsetY:n-2*c,scaleX:l,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){let n;if(La(t,this._bbox),i===Ia)n=Et.singularValueDecompose2dScale(Yt(t));else if(n=Et.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=Et.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const a=this._createMeshCanvas(n,i===Ia?null:this._background,e.cachedCanvases);return i!==Ia&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class Ba extends Da{getPattern(){return"hotpink"}}const Ha=1,$a=2;class Ua{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i}createPatternCanvas(t){const{bbox:e,operatorList:s,paintType:i,tilingType:n,color:a,canvasGraphicsFactory:r}=this;let{xstep:o,ystep:h}=this;o=Math.abs(o),h=Math.abs(h),ut("TilingType: "+n);const l=e[0],c=e[1],d=e[2],u=e[3],p=d-l,g=u-c,f=Et.singularValueDecompose2dScale(this.matrix),m=Et.singularValueDecompose2dScale(this.baseTransform),b=f[0]*m[0],w=f[1]*m[1];let v=p,A=g,_=!1,y=!1;const x=Math.ceil(o*b),E=Math.ceil(h*w);x>=Math.ceil(p*b)?v=o:_=!0,E>=Math.ceil(g*w)?A=h:y=!0;const S=this.getSizeAndScale(v,this.ctx.canvas.width,b),k=this.getSizeAndScale(A,this.ctx.canvas.height,w),M=t.cachedCanvases.getCanvas("pattern",S.size,k.size),C=M.context,T=r.createCanvasGraphics(C);if(T.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(T,i,a),C.translate(-S.scale*l,-k.scale*c),T.transform(S.scale,0,0,k.scale,0,0),C.save(),this.clipBbox(T,l,c,d,u),T.baseTransform=Yt(T.ctx),T.executeOperatorList(s),T.endDrawing(),C.restore(
2),_||y){const e=M.canvas;_&&(v=o),y&&(A=h);const s=this.getSizeAndScale(v,this.ctx.canvas.width,b),i=this.getSizeAndScale(A,this.ctx.canvas.height,w),n=s.size,a=i.size,r=t.cachedCanvases.getCanvas("pattern-workaround",n,a),d=r.context,u=_?Math.floor(p/o):0,f=y?Math.floor(g/h):0;for(let t=0;t<=u;t++)for(let s=0;s<=f;s++)d.drawImage(e,n*t,a*s,n,a,0,0,n,a);return{canvas:r.canvas,scaleX:s.scale,scaleY:i.scale,offsetX:l,offsetY:c}}return{canvas:M.canvas,scaleX:S.scale,scaleY:k.scale,offsetX:l,offsetY:c}}getSizeAndScale(t,e,s){const i=Math.max(Ua.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 a=i-e,r=n-s;t.ctx.rect(e,s,a,r),t.current.updateRectMinMax(Yt(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case Ha:const t=this.ctx;i.fillStyle=t.fillStyle,i.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case $a:const a=Et.makeHexColor(s[0],s[1],s[2]);i.fillStyle=a,i.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new FormatError(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i){let n=s;i!==Ia&&(n=Et.transform(n,e.baseTransform),this.matrix&&(n=Et.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let r=new DOMMatrix(n);r=r.translate(a.offsetX,a.offsetY),r=r.scale(1/a.scaleX,1/a.scaleY);const o=t.createPattern(a.canvas,"repeat");return o.setTransform(r),o}}function za(t){let{src:e,srcPos:s=0,dest:i,width:n,height:a,nonBlackColor:r=4294967295,inverseDecode:o=!1}=t;const h=yt.isLittleEndian?4278190080:255,[l,c]=o?[r,h]:[h,r],d=n>>3,u=7&n,p=e.length;i=new Uint32Array(i.buffer);let g=0;for(let t=0;t<a;t++){for(const t=s+d;s<t;s++){const t=s<p?e[s]:255;i[g++]=128&t?c:l,i[g++]=64&t?c:l,i[g++]=32&t?c:l,i[g++]=16&t?c:l,i[g++]=8&t?c:l,i[g++]=4&t?c:l,i[g++]=2&t?c:l,i[g++]=1&t?c:l}if(0===u)continue;const t=s<p?e[s++]:255;for(let e=0;e<u;e++)i[g++]=t&1<<7-e?c:l}return{srcPos:s,destPos:g}}const ja=16,Ga=new DOMMatrix;class Va{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return void 0!==this.cache[t]?(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 qa(t,e,s,i,n,a,r,o,h,l){const[c,d,u,p,g,f]=Yt(t);if(0===d&&0===u){const m=r*c+g,b=Math.round(m),w=o*p+f,v=Math.round(w),A=(r+h)*c+g,_=Math.abs(Math.round(A)-b)||1,y=(o+l)*p+f,x=Math.abs(Math.round(y)-v)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),b,v),t.drawImage(e,s,i,n,a,0,0,_,x),t.setTransform(c,d,u,p,g,f),[_,x]}if(0===c&&0===p){const m=o*u+g,b=Math.round(m),w=r*d+f,v=Math.round(w),A=(o+l)*u+g,_=Math.abs(Math.round(A)-b)||1,y=(r+h)*d+f,x=Math.abs(Math.round(y)-v)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,b,v),t.drawImage(e,s,i,n,a,0,0,x,_),t.setTransform(c,d,u,p,g,f),[x,_]}t.drawImage(e,s,i,n,a,r,o,h,l);return[Math.hypot(c,d)*h,Math.hypot(u,p)*l]}class Xa{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=C,this.textMatrixScale=1,this.fontMatrix=T,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=z,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}updateRectMinMax(t,e){const s=Et.applyTransform(e,t),i=Et.applyTransform(e.slice(2),t),n=Et.applyTransform([e[0],e[3]],t),a=Et.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],a[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],a[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],a[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],a[1])}getPathBoundingBox(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ra,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Pa){e||gt("Stroke bounding box must include transform.");const t=Et.singularValueDecompose2dScale(e),i=t[0]*this.lineWidth/2,n=t[1]*this.lineWidth/2;s[0]-=i,s[1]-=n,s[2]+=i,s[3]+=n}return s}updateClipFromPath(){const t=Et.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(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ra,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Et.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Ya(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const s=e.height,i=e.width,n=s%ja,a=(s-n)/ja,r=0===n?a:a+1,o=t.createImageData(i,ja);let h,l=0;const c=e.data,d=o.data;let u,p,g,f;if(e.kind===Y.GRAYSCALE_1BPP){const e=c.byteLength,s=new Uint32Array(d.buffer,0,d.byteLength>>2),f=s.length,m=i+7>>3,b=4294967295,w=yt.isLittleEndian?4278190080:255;for(u=0;
2u<r;u++){for(g=u<a?ja:n,h=0,p=0;p<g;p++){const t=e-l;let n=0;const a=t>m?i:8*t-7,r=-8&a;let o=0,d=0;for(;n<r;n+=8)d=c[l++],s[h++]=128&d?b:w,s[h++]=64&d?b:w,s[h++]=32&d?b:w,s[h++]=16&d?b:w,s[h++]=8&d?b:w,s[h++]=4&d?b:w,s[h++]=2&d?b:w,s[h++]=1&d?b:w;for(;n<a;n++)0===o&&(d=c[l++],o=128),s[h++]=d&o?b:w,o>>=1}for(;h<f;)s[h++]=0;t.putImageData(o,0,u*ja)}}else if(e.kind===Y.RGBA_32BPP){for(p=0,f=i*ja*4,u=0;u<a;u++)d.set(c.subarray(l,l+f)),l+=f,t.putImageData(o,0,p),p+=ja;u<r&&(f=i*n*4,d.set(c.subarray(l,l+f)),t.putImageData(o,0,p))}else{if(e.kind!==Y.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=ja,f=i*g,u=0;u<r;u++){for(u>=a&&(g=n,f=i*g),h=0,p=f;p--;)d[h++]=c[l++],d[h++]=c[l++],d[h++]=c[l++],d[h++]=255;t.putImageData(o,0,u*ja)}}}function Ka(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const s=e.height,i=e.width,n=s%ja,a=(s-n)/ja,r=0===n?a:a+1,o=t.createImageData(i,ja);let h=0;const l=e.data,c=o.data;for(let e=0;e<r;e++){const s=e<a?ja:n;({srcPos:h}=za({src:l,srcPos:h,dest:c,width:i,height:s,nonBlackColor:0})),t.putImageData(o,0,e*ja)}}function Qa(t,e){const s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const i of s)void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function Ja(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!M){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function Za(t,e){if(e)return!0;const s=Et.singularValueDecompose2dScale(t);s[0]=Math.fround(s[0]),s[1]=Math.fround(s[1]);const i=Math.fround(Jt.pixelRatio*Nt.PDF_TO_CSS_UNITS);return s[0]<=i&&s[1]<=i}const tr=["butt","round","square"],er=["miter","round","bevel"],sr={},ir={};var nr=new WeakSet;class ar{constructor(t,e,s,i,n,a,r,o){let{optionalContentConfig:h,markedContentStack:l=null}=a;b(this,nr),this.ctx=t,this.current=new Xa(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=l||[],this.optionalContentConfig=h,this.cachedCanvases=new Va(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=r,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=o,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing(t){let{transform:e,viewport:s,transparency:i=!1,background:n=null}=t;const a=this.ctx.canvas.width,r=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,a,r),this.ctx.fillStyle=o,i){const t=this.cachedCanvases.getCanvas("transparent",a,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Yt(this.compositeCtx))}this.ctx.save(),Ja(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...s.transform),this.viewportScale=s.scale,this.baseTransform=Yt(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,a=t.fnArray;let r=e||0;const o=n.length;if(o===r)return r;const h=o-r>10&&"function"==typeof s,l=h?Date.now()+15:0;let c=0;const d=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==i&&r===i.nextBreakPoint)return i.breakIt(r,s),r;if(p=a[r],p!==it.dependency)this[p].apply(this,n[r]);else for(const t of n[r]){const e=t.startsWith("g_")?d:u;if(!e.has(t))return e.get(t,s),r}if(r++,r===o)return r;if(h&&++c>10){if(Date.now()>l)return s(),r;c=0}}}endDrawing(){E(nr,this,rr).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),E(nr,this,or).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let n,a,r=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),h=s,l=i,c="prescale1";for(;r>2&&h>1||o>2&&l>1;){let e=h,s=l;r>2&&h>1&&(e=h>
2=16384?Math.floor(h/2)-1||1:Math.ceil(h/2),r/=h/e),o>2&&l>1&&(s=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,o/=l/s),n=this.cachedCanvases.getCanvas(c,e,s),a=n.context,a.clearRect(0,0,e,s),a.drawImage(t,0,0,h,l,0,0,e,s),t=n.canvas,h=e,l=s,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:h,paintHeight:l}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,a=this.current.patternFill,r=Yt(e);let o,h,l,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;h=JSON.stringify(a?r:[r.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const s=o.get(h);if(s&&!a){return{canvas:s,offsetX:Math.round(Math.min(r[0],r[2])+r[4]),offsetY:Math.round(Math.min(r[1],r[3])+r[5])}}l=s}l||(c=this.cachedCanvases.getCanvas("maskCanvas",s,i),Ka(c.context,t));let d=Et.transform(r,[1/s,0,0,-1/i,0,0]);d=Et.transform(d,[1,0,0,1,0,-i]);const[u,p,g,f]=Et.getAxialAlignedBoundingBox([0,0,s,i],d),m=Math.round(g-u)||1,b=Math.round(f-p)||1,w=this.cachedCanvases.getCanvas("fillCanvas",m,b),v=w.context,A=u,_=p;v.translate(-A,-_),v.transform(...d),l||(l=this._scaleImage(c.canvas,Kt(v)),l=l.img,o&&a&&o.set(h,l)),v.imageSmoothingEnabled=Za(Yt(v),t.interpolate),qa(v,l,0,0,l.width,l.height,0,0,s,i),v.globalCompositeOperation="source-in";const y=Et.transform(Kt(v),[1,0,0,1,-A,-_]);return v.fillStyle=a?n.getPattern(e,this,y,Ra):n,v.fillRect(0,0,s,i),o&&!a&&(this.cachedCanvases.delete("fillCanvas"),o.set(h,w.canvas)),{canvas:w.canvas,offsetX:Math.round(A),offsetY:Math.round(_)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=tr[t]}setLineJoin(t){this.ctx.lineJoin=er[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;void 0!==s.setLineDash&&(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.ctx.globalAlpha=this.current.fillAlpha=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)}}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;const n=this.ctx=i.context;n.setTransform(this.suspendedCtx.getTransform()),Qa(this.suspendedCtx,n),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()}
2,t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,s){e.translate(t,s),this.__originalTranslate(t,s)},t.scale=function(t,s){e.scale(t,s),this.__originalScale(t,s)},t.transform=function(t,s,i,n,a,r){e.transform(t,s,i,n,a,r),this.__originalTransform(t,s,i,n,a,r)},t.setTransform=function(t,s,i,n,a,r){e.setTransform(t,s,i,n,a,r),this.__originalSetTransform(t,s,i,n,a,r)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,s){e.moveTo(t,s),this.__originalMoveTo(t,s)},t.lineTo=function(t,s){e.lineTo(t,s),this.__originalLineTo(t,s)},t.bezierCurveTo=function(t,s,i,n,a,r){e.bezierCurveTo(t,s,i,n,a,r),this.__originalBezierCurveTo(t,s,i,n,a,r)},t.rect=function(t,s,i,n){e.rect(t,s,i,n),this.__originalRect(t,s,i,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Qa(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],a=i[1],r=i[2]-n,o=i[3]-a;0!==r&&0!==o&&(this.genericComposeSMask(e.context,s,r,o,e.subtype,e.backdrop,e.transferMap,n,a,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,a,r,o,h,l,c){let d=t.canvas,u=o-l,p=h-c;if(a){const e=Et.makeHexColor(...a);if(u<0||p<0||u+s>d.width||p+i>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",s,i),n=t.context;n.drawImage(d,-u,-p),n.globalCompositeOperation="destination-atop",n.fillStyle=e,n.fillRect(0,0,s,i),n.globalCompositeOperation="source-over",d=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const n=new Path2D;n.rect(u,p,s,i),t.clip(n),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&r?e.filter=this.filterFactory.addAlphaFilter(r):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(r));const g=new Path2D;g.rect(o,h,s,i),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,s,i,o,h,s,i),e.restore()}save(){this.inSMaskMode&&Qa(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Qa(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,s,i,n,a){this.ctx.transform(t,e,s,i,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){let[i]=e;if(!s)return i||=e[0]=new Path2D,void this[t](i);if(!(i instanceof Path2D)){const t=e[0]=new Path2D;for(let e=0,s=i.length;e<s;)switch(i[e++]){case nt:t.moveTo(i[e++],i[e++]);break;case at:t.lineTo(i[e++],i[e++]);break;case rt:t.bezierCurveTo(i[e++],i[e++],i[e++],i[e++],i[e++],i[e++]);break;case ot:t.closePath();break;default:pt(`Unrecognized drawing path operator: ${i[e-1]}`)}i=t}this.current.updateRectMinMax(Yt(this.ctx),s),this[t](i)}closePath(){this.ctx.closePath()}stroke(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const s=this.ctx,i=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof i&&i?.getPattern){const e=i.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=i.getPattern(s,this,Kt(s),Pa),e){const i=new Path2D;i.addPath(t,s.getTransform().invertSelf().multiplySelf(e)),t=i}
2this.rescaleAndStroke(t,!1),s.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(Pa,Yt(this.ctx))),s.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const s=this.ctx,i=this.current.fillColor;let n=!1;if(this.current.patternFill){const e=i.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.fillStyle=i.getPattern(s,this,Kt(s),Ra),e){const i=new Path2D;i.addPath(t,s.getTransform().invertSelf().multiplySelf(e)),t=i}n=!0}const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(s.fill(t,"evenodd"),this.pendingEOFill=!1):s.fill(t)),n&&s.restore(),e&&this.consumePath(t,a)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}clip(){this.pendingClip=sr}eoClip(){this.pendingClip=ir}beginText(){this.current.textMatrix=C,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(void 0===t)return void e.beginPath();const s=new Path2D,i=e.getTransform().invertSelf();for(const{transform:e,x:n,y:a,fontSize:r,path:o}of t)s.addPath(o,new DOMMatrix(e).preMultiplySelf(i).translate(n,a).scale(r,-r));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){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||T,0!==i.fontMatrix[0]&&0!==i.fontMatrix[3]||pt("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",a=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`;let r="normal";s.black?r="900":s.bold&&(r="bold");const o=s.italic?"italic":"normal";let h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font=`${o} ${r} ${h}px ${a}`}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,a){this.current.textMatrix=[t,e,s,i,n,a],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 a=this.ctx,r=this.current,o=r.font,h=r.textRenderingMode,l=r.fontSize/r.fontSizeScale,c=h&q,d=!!(h&X),u=r.patternFill&&!o.missingFile,p=r.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||d||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p){let t;if(a.save(),a.translate(e,s),a.scale(l,-l),c!==z&&c!==G||(i?(t=a.getTransform(),a.setTransform(...i),a.fill(E(nr,this,hr).call(this,g,t,i))):a.fill(g)),c===j||c===G)if(n){t||=a.getTransform(),a.setTransform(...n);const{a:e,b:s,c:i,d:r}=t,o=Et.inverseTransform(n),h=Et.transform([e,s,i,r,0,0],o),[c,d]=Et.singularValueDecompose2dScale(h);a.lineWidth*=Math.max(c,d)/l,a.stroke(E(nr,this,hr).call(this,g,t,n))}else a.lineWidth/=l,a.stroke(g);a.restore()}else c!==z&&c!==G||a.fillText(t,e,s),c!==j&&c!==G||a.strokeText(t,e,s);if(d){(this.pendingTextPaths||=[]).push({transform:Yt(a),x:e,y:s,fontSize:l,path:g})}}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 t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){s=!0;break}return bt(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(0===i)return;const n=this.ctx,a=e.fontSizeScale,r=e.charSpacing,o=e.wordSpacing,h=e.fontDirection,l=e.textHScale*h,c=t.length,d=s.vertical,u=d?1:-1,p=s.defaultVMetrics,g=i*e.fontMatrix[0],f=e.textRenderingMode===z&&!s.disableFontFace&&!e.patternFill;let m,b;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),h>0?n.scale(l,-1):n.scale(l,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,Kt(n),Ra);
2m=Yt(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,Kt(n),Pa);b=Yt(n),n.restore(),n.strokeStyle=t}let w=e.lineWidth;const v=e.textMatrixScale;if(0===v||0===w){const t=e.textRenderingMode&q;t!==j&&t!==G||(w=this.getSinglePixelWidth())}else w/=v;if(1!==a&&(n.scale(a,a),w/=a),n.lineWidth=w,s.isInvalidPDFjsFont){const s=[];let i=0;for(const e of t)s.push(e.unicode),i+=e.width;return n.fillText(s.join(""),0,0),e.x+=i*g*l,n.restore(),void this.compose()}let A,_=0;for(A=0;A<c;++A){const e=t[A];if("number"==typeof e){_+=u*e*i/1e3;continue}let l=!1;const c=(e.isSpace?o:0)+r,w=e.fontChar,v=e.accent;let y,x,E=e.width;if(d){const t=e.vmetric||p,s=-(e.vmetric?t[1]:.5*E)*g,i=t[2]*g;E=t?-t[0]:E,y=s/a,x=(_+i)/a}else y=_/a,x=0;if(s.remeasure&&E>0){const t=1e3*n.measureText(w).width/i*a;if(E<t&&this.isFontSubpixelAAEnabled){const e=E/t;l=!0,n.save(),n.scale(e,1),y/=e}else E!==t&&(y+=(E-t)/2e3*i/a)}if(this.contentVisible&&(e.isInFont||s.missingFile))if(f&&!v)n.fillText(w,y,x);else if(this.paintChar(w,y,x,m,b),v){const t=y+i*v.offset.x/a,e=x-i*v.offset.y/a;this.paintChar(v.fontChar,t,e,m,b)}_+=d?E*g-c*h:E*g+c*h,l&&n.restore()}d?e.y-=_:e.x+=_*l,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,a=s.fontDirection,r=i.vertical?1:-1,o=s.charSpacing,h=s.wordSpacing,l=s.textHScale*a,c=s.fontMatrix||T,d=t.length;let u,p,g,f;if(!(s.textRenderingMode===V)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...s.textMatrix),e.translate(s.x,s.y+s.textRise),e.scale(l,a),u=0;u<d;++u){if(p=t[u],"number"==typeof p){f=r*p*n/1e3,this.ctx.translate(f,0),s.x+=f*l;continue}const a=(p.isSpace?h:0)+o,d=i.charProcOperatorList[p.operatorListId];d?this.contentVisible&&(this.processingType3=p,this.save(),e.scale(n,n),e.transform(...c),this.executeOperatorList(d),this.restore()):pt(`Type3 character "${p.operatorListId}" is not available.`);g=Et.applyTransform([p.width,0],c)[0]*n+a,e.translate(g,0),s.x+=g*l}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,a){this.ctx.rect(s,i,n-s,a-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const s=this.baseTransform||Yt(this.ctx),i={createCanvasGraphics:t=>new ar(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ua(t,this.ctx,i,s)}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=Et.makeHexColor(t,e,s),this.current.patternStroke=!1}
2setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=Et.makeHexColor(t,e,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t){let e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.cachedPatterns.has(t)?e=this.cachedPatterns.get(t):(e=function(t){switch(t[0]){case"RadialAxial":return new Na(t);case"Mesh":return new Wa(t);case"Dummy":return new Ba}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,e)),s&&(e.matrix=s),e}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,Kt(e),Ia);const i=Kt(e);if(i){const{width:t,height:s}=e.canvas,[n,a,r,o]=Et.getAxialAlignedBoundingBox([0,0,t,s],i);this.ctx.fillRect(n,a,r-n,o-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){gt("Should not call beginInlineImage")}beginImageData(){gt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Yt(this.ctx),e)){const t=e[2]-e[0],s=e[3]-e[1];this.ctx.rect(e[0],e[1],t,s),this.current.updateRectMinMax(Yt(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;
2t.isolated||ut("TODO: Support non-isolated groups."),t.knockout&&pt("Knockout groups not supported.");const s=Yt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=Et.getAxialAlignedBoundingBox(t.bbox,Yt(e));const n=[0,0,e.canvas.width,e.canvas.height];i=Et.intersect(i,n)||[0,0,0,0];const a=Math.floor(i[0]),r=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-a,1),h=Math.max(Math.ceil(i[3])-r,1);this.current.startNewPathAndClipBox([0,0,o,h]);let l="groupAt"+this.groupLevel;t.smask&&(l+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(l,o,h),d=c.context;d.translate(-a,-r),d.transform(...s);let u=new Path2D;const[p,g,f,m]=t.bbox;if(u.rect(p,g,f-p,m-g),t.matrix){const e=new Path2D;e.addPath(u,new DOMMatrix(t.matrix)),u=e}d.clip(u),t.smask?this.smaskStack.push({canvas:c.canvas,context:d,offsetX:a,offsetY:r,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(a,r),e.save()),Qa(e,d),this.ctx=d,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 t=Yt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const s=Et.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotation(t,e,s,i,n){if(E(nr,this,rr).call(this),Ja(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const i=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0],s[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=i,e[3]=a;const[n,r]=Et.singularValueDecompose2dScale(Yt(this.ctx)),{viewportScale:o}=this,h=Math.ceil(i*this.outputScaleX*o),l=Math.ceil(a*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(h,l);const{canvas:c,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(t,c),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(n,0,0,-r,0,a*r),Ja(this.ctx)}else Ja(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],i,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new Xa(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),E(nr,this,or).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)).count=e;const s=this.ctx,i=this.processingType3;if(i&&(void 0===i.compiled&&(i.compiled=function(t){const{width:e,height:s}=t;if(e>1e3||s>1e3)return null;const i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1,a=new Uint8Array(n*(s+1));let r,o,h;const l=e+7&-8,c=new Uint8Array(l*s);let d=0;for(const e of t.data){let t=128;for(;t>0;)c[d++]=e&t?0:255,t>>=1}let u=0;for(d=0,0!==c[d]&&(a[0]=1,++u),o=1;o<e;o++)c[d]!==c[d+1]&&(a[o]=c[d]?2:1,++u),d++;for(0!==c[d]&&(a[o]=2,++u),r=1;r<s;r++){d=r*l,h=r*n,c[d-l]!==c[d]&&(a[h]=c[d]?1:8,++u);let t=(c[d]?4:0)+(c[d-l]?8:0);for(o=1;o<e;o++)t=(t>>2)+(c[d+1]?4:0)+(c[d-l+1]?8:0),i[t]&&(a[h+o]=i[t],++u),d++;if(c[d-l]!==c[d]&&(a[h+o]=c[d]?2:4,++u),u>1e3)return null}for(d=l*(s-1),h=r*n,0!==c[d]&&(a[h]=8,++u),o=1;o<e;o++)c[d]!==c[d+1]&&(a[h+o]=c[d]?4:8,++u),d++;if(0!==c[d]&&(a[h+o]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D,{a:f,b:m,c:b,d:w,e:v,f:A}=(new DOMMatrix).scaleSelf(1/e,-1/s).translateSelf(0,-s);for(r=0;u&&r<=s;r++){let t=r*n;const s=t+e;for(;t<s&&!a[t];)t++;if(t===s)continue;let i=t%n,o=r;g.moveTo(f*i+b*o+v,m*i+w*o+A);const h=t;let l=a[t];do{const e=p[l];do{t+=e}while(!a[t]);const s=a[t];5!==s&&10!==s?(l=s,a[t]=0):(l=s&51*l>>4,a[t]&=l>>2|l<<2),i=t%n,o=t/n|0,g.lineTo(f*i+b*o+v,m*i+w*o+A),a[t]||--u}while(h!==t);--r}return g}(t)),i.compiled))return void s.fill(i.compiled);const n=this._createMaskCanvas(t),a=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,n.offsetX,n.offsetY),s.restore(
2),this.compose()}paintImageMaskXObjectRepeat(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;if(!this.contentVisible)return;t=this.getObject(t.data,t);const r=this.ctx;r.save();const o=Yt(r);r.transform(e,s,i,n,0,0);const h=this._createMaskCanvas(t);r.setTransform(1,0,0,1,h.offsetX-o[4],h.offsetY-o[5]);for(let t=0,l=a.length;t<l;t+=2){const l=Et.transform(o,[e,s,i,n,a[t],a[t+1]]),[c,d]=Et.applyTransform([0,0],l);r.drawImage(h.canvas,c,d)}r.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:t,width:a,height:r,transform:o}=n,h=this.cachedCanvases.getCanvas("maskCanvas",a,r),l=h.context;l.save();Ka(l,this.getObject(t,n)),l.globalCompositeOperation="source-in",l.fillStyle=i?s.getPattern(l,this,Kt(e),Ra):s,l.fillRect(0,0,a,r),l.restore(),e.save(),e.transform(...o),e.scale(1,-1),qa(e,h.canvas,0,0,a,r,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):pt("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void pt("Dependent image isn't ready yet");const a=n.width,r=n.height,o=[];for(let t=0,n=i.length;t<n;t+=2)o.push({transform:[e,0,0,s,i[t],i[t+1]],x:0,y:0,w:a,h:r});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;if(this.save(),!M){const{filter:t}=i;"none"!==t&&""!==t&&(i.filter="none")}let n;if(i.scale(1/e,-1/s),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const i=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Ya(i,t),n=this.applyTransferMapsToCanvas(i)}const a=this._scaleImage(n,Kt(i));i.imageSmoothingEnabled=Za(Yt(i),t.interpolate),qa(i,a.img,0,0,a.paintWidth,a.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 e=t.width,s=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Ya(n,t),i=this.applyTransferMapsToCanvas(n)}for(const t of e)s.save(),s.transform(...t.transform),s.scale(1,-1),qa(s,i,t.x,t.y,t.w,t.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){"OC"===t?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,e){const s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const i=this.ctx;this.pendingClip&&(s||(this.pendingClip===ir?i.clip(t,"evenodd"):i.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Yt(this.ctx);if(0===t[1]&&0===t[2])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(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let a,r;if(0===s&&0===i){const s=Math.abs(e),i=Math.abs(n);if(s===i)if(0===t)a=r=1/s;else{const e=s*t;a=r=e<1?1/e:1}else if(0===t)a=1/s,r=1/i;else{const e=s*t,n=i*t;a=e<1?1/e:1,r=n<1?1/n:1}}else{const o=Math.abs(e*n-s*i),h=Math.hypot(e,s),l=Math.hypot(i,n);if(0===t)a=l/o,r=h/o;else{const e=t*o;a=l>e?l/e:1,r=h>e?h/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[n,a]=this.getScaleForStroking();if(n===a)return s.lineWidth=(i||1)*n,void s.stroke(t);const r=s.getLineDash();e&&s.save(),s.scale(n,a),Ga.a=1/n,Ga.d=1/a;const o=new Path2D;if(o.addPath(t,Ga),r.length>0){const t=Math.max(n,a);
2s.setLineDash(r.map((e=>e/t))),s.lineDashOffset/=t}s.lineWidth=i||1,s.stroke(o),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}function rr(){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)}function or(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}function hr(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i}for(const t in it)void 0!==ar.prototype[t]&&(ar.prototype[it[t]]=ar.prototype[t]);class lr{static#l=null;static#c="";static get workerPort(){return this.#l}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#l=t}static get workerSrc(){return this.#c}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#c=t}}class cr{#d;#u;constructor(t){let{parsedData:e,rawData:s}=t;this.#d=e,this.#u=s}getRaw(){return this.#u}get(t){return this.#d.get(t)??null}getAll(){return _t(this.#d)}has(t){return this.#d.has(t)}}const dr=Symbol("INTERNAL");class ur{#p=!1;#g=!1;#f=!1;#m=!0;constructor(t,e){let{name:s,intent:i,usage:n,rbGroups:a}=e;this.#p=!!(t&I),this.#g=!!(t&L),this.name=s,this.intent=i,this.usage=n,this.rbGroups=a}get visible(){if(this.#f)return this.#m;if(!this.#m)return!1;const{print:t,view:e}=this.usage;return this.#p?"OFF"!==e?.viewState:!this.#g||"OFF"!==t?.printState}_setVisible(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t!==dr&&gt("Internal method `_setVisible` called."),this.#f=s,this.#m=e}}var pr=new WeakMap,gr=new WeakMap,fr=new WeakMap,mr=new WeakMap,br=new WeakSet;class wr{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:I;if(b(this,br),w(this,pr,null),w(this,gr,new Map),w(this,fr,null),w(this,mr,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,y(mr,this,t.order);for(const s of t.groups)_(gr,this).set(s.id,new ur(e,s));if("OFF"===t.baseState)for(const t of _(gr,this).values())t._setVisible(dr,!1);for(const e of t.on)_(gr,this).get(e)._setVisible(dr,!0);for(const e of t.off)_(gr,this).get(e)._setVisible(dr,!1);y(fr,this,this.getHash())}}isVisible(t){if(0===_(gr,this).size)return!0;if(!t)return ut("Optional content group not defined."),!0;if("OCG"===t.type)return _(gr,this).has(t.id)?_(gr,this).get(t.id).visible:(pt(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return E(br,this,vr).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!_(gr,this).has(e))return pt(`Optional content group not found: ${e}`),!0;if(_(gr,this).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!_(gr,this).has(e))return pt(`Optional content group not found: ${e}`),!0;if(!_(gr,this).get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!_(gr,this).has(e))return pt(`Optional content group not found: ${e}`),!0;if(!_(gr,this).get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!_(gr,this).has(e))return pt(`Optional content group not found: ${e}`),!0;if(_(gr,this).get(e).visible)return!1}return!0}return pt(`Unknown optional content policy ${t.policy}.`),!0}return pt(`Unknown group type ${t.type}.`),!0}setVisibility(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const i=_(gr,this).get(t);if(i){if(s&&e&&i.rbGroups.length)for(const e of i.rbGroups)for(const s of e)s!==t&&_(gr,this).get(s)?._setVisible(dr,!1,!0);i._setVisible(dr,!!e,!0),y(pr,this,null)}else pt(`Optional content group not found: ${t}`)}setOCGState(t){let e,{state:s,preserveRB:i}=t;
2for(const t of s){switch(t){case"ON":case"OFF":case"Toggle":e=t;continue}const s=_(gr,this).get(t);if(s)switch(e){case"ON":this.setVisibility(t,!0,i);break;case"OFF":this.setVisibility(t,!1,i);break;case"Toggle":this.setVisibility(t,!s.visible,i)}}y(pr,this,null)}get hasInitialVisibility(){return null===_(fr,this)||this.getHash()===_(fr,this)}getOrder(){return _(gr,this).size?_(mr,this)?_(mr,this).slice():[..._(gr,this).keys()]:null}getGroups(){return _(gr,this).size>0?_t(_(gr,this)):null}getGroup(t){return _(gr,this).get(t)||null}getHash(){if(null!==_(pr,this))return _(pr,this);const t=new Sn;for(const[e,s]of _(gr,this))t.update(`${e}:${s.visible}`);return y(pr,this,t.hexdigest())}}function vr(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const e=t[i];let n;if(Array.isArray(e))n=E(br,this,vr).call(this,e);else{if(!_(gr,this).has(e))return pt(`Optional content group not found: ${e}`),!0;n=_(gr,this).get(e).visible}switch(s){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===s}class Ar{constructor(t,e){let{disableRange:s=!1,disableStream:i=!1}=e;ft(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:n,initialData:a,progressiveDone:r,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=o,a?.length>0){const t=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!s,this._contentLength=n,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData(t){let{begin:e,chunk:s}=t;const i=s instanceof Uint8Array&&s.byteLength===s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer;if(void 0===e)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{ft(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(i),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){ft(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new _r(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new yr(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class _r{constructor(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;this._stream=t,this._done=s||!1,this._filename=Bt(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else 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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class yr{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(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.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 t=this._queuedChunk;return this._queuedChunk=null,{value:t,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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function xr(t,e){const s=new Headers;if(!t||!e||"object"!=typeof e)return s;for(const t in e){const i=e[t];void 0!==i&&s.append(t,i)}return s}function Er(t){return URL.parse(t)?.origin??null}function Sr(t){let{responseHeaders:e,isHttp:s,rangeChunkSize:i,disableRange:n}=t;const a={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(e.get("Content-Length"),10);if(!Number.isInteger(r))return a;
vendor: 12,047 bytes, line 2
2if(a.suggestedLength=r,r<=2*i)return a;if(n||!s)return a;if("bytes"!==e.get("Accept-Ranges"))return a;return"identity"!==(e.get("Content-Encoding")||"identity")||(a.allowRangeRequests=!0),a}function kr(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,s=i("filename\\*","i").exec(t);if(s){s=s[1];let t=r(s);return t=unescape(t),t=o(t),t=h(t),a(t)}if(s=function(t){const e=[];let s;const n=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(s=n.exec(t));){let[,t,i,n]=s;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[i,n]}const a=[];for(let t=0;t<e.length&&t in e;++t){let[s,i]=e[t];i=r(i),s&&(i=unescape(i),0===t&&(i=o(i))),a.push(i)}return a.join("")}(t),s)return a(h(s));if(s=i("filename","i").exec(t),s){s=s[1];let t=r(s);return t=h(t),a(t)}function i(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,s){if(t){if(!/^[\x00-\xFF]+$/.test(s))return s;try{const i=new TextDecoder(t,{fatal:!0}),n=At(s);s=i.decode(n),e=!1}catch{}}return s}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function r(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const s=e[t].indexOf('"');-1!==s&&(e[t]=e[t].slice(0,s),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function h(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,s,i){if("q"===s||"Q"===s)return n(e,i=(i=i.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{i=atob(i)}catch{}return n(e,i)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Bt(t))return t}return null}function createResponseError(t,e){return new ResponseException(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function Mr(t){return 200===t||206===t}function Cr(t,e,s){return{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Tr(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(pt(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Rr{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=xr(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ft(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Pr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Ir(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Pr{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,Cr(s,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=Er(e.url),!Mr(e.status))throw createResponseError(e.status,i);this._reader=e.body.getReader(),this._headersCapability.resolve();const s=e.headers,{allowRangeRequests:n,suggestedLength:a}=Sr({responseHeaders:s,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=kr(s),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new AbortException("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Tr(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ir{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 a=i.url;fetch(a,Cr(n,this._withCredentials,this._abortController)).then((e=>{const s=Er(e.url);if(s!==t._responseOrigin)throw new Error(`Expected range response-origin "${s}" to match "${t._responseOrigin}".`);if(!Mr(e.status))throw createResponseError(e.status,a);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Tr(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Lr{_responseOrigin=null;constructor(t){let{url:e,httpHeaders:s,withCredentials:i}=t;this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=xr(this.isHttp,s),this.withCredentials=i||!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[t,s]of this.headers)e.setRequestHeader(t,s);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=206):i.expectedStatus=200,e.responseType="arraybuffer",ft(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){const s=this.pendingRequests[t];s&&s.onProgress?.(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),4!==i.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===i.status&&this.isHttp)return void s.onError(i.status);const n=i.status||200;if(!(200===n&&206===s.expectedStatus)&&n!==s.expectedStatus)return void s.onError(i.status);const a=function(t){const e=t.response;return"string"!=typeof e?e:At(e).buffer}(i);if(206===n){const t=i.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?s.onDone({begin:parseInt(e[1],10),chunk:a}):(pt('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 Dr{constructor(t){this._source=t,this._manager=new Lr(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 ft(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Nr(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Fr(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Nr{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=Er(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...s]=t.split(": ");return[e,s.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:a}=Sr({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=kr(i),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=createResponseError(t,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Fr{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(){const t=Er(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;
2if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=createResponseError(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Or=/^[a-z][a-z0-9\-+.]+:/i;class Wr{constructor(t){this.source=t,this.url=function(t){if(Or.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),ft("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ft(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Br(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Hr(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Br{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((t=>{this._contentLength=t.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=createResponseError(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Hr{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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const $r=30;var Ur=new WeakMap,zr=new WeakMap,jr=new WeakMap,Gr=new WeakMap,Vr=new WeakMap,qr=new WeakMap,Xr=new WeakMap,Yr=new WeakMap,Kr=new WeakMap,Qr=new WeakMap,Jr=new WeakMap,Zr=ne
2w WeakMap,to=new WeakMap,eo=new WeakMap,so=new WeakMap,io=new WeakMap,no=new WeakMap,ao=new WeakMap,ro=new WeakSet;class oo{constructor(t){let{textContentSource:e,container:s,viewport:i}=t;if(b(this,ro),w(this,Ur,Promise.withResolvers()),w(this,zr,null),w(this,jr,!1),w(this,Gr,!!globalThis.FontInspector?.enabled),w(this,Vr,null),w(this,qr,null),w(this,Xr,0),w(this,Yr,0),w(this,Kr,null),w(this,Qr,null),w(this,Jr,0),w(this,Zr,0),w(this,to,Object.create(null)),w(this,eo,[]),w(this,so,null),w(this,io,[]),w(this,no,new WeakMap),w(this,ao,null),e instanceof ReadableStream)y(so,this,e);else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');y(so,this,new ReadableStream({start(t){t.enqueue(e),t.close()}}))}y(zr,this,y(Qr,this,s)),y(Zr,this,i.scale*Jt.pixelRatio),y(Jr,this,i.rotation),y(qr,this,{div:null,properties:null,ctx:null});const{pageWidth:n,pageHeight:a,pageX:r,pageY:o}=i.rawDims;y(ao,this,[1,0,0,-1,-r,o+a]),y(Yr,this,n),y(Xr,this,a),go.call(oo),Qt(s,i),_(Ur,this).promise.finally((()=>{Ao._.delete(this),y(qr,this,null),y(to,this,null)})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=yt.platform;return bt(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{_(Kr,this).read().then((e=>{let{value:s,done:i}=e;i?_(Ur,this).resolve():(_(Vr,this)??y(Vr,this,s.lang),Object.assign(_(to,this),s.styles),E(ro,this,ho).call(this,s.items),t())}),_(Ur,this).reject)};return y(Kr,this,_(so,this).getReader()),Ao._.add(this),t(),_(Ur,this).promise}update(t){let{viewport:e,onBefore:s=null}=t;const i=e.scale*Jt.pixelRatio,n=e.rotation;if(n!==_(Jr,this)&&(s?.(),y(Jr,this,n),Qt(_(Qr,this),{rotation:n})),i!==_(Zr,this)){s?.(),y(Zr,this,i);const t={div:null,properties:null,ctx:uo.call(oo,_(Vr,this))};for(const e of _(io,this))t.properties=_(no,this).get(e),t.div=e,E(ro,this,co).call(this,t)}}cancel(){const t=new AbortException("TextLayer task cancelled.");_(Kr,this)?.cancel(t).catch((()=>{})),y(Kr,this,null),_(Ur,this).reject(t)}get textDivs(){return _(io,this)}get textContentItemsStr(){return _(eo,this)}static cleanup(){if(!(E(oo,this,Ao)._.size>0)){E(oo,this,mo)._.clear();for(const{canvas:t}of E(oo,this,bo)._.values())t.remove();E(oo,this,bo)._.clear()}}}function ho(t){if(_(jr,this))return;_(qr,this).ctx??=uo.call(h,_(Vr,this));const e=_(io,this),s=_(eo,this);for(const i of t){if(e.length>1e5)return pt("Ignoring additional textDivs for performance reasons."),void y(jr,this,!0);if(void 0!==i.str)s.push(i.str),E(ro,this,lo).call(this,i);else if("beginMarkedContentProps"===i.type||"beginMarkedContent"===i.type){const t=_(zr,this);y(zr,this,document.createElement("span")),_(zr,this).classList.add("markedContent"),null!==i.id&&_(zr,this).setAttribute("id",`${i.id}`),t.append(_(zr,this))}else"endMarkedContent"===i.type&&y(zr,this,_(zr,this).parentNode)}}function lo(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};_(io,this).push(e);const i=Et.transform(_(ao,this),t.transform);let n=Math.atan2(i[1],i[0]);const a=_(to,this)[t.fontName];a.vertical&&(n+=Math.PI/2);let r=_(Gr,this)&&a.fontSubstitution||a.fontFamily;r=h.fontFamilyMap.get(r)||r;const o=Math.hypot(i[2],i[3]),l=o*fo.call(h,r,a,_(Vr,this));let c,d;0===n?(c=i[4],d=i[5]-l):(c=i[4]+l*Math.sin(n),d=i[5]-l*Math.cos(n));const u="calc(var(--total-scale-factor) *",p=e.style;_(zr,this)===_(Qr,this)?(p.left=`${(100*c/_(Yr,this)).toFixed(2)}%`,p.top=`${(100*d/_(Xr,this)).toFixed(2)}%`):(p.left=`${u}${c.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(vo._*o).toFixed(2)}px)`,p.fontFamily=r,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,_(Gr,this)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==n&&(s.angle=n*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),s=Math.abs(t.transform[3]);e!==s&&Math.max(e,s)/Math.min(e,s)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),_(no,this).set(e,s),_(qr,this).div=e,_(qr,this).properties=s,E(ro,this,co).c
2all(this,_(qr,this)),s.hasText&&_(zr,this).append(e),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),_(zr,this).append(t)}}function co(t){const{div:e,properties:s,ctx:i}=t,{style:n}=e;let a="";if(vo._>1&&(a=`scale(${1/vo._})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:t}=n,{canvasWidth:r,fontSize:o}=s;po.call(h,i,o*_(Zr,this),t);const{width:l}=i.measureText(e.textContent);l>0&&(a=`scaleX(${r*_(Zr,this)/l}) ${a}`)}0!==s.angle&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(n.transform=a)}function uo(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=E(h,this,bo)._.get(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}),E(h,this,bo)._.set(t,e),E(h,this,wo)._.set(e,{size:0,family:""})}return e}function po(t,e,s){const i=E(h,this,wo)._.get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)}function go(){if(null!==E(h,this,vo)._)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),vo._=E(h,this,t.getBoundingClientRect().height),t.remove()}function fo(t,e,s){const i=E(h,this,mo)._.get(t);if(i)return i;const n=E(h,this,uo).call(this,s);n.canvas.width=n.canvas.height=$r,E(h,this,po).call(this,n,$r,t);const a=n.measureText(""),r=a.fontBoundingBoxAscent,o=Math.abs(a.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return r?l=r/(r+o):(yt.platform.isFirefox&&pt("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.desce
2nt)),E(h,this,mo)._.set(t,l),l}h=oo;var mo={_:new Map},bo={_:new Map},wo={_:new WeakMap},vo={_:null},Ao={_:new Set};class _o{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};return function t(s){if(!s)return;let i=null;const n=s.name;if("#text"===n)i=s.value;else{if(!_o.shouldBuildText(n))return;s?.attributes?.textContent?i=s.attributes.textContent:s.value&&(i=s.value)}if(null!==i&&e.push({str:i}),s.children)for(const e of s.children)t(e)}(t),s}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const yo=65536;function xo(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Mo,{docId:s}=e,i=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(M)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(M&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return At(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,a=t.httpHeaders||null,r=!0===t.withCredentials,o=t.password??null,h=t.range instanceof Co?t.range:null,l=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:yo;let c=t.worker instanceof Fo?t.worker:null;const d=t.verbosity,u="string"!=typeof t.docBaseUrl||Wt(t.docBaseUrl)?null:t.docBaseUrl,p=Eo(t.cMapUrl),g=!1!==t.cMapPacked,f=t.CMapReaderFactory||(M?Ma:Qn),m=Eo(t.iccUrl),b=Eo(t.standardFontDataUrl),w=t.StandardFontDataFactory||(M?Ca:_a),v=Eo(t.wasmUrl),A=t.WasmFactory||(M?Ta:xa),_=!0!==t.stopAtErrors,y=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,x=!1!==t.isEvalSupported,E="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!M,S="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!M&&(yt.platform.isFirefox||!globalThis.chrome),k=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:M,T=!0===t.fontExtraProperties,R=!0===t.enableXfa,P=t.ownerDocument||globalThis.document,I=!0===t.disableRange,L=!0===t.disableStream,D=!0===t.disableAutoFetch,N=!0===t.pdfBug,F=t.CanvasFactory||(M?ka:Yn),O=t.FilterFactory||(M?Sa:oa),W=!0===t.enableHWA,B=!1!==t.useWasm,H=h?h.length:t.length??NaN,$="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!M&&!C,U="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(f===Qn&&w===_a&&A===xa&&p&&b&&v&&zt(p,document.baseURI)&&zt(b,document.baseURI)&&zt(v,document.baseURI));ct(d);const z={canvasFactory:new F({ownerDocument:P,enableHWA:W}),filterFactory:new O({docId:s,ownerDocument:P}),cMapReaderFactory:U?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:U?null:new w({baseUrl:b}),wasmFactory:U?null:new A({baseUrl:v})};if(!c){const t={verbosity:d,port:lr.workerPort};c=t.port?Fo.fromPort(t):new Fo(t),e._worker=c}const j={docId:s,apiVersion:"5.1.91",data:n,password:o,disableAutoFetch:D,rangeChunkSize:l,length:H,docBaseUrl:u,enableXfa:R,evaluatorOptions:{maxImageSize:y,disableFontFace:C,ignoreErrors:_,isEvalSupported:x,isOffscreenCanvasSupported:E,isImageDecoderSupported:S,canvasMaxAreaInBytes:k,fontExtraProperties:T,useSystemFonts:$,useWasm:B,useWorkerFetch:U,cMapUrl:p,iccUrl:m,standardFontDataUrl:b,wasmUrl:v}},G={ownerDocument:P,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:D,enableXfa:R}};return c.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",j,n?[n.buffer]:null);let o;if(h)o=new Ar(h,{disableRange:I,disableStream:L});else if(!n){if(!i)throw new Error("getDocument - no `url` parameter provided.");let t;if(M)if(zt(i)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");t=Rr}else t=Wr;else t=zt(i)?Rr:Dr;o=new t({url:i,length:H,httpHeaders:a,withCredentials:r,rangeChunkSize:l,disableRange:I,disableStream:L})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const i=new zn(s,t,c.port),n=new Xo(i,e,o,G,z);e._transport=n,i.send("Ready",null)}))})).catch(e._capability.reject),e}function Eo(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const So=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,ko=function(t,e,s){if(!Array.isArray(s)||s.length<2)return!1;const[i,n,...a]=s;
2if(!t(i)&&!Number.isInteger(i))return!1;if(!e(n))return!1;const r=a.length;let o=!0;switch(n.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return 0===r;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(4!==r)return!1;o=!1;break;default:return!1}for(const t of a)if(!("number"==typeof t||o&&null===t))return!1;return!0}.bind(null,So,(t=>"object"==typeof t&&"string"==typeof t?.name));class Mo{static#b=0;_capability=(()=>Promise.withResolvers())();_transport=null;_worker=null;docId=(()=>"d"+Mo.#b++)();destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class Co{constructor(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]: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){gt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class To{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 bt(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(){let{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];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()}}var Ro=new WeakMap,Po=new WeakSet;class Io{constructor(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];b(this,Po),w(this,Ro,!1),this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Ut:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Zo,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(){let{scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ot({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations(){let{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{renderingIntent:e}
2=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 bt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render(t){let{canvasContext:e,viewport:s,intent:i="display",annotationMode:n=B.ENABLE,transform:a=null,background:r=null,optionalContentConfigPromise:o=null,annotationCanvasMap:h=null,pageColors:l=null,printAnnotationStorage:c=null,isEditing:d=!1}=t;this._stats?.time("Overall");const u=this._transport.getRenderingIntent(i,n,c,d),{renderingIntent:p,cacheKey:g}=u;y(Ro,this,!1),o||=this._transport.getOptionalContentConfig(p);let f=this._intentStates.get(g);f||(f=Object.create(null),this._intentStates.set(g,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const m=!!(p&L);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));const b=t=>{f.renderTasks.delete(w),m&&y(Ro,this,!0),E(Po,this,Lo).call(this),t?(w.capability.reject(t),this._abortOperatorList({intentState:f,reason:t instanceof Error?t:new Error(t)})):w.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},w=new sh({callback:b,params:{canvasContext:e,viewport:s,transform:a,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:f.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!m,pdfBug:this._pdfBug,pageColors:l});(f.renderTasks||=new Set).add(w);const v=w.task;return Promise.all([f.displayReadyCapability.promise,o]).then((t=>{let[e,s]=t;if(this.destroyed)b();else{if(this._stats?.time("Rendering"),!(s.renderingIntent&p))throw new Error("Mu
2st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");w.initializeGraphics({transparency:e,optionalContentConfig:s}),w.operatorListChanged()}})).catch(b),v}getOperatorList(){let{intent:t="display",annotationMode:e=B.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=this._transport.getRenderingIntent(t,e,s,i,!0);let a,r=this._intentStates.get(n.cacheKey);return r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r)),r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.opListReadCapability.promise}streamTextContent(){let{includeMarkedContent:t=!1,disableNormalization:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._transport._htmlForXfa)return this.getXfa().then((t=>_o.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,s){const i=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){i.read().then((function(s){let{value:i,done:a}=s;a?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),s)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),y(Ro,this,!1),Promise.all(t)}cleanup(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];y(Ro,this,!0);const e=E(Po,this,Lo).call(this);return t&&e&&(this._stats&&=new Ut),e}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.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 t of e.renderTasks)t.operatorListChanged();t.lastChunk&&E(Po,this,Lo).call(this)}_pumpOperatorList(t){let{renderingIntent:e,cacheKey:s,annotationStorageSerializable:i,modifiedIds:n}=t;const{map:a,transfer:r}=i,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:s,annotationStorage:a,modifiedIds:n},r).getReader(),h=this._intentStates.get(s);h.streamReader=o;const l=()=>{o.read().then((t=>{let{value:e,done:s}=t;s?h.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,h),l())}),(t=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const t of h.renderTasks)t.operatorListChanged();E(Po,this,Lo).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(t);else{if(!h.opListReadCapability)throw t;h.opListReadCapability.reject(t)}}}))};l()}_abortOperatorList(t){let{intentState:e,reason:s,force:i=!1}=t;if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!i){if(e.renderTasks.size>0)return;if(s instanceof RenderingCancelledException){let t=100;return s.extraDelay>0&&s.extraDelay<1e3&&(t+=s.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:s,force:!0})}),t))}}if(e.streamReader.cancel(new AbortException(s.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(const[t,s]of this._intentStates)if(s===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}function Lo(){if(!_(Ro,this)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),y(Ro,this,!1),!0}class Do{#w=(()=>new Map)();#v=(()=>Promise.resolve())();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#v.then((()=>{for(const[t]of this.#w)t.call(this,s)}))}addEventListener(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=null;if(s?.signal instanceof AbortSignal){const{signal:n}=s;if(n.aborted)return void pt("LoopbackPort - cannot use an `aborted` signal.");const a=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}this.#w.set(e,i)}removeEventListener(t,e){const s=this.#w.get(e);s?.(),this.#w.delete(e)}terminate(){for(const[,t]of this.#w)t?.();this.#w.clear()}}var No=new WeakSet;class Fo{constructor(){let{name:t=null,port:e=null,verbosity:s=dt()}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(b(this,No),this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if($o._?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return($o._||($o._=new WeakMap)).set(e,this),void this._initializeFromPort(e)}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 zn("main","worker",t),this._messageHandler.on("ready",(function(){})),E(No,this,Oo).call(this)}_initialize(){if(Ho._||Wo(Fo))return void this._setupFakeWorker();let{workerSrc:t}=Fo;try{Fo._isSameOrigin(window.location,t)||(t=Fo._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new zn("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",(t=>{n.abort(),!this.destroyed&&t?(this._messageHandler=s,this._port=e,this._webWorker=e,E(No,this,Oo).call(this)):i()})),s.on("ready",(t=>{if(n.abort(),this.destroyed)i();else try{a()}catch{this._setupFakeWorker()}}));const a=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};return void a()}catch{ut("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){Ho._||(pt("Setting up fake worker."),Ho._=!0),Fo._setupFakeWorkerGlobal.then((t=>{var e,s;if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const i=new Do;this._port=i;const n=`fake${Bo._=(e=Bo._,s=e++,e),s}`,a=new zn(n+"_worker",n,i);t.setup(a,i),this._messageHandler=new zn(n,n+"_worker",i),E(No,this,Oo).call(this)})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,$o._?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=E(Fo,this,$o)._?.get(t.port);
2if(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 Fo(t)}static get workerSrc(){if(lr.workerSrc)return lr.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return bt(this,"_setupFakeWorkerGlobal",(async()=>{if(A(Fo,this,Wo))return A(Fo,this,Wo);return(await import(this.workerSrc)).WorkerMessageHandler})())}}function Oo(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}function Wo(t){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}l=Fo;var Bo={_:0},Ho={_:!1},$o={_:void 0};M&&(Ho._=E(l,l,!0),lr.workerSrc||="./pdf.worker.mjs"),l._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!s?.origin||"null"===s.origin)return!1;const i=new URL(e,s);return s.origin===i.origin},l._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};var Uo=new WeakMap,zo=new WeakMap,jo=new WeakMap,Go=new WeakMap,Vo=new WeakMap,qo=new WeakSet;class Xo{constructor(t,e,s,i,n){b(this,qo),w(this,Uo,new Map),w(this,zo,new Map),w(this,jo,new Map),w(this,Go,new Map),w(this,Vo,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Zo,this.fontLoader=new Dn({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.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return bt(this,"annotationStorage",new Pn)}getRenderingIntent(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:B.ENABLE,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=I,r=kn;switch(t){case"any":a=P;break;case"display":break;case"print":a=L;break;default:pt(`getRenderingIntent - invalid intent: ${t}`)}const o=a&L&&s instanceof Ln?s:this.annotationStorage;switch(e){case B.DISABLE:a+=F;break;case B.ENABLE:break;case B.ENABLE_FORMS:a+=D;break;case B.ENABLE_STORAGE:a+=N,r=o.serializable;break;default:pt(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=O),n&&(a+=W);const{ids:h,hash:l}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,r.hash,l].join("_"),annotationStorageSerializable:r,modifiedIds:h}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),_(Vo,this)?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of _(zo,this).values())t.push(e._destroy());_(zo,this).clear(),_(jo,this).clear(),_(Go,this).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),_(Uo,this).clear(),this.filterFactory.destroy(),oo.cleanup(),this._networkStream?.cancelAllRequests(new AbortException("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{ft(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function(t){let{value:s,done:i}=t;i?e.close():(ft(s instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(s),1,[s]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async t=>{await this._fullReader.headersReady;const{isStreamingSupported:s,isRangeSupported:i,contentLength:n}=this._fullReader;return s&&i||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:s,isRangeSupported:i,contentLength:n}})),t.on("GetRangeReader",((t,e)=>{ft(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const s=this._networkStream.getRangeReader(t.begin,t.end);s?(e.onPull=()=>{s.read().then((function(t){let{value:s,done:i}=t;i?e.close():(ft(s instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(s),1,[s]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{s.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(t=>{let{pdfInfo:s}=t;this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new To(s,this))})),t.on("DocException",(t=>{e._capability.reject(Hn(t))})),t.on("PasswordRequest",(t=>{y(Vo,this,Promise.withResolvers());try{if(!e.onPassword)throw Hn(t);const s=t=>{t instanceof Error?_(Vo,this).reject(t):_(Vo,this).resolve({password:t})};e.onPassword(s,t.code)}catch(t){_(Vo,this).reject(t)}return _(Vo,this).promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{if(this.destroyed)return;_(zo,this).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(e=>{let[s,i,n]=e;if(this.destroyed)return null;if(this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in n){const t=n.error;pt(`Error during font loading: ${t}`),this.commonObjs.resolve(s,t);break}const e=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,a=new Nn(n,e);this.fontLoader.bind(a).catch((()=>
2t.sendWithPromise("FontFallback",{id:s}))).finally((()=>{!a.fontExtraProperties&&a.data&&(a.data=null),this.commonObjs.resolve(s,a)}));break;case"CopyLocalImage":const{imageRef:r}=n;ft(r,"The imageRef must be defined.");for(const t of _(zo,this).values())for(const[,e]of t.objs)if(e?.ref===r)return e.dataLen?(this.commonObjs.resolve(s,structuredClone(e)),e.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",(t=>{let[e,s,i,n]=t;if(this.destroyed)return;const a=_(zo,this).get(s);if(!a.objs.has(e))if(0!==a._intentStates.size)switch(i){case"Image":case"Pattern":a.objs.resolve(e,n);break;default:throw new Error(`Got unknown object type ${i}`)}else n?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBinaryData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&pt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.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=_(jo,this).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((s=>{if(this.destroyed)throw new Error("Transport destroyed");s.refStr&&_(Go,this).set(s.refStr,t);const i=new Io(e,s,this,this._params.pdfBug);return _(zo,this).set(e,i),i}));return _(jo,this).set(e,i),i}getPageIndex(t){return So(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 E(qo,this,Yo).call(this,"GetFieldObjects")}hasJSActions(){return E(qo,this,Yo).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?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 E(qo,this,Yo).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 E(qo,this,Yo).call(this,"GetOptionalContentConfig").then((e=>new wr(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=_(Uo,this).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new cr(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return _(Uo,this).set(t,s),s}
2getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of _(zo,this).values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),_(Uo,this).clear(),this.filterFactory.destroy(!0),oo.cleanup()}}cachedPageNumber(t){if(!So(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return _(Go,this).get(e)??null}}function Yo(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const s=_(Uo,this).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return _(Uo,this).set(t,i),i}const Ko=Symbol("INITIAL_DATA");var Qo=new WeakMap,Jo=new WeakSet;class Zo{constructor(){b(this,Jo),w(this,Qo,Object.create(null))}get(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e){const s=E(Jo,this,th).call(this,t);return s.promise.then((()=>e(s.data))),null}const s=_(Qo,this)[t];if(!s||s.data===Ko)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=_(Qo,this)[t];return!!e&&e.data!==Ko}delete(t){const e=_(Qo,this)[t];return!(!e||e.data===Ko)&&(delete _(Qo,this)[t],!0)}resolve(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const s=E(Jo,this,th).call(this,t);s.data=e,s.resolve()}clear(){for(const t in _(Qo,this)){const{data:e}=_(Qo,this)[t];e?.bitmap?.close()}y(Qo,this,Object.create(null))}*[Symbol.iterator](){for(const t in _(Qo,this)){const{data:e}=_(Qo,this)[t];e!==Ko&&(yield[t,e])}}}function th(t){return _(Qo,this)[t]||={...Promise.withResolvers(),data:Ko}}class eh{#A=null;onContinue=null;onError=null;constructor(t){this.#A=t}get promise(){return this.#A.capability.promise}cancel(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.#A.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#A.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#A;return t.form||t.canvas&&e?.size>0}}class sh{#_=null;static#y=(()=>new WeakSet)();constructor(t){let{callback:e,params:s,objs:i,commonObjs:n,annotationCanvasMap:a,operatorList:r,pageIndex:o,canvasFactory:h,filterFactory:l,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null}=t;this.callback=e,this.params=s,this.objs=i,this.commonObjs=n,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=o,this.canvasFactory=h,this.filterFactory=l,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new eh(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=s.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics(t){let{transparency:e=!1,optionalContentConfig:s}=t;if(this.cancelled)return;if(this._canvas){if(sh.#y.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.");sh.#y.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:i,viewport:n,transform:a,background:r}=this.params;this.gfx=new ar(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:s},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:n,transparency:e,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#_&&(window.cancelAnimationFrame(this.#_),this.#_=null),sh.#y.delete(this._canvas),t||=new RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#_=window.requestAnimationFrame((()=>{this.#_=null,this._nextBound().catch(this._cancelBound)}
2)):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),sh.#y.delete(this._canvas),this.callback())))}}const ih="5.1.91",nh="45cbe8bb0";function ah(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function rh(t){return Math.max(0,Math.min(255,255*t))}class oh{static CMYK_G(t){let[e,s,i,n]=t;return["G",1-Math.min(1,.3*e+.59*i+.11*s+n)]}static G_CMYK(t){let[e]=t;return["CMYK",0,0,0,1-e]}static G_RGB(t){let[e]=t;return["RGB",e,e,e]}static G_rgb(t){let[e]=t;return e=rh(e),[e,e,e]}static G_HTML(t){let[e]=t;const s=ah(e);return`#${s}${s}${s}`}static RGB_G(t){let[e,s,i]=t;return["G",.3*e+.59*s+.11*i]}static RGB_rgb(t){return t.map(rh)}static RGB_HTML(t){return`#${t.map(ah).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB(t){let[e,s,i,n]=t;return["RGB",1-Math.min(1,e+n),1-Math.min(1,i+n),1-Math.min(1,s+n)]}static CMYK_rgb(t){let[e,s,i,n]=t;return[rh(1-Math.min(1,e+n)),rh(1-Math.min(1,i+n)),rh(1-Math.min(1,s+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK(t){let[e,s,i]=t;const n=1-e,a=1-s,r=1-i;return["CMYK",n,a,r,Math.min(n,a,r)]}}class hh{create(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];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("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){gt("Abstract method `_createSVG` called.")}}class lh extends hh{_createSVG(t){return document.createElementNS(Dt,t)}}class ch{static setupStorage(t,e,s,i,n){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===n)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===s.attributes.type||"checkbox"===s.attributes.type){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{i.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===n)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of s.children)t.attributes.value===a.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const s=t.target.options,n=-1===s.selectedIndex?"":s[s.selectedIndex].value;i.setValue(e,{value:n})}))}}static setAttributes(t){let{html:e,element:s,storage:i=null,intent:n,linkService:a}=t;const{attributes:r}=s,o=e instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${n}`);for(const[t,s]of Object.entries(r))if(null!=s)switch(t){case"class":s.length&&e.setAttribute(t,s.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",s);break;case"style":Object.assign(e.style,s);break;case"textContent":e.textContent=s;break;default:(!o||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,s)}o&&a.addLinkAttributes(e,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(e,r.dataId,s,i)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:n,linkService:s});const r="richText"!==n,o=t.div;if(o.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}r&&o.setAttribute("class","xfaLayer xfaFont");const h=[];if(0===i.children.length){if(i.value){const t=document.createTextNode(i.value);a.append(t),r&&_o.shouldBuildText(i.name)&&h.push(t)}return{textDivs:h}}const l=[[i,-1,a]];for(;l.length>0;){const[t,i,a]=l.at(-1);if(i+1===t.children.length){l.pop();continue}const o=t.children[++l.at(-1)[1]];if(null===o)continue;const{name:c}=o;if("#text"===c){const t=document.createTextNode(o.value);h.push(t),a.append(t);continue}const d=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,c):document.createElement(c);if(a.append(d),o.attributes&&this.setAttributes({html:d,element:o,storage:e,intent:n,linkService:s}),o.children?.length>0)l.push([o,-1,d]);else if(o.value){const t=document.createTextNode(o.value);r&&_o.shouldBuildText(c)&&h.push(t),d.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const dh=1e3,uh=new WeakSet;class ph{static create(t){switch(t.data.annotationType){case K.LINK:return new _h(t);case K.TEXT:return new Sh(t);case K.WIDGET:switch(t.data.fieldType){case"Tx":return new Mh(t);case"Btn":return t.data.radioButton?new Rh(t):t.data.checkBox?new Th(t):new Ph(t);case"Ch":return new Ih(t);case"Sig":return new Ch(t)}return new kh(t);case K.POPUP:return new Lh(t);case K.FREETEXT:return new cl(t);case K.LINE:return new dl(t);case K.SQUARE:return new ul(t);case K.CIRCLE:return new pl(t);case K.POLYLINE:return new gl(t);case K.CARET:return new ml(t);case K.INK:return new Al(t);case K.POLYGON:return new fl(t);case K.HIGHLIGHT:return new yl(t);case K.UNDERLINE:return new xl(t);case K.SQUIGGLY:return new El(t);case K.STRIKEOUT:return new Sl(t);case K.STAMP:return new kl(t);case K.FILEATTACHMENT:return new Tl(t);default:return new wh(t)}}}var gh=new WeakMap,fh=new WeakMap,mh=new WeakMap,bh=new WeakSet;class wh{constructor(t){let{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};b(this,bh),w(this,gh,null),w(this,fh,!1),w(this,mh,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(t){let{titleObj:e,contentsObj:s,richText:i}=t;return!!(e?.str||s?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return wh._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;_(gh,this)||y(gh,this,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&E(bh,this,vh).call(this,e),_(mh,this)?.popup.updateEdited(t)}resetEdited(){_(gh,this)&&(E(bh,this,vh).call(this,_(gh,this).rect),_(mh,this)?.popup.resetEdited(),y(gh,this,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 kh||(n.tabIndex=dh);const{style:a}=n;
vendor: 3,323 bytes, line 2
2if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Lh){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:r,height:o}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,s=e.borderStyle.verticalCornerRadius;if(t>0||s>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${s}px * var(--total-scale-factor))`;a.borderRadius=e}else if(this instanceof Rh){const t=`calc(${r}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case Q:a.borderStyle="solid";break;case J:a.borderStyle="dashed";break;case Z:pt("Unimplemented border style: beveled");break;case tt:pt("Unimplemented border style: inset");break;case et:a.borderBottomStyle="solid"}const i=e.borderColor||null;i?(y(fh,this,!0),a.borderColor=Et.makeHexColor(0|i[0],0|i[1],0|i[2])):a.borderWidth=0}const h=Et.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:l,pageHeight:c,pageX:d,pageY:u}=i.rawDims;a.left=100*(h[0]-d)/l+"%",a.top=100*(h[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=100*r/l+"%",a.height=100*o/c+"%"):this.setRotation(p,n),n}setRotation(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.container;if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:n,height:a}=this;t%180!=0&&([n,a]=[a,n]),e.style.width=100*n/s+"%",e.style.height=100*a/i+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,s)=>{const i=s.detail[t],n=i[0],a=i.slice(1);s.target.style[e]=oh[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:oh[`${n}_rgb`](a)})};return bt(this,"_commonActions",{display:t=>{const{display:e}=t.detail,s=e%2==1;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];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 a=s[i];if(a){a({detail:{[i]:n},target:t}),delete e[i]}}}
2_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[a,r,o,h]=t.subarray(2,6);if(i===a&&n===r&&e===o&&s===h)return}const{style:a}=this.container;let r;if(_(fh,this)){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,r=["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="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=i-e,h=n-s,{svgFactory:l}=this,c=l.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);const d=l.createElement("defs");c.append(d);const u=l.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let s=2,i=t.length;s<i;s+=8){const i=t[s],a=t[s+1],c=t[s+2],d=t[s+3],p=l.createElement("rect"),g=(c-e)/o,f=(n-a)/h,m=(i-c)/o,b=(a-d)/h;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),r?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}_(fh,this)&&(r.push("</g></svg>')"),a.backgroundImage=r.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=y(mh,this,new Lh({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(){gt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:t,id:n,exportValues:a}of i){if(-1===t)continue;if(n===e)continue;const i="string"==typeof a?a:null,r=document.querySelector(`[data-element-id="${n}"]`);!r||uh.has(r)?s.push({id:n,exportValue:i,domElement:r}):pt(`_getElementsByName - element not allowed: ${n}`)}return s}for(const i of document.getElementsByName(t)){const{exportValue:t}=i,n=i.getAttribute("data-element-id");n!==e&&(uh.has(i)&&s.push({id:n,exportValue:t,domElement:i}))}return s}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}function vh(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}}}=this;s?.splice(0,4,...t),e.left=100*(t[0]-r)/n+"%",e.top=100*(a-t[3]+o)/a+"%",0===i?(e.width=100*(t[2]-t[0])/n+"%",e.height=100*(t[3]-t[1])/a+"%"):this.setRotation(i)}var Ah=new WeakSet;class _h extends wh{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),b(this,Ah),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action),i=!0):t.attachment?(E(Ah,this,xh).call(this,s,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(E(Ah,this,Eh).call(this,s,t.setOCGState),i=!0):t.dest?(this._bindLink(s,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkA
2nnotation"),i&&this.container.append(s),this.container}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&E(Ah,this,yh).call(this)}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),E(Ah,this,yh).call(this)}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),E(Ah,this,yh).call(this)}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),E(Ah,this,yh).call(this),!this._fieldObjects)return pt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(s||(t.onclick=()=>!1));t.onclick=()=>{s?.();const{fields:t,refs:i,include:n}=e,a=[];if(0!==t.length||0!==i.length){const e=new Set(i);for(const s of t){const t=this._fieldObjects[s]||[];for(const{id:s}of t)e.add(s)}for(const t of Object.values(this._fieldObjects))for(const s of t)e.has(s.id)===n&&a.push(s)}else for(const t of Object.values(this._fieldObjects))a.push(...t);const r=this.annotationStorage,o=[];for(const t of a){const{id:e}=t;switch(o.push(e),t.type){case"text":{const s=t.defaultValue||"";r.setValue(e,{value:s});break}case"checkbox":case"radiobutton":{const s=t.defaultValue===t.exportValues;r.setValue(e,{value:s});break}case"combobox":case"listbox":{const s=t.defaultValue||"";r.setValue(e,{value:s});break}default:continue}const s=document.querySelector(`[data-element-id="${e}"]`);s&&(uh.has(s)?s.dispatchEvent(new Event("resetform")):pt(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}function yh(){this.container.setAttribute("data-internal-link","")}function xh(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),E(Ah,this,yh).call(this)}function Eh(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),E(Ah,this,yh).call(this)}class Sh extends wh{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 kh extends wh{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return yt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(s,(t=>{if("blur"===s){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===s){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(t)}})}))}_setEventListeners(t,e,s,i){for(const[n,a]of s)("Action"===a||this.data.actions?.[a])&&("Focus"!==a&&"Blur"!==a||(e||={focused:!1}),this._setEventListener(t,e,n,a,i),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}
2_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":Et.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,n=t.style;let a;const r=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(R*i))||1);a=Math.min(i,r(e/R))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(i,r(t/R))}n.fontSize=`calc(${a}px * var(--total-scale-factor))`,n.color=Et.makeHexColor(s[0],s[1],s[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Mh extends kh{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),n.setValue(a.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let n=i.value||"";const a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&n.length>a&&(n=n.slice(0,a));let r=i.formattedValue||this.data.textContent?.join("\n")||null;r&&this.data.comb&&(r=r.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:r,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=r??n,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",r??n),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),uh.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=dh,this._setRequired(s,this.data.required),a&&(s.maxLength=a),s.addEventListener("input",(i=>{t.setValue(e,{value:i.target.value}),this.setPropertyOnSiblings(s,"value",i.target.value,"value"),o.formattedValue=null})),s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";s.value=o.userValue=e,o.formattedValue=null}));let h=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",(t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),s.addEventListener("updatefromsandbox",(s=>{this.showElementAndHideCanvas(s.target);const i={value(s){o.userValue=s.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),s.target.value=o.userValue},formattedValue(s){const{formattedValue:i}=s.detail;o.formattedValue=i,null!=i&&s.target!==document.activeElement&&(s.target.value=i),t.setValue(e,{formattedValue:i})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:s=>{const{charLimit:i}=s.detail,{target:n}=s;if(0===i)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",i);let a=o.userValue;!a||a.length<=i||(a=a.slice(0,i),n.value=o.userValue=a,t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(i,s)})),s.addEventListener("keydown",(t=>{o.commitKey=1;let s=-1;if("Escape"===t.key?s=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):s=2,-1===s)return;const{value:i}=t.target;o.lastCommittedValue!==i&&(o.lastCommittedValue=i,o.userValue=i,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:s,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const i=h;h=null,s.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:s}=t.target;o.userValue=s,o.lastCommittedValue!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,
2commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),i(t)})),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:s,target:i}=t,{value:n,selectionStart:a,selectionEnd:r}=i;let h=a,l=r;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,a).match(/\w*[^\w]*$/);t&&(h-=t[0].length);break}case"deleteWordForward":{const t=n.substring(a).match(/^[^\w]*\w*/);t&&(l+=t[0].length);break}case"deleteContentBackward":a===r&&(h-=1);break;case"deleteContentForward":a===r&&(l+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:s||"",willCommit:!1,selStart:h,selEnd:l}})})),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(h&&s.addEventListener("blur",h),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/a;s.classList.add("comb"),s.style.letterSpacing=`calc(${t}px * var(--total-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 Ch extends kh{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Th extends kh{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;"string"==typeof i&&(i="Off"!==i,t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return uh.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=dh,n.addEventListener("change",(i=>{const{name:n,checked:a}=i.target;for(const i of this._getElementsByName(n,s)){const s=a&&i.exportValue===e.exportValue;i.domElement&&(i.domElement.checked=s),t.setValue(i.id,{value:s})}t.setValue(s,{value:a})})),n.addEventListener("resetform",(t=>{const s=e.defaultFieldValue||"Off";t.target.checked=s===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const i={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(s,{value:e.target.checked})}};this._dispatchEventFromSandbox(i,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Rh extends kh{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("string"==typeof i&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const i of this._getElementsByName(e.fieldName,s))t.setValue(i.id,{value:!1});const n=document.createElement("input");if(uh.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=dh,n.addEventListener("change",(e=>{const{name:i,checked:n}=e.target;for(const e of this._getElementsByName(i,s))t.setValue(e.id,{value:!1});t.setValue(s,{value:n})})),n.addEventListener("resetform",(t=>{const s=e.defaultFieldValue;t.target.checked=null!=s&&s===e.buttonValue})),this.enableScripting&&this.hasJSActions){const i=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{const n={value:e=>{const n=i===e.detail.value;for(const i of this._getElementsByName(e.target.name)){const e=n&&i.id===s;i.domElement&&(i.domElement.checked=e),t.setValue(i.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}
2return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Ph extends _h{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",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Ih extends kh{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");uh.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=dh;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",(t=>{const e=this.data.defaultFieldValue;for(const t of i.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,s.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),i.append(e)}let a=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),i.prepend(t),a=()=>{t.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const r=t=>{const e=t?"value":"textContent",{options:s,multiple:n}=i;return n?Array.prototype.filter.call(s,(t=>t.selected)).map((t=>t[e])):-1===s.selectedIndex?null:s[s.selectedIndex][e]};let o=r(!1);const h=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",(s=>{const n={value(s){a?.();const n=s.detail.value,h=new Set(Array.isArray(n)?n:[n]);for(const t of i.options)t.selected=h.has(t.value);t.setValue(e,{value:r(!0)}),o=r(!1)},multipleSelection(t){i.multiple=!0},remove(s){const n=i.options,a=s.detail.remove;if(n[a].selected=!1,i.remove(a),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:r(!0),items:h(s)}),o=r(!1)},clear(s){for(;0!==i.length;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=r(!1)},insert(s){const{index:n,displayValue:a,exportValue:l}=s.detail.insert,c=i.children[n],d=document.createElement("option");d.textContent=a,d.value=l,c?c.before(d):i.append(d),t.setValue(e,{value:r(!0),items:h(s)}),o=r(!1)},items(s){const{items:n}=s.detail;for(;0!==i.length;)i.remove(0);for(const t of n){const{displayValue:e,exportValue:s}=t,n=document.createElement("option");n.textContent=e,n.value=s,i.append(n)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:r(!0),items:h(s)}),o=r(!1)},indices(s){const i=new Set(s.detail.indices);for(const t of s.target.options)t.selected=i.has(t.index);t.setValue(e,{value:r(!0)}),o=r(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,s)})),i.addEventListener("input",(s=>{const i=r(!0),n=r(!1);t.setValue(e,{value:i}),s.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:i,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"]],(t=>t.target.value))):i.addEventListener("input",(function(s){t.setValue(e,{value:r(!0)})})),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Lh extends wh{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:wh._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");
2const t=this.popup=new tl({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((t=>`${Pt}${t}`)).join(",")),this.container}}var Dh=new WeakMap,Nh=new WeakMap,Fh=new WeakMap,Oh=new WeakMap,Wh=new WeakMap,Bh=new WeakMap,Hh=new WeakMap,$h=new WeakMap,Uh=new WeakMap,zh=new WeakMap,jh=new WeakMap,Gh=new WeakMap,Vh=new WeakMap,qh=new WeakMap,Xh=new WeakMap,Yh=new WeakMap,Kh=new WeakMap,Qh=new WeakMap,Jh=new WeakMap,Zh=new WeakSet;class tl{constructor(t){let{container:e,color:s,elements:i,titleObj:n,modificationDate:a,contentsObj:r,richText:o,parent:h,rect:l,parentRect:c,open:d}=t;b(this,Zh),w(this,Dh,E(Zh,this,al).bind(this)),w(this,Nh,E(Zh,this,ll).bind(this)),w(this,Fh,E(Zh,this,hl).bind(this)),w(this,Oh,E(Zh,this,ol).bind(this)),w(this,Wh,null),w(this,Bh,null),w(this,Hh,null),w(this,$h,null),w(this,Uh,null),w(this,zh,null),w(this,jh,null),w(this,Gh,!1),w(this,Vh,null),w(this,qh,null),w(this,Xh,null),w(this,Yh,null),w(this,Kh,null),w(this,Qh,null),w(this,Jh,!1),y(Bh,this,e),y(Kh,this,n),y(Hh,this,r),y(Yh,this,o),y(zh,this,h),y(Wh,this,s),y(Xh,this,l),y(jh,this,c),y(Uh,this,i),y($h,this,Vt.toDateObject(a)),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",_(Oh,this)),t.addEventListener("mouseenter",_(Fh,this)),t.addEventListener("mouseleave",_(Nh,this)),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",_(Dh,this));_(Bh,this).hidden=!0,d&&E(Zh,this,ol).call(this)}render(){if(_(Vh,this))return;const t=y(Vh,this,document.createElement("div"));if(t.className="popup",_(Wh,this)){const e=t.style.outlineColor=Et.makeHexColor(..._(Wh,this));t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),({dir:s.dir,str:s.textContent}=_(Kh,this)),t.append(e),_($h,this)){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:_($h,this).valueOf()})),e.append(t)}const i=A(Zh,this,el);if(i)ch.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(_(Hh,this));t.append(e)}_(Bh,this).append(t)}_formatContents(t){let{str:e,dir:s}=t;const i=document.createElement("p");i.classList.add("popupContent"),i.dir=s;const n=e.split(/(?:\r\n?|\n)/);for(let t=0,e=n.length;t<e;++t){const s=n[t];i.append(document.createTextNode(s)),t<e-1&&i.append(document.createElement("br"))}return i}updateEdited(t){let{rect:e,popupContent:s}=t;_(Qh,this)||y(Qh,this,{contentsObj:_(Hh,this),richText:_(Yh,this)}),e&&y(qh,this,null),s&&(y(Yh,this,E(Zh,this,nl).call(this,s)),y(Hh,this,null)),_(Vh,this)?.remove(),y(Vh,this,null)}resetEdited(){_(Qh,this)&&(({contentsObj:m(y,[Hh,this])._,richText:m(y,[Yh,this])._}=_(Qh,this)),y(Qh,this,null),_(Vh,this)?.remove(),y(Vh,this,null),y(qh,this,null))}forceHide(){y(Jh,this,this.isVisible),_(Jh,this)&&(_(Bh,this).hidden=!0)}maybeShow(){_(Jh,this)&&(_(Vh,this)||E(Zh,this,hl).call(this),y(Jh,this,!1),_(Bh,this).hidden=!1)}get isVisible(){return!1===_(Bh,this).hidden}}function el(t){const e=_(Yh,t),s=_(Hh,t);return!e?.str||s?.str&&s.str!==e.str?null:_(Yh,t).html||null}function sl(t){return A(Zh,t,el)?.attributes?.style?.fontSize||0}function il(t){return A(Zh,t,el)?.attributes?.style?.color||null}function nl(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:A(Zh,this,il),fontSize:A(Zh,this,sl)?`calc(${A(Zh,this,sl)}px * var(--total-scale-factor))`:""}};for(const s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return s}function al(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&_(Gh,this))&&E(Zh,this,ol).call(this)}function rl(){if(null!==_(qh,this))return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=_(zh,this);let a=!!_(jh,this),r=_(a?jh:Xh,this);for(const t of _(Uh,this))if(!r||null!==Et.intersect(t.data.rect,r)){r=t.data.rect,a=!0;break}const o=Et.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),h=a?r[2]-r[0]+5:0,l=o[0]+h,c=o[1];y(qh,this,[100*(l-i)/e,100*(c-n)/s]);const{style:d}=_(Bh,this);d.left=`${_(qh,this)[0]}%`,d.top=`${_(qh,this)[1]}%`}function ol(){y(Gh,this,!_(Gh,this)),_(Gh,this)?(E(Zh,this,hl).call(this),_(Bh,this).addEventListener("click",_(Oh,this)),_(Bh,this).addEventListener("keydown",_(Dh,this))):(E(Zh,this,ll).call(this),_(Bh,this).removeEventListener("click",_(Oh,this)),_(Bh,this).removeEventListener("keydown",_(Dh,this)))}function hl(){_(Vh,this)||this.render(),this.isVisible?_(Gh,this)&&_(Bh,this).classList.add("focused"):(E(Zh,this,rl).call(this),_(Bh,this).hidden=!1,_(Bh,this).style.zIndex=parseInt(_(Bh,this).style.zIndex)+1e3)}function ll(){_(Bh,this).classList.remove("focused"),!_(Gh,this)&&this.isVisible&&(_(Bh,this).hidden=!0,_(Bh,this).style.zIndex=parseInt(_(Bh,this).style.zIndex)-1e3)}class cl extends wh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=H.FREETEXT}
2render(){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 dl extends wh{#x=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=this.#x=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#x}addHighlightArea(){this.container.classList.add("highlightArea")}}class ul extends wh{#E=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,a=this.#E=this.svgFactory.createElement("svg:rect");return a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",s-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#E}addHighlightArea(){this.container.classList.add("highlightArea")}}class pl extends wh{#S=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,a=this.#S=this.svgFactory.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",s/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",s/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#S}addHighlightArea(){this.container.classList.add("highlightArea")}}class gl extends wh{#k=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:s,popupRef:i},width:n,height:a}=this;if(!e)return this.container;const r=this.svgFactory.create(n,a,!0);let o=[];for(let s=0,i=e.length;s<i;s+=2){const i=e[s]-t[0],n=t[3]-e[s+1];o.push(`${i},${n}`)}o=o.join(" ");const h=this.#k=this.svgFactory.createElement(this.svgElementName);return h.setAttribute("points",o),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),r.append(h),this.container.append(r),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#k}addHighlightArea(){this.container.classList.add("highlightArea")}}class fl extends gl{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class ml extends wh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var bl=new WeakMap,wl=new WeakMap,vl=new WeakSet;class Al extends wh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),b(this,vl),w(this,bl,null),w(this,wl,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?H.HIGHLIGHT:H.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:n}}=this,{transform:a,width:r,height:o}=E(vl,this,_l).call(this,e,t),h=this.svgFactory.create(r,o,!0),l=y(bl,this,this.svgFactory.createElement("svg:g"));h.append(l),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke-linecap","round"),l.setAttribute("stroke-linejoin","round"),l.setAttribute("stroke-miterlimit",10),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),l.setAttribute("transform",a);for(let t=0,e=s.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);_(wl,this).push(e),e.setAttribute("points",s[t].join(",")),l.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:s,rect:i}=t,n=_(bl,this);if(e>=0&&n.setAttribute("stroke-width",e||1),s)for(let t=0,e=_(wl,this).length;t<e;t++)_(wl,this)[t].setAttribute("points",s[t].join(","));if(i){const{transform:t,width:e,height:s}=E(vl,this,_l).call(this,this.data.rotation,i);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${s}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return _(wl,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function _l(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}class yl extends wh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=H.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}
2class xl extends wh{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 El extends wh{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 Sl extends wh{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 kl extends wh{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=H.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var Ml=new WeakMap,Cl=new WeakSet;class Tl extends wh{constructor(t){super(t,{isRenderable:!0}),b(this,Cl),w(this,Ml,null);const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let s;e.hasAppearance||0===e.fillAlpha?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),s.addEventListener("dblclick",E(Cl,this,Rl).bind(this)),y(Ml,this,s);const{isMac:i}=yt.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(i?t.metaKey:t.ctrlKey)&&E(Cl,this,Rl).call(this)})),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return _(Ml,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function Rl(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}var Pl=new WeakMap,Il=new WeakMap,Ll=new WeakMap,Dl=new WeakMap,Nl=new WeakSet;class Fl{constructor(t){let{div:e,accessibilityManager:s,annotationCanvasMap:i,annotationEditorUIManager:n,page:a,viewport:r,structTreeLayer:o}=t;b(this,Nl),w(this,Pl,null),w(this,Il,null),w(this,Ll,new Map),w(this,Dl,null),this.div=e,y(Pl,this,s),y(Il,this,i),y(Dl,this,o||null),this.page=a,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=n}hasEditableAnnotations(){return _(Ll,this).size>0}async render(t){const{annotations:e}=t,s=this.div;Qt(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new lh,annotationStorage:t.annotationStorage||new Pn,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===K.POPUP;if(e){const e=i.get(t.id);if(!e)continue;n.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;n.data=t;const s=ph.create(n);if(!s.isRenderable)continue;if(!e&&t.popupRef){const e=i.get(t.popupRef);e?e.push(s):i.set(t.popupRef,[s])}const a=s.render();t.hidden&&(a.style.visibility="hidden"),await E(Nl,this,Ol).call(this,a,t.id),s._isEditable&&(_(Ll,this).set(s.data.id,s),this._annotationEditorUIManager?.renderAnnotationElement(s))}E(Nl,this,Wl).call(this)}async addLinkAnnotations(t,e){const s={data:null,layer:this.div,linkService:e,svgFactory:new lh,parent:this};for(const e of t){e.borderStyle||=Fl._defaultBorderStyle,s.data=e;const t=ph.create(s);if(!t.isRenderable)continue;const i=t.render();await E(Nl,this,Ol).call(this,i,e.id)}}update(t){let{viewport:e}=t;const s=this.div;this.viewport=e,Qt(s,{rotation:e.rotation}),E(Nl,this,Wl).call(this),s.hidden=!1}getEditableAnnotations(){return Array.from(_(Ll,this).values())}getEditableAnnotation(t){return _(Ll,this).get(t)}static get _defaultBorderStyle(){return bt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Q,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}async function Ol(t,e){const s=t.firstChild||t,i=s.id=`${Pt}${e}`,n=await(_(Dl,this)?.getAriaAttributes(i));if(n)for(const[t,e]of n)s.setAttribute(t,e);this.div.append(t),_(Pl,this)?.moveElementInDOM(this.div,t,s,!1)}function Wl(){if(!_(Il,this))return;const t=this.div;for(const[e,s]of _(Il,this)){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?"CANVAS"===n.nodeName?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s);const a=_(Ll,this).get(e);a&&(a._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,i.id,s),a._hasNoCanvas=!1):a.canvas=s)}_(Il,this).clear()}const Bl=/\r\n?|\n/g;var Hl=new WeakMap,$l=new WeakMap,Ul=new WeakMap,zl=new WeakMap,jl=new WeakMap,Gl=new WeakSet;class Vl extends tn{static get _keyboardManager(){const t=Vl.prototype,e=t=>t.isEmpty(),s=Ms.TRANSLATE_SMALL,i=Ms.TRANSLATE_BIG;return bt(this,"_keyboardManager",new Le([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}constructor(t){super({...t,name:"freeTextEditor"}),b(this,Gl),w(this,Hl,void 0),w(this,$l,""),w(this,Ul,`${this.id}-editor`),w(this,zl,null),w(this,jl,void 0),y(Hl,this,t.color||Vl._defaultColor||tn._defaultLineColor),y(jl,this,t.fontSize||Vl._defaultFontSize)}static initialize(t,e){tn.initialize(t,e);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}
2static updateDefaultParams(t,e){switch(t){case $.FREETEXT_SIZE:Vl._defaultFontSize=e;break;case $.FREETEXT_COLOR:Vl._defaultColor=e}}updateParams(t,e){switch(t){case $.FREETEXT_SIZE:E(Gl,this,ql).call(this,e);break;case $.FREETEXT_COLOR:E(Gl,this,Xl).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$.FREETEXT_SIZE,Vl._defaultFontSize],[$.FREETEXT_COLOR,Vl._defaultColor||tn._defaultLineColor]]}get propertiesToUpdate(){return[[$.FREETEXT_SIZE,_(jl,this)],[$.FREETEXT_COLOR,_(Hl,this)]]}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Vl._internalPadding*t,-(Vl._internalPadding+_(jl,this))*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(H.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),y(zl,this,new AbortController);const t=this._uiManager.combinedSignal(_(zl,this));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",_(Ul,this)),this._isDraggable=!0,_(zl,this)?.abort(),y(zl,this,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=_($l,this),e=y($l,this,E(Gl,this,Yl).call(this).trimEnd());if(t===e)return;const s=t=>{y($l,this,t),t?(E(Gl,this,Jl).call(this),this._uiManager.rebuild(this),E(Gl,this,Kl).call(this)):this.remove()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),E(Gl,this,Kl).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Vl._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",_(Ul,this)),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:s}=this.editorDiv;if(s.fontSize=`calc(${_(jl,this)}px * var(--total-scale-factor))`,s.color=_(Hl,this),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),xe(this,this.div,["dblclick","keydown"]),this._isCopy||this.annotationElementId){const[s,i]=this.parentDimensions;
2if(this.annotationElementId){const{position:n}=this._initialData;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);const[o,h]=this.pageDimensions,[l,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(n[0]-l)/o,u=e+this.height-(n[1]-c)/h;break;case 90:d=t+(n[0]-l)/o,u=e-(n[1]-c)/h,[a,r]=[r,-a];break;case 180:d=t-this.width+(n[0]-l)/o,u=e-(n[1]-c)/h,[a,r]=[-a,-r];break;case 270:d=t+(n[0]-l-this.height*h)/o,u=e+(n[1]-c-this.width*o)/h,[a,r]=[-r,a]}this.setAt(d*s,u*i,a,r)}else this._moveAfterPaste(t,e);E(Gl,this,Jl).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(1===s.length&&"text/plain"===s[0])return;t.preventDefault();const i=tc.call(Vl,e.getData("text")||"").replaceAll(Bl,"\n");if(!i)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const a=n.getRangeAt(0);if(!i.includes("\n"))return a.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:r,startOffset:o}=a,h=[],l=[];if(r.nodeType===Node.TEXT_NODE){const t=r.parentElement;if(l.push(r.nodeValue.slice(o).replaceAll(Bl,"")),t!==this.editorDiv){let e=h;for(const s of this.editorDiv.childNodes)s!==t?e.push(Ql.call(Vl,s)):e=l}h.push(r.nodeValue.slice(0,o).replaceAll(Bl,""))}else if(r===this.editorDiv){let t=h,e=0;for(const s of this.editorDiv.childNodes)e++===o&&(t=l),t.push(Ql.call(Vl,s))}y($l,this,`${h.join("\n")}${i}${l.join("\n")}`),E(Gl,this,Jl).call(this);const c=new Range;let d=Math.sumPrecise(h.map((t=>t.length)));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(d<=e){c.setStart(t,d),c.setEnd(t,d);break}d-=e}n.removeAllRanges(),n.addRange(c)}get contentDiv(){return this.editorDiv}static async deserialize(t,e,s){let i=null;if(t instanceof cl){const{data:{defaultAppearanceData:{fontSize:e,fontColor:s},rect:n,rotation:a,id:r,popupRef:o},textContent:h,textPosition:l,parent:{page:{pageNumber:c}}}=t;if(!h||0===h.length)return null;i=t={annotationType:H.FREETEXT,color:Array.from(s),fontSize:e,value:h.join("\n"),position:l,pageIndex:c-1,rect:n.slice(0),rotation:a,id:r,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,s);return y(jl,n,t.fontSize),y(Hl,n,Et.makeHexColor(...t.color)),y($l,n,tc.call(Vl,t.value)),n.annotationElementId=t.id||null,n._initialData=i,n}serialize(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=Vl._internalPadding*this.parentScale,s=this.getRect(e,e),i=tn._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:_(Hl,this)),n={annotationType:H.FREETEXT,color:i,fontSize:_(jl,this),value:E(Gl,this,Zl).call(this),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(n.isCopy=!0,n):this.annotationElementId&&!E(Gl,this,ec).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:s}=e;s.fontSize=`calc(${_(jl,this)}px * var(--total-scale-factor))`,s.color=_(Hl,this),e.replaceChildren();for(const t of _($l,this).split("\n")){const s=document.createElement("div");s.append(t?document.createTextNode(t):document.createElement("br")),e.append(s)}const i=Vl._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:_($l,this)}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}function ql(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-_(jl,this))*this.parentScale),y(jl,this,t),E(Gl,this,Kl).call(this)},s=_(jl,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}function Xl(t){const e=t=>{y(Hl,this,this.editorDiv.style.color=t)},s=_(Hl,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}function Yl(){const t=[];
2this.editorDiv.normalize();let e=null;for(const s of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===s.nodeName||(t.push(Ql.call(c,s)),e=s);return t.join("\n")}function Kl(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,i=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),s=e.getBoundingClientRect(),e.remove(),e.style.display=i,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}function Ql(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Bl,"")}function Jl(){if(this.editorDiv.replaceChildren(),_($l,this))for(const t of _($l,this).split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}function Zl(){return _($l,this).replaceAll(" "," ")}function tc(t){return t.replaceAll(" "," ")}function ec(t){const{value:e,fontSize:s,color:i,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some(((t,e)=>t!==i[e]))||t.pageIndex!==n}c=Vl,x(Vl,"_freeTextDefaultContent",""),x(Vl,"_internalPadding",0),x(Vl,"_defaultColor",null),x(Vl,"_defaultFontSize",10),x(Vl,"_type","freetext"),x(Vl,"_editorType",H.FREETEXT);class sc{static PRECISION=1e-4;toSVGPath(){gt("Abstract method `toSVGPath` must be implemented.")}get box(){gt("Abstract getter `box` must be implemented.")}serialize(t,e){gt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r]*i,a[r+1]=s+t[r+1]*n;return a}static _rescaleAndSwap(t,e,s,i,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r+1]*i,a[r+1]=s+t[r]*n;return a}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let n=0,a=t.length;n<a;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(1e4*t)}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,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+a)/6,(s+n)/2,(i+a)/2]}}var ic=new WeakMap,nc=new WeakMap,ac=new WeakMap,rc=new WeakMap,oc=new WeakMap,hc=new WeakMap,lc=new WeakMap,cc=new WeakMap,dc=new WeakMap,uc=new WeakMap,pc=new WeakMap,gc=new WeakMap,fc=new WeakMap,mc=new WeakSet;class bc{constructor(t,e,s,i,n){let{x:a,y:r}=t,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;b(this,mc),w(this,ic,void 0),w(this,nc,[]),w(this,ac,void 0),w(this,rc,void 0),w(this,oc,[]),w(this,hc,new Float32Array(18)),w(this,lc,void 0),w(this,cc,void 0),w(this,dc,void 0),w(this,uc,void 0),w(this,pc,void 0),w(this,gc,void 0),w(this,fc,[]),y(ic,this,e),y(gc,this,i*s),y(rc,this,n),_(hc,this).set([NaN,NaN,NaN,NaN,a,r],6),y(ac,this,o),y(uc,this,Sc._*s),y(dc,this,kc._*s),y(pc,this,s),_(fc,this).push(a,r)}isEmpty(){return isNaN(_(hc,this)[8])}add(t){let{x:e,y:s}=t;y(lc,this,e),y(cc,this,s);const[i,n,a,r]=_(ic,this);let[o,h,l,c]=_(hc,this).subarray(8,12);const d=e-l,u=s-c,p=Math.hypot(d,u);if(p<_(dc,this))return!1;const g=p-_(uc,this),f=g/p,m=f*d,b=f*u;let w=o,v=h;o=l,h=c,l+=m,c+=b,_(fc,this)?.push(e,s);const A=m/g,x=-b/g*_(gc,this),E=A*_(gc,this);if(_(hc,this).set(_(hc,this).subarray(2,8),0),_(hc,this).set([l+x,c+E],4),_(hc,this).set(_(hc,this).subarray(14,18),12),_(hc,this).set([l-x,c-E],16),isNaN(_(hc,this)[6]))return 0===_(oc,this).length&&(_(hc,this).set([o+x,h+E],2),_(oc,this).push(NaN,NaN,NaN,NaN,(o+x-i)/a,(h+E-n)/r),_(hc,this).set([o-x,h-E],14),_(nc,this).push(NaN,NaN,NaN,NaN,(o-x-i)/a,(h-E-n)/r)),_(hc,this).set([w,v,o,h,l,c],6),!this.isEmpty();_(hc,this).set([w,v,o,h,l,c],6);return Math.abs(Math.atan2(v-h,w-o)-Math.atan2(b,m))<Math.PI/2?([o,h,l,c]=_(hc,this).subarray(2,6),_(oc,this).push(NaN,NaN,NaN,NaN,((o+l)/2-i)/a,((h+c)/2-n)/r),[o,h,w,v]=_(hc,this).subarray(14,18),_(nc,this).push(NaN,NaN,NaN,NaN,((w+o)/2-i)/a,((v+h)/2-n)/r),!0):([w,v,o,h,l,c]=_(hc,this).subarray(0,6),_(oc,this).push(((w+5*o)/6-i)/a,((v+5*h)/6-n)/r,((5*o+l)/6-i)/a,((5*h+c)/6-n)/r,((o+l)/2-i)/a,((h+c)/2-n)/r),[l,c,o,h,w,v]=_(hc,this).subarray(12,18),_(nc,this).push(((w+5*o)/6-i)/a,((v+5*h)/6-n)/r,((5*o+l)/6-i)/a,((5*h+c)/6-n)/r,((o+l)/2-i)/a,((h+c)/2-n)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=_(oc,this),e=_(nc,this);if(isNaN(_(hc,this)[6])&&!this.isEmpty())return E(mc,this,vc).call(this);const s=[];
2s.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?s.push(`L${t[e+4]} ${t[e+5]}`):s.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);E(mc,this,_c).call(this,s);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?s.push(`L${e[t+4]} ${e[t+5]}`):s.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return E(mc,this,Ac).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,a){return new Nc(t,e,s,i,n,a)}getOutlines(){const t=_(oc,this),e=_(nc,this),s=_(hc,this),[i,n,a,r]=_(ic,this),o=new Float32Array((_(fc,this)?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(_(fc,this)[t]-i)/a,o[t+1]=(_(fc,this)[t+1]-n)/r;if(o[o.length-2]=(_(lc,this)-i)/a,o[o.length-1]=(_(cc,this)-n)/r,isNaN(s[6])&&!this.isEmpty())return E(mc,this,yc).call(this,o);const h=new Float32Array(_(oc,this).length+24+_(nc,this).length);let l=t.length;for(let e=0;e<l;e+=2)isNaN(t[e])?h[e]=h[e+1]=NaN:(h[e]=t[e],h[e+1]=t[e+1]);l=E(mc,this,Ec).call(this,h,l);for(let t=e.length-6;t>=6;t-=6)for(let s=0;s<6;s+=2)isNaN(e[t+s])?(h[l]=h[l+1]=NaN,l+=2):(h[l]=e[t+s],h[l+1]=e[t+s+1],l+=2);return E(mc,this,xc).call(this,h,l),this.newFreeDrawOutline(h,o,_(ic,this),_(pc,this),_(ac,this),_(rc,this))}}function wc(){const t=_(hc,this).subarray(4,6),e=_(hc,this).subarray(16,18),[s,i,n,a]=_(ic,this);return[(_(lc,this)+(t[0]-e[0])/2-s)/n,(_(cc,this)+(t[1]-e[1])/2-i)/a,(_(lc,this)+(e[0]-t[0])/2-s)/n,(_(cc,this)+(e[1]-t[1])/2-i)/a]}function vc(){const[t,e,s,i]=_(ic,this),[n,a,r,o]=E(mc,this,wc).call(this);return`M${(_(hc,this)[2]-t)/s} ${(_(hc,this)[3]-e)/i} L${(_(hc,this)[4]-t)/s} ${(_(hc,this)[5]-e)/i} L${n} ${a} L${r} ${o} L${(_(hc,this)[16]-t)/s} ${(_(hc,this)[17]-e)/i} L${(_(hc,this)[14]-t)/s} ${(_(hc,this)[15]-e)/i} Z`}function Ac(t){const e=_(nc,this);t.push(`L${e[4]} ${e[5]} Z`)}function _c(t){const[e,s,i,n]=_(ic,this),a=_(hc,this).subarray(4,6),r=_(hc,this).subarray(16,18),[o,h,l,c]=E(mc,this,wc).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/n} L${o} ${h} L${l} ${c} L${(r[0]-e)/i} ${(r[1]-s)/n}`)}function yc(t){const e=_(hc,this),[s,i,n,a]=_(ic,this),[r,o,h,l]=E(mc,this,wc).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/a,NaN,NaN,NaN,NaN,r,o,NaN,NaN,NaN,NaN,h,l,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/a],0),this.newFreeDrawOutline(c,t,_(ic,this),_(pc,this),_(ac,this),_(rc,this))}function xc(t,e){const s=_(nc,this);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+6}function Ec(t,e){const s=_(hc,this).subarray(4,6),i=_(hc,this).subarray(16,18),[n,a,r,o]=_(ic,this),[h,l,c,d]=E(mc,this,wc).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/r,(s[1]-a)/o,NaN,NaN,NaN,NaN,h,l,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(i[0]-n)/r,(i[1]-a)/o],e),e+24}var Sc={_:8},kc={_:Sc._+2},Mc=new WeakMap,Cc=new WeakMap,Tc=new WeakMap,Rc=new WeakMap,Pc=new WeakMap,Ic=new WeakMap,Lc=new WeakMap,Dc=new WeakSet;class Nc extends sc{constructor(t,e,s,i,n,a){super(),b(this,Dc),w(this,Mc,void 0),w(this,Cc,new Float32Array(4)),w(this,Tc,void 0),w(this,Rc,void 0),w(this,Pc,void 0),w(this,Ic,void 0),w(this,Lc,void 0),y(Lc,this,t),y(Pc,this,e),y(Mc,this,s),y(Ic,this,i),y(Tc,this,n),y(Rc,this,a),this.lastPoint=[NaN,NaN],E(Dc,this,Fc).call(this,a);const[r,o,h,l]=_(Cc,this);for(let e=0,s=t.length;e<s;e+=2)t[e]=(t[e]-r)/h,t[e+1]=(t[e+1]-o)/l;for(let t=0,s=e.length;t<s;t+=2)e[t]=(e[t]-r)/h,e[t+1]=(e[t+1]-o)/l}toSVGPath(){const t=[`M${_(Lc,this)[4]} ${_(Lc,this)[5]}`];for(let e=6,s=_(Lc,this).length;e<s;e+=6)isNaN(_(Lc,this)[e])?t.push(`L${_(Lc,this)[e+4]} ${_(Lc,this)[e+5]}`):t.push(`C${_(Lc,this)[e]} ${_(Lc,this)[e+1]} ${_(Lc,this)[e+2]} ${_(Lc,this)[e+3]} ${_(Lc,this)[e+4]} ${_(Lc,this)[e+5]}`);return t.push("Z"),t.join(" ")}serialize(t,e){let[s,i,n,a]=t;const r=n-s,o=a-i;let h,l;switch(e){case 0:h=sc._rescale(_(Lc,this),s,a,r,-o),l=sc._rescale(_(Pc,this),s,a,r,-o);break;case 90:h=sc._rescaleAndSwap(_(Lc,this),s,i,r,o),l=sc._rescaleAndSwap(_(Pc,this),s,i,r,o);break;case 180:h=sc._rescale(_(Lc,this),n,i,-r,o),l=sc._rescale(_(Pc,this),n,i,-r,o);break;case 270:h=sc._rescaleAndSwap(_(Lc,this),n,a,-r,-o),l=sc._rescaleAndSwap(_(Pc,this),n,a,-r,-o)}return{outline:Array.from(h),points:[Array.from(l)]}}get box(){return _(Cc,this)}newOutliner(t,e,s,i,n){return new bc(t,e,s,i,n,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}getNewOutline(t,e){const[s,i,n,a]=_(Cc,this),[r,o,h,l]=_(Mc,this),c=n*h,d=a*l,u=s*h+r,p=i*l+o,g=this.newOutliner({x:_(Pc,this)[0]*c+u,y:_(Pc,this)[1]*d+p},_(Mc,this),_(Ic,this),t,_(Rc,this),e??_(Tc,this));for(let t=2;t<_(Pc,this).length;t+=2)g.add({x:_(Pc,this)[t]*c+u,y:_(Pc,this)[t+1]*d+p});return g.getOutlines()}}function Fc(t){const e=_(Lc,this);let s=e[4],i=e[5];const n=[s,i,s,i];let a=s,r=i;const o=t?Math.max:Math.min;for(let t=6,h=e.length;t<h;t+=6){const h=e[t+4],l=e[t+5];
2if(isNaN(e[t]))Et.pointBoundingBox(h,l,n),r<l?(a=h,r=l):r===l&&(a=o(a,h));else{const h=[1/0,1/0,-1/0,-1/0];Et.bezierBoundingBox(s,i,...e.slice(t,t+6),h),Et.rectBoundingBox(...h,n),r<h[3]?(a=h[2],r=h[3]):r===h[3]&&(a=o(a,h[2]))}s=h,i=l}const h=_(Cc,this);h[0]=n[0]-_(Tc,this),h[1]=n[1]-_(Tc,this),h[2]=n[2]-n[0]+2*_(Tc,this),h[3]=n[3]-n[1]+2*_(Tc,this),this.lastPoint=[a,r]}var Oc=new WeakMap,Wc=new WeakMap,Bc=new WeakMap,Hc=new WeakMap,$c=new WeakSet;class Uc{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];b(this,$c),w(this,Oc,void 0),w(this,Wc,void 0),w(this,Bc,[]),w(this,Hc,[]);const n=[1/0,1/0,-1/0,-1/0],a=10**-4;for(const{x:s,y:i,width:r,height:o}of t){const t=Math.floor((s-e)/a)*a,h=Math.ceil((s+r+e)/a)*a,l=Math.floor((i-e)/a)*a,c=Math.ceil((i+o+e)/a)*a,d=[t,l,c,!0],u=[h,l,c,!1];_(Bc,this).push(d,u),Et.rectBoundingBox(t,l,h,c,n)}const r=n[2]-n[0]+2*s,o=n[3]-n[1]+2*s,h=n[0]-s,l=n[1]-s,c=_(Bc,this).at(i?-1:-2),d=[c[0],c[2]];for(const t of _(Bc,this)){const[e,s,i]=t;t[0]=(e-h)/r,t[1]=(s-l)/o,t[2]=(i-l)/o}y(Oc,this,new Float32Array([h,l,r,o])),y(Wc,this,d)}getOutlines(){_(Bc,this).sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of _(Bc,this))e[3]?(t.push(...E($c,this,qc).call(this,e)),E($c,this,Gc).call(this,e)):(E($c,this,Vc).call(this,e),t.push(...E($c,this,qc).call(this,e)));return E($c,this,zc).call(this,t)}}function zc(t){const e=[],s=new Set;for(const s of t){const[t,i,n]=s;e.push([t,i,s],[t,n,s])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,i=e.length;t<i;t+=2){const i=e[t][2],n=e[t+1][2];i.push(n),n.push(i),s.add(i),s.add(n)}const i=[];let n;for(;s.size>0;){const t=s.values().next().value;let[e,a,r,o,h]=t;s.delete(t);let l=e,c=a;for(n=[e,r],i.push(n);;){let t;if(s.has(o))t=o;else{if(!s.has(h))break;t=h}s.delete(t),[e,a,r,o,h]=t,l!==e&&(n.push(l,c,e,c===a?a:r),l=e),c=c===a?r:a}n.push(l,c)}return new Xc(i,_(Oc,this),_(Wc,this))}function jc(t){const e=_(Hc,this);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,a=e[n][0];if(a===t)return n;a<t?s=n+1:i=n-1}return i+1}function Gc(t){let[,e,s]=t;const i=E($c,this,jc).call(this,e);_(Hc,this).splice(i,0,[e,s])}function Vc(t){let[,e,s]=t;const i=E($c,this,jc).call(this,e);for(let t=i;t<_(Hc,this).length;t++){const[i,n]=_(Hc,this)[t];if(i!==e)break;if(i===e&&n===s)return void _(Hc,this).splice(t,1)}for(let t=i-1;t>=0;t--){const[i,n]=_(Hc,this)[t];if(i!==e)break;if(i===e&&n===s)return void _(Hc,this).splice(t,1)}}function qc(t){const[e,s,i]=t,n=[[e,s,i]],a=E($c,this,jc).call(this,i);for(let t=0;t<a;t++){const[s,i]=_(Hc,this)[t];for(let t=0,a=n.length;t<a;t++){const[,r,o]=n[t];if(!(i<=r||o<=s))if(r>=s)if(o>i)n[t][1]=i;else{if(1===a)return[];n.splice(t,1),t--,a--}else n[t][2]=s,o>i&&n.push([e,i,o])}}return n}class Xc extends sc{#M;#C;constructor(t,e,s){super(),this.#C=t,this.#M=e,this.lastPoint=s}toSVGPath(){const t=[];for(const e of this.#C){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const a=e[n],r=e[n+1];a===s?(t.push(`V${r}`),i=r):r===i&&(t.push(`H${a}`),s=a)}t.push("Z")}return t.join(" ")}serialize(t,e){let[s,i,n,a]=t;const r=[],o=n-s,h=a-i;for(const t of this.#C){const e=new Array(t.length);for(let i=0;i<t.length;i+=2)e[i]=s+t[i]*o,e[i+1]=a-t[i+1]*h;r.push(e)}return r}get box(){return this.#M}get classNamesForOutlining(){return["highlightOutline"]}}class Yc extends bc{newFreeDrawOutline(t,e,s,i,n,a){return new Kc(t,e,s,i,n,a)}}class Kc extends Nc{newOutliner(t,e,s,i,n){return new Yc(t,e,s,i,n,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}}var Qc=new WeakMap,Jc=new WeakMap,Zc=new WeakMap,td=new WeakMap,ed=new WeakMap,sd=new WeakMap,id=new WeakMap,nd=new WeakMap,ad=new WeakMap,rd=new WeakMap,od=new WeakMap,hd=new WeakSet;class ld{static get _keyboardManager(){return bt(this,"_keyboardManager",new Le([[["Escape","mac+Escape"],ld.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ld.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ld.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ld.prototype._moveToPrevious],[["Home","mac+Home"],ld.prototype._moveToBeginning],[["End","mac+End"],ld.prototype._moveToEnd]]))}constructor(t){let{editor:e=null,uiManager:s=null}=t;b(this,hd),w(this,Qc,null),w(this,Jc,null),w(this,Zc,void 0),w(this,td,null),w(this,ed,!1),w(this,sd,!1),w(this,id,null),w(this,nd,void 0),w(this,ad,null),w(this,rd,null),w(this,od,void 0),e?(y(sd,this,!1),y(od,this,$.HIGHLIGHT_COLOR),y(id,this,e)):(y(sd,this,!0),y(od,this,$.HIGHLIGHT_DEFAULT_COLOR)),y(rd,this,e?._uiManager||s),y(nd,this,_(rd,this)._eventBus),y(Zc,this,e?.color||_(rd,this)?.highlightColors.values().next().value||"#FFFF98"),md._||(md._=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}renderButton(){const t=y(Qc,this,document.createElement("button"));
2t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=_(rd,this)._signal;t.addEventListener("click",E(hd,this,pd).bind(this),{signal:e}),t.addEventListener("keydown",E(hd,this,ud).bind(this),{signal:e});const s=y(Jc,this,document.createElement("span"));return s.className="swatch",s.setAttribute("aria-hidden",!0),s.style.backgroundColor=_(Zc,this),t.append(s),t}renderMainDropdown(){const t=y(td,this,E(hd,this,cd).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target===_(Qc,this))return void E(hd,this,pd).call(this,t);const e=t.target.getAttribute("data-color");e&&E(hd,this,dd).call(this,e,t)}_moveToNext(t){A(hd,this,fd)?t.target!==_(Qc,this)?t.target.nextSibling?.focus():_(td,this).firstChild?.focus():E(hd,this,pd).call(this,t)}_moveToPrevious(t){t.target!==_(td,this)?.firstChild&&t.target!==_(Qc,this)?(A(hd,this,fd)||E(hd,this,pd).call(this,t),t.target.previousSibling?.focus()):A(hd,this,fd)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){A(hd,this,fd)?_(td,this).firstChild?.focus():E(hd,this,pd).call(this,t)}_moveToEnd(t){A(hd,this,fd)?_(td,this).lastChild?.focus():E(hd,this,pd).call(this,t)}hideDropdown(){_(td,this)?.classList.add("hidden"),_(ad,this)?.abort(),y(ad,this,null)}_hideDropdownFromKeyboard(){_(sd,this)||(A(hd,this,fd)?(this.hideDropdown(),_(Qc,this).focus({preventScroll:!0,focusVisible:_(ed,this)})):_(id,this)?.unselect())}updateColor(t){if(_(Jc,this)&&(_(Jc,this).style.backgroundColor=t),!_(td,this))return;const e=_(rd,this).highlightColors.values();for(const s of _(td,this).children)s.setAttribute("aria-selected",e.next().value===t)}destroy(){_(Qc,this)?.remove(),y(Qc,this,null),y(Jc,this,null),_(td,this)?.remove(),y(td,this,null)}}function cd(){const t=document.createElement("div"),e=_(rd,this)._signal;t.addEventListener("contextmenu",jt,{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 _(rd,this).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",md._[s]);const a=document.createElement("span");n.append(a),a.className="swatch",a.style.backgroundColor=i,n.setAttribute("aria-selected",i===_(Zc,this)),n.addEventListener("click",E(hd,this,dd).bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",E(hd,this,ud).bind(this),{signal:e}),t}function dd(t,e){e.stopPropagation(),_(nd,this).dispatch("switchannotationeditorparams",{source:this,type:_(od,this),value:t})}function ud(t){d._keyboardManager.exec(this,t)}function pd(t){if(A(hd,this,fd))return void this.hideDropdown();if(y(ed,this,0===t.detail),_(ad,this)||(y(ad,this,new AbortController),window.addEventListener("pointerdown",E(hd,this,gd).bind(this),{signal:_(rd,this).combinedSignal(_(ad,this))})),_(td,this))return void _(td,this).classList.remove("hidden");const e=y(td,this,E(hd,this,cd).call(this));_(Qc,this).append(e)}function gd(t){_(td,this)?.contains(t.target)||this.hideDropdown()}function fd(t){return _(td,t)&&!_(td,t).classList.contains("hidden")}d=ld;var md={_:null},bd=new WeakMap,wd=new WeakMap,vd=new WeakMap,Ad=new WeakMap,_d=new WeakMap,yd=new WeakMap,xd=new WeakMap,Ed=new WeakMap,Sd=new WeakMap,kd=new WeakMap,Md=new WeakMap,Cd=new WeakMap,Td=new WeakMap,Rd=new WeakMap,Pd=new WeakMap,Id=new WeakMap,Ld=new WeakMap,Dd=new WeakMap,Nd=new WeakSet;class Fd extends tn{static get _keyboardManager(){const t=Fd.prototype;return bt(this,"_keyboardManager",new Le([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),b(this,Nd),w(this,bd,null),w(this,wd,0),w(this,vd,void 0),w(this,Ad,null),w(this,_d,null),w(this,yd,null),w(this,xd,null),w(this,Ed,0),w(this,Sd,null),w(this,kd,null),w(this,Md,null),w(this,Cd,!1),w(this,Td,null),w(this,Rd,void 0),w(this,Pd,null),w(this,Id,""),w(this,Ld,void 0),w(this,Dd,""),this.color=t.color||Fd._defaultColor,y(Ld,this,t.thickness||Fd._defaultThickness),y(Rd,this,t.opacity||Fd._defaultOpacity),y(vd,this,t.boxes||null),y(Dd,this,t.methodOfCreation||""),y(Id,this,t.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(y(Cd,this,!0),E(Nd,this,Wd).call(this,t),E(Nd,this,zd).call(this)):_(vd,this)&&(y(bd,this,t.anchorNode),y(wd,this,t.anchorOffset),y(xd,this,t.focu
2sNode),y(Ed,this,t.focusOffset),E(Nd,this,Od).call(this),E(Nd,this,zd).call(this),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:_(Cd,this)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:_(Ld,this),methodOfCreation:_(Dd,this)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,e){tn.initialize(t,e),Fd._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case $.HIGHLIGHT_DEFAULT_COLOR:Fd._defaultColor=e;break;case $.HIGHLIGHT_THICKNESS:Fd._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return _(Td,this)}updateParams(t,e){switch(t){case $.HIGHLIGHT_COLOR:E(Nd,this,Bd).call(this,e);break;case $.HIGHLIGHT_THICKNESS:E(Nd,this,Hd).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$.HIGHLIGHT_DEFAULT_COLOR,Fd._defaultColor],[$.HIGHLIGHT_THICKNESS,Fd._defaultThickness]]}get propertiesToUpdate(){return[[$.HIGHLIGHT_COLOR,this.color||Fd._defaultColor],[$.HIGHLIGHT_THICKNESS,_(Ld,this)||Fd._defaultThickness],[$.HIGHLIGHT_FREE,_(Cd,this)]]}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(y(_d,this,new ld({editor:this})),t.addColorPicker(_(_d,this))),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(E(Nd,this,qd).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,E(Nd,this,qd).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){E(Nd,this,Ud).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(E(Nd,this,zd).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?E(Nd,this,Ud).call(this):t&&(E(Nd,this,zd).call(this,t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}rotate(t){const{drawLayer:e}=this.parent;let s;_(Cd,this)?(t=(t-this.rotation+360)%360,s=jd.call(Fd,_(kd,this).box,t)):s=jd.call(Fd,[this.x,this.y,this.width,this.height],t),e.updateProperties(_(Md,this),{bbox:s,root:{"data-main-rotation":t}}),e.updateProperties(_(Pd,this),{bbox:jd.call(Fd,_(yd,this).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();_(Id,this)&&(t.setAttribute("aria-label",_(Id,this)),t.setAttribute("role","mark")),_(Cd,this)?t.classList.add("free"):this.div.addEventListener("keydown",E(Nd,this,Gd).bind(this),{signal:this._uiManager._signal});const e=y(Sd,this,document.createElement("div"));t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=_(Ad,this);const[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),xe(this,_(Sd,this),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(_(Pd,this),{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(_(Pd,this),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:E(Nd,this,Vd).call(this,!0);break;case 1:case 3:E(Nd,this,Vd).call(this,!1)}}select(){super.select(),_(Pd,this)&&this.parent?.drawLayer.updateProperties(_(Pd,this),{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),_(Pd,this)&&(this.parent?.drawLayer.updateProperties(_(Pd,this),{rootClass:{selected:!1}}),_(Cd,this)||E(Nd,this,Vd).call(this,!1))}get _mustFixPosition(){return!_(Cd,this)}show(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(_(Md,this),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(_(Pd,this),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,s){let{target:i,x:n,y:a}=s;const{x:r,y:o,width:h,height:l}=i.getBoundingClientRect(),c=new AbortController,d=t.combinedSignal(c),u=e=>{c.abort(),E(Fd,this,Qd).call(this,t,e)};window.addEventListener("blur",u,{signal:d}),window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("pointerdown",Gt,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",jt,{signal:d}),i.addEventListener("pointermove",E(Fd,this,Kd).bind(this,t),{signal:d}),this._freeHighlight=new Yc({x:n,y:a},[r,o,h,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static async deserialize(t,e,s){let i=null;if(t instanceof yl){const{data:{quadPoints:e,rect:s,rotation:n,id:a,color:r,opacity:o,popupRef:h},parent:{page:{pageNumber:l}}}=t;i=t={annotationType:H.HIGHLIGHT,color:Array.from(r),opacity:o,quadPoints:e,boxes:null,pageIndex:l-1,rect:s.slice(0),rotation:n,id:a,deleted:!1,popupRef:h}}else if(t instanceof Al){const{data:{inkLists:e,rect:s,rotation:n,id:a,color:r,borderStyle:{rawWidth:o},popupRef:h},parent:{page:{pageNumber:l}}}=t;i=t={annotationType:H.HIGHLIGHT,color:Array.from(r),thickness:o,inkLists:e,boxes:null,pageIndex:l-1,rect:s.slice(0),rotation:n,id:a,deleted:!1,popupRef:h}}const{color:n,quadPoints:a,inkLists:r,opacity:o}=t,h=await super.deserialize(t,e,s);h.color=Et.makeHexColor(...n),y(Rd,h,o||1),r&&y(Ld,h,t.thickness),h.annotationElementId=t.id||null,h._initialData=i;const[l,c]=h.pageDimensions,[d,u]=h.pageTranslation;if(a){const t=y(vd,h,[]);for(let e=0;e<a.length;e+=8)t.push({x:(a[e]-d)/l,y:1-(a[e+1]-u)/c,width:(a[e+2]-a[e])/l,height:(a[e+1]-a[e+5])/c});E(Nd,h,Od).call(h),E(Nd,h,zd).call(h),h.rotate(h.rotation)}else if(r){y(Cd,h,!0);const t=r[0],s={x:t[0]-d,y:c-(t[1]-u)},i=new Yc(s,[0,0,l,c],1,_(Ld,h)/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)s.x=t[e]-d,s.y=c-(t[e+1]-u),i.add(s);const{id:n,clipPathId:a}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:i.toSVGPath()}},!0,!0);E(Nd,h,Wd).call(h,{highlightOutlines:i.getOutlines(),highlightId:n,clipPathId:a}),E(Nd,h,zd).call(h),h.rotate(h.parentRotation)}return h}serialize(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),s=tn._colorManager.convert(this.color),i={annotationType:H.HIGHLIGHT,color:s,opacity:_(Rd,this),thickness:_(Ld,this),quadPoints:E(Nd,this,Xd).call(this),outlines:E(Nd,this,Yd).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:E(Nd,this,qd).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!E(Nd,this,Jd).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function Od(){const t=new Uc(_(vd,this),.001);y(kd,this,t.getOutlines()),[this.x,this.y,this.width,this.height]=_(kd,this).box;const e=new Uc(_(vd,this),.0025,.001,"ltr"===this._uiManager.direction);y(yd,this,e.getOutlines());const{lastPoint:s}=_(yd,this);y(Td,this,[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height])}function Wd(t){let{highlightOutlines:e,highlightId:s,clipPathId:i}=t;y(kd,this,e);if(y(yd,this,e.getNewOutline(_(Ld,this)/2+1.5,.0025)),s>=0)y(Md,this,s),y(Ad,this,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),y(Pd,this,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:_(yd,this).box,path:{d:_(yd,this).toSVGPath()}},!0));else if(this.parent){const t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(_(Md,this),{bbox:jd.call(u,_(kd,this).box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(_(Pd,this),{bbox:jd.call(u,_(yd,this).box,t),path:{d:_(yd,this).toSVGPath()}})}const[n,a,r,o]=e.box;switch(this.rotation){case 0:this.x=n,this.y=a,this.width=r,this.height=o;break;case 90:{const[t,e]=this.parentDimensions;this.x=a,this.y=1-n,this.width=r*e/t,this.height=o*t/e;break}case 180:this.x=1-n,this.y=1-a,this.width=r,this.height=o;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-a,this.y=n,this.width=r*e/t,this.height=o*t/e;break}}const{lastPoint:h}=_(yd,this);y(Td,this,[(h[0]-n)/r,(h[1]-a)/o])}function Bd(t){const e=(t,e)=>{this.color=t,y(Rd,this,e),this.parent?.drawLayer.updateProperties(_(Md,this),{root:{fill:t,"fill-opacity":e}}),_(_d,this)?.updateColor(t)},s=this.color,i=_(Rd,this);this.addCommands({cmd:e.bind(this,t,u._defaultOpacity),undo:e.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}function Hd(t){const e=_(Ld,this),s=t=>{y(Ld,this,t),E(Nd,this,$d).call(this,t)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}function $d(t){if(!_(Cd,this))return;E(Nd,this,Wd).call(this,{highlightOutlines:_(kd,this).getNewOutline(t/2)}),this.fixAndSetPosition();const[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)}function Ud(){null!==_(Md,this)&&this.parent&&(this.parent.drawLayer.remove(_(Md,this)),y(Md,this,null),this.parent.drawLayer.remove(_(Pd,this)),y(Pd,this,null))}function zd(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null===_(Md,this)&&(({id:m(y,[Md,this])._,clipPathId:m(y,[Ad,this])._}=t.drawLayer.draw({bbox:_(kd,this).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":_(Rd,this)},rootClass:{highlight:!0,free:_(Cd,this)},path:{d:_(kd,this).toSVGPath()}},!1,!0)),y(Pd,this,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:_(Cd,this)},bbox:_(yd,this).box,path:{d:_(yd,this).toSVGPath()}},_(Cd,this))),_(Sd,this)&&(_(Sd,this).style.clipPath=_(Ad,this)))}
2function jd(t,e){let[s,i,n,a]=t;switch(e){case 90:return[1-i-a,s,a,n];case 180:return[1-s-n,1-i-a,n,a];case 270:return[i,1-s-n,a,n]}return[s,i,n,a]}function Gd(t){u._keyboardManager.exec(this,t)}function Vd(t){if(!_(bd,this))return;const e=window.getSelection();t?e.setPosition(_(bd,this),_(wd,this)):e.setPosition(_(xd,this),_(Ed,this))}function qd(){return _(Cd,this)?this.rotation:0}function Xd(){if(_(Cd,this))return null;const[t,e]=this.pageDimensions,[s,i]=this.pageTranslation,n=_(vd,this),a=new Float32Array(8*n.length);let r=0;for(const{x:o,y:h,width:l,height:c}of n){const n=o*t+s,d=(1-h)*e+i;a[r]=a[r+4]=n,a[r+1]=a[r+3]=d,a[r+2]=a[r+6]=n+l*t,a[r+5]=a[r+7]=d-c*e,r+=8}return a}function Yd(t){return _(kd,this).serialize(t,E(Nd,this,qd).call(this))}function Kd(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}function Qd(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}function Jd(t){const{color:e}=this._initialData;return t.color.some(((t,s)=>t!==e[s]))}u=Fd,x(Fd,"_defaultColor",null),x(Fd,"_defaultOpacity",1),x(Fd,"_defaultThickness",12),x(Fd,"_type","highlight"),x(Fd,"_editorType",H.HIGHLIGHT),x(Fd,"_freeHighlightId",-1),x(Fd,"_freeHighlight",null),x(Fd,"_freeHighlightClipId","");class Zd{#T=(()=>Object.create(null))();updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){this.#T[t]=e}toSVGProperties(){const t=this.#T;return this.#T=Object.create(null),{root:t}}reset(){this.#T=Object.create(null)}updateAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this;this.updateProperties(t)}clone(){gt("Not implemented")}}var tu=new WeakMap,eu=new WeakMap,su=new WeakSet;class iu extends tn{constructor(t){super(t),b(this,su),w(this,tu,null),w(this,eu,void 0),x(this,"_drawId",null),y(eu,this,t.mustBeCommitted||!1),this._addOutlines(t)}_addOutlines(t){t.drawOutlines&&(E(su,this,nu).call(this,t),E(su,this,ou).call(this))}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[i,n]of Object.entries(e))s.has(i)?Object.assign(t[i],n):t[i]=n;return t}static getDefaultDrawingOptions(t){gt("Not implemented")}static get typesMap(){gt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&(uu._.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){const i=this._drawingOptions,n=i[e],a=t=>{i.updateProperty(e,t);const s=_(tu,this).updateProperty(e,t);s&&E(su,this,cu).call(this,s),this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties())};this.addCommands({cmd:a.bind(this,s),undo:a.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,iu._mergeSVGProperties(_(tu,this).getPathResizingSVGProperties(E(su,this,lu).call(this)),{bbox:E(su,this,du).call(this)}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,iu._mergeSVGProperties(_(tu,this).getPathResizedSVGProperties(E(su,this,lu).call(this)),{bbox:E(su,this,du).call(this)}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:E(su,this,du).call(this)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,iu._mergeSVGProperties(_(tu,this).getPathTranslatedSVGProperties(E(su,this,lu).call(this),this.parentDimensions),{bbox:E(su,this,du).call(this)}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,_(eu,this)&&(y(eu,this,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){E(su,this,ru).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(E(su,this,ou).call(this),E(su,this,cu).call(this,_(tu,this).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),E(su,this,ru).call(this)):t&&(this._uiManager.addShouldRescale(this),E(su,this,ou).call(this,t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,iu._mergeSVGProperties({bbox:E(su,this,du).call(this)},_(tu,this).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&E(su,this,cu).call(this,_(tu,this).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}
2render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const s=super.render();s.classList.add("draw");const i=document.createElement("div");s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal";const[n,a]=this.parentDimensions;return this.setDims(this.width*n,this.height*a),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),s}static createDrawerInstance(t,e,s,i,n){gt("Not implemented")}static startDrawing(t,e,s,i){const{target:n,offsetX:a,offsetY:r,pointerId:o,pointerType:h}=i;if(mu._&&mu._!==h)return;const{viewport:{rotation:l}}=t,{width:c,height:d}=n.getBoundingClientRect(),u=pu._=new AbortController,p=t.combinedSignal(u);fu._||(fu._=o),mu._??(mu._=h),window.addEventListener("pointerup",(t=>{fu._===t.pointerId?this._endDraw(t):bu._?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{fu._===t.pointerId?this._currentParent.endDrawingSession():bu._?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{mu._===t.pointerType&&((bu._||(bu._=new Set)).add(t.pointerId),uu._.isCancellable()&&(uu._.removeLastElement(),uu._.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",jt,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===wu._&&Gt(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),uu._?t.drawLayer.updateProperties(this._currentDrawId,uu._.startNew(a,r,c,d,l)):(e.updateUIForDefaultProperties(this),uu._=this.createDrawerInstance(a,r,c,d,l),gu._=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(gu._.toSVGProperties(),uu._.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(wu._=-1,!uu._)return;const{offsetX:e,offsetY:s,pointerId:i}=t;fu._===i&&(bu._?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,uu._.add(e,s)),wu._=t.timeStamp,Gt(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,uu._=null,gu._=null,mu._=null,wu._=NaN),pu._&&(pu._.abort(),pu._=null,fu._=NaN,bu._=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,uu._.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=uu._,s=this._currentDrawId,i=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(s,t.setLastElement(i))},undo:()=>{e.drawLayer.updateProperties(s,t.removeLastElement())},mustExec:!1,type:$.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack($.DRAW_STEP),!uu._.isEmpty()){const{pageDimensions:[s,i],scale:n}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:uu._.getOutlines(s*n,i*n,n,this._INNER_MARGIN),drawingOptions:gu._,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,n,a){gt("Not implemented")}static async deserialize(t,e,s){const{rawDims:{pageWidth:i,pageHeight:n,pageX:a,pageY:r}}=e.viewport,o=this.deserializeDraw(a,r,i,n,this._INNER_MARGIN,t),h=await super.deserialize(t,e,s);return h.createDrawingOptions(t),E(su,h,nu).call(h,{drawOutlines:o}),E(su,h,ou).call(h),h.onScaleChanging(),h.rotate(),h}serializeDraw(t){const[e,s]=this.pageTranslation,[i,n]=this.pageDimensions;return _(tu,this).serialize([e,s,i,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function nu(t){let{drawOutlines:e,drawId:s,drawingOptions:i}=t;y(tu,this,e),this._drawingOptions||=i,s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=E(su,this,au).call(this,e,this.parent),E(su,this,cu).call(this,e.box)}function au(t,e){const{id:s}=e.drawLayer.draw(p._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return s}function ru(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}function ou(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=E(su,this,au).call(this,_(tu,this),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}function hu(t){let[e,s,i,n]=t;const{parentDimensions:[a,r],rotation:o}=this;switch(o){case 90:return[s,1-e,i*(r/a),n*(a/r)];case 180:return[1-e,1-s,i,n];case 270:return[1-s,e,i*(r/a),n*(a/r)];default:return[e,s,i,n]}}function lu(){const{x:t,y:e,width:s,height:i,parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[1-e,t,s*(n/a),i*(a/n)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(n/a),i*(a/n)];default:return[t,e,s,i]}}function cu(t){if([this.x,this.y,this.width,this.height]=E(su,this,hu).call(this,t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}function du(){const{x:t,y:e,width:s,height:i,rotation:n,parentRotation:a,parentDimensions:[r,o]}=this;switch((4*n+a)/90){case 1:return[1-e-i,t,i,s];case 2:return[1-t-s,1-e-i,s,i];case 3:return[e,1-t-s,i,s];case 4:return[t,e-s*(r/o),i*(o/r),s*(r/o)];case 5:return[1-e,t,s*(r/o),i*(o/r)];case 6:return[1-t-i*(o/r),1-e,i*(o/r),s*(r/o)];case 7:return[e-s*(r/o),1-t-i*(o/r),s*(r/o),i*(o/r)];case 8:return[t-s,e-i,s,i];case 9:return[1-e,t-s,i,s];case 10:return[1-t,1-e,s,i];case 11:return[e-i,1-t,i,s];case 12:return[t-i*(o/r),e,i*(o/r),s*(r/o)];case 13:return[1-e-s*(r/o),t-i*(o/r),s*(r/o),i*(o/r)];case 14:return[1-t,1-e-s*(r/o),i*(o/r),s*(r/o)];case 15:return[e,1-t,s*(r/o),i*(o/r)];default:return[t,e,s,i]}}p=iu,x(iu,"_currentDrawId",-1),x(iu,"_currentParent",null);var uu={_:null},pu={_:null},gu={_:null},fu={_:NaN},mu={_:null},bu={_:null},wu={_:NaN};x(iu,"_INNER_MARGIN",3);var vu=new WeakMap,Au=new WeakMap,_u=new WeakMap,yu=new WeakMap,xu=new WeakMap,Eu=new WeakMap,Su=new WeakMap,ku=new WeakMap,Mu=new WeakMap,Cu=new WeakMap,Tu=new WeakMap,Ru=new WeakSet;class Pu{constructor(t,e,s,i,n,a){b(this,Ru),w(this,vu,new Float64Array(6)),w(this,Au,void 0),w(this,_u,void 0),w(this,yu,void 0),w(this,xu,void 0),w(this,Eu,void 0),w(this,Su,""),w(this,ku,0),w(this,Mu,new zu),w(this,Cu,void 0),w(this,Tu,void 0),y(Cu,this,s),y(Tu,this,i),y(yu,this,n),y(xu,this,a),[t,e]=E(Ru,this,Iu).call(this,t,e);const r=y(Au,this,[NaN,NaN,NaN,NaN,t,e]);y(Eu,this,[t,e]),y(_u,this,[{line:r,points:_(Eu,this)}]),_(vu,this).set(r,0)}updateProperty(t,e){"stroke-width"===t&&y(xu,this,e)}isEmpty(){return!_(_u,this)||0===_(_u,this).length}isCancellable(){return _(Eu,this).length<=10}add(t,e){[t,e]=E(Ru,this,Iu).call(this,t,e);const[s,i,n,a]=_(vu,this).subarray(2,6),r=t-n,o=e-a;return Math.hypot(_(Cu,this)*r,_(Tu,this)*o)<=2?null:(_(Eu,this).push(t,e),isNaN(s)?(_(vu,this).set([n,a,t,e],2),_(Au,this).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(_(vu,this)[0])&&_(Au,this).splice(6,6),_(vu,this).set([s,i,n,a,t,e],0),_(Au,this).push(...sc.createBezierPoints(s,i,n,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(2===_(Eu,this).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,n){y(Cu,this,s),y(Tu,this,i),y(yu,this,n),[t,e]=E(Ru,this,Iu).call(this,t,e);const a=y(Au,this,[NaN,NaN,NaN,NaN,t,e]);y(Eu,this,[t,e]);const r=_(_u,this).at(-1);return r&&(r.line=new Float32Array(r.line),r.points=new Float32Array(r.points)),_(_u,this).push({line:a,points:_(Eu,this)}),_(vu,this).set(a,0),y(ku,this,0),this.toSVGPath(),null}getLastElement(){return _(_u,this).at(-1)}setLastElement(t){return _(_u,this)?(_(_u,this).push(t),y(Au,this,t.line),y(Eu,this,t.points),y(ku,this,0),{path:{d:this.toSVGPath()}}):_(Mu,this).setLastElement(t)}removeLastElement(){if(!_(_u,this))return _(Mu,this).removeLastElement();_(_u,this).pop(),y(Su,this,"");for(let t=0,e=_(_u,this).length;t<e;t++){const{line:e,points:s}=_(_u,this)[t];y(Au,this,e),y(Eu,this,s),y(ku,this,0),this.toSVGPath()}return{path:{d:_(Su,this)}}}toSVGPath(){const t=sc.svgRound(_(Au,this)[4]),e=sc.svgRound(_(Au,this)[5]);if(2===_(Eu,this).length)return y(Su,this,`${_(Su,this)} M ${t} ${e} Z`),_(Su,this);if(_(Eu,this).length<=6){const s=_(Su,this).lastIndexOf("M");y(Su,this,`${_(Su,this).slice(0,s)} M ${t} ${e}
vendor: 4,644 bytes, line 2
2`),y(ku,this,6)}if(4===_(Eu,this).length){const t=sc.svgRound(_(Au,this)[10]),e=sc.svgRound(_(Au,this)[11]);return y(Su,this,`${_(Su,this)} L ${t} ${e}`),y(ku,this,12),_(Su,this)}const s=[];0===_(ku,this)&&(s.push(`M ${t} ${e}`),y(ku,this,6));for(let t=_(ku,this),e=_(Au,this).length;t<e;t+=6){const[e,i,n,a,r,o]=_(Au,this).slice(t,t+6).map(sc.svgRound);s.push(`C${e} ${i} ${n} ${a} ${r} ${o}`)}return y(Su,this,_(Su,this)+s.join(" ")),y(ku,this,_(Au,this).length),_(Su,this)}getOutlines(t,e,s,i){const n=_(_u,this).at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),_(Mu,this).build(_(_u,this),t,e,s,_(yu,this),_(xu,this),i),y(vu,this,null),y(Au,this,null),y(_u,this,null),y(Su,this,null),_(Mu,this)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}function Iu(t,e){return sc._normalizePoint(t,e,_(Cu,this),_(Tu,this),_(yu,this))}var Lu=new WeakMap,Du=new WeakMap,Nu=new WeakMap,Fu=new WeakMap,Ou=new WeakMap,Wu=new WeakMap,Bu=new WeakMap,Hu=new WeakMap,$u=new WeakMap,Uu=new WeakSet;class zu extends sc{constructor(){super(...arguments),b(this,Uu),w(this,Lu,void 0),w(this,Du,0),w(this,Nu,void 0),w(this,Fu,void 0),w(this,Ou,void 0),w(this,Wu,void 0),w(this,Bu,void 0),w(this,Hu,void 0),w(this,$u,void 0)}build(t,e,s,i,n,a,r){y(Ou,this,e),y(Wu,this,s),y(Bu,this,i),y(Hu,this,n),y($u,this,a),y(Nu,this,r??0),y(Fu,this,t),E(Uu,this,Vu).call(this)}get thickness(){return _($u,this)}setLastElement(t){return _(Fu,this).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return _(Fu,this).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of _(Fu,this))if(t.push(`M${sc.svgRound(e[4])} ${sc.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${sc.svgRound(e[10])} ${sc.svgRound(e[11])}`);else for(let s=6,i=e.length;s<i;s+=6){const[i,n,a,r,o,h]=e.subarray(s,s+6).map(sc.svgRound);t.push(`C${i} ${n} ${a} ${r} ${o} ${h}`)}else t.push("Z");return t.join("")}serialize(t,e){let[s,i,n,a]=t;const r=[],o=[],[h,l,c,d]=E(Uu,this,Gu).call(this);let u,p,g,f,m,b,w,v,A;switch(_(Hu,this)){case 0:A=sc._rescale,u=s,p=i+a,g=n,f=-a,m=s+h*n,b=i+(1-l-d)*a,w=s+(h+c)*n,v=i+(1-l)*a;break;case 90:A=sc._rescaleAndSwap,u=s,p=i,g=n,f=a,m=s+l*n,b=i+h*a,w=s+(l+d)*n,v=i+(h+c)*a;break;case 180:A=sc._rescale,u=s+n,p=i,g=-n,f=a,m=s+(1-h-c)*n,b=i+l*a,w=s+(1-h)*n,v=i+(l+d)*a;break;case 270:A=sc._rescaleAndSwap,u=s+n,p=i+a,g=-n,f=-a,m=s+(1-l-d)*n,b=i+(1-h-c)*a,w=s+(1-l)*n,v=i+(1-h)*a}for(const{line:t,points:s}of _(Fu,this))r.push(A(t,u,p,g,f,e?new Array(t.length):null)),o.push(A(s,u,p,g,f,e?new Array(s.length):null));return{lines:r,points:o,rect:[m,b,w,v]}}static deserialize(t,e,s,i,n,a){let{paths:{lines:r,points:o},rotation:h,thickness:l}=a;const c=[];let d,u,p,g,f;switch(h){case 0:f=sc._rescale,d=-t/s,u=e/i+1,p=1/s,g=-1/i;break;case 90:f=sc._rescaleAndSwap,d=-e/i,u=-t/s,p=1/i,g=1/s;break;case 180:f=sc._rescale,d=t/s+1,u=-e/i,p=-1/s,g=1/i;break;case 270:f=sc._rescaleAndSwap,d=e/i+1,u=t/s+1,p=-1/i,g=-1/s}if(!r){r=[];for(const t of o){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const s=new Float32Array(3*(e-2));r.push(s);let[i,n,a,o]=t.subarray(0,4);s.set([NaN,NaN,NaN,NaN,i,n],0);for(let r=4;r<e;r+=2){const e=t[r],h=t[r+1];s.set(sc.createBezierPoints(i,n,a,o,e,h),3*(r-2)),[i,n,a,o]=[a,o,e,h]}}}for(let t=0,e=r.length;t<e;t++)c.push({line:f(r[t].map((t=>t??NaN)),d,u,p,g),points:f(o[t].map((t=>t??NaN)),d,u,p,g)});const m=new this.prototype.constructor;return m.build(c,s,i,1,h,l,n),m}get box(){return _(Lu,this)}updateProperty(t,e){return"stroke-width"===t?E(Uu,this,qu).call(this,e):null}updateParentDimensions(t,e){let[s,i]=t;const[n,a]=E(Uu,this,ju).call(this);y(Ou,this,s),y(Wu,this,i),y(Bu,this,e);const[r,o]=E(Uu,this,ju).call(this),h=r-n,l=o-a,c=_(Lu,this);return c[0]-=h,c[1]-=l,c[2]+=2*h,c[3]+=2*l,c}updateRotation(t){return y(Du,this,t),{path:{transform:this.rotationTransform}}}get viewBox(){return _(Lu,this).map(sc.svgRound).join(" ")}get defaultProperties(){const[t,e]=_(Lu,this);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sc.svgRound(t)} ${sc.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=_(Lu,this);let s=0,i=0,n=0,a=0,r=0,o=0;switch(_(Du,this)){case 90:i=e/t,n=-t/e,r=t;break;case 180:s=-1,a=-1,r=t,o=e;break;case 270:i=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${n} ${a} ${sc.svgRound(r)} ${sc.svgRound(o)})`}getPathResizingSVGProperties(t){let[e,s,i,n]=t;const[a,r]=E(Uu,this,ju).call(this),[o,h,l,c]=_(Lu,this);
2if(Math.abs(l-a)<=sc.PRECISION||Math.abs(c-r)<=sc.PRECISION){const t=e+i/2-(o+l/2),a=s+n/2-(h+c/2);return{path:{"transform-origin":`${sc.svgRound(e)} ${sc.svgRound(s)}`,transform:`${this.rotationTransform} translate(${t} ${a})`}}}const d=(i-2*a)/(l-2*a),u=(n-2*r)/(c-2*r),p=l/i,g=c/n;return{path:{"transform-origin":`${sc.svgRound(o)} ${sc.svgRound(h)}`,transform:`${this.rotationTransform} scale(${p} ${g}) translate(${sc.svgRound(a)} ${sc.svgRound(r)}) scale(${d} ${u}) translate(${sc.svgRound(-a)} ${sc.svgRound(-r)})`}}}getPathResizedSVGProperties(t){let[e,s,i,n]=t;const[a,r]=E(Uu,this,ju).call(this),o=_(Lu,this),[h,l,c,d]=o;if(o[0]=e,o[1]=s,o[2]=i,o[3]=n,Math.abs(c-a)<=sc.PRECISION||Math.abs(d-r)<=sc.PRECISION){const t=e+i/2-(h+c/2),a=s+n/2-(l+d/2);for(const{line:e,points:s}of _(Fu,this))sc._translate(e,t,a,e),sc._translate(s,t,a,s);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sc.svgRound(e)} ${sc.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(i-2*a)/(c-2*a),p=(n-2*r)/(d-2*r),g=-u*(h+a)+e+a,f=-p*(l+r)+s+r;if(1!==u||1!==p||0!==g||0!==f)for(const{line:t,points:e}of _(Fu,this))sc._rescale(t,g,f,u,p,t),sc._rescale(e,g,f,u,p,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sc.svgRound(e)} ${sc.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties(t,e){let[s,i]=t;const[n,a]=e,r=_(Lu,this),o=s-r[0],h=i-r[1];if(_(Ou,this)===n&&_(Wu,this)===a)for(const{line:t,points:e}of _(Fu,this))sc._translate(t,o,h,t),sc._translate(e,o,h,e);else{const t=_(Ou,this)/n,e=_(Wu,this)/a;y(Ou,this,n),y(Wu,this,a);for(const{line:s,points:i}of _(Fu,this))sc._rescale(s,o,h,t,e,s),sc._rescale(i,o,h,t,e,i);r[2]*=t,r[3]*=e}return r[0]=s,r[1]=i,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${sc.svgRound(s)} ${sc.svgRound(i)}`}}}get defaultSVGProperties(){const t=_(Lu,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${sc.svgRound(t[0])} ${sc.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}function ju(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_($u,this);const e=_(Nu,this)+t/2*_(Bu,this);return _(Hu,this)%180==0?[e/_(Ou,this),e/_(Wu,this)]:[e/_(Wu,this),e/_(Ou,this)]}function Gu(){const[t,e,s,i]=_(Lu,this),[n,a]=E(Uu,this,ju).call(this,0);return[t+n,e+a,s-2*n,i-2*a]}function Vu(){const t=y(Lu,this,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:e}of _(Fu,this)){if(e.length<=12){for(let s=4,i=e.length;s<i;s+=6)Et.pointBoundingBox(e[s],e[s+1],t);continue}let s=e[4],i=e[5];for(let n=6,a=e.length;n<a;n+=6){const[a,r,o,h,l,c]=e.subarray(n,n+6);Et.bezierBoundingBox(s,i,a,r,o,h,l,c,t),s=l,i=c}}const[e,s]=E(Uu,this,ju).call(this);t[0]=It(t[0]-e,0,1),t[1]=It(t[1]-s,0,1),t[2]=It(t[2]+e,0,1),t[3]=It(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}function qu(t){const[e,s]=E(Uu,this,ju).call(this);y($u,this,t);const[i,n]=E(Uu,this,ju).call(this),[a,r]=[i-e,n-s],o=_(Lu,this);return o[0]-=a,o[1]-=r,o[2]+=2*a,o[3]+=2*r,o}class Xu extends Zd{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:tn._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Xu(this._viewParameters);return t.updateAll(this),t}}var Yu=new WeakSet;class Ku extends iu{constructor(t){super({...t,name:"inkEditor"}),b(this,Yu),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){tn.initialize(t,e),this._defaultDrawingOptions=new Xu(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return bt(this,"typesMap",new Map([[$.INK_THICKNESS,"stroke-width"],[$.INK_COLOR,"stroke"],[$.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,i,n){return new Pu(t,e,s,i,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,n,a){return zu.deserialize(t,e,s,i,n,a)}static async deserialize(t,e,s){let i=null;if(t instanceof Al){const{data:{inkLists:e,rect:s,rotation:n,id:a,color:r,opacity:o,borderStyle:{rawWidth:h},popupRef:l},parent:{page:{pageNumber:c}}}=t;i=t={annotationType:H.INK,color:Array.from(r),thickness:h,opacity:o,paths:{points:e},boxes:null,pageIndex:c-1,rect:s.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}const n=await super.deserialize(t,e,s);return n.annotationElementId=t.id||null,n._initialData=i,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions(t){let{color:e,thickness:s,opacity:i}=t;this._drawingOptions=Ku.getDefaultDrawingOptions({stroke:Et.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:s,rect:i}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":a,"stroke-width":r}}=this,o={annotationType:H.INK,color:tn._colorManager.convert(n),opacity:a,thickness:r,paths:{lines:e,points:s},pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(o.isCopy=!0,o):this.annotationElementId&&!E(Yu,this,Qu).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){const{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e}),null}}function Qu(t){const{color:e,thickness:s,opacity:i,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,s)=>t!==e[s]))||t.thickness!==s||t.opacity!==i||t.pageIndex!==n}x(Ku,"_type","ink"),x(Ku,"_editorType",H.INK),x(Ku,"_defaultDrawingOptions",null);class Ju extends zu{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class Zu{static extractContoursFromText(t,e,s,i,n,a){let{fontFamily:r,fontStyle:o,fontWeight:h}=e,l=new OffscreenCanvas(1,1),c=l.getContext("2d",{alpha:!1});const d=c.font=`${o} ${h} 200px ${r}`,{actualBoundingBoxLeft:u,actualBoundingBoxRight:p,actualBoundingBoxAscent:g,actualBoundingBoxDescent:f,fontBoundingBoxAscent:m,fontBoundingBoxDescent:b,width:w}=c.measureText(t),v=1.5,A=Math.ceil(Math.max(Math.abs(u)+Math.abs(p)||0,w)*v),_=Math.ceil(Math.max(Math.abs(g)+Math.abs(f)||200,Math.abs(m)+Math.abs(b)||200)*v);l=new OffscreenCanvas(A,_),c=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=d,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,A,_),c.fillStyle="black",c.fillText(t,.5*A/2,1.5*_/2);const y=E(Zu,this,hp).call(this,c.getImageData(0,0,A,_).data),x=E(Zu,this,op).call(this,y),S=E(Zu,this,lp).call(this,x),k=E(Zu,this,ip).call(this,y,A,_,S);return this.processDrawnLines({lines:{curves:k,width:A,height:_},pageWidth:s,pageHeight:i,rotation:n,innerMargin:a,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,n){const[a,r,o]=E(Zu,this,cp).call(this,t),[h,l]=E(Zu,this,rp).call(this,a,r,o,Math.hypot(r,o)*E(Zu,this,dp)._.sigmaSFactor,E(Zu,this,dp)._.sigmaR,E(Zu,this,dp)._.kernelSize),c=E(Zu,this,lp).call(this,l),d=E(Zu,this,ip).call(this,h,r,o,c);return this.processDrawnLines({lines:{curves:d,width:r,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines(t){let{lines:e,pageWidth:s,pageHeight:i,rotation:n,innerMargin:a,mustSmooth:r,areContours:o}=t;n%180!=0&&([s,i]=[i,s]);const{curves:h,width:l,height:c}=e,d=e.thickness??0,u=[],p=Math.min(s/l,i/c),g=p/s,f=p/i,m=[];for(const{points:t}of h){const e=r?E(Zu,this,ap).call(this,t):t;if(!e)continue;m.push(e);const s=e.length,i=new Float32Array(s),n=new Float32Array(3*(2===s?2:s-2));if(u.push({line:n,points:i}
2),2===s){i[0]=e[0]*g,i[1]=e[1]*f,n.set([NaN,NaN,NaN,NaN,i[0],i[1]],0);continue}let[a,o,h,l]=e;a*=g,o*=f,h*=g,l*=f,i.set([a,o,h,l],0),n.set([NaN,NaN,NaN,NaN,a,o],0);for(let t=4;t<s;t+=2){const s=i[t]=e[t]*g,r=i[t+1]=e[t+1]*f;n.set(sc.createBezierPoints(a,o,h,l,s,r),3*(t-2)),[a,o,h,l]=[h,l,s,r]}}if(0===u.length)return null;const b=o?new Ju:new zu;return b.build(u,s,i,1,n,o?0:d,a),{outline:b,newCurves:m,areContours:o,thickness:d,width:l,height:c}}static async compressSignature(t){let e,{outlines:s,areContours:i,thickness:n,width:a,height:r}=t,o=1/0,h=-1/0,l=0;for(const t of s){l+=t.length;for(let e=2,s=t.length;e<s;e++){const s=t[e]-t[e-2];o=Math.min(o,s),h=Math.max(h,s)}}e=o>=-128&&h<=127?Int8Array:o>=-32768&&h<=32767?Int16Array:Int32Array;const c=s.length,d=8+3*c,u=new Uint32Array(d);let p=0;u[p++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*e.BYTES_PER_ELEMENT,u[p++]=0,u[p++]=a,u[p++]=r,u[p++]=i?0:1,u[p++]=Math.max(0,Math.floor(n??0)),u[p++]=c,u[p++]=e.BYTES_PER_ELEMENT;for(const t of s)u[p++]=t.length-2,u[p++]=t[0],u[p++]=t[1];const g=new CompressionStream("deflate-raw"),f=g.writable.getWriter();await f.ready,f.write(u);const m=e.prototype.constructor;for(const t of s){const e=new m(t.length-2);for(let s=2,i=t.length;s<i;s++)e[s-2]=t[s]-t[s-2];f.write(e)}f.close();const b=await new Response(g.readable).arrayBuffer();return Lt(new Uint8Array(b))}static async decompressSignature(t){try{const s=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):At(atob(e))),{readable:i,writable:n}=new DecompressionStream("deflate-raw"),a=n.getWriter();await a.ready,a.write(s).then((async()=>{await a.ready,await a.close()})).catch((()=>{}));let r=null,o=0;for await(const t of i)r||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),r.set(t,o),o+=t.length;const h=new Uint32Array(r.buffer,0,r.length>>2),l=h[1];if(0!==l)throw new Error(`Invalid version: ${l}`);const c=h[2],d=h[3],u=0===h[4],p=h[5],g=h[6],f=h[7],m=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;let w;switch(f){case Int8Array.BYTES_PER_ELEMENT:w=new Int8Array(r.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:w=new Int16Array(r.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:w=new Int32Array(r.buffer,b)}o=0;for(let t=0;t<g;t++){const e=h[3*t+8],s=new Float32Array(e+2);m.push(s);for(let e=0;e<2;e++)s[e]=h[3*t+8+e+1];for(let t=0;t<e;t++)s[t+2]=s[t]+w[o++]}return{areContours:u,thickness:p,outlines:m,width:c,height:d}}catch(t){return pt(`decompressSignature: ${t}`),null}var e}}function tp(t,e,s,i){return i-=e,0===(s-=t)?i>0?0:4:1===s?i+6:2-i}function ep(t,e,s,i,n,a,r){const o=E(g,this,tp).call(this,s,i,n,a);for(let n=0;n<8;n++){const a=(-n+o-r+16)%8;if(0!==t[(s+E(g,this,up)._[2*a])*e+(i+E(g,this,up)._[2*a+1])])return a}return-1}function sp(t,e,s,i,n,a,r){const o=E(g,this,tp).call(this,s,i,n,a);for(let n=0;n<8;n++){const a=(n+o+r+16)%8;if(0!==t[(s+E(g,this,up)._[2*a])*e+(i+E(g,this,up)._[2*a+1])])return a}return-1}function ip(t,e,s,i){const n=t.length,a=new Int32Array(n);for(let e=0;e<n;e++)a[e]=t[e]<=i?1:0;for(let t=1;t<s-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*s-1-t]=0;let r,o=1;const h=[];for(let t=1;t<s-1;t++){r=1;for(let s=1;s<e-1;s++){const i=t*e+s,n=a[i];if(0===n)continue;let l=t,c=s;if(1===n&&0===a[i-1])o+=1,c-=1;else{if(!(n>=1&&0===a[i+1])){1!==n&&(r=Math.abs(n));continue}o+=1,c+=1,n>1&&(r=n)}const d=[s,t],u=c===s+1,p={isHole:u,points:d,id:o,parent:0};let f;h.push(p);for(const t of h)if(t.id===r){f=t;break}f?f.isHole?p.parent=u?f.parent:r:p.parent=u?r:f.parent:p.parent=u?r:0;const m=E(g,this,ep).call(this,a,e,t,s,l,c,0);if(-1===m){a[i]=-o,1!==a[i]&&(r=Math.abs(a[i]));continue}let b=E(g,this,up)._[2*m],w=E(g,this,up)._[2*m+1];const v=t+b,A=s+w;l=v,c=A;let _=t,y=s;for(;;){const n=E(g,this,sp).call(this,a,e,_,y,l,c,1);b=E(g,this,up)._[2*n],w=E(g,this,up)._[2*n+1];const h=_+b,u=y+w;d.push(u,h);const p=_*e+y;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),h===t&&u===s&&_===v&&y===A){1!==a[i]&&(r=Math.abs(a[i]));break}l=_,c=y,_=h,y=u}}}return h}function np(t,e,s,i){if(s-e<=4){for(let n=e;n<s-2;n+=2)i.push(t[n],t[n+1]);return}const n=t[e],a=t[e+1],r=t[s-4]-n,o=t[s-3]-a,h=Math.hypot(r,o),l=r/h,c=o/h,d=l*a-c*n,u=o/r,p=1/h,f=Math.atan(u),m=Math.cos(f),b=Math.sin(f),w=p*(Math.abs(m)+Math.abs(b)),v=p*(1-w+w**2),A=Math.max(Math.atan(Math.abs(b+m)*v),Math.atan(Math.abs(b-m)*v));let _=0,y=e;for(let i=e+2;i<s-2;i+=2){const e=Math.abs(d-l*t[i+1]+c*t[i]);e>_&&(y=i,_=e)}_>(h*A)**2?(E(g,this,np).call(this,t,e,y+2,i),E(g,this,np).call(this,t,y,s,i)):i.push(n,a)}function ap(t){const e=[],s=t.length;return E(g,this,np).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}function rp(t,e,s,i,n,a){const r=new Float32Array(a**2),o=-2*i**2,h=a>>1;for(let t=0;t<a;t++){const e=(t-h)**2;for(let s=0;s<a;s++)r[t*a+s]=Math.exp((e+(s-h)**2)/o)}const l=new Float32Array(256),c=-2*n**2;for(let t=0;t<256;t++)l[t]=Math.exp(t**2/c);const d=t.length,u=new Uint8Array(d),p=new Uint32Array(256);for(let i=0;i<s;i++)for(let n=0;n<e;n++){const o=i*e+n,c=t[o];let d=0,g=0;for(let o=0;o<a;o++){const u=i+o-h;if(!(u<0||u>=s))for(let s=0;s<a;s++){const i=n+s-h;if(i<0||i>=e)continue;const p=t[u*e+i],f=r[o*a+s]*l[Math.abs(p-c)];d+=p*f,g+=f}}p[u[o]=Math.round(d/g)]++}return[u,p]}function op(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e}function hp(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,n=1/0;for(let e=0,a=s.length;e<a;e++){if(0===t[3+(e<<2)]){i=s[e]=255;continue}const a=s[e]=t[e<<2];a>i&&(i=a),a<n&&(n=a)}const a=255/(i-n);for(let t=0;t<e;t++)s[t]=(s[t]-n)*a;return s}function lp(t){let e,s=-1/0,i=-1/0;const n=t.findIndex((t=>0!==t));let a=n,r=n;for(e=n;e<256;e++){const n=t[e];n>s&&(e-a>i&&(i=e-a,r=e-1),s=n,a=e)}for(e=r-1;e>=0&&!(t[e]>t[e+1]);e--);return e}function cp(t){const e=t,{width:s,height:i}=t,{maxDim:n}=E(g,this,dp)._;let a=s,r=i;if(s>n||i>n){let o=s,h=i,l=Math.log2(Math.max(s,i)/n);const c=Math.floor(l);l=l===c?c-1:c;for(let s=0;s<l;s++){a=o,r=h,a>n&&(a=Math.ceil(a/2)),r>n&&(r=Math.ceil(r/2));const s=new OffscreenCanvas(a,r);s.getContext("2d").drawImage(t,0,0,o,h,0,0,a,r),o=a,h=r,t!==e&&t.close(),t=s.transferToImageBitmap()}const d=Math.min(n/a,n/r);a=Math.round(a*d),r=Math.round(r*d)}const o=new OffscreenCanvas(a,r).getContext("2d",{willReadFrequently:!0});o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,a,r);const h=o.getImageData(0,0,a,r).data;return[E(g,this,hp).call(this,h),a,r]}g=Zu;var dp={_:{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}},up={_:new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1])};class pp extends Zd{constructor(){super(),super.updateProperties({fill:"C
2anvasText","stroke-width":0})}clone(){const t=new pp;return t.updateAll(this),t}}class gp extends Xu{constructor(t){super(t),super.updateProperties({stroke:"CanvasText","stroke-width":1})}clone(){const t=new gp(this._viewParameters);return t.updateAll(this),t}}class fp extends iu{#R=!1;#P=null;#I=null;#L=null;static _type="signature";static _editorType=(()=>H.SIGNATURE)();static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#I=t.signatureData||null,this.#P=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){tn.initialize(t,e),this._defaultDrawingOptions=new pp,this._defaultDrawnSignatureOptions=new gp(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return bt(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#P}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#I){const{lines:t,mustSmooth:e,areContours:s,description:i,uuid:n,heightInPage:a}=this.#I,{rawDims:{pageWidth:r,pageHeight:o},rotation:h}=this.parent.viewport,l=Zu.processDrawnLines({lines:t,pageWidth:r,pageHeight:o,rotation:h,innerMargin:fp._INNER_MARGIN,mustSmooth:e,areContours:s});this.addSignature(l,a,i,n)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);return s&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#L=t,this.addEditToolbar()}getUuid(){return this.#L}get description(){return this.#P}set description(t){this.#P=t,super.addEditToolbar().then((e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:s,width:i,height:n}=this.#I,a=Math.max(i,n);return{areContours:e,outline:Zu.processDrawnLines({lines:{curves:t.map((t=>({points:t}))),thickness:s,width:i,height:n},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.signatureManager&&null!==this.#P&&(await t.addEditSignatureButton(this._uiManager.signatureManager,this.#L,this.#P),t.show()),t):null}addSignature(t,e,s,i){const{x:n,y:a}=this,{outline:r}=this.#I=t;let o;this.#R=r instanceof Ju,this.#P=s,this.div.setAttribute("data-l10n-args",JSON.stringify({description:s})),this.#R?o=fp.getDefaultDrawingOptions():(o=fp._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":r.thickness})),this._addOutlines({drawOutlines:r,drawingOptions:o});const[h,l]=this.parentDimensions,[,c]=this.pageDimensions;let d=e/c;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(
2h*this.width,l*this.height),this.x=n,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Zu.process(t,e,s,i,fp._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return Zu.extractContoursFromText(t,e,s,i,n,fp._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return Zu.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:fp._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions(t){let{areContours:e,thickness:s}=t;e?this._drawingOptions=fp.getDefaultDrawingOptions():(this._drawingOptions=fp._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;const{lines:e,points:s,rect:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,a={annotationType:H.SIGNATURE,isSignature:!0,areContours:this.#R,color:[0,0,0],thickness:this.#R?0:n,pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(a.paths={lines:e,points:s},a.uuid=this.#L,a.isCopy=!0):a.lines=e,this.#P&&(a.accessibilityData={type:"Figure",alt:this.#P}),a}static deserializeDraw(t,e,s,i,n,a){return a.areContours?Ju.deserialize(t,e,s,i,n,a):zu.deserialize(t,e,s,i,n,a)}static async deserialize(t,e,s){const i=await super.deserialize(t,e,s);return i.#R=t.areContours,i.#P=t.accessibilityData?.alt||"",i.#L=t.uuid,i}}var mp=new WeakMap,bp=new WeakMap,wp=new WeakMap,vp=new WeakMap,Ap=new WeakMap,_p=new WeakMap,yp=new WeakMap,xp=new WeakMap,Ep=new WeakMap,Sp=new WeakMap,kp=new WeakMap,Mp=new WeakSet;class Cp extends tn{constructor(t){super({...t,name:"stampEditor"}),b(this,Mp),w(this,mp,null),w(this,bp,null),w(this,wp,null),w(this,vp,null),w(this,Ap,null),w(this,_p,""),w(this,yp,null),w(this,xp,!1),w(this,Ep,null),w(this,Sp,!1),w(this,kp,!1),y(vp,this,t.bitmapUrl),y(Ap,this,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){tn.initialize(t,e)}static isHandlingMimeForPasting(t){return Zt.includes(t)}static paste(t,e){e.pasteEditor(H.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}async mlGuessAltText(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.hasAltTextData())return null;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:n,height:a}=t||this.copyCanvas(null,null,!0).imageData,r=await s.guess({name:"altText",request:{data:i,width:n,height:a,channels:i.length/(n*a)}});if(!r)throw new Error("No response from the AI service.");if(r.error)throw new Error("Error from the AI service.");if(r.cancel)return null;if(!r.output)throw new Error("No valid response from the AI service.");const o=r.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}remove(){_(bp,this)&&(y(mp,this,null),this._uiManager.imageManager.deleteId(_(bp,this)),_(yp,this)?.remove(),y(yp,this,null),_(Ep,this)&&(clearTimeout(_(Ep,this)),y(Ep,this,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(_(bp,this)&&null===_(yp,this)&&E(Mp,this,Pp).call(this),this.isAttachedToDOM||this.parent.add(this))):_(bp,this)&&E(Mp,this,Pp).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(_(wp,this)||_(mp,this)||_(vp,this)||_(Ap,this)||_(bp,this)||_(xp,this))}get isResizable(){return!0}
2render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),_(xp,this)||(_(mp,this)?E(Mp,this,Ip).call(this):E(Mp,this,Pp).call(this)),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(y(bp,this,s),i&&y(mp,this,i),y(xp,this,!1),E(Mp,this,Ip).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==_(Ep,this)&&clearTimeout(_(Ep,this));y(Ep,this,setTimeout((()=>{y(Ep,this,null),E(Mp,this,Dp).call(this)}),200))}copyCanvas(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||(t=224);const{width:i,height:n}=_(mp,this),a=new Jt;let r=_(mp,this),o=i,h=n,l=null;if(e){if(i>e||n>e){const t=Math.min(e/i,e/n);o=Math.floor(i*t),h=Math.floor(n*t)}l=document.createElement("canvas");const t=l.width=Math.ceil(o*a.sx),s=l.height=Math.ceil(h*a.sy);_(Sp,this)||(r=E(Mp,this,Lp).call(this,t,s));const c=l.getContext("2d");c.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(d="#8f8f9d",u="#42414d");const p=15,g=p*a.sx,f=p*a.sy,m=new OffscreenCanvas(2*g,2*f),b=m.getContext("2d");b.fillStyle=d,b.fillRect(0,0,2*g,2*f),b.fillStyle=u,b.fillRect(0,0,g,f),b.fillRect(g,f,g,f),c.fillStyle=c.createPattern(m,"repeat"),c.fillRect(0,0,t,s),c.drawImage(r,0,0,r.width,r.height,0,0,t,s)}let c=null;if(s){let e,s;if(a.symmetric&&r.width<t&&r.height<t)e=r.width,s=r.height;else if(r=_(mp,this),i>t||n>t){const a=Math.min(t/i,t/n);e=Math.floor(i*a),s=Math.floor(n*a),_(Sp,this)||(r=E(Mp,this,Lp).call(this,e,s))}const o=new OffscreenCanvas(e,s).getContext("2d",{willReadFrequently:!0});o.drawImage(r,0,0,r.width,r.height,0,0,e,s),c={width:e,height:s,data:o.getImageData(0,0,e,s).data}}return{canvas:l,width:o,height:h,imageData:c}}static async deserialize(t,e,s){let i=null,n=!1;if(t instanceof kl){const{data:{rect:a,rotation:r,id:o,structParent:h,popupRef:l},container:c,parent:{page:{pageNumber:d}},canvas:u}=t;let p,g;u?(delete t.canvas,({id:p,bitmap:g}=s.imageManager.getFromCanvas(c.id,u)),u.remove()):(n=!0,t._hasNoCanvas=!0);const f=(await e._structTree.getAriaAttributes(`${Pt}${o}`))?.get("aria-label")||"";i=t={annotationType:H.STAMP,bitmapId:p,bitmap:g,pageIndex:d-1,rect:a.slice(0),rotation:r,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:f},isSvg:!1,structParent:h,popupRef:l}}const a=await super.deserialize(t,e,s),{rect:r,bitmap:o,bitmapUrl:h,bitmapId:l,isSvg:c,accessibilityData:d}=t;n?(s.addMissingCanvas(t.id,a),y(xp,a,!0)):l&&s.imageManager.isValidId(l)?(y(bp,a,l),o&&y(mp,a,o)):y(vp,a,h),y(Sp,a,c);const[u,p]=a.pageDimensions;return a.width=(r[2]-r[0])/u,a.height=(r[3]-r[1])/p,a.annotationElementId=t.id||null,d&&(a.altTextData=d),a._initialData=i,y(kp,a,!!i),a}serialize(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s={annotationType:H.STAMP,bitmapId:_(bp,this),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:_(Sp,this),structTreeParentId:this._structTreeParentId};if(t)return s.bitmapUrl=E(Mp,this,Np).call(this,!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;const{decorative:i,altText:n}=this.serializeAltText(!1);if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=E(Mp,this,Fp).call(this,s);if(t.isSame)return null;t.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1}if(s.id=this.annotationElementId,null===e)return s;e.stamps||=new Map;const a=_(Sp,this)?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(e.stamps.has(_(bp,this))){if(_(Sp,this)){const t=e.stamps.get(_(bp,this));a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=E(Mp,this,Np).call(this,!1))}}else e.stamps.set(_(bp,this),{area:a,serialized:s}),s.bitmap=E(Mp,this,Np).call(this,!1);return s}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}function Tp(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?(y(mp,this,t.bitmap),e||(y(bp,this,t.id),y(Sp,this,t.isSvg)),t.file&&y(_p,this,t.file.name),E(Mp,this,Ip).call(this)):this.remove()}function Rp(){if(y(wp,this,null),this._uiManager.enableWaiting(!1),_(yp,this)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_(mp,this))return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_(mp,this)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}function Pp(){if(_(bp,this))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(_(bp,this)).then((t=>E(Mp,this,Tp).call(this,t,!0))).finally((()=>E(Mp,this,Rp).call(this)));if(_(vp,this)){const t=_(vp,this);return y(vp,this,null),this._uiManager.enableWaiting(!0),void y(wp,this,this._uiManager.imageManager.getFromUrl(t).then((t=>E(Mp,this,Tp).call(this,t))).finally((()=>E(Mp,this,Rp).call(this))))}if(_(Ap,this)){const t=_(Ap,this);return y(Ap,this,null),this._uiManager.enableWaiting(!0),void y(wp,this,this._uiManager.imageManager.getFromFile(t).then((t=>E(Mp,this,Tp).call(this,t))).finally((()=>E(Mp,this,Rp).call(this))))}const t=document.createElement("input");t.type="file",t.accept=Zt.join(",");const e=this._uiManager._signal;y(wp,this,new Promise((s=>{t.addEventListener("change",(async()=>
2{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),E(Mp,this,Tp).call(this,e)}else this.remove();s()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),s()}),{signal:e})})).finally((()=>E(Mp,this,Rp).call(this)))),t.click()}function Ip(){const{div:t}=this;let{width:e,height:s}=_(mp,this);const[i,n]=this.pageDimensions,a=.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>a*i||s>a*n){const t=Math.min(a*i/e,a*n/s);e*=t,s*=t}const[r,o]=this.parentDimensions;this.setDims(e*r/i,s*o/n),this._uiManager.enableWaiting(!1);const h=y(yp,this,document.createElement("canvas"));h.setAttribute("role","img"),this.addContainer(h),this.width=e/i,this.height=s/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),E(Mp,this,Dp).call(this),_(kp,this)||(this.parent.addUndoableEditor(this),y(kp,this,!0)),this._reportTelemetry({action:"inserted_image"}),_(_p,this)&&this.div.setAttribute("aria-description",_(_p,this))}function Lp(t,e){const{width:s,height:i}=_(mp,this);let n=s,a=i,r=_(mp,this);for(;n>2*t||a>2*e;){const s=n,i=a;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const o=new OffscreenCanvas(n,a);o.getContext("2d").drawImage(r,0,0,s,i,0,0,n,a),r=o.transferToImageBitmap()}return r}function Dp(){const[t,e]=this.parentDimensions,{width:s,height:i}=this,n=new Jt,a=Math.ceil(s*t*n.sx),r=Math.ceil(i*e*n.sy),o=_(yp,this);if(!o||o.width===a&&o.height===r)return;o.width=a,o.height=r;const h=_(Sp,this)?_(mp,this):E(Mp,this,Lp).call(this,a,r),l=o.getContext("2d");l.filter=this._uiManager.hcmFilter,l.drawImage(h,0,0,h.width,h.height,0,0,a,r)}function Np(t){if(t){if(_(Sp,this)){const t=this._uiManager.imageManager.getSvgUrl(_(bp,this));if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=_(mp,this));return t.getContext("2d").drawImage(_(mp,this),0,0),t.toDataURL()}if(_(Sp,this)){const[t,e]=this.pageDimensions,s=Math.round(this.width*t*Nt.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*Nt.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(s,i);return n.getContext("2d").drawImage(_(mp,this),0,0,_(mp,this).width,_(mp,this).height,0,0,s,i),n.transferToImageBitmap()}return structuredClone(_(mp,this))}function Fp(t){const{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===s;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&i&&n,isSameAltText:n}}x(Cp,"_type","stamp"),x(Cp,"_editorType",H.STAMP);var Op=new WeakMap,Wp=new WeakMap,Bp=new WeakMap,Hp=new WeakMap,$p=new WeakMap,Up=new WeakMap,zp=new WeakMap,jp=new WeakMap,Gp=new WeakMap,Vp=new WeakMap,qp=new WeakMap,Xp=new WeakMap,Yp=new WeakMap,Kp=new WeakMap,Qp=new WeakSet;class Jp{constructor(t){let{uiManager:e,pageIndex:s,div:i,structTreeLayer:n,accessibilityManager:a,annotationLayer:r,drawLayer:o,textLayer:h,viewport:l,l10n:c}=t;b(this,Qp),w(this,Op,void 0),w(this,Wp,!1),w(this,Bp,null),w(this,Hp,null),w(this,$p,null),w(this,Up,new Map),w(this,zp,!1),w(this,jp,!1),w(this,Gp,!1),w(this,Vp,null),w(this,qp,null),w(this,Xp,null),w(this,Yp,null),w(this,Kp,void 0);const d=[...ng._.values()];if(!Jp._initialized){Jp._initialized=!0;for(const t of d)t.initialize(c,e)}e.registerEditorTypes(d),y(Kp,this,e),this.pageIndex=s,this.div=i,y(Op,this,a),y(Bp,this,r),this.viewport=l,y(Xp,this,h),this.drawLayer=o,this._structTree=n,_(Kp,this).addLayer(this)}get isEmpty(){return 0===_(Up,this).size}get isInvisible(){return this.isEmpty&&_(Kp,this).getMode()===H.NONE}updateToolbar(t){_(Kp,this).updateToolbar(t)}updateMode(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_(Kp,this).getMode();switch(E(Qp,this,ig).call(this),t){case H.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case H.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case H.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 ng._.values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===_(Xp,this)?.div}setEditingState(t){_(Kp,this).setEditingState(t)}addCommands(t){_(Kp,this).addCommands(t)}cleanUndoStack(t){_(Kp,this).cleanUndoStack(t)}toggleDrawing(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("drawing",!t)}togglePointerEvents(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];_(Bp,this)?.div.classList.toggle("disabled",!t)}async enable(){y(Gp,this,!0),this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of _(Up,this).values())e.enableEditing(),e.show(!0),e.annotationElementId&&(_(Kp,this).removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!_(Bp,this))return void y(Gp,this,!1);const e=_(Bp,this).getEditableAnnotations();for(const s of e){if(s.hide(),_(Kp,this).isDeletedAnnotationElement(s.data.id))continue;if(t.has(s.data.id))continue;const e=await this.deserialize(s);e&&(this.addOrRebuild(e),e.enableEditing())}y(Gp,this,!1)}disable(){y(jp,this,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const s of _(Up,this).values())s.disableEditing(),s.annotationElementId&&(null===s.serialize()?(e.set(s.annotationElementId,s),this.getEditableAnnotation(s.annotationElementId)?.show(),s.remove()):t.set(s.annotationElementId,s));if(_(Bp,this)){const s=_(Bp,this).getEditableAnnotations();for(const i of s){const{id:s}=i.data;if(_(Kp,this).isDeletedAnnotationElement(s))continue;let n=e.get(s);n?(n.resetAnnotationElement(i),n.show(!1),i.show()):(n=t.get(s),n&&(_(Kp,this).addChangedExistingAnnotation(n),n.renderAnnotationElement(i)&&n.show(!1)),i.show())}}E(Qp,this,ig).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const t of ng._.values())s.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),y(jp,this,!1)}getEditableAnnotation(t){return _(Bp,this)?.getEditableAnnotation(t)||null}setActiveEditor(t){_(Kp,this).getActive()!==t&&_(Kp,this).setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,_(Xp,this)?.div&&!_(Yp,this)){y(Yp,this,new AbortController);const t=_(Kp,this).combinedSignal(_(Yp,this));_(Xp,this).div.addEventListener("pointerdown",E(Qp,this,Zp).bind(this),{signal:t}),_(Xp,this).div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,_(Xp,this)?.div&&_(Yp,this)&&(_(Yp,this).abort(),y(Yp,this,null),_(Xp,this).div.classList.remove("highlighting"))}enableClick(){if(_(Hp,this))return;y(Hp,this,new AbortController);const t=_(Kp,this).combinedSignal(_(Hp,this));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(){_(Hp,this)?.abort(),y(Hp,this,null)}attach(t){_(Up,this).set(t.id,t);const{annotationElementId:e}=t;e&&_(Kp,this).isDeletedAnnotationElement(e)&&_(Kp,this).removeDeletedAnnotationElement(t)}detach(t){_(Up,this).delete(t.id),_(Op,this)?.removePointerInTextLayer(t.contentDiv),!_(jp,this)&&t.annotationElementId&&_(Kp,this).addDeletedAnnotationElement(t)}remove(t){this.detach(t),_(Kp,this).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(_(Kp,this).addDeletedAnnotationElement(t.annotationElementId),tn.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),_(Kp,this).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!_(Gp,this)),_(Kp,this).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!_($p,this)&&(t._focusEventsAllowed=!1,y($p,this,setTimeout((()=>{y($p,this,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:_(Kp,this)._signal}),e.focus())}),0))),t._structTreeParentId=_(Op,this)?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return _(Kp,this).getId()}combinedSignal(t){return _(Kp,this).combinedSignal(t)}canCreateNewEmptyEditor(){return A(Qp,this,tg)?.canCreateNewEmptyEditor()}async pasteEditor(t,e){_(Kp,this).updateToolbar(t),await _(Kp,this).updateMode(t);const{offsetX:s,offsetY:i}=E(Qp,this,sg).call(this),n=this.getNextId(),a=E(Qp,this,eg).call(this,{parent:this,id:n,x:s,y:i,uiManager:_(Kp,this),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){return await(ng._.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,_(Kp,this)))||null}createAndAddNewEditor(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=this.getNextId(),n=E(Qp,this,eg).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:_(Kp,this),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.createAndAddNewEditor(E(Qp,this,sg).call(this),!0,t)}setSelected(t){_(Kp,this).setSelected(t)}toggleSelected(t){_(Kp,this).toggleSelected(t)}unselect(t){_(Kp,this).unselect(t)}pointerup(t){const{isMac:e}=yt.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!_(zp,this))return;if(y(zp,this,!1),A(Qp,this,tg)?.isDrawer&&A(Qp,this,tg).supportMultipleDrawings)return;if(!_(Wp,this))return void y(Wp,this,!0);const s=_(Kp,this).getMode();s!==H.STAMP&&s!==H.SIGNATURE?this.createAndAddNewEditor(t,!1):_(Kp,this).unselectAll()}pointerdown(t){if(_(Kp,this).getMode()===H.HIGHLIGHT&&this.enableTextSelection(),_(zp,this))return void y(zp,this,!1);const{isMac:e}=yt.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(y(zp,this,!0),A(Qp,this,tg)?.isDrawer)return void this.startDrawingSession(t);const s=_(Kp,this).getActive();y(Wp,this,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),_(Vp,this))return void A(Qp,this,tg).startDrawing(this,_(Kp,this),!1,t);_(Kp,this).setCurrentDrawingSession(this),y(Vp,this,new AbortController);const e=_(Kp,this).combinedSignal(_(Vp,this));this.div.addEventListener("blur",(t=>{let{relatedTarget:e}=t;e&&!this.div.contains(e)&&(y(qp,this,null),this.commitOrRemove())}),{signal:e}),A(Qp,this,tg).startDrawing(this,_(Kp,this),!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&y(qp,this,t)}else _(qp,this)&&setTimeout((()=>
2{_(qp,this)?.focus(),y(qp,this,null)}),0)}endDrawingSession(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return _(Vp,this)?(_(Kp,this).setCurrentDrawingSession(null),_(Vp,this).abort(),y(Vp,this,null),y(qp,this,null),A(Qp,this,tg).endDrawing(t)):null}findNewParent(t,e,s){const i=_(Kp,this).findParent(e,s);return null!==i&&i!==this&&(i.changeParent(t),!0)}commitOrRemove(){return!!_(Vp,this)&&(this.endDrawingSession(),!0)}onScaleChanging(){_(Vp,this)&&A(Qp,this,tg).onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),_(Kp,this).getActive()?.parent===this&&(_(Kp,this).commitOrRemove(),_(Kp,this).setActiveEditor(null)),_($p,this)&&(clearTimeout(_($p,this)),y($p,this,null));for(const t of _(Up,this).values())_(Op,this)?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,_(Up,this).clear(),_(Kp,this).removeLayer(this)}render(t){let{viewport:e}=t;this.viewport=e,Qt(this.div,e);for(const t of _(Kp,this).getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update(t){let{viewport:e}=t;_(Kp,this).commitOrRemove(),E(Qp,this,ig).call(this);const s=this.viewport.rotation,i=e.rotation;if(this.viewport=e,Qt(this.div,{rotation:i}),s!==i)for(const t of _(Up,this).values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return _(Kp,this).viewParameters.realScale}}function Zp(t){_(Kp,this).unselectAll();const{target:e}=t;if(e===_(Xp,this).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&_(Xp,this).div.contains(e)){const{isMac:e}=yt.platform;if(0!==t.button||t.ctrlKey&&e)return;_(Kp,this).showAllEditors("highlight",!0,!0),_(Xp,this).div.classList.add("free"),this.toggleDrawing(),Fd.startHighlighting(this,"ltr"===_(Kp,this).direction,{target:_(Xp,this).div,x:t.x,y:t.y}),_(Xp,this).div.addEventListener("pointerup",(()=>{_(Xp,this).div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:_(Kp,this)._signal}),t.preventDefault()}}function tg(t){return ng._.get(_(Kp,t).getMode())}function eg(t){const e=A(Qp,this,tg);return e?new e.prototype.constructor(t):null}function sg(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),r=(n+Math.min(window.innerWidth,t+s))/2-t,o=(a+Math.min(window.innerHeight,e+i))/2-e,[h,l]=this.viewport.rotation%180==0?[r,o]:[o,r];return{offsetX:h,offsetY:l}}function ig(){for(const t of _(Up,this).values())t.isEmpty()&&t.remove()}x(Jp,"_initialized",!1);var ng={_:new Map([Vl,Ku,Cp,Fd,fp].map((t=>[t._editorType,t])))},ag=new WeakMap,rg=new WeakMap,og=new WeakMap,hg=new WeakSet;class lg{constructor(t){let{pageIndex:e}=t;b(this,hg),w(this,ag,null),w(this,rg,new Map),w(this,og,new Map),this.pageIndex=e}setParent(t){if(_(ag,this)){if(_(ag,this)!==t){if(_(rg,this).size>0)for(const e of _(rg,this).values())e.remove(),t.append(e);y(ag,this,t)}}else y(ag,this,t)}static get _svgFactory(){return bt(this,"_svgFactory",new lh)}draw(t){var e,s;let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const a=(gg._=(e=gg._,s=e++,e),s),r=E(hg,this,dg).call(this),o=lg._svgFactory.createElement("defs");r.append(o);const h=lg._svgFactory.createElement("path");o.append(h);const l=`path_p${this.pageIndex}_${a}`;h.setAttribute("id",l),h.setAttribute("vector-effect","non-scaling-stroke"),i&&_(og,this).set(a,h);const c=n?E(hg,this,ug).call(this,o,l):null,d=lg._svgFactory.createElement("use");return r.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(r,t),_(rg,this).set(a,r),{id:a,clipPathId:`url(#${c})`}}drawOutline(t,e){var s,i;const n=(gg._=(s=gg._,i=s++,s),i),a=E(hg,this,dg).call(this),r=lg._svgFactory.createElement("defs");a.append(r);const o=lg._svgFactory.createElement("path");r.append(o);const h=`path_p${this.pageIndex}_${n}`;let l;if(o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke"),e){const t=lg._svgFactory.createElement("mask");r.append(t),l=`mask_p${this.pageIndex}_${n}`,t.setAttribute("id",l),t.setAttribute("maskUnits","objectBoundingBox");const e=lg._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const s=lg._svgFactory.createElement("use");t.append(s),s.setAttribute("href",`#${h}`),s.setAttribute("stroke","none"),s.setAttribute("fill","black"),s.setAttribute("fill-rule","nonzero"),s.classList.add("mask")}const c=lg._svgFactory.createElement("use");a.append(c),c.setAttribute("href",`#${h}`),l&&c.setAttribute("mask",`url(#${l})`);const d=c.cloneNode();return a.append(d),c.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(a,t),_(rg,this).set(n,a),n}finalizeDraw(t,e){_(og,this).delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:s,bbox:i,rootClass:n,path:a}=e,r="number"==typeof t?_(rg,this).get(t):t;if(r){if(s&&E(hg,this,pg).call(this,r,s),i&&cg.call(lg,r,i),n){const{classList:t}=r;for(const[e,s]of Object.entries(n))t.toggle(e,s)}if(a){const t=r.firstChild.firstChild;E(hg,this,pg).call(this,t,a)}}}updateParent(t,e){if(e===this)return;const s=_(rg,this).get(t);s&&(_(ag,e).append(s),_(rg,this).delete(t),_(rg,e).set(t,s))}remove(t){_(og,this).delete(t),null!==_(ag,this)&&(_(rg,this).get(t).remove(),_(rg,this).delete(t))}destroy(){y(ag,this,null);for(const t of _(rg,this).values())t.remove();_(rg,this).clear(),_(og,this).clear()}}function cg(t,e){let[s,i,n,a]=e;const{style:r}=t;r.top=100*i+"%",r.left=100*s+"%",r.width=100*n+"%",r.height=100*a+"%"}function dg(){const t=f._svgFactory.create(1,1,!0);return _(ag,this).append(t),t.setAttribute("aria-hidden",!0),t}function ug(t,e){const s=f._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=f._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}function pg(t,e){for(const[s,i]of Object.entries(e))null===i?t.removeAttribute(s):t.setAttribute(s,i)}f=lg;var gg={_:0};globalThis.pdfjsTestingUtils={HighlightOutliner:Uc};var fg=k.AnnotationEditorType,mg=k.AnnotationMode,bg=k.GlobalWorkerOptions,wg=k.PDFDataRangeTransport,vg=k.ResponseException,Ag=k.Util,_g=k.getDocument},62053:(t,e,s)=>{var i,n=s(1942),a=s(5613),r=s(79117),o=s(5604),h=s(16881),l=s(5234),c=s(66209),d=s(14188),u=s(80866),p=s(44318),g=s(80831),f=s(6032),m=s(38873),b=s(3770),w=s(65438),v=s(74418),A=s(94417),_=s(88088),y=s(69389),x=s(89445),E=s(23113),S=s(98093),k=s(33243),M=s(29800),C=s(8850),T=s(14582),R=s(69059),P=r.Object,I=r.Array,L=r.Date,D=r.Error,N=r.TypeError,F=r.PerformanceMark,O=o("DOMException"),W=S.Map,B=S.has,H=S.get,$=S.set,U=k.Set,z=k.add,j=k.has,G=o("Object","keys"),V=h([].push),q=h((!0).valueOf),X=h(1.1.valueOf),Y=h("".valueOf),K=h(L.prototype.getTime),Q=c("structuredClone"),J="DataCloneError",Z="Transferring",tt=function(t){return!l((function(){var e=new r.Set([7]),s=t(e),i=t(P(7));return s===e||!s.has(7)||!g(i)||7!=+i}))&&t},et=function(t,e){return!l((function(){var s=new e,i=t({a:s,b:s});return!(i&&i.a===i.b&&i.a instanceof e&&i.a.stack===s.stack)}))},st=r.structuredClone,it=n||!et(st,D)||!et(st,O)||(i=st,!!l((function(){var t=i(new r.AggregateError([1],Q,{cause:3}));return"AggregateError"!==t.name||1!==t.errors[0]||t.message!==Q||3!==t.cause}))),nt=!st&&tt((function(t){return new F(Q,{detail:t}).detail})),at=tt(st)||nt,rt=function(t){throw new O("Uncloneable type: "+t,J)},ot=function(t,e){throw new O((e||"Cloning")+" of "+t+" cannot be properly polyfilled in this engine",J)},ht=function(t,e){return at||ot(e),at(t)},lt=function(t,e,s){if(B(e,t))return H(e,t);var i,n,a,o,h,l;if("SharedArrayBuffer"===(s||w(t)))i=at?at(t):t;else{var c=r.DataView;c||d(t.slice)||ot("ArrayBuffer");try{if(d(t.slice)&&!t.resizable)i=t.slice(0);else{n=t.byteLength,a="maxByteLength"in t?{maxByteLength:t.maxByteLength}:void 0,i=new ArrayBuffer(n,a),o=new c(t),h=new c(i);for(l=0;l<n;l++)h.setUint8(l,o.getUint8(l))}}catch(t){throw new O("ArrayBuffer is detached",J)}
vendor: 5,590 bytes, line 2
2}return $(e,t,i),i},ct=function(t,e){if(f(t)&&rt("Symbol"),!g(t))return t;if(e){if(B(e,t))return H(e,t)}else e=new W;var s,i,n,a,h,l,c,u,p=w(t);switch(p){case"Array":n=I(y(t));break;case"Object":n={};break;case"Map":n=new W;break;case"Set":n=new U;break;case"RegExp":n=new RegExp(t.source,E(t));break;case"Error":switch(i=t.name){case"AggregateError":n=new(o(i))([]);break;case"EvalError":case"RangeError":case"ReferenceError":case"SuppressedError":case"SyntaxError":case"TypeError":case"URIError":n=new(o(i));break;case"CompileError":case"LinkError":case"RuntimeError":n=new(o("WebAssembly",i));break;default:n=new D}break;case"DOMException":n=new O(t.message,t.name);break;case"ArrayBuffer":case"SharedArrayBuffer":n=lt(t,e,p);break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float16Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":l="DataView"===p?t.byteLength:t.length,n=function(t,e,s,i,n){var a=r[e];return g(a)||ot(e),new a(lt(t.buffer,n),s,i)}(t,p,t.byteOffset,l,e);break;case"DOMQuad":try{n=new DOMQuad(ct(t.p1,e),ct(t.p2,e),ct(t.p3,e),ct(t.p4,e))}catch(e){n=ht(t,p)}break;case"File":if(at)try{n=at(t),w(n)!==p&&(n=void 0)}catch(t){}if(!n)try{n=new File([t],t.name,t)}catch(t){}n||ot(p);break;case"FileList":if(a=function(){var t;try{t=new r.DataTransfer}catch(e){try{t=new r.ClipboardEvent("").clipboardData}catch(t){}}return t&&t.items&&t.files?t:null}()){for(h=0,l=y(t);h<l;h++)a.items.add(ct(t[h],e));n=a.files}else n=ht(t,p);break;case"ImageData":try{n=new ImageData(ct(t.data,e),t.width,t.height,{colorSpace:t.colorSpace})}catch(e){n=ht(t,p)}break;default:if(at)n=at(t);else switch(p){case"BigInt":n=P(t.valueOf());break;case"Boolean":n=P(q(t));break;case"Number":n=P(X(t));break;case"String":n=P(Y(t));break;case"Date":n=new L(K(t));break;case"Blob":try{n=t.slice(0,t.size,t.type)}catch(t){ot(p)}break;case"DOMPoint":case"DOMPointReadOnly":s=r[p];try{n=s.fromPoint?s.fromPoint(t):new s(t.x,t.y,t.z,t.w)}catch(t){ot(p)}break;case"DOMRect":case"DOMRectReadOnly":s=r[p];try{n=s.fromRect?s.fromRect(t):new s(t.x,t.y,t.width,t.height)}catch(t){ot(p)}break;case"DOMMatrix":case"DOMMatrixReadOnly":s=r[p];try{n=s.fromMatrix?s.fromMatrix(t):new s(t)}catch(t){ot(p)}break;case"AudioData":case"VideoFrame":d(t.clone)||ot(p);try{n=t.clone()}catch(t){rt(p)}break;case"CropTarget":case"CryptoKey":case"FileSystemDirectoryHandle":case"FileSystemFileHandle":case"FileSystemHandle":case"GPUCompilationInfo":case"GPUCompilationMessage":case"ImageBitmap":case"RTCCertificate":case"WebAssembly.Module":ot(p);default:rt(p)}}switch($(e,t,n),p){case"Array":case"Object":for(c=G(t),h=0,l=y(c);h<l;h++)u=c[h],A(n,u,ct(t[u],e));break;case"Map":t.forEach((function(t,s){$(n,ct(s,e),ct(t,e))}));break;case"Set":t.forEach((function(t){z(n,ct(t,e))}));break;case"Error":_(n,"message",ct(t.message,e)),v(t,"cause")&&_(n,"cause",ct(t.cause,e)),"AggregateError"===i?n.errors=ct(t.errors,e):"SuppressedError"===i&&(n.error=ct(t.error,e),n.suppressed=ct(t.suppressed,e));case"DOMException":T&&_(n,"stack",ct(t.stack,e))}return n};a({global:!0,enumerable:!0,sham:!R,forced:it},{structuredClone:function(t){var e,s,i=x(arguments.length,1)>1&&!p(arguments[1])?b(arguments[1]):void 0,n=i?i.transfer:void 0;void 0!==n&&(s=function(t,e){if(!g(t))throw new N("Transfer option cannot be converted to a sequence");var s=[];m(t,(function(t){V(s,b(t))}));for(var i,n,a,o,h,l=0,c=y(s),p=new U;l<c;){if(i=s[l++],"ArrayBuffer"===(n=w(i))?j(p,i):B(e,i))throw new O("Duplicate transferable",J);if("ArrayBuffer"!==n){if(R)o=st(i,{transfer:[i]});else switch(n){case"ImageBitmap":a=r.OffscreenCanvas,u(a)||ot(n,Z);try{(h=new a(i.width,i.height)).getContext("bitmaprenderer").transferFromImageBitmap(i),o=h.transferToImageBitmap()}catch(t){}break;case"AudioData":case"VideoFrame":d(i.clone)&&d(i.close)||ot(n,Z);try{o=i.clone(),i.close()}catch(t){}break;case"MediaSourceHandle":case"MessagePort":case"MIDIAccess":case"OffscreenCanvas":case"ReadableStream":case"RTCDataChannel":case"TransformStream":case"WebTransportReceiveStream":case"WebTransportSendStream":case"WritableStream":ot(n,Z)}if(void 0===o)throw new O("This object cannot be transferred: "+n,J);$(e,i,o)}else z(p,i)}return p}(n,e=new W));var a=ct(t,e);return s&&function(t){M(t,(function(t){R?at(t,{transfer:[t]}):d(t.transfer)?t.transfer():C?C(t):ot("ArrayBuffer",Z)}))}(s),a}})},70784:(t,e,s)=>{var i=s(5613),n=s(5604),a=s(89445),r=s(92618),o=s(96301),h=n("URL");i({target:"URL",stat:!0,forced:!o},{parse:function(t){var e=a(arguments.length,1),s=r(t),i=e<2||void 0===arguments[1]?void 0:r(arguments[1]);try{return new h(s,i)}catch(t){return null}}})},72306:(t,e,s)=>{var i=s(79117),n=s(5234),a=i.RegExp,r=!n((function(){var t=!0;try{a(".","d")}catch(e){t=!1}var e={},s="",i=t?"dgimsy":"gimsy",n=function(t,i){Object.defineProperty(e,t,{get:function(){return s+=i,!0}})},r={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var o in t&&(r.hasIndices="d"),r)n(o,r[o]);return Object.getOwnPropertyDescriptor(a.prototype,"flags").get.call(e)!==i||s!==i}));t.exports={correct:r}},80866:(t,e,s)=>{var i=s(16881),n=s(5234),a=s(14188),r=s(65438),o=s(5604),h=s(13029),l=function(){},c=o("Reflect","construct"),d=/^\s*(?:class|function)\b/,u=i(d.exec),p=!d.test(l),g=function(t){if(!a(t))return!1;try{return c(l,[],t),!0}catch(t){return!1}},f=function(t){if(!a(t))return!1;switch(r(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return p||!!u(d,h(t))}catch(t){return!0}};
2f.sham=!0,t.exports=!c||n((function(){var t;return g(g.call)||!g(Object)||!g((function(){t=!0}))||t}))?f:g},85178:(t,e,s)=>{var i=s(5613),n=s(79117),a=s(40646),r=s(27825),o=s(59444),h=s(44977),l=s(96042),c=n.Promise,d=!1;i({target:"Promise",stat:!0,forced:!c||!c.try||l((function(){c.try((function(t){d=8===t}),8)})).error||!d},{try:function(t){var e=arguments.length>1?r(arguments,1):[],s=o.f(this),i=l((function(){return a(h(t),void 0,e)}));return(i.error?s.reject:s.resolve)(i.value),s.promise}})},91242:(t,e,s)=>{var i=s(5613),n=s(79117),a=s(76759),r=s(81730),o=n.Uint8Array,h=!o||!o.fromBase64||!function(){try{return void o.fromBase64("a")}catch(t){}try{o.fromBase64("",null)}catch(t){return!0}}();o&&i({target:"Uint8Array",stat:!0,forced:h},{fromBase64:function(t){var e=r(t,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return a(o,e.bytes)}})},96042:t=>{t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},96301:(t,e,s)=>{var i=s(5234),n=s(4282),a=s(96893),r=s(1942),o=n("iterator");t.exports=!i((function(){var t=new URL("b?a=1&b=2&c=3","https://a"),e=t.searchParams,s=new URLSearchParams("a=1&a=2&b=3"),i="";return t.pathname="c%20d",e.forEach((function(t,s){e.delete("b"),i+=s+t})),s.delete("a",2),s.delete("b",void 0),r&&(!t.toJSON||!s.has("a",1)||s.has("a",2)||!s.has("a",void 0)||s.has("b"))||!e.size&&(r||!a)||!e.sort||"https://a/c%20d?a=1&c=3"!==t.href||"3"!==e.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[o]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==i||"x"!==new URL("https://x",void 0).host}))},97015:(t,e,s)=>{s(91242)},98093:(t,e,s)=>{var i=s(16881),n=Map.prototype;t.exports={Map,set:i(n.set),get:i(n.get),has:i(n.has),remove:i(n.delete),proto:n}},99990:(t,e,s)=>{s(52573)}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.